From 837eb5f9389c3351ee31cc252c3d389165df5934 Mon Sep 17 00:00:00 2001 From: Michael Kavulich Date: Sun, 31 Jan 2021 20:42:42 -0700 Subject: [PATCH 01/10] Add MACOS and Generic Linux options for regional_workflow (#402) This PR adds generic platforms to the regional_workflow, not specific to any one machine, that should allow users to run the ufs-srweather-app on any UNIX-based machine, without a workflow manager, so long as the NCEPLIBS and other prerequisites have been properly installed. This can be done using the scripts described in regional_workflow/ush/wrappers/README.md; additional documentation is currently being written. Users can utilize these options by setting the MACHINE variable in config.sh to either "LINUX" or "MACOS". The LINUX option should allow most users to run the ufs-srweather-app on a generic Linux OS machine. The MACOS option is for MacOS/Darwin operating systems; this needs to be kept separate because the MacOS version of bash is very old, and missing some functionality, as well as several GNU Linux utilities having different functionality and/or names. "Generic Linux" test was run on Cheyenne machine (GNU 9.1.0 compilers) as a fresh install, including stand-alone install of NCEPLIBS, with no reference to staged or pre-built input files. This was run without rocoto or directly submitting jobs via PBS, but rather the entire workflow was run interactively on a compute node (using the `qinteractive` command which emulated the running of the workflow on a machine with no job scheduler). On MacOS (Catalina, 10.15.7), with GNU 10.1.0 compilers, was able to successfully generate workflow, and run end-to-end successfully. Currently there is a bug in UFS_UTILS that makes the make_orog test fail; UFS UTILS PR245 must be merged to fix this. Resolves #369 --- jobs/JREGIONAL_GET_EXTRN_MDL_FILES | 2 +- jobs/JREGIONAL_MAKE_GRID | 2 +- jobs/JREGIONAL_MAKE_ICS | 2 +- jobs/JREGIONAL_MAKE_LBCS | 2 +- jobs/JREGIONAL_MAKE_OROG | 2 +- jobs/JREGIONAL_MAKE_SFC_CLIMO | 2 +- jobs/JREGIONAL_RUN_FCST | 2 +- jobs/JREGIONAL_RUN_POST | 4 +- scripts/exregional_get_extrn_mdl_files.sh | 6 +- scripts/exregional_make_grid.sh | 20 +- scripts/exregional_make_ics.sh | 17 +- scripts/exregional_make_lbcs.sh | 19 +- scripts/exregional_make_orog.sh | 10 +- scripts/exregional_make_sfc_climo.sh | 10 +- scripts/exregional_run_fcst.sh | 14 +- scripts/exregional_run_post.sh | 16 +- tests/run_experiments.sh | 35 +- ush/bash_utils/change_case.sh | 241 ++++++++++ ush/bash_utils/check_for_preexist_dir_file.sh | 2 +- ush/bash_utils/check_var_valid_value.sh | 2 +- ush/bash_utils/count_files.sh | 2 +- ush/bash_utils/define_macos_utilities.sh | 45 ++ ush/bash_utils/filesys_cmds_vrfy.sh | 6 +- ush/bash_utils/get_charvar_from_netcdf.sh | 4 +- ush/bash_utils/get_elem_inds.sh | 4 +- .../get_manage_externals_config_property.sh | 6 +- ush/bash_utils/interpol_to_arbit_CRES.sh | 2 +- ush/bash_utils/is_array.sh | 2 +- ush/bash_utils/is_element_of.sh | 2 +- ush/bash_utils/print_input_args.sh | 6 +- ush/bash_utils/print_msg.sh | 8 +- ush/bash_utils/process_args.sh | 4 +- ush/bash_utils/save_restore_shell_opts.sh | 2 +- ush/bash_utils/set_bash_param.sh | 4 +- ush/bash_utils/set_file_param.sh | 4 +- ush/cmp_expt_to_baseline.sh | 411 ------------------ ush/cmp_rundirs_ncfiles.sh | 100 ----- ush/compare_config_scripts.sh | 8 +- ush/config_defaults.sh | 30 ++ ush/create_diag_table_files.sh | 2 +- ush/create_model_configure_file.sh | 7 +- ush/generate_FV3LAM_wflow.sh | 109 ++--- ush/get_extrn_mdl_file_dir_info.sh | 36 +- ush/launch_FV3LAM_wflow.sh | 20 +- ush/link_fix.sh | 4 +- ush/load_modules_run_task.sh | 8 +- ush/make_grid_mosaic_file.sh | 6 +- ush/set_FV3nml_sfc_climo_filenames.sh | 6 +- ush/set_FV3nml_stoch_params.sh | 2 +- ush/set_cycle_dates.sh | 4 +- ush/set_extrn_mdl_params.sh | 100 ++--- ush/set_gridparams_ESGgrid.sh | 2 +- ush/set_gridparams_GFDLgrid.sh | 6 +- ush/set_ozone_param.sh | 8 +- ush/set_predef_grid_params.sh | 2 +- ush/set_thompson_mp_fix_files.sh | 4 +- ush/setup.sh | 209 ++++++--- ush/source_util_funcs.sh | 24 +- ush/valid_param_vals.sh | 3 +- 59 files changed, 819 insertions(+), 803 deletions(-) create mode 100644 ush/bash_utils/change_case.sh create mode 100644 ush/bash_utils/define_macos_utilities.sh delete mode 100755 ush/cmp_expt_to_baseline.sh delete mode 100755 ush/cmp_rundirs_ncfiles.sh diff --git a/jobs/JREGIONAL_GET_EXTRN_MDL_FILES b/jobs/JREGIONAL_GET_EXTRN_MDL_FILES index 6b373895e..bfe2d7bce 100755 --- a/jobs/JREGIONAL_GET_EXTRN_MDL_FILES +++ b/jobs/JREGIONAL_GET_EXTRN_MDL_FILES @@ -57,7 +57,7 @@ # #----------------------------------------------------------------------- # -scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) +scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) scrfunc_fn=$( basename "${scrfunc_fp}" ) scrfunc_dir=$( dirname "${scrfunc_fp}" ) # diff --git a/jobs/JREGIONAL_MAKE_GRID b/jobs/JREGIONAL_MAKE_GRID index 641196137..bbf22e024 100755 --- a/jobs/JREGIONAL_MAKE_GRID +++ b/jobs/JREGIONAL_MAKE_GRID @@ -125,7 +125,7 @@ # #----------------------------------------------------------------------- # -scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) +scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) scrfunc_fn=$( basename "${scrfunc_fp}" ) scrfunc_dir=$( dirname "${scrfunc_fp}" ) # diff --git a/jobs/JREGIONAL_MAKE_ICS b/jobs/JREGIONAL_MAKE_ICS index 01027b4ac..9c5125f41 100755 --- a/jobs/JREGIONAL_MAKE_ICS +++ b/jobs/JREGIONAL_MAKE_ICS @@ -27,7 +27,7 @@ # #----------------------------------------------------------------------- # -scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) +scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) scrfunc_fn=$( basename "${scrfunc_fp}" ) scrfunc_dir=$( dirname "${scrfunc_fp}" ) # diff --git a/jobs/JREGIONAL_MAKE_LBCS b/jobs/JREGIONAL_MAKE_LBCS index b46d0e950..bc7afbaf7 100755 --- a/jobs/JREGIONAL_MAKE_LBCS +++ b/jobs/JREGIONAL_MAKE_LBCS @@ -27,7 +27,7 @@ # #----------------------------------------------------------------------- # -scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) +scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) scrfunc_fn=$( basename "${scrfunc_fp}" ) scrfunc_dir=$( dirname "${scrfunc_fp}" ) # diff --git a/jobs/JREGIONAL_MAKE_OROG b/jobs/JREGIONAL_MAKE_OROG index e3935037d..50b6c0369 100755 --- a/jobs/JREGIONAL_MAKE_OROG +++ b/jobs/JREGIONAL_MAKE_OROG @@ -27,7 +27,7 @@ # #----------------------------------------------------------------------- # -scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) +scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) scrfunc_fn=$( basename "${scrfunc_fp}" ) scrfunc_dir=$( dirname "${scrfunc_fp}" ) # diff --git a/jobs/JREGIONAL_MAKE_SFC_CLIMO b/jobs/JREGIONAL_MAKE_SFC_CLIMO index f2993bbaf..24af27bfa 100755 --- a/jobs/JREGIONAL_MAKE_SFC_CLIMO +++ b/jobs/JREGIONAL_MAKE_SFC_CLIMO @@ -27,7 +27,7 @@ # #----------------------------------------------------------------------- # -scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) +scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) scrfunc_fn=$( basename "${scrfunc_fp}" ) scrfunc_dir=$( dirname "${scrfunc_fp}" ) # diff --git a/jobs/JREGIONAL_RUN_FCST b/jobs/JREGIONAL_RUN_FCST index a4806c765..dbd4c80c4 100755 --- a/jobs/JREGIONAL_RUN_FCST +++ b/jobs/JREGIONAL_RUN_FCST @@ -37,7 +37,7 @@ # #----------------------------------------------------------------------- # -scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) +scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) scrfunc_fn=$( basename "${scrfunc_fp}" ) scrfunc_dir=$( dirname "${scrfunc_fp}" ) # diff --git a/jobs/JREGIONAL_RUN_POST b/jobs/JREGIONAL_RUN_POST index e4e2122e4..71cc9d85e 100755 --- a/jobs/JREGIONAL_RUN_POST +++ b/jobs/JREGIONAL_RUN_POST @@ -36,7 +36,7 @@ # #----------------------------------------------------------------------- # -scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) +scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) scrfunc_fn=$( basename "${scrfunc_fp}" ) scrfunc_dir=$( dirname "${scrfunc_fp}" ) # @@ -100,7 +100,7 @@ cd_vrfy "${fhr_dir}" # #----------------------------------------------------------------------- # -fhr=$( printf "%s" "${fhr}" | sed -n -r -e "s/^([0-9]+)$/\1/p" ) +fhr=$( printf "%s" "${fhr}" | $SED -n -r -e "s/^([0-9]+)$/\1/p" ) if [ -z "$fhr" ]; then print_err_msg_exit "\ The forecast hour (fhr) must be a non-empty string consisting of only diff --git a/scripts/exregional_get_extrn_mdl_files.sh b/scripts/exregional_get_extrn_mdl_files.sh index 35e8d373b..ac5127eb8 100755 --- a/scripts/exregional_get_extrn_mdl_files.sh +++ b/scripts/exregional_get_extrn_mdl_files.sh @@ -27,7 +27,7 @@ # #----------------------------------------------------------------------- # -scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) +scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) scrfunc_fn=$( basename "${scrfunc_fp}" ) scrfunc_dir=$( dirname "${scrfunc_fp}" ) # @@ -524,7 +524,7 @@ not happen." # to the current directory. Then move the files. # rel_dir=$( printf "%s" "${extrn_mdl_arcvrel_dir}" | \ - sed -r 's%^(\/|\.\/)([^/]*)(.*)%\2\3%' ) + $SED -r 's%^(\/|\.\/)([^/]*)(.*)%\2\3%' ) mv_vrfy ${rel_dir}/* . # # Get the first subdirectory in rel_dir, i.e. the subdirectory before the @@ -533,7 +533,7 @@ not happen." # it. # subdir_to_remove=$( printf "%s" "${rel_dir}" | \ - sed -r 's%^([^/]*)(.*)%\1%' ) + $SED -r 's%^([^/]*)(.*)%\1%' ) rm_vrfy -rf ./${subdir_to_remove} # # If extrn_mdl_arcvrel_dir does not start with a "/" (and it is not diff --git a/scripts/exregional_make_grid.sh b/scripts/exregional_make_grid.sh index a7921b5bb..1d06aa2ed 100755 --- a/scripts/exregional_make_grid.sh +++ b/scripts/exregional_make_grid.sh @@ -39,7 +39,7 @@ # #----------------------------------------------------------------------- # -scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) +scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) scrfunc_fn=$( basename "${scrfunc_fp}" ) scrfunc_dir=$( dirname "${scrfunc_fp}" ) # @@ -147,6 +147,14 @@ case $MACHINE in ulimit -a ;; + "MACOS") + APRUN=time + ;; + + "LINUX") + APRUN=time + ;; + *) print_err_msg_exit "\ Run command has not been specified for this machine: @@ -433,11 +441,19 @@ uniform cubed-sphere grid equivalent resolution returned with nonzero exit code: exec_fp = \"${exec_fp}\"" +# Make sure 'ncdump' is available before we try to use it +if ! command -v ncdump &> /dev/null +then + print_err_msg_exit "\ +The utility 'ncdump' was not found in the environment. Be sure to add the +netCDF 'bin/' directory to your PATH." +fi + # Make the following (reading of res_equiv) a function in another file # so that it can be used both here and in the exregional_make_orog.sh # script. res_equiv=$( ncdump -h "${grid_fp}" | \ - grep -o ":RES_equiv = [0-9]\+" | grep -o "[0-9]" ) || \ + grep -o ":RES_equiv = [0-9]\+" | $SED 's/[^0-9]*//g' ) || \ print_err_msg_exit "\ Attempt to extract the equivalent global uniform cubed-sphere grid reso- lution from the grid file (grid_fp) failed: diff --git a/scripts/exregional_make_ics.sh b/scripts/exregional_make_ics.sh index c81efddf2..3835d9903 100755 --- a/scripts/exregional_make_ics.sh +++ b/scripts/exregional_make_ics.sh @@ -27,7 +27,7 @@ # #----------------------------------------------------------------------- # -scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) +scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) scrfunc_fn=$( basename "${scrfunc_fp}" ) scrfunc_dir=$( dirname "${scrfunc_fp}" ) # @@ -116,6 +116,21 @@ case "$MACHINE" in APRUN="ibrun" ;; + "MACOS") + APRUN=$RUN_CMD_UTILS + ;; + + "LINUX") + APRUN=$RUN_CMD_UTILS + ;; + + *) + print_err_msg_exit "\ +Run command has not been specified for this machine: + MACHINE = \"$MACHINE\" + APRUN = \"$APRUN\"" + ;; + esac # #----------------------------------------------------------------------- diff --git a/scripts/exregional_make_lbcs.sh b/scripts/exregional_make_lbcs.sh index 5205b74e1..64109e217 100755 --- a/scripts/exregional_make_lbcs.sh +++ b/scripts/exregional_make_lbcs.sh @@ -27,7 +27,7 @@ # #----------------------------------------------------------------------- # -scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) +scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) scrfunc_fn=$( basename "${scrfunc_fp}" ) scrfunc_dir=$( dirname "${scrfunc_fp}" ) # @@ -116,6 +116,21 @@ case "$MACHINE" in APRUN="ibrun" ;; + "MACOS") + APRUN=$RUN_CMD_UTILS + ;; + + "LINUX") + APRUN=$RUN_CMD_UTILS + ;; + + *) + print_err_msg_exit "\ +Run command has not been specified for this machine: + MACHINE = \"$MACHINE\" + APRUN = \"$APRUN\"" + ;; + esac # #----------------------------------------------------------------------- @@ -409,7 +424,7 @@ list file has not specified for this external LBC model (EXTRN_MDL_NAME_LBCS): dd="${EXTRN_MDL_CDATE:6:2}" hh="${EXTRN_MDL_CDATE:8:2}" - cdate_crnt_fhr=$( date --utc --date "${yyyymmdd} ${hh} UTC + ${fhr} hours" "+%Y%m%d%H" ) + cdate_crnt_fhr=$( $DATE_UTIL --utc --date "${yyyymmdd} ${hh} UTC + ${fhr} hours" "+%Y%m%d%H" ) # # Get the month, day, and hour corresponding to the current forecast time # of the the external model. diff --git a/scripts/exregional_make_orog.sh b/scripts/exregional_make_orog.sh index 873fab97d..7b7d71c66 100755 --- a/scripts/exregional_make_orog.sh +++ b/scripts/exregional_make_orog.sh @@ -35,7 +35,7 @@ # #----------------------------------------------------------------------- # -scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) +scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) scrfunc_fn=$( basename "${scrfunc_fp}" ) scrfunc_dir=$( dirname "${scrfunc_fp}" ) # @@ -147,6 +147,14 @@ case $MACHINE in export APRUN="time" ;; + "MACOS") + APRUN=time + ;; + + "LINUX") + APRUN=time + ;; + *) print_err_msg_exit "\ Run command has not been specified for this machine: diff --git a/scripts/exregional_make_sfc_climo.sh b/scripts/exregional_make_sfc_climo.sh index 5d5c526d8..e19fca8b7 100755 --- a/scripts/exregional_make_sfc_climo.sh +++ b/scripts/exregional_make_sfc_climo.sh @@ -35,7 +35,7 @@ # #----------------------------------------------------------------------- # -scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) +scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) scrfunc_fn=$( basename "${scrfunc_fp}" ) scrfunc_dir=$( dirname "${scrfunc_fp}" ) # @@ -170,6 +170,14 @@ case $MACHINE in APRUN="ibrun -np ${nprocs}" ;; + "MACOS") + APRUN=$RUN_CMD_UTILS + ;; + + "LINUX") + APRUN=$RUN_CMD_UTILS + ;; + *) print_err_msg_exit "\ Run command has not been specified for this machine: diff --git a/scripts/exregional_run_fcst.sh b/scripts/exregional_run_fcst.sh index 7f78b4cf6..4c4161e36 100755 --- a/scripts/exregional_run_fcst.sh +++ b/scripts/exregional_run_fcst.sh @@ -35,7 +35,7 @@ # #----------------------------------------------------------------------- # -scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) +scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) scrfunc_fn=$( basename "${scrfunc_fp}" ) scrfunc_dir=$( dirname "${scrfunc_fp}" ) # @@ -144,6 +144,14 @@ case $MACHINE in APRUN="ibrun -np ${PE_MEMBER01}" ;; + "MACOS") + APRUN=$RUN_CMD_FCST + ;; + + "LINUX") + APRUN=$RUN_CMD_FCST + ;; + *) print_err_msg_exit "\ Run command has not been specified for this machine: @@ -360,9 +368,9 @@ for (( i=0; i<${num_symlinks}; i++ )); do mapping="${CYCLEDIR_LINKS_TO_FIXam_FILES_MAPPING[$i]}" symlink=$( printf "%s\n" "$mapping" | \ - sed -n -r -e "s/${regex_search}/\1/p" ) + $SED -n -r -e "s/${regex_search}/\1/p" ) target=$( printf "%s\n" "$mapping" | \ - sed -n -r -e "s/${regex_search}/\2/p" ) + $SED -n -r -e "s/${regex_search}/\2/p" ) symlink="${run_dir}/$symlink" target="$FIXam/$target" diff --git a/scripts/exregional_run_post.sh b/scripts/exregional_run_post.sh index eaf79e12b..89f15ce51 100755 --- a/scripts/exregional_run_post.sh +++ b/scripts/exregional_run_post.sh @@ -27,7 +27,7 @@ # #----------------------------------------------------------------------- # -scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) +scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) scrfunc_fn=$( basename "${scrfunc_fp}" ) scrfunc_dir=$( dirname "${scrfunc_fp}" ) # @@ -135,6 +135,14 @@ case $MACHINE in APRUN="ibrun -n $nprocs" ;; + "MACOS") + APRUN=$RUN_CMD_POST + ;; + + "LINUX") + APRUN=$RUN_CMD_POST + ;; + *) print_err_msg_exit "\ Run command has not been specified for this machine: @@ -207,7 +215,7 @@ tmmark="tm00" dyn_file="${run_dir}/dynf${fhr}.nc" phy_file="${run_dir}/phyf${fhr}.nc" -post_time=$( date --utc --date "${yyyymmdd} ${hh} UTC + ${fhr} hours" "+%Y%m%d%H" ) +post_time=$( $DATE_UTIL --utc --date "${yyyymmdd} ${hh} UTC + ${fhr} hours" "+%Y%m%d%H" ) post_yyyy=${post_time:0:4} post_mm=${post_time:4:2} post_dd=${post_time:6:2} @@ -278,8 +286,8 @@ mv_vrfy BGRD3D.GrbF${post_fhr} ${postprd_dir}/${NET}.t${cyc}z.bgrd3df${fhr}.${tm # and hh are calculated above, i.e. start_date is just cdate but with a # space inserted between the dd and hh. If so, just use "$yyyymmdd $hh" # instead of calling sed. -start_date=$( echo "${cdate}" | sed 's/\([[:digit:]]\{2\}\)$/ \1/' ) -basetime=$( date +%y%j%H%M -d "${start_date}" ) +start_date=$( echo "${cdate}" | $SED 's/\([[:digit:]]\{2\}\)$/ \1/' ) +basetime=$( $DATE_UTIL +%y%j%H%M -d "${start_date}" ) ln_vrfy -fs ${postprd_dir}/${NET}.t${cyc}z.bgdawpf${fhr}.${tmmark}.grib2 \ ${postprd_dir}/BGDAWP_${basetime}f${fhr}00 ln_vrfy -fs ${postprd_dir}/${NET}.t${cyc}z.bgrd3df${fhr}.${tmmark}.grib2 \ diff --git a/tests/run_experiments.sh b/tests/run_experiments.sh index 47ac5b477..03ba9afcb 100755 --- a/tests/run_experiments.sh +++ b/tests/run_experiments.sh @@ -9,7 +9,12 @@ # #----------------------------------------------------------------------- # -scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) +if [[ $(uname -s) == Darwin ]]; then + command -v greadlink >/dev/null 2>&1 || { echo >&2 "For Darwin-based operating systems (MacOS), the 'greadlink' utility is required to run the UFS SRW Application. Reference the User's Guide for more information about platform requirements. Aborting."; exit 1; } + scrfunc_fp=$( greadlink -f "${BASH_SOURCE[0]}" ) +else + scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) +fi scrfunc_fn=$( basename "${scrfunc_fp}" ) scrfunc_dir=$( dirname "${scrfunc_fp}" ) # @@ -150,7 +155,7 @@ fi # #----------------------------------------------------------------------- # -expts_list_fp=$( readlink -f "${expts_file}" ) +expts_list_fp=$( $READLINK -f "${expts_file}" ) if [ ! -f "${expts_list_fp}" ]; then print_err_msg_exit "\ @@ -222,20 +227,20 @@ for (( i=0; i<=$((num_lines-1)); i++ )); do # all_lines. # all_lines[$i]=$( printf "%s" "${all_lines[$i]}" | \ - sed -r -e "s/^[ ]*//" -e "s/[ ]*$//" ) + $SED -r -e "s/^[ ]*//" -e "s/[ ]*$//" ) # # Remove spaces before and after all field separators in the current # element of all_lines. Note that we use the pipe symbol, "|", as the # field separator. # all_lines[$i]=$( printf "%s" "${all_lines[$i]}" | \ - sed -r -e "s/[ ]*${field_separator}[ ]*/${field_separator}/g" ) + $SED -r -e "s/[ ]*${field_separator}[ ]*/${field_separator}/g" ) # # If the last character of the current line is a field separator, remove # it. # all_lines[$i]=$( printf "%s" "${all_lines[$i]}" | \ - sed -r -e "s/${field_separator}$//g" ) + $SED -r -e "s/${field_separator}$//g" ) # # If after the processing above the current element of all_lines is not # empty, save it as the next element of expts_list. @@ -286,9 +291,9 @@ Processing experiment \"${expts_list[$i]}\" ..." # regex_search="^([^${field_separator}]*)(${field_separator}(.*)|)" baseline_name=$( printf "%s" "${expts_list[$i]}" | \ - sed -r -n -e "s/${regex_search}/\1/p" ) + $SED -r -n -e "s/${regex_search}/\1/p" ) remainder=$( printf "%s" "${expts_list[$i]}" | \ - sed -r -n -e "s/${regex_search}/\3/p" ) + $SED -r -n -e "s/${regex_search}/\3/p" ) # # Get the names and corresponding values of the variables that need to # be modified in the current baseline to obtain the current experiment. @@ -304,18 +309,18 @@ Processing experiment \"${expts_list[$i]}\" ..." # of remainder back into itself. # next_field=$( printf "%s" "$remainder" | \ - sed -r -e "s/${regex_search}/\1/" ) + $SED -r -e "s/${regex_search}/\1/" ) remainder=$( printf "%s" "$remainder" | \ - sed -r -e "s/${regex_search}/\3/" ) + $SED -r -e "s/${regex_search}/\3/" ) # # Save the name of the variable in the variable-value pair obtained # above in the array modvar_name. Then save the value in the variable- # value pair in the array modvar_value. # modvar_name[${num_mod_vars}]=$( printf "%s" "${next_field}" | \ - sed -r -e "s/^([^=]*)=(.*)/\1/" ) + $SED -r -e "s/^([^=]*)=(.*)/\1/" ) modvar_value[${num_mod_vars}]=$( printf "%s" "${next_field}" | \ - sed -r -e "s/^([^=]*)=(\")?([^\"]+*)(\")?/\3/" ) + $SED -r -e "s/^([^=]*)=(\")?([^\"]+*)(\")?/\3/" ) # # Increment the index that keeps track of the number of variables that # need to be modified in the current baseline to obtain the current ex- @@ -417,7 +422,7 @@ Please correct and rerun." # #----------------------------------------------------------------------- # - MACHINE="${machine^^}" + MACHINE=$(echo_uppercase $machine) ACCOUNT="${account}" # Note that if expt_basedir is a null (or unset) string, ${expt_basedir:+/} @@ -667,7 +672,7 @@ COMINgfs=\"${COMINgfs}\"" # # Set STMP and PTMP. # - nco_basedir=$( readlink -f "$homerrfs/../../nco_dirs" ) + nco_basedir=$( $READLINK -f "$homerrfs/../../nco_dirs" ) STMP=${stmp:-"${nco_basedir}/stmp"} PTMP=${ptmp:-"${nco_basedir}/ptmp"} @@ -715,7 +720,7 @@ machine (MACHINE): fi elif [ "${EXTRN_MDL_NAME_ICS}" = "HRRR" ] || \ [ "${EXTRN_MDL_NAME_ICS}" = "RAP" ]; then - EXTRN_MDL_FILES_ICS=( "${EXTRN_MDL_NAME_ICS,,}.out.for_f000" ) + EXTRN_MDL_FILES_ICS=( "$(echo_lowercase $EXTRN_MDL_NAME_ICS).out.for_f000" ) fi EXTRN_MDL_SOURCE_BASEDIR_LBCS="${extrn_mdl_source_basedir}/${EXTRN_MDL_NAME_LBCS}" @@ -745,7 +750,7 @@ boundary conditions specification interval (LBC_SPEC_INTVL_HRS): fi elif [ "${EXTRN_MDL_NAME_LBCS}" = "HRRR" ] || \ [ "${EXTRN_MDL_NAME_LBCS}" = "RAP" ]; then - EXTRN_MDL_FILES_LBCS=( "${EXTRN_MDL_FILES_LBCS[@]/#/${EXTRN_MDL_NAME_LBCS,,}.out.for_f}" ) + EXTRN_MDL_FILES_LBCS=( "${EXTRN_MDL_FILES_LBCS[@]/#/$(echo_lowercase $EXTRN_MDL_NAME_LBCS).out.for_f}" ) fi str=${str}" diff --git a/ush/bash_utils/change_case.sh b/ush/bash_utils/change_case.sh new file mode 100644 index 000000000..0fe69c853 --- /dev/null +++ b/ush/bash_utils/change_case.sh @@ -0,0 +1,241 @@ +# +#----------------------------------------------------------------------- +# +# This file defines functions used to change string to all uppercase or +# all lowercase +# +#----------------------------------------------------------------------- +# + + +# +#----------------------------------------------------------------------- +# +# Function to echo the given string as an uppercase string +# +#----------------------------------------------------------------------- +# +function echo_uppercase() { +# +#----------------------------------------------------------------------- +# +# Save current shell options (in a global array). Then set new options +# for this script/function. +# +#----------------------------------------------------------------------- +# + { save_shell_opts; set -u +x; } > /dev/null 2>&1 +# +#----------------------------------------------------------------------- +# +# Get the full path to the file in which this script/function is located +# (scrfunc_fp), the name of that file (scrfunc_fn), and the directory in +# which the file is located (scrfunc_dir). +# +#----------------------------------------------------------------------- +# + local scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) + local scrfunc_fn=$( basename "${scrfunc_fp}" ) + local scrfunc_dir=$( dirname "${scrfunc_fp}" ) +# +#----------------------------------------------------------------------- +# +# Get the name of this function. +# +#----------------------------------------------------------------------- +# + local func_name="${FUNCNAME[0]}" +# +#----------------------------------------------------------------------- +# +# Get information about the script or function that calls this function. +# Note that caller_name will be set as follows: +# +# 1) If the caller is a function, caller_name will be set to the name of +# that function. +# 2) If the caller is a sourced script, caller_name will be set to +# "script". Note that a sourced script cannot be the top level +# script since by defintion, it is sourced by another script or func- +# tion. +# 3) If the caller is the top-level script, caller_name will be set to +# "main". +# +# Thus, if caller_name is set to "script" or "main", the caller is a +# script, and if it is set to anything else, the caller is a function. +# +#----------------------------------------------------------------------- +# + local caller_fp=$( $READLINK -f "${BASH_SOURCE[1]}" ) + local caller_fn=$( basename "${caller_fp}" ) + local caller_dir=$( dirname "${caller_fp}" ) + local caller_name="${FUNCNAME[1]}" +# +# Get input string + + local input + + if [ "$#" -eq 1 ]; then + + input="$1" + +# +#----------------------------------------------------------------------- +# +# If no arguments or more than one, print out a usage message and exit. +# +#----------------------------------------------------------------------- +# + else + + print_err_msg_exit " +Incorrect number of arguments specified: + + Function name: \"${func_name}\" + Number of arguments specified: $# + +Usage: + + ${func_name} string + +where: + + string: + This is the string that should be converted to uppercase and echoed. +" + + fi + +# Echo the input string as upperercase + +echo $input| tr '[a-z]' '[A-Z]' + +# +#----------------------------------------------------------------------- +# +# Restore the shell options saved at the beginning of this script/func- +# tion. +# +#----------------------------------------------------------------------- +# + { restore_shell_opts; } > /dev/null 2>&1 + + +} + + +# +#----------------------------------------------------------------------- +# +# Function to echo the given string as a lowercase string +# +#----------------------------------------------------------------------- +# +function echo_lowercase() { +# +#----------------------------------------------------------------------- +# +# Save current shell options (in a global array). Then set new options +# for this script/function. +# +#----------------------------------------------------------------------- +# + { save_shell_opts; set -u +x; } > /dev/null 2>&1 +# +#----------------------------------------------------------------------- +# +# Get the full path to the file in which this script/function is located +# (scrfunc_fp), the name of that file (scrfunc_fn), and the directory in +# which the file is located (scrfunc_dir). +# +#----------------------------------------------------------------------- +# + local scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) + local scrfunc_fn=$( basename "${scrfunc_fp}" ) + local scrfunc_dir=$( dirname "${scrfunc_fp}" ) +# +#----------------------------------------------------------------------- +# +# Get the name of this function. +# +#----------------------------------------------------------------------- +# + local func_name="${FUNCNAME[0]}" +# +#----------------------------------------------------------------------- +# +# Get information about the script or function that calls this function. +# Note that caller_name will be set as follows: +# +# 1) If the caller is a function, caller_name will be set to the name of +# that function. +# 2) If the caller is a sourced script, caller_name will be set to +# "script". Note that a sourced script cannot be the top level +# script since by defintion, it is sourced by another script or func- +# tion. +# 3) If the caller is the top-level script, caller_name will be set to +# "main". +# +# Thus, if caller_name is set to "script" or "main", the caller is a +# script, and if it is set to anything else, the caller is a function. +# +#----------------------------------------------------------------------- +# + local caller_fp=$( $READLINK -f "${BASH_SOURCE[1]}" ) + local caller_fn=$( basename "${caller_fp}" ) + local caller_dir=$( dirname "${caller_fp}" ) + local caller_name="${FUNCNAME[1]}" +# +# Get input string + + local input + + if [ "$#" -eq 1 ]; then + + input="$1" + +# +#----------------------------------------------------------------------- +# +# If no arguments or more than one, print out a usage message and exit. +# +#----------------------------------------------------------------------- +# + else + + print_err_msg_exit " +Incorrect number of arguments specified: + + Function name: \"${func_name}\" + Number of arguments specified: $# + +Usage: + + ${func_name} string + +where: + + string: + This is the string that should be converted to lowercase and echoed. +" + + fi + +# Echo the input string as lowercase + +echo $input| tr '[A-Z]' '[a-z]' + +# +#----------------------------------------------------------------------- +# +# Restore the shell options saved at the beginning of this script/func- +# tion. +# +#----------------------------------------------------------------------- +# + { restore_shell_opts; } > /dev/null 2>&1 + + +} + + + diff --git a/ush/bash_utils/check_for_preexist_dir_file.sh b/ush/bash_utils/check_for_preexist_dir_file.sh index 7b9b59772..dac2688a3 100644 --- a/ush/bash_utils/check_for_preexist_dir_file.sh +++ b/ush/bash_utils/check_for_preexist_dir_file.sh @@ -26,7 +26,7 @@ function check_for_preexist_dir_file() { # #----------------------------------------------------------------------- # - local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) + local scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) local scrfunc_fn=$( basename "${scrfunc_fp}" ) local scrfunc_dir=$( dirname "${scrfunc_fp}" ) # diff --git a/ush/bash_utils/check_var_valid_value.sh b/ush/bash_utils/check_var_valid_value.sh index 723460ea1..7a0e20707 100644 --- a/ush/bash_utils/check_var_valid_value.sh +++ b/ush/bash_utils/check_var_valid_value.sh @@ -25,7 +25,7 @@ function check_var_valid_value() { # #----------------------------------------------------------------------- # - local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) + local scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) local scrfunc_fn=$( basename "${scrfunc_fp}" ) local scrfunc_dir=$( dirname "${scrfunc_fp}" ) # diff --git a/ush/bash_utils/count_files.sh b/ush/bash_utils/count_files.sh index 633bbf7ce..c80f342cb 100644 --- a/ush/bash_utils/count_files.sh +++ b/ush/bash_utils/count_files.sh @@ -25,7 +25,7 @@ function count_files() { # #----------------------------------------------------------------------- # - local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) + local scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) local scrfunc_fn=$( basename "${scrfunc_fp}" ) local scrfunc_dir=$( dirname "${scrfunc_fp}" ) # diff --git a/ush/bash_utils/define_macos_utilities.sh b/ush/bash_utils/define_macos_utilities.sh new file mode 100644 index 000000000..1c5aca621 --- /dev/null +++ b/ush/bash_utils/define_macos_utilities.sh @@ -0,0 +1,45 @@ +# +#----------------------------------------------------------------------- +# +# This script defines MacOS-specific UNIX command-line utilities that +# mimic the functionality of the GNU equivalents. +# +#----------------------------------------------------------------------- +# +# +# +#----------------------------------------------------------------------- +# +# Check if we are on a Darwin machine; if so we need to use the gnu-like +# equivalent of readlink and sed. +# +#----------------------------------------------------------------------- +# +darwinerror () { + + utility=$1 + echo >&2 " +For Darwin-based operating systems (MacOS), the '${utility}' utility is required to run the UFS SRW Application. +Reference the User's Guide for more information about platform requirements. + +Aborting. +" + exit 1 +} + + if [[ $(uname -s) == Darwin ]]; then + export READLINK=greadlink + command -v $READLINK >/dev/null 2>&1 || darwinerror $READLINK + export SED=gsed + command -v $SED >/dev/null 2>&1 || darwinerror $SED + export DATE_UTIL=gdate + command -v $DATE_UTIL >/dev/null 2>&1 || darwinerror $DATE_UTIL + export LN_UTIL=gln + command -v $LN_UTIL >/dev/null 2>&1 || darwinerror $LN_UTIL + else + export READLINK=readlink + export SED=sed + export DATE_UTIL=date + export LN_UTIL=ln + fi + diff --git a/ush/bash_utils/filesys_cmds_vrfy.sh b/ush/bash_utils/filesys_cmds_vrfy.sh index d11ec4720..fc2afe81c 100644 --- a/ush/bash_utils/filesys_cmds_vrfy.sh +++ b/ush/bash_utils/filesys_cmds_vrfy.sh @@ -28,7 +28,7 @@ function filesys_cmd_vrfy() { # #----------------------------------------------------------------------- # - local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) + local scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) local scrfunc_fn=$( basename "${scrfunc_fp}" ) local scrfunc_dir=$( dirname "${scrfunc_fp}" ) # @@ -66,7 +66,7 @@ function filesys_cmd_vrfy() { # #----------------------------------------------------------------------- # - local caller_fp=$( readlink -f "${BASH_SOURCE[2]}" ) + local caller_fp=$( $READLINK -f "${BASH_SOURCE[2]}" ) local caller_fn=$( basename "${caller_fp}" ) local caller_dir=$( dirname "${caller_fp}" ) local caller_name="${FUNCNAME[2]}" @@ -248,7 +248,7 @@ function rm_vrfy() { function ln_vrfy() { { save_shell_opts; set -u +x; } > /dev/null 2>&1 - filesys_cmd_vrfy "ln" "$@" + filesys_cmd_vrfy "$LN_UTIL" "$@" { restore_shell_opts; } > /dev/null 2>&1 } diff --git a/ush/bash_utils/get_charvar_from_netcdf.sh b/ush/bash_utils/get_charvar_from_netcdf.sh index 71bcf9dd0..ac70cf68d 100644 --- a/ush/bash_utils/get_charvar_from_netcdf.sh +++ b/ush/bash_utils/get_charvar_from_netcdf.sh @@ -35,7 +35,7 @@ function get_charvar_from_netcdf() { # #----------------------------------------------------------------------- # - local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) + local scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) local scrfunc_fn=$( basename "${scrfunc_fp}" ) local scrfunc_dir=$( dirname "${scrfunc_fp}" ) # @@ -173,7 +173,7 @@ The arguments to this function are defined as follows: #----------------------------------------------------------------------- # nc_var_value=$( ncdump -v "${nc_var_name}" "${nc_file}" | \ - sed -r -e '1,/data:/d' \ + $SED -r -e '1,/data:/d' \ -e '/^[ ]*'${nc_var_name}'/d' \ -e '/^}$/d' \ -e 's/.*"(.*)".*/\1/' \ diff --git a/ush/bash_utils/get_elem_inds.sh b/ush/bash_utils/get_elem_inds.sh index 70da5b248..89a9c4122 100644 --- a/ush/bash_utils/get_elem_inds.sh +++ b/ush/bash_utils/get_elem_inds.sh @@ -24,7 +24,7 @@ function get_elem_inds() { # #----------------------------------------------------------------------- # - local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) + local scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) local scrfunc_fn=$( basename "${scrfunc_fp}" ) local scrfunc_dir=$( dirname "${scrfunc_fp}" ) # @@ -123,7 +123,7 @@ The arguments to this function are defined as follows: # #----------------------------------------------------------------------- # - inds_to_return="${inds_to_return,,}" + inds_to_return=$(echo_lowercase $inds_to_return) valid_vals_inds_to_return=( "first" "last" "all" ) check_var_valid_value "inds_to_return" "valid_vals_inds_to_return" # diff --git a/ush/bash_utils/get_manage_externals_config_property.sh b/ush/bash_utils/get_manage_externals_config_property.sh index b42605ec9..370d448f2 100644 --- a/ush/bash_utils/get_manage_externals_config_property.sh +++ b/ush/bash_utils/get_manage_externals_config_property.sh @@ -24,7 +24,7 @@ function get_manage_externals_config_property() { # #----------------------------------------------------------------------- # - local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) + local scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) local scrfunc_fn=$( basename "${scrfunc_fp}" ) local scrfunc_dir=$( dirname "${scrfunc_fp}" ) # @@ -184,7 +184,7 @@ does not exist: #----------------------------------------------------------------------- # regex_search="^[ ]*(${property_name})[ ]*=[ ]*([^ ]*).*" - line=$( sed -r -n \ + line=$( $SED -r -n \ -e "/^[ ]*\[${external_name}\]/!b" \ -e ":SearchForLine" \ -e "s/(${regex_search})/\1/;t FoundLine" \ @@ -225,7 +225,7 @@ fied external (external_name): else property_value=$( printf "%s" "${line}" | \ - sed -r -n -e "s/${regex_search}/\2/p" ) + $SED -r -n -e "s/${regex_search}/\2/p" ) printf "%s\n" "${property_value}" fi diff --git a/ush/bash_utils/interpol_to_arbit_CRES.sh b/ush/bash_utils/interpol_to_arbit_CRES.sh index 6f685c1a5..bc4c6e833 100644 --- a/ush/bash_utils/interpol_to_arbit_CRES.sh +++ b/ush/bash_utils/interpol_to_arbit_CRES.sh @@ -27,7 +27,7 @@ function interpol_to_arbit_CRES() { # #----------------------------------------------------------------------- # - local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) + local scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) local scrfunc_fn=$( basename "${scrfunc_fp}" ) local scrfunc_dir=$( dirname "${scrfunc_fp}" ) # diff --git a/ush/bash_utils/is_array.sh b/ush/bash_utils/is_array.sh index 16be2fbb7..c831f313e 100644 --- a/ush/bash_utils/is_array.sh +++ b/ush/bash_utils/is_array.sh @@ -31,7 +31,7 @@ function is_array() { # #----------------------------------------------------------------------- # - local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) + local scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) local scrfunc_fn=$( basename "${scrfunc_fp}" ) local scrfunc_dir=$( dirname "${scrfunc_fp}" ) # diff --git a/ush/bash_utils/is_element_of.sh b/ush/bash_utils/is_element_of.sh index bd92c6f3f..e5a421dab 100644 --- a/ush/bash_utils/is_element_of.sh +++ b/ush/bash_utils/is_element_of.sh @@ -24,7 +24,7 @@ function is_element_of() { # #----------------------------------------------------------------------- # - local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) + local scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) local scrfunc_fn=$( basename "${scrfunc_fp}" ) local scrfunc_dir=$( dirname "${scrfunc_fp}" ) # diff --git a/ush/bash_utils/print_input_args.sh b/ush/bash_utils/print_input_args.sh index 10bbe4ca6..72b7744b3 100644 --- a/ush/bash_utils/print_input_args.sh +++ b/ush/bash_utils/print_input_args.sh @@ -31,7 +31,7 @@ function print_input_args() { # #----------------------------------------------------------------------- # - local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) + local scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) local scrfunc_fn=$( basename "${scrfunc_fp}" ) local scrfunc_dir=$( dirname "${scrfunc_fp}" ) # @@ -62,7 +62,7 @@ function print_input_args() { # #----------------------------------------------------------------------- # - local caller_fp=$( readlink -f "${BASH_SOURCE[1]}" ) + local caller_fp=$( $READLINK -f "${BASH_SOURCE[1]}" ) local caller_fn=$( basename "${caller_fp}" ) local caller_dir=$( dirname "${caller_fp}" ) local caller_name="${FUNCNAME[1]}" @@ -174,7 +174,7 @@ have been set as follows: # #----------------------------------------------------------------------- # - if [ ! -v VERBOSE ]; then + if [ -z ${VERBOSE+x} ]; then print_info_msg "$msg" else print_info_msg "$VERBOSE" "$msg" diff --git a/ush/bash_utils/print_msg.sh b/ush/bash_utils/print_msg.sh index 544357f62..d83732942 100644 --- a/ush/bash_utils/print_msg.sh +++ b/ush/bash_utils/print_msg.sh @@ -33,7 +33,7 @@ function print_info_msg() { # #----------------------------------------------------------------------- # - local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) + local scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) local scrfunc_fn=$( basename "${scrfunc_fp}" ) local scrfunc_dir=$( dirname "${scrfunc_fp}" ) # @@ -64,7 +64,7 @@ function print_info_msg() { # #----------------------------------------------------------------------- # - local caller_fp=$( readlink -f "${BASH_SOURCE[1]}" ) + local caller_fp=$( $READLINK -f "${BASH_SOURCE[1]}" ) local caller_fn=$( basename "${caller_fp}" ) local caller_dir=$( dirname "${caller_fp}" ) local caller_name="${FUNCNAME[1]}" @@ -182,7 +182,7 @@ function print_err_msg_exit() { # #----------------------------------------------------------------------- # - local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) + local scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) local scrfunc_fn=$( basename "${scrfunc_fp}" ) local scrfunc_dir=$( dirname "${scrfunc_fp}" ) # @@ -213,7 +213,7 @@ function print_err_msg_exit() { # #----------------------------------------------------------------------- # - local caller_fp=$( readlink -f "${BASH_SOURCE[1]}" ) + local caller_fp=$( $READLINK -f "${BASH_SOURCE[1]}" ) local caller_fn=$( basename "${caller_fp}" ) local caller_dir=$( dirname "${caller_fp}" ) local caller_name="${FUNCNAME[1]}" diff --git a/ush/bash_utils/process_args.sh b/ush/bash_utils/process_args.sh index 4363348ba..203bdedcf 100644 --- a/ush/bash_utils/process_args.sh +++ b/ush/bash_utils/process_args.sh @@ -99,7 +99,7 @@ function process_args() { # #----------------------------------------------------------------------- # - local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) + local scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) local scrfunc_fn=$( basename "${scrfunc_fp}" ) local scrfunc_dir=$( dirname "${scrfunc_fp}" ) # @@ -263,7 +263,7 @@ ments (num_valid_args) specified in the array valid_arg_names: # Remove spaces (if any exist) from the current valid argument name. valid_arg_name_no_spaces=$( \ - printf "%s\n" "${valid_arg_name}" | sed -r -e 's/[[:space:]]//g' ) + printf "%s\n" "${valid_arg_name}" | $SED -r -e 's/[[:space:]]//g' ) if [ "${valid_arg_name_no_spaces}" != "${valid_arg_name}" ]; then print_err_msg_exit "\ diff --git a/ush/bash_utils/save_restore_shell_opts.sh b/ush/bash_utils/save_restore_shell_opts.sh index 37f699590..b561b6cea 100644 --- a/ush/bash_utils/save_restore_shell_opts.sh +++ b/ush/bash_utils/save_restore_shell_opts.sh @@ -19,7 +19,7 @@ function save_shell_opts() { # local shell_opts="$(set +o)"$'\n'"set -$-" shell_opts=${shell_opts//$'\n'/ } - shell_opts=$( printf "%s\n" "$shell_opts" | sed -r -e "s/set ([+-])/\1/g" ) + shell_opts=$( printf "%s\n" "$shell_opts" | $SED -r -e "s/set ([+-])/\1/g" ) # # Store the current set of shell options in the global array shell_- # opts_array so we can reuse them later. diff --git a/ush/bash_utils/set_bash_param.sh b/ush/bash_utils/set_bash_param.sh index 12c2e49be..dd2220607 100644 --- a/ush/bash_utils/set_bash_param.sh +++ b/ush/bash_utils/set_bash_param.sh @@ -25,7 +25,7 @@ function set_bash_param() { # #----------------------------------------------------------------------- # - local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) + local scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) local scrfunc_fn=$( basename "${scrfunc_fp}" ) local scrfunc_dir=$( dirname "${scrfunc_fp}" ) # @@ -129,7 +129,7 @@ lar expression (regex_search): regex_search = ${regex_search}" }; - sed -i -r -e "s%${regex_search}%${regex_replace}%" "${file_full_path}" + $SED -i -r -e "s%${regex_search}%${regex_replace}%" "${file_full_path}" # #----------------------------------------------------------------------- # diff --git a/ush/bash_utils/set_file_param.sh b/ush/bash_utils/set_file_param.sh index 72a9ab041..d45451483 100644 --- a/ush/bash_utils/set_file_param.sh +++ b/ush/bash_utils/set_file_param.sh @@ -25,7 +25,7 @@ function set_file_param() { # #----------------------------------------------------------------------- # - local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) + local scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) local scrfunc_fn=$( basename "${scrfunc_fp}" ) local scrfunc_dir=$( dirname "${scrfunc_fp}" ) # @@ -171,7 +171,7 @@ specified for this file: grep -q -E "${regex_search}" "${file_full_path}" if [ $? -eq 0 ]; then - sed -i -r -e "s%${regex_search}%${regex_replace}%" "${file_full_path}" + $SED -i -r -e "s%${regex_search}%${regex_replace}%" "${file_full_path}" else print_err_msg_exit "\ Specified file (file_full_path) does not contain the searched-for regu- diff --git a/ush/cmp_expt_to_baseline.sh b/ush/cmp_expt_to_baseline.sh deleted file mode 100755 index 94e6e0c47..000000000 --- a/ush/cmp_expt_to_baseline.sh +++ /dev/null @@ -1,411 +0,0 @@ -#!/bin/sh -l -#----------------------------------------------------------------------- -# Description: Compare experiment to a baseline. Can be run with one -# or two command line arguments. With one argument, it -# assumes this is your experiment directory and creates a -# directory for the baseline based on your experiment's -# setup (by reading in the var_defns.sh file in your ex- -# periment directory). With two arguments, it takes the -# first one to be your experiment directory and the second -# the baseline directory. -# -# Usage: ./cmp_expt_to_baseline.sh ${expt_dir} [${baseline_dir}] -# -# Assumptions: RUNDIR1 and RUNDIR2 have the same subdirectory structure. -# nccmp is available as module load -# Script has only been tested on theia -#----------------------------------------------------------------------- - -# Do these need to be machine specific, e.g. by using modulefiles? -module load intel -module load nccmp -# -#----------------------------------------------------------------------- -# -# Get the full path to the file in which this script/function is located -# (scrfunc_fp), the name of that file (scrfunc_fn), and the directory in -# which the file is located (scrfunc_dir). -# -#----------------------------------------------------------------------- -# -scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) -scrfunc_fn=$( basename "${scrfunc_fp}" ) -scrfunc_dir=$( dirname "${scrfunc_fp}" ) -# -#----------------------------------------------------------------------- -# -# Source bash utility functions. -# -#----------------------------------------------------------------------- -# -. ${scrfunc_dir}/source_util_funcs.sh -# -#----------------------------------------------------------------------- -# -# Save current shell options (in a global array). Then set new options -# for this script/function. -# -#----------------------------------------------------------------------- -# -{ save_shell_opts; set -u +x; } > /dev/null 2>&1 -# -#----------------------------------------------------------------------- -# -# Process arguments. -# -#----------------------------------------------------------------------- -# -if [ $# -eq 0 ] || [ $# -gt 2 ]; then - - printf " -ERROR from script ${scrfunc_fn}: -Only 1 or 2 arguments may be specified. Usage: - - > ${scrfunc_fn} expt_dir [baseline_dir] - -where expt_dir is the experiment directory and baseline_dir is an op- -tional baseline directory. -Exiting with nonzero exit code. -" - exit 1 - -fi -# -#----------------------------------------------------------------------- -# -# Set the experiment directory and make sure that it exists. -# -#----------------------------------------------------------------------- -# -expt_dir="$1" -if [ ! -d "${expt_dir}" ]; then - print_err_msg_exit "\ -The specified experiment directory (expt_dir) does not exist: - expt_dir = \"$expt_dir\" -Exiting script with nonzero return code." -fi -# -#----------------------------------------------------------------------- -# -# Read the variable definitions file in the experiment directory. -# -#----------------------------------------------------------------------- -# -. ${expt_dir}/var_defns.sh -CDATE="${DATE_FIRST_CYCL[0]}${CYCL_HRS[0]}" -# -#----------------------------------------------------------------------- -# -# If two arguments are specified, then take the second one to be the di- -# rectory for the baseline. If only one argument is specified, form a -# baseline directory name from the parameters used in the experiment di- -# rectory. If any other number of arguments is specified, print out an -# error message and exit. -# -#----------------------------------------------------------------------- -# -if [ $# -eq 2 ]; then - - baseline_dir="$2" - -else - - baseline_dir="/scratch2/BMC/det/regional_FV3/regr_baselines" - if [ -n ${PREDEF_GRID_NAME} ]; then - baseline_dir="${baseline_dir}/${PREDEF_GRID_NAME}" - else - printf "\ -The experiment must be run on one of the predefined domains. Thus, -PREDEF_GRID_NAME cannot be empty: - PREDEF_GRID_NAME = \"${PREDEF_GRID_NAME}\" -Exiting script with nonzero return code. -" - exit 1 - fi - baseline_dir="${baseline_dir}/${CCPP_PHYS_SUITE}phys" - baseline_dir="${baseline_dir}/ICs-${EXTRN_MDL_NAME_ICS}_LBCs-${EXTRN_MDL_NAME_LBCS}" - baseline_dir="${baseline_dir}/$CDATE" - -fi -# -# Make sure that the baseline directory exists. -# -if [ ! -d "${baseline_dir}" ]; then - printf "\n -A baseline directory corresponding to the configuration used in the ex- -periment directory (expt_dir) does not exist: - expt_dir = \"$expt_dir\" - baseline_dir (missing) = \"$baseline_dir\" -Exiting script with nonzero return code." - exit 1 -fi -# -#----------------------------------------------------------------------- -# -# Print out the experiment and baseline directories. -# -#----------------------------------------------------------------------- -# -print_info_msg " -The experiment and baseline directories are: - expt_dir = \"$expt_dir\" - baseline_dir = \"$baseline_dir\"" -# -#----------------------------------------------------------------------- -# -# Set the array containing the names of the subdirectories that will be -# compared. -# -#----------------------------------------------------------------------- -# -# This list should also include $CDATE/postprd since that contains the -# post-processed grib files, but those files' names don't end in a -# standard file extension, e.g. .grb, etc. Must look into this more. -# "grid" \ -# "orog" \ -# "sfc_climo" \ -subdirs=( "." \ - "fix_lam" \ - "$CDATE/${EXTRN_MDL_NAME_ICS}/ICS" \ - "$CDATE/${EXTRN_MDL_NAME_LBCS}/LBCS" \ - "$CDATE/INPUT" \ - "$CDATE/RESTART" \ - "$CDATE" \ - ) -# -#----------------------------------------------------------------------- -# -# Set the array that defines the file extensions to compare in each sub- -# directory. -# -#----------------------------------------------------------------------- -# -#declare -a file_extensions=( "nc" "nemsio" "grb" ) -declare -a file_extensions=( "nc" "grb" ) -#declare -a file_extensions=( "nc" ) -# -#----------------------------------------------------------------------- -# -# Initialize file counts to 0. These are defined as follows: -# -# nfiles_total: -# The number of files in the experiment directory that we attempted to -# compare to the corresponding file in the baseline directory. -# -# nfiles_missing: -# The number of files (out of nfiles_total) that are missing from the -# baseline directory. -# -# nfiles_different: -# The number of files that exist in both the experiment and baseline di- -# rectories and are different. -# -#----------------------------------------------------------------------- -# -nfiles_total=0 -nfiles_missing=0 -nfiles_different=0 -# -#----------------------------------------------------------------------- -# -# Loop over the specified subdirectories. For each subdirectory, com- -# pare files having the specified extensions for the experiment and the -# baseline. -# -#----------------------------------------------------------------------- -# -for subdir in "${subdirs[@]}"; do - - msg="Comparing files in subdirectory \"$subdir\" ..." - msglen=${#msg} - printf "\n%s\n" "$msg" - printf "%0.s=" $(seq 1 $msglen) - printf "\n" - - for file_ext in "${file_extensions[@]}"; do - - msg="Comparing files with extension \"${file_ext}\" ..." - msglen=${#msg} - printf "\n%s\n" " $msg" - printf " " - printf "%0.s~" $(seq 1 $msglen) - printf "\n" - -# cmp_files_btwn_dirs "$expt_dir/$subdir" "${baseline_dir}/$subdir" "${ext}" || { \ -# printf " -#Call to file comparison function failed. Exiting with nonzero exit code. -#"; -# exit 1; } -# -#----------------------------------------------------------------------- -# -# -#----------------------------------------------------------------------- -# - if [ "$file_ext" = "nemsio" ] || [ "$file_ext" = "grb" ]; then - compare_tool="cmp" - elif [ "$file_ext" = "nc" ]; then - compare_tool="nccmp -d" - else - printf "\ -The file comparison tool to use for this file extension has not been -specified: - file_ext = \"${file_ext}\" -Please specify the compare tool and rerun. -Exiting script with nonzero exit code. -" - fi -# -#----------------------------------------------------------------------- -# -# -# -#----------------------------------------------------------------------- -# - cd ${expt_dir}/$subdir - num_files=$( ls -1 *.${file_ext} 2>/dev/null | wc -l ) -# num_files=$( count_files *.${file_ext} 2>/dev/null | wc -l ) - printf " - Number of files with extension \"${file_ext}\" in subdirectory \"$subdir\" - of the experiment directory is: ${num_files} -" - - if [ "${num_files}" -eq "0" ]; then - printf "\ - Skipping comparison of files with extension \"${file_ext}\" in this subdirectory. -" - else - - fn_len_max=0 - for fn in *.${file_ext}; do - fn_len=${#fn} - if [ ${fn_len} -gt ${fn_len_max} ]; then - fn_len_max=${fn_len} - fi - done - compare_msg_pre=" Comparing file " - msg_len_max=$(( fn_len_max + ${#compare_msg_pre} )) - - for fn in *.${file_ext}; do - - nfiles_total=$(( $nfiles_total + 1 )) - - fn1="$fn" - fn2="${baseline_dir}/$subdir/$fn" - if [ ! -e "$fn2" ]; then # Check if file exists in baseline directory. - - printf " - File specified by fn exists in subdirectory \"$subdir\" of the - experiment directory but not in that of the the baseline directory: - fn = \"$fn\" - subdir = \"$subdir\" - Incrementing missing file count and moving to next file or sub- - directory.\n" - nfiles_missing=$(( nfiles_missing + 1 )) - - else - - msg="${compare_msg_pre}\"$fn\"" - msg_len="${#msg}" - num_dots=$(( msg_len_max - msg_len + 7 )) - dots_str=$( printf "%0.s." $(seq 1 ${num_dots} ) ) - msg="${msg} ${dots_str}" - - printf "$msg" - eval_output=$( eval ${compare_tool} $fn1 $fn2 2>&1 ) - - if [ $? -eq 0 ]; then - printf " Files are identical.\n" - else - printf " FILES ARE DIFFERENT!!!\n" - printf "\ - Error message from \"${compare_tool}\" command is: -${eval_output} -" - nfiles_different=$(( $nfiles_different + 1 )) - fi - - fi - - done # Loop over files of the same extension. - - fi # Number of files > 0 - - done # Loop over file extensions. - -done # Loop over subdirectories. -# -#----------------------------------------------------------------------- -# -# Print out final results. -# -#----------------------------------------------------------------------- -# -msg="Summary of regression test:" -msglen=${#msg} -msg="$msg" -printf "\n%s\n" "$msg" -printf "%0.s=" $(seq 1 $msglen) -printf "\n" - -file_extensions_str=$(printf "\"%s\" " "${file_extensions[@]}"); -file_extensions_str="( ${file_extensions_str})" - -printf " - expt_dir = \"$expt_dir\" - baseline_dir = \"$baseline_dir\" - - file_extensions = ${file_extensions_str} - nfiles_total = ${nfiles_total} - nfiles_missing = ${nfiles_missing} - nfiles_different = ${nfiles_different} - -where - - file_extensions: - Array containing the file extensions considered when comparing files. - Only files ending with one of these extensions are compared. - - nfiles_total: - The number of files in the experiment directory that we attempted to - compare to the corresponding file in the baseline directory. - - nfiles_missing: - The number of files (out of nfiles_total) that are missing from the - baseline directory. - - nfiles_different: - The number of files that exist in both the experiment and baseline di- - rectories and are different. - -" - -if [ ${nfiles_missing} -eq 0 ] && [ ${nfiles_different} -eq 0 ]; then - result_str="PASS :)" - exit_code=0 -else - - exit_code=1 - if [ ${nfiles_missing} -ne 0 ] && [ ${nfiles_different} -eq 0 ]; then - result_str="FAIL (due to missing files)" - elif [ ${nfiles_missing} -eq 0 ] && [ ${nfiles_different} -ne 0 ]; then - result_str="FAIL (due to differing files)" - elif [ ${nfiles_missing} -ne 0 ] && [ ${nfiles_different} -ne 0 ]; then - result_str="FAIL (due to missing and differing files)" - fi - -fi - -printf "Final result of regression test: ${result_str}\n" -# -#----------------------------------------------------------------------- -# -# Restore the shell options saved at the beginning of this script/func- -# tion. -# -#----------------------------------------------------------------------- -# -{ restore_shell_opts; } > /dev/null 2>&1 - -exit ${exit_code} - diff --git a/ush/cmp_rundirs_ncfiles.sh b/ush/cmp_rundirs_ncfiles.sh deleted file mode 100755 index c65045487..000000000 --- a/ush/cmp_rundirs_ncfiles.sh +++ /dev/null @@ -1,100 +0,0 @@ -#!/bin/sh -l - -module load nccmp -# -#----------------------------------------------------------------------- -# -# Define generic function to compare NetCDF files in two directories. -# -#----------------------------------------------------------------------- -# -function cmp_ncfiles_one_dir() { - - local dir1="$1" - local dir2="$2" - local subdir="$3" - local fileext="$4" - - local fn="" - local msg="" - - cd $dir1/$subdir - - for fn in *.$fileext; do - - fn1="$fn" - if [ -f "$fn1" ] && [ ! -L "$fn1" ]; then # Check if regular file and not a symlink. - - fn2="$dir2/$subdir/$fn" - if [ -e "$fn2" ]; then # Check if file exists. - - if [ -f "$fn2" ] && [ ! -L "$fn2" ]; then # Check if regular file and not a symlink. - - printf "\nComparing file \"$fn\" in subdirectory \"$subdir\" ...\n" - nccmp -d $fn1 $fn2 -# nccmp -dS $fn1 $fn2 -# nccmp -d -t 1e-3 $fn1 $fn2 -# nccmp -d --precision='%g10.5' $fn1 $fn2 - - if [ $? = 0 ]; then - msg=$( printf "%s" "Files are identical." ) - elif [ $? = 1 ]; then - msg=$( printf "%s" "===>>> FILES ARE DIFFERENT!!!" ) - else - msg=$( printf "%s" "FATAL ERROR. Exiting script." ) - exit 1 - fi - - printf "%s\n" "$msg" - - else - printf "\n%s\n" "File \"$fn\" in \"$dir2/$subdir\" is a symbolic link. Skipping." - fi - - else - printf "\n%s\n" "File \"$fn\" does not exist in \"$dir2/$subdir\"." - printf "\n%s\n" "Exiting script." - exit 1 - fi - - else - printf "\n%s\n" "File \"$fn\" in \"$dir1/$subdir\" is a symbolic link. Skipping." - fi - - done - -} -# -#----------------------------------------------------------------------- -# -# Get the two run directories to compare from command-line arguments. -# Then compare NetCDF files in the run directories as well as in their -# INPUT subdirectories. -# -#----------------------------------------------------------------------- -# -#set -x - -rundir1="$( readlink -f $1 )" -rundir2="$( readlink -f $2 )" - -printf "\n" -printf "%s\n" "rundir1 = \"$rundir1\"" -printf "%s\n" "rundir2 = \"$rundir2\"" - -subdirs=("INPUT" ".") - -for subdir in "${subdirs[@]}"; do - - msg=$( printf "%s" "Comparing files in subdirectory \"$subdir\" ..." ) - msglen=${#msg} - printf "\n%s\n" "$msg" - printf "%0.s=" $(seq 1 $msglen) - printf "\n" - - cmp_ncfiles_one_dir "$rundir1" "$rundir2" "$subdir" "nc" - -done - - - diff --git a/ush/compare_config_scripts.sh b/ush/compare_config_scripts.sh index 279903ab3..791fa4e34 100644 --- a/ush/compare_config_scripts.sh +++ b/ush/compare_config_scripts.sh @@ -19,7 +19,7 @@ function compare_config_scripts() { # #----------------------------------------------------------------------- # -local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) +local scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) local scrfunc_fn=$( basename "${scrfunc_fp}" ) local scrfunc_dir=$( dirname "${scrfunc_fp}" ) # @@ -65,7 +65,7 @@ local func_name="${FUNCNAME[0]}" #----------------------------------------------------------------------- # var_list_default=$( \ -sed -r \ +$SED -r \ -e "s/^([ ]*)([^ ]+.*)/\2/g" \ -e "/^#.*/d" \ -e "/^$/d" \ @@ -73,7 +73,7 @@ sed -r \ ) var_list_local=$( \ -sed -r \ +$SED -r \ -e "s/^([ ]*)([^ ]+.*)/\2/g" \ -e "/^#.*/d" \ -e "/^$/d" \ @@ -95,7 +95,7 @@ while read crnt_line; do # Note that a variable name will be found only if the equal sign immed- # iately follows the variable name. # - var_name=$( printf "%s" "${crnt_line}" | sed -n -r -e "s/^([^ =\"]*)=.*/\1/p") + var_name=$( printf "%s" "${crnt_line}" | $SED -n -r -e "s/^([^ =\"]*)=.*/\1/p") if [ -z "${var_name}" ]; then diff --git a/ush/config_defaults.sh b/ush/config_defaults.sh index 0234ef47a..a38d713cc 100644 --- a/ush/config_defaults.sh +++ b/ush/config_defaults.sh @@ -46,6 +46,11 @@ RUN_ENVIR="nco" # ACCOUNT: # The account under which to submit jobs to the queue. # +# WORKFLOW_MANAGER: +# The workflow manager to use (e.g. rocoto). This is set to "none" by +# default, but if the machine name is set to a platform that supports +# rocoto, this will be overwritten and set to "rocoto". +# # SCHED: # The job scheduler to use (e.g. slurm). Set this to an empty string in # order for the experiment generation script to set it depending on the @@ -103,6 +108,7 @@ RUN_ENVIR="nco" # MACHINE="BIG_COMPUTER" ACCOUNT="project_name" +WORKFLOW_MANAGER="none" SCHED="" PARTITION_DEFAULT="" QUEUE_DEFAULT="" @@ -113,6 +119,30 @@ QUEUE_FCST="" # #----------------------------------------------------------------------- # +# Set run commands for platforms without a workflow manager. These values +# will be ignored unless WORKFLOW_MANAGER="none". Definitions: +# +# RUN_CMD_UTILS: +# The run command for pre-processing utilities (shave, orog, sfc_climo_gen, etc.) +# Can be left blank for smaller domains, in which case the executables will run +# without MPI. +# +# RUN_CMD_FCST: +# The run command for the model forecast step. This will be appended to the end +# of the variable definitions file, so it can reference other variables. +# +# RUN_CMD_POST: +# The run command for post-processing (UPP). Can be left blank for smaller +# domains, in which case UPP will run without MPI. +# +#----------------------------------------------------------------------- +# +RUN_CMD_UTILS="mpirun -np 1" +RUN_CMD_FCST="mpirun -np \${PE_MEMBER01}" +RUN_CMD_POST="mpirun -np 1" +# +#----------------------------------------------------------------------- +# # Set cron-associated parameters. Definitions: # # USE_CRON_TO_RELAUNCH: diff --git a/ush/create_diag_table_files.sh b/ush/create_diag_table_files.sh index cff8c0424..f2a54dc7c 100644 --- a/ush/create_diag_table_files.sh +++ b/ush/create_diag_table_files.sh @@ -25,7 +25,7 @@ function create_diag_table_files() { # #----------------------------------------------------------------------- # - local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) + local scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) local scrfunc_fn=$( basename "${scrfunc_fp}" ) local scrfunc_dir=$( dirname "${scrfunc_fp}" ) # diff --git a/ush/create_model_configure_file.sh b/ush/create_model_configure_file.sh index f64e96c07..043b3e1b7 100644 --- a/ush/create_model_configure_file.sh +++ b/ush/create_model_configure_file.sh @@ -25,7 +25,7 @@ function create_model_configure_file() { # #----------------------------------------------------------------------- # - local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) + local scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) local scrfunc_fn=$( basename "${scrfunc_fp}" ) local scrfunc_dir=$( dirname "${scrfunc_fp}" ) # @@ -97,8 +97,9 @@ run directory (run_dir): # # Set parameters in the model configure file. # - dot_quilting_dot="."${QUILTING,,}"." - dot_print_esmf_dot="."${PRINT_ESMF,,}"." + + dot_quilting_dot="."$(echo_lowercase $QUILTING)"." + dot_print_esmf_dot="."$(echo_lowercase $PRINT_ESMF)"." # #----------------------------------------------------------------------- # diff --git a/ush/generate_FV3LAM_wflow.sh b/ush/generate_FV3LAM_wflow.sh index 6701c25c2..650f2c8f7 100755 --- a/ush/generate_FV3LAM_wflow.sh +++ b/ush/generate_FV3LAM_wflow.sh @@ -19,7 +19,11 @@ function generate_FV3LAM_wflow() { # #----------------------------------------------------------------------- # -local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) + if [[ $(uname -s) == Darwin ]]; then + local scrfunc_fp=$( greadlink -f "${BASH_SOURCE[0]}" ) + else + local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) + fi local scrfunc_fn=$( basename "${scrfunc_fp}" ) local scrfunc_dir=$( dirname "${scrfunc_fp}" ) # @@ -296,12 +300,13 @@ $settings" # script to generate the experiment's actual XML file from this template # file. # -template_xml_fp="${TEMPLATE_DIR}/${WFLOW_XML_FN}" -$USHDIR/fill_jinja_template.py -q \ - -u "${settings}" \ - -t ${template_xml_fp} \ - -o ${WFLOW_XML_FP} || \ - print_err_msg_exit "\ +if [ "${WORKFLOW_MANAGER}" = "rocoto" ]; then + template_xml_fp="${TEMPLATE_DIR}/${WFLOW_XML_FN}" + $USHDIR/fill_jinja_template.py -q \ + -u "${settings}" \ + -t ${template_xml_fp} \ + -o ${WFLOW_XML_FP} || \ + print_err_msg_exit "\ Call to python script fill_jinja_template.py to create a rocoto workflow XML file from a template file failed. Parameters passed to this script are: @@ -312,6 +317,7 @@ are: Namelist settings specified on command line: settings = $settings" +fi # #----------------------------------------------------------------------- # @@ -354,7 +360,7 @@ if [ "${USE_CRON_TO_RELAUNCH}" = "TRUE" ]; then # # Make a backup copy of the user's crontab file and save it in a file. # - time_stamp=$( date "+%F_%T" ) + time_stamp=$( $DATE_UTIL "+%F_%T" ) crontab_backup_fp="$EXPTDIR/crontab.bak.${time_stamp}" print_info_msg " Copying contents of user cron table to backup file: @@ -367,7 +373,7 @@ Copying contents of user cron table to backup file: # CRONTAB_LINE with backslashes. Do this next. # crontab_line_esc_astr=$( printf "%s" "${CRONTAB_LINE}" | \ - sed -r -e "s%[*]%\\\\*%g" ) + $SED -r -e "s%[*]%\\\\*%g" ) # # In the grep command below, the "^" at the beginning of the string be- # ing passed to grep is a start-of-line anchor while the "$" at the end @@ -609,9 +615,9 @@ for (( i=0; i<${num_nml_vars}; i++ )); do mapping="${FV3_NML_VARNAME_TO_FIXam_FILES_MAPPING[$i]}" nml_var_name=$( printf "%s\n" "$mapping" | \ - sed -n -r -e "s/${regex_search}/\1/p" ) + $SED -n -r -e "s/${regex_search}/\1/p" ) FIXam_fn=$( printf "%s\n" "$mapping" | - sed -n -r -e "s/${regex_search}/\2/p" ) + $SED -n -r -e "s/${regex_search}/\2/p" ) fp="\"\"" if [ ! -z "${FIXam_fn}" ]; then @@ -727,9 +733,11 @@ cp_vrfy $USHDIR/${EXPT_CONFIG_FN} $EXPTDIR # #----------------------------------------------------------------------- # -wflow_db_fn="${WFLOW_XML_FN%.xml}.db" -rocotorun_cmd="rocotorun -w ${WFLOW_XML_FN} -d ${wflow_db_fn} -v 10" -rocotostat_cmd="rocotostat -w ${WFLOW_XML_FN} -d ${wflow_db_fn} -v 10" +if [ "${WORKFLOW_MANAGER}" = "rocoto" ]; then + wflow_db_fn="${WFLOW_XML_FN%.xml}.db" + rocotorun_cmd="rocotorun -w ${WFLOW_XML_FN} -d ${wflow_db_fn} -v 10" + rocotostat_cmd="rocotostat -w ${WFLOW_XML_FN} -d ${wflow_db_fn} -v 10" +fi print_info_msg " ======================================================================== @@ -745,37 +753,24 @@ The experiment directory is: > EXPTDIR=\"$EXPTDIR\" " -case $MACHINE in - -"CHEYENNE") +# +#----------------------------------------------------------------------- +# +# If rocoto is required, print instructions on how to load and use it +# +#----------------------------------------------------------------------- +# +if [ "${WORKFLOW_MANAGER}" = "rocoto" ]; then print_info_msg "\ To launch the workflow, first ensure that you have a compatible version -of rocoto in your \$PATH. On Cheyenne, version 1.3.1 has been pre-built; -you can load it in your \$PATH with one of the following commands, depending -on your default shell: +of rocoto available. For most pre-configured platforms, rocoto can be +loaded via a module: -bash: - > export PATH=\${PATH}:/glade/p/ral/jntp/tools/rocoto/rocoto-1.3.1/bin/ + > module load rocoto -tcsh: - > setenv PATH \${PATH}:/glade/p/ral/jntp/tools/rocoto/rocoto-1.3.1/bin/ -" - ;; +For more details on rocoto, see the User's Guide. -*) - print_info_msg "\ -To launch the workflow, first ensure that you have a compatible version -of rocoto loaded. For example, to load version 1.3.1 of rocoto, use - > module load rocoto/1.3.1 - -(This version has been tested on hera; later versions may also work but -have not been tested.) -" - ;; - -esac -print_info_msg " To launch the workflow, change location to the experiment directory (EXPTDIR) and issue the rocotrun command, as follows: @@ -805,6 +800,7 @@ edit the cron table): Done. " +fi # # If necessary, run the NOMADS script to source external model data. # @@ -848,7 +844,12 @@ set -u # #----------------------------------------------------------------------- # -scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) +if [[ $(uname -s) == Darwin ]]; then + command -v greadlink >/dev/null 2>&1 || { echo >&2 "For Darwin-based operating systems (MacOS), the 'greadlink' utility is required to run the UFS SRW Application. Reference the User's Guide for more information about platform requirements. Aborting."; exit 1; } + scrfunc_fp=$( greadlink -f "${BASH_SOURCE[0]}" ) +else + scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) +fi scrfunc_fn=$( basename "${scrfunc_fp}" ) scrfunc_dir=$( dirname "${scrfunc_fp}" ) # @@ -901,27 +902,29 @@ echo "$retval" >> "${tmp_fp}" # place in a subshell (due to the fact that we are then piping its out- # put to the "tee" command). Then remove the temporary file. # -exptdir=$( sed "1q;d" "${tmp_fp}" ) -retval=$( sed "2q;d" "${tmp_fp}" ) -rm "${tmp_fp}" +if [ -f "${tmp_fp}" ]; then + exptdir=$( sed "1q;d" "${tmp_fp}" ) + retval=$( sed "2q;d" "${tmp_fp}" ) + rm "${tmp_fp}" # # If the call to the generate_FV3LAM_wflow function above was success- # ful, move the log file in which the "tee" command saved the output of # the function to the experiment directory. # -if [ $retval -eq 0 ]; then - mv "${log_fp}" "$exptdir" + if [ $retval -eq 0 ]; then + mv "${log_fp}" "$exptdir" # # If the call to the generate_FV3LAM_wflow function above was not suc- # cessful, print out an error message and exit with a nonzero return # code. # -else - printf " -Experiment/workflow generation failed. Check the log file from the ex- -periment/workflow generation script in the file specified by log_fp: - log_fp = \"${log_fp}\" -Stopping. -" - exit 1 + else + printf " + Experiment/workflow generation failed. Check the log file from the ex- + periment/workflow generation script in the file specified by log_fp: + log_fp = \"${log_fp}\" + Stopping. + " + exit 1 + fi fi diff --git a/ush/get_extrn_mdl_file_dir_info.sh b/ush/get_extrn_mdl_file_dir_info.sh index b241dad80..787405e61 100755 --- a/ush/get_extrn_mdl_file_dir_info.sh +++ b/ush/get_extrn_mdl_file_dir_info.sh @@ -37,7 +37,7 @@ function get_extrn_mdl_file_dir_info() { # #----------------------------------------------------------------------- # - local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) + local scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) local scrfunc_fn=$( basename "${scrfunc_fp}" ) local scrfunc_dir=$( dirname "${scrfunc_fp}" ) # @@ -166,7 +166,7 @@ where the arguments are defined as follows: varname_extrn_mdl_sysdir: Name of the global variable that will contain the system directory in - which the externaml model output files may be stored. + which the external model output files may be stored. varname_extrn_mdl_arcv_fmt: Name of the global variable that will contain the format of the ar- @@ -213,7 +213,7 @@ fi # #----------------------------------------------------------------------- # - anl_or_fcst="${anl_or_fcst^^}" + anl_or_fcst=$(echo_uppercase $anl_or_fcst) valid_vals_anl_or_fcst=( "ANL" "FCST" ) check_var_valid_value "anl_or_fcst" "valid_vals_anl_or_fcst" # @@ -234,7 +234,7 @@ fi hh=${cdate_FV3LAM:8:2} yyyymmdd=${cdate_FV3LAM:0:8} - cdate=$( date --utc --date "${yyyymmdd} ${hh} UTC - ${time_offset_hrs} hours" "+%Y%m%d%H" ) + cdate=$( $DATE_UTIL --utc --date "${yyyymmdd} ${hh} UTC - ${time_offset_hrs} hours" "+%Y%m%d%H" ) # #----------------------------------------------------------------------- # @@ -298,7 +298,7 @@ fi # Get the Julian day-of-year of the starting date and time of the exter- # nal model forecast. # - ddd=$( date --utc --date "${yyyy}-${mm}-${dd} ${hh}:${mn} UTC" "+%j" ) + ddd=$( $DATE_UTIL --utc --date "${yyyy}-${mm}-${dd} ${hh}:${mn} UTC" "+%j" ) # # Get the last two digits of the year of the starting date and time of # the external model forecast. @@ -559,6 +559,7 @@ bination of external model (extrn_mdl_name) and analysis or forecast sysbasedir="${EXTRN_MDL_SYSBASEDIR_LBCS}" fi + sysdir="" case "${extrn_mdl_name}" in # @@ -592,11 +593,13 @@ bination of external model (extrn_mdl_name) and analysis or forecast sysdir="$sysbasedir" ;; *) - print_err_msg_exit "\ + if [ "${USE_USER_STAGED_EXTRN_FILES}" != "TRUE" ]; then + print_err_msg_exit "\ The system directory in which to look for external model output files has not been specified for this external model and machine combination: extrn_mdl_name = \"${extrn_mdl_name}\" MACHINE = \"$MACHINE\"" + fi ;; esac ;; @@ -629,11 +632,13 @@ has not been specified for this external model and machine combination: sysdir="$sysbasedir" ;; *) - print_err_msg_exit "\ + if [ "${USE_USER_STAGED_EXTRN_FILES}" != "TRUE" ]; then + print_err_msg_exit "\ The system directory in which to look for external model output files has not been specified for this external model and machine combination: extrn_mdl_name = \"${extrn_mdl_name}\" MACHINE = \"$MACHINE\"" + fi ;; esac ;; @@ -663,11 +668,13 @@ has not been specified for this external model and machine combination: sysdir="$sysbasedir" ;; *) - print_err_msg_exit "\ + if [ "${USE_USER_STAGED_EXTRN_FILES}" != "TRUE" ]; then + print_err_msg_exit "\ The system directory in which to look for external model output files has not been specified for this external model and machine combination: extrn_mdl_name = \"${extrn_mdl_name}\" MACHINE = \"$MACHINE\"" + fi ;; esac ;; @@ -697,11 +704,13 @@ has not been specified for this external model and machine combination: sysdir="$sysbasedir" ;; *) - print_err_msg_exit "\ + if [ "${USE_USER_STAGED_EXTRN_FILES}" != "TRUE" ]; then + print_err_msg_exit "\ The system directory in which to look for external model output files has not been specified for this external model and machine combination: extrn_mdl_name = \"${extrn_mdl_name}\" MACHINE = \"$MACHINE\"" + fi ;; esac ;; @@ -730,22 +739,25 @@ has not been specified for this external model and machine combination: sysdir="$sysbasedir" ;; *) - print_err_msg_exit "\ + if [ "${USE_USER_STAGED_EXTRN_FILES}" != "TRUE" ]; then + print_err_msg_exit "\ The system directory in which to look for external model output files has not been specified for this external model and machine combination: extrn_mdl_name = \"${extrn_mdl_name}\" MACHINE = \"$MACHINE\"" + fi ;; esac ;; *) - print_err_msg_exit "\ + if [ "${USE_USER_STAGED_EXTRN_FILES}" != "TRUE" ]; then + print_err_msg_exit "\ The system directory in which to look for external model output files has not been specified for this external model: extrn_mdl_name = \"${extrn_mdl_name}\"" - + fi esac # #----------------------------------------------------------------------- diff --git a/ush/launch_FV3LAM_wflow.sh b/ush/launch_FV3LAM_wflow.sh index 702dbdf93..a79f7d9b6 100755 --- a/ush/launch_FV3LAM_wflow.sh +++ b/ush/launch_FV3LAM_wflow.sh @@ -17,7 +17,12 @@ set -u # #----------------------------------------------------------------------- # -scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) +if [[ $(uname -s) == Darwin ]]; then + command -v greadlink >/dev/null 2>&1 || { echo >&2 "For Darwin-based operating systems (MacOS), the 'greadlink' utility is required to run the UFS SRW Application. Reference the User's Guide for more information about platform requirements. Aborting."; exit 1; } + scrfunc_fp=$( greadlink -f "${BASH_SOURCE[0]}" ) +else + scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) +fi scrfunc_fn=$( basename "${scrfunc_fp}" ) scrfunc_dir=$( dirname "${scrfunc_fp}" ) # @@ -65,7 +70,12 @@ scrfunc_dir=$( dirname "${scrfunc_fp}" ) #----------------------------------------------------------------------- # exptdir=$( dirname "$0" ) -exptdir=$( readlink -f "$exptdir" ) +if [[ $(uname -s) == Darwin ]]; then + command -v greadlink >/dev/null 2>&1 || { echo >&2 "For Darwin-based operating systems (MacOS), the 'greadlink' utility is required to run the UFS SRW Application. Reference the User's Guide for more information about platform requirements. Aborting."; exit 1; } + exptdir=$( greadlink -f "$exptdir" ) +else + exptdir=$( readlink -f "$exptdir" ) +fi # #----------------------------------------------------------------------- # @@ -298,8 +308,8 @@ while read -r line; do # if [ $i -gt 0 ]; then im1=$((i-1)) - cycle_str[im1]=$( echo "$line" | sed -r -n -e "s/${regex_search}/\1/p" ) - cycle_status[im1]=$( echo "$line" | sed -r -n -e "s/${regex_search}/\2/p" ) + cycle_str[im1]=$( echo "$line" | $SED -r -n -e "s/${regex_search}/\1/p" ) + cycle_status[im1]=$( echo "$line" | $SED -r -n -e "s/${regex_search}/\2/p" ) fi i=$((i+1)) done <<< "${rocotostat_output}" @@ -394,7 +404,7 @@ launch script for this experiment: # CRONTAB_LINE with backslashes. Do this next. # crontab_line_esc_astr=$( printf "%s" "${CRONTAB_LINE}" | \ - sed -r -e "s%[*]%\\\\*%g" ) + $SED -r -e "s%[*]%\\\\*%g" ) # # In the string passed to the grep command below, we use the line start # and line end anchors ("^" and "$", respectively) to ensure that we on- diff --git a/ush/link_fix.sh b/ush/link_fix.sh index 651f4fbfd..06c71d5e1 100755 --- a/ush/link_fix.sh +++ b/ush/link_fix.sh @@ -26,7 +26,7 @@ function link_fix() { # #----------------------------------------------------------------------- # - local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) + local scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) local scrfunc_fn=$( basename "${scrfunc_fp}" ) local scrfunc_dir=$( dirname "${scrfunc_fp}" ) # @@ -283,7 +283,7 @@ Creating links in the FIXLAM directory to the grid files..." fn=$( basename $fp ) - res=$( printf "%s" $fn | sed -n -r -e "s/^C([0-9]*).*/\1/p" ) + res=$( printf "%s" $fn | $SED -n -r -e "s/^C([0-9]*).*/\1/p" ) if [ -z $res ]; then print_err_msg_exit "\ The resolution could not be extracted from the current file's name. The diff --git a/ush/load_modules_run_task.sh b/ush/load_modules_run_task.sh index c2e7cbc9a..3a30fa4bf 100755 --- a/ush/load_modules_run_task.sh +++ b/ush/load_modules_run_task.sh @@ -27,7 +27,7 @@ # #----------------------------------------------------------------------- # -scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) +scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) scrfunc_fn=$( basename "${scrfunc_fp}" ) scrfunc_dir=$( dirname "${scrfunc_fp}" ) # @@ -152,7 +152,7 @@ jjob_fp="$2" # #----------------------------------------------------------------------- # -machine=${MACHINE,,} +machine=$(echo_lowercase $MACHINE) env_fn="build_${machine}_${COMPILER}.env" env_fp="${SR_WX_APP_TOP_DIR}/env/${env_fn}" source "${env_fp}" || print_err_msg_exit "\ @@ -224,11 +224,11 @@ use_default_modulefile=0 #else -# modulefile_path=$( readlink -f "${modules_dir}/${modulefile_name}" ) +# modulefile_path=$( $READLINK -f "${modules_dir}/${modulefile_name}" ) # if [ ! -f "${modulefile_path}" ]; then -# default_modulefile_path=$( readlink -f "${default_modules_dir}/${default_modulefile_name}" ) +# default_modulefile_path=$( $READLINK -f "${default_modules_dir}/${default_modulefile_name}" ) # if [ -f "${default_modulefile_path}" ]; then # # If the task-specific modulefile does not exist but a default one does, diff --git a/ush/make_grid_mosaic_file.sh b/ush/make_grid_mosaic_file.sh index 0026cb86a..fd280a027 100644 --- a/ush/make_grid_mosaic_file.sh +++ b/ush/make_grid_mosaic_file.sh @@ -27,7 +27,11 @@ function make_grid_mosaic_file() { # #----------------------------------------------------------------------- # - local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) + if [[ $(uname -s) == Darwin ]]; then + local scrfunc_fp=$( greadlink -f "${BASH_SOURCE[0]}" ) + else + local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) + fi local scrfunc_fn=$( basename "${scrfunc_fp}" ) local scrfunc_dir=$( dirname "${scrfunc_fp}" ) # diff --git a/ush/set_FV3nml_sfc_climo_filenames.sh b/ush/set_FV3nml_sfc_climo_filenames.sh index 2d44a9d0c..13f2ecdf5 100644 --- a/ush/set_FV3nml_sfc_climo_filenames.sh +++ b/ush/set_FV3nml_sfc_climo_filenames.sh @@ -30,7 +30,7 @@ function set_FV3nml_sfc_climo_filenames() { # #----------------------------------------------------------------------- # - local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) + local scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) local scrfunc_fn=$( basename "${scrfunc_fp}" ) local scrfunc_dir=$( dirname "${scrfunc_fp}" ) # @@ -145,9 +145,9 @@ for (( i=0; i<${num_nml_vars}; i++ )); do mapping="${FV3_NML_VARNAME_TO_SFC_CLIMO_FIELD_MAPPING[$i]}" nml_var_name=$( printf "%s\n" "$mapping" | \ - sed -n -r -e "s/${regex_search}/\1/p" ) + $SED -n -r -e "s/${regex_search}/\1/p" ) sfc_climo_field_name=$( printf "%s\n" "$mapping" | - sed -n -r -e "s/${regex_search}/\2/p" ) + $SED -n -r -e "s/${regex_search}/\2/p" ) # # Check that the surface climatology field associated with the current # namelist variable is valid. diff --git a/ush/set_FV3nml_stoch_params.sh b/ush/set_FV3nml_stoch_params.sh index 98e1c3469..61e5bcec9 100644 --- a/ush/set_FV3nml_stoch_params.sh +++ b/ush/set_FV3nml_stoch_params.sh @@ -33,7 +33,7 @@ function set_FV3nml_stoch_params() { # #----------------------------------------------------------------------- # - local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) + local scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) local scrfunc_fn=$( basename "${scrfunc_fp}" ) local scrfunc_dir=$( dirname "${scrfunc_fp}" ) # diff --git a/ush/set_cycle_dates.sh b/ush/set_cycle_dates.sh index b8d406c12..c4b3adfbf 100644 --- a/ush/set_cycle_dates.sh +++ b/ush/set_cycle_dates.sh @@ -30,7 +30,7 @@ function set_cycle_dates() { # #----------------------------------------------------------------------- # - local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) + local scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) local scrfunc_fn=$( basename "${scrfunc_fp}" ) local scrfunc_dir=$( dirname "${scrfunc_fp}" ) # @@ -106,7 +106,7 @@ End date (date_end) must be at or after start date (date_start): date_crnt="${date_start}" while [ "${date_crnt}" -le "${date_end}" ]; do all_cdates+=( $( printf "%s " ${cycle_hrs[@]/#/${date_crnt}} ) ) - date_crnt=$( date -d "${date_crnt} + 1 days" +%Y%m%d ) + date_crnt=$( $DATE_UTIL -d "${date_crnt} + 1 days" +%Y%m%d ) done # #----------------------------------------------------------------------- diff --git a/ush/set_extrn_mdl_params.sh b/ush/set_extrn_mdl_params.sh index cd63a1ff4..a94d5b7b2 100644 --- a/ush/set_extrn_mdl_params.sh +++ b/ush/set_extrn_mdl_params.sh @@ -17,7 +17,7 @@ function set_extrn_mdl_params() { # #----------------------------------------------------------------------- # -local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) +local scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) local scrfunc_fn=$( basename "${scrfunc_fp}" ) local scrfunc_dir=$( dirname "${scrfunc_fp}" ) # @@ -49,25 +49,12 @@ if [ "${RUN_ENVIR}" = "nco" ]; then else + EXTRN_MDL_SYSBASEDIR_ICS="" + case ${EXTRN_MDL_NAME_ICS} in "GSMGFS") case $MACHINE in - "WCOSS_CRAY") - EXTRN_MDL_SYSBASEDIR_ICS="" - ;; - "WCOSS_DELL_P3") - EXTRN_MDL_SYSBASEDIR_ICS="" - ;; - "HERA") - EXTRN_MDL_SYSBASEDIR_ICS="" - ;; - "ORION") - EXTRN_MDL_SYSBASEDIR_ICS="" - ;; - "JET") - EXTRN_MDL_SYSBASEDIR_ICS="" - ;; "ODIN") EXTRN_MDL_SYSBASEDIR_ICS="/scratch/ywang/EPIC/GDAS/2019053000_mem001" ;; @@ -91,9 +78,6 @@ else "HERA") EXTRN_MDL_SYSBASEDIR_ICS="/scratch1/NCEPDEV/rstprod/com/gfs/prod" ;; - "ORION") - EXTRN_MDL_SYSBASEDIR_ICS="" - ;; "JET") EXTRN_MDL_SYSBASEDIR_ICS="/public/data/grids/gfs/nemsio" ;; @@ -114,9 +98,6 @@ else "HERA") EXTRN_MDL_SYSBASEDIR_ICS="/scratch2/BMC/public/data/gsd/rap/full/wrfnat" ;; - "ORION") - EXTRN_MDL_SYSBASEDIR_ICS="" - ;; "JET") EXTRN_MDL_SYSBASEDIR_ICS="/misc/whome/rtrr/rap" ;; @@ -131,9 +112,6 @@ else "HERA") EXTRN_MDL_SYSBASEDIR_ICS="/scratch2/BMC/public/data/gsd/hrrr/conus/wrfnat" ;; - "ORION") - EXTRN_MDL_SYSBASEDIR_ICS="" - ;; "JET") EXTRN_MDL_SYSBASEDIR_ICS="/misc/whome/rtrr/hrrr" ;; @@ -147,17 +125,24 @@ else fi # -# If EXTRN_MDL_SYSBASEDIR_ICS has not been set (not even to a null string), -# print out an error message and exit. +# If EXTRN_MDL_SYSBASEDIR_ICS has not been set, check if user has specified their own +# input data or HPSS_QUEUE is set (in order to pull data from HPSS at runtime). If +# none of these avenues for getting data are available, print out an error message and +# exit. # -if [ -z "${EXTRN_MDL_SYSBASEDIR_ICS+x}" ]; then +if [ "${USE_USER_STAGED_EXTRN_FILES}" = "FALSE" -a -z "${EXTRN_MDL_SYSBASEDIR_ICS}" -a -z "${QUEUE_HPSS}" ]; then print_err_msg_exit "\ -The variable EXTRN_MDL_SYSBASEDIR_ICS specifying the system directory -in which to look for the files generated by the external model for ICs -has not been set for the current combination of machine (MACHINE) and -external model (EXTRN_MDL_NAME_ICS): + +No source of initial condition files has been set for this combination +of machine (MACHINE) and external model (EXTRN_MDL_NAME_ICS), and there +is no HPSS_QUEUE specified to pull data from HPSS. Check those values +to ensure that data is available for your machine, or stage your own +data by setting USE_USER_STAGED_EXTRN_FILES = TRUE in config.sh. See +the users guide for additional information on staging input data. MACHINE = \"$MACHINE\" - EXTRN_MDL_NAME_ICS = \"${EXTRN_MDL_NAME_ICS}\"" + EXTRN_MDL_NAME_ICS = \"${EXTRN_MDL_NAME_ICS}\" + USE_USER_STAGED_EXTRN_FILES = \"${USE_USER_STAGED_EXTRN_FILES}\"" + fi # #----------------------------------------------------------------------- @@ -203,25 +188,12 @@ if [ "${RUN_ENVIR}" = "nco" ]; then else + EXTRN_MDL_SYSBASEDIR_LBCS="" + case ${EXTRN_MDL_NAME_LBCS} in "GSMGFS") case $MACHINE in - "WCOSS_CRAY") - EXTRN_MDL_SYSBASEDIR_LBCS="" - ;; - "WCOSS_DELL_P3") - EXTRN_MDL_SYSBASEDIR_LBCS="" - ;; - "HERA") - EXTRN_MDL_SYSBASEDIR_LBCS="" - ;; - "ORION") - EXTRN_MDL_SYSBASEDIR_LBCS="" - ;; - "JET") - EXTRN_MDL_SYSBASEDIR_LBCS="" - ;; "ODIN") EXTRN_MDL_SYSBASEDIR_LBCS="/scratch/ywang/EPIC/GDAS/2019053000_mem001" ;; @@ -245,9 +217,6 @@ else "HERA") EXTRN_MDL_SYSBASEDIR_LBCS="/scratch1/NCEPDEV/rstprod/com/gfs/prod" ;; - "ORION") - EXTRN_MDL_SYSBASEDIR_LBCS="" - ;; "JET") EXTRN_MDL_SYSBASEDIR_LBCS="/public/data/grids/gfs/nemsio" ;; @@ -268,15 +237,9 @@ else "HERA") EXTRN_MDL_SYSBASEDIR_LBCS="/scratch2/BMC/public/data/gsd/rap/full/wrfnat" ;; - "ORION") - EXTRN_MDL_SYSBASEDIR_LBCS="" - ;; "JET") EXTRN_MDL_SYSBASEDIR_LBCS="/misc/whome/rtrr/rap" ;; - "CHEYENNE") - EXTRN_MDL_SYSBASEDIR_LBCS="dummy_value" - ;; esac ;; @@ -285,9 +248,6 @@ else "HERA") EXTRN_MDL_SYSBASEDIR_LBCS="/scratch2/BMC/public/data/gsd/hrrr/conus/wrfnat" ;; - "ORION") - EXTRN_MDL_SYSBASEDIR_LBCS="" - ;; "JET") EXTRN_MDL_SYSBASEDIR_LBCS="/misc/whome/rtrr/hrrr" ;; @@ -298,17 +258,21 @@ else fi # -# If EXTRN_MDL_SYSBASEDIR_LBCS has not been set (not even to a null string), -# print out an error message and exit. +# If EXTRN_MDL_SYSBASEDIR_LBCS has not been set, check if user has specified their own +# input data or HPSS_QUEUE is set (in order to pull data from HPSS at runtime). If +# none of these avenues for getting data are available, print out an error message and +# exit. # -if [ -z "${EXTRN_MDL_SYSBASEDIR_LBCS+x}" ]; then +if [ "${USE_USER_STAGED_EXTRN_FILES}" = "FALSE" -a -z "${EXTRN_MDL_SYSBASEDIR_LBCS}" -a -z "${QUEUE_HPSS}" ]; then print_err_msg_exit "\ -The variable EXTRN_MDL_SYSBASEDIR_LBCS specifying the system directory -in which to look for the files generated by the external model for LBCs -has not been set for the current combination of machine (MACHINE) and -external model (EXTRN_MDL_NAME_LBCS): +of machine (MACHINE) and external model (EXTRN_MDL_NAME_LBCS), and there +is no HPSS_QUEUE specified to pull data from HPSS. Check those values +to ensure that data is available for your machine, or stage your own +data by setting USE_USER_STAGED_EXTRN_FILES = TRUE in config.sh. See +the users guide for additional information on staging input data. MACHINE = \"$MACHINE\" - EXTRN_MDL_NAME_LBCS = \"${EXTRN_MDL_NAME_LBCS}\"" + EXTRN_MDL_NAME_LBCS = \"${EXTRN_MDL_NAME_LBCS}\" + USE_USER_STAGED_EXTRN_FILES = \"${USE_USER_STAGED_EXTRN_FILES}\"" fi } # diff --git a/ush/set_gridparams_ESGgrid.sh b/ush/set_gridparams_ESGgrid.sh index 8cef16ee3..1b86c99aa 100644 --- a/ush/set_gridparams_ESGgrid.sh +++ b/ush/set_gridparams_ESGgrid.sh @@ -26,7 +26,7 @@ function set_gridparams_ESGgrid() { # #----------------------------------------------------------------------- # - local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) + local scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) local scrfunc_fn=$( basename "${scrfunc_fp}" ) local scrfunc_dir=$( dirname "${scrfunc_fp}" ) # diff --git a/ush/set_gridparams_GFDLgrid.sh b/ush/set_gridparams_GFDLgrid.sh index 7d47affb1..a76b9a58a 100644 --- a/ush/set_gridparams_GFDLgrid.sh +++ b/ush/set_gridparams_GFDLgrid.sh @@ -26,7 +26,7 @@ function set_gridparams_GFDLgrid() { # #----------------------------------------------------------------------- # - local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) + local scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) local scrfunc_fn=$( basename "${scrfunc_fp}" ) local scrfunc_dir=$( dirname "${scrfunc_fp}" ) # @@ -425,8 +425,8 @@ AFTER adjustments are: nx_of_t6_on_t6sg=$(( 2*nx_of_t6_on_t6g )) ny_of_t6_on_t6sg=$(( 2*ny_of_t6_on_t6g )) - prime_factors_nx_of_t7_on_t7g=$( factor ${nx_of_t7_on_t7g} | sed -r -e 's/^[0-9]+: (.*)/\1/' ) - prime_factors_ny_of_t7_on_t7g=$( factor ${ny_of_t7_on_t7g} | sed -r -e 's/^[0-9]+: (.*)/\1/' ) + prime_factors_nx_of_t7_on_t7g=$( factor ${nx_of_t7_on_t7g} | $SED -r -e 's/^[0-9]+: (.*)/\1/' ) + prime_factors_ny_of_t7_on_t7g=$( factor ${ny_of_t7_on_t7g} | $SED -r -e 's/^[0-9]+: (.*)/\1/' ) print_info_msg "$VERBOSE" " The number of cells in the two horizontal directions (x and y) on the diff --git a/ush/set_ozone_param.sh b/ush/set_ozone_param.sh index 5fb90f839..c85749279 100644 --- a/ush/set_ozone_param.sh +++ b/ush/set_ozone_param.sh @@ -44,7 +44,7 @@ function set_ozone_param() { # #----------------------------------------------------------------------- # - local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) + local scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) local scrfunc_fn=$( basename "${scrfunc_fp}" ) local scrfunc_dir=$( dirname "${scrfunc_fp}" ) # @@ -130,7 +130,7 @@ function set_ozone_param() { #----------------------------------------------------------------------- # regex_search="^[ ]*(ozphys.*)<\/scheme>[ ]*$" - ozone_param=$( sed -r -n -e "s/${regex_search}/\1/p" "${ccpp_phys_suite_fp}" ) + ozone_param=$( $SED -r -n -e "s/${regex_search}/\1/p" "${ccpp_phys_suite_fp}" ) if [ "${ozone_param}" = "ozphys_2015" ]; then fixgsm_ozone_fn="ozprdlos_2015_new_sbuvO3_tclm15_nuchem.f77" @@ -175,11 +175,11 @@ num_symlinks=${#CYCLEDIR_LINKS_TO_FIXam_FILES_MAPPING[@]} for (( i=0; i<${num_symlinks}; i++ )); do mapping="${CYCLEDIR_LINKS_TO_FIXam_FILES_MAPPING[$i]}" symlink=$( printf "%s\n" "$mapping" | \ - sed -n -r -e "s/${regex_search}/\1/p" ) + $SED -n -r -e "s/${regex_search}/\1/p" ) if [ "$symlink" = "${ozone_symlink}" ]; then regex_search="^[ ]*([^| ]+[ ]*)[|][ ]*([^| ]*)[ ]*$" mapping_ozone=$( printf "%s\n" "$mapping" | \ - sed -n -r -e "s/${regex_search}/\1/p" ) + $SED -n -r -e "s/${regex_search}/\1/p" ) mapping_ozone="${mapping_ozone}| ${fixgsm_ozone_fn}" CYCLEDIR_LINKS_TO_FIXam_FILES_MAPPING[$i]="${mapping_ozone}" fixgsm_ozone_fn_is_set="TRUE" diff --git a/ush/set_predef_grid_params.sh b/ush/set_predef_grid_params.sh index e87e9ecdb..1dde42871 100644 --- a/ush/set_predef_grid_params.sh +++ b/ush/set_predef_grid_params.sh @@ -16,7 +16,7 @@ function set_predef_grid_params() { # #----------------------------------------------------------------------- # -local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) +local scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) local scrfunc_fn=$( basename "${scrfunc_fp}" ) local scrfunc_dir=$( dirname "${scrfunc_fp}" ) # diff --git a/ush/set_thompson_mp_fix_files.sh b/ush/set_thompson_mp_fix_files.sh index 9e3143aed..f24f55c88 100644 --- a/ush/set_thompson_mp_fix_files.sh +++ b/ush/set_thompson_mp_fix_files.sh @@ -32,7 +32,7 @@ function set_thompson_mp_fix_files() { # #----------------------------------------------------------------------- # - local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) + local scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) local scrfunc_fn=$( basename "${scrfunc_fp}" ) local scrfunc_dir=$( dirname "${scrfunc_fp}" ) # @@ -93,7 +93,7 @@ function set_thompson_mp_fix_files() { # thompson_mp_name="mp_thompson" regex_search="^[ ]*(${thompson_mp_name})<\/scheme>[ ]*$" - thompson_mp_name_or_null=$( sed -r -n -e "s/${regex_search}/\1/p" "${ccpp_phys_suite_fp}" ) + thompson_mp_name_or_null=$( $SED -r -n -e "s/${regex_search}/\1/p" "${ccpp_phys_suite_fp}" ) if [ "${thompson_mp_name_or_null}" = "${thompson_mp_name}" ]; then thompson_mp_used="TRUE" diff --git a/ush/setup.sh b/ush/setup.sh index 8f23bbefe..3b8248ac6 100755 --- a/ush/setup.sh +++ b/ush/setup.sh @@ -1,3 +1,4 @@ +#!/bin/bash # #----------------------------------------------------------------------- # @@ -23,7 +24,7 @@ function setup() { # #----------------------------------------------------------------------- # -local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) +local scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) local scrfunc_fn=$( basename "${scrfunc_fp}" ) local scrfunc_dir=$( dirname "${scrfunc_fp}" ) # @@ -139,7 +140,7 @@ check_var_valid_value "VERBOSE" "valid_vals_VERBOSE" # Set VERBOSE to either "TRUE" or "FALSE" so we don't have to consider # other valid values later on. # -VERBOSE=${VERBOSE^^} +VERBOSE=$(echo_uppercase $VERBOSE) if [ "$VERBOSE" = "TRUE" ] || \ [ "$VERBOSE" = "YES" ]; then VERBOSE="TRUE" @@ -159,7 +160,7 @@ check_var_valid_value "USE_CRON_TO_RELAUNCH" "valid_vals_USE_CRON_TO_RELAUNCH" # Set USE_CRON_TO_RELAUNCH to either "TRUE" or "FALSE" so we don't have to consider # other valid values later on. # -USE_CRON_TO_RELAUNCH=${USE_CRON_TO_RELAUNCH^^} +USE_CRON_TO_RELAUNCH=$(echo_uppercase $USE_CRON_TO_RELAUNCH) if [ "${USE_CRON_TO_RELAUNCH}" = "TRUE" ] || \ [ "${USE_CRON_TO_RELAUNCH}" = "YES" ]; then USE_CRON_TO_RELAUNCH="TRUE" @@ -179,7 +180,7 @@ check_var_valid_value "RUN_TASK_MAKE_GRID" "valid_vals_RUN_TASK_MAKE_GRID" # Set RUN_TASK_MAKE_GRID to either "TRUE" or "FALSE" so we don't have to # consider other valid values later on. # -RUN_TASK_MAKE_GRID=${RUN_TASK_MAKE_GRID^^} +RUN_TASK_MAKE_GRID=$(echo_uppercase $RUN_TASK_MAKE_GRID) if [ "${RUN_TASK_MAKE_GRID}" = "TRUE" ] || \ [ "${RUN_TASK_MAKE_GRID}" = "YES" ]; then RUN_TASK_MAKE_GRID="TRUE" @@ -220,7 +221,7 @@ check_var_valid_value \ # Set RUN_TASK_MAKE_SFC_CLIMO to either "TRUE" or "FALSE" so we don't # have to consider other valid values later on. # -RUN_TASK_MAKE_SFC_CLIMO=${RUN_TASK_MAKE_SFC_CLIMO^^} +RUN_TASK_MAKE_SFC_CLIMO=$(echo_uppercase $RUN_TASK_MAKE_SFC_CLIMO) if [ "${RUN_TASK_MAKE_SFC_CLIMO}" = "TRUE" ] || \ [ "${RUN_TASK_MAKE_SFC_CLIMO}" = "YES" ]; then RUN_TASK_MAKE_SFC_CLIMO="TRUE" @@ -240,7 +241,7 @@ check_var_valid_value "DO_SHUM" "valid_vals_DO_SHUM" # Set DO_SHUM to either "TRUE" or "FALSE" so we don't # have to consider other valid values later on. # -DO_SHUM=${DO_SHUM^^} +DO_SHUM=$(echo_uppercase $DO_SHUM) if [ "${DO_SHUM}" = "TRUE" ] || \ [ "${DO_SHUM}" = "YES" ]; then DO_SHUM="TRUE" @@ -260,7 +261,7 @@ check_var_valid_value "DO_SPPT" "valid_vals_DO_SPPT" # Set DO_SPPT to either "TRUE" or "FALSE" so we don't # have to consider other valid values later on. # -DO_SPPT=${DO_SPPT^^} +DO_SPPT=$(echo_uppercase $DO_SPPT) if [ "${DO_SPPT}" = "TRUE" ] || \ [ "${DO_SPPT}" = "YES" ]; then DO_SPPT="TRUE" @@ -280,7 +281,7 @@ check_var_valid_value "DO_SKEB" "valid_vals_DO_SKEB" # Set DO_SKEB to either "TRUE" or "FALSE" so we don't # have to consider other valid values later on. # -DO_SKEB=${DO_SKEB^^} +DO_SKEB=$(echo_uppercase $DO_SKEB) if [ "${DO_SKEB}" = "TRUE" ] || \ [ "${DO_SKEB}" = "YES" ]; then DO_SKEB="TRUE" @@ -321,7 +322,7 @@ check_var_valid_value "USE_FVCOM" "valid_vals_USE_FVCOM" # Set USE_FVCOM to either "TRUE" or "FALSE" so we don't have to consider # other valid values later on. # -USE_FVCOM=${USE_FVCOM^^} +USE_FVCOM=$(echo_uppercase $USE_FVCOM) if [ "$USE_FVCOM" = "TRUE" ] || \ [ "$USE_FVCOM" = "YES" ]; then USE_FVCOM="TRUE" @@ -345,7 +346,7 @@ check_var_valid_value "DOT_OR_USCORE" "valid_vals_DOT_OR_USCORE" # #----------------------------------------------------------------------- # -MACHINE=$( printf "%s" "$MACHINE" | sed -e 's/\(.*\)/\U\1/' ) +MACHINE=$( printf "%s" "$MACHINE" | $SED -e 's/\(.*\)/\U\1/' ) check_var_valid_value "MACHINE" "valid_vals_MACHINE" # #----------------------------------------------------------------------- @@ -356,10 +357,12 @@ check_var_valid_value "MACHINE" "valid_vals_MACHINE" # #----------------------------------------------------------------------- # +NCORES_PER_NODE="" case $MACHINE in "WCOSS_CRAY") - NCORES_PER_NODE="24" + WORKFLOW_MANAGER="rocoto" + NCORES_PER_NODE=24 SCHED="lsfcray" QUEUE_DEFAULT=${QUEUE_DEFAULT:-"dev"} QUEUE_HPSS=${QUEUE_HPSS:-"dev_transfer"} @@ -367,6 +370,7 @@ case $MACHINE in ;; "WCOSS_DELL_P3") + WORKFLOW_MANAGER="rocoto" NCORES_PER_NODE=24 SCHED="lsf" QUEUE_DEFAULT=${QUEUE_DEFAULT:-"dev"} @@ -375,6 +379,7 @@ case $MACHINE in ;; "HERA") + WORKFLOW_MANAGER="rocoto" NCORES_PER_NODE=40 SCHED="${SCHED:-slurm}" PARTITION_DEFAULT=${PARTITION_DEFAULT:-"hera"} @@ -386,6 +391,7 @@ case $MACHINE in ;; "ORION") + WORKFLOW_MANAGER="rocoto" NCORES_PER_NODE=40 SCHED="${SCHED:-slurm}" PARTITION_DEFAULT=${PARTITION_DEFAULT:-"orion"} @@ -397,6 +403,7 @@ case $MACHINE in ;; "JET") + WORKFLOW_MANAGER="rocoto" NCORES_PER_NODE=24 SCHED="${SCHED:-slurm}" PARTITION_DEFAULT=${PARTITION_DEFAULT:-"sjet,vjet,kjet,xjet"} @@ -408,6 +415,7 @@ case $MACHINE in ;; "ODIN") + WORKFLOW_MANAGER="rocoto" NCORES_PER_NODE=24 SCHED="${SCHED:-slurm}" PARTITION_DEFAULT=${PARTITION_DEFAULT:-"workq"} @@ -419,6 +427,7 @@ case $MACHINE in ;; "CHEYENNE") + WORKFLOW_MANAGER="rocoto" NCORES_PER_NODE=36 SCHED="${SCHED:-pbspro}" QUEUE_DEFAULT=${QUEUE_DEFAULT:-"regular"} @@ -427,6 +436,7 @@ case $MACHINE in ;; "STAMPEDE") + WORKFLOW_MANAGER="rocoto" NCORES_PER_NODE=68 SCHED="slurm" PARTITION_DEFAULT=${PARTITION_DEFAULT:-"normal"} @@ -437,6 +447,28 @@ case $MACHINE in QUEUE_FCST=${QUEUE_FCST:-"normal"} ;; + "GAEA") + NCORES_PER_NODE=36 + SCHED="slurm" + CLUSTERS_DEFAULT=${CLUSTERS_DEFAULT:-"c4"} + QUEUE_DEFAULT=${QUEUE_DEFAULT:-"normal"} + PARTITION_HPSS=${PARTITION_HPSS:-"rdtn"} + CLUSTERS_HPSS=${CLUSTERS_HPSS:-"es"} + QUEUE_HPSS=${QUEUE_HPSS:-"normal"} + CLUSTERS_FCST=${CLUSTERS_FCST:-"c4"} + QUEUE_FCST=${QUEUE_FCST:-"normal"} + ;; + + "MACOS") + WORKFLOW_MANAGER="none" + SCHED="none" + ;; + + "LINUX") + WORKFLOW_MANAGER="none" + SCHED="none" + ;; + esac # #----------------------------------------------------------------------- @@ -445,20 +477,26 @@ esac # #----------------------------------------------------------------------- # -SCHED="${SCHED,,}" +SCHED=$(echo_lowercase $SCHED) check_var_valid_value "SCHED" "valid_vals_SCHED" -# #----------------------------------------------------------------------- # -# Verify that the ACCOUNT variable is not empty. If it is, print out an -# error message and exit. +# If we are using a workflow manager, run some checks. First, +# verify that the ACCOUNT variable is not empty. Second, ensure that the +# custom RUN_CMD variables are not set. # #----------------------------------------------------------------------- # -if [ -z "$ACCOUNT" ]; then - print_err_msg_exit "\ -The variable ACCOUNT cannot be empty: - ACCOUNT = \"$ACCOUNT\"" +if [ "$WORKFLOW_MANAGER" != "none" ]; then + if [ -z "$ACCOUNT" ]; then + print_err_msg_exit "\ +The variable ACCOUNT cannot be empty if you are using a workflow manager: + ACCOUNT = \"$ACCOUNT\" + WORKFLOW_MANAGER = \"$WORKFLOW_MANAGER\"" + fi + RUN_CMD_UTILS="" + RUN_CMD_FCST="" + RUN_CMD_POST="" fi # #----------------------------------------------------------------------- @@ -527,7 +565,7 @@ check_var_valid_value \ #----------------------------------------------------------------------- # DATE_OR_NULL=$( printf "%s" "${DATE_FIRST_CYCL}" | \ - sed -n -r -e "s/^([0-9]{8})$/\1/p" ) + $SED -n -r -e "s/^([0-9]{8})$/\1/p" ) if [ -z "${DATE_OR_NULL}" ]; then print_err_msg_exit "\ DATE_FIRST_CYCL must be a string consisting of exactly 8 digits of the @@ -537,7 +575,7 @@ month, and DD is the 2-digit day-of-month. fi DATE_OR_NULL=$( printf "%s" "${DATE_LAST_CYCL}" | \ - sed -n -r -e "s/^([0-9]{8})$/\1/p" ) + $SED -n -r -e "s/^([0-9]{8})$/\1/p" ) if [ -z "${DATE_OR_NULL}" ]; then print_err_msg_exit "\ DATE_LAST_CYCL must be a string consisting of exactly 8 digits of the @@ -559,7 +597,7 @@ CYCL_HRS_str="( $CYCL_HRS_str)" i=0 for CYCL in "${CYCL_HRS[@]}"; do - CYCL_OR_NULL=$( printf "%s" "$CYCL" | sed -n -r -e "s/^([0-9]{2})$/\1/p" ) + CYCL_OR_NULL=$( printf "%s" "$CYCL" | $SED -n -r -e "s/^([0-9]{2})$/\1/p" ) if [ -z "${CYCL_OR_NULL}" ]; then print_err_msg_exit "\ @@ -719,7 +757,8 @@ case $MACHINE in ;; *) - print_err_msg_exit "\ + if [ -z "$FIXgsm" -o -z "$TOPO_DIR" -o -z "$SFC_CLIMO_INPUT_DIR" ]; then + print_err_msg_exit "\ One or more fix file directories have not been specified for this machine: MACHINE = \"$MACHINE\" FIXgsm = \"${FIXgsm:-\"\"} @@ -727,6 +766,7 @@ One or more fix file directories have not been specified for this machine: SFC_CLIMO_INPUT_DIR = \"${SFC_CLIMO_INPUT_DIR:-\"\"} FIXLAM_NCO_BASEDIR = \"${FIXLAM_NCO_BASEDIR:-\"\"} You can specify the missing location(s) in config.sh" + fi ;; esac @@ -743,7 +783,7 @@ esac # #----------------------------------------------------------------------- # -mng_extrns_cfg_fn=$( readlink -f "${SR_WX_APP_TOP_DIR}/Externals.cfg" ) +mng_extrns_cfg_fn=$( $READLINK -f "${SR_WX_APP_TOP_DIR}/Externals.cfg" ) property_name="local_path" # # Get the base directory of the FV3 forecast model code. @@ -815,7 +855,7 @@ check_var_valid_value \ # Set USE_CUSTOM_POST_CONFIG_FILE to either "TRUE" or "FALSE" so we don't # have to consider other valid values later on. # -USE_CUSTOM_POST_CONFIG_FILE=${USE_CUSTOM_POST_CONFIG_FILE^^} +USE_CUSTOM_POST_CONFIG_FILE=$(echo_uppercase $USE_CUSTOM_POST_CONFIG_FILE) if [ "$USE_CUSTOM_POST_CONFIG_FILE" = "TRUE" ] || \ [ "$USE_CUSTOM_POST_CONFIG_FILE" = "YES" ]; then USE_CUSTOM_POST_CONFIG_FILE="TRUE" @@ -992,7 +1032,7 @@ fi if [ "${EXPT_BASEDIR:0:1}" != "/" ]; then EXPT_BASEDIR="${SR_WX_APP_TOP_DIR}/../expt_dirs/${EXPT_BASEDIR}" fi -EXPT_BASEDIR="$( readlink -m ${EXPT_BASEDIR} )" +EXPT_BASEDIR="$( $READLINK -m ${EXPT_BASEDIR} )" mkdir_vrfy -p "${EXPT_BASEDIR}" # #----------------------------------------------------------------------- @@ -1065,11 +1105,55 @@ check_for_preexist_dir_file "$EXPTDIR" "${PREEXISTING_DIR_METHOD}" # LOGDIR="${EXPTDIR}/log" -FIXam="${EXPTDIR}/fix_am" -FIXLAM="${EXPTDIR}/fix_lam" - if [ "${RUN_ENVIR}" = "nco" ]; then + FIXam="${FIXrrfs}/fix_am" +# +# In NCO mode (i.e. if RUN_ENVIR set to "nco"), it is assumed that before +# running the experiment generation script, the path specified in FIXam +# already exists and is either itself the directory in which various fixed +# files (but not the ones containing the regional grid and the orography +# and surface climatology on that grid) are located, or it is a symlink +# to such a directory. Resolve any symlinks in the path specified by +# FIXam and check that this is the case. +# + path_resolved=$( $READLINK -m "$FIXam" ) + if [ ! -d "${path_resolved}" ]; then + print_err_msg_exit "\ +In order to be able to generate a forecast experiment in NCO mode (i.e. +when RUN_ENVIR set to \"nco\"), the path specified by FIXam after resolving +all symlinks (path_resolved) must be an existing directory (but in this +case isn't): + RUN_ENVIR = \"${RUN_ENVIR}\" + FIXam = \"$FIXam\" + path_resolved = \"${path_resolved}\" +Please ensure that path_resolved is an existing directory and then rerun +the experiment generation script." + fi + + FIXLAM="${FIXrrfs}/fix_lam/${PREDEF_GRID_NAME}" +# +# In NCO mode (i.e. if RUN_ENVIR set to "nco"), it is assumed that before +# running the experiment generation script, the path specified in FIXLAM +# already exists and is either itself the directory in which the fixed +# grid, orography, and surface climatology files are located, or it is a +# symlink to such a directory. Resolve any symlinks in the path specified +# by FIXLAM and check that this is the case. +# + path_resolved=$( $READLINK -m "$FIXLAM" ) + if [ ! -d "${path_resolved}" ]; then + print_err_msg_exit "\ +In order to be able to generate a forecast experiment in NCO mode (i.e. +when RUN_ENVIR set to \"nco\"), the path specified by FIXLAM after resolving +all symlinks (path_resolved) must be an existing directory (but in this +case isn't): + RUN_ENVIR = \"${RUN_ENVIR}\" + FIXLAM = \"$FIXLAM\" + path_resolved = \"${path_resolved}\" +Please ensure that path_resolved is an existing directory and then rerun +the experiment generation script." + fi + CYCLE_BASEDIR="$STMP/tmpnwprd/$RUN" check_for_preexist_dir_file "${CYCLE_BASEDIR}" "${PREEXISTING_DIR_METHOD}" COMROOT="$PTMP/com" @@ -1228,7 +1312,7 @@ check_var_valid_value "USE_USER_STAGED_EXTRN_FILES" "valid_vals_USE_USER_STAGED_ # Set USE_USER_STAGED_EXTRN_FILES to either "TRUE" or "FALSE" so we don't # have to consider other valid values later on. # -USE_USER_STAGED_EXTRN_FILES=${USE_USER_STAGED_EXTRN_FILES^^} +USE_USER_STAGED_EXTRN_FILES=$(echo_uppercase $USE_USER_STAGED_EXTRN_FILES) if [ "${USE_USER_STAGED_EXTRN_FILES}" = "YES" ]; then USE_USER_STAGED_EXTRN_FILES="TRUE" elif [ "${USE_USER_STAGED_EXTRN_FILES}" = "NO" ]; then @@ -1275,7 +1359,7 @@ check_var_valid_value "DO_ENSEMBLE" "valid_vals_DO_ENSEMBLE" # Set DO_ENSEMBLE to either "TRUE" or "FALSE" so we don't have to consider # other valid values later on. # -DO_ENSEMBLE=${DO_ENSEMBLE^^} +DO_ENSEMBLE=$(echo_uppercase $DO_ENSEMBLE) if [ "$DO_ENSEMBLE" = "TRUE" ] || \ [ "$DO_ENSEMBLE" = "YES" ]; then DO_ENSEMBLE="TRUE" @@ -1747,8 +1831,35 @@ mkdir_vrfy -p "$EXPTDIR" # #----------------------------------------------------------------------- # -mkdir_vrfy -p "$FIXLAM" -RES_IN_FIXLAM_FILENAMES="" +if [ "${RUN_ENVIR}" = "nco" ]; then + + suffix="${DOT_OR_USCORE}mosaic.halo${NH3}.nc" + glob_pattern="C*$suffix" + cd_vrfy $FIXLAM + num_files=$( ls -1 ${glob_pattern} 2>/dev/null | wc -l ) + + if [ "${num_files}" -ne "1" ]; then + print_err_msg_exit "\ +Exactly one file must exist in directory FIXLAM matching the globbing +pattern glob_pattern: + FIXLAM = \"${FIXLAM}\" + glob_pattern = \"${glob_pattern}\" + num_files = ${num_files}" + fi + + fn=$( ls -1 ${glob_pattern} ) + RES_IN_FIXLAM_FILENAMES=$( \ + printf "%s" $fn | $SED -n -r -e "s/^C([0-9]*)$suffix/\1/p" ) + if [ "${GRID_GEN_METHOD}" = "GFDLgrid" ] && \ + [ "${GFDLgrid_RES}" -ne "${RES_IN_FIXLAM_FILENAMES}" ]; then + print_err_msg_exit "\ +The resolution extracted from the fixed file names (RES_IN_FIXLAM_FILENAMES) +does not match the resolution specified by GFDLgrid_RES: + GFDLgrid_RES = ${GFDLgrid_RES} + RES_IN_FIXLAM_FILENAMES = ${RES_IN_FIXLAM_FILENAMES}" + fi + +else # #----------------------------------------------------------------------- # @@ -1866,7 +1977,7 @@ check_var_valid_value "QUILTING" "valid_vals_QUILTING" # Set QUILTING to either "TRUE" or "FALSE" so we don't have to consider # other valid values later on. # -QUILTING=${QUILTING^^} +QUILTING=$(echo_uppercase $QUILTING) if [ "$QUILTING" = "TRUE" ] || \ [ "$QUILTING" = "YES" ]; then QUILTING="TRUE" @@ -1886,7 +1997,7 @@ check_var_valid_value "PRINT_ESMF" "valid_vals_PRINT_ESMF" # Set PRINT_ESMF to either "TRUE" or "FALSE" so we don't have to consider # other valid values later on. # -PRINT_ESMF=${PRINT_ESMF^^} +PRINT_ESMF=$(echo_uppercase $PRINT_ESMF) if [ "${PRINT_ESMF}" = "TRUE" ] || \ [ "${PRINT_ESMF}" = "YES" ]; then PRINT_ESMF="TRUE" @@ -1957,18 +2068,17 @@ NNODES_RUN_FCST=$(( (PE_MEMBER01 + PPN_RUN_FCST - 1)/PPN_RUN_FCST )) # #----------------------------------------------------------------------- # -# Set the name of the file containing aerosol climatology data that, if -# necessary, can be used to generate approximate versions of the aerosol -# fields needed by Thompson microphysics. This file will be used to -# generate such approximate aerosol fields in the ICs and LBCs if Thompson -# MP is included in the physics suite and if the exteranl model for ICs -# or LBCs does not already provide these fields. Also, set the full path -# to this file. +# Create a new experiment directory. Note that at this point we are +# guaranteed that there is no preexisting experiment directory. For +# platforms with no workflow manager, we need to create LOGDIR as well, +# since it won't be created later at runtime. # #----------------------------------------------------------------------- # -THOMPSON_MP_CLIMO_FN="Thompson_MP_MONTHLY_CLIMO.nc" -THOMPSON_MP_CLIMO_FP="$FIXam/${THOMPSON_MP_CLIMO_FN}" +mkdir_vrfy -p "$EXPTDIR" +mkdir_vrfy -p "$LOGDIR" + + # #----------------------------------------------------------------------- # @@ -2027,7 +2137,7 @@ cp_vrfy $USHDIR/${EXPT_DEFAULT_CONFIG_FN} ${GLOBAL_VAR_DEFNS_FP} # # Read all lines of GLOBAL_VAR_DEFNS file into the variable line_list. -line_list=$( sed -r -e "s/(.*)/\1/g" ${GLOBAL_VAR_DEFNS_FP} ) +line_list=$( $SED -r -e "s/(.*)/\1/g" ${GLOBAL_VAR_DEFNS_FP} ) # # Loop through the lines in line_list and concatenate lines ending with # the line bash continuation character "\". @@ -2068,7 +2178,7 @@ done <<< "${line_list}" #----------------------------------------------------------------------- # # Also should remove trailing whitespace... -line_list=$( sed -r \ +line_list=$( $SED -r \ -e "s/^([ ]*)([^ ]+.*)/\2/g" \ -e "/^#.*/d" \ -e "/^$/d" \ @@ -2114,7 +2224,7 @@ str_to_insert=${str_to_insert//$'\n'/\\n} # the string "#!", e.g. "#!/bin/bash"). # regexp="(^#!.*)" -sed -i -r -e "s|$regexp|\1\n\n${str_to_insert}\n|g" ${GLOBAL_VAR_DEFNS_FP} +$SED -i -r -e "s|$regexp|\1\n\n${str_to_insert}\n|g" ${GLOBAL_VAR_DEFNS_FP} @@ -2134,7 +2244,7 @@ while read crnt_line; do # or more characters representing the value that the variable is being # set to. # - var_name=$( printf "%s" "${crnt_line}" | sed -n -r -e "s/^([^ ]*)=.*/\1/p" ) + var_name=$( printf "%s" "${crnt_line}" | $SED -n -r -e "s/^([^ ]*)=.*/\1/p" ) #echo #echo "============================" #printf "%s\n" "var_name = \"${var_name}\"" @@ -2338,7 +2448,7 @@ FV3_NML_ENSMEM_FPS=( $( printf "\"%s\" " "${FV3_NML_ENSMEM_FPS[@]}" )) GLOBAL_VAR_DEFNS_FP="${GLOBAL_VAR_DEFNS_FP}" # Try this at some point instead of hard-coding it as above; it's a more # flexible approach (if it works). -#GLOBAL_VAR_DEFNS_FP=$( readlink -f "${BASH_SOURCE[0]}" ) +# GLOBAL_VAR_DEFNS_FP=$( $READLINK -f "${BASH_SOURCE[0]}" ) DATA_TABLE_TMPL_FN="${DATA_TABLE_TMPL_FN}" DIAG_TABLE_TMPL_FN="${DIAG_TABLE_TMPL_FN}" @@ -2561,6 +2671,7 @@ FVCOM_FILE="${FVCOM_FILE}" # NCORES_PER_NODE="${NCORES_PER_NODE}" PE_MEMBER01="${PE_MEMBER01}" +RUN_CMD_FCST="${RUN_CMD_FCST}" EOM } || print_err_msg_exit "\ Heredoc (cat) command to append new variable definitions to variable diff --git a/ush/source_util_funcs.sh b/ush/source_util_funcs.sh index 1ebe07aff..1b63ade7b 100644 --- a/ush/source_util_funcs.sh +++ b/ush/source_util_funcs.sh @@ -8,7 +8,11 @@ function source_util_funcs() { # #----------------------------------------------------------------------- # - local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) + if [[ $(uname -s) == Darwin ]]; then + local scrfunc_fp=$( greadlink -f "${BASH_SOURCE[0]}" ) + else + local scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" ) + fi local scrfunc_fn=$( basename "${scrfunc_fp}" ) local scrfunc_dir=$( dirname "${scrfunc_fp}" ) # @@ -40,6 +44,15 @@ function source_util_funcs() { # #----------------------------------------------------------------------- # +# Source the file that defines MacOS-specific UNIX command-line +# utilities, that mimic the functionality of the GNU equivalents +# +#----------------------------------------------------------------------- +# + . ${bashutils_dir}/define_macos_utilities.sh +# +#----------------------------------------------------------------------- +# # Source the file containing the functions that print out messages. # #----------------------------------------------------------------------- @@ -74,6 +87,15 @@ function source_util_funcs() { # #----------------------------------------------------------------------- # +# Source the file containing the functions that will echo given strings +# as uppercase or lowercase +# +#----------------------------------------------------------------------- +# + . ${bashutils_dir}/change_case.sh +# +#----------------------------------------------------------------------- +# # Source the file containing the function that checks for preexisting # directories or files and handles them according to a specified method # (which can be one of "delete", "rename", and "quit"). diff --git a/ush/valid_param_vals.sh b/ush/valid_param_vals.sh index f94a1569d..b6b05bc14 100644 --- a/ush/valid_param_vals.sh +++ b/ush/valid_param_vals.sh @@ -1,7 +1,8 @@ valid_vals_RUN_ENVIR=("nco" "community") valid_vals_VERBOSE=("TRUE" "true" "YES" "yes" "FALSE" "false" "NO" "no") -valid_vals_MACHINE=("WCOSS_CRAY" "WCOSS_DELL_P3" "HERA" "ORION" "JET" "ODIN" "CHEYENNE" "STAMPEDE") +valid_vals_MACHINE=("WCOSS_CRAY" "WCOSS_DELL_P3" "HERA" "ORION" "JET" "ODIN" "CHEYENNE" "STAMPEDE" "GAEA" "MACOS" "LINUX") valid_vals_SCHED=("slurm" "pbspro" "lsf" "lsfcray" "none") +valid_vals_WORKFLOW_MANAGER=("rocoto" "none") valid_vals_PREDEF_GRID_NAME=( \ "RRFS_CONUS_25km" \ "RRFS_CONUS_13km" \ From d7f799256bc850eabe1d432710cbeebb2371a771 Mon Sep 17 00:00:00 2001 From: JeffBeck-NOAA <55201531+JeffBeck-NOAA@users.noreply.github.com> Date: Sat, 6 Feb 2021 14:09:59 -0700 Subject: [PATCH 02/10] Source bash utils in the workflow launch script and set the workflow manager as Rocoto. (#426) ## DESCRIPTION OF CHANGES: Added sourcing of bash utilities to avoid $SED undefined variable error when using the workflow launch script. Add Rocoto as the workflow manager on Gaea. ## TESTS CONDUCTED: Tested on Gaea. Release branch end-to-end tests (aside from 3km runs) were run on Hera and all passed. ## CONTRIBUTORS (optional): @climbfuji, @mkavulich, @gsketefian --- ush/launch_FV3LAM_wflow.sh | 8 ++++++++ ush/setup.sh | 1 + 2 files changed, 9 insertions(+) diff --git a/ush/launch_FV3LAM_wflow.sh b/ush/launch_FV3LAM_wflow.sh index a79f7d9b6..7075e8dd9 100755 --- a/ush/launch_FV3LAM_wflow.sh +++ b/ush/launch_FV3LAM_wflow.sh @@ -87,6 +87,14 @@ fi # #----------------------------------------------------------------------- # +# Source bash utility functions. +# +#----------------------------------------------------------------------- +# +. $USHDIR/source_util_funcs.sh +# +#----------------------------------------------------------------------- +# # Set the name of the experiment. We take this to be the name of the # experiment subdirectory (i.e. the string after the last "/" in the # full path to the experiment directory). diff --git a/ush/setup.sh b/ush/setup.sh index 3b8248ac6..0f6f892b2 100755 --- a/ush/setup.sh +++ b/ush/setup.sh @@ -448,6 +448,7 @@ case $MACHINE in ;; "GAEA") + WORKFLOW_MANAGER="rocoto" NCORES_PER_NODE=36 SCHED="slurm" CLUSTERS_DEFAULT=${CLUSTERS_DEFAULT:-"c4"} From 78e209820be0e1489c797194cfc0e79633678cab Mon Sep 17 00:00:00 2001 From: "Christina.Holt" Date: Wed, 10 Feb 2021 16:55:57 +0000 Subject: [PATCH 03/10] Run with LINUX + rocoto. --- scripts/exregional_run_fcst.sh | 14 +++ ush/config_defaults.sh | 6 ++ ush/create_diag_table_files.sh | 35 +++--- ush/generate_FV3LAM_wflow.sh | 20 ---- ush/setup.sh | 192 ++++++++++++++++++--------------- ush/templates/FV3LAM_wflow.xml | 2 +- 6 files changed, 142 insertions(+), 127 deletions(-) diff --git a/scripts/exregional_run_fcst.sh b/scripts/exregional_run_fcst.sh index 4c4161e36..c14a27a80 100755 --- a/scripts/exregional_run_fcst.sh +++ b/scripts/exregional_run_fcst.sh @@ -9,6 +9,7 @@ # . ${GLOBAL_VAR_DEFNS_FP} . $USHDIR/source_util_funcs.sh +. $USHDIR/create_diag_table_file.sh # #----------------------------------------------------------------------- # @@ -440,6 +441,19 @@ cycle's (cdate) run directory (run_dir) failed: # #----------------------------------------------------------------------- # +# Call the function that creates the model configuration file within each +# cycle directory. +# +#----------------------------------------------------------------------- +# +create_diag_table_file \ + run_dir="${run_dir}" || print_err_msg_exit "\ + Call to function to create a diag table file for the current + cycle's (cdate) run directory (run_dir) failed: + run_dir = \"${run_dir}\"" +# +#----------------------------------------------------------------------- +# # If running ensemble forecasts, create a link to the cycle-specific # diagnostic tables file in the cycle directory. Note that this link # should not be made if not running ensemble forecasts because in that diff --git a/ush/config_defaults.sh b/ush/config_defaults.sh index a38d713cc..b8059db4a 100644 --- a/ush/config_defaults.sh +++ b/ush/config_defaults.sh @@ -51,6 +51,11 @@ RUN_ENVIR="nco" # default, but if the machine name is set to a platform that supports # rocoto, this will be overwritten and set to "rocoto". # +# NCORES_PER_NODE: +# The number of cores available per node on the compute platform. Set +# for supported platforms in setup.sh, but is now also configurable for +# generic platforms. +# # SCHED: # The job scheduler to use (e.g. slurm). Set this to an empty string in # order for the experiment generation script to set it depending on the @@ -109,6 +114,7 @@ RUN_ENVIR="nco" MACHINE="BIG_COMPUTER" ACCOUNT="project_name" WORKFLOW_MANAGER="none" +NCORES_PER_NODE="" SCHED="" PARTITION_DEFAULT="" QUEUE_DEFAULT="" diff --git a/ush/create_diag_table_files.sh b/ush/create_diag_table_files.sh index f2a54dc7c..26c990702 100644 --- a/ush/create_diag_table_files.sh +++ b/ush/create_diag_table_files.sh @@ -6,7 +6,7 @@ # #----------------------------------------------------------------------- # -function create_diag_table_files() { +function create_diag_table_file() { # #----------------------------------------------------------------------- # @@ -45,7 +45,9 @@ function create_diag_table_files() { # #----------------------------------------------------------------------- # - local valid_args=() + local valid_args=( + run_dir \ + ) process_args valid_args "$@" # #----------------------------------------------------------------------- @@ -65,8 +67,6 @@ function create_diag_table_files() { #----------------------------------------------------------------------- # local i \ - cdate \ - cycle_dir \ diag_table_fp \ settings # @@ -77,31 +77,31 @@ function create_diag_table_files() { #----------------------------------------------------------------------- # print_info_msg "$VERBOSE" " -Creating a diagnostics table file (\"${DIAG_TABLE_FN}\") within each cycle -directory..." +Creating a diagnostics table file (\"${DIAG_TABLE_FN}\") in the +specified run +directory (run_dir): + run_dir = \"${run_dir}\"" - for (( i=0; i<${NUM_CYCLES}; i++ )); do - cdate="${ALL_CDATES[$i]}" - cycle_dir="${CYCLE_BASEDIR}/$cdate" - - diag_table_fp="${cycle_dir}/${DIAG_TABLE_FN}" - print_info_msg "$VERBOSE" " + # Copy template diag_table file from the templates directory to the + # run directory. + diag_table_fp="${cycle_dir}/${DIAG_TABLE_FN}" + print_info_msg "$VERBOSE" " Using the template diagnostics table file: - diag_table_tmpl_fp = ${DIAG_TABLE_TMPL_FP} + diag_table_tmpl_fp = ${DIAG_TABLE_TMPL_FP} to create: - diag_table_fp = \"${diag_table_fp}\"" + diag_table_fp = \"${diag_table_fp}\"" - settings=" + settings=" starttime: !datetime ${ALL_CDATES[$i]} cres: ${CRES} " - $USHDIR/fill_jinja_template.py -q -u "${settings}" -t "${DIAG_TABLE_TMPL_FP}" -o "${diag_table_fp}" || \ - print_err_msg_exit " + $USHDIR/fill_jinja_template.py -q -u "${settings}" -t "${DIAG_TABLE_TMPL_FP}" -o "${diag_table_fp}" || \ + print_err_msg_exit " !!!!!!!!!!!!!!!!! fill_jinja_template.py failed! @@ -109,7 +109,6 @@ fill_jinja_template.py failed! !!!!!!!!!!!!!!!!! " - done # #----------------------------------------------------------------------- # diff --git a/ush/generate_FV3LAM_wflow.sh b/ush/generate_FV3LAM_wflow.sh index 650f2c8f7..e590ab78f 100755 --- a/ush/generate_FV3LAM_wflow.sh +++ b/ush/generate_FV3LAM_wflow.sh @@ -52,7 +52,6 @@ ushdir="${scrfunc_dir}" . $ushdir/source_util_funcs.sh . $ushdir/set_FV3nml_sfc_climo_filenames.sh . $ushdir/set_FV3nml_stoch_params.sh -. $ushdir/create_diag_table_files.sh # #----------------------------------------------------------------------- # @@ -321,21 +320,6 @@ fi # #----------------------------------------------------------------------- # -# Create the cycle directories. -# -#----------------------------------------------------------------------- -# -print_info_msg "$VERBOSE" " -Creating the cycle directories..." - -for (( i=0; i<${NUM_CYCLES}; i++ )); do - cdate="${ALL_CDATES[$i]}" - cycle_dir="${CYCLE_BASEDIR}/$cdate" - mkdir_vrfy -p "${cycle_dir}" -done -# -#----------------------------------------------------------------------- -# # Create a symlink in the experiment directory that points to the workflow # (re)launch script. # @@ -708,10 +692,6 @@ Call to function to set stochastic parameters in the FV3 namelist files for the various ensemble members failed." fi - create_diag_table_files || print_err_msg_exit "\ -Call to function to create a diagnostics table file under each cycle -directory failed." - fi # #----------------------------------------------------------------------- diff --git a/ush/setup.sh b/ush/setup.sh index 0f6f892b2..7cb069568 100755 --- a/ush/setup.sh +++ b/ush/setup.sh @@ -357,7 +357,7 @@ check_var_valid_value "MACHINE" "valid_vals_MACHINE" # #----------------------------------------------------------------------- # -NCORES_PER_NODE="" +NCORES_PER_NODE=${NCORES_PER_NODE:-""} case $MACHINE in "WCOSS_CRAY") @@ -466,8 +466,8 @@ case $MACHINE in ;; "LINUX") - WORKFLOW_MANAGER="none" - SCHED="none" + WORKFLOW_MANAGER=${WORKFLOW_MANAGER:-"none"} + SCHED=${SCHED:-"none"} ;; esac @@ -1014,6 +1014,92 @@ Please set this to a valid numerical value in the user-specified experiment configuration file (EXPT_CONFIG_FP) and rerun: EXPT_CONFIG_FP = \"${EXPT_CONFIG_FP}\"" fi + +# +#----------------------------------------------------------------------- +# +# If using the FV3_HRRR physics suite, make sure that the directory from +# which certain fixed orography files will be copied to the experiment +# directory actually exists. Note that this is temporary code. It should +# be removed once there is a script or code available that will create +# these orography files for any grid. +# +#----------------------------------------------------------------------- +# +GWD_HRRRsuite_DIR="" +if [ "${CCPP_PHYS_SUITE}" = "FV3_HRRR" ]; then +# +# If in NCO mode, make sure that GWD_HRRRsuite_BASEDIR is set equal to +# FIXLAM_NCO_BASEDIR +# + if [ "${RUN_ENVIR}" = "nco" ]; then + + if [ "${GWD_HRRRsuite_BASEDIR}" != "${FIXLAM_NCO_BASEDIR}" ]; then + + gwd_hrrrsuite_basedir_orig="${GWD_HRRRsuite_BASEDIR}" + GWD_HRRRsuite_BASEDIR="${FIXLAM_NCO_BASEDIR}" + + if [ ! -z "${gwd_hrrrsuite_basedir_orig}" ]; then + print_err_msg_exit " +When RUN_ENVIR is set to \"nco\", the workflow assumes that the base +directory (GWD_HRRRsuite_BASEDIR) under which the grid-specific +subdirectories containing the gravity wave drag-related orography +statistics files for the FV3_HRRR suite are located is the same as the +base directory (FIXLAM_NCO_BASEDIR) under which the other fixed files +are located. Currently, this is not the case: + GWD_HRRRsuite_BASEDIR = \"${gwd_hrrrsuite_basedir_orig}\" + FIXLAM_NCO_BASEDIR = \"${FIXLAM_NCO_BASEDIR}\" +Resetting GWD_HRRRsuite_BASEDIR to FIXLAM_NCO_BASEDIR. Reset value is: + GWD_HRRRsuite_BASEDIR = \"${GWD_HRRRsuite_BASEDIR}\"" + fi + + fi + + fi +# +# Check that GWD_HRRRsuite_BASEDIR exists and is a directory. +# + if [ ! -d "${GWD_HRRRsuite_BASEDIR}" ]; then + print_err_msg_exit "\ +The base directory (GWD_HRRRsuite_BASEDIR) under which the grid-specific +subdirectories containing the gravity wave drag-related orography files +for the FV3_HRRR suite should be located does not exist (or is not a +directory): + GWD_HRRRsuite_BASEDIR = \"${GWD_HRRRsuite_BASEDIR}\"" + fi + GWD_HRRRsuite_DIR="${GWD_HRRRsuite_BASEDIR}/${PREDEF_GRID_NAME}" +# +# Ensure that PREDEF_GRID_NAME is not set to a null string. Currently, +# only predefined grids can be used with the FV3_HRRR suite because +# orography statistics files required by this suite are available only +# for (some of) the predefined grids. +# + if [ -z "${PREDEF_GRID_NAME}" ]; then + print_err_msg_exit "\ +A predefined grid name (PREDEF_GRID_NAME) must be specified when using +the FV3_HRRR physics suite: + CCPP_PHYS_SUITE = \"${CCPP_PHYS_SUITE}\" + PREDEF_GRID_NAME = \"${PREDEF_GRID_NAME}\"" + else +# +# Ensure that the directory GWD_HRRRsuite_DIR in which the orography +# statistics files required by the FV3_HRRR suite are located actually +# exists. +# + if [ ! -d "${GWD_HRRRsuite_DIR}" ]; then + print_err_msg_exit "\ +The directory (GWD_HRRRsuite_DIR) that should contain the gravity wave +drag-related orography files for the FV3_HRRR suite does not exist: + GWD_HRRRsuite_DIR = \"${GWD_HRRRsuite_DIR}\"" + elif [ ! "$( ls -A ${GWD_HRRRsuite_DIR} )" ]; then + print_err_msg_exit "\ +The directory (GWD_HRRRsuite_DIR) that should contain the gravity wave +drag related orography files for the FV3_HRRR suite is empty: + GWD_HRRRsuite_DIR = \"${GWD_HRRRsuite_DIR}\"" + fi + fi + +fi # #----------------------------------------------------------------------- # @@ -1106,55 +1192,10 @@ check_for_preexist_dir_file "$EXPTDIR" "${PREEXISTING_DIR_METHOD}" # LOGDIR="${EXPTDIR}/log" +FIXam="${EXPTDIR}/fix_am" +FIXLAM="${EXPTDIR}/fix_lam" if [ "${RUN_ENVIR}" = "nco" ]; then - FIXam="${FIXrrfs}/fix_am" -# -# In NCO mode (i.e. if RUN_ENVIR set to "nco"), it is assumed that before -# running the experiment generation script, the path specified in FIXam -# already exists and is either itself the directory in which various fixed -# files (but not the ones containing the regional grid and the orography -# and surface climatology on that grid) are located, or it is a symlink -# to such a directory. Resolve any symlinks in the path specified by -# FIXam and check that this is the case. -# - path_resolved=$( $READLINK -m "$FIXam" ) - if [ ! -d "${path_resolved}" ]; then - print_err_msg_exit "\ -In order to be able to generate a forecast experiment in NCO mode (i.e. -when RUN_ENVIR set to \"nco\"), the path specified by FIXam after resolving -all symlinks (path_resolved) must be an existing directory (but in this -case isn't): - RUN_ENVIR = \"${RUN_ENVIR}\" - FIXam = \"$FIXam\" - path_resolved = \"${path_resolved}\" -Please ensure that path_resolved is an existing directory and then rerun -the experiment generation script." - fi - - FIXLAM="${FIXrrfs}/fix_lam/${PREDEF_GRID_NAME}" -# -# In NCO mode (i.e. if RUN_ENVIR set to "nco"), it is assumed that before -# running the experiment generation script, the path specified in FIXLAM -# already exists and is either itself the directory in which the fixed -# grid, orography, and surface climatology files are located, or it is a -# symlink to such a directory. Resolve any symlinks in the path specified -# by FIXLAM and check that this is the case. -# - path_resolved=$( $READLINK -m "$FIXLAM" ) - if [ ! -d "${path_resolved}" ]; then - print_err_msg_exit "\ -In order to be able to generate a forecast experiment in NCO mode (i.e. -when RUN_ENVIR set to \"nco\"), the path specified by FIXLAM after resolving -all symlinks (path_resolved) must be an existing directory (but in this -case isn't): - RUN_ENVIR = \"${RUN_ENVIR}\" - FIXLAM = \"$FIXLAM\" - path_resolved = \"${path_resolved}\" -Please ensure that path_resolved is an existing directory and then rerun -the experiment generation script." - fi - CYCLE_BASEDIR="$STMP/tmpnwprd/$RUN" check_for_preexist_dir_file "${CYCLE_BASEDIR}" "${PREEXISTING_DIR_METHOD}" COMROOT="$PTMP/com" @@ -1832,35 +1873,9 @@ mkdir_vrfy -p "$EXPTDIR" # #----------------------------------------------------------------------- # -if [ "${RUN_ENVIR}" = "nco" ]; then - suffix="${DOT_OR_USCORE}mosaic.halo${NH3}.nc" - glob_pattern="C*$suffix" - cd_vrfy $FIXLAM - num_files=$( ls -1 ${glob_pattern} 2>/dev/null | wc -l ) - - if [ "${num_files}" -ne "1" ]; then - print_err_msg_exit "\ -Exactly one file must exist in directory FIXLAM matching the globbing -pattern glob_pattern: - FIXLAM = \"${FIXLAM}\" - glob_pattern = \"${glob_pattern}\" - num_files = ${num_files}" - fi - - fn=$( ls -1 ${glob_pattern} ) - RES_IN_FIXLAM_FILENAMES=$( \ - printf "%s" $fn | $SED -n -r -e "s/^C([0-9]*)$suffix/\1/p" ) - if [ "${GRID_GEN_METHOD}" = "GFDLgrid" ] && \ - [ "${GFDLgrid_RES}" -ne "${RES_IN_FIXLAM_FILENAMES}" ]; then - print_err_msg_exit "\ -The resolution extracted from the fixed file names (RES_IN_FIXLAM_FILENAMES) -does not match the resolution specified by GFDLgrid_RES: - GFDLgrid_RES = ${GFDLgrid_RES} - RES_IN_FIXLAM_FILENAMES = ${RES_IN_FIXLAM_FILENAMES}" - fi - -else +mkdir_vrfy -p "$FIXLAM" +RES_IN_FIXLAM_FILENAMES="" # #----------------------------------------------------------------------- # @@ -2064,22 +2079,23 @@ fi # NNODES_RUN_FCST=$(( (PE_MEMBER01 + PPN_RUN_FCST - 1)/PPN_RUN_FCST )) - - # #----------------------------------------------------------------------- # -# Create a new experiment directory. Note that at this point we are -# guaranteed that there is no preexisting experiment directory. For -# platforms with no workflow manager, we need to create LOGDIR as well, -# since it won't be created later at runtime. +# Set the name of the file containing aerosol climatology data that, if +# necessary, can be used to generate approximate versions of the aerosol +# fields needed by Thompson microphysics. This file will be used to +# generate such approximate aerosol fields in the ICs and LBCs if +# Thompson +# MP is included in the physics suite and if the exteranl model for ICs +# or LBCs does not already provide these fields. Also, set the full +# path +# to this file. # #----------------------------------------------------------------------- # -mkdir_vrfy -p "$EXPTDIR" -mkdir_vrfy -p "$LOGDIR" - - +THOMPSON_MP_CLIMO_FN="Thompson_MP_MONTHLY_CLIMO.nc" +THOMPSON_MP_CLIMO_FP="$FIXam/${THOMPSON_MP_CLIMO_FN}" # #----------------------------------------------------------------------- # diff --git a/ush/templates/FV3LAM_wflow.xml b/ush/templates/FV3LAM_wflow.xml index 2f20b7faf..e4292773a 100644 --- a/ush/templates/FV3LAM_wflow.xml +++ b/ush/templates/FV3LAM_wflow.xml @@ -373,7 +373,7 @@ MODULES_RUN_TASK_FP script. &RSRV_FCST; &LOAD_MODULES_RUN_TASK_FP; "&RUN_FCST_TN;" "&JOBSDIR;/JREGIONAL_RUN_FCST" - {% if machine in ["JET", "HERA"] %} + {% if machine in ["JET", "HERA", "LINUX"] %} {{ ncores_run_fcst }} {{ native_run_fcst }} {% else %} From bc2777844ef26d17665622eb9576f695749654b6 Mon Sep 17 00:00:00 2001 From: "Christina.Holt" Date: Wed, 10 Feb 2021 16:56:44 +0000 Subject: [PATCH 04/10] Adding reference configs for Hera --- ush/config.sh.aws_cloud | 58 +++++++++++++++++++++++++++++++++++++++++ ush/config.sh.hera | 42 +++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 ush/config.sh.aws_cloud create mode 100644 ush/config.sh.hera diff --git a/ush/config.sh.aws_cloud b/ush/config.sh.aws_cloud new file mode 100644 index 000000000..480e19693 --- /dev/null +++ b/ush/config.sh.aws_cloud @@ -0,0 +1,58 @@ +ACCOUNT=zrtrr + +MACHINE=LINUX +WORKFLOW_MANAGER=rocoto +SCHED=slurm + +NCORES_PER_NODE=40 +PARTITION_DEFAULT="hera" +QUEUE_DEFAULT=batch +PARTITION_HPSS=service +QUEUE_HPSS=batch +PARTITION_FCST=hera +QUEUE_FCST=batch + +EXPT_BASEDIR=/scratch2/BMC/wrfruc/cholt +EXPT_SUBDIR=rrfs_cloud + +# Copied directly from setup.sh HERA settings +FIXgsm=${FIXgsm:-"/scratch1/NCEPDEV/global/glopara/fix/fix_am"} +TOPO_DIR=${TOPO_DIR:-"/scratch1/NCEPDEV/global/glopara/fix/fix_orog"} +SFC_CLIMO_INPUT_DIR=${SFC_CLIMO_INPUT_DIR:-"/scratch1/NCEPDEV/global/glopara/fix/fix_sfc_climo"} +FIXLAM_NCO_BASEDIR=${FIXLAM_NCO_BASEDIR:-"/scratch2/BMC/det/FV3LAM_pregen"} + + +VERBOSE="TRUE" + +RUN_ENVIR="nco" +PREEXISTING_DIR_METHOD="rename" + +PREDEF_GRID_NAME=RRFS_CONUS_3km + +QUILTING="TRUE" +CCPP_PHYS_SUITE="FV3_GSD_SAR" +FCST_LEN_HRS="12" +LBC_SPEC_INTVL_HRS="6" + +HALO_BLEND=10 + +WTIME_RUN_FCST="06:45:00" + +DATE_FIRST_CYCL="20210128" +DATE_LAST_CYCL="20220130" +CYCL_HRS=( "00" "06" "12" "18" ) + + +EXTRN_MDL_NAME_ICS="HRRR" +EXTRN_MDL_NAME_LBCS="RAP" + +envir="para" + +NET="RRFS_CONUS" + +STMP="/lfs4/BMC/nrtrr/NCO_dirs/stmp" +PTMP="/lfs4/BMC/nrtrr/NCO_dirs/ptmp" + + +STMP="/scratch2/BMC/wrfruc/cholt/NCO_dirs/rrfs_cloud/stmp" +PTMP="/scratch2/BMC/wrfruc/cholt/NCO_dirs/rrfs_cloud/ptmp" diff --git a/ush/config.sh.hera b/ush/config.sh.hera new file mode 100644 index 000000000..43f1f1f0e --- /dev/null +++ b/ush/config.sh.hera @@ -0,0 +1,42 @@ +ACCOUNT=zrtrr + +MACHINE=HERA +SCHED=slurm + +EXPT_BASEDIR=/scratch2/BMC/wrfruc/cholt +EXPT_SUBDIR=rrfs_cloud_hera + +VERBOSE="TRUE" + +RUN_ENVIR="nco" +PREEXISTING_DIR_METHOD="rename" + +PREDEF_GRID_NAME=RRFS_CONUS_3km + +QUILTING="TRUE" +CCPP_PHYS_SUITE="FV3_GSD_SAR" +FCST_LEN_HRS="12" +LBC_SPEC_INTVL_HRS="6" + +HALO_BLEND=10 + +WTIME_RUN_FCST="06:45:00" + +DATE_FIRST_CYCL="20210128" +DATE_LAST_CYCL="20220130" +CYCL_HRS=( "00" "06" "12" "18" ) + + +EXTRN_MDL_NAME_ICS="HRRR" +EXTRN_MDL_NAME_LBCS="RAP" + +envir="para" + +NET="RRFS_CONUS" + +STMP="/lfs4/BMC/nrtrr/NCO_dirs/stmp" +PTMP="/lfs4/BMC/nrtrr/NCO_dirs/ptmp" + + +STMP="/scratch2/BMC/wrfruc/cholt/NCO_dirs/rrfs_cloud/stmp" +PTMP="/scratch2/BMC/wrfruc/cholt/NCO_dirs/rrfs_cloud/ptmp" From 1a1e13a176c36550b7d1e430c4107026a7cc3966 Mon Sep 17 00:00:00 2001 From: "Christina.Holt" Date: Thu, 11 Feb 2021 16:16:24 +0000 Subject: [PATCH 05/10] Updating configs to work on Hera. --- ush/config.sh.aws_cloud | 27 ++++++++++++++++++++++----- ush/config.sh.hera | 17 ++++++++++------- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/ush/config.sh.aws_cloud b/ush/config.sh.aws_cloud index 480e19693..13b7fd50a 100644 --- a/ush/config.sh.aws_cloud +++ b/ush/config.sh.aws_cloud @@ -4,6 +4,9 @@ MACHINE=LINUX WORKFLOW_MANAGER=rocoto SCHED=slurm +LMOD_PATH=/apps/lmod/lmod/init/sh +BUILD_ENV_FN=build_hera_intel.env + NCORES_PER_NODE=40 PARTITION_DEFAULT="hera" QUEUE_DEFAULT=batch @@ -15,6 +18,8 @@ QUEUE_FCST=batch EXPT_BASEDIR=/scratch2/BMC/wrfruc/cholt EXPT_SUBDIR=rrfs_cloud +RUN=RRFS_CONUS + # Copied directly from setup.sh HERA settings FIXgsm=${FIXgsm:-"/scratch1/NCEPDEV/global/glopara/fix/fix_am"} TOPO_DIR=${TOPO_DIR:-"/scratch1/NCEPDEV/global/glopara/fix/fix_orog"} @@ -22,6 +27,18 @@ SFC_CLIMO_INPUT_DIR=${SFC_CLIMO_INPUT_DIR:-"/scratch1/NCEPDEV/global/glopara/fix FIXLAM_NCO_BASEDIR=${FIXLAM_NCO_BASEDIR:-"/scratch2/BMC/det/FV3LAM_pregen"} +# Get external model files +USE_USER_STAGED_EXTRN_FILES=TRUE +EXTRN_MDL_SOURCE_BASEDIR_ICS="/scratch2/BMC/wrfruc/cholt/data/gfs" +EXTRN_MDL_FILES_ICS=( "gfs.t00z.pgrb2.0p25.f000") +EXTRN_MDL_SOURCE_BASEDIR_LBCS="/scratch2/BMC/wrfruc/cholt/data/gfs" +EXTRN_MDL_FILES_LBCS=( \ + "gfs.t00z.pgrb2.0p25.f006" + "gfs.t00z.pgrb2.0p25.f012" +) +FV3GFS_FILE_FMT_ICS=grib2 + + VERBOSE="TRUE" RUN_ENVIR="nco" @@ -38,13 +55,13 @@ HALO_BLEND=10 WTIME_RUN_FCST="06:45:00" -DATE_FIRST_CYCL="20210128" -DATE_LAST_CYCL="20220130" -CYCL_HRS=( "00" "06" "12" "18" ) +DATE_FIRST_CYCL="20210210" +DATE_LAST_CYCL="20210210" +CYCL_HRS=( "00" ) -EXTRN_MDL_NAME_ICS="HRRR" -EXTRN_MDL_NAME_LBCS="RAP" +EXTRN_MDL_NAME_ICS="FV3GFS" +EXTRN_MDL_NAME_LBCS="FV3GFS" envir="para" diff --git a/ush/config.sh.hera b/ush/config.sh.hera index 43f1f1f0e..e5ecf5427 100644 --- a/ush/config.sh.hera +++ b/ush/config.sh.hera @@ -11,6 +11,8 @@ VERBOSE="TRUE" RUN_ENVIR="nco" PREEXISTING_DIR_METHOD="rename" +RUN="RRFS_CONUS" + PREDEF_GRID_NAME=RRFS_CONUS_3km QUILTING="TRUE" @@ -22,13 +24,14 @@ HALO_BLEND=10 WTIME_RUN_FCST="06:45:00" -DATE_FIRST_CYCL="20210128" -DATE_LAST_CYCL="20220130" -CYCL_HRS=( "00" "06" "12" "18" ) +DATE_FIRST_CYCL="20210210" +DATE_LAST_CYCL="20210210" +CYCL_HRS=( "00" ) -EXTRN_MDL_NAME_ICS="HRRR" -EXTRN_MDL_NAME_LBCS="RAP" +EXTRN_MDL_NAME_ICS="FV3GFS" +EXTRN_MDL_NAME_LBCS="FV3GFS" +FV3GFS_FILE_FMT_ICS=grib2 envir="para" @@ -38,5 +41,5 @@ STMP="/lfs4/BMC/nrtrr/NCO_dirs/stmp" PTMP="/lfs4/BMC/nrtrr/NCO_dirs/ptmp" -STMP="/scratch2/BMC/wrfruc/cholt/NCO_dirs/rrfs_cloud/stmp" -PTMP="/scratch2/BMC/wrfruc/cholt/NCO_dirs/rrfs_cloud/ptmp" +STMP="/scratch2/BMC/wrfruc/cholt/NCO_dirs/rrfs_cloud_hera/stmp" +PTMP="/scratch2/BMC/wrfruc/cholt/NCO_dirs/rrfs_cloud_hera/ptmp" From 3cd743517e1296dbebe58e8d6ec860788389944f Mon Sep 17 00:00:00 2001 From: "Christina.Holt" Date: Thu, 11 Feb 2021 16:18:09 +0000 Subject: [PATCH 06/10] Add configurable options needed for linux. --- ush/config_defaults.sh | 10 ++++++++++ ush/load_modules_run_task.sh | 9 +++++++-- ush/setup.sh | 3 --- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/ush/config_defaults.sh b/ush/config_defaults.sh index b8059db4a..ab29435aa 100644 --- a/ush/config_defaults.sh +++ b/ush/config_defaults.sh @@ -56,6 +56,14 @@ RUN_ENVIR="nco" # for supported platforms in setup.sh, but is now also configurable for # generic platforms. # +# LMOD_PATH: +# Path to the LMOD sh file on your Linux system. Is set automatically +# for supported machines. +# +# BUILD_ENV_FN: +# Name of alternative environment file to use if using Linux system. Is +# set automativally for supported machines. +# # SCHED: # The job scheduler to use (e.g. slurm). Set this to an empty string in # order for the experiment generation script to set it depending on the @@ -115,6 +123,8 @@ MACHINE="BIG_COMPUTER" ACCOUNT="project_name" WORKFLOW_MANAGER="none" NCORES_PER_NODE="" +LMOD_PATH="" +BUILD_ENV_FN="" SCHED="" PARTITION_DEFAULT="" QUEUE_DEFAULT="" diff --git a/ush/load_modules_run_task.sh b/ush/load_modules_run_task.sh index 3a30fa4bf..d36bc5445 100755 --- a/ush/load_modules_run_task.sh +++ b/ush/load_modules_run_task.sh @@ -128,10 +128,15 @@ case "$MACHINE" in ;; # *) - print_err_msg_exit "\ + + if [[ -n ${LMOD_PATH:-""} && -f ${LMOD_PATH:-""} ]] ; then + . ${LMOD_PATH} + else + print_err_msg_exit "\ The script to source to initialize lmod (module loads) has not yet been specified for the current machine (MACHINE): MACHINE = \"$MACHINE\"" + fi ;; # esac @@ -153,7 +158,7 @@ jjob_fp="$2" #----------------------------------------------------------------------- # machine=$(echo_lowercase $MACHINE) -env_fn="build_${machine}_${COMPILER}.env" +env_fn=${BUILD_ENV_FN:-"build_${machine}_${COMPILER}.env"} env_fp="${SR_WX_APP_TOP_DIR}/env/${env_fn}" source "${env_fp}" || print_err_msg_exit "\ Sourcing platform- and compiler-specific environment file (env_fp) for the diff --git a/ush/setup.sh b/ush/setup.sh index 7cb069568..730928ef1 100755 --- a/ush/setup.sh +++ b/ush/setup.sh @@ -495,9 +495,6 @@ The variable ACCOUNT cannot be empty if you are using a workflow manager: ACCOUNT = \"$ACCOUNT\" WORKFLOW_MANAGER = \"$WORKFLOW_MANAGER\"" fi - RUN_CMD_UTILS="" - RUN_CMD_FCST="" - RUN_CMD_POST="" fi # #----------------------------------------------------------------------- From 925c608721386744857ac2a5028625949f3ba93b Mon Sep 17 00:00:00 2001 From: "Christina.Holt" Date: Thu, 11 Feb 2021 16:18:33 +0000 Subject: [PATCH 07/10] Add modulefiles needed for linux. --- modulefiles/tasks/linux/make_grid.local | 6 ++++++ modulefiles/tasks/linux/make_ics.local | 6 ++++++ modulefiles/tasks/linux/make_lbcs.local | 6 ++++++ modulefiles/tasks/linux/run_fcst.local | 6 ++++++ 4 files changed, 24 insertions(+) create mode 100644 modulefiles/tasks/linux/make_grid.local create mode 100644 modulefiles/tasks/linux/make_ics.local create mode 100644 modulefiles/tasks/linux/make_lbcs.local create mode 100644 modulefiles/tasks/linux/run_fcst.local diff --git a/modulefiles/tasks/linux/make_grid.local b/modulefiles/tasks/linux/make_grid.local new file mode 100644 index 000000000..52955b476 --- /dev/null +++ b/modulefiles/tasks/linux/make_grid.local @@ -0,0 +1,6 @@ +#%Module +module use -a /contrib/miniconda3/modulefiles +module load miniconda3 +if [module-info mode load] { + system "conda activate regional_workflow" +} diff --git a/modulefiles/tasks/linux/make_ics.local b/modulefiles/tasks/linux/make_ics.local new file mode 100644 index 000000000..52955b476 --- /dev/null +++ b/modulefiles/tasks/linux/make_ics.local @@ -0,0 +1,6 @@ +#%Module +module use -a /contrib/miniconda3/modulefiles +module load miniconda3 +if [module-info mode load] { + system "conda activate regional_workflow" +} diff --git a/modulefiles/tasks/linux/make_lbcs.local b/modulefiles/tasks/linux/make_lbcs.local new file mode 100644 index 000000000..52955b476 --- /dev/null +++ b/modulefiles/tasks/linux/make_lbcs.local @@ -0,0 +1,6 @@ +#%Module +module use -a /contrib/miniconda3/modulefiles +module load miniconda3 +if [module-info mode load] { + system "conda activate regional_workflow" +} diff --git a/modulefiles/tasks/linux/run_fcst.local b/modulefiles/tasks/linux/run_fcst.local new file mode 100644 index 000000000..52955b476 --- /dev/null +++ b/modulefiles/tasks/linux/run_fcst.local @@ -0,0 +1,6 @@ +#%Module +module use -a /contrib/miniconda3/modulefiles +module load miniconda3 +if [module-info mode load] { + system "conda activate regional_workflow" +} From edd6087f82bc4a6fa0ec0a12712c245e83372b1c Mon Sep 17 00:00:00 2001 From: Michael Kavulich Date: Wed, 10 Feb 2021 21:23:11 -0700 Subject: [PATCH 08/10] Remove the first instance of "RUN_CMD_FCST" in var_defns.sh to avoid potential undefined variable issues (#433) ## DESCRIPTION OF CHANGES: It was found that if set -u is in the user's default bash environment, this will cause the launch script or individual run scripts to fail because you're using a variable before it's defined; this is likely to occur if you submit any of these scripts from a crontab. This was due to the way that the default run command was set up for MacOS and generic LINUX platforms, which was a bit of a hack that resulted in RUN_CMD_FCST being defined twice in var_defns.sh. The fix will delete the first instance of RUN_CMD_FCST in var_defns.sh so that it is no longer referencing an undefined variable early on. This potential bug does not affect Tier 1 supported platforms, only MacOS and generic Linux. ## TESTS CONDUCTED: Tested on affected MacOS platform and the fix worked. Also ran end-to-end tests on Hera and Cheyenne (still running) as a sanity check. --- ush/setup.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ush/setup.sh b/ush/setup.sh index 730928ef1..f9604ab78 100755 --- a/ush/setup.sh +++ b/ush/setup.sh @@ -2595,6 +2595,15 @@ fi # #----------------------------------------------------------------------- # +# Because RUN_CMD_FCST can include PE_MEMBER01 (and theoretically other +# variables calculated in this script), delete the first occurance of it +# in the var_defns file, and write it again at the end. +# +#----------------------------------------------------------------------- +$SED -i '/^RUN_CMD_FCST=/d' $GLOBAL_VAR_DEFNS_FP +# +#----------------------------------------------------------------------- +# # Continue appending variable defintions to the variable definitions # file. # From 654e882fa39b384e6c77fa1134bfed162de8f1f9 Mon Sep 17 00:00:00 2001 From: "Christina.Holt" Date: Tue, 16 Feb 2021 21:17:58 +0000 Subject: [PATCH 09/10] Other mods for running on Hera. --- ush/config.sh.aws_cloud | 6 +++++- ush/config.sh.hera | 12 +++++++++++- ...diag_table_files.sh => create_diag_table_file.sh} | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) rename ush/{create_diag_table_files.sh => create_diag_table_file.sh} (98%) diff --git a/ush/config.sh.aws_cloud b/ush/config.sh.aws_cloud index 13b7fd50a..74f65d84a 100644 --- a/ush/config.sh.aws_cloud +++ b/ush/config.sh.aws_cloud @@ -7,6 +7,10 @@ SCHED=slurm LMOD_PATH=/apps/lmod/lmod/init/sh BUILD_ENV_FN=build_hera_intel.env +RUN_CMD_UTILS="srun" +RUN_CMD_FCST="srun" +RUN_CMD_POST="srun" + NCORES_PER_NODE=40 PARTITION_DEFAULT="hera" QUEUE_DEFAULT=batch @@ -37,7 +41,7 @@ EXTRN_MDL_FILES_LBCS=( \ "gfs.t00z.pgrb2.0p25.f012" ) FV3GFS_FILE_FMT_ICS=grib2 - +FV3GFS_FILE_FMT_LBCS=grib2 VERBOSE="TRUE" diff --git a/ush/config.sh.hera b/ush/config.sh.hera index e5ecf5427..73ecab20d 100644 --- a/ush/config.sh.hera +++ b/ush/config.sh.hera @@ -11,6 +11,15 @@ VERBOSE="TRUE" RUN_ENVIR="nco" PREEXISTING_DIR_METHOD="rename" +# Get external model files +USE_USER_STAGED_EXTRN_FILES=TRUE +EXTRN_MDL_SOURCE_BASEDIR_ICS="/scratch2/BMC/wrfruc/cholt/data/gfs" +EXTRN_MDL_FILES_ICS=( "gfs.t12z.pgrb2.0p25.f000" ) +EXTRN_MDL_SOURCE_BASEDIR_LBCS="/scratch2/BMC/wrfruc/cholt/data/gfs" +EXTRN_MDL_FILES_LBCS=( \ + "gfs.t12z.pgrb2.0p25.f006" \ + "gfs.t12z.pgrb2.0p25.f012" \ +) RUN="RRFS_CONUS" PREDEF_GRID_NAME=RRFS_CONUS_3km @@ -26,12 +35,13 @@ WTIME_RUN_FCST="06:45:00" DATE_FIRST_CYCL="20210210" DATE_LAST_CYCL="20210210" -CYCL_HRS=( "00" ) +CYCL_HRS=( "12" ) EXTRN_MDL_NAME_ICS="FV3GFS" EXTRN_MDL_NAME_LBCS="FV3GFS" FV3GFS_FILE_FMT_ICS=grib2 +FV3GFS_FILE_FMT_LBCS=grib2 envir="para" diff --git a/ush/create_diag_table_files.sh b/ush/create_diag_table_file.sh similarity index 98% rename from ush/create_diag_table_files.sh rename to ush/create_diag_table_file.sh index 26c990702..1b8ac34c7 100644 --- a/ush/create_diag_table_files.sh +++ b/ush/create_diag_table_file.sh @@ -96,7 +96,7 @@ to create: diag_table_fp = \"${diag_table_fp}\"" settings=" - starttime: !datetime ${ALL_CDATES[$i]} + starttime: !datetime ${CDATE} cres: ${CRES} " From 73e632938a17f2c2aa826b6ade42204fd9b13c46 Mon Sep 17 00:00:00 2001 From: "Christina.Holt" Date: Wed, 17 Feb 2021 00:07:08 +0000 Subject: [PATCH 10/10] Fix needed for create_diag_table_file change. --- scripts/exregional_make_grid.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/scripts/exregional_make_grid.sh b/scripts/exregional_make_grid.sh index 1d06aa2ed..5bc0e9434 100755 --- a/scripts/exregional_make_grid.sh +++ b/scripts/exregional_make_grid.sh @@ -20,7 +20,7 @@ . $USHDIR/link_fix.sh . $USHDIR/set_FV3nml_sfc_climo_filenames.sh . $USHDIR/set_FV3nml_stoch_params.sh -. $USHDIR/create_diag_table_files.sh +. $USHDIR/create_diag_table_file.sh # #----------------------------------------------------------------------- # @@ -699,9 +699,6 @@ Call to function to set stochastic parameters in the FV3 namelist files for the various ensemble members failed." fi -create_diag_table_files || print_err_msg_exit "\ -Call to function to create a diagnostics table file under each cycle -directory failed." # #----------------------------------------------------------------------- #