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 0ff122bad..b4d549012 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 895ab9395..70b7616ed 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}" ) # @@ -152,6 +152,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: @@ -438,11 +446,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 fe54d62bf..ffe63d404 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}" ) # @@ -120,6 +120,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 8e1bcd577..a9380b18a 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}" ) # @@ -120,6 +120,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 # #----------------------------------------------------------------------- @@ -480,7 +495,7 @@ list file has not specified for this external model: 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 9524fcad1..9ef278add 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}" ) # @@ -152,6 +152,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 baa42c86c..115d1739a 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}" ) # @@ -174,6 +174,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 2f3004130..065b42494 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}" ) # @@ -148,6 +148,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: @@ -364,9 +372,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 e3f22a0ff..808cd8093 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}" ) # @@ -139,6 +139,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: @@ -211,7 +219,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} @@ -282,8 +290,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 e396ec559..a85d780fb 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:+/} @@ -679,7 +684,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"} @@ -729,7 +734,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}" @@ -759,7 +764,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 7aefa8f88..daf22738f 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 @@ -128,6 +133,7 @@ RUN_ENVIR="nco" # MACHINE="BIG_COMPUTER" ACCOUNT="project_name" +WORKFLOW_MANAGER="none" SCHED="" PARTITION_DEFAULT="" CLUSTERS_DEFAULT="" @@ -141,6 +147,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 063a9ef34..a9bdf38df 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}" ) # @@ -299,12 +303,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: @@ -315,6 +320,7 @@ are: Namelist settings specified on command line: settings = $settings" +fi # #----------------------------------------------------------------------- # @@ -357,7 +363,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: @@ -370,7 +376,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 @@ -589,9 +595,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 @@ -707,9 +713,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 " ======================================================================== @@ -725,37 +733,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: @@ -785,6 +780,7 @@ edit the cron table): Done. " +fi # # If necessary, run the NOMADS script to source external model data. # @@ -828,7 +824,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}" ) # @@ -881,27 +882,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 69a3f69b5..ae734f00c 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 # @@ -595,11 +596,13 @@ bination of external model (extrn_mdl_name) and analysis or forecast sysdir="" ;; *) - 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 ;; @@ -635,11 +638,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 ;; @@ -675,11 +680,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 ;; @@ -715,11 +722,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 ;; @@ -754,22 +763,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 24e9088a4..ebf1336df 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 # #----------------------------------------------------------------------- # @@ -301,8 +311,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}" @@ -397,7 +407,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 05bb99238..05b7d248f 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}" ) # @@ -156,7 +156,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 "\ @@ -228,11 +228,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 9554d6a32..67968cc94 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" ;; @@ -94,9 +81,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" ;; @@ -120,9 +104,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" ;; @@ -140,9 +121,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" ;; @@ -159,17 +137,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 # #----------------------------------------------------------------------- @@ -215,25 +200,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" ;; @@ -257,9 +229,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" ;; @@ -283,15 +252,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 ;; @@ -300,9 +263,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" ;; @@ -313,17 +273,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 7b87c8fc1..19ad295fc 100644 --- a/ush/set_thompson_mp_fix_files.sh +++ b/ush/set_thompson_mp_fix_files.sh @@ -30,7 +30,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}" ) # @@ -89,7 +89,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_is_used="TRUE" diff --git a/ush/setup.sh b/ush/setup.sh index c5c146527..fc9d3c20c 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" @@ -200,7 +201,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" @@ -242,7 +243,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" @@ -262,7 +263,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" @@ -282,7 +283,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" @@ -323,7 +324,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" @@ -347,7 +348,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" # #----------------------------------------------------------------------- @@ -358,10 +359,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"} @@ -369,6 +372,7 @@ case $MACHINE in ;; "WCOSS_DELL_P3") + WORKFLOW_MANAGER="rocoto" NCORES_PER_NODE=24 SCHED="lsf" QUEUE_DEFAULT=${QUEUE_DEFAULT:-"dev"} @@ -377,6 +381,7 @@ case $MACHINE in ;; "HERA") + WORKFLOW_MANAGER="rocoto" NCORES_PER_NODE=40 SCHED="${SCHED:-slurm}" PARTITION_DEFAULT=${PARTITION_DEFAULT:-"hera"} @@ -388,6 +393,7 @@ case $MACHINE in ;; "ORION") + WORKFLOW_MANAGER="rocoto" NCORES_PER_NODE=40 SCHED="${SCHED:-slurm}" PARTITION_DEFAULT=${PARTITION_DEFAULT:-"orion"} @@ -399,6 +405,7 @@ case $MACHINE in ;; "JET") + WORKFLOW_MANAGER="rocoto" NCORES_PER_NODE=24 SCHED="${SCHED:-slurm}" PARTITION_DEFAULT=${PARTITION_DEFAULT:-"sjet,vjet,kjet,xjet"} @@ -410,6 +417,7 @@ case $MACHINE in ;; "ODIN") + WORKFLOW_MANAGER="rocoto" NCORES_PER_NODE=24 SCHED="${SCHED:-slurm}" PARTITION_DEFAULT=${PARTITION_DEFAULT:-"workq"} @@ -421,6 +429,7 @@ case $MACHINE in ;; "CHEYENNE") + WORKFLOW_MANAGER="rocoto" NCORES_PER_NODE=36 SCHED="${SCHED:-pbspro}" QUEUE_DEFAULT=${QUEUE_DEFAULT:-"regular"} @@ -429,6 +438,7 @@ case $MACHINE in ;; "STAMPEDE") + WORKFLOW_MANAGER="rocoto" NCORES_PER_NODE=68 SCHED="slurm" PARTITION_DEFAULT=${PARTITION_DEFAULT:-"normal"} @@ -450,6 +460,16 @@ case $MACHINE in CLUSTERS_FCST=${CLUSTERS_FCST:-"c4"} QUEUE_FCST=${QUEUE_FCST:-"normal"} ;; + + "MACOS") + WORKFLOW_MANAGER="none" + SCHED="none" + ;; + + "LINUX") + WORKFLOW_MANAGER="none" + SCHED="none" + ;; esac # @@ -459,20 +479,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 # #----------------------------------------------------------------------- @@ -541,7 +567,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 @@ -551,7 +577,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 @@ -573,7 +599,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 "\ @@ -732,13 +758,15 @@ 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:-\"\"} TOPO_DIR = \"${TOPO_DIR:-\"\"} SFC_CLIMO_INPUT_DIR = \"${SFC_CLIMO_INPUT_DIR:-\"\"} You can specify the missing location(s) in config.sh" + fi ;; esac @@ -755,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. @@ -827,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" @@ -991,7 +1019,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}" # #----------------------------------------------------------------------- @@ -1076,7 +1104,7 @@ if [ "${RUN_ENVIR}" = "nco" ]; then # 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" ) + 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. @@ -1099,7 +1127,7 @@ the experiment generation script." # 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" ) + 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. @@ -1275,7 +1303,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 @@ -1322,7 +1350,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" @@ -1788,7 +1816,7 @@ pattern glob_pattern: fn=$( ls -1 ${glob_pattern} ) RES_IN_FIXLAM_FILENAMES=$( \ - printf "%s" $fn | sed -n -r -e "s/^C([0-9]*)$suffix/\1/p" ) + 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 "\ @@ -1918,7 +1946,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" @@ -1938,7 +1966,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" @@ -2008,15 +2036,14 @@ 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. +# 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. # #----------------------------------------------------------------------- # mkdir_vrfy -p "$EXPTDIR" - - - - +mkdir_vrfy -p "$LOGDIR" @@ -2078,7 +2105,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 "\". @@ -2119,7 +2146,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" \ @@ -2165,7 +2192,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} @@ -2185,7 +2212,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}\"" @@ -2390,7 +2417,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}" @@ -2601,6 +2628,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 d837796a9..ec9f4178e 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" "GAEA") +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" \