# -*- mode: shell-script -*- "This file is the set of commands that have to be included by CNRM-CM in a forced or coupled experiment job in order to post-process Arpege outputs the way EAC does it for Arpege global runs and Cordex runs. You tell CNRM-CM to do so simply by adding the path for the current file to variable PLUGINS (in the experiment 'param_' file). This will dispatch these commands to various stages of the run. See CNRM-CM doc for details From that point, you just have to set a few parameters in your CM param_ file. Comment for parameters meaning stand in the first few lines of [ PLUGIN_INSTALL ]. It is much wiser to change parameter values in your 'param_' file than generate a modified copy of the present file. If you must repeat that for a number of experiment, consider the solution of sourcing a fixed file that sets these values, from your param_ file This plugin modifies the standard behaviour of CNRM-CM forced mode on one point : unless asked for, there will be no raw outputs for Arpege nor Surfex (but only post-processed ones) For the post-processing steps, a dedicated working directory is used, which value is PATHWRK=$WORKDIR/POST_$EXPID (see further below)" ################################################################################# [ PLUGIN_PREINSTALL ] LATMOUT=${LATMOUT:-0} # Do not produce Arpege raw outputs unless explicitly requested LSFXOUT=${LSFXOUT:-0} # Do not produce Surfex raw outputs unless explicitly requested ################################################################################# [ PLUGIN_INSTALL ] # Setting postpro params to default values if not already set by the # 'param_' file. Here defaults values come in two sets : those fine # for global runs and traditional postprocessing binaries and those # relevant to CORDEX if [ "$STANDARD_CORDEX_POST" == 1 ] ; then # Post-processing step (inhours) NHH=3 # File provding the lat and on for all data points in the simulation ALL_LONLAT=${ALL_LONLAT:-~mrga589/bcond/lonlat_${GEOM}CI} NPT=$( cat $ALL_LONLAT | wc -l ) # Number of grid points for sub-domain 'E' NPE=$NPT #-List of fields to post-process LISTPP=~mrga589/aladin/cordex/diag/pp_${GEOM}_cordex # Script for counting various things from LISTPP compteur=~mrga589/bin/compte_champs.pl # Mask for local series (sub-domain 'F') MSKF=~mrga589/aladin/cordex/diag/france_0 # The list of global and hemispheric variables for time series will be constructed dynamically GVARS="" ; EVARS="" # Post-processing binaries (these ones allow tuning of variable renaming ) postM=~mrga589/bin/postM5c ; postG=~mrga589/bin/postG5c ; postE=~mrga589/bin/postE5c ; postL=~mrga589/bin/postF5c ; #-Specifying the directories where the diagnostics are saved # for the cordex-type outputs (they will be created) PATHM=nec/ifs/CORDEX/${EXPID}/MM ; PATHG=nec/ifs/CORDEX/${EXPID}/${NHH}H PATHE=nec/ifs/CORDEX/${EXPID}/DD ; PATHL=nec/ifs/CORDEX/${EXPID}/LIST else ALL_LONLAT=${ALL_LONLAT:-~/mrga602/bcond/lonlat_$GEOM} # Compute number of points in the total domain NPT=$(cat $ALL_LONLAT | wc -l ) # Number of grid points for sub-domain 'E' NPE=$(( $NPT/2 )) # but one could take NPE=$NPT as well #-List of fields to post-process LISTPP=${LISTPP:-~mrga602/arpege/pp_$GEOM} # Global latlon file GLOB_LONLAT=${GLOB_LONLAT:-~/mrga602/bcond/lonlat_$GEOM} # Mask for local series MSKF=${MSKF:-~mrga602/bcond/france_$GEOM} # Script for counting various things from LISTPP compteur=${compteur:-~mrga561/perlscripts/compte_champs.pl} # Postprocessing time step (in hours) NHH=${NHH:-6} # Post-processing binaries postL=${postL:-~mrga561/library/postF5a} ; postM=${postM:-~mrga561/library/postM5a} postE=${postE:-~mrga561/library/postE5a} ; postG=${postG:-~mrga561/library/postG5a} # List of processed variables out of global and hemispheric post-pro GVARS=${GVARS:-"TMIN TMAX PREC Z500 PMER"} EVARS=${EVARS:-"TSUR SMOI SNOW TAUX TAUY CLFR NSWR NLWR DSWR DLWR LATH EVAP SENH RUNO UW10 VW10 TCLS RCLS QCLS WMAX PSUR"} #-Specifying the directories where the diagnostics are saved (they will be created) PATHM=${PATHM:-nec/ifs/sorties/$EXPID} # monthly means PATHG=${PATHG:-nec/ifs/series/$EXPID} # global series PATHE=${PATHE:-nec/ifs/prudence/$EXPID} # "hemispheric" series PATHL=${PATHL:-nec/ifs/regclim/$EXPID} # local series fi # All parameters that could be set stand before this line #--------------------------------------------------------- # Verifying that input files and binaries do exist for file in $MSKF $GLOB_LONLAT $LISTPP ; do [ ! -f $file ] && err=1 && echo "File $file does not exist" >> $$.diag done for file in $postL $postE $postG $postM ; do [ ! -x $file ] && err=1 && echo "Issue with binary $file (not executable)" >> $$.diag done # Updating NFRPOS, NFRCORM and NFRRAZ in Arpege Namelist using NHH TSTEP=$(get_timestep arpege $RELEXP/$ATMNAM) NFRPOS=$(( NHH * 3600 / TSTEP )) change_var_in_namelist $RELEXP/$ATMNAM NFRPOS $NFRPOS arpege [ $LMSE -eq 1 ] && change_var_in_namelist $RELEXP/$ATMNAM NFRSFXHIS $NFRPOS arpege # xxx EAC/reg apply mass correction once per day . EAC/glob once per NFRPOS NFRCORM=$(( 86400 / TSTEP )) change_var_in_namelist $RELEXP/$ATMNAM NFRCORM $NFRCORM arpege change_var_in_namelist $RELEXP/$ATMNAM NFRRAZ $NFRPOS arpege # xxx revoir les mises à jour basées sur NPROC # Creating the directories on archive machine (should be useless from may 2012 at MF) > cmd_mkdir for dir in $PATHM $PATHG $PATHE $PATHL ; do $TOOL/cree_arbo.sh $dir cmd_mkdir ; done $FTP $ARCHIVE < cmd_mkdir | grep -v "Create directory operation failed." rm cmd_mkdir # Letting all steps know about some variables cat <> $RELEXP/$EXPID.conf # Variables used by plugin atm_post NHH=$NHH MSKF=$MSKF GLOB_LONLAT=$GLOB_LONLAT LISTPP=$LISTPP compteur=$compteur PATHM=$PATHM PATHG=$PATHG PATHE=$PATHE PATHL=$PATHL GVARS="$GVARS" EVARS="$EVARS" postM=$postM postE=$postE postL=$postL postG=$postG NPT=$NPT NPE=$NPE EOF ################################################################################# [ PLUGIN_FETCH ] ################################################################################# [ PLUGIN_COMPUTE_INIT ] # Number of grid points in the local series NPF=$( cat $MSKF | wc -l ) # Setting environment variables for post-pro binaries (NFO,NFM,NFT, # NFC,NFG,NFE,NFF) from analysis of the list of fields to process eval $($compteur < $LISTPP ) # Creating transient directories and letting ftput step know about it PATHWRK=$WORKDIR/POST_$EXPID PATHSOM=$PATHWRK/moyennes PATHSOG=$PATHWRK/series PATHSOE=$PATHWRK/prudence PATHSOL=$PATHWRK/regclim for d in $PATHSOM $PATHSOG $PATHSOE $PATHSOL ; do mkdir -p $d ; done #MTOOL broadcast id=ftput vars=PATHWRK,PATHSOM,PATHSOG,PATHSOE,PATHSOL # Linking binaries for post-processing ln -sf $postM postM ; ln -sf $postG postG ; ln -sf $postE postE ; ln -sf $postL postL ln -sf $MSKF local_domain ; ln -sf $LISTPP fort.40 # xxx Dans MAD12 : #export DR_HOOK_NOT_MPI=1 #export MPIEXPORT="F_RECLUNIT,F_PROGINF,F_FILEINF,MPIPROGINF,MPISUSPEND,F_SETBUF,F_ERRCNT,DR_HOOK,DR_HOOK_IGNORE_SIGNALS,DR_HOOK_SILENT,EC_PROFILE_HEAP,DR_HOOK_NOT_MPI" ################################################################################# [ PLUGIN_COMPUTE_AFTER ] # Applying each post-processing binary to Arpege outputs for one month # Renaming Arpege outputs for postM rm PF0123000+0000 ; XFIC=0 for f in PF0123000+* ; do XFIC=$((XFIC+1)); typeset -Z6 CFIC=$XFIC ; ln -sf $f F$CFIC ; done echo $NFO $NFM $XFIC $NPT $NHH | ./postM || ERROR mv FICM $PATHSOM/PL${EXPID}.M$YEAR$MONTH echo "$NFO $NFT $NFC $XFIC $NPT $NPE $NPF $NHH" | ./postL || ERROR mv FICF $PATHSOL/S$EXPID$YEAR$MONTH rm F000??? echo "$NFO $NFG $XFIC $NPT $NHH $YEAR $MONTH $EXPID" | ./postG || ERROR if [ -z $GVARS ] ; then for CFLD in $(ls G_*$EXPID$YEAR$MONTH) ; do mv $CFLD $PATHSOG/$(echo $CFLD | awk -FG_ '{print $2}') done else for CFLD in $GVARS ; do mv $CFLD$EXPID$YEAR$MONTH $PATHSOG ; done ; fi rm FICG echo "$NFO $NFE $XFIC $NPE $NHH $YEAR $MONTH $EXPID" | ./postE || ERROR if [ -z $EVARS ] ; then for CFLD in $(ls E_*$EXPID$YYMMDATE) ; do mv $CFLD $PATHSOE/$(echo $CFLD | awk -FE_ '{print $2}') done else for CFLD in $EVARS ; do mv $CFLD$EXPID$YEAR$MONTH $PATHSOE ; done ; fi rm FICE ################################################################################# [ PLUGIN_PUT_LOOP ] ( cd $PATHSOM # Archiving monthly means in PL format $FTPUT PL${EXPID}.M$YEAR$MONTH $PATHM/PL${EXPID}.M$YEAR$MONTH rm PL${EXPID}.M$YEAR$MONTH ) # If we have reached december, or job end, the series are gathered # in yearly files and archived. Processing one year in multiple # jobs should work if [ $MONTH -eq 12 -o $AT_END -eq 1 ] then ( cd $PATHSOG for CFLD in $(ls *${EXPID}${YEAR} |awk -F${EXPID} '{print $1}' |uniq) do tar cvf $CFLD$EXPID$YEAR.tar $CFLD$EXPID$YEAR?? rm $CFLD$EXPID$YEAR?? $FTPUT $CFLD$EXPID$YEAR.tar $PATHG/$CFLD$EXPID$YEAR.tar rm $CFLD$EXPID$YEAR.tar done cd $PATHSOE for CFLD in $(ls *${EXPID}${YEAR} |awk -F${EXPID} '{print $1}' |uniq) do tar cvf $CFLD$EXPID$YEAR.tar $CFLD$EXPID$YEAR?? rm $CFLD$EXPID$YEAR?? $FTPUT $CFLD$EXPID$YEAR.tar $PATHE/$CFLD$EXPID$YEAR.tar rm $CFLD$EXPID$YEAR.tar done cd $PATHSOL tar cvf S$EXPID$YEAR.tar S$EXPID$YEAR?? rm S$EXPID$YEAR?? $FTPUT S$EXPID$YEAR.tar $PATHL/S$EXPID$YEAR.tar rm S$EXPID$YEAR.tar ) fi