From 9f71d579184313d6345aa09e7462a877bedaf553 Mon Sep 17 00:00:00 2001 From: Daniel Abdi Date: Wed, 8 Mar 2023 23:02:32 +0000 Subject: [PATCH] Modify post task. --- jobs/JREGIONAL_RUN_POST | 23 +++- scripts/exregional_run_post.sh | 196 +++++++++++++++++++++++++-------- ush/config_defaults.yaml | 20 ++++ 3 files changed, 190 insertions(+), 49 deletions(-) diff --git a/jobs/JREGIONAL_RUN_POST b/jobs/JREGIONAL_RUN_POST index 96c4c04aae..d91d2afa1e 100755 --- a/jobs/JREGIONAL_RUN_POST +++ b/jobs/JREGIONAL_RUN_POST @@ -62,7 +62,13 @@ on the output files corresponding to a specified forecast hour. # #----------------------------------------------------------------------- # -DATA="${DATA:-${COMIN}${SLASH_ENSMEM_SUBDIR}}" +CYCLE_TYPE=${CYCLE_TYPE:-prod} +CYCLE_SUBTYPE=${CYCLE_SUBTYPE:-empty} +if [ ${CYCLE_TYPE} == "spinup" ]; then + DATA="${DATA:-${COMIN}${SLASH_ENSMEM_SUBDIR}}/fcst_fv3lam_spinup" +else + DATA="${DATA:-${COMIN}${SLASH_ENSMEM_SUBDIR}}/fcst_fv3lam" +fi # # If SUB_HOURLY_POST is not set to "TRUE", ensure that the forecast # minutes (fmn) are set to "00". This is necessary in order to pass @@ -90,11 +96,22 @@ fi # #----------------------------------------------------------------------- # -if [ "${RUN_ENVIR}" != "nco" ]; then - export COMOUT="${DATA}/postprd" +if [ "${RUN_ENVIR}" = "nco" ]; then + if [ ${CYCLE_TYPE} = "spinup" ]; then + export COMOUT="${COMOUT}_spinup" + else + export COMOUT="${COMOUT}" + fi +else + if [ ${CYCLE_TYPE} = "spinup" ]; then + export COMOUT="${DATA}/postprd_spinup" + else + export COMOUT="${DATA}/postprd" + fi fi mkdir_vrfy -p "${COMOUT}" +# subhourly post if [ "${SUB_HOURLY_POST}" = "TRUE" ]; then export DATA_FHR="${DATA:-$COMOUT}/$fhr$fmn" else diff --git a/scripts/exregional_run_post.sh b/scripts/exregional_run_post.sh index 673ac861d7..67bd17c42d 100755 --- a/scripts/exregional_run_post.sh +++ b/scripts/exregional_run_post.sh @@ -85,44 +85,48 @@ rm_vrfy -f fort.* cp_vrfy ${PARMdir}/upp/nam_micro_lookup.dat ./eta_micro_lookup.dat if [ ${USE_CUSTOM_POST_CONFIG_FILE} = "TRUE" ]; then post_config_fp="${CUSTOM_POST_CONFIG_FP}" + post_params_fp="${CUSTOM_POST_PARAMS_FP}" print_info_msg " ==================================================================== Copying the user-defined post flat file specified by CUSTOM_POST_CONFIG_FP to the temporary work directory (DATA_FHR): CUSTOM_POST_CONFIG_FP = \"${CUSTOM_POST_CONFIG_FP}\" + CUSTOM_POST_PARAMS_FP = \"${CUSTOM_POST_PARAMS_FP}\" DATA_FHR = \"${DATA_FHR}\" ====================================================================" else if [ "${CPL_AQM}" = "TRUE" ]; then post_config_fp="${PARMdir}/upp/postxconfig-NT-AQM.txt" + post_params_fp="${PARMdir}/upp/params_grib2_tbl_new" else post_config_fp="${PARMdir}/upp/postxconfig-NT-fv3lam.txt" + post_params_fp="${PARMdir}/upp/params_grib2_tbl_new" fi print_info_msg " ==================================================================== Copying the default post flat file specified by post_config_fp to the temporary work directory (DATA_FHR): post_config_fp = \"${post_config_fp}\" + post_params_fp = \"${post_params_fp}\" DATA_FHR = \"${DATA_FHR}\" ====================================================================" fi cp_vrfy ${post_config_fp} ./postxconfig-NT.txt -cp_vrfy ${PARMdir}/upp/params_grib2_tbl_new . +cp_vrfy ${post_params_fp} ./params_grib2_tbl_new +# +#----------------------------------------------------------------------- +# +# Symlink CRTM fix files +# +#----------------------------------------------------------------------- +# if [ ${USE_CRTM} = "TRUE" ]; then - cp_vrfy ${CRTM_DIR}/fix/EmisCoeff/IR_Water/Big_Endian/Nalli.IRwater.EmisCoeff.bin ./ - cp_vrfy ${CRTM_DIR}/fix/EmisCoeff/MW_Water/Big_Endian/FAST*.bin ./ - cp_vrfy ${CRTM_DIR}/fix/EmisCoeff/IR_Land/SEcategory/Big_Endian/NPOESS.IRland.EmisCoeff.bin ./ - cp_vrfy ${CRTM_DIR}/fix/EmisCoeff/IR_Snow/SEcategory/Big_Endian/NPOESS.IRsnow.EmisCoeff.bin ./ - cp_vrfy ${CRTM_DIR}/fix/EmisCoeff/IR_Ice/SEcategory/Big_Endian/NPOESS.IRice.EmisCoeff.bin ./ - cp_vrfy ${CRTM_DIR}/fix/AerosolCoeff/Big_Endian/AerosolCoeff.bin ./ - cp_vrfy ${CRTM_DIR}/fix/CloudCoeff/Big_Endian/CloudCoeff.bin ./ - cp_vrfy ${CRTM_DIR}/fix/SpcCoeff/Big_Endian/*.bin ./ - cp_vrfy ${CRTM_DIR}/fix/TauCoeff/ODPS/Big_Endian/*.bin ./ + ln_vrfy -snf ${FIXcrtmupp}/*bin ./ print_info_msg " ==================================================================== -Copying the external CRTM fix files from CRTM_DIR to the temporary +Copying the external CRTM fix files from FIXcrtm to the temporary work directory (DATA_FHR): - CRTM_DIR = \"${CRTM_DIR}\" + FIXcrtmupp = \"${FIXcrtmupp}\" DATA_FHR = \"${DATA_FHR}\" ====================================================================" fi @@ -163,16 +167,25 @@ if [ "${SUB_HOURLY_POST}" = "TRUE" ]; then mnts_secs_str=":${fmn}:00" fi fi + # # Set the names of the forecast model's write-component output files. # if [ "${RUN_ENVIR}" = "nco" ]; then - DATAFCST=$DATAROOT/run_fcst${dot_ensmem/./_}.${share_pid} + DATAFCST=${DATAROOT}/${TAG}run_fcst_${CYCLE_TYPE}${dot_ensmem/./_}.${share_pid} else - DATAFCST=$DATA + DATAFCST=${COMIN}${SLASH_ENSMEM_SUBDIR} fi + +if [ ${CYCLE_TYPE} == "spinup" ]; then + DATAFCST="${DATAFCST}/fcst_fv3lam_spinup" +else + DATAFCST="${DATAFCST}/fcst_fv3lam" +fi + dyn_file="${DATAFCST}/dynf${fhr}${mnts_secs_str}.nc" phy_file="${DATAFCST}/phyf${fhr}${mnts_secs_str}.nc" + # # Set parameters that specify the actual time (not forecast time) of the # output. @@ -197,8 +210,10 @@ fileName='${dyn_file}' IOFORM='netcdf' grib='grib2' DateStr='${post_yyyy}-${post_mm}-${post_dd}_${post_hh}:${post_mn}:00' -MODELNAME='FV3R' +MODELNAME='${POST_FULL_MODEL_NAME}' +SUBMODELNAME='${POST_SUB_MODEL_NAME}' fileNameFlux='${phy_file}' +fileNameFlat='postxconfig-NT.txt' / &NAMPGB @@ -208,6 +223,42 @@ EOF # #----------------------------------------------------------------------- # +# Run wgrib2 +# +#----------------------------------------------------------------------- +# +if [ ${PREDEF_GRID_NAME} = "RRFS_CONUS_3km_HRRRIC" ]; then + grid_specs_rrfs="lambert:-97.5:38.500000 237.826355:1746:3000 21.885885:1014:3000" +elif [ ${PREDEF_GRID_NAME} = "RRFS_CONUS_3km" ]; then + grid_specs_rrfs="lambert:-97.5:38.500000 237.280472:1799:3000 21.138123:1059:3000" +elif [ ${PREDEF_GRID_NAME} = "RRFS_NA_3km" ]; then + grid_specs_rrfs="rot-ll:247.000000:-35.000000:0.000000 299.000000:4881:0.025000 -37.0000000:2961:0.025000" +elif [ ${PREDEF_GRID_NAME} = "RRFS_NA_13km" ]; then + grid_specs_rrfs="rot-ll:254.000000:-36.000000:0.000000 304.174600:956:0.1169118 -48.5768500:831:0.1170527" +fi +if [ ${PREDEF_GRID_NAME} = "RRFS_CONUS_3km_HRRRIC" ] || \ + [ ${PREDEF_GRID_NAME} = "RRFS_CONUS_3km" ] || \ + [ ${PREDEF_GRID_NAME} = "RRFS_NA_3km" ] || \ + [ ${PREDEF_GRID_NAME} = "RRFS_NA_13km" ]; then + + if [ -f ${FFG_DIR}/latest.FFG ]; then + cp_vrfy ${FFG_DIR}/latest.FFG . + wgrib2 latest.FFG -match "0-12 hour" -end -new_grid_interpolation bilinear -new_grid_winds grid -new_grid ${grid_specs_rrfs} ffg_12h.grib2 + wgrib2 latest.FFG -match "0-6 hour" -end -new_grid_interpolation bilinear -new_grid_winds grid -new_grid ${grid_specs_rrfs} ffg_06h.grib2 + wgrib2 latest.FFG -match "0-3 hour" -end -new_grid_interpolation bilinear -new_grid_winds grid -new_grid ${grid_specs_rrfs} ffg_03h.grib2 + wgrib2 latest.FFG -match "0-1 hour" -end -new_grid_interpolation bilinear -new_grid_winds grid -new_grid ${grid_specs_rrfs} ffg_01h.grib2 + fi + for ayear in 100y 10y 5y 2y ; do + for ahour in 01h 03h 06h 12h 24h; do + if [ -f ${PARMdir}/upp/${PREDEF_GRID_NAME}/ari${ayear}_${ahour}.grib2 ]; then + ln_vrfy -snf ${PARMdir}/upp/${PREDEF_GRID_NAME}/ari${ayear}_${ahour}.grib2 ari${ayear}_${ahour}.grib2 + fi + done + done +fi +# +#----------------------------------------------------------------------- +# # Run the UPP executable in the temporary directory (DATA_FHR) for this # output time. # @@ -230,11 +281,14 @@ POST_STEP # the work directory. # #----------------------------------------------------------------------- +# + # # Set variables needed in constructing the names of the grib2 files # generated by UPP. # len_fhr=${#fhr} +subh_fhr=${fhr} if [ ${len_fhr} -eq 2 ]; then post_fhr=${fhr} elif [ ${len_fhr} -eq 3 ]; then @@ -243,12 +297,29 @@ elif [ ${len_fhr} -eq 3 ]; then else post_fhr="${fhr}" fi +elif [ ${len_fhr} -eq 9 ]; then + if [ "${fhr:0:1}" = "0" ]; then + if [ ${post_min} -eq 00 ]; then + post_fhr="${fhr:1:2}" + subh_fhr="${fhr:0:3}" + else + post_fhr="${fhr:1:2}.${fhr:4:2}" + fi + else + if [ ${post_min} -eq 00 ]; then + post_fhr="${fhr:0:3}" + subh_fhr="${fhr:0:3}" + else + post_fhr="${fhr:0:3}.${fhr:4:2}" + fi + fi else print_err_msg_exit "\ The \${fhr} variable contains too few or too many characters: fhr = \"$fhr\"" fi +# set post minutes post_mn_or_null="" dot_post_mn_or_null="" if [ "${post_mn}" != "00" ]; then @@ -257,47 +328,80 @@ if [ "${post_mn}" != "00" ]; then fi post_fn_suffix="GrbF${post_fhr}${dot_post_mn_or_null}" -post_renamed_fn_suffix="f${fhr}${post_mn_or_null}.${POST_OUTPUT_DOMAIN_NAME}.grib2" +post_renamed_fn_suffix="f${subh_fhr}${post_mn_or_null}.${POST_OUTPUT_DOMAIN_NAME}.grib2" + +basetime=$( $DATE_UTIL --date "$yyyymmdd $hh" +%y%j%H%M ) +symlink_suffix="${dot_ensmem/./_}_${basetime}f${fhr}${post_mn}" # -# For convenience, change location to COMOUT (where the final output -# from UPP will be located). Then loop through the two files that UPP -# generates (i.e. "...prslev..." and "...natlev..." files) and move, -# rename, and create symlinks to them. +# write grib file to COMOUT # -cd_vrfy "${COMOUT}" -basetime=$( $DATE_UTIL --date "$yyyymmdd $hh" +%y%j%H%M ) -symlink_suffix="${dot_ensmem}.${basetime}f${fhr}${post_mn}" if [ "${CPL_AQM}" = "TRUE" ]; then - fids=( "cmaq" ) + + bgdawp=${COMOUT}/${NET}.${cycle}${dot_ensmem}.cmaq.${post_renamed_fn_suffix} + + wgrib2 CMAQ.${post_fn_suffix} -set center 7 -grib ${bgdawp} + ln_vrfy -sf ${bgdawp} ${COMOUT}/CMAQ${symlink_suffix} + + if [ $SENDDBN = "TRUE" ]; then + $DBNROOT/bin/dbn_alert MODEL rrfs_post ${job} ${bgdawp} + fi + + # Move phy and dyn files to COMIN only for AQM in NCO mode + if [ "${RUN_ENVIR}" = "nco" ]; then + mv_vrfy ${dyn_file} ${COMIN}/${NET}.${cycle}${dot_ensmem}.dyn.f${fhr}.nc + mv_vrfy ${phy_file} ${COMIN}/${NET}.${cycle}${dot_ensmem}.phy.f${fhr}.nc + fi + else - fids=( "prslev" "natlev" ) -fi -for fid in "${fids[@]}"; do - FID=$(echo_uppercase $fid) - post_orig_fn="${FID}.${post_fn_suffix}" - post_renamed_fn="${NET}.${cycle}${dot_ensmem}.${fid}.${post_renamed_fn_suffix}" - mv_vrfy ${DATA_FHR}/${post_orig_fn} ${post_renamed_fn} - if [ $RUN_ENVIR != "nco" ]; then - create_symlink_to_file target="${post_renamed_fn}" \ - symlink="${FID}${symlink_suffix}" \ - relative="TRUE" - fi - # DBN alert - if [ $SENDDBN = "TRUE" ]; then - $DBNROOT/bin/dbn_alert MODEL rrfs_post ${job} ${COMOUT}/${post_renamed_fn} - fi -done -# Move phy and dyn files to COMIN only for AQM -if [ "${CPL_AQM}" = "TRUE" ]; then - mv_vrfy ${dyn_file} ${COMIN}/${NET}.${cycle}${dot_ensmem}.dyn.f${fhr}.nc - mv_vrfy ${phy_file} ${COMIN}/${NET}.${cycle}${dot_ensmem}.phy.f${fhr}.nc + if [ $DO_RRFS_DEV = "TRUE" ]; then + bgdawp=${COMOUT}/${NET}.${cycle}${dot_ensmem}.bgdawp.${post_renamed_fn_suffix} + bgrd3d=${COMOUT}/${NET}.${cycle}${dot_ensmem}.bgrd3d.${post_renamed_fn_suffix} + else + bgdawp=${COMOUT}/${NET}.${cycle}${dot_ensmem}.prslev.${post_renamed_fn_suffix} + bgrd3d=${COMOUT}/${NET}.${cycle}${dot_ensmem}.natlev.${post_renamed_fn_suffix} + fi + if [ ${DO_RRFS_DEV} = "TRUE" ] && [ ${USE_CUSTOM_POST_CONFIG_FILE} = "TRUE" ]; then + wgrib2 BGDAWP.${post_fn_suffix} -set center 7 -grib ${bgdawp} + wgrib2 BGRD3D.${post_fn_suffix} -set center 7 -grib ${bgrd3d} + ln_vrfy -sf ${bgdawp} ${COMOUT}/BGDAWP${symlink_suffix} + ln_vrfy -sf ${bgdawp} ${COMOUT}/BGRD3D${symlink_suffix} + else + wgrib2 PRSLEV.${post_fn_suffix} -set center 7 -grib ${bgdawp} + wgrib2 NATLEV.${post_fn_suffix} -set center 7 -grib ${bgrd3d} + ln_vrfy -sf ${bgdawp} ${COMOUT}/PRSLEV${symlink_suffix} + ln_vrfy -sf ${bgdawp} ${COMOUT}/NATLEV${symlink_suffix} + fi + + if [ $SENDDBN = "TRUE" ]; then + $DBNROOT/bin/dbn_alert MODEL rrfs_post ${job} ${bgdawp} + $DBNROOT/bin/dbn_alert MODEL rrfs_post ${job} ${bgrd3d} + fi + + if [ -f IFIFIP.${post_fn_suffix} ]; then + bgifi=${COMOUT}/${NET}.${cycle}${dot_ensmem}.bgifi.${post_renamed_fn_suffix} + wgrib2 IFIFIP.${post_fn_suffix} -set center 7 -grib ${bgifi} + ln_vrfy -sf ${bgifi} ${COMOUT}/BGIFI${symlink_suffix} + + if [ $SENDDBN = "TRUE" ]; then + $DBNROOT/bin/dbn_alert MODEL rrfs_post ${job} ${bgifi} + fi + fi + fi +# remove DATA_FHR rm_vrfy -rf ${DATA_FHR} +# # Delete the forecast directory -if [ $RUN_ENVIR = "nco" ] && [ $KEEPDATA = "FALSE" ]; then +# +if [ $CYCLE_TYPE = "spinup" ]; then + fhr_l=$(printf "%03d" $FCST_LEN_HRS_SPINUP) +else + fhr_l=$(printf "%03d" $FCST_LEN_HRS) +fi +if [ $RUN_ENVIR = "nco" ] && [ $KEEPDATA = "FALSE" ] && [ $fhr = $fhr_l ]; then rm -rf $DATAFCST fi # diff --git a/ush/config_defaults.yaml b/ush/config_defaults.yaml index fbb59040a7..489d22b497 100644 --- a/ush/config_defaults.yaml +++ b/ush/config_defaults.yaml @@ -1993,6 +1993,21 @@ task_run_post: # used for post-processing. This is only used if CUSTOM_POST_CONFIG_FILE # is set to true. # + # CUSTOM_POST_PARAMS_FP: + # The full path to the custom post params file, including filename, to be + # used for post-processing. This is only used if CUSTOM_POST_CONFIG_FILE + # is set to "TRUE". + # + # POST_FULL_MODEL_NAME + # The full module name required by UPP and set in the itag file + # + # POST_SUB_MODEL_NAME + # The SUB module name required by UPP and set in the itag file + # + # TESTBED_FIELDS_FN + # The file which lists grib2 fields to be extracted to bgsfc for testbed + # Empty string means no need to generate bgsfc for testbed + # # POST_OUTPUT_DOMAIN_NAME: # Domain name (in lowercase) used in constructing the names of the output # files generated by UPP [which is called either by running the TN_RUN_POST @@ -2010,6 +2025,11 @@ task_run_post: # USE_CUSTOM_POST_CONFIG_FILE: false CUSTOM_POST_CONFIG_FP: "" + CUSTOM_POST_PARAMS_FP: "" + POST_FULL_MODEL_NAME: "FV3R" + POST_SUB_MODEL_NAME: "NONE" + TESTBED_FIELDS_FN: "" + TESTBED_FIELDS_FN2: "" POST_OUTPUT_DOMAIN_NAME: '{{ workflow.PREDEF_GRID_NAME }}' #----------------------------