From 6dd7d588280100759208f10be95ed0fe41d62cf3 Mon Sep 17 00:00:00 2001 From: Tracy Date: Tue, 3 Nov 2020 16:31:08 -0700 Subject: [PATCH] Modified UPP stand-alone run script with name change to run_upp --- scripts/{run_unipost => run_upp} | 289 +++++++++++-------------------- 1 file changed, 105 insertions(+), 184 deletions(-) rename scripts/{run_unipost => run_upp} (58%) diff --git a/scripts/run_unipost b/scripts/run_upp similarity index 58% rename from scripts/run_unipost rename to scripts/run_upp index a755e2b59..362d25ca1 100755 --- a/scripts/run_unipost +++ b/scripts/run_upp @@ -19,47 +19,40 @@ set -x # October 2019: Modified for new unified build system; # ndate.exe and copygb.exe have been removed # +# October 2020: Modified to remove WRF and grib1; Add FV3LAM +# Updates for cmake build, Change exec name +# #-------------------------------------------------------- # -# This script runs the community version of UPP, unipost.exe +# This script runs the stand-alone community version of UPP, ncep_post # #-------------------------------------------------------- #---------------------------------------------------------------------------------- #--- USER EDIT DESCIPTIONS -------------------------------------------------------- # See UPP User's Guide for more information -# http://www.dtcenter.org/upp/users/docs/user_guide/V4/upp_users_guide.pdf +# https://upp.readthedocs.io/en/ufs-v2.0.0/ #---------------------------------------------------------------------------------- -# TOP_DIR : Top level directory for source codes (UPPV4.0) +# TOP_DIR : Top level directory for building and running UPP # DOMAINPATH : Working directory for this run. -# UNIPOST_HOME : Where the UPP build directory located -# POSTEXEC : Where the UPP executables are located -# SCRIPTS : Where the UPP scripts directory is (i.e. UPPV4.0/scripts/) -# modelDataPath : Where are the model data files to be processed located -# e.g. "wrfprd/" for WRF-based runs -# FV3 model filename examples (may need to alter in script) -# inFileName=dynf012.nemsio (default) or gfs.t00z.atmf012.nemsio -# flxFileName=phyf012.nemsio (default) or gfs.t00z.sfcf012.nemsio -# paramFile : Name and location of cntrl.parm file (wrf_cntrl.parm) -# Text file lists desired fields for grib1 output. Template in UPPV4.0/parm/ -# txtCntrlFile : Name and location of post flat file (postxconfig-NT.txt) for grib2 -# Text file listing desired fields to be generated by the user before running UPP. -# Step 1: Edit postcntrl.xml to include desired fields (template in UPPV4.0/parm) -# Step 2: Validate postcntrl.xml and post_avblflds.xml -# Step 3: Type 'make' in parm directory to generate the post flat file -# dyncore : What model is used ARW (WRF) or FV3 (GFS) +# UNIPOST_HOME : Location of the EMC-post directory +# POSTEXEC : Location of the UPP executable +# modelDataPath : Location of the model output data files to be post-processed +# txtCntrlFile : Name and location of the flat text file that lists desired fields for output +# GFS: postxconfig-NT-GFS-F00.txt (0-hour lead) and postxconfig-NT-GFS.txt (all other +# leads) +# LAM (Limited Area Model): postxconfig-NT-fv3lam.txt +# model : What model is used? GFS or LAM (Limited Area Model) # inFormat : Format of the model data -# arw - "netcdf" -# fv3 - "binarynemsiompiio" or "netcdf" +# GFS - "binarynemsiompiio" or "netcdf" +# LAM - "netcdf" # outFormat : Format of output from UPP -# grib (WRF only) # grib2 # startdate : Forecast start date (YYYYMMDDHH) # fhr : First forecast hour to be post-processed # lastfhr : Last forecast hour to be post-processed # incrementhr : Increment (in hours) between forecast files # * Do not set to 0 or the script will loop continuously * -# domain_list : List of domains for run # RUN_COMMAND : System run command for serial or parallel runs, examples below. # #---------------------------------------------------------------------------------- @@ -68,42 +61,36 @@ set -x # Set relevant paths and data information # This script assumes you created a directory $DOMAINPATH/postprd -# and that your model output is in $DOMAINPATH/wrfprd # as recommended in the users guide where UPP will output. export TOP_DIR=/home/username -export DOMAINPATH=${TOP_DIR}/DOMAINS/test_case -export UNIPOST_HOME=${TOP_DIR}/UPPV4.0 -export POSTEXEC=${UNIPOST_HOME}/exec -export SCRIPTS=${UNIPOST_HOME}/scripts -export modelDataPath=${DOMAINPATH}/wrfprd -export paramFile=${DOMAINPATH}/parm/wrf_cntrl.parm # grib1 (WRF only) -export txtCntrlFile=${DOMAINPATH}/parm/postxconfig-NT-WRF.txt # grib2 (or postxconfig-NT-GFS.txt) - -# Specify Dyn Core (ARW or FV3 in upper case) -export dyncore="ARW" - -# Set input format from model and ouput format from unipost +export DOMAINPATH=${TOP_DIR}/test_case +export UNIPOST_HOME=${TOP_DIR}/EMC_post +export POSTEXEC=${UNIPOST_HOME}/bin +export modelDataPath=/path/to/model/data +export txtCntrlFile=${DOMAINPATH}/parm/postxconfig-NT-GFS.txt + +# Specify model ("GFS" or "LAM" in upper case) +export model="GFS" + +# Set input format from model and ouput format from UPP export inFormat="netcdf" export outFormat="grib2" # Set date/time information -export startdate=2014020412 +export startdate=2020020400 export fhr=00 export lastfhr=06 export incrementhr=03 -# Set domain lists -export domain_list="d01" - # Set run command: -# Serial command example -export RUN_COMMAND="${POSTEXEC}/unipost.exe " +# Single processor command example +#export RUN_COMMAND="${POSTEXEC}/ncep_post " # Parallel command examples: -#export RUN_COMMAND="mpirun -np 1 ${POSTEXEC}/unipost.exe " -#export RUN_COMMAND="mpirun.lsf ${POSTEXEC}/unipost.exe " -#export RUN_COMMAND="mpiexec_mpt ${POSTEXEC}/unipost.exe " +export RUN_COMMAND="mpirun -np 1 ${POSTEXEC}/ncep_post " +#export RUN_COMMAND="mpirun.lsf ${POSTEXEC}/ncep_post " +#export RUN_COMMAND="mpiexec_mpt ${POSTEXEC}/ncep_post " # DEBUG command example found further below, search "DEBUG" @@ -132,47 +119,44 @@ if [ ! -d ${POSTEXEC} ]; then exit 1 fi -if [ ! -x ${POSTEXEC}/unipost.exe ]; then - echo "ERROR: unipost.exe, '${POSTEXEC}/unipost.exe', does not exist or is not executable." +if [ ! -x ${POSTEXEC}/ncep_post ]; then + echo "ERROR: ncep_post, '${POSTEXEC}/ncep_post', does not exist or is not executable." exit 1 fi -# Set tag based on user defined $dyncore (ARW or FV3 in upper case) -if [ $dyncore = "ARW" ]; then - export tag=NCAR -elif [ $dyncore = "FV3" ]; then +# Set tag based on user defined model (GFS or LAM) +if [ $model = "GFS" ]; then export tag=GFS +elif [ $model = "LAM" ]; then + export tag=FV3R else - echo "${dyncore} is not supported. Edit script to choose ARW or FV3 dyncore." - exit + echo "${model} is not supported. Edit script to choose 'GFS' or 'LAM' model." + exit fi -if [[ ${dyncore} == "ARW" ]]; then - if [[ ${inFormat} != "netcdf" ]]; then - echo "ERROR: 'inFormat' must be 'netcdf' for ARW model output. Exiting... " - exit 1 - fi -elif [ ${dyncore} == "FV3" ]; then +if [ ${model} == "GFS" ]; then if [[ ${inFormat} == "binarynemsiompiio" ]]; then - echo "Check: You are using 'dyncore' 'inFormat'!" + echo "Check: You are using 'model' 'inFormat'!" elif [[ ${inFormat} == "netcdf" ]]; then - echo "Check: You are using 'dyncore' 'inFormat'!" + echo "Check: You are using 'model' 'inFormat'!" else - echo "ERROR: 'inFormat' must be 'binarynemsiompiio' or 'netcdf' for FV3 model output. Exiting... " + echo "ERROR: 'inFormat' must be 'binarynemsiompiio' or 'netcdf' for GFS model output. Exiting... " exit 1 fi -fi - -if [[ ${outFormat} == "grib" ]]; then - if [ ! -e ${paramFile} ]; then - echo "ERROR: 'paramFile' not found in '${paramFile}'. Exiting... " +elif [[ ${model} == "LAM" ]]; then + if [[ ${inFormat} != "netcdf" ]]; then + echo "ERROR: 'inFormat' must be 'netcdf' for LAM model output. Exiting... " exit 1 fi -elif [[ ${outFormat} == "grib2" ]]; then +fi + +if [[ ${outFormat} == "grib2" ]]; then if [ ! -e ${txtCntrlFile} ]; then echo "ERROR: 'txtCntrlFile' not found in '${txtCntrlFile}'. Exiting... " exit 1 fi +else + echo "${outFormat} is not supported. Edit script to choose 'grib2' for 'outFormat'. Exiting... " fi if [ ! -d ${DOMAINPATH}/postprd ]; then @@ -202,26 +186,16 @@ if test "$err1" -ne 0; then exit 1 fi -# Get local copy of parm file -# For GRIB1 the code uses wrf_cntrl.parm to select variables for output -# the available fields are set at compilation -if [[ ${outFormat} == "grib" ]]; then - if [[ ${dyncore} == "ARW" ]]; then - ln -fs ${paramFile} wrf_cntrl.parm - elif [[ ${dyncore} == "FV3" ]]; then - echo "ERROR: FV3 not available for grib1 output. Use GRIB2 output. Exiting..." - exit 1 - fi -elif [[ ${outFormat} == "grib2" ]]; then -# For GRIB2 the code reads postxconfig-NT.txt to select variables for output -# the available fields are defined in post_avlbflds.xml -- while we +# For GRIB2 the code reads a flat text tile to select variables for output. +# The available fields are defined in post_avlbflds.xml -- while we # set a link to this file for reading during runtime it is not typical # for one to update this file, therefore the link goes back to the # program directory - this is true for params_grib2_tbl_new also - a # file which defines the GRIB2 table values -ln -fs ${txtCntrlFile} postxconfig-NT.txt -ln -fs ${UNIPOST_HOME}/parm/post_avblflds.xml post_avblflds.xml -ln -fs ${UNIPOST_HOME}/parm/params_grib2_tbl_new params_grib2_tbl_new +if [[ ${outFormat} == "grib2" ]]; then + ln -fs ${txtCntrlFile} postxconfig-NT.txt + ln -fs ${UNIPOST_HOME}/parm/post_avblflds.xml post_avblflds.xml + ln -fs ${UNIPOST_HOME}/parm/params_grib2_tbl_new params_grib2_tbl_new fi # Link microphysics tables - code will use based on mp_physics option @@ -230,7 +204,7 @@ ln -fs ${UNIPOST_HOME}/parm/nam_micro_lookup.dat . ln -fs ${UNIPOST_HOME}/parm/hires_micro_lookup.dat . # link coefficients for crtm2 (simulated synthetic satellites) -CRTMDIR=${UNIPOST_HOME}/sorc/comlibs/crtm2/src/fix +CRTMDIR=${UNIPOST_HOME}/crtm/fix ln -fs $CRTMDIR/EmisCoeff/IR_Water/Big_Endian/Nalli.IRwater.EmisCoeff.bin ./ ln -fs $CRTMDIR/EmisCoeff/MW_Water/Big_Endian/FASTEM4.MWwater.EmisCoeff.bin ./ ln -fs $CRTMDIR/EmisCoeff/MW_Water/Big_Endian/FASTEM5.MWwater.EmisCoeff.bin ./ @@ -283,9 +257,9 @@ ln -fs $CRTMDIR/TauCoeff/ODPS/Big_Endian/ahi_himawari8.TauCoeff.bin ./ ln -fs $CRTMDIR/SpcCoeff/Big_Endian/ahi_himawari8.SpcCoeff.bin ./ ####################################################### -# 1. Run Unipost +# 1. Run UPP # -# The Unipost is used to read native WRF model +# The UPP is used to read native GFS and LAM model # output and put out isobaric state fields and derived fields. ####################################################### @@ -313,74 +287,41 @@ iHH=`echo $startdate | cut -c9-10` echo 'NEWDATE' $NEWDATE echo 'YY' $YY -# Begin looping through domains list -for domain in ${domain_list}; do - # Create model file name (inFileName) -dom_id=`echo "${domain}" | cut -d 'd' -f 2` -if [[ ${dyncore} == "ARW" ]]; then - inFileName=${modelDataPath}/wrfout_d${dom_id}_${YY}-${MM}-${DD}_${HH}:00:00 -elif [ ${dyncore} == "FV3" ]; then -if [[ ${inFormat} == "binarynemsiompiio" ]]; then - inFileName=${modelDataPath}/dynf${fhour}.nemsio - flxFileName=${modelDataPath}/phyf${fhour}.nemsio -elif [ ${inFormat} == "netcdf" ]; then - inFileName=${modelDataPath}/gfs.t${fhr}z.atmf006.nc - flxFileName=${modelDataPath}/gfs.t${fhr}z.sfcf006.nc -fi +if [ ${model} == "GFS" ]; then + if [[ ${inFormat} == "binarynemsiompiio" ]]; then + inFileName=${modelDataPath}/atmf${fhour}.nemsio + flxFileName=${modelDataPath}/sfcf${fhour}.nemsio + elif [ ${inFormat} == "netcdf" ]; then + inFileName=${modelDataPath}/atmf${fhour}.nc + flxFileName=${modelDataPath}/sfcf${fhour}.nc + fi +elif [ ${model} == "LAM" ]; then + if [ ${inFormat} == "netcdf" ]; then + inFileName=${modelDataPath}/dynf${fhour}.nc + flxFileName=${modelDataPath}/dynf${fhour}.nc + fi fi # Check if the files exist if [[ ! -e ${inFileName} ]]; then - echo "ERROR: Can't find 'inFileName': ${inFileName}. Directory or file does not exist. Exiting..." - echo "ERROR: Check if 'modelDataPath': ${modelDataPath} exists." - if [[ ${dyncore} == "ARW" ]]; then - echo "ERROR: Check if file: 'wrfout_d${dom_id}_${YY}-${MM}-${DD}_${HH}:00:00' exists in modelDataPath." - elif [ ${dyncore} == "FV3" ]; then - echo "ERROR: Check if file: 'dynf${fhour}.nemsio' exists in modelDataPath." -# echo "ERROR: Check if file: 'gfs.t${iHH}z.sfcf${fhour}.nemsio' exists in modelDataPath." - fi - exit 1 + echo "ERROR: Can't find 'inFileName': ${inFileName}. Directory or file does not exist. Exiting..." + echo "ERROR: Check if 'modelDataPath': ${modelDataPath} exists." + exit 1 fi -# Check if that flux file exists for FV3 -if [ ${dyncore} == "FV3" ]; then - if [[ ! -e ${flxFileName} ]]; then - echo "ERROR: Can't find 'flxFileName': ${flxFileName}. Directory or file does not exist. Exiting..." - echo "ERROR: Check if 'modelDataPath': ${modelDataPath} exists." - echo "ERROR: Check if file: 'phyf${fhour}.nemsio' exists in modelDataPath." -# echo "ERROR: Check if file: 'gfs.t${iHH}z.sfcf${fhour}.nemsio' exists in modelDataPath." - exit 1 - fi +if [[ ! -e ${flxFileName} ]]; then + echo "ERROR: Can't find 'flxFileName': ${flxFileName}. Directory or file does not exist. Exiting..." + echo "ERROR: Check if 'modelDataPath': ${modelDataPath} exists." + exit 1 fi # Create itag based on user provided info. # Output format now set by user so if-block below uses this # to generate the correct itag. -if [[ ${outFormat} == "grib" ]]; then - -cat > itag < itag < itag < unipost_${domain}.${fhr}.out 2>&1 -elif [ ${dyncore} == "FV3" ]; then - ${RUN_COMMAND} > unipost.${fhr}.out 2>&1 +if [[ ${model} == "GFS" || ${model} == "LAM" ]]; then + ${RUN_COMMAND} > upp.f${fhour}.out 2>&1 fi -#---------------------------------------------------------------------- -# DEBUG Example, uncomment below and comment ${RUN_COMMAND} line above. - -# debugger runs - enter your debugger and hour of error -#if [[ $((10#${fhr})) -eq 3 ]]; then -# mpirun.dbg.totalview -progname ${POSTEXEC}/unipost.exe > unipost_${domain}.${fhr}.out 2>&1 -#else -# mpirun -np 1 ${POSTEXEC}/unipost.exe > unipost_${domain}.${fhr}.out 2>&1 -#fi -#---------------------------------------------------------------------- - -# This prefix was given in the wrf_cntl.parm file (GRIB1) -# or postcntrl.xml(GRIB2) +# The prefixes are given in the postcntrl.xml file datset variable (GRIB2) -if [[ ${dyncore} == "ARW" ]]; then - mv WRFPRS${fhr}.${tmmark} WRFPRS_${domain}.${fhr} -elif [ ${dyncore} == "FV3" ]; then - mv GFSPRS.GrbF${fhr} GFSPRS.${fhr} +if [[ ${model} == "GFS" ]]; then + mv GFSPRS.GrbF${fhr} GFSPRS.${fhour} +elif [ ${model} == "LAM" ]; then + mv BGDAWP${fhr}.tm00 BGDAWP.${fhour} + mv BGRD3D${fhr}.tm00 BGRD3D.${fhour} fi # #---------------------------------------------------------------------- -# End of unipost job +# End of ncep_post job #---------------------------------------------------------------------- -# check to make sure UPP was successful and script linked the file -if [[ ${dyncore} == "ARW" ]]; then - ls -l WRFPRS_${domain}.${fhr} +# check to make sure UPP was successful +if [[ ${model} == "GFS" ]]; then + ls -l GFSPRS.${fhour} err1=$? -elif [ ${dyncore} == "FV3" ]; then - ls -l GFSPRS.${fhr} +elif [ ${model} == "LAM" ]; then + ls -l BGDAWP.${fhour} err1=$? + ls -l BGRD3D.${fhour} + err2=$? fi -if test "$err1" -ne 0; then - echo 'UNIPOST FAILED, EXITTING' +if [[ ${err1} -ne 0 || ${err2} -ne 0 ]]; then + echo 'UPP FAILED, EXITTING' exit -fi - -done +fi fhr=$((10#${fhr}+$((${incrementhr}))))