ARJO SEGERS
KNMI
Date: 21/04/2004
Module to access TM meteo.
The main structure provides access to a list of opened meteo files. If a new meteo field is required, the subroutines search in the list wether the field is available. If not, a new file is opened and added to the list. Optionally, a shell script is invoked to search for a file and to store it locally if necessary.
! --- modules -----------------------------------------
use GO, only : TDate, NewDate
use grid, only : TllGridInfo, Init, Done
use grid, only : TLevelInfo, Init, Done
use TMM, only : TTmMeteo
use TMM, only : Init, Done
use TMM, only : ReadField, ReadUVSP
! --- local -----------------------------------------
type(TllGridInfo) :: lli
type(TLevelInfo) :: levi_ec, levi
type(TTmMeteo) :: tmmd
type(TDate) :: tday, t1, t2
real :: psurf(120,90)
real :: temper(120,90,25)
real :: pu(0:120,90,25)
! --- begin -----------------------------------------
! define horizontal grid
call Init( lli, -178.5, 3.0, 120, -89.0, 2.0, 90, status )
! define vertical hybride levels
call Init( levi_ec, 'ec60', status ) ! ecmwf levels
call Init( levi, levi_ec, (/60,..,0/), status ) ! tm half level selection
! setup TM meteo access:
call Init( tmmd, 'tm5.rc', status )
! define time range for field:
tday = NewDate( year=2003, month=01, day=01 )
t1 = NewDate( year=2002, month=12, day=31, hour=21 )
t2 = NewDate( year=2003, month=01, day=01, hour=03 )
! Read meteo arrays; specify grid, parameter, time, etc.
!
! Type of grid is defined by nuv key:
! 'n' = normal grid (cell centers)
! 'u' = u-grid (east/west boundaries)
! 'v' = v-grid (north/south boundaries)
!
! Requested grid (lli/levi) might be different from the grid in the file.
! Horizontal:
! o if file contains same resolutions as defined by lli,
! a part of the data in the file is selected;
! o if file contains higher resolution fields,
! the ll array is filled with combined values from the file;
! depending on the parameter, the result is summed/avaraged/etc.
! Vertical:
! o if a file contains a supperset of the levels in levi,
! some levels are combined;
! depending on the parameter, the result is summed/avaraged/etc;
! o the file might contain fields with reversed level order.
!
! 3D fields require surface pressure for the level definition.
! It should be valid for [t1,t2] !
! Best is to use the spm from ReadUVSP.
call ReadUVSP ( tmmd, 'tmpp:od-fc-ml60-glb3x2', tday, t1, t2, lli, levi, sp1, spm, sp2, pu, pv, status )
call ReadField( tmmd, 'tmpp:od-fc-ml60-glb3x2', 'T' , tday, t1, t2, lli, 'n', levi, spm, temper, status )
call ReadField( tmmd, 'tmpp:od-fc-ml60-glb3x2', 'pu', tday, t1, t2, lli, 'u', levi, spm, pu , status )
!
! TMPP surface fields can be called using the 1x1 as well as the 3x2 key.
!
call ReadField( tmmd, 'tmpp:od-fc-sfc-glb1x1' , 'ci', tday, t1, t2, lli, 'n', ci, status )
call ReadField( tmmd, 'tmpp:od-fc-ml60-glb3x2', 'ci', tday, t1, t2, lli, 'n', ci, status )
!
! Similar for spm surface pressures:
!
call ReadField( tmmd, 'tmpp:od-fc-ml1-glb3x2' , 'spm', tday, t1, t1, lli, 'n', spm, status )
call ReadField( tmmd, 'tmpp:od-fc-ml60-glb3x2', 'spm', tday, t1, t1, lli, 'n', spm, status )
! *** output
call WriteField( tmmd, 'tmpp:od-fc-ml60-glb3x2', 'T', 'K', t1, t2, &
lli, 'n', levi, spm, temper, status )
! *** finish
call Done( tmmd, status )
call Done( levi, status )
call Done( levi_ec, status )
call Done( lli )
! -- end
!
! Meteo files are linked to or unpacked in a buffer directory.
! o Set the clean flag (T|F) such that files that have not been accessed
! for a long time are removed if a maximum buffer usage is exceeded.
! o specify a maximum size in Mb
!
tmm.dir : ${RUNDIR}/tmm-buf
tmm.dir.clean : T
tmm.dir.size : 500
!
! TMM requires keys on how to form meteo for a certain region.
! A key should be defined for each region, names are in 'dims_grid.F90'
! For example:
!
! tmpp:od-fc-ml60-glb3x2
! Read global 3x2, 60 level files produced by TMPP.
! Optionally, the meteo is combined over levels or grid cells.
! The files are expected to be present in the buffer directory
! specified below after 'tmm.buf.dir' .
! To have the appropriate files installed at the begin of a run,
! use the 'tmm.setup.*' stuff below.
!
! tmppS:od-fc-ml60-glb3x2
! Idem, but also calls a script to search for an appropriate file
! from within the fortran program.
! The system call to this script turned out to be rather slow.
! This source type should be avoided therefore, but might be
! very usefull in case of limitted disk space.
!
! prism:
! Receive meteo from the prism coupler.
!
tmm.sourcekey.glb6x4 : tmpp:od-fc-ml60-glb3x2
tmm.sourcekey.eur3x2 : tmpp:od-fc-ml60-glb3x2
tmm.sourcekey.eur1x1 : tmpp:od-fc-tropo25-eur1x1
!
! Meteo files could be setup before the actual program is started.
! Fill the following settings:
! o set the apply flag apply this feature or not (T|F)
! o specify a list of meteo files to be installed (spm,uvsp, etc)
! o specify a list of meteo sources (od-fc-ml60-glb3x2 etc)
! o specify wether message are printend or not (T|F)
!
tmm.setup.apply : T
tmm.setup.files : spm uvsp t q cld sub surf
tmm.setup.sources : od-fc-ml60-glb3x2
tmm.setup.verbose : T
!
! Archive(s) to be searched for monthly tar files.
! If more than one is specified (space seperated list),
! multiple directories are examined.
! o disk archives
! o tape archives ecfs/mos ('massive-storage-system')
!
tmm.search.disk : ${DATADIR}/meteo
tmm.search.mss : /nlh/TM/meteo
tmm.f90 : Main routines and collecting data structure.
Provides access to a list of open meteo files.
tmm_mf.f90 : Search, open, close a meteo file.
Calls shell script 'bin/tmm_getmeteo'.
Calls specific routines for hdf/etc files.
tmm_mf_hdf.f90 : Read fields from hdf files.
tmm_param.f90 : Parameter specific stuff:
what to do with temperature fields,
what to do with mass fluxes etc.