#---------------------------------------------------------------------------- # Script to interpolate ENSEMBLES model level data (atchived in MARS) # to pressure levels # # Structure: # 1. general settings (directories, data specifications etc) # 2. get model level data from MARS # 3. resort model level grib files # 4. interpolate model level data to pressure levels using cdo # 5. adapt GRIB headers # 6. resort interpolated grib files # # Uses: # cdo - the Climate Data Operators, a collection of useful command # line operators to manipulate and analyse climate data files; # maintained by Uwe Schulzweida from MPI Hamburg; # see also: www.mpimet.mpg.de/~cdo/; # can be used on ecgate, leda and metis # Note: Please change your PATH variable accordingly, # i.e., PATH=/home/ms/spdesvhc/hcu/local/bin:$PATH # # Own modifications: # - loadleveler output and error directories # - WDIR for working directory # - MARS directory # - PARAM, DATE, TIME, STEP according to data # - EXPVER (provided by ECMWF) # - PL for pressure levels you wish to interpolate to # # Antje Weisheimer # July 2005 #-------------------------------------------------------------- cat<<\EOJ>job_ml2pl #!/bin/ksh # #................................................................. # Job to interpolate ENSEMBLES model level data to pressure levels #................................................................. # # ---------------------------------------------------- # Setting up the parameters for loadleveler # ---------------------------------------------------- #@ shell = /usr/bin/ksh # Specifies the shell that parses the script. If not # specified, your login shell will be used. # #@ Class = express # Specifies that your job should be run in the normal # class (queue). # Options: normal - default class # express - suitable for short jobs # long - suitable for long and/or large jobs # #@ job_name = ml_to_pl # Assigns the specified name to the request # #@ job_type = serial # Specifies that your job is serial. Note that when you # specify job_type=serial, you cannot specify the following # keywords: node, tasks_per_node and total_tasks. # Other option: np, which is used to run parallel jobs. # #@ output = /home/rd/ne4/waitqueue/$(job_name).$(host).$(jobid).out # Specifies the name and location of STDOUT. If not # given, the default is /dev/null. The file will be # written in the submitting directory, by default. # #@ error = /home/rd/ne4/waitqueue/$(job_name).$(host).$(jobid).err # Specifies the name and location of STDERR. If not # given, the default is /dev/null. The file will be # written in the submitting directory, by default. # ##@ environment = COPY_ALL # Specifies that all environment variables from your # shell should be used. You can also list individual # variables which should be separated with semicolons. # #@ notification = error # Specifies that email should be sent in case the job # fails. # Other options include always, complete, start, and # never. The default is notification = complete. # ##@ cpu_limit = 06:00:00 # Specifies the (hard) limit for the CPU time to be # used by each individual process of a job step. # #@ restart = no # Avoids or not the restart of a job if it fails. # If restart=yes, which is the default, and the job # is vacated from its executing machine before completing, # the central manager requeues the job. It can start # running again when a machine on which it can run # becomes available. If restart=no, a vacated job is # canceled rather than requeued. # #@ queue # Places your job in the queue. It must be the last # keyword specified. Any keywords placed after this in # the script are ignored by the current job step # # ---------------------------------------------------- # End of parameters for loadleveler # ---------------------------------------------------- # # if you want an expanded output, use the following: #set -evx # #----------------------------------------------------- # 1. general settings #----------------------------------------------------- # # working directory if [ ! -d ${SCRATCH}/ENS/ml2pl ] ; then mkdir -p ${SCRATCH}/ENS/ml2pl fi typeset -rx WDIR=${SCRATCH}/ENS/ml2pl # MARS directory if [ ! -d ${WDIR}/mars ] ; then mkdir ${WDIR}/mars fi typeset -rx MARS_DIR=${WDIR}/mars # parameter typeset -rx PARAM=130 # date typeset -rx DATE=19910101 # time typeset -rx TIME=00 # step typeset -ix STEP # step_end typeset -irx STEP_END=4416 # ensemble member typeset -irx NUM=0 # experiment version typeset -rx EXPVER=emu2 # requiered pressure level in hPa typeset -irx PL=1000 # MARS output file typeset -rx MARS_OUTPUT_ml="${WDIR}/${PARAM}_${DATE}_${TIME}_ens${NUM}_ml.grb" if [ -a ${MARS_OUTPUT_ml} ] ; then rm -f ${MARS_OUTPUT_ml} fi # cdo output file # extrapolate missing values on typeset -rx EXTRAPOLATE=1 typeset -rx CDO_OUTPUT_ml=${WDIR}/${PARAM}_${DATE}_${TIME}_ens${NUM}_${PL}hPa_ml_cdo.grb if [ -a ${CDO_OUTPUT_ml} ] ; then rm -f ${CDO_OUTPUT_ml} fi #...........................................START......................................... #----------------------------------------------------- # 2. retrieve all model level data from MARS (cdo require grid point data) #----------------------------------------------------- cat > ${MARS_DIR}/mars_req_ml << EOF_ml retrieve, class=rd, stream=seas, expver=${EXPVER}, type=fc, method=1, repres=gg, grid=48, gaussian=reduced, resol=av, levtype=ml, levelist=1/to/40, param=${PARAM}, number=${NUM}, date=${DATE}, time=${TIME}, step=12/to/${STEP_END}/by/12, target="${MARS_OUTPUT_ml}" retrieve, levelist=1, param=129/152 EOF_ml mars ${MARS_DIR}/mars_req_ml #----------------------------------------------------- # 3. re-sort fields for each step (required for cdo) #----------------------------------------------------- # ...first step cat > ${MARS_DIR}/mars_resort_ml << EOF read, source="${MARS_OUTPUT_ml}", levelist=1/to/40, param=${PARAM}, step=12, target="${MARS_OUTPUT_ml}_sort" read, levelist=1, param=129/152 EOF # ...remaining steps STEP=24 while [ ${STEP} -le ${STEP_END} ] ; do cat >> ${MARS_DIR}/mars_resort_ml << EOF read, levelist=1/to/40, param=${PARAM}, step=${STEP} read, levelist=1, param=129/152 EOF STEP=STEP+12 done # while mars ${MARS_DIR}/mars_resort_ml #----------------------------------------------------- # 4. interpolate from model levels to pressure levels #----------------------------------------------------- cdo ml2pl,${PL}00 ${MARS_OUTPUT_ml}_sort ${CDO_OUTPUT_ml} #----------------------------------------------------- # 5. adopt the GRIB headers #----------------------------------------------------- cat > ${MARS_DIR}/nam_chhea << EOF &USHEAD IUSEC1(24)=1, IUSEC1(37)=15, IUSEC1(38)=2, IUSEC1(39)=9, IUSEC1(40)=1090, IUSEC1(42)=0, IUSEC1(43)=0, IUSEC1(44)=0, IUSEC1(45)=1, IUSEC2(4)=88572, IUSEC2(7)=-88572, IUSEC2(8)=358125, IUSEC2(10)=48, CNMEXP='${EXPVER}' / EOF mv ${CDO_OUTPUT_ml} ${MARS_DIR}/grib_in modify_grib -d -n ${MARS_DIR}/nam_chhea -i ${MARS_DIR}/grib_in -o ${CDO_OUTPUT_ml}_dummy #----------------------------------------------------- # 6. sort out just the one interesting field in grib file #----------------------------------------------------- cat > ${MARS_DIR}/mars_sort_ml << EOF read, source="${CDO_OUTPUT_ml}_dummy", levtype=pl, levelist=${PL}, param=${PARAM}, target="${CDO_OUTPUT_ml}" EOF mars ${MARS_DIR}/mars_sort_ml #----------------------------------------------------- # tidy up a bit #----------------------------------------------------- #rm -rf ${MARS_OUTPUT_ml}_sort rm -rf ${CDO_OUTPUT_ml}_dummy eoj EOJ #----------------------------------------------------------------- llsubmit job_ml2pl exit 0