|
◆ qccliinit()
subroutine modqccli::qccliinit |
( |
type(qcclitype), intent(inout) |
qccli, |
|
|
type (vol7d), intent(in), target |
v7d, |
|
|
character(len=*), dimension(:), intent(in) |
var, |
|
|
type(datetime), intent(in), optional |
timei, |
|
|
type(datetime), intent(in), optional |
timef, |
|
|
integer, dimension(:,:,:,:,:), intent(in), optional, target |
data_id_in, |
|
|
character(len=*), intent(in), optional |
macropath, |
|
|
character(len=*), intent(in), optional |
climapath, |
|
|
character(len=*), intent(in), optional |
extremepath, |
|
|
character(len=*), intent(in), optional |
dsncli, |
|
|
character(len=*), intent(in), optional |
dsnextreme, |
|
|
character(len=*), intent(in), optional |
user, |
|
|
character(len=*), intent(in), optional |
password, |
|
|
logical, intent(in), optional |
height2level, |
|
|
character(len=*), intent(in), optional |
categoryappend |
|
) |
| |
|
private |
Init del controllo di qualità climatico.
Effettua la lettura dei file e altre operazioni di inizializzazione. - Parametri
-
[in,out] | qccli | Oggetto per il controllo climatico |
[in] | v7d | Il volume Vol7d da controllare |
[in] | var | variabili da importare secondo la tabella B locale o relativi alias |
[in] | timei | estremi temporali (inizio e fine) dell'estrazione per l'importazione |
[in] | timef | estremi temporali (inizio e fine) dell'estrazione per l'importazione |
[in] | data_id_in | Indici dei dati in DB |
[in] | macropath | file delle macroaree |
[in] | climapath | file con il volume del clima |
[in] | extremepath | file con il volume del clima |
[in] | height2level | use conventional level starting from station height |
[in] | categoryappend | appennde questo suffisso al namespace category di log4fortran $!> coordinate minime e massime che definiscono il $!! rettangolo di estrazione per l'importazione $TYPE(geo_coord),INTENT(inout),optional :: coordmin,coordmax |
Definizione alla linea 371 del file modqccli.F90.
379 ltimei=cyclicdatetime_to_conventional(cyclicdatetime_new(month=monthi, hour=00))
380 ltimef=cyclicdatetime_to_conventional(cyclicdatetime_new(month=monthf, hour=23))
391 call init(network, "qcclima-perc")
392 call optio(dsnextreme,ldsnextreme)
394 if (.not. c_e(ldsnextreme)) then
398 if (.not. c_e(filepathextreme)) then
399 filepathextreme=get_package_filepath( 'qcclima-extreme.v7d', filetype_data)
402 if (c_e(filepathextreme)) then
404 select case (trim(lowercase(suffixname(filepathextreme))))
408 call import(qccli%extreme,filename=filepathextreme,unit=iuni)
413 call init(v7d_dballeextreme,file=.true.,filename=filepathextreme,categoryappend=trim(a_name)// ".climaextreme")
415 call import(v7d_dballeextreme,var=var,coordmin=lcoordmin, coordmax=lcoordmax, timei=ltimei, timef=ltimef, &
416 varkind=(/( "r",i=1, size(var))/),attr=(/qcattrvarsbtables(2)/),attrkind=(/ "b"/),network=network)
417 call copy(v7d_dballeextreme%vol7d,qccli%extreme)
418 call delete(v7d_dballeextreme)
423 if (c_e(filepathextreme)) then
424 call l4f_category_log(qccli%category,l4f_error,&
425 "file type not supported (user .v7d or .bufr suffix only): "//trim(filepathextreme))
431 call l4f_category_log(qccli%category,l4f_warn, "extreme volume not iniziatized: QC or normalize data will not be possible")
433 call init(qccli%extreme)
440 call l4f_category_log(qccli%category,l4f_debug, "init v7d_dballeextreme")
441 call init(v7d_dballeextreme,dsn=ldsnextreme,user=luser,password=lpassword,&
442 write=.false.,file=.false.,categoryappend=trim(a_name)// ".climaextreme")
443 call l4f_category_log(qccli%category,l4f_debug, import v7d_dballeextreme ")
445 call import(v7d_dballeextreme,var=var,coordmin=lcoordmin, coordmax=lcoordmax, timei=ltimei, timef=ltimef, &
446 varkind=(/("r ",i=1,size(var))/),attr=(/qcattrvarsbtables(2)/),attrkind=(/"b "/),network=network)
447 call copy(v7d_dballeextreme%vol7d,qccli%extreme)
448 call delete(v7d_dballeextreme)
457 call qcclialloc(qccli)
460 ! valuto in quale macroarea sono le stazioni
462 !!$IF (macroa%arraysize <= 0) THEN
463 !!$ CALL l4f_category_log(qccli%category,L4F_ERROR,"maskgen: poly parameter missing or empty ")
464 !!$ CALL raise_fatal_error()
467 if (associated(qccli%in_macroa)) then
468 qccli%in_macroa = imiss
470 DO i = 1, SIZE(qccli%v7d%ana)
471 ! temporary, improve!!!!
472 CALL getval(qccli%v7d%ana(i)%coord,lon=lon,lat=lat)
473 point = georef_coord_new(x=lon, y=lat)
474 DO j = 1, macroa%arraysize
475 IF (inside(point, macroa%array(j))) THEN
476 qccli%in_macroa(i) = j
486 end subroutine qccliinit
489 !>\brief Allocazioni di memoria
490 subroutine qcclialloc(qccli)
491 ! pseudo costruttore con distruttore automatico
493 type(qcclitype),intent(in out) :: qccli !< Oggetto per il controllo climatico
498 ! se ti sei dimenticato di deallocare ci penso io
499 call qcclidealloc(qccli)
502 !!$if (associated (qccli%v7d%dativar%r )) then
503 !!$ nv=size(qccli%v7d%dativar%r)
505 !!$ allocate(qccli%valminr(nv),stat=istat)
506 !!$ istatt=istatt+istat
507 !!$ allocate(qccli%valmaxr(nv),stat=istat)
508 !!$ istatt=istatt+istat
510 !!$ if (istatt /= 0) ier=1
514 if (associated (qccli%v7d%ana )) then
515 allocate (qccli%in_macroa(size(qccli%v7d%ana )),stat=istatt)
516 if (istatt /= 0) then
517 call l4f_category_log(qccli%category,L4F_ERROR,"allocate error ")
518 call raise_error("allocate error ")
522 if (associated(qccli%data_id_in))then
523 sh=shape(qccli%data_id_in)
524 allocate (qccli%data_id_out(sh(1),sh(2),sh(3),sh(4),sh(5)),stat=istatt)
526 call l4f_category_log(qccli%category,L4F_ERROR,"allocate error ")
527 call raise_error("allocate error ")
529 qccli%data_id_out=imiss
535 end subroutine qcclialloc
538 !>\brief Deallocazione della memoria
540 subroutine qcclidealloc(qccli)
543 type(qcclitype),intent(in out) :: qccli !< Oggetto per l controllo climatico
545 !!$if ( associated ( qccli%valminr)) then
546 !!$ deallocate(qccli%valminr)
549 !!$if ( associated ( qccli%valmaxr)) then
550 !!$ deallocate(qccli%valmaxr)
553 if (associated (qccli%in_macroa)) then
554 deallocate (qccli%in_macroa)
557 if (associated(qccli%data_id_out))then
558 deallocate (qccli%data_id_out)
562 end subroutine qcclidealloc
565 !>\brief Cancellazione
568 subroutine qcclidelete(qccli)
569 ! decostruttore a mezzo
570 type(qcclitype),intent(in out) :: qccli !< Oggetto per l controllo climatico
572 call qcclidealloc(qccli)
574 call delete(qccli%clima)
575 call delete(qccli%extreme)
578 call l4f_category_delete(qccli%category)
581 end subroutine qcclidelete
585 !> Modulo 1: Calcolo dei parametri di normalizzazione dei dati
586 °°° !! I parametri di normalizzazione sono il 25, il 50 e il 75 percentile
588 !!oppure (p15.87,p50.,p84.13)
589 !! Tali parametri verranno calcolati per ogni mese, per ogni ora, per ogni area.
590 !! Modulo 2: Normalizzazione dati
591 à !! Ciascun dato D verr normalizzato come segue:
592 !! DN = (D-p50)*2/(p75-p25)
593 !! oppure DN = (D-p50)*2/(p16-p84)
594 è !! dove DN il valore normalizzato.
595 !! La scelta dei parametri di normalizzazione dipende dal mese, dall'ora,
597 SUBROUTINE vol7d_normalize_data(qccli)
599 TYPE(qcclitype),INTENT(inout) :: qccli !< volume providing data to be computed, it is modified by the method
600 !character (len=10) ,intent(in),optional :: battrinv !< attributo invalidated in input/output
602 real :: datoqui, perc25, perc50,perc75
603 integer :: indana , indtime ,indlevel ,indtimerange ,inddativarr, indnetwork
604 integer :: indcana, indvar,indctime,indclevel,indctimerange,indcdativarr,indcnetwork
605 !integer :: indbattrinv
606 integer :: iclv(size(qccli%v7d%ana))
608 character(len=1) :: type
609 TYPE(vol7d_var) :: var
610 TYPE(vol7d_ana) :: ana
611 TYPE(datetime) :: time, nintime
612 TYPE(vol7d_level):: level
613 integer :: mese, ora, desc, iarea, k
616 character(len=1) :: mycanc, canc = "# "
618 CHARACTER(len=vol7d_ana_lenident) :: ident
622 !!$if (associated(qccli%v7d%dativarattr%b))then
623 !!$ if (present(battrinv))then
624 !!$ indbattrinv = index_c(qccli%v7d%dativarattr%b(:)%btable, battrinv)
626 !!$ indbattrinv = index_c(qccli%v7d%dativarattr%b(:)%btable, qcattrvarsbtables(1))
631 .not. if ( associated(qccli%extreme%voldatir))then
632 call l4f_category_log(qccli%category,L4F_WARN,"extreme data not associated: normalize data not possible ")
633 qccli%v7d%voldatir=rmiss
634 ! call raise_fatal_error()
639 if (qccli%height2level) then
640 call init(var, btable="b07030 ") ! height
643 indvar = index(qccli%v7d%anavar, var, type=type)
645 do indana=1,size(qccli%v7d%ana)
648 ! here we take the height fron any network (the first network win)
649 do indnetwork=1,size(qccli%v7d%network)
651 if( indvar > 0 ) then
654 height=realdat(qccli%v7d%volanad(indana,indvar,indnetwork),qccli%v7d%anavar%d(indvar))
656 height=realdat(qccli%v7d%volanar(indana,indvar,indnetwork),qccli%v7d%anavar%r(indvar))
658 height=realdat(qccli%v7d%volanai(indana,indvar,indnetwork),qccli%v7d%anavar%i(indvar))
660 height=realdat(qccli%v7d%volanab(indana,indvar,indnetwork),qccli%v7d%anavar%b(indvar))
662 height=realdat(qccli%v7d%volanac(indana,indvar,indnetwork),qccli%v7d%anavar%c(indvar))
666 if (c_e(height)) exit
669 if (c_e(height)) then
670 .and. iclv(indana)=firsttrue(cli_level1 <= height height <= cli_level2 )
676 call l4f_category_log(qccli%category,L4F_DEBUG, 'vol7d_normalize_data height has value '//t2c(height,"missing "))
677 call l4f_category_log(qccli%category,L4F_DEBUG, 'for indana having number '//t2c(indana)//&
678 ' iclv has value '//t2c(iclv(indana),"missing "))
|