diff --git a/Externals.cfg b/Externals.cfg index 48320c3f73..6f1bfddc53 100644 --- a/Externals.cfg +++ b/Externals.cfg @@ -58,7 +58,7 @@ protocol = git repo_url = https://github.com/NOAA-EMC/AQM-utils # Specify either a branch name or a hash but not both. #branch = develop -hash = b066931 +hash = 8e084f9 local_path = sorc/AQM-utils required = True diff --git a/jobs/JREGIONAL_BIAS_CORRECTION_O3 b/jobs/JREGIONAL_BIAS_CORRECTION_O3 index 4b2d3f33a8..32b12accd5 100755 --- a/jobs/JREGIONAL_BIAS_CORRECTION_O3 +++ b/jobs/JREGIONAL_BIAS_CORRECTION_O3 @@ -65,10 +65,6 @@ DATA="${DATA:-${COMIN}${SLASH_ENSMEM_SUBDIR}}" export PARMaqm_utils="${PARMaqm_utils:-${HOMEdir}/sorc/AQM-utils/parm}" TMP_STDAY=`${NDATE} -8760 ${PDY}${cyc} | cut -c1-8` # 1 year back -# The earliest day of training data is August 1 2020 -if [ ${TMP_STDAY} -le 20220810 ]; then - TMP_STDAY=20220810 -fi export BC_STDAY=${BC_STDAY:-${TMP_STDAY}} # #----------------------------------------------------------------------- diff --git a/jobs/JREGIONAL_BIAS_CORRECTION_PM25 b/jobs/JREGIONAL_BIAS_CORRECTION_PM25 index 3ad39a8ec0..27c6728e9c 100755 --- a/jobs/JREGIONAL_BIAS_CORRECTION_PM25 +++ b/jobs/JREGIONAL_BIAS_CORRECTION_PM25 @@ -65,10 +65,6 @@ DATA="${DATA:-${COMIN}${SLASH_ENSMEM_SUBDIR}}" export PARMaqm_utils="${PARMaqm_utils:-${HOMEdir}/sorc/AQM-utils/parm}" TMP_STDAY=`${NDATE} -8760 ${PDY}${cyc} | cut -c1-8` # 1 year back -# The earliest day of training data is August 1 2020 -if [ ${TMP_STDAY} -le 20220810 ]; then - TMP_STDAY=20220810 -fi export BC_STDAY=${BC_STDAY:-${TMP_STDAY}} # #----------------------------------------------------------------------- diff --git a/parm/FV3.input.yml b/parm/FV3.input.yml index 6ab6c7e778..851918e23d 100644 --- a/parm/FV3.input.yml +++ b/parm/FV3.input.yml @@ -315,11 +315,20 @@ FV3_GFS_v15_thompson_mynn_lam3km: gfs_physics_nml: avg_max_length: 3600.0 cdmbgwd: [0.88, 0.04] + debug: True do_deep: False + do_gsl_drag_ls_bl: False + do_gsl_drag_ss: True + do_gsl_drag_tofd: True do_mynnsfclay: True + do_tofd: False do_ugwp: False + do_ugwp_v0: False + do_ugwp_v0_nst_only: False + do_ugwp_v0_orog_only: False fhswr: 900.0 fhlwr: 900.0 + gwd_opt: 2 iaer: 1011 iccn: 2 icliq_sw: 2 @@ -337,16 +346,20 @@ FV3_GFS_v15_thompson_mynn_lam3km: iopt_snf: 4 iopt_stc: 1 iopt_tbot: 2 - iopt_trs: 2 + iopt_trs: !!python/none iovr: 3 ldiag_ugwp: False lgfdlmprad: False lsm: 1 + lsoil: !!python/none lsoil_lsm: !!python/none ltaerosol: False + print_diff_pgr: True + sfclay_compute_flux: !!python/none xkzminv: 0.3 xkzm_m: 1.0 xkzm_h: 1.0 + surf_map_nml: !!python/none FV3_GFS_v16: cires_ugwp_nml: @@ -356,6 +369,8 @@ FV3_GFS_v16: agrid_vel_rst: False d2_bg_k1: 0.2 d2_bg_k2: 0.0 + delt_max: 0.002 + dz_min: 6 fv_sg_adj: 450 hord_dp: -5 hord_mt: 5 @@ -395,7 +410,6 @@ FV3_GFS_v16: lndp_type: !!python/none lsoil: 4 n_var_lndp: !!python/none - nstf_name: [2, 1, 0, 0, 0] prautco: [0.00015, 0.00015] psautco: [0.0008, 0.0005] satmedmf: True @@ -506,7 +520,6 @@ FV3_GFS_v17_p8: min_lakeice: 0.15 min_seaice: 0.15 nsfullradar_diag: !!python/none - nstf_name: [2, 0, 0, 0, 0] prautco: [0.00015, 0.00015] psautco: [0.0008, 0.0005] qdiag3d: False diff --git a/parm/model_configure b/parm/model_configure index e5c6d975ef..58ea7378d4 100644 --- a/parm/model_configure +++ b/parm/model_configure @@ -1,5 +1,3 @@ -total_member: 1 -PE_MEMBER01: {{ PE_MEMBER01 }} start_year: {{ start_year }} start_month: {{ start_month }} start_day: {{ start_day }} @@ -7,17 +5,22 @@ start_hour: {{ start_hour }} start_minute: 0 start_second: 0 nhours_fcst: {{ nhours_fcst }} +fhrot: {{ fhrot }} RUN_CONTINUE: .false. ENS_SPS: .false. dt_atmos: {{ dt_atmos }} calendar: 'julian' memuse_verbose: .false. -atmos_nthreads: {{ atmos_nthreads }} restart_interval: {{ restart_interval }} output_1st_tstep_rst: .false. write_dopost: {{ write_dopost }} ideflate: 0 nbits: 0 +ichunk2d: -1 +jchunk2d: -1 +ichunk3d: -1 +jchunk3d: -1 +kchunk3d: -1 quilting: {{ quilting }} {% if quilting %} # diff --git a/parm/nems.configure b/parm/nems.configure index 3e626ad0b3..14d9503c47 100644 --- a/parm/nems.configure +++ b/parm/nems.configure @@ -2,10 +2,13 @@ #### NEMS Run-Time Configuration File ##### ############################################# -{% if not print_esmf %} # ESMF # +{%- if print_esmf %} +logKindFlag: ESMF_LOGKIND_MULTI +{%- else %} logKindFlag: ESMF_LOGKIND_MULTI_ON_ERROR -{% endif %} +{%- endif %} +globalResourceControl: true {% if cpl_aqm %} # EARTH # @@ -40,9 +43,23 @@ runSeq:: @ :: {% else %} +# EARTH # EARTH_component_list: ATM - ATM_model: fv3 - runSeq:: - ATM - :: +EARTH_attributes:: + Verbosity = 0 +:: + +# ATM # +ATM_model: fv3 +ATM_petlist_bounds: 0 {{ pe_member01_m1 }} +ATM_omp_num_threads: {{ atm_omp_num_threads }} +ATM_attributes:: + Verbosity = 0 + Diagnostic = 0 +:: + +# Run Sequence # +runSeq:: + ATM +:: {% endif %} diff --git a/parm/wflow/aqm_all.yaml b/parm/wflow/aqm_all.yaml index b41d7e39be..9e1354dc20 100644 --- a/parm/wflow/aqm_all.yaml +++ b/parm/wflow/aqm_all.yaml @@ -12,7 +12,6 @@ default_aqm_task: &default_aqm subcyc: !cycstr "@M" LOGDIR: !cycstr "&LOGDIR;" SLASH_ENSMEM_SUBDIR: '&SLASH_ENSMEM_SUBDIR;' - memory: 2G native: '{{ platform.SCHED_NATIVE_CMD }}' nnodes: 1 nodes: '{{ nnodes }}:ppn={{ ppn }}' @@ -27,6 +26,7 @@ task_nexus_gfs_sfc: command: '&LOAD_MODULES_RUN_TASK_FP; "nexus_gfs_sfc" "&JOBSdir;/JREGIONAL_NEXUS_GFS_SFC"' partition: '{% if platform.get("PARTITION_HPSS") %}&PARTITION_HPSS;{% else %}None{% endif %}' join: !cycstr '&LOGDIR;/{{ jobname }}_@Y@m@d@H&LOGEXT;' + memory: 2G dependency: or: and: @@ -72,6 +72,7 @@ task_fire_emission: <<: *default_aqm command: '&LOAD_MODULES_RUN_TASK_FP; "fire_emission" "&JOBSdir;/JREGIONAL_FIRE_EMISSION"' join: !cycstr '&LOGDIR;/{{ jobname }}_@Y@m@d@H&LOGEXT;' + memory: 2G task_point_source: <<: *default_aqm @@ -146,7 +147,7 @@ task_aqm_lbcs: dependency: taskdep: attrs: - task: make_lbcs + task: make_lbcs_mem000 task_pre_post_stat: <<: *default_aqm diff --git a/parm/wflow/default_workflow.yaml b/parm/wflow/default_workflow.yaml index fa64250320..d882adbcac 100644 --- a/parm/wflow/default_workflow.yaml +++ b/parm/wflow/default_workflow.yaml @@ -27,6 +27,7 @@ rocoto: SCRIPTSdir: '{{ user.SCRIPTSdir }}' SLASH_ENSMEM_SUBDIR: '{% if global.DO_ENSEMBLE %}{{ "/mem#mem#" }}{% else %}{{ "/" }}{% endif %}' USHdir: '{{ user.USHdir }}' + COLDSTART: '{{ workflow.COLDSTART }}' WARMSTART_CYCLE_DIR: '{{ workflow.WARMSTART_CYCLE_DIR }}' WORKFLOW_ID: '{{ workflow.WORKFLOW_ID }}' attrs: diff --git a/parm/wflow/post.yaml b/parm/wflow/post.yaml index 0f80981a8c..782b21b020 100644 --- a/parm/wflow/post.yaml +++ b/parm/wflow/post.yaml @@ -29,7 +29,7 @@ metatask_run_ens_post: metatask_run_post: var: fhr: '{% for h in range(0, workflow.LONG_FCST_LEN+1) %}{{ " %03d" % h }}{% endfor %}' - cycledef: '{% for h in range(0, workflow.LONG_FCST_LEN+1) %}{% if h <= workflow.FCST_LEN_HRS %}forecast {% else %}long_forecast {% endif %}{% endfor %}' + cycledef: '{% for h in range(0, workflow.LONG_FCST_LEN+1) %}{% if h <= workflow.FCST_LEN_CYCL|min %}forecast {% else %}long_forecast {% endif %}{% endfor %}' task_run_post_mem#mem#_f#fhr#: <<: *default_task dependency: diff --git a/scripts/exregional_aqm_lbcs.sh b/scripts/exregional_aqm_lbcs.sh index 71f72d2045..99da094000 100755 --- a/scripts/exregional_aqm_lbcs.sh +++ b/scripts/exregional_aqm_lbcs.sh @@ -60,18 +60,15 @@ export OMP_STACKSIZE=${OMP_STACKSIZE_MAKE_LBCS} # #----------------------------------------------------------------------- # -set -x eval ${PRE_TASK_CMDS} -nprocs=$(( NNODES_AQM_LBCS*PPN_AQM_LBCS )) - -if [ -z "${RUN_CMD_UTILS:-}" ] ; then +if [ -z "${RUN_CMD_AQMLBC:-}" ] ; then print_err_msg_exit "\ Run command was not set in machine file. \ - Please set RUN_CMD_UTILS for your platform" + Please set RUN_CMD_AQM_LBC for your platform" else print_info_msg "$VERBOSE" " - All executables will be submitted with command \'${RUN_CMD_UTILS}\'." + All executables will be submitted with command \'${RUN_CMD_AQMLBC}\'." fi # diff --git a/scripts/exregional_bias_correction_o3.sh b/scripts/exregional_bias_correction_o3.sh index e265851c49..468d2968cb 100755 --- a/scripts/exregional_bias_correction_o3.sh +++ b/scripts/exregional_bias_correction_o3.sh @@ -53,6 +53,7 @@ This is the ex-script for the task that runs BIAS-CORRECTION-O3. export KMP_AFFINITY=${KMP_AFFINITY_BIAS_CORRECTION_O3} export OMP_NUM_THREADS=${OMP_NUM_THREADS_BIAS_CORRECTION_O3} export OMP_STACKSIZE=${OMP_STACKSIZE_BIAS_CORRECTION_O3} +export OMP_PLACES=cores # #----------------------------------------------------------------------- # @@ -84,8 +85,6 @@ rm_vrfy -rf "$DATA" mkdir_vrfy -p "$DATA" cd_vrfy $DATA -set -x - yyyy=${PDY:0:4} yyyymm=${PDY:0:6} yyyy_m1=${PDYm1:0:4} @@ -207,7 +206,7 @@ fi mkdir_vrfy -p ${DATA}/data/sites cp_vrfy ${PARMaqm_utils}/bias_correction/config.ozone.bias_corr_${id_domain}.${cyc}z ${DATA} - + PREP_STEP eval ${RUN_CMD_SERIAL} ${EXECdir}/aqm_bias_correct config.ozone.bias_corr_${id_domain}.${cyc}z ${cyc}z ${BC_STDAY} ${PDY} ${REDIRECT_OUT_ERR} || print_err_msg_exit "Call to executable to run AQM_BIAS_CORRECT returned with nonzero exit code." POST_STEP diff --git a/scripts/exregional_bias_correction_pm25.sh b/scripts/exregional_bias_correction_pm25.sh index 57fc639952..834d1586f5 100755 --- a/scripts/exregional_bias_correction_pm25.sh +++ b/scripts/exregional_bias_correction_pm25.sh @@ -53,6 +53,7 @@ This is the ex-script for the task that runs BIAS-CORRECTION-PM25. export KMP_AFFINITY=${KMP_AFFINITY_BIAS_CORRECTION_PM25} export OMP_NUM_THREADS=${OMP_NUM_THREADS_BIAS_CORRECTION_PM25} export OMP_STACKSIZE=${OMP_STACKSIZE_BIAS_CORRECTION_PM25} +export OMP_PLACES=cores # #----------------------------------------------------------------------- # @@ -84,8 +85,6 @@ rm_vrfy -rf $DATA mkdir_vrfy -p "$DATA" cd_vrfy $DATA -set -x - yyyy=${PDY:0:4} yyyymm=${PDY:0:6} yyyy_m1=${PDYm1:0:4} diff --git a/scripts/exregional_get_extrn_mdl_files.sh b/scripts/exregional_get_extrn_mdl_files.sh index 9b43bb34fe..81f2ae34e3 100755 --- a/scripts/exregional_get_extrn_mdl_files.sh +++ b/scripts/exregional_get_extrn_mdl_files.sh @@ -54,7 +54,6 @@ or lateral boundary conditions for the FV3. # #----------------------------------------------------------------------- # -set -x if [ "${ICS_OR_LBCS}" = "ICS" ]; then if [ ${TIME_OFFSET_HRS} -eq 0 ] ; then file_set="anl" diff --git a/scripts/exregional_make_orog.sh b/scripts/exregional_make_orog.sh index 99da64c4b6..4782ff0001 100755 --- a/scripts/exregional_make_orog.sh +++ b/scripts/exregional_make_orog.sh @@ -244,7 +244,8 @@ mv_vrfy "${raw_orog_fp_orig}" "${raw_orog_fp}" # #----------------------------------------------------------------------- # -if [ "${CCPP_PHYS_SUITE}" = "FV3_HRRR" ] || [ "${CCPP_PHYS_SUITE}" = "FV3_GFS_v17_p8" ]; then +suites=( "FV3_HRRR" "FV3_GFS_v15_thompson_mynn_lam3km" "FV3_GFS_v17_p8" ) +if [[ ${suites[@]} =~ "${CCPP_PHYS_SUITE}" ]] ; then DATA="${DATA:-${OROG_DIR}/temp_orog_data}" mkdir_vrfy -p ${DATA} cd_vrfy ${DATA} diff --git a/scripts/exregional_nexus_emission.sh b/scripts/exregional_nexus_emission.sh index 9d3f04b86f..53c6e6e48e 100755 --- a/scripts/exregional_nexus_emission.sh +++ b/scripts/exregional_nexus_emission.sh @@ -61,19 +61,16 @@ export OMP_STACKSIZE=${OMP_STACKSIZE_NEXUS_EMISSION} # #----------------------------------------------------------------------- # -set -x eval ${PRE_TASK_CMDS} -omp_num_threads_run_aqm="${OMP_NUM_THREADS_NEXUS_EMISSION}" - -if [ -z "${RUN_CMD_AQM:-}" ] ; then +if [ -z "${RUN_CMD_NEXUS:-}" ] ; then print_err_msg_exit "\ Run command was not set in machine file. \ - Please set RUN_CMD_AQM for your platform" + Please set RUN_CMD_NEXUS for your platform" else - RUN_CMD_AQM=$(eval echo ${RUN_CMD_AQM}) + RUN_CMD_NEXUS=$(eval echo ${RUN_CMD_NEXUS}) print_info_msg "$VERBOSE" " - All executables will be submitted with command \'${RUN_CMD_AQM}\'." + All executables will be submitted with command \'${RUN_CMD_NEXUS}\'." fi # #----------------------------------------------------------------------- @@ -277,7 +274,7 @@ fi #----------------------------------------------------------------------- # PREP_STEP -eval ${RUN_CMD_AQM} ${EXECdir}/nexus -c NEXUS_Config.rc -r grid_spec.nc -o NEXUS_Expt_split.nc ${REDIRECT_OUT_ERR} || \ +eval ${RUN_CMD_NEXUS} ${EXECdir}/nexus -c NEXUS_Config.rc -r grid_spec.nc -o NEXUS_Expt_split.nc ${REDIRECT_OUT_ERR} || \ print_err_msg_exit "\ Call to execute nexus standalone for the FV3LAM failed." POST_STEP diff --git a/scripts/exregional_nexus_gfs_sfc.sh b/scripts/exregional_nexus_gfs_sfc.sh index adf3ef5f2d..b18dddd3b2 100755 --- a/scripts/exregional_nexus_gfs_sfc.sh +++ b/scripts/exregional_nexus_gfs_sfc.sh @@ -48,7 +48,6 @@ data files from disk or HPSS. # #----------------------------------------------------------------------- # -set -x DATA="${DATA}/tmp_GFS_SFC" mkdir_vrfy -p "$DATA" cd_vrfy $DATA diff --git a/scripts/exregional_post_stat_o3.sh b/scripts/exregional_post_stat_o3.sh index 402f2a064e..1913038195 100755 --- a/scripts/exregional_post_stat_o3.sh +++ b/scripts/exregional_post_stat_o3.sh @@ -47,16 +47,6 @@ This is the ex-script for the task that runs POST-STAT-O3. # #----------------------------------------------------------------------- # -# Set OpenMP variables. -# -#----------------------------------------------------------------------- -# -export KMP_AFFINITY=${KMP_AFFINITY_POST_STAT_O3} -export OMP_NUM_THREADS=${OMP_NUM_THREADS_POST_STAT_O3} -export OMP_STACKSIZE=${OMP_STACKSIZE_POST_STAT_O3} -# -#----------------------------------------------------------------------- -# # Set run command. # #----------------------------------------------------------------------- @@ -83,8 +73,6 @@ fi DATA="${DATA}/tmp_POST_STAT_O3" mkdir_vrfy -p "$DATA" cd_vrfy $DATA - -set -x # #----------------------------------------------------------------------- # diff --git a/scripts/exregional_post_stat_pm25.sh b/scripts/exregional_post_stat_pm25.sh index fe18f5c973..cc3131b3da 100755 --- a/scripts/exregional_post_stat_pm25.sh +++ b/scripts/exregional_post_stat_pm25.sh @@ -47,16 +47,6 @@ This is the ex-script for the task that runs POST-STAT-PM25. # #----------------------------------------------------------------------- # -# Set OpenMP variables. -# -#----------------------------------------------------------------------- -# -export KMP_AFFINITY=${KMP_AFFINITY_POST_STAT_PM25} -export OMP_NUM_THREADS=${OMP_NUM_THREADS_POST_STAT_PM25} -export OMP_STACKSIZE=${OMP_STACKSIZE_POST_STAT_PM25} -# -#----------------------------------------------------------------------- -# # Set run command. # #----------------------------------------------------------------------- @@ -83,9 +73,6 @@ fi DATA="${DATA}/tmp_POST_STAT_PM25" mkdir_vrfy -p "$DATA" cd_vrfy $DATA - -set -x - # #----------------------------------------------------------------------- # diff --git a/scripts/exregional_run_fcst.sh b/scripts/exregional_run_fcst.sh index 7708c5d217..032f9e9161 100755 --- a/scripts/exregional_run_fcst.sh +++ b/scripts/exregional_run_fcst.sh @@ -8,7 +8,7 @@ #----------------------------------------------------------------------- # . $USHdir/source_util_funcs.sh -source_config_for_task "task_run_fcst|task_run_post|task_get_extrn_lbcs" ${GLOBAL_VAR_DEFNS_FP} +source_config_for_task "task_run_fcst|task_run_post|task_get_extrn_ics|task_get_extrn_lbcs" ${GLOBAL_VAR_DEFNS_FP} # #----------------------------------------------------------------------- # @@ -48,13 +48,19 @@ specified cycle. # #----------------------------------------------------------------------- # -# Set OpenMP variables. +# Set environment variables. # #----------------------------------------------------------------------- # export KMP_AFFINITY=${KMP_AFFINITY_RUN_FCST} export OMP_NUM_THREADS=${OMP_NUM_THREADS_RUN_FCST} export OMP_STACKSIZE=${OMP_STACKSIZE_RUN_FCST} +export MPI_TYPE_DEPTH=20 +export ESMF_RUNTIME_COMPLIANCECHECK=OFF:depth=4 +if [ "${PRINT_ESMF}" = "TRUE" ]; then + export ESMF_RUNTIME_PROFILE=ON + export ESMF_RUNTIME_PROFILE_OUTPUT="SUMMARY" +fi # #----------------------------------------------------------------------- # @@ -188,18 +194,16 @@ create_symlink_to_file target="$target" symlink="$symlink" \ # that the FV3 model is hardcoded to recognize, and those are the names # we use below. # -if [ "${CCPP_PHYS_SUITE}" = "FV3_HRRR" ] || [ "${CCPP_PHYS_SUITE}" = "FV3_GFS_v17_p8" ]; then - - fileids=( "ss" "ls" ) - for fileid in "${fileids[@]}"; do - target="${FIXlam}/${CRES}${DOT_OR_USCORE}oro_data_${fileid}.tile${TILE_RGNL}.halo${NH0}.nc" - symlink="oro_data_${fileid}.nc" +suites=( "FV3_HRRR" "FV3_GFS_v15_thompson_mynn_lam3km" "FV3_GFS_v17_p8" ) +if [[ ${suites[@]} =~ "${CCPP_PHYS_SUITE}" ]] ; then + file_ids=( "ss" "ls" ) + for file_id in "${file_ids[@]}"; do + target="${FIXlam}/${CRES}${DOT_OR_USCORE}oro_data_${file_id}.tile${TILE_RGNL}.halo${NH0}.nc" + symlink="oro_data_${file_id}.nc" create_symlink_to_file target="$target" symlink="$symlink" \ relative="${relative_link_flag}" done - fi - # #----------------------------------------------------------------------- # @@ -433,8 +437,105 @@ cat > itag <=0; ih_rst-- )); do + cdate_restart_hr=$( $DATE_UTIL --utc --date "${PDY} ${cyc} UTC + ${restart_hrs[ih_rst]} hours" "+%Y%m%d%H" ) + rst_yyyymmdd="${cdate_restart_hr:0:8}" + rst_hh="${cdate_restart_hr:8:2}" + + num_rst_files=0 + for file_id in "${file_ids[@]}"; do + if [ -e "${DATA}/RESTART/${rst_yyyymmdd}.${rst_hh}0000.${file_id}" ]; then + (( num_rst_files=num_rst_files+1 )) + fi + done + if [ "${num_rst_files}" = "${num_file_ids}" ]; then + FHROT="${restart_hrs[ih_rst]}" + break + fi + done + + # Create soft-link of restart files in INPUT directory + cd_vrfy ${DATA}/INPUT + for file_id in "${file_ids[@]}"; do + rm_vrfy "${file_id}" + target="${DATA}/RESTART/${rst_yyyymmdd}.${rst_hh}0000.${file_id}" + symlink="${file_id}" + create_symlink_to_file target="$target" symlink="$symlink" relative="${relative_link_flag}" + done + cd_vrfy ${DATA} +fi # #----------------------------------------------------------------------- # @@ -442,9 +543,11 @@ if [ "${CPL_AQM}" = "TRUE" ]; then # #----------------------------------------------------------------------- # - init_concentrations="false" - if [ "${COLDSTART}" = "TRUE" ] && [ "${PDY}${cyc}" = "${DATE_FIRST_CYCL:0:10}" ]; then +if [ "${CPL_AQM}" = "TRUE" ]; then + if [ "${COLDSTART}" = "TRUE" ] && [ "${PDY}${cyc}" = "${DATE_FIRST_CYCL:0:10}" ] && [ "${flag_fcst_restart}" = "FALSE" ]; then init_concentrations="true" + else + init_concentrations="false" fi # #----------------------------------------------------------------------- @@ -458,31 +561,14 @@ if [ "${CPL_AQM}" = "TRUE" ]; then --path-to-defns ${GLOBAL_VAR_DEFNS_FP} \ --cdate "$CDATE" \ --run-dir "${DATA}" \ - --init-concentration "${init_concentrations}" \ + --init_concentrations "${init_concentrations}" \ || print_err_msg_exit "\ Call to function to create an aqm.rc file for the current cycle's (cdate) run directory (DATA) failed: cdate = \"${CDATE}\" DATA = \"${DATA}\"" fi -# -#----------------------------------------------------------------------- -# -if [ "${DO_ENSEMBLE}" = TRUE ] && ([ "${DO_SPP}" = TRUE ] || [ "${DO_SPPT}" = TRUE ] || [ "${DO_SHUM}" = TRUE ] || \ - [ "${DO_SKEB}" = TRUE ] || [ "${DO_LSM_SPP}" = TRUE ]); then - python3 $USHdir/set_FV3nml_ens_stoch_seeds.py \ - --path-to-defns ${GLOBAL_VAR_DEFNS_FP} \ - --cdate "$CDATE" || print_err_msg_exit "\ -Call to function to create the ensemble-based namelist for the current -cycle's (cdate) run directory (DATA) failed: - cdate = \"${CDATE}\" - DATA = \"${DATA}\"" -else - create_symlink_to_file target="${FV3_NML_FP}" \ - symlink="${DATA}/${FV3_NML_FN}" \ - relative="${relative_link_flag}" -fi # #----------------------------------------------------------------------- # @@ -495,6 +581,7 @@ python3 $USHdir/create_model_configure_file.py \ --path-to-defns ${GLOBAL_VAR_DEFNS_FP} \ --cdate "$CDATE" \ --fcst_len_hrs "${FCST_LEN_HRS}" \ + --fhrot "${FHROT}" \ --run-dir "${DATA}" \ --sub-hourly-post "${SUB_HOURLY_POST}" \ --dt-subhourly-post-mnts "${DT_SUBHOURLY_POST_MNTS}" \ diff --git a/scripts/exregional_run_prdgen_subpiece.sh b/scripts/exregional_run_prdgen_subpiece.sh index 327dadd5e3..c3dd10edd4 100755 --- a/scripts/exregional_run_prdgen_subpiece.sh +++ b/scripts/exregional_run_prdgen_subpiece.sh @@ -13,8 +13,6 @@ # 2022-11-29 Ben Blake # -set -x - fhr=$1 cyc=$2 subpiece=$3 diff --git a/ush/config.aqm.community.yaml b/ush/config.aqm.community.yaml index a6dd2f22be..9fc019ed66 100644 --- a/ush/config.aqm.community.yaml +++ b/ush/config.aqm.community.yaml @@ -5,7 +5,7 @@ user: MACHINE: [hera or wcoss2] ACCOUNT: [account name] workflow: - USE_CRON_TO_RELAUNCH: false + USE_CRON_TO_RELAUNCH: true CRON_RELAUNCH_INTVL_MNTS: 3 EXPT_SUBDIR: aqm_community_aqmna13 PREDEF_GRID_NAME: AQM_NA_13km @@ -27,7 +27,8 @@ nco: NET: aqm rocoto: tasks: - taskgroups: '{{ ["parm/wflow/prep.yaml", "parm/wflow/coldstart.yaml", "parm/wflow/aqm_all.yaml"]|include }}' + taskgroups: '{{ ["parm/wflow/prep.yaml", "parm/wflow/coldstart.yaml", "parm/wflow/post.yaml", "parm/wflow/aqm_all.yaml"]|include }}' + task_aqm_ics_ext: task_post_stat_o3: task_post_stat_pm25: task_bias_correction_o3: @@ -52,8 +53,10 @@ task_run_fcst: RESTART_INTERVAL: 6 QUILTING: true PRINT_ESMF: false + DO_FCST_RESTART: false task_run_post: POST_OUTPUT_DOMAIN_NAME: 793 + USE_CUSTOM_POST_CONFIG_FILE: false global: DO_ENSEMBLE: false NUM_ENS_MEMBERS: 2 diff --git a/ush/config.aqm.nco.realtime.yaml b/ush/config.aqm.nco.realtime.yaml index 55043cad4a..04a5b1edf5 100644 --- a/ush/config.aqm.nco.realtime.yaml +++ b/ush/config.aqm.nco.realtime.yaml @@ -5,13 +5,13 @@ user: MACHINE: wcoss2 ACCOUNT: [account name] workflow: - USE_CRON_TO_RELAUNCH: false + USE_CRON_TO_RELAUNCH: true CRON_RELAUNCH_INTVL_MNTS: 3 EXPT_SUBDIR: aqm_nco_aqmna13km PREDEF_GRID_NAME: AQM_NA_13km CCPP_PHYS_SUITE: FV3_GFS_v16 - DATE_FIRST_CYCL: '2023021700' - DATE_LAST_CYCL: '2023021718' + DATE_FIRST_CYCL: '2023032300' + DATE_LAST_CYCL: '2023032318' INCR_CYCL_FREQ: 6 FCST_LEN_HRS: -1 FCST_LEN_CYCL: @@ -34,8 +34,8 @@ nco: RUN: aqm_nco_aqmna13km OPSROOT: /path/to/custom/opsroot rocoto: - taskgroups: '{{ ["parm/wflow/all_aqm.yaml", "parm/wflow/coldstart.yaml"]|include }}' tasks: + taskgroups: '{{ ["parm/wflow/aqm_all.yaml", "parm/wflow/coldstart.yaml", "parm/wflow/post.yaml"]|include }}' task_get_extrn_lbcs: walltime: 02:00:00 metatask_run_ensemble: @@ -63,10 +63,10 @@ task_run_fcst: LAYOUT_X: 50 LAYOUT_Y: 34 BLOCKSIZE: 16 - RESTART_INTERVAL: 6 18 - OMP_NUM_THREADS_RUN_FCST: 1 + RESTART_INTERVAL: 6 24 42 60 QUILTING: true PRINT_ESMF: false + DO_FCST_RESTART: false task_run_post: POST_OUTPUT_DOMAIN_NAME: 793 global: diff --git a/ush/config_defaults.yaml b/ush/config_defaults.yaml index 559cf64625..2bdaa16222 100644 --- a/ush/config_defaults.yaml +++ b/ush/config_defaults.yaml @@ -846,7 +846,8 @@ workflow: # This pattern is recurred for all cycle dates. # Must have the same number of entries as cycles per day, or if less # than one day the entries must include the length of each cycle to be - # run. + # run. By default, set it to a 1-item list containing the standard + # fcst length. # #----------------------------------------------------------------------- # @@ -855,11 +856,8 @@ workflow: INCR_CYCL_FREQ: 24 FCST_LEN_HRS: 24 FCST_LEN_CYCL: - - 6 - - 12 - - 12 - - 6 - LONG_FCST_LEN: '{% if FCST_LEN_HRS < 0 %}{{ FCST_LEN_CYCL|min }}{% else %}{{ FCST_LEN_HRS }}{% endif %}' + - '{{ FCST_LEN_HRS }}' + LONG_FCST_LEN: '{% if FCST_LEN_HRS < 0 %}{{ FCST_LEN_CYCL|max }}{% else %}{{ FCST_LEN_HRS }}{% endif %}' # #----------------------------------------------------------------------- @@ -1574,8 +1572,8 @@ task_run_fcst: #----------------------------------------------------------------------- # KMP_AFFINITY_RUN_FCST: "scatter" - OMP_NUM_THREADS_RUN_FCST: 2 # atmos_nthreads in model_configure - OMP_STACKSIZE_RUN_FCST: "1024m" + OMP_NUM_THREADS_RUN_FCST: 1 # ATM_omp_num_threads in nems.configure + OMP_STACKSIZE_RUN_FCST: "512m" # #----------------------------------------------------------------------- # @@ -1587,6 +1585,9 @@ task_run_fcst: # which the top level routine in the dynamics is called as well as the # frequency with which the physics is called." # + # FHROT: + # Forecast hour at restart + # # RESTART_INTERVAL: # frequency of the output restart files (unit:hour). # Default=0: restart files are produced at the end of a forecast run @@ -1604,9 +1605,9 @@ task_run_fcst: #----------------------------------------------------------------------- # DT_ATMOS: "" + FHROT: 0 RESTART_INTERVAL: 0 WRITE_DOPOST: false - # #----------------------------------------------------------------------- # @@ -1780,6 +1781,15 @@ task_run_fcst: #----------------------------------------------------------------------- # USE_MERRA_CLIMO: '{{ workflow.CCPP_PHYS_SUITE == "FV3_GFS_v15_thompson_mynn_lam3km" or workflow.CCPP_PHYS_SUITE == "FV3_GFS_v17_p8" }}' + # + #----------------------------------------------------------------------- + # + # DO_FCST_RESTART: + # Flag turning on/off restart capability of forecast task + # + #----------------------------------------------------------------------- + # + DO_FCST_RESTART: false #---------------------------- # POST config parameters @@ -1856,16 +1866,6 @@ task_run_post: POST_OUTPUT_DOMAIN_NAME: '{{ workflow.PREDEF_GRID_NAME }}' TESTBED_FIELDS_FN: "" -#---------------------------- -# NEXUS_EMISSION config parameters -#----------------------------- -task_nexus_emission: - PPN_NEXUS_EMISSION: '{{ platform.NCORES_PER_NODE // OMP_NUM_THREADS_NEXUS_EMISSION }}' - KMP_AFFINITY_NEXUS_EMISSION: "scatter" - OMP_NUM_THREADS_NEXUS_EMISSION: 2 - OMP_STACKSIZE_NEXUS_EMISSION: "1024m" - - #---------------------------- # RUN PRDGEN config parameters #----------------------------- @@ -1931,6 +1931,31 @@ task_plot_allvars: #------------------------------------------------------------------------------- PLOT_DOMAINS: ["conus"] +#---------------------------- +# NEXUS_EMISSION config parameters +#----------------------------- +task_nexus_emission: + PPN_NEXUS_EMISSION: '{{ platform.NCORES_PER_NODE // OMP_NUM_THREADS_NEXUS_EMISSION }}' + KMP_AFFINITY_NEXUS_EMISSION: "scatter" + OMP_NUM_THREADS_NEXUS_EMISSION: 2 + OMP_STACKSIZE_NEXUS_EMISSION: "1024m" + +#---------------------------- +# BIAS_CORRECTION_O3 config parameters +#----------------------------- +task_bias_correction_o3: + KMP_AFFINITY_BIAS_CORRECTION_O3: "scatter" + OMP_NUM_THREADS_BIAS_CORRECTION_O3: 32 + OMP_STACKSIZE_BIAS_CORRECTION_O3: "2056M" + +#---------------------------- +# BIAS_CORRECTION_PM25 config parameters +#----------------------------- +task_bias_correction_pm25: + KMP_AFFINITY_BIAS_CORRECTION_PM25: "scatter" + OMP_NUM_THREADS_BIAS_CORRECTION_PM25: 32 + OMP_STACKSIZE_BIAS_CORRECTION_PM25: "2056M" + #---------------------------- # global config parameters #----------------------------- diff --git a/ush/create_aqm_rc_file.py b/ush/create_aqm_rc_file.py index 733449514e..926278de7c 100644 --- a/ush/create_aqm_rc_file.py +++ b/ush/create_aqm_rc_file.py @@ -159,7 +159,7 @@ def parse_args(argv): required=True, help="Date string in YYYYMMDD format.") - parser.add_argument("-i", "--init-concentrations", + parser.add_argument("-i", "--init_concentrations", dest="init_concentrations", required=True, help="Flag for initial concentrations.") diff --git a/ush/create_model_configure_file.py b/ush/create_model_configure_file.py index 8fa978755c..47e1ba3daf 100644 --- a/ush/create_model_configure_file.py +++ b/ush/create_model_configure_file.py @@ -24,7 +24,7 @@ def create_model_configure_file( - cdate, fcst_len_hrs, run_dir, sub_hourly_post, dt_subhourly_post_mnts, dt_atmos + cdate, fcst_len_hrs, fhrot, run_dir, sub_hourly_post, dt_subhourly_post_mnts, dt_atmos ): """Creates a model configuration file in the specified run directory @@ -32,6 +32,7 @@ def create_model_configure_file( Args: cdate: cycle date fcst_len_hrs: forecast length in hours + fhrot: forecast hour at restart run_dir: run directory sub_hourly_post dt_subhourly_post_mnts @@ -81,14 +82,13 @@ def create_model_configure_file( # ----------------------------------------------------------------------- # settings = { - "PE_MEMBER01": PE_MEMBER01, "start_year": yyyy, "start_month": mm, "start_day": dd, "start_hour": hh, "nhours_fcst": fcst_len_hrs, + "fhrot": fhrot, "dt_atmos": DT_ATMOS, - "atmos_nthreads": OMP_NUM_THREADS_RUN_FCST, "restart_interval": RESTART_INTERVAL, "write_dopost": dot_write_dopost, "quilting": dot_quilting_dot, @@ -260,6 +260,14 @@ def parse_args(argv): help="Forecast length in hours.", ) + parser.add_argument( + "-b", + "--fhrot", + dest="fhrot", + required=True, + help="Forecast hour at restart.", + ) + parser.add_argument( "-s", "--sub-hourly-post", @@ -304,6 +312,7 @@ def parse_args(argv): run_dir=args.run_dir, cdate=str_to_type(args.cdate), fcst_len_hrs=str_to_type(args.fcst_len_hrs), + fhrot=str_to_type(args.fhrot), sub_hourly_post=str_to_type(args.sub_hourly_post), dt_subhourly_post_mnts=str_to_type(args.dt_subhourly_post_mnts), dt_atmos=str_to_type(args.dt_atmos), @@ -318,6 +327,7 @@ def test_create_model_configure_file(self): run_dir=path, cdate=datetime(2021, 1, 1), fcst_len_hrs=72, + fhrot=0, sub_hourly_post=True, dt_subhourly_post_mnts=4, dt_atmos=1, @@ -337,10 +347,9 @@ def setUp(self): set_env_var("USHdir", USHdir) set_env_var("MODEL_CONFIG_FN", MODEL_CONFIG_FN) set_env_var("MODEL_CONFIG_TMPL_FP", MODEL_CONFIG_TMPL_FP) - set_env_var("PE_MEMBER01", 24) set_env_var("FCST_LEN_HRS", 72) + set_env_var("FHROT", 0) set_env_var("DT_ATMOS", 1) - set_env_var("OMP_NUM_THREADS_RUN_FCST", 1) set_env_var("RESTART_INTERVAL", 4) set_env_var("WRTCMP_write_groups", 1) diff --git a/ush/create_nems_configure_file.py b/ush/create_nems_configure_file.py index 5b4f82e9d5..f1837f54a2 100644 --- a/ush/create_nems_configure_file.py +++ b/ush/create_nems_configure_file.py @@ -52,6 +52,7 @@ def create_nems_configure_file(run_dir): # Set output file path # nems_config_fp = os.path.join(run_dir, NEMS_CONFIG_FN) + pe_member01_m1 = str(int(PE_MEMBER01)-1) # #----------------------------------------------------------------------- # @@ -64,7 +65,9 @@ def create_nems_configure_file(run_dir): settings = { "dt_atmos": DT_ATMOS, "print_esmf": PRINT_ESMF, - "cpl_aqm": CPL_AQM + "cpl_aqm": CPL_AQM, + "pe_member01_m1": pe_member01_m1, + "atm_omp_num_threads": OMP_NUM_THREADS_RUN_FCST, } settings_str = cfg_to_yaml_str(settings) diff --git a/ush/generate_FV3LAM_wflow.py b/ush/generate_FV3LAM_wflow.py index a4d43a70e4..3e3d689dc7 100755 --- a/ush/generate_FV3LAM_wflow.py +++ b/ush/generate_FV3LAM_wflow.py @@ -258,12 +258,6 @@ def generate_FV3LAM_wflow(ushdir, logfile: str = "log.generate_FV3LAM_wflow", de ) cp_vrfy(FIELD_TABLE_TMPL_FP, FIELD_TABLE_FP) - log_info( - f""" - Copying the template NEMS configuration file to the experiment directory...""", - verbose=verbose, - ) - cp_vrfy(NEMS_CONFIG_TMPL_FP, NEMS_CONFIG_FP) # # Copy the CCPP physics suite definition file from its location in the # clone of the FV3 code repository to the experiment directory (EXPT- @@ -335,6 +329,8 @@ def generate_FV3LAM_wflow(ushdir, logfile: str = "log.generate_FV3LAM_wflow", de SDF_USES_RUC_LSM ): lsoil = 9 + if CCPP_PHYS_SUITE == "FV3_GFS_v15_thompson_mynn_lam3km": + lsoil = "" # # Create a multiline variable that consists of a yaml-compliant string # specifying the values that the namelist variables that are physics- diff --git a/ush/link_fix.py b/ush/link_fix.py index 3aa0ffa5b7..114d645f10 100755 --- a/ush/link_fix.py +++ b/ush/link_fix.py @@ -208,7 +208,7 @@ def link_fix( f"C*{dot_or_uscore}oro_data.tile{tile_rgnl}.halo{nh0}.nc", f"C*{dot_or_uscore}oro_data.tile{tile_rgnl}.halo{nh4}.nc", ] - if ccpp_phys_suite == "FV3_HRRR" or ccpp_phys_suite == "FV3_GFS_v17_p8": + if ccpp_phys_suite == "FV3_HRRR" or ccpp_phys_suite == "FV3_GFS_v15_thompson_mynn_lam3km" or ccpp_phys_suite == "FV3_GFS_v17_p8": fns += [ f"C*{dot_or_uscore}oro_data_ss.tile{tile_rgnl}.halo{nh0}.nc", f"C*{dot_or_uscore}oro_data_ls.tile{tile_rgnl}.halo{nh0}.nc", diff --git a/ush/machine/cheyenne.yaml b/ush/machine/cheyenne.yaml index 2709222192..c738a772fc 100644 --- a/ush/machine/cheyenne.yaml +++ b/ush/machine/cheyenne.yaml @@ -17,7 +17,7 @@ platform: RUN_CMD_PRDGEN: mpirun -np $nprocs RUN_CMD_SERIAL: time RUN_CMD_UTILS: mpirun -np $nprocs - RUN_CMD_AQM: mpirun -np $nprocs + RUN_CMD_NEXUS: mpirun -np $nprocs RUN_CMD_AQMLBC: mpirun -np ${NUMTS} PRE_TASK_CMDS: '{ ulimit -s unlimited; ulimit -a; }' TEST_EXTRN_MDL_SOURCE_BASEDIR: /glade/work/epicufsrt/contrib/UFS_SRW_data/develop/input_model_data diff --git a/ush/machine/hera.yaml b/ush/machine/hera.yaml index 314f770d94..b3caacf97b 100644 --- a/ush/machine/hera.yaml +++ b/ush/machine/hera.yaml @@ -20,7 +20,7 @@ platform: RUN_CMD_PRDGEN: srun --export=ALL RUN_CMD_SERIAL: time RUN_CMD_UTILS: srun --export=ALL - RUN_CMD_AQM: srun -n ${nprocs} --export=ALL + RUN_CMD_NEXUS: srun -n ${nprocs} --export=ALL RUN_CMD_AQMLBC: srun --export=ALL -n ${NUMTS} SCHED_NATIVE_CMD: --export=NONE PRE_TASK_CMDS: '{ ulimit -s unlimited; ulimit -a; }' diff --git a/ush/machine/orion.yaml b/ush/machine/orion.yaml index 2a7d084bc1..a9c8baf031 100644 --- a/ush/machine/orion.yaml +++ b/ush/machine/orion.yaml @@ -20,7 +20,7 @@ platform: RUN_CMD_PRDGEN: srun --export=ALL RUN_CMD_SERIAL: time RUN_CMD_UTILS: srun --export=ALL - RUN_CMD_AQM: srun --export=ALL + RUN_CMD_NEXUS: srun --export=ALL RUN_CMD_AQMLBC: srun --export=ALL -n ${NUMTS} SCHED_NATIVE_CMD: --export=NONE PRE_TASK_CMDS: '{ ulimit -s unlimited; ulimit -a; }' diff --git a/ush/machine/wcoss2.yaml b/ush/machine/wcoss2.yaml index 9ba28b4d3d..b0997381c0 100644 --- a/ush/machine/wcoss2.yaml +++ b/ush/machine/wcoss2.yaml @@ -15,9 +15,9 @@ platform: RUN_CMD_FCST: mpiexec -n ${PE_MEMBER01} -ppn ${PPN_RUN_FCST} --cpu-bind core -depth ${OMP_NUM_THREADS_RUN_FCST} RUN_CMD_POST: mpiexec -n ${nprocs} RUN_CMD_PRDGEN: mpiexec -n ${nprocs} --cpu-bind core cfp - RUN_CMD_SERIAL: mpiexec + RUN_CMD_SERIAL: time RUN_CMD_UTILS: mpiexec -n ${nprocs} - RUN_CMD_AQM: mpiexec -n ${nprocs} -ppn ${ppn_run_aqm} --cpu-bind core -depth ${omp_num_threads_run_aqm} + RUN_CMD_NEXUS: mpiexec -n ${nprocs} -ppn ${PPN_NEXUS_EMISSION} --cpu-bind core -depth ${OMP_NUM_THREADS_NEXUS_EMISSION} RUN_CMD_AQMLBC: mpiexec -n ${NUMTS} SCHED_NATIVE_CMD: -l place=excl PRE_TASK_CMDS: '{ ulimit -s unlimited; ulimit -a; }' @@ -66,9 +66,10 @@ rocoto: task_run_fcst_mem#mem#: cores: native: '{{ platform.SCHED_NATIVE_CMD }}' - nodes: '{{ parent.nnodes }}:ppn={{ parent.ppn }}:tpp={{ task_run_fcst.OMP_NUM_THREADS_RUN_FCST }}' + nodes: '{{ nnodes }}:ppn={{ ppn }}:tpp={{ task_run_fcst.OMP_NUM_THREADS_RUN_FCST }}' nodesize: '{{ platform.NCORES_PER_NODE }}' - task_nexus_emission_#nspt#: - nodes: '{{ parent.nnodes }}:ppn={{ parent.ppn }}:tpp={{ task_nexus_emission.OMP_NUM_THREADS_NEXUS_EMISSION }}' + metatask_nexus_emission: + task_nexus_emission_#nspt#: + nodes: '{{ nnodes }}:ppn={{ ppn }}:tpp={{ task_nexus_emission.OMP_NUM_THREADS_NEXUS_EMISSION }}' task_fire_emission: native: diff --git a/ush/predef_grid_params.yaml b/ush/predef_grid_params.yaml index 9674ca68c9..a5ab412a26 100644 --- a/ush/predef_grid_params.yaml +++ b/ush/predef_grid_params.yaml @@ -204,7 +204,7 @@ DT_ATMOS: 36 LAYOUT_X: 28 LAYOUT_Y: 28 - BLOCKSIZE: 29 + BLOCKSIZE: 28 QUILTING: WRTCMP_write_groups: 1 WRTCMP_write_tasks_per_group: 28 diff --git a/ush/setup.py b/ush/setup.py index b133612bef..d4ad08d4ab 100644 --- a/ush/setup.py +++ b/ush/setup.py @@ -728,6 +728,27 @@ def get_location(xcs, fmt, expt_cfg): rocoto_config['cycledefs']['long_forecast'] = fcst_cdef + # check the availability of restart intervals for restart capability of forecast + do_fcst_restart = fcst_config.get("DO_FCST_RESTART") + if do_fcst_restart: + restart_interval = fcst_config.get("RESTART_INTERVAL") + restart_hrs = [] + if " " in str(restart_interval): + restart_hrs = restart_interval.split() + else: + restart_hrs.append(str(restart_interval)) + + lbc_spec_intvl_hrs = expt_config["task_get_extrn_lbcs"]["LBC_SPEC_INTVL_HRS"] + for irst in restart_hrs: + rem_rst = int(irst) % lbc_spec_intvl_hrs + if rem_rst != 0: + raise Exception( + f""" + The restart interval is not divided by LBC_SPEC_INTVL_HRS: + RESTART_INTERVAL = {irst} + LBC_SPEC_INTVL_HRS = {lbc_spec_intvl_hrs}""" + ) + # # ----------------------------------------------------------------------- # diff --git a/ush/update_input_nml.py b/ush/update_input_nml.py new file mode 100644 index 0000000000..703032a96c --- /dev/null +++ b/ush/update_input_nml.py @@ -0,0 +1,174 @@ +#!/usr/bin/env python3 + +import os +import sys +import argparse +import unittest +import logging +from textwrap import dedent + +from python_utils import ( + import_vars, + print_input_args, + print_info_msg, + print_err_msg_exit, + cfg_to_yaml_str, + load_shell_config, + flatten_dict, +) + +from set_namelist import set_namelist + + +def update_input_nml(run_dir): + """Update the FV3 input.nml file in the specified run directory + + Args: + run_dir: run directory + Returns: + Boolean + """ + + print_input_args(locals()) + + # import all environment variables + import_vars() + + # + # ----------------------------------------------------------------------- + # + # Update the FV3 input.nml file in the specified run directory. + # + # ----------------------------------------------------------------------- + # + print_info_msg( + f""" + Updating the FV3 input.nml file in the specified run directory (run_dir): + run_dir = '{run_dir}'""", + verbose=VERBOSE, + ) + # + # ----------------------------------------------------------------------- + # + # Set new values of the specific parameters to be updated. + # + # ----------------------------------------------------------------------- + # + settings = {} + + # For restart run + if args.restart: + settings["fv_core_nml"] = { + "external_ic": False, + "make_nh": False, + "mountain": True, + "na_init": 0, + "nggps_ic": False, + "warm_start": True, + } + + settings["gfs_physics_nml"] = { + "nstf_name": [2, 0, 0, 0, 0], + } + + # For AQM_NA_13km domain for air quality modeling + if args.aqm_na_13km: + settings["fv_core_nml"] = { + "k_split": 1, + "n_split": 8, + } + + + settings_str = cfg_to_yaml_str(settings) + + print_info_msg( + dedent( + f""" + The variable 'settings' specifying values to be used in the FV3 'input.nml' + file for restart has been set as follows:\n + settings =\n\n""" + ) + + settings_str, + verbose=VERBOSE, + ) + # + # ----------------------------------------------------------------------- + # + # Call a python script to update the experiment's actual FV3 INPUT.NML + # file for restart. + # + # ----------------------------------------------------------------------- + # + fv3_input_nml_fp = os.path.join(run_dir, FV3_NML_FN) + + try: + set_namelist( + [ + "-q", + "-n", + fv3_input_nml_fp, + "-u", + settings_str, + "-o", + fv3_input_nml_fp, + ] + ) + except: + logging.exception( + dedent( + f""" + Call to python script set_namelist.py to generate an FV3 namelist file + failed. Parameters passed to this script are: + Full path to base namelist file: + fv3_input_nml_fp = '{fv3_input_nml_fp}' + Full path to output namelist file: + fv3_input_nml_fp = '{fv3_input_nml_fp}' + Namelist settings specified on command line:\n + settings =\n\n""" + ) + + settings_str + ) + return False + + return True + + +def parse_args(argv): + """Parse command line arguments""" + parser = argparse.ArgumentParser(description="Update FV3 input.nml file for restart.") + + parser.add_argument( + "-r", "--run_dir", + dest="run_dir", + required=True, + help="Run directory." + ) + + parser.add_argument( + "-p", "--path-to-defns", + dest="path_to_defns", + required=True, + help="Path to var_defns file.", + ) + + parser.add_argument( + "--restart", + action='store_true', + help='Update for restart') + + parser.add_argument( + "--aqm_na_13km", + action='store_true', + help='Update for AQM_NA_13km in air quality modeling') + + return parser.parse_args(argv) + + +if __name__ == "__main__": + args = parse_args(sys.argv[1:]) + cfg = load_shell_config(args.path_to_defns) + cfg = flatten_dict(cfg) + import_vars(dictionary=cfg) + update_input_nml( + run_dir=args.run_dir, + )