123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388 |
- !### macro's #####################################################
- !
- #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
- !
- !#################################################################
- module grib_table
- implicit none
-
- ! --- in/out -----------------------------------
-
- private
-
- public :: GetPid
- public :: GetPidName
-
-
- ! --- const ------------------------------
-
- character(len=*), parameter :: mname = 'grib_table'
-
- contains
- ! =============================================================
- subroutine GetPid( table, key, pid, tabid, status )
-
- use GO, only : gol, goErr
-
- ! --- in/out --------------------------------
-
- character(len=*), intent(in) :: table
- character(len=*), intent(in) :: key
- integer, intent(out) :: pid
- integer, intent(out) :: tabid
- integer, intent(out) :: status
-
- ! --- const --------------------------------------
-
- character(len=*), parameter :: rname = mname//'/GetPid'
-
- ! --- local ----------------------------------
-
- integer :: tabv
-
- ! --- begin ----------------------------------
-
- ! default table version:
- tabid = 128
- select case ( table )
-
- ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ! ECMWF codes
- ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- case ( 'ec' )
-
- select case ( key )
- case ( 'CVL' , 'cvl' ); pid = 027 ! low vegetation cover
- case ( 'CVH' , 'cvh' ); pid = 028 ! high vegetation cover
- case ( 'TVL' , 'tvl' ); pid = 029 ! type of low vegetation
- case ( 'TVH' , 'tvh' ); pid = 030 ! type of high vegetation
- case ( 'CI' , 'ci' ); pid = 031 ! sea-ice cover
- case ( 'SSTK', 'sstk', 'sst' ); pid = 034 ! sea surface temperature
- case ( 'SWV1', 'swv1', 'swvl1' ); pid = 039 ! volumetric soil water layer 1
- case ( 'SWV2', 'swv2', 'swvl2' ); pid = 040 ! volumetric soil water layer 2
- case ( 'SWV3', 'swv3', 'swvl3' ); pid = 041 ! volumetric soil water layer 3
- case ( 'SWV4', 'swv4', 'swvl4' ); pid = 042 ! volumetric soil water layer 4
- case ( 'G10M', 'g10m' ); pid = 049 ! wind gust at 10m (Need to account for the following two lines)
- case ( '10FG', '10fg' ); pid = 049 ! wind gust at 10m 3-HOURLY (before cycle 37r3) and HOURLY accumulation (after cycle 37r3)
- case ( '10FG3', '10fg3' ); pid = 028; tabid=228 ! wind gust at 10m 3-HOURLY accumulation (from cycle 37r3)
- case ( 'PV' ); pid = 60 ! potential vorticity (K m2/kg/s)
- ! era40, local table 162
- ! NOTE: for era2004 set, local table in grib files is actually 128 (error!)
- case ( 'UDMF' ); pid = 104; tabid=162 ! updraught mass flux kg/m2
- case ( 'DDMF' ); pid = 105; tabid=162 ! downdraught mass flux kg/m2
- case ( 'UDDR' ); pid = 106; tabid=162 ! updraught detrainment rate kg/m3
- case ( 'DDDR' ); pid = 107; tabid=162 ! downdraught detrainment rate kg/m3
- case ( 'K' ); pid = 109; tabid=162 ! diffusion (m2/s)
- case ( 'U' ); pid = 131 ! u wind
- case ( 'V' ); pid = 132 ! v wind
- case ( 'Z' ); pid = 129 ! geopotential, orography at surface
- case ( 'oro' ); pid = 129 ! orography (geopotential at surface)
- case ( 'T' ); pid = 130 ! temperature
- case ( 'Q' ); pid = 133 ! specific humidity
- case ( 'SP' , 'sp' ); pid = 134
- case ( 'W' ); pid = 135
- case ( 'VO' ); pid = 138
- case ( 'SLW' , 'slw' ); pid = 140
- case ( 'SD' , 'sd' ); pid = 141
- case ( 'LSP' , 'lsp' ); pid = 142
- case ( 'CP' , 'cp' ); pid = 143
- case ( 'SF' , 'sf' ); pid = 144
- case ( 'SSHF', 'sshf' ); pid = 146
- case ( 'SLHF', 'slhf' ); pid = 147 ! surface latent heat flux (W m**-2 s)
- case ( 'LNSP', 'lnsp' ); pid = 152
- case ( 'D' , 'd' ); pid = 155
- case ( 'GH' , 'gh' ); pid = 156 ! geopotential height
- case ( 'BLH' , 'blh' ); pid = 159 ! boundary layer height
- case ( 'U10M', 'u10m' ); pid = 165
- case ( 'V10M', 'v10m' ); pid = 166
- case ( 'T2M' , 't2m' ); pid = 167
- case ( 'D2M' , 'd2m' ); pid = 168
- case ( 'LSM' , 'lsm' ); pid = 172 ! land/sea mask
- case ( 'z0m' ); pid = 173
- case ( 'SR' , 'sr' ); pid = 173
- case ( 'AL' , 'al', 'albedo' ); pid = 174 ! Albedo (0-1)
- case ( 'EWSS', 'ewss' ); pid = 180
- case ( 'NSSS', 'nsss' ); pid = 181
- case ( 'LSRH', 'lsrh' ); pid = 234 ! Log. Surf.Roughn. length for Heat
- case ( 'ustar' ); pid = 250
- case ( 'Raero' ); pid = 251
- case ( 'CLWC' , 'clwc' ); pid = 246 ! cloud liquid water content
- case ( 'CIWC' , 'ciwc' ); pid = 247 ! cloud ice water content
- case ( 'CC' , 'cc' ); pid = 248 ! cloud cover
- case ( 'SSR' , 'ssr' ); pid = 176 ! surface solar radiation
- case ( 'SSRD' , 'ssrd' ); pid = 169 ! surface solar radiation downwards
- case ( 'STR' , 'str' ); pid = 177 ! surface thermal radiation
- case ( 'STRD' , 'strd' ); pid = 175 ! surface thermal radiation downwards
- case ( 'SRC' , 'src' ); pid = 198 ! skin reservoir content
- case ( 'SKT' , 'skt' ); pid = 235 ! skin temperature
- case ( 'CH4FIRE', 'ch4fire' ); pid = 082 ; tabid = 210 ! wildfire flux of methane
- case default
- write (gol,'("unknown key `",a,"`")') trim(key); call goErr
- write (gol,'(" table : ",a)') trim(table); call goErr
- TRACEBACK; status=1; return
- end select
- ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ! TM codes
- ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- case ( 'tm' )
-
- select case ( key )
- case ( 'PV' ); pid = 60 ! potential vorticity (K m2/kg/s)
- case ( 'K' ); pid = 109 ! diffusion (m2/s)
- case ( 'u' ); pid = 131 ! u wind
- case ( 'v' ); pid = 132 ! v wind
- case ( 'ps' ); pid = 160 ! average surface pressure
- case ( 'pu' ); pid = 158 ! u flux
- case ( 'pv' ); pid = 159 ! v flux
- case ( 'pw' ); pid = 157 ! w flux
- case ( 'Z' ); pid = 129 ! geopotential, orography at surface
- case ( 'T' ); pid = 130 ! temperature
- case ( 'Q' ); pid = 133 ! specific humidity
- case ( 'GH' ); pid = 156 ! geopotential height
- case ( 'eu' ); pid = 161 ! entrainment updraft
- case ( 'du' ); pid = 162 ! detrainment updraft
- case ( 'ed' ); pid = 164 ! entrainment downdraft
- case ( 'dd' ); pid = 165 ! detrainment downdraft
- case ( 'dk' ); pid = 163 ! vertical diffusion coef.
- case ( 'clbas' ); pid = 190 ! cloud base
- case ( 'cltop' ); pid = 191 ! cloud top
- case ( 'cllfs' ); pid = 192
- case ( 'Kz' ); pid = 163
- case ( 'pblh' ); pid = 159
- case ( 'pblh?' ); pid = 203
- case ( 'lsp' ); pid = 142
- case ( 'cp' ); pid = 143
- case ( 'sf' ); pid = 144
- case ( 'sshf' ); pid = 146
- case ( 'slhf' ); pid = 147 ! surface latent heat flux (W m**-2 s)
- case ( 'slw' ); pid = 140
- case ( 'sd' ); pid = 141
- case ( 'T2M', 'T2m', 't2m' ); pid = 167
- case ( 'D2M', 'D2m', 'd2m' ); pid = 168
- case ( 'z0m', 'SR' ); pid = 173
- case ( 'al' ); pid = 174 ! Albedo (0-1)
- case ( 'ewss' ); pid = 180
- case ( 'nsss' ); pid = 181
- case ( 'ustar' ); pid = 250
- case ( 'Raero' ); pid = 251
- case ( 'CLWC', 'clwc' ); pid = 246 ! cloud liquid water content
- case ( 'CIWC', 'ciwc' ); pid = 247 ! cloud ice water content
- case ( 'CC' , 'cc' ); pid = 248 ! cloud cover
- case ( 'CCO' , 'cco' ); pid = 249 ! overhead cloud cover
- case ( 'CCU' , 'ccu' ); pid = 250 ! underfeet cloud cover
- case ( 'ssr' ); pid = 176 ! surface solar radiation
- case ( 'src' ); pid = 198 ! skin reservoir content
- case default
- write (gol,'("unknown key `",a,"`")') trim(key); call goErr
- write (gol,'(" table : ",a)') trim(table); call goErr
- TRACEBACK; status=1; return
- end select
- case default
- write (gol,'("unknown table `",a,"`")') trim(table); call goErr
- TRACEBACK; status=1; return
- end select
-
- ! ok
- status = 0
- end subroutine GetPid
-
- ! =============================================================
- subroutine GetPidName( table, pid, name, status )
-
- use GO, only : gol, goErr
-
- ! --- in/out ------------------------------
-
- character(len=*), intent(in) :: table
- integer, intent(in) :: pid
- character(len=*), intent(out) :: name
- integer, intent(out) :: status
-
- ! --- const --------------------------------------
-
- character(len=*), parameter :: rname = mname//'/GetPidName'
-
- ! --- begin -------------------------------
-
- select case ( table )
-
- ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ! ECMWF codes
- ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- case ( 'ec' )
-
- select case ( pid )
- case ( 109 ) ; name = 'K ' ! diffusion (m2/s); experimental
- case ( 129 ) ; name = 'Z '
- case ( 130 ) ; name = 'T '
- case ( 131 ) ; name = 'U '
- case ( 132 ) ; name = 'V '
- case ( 133 ) ; name = 'Q '
- case ( 134 ) ; name = 'SP '
- case ( 135 ) ; name = 'W '
- case ( 138 ) ; name = 'VO '
- case ( 141 ) ; name = 'SD '
- case ( 142 ) ; name = 'LSP '
- case ( 143 ) ; name = 'CP '
- case ( 144 ) ; name = 'SF '
- case ( 146 ) ; name = 'SSHF'
- case ( 147 ) ; name = 'SLHF'
- case ( 152 ) ; name = 'LNSP'
- case ( 155 ) ; name = 'D '
- case ( 156 ) ; name = 'GH '
- case ( 159 ) ; name = 'BLH '
- case ( 165 ) ; name = 'U10M'
- case ( 166 ) ; name = 'V10M'
- case ( 167 ) ; name = 'T2M '
- case ( 168 ) ; name = 'D2M '
- case ( 172 ) ; name = 'LSM '
- case ( 173 ) ; name = 'SR '
- case ( 174 ) ; name = 'AL '
- case ( 176 ) ; name = 'SSR '
- case ( 180 ) ; name = 'EWSS'
- case ( 181 ) ; name = 'NSSS'
- case ( 198 ) ; name = 'SRC '
- case ( 234 ) ; name = 'LSRH'
- case ( 246 ) ; name = 'CLWC'
- case ( 247 ) ; name = 'CIWC'
- case ( 248 ) ; name = 'CC '
- case default
- write (name,'("p",i3.3)') pid
- end select
-
- ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ! TM codes
- ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- case ( 'tm' )
-
- select case ( pid )
- case ( 104 ) ; name = 'MU ' ! updraught mass flux kg m-2
- case ( 105 ) ; name = 'MD ' ! downdraught mass flux kg m-2
- case ( 106 ) ; name = 'DU ' ! updraught detrainment rate s m-1
- case ( 107 ) ; name = 'DD ' ! downdraught detrainment rate s m-1
- case ( 109 ) ; name = 'K ' ! diffusion (m2/s); experimental
- case ( 129 ) ; name = 'Z '
- case ( 130 ) ; name = 'T '
- case ( 131 ) ; name = 'U '
- case ( 132 ) ; name = 'V '
- case ( 133 ) ; name = 'Q '
- case ( 134 ) ; name = 'SP '
- case ( 135 ) ; name = 'W '
- case ( 138 ) ; name = 'VO '
- case ( 141 ) ; name = 'SD '
- case ( 142 ) ; name = 'LSP '
- case ( 143 ) ; name = 'CP '
- case ( 144 ) ; name = 'SF '
- case ( 146 ) ; name = 'SSHF'
- case ( 147 ) ; name = 'SLHF'
- case ( 152 ) ; name = 'LNSP'
- case ( 155 ) ; name = 'D '
- case ( 156 ) ; name = 'zg ' ! ECMWF : GH
- case ( 157 ) ; name = 'pw '
- case ( 158 ) ; name = 'pu '
- case ( 159 ) ; name = 'pv '
- case ( 160 ) ; name = 'sp '
- case ( 161 ) ; name = 'eu '
- case ( 162 ) ; name = 'du '
- case ( 163 ) ; name = 'dk '
- case ( 164 ) ; name = 'ed '
- case ( 165 ) ; name = 'dd '
- case ( 167 ) ; name = 'T2M '
- case ( 168 ) ; name = 'D2M '
- case ( 172 ) ; name = 'LSM '
- case ( 173 ) ; name = 'SR '
- case ( 174 ) ; name = 'AL '
- case ( 176 ) ; name = 'SSR '
- case ( 180 ) ; name = 'EWSS'
- case ( 181 ) ; name = 'NSSS'
- case ( 190 ) ; name = 'clb '
- case ( 191 ) ; name = 'clt '
- case ( 192 ) ; name = 'clfs'
- case ( 198 ) ; name = 'SRC '
- case ( 203 ) ; name = 'blh ' ! ECMWF's BLH has code 159, but this is pv in TM ...
- case ( 234 ) ; name = 'LSRH'
- case ( 246 ) ; name = 'CLWC'
- case ( 247 ) ; name = 'CIWC'
- case ( 248 ) ; name = 'CC '
- case ( 249 ) ; name = 'cco '
- case ( 250 ) ; name = 'ccu '
- case default
- write (name,'("p",i3.3)') pid
- end select
-
- case default
- write (gol,'("unknown table `",a,"`")') trim(table); call goErr
- TRACEBACK; status=1; return
- end select
- ! ok
- status = 0
-
- end subroutine GetPidName
-
- end module grib_table
|