12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778 |
- #define TRACEBACK write (gol,'("in ",a," (",a,", line",i5,")")') rname, __FILE__, __LINE__; call goErr
- #define IF_NOTOK_RETURN(action) if (status/=0) then; TRACEBACK; action; return; end if
- #define IF_ERROR_RETURN(action) if (status> 0) then; TRACEBACK; action; return; end if
- #include "tmm.inc"
- module tmm_mf_ecmwf_tmpp
- use GO , only : gol, goErr, goPr
- use GO , only : TDate
- use file_grib, only : TGribFile
- implicit none
-
-
-
- private
-
- public :: TMeteoFile_ecmwf_tmpp
- public :: Init, Done
- public :: Get
- public :: ReadRecord
-
-
-
- character(len=*), parameter :: mname = 'tmm_mf_ecmwf_tmpp'
-
-
-
- type TMeteoFile_ecmwf_tmpp
-
- character(len=256) :: fname
-
- type(TDate) :: trange(2)
- logical :: constant
-
- character(len=16) :: treskey
- type(TDate) :: tday
-
- type(TDate) :: tref, t1, t2
-
-
-
- character(len=16) :: ec_class, ec_type
- character(len=256) :: paramkeys
-
-
-
- type(TGribFile) :: grib
-
-
-
- logical :: do_spm
- character(len=256) :: spm_fname
- type(TGribFile) :: spm_grib
- logical :: spm_lnsp2sp
-
- end type TMeteoFile_ecmwf_tmpp
-
-
-
-
- interface Init
- module procedure mf_Init
- end interface
- interface Done
- module procedure mf_Done
- end interface
- interface Get
- module procedure mf_Get
- end interface
- interface ReadRecord
- module procedure mf_ReadRecord
- end interface
- contains
-
-
-
-
-
- subroutine mf_Init( mf, dir, archivekeys, paramkey, &
- tday, t1, t2, status )
-
- use GO, only : TDate, Get, NewDate, operator(>)
- use GO, only : goVarValue, goWriteKeyNum
-
-
-
- type(TMeteoFile_ecmwf_tmpp), intent(out) :: mf
- character(len=*), intent(in) :: dir
- character(len=*), intent(in) :: archivekeys
- character(len=*), intent(in) :: paramkey
- type(TDate), intent(in) :: tday, t1, t2
- integer, intent(out) :: status
-
-
-
- character(len=*), parameter :: rname = mname//'/mf_Init'
-
-
-
- character(len=16) :: form
- character(len=16) :: ec_class, ec_type, ec_tres, ec_levs, mfile
- integer :: ec_sh, ec_gg
- character(len=16) :: grid, gridN, gridT
- character(len=16) :: levs
- character(len=16) :: spm_tres
-
- type(TDate) :: tfile
- integer :: ccyy, mm, dd
- type(TDate) :: tc
-
- logical :: exist
-
-
-
-
-
-
- form = 'tmpp'
- call goVarValue( archivekeys, ';', 'form', '=', form, status )
- IF_ERROR_RETURN(status=1)
-
- ec_class = 'od'
- call goVarValue( archivekeys, ';', 'class', '=', ec_class, status )
- IF_ERROR_RETURN(status=1)
-
- ec_type = 'fc'
- call goVarValue( archivekeys, ';', 'type', '=', ec_type, status )
- IF_ERROR_RETURN(status=1)
-
- ec_levs = 'ml60'
- call goVarValue( archivekeys, ';', 'levs', '=', ec_levs, status )
- IF_ERROR_RETURN(status=1)
-
- ec_sh = 159
- call goVarValue( archivekeys, ';', 'sh', '=', ec_sh, status )
- IF_ERROR_RETURN(status=1)
-
- ec_gg = 80
- call goVarValue( archivekeys, ';', 'gg', '=', ec_gg, status )
- IF_ERROR_RETURN(status=1)
-
- ec_tres = ''
- call goVarValue( archivekeys, ';', 'tres', '=', ec_tres, status )
- IF_ERROR_RETURN(status=1)
-
-
-
- if ( ec_tres == '_fg006up4tr3' ) then
- tc = NewDate( 2000, 09, 12, 00, 00, 00 )
- if ( t1 > tc ) then
- write (gol,'(" WARNING - using fc data after 2000-09-12 00:00")'); call goPr
- ec_type = 'fc'
- ec_tres = '_fc012up2tr3'
- end if
- end if
-
-
- mf%ec_class = ec_class
- mf%ec_type = ec_type
-
-
-
-
-
-
- call goWriteKeyNum( gridT, 'T', ec_sh )
- call goWriteKeyNum( gridN, 'N', ec_gg )
-
-
- levs = ec_levs
- grid = 'Xxx'
- mfile = trim(paramkey)
- mf%paramkeys = '-'//trim(paramkey)//'-'
- mf%constant = .false.
- mf%do_spm = .false.
- mf%spm_fname = 'none'
- mf%spm_lnsp2sp = .false.
- spm_tres = ec_tres
-
-
- select case ( paramkey )
- case ( 'LNSP' )
- levs = 'ml1'
- grid = gridT
- if ( form /= '3hr' ) ec_tres = '_03p03'
- case ( 'VO', 'D' )
- mfile = 'VOD'
- mf%paramkeys = '-VO-D-'
- grid = gridT
- mf%do_spm = .true.
- spm_tres = '_03p03'
- if ( form == '3hr' ) then
- mfile = paramkey
- mf%paramkeys = '-'//trim(paramkey)//'-'
- spm_tres = ec_tres
- end if
- case ( 'T', 'W' )
- grid = gridT
- mf%do_spm = .true.
- spm_tres = '_03p03'
- if ( form == '3hr' ) then
- spm_tres = ec_tres
- end if
- case ( 'Q' )
- grid = gridN
- mf%do_spm = .true.
- spm_tres = '_03p03'
- mf%spm_lnsp2sp = .true.
- if ( form == '3hr' ) then
- spm_tres = ec_tres
- end if
- case ( 'CLWC', 'CIWC', 'CC', 'CCO', 'CCU' )
- grid = gridN
- mfile = 'CLD'
- mf%paramkeys = '-CLWC-CIWC-CC-CCO-CCU-'
- mf%do_spm = .true.
- spm_tres = '_03p03'
- mf%spm_lnsp2sp = .true.
- if ( form == '3hr' ) then
- spm_tres = ec_tres
- end if
- case ( 'oro' )
- levs = 'sfc'
- grid = gridN
- mf%constant = .true.
- ec_tres = 'const'
- case ( 'lsm' )
- levs = 'sfc'
- grid = gridN
- mf%constant = .true.
- case ( 'cvl', 'cvh', 'tvl', 'tvh', 'sr', 'al', 'lsrh' )
- ec_type = 'an'
- levs = 'sfc'
- grid = gridN
- mfile = 'S0'
- mf%paramkeys = '-cvl-cvh-tvl-tvh-sr-al-lsrh-'
- ec_tres = '_06p06'
- case ( 'ci', 'swvl1', 'swvl2', 'swvl3', 'swvl4', '10fg', 'sd', 'lsp', &
- 'cp', 'sf', 'sshf', 'slhf', 'blh', 'u10m', 'v10m', 't2m', 'd2m', &
- 'ssr', 'ewss', 'nsss', 'sstr' ,'src' )
- levs = 'sfc'
- grid = gridN
- mfile = 'S1'
- mf%paramkeys = '-'
- mf%paramkeys = trim(mf%paramkeys)//'ci-swvl1-swvl2-swvl3-swvl4-10fg-sd-lsp-'
- mf%paramkeys = trim(mf%paramkeys)//'cp-sf-sshf-slhf-blh-10u-10v-2t-2d-'
- mf%paramkeys = trim(mf%paramkeys)//'ssr-ewss-nsss-sstr-src-'
- ec_tres = '_03p03'
- end select
-
-
- call GetGribTime( ec_tres, tday, t1, t2, status, tfile=tfile, trange=mf%trange )
- IF_NOTOK_RETURN(status=1)
-
-
- mf%treskey = ec_tres
- if ( ec_type == 'an' ) mf%treskey = 'an'//ec_tres
- mf%tday = tday
-
-
-
- select case ( paramkey )
- case ( 'oro' )
- write (mf%fname,'(a,"/",a,"-",a,"-",i4.4,"-",i2.2,"-",a,"-",a,"-",a,a)') &
- trim(dir), &
- trim(ec_class), trim(ec_type), 0000, 00, trim(levs), trim(grid), &
- 'Z', '.gb'
- case ( 'lsm' )
- write (mf%fname,'(a,"/",a,"-",a,"-",i4.4,"-",i2.2,"-",a,"-",a,"-",a,a)') &
- trim(dir), &
- trim(ec_class), trim(ec_type), 0000, 00, trim(levs), trim(grid), &
- 'LSM', '.gb'
- case default
-
- call Get( tfile, year=ccyy, month=mm, day=dd )
-
- write (mf%fname,'(a,"/",a,"-",a,"-",i4.4,"-",i2.2,"-",a,"-",a,"-",a,"_",i4.4,2i2.2,a,a)') &
- trim(dir), &
- trim(ec_class), trim(ec_type), ccyy, mm, trim(levs), trim(grid), &
- trim(mfile), ccyy, mm, dd, trim(ec_tres), '.gb'
- end select
-
-
- inquire( file=mf%fname, exist=exist )
- if ( .not. exist ) then
- write (gol,'("grib file does not exist:")'); call goErr
- write (gol,'(" ",a)') trim(mf%fname); call goErr
- write (gol,'("in ",a)') rname; call goErr; status=1; return
- end if
-
-
-
-
-
- if ( mf%do_spm ) then
-
- grid = gridT
-
-
- levs = 'ml1'
-
-
- write (mf%spm_fname,'(a,"/",a,"-",a,"-",i4.4,"-",i2.2,"-",a,"-",a,"-",a,"_",i4.4,2i2.2,a,a)') &
- trim(dir), &
- trim(ec_class), trim(ec_type), ccyy, mm, trim(levs), trim(grid), &
- 'LNSP', ccyy, mm, dd, trim(spm_tres), '.gb'
-
- inquire( file=mf%spm_fname, exist=exist )
- if ( .not. exist ) then
- write (gol,'("grib file does not exist:")'); call goErr
- write (gol,'(" ",a)') trim(mf%spm_fname); call goErr
- write (gol,'("in ",a)') rname; call goErr; status=1; return
- end if
- end if
-
- status = 0
-
- end subroutine mf_Init
-
-
-
-
-
- subroutine mf_Done( mf, status )
-
- use file_grib, only : Done
-
-
- type(TMeteoFile_ecmwf_tmpp), intent(inout) :: mf
- integer, intent(out) :: status
-
-
- character(len=*), parameter :: rname = mname//'/mf_Done'
-
-
-
-
- status = 0
-
- end subroutine mf_Done
-
-
-
- subroutine mf_Get( mf, status, trange1, trange2, paramkeys )
-
- use GO, only : TDate
-
-
-
- type(TMeteoFile_ecmwf_tmpp), intent(in) :: mf
- integer, intent(out) :: status
- type(TDate), intent(out), optional :: trange1, trange2
- character(len=*), intent(out), optional :: paramkeys
-
-
-
- character(len=*), parameter :: rname = mname//'/mf_Get'
-
-
-
-
-
- if ( present(trange1) ) trange1 = mf%trange(1)
- if ( present(trange2) ) trange2 = mf%trange(2)
-
- if ( present(paramkeys) ) paramkeys = trim(mf%paramkeys)
-
-
- status = 0
-
- end subroutine mf_Get
-
-
-
- subroutine mf_ReadRecord( mf, paramkey, t1, t2, nuv, nw, &
- gridtype, levi, &
- lli, ll, sp_ll, &
- ggi, gg, sp_gg, &
- shi, sh, lnsp_sh, &
- tmi, status )
-
- use parray , only : pa_Init, pa_Done
- use GO , only : TDate
- use Grid , only : TLevelInfo
- use Grid , only : TllGridInfo, TggGridInfo, TshGridInfo
- use tmm_info , only : TMeteoInfo
-
-
- type(TMeteoFile_ecmwf_tmpp), intent(inout) :: mf
- character(len=*), intent(in) :: paramkey
- type(TDate), intent(in) :: t1, t2
- character(len=1), intent(in) :: nuv
- character(len=1), intent(in) :: nw
- character(len=2), intent(out) :: gridtype
- type(TLevelInfo), intent(out) :: levi
- type(TllGridInfo), intent(inout) :: lli
- real, pointer :: ll(:,:,:)
- real, pointer :: sp_ll(:,:)
- type(TggGridInfo), intent(inout) :: ggi
- real, pointer :: gg(:,:)
- real, pointer :: sp_gg(:)
- type(TshGridInfo), intent(inout) :: shi
- complex, pointer :: sh(:,:)
- complex, pointer :: lnsp_sh(:)
- type(TMeteoInfo), intent(out) :: tmi
- integer, intent(out) :: status
-
-
- character(len=*), parameter :: rname = mname//'/mf_ReadRecord'
-
-
-
- real, pointer :: ll2(:,:,:)
- real, pointer :: gg2(:,:)
- complex, pointer :: sh2(:,:)
-
-
-
-
- select case ( paramkey )
-
- case ( 'sstr' )
-
-
- call mf_ReadRecord_1( mf, 'ewss', t1, t2, nuv, nw, &
- gridtype, levi, &
- lli, ll, sp_ll, &
- ggi, gg, sp_gg, &
- shi, sh, lnsp_sh, &
- tmi, status )
- IF_NOTOK_RETURN(status=1)
-
- call pa_Init( ll2 )
- call pa_Init( gg2 )
- call pa_Init( sh2 )
-
- call mf_ReadRecord_1( mf, 'nsss', t1, t2, nuv, nw, &
- gridtype, levi, &
- lli, ll2, sp_ll, &
- ggi, gg2, sp_gg, &
- shi, sh2, lnsp_sh, &
- tmi, status )
- IF_NOTOK_RETURN(status=1)
-
- select case ( gridtype )
- case ( 'll' ) ; ll = sqrt( ll**2 + ll2**2 )
- case ( 'gg' ) ; gg = sqrt( gg**2 + gg2**2 )
- case ( 'sh' ) ; sh = sqrt( sh**2 + sh2**2 )
- case default
- write (gol,'("unsupported gridtype for substract :",a)') gridtype; call goErr
- write (gol,'("in ",a)') rname; call goErr; status=1; return
- end select
-
- call pa_Done( ll2 )
- call pa_Done( gg2 )
- call pa_Done( sh2 )
- case default
-
- call mf_ReadRecord_1( mf, paramkey, t1, t2, nuv, nw, &
- gridtype, levi, &
- lli, ll, sp_ll, &
- ggi, gg, sp_gg, &
- shi, sh, lnsp_sh, &
- tmi, status )
- IF_NOTOK_RETURN(status=1)
-
- end select
-
-
- status = 0
- end subroutine mf_ReadRecord
-
-
-
- subroutine mf_ReadRecord_1( mf, paramkey, t1, t2, nuv, nw, &
- gridtype, levi, &
- lli, ll, sp_ll, &
- ggi, gg, sp_gg, &
- shi, sh, lnsp_sh, &
- tmi, status )
-
- use parray , only : pa_Init, pa_Done
- use GO , only : TDate, operator(<), operator(-), rTotal, wrtgol
- use Grid , only : TLevelInfo
- use Grid , only : TllGridInfo, TggGridInfo, TshGridInfo
- use tmm_info , only : TMeteoInfo
-
-
- type(TMeteoFile_ecmwf_tmpp), intent(inout) :: mf
- character(len=*), intent(in) :: paramkey
- type(TDate), intent(in) :: t1, t2
- character(len=1), intent(in) :: nuv
- character(len=1), intent(in) :: nw
- character(len=2), intent(out) :: gridtype
- type(TLevelInfo), intent(out) :: levi
- type(TllGridInfo), intent(inout) :: lli
- real, pointer :: ll(:,:,:)
- real, pointer :: sp_ll(:,:)
- type(TggGridInfo), intent(inout) :: ggi
- real, pointer :: gg(:,:)
- real, pointer :: sp_gg(:)
- type(TshGridInfo), intent(inout) :: shi
- complex, pointer :: sh(:,:)
- complex, pointer :: lnsp_sh(:)
- type(TMeteoInfo), intent(out) :: tmi
- integer, intent(out) :: status
-
-
- character(len=*), parameter :: rname = mname//'/mf_ReadRecord_1'
-
-
-
- type(TDate) :: tref
- real, pointer :: ll1(:,:,:)
- real, pointer :: gg1(:,:)
- complex, pointer :: sh1(:,:)
- real :: dt_sec
-
-
-
-
- select case ( paramkey )
-
-
-
-
- case ( 'lsp', 'cp', 'sf', 'sshf', 'slhf', 'ssr', 'ewss', 'nsss' )
-
-
- call GetGribTime( mf%treskey, mf%tday, t1, t2, status, tref=tref )
- IF_NOTOK_RETURN(status=1)
-
- if ( .not. (t1 < t2) ) then
- write (gol,'("accumulated fields requires time interval:")'); call goErr
- write (gol,'(" paramkey : ",a)') paramkey; call goErr
- call wrtgol( ' t1 : ', t1 ); call goErr
- call wrtgol( ' t2 : ', t2 ); call goErr
- write (gol,'("in ",a)') rname; call goErr; status=1; return
- end if
-
-
- call mf_ReadRecord_2( mf, paramkey, tref, t2, t2, nuv, nw, &
- gridtype, levi, &
- lli, ll, sp_ll, &
- ggi, gg, sp_gg, &
- shi, sh, lnsp_sh, &
- tmi, status )
- IF_NOTOK_RETURN(status=1)
-
- if ( tref < t1 ) then
-
-
- call pa_Init( ll1 )
- call pa_Init( gg1 )
- call pa_Init( sh1 )
-
- call mf_ReadRecord_2( mf, paramkey, tref, t1, t1, nuv, nw, &
- gridtype, levi, &
- lli, ll1, sp_ll, &
- ggi, gg1, sp_gg, &
- shi, sh1, lnsp_sh, &
- tmi, status )
- IF_NOTOK_RETURN(status=1)
-
- select case ( gridtype )
- case ( 'll' ) ; ll = ll - ll1
- case ( 'gg' ) ; gg = gg - gg1
- case ( 'sh' ) ; sh = sh - sh1
- case default
- write (gol,'("unsupported gridtype for substract :",a)') gridtype; call goErr
- write (gol,'("in ",a)') rname; call goErr; status=1; return
- end select
-
- call pa_Done( ll1 )
- call pa_Done( gg1 )
- call pa_Done( sh1 )
-
- end if
-
-
- dt_sec = rTotal( t2 - t1, 'sec' )
- select case ( gridtype )
- case ( 'll' ) ; ll = ll / dt_sec
- case ( 'gg' ) ; gg = gg / dt_sec
- case ( 'sh' ) ; sh = sh / dt_sec
- case default
- write (gol,'("unsupported gridtype for time average :",a)') gridtype; call goErr
- write (gol,'("in ",a)') rname; call goErr; status=1; return
- end select
-
-
-
-
- case default
-
-
- call GetGribTime( mf%treskey, mf%tday, t1, t2, status, tref=tref )
- IF_NOTOK_RETURN(status=1)
-
- call mf_ReadRecord_2( mf, paramkey, tref, t1, t2, nuv, nw, &
- gridtype, levi, &
- lli, ll, sp_ll, &
- ggi, gg, sp_gg, &
- shi, sh, lnsp_sh, &
- tmi, status )
- IF_NOTOK_RETURN(status=1)
-
- end select
-
-
- status = 0
- end subroutine mf_ReadRecord_1
-
-
-
- subroutine mf_ReadRecord_2( mf, paramkey, tref, t1, t2, nuv, nw, &
- gridtype, levi, &
- lli, ll, sp_ll, &
- ggi, gg, sp_gg, &
- shi, sh, lnsp_sh, &
- tmi, status )
- use GO , only : TDate, wrtgol
- use Grid , only : Init, Done
- use Grid , only : TLevelInfo
- use Grid , only : TllGridInfo, TggGridInfo, TshGridInfo
- use Grid , only : Interpol
- use file_grib , only : Init, Done, ReadRecord, Get, Check
- use file_grib , only : levtype_sfc, levtype_hyb
- use file_grib , only : gridtype_ll, gridtype_gg, gridtype_sh
- use grib_table, only : GetPid
- use PArray , only : pa_Init, pa_Done, pa_SetShape
- use tmm_info , only : TMeteoInfo, Init, AddHistory
-
-
- type(TMeteoFile_ecmwf_tmpp), intent(inout) :: mf
- character(len=*), intent(in) :: paramkey
- type(TDate), intent(in) :: tref, t1, t2
- character(len=1), intent(in) :: nuv
- character(len=1), intent(in) :: nw
- character(len=2), intent(out) :: gridtype
- type(TLevelInfo), intent(out) :: levi
- type(TllGridInfo), intent(inout) :: lli
- real, pointer :: ll(:,:,:)
- real, pointer :: sp_ll(:,:)
- type(TggGridInfo), intent(inout) :: ggi
- real, pointer :: gg(:,:)
- real, pointer :: sp_gg(:)
- type(TshGridInfo), intent(inout) :: shi
- complex, pointer :: sh(:,:)
- complex, pointer :: lnsp_sh(:)
- type(TMeteoInfo), intent(out) :: tmi
- integer, intent(out) :: status
-
-
- character(len=*), parameter :: rname = mname//'/mf_ReadRecord_2'
-
-
-
- logical :: isfirst
- logical :: reopened
- integer :: pid, tabid
- integer :: nlev, glevtype, glevel
- integer :: level
- integer :: ggridtype
- real :: lon_first, lon_inc
- integer :: lon_n
- real :: lat_first, lat_inc
- integer :: lat_n
- integer :: ggN
- integer :: shT
-
- integer :: greftime(5), gtimerange(4)
- character(len=64) :: key
- integer :: ilat
- real, pointer :: pat(:,:)
- type(TshGridInfo) :: tmp_shi
- complex, pointer :: tmp_sh(:)
-
-
-
- if ( nuv /= 'n' ) then
- write (gol,'("unsupported nuv key : ",a)') nuv; call goErr
- write (gol,'("in ",a)') rname; call goErr; status=1; return
- end if
-
- call pa_Init( pat )
-
-
-
-
-
- call Init( mf%grib, mf%fname, 'r', status )
- IF_NOTOK_RETURN(status=1)
-
- isfirst = .true.
- reopened = .false.
-
-
- level = 0
- do
-
-
-
-
-
- call ReadRecord( mf%grib, status )
- select case ( status )
- case ( 0 )
-
- case ( 1 )
-
- if ( .not. reopened ) then
-
-
- call Done( mf%grib, status )
- IF_NOTOK_RETURN(status=1)
-
- call Init( mf%grib, mf%fname, 'r', status )
- IF_NOTOK_RETURN(status=1)
- reopened = .true.
- cycle
- else
- write (gol,'("reached eof before requested record was found")') ; call goErr
- write (gol,'(" file : ",a)') trim(mf%fname) ; call goErr
- write (gol,'(" paramkey : ",a)') trim(paramkey) ; call goErr
- call wrtgol( ' tref : ', tref ) ; call goErr
- call wrtgol( ' t1 : ', t1 ) ; call goErr
- call wrtgol( ' t2 : ', t2 ) ; call goErr
- TRACEBACK ; status=1; return
- end if
- case default
- write (gol,'("error from grib ReadRecord; status=",i6)') status; call goErr
- TRACEBACK ; status=1; return
- end select
-
-
-
-
-
-
-
- select case ( paramkey )
- case ( 'spm' ) ; call GetPid( 'ec', 'SP' , pid, tabid, status )
- case default ; call GetPid( 'ec', paramkey, pid, tabid, status )
- end select
- IF_NOTOK_RETURN(status=1)
-
- call Check( mf%grib, pid=pid, debug=0, status=status )
- if (status/=0) cycle
-
-
- if ( .not. mf%constant ) then
-
-
- call SetTime( mf, status )
- IF_NOTOK_RETURN(status=1)
-
- call CheckTime( mf, tref, t1, t2, status )
- if (status/=0) then
-
- cycle
-
-
-
-
-
-
-
-
- end if
-
- end if
-
- call Get( mf%grib, nlev=nlev, levtype=glevtype, level=glevel, status=status )
- IF_NOTOK_RETURN(status=1)
-
- select case ( glevtype )
- case ( levtype_sfc )
-
- nlev = 1
- glevel = 1
- case ( levtype_hyb )
- select case ( paramkey )
- case ( 'LNSP' )
- nlev = 1
- case default
-
- end select
- case default
- write (gol,'("found unexpected level type: ")'); call goErr
- write (gol,'(" leveltype : ",i3)') glevtype; call goErr
- write (gol,'(" paramkey : ",a)') paramkey; call goErr
- write (gol,'(" grib file : ",a)') trim(mf%fname); call goErr
- TRACEBACK ; status=1; return
- end select
-
- level = level + 1
- if ( glevel /= level ) then
- write (gol,'("found unexpected level: ")'); call goErr
- write (gol,'(" paramkey : ",a)') paramkey; call goErr
- write (gol,'(" req. level : ",i6)') level; call goErr
- write (gol,'(" grib level : ",i6)') glevel; call goErr
- write (gol,'(" grib nlev : ",i6)') nlev; call goErr
- write (gol,'(" grib file : ",a)') trim(mf%fname); call goErr
- TRACEBACK ; status=1; return
- end if
-
-
-
-
- if ( isfirst ) then
-
-
-
-
-
-
-
- call Init( tmi, paramkey, 'unknown', status )
- call AddHistory( tmi, 'model==ecmwf', status )
- call AddHistory( tmi, 'class=='//trim(mf%ec_class), status )
- call AddHistory( tmi, 'type=='//trim(mf%ec_type) , status )
-
- call Get( mf%grib, status, reftime=greftime, timerange=gtimerange )
- IF_NOTOK_RETURN(status=1)
- write (key,'("tref==",i4.4,4(",",i2.2))') greftime
- call AddHistory( tmi, trim(key), status )
- write (key,'("trange==",i3.3,3(",",i3.3))') gtimerange
- call AddHistory( tmi, trim(key), status )
-
- write (key,'("nlev==",i3.3)') nlev
- call AddHistory( tmi, trim(key), status )
-
-
-
-
- call Get( mf%grib, status, gridtype=ggridtype )
- IF_NOTOK_RETURN(status=1)
-
- select case ( ggridtype )
-
- case ( gridtype_ll )
-
- gridtype = 'll'
-
- call Get( mf%grib, status, &
- lon_first=lon_first, lon_inc=lon_inc, lon_n=lon_n, &
- lat_last =lat_first, lat_inc=lat_inc, lat_n=lat_n )
- IF_NOTOK_RETURN(status=1)
-
- call Init( lli, lon_first, lon_inc, lon_n, &
- lat_first, lat_inc, lat_n, status )
- IF_NOTOK_RETURN(status=1)
-
-
- call pa_SetShape( pat, lon_n, lat_n )
-
-
- call pa_SetShape( ll, lon_n, lat_n, nlev )
-
- write (key,'("longrid==",f7.2,",",f6.2,",",i4)') lon_first, lon_inc, lon_n
- call AddHistory( tmi, trim(key), status )
- write (key,'("latgrid==",f7.2,",",f6.2,",",i4)') lat_first, lat_inc, lat_n
- call AddHistory( tmi, trim(key), status )
-
- case ( gridtype_gg )
-
- gridtype = 'gg'
-
- call Get( mf%grib, status, N=ggN )
- IF_NOTOK_RETURN(status=1)
-
- call Init( ggi, ggN, .true., status )
- IF_NOTOK_RETURN(status=1)
-
-
- call pa_SetShape( gg, ggi%np, nlev )
-
- write (key,'("gg==",i4.4)') ggN
- call AddHistory( tmi, trim(key), status )
-
- case ( gridtype_sh )
-
- gridtype = 'sh'
-
- call Get( mf%grib, status, T=shT )
- IF_NOTOK_RETURN(status=1)
-
- call Init( shi, shT, status )
- IF_NOTOK_RETURN(status=1)
-
- call pa_SetShape( sh, shi%np, nlev )
-
- write (key,'("sh==",i4.4)') shT
- call AddHistory( tmi, trim(key), status )
- case default
- write (gol,'("unsupported gridtype for setup : ",i6)') ggridtype; call goErr
- TRACEBACK ; status=1; return
- end select
-
-
-
- select case ( nlev )
- case ( 1 )
- call Init( levi, nlev, (/0.0,0.0/), (/0.0,0.0/), status )
- IF_NOTOK_RETURN(status=1)
- case ( 60 )
- call Init( levi, 'ec60', status )
- IF_NOTOK_RETURN(status=1)
- end select
-
-
- isfirst = .false.
- end if
-
-
-
-
-
- select case ( ggridtype )
-
- case ( gridtype_ll )
-
-
- call Get( mf%grib, status, ll=pat )
- IF_NOTOK_RETURN(status=1)
-
- do ilat = 1, lat_n
- ll(:,ilat,level) = pat(:,lat_n+1-ilat)
- end do
-
- case ( gridtype_gg )
-
-
- call Get( mf%grib, status, gg=gg(:,level) )
- IF_NOTOK_RETURN(status=1)
- case ( gridtype_sh )
-
-
- call Get( mf%grib, status, sh=sh(:,level) )
- IF_NOTOK_RETURN(status=1)
- case default
- write (gol,'("unsupported gridtype for 2d pat : ",i6)') gridtype; call goErr
- TRACEBACK ; status=1; return
- end select
-
- if ( glevel == nlev ) exit
- end do
-
-
- call Done( mf%grib, status )
- IF_NOTOK_RETURN(status=1)
-
-
-
-
-
- if ( mf%do_spm ) then
-
-
- call Init( mf%spm_grib, mf%spm_fname, 'r', status )
- IF_NOTOK_RETURN(status=1)
-
-
- do
-
- call ReadRecord( mf%spm_grib, status )
- IF_NOTOK_RETURN(status=1)
-
- call SetTime( mf, status )
- IF_NOTOK_RETURN(status=1)
-
- call CheckTime( mf, tref, t1, t2, status )
- if (status/=0) then
-
- cycle
-
-
-
-
-
-
-
-
- end if
-
-
- exit
-
- end do
-
- select case ( ggridtype )
- case ( gridtype_ll )
- call GetPid( 'ec', 'SP', pid, tabid, status )
- IF_NOTOK_RETURN(status=1)
- case ( gridtype_gg )
- if ( mf%spm_lnsp2sp ) then
- call GetPid( 'ec', 'LNSP', pid, tabid, status )
- IF_NOTOK_RETURN(status=1)
- else
- call GetPid( 'ec', 'SP', pid, tabid, status )
- IF_NOTOK_RETURN(status=1)
- end if
- case ( gridtype_sh )
- call GetPid( 'ec', 'LNSP', pid, tabid, status )
- IF_NOTOK_RETURN(status=1)
- case default
- write (gol,'("unsupported gridtype for setup sp/lnsp : ",i6)') ggridtype; call goErr
- TRACEBACK ; status=1; return
- end select
-
- call Check( mf%spm_grib, pid=pid, debug=1, status=status )
- IF_NOTOK_RETURN(status=1)
-
- call Get( mf%spm_grib, levtype=glevtype, level=glevel, status=status )
- IF_NOTOK_RETURN(status=1)
- select case ( ggridtype )
- case ( gridtype_ll )
- if ( glevtype /= levtype_sfc ) then
- write (gol,'("found unexpected level type ")'); call goErr
- write (gol,'(" paramkey : ",a)') paramkey; call goErr
- write (gol,'(" sfc level type : ",i6)') levtype_sfc; call goErr
- write (gol,'(" grib level type : ",i6)') glevtype; call goErr
- write (gol,'(" grib file : ",a)') trim(mf%spm_fname); call goErr
- TRACEBACK ; status=1; return
- end if
- case ( gridtype_gg )
- if ( mf%spm_lnsp2sp ) then
- if ( (glevtype /= levtype_hyb) .or. (glevel /= 1) ) then
- write (gol,'("found unexpected level type (lnsp for 3d gg)")'); call goErr
- write (gol,'(" paramkey : ",a)') paramkey; call goErr
- write (gol,'(" hyb level type : ",i6)') levtype_hyb; call goErr
- write (gol,'(" grib level type : ",i6)') glevtype; call goErr
- write (gol,'(" grib level : ",i6)') glevel; call goErr
- write (gol,'(" grib file : ",a)') trim(mf%spm_fname); call goErr
- TRACEBACK ; status=1; return
- end if
- else
- if ( glevtype /= levtype_sfc ) then
- write (gol,'("found unexpected level type ")'); call goErr
- write (gol,'(" paramkey : ",a)') paramkey; call goErr
- write (gol,'(" sfc level type : ",i6)') levtype_sfc; call goErr
- write (gol,'(" grib level type : ",i6)') glevtype; call goErr
- write (gol,'(" grib file : ",a)') trim(mf%spm_fname); call goErr
- TRACEBACK ; status=1; return
- end if
- end if
- case ( gridtype_sh )
- if ( (glevtype /= levtype_hyb) .or. (glevel /= 1) ) then
- write (gol,'("found unexpected level type ")'); call goErr
- write (gol,'(" paramkey : ",a)') paramkey; call goErr
- write (gol,'(" hyb level type : ",i6)') levtype_hyb; call goErr
- write (gol,'(" grib level type : ",i6)') glevtype; call goErr
- write (gol,'(" grib level : ",i6)') glevel; call goErr
- write (gol,'(" grib file : ",a)') trim(mf%spm_fname); call goErr
- TRACEBACK ; status=1; return
- end if
- case default
- write (gol,'("unsupported gridtype for sp/lnsp levs : ",i6)') ggridtype; call goErr
- TRACEBACK ; status=1; return
- end select
-
-
- select case ( ggridtype )
- case ( gridtype_ll )
-
- call pa_SetShape( sp_ll, lon_n, lat_n )
-
- call Get( mf%spm_grib, status, ll=pat )
- IF_NOTOK_RETURN(status=1)
-
- do ilat = 1, lat_n
- sp_ll(:,ilat) = pat(:,lat_n+1-ilat)
- end do
- case ( gridtype_gg )
-
- call pa_SetShape( sp_gg, ggi%np )
-
- if ( mf%spm_lnsp2sp ) then
-
- call pa_SetShape( sh, shi%np, nlev )
-
- call Get( mf%spm_grib, status, T=shT )
- IF_NOTOK_RETURN(status=1)
-
- call Init( tmp_shi, shT, status )
- IF_NOTOK_RETURN(status=1)
-
- call pa_Init( tmp_sh )
- call pa_SetShape( tmp_sh, tmp_shi%np )
-
- call Get( mf%spm_grib, status, sh=tmp_sh )
- IF_NOTOK_RETURN(status=1)
-
- call Interpol( tmp_shi, tmp_sh, ggi, sp_gg, status )
- IF_NOTOK_RETURN(status=1)
-
- call Done( tmp_shi )
- call pa_Done( tmp_sh )
-
- sp_gg = exp(sp_gg)
- else
-
- call Get( mf%spm_grib, status, gg=sp_gg )
- IF_NOTOK_RETURN(status=1)
- end if
-
- case ( gridtype_sh )
-
- call pa_SetShape( lnsp_sh, shi%np )
-
- call Get( mf%spm_grib, status, sh=lnsp_sh )
- IF_NOTOK_RETURN(status=1)
-
- case default
- write (gol,'("unsupported gridtype for reading sp/lnsp : ",i6)') ggridtype; call goErr
- TRACEBACK ; status=1; return
- end select
-
- call Done( mf%spm_grib, status )
- IF_NOTOK_RETURN(status=1)
- end if
-
-
-
-
-
-
- call pa_Done( pat )
-
-
- status = 0
- end subroutine mf_ReadRecord_2
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- subroutine GetGribTime( ec_treskey, tday, t1, t2, status, tfile, trange, tref )
-
- use GO, only : TDate, Get, Set, wrtgol, NewDate, IncrDate, operator(+), operator(-)
-
-
-
- character(len=*), intent(in) :: ec_treskey
- type(TDate), intent(in) :: tday, t1, t2
- integer, intent(out) :: status
-
- type(TDate), intent(out), optional :: tfile
- type(TDate), intent(out), optional :: trange(2)
- type(TDate), intent(out), optional :: tref
-
-
-
- character(len=*), parameter :: rname = mname//'/GetGribTime'
-
-
- integer :: hour2, time6(6)
- integer :: dd, hh, step
-
-
- select case ( ec_treskey )
-
-
-
-
- case ( 'const' )
-
-
- if ( present(tfile ) ) tfile = tday
- if ( present(trange) ) trange = (/t1,t2/)
- if ( present(tref ) ) tref = tday
-
-
-
-
-
- case ( '_fg006up4tr3' )
-
-
- call Get( t2, hour=hour2 )
-
- select case ( hour2 )
- case ( 00 ) ; dd = 0 ; hh = 00 ; step = 6
- case ( 03 ) ; dd = 0 ; hh = 03 ; step = 3
- case ( 06 ) ; dd = 0 ; hh = 06 ; step = 6
- case ( 09 ) ; dd = 0 ; hh = 09 ; step = 3
- case ( 12 ) ; dd = 0 ; hh = 12 ; step = 6
- case ( 15 ) ; dd = 0 ; hh = 15 ; step = 3
- case ( 18 ) ; dd = 0 ; hh = 18 ; step = 6
- case ( 21 ) ; dd = 0 ; hh = 21 ; step = 3
- case default
- write (gol,'("unsupported hour :")'); call goErr
- write (gol,'(" hour2 : ",i2)') hour2; call goErr
- write (gol,'(" timesteps : ",a )') ec_treskey; call goErr
- call wrtgol( ' time1 : ', t1 ); call goErr
- TRACEBACK ; status=1; return
- end select
-
-
- if ( present(tfile) ) then
- tfile = t1
- call Set( tfile, hour=00 )
- end if
-
-
- if ( present(trange) ) then
- trange(1) = t1
- call Set( trange(1), hour=0, min=0, sec=0, mili=0 )
- trange(2) = trange(1) + IncrDate(hour=23,min=59,sec=59,mili=999)
-
- call Get( tfile, time6=time6 )
- if ( all(time6(1:3)==(/2000,09,12/)) ) trange(2) = trange(1)
- end if
-
-
- if ( present(tref) ) then
- call Get( t1, time6=time6 )
- time6(4:6) = 0
- tref = NewDate( time6=time6 ) + IncrDate( day=dd, hour=hh )
- end if
-
-
-
-
- case ( '_fc012up2tr3', '_03p03' )
-
-
- call Get( t2, hour=hour2 )
-
- select case ( hour2 )
- case ( 00 ) ; dd = -1 ; hh = 12 ; step = 12
- case ( 03 ) ; dd = 0 ; hh = 00 ; step = 3
- case ( 06 ) ; dd = 0 ; hh = 00 ; step = 6
- case ( 09 ) ; dd = 0 ; hh = 00 ; step = 9
- case ( 12 ) ; dd = 0 ; hh = 00 ; step = 12
- case ( 15 ) ; dd = 0 ; hh = 12 ; step = 3
- case ( 18 ) ; dd = 0 ; hh = 12 ; step = 6
- case ( 21 ) ; dd = 0 ; hh = 12 ; step = 9
- case default
- write (gol,'("unsupported hour :")'); call goErr
- write (gol,'(" hour2 : ",i2)') hour2; call goErr
- write (gol,'(" timesteps : ",a )') ec_treskey; call goErr
- call wrtgol( ' time1 : ', t1 ); call goErr
- TRACEBACK ; status=1; return
- end select
-
-
- if ( present(tfile) ) then
-
- tfile = t2
- call Set( tfile, hour=0, min=0, sec=0, mili=0 )
-
- call Get( t2, time6=time6 )
- if ( all(time6(4:6)==0) ) tfile = tfile - IncrDate(day=1)
- end if
-
-
- if ( present(trange) ) then
- trange(1) = t2
- call Set( trange(1), hour=0, min=0, sec=0, mili=0 )
-
- call Get( t2, time6=time6 )
- if ( all(time6(4:6)==0) ) trange(1) = trange(1) - IncrDate(day=1)
-
- trange(2) = trange(1) + IncrDate(day=1)
- call Set( trange(1), mili=1 )
- end if
-
-
- if ( present(tref) ) then
- call Get( t2, time6=time6 )
- time6(4:6) = 0
- tref = NewDate( time6=time6 ) + IncrDate( day=dd, hour=hh )
- end if
-
-
-
-
- case ( '_06p06' )
-
-
- call Get( t2, hour=hour2 )
-
- select case ( hour2 )
- case ( 00 ) ; dd = -1 ; hh = 12 ; step = 12
- case ( 06 ) ; dd = 0 ; hh = 00 ; step = 6
- case ( 12 ) ; dd = 0 ; hh = 00 ; step = 12
- case ( 18 ) ; dd = 0 ; hh = 12 ; step = 6
- case default
- write (gol,'("unsupported hour :")'); call goErr
- write (gol,'(" hour2 : ",i2)') hour2; call goErr
- write (gol,'(" timesteps : ",a )') ec_treskey; call goErr
- call wrtgol( ' time1 : ', t1 ); call goErr
- TRACEBACK ; status=1; return
- end select
-
-
- if ( present(tfile) ) then
-
- tfile = t1
- call Set( tfile, hour=00 )
-
- call Get( t1, time6=time6 )
- if ( all(time6(4:6)==0) ) tfile = tfile - IncrDate(day=1)
- end if
-
-
- if ( present(trange) ) then
- trange(1) = t1
- call Set( trange(1), hour=0, min=0, sec=0, mili=0 )
-
- call Get( t1, time6=time6 )
- if ( all(time6(4:6)==0) ) trange(1) = trange(1) - IncrDate(day=1)
-
- trange(2) = trange(1) + IncrDate(day=1)
- call Set( trange(1), mili=1 )
- end if
-
-
- if ( present(tref) ) then
- call Get( t1, time6=time6 )
- time6(4:6) = 0
- tref = NewDate( time6=time6 ) + IncrDate( day=dd, hour=hh )
- end if
-
-
-
-
- case ( 'an_06p06' )
-
-
- call Get( t2, hour=hour2 )
-
- select case ( hour2 )
- case ( 00 ) ; dd = 0 ; hh = 00 ; step = 00
- case ( 06 ) ; dd = 0 ; hh = 06 ; step = 00
- case ( 12 ) ; dd = 0 ; hh = 12 ; step = 00
- case ( 18 ) ; dd = 0 ; hh = 18 ; step = 00
- case default
- write (gol,'("unsupported hour :")'); call goErr
- write (gol,'(" hour2 : ",i2)') hour2; call goErr
- write (gol,'(" timesteps : ",a )') ec_treskey; call goErr
- call wrtgol( ' time1 : ', t1 ); call goErr
- TRACEBACK ; status=1; return
- end select
-
-
- if ( present(tfile) ) then
-
- tfile = t1
- call Set( tfile, hour=00 )
-
- call Get( t1, time6=time6 )
- if ( all(time6(4:6)==0) ) tfile = tfile - IncrDate(day=1)
- end if
-
-
- if ( present(trange) ) then
- trange(1) = t1
- call Set( trange(1), hour=0, min=0, sec=0, mili=0 )
-
- call Get( t1, time6=time6 )
- if ( all(time6(4:6)==0) ) trange(1) = trange(1) - IncrDate(day=1)
-
- trange(2) = trange(1) + IncrDate(day=1)
- call Set( trange(1), mili=1 )
- end if
-
-
- if ( present(tref) ) then
- call Get( t1, time6=time6 )
- time6(4:6) = 0
- tref = NewDate( time6=time6 ) + IncrDate( day=dd, hour=hh )
- end if
-
-
-
-
- case default
-
- write (gol,'("unsupported time resolution key:")'); call goErr
- write (gol,'(" ",a)') trim(ec_treskey); call goErr
- TRACEBACK ; status=1; return
-
- end select
-
- status = 0
-
- end subroutine GetGribTime
-
-
-
-
-
-
-
-
- subroutine SetTime( mf, status )
- use GO, only : TDate, NewDate, IncrDate, operator(+), wrtgol
- use file_grib, only : TGribFile, Get
-
-
-
- character(len=*), parameter :: rname = mname//'/SetTime'
-
-
-
- type(TMeteoFile_ecmwf_tmpp), intent(inout) :: mf
- integer, intent(out) :: status
-
-
-
- integer :: reftime(5), timerange(4)
-
-
- call Get( mf%grib, status, reftime=reftime, timerange=timerange )
- IF_NOTOK_RETURN(status=1)
-
-
-
- select case ( timerange(4) )
-
- case ( 0, 1 )
-
-
-
-
-
-
-
-
- mf%tref = NewDate( time5=reftime )
-
-
-
- mf%t1 = NewDate( time5=reftime )
- select case ( timerange(1) )
- case ( 1 )
- mf%t1 = mf%t1 + IncrDate( hour=timerange(2) )
- case default
- write (gol,'("grib timerange units other than hours not supported yet")'); call goErr
- write (gol,'(" reftime : ",i4,4i3)') reftime; call goErr
- write (gol,'(" timerange : ",4i3)') timerange; call goErr
- write (gol,'(" file : ",a)') trim(mf%grib%fname); call goErr
- TRACEBACK ; status=1; return
- end select
-
-
- mf%t2 = mf%t1
-
- case ( 2 )
-
-
-
-
-
-
-
- mf%t1 = NewDate( time5=reftime )
- select case ( timerange(1) )
- case ( 1 )
- mf%t1 = mf%t1 + IncrDate( hour=timerange(2) )
- case default
- write (gol,'("grib timerange units other than hours not supported yet")'); call goErr
- write (gol,'(" file : ",a)') trim(mf%grib%fname); call goErr
- TRACEBACK ; status=1; return
- end select
-
-
-
- mf%t2 = NewDate( time5=reftime )
- select case ( timerange(1) )
- case ( 1 )
- mf%t2 = mf%t2 + IncrDate( hour=timerange(3) )
- case default
- write (gol,'("grib timerange units other than hours not supported yet")'); call goErr
- write (gol,'(" file : ",a)') trim(mf%grib%fname); call goErr
- TRACEBACK ; status=1; return
- end select
-
- case default
- write (gol,'("unsupported time range indicator:")'); call goErr
- write (gol,'(" indicator : ",i6)') timerange(4); call goErr
- write (gol,'(" file : ",a)') trim(mf%grib%fname); call goErr
- TRACEBACK ; status=1; return
-
- end select
-
-
- status = 0
- end subroutine SetTime
-
-
-
-
- subroutine CheckTime( mf, tref, t1, t2, status )
- use GO
- use file_grib, only : Get
-
-
-
- character(len=*), parameter :: rname = mname//'/CheckTime'
-
-
-
- type(TMeteoFile_ecmwf_tmpp), intent(in) :: mf
- type(TDate), intent(in) :: tref, t1, t2
- integer, intent(out) :: status
-
-
-
- integer :: year1, year2
-
-
-
- call Get( t1, year=year1 )
- call Get( t2, year=year2 )
- if ( (year1 == 0) .and. (year2 == 0) ) then
-
- status = 0; return
- end if
-
- if ( year1 == 0 ) then
-
- if ( t2 == mf%t2 ) then
- status = 0; return
- else
- status = 1; return
- end if
- else if ( year2 == 0 ) then
-
- if ( t1 == mf%t1 ) then
- status = 0; return
- else
- status = 1; return
- end if
- end if
-
- if ( (tref == mf%tref) .and. (t1 == mf%t1) .and. (t2 == mf%t2) ) then
- status = 0; return
- else
- status = 1; return
- end if
-
-
- status = 1
- end subroutine CheckTime
-
-
- end module tmm_mf_ecmwf_tmpp
|