Chapter 5
Model preprocessor
This chapter will describe the model preprocessors and the related source code. This code will allow the user to easily check or change things that need to done in a different way from the original design. Some major points of how to create the preprocessor files will be addressed. Hopefully, users will now be able to easily find the starting point of the preprocessor, which may be very important.
There are two major input files, sigma and surface file, which are also called the restart files. In order to prepare the restart files, the terrain related files have to be prepared. Some concepts and example of data analysis and assimilation to be used for the model preparation are also discussed.
5.1 Prepare model terrain file and related code
There are two global terrain or topography data files in this package, however, if you have your own, which may be higher resolution than what we have provided, you can follow this section to locate the source file and scripts to prepare it for the model.
The related files and the process to get terrain files created are as follows.
script file: $DISK/common/script/PRMTN #! /bin/sh cd $DIRRMTN rm -rf topodata* cp $TOPODATA topodata.Z && uncompress topodata.Z cp $DIRHOME/LOCRSM rsmlocation # $FILEENV $ASSIGN topodata $FILEFORM ${UNIT}11 $ASSIGN $rmtnslm $FILEFORM ${UNIT}51 $ASSIGN $rmtnoro $FILEFORM ${UNIT}52 $ASSIGN $rmtnvar $FILEFORM ${UNIT}53 $ASSIGN $rmtnors $FILEFORM ${UNIT}54 $ASSIGN $rmtnoss $FILEFORM ${UNIT}55 rmtnexec=$DIREXEC/rmtn.x $rmtnexec <rsmlocation >stdout.rmtn cat stdout.rmtn rm -rf ${UNIT}* topodata include file : $DISK/common/include/INCRMTN %INCLUDE DCLSYS ; %INCLUDE DCLRFCST ; %INCLUDE CONSTANT; %INCLUDE DCLFULL; %INCLUDE MAINRMTN; %INCLUDE RSSETGRD; %INCLUDE RSSHLFIO; %INCLUDE RSSUMSFB; %INCLUDE RSTRANS; %INCLUDE RSNFSNFA; %INCLUDE RSMAXMIN; %INCLUDE FFT99M; topo dataset : $DISK/common/fmtdata/topo05.fmt.Z $DISK/common/fmtdata/navy10.fmt.Z do compilation by : $DISK/[machine]/[exp]/run[case] cmpl with RDMTN=yes in run[case] after DCLSYS is defined. executable file : $DISK/run/[exp]exec/rmtn.x create terrain : $DISK/[machine]/[exp]/run[case] rmtn after LOCRSM is defined. output files : $DISK/run/[exp]/rmtn/ rmtnslm : sea land mask rmtnvar : mountain variance rmtnoro : interpolated terrain grid value rmtnors : spectral transformed grid rmtnoss : Lanczos smoothed grid value main source file : $DISK/common/source97/MAINRMTN related code files : can be seen from INCRMTN as
where [machine] can be sgi, dec, sun or hp etc, [exp] can be g2n97, g2r97, or c2n97 etc, [case] can be g2n, g2r, etc. Then let's go into the code structure.
Code tree: see $DISK/common/source97/MAINRMTN main subroutines MOUNTAIN - SETGRD : set latitude/longitude DEFG2R : define data location for each grid GETNAVY : get NAVY10 data or GETNETP5 : get TOPO05 data ---------> obtained rmtnslm, rmtnoro, rmtnvar PLNINI : define constants for spectral trans in y RFTINI : define constant for FFT in x MAXMIN : show maximum and minimum of a field FFACOS : grid to coefficient by FFT in x SUMGGC : then summation in y to get final spectral SUMFFC : sum coefficient in y to get grid FFSCOS : do FFT in x to get grid ---------> obtained rmtnors LNCZS : apply Lanczos smooth SUMFFC : sum coefficient in y to get grid FFSCOS : do FFT in x to get grid ---------> obtained rmtnoss SHALFO : shulfer model grid to regular grid ---------> write out
For example, in $DISK/sgi/g2n97, we define DCLSYS and LOCRSM, then run the command 'rung2n cmpl' and make sure rmtn.x in $DISK/run/g2n97/exec, then use the command 'rung2n rmtn', and make sure rmtnvar etc is in $DISK/run/g2n97/rmtn.
There is a general rule, no matter which file you want to change in $DISK/common for a special experiment for compilation. You must first copy this file from the common place, then modify the file, but DO NOT CHANGE ITS NAME, it will be the one used the one in your directory. For example, suppose you want to change the source code MAINRMTN so that it can be used to read different topography data. First copy this file from $DISK/common/source97 to your directory, and make the change. Once you do 'rung2n cmpl', for example, the script PCMPL in $DISK/common/script will first go to the common place first, and then go to your directory to overwrite MAINRMTN in a temporary place and do the compilation for you.
5.2 Preparing the sigma file from a different source
This section could be explained along with the next section, but since the file type is different and you may need to use a different method. So far, this model has used the global files from NCEP, CWB and EC data. Since we know the structure of the sigma file in the last chapter and since we know the data we want to read, we should be able to write a file for the model to read. There is a trick if you cannot easy to provide a global file which needs to be provided in spectral coefficient for the g2n or g2r experiments. The trick is that the file structure must have the same structure as the global model but only a coarse grid mesh is needed. If the data has grid-point values instead of spectral coefficients, you can simple apply use c2n or c2r programs. Remember that you have to make the initial data and forecast data in the coarse grid mesh and the file structure and grid definitions should be the same as the one now used.
Let's start from a general approach and then walk through the elements of the input processor.
main source file: $DISK/common/source97/MAINRINP related code file : can be seen from the include file include file : $DISK/common/include/INCRINP %INCLUDE DCLGSM ; %INCLUDE DCLSYS ; %INCLUDE DCLRFCST; %INCLUDE DCLRINP ; %INCLUDE CONSTANT; %INCLUDE DCLFULL; %INCLUDE DCLFCST; %INCLUDE DCLRINP; %INCLUDE MAINRINP; %INCLUDE RSG2RINP; %INCLUDE RSS2RINP; %INCLUDE RSR2RINP; %INCLUDE RSRCHGR; %INCLUDE RSSETGRD; %INCLUDE RSSETSIG; %INCLUDE RSSPHPT; %INCLUDE RSSPHQK; %INCLUDE RSGG2RG; %INCLUDE RSGGTORG; %INCLUDE RSGGTOBG; %INCLUDE RSCG2RG; %INCLUDE RSCGTORG; %INCLUDE RSCGTOBG; %INCLUDE RSEXPAND; %INCLUDE RSLLTOXY; %INCLUDE RSREGIO; %INCLUDE RSPINT3; %INCLUDE RSSHLFIO; %INCLUDE RSTRANS; %INCLUDE RSSUMSFB; %INCLUDE RSNFSNFA; %INCLUDE RSRMSGT; %INCLUDE RSFPLFML; %INCLUDE RSMAXMIN; %INCLUDE GLATS; %INCLUDE FFTAEV2; %INCLUDE LUPASUBS; %INCLUDE INDIBMCR; %INCLUDE SUMSGENP; %INCLUDE SUMTOP; %INCLUDE GOZRIM; %INCLUDE TIO; %INCLUDE RMST; %INCLUDE FFT99M; where files before MAINRINP are definition in $DISK/common/definition, after it are all in $DISK/common/source97. do compilation : $DISK/[machine]/[exp]/run[case] cmpl with RINPT=yes in run[case] executable file : $DISK/run/[exp]/exec/rinp.x define namelist : in $DISK/[machine]/[exp]/run[case], there is a block as echo " &NAMRIN " >rinpparm echo " SIG2RG=.TRUE.,SFC2RG=.FALSE.,PERCMTN=0.2, " >>rinpparm echo " NEWSIG=.FALSE.,NEWMTN=.TRUE.,NEWHOR=.FALSE.," >>rinpparm echo " &END " >>rinpparm which has to be defined before run rinp, the MEANING of them has been described in chanpter 3. The example here shows there is a need to run sigma file preparation only, thus only two are true, one is SIG2RG and NEWMTN. script file : $DISK/common/script/PRINP #! /bin/sh set -x NEWMTN=${NEWMTN:-FALSE} ## Prepare regional spectral model input ## mtnvar=$DIRCONS/mtnvar.$WAVINP $FILEENV $ASSIGN $mtnvar $FILEFORM ${UNIT}10 $ASSIGN siganl $FILEFORM ${UNIT}11 $ASSIGN sfcanl $FILEFORM ${UNIT}12 $ASSIGN $rmtnslm $FILEFORM ${UNIT}13 $ASSIGN $rmtnoss $FILEFORM ${UNIT}14 $ASSIGN $rmtnvar $FILEFORM ${UNIT}15 $ASSIGN r_sigtmp $FILEFORM ${UNIT}51 $ASSIGN r_sfctmp $FILEFORM ${UNIT}52 $ASSIGN r_sigi $FILEFORM ${UNIT}61 $ASSIGN r_sfci $FILEFORM ${UNIT}62 rinpexec=$DIREXEC/rinp.x cp $DIRHOME/LOCRSM rsmlocation cat rinpparm rsmlocation >stdinp.rinp $rinpexec <stdinp.rinp >stdout.rinp || exit 1 if [ $NEWMTN = FALSE ] then cp r_sigtmp r_sigi || exit 2 cp r_sfctmp r_sfci || exit 3 fi echo "PRINP exit normally.........." : where all $ variables are defined in run script. As mentioned before, this script is for sigma and surface files preparation. But it is flexible that it can be used for sigma file with or without new regional mountains, or surface file etc, and for g2n, g2r, c2n or c2r. run it : $DISK/[machine]/[exp]/run[case] rinp input files : $DISK/[machine]/condata/mtvar.126 or 62 the above is for g2r or g2n. $DISK/run/[exp]/dirrun/siganl and/or sfcanl $DISK/run/[exp]/rmtn/rmtnslm .... output files : $DISK/run/[exp]/dirrun/r_sigtmp r_sfctmp if NEWMTN=.FALSE. or r_sigi r_sfci if NEWMTN=.TRUE. Code tree : REGINP - for g2n or g2r G2RINP - SETGRD - GLATS - G2RINI - GTOINI - CMPIND - GFT_LONF - GPLN2I - EPSILO - GGOZRM [ get map factor over globe - PLN2I - FTI_LONF - FPLFML - FL2I } - SPHQK1 - SPHQK2 [ read global spectral coefficent ] - DZUVLE [ add map factor into u/v - PLN2I - SUMS2I - SUMTOP - FTI_LONF - FTI_LONF - FPLFML - FL2I ] - SPHQK1 - RWRITE S2RINP - SETGRD - GLATS - G2RINI get sea land ice mask first read each field and - EXPND sea field - EXPND land field - GG2RG sea field - GG2RG land field merge them together - SHALFO write each field for c2n or c2r C2RINP - SETGRD - C2RINI - CTORINI prepare map factor - SHALFO - TODXDY - SHALFI read coarse regional sigma file - CGTORG for map factor define wind direction transformation - LL2XY - XY2LL change u/v to new projection direction - MAXMIN - CG2RG for precipitation (not necessary) - RWRITE S2RINP : as the same as above but CG2RG. for NEWSIG or NEWMTN RCHGR - RREAD - RSETSIG [ if new sig - NEWSIG - RSETSIG ] [ if new mountain read the new terrain data - SHALFI blending the mountain along lateral boundary zone modify the changes with spectral smoothing - PLNINI - RFTINI get perturbation - GDTOCC - CCTOGD get full field ] - EXTRAP - NEWPS - SG2SG - TRISPL - VALTS check extrapolated value etc - RWRITE the remain for horizontal resolution change not yet implemented but dummy replacement there.
in $DISK/common/source97/RSG2RINP and RSGS2BG
_____________________________________________________
change from
CALL DZUVLE(DI,ZE,ULN,VLN,UVTOP(1,1,1),UVTOP(1,1,#LEVS+1))
to
##DZ CALL DZUVLE(DI,ZE,ULN,VLN,UVTOP(1,1,1),UVTOP(1,1,#LEVS+1)) ##UV DO K=1,KMAX ##UV DO J=1,MAXWV2 ##UV ULN(J,K)=DI(J,K) ##UV VLN(J,K)=ZE(J,K) ##UV ENDDO ##UV ENDDO
____________________________________________________________
and change from (inside of loop 2000 for RSG2RINP & 1000 for RSGS2BG)
CALL SUMTOP(SYN(1,1),UVTOP,QVV,KMAX*2,#LONF,#LONF/2)
to
##DZ CALL SUMTOP(SYN(1,1),UVTOP,QVV,KMAX*2,#LONF,#LONF/2)
_____________________________________________________________
and change from (inside of loop 2000 for RSG2RINP & 1000 for RSGS2BG)
COSLAT = COS( HFPI - COLRAD(LAT) ) RCSLT = 0.0 IF( COSLAT.NE.0.0 ) RCSLT = 1. / COSLAT KM2P1 = KMAX*2 + 1 DO 270 J=1,#LONF2 SYN(J, KM2P1) = SYN(J, KM2P1) * RCSLT 270 CONTINUE
to
##DZ COSLAT = COS( HFPI - COLRAD(LAT) ) ##DZ RCSLT = 0.0 ##DZ IF( COSLAT.NE.0.0 ) RCSLT = 1. / COSLAT ##DZ KM2P1 = KMAX*2 + 1 ##DZ DO J=1,#LONF2 ##DZ SYN(J, KM2P1) = SYN(J, KM2P1) * RCSLT ##DZ ENDDO
% ##DZ = 'C-DZ'; % ##UV = ' ';
in DCLSYS , thus you can read global files for the model with u/v coefficient. But if you want to read global file with div/vor coefficient, you have to define as
% ##DZ = ' '; % ##UV = 'C-UV';
Finally, if you don't know how to prepare spectral coefficient data from any grid point data, say Gaussian grid or equal latitude/ longitude grid. You can use the model related projection, interpolated to your Gaussian or lat/lon grid to the model related grid. Of course, the grid should be about the same resolution as the global data resolution and the domain should be large enough to cover the regional fine mesh. How large? You have to cover the fine mesh domain with at least three extra coarse scale grid points outside the regional domain. The related definition of the regional model related projection in RSSETGRD and the interpolation is done in RSGG2RG or RSGGTORG. Note that RSGG2RG uses bi-linear interpolation; RSGGTORG uses bi-cubic interpolation.
5.3 Prepare surface file from different source
Users should refer to the previous section to locate the resource to do the preparation of the surface files, however, the namelist and input files can be have only surface parts, such as
define namelist: in $DISK/[machine]/[exp]/run[case], there is a block as echo " &NAMRIN " >rinpparm echo " SIG2RG=.FALSE.,SFC2RG=.TRUE.,PERCMTN=0.2, " >>rinpparm echo " NEWSIG=.FALSE.,NEWMTN=.FALSE.,NEWHOR=.FALSE.," >>rinpparm echo " &END " >>rinpparm which has to be defined before run rinp, the MEANING of them has been described in chanpter 3. The example here shows there is a need to run surface file preparation only, thus only one is true, SFC2RG. input files : $DISK/[machine]/condata/mtvar.126 or 62 the above is for g2r or g2n. $DISK/run/[exp]/dirrun/sfcanl $DISK/run/[exp]/rmtn/rmtnslm .... output files : $DISK/run/[exp]/dirrun/r_sfctmp if NEWMTN=.FALSE. or r_sfci if NEWMTN=.TRUE.
Even though all other definitions and commands are the same as in the previous section, some of the source code and script commands there are not necessary for the surface preparation.
Finally, if you don't know how to prepare Gaussian grid data from any grid point data, say equal latitude/ longitude grid. You can use the model related projection, interpolated your lat/lon grid to the model related grid, of course the grid should be about the same resolution as the global data resolution and the domain should be large enough to cover the regional fine mesh. See previous section for how large a grid is needed. The related definition of the regional model related projection is in RSSETGRD and the interpolation is in RSGG2RG or RSGGTORG. Note that RSGG2RG uses bi-linear interpolation; RSGGTORG uses bi-cubic interpolation.
5.4 Data analysis and assimilation
The current version doesn't have portable data assimilation, since the workable version is Cray version or FORTRAN f90 version. Since data assimilation requires so many observed data and it can read only GRIB or BUFFER types of files. If you are one of the specific users that really needs data assimilation, please don't hesitate to ask (see chapter 1 for details about how to contact us).
The Cray version of data assimilation contains two parts. One is the grid point version of spectral statistical interpolation with dynamic constraint and background error; the other part is the surface cycling program, which replaced all the possible surface conditions, such as albedo, ice/snow coverage, sea surface temperature, soil moisture and temperature, vegetation, roughness etc. Since the mesoscale features are most likely related to surface conditions, we suggest all the users try to use a higher resolution surface condition before jumping into atmospheric data assimilation, especially since the atmospheric data may not be sufficient for high resolution mesoscale modeling.
webmaster: Hann-Ming Henry Juang
henry.juang@noaa.gov