diff --git a/.github/workflows/bash_code_analysis.yaml b/.github/workflows/bash_code_analysis.yaml index 27be4c76b6c..ca6160175a7 100644 --- a/.github/workflows/bash_code_analysis.yaml +++ b/.github/workflows/bash_code_analysis.yaml @@ -1,8 +1,8 @@ name: bash_code_analysis on: - push: - branches: - - develop + # push: + # branches: + # - develop pull_request: workflow_dispatch: @@ -32,11 +32,12 @@ jobs: # with: # filter_mode: nofilter # level: warning + # reporter: github-pr-review - name: Install shfmt uses: mfinelli/setup-shfmt@v4 - name: shfmt scan - run: shfmt -d dev/jobs dev/job_cards dev/scripts + run: shfmt -d dev/jobs dev/job_cards dev/scripts dev/ush ush shellcheck: runs-on: ubuntu-22.04 @@ -57,10 +58,13 @@ jobs: with: filter_mode: nofilter level: warning + reporter: github-pr-review path: | dev/jobs - jobs - scripts + dev/job_cards + dev/scripts + dev/ush + ush pattern: | config.* J* @@ -88,6 +92,7 @@ jobs: with: filter_mode: added level: warning + reporter: github-pr-review check_all_files_with_shebangs: true pattern: | config.* diff --git a/dev/ush/get_warm_s2sw_restart_tarballs.sh b/dev/ush/get_warm_s2sw_restart_tarballs.sh index 6adba89a21c..44a968b08f3 100755 --- a/dev/ush/get_warm_s2sw_restart_tarballs.sh +++ b/dev/ush/get_warm_s2sw_restart_tarballs.sh @@ -33,9 +33,9 @@ fi cd "${untar_dir}" -ptargets=( "enkfgdas_restartb_grp1.tar" "enkfgdas_restartb_grp2.tar" "enkfgdas_restartb_grp3.tar" "enkfgdas_restartb_grp4.tar" "enkfgdas_restartb_grp5.tar" "enkfgdas_restartb_grp6.tar" "enkfgdas_restartb_grp7.tar" "enkfgdas_restartb_grp8.tar" "gdas_restartb.tar" "gdasocean_restart.tar" "gdaswave_restart.tar" ) +ptargets=("enkfgdas_restartb_grp1.tar" "enkfgdas_restartb_grp2.tar" "enkfgdas_restartb_grp3.tar" "enkfgdas_restartb_grp4.tar" "enkfgdas_restartb_grp5.tar" "enkfgdas_restartb_grp6.tar" "enkfgdas_restartb_grp7.tar" "enkfgdas_restartb_grp8.tar" "gdas_restartb.tar" "gdasocean_restart.tar" "gdaswave_restart.tar") -targets=( "enkfgdas_restarta_grp1.tar" "enkfgdas_restarta_grp2.tar" "enkfgdas_restarta_grp3.tar" "enkfgdas_restarta_grp4.tar" "enkfgdas_restarta_grp5.tar" "enkfgdas_restarta_grp6.tar" "enkfgdas_restarta_grp7.tar" "enkfgdas_restarta_grp8.tar" "gdas_restarta.tar" "gdasocean_analysis.tar") +targets=("enkfgdas_restarta_grp1.tar" "enkfgdas_restarta_grp2.tar" "enkfgdas_restarta_grp3.tar" "enkfgdas_restarta_grp4.tar" "enkfgdas_restarta_grp5.tar" "enkfgdas_restarta_grp6.tar" "enkfgdas_restarta_grp7.tar" "enkfgdas_restarta_grp8.tar" "gdas_restarta.tar" "gdasocean_analysis.tar") # This is all specific to Gaea C6 clusters="es" @@ -48,7 +48,7 @@ tasks=1 # Construct a wrapper script in a loop to submit to the sbatch system for tarball in "${targets[@]}"; do - sbatch << EOF + sbatch << EOF #!/bin/bash #SBATCH --job-name=get_retro_${tarball} #SBATCH --output=get_retro_${tarball}.out @@ -81,7 +81,7 @@ done # Now do the same for the previous cycle tarballs for tarball in "${ptargets[@]}"; do - sbatch << EOF + sbatch << EOF #!/bin/bash #SBATCH --job-name=get_retro_${tarball} #SBATCH --output=get_retro_${tarball}.out diff --git a/dev/ush/gw_setup.sh b/dev/ush/gw_setup.sh index 5b70b9b4fce..04d9433f819 100755 --- a/dev/ush/gw_setup.sh +++ b/dev/ush/gw_setup.sh @@ -11,10 +11,10 @@ # Determine if HOMEgfs is already set unset_homegfs=NO if [[ -z "${HOMEgfs+x}" ]]; then - script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd )" - HOMEgfs=$(cd "${script_dir}" && git rev-parse --show-toplevel) - export HOMEgfs - unset_homegfs=YES + script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null 2>&1 && pwd)" + HOMEgfs=$(cd "${script_dir}" && git rev-parse --show-toplevel) + export HOMEgfs + unset_homegfs=YES fi source "${HOMEgfs}/ush/detect_machine.sh" source "${HOMEgfs}/ush/module-setup.sh" @@ -23,18 +23,16 @@ module use "${HOMEgfs}/modulefiles" module load "gw_setup.${MACHINE_ID}" err=$? if [[ "${err}" -ne 0 ]]; then - echo "FATAL ERROR: Failed to load module_gwsetup.${MACHINE_ID}" - exit 1 + echo "FATAL ERROR: Failed to load module_gwsetup.${MACHINE_ID}" + exit 1 fi # Set up the PYTHONPATH to include wxflow from HOMEgfs if [[ -d "${HOMEgfs}/sorc/wxflow/src" ]]; then - PYTHONPATH="${HOMEgfs}/sorc/wxflow/src${PYTHONPATH:+:${PYTHONPATH}}" - export PYTHONPATH + PYTHONPATH="${HOMEgfs}/sorc/wxflow/src${PYTHONPATH:+:${PYTHONPATH}}" + export PYTHONPATH fi - if [[ ${unset_homegfs} == "YES" ]]; then - unset HOMEgfs + unset HOMEgfs fi - diff --git a/dev/ush/load_modules.sh b/dev/ush/load_modules.sh index d049bcf92ce..263549f9f6c 100755 --- a/dev/ush/load_modules.sh +++ b/dev/ush/load_modules.sh @@ -8,14 +8,14 @@ ############################################################### if [[ "$-" == *x* ]]; then - set_x=YES + set_x=YES else - set_x=NO + set_x=NO fi if [[ "${DEBUG_WORKFLOW:-NO}" == "NO" ]]; then - echo "Loading modules quietly..." - set +x + echo "Loading modules quietly..." + set +x fi # Parse module type argument @@ -24,11 +24,11 @@ MODULE_TYPE="${1:-run}" # For backwards compatibility, handle ufsda options UFSDA_MODS="GDAS" if [[ "${MODULE_TYPE}" == "--eva" ]]; then - MODULE_TYPE="ufsda" - UFSDA_MODS="EVA" + MODULE_TYPE="ufsda" + UFSDA_MODS="EVA" elif [[ "${MODULE_TYPE}" == "--gdas" ]]; then - MODULE_TYPE="ufsda" - UFSDA_MODS="GDAS" + MODULE_TYPE="ufsda" + UFSDA_MODS="GDAS" fi # Setup runtime environment by loading modules @@ -37,25 +37,25 @@ ulimit_s=$(ulimit -S -s) # Test if HOMEgfs is defined. If not, then try to determine it with git rev-parse _unset_homegfs="NO" if [[ -z ${HOMEgfs+x} ]]; then - echo "INFO: HOMEgfs is not defined. Attempting to find the global-workflow root directory" - # HOMEgfs will be removed from the environment at the end of this script - _unset_homegfs="YES" - - script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd) - HOMEgfs=$(cd "${script_dir}" && git rev-parse --show-toplevel) - export HOMEgfs - err=$? - if [[ ${err} -ne 0 ]]; then - is_git_dir=$(cd -- "${script_dir}" &> /dev/null && git rev-parse --is-inside-work-tree) - git_stat=$? - if [[ ${git_stat} -ne 0 || ${is_git_dir} != "true" ]]; then - echo "FATAL ERROR: unable to determine the root because it is not a git repository." - else - echo "FATAL ERROR: unable to determine the root because git rev-parse --show-toplevel failed for an unknown reason" + echo "INFO: HOMEgfs is not defined. Attempting to find the global-workflow root directory" + # HOMEgfs will be removed from the environment at the end of this script + _unset_homegfs="YES" + + script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd) + HOMEgfs=$(cd "${script_dir}" && git rev-parse --show-toplevel) + export HOMEgfs + err=$? + if [[ ${err} -ne 0 ]]; then + is_git_dir=$(cd -- "${script_dir}" &> /dev/null && git rev-parse --is-inside-work-tree) + git_stat=$? + if [[ ${git_stat} -ne 0 || ${is_git_dir} != "true" ]]; then + echo "FATAL ERROR: unable to determine the root because it is not a git repository." + else + echo "FATAL ERROR: unable to determine the root because git rev-parse --show-toplevel failed for an unknown reason" + fi + echo "FATAL ERROR: Unable to load modules. Exiting" + exit 1 fi - echo "FATAL ERROR: Unable to load modules. Exiting" - exit 1 - fi fi # Find module command and purge: @@ -64,162 +64,162 @@ source "${HOMEgfs}/ush/module-setup.sh" # Handle different module types case "${MODULE_TYPE}" in - "ufswm") - # UFS Weather Model modules - special handling - module use "${HOMEgfs}/sorc/ufs_model.fd/modulefiles" - module load "ufs_${MACHINE_ID}.intel" - export err=$? - if [[ ${err} -ne 0 ]]; then - echo "FATAL ERROR: Failed to load ufs_${MACHINE_ID}.intel" - exit 1 - fi - module load prod_util - if [[ "${MACHINE_ID}" = "wcoss2" ]]; then - module load cray-pals - module load cfp - module load libjpeg - module load craype-network-ucx - module load cray-mpich-ucx - module load python/3.8.6 - module load wgrib2 - else - export UTILROOT=${prod_util_ROOT} - source "${HOMEgfs}/versions/run.ver" - module load "wgrib2/${wgrib2_ver}" - fi - export WGRIB2=wgrib2 - - module list - unset MACHINE_ID - ;; - - "ufsda") - # UFSDA modules - special handling - module use "${HOMEgfs}/sorc/gdas.cd/modulefiles" - - case "${MACHINE_ID}" in - ("hera" | "orion" | "hercules" | "wcoss2" | "gaeac5" | "gaeac6" | "ursa" | "noaacloud") - #TODO: Remove LMOD_TMOD_FIND_FIRST line when spack-stack on WCOSS2 - if [[ "${MACHINE_ID}" == "wcoss2" ]]; then - export LMOD_TMOD_FIND_FIRST=yes - # TODO: Add path to GDASApp libraries and cray-mpich as temporary patches - export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${HOMEgfs}/sorc/gdas.cd/build/lib" - # TODO: Remove LD_LIBRARY_PATH line as soon as permanent solution is available - export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/opt/cray/pe/mpich/8.1.29/ofi/intel/2022.1/lib" - fi - module load "${UFSDA_MODS}/${MACHINE_ID}" + "ufswm") + # UFS Weather Model modules - special handling + module use "${HOMEgfs}/sorc/ufs_model.fd/modulefiles" + module load "ufs_${MACHINE_ID}.intel" export err=$? if [[ ${err} -ne 0 ]]; then - echo "FATAL ERROR: Failed to load ${UFSDA_MODS}/${MACHINE_ID}" - exit 1 + echo "FATAL ERROR: Failed to load ufs_${MACHINE_ID}.intel" + exit 1 fi - ncdump=$(command -v ncdump) - NETCDF=$(echo "${ncdump}" | cut -d " " -f 3) - export NETCDF - ;; - ("acorn") - echo WARNING: UFSDA NOT SUPPORTED ON 'acorn' - ;; - *) - echo "WARNING: UNKNOWN PLATFORM" + module load prod_util + if [[ "${MACHINE_ID}" == "wcoss2" ]]; then + module load cray-pals + module load cfp + module load libjpeg + module load craype-network-ucx + module load cray-mpich-ucx + module load python/3.8.6 + module load wgrib2 + else + export UTILROOT=${prod_util_ROOT} + source "${HOMEgfs}/versions/run.ver" + module load "wgrib2/${wgrib2_ver}" + fi + export WGRIB2=wgrib2 + + module list + unset MACHINE_ID ;; - esac - module list + "ufsda") + # UFSDA modules - special handling + module use "${HOMEgfs}/sorc/gdas.cd/modulefiles" + + case "${MACHINE_ID}" in + "hera" | "orion" | "hercules" | "wcoss2" | "gaeac5" | "gaeac6" | "ursa" | "noaacloud") + #TODO: Remove LMOD_TMOD_FIND_FIRST line when spack-stack on WCOSS2 + if [[ "${MACHINE_ID}" == "wcoss2" ]]; then + export LMOD_TMOD_FIND_FIRST=yes + # TODO: Add path to GDASApp libraries and cray-mpich as temporary patches + export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${HOMEgfs}/sorc/gdas.cd/build/lib" + # TODO: Remove LD_LIBRARY_PATH line as soon as permanent solution is available + export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/opt/cray/pe/mpich/8.1.29/ofi/intel/2022.1/lib" + fi + module load "${UFSDA_MODS}/${MACHINE_ID}" + export err=$? + if [[ ${err} -ne 0 ]]; then + echo "FATAL ERROR: Failed to load ${UFSDA_MODS}/${MACHINE_ID}" + exit 1 + fi + ncdump=$(command -v ncdump) + NETCDF=$(echo "${ncdump}" | cut -d " " -f 3) + export NETCDF + ;; + "acorn") + echo WARNING: UFSDA NOT SUPPORTED ON 'acorn' + ;; + *) + echo "WARNING: UNKNOWN PLATFORM" + ;; + esac + + module list + + ftype=$(type -t set_trace || echo "") + if [[ "${ftype}" == "function" ]]; then + set_trace + elif [[ "${set_x}" == "YES" ]]; then + set -x + fi - ftype=$(type -t set_trace || echo "") - if [[ "${ftype}" == "function" ]]; then - set_trace - elif [[ "${set_x}" == "YES" ]]; then - set -x - fi + pip list - pip list + # Detect the Python major.minor version + _regex="[0-9]+\.[0-9]+" + # shellcheck disable=SC2312 + if [[ $(python --version) =~ ${_regex} ]]; then + export PYTHON_VERSION="${BASH_REMATCH[0]}" + else + echo "FATAL ERROR: Could not detect the python version" + exit 1 + fi - # Detect the Python major.minor version - _regex="[0-9]+\.[0-9]+" - # shellcheck disable=SC2312 - if [[ $(python --version) =~ ${_regex} ]]; then - export PYTHON_VERSION="${BASH_REMATCH[0]}" - else - echo "FATAL ERROR: Could not detect the python version" - exit 1 - fi + ############################################################### + # setup python path for ioda utilities + # TODO: a better solution should be created for setting paths to package python scripts + # shellcheck disable=SC2311 + pyiodaPATH="${HOMEgfs}/sorc/gdas.cd/build/lib/python${PYTHON_VERSION}/" + pybufrPATH="${HOMEgfs}/sorc/gdas.cd/build/lib/python${PYTHON_VERSION}/site-packages/" + PYTHONPATH="${pyiodaPATH}:${pybufrPATH}${PYTHONPATH:+:${PYTHONPATH}}" + export PYTHONPATH + ;; - ############################################################### - # setup python path for ioda utilities - # TODO: a better solution should be created for setting paths to package python scripts - # shellcheck disable=SC2311 - pyiodaPATH="${HOMEgfs}/sorc/gdas.cd/build/lib/python${PYTHON_VERSION}/" - pybufrPATH="${HOMEgfs}/sorc/gdas.cd/build/lib/python${PYTHON_VERSION}/site-packages/" - PYTHONPATH="${pyiodaPATH}:${pybufrPATH}${PYTHONPATH:+:${PYTHONPATH}}" - export PYTHONPATH - ;; - - "run" | "gsi" | "verif" | "setup" | "upp") - - # Test that the version file exists - if [[ ! -f "${HOMEgfs}/versions/run.ver" ]]; then - echo "FATAL ERROR: ${HOMEgfs}/versions/run.ver does not exist!" - echo "HINT: Run link_workflow.sh first." - exit 1 - fi + "run" | "gsi" | "verif" | "setup" | "upp") - # Load our modules: - module use "${HOMEgfs}/modulefiles" - - # Determine target module based on type and machine - target_module="gw_${MODULE_TYPE}.${MACHINE_ID}" - - # Check if the target module file exists, fall back to gw_run if not - if ! module is-avail "${target_module}" 2>/dev/null; then - if [[ "${MODULE_TYPE}" != "run" ]]; then - echo "INFO: ${target_module} module not available, falling back to gw_run.${MACHINE_ID}" - mod_type="run" - fi - target_module="gw_run.${MACHINE_ID}" - else - mod_type="${MODULE_TYPE}" - fi + # Test that the version file exists + if [[ ! -f "${HOMEgfs}/versions/run.ver" ]]; then + echo "FATAL ERROR: ${HOMEgfs}/versions/run.ver does not exist!" + echo "HINT: Run link_workflow.sh first." + exit 1 + fi - # Source versions file (except for upp) - if [[ "${mod_type}" != "upp" ]]; then - source "${HOMEgfs}/versions/run.ver" - fi + # Load our modules: + module use "${HOMEgfs}/modulefiles" + + # Determine target module based on type and machine + target_module="gw_${MODULE_TYPE}.${MACHINE_ID}" + + # Check if the target module file exists, fall back to gw_run if not + if ! module is-avail "${target_module}" 2> /dev/null; then + if [[ "${MODULE_TYPE}" != "run" ]]; then + echo "INFO: ${target_module} module not available, falling back to gw_run.${MACHINE_ID}" + mod_type="run" + fi + target_module="gw_run.${MACHINE_ID}" + else + mod_type="${MODULE_TYPE}" + fi - if [[ -n "${target_module}" ]]; then - module load "${target_module}" - export err=$? - if [[ ${err} -ne 0 ]]; then - echo "FATAL ERROR: Failed to load ${target_module}" - exit 1 - fi - else - echo "FATAL ERROR: Could not determine target module for MODULE_TYPE='${MODULE_TYPE}' and MACHINE_ID='${MACHINE_ID}'" - exit 1 - fi + # Source versions file (except for upp) + if [[ "${mod_type}" != "upp" ]]; then + source "${HOMEgfs}/versions/run.ver" + fi - module list + if [[ -n "${target_module}" ]]; then + module load "${target_module}" + export err=$? + if [[ ${err} -ne 0 ]]; then + echo "FATAL ERROR: Failed to load ${target_module}" + exit 1 + fi + else + echo "FATAL ERROR: Could not determine target module for MODULE_TYPE='${MODULE_TYPE}' and MACHINE_ID='${MACHINE_ID}'" + exit 1 + fi - # If this function exists in the environment, run it; else set -x if it was set on entering this script - ftype=$(type -t set_trace || echo "") - if [[ "${ftype}" == "function" ]]; then - set_trace - elif [[ "${set_x}" == "YES" ]]; then - set -x - fi - ;; + module list + + # If this function exists in the environment, run it; else set -x if it was set on entering this script + ftype=$(type -t set_trace || echo "") + if [[ "${ftype}" == "function" ]]; then + set_trace + elif [[ "${set_x}" == "YES" ]]; then + set -x + fi + ;; + + *) + echo "FATAL ERROR: Unknown module type '${MODULE_TYPE}'" + echo "Valid types: run, gsi, verif, ufsda, ufswm, setup" + ;; - *) - echo "FATAL ERROR: Unknown module type '${MODULE_TYPE}'" - echo "Valid types: run, gsi, verif, ufsda, ufswm, setup" - exit 1 - ;; esac # Set up the PYTHONPATH to include wxflow from HOMEgfs if [[ -d "${HOMEgfs}/sorc/wxflow/src" ]]; then - PYTHONPATH="${HOMEgfs}/sorc/wxflow/src${PYTHONPATH:+:${PYTHONPATH}}" + PYTHONPATH="${HOMEgfs}/sorc/wxflow/src${PYTHONPATH:+:${PYTHONPATH}}" fi # Add HOMEgfs/ush/python to PYTHONPATH @@ -232,5 +232,5 @@ unset ulimit_s # Unset HOMEgfs if it was not set at the beginning of this script if [[ ${_unset_homegfs} == "YES" ]]; then - unset HOMEgfs + unset HOMEgfs fi diff --git a/dev/ush/make_ee2_links.sh b/dev/ush/make_ee2_links.sh index 674e83a5013..9704dc553bd 100755 --- a/dev/ush/make_ee2_links.sh +++ b/dev/ush/make_ee2_links.sh @@ -14,7 +14,6 @@ set -eux # WARNING: This script does not create all links needed for EE2 compatibility. It only creates links needed to # restart an existing experiment. - if [[ $# -ne 1 ]]; then echo "Usage: $0 " exit 1 @@ -43,18 +42,18 @@ link_file() { return 0 } -gdas_list=($(ls -d gdas.* || true )) -gfs_list=($(ls -d gfs.* || true )) -gcdas_list=($(ls -d gcdas.* || true )) -gcafs_list=($(ls -d gcafs.* || true )) -enkfgdas_list=($(ls -d enkfgdas.* || true )) -enkfgfs_list=($(ls -d enkfgfs.* || true )) -enkfgcdas_list=($(ls -d enkfgcdas.* || true )) +gdas_list=($(ls -d gdas.* || true)) +gfs_list=($(ls -d gfs.* || true)) +gcdas_list=($(ls -d gcdas.* || true)) +gcafs_list=($(ls -d gcafs.* || true)) +enkfgdas_list=($(ls -d enkfgdas.* || true)) +enkfgfs_list=($(ls -d enkfgfs.* || true)) +enkfgcdas_list=($(ls -d enkfgcdas.* || true)) # If the length of all of the arrays is zero, exit with a message if [[ ${#gdas_list[@]} -eq 0 && ${#gfs_list[@]} -eq 0 && ${#gcdas_list[@]} -eq 0 && - ${#gcafs_list[@]} -eq 0 && ${#enkfgdas_list[@]} -eq 0 && - ${#enkfgfs_list[@]} -eq 0 && ${#enkfgcdas_list[@]} -eq 0 ]]; then + ${#gcafs_list[@]} -eq 0 && ${#enkfgdas_list[@]} -eq 0 && + ${#enkfgfs_list[@]} -eq 0 && ${#enkfgcdas_list[@]} -eq 0 ]]; then echo "No gdas, gfs, gcdas, gcafs, enkfgdas, enkfgfs, or enkfgcdas directories found. Exiting." exit 0 fi @@ -70,10 +69,13 @@ for dir in "${gdas_list[@]}" "${gfs_list[@]}" "${gcdas_list[@]}" "${gcafs_list[@ gfs.*) system_prefix="gfs" ;; gcdas.*) system_prefix="gcdas" ;; gcafs.*) system_prefix="gcafs" ;; - *) echo "Unknown directory prefix: ${dir}"; exit 1 ;; + *) + echo "Unknown directory prefix: ${dir}" + exit 1 + ;; esac - cycle_list=($(ls -d -- ?? || true )) + cycle_list=($(ls -d -- ?? || true)) for cyc in "${cycle_list[@]}"; do if [[ -d "${cwd}/${dir}/${cyc}/analysis/atmos" ]]; then cd "${cwd}/${dir}/${cyc}/analysis/atmos" @@ -82,93 +84,93 @@ for dir in "${gdas_list[@]}" "${gfs_list[@]}" "${gcdas_list[@]}" "${gcafs_list[@ link_file "${system_prefix}.t${cyc}z.${abias_type}" "${system_prefix}.t${cyc}z.${abias_type}.txt" fi done - if [[ -f "${system_prefix}.t${cyc}z.radstat" ]]; then - link_file "${system_prefix}.t${cyc}z.radstat" "${system_prefix}.t${cyc}z.radstat.tar" - fi - if [[ -f "${system_prefix}.t${cyc}z.atmi003.nc" ]]; then - link_file "${system_prefix}.t${cyc}z.atmi003.nc" "${system_prefix}.t${cyc}z.increment.atm.i003.nc" - fi - if [[ -f "${system_prefix}.t${cyc}z.atminc.nc" ]]; then - link_file "${system_prefix}.t${cyc}z.atminc.nc" "${system_prefix}.t${cyc}z.increment.atm.i006.nc" - fi - if [[ -f "${system_prefix}.t${cyc}z.atmi009.nc" ]]; then - link_file "${system_prefix}.t${cyc}z.atmi009.nc" "${system_prefix}.t${cyc}z.increment.atm.i009.nc" - fi - if [[ -f "${system_prefix}.t${cyc}z.atma003.ensres.nc" ]]; then - link_file "${system_prefix}.t${cyc}z.atma003.ensres.nc" "${system_prefix}.t${cyc}z.ensres_analysis.atm.a003.nc" - fi - if [[ -f "${system_prefix}.t${cyc}z.atmanl.nc" ]]; then - link_file "${system_prefix}.t${cyc}z.atmanl.nc" "${system_prefix}.t${cyc}z.analysis.atm.a006.nc" - fi - if [[ -f "${system_prefix}.t${cyc}z.atmanl.ensres.nc" ]]; then - link_file "${system_prefix}.t${cyc}z.atmanl.ensres.nc" "${system_prefix}.t${cyc}z.ensres_analysis.atm.a006.nc" - fi - if [[ -f "${system_prefix}.t${cyc}z.atma009.ensres.nc" ]]; then - link_file "${system_prefix}.t${cyc}z.atma009.ensres.nc" "${system_prefix}.t${cyc}z.ensres_analysis.atm.a009.nc" - fi - if [[ -f "${system_prefix}.t${cyc}z.cnvstat" ]]; then - link_file "${system_prefix}.t${cyc}z.cnvstat" "${system_prefix}.t${cyc}z.cnvstat.tar" - fi - if [[ -f "${system_prefix}.t${cyc}z.dtfanl.nc" ]]; then - link_file "${system_prefix}.t${cyc}z.dtfanl.nc" "${system_prefix}.t${cyc}z.analysis.dtf.a006.nc" - fi - if [[ -f "${system_prefix}.t${cyc}z.gsistat" ]]; then - link_file "${system_prefix}.t${cyc}z.gsistat" "${system_prefix}.t${cyc}z.gsistat.txt" - fi - if [[ -f "${system_prefix}.t${cyc}z.oznstat" ]]; then - link_file "${system_prefix}.t${cyc}z.oznstat" "${system_prefix}.t${cyc}z.oznstat.tar" - fi - if [[ -f "${system_prefix}.t${cyc}z.loginc.txt" ]]; then - link_file "${system_prefix}.t${cyc}z.loginc.txt" "${system_prefix}.t${cyc}z.increment.done.txt" - fi - if [[ -f "${system_prefix}.t${cyc}z.loganl.txt" ]]; then - link_file "${system_prefix}.t${cyc}z.loganl.txt" "${system_prefix}.t${cyc}z.analysis.done.txt" - fi - if [[ -f "${system_prefix}.t${cyc}z.sfci003.nc" ]]; then - link_file "${system_prefix}.t${cyc}z.sfci003.nc" "${system_prefix}.t${cyc}z.increment.sfc.i003.nc" - fi - if [[ -f "${system_prefix}.t${cyc}z.sfci006.nc" ]]; then - link_file "${system_prefix}.t${cyc}z.sfci006.nc" "${system_prefix}.t${cyc}z.increment.sfc.i006.nc" - fi - if [[ -f "${system_prefix}.t${cyc}z.sfci009.nc" ]]; then - link_file "${system_prefix}.t${cyc}z.sfci009.nc" "${system_prefix}.t${cyc}z.increment.sfc.i009.nc" - fi - if [[ -f "${system_prefix}.t${cyc}z.sfcanl.nc" ]]; then - link_file "${system_prefix}.t${cyc}z.sfcanl.nc" "${system_prefix}.t${cyc}z.analysis.sfc.a006.nc" - fi - if [[ -f "${system_prefix}.t${cyc}z.sfcinc.nc" ]]; then - link_file "${system_prefix}.t${cyc}z.sfcinc.nc" "${system_prefix}.t${cyc}z.increment.sfc.i006.nc" - fi - if [[ -f "sfc_inc.tile1.nc" ]]; then - for tile in {1..6}; do - link_file "sfc_inc.tile${tile}.nc" "increment.sfc.tile${tile}.nc" - done - fi - if [[ -f "${system_prefix}.t${cyc}z.cubed_sphere_grid_atminc.tile1.nc" ]]; then - for tile in {1..6}; do - link_file "${system_prefix}.t${cyc}z.cubed_sphere_grid_atminc.tile${tile}.nc" "${system_prefix}.t${cyc}z.jedi_increment.atm.i006.tile${tile}.nc" - done - fi - fi - cd "${cwd}" - if [[ -d "${cwd}/${dir}/${cyc}/analysis/ocean" ]]; then - cd "${cwd}/${dir}/${cyc}/analysis/ocean" - if [[ -f "${system_prefix}.t${cyc}z.ocninc.nc" ]]; then - link_file "${system_prefix}.t${cyc}z.ocninc.nc" "${system_prefix}.t${cyc}z.mom6_increment.i006.nc" - fi - fi - cd "${cwd}" - if [[ -d "${cwd}/${dir}/${cyc}/analysis/ice" ]]; then - cd "${cwd}/${dir}/${cyc}/analysis/ice" - for ice_file in *.cice_model_anl.res.nc; do - if [[ -f "${ice_file}" ]]; then - # This gets the first two fields of the filename separated by dots - prefix=$(echo "${ice_file}" | cut -d. -f1-2) - link_file "${ice_file}" "${prefix}.analysis.cice_model.res.nc" - fi - done - fi - cd "${cwd}" + if [[ -f "${system_prefix}.t${cyc}z.radstat" ]]; then + link_file "${system_prefix}.t${cyc}z.radstat" "${system_prefix}.t${cyc}z.radstat.tar" + fi + if [[ -f "${system_prefix}.t${cyc}z.atmi003.nc" ]]; then + link_file "${system_prefix}.t${cyc}z.atmi003.nc" "${system_prefix}.t${cyc}z.increment.atm.i003.nc" + fi + if [[ -f "${system_prefix}.t${cyc}z.atminc.nc" ]]; then + link_file "${system_prefix}.t${cyc}z.atminc.nc" "${system_prefix}.t${cyc}z.increment.atm.i006.nc" + fi + if [[ -f "${system_prefix}.t${cyc}z.atmi009.nc" ]]; then + link_file "${system_prefix}.t${cyc}z.atmi009.nc" "${system_prefix}.t${cyc}z.increment.atm.i009.nc" + fi + if [[ -f "${system_prefix}.t${cyc}z.atma003.ensres.nc" ]]; then + link_file "${system_prefix}.t${cyc}z.atma003.ensres.nc" "${system_prefix}.t${cyc}z.ensres_analysis.atm.a003.nc" + fi + if [[ -f "${system_prefix}.t${cyc}z.atmanl.nc" ]]; then + link_file "${system_prefix}.t${cyc}z.atmanl.nc" "${system_prefix}.t${cyc}z.analysis.atm.a006.nc" + fi + if [[ -f "${system_prefix}.t${cyc}z.atmanl.ensres.nc" ]]; then + link_file "${system_prefix}.t${cyc}z.atmanl.ensres.nc" "${system_prefix}.t${cyc}z.ensres_analysis.atm.a006.nc" + fi + if [[ -f "${system_prefix}.t${cyc}z.atma009.ensres.nc" ]]; then + link_file "${system_prefix}.t${cyc}z.atma009.ensres.nc" "${system_prefix}.t${cyc}z.ensres_analysis.atm.a009.nc" + fi + if [[ -f "${system_prefix}.t${cyc}z.cnvstat" ]]; then + link_file "${system_prefix}.t${cyc}z.cnvstat" "${system_prefix}.t${cyc}z.cnvstat.tar" + fi + if [[ -f "${system_prefix}.t${cyc}z.dtfanl.nc" ]]; then + link_file "${system_prefix}.t${cyc}z.dtfanl.nc" "${system_prefix}.t${cyc}z.analysis.dtf.a006.nc" + fi + if [[ -f "${system_prefix}.t${cyc}z.gsistat" ]]; then + link_file "${system_prefix}.t${cyc}z.gsistat" "${system_prefix}.t${cyc}z.gsistat.txt" + fi + if [[ -f "${system_prefix}.t${cyc}z.oznstat" ]]; then + link_file "${system_prefix}.t${cyc}z.oznstat" "${system_prefix}.t${cyc}z.oznstat.tar" + fi + if [[ -f "${system_prefix}.t${cyc}z.loginc.txt" ]]; then + link_file "${system_prefix}.t${cyc}z.loginc.txt" "${system_prefix}.t${cyc}z.increment.done.txt" + fi + if [[ -f "${system_prefix}.t${cyc}z.loganl.txt" ]]; then + link_file "${system_prefix}.t${cyc}z.loganl.txt" "${system_prefix}.t${cyc}z.analysis.done.txt" + fi + if [[ -f "${system_prefix}.t${cyc}z.sfci003.nc" ]]; then + link_file "${system_prefix}.t${cyc}z.sfci003.nc" "${system_prefix}.t${cyc}z.increment.sfc.i003.nc" + fi + if [[ -f "${system_prefix}.t${cyc}z.sfci006.nc" ]]; then + link_file "${system_prefix}.t${cyc}z.sfci006.nc" "${system_prefix}.t${cyc}z.increment.sfc.i006.nc" + fi + if [[ -f "${system_prefix}.t${cyc}z.sfci009.nc" ]]; then + link_file "${system_prefix}.t${cyc}z.sfci009.nc" "${system_prefix}.t${cyc}z.increment.sfc.i009.nc" + fi + if [[ -f "${system_prefix}.t${cyc}z.sfcanl.nc" ]]; then + link_file "${system_prefix}.t${cyc}z.sfcanl.nc" "${system_prefix}.t${cyc}z.analysis.sfc.a006.nc" + fi + if [[ -f "${system_prefix}.t${cyc}z.sfcinc.nc" ]]; then + link_file "${system_prefix}.t${cyc}z.sfcinc.nc" "${system_prefix}.t${cyc}z.increment.sfc.i006.nc" + fi + if [[ -f "sfc_inc.tile1.nc" ]]; then + for tile in {1..6}; do + link_file "sfc_inc.tile${tile}.nc" "increment.sfc.tile${tile}.nc" + done + fi + if [[ -f "${system_prefix}.t${cyc}z.cubed_sphere_grid_atminc.tile1.nc" ]]; then + for tile in {1..6}; do + link_file "${system_prefix}.t${cyc}z.cubed_sphere_grid_atminc.tile${tile}.nc" "${system_prefix}.t${cyc}z.jedi_increment.atm.i006.tile${tile}.nc" + done + fi + fi + cd "${cwd}" + if [[ -d "${cwd}/${dir}/${cyc}/analysis/ocean" ]]; then + cd "${cwd}/${dir}/${cyc}/analysis/ocean" + if [[ -f "${system_prefix}.t${cyc}z.ocninc.nc" ]]; then + link_file "${system_prefix}.t${cyc}z.ocninc.nc" "${system_prefix}.t${cyc}z.mom6_increment.i006.nc" + fi + fi + cd "${cwd}" + if [[ -d "${cwd}/${dir}/${cyc}/analysis/ice" ]]; then + cd "${cwd}/${dir}/${cyc}/analysis/ice" + for ice_file in *.cice_model_anl.res.nc; do + if [[ -f "${ice_file}" ]]; then + # This gets the first two fields of the filename separated by dots + prefix=$(echo "${ice_file}" | cut -d. -f1-2) + link_file "${ice_file}" "${prefix}.analysis.cice_model.res.nc" + fi + done + fi + cd "${cwd}" if [[ -d "${cwd}/${dir}/${cyc}/analysis/snow" ]]; then cd "${cwd}/${dir}/${cyc}/analysis/snow" for snow_file in snowinc*.sfc_data.tile1.nc; do @@ -189,18 +191,21 @@ done for dir in "${enkfgdas_list[@]}" "${enkfgfs_list[@]}"; do cd "${dir}" - cycle_list=($(ls -d -- ?? || true )) + cycle_list=($(ls -d -- ?? || true)) # Determine the system prefix system_prefix="" case "${dir}" in enkfgdas.*) system_prefix="enkfgdas" ;; enkfgfs.*) system_prefix="enkfgfs" ;; enkfgcdas.*) system_prefix="enkfgcdas" ;; - *) echo "Unknown directory prefix: ${dir}"; exit 1 ;; + *) + echo "Unknown directory prefix: ${dir}" + exit 1 + ;; esac for cyc in "${cycle_list[@]}"; do cd "${cwd}/${dir}/${cyc}" - mem_list=($(ls -d mem* || true )) + mem_list=($(ls -d mem* || true)) for mem in "${mem_list[@]}"; do # atmos if [[ -d "${cwd}/${dir}/${cyc}/${mem}/analysis/atmos" ]]; then @@ -280,12 +285,12 @@ for dir in "${enkfgdas_list[@]}" "${enkfgfs_list[@]}"; do cd "${cwd}/${dir}/${cyc}/${mem}/analysis/snow" # The old snow analysis files start with YYYYMMDD.HHMMSS, which we want to keep for snow_file in ????????.??????.sfc_data.tile1.nc; do - if [[ -f "${snow_file}" ]]; then - prefix=$(echo "${snow_file}" | cut -d. -f1-2) - for tile in {1..6}; do - link_file "${prefix}.sfc_data.tile${tile}.nc" "${prefix}.snow_analysis.sfc_data.tile${tile}.nc" - done - fi + if [[ -f "${snow_file}" ]]; then + prefix=$(echo "${snow_file}" | cut -d. -f1-2) + for tile in {1..6}; do + link_file "${prefix}.sfc_data.tile${tile}.nc" "${prefix}.snow_analysis.sfc_data.tile${tile}.nc" + done + fi done fi cd "${cwd}" diff --git a/ush/atmos_ensstat.sh b/ush/atmos_ensstat.sh index 36218731627..4be0a96d56b 100755 --- a/ush/atmos_ensstat.sh +++ b/ush/atmos_ensstat.sh @@ -24,8 +24,8 @@ for ((mem_num = 0; mem_num <= "${NMEM_ENS:-0}"; mem_num++)); do done num_found=${#input_files[@]} -if (( num_found != NMEM_ENS + 1 )); then - echo "FATAL ERROR: Only ${num_found} grib files found out of $(( NMEM_ENS + 1 )) expected members." +if ((num_found != NMEM_ENS + 1)); then + echo "FATAL ERROR: Only ${num_found} grib files found out of $((NMEM_ENS + 1)) expected members." exit 10 fi @@ -47,8 +47,8 @@ cat << EOF > input.nml cfopg2="${spr_out}" $( - for (( filenum = 1; filenum <= num_found; filenum++ )); do - echo " cfipg(${filenum})=\"${input_files[$((filenum-1))]}\"," + for ((filenum = 1; filenum <= num_found; filenum++)); do + echo " cfipg(${filenum})=\"${input_files[$((filenum - 1))]}\"," echo " iskip(${filenum})=0," done ) @@ -61,7 +61,7 @@ cat input.nml "${EXECgfs}/ensstat.x" < input.nml export err=$? -if (( err != 0 )) ; then +if [[ "${err}" -ne 0 ]]; then echo "FATAL ERROR: ensstat returned error code ${err}" exit "${err}" fi @@ -78,7 +78,7 @@ for outfile in ${mean_out} ${spr_out}; do ${WGRIB2} -s "${outfile}" > "${outfile}.idx" err=$? - if (( err != 0 )); then + if [[ "${err}" -ne 0 ]]; then echo "FATAL ERROR: Failed to create inventory file, wgrib2 returned ${err}" exit "${err}" fi @@ -94,4 +94,3 @@ for outfile in ${mean_out} ${spr_out}; do fi done - diff --git a/ush/atmos_extractvars.sh b/ush/atmos_extractvars.sh index 2033fd8c849..31cd61087bd 100755 --- a/ush/atmos_extractvars.sh +++ b/ush/atmos_extractvars.sh @@ -14,101 +14,101 @@ dcnt=1 # lead day subdata=${1} if [[ ! -d "${subdata}" ]]; then - mkdir -p "${subdata}" + mkdir -p "${subdata}" fi for outtype in "f2d" "f3d"; do - if [[ "${outtype}" == "f2d" ]]; then - varlist=${varlist_2d} - ARC_RFCST_PROD_ATMOS="${ARC_RFCST_PROD_ATMOS_F2D}" - elif [[ "${outtype}" == "f3d" ]]; then - varlist=${varlist_3d} - varlist_d=${varlist_3d_d} - ARC_RFCST_PROD_ATMOS="${ARC_RFCST_PROD_ATMOS_F3D}" - fi - - outdirpre="${subdata}/${outtype}" - if [[ ! -d "${outdirpre}" ]]; then - mkdir -p "${outdirpre}" - fi - - nh=${FHMIN} - - while (( nh <= FHMAX_GFS )); do - fnh=$(printf "%3.3d" "${nh}") - if [[ "${outtype}" == "f2d" ]]; then - if (( nh < FHMAX_HF_GFS )); then - outres="0p25" - else - outres="0p50" - fi + varlist=${varlist_2d} + ARC_RFCST_PROD_ATMOS="${ARC_RFCST_PROD_ATMOS_F2D}" elif [[ "${outtype}" == "f3d" ]]; then - outres="1p00" + varlist=${varlist_3d} + varlist_d=${varlist_3d_d} + ARC_RFCST_PROD_ATMOS="${ARC_RFCST_PROD_ATMOS_F3D}" fi - if [[ "${outtype}" == "f2d" ]]; then - if (( nh < FHMAX_HF_GFS )); then - outfreq=${FHOUT_HF_GFS} - else - outfreq=${FHOUT_GFS} - fi - elif [[ "${outtype}" == "f3d" ]]; then - outfreq=${FHOUT_GFS} + outdirpre="${subdata}/${outtype}" + if [[ ! -d "${outdirpre}" ]]; then + mkdir -p "${outdirpre}" fi - com_var="COMIN_ATMOS_GRIB_${outres}" - infile1="${!com_var}/${RUN}.t${cyc}z.pres_a.${outres}.f${fnh}.grib2" - infile2="${!com_var}/${RUN}.t${cyc}z.pres_b.${outres}.f${fnh}.grib2" - outfile="${outdirpre}/${RUN}.t${cyc}z.pres_a.${outres}.f${fnh}.grib2" - rm -f "${outfile}" #remove outfile if it already exists before extraction - - for infile in "${infile1}" "${infile2}"; do - if [[ -f "${infile}" ]]; then # check if input file exists before extraction - new_infile="${outdirpre}/$(basename "${infile}")_ext" - if ! cpfs "${infile}" "${new_infile}"; then - echo "FATAL ERROR: Failed to copy ${infile} to ${new_infile}." - exit 1 + nh=${FHMIN} + + while ((nh <= FHMAX_GFS)); do + fnh=$(printf "%3.3d" "${nh}") + + if [[ "${outtype}" == "f2d" ]]; then + if ((nh < FHMAX_HF_GFS)); then + outres="0p25" + else + outres="0p50" + fi + elif [[ "${outtype}" == "f3d" ]]; then + outres="1p00" fi - # shellcheck disable=SC2312 - ${WGRIB2} "${new_infile}" | grep -F -f "${varlist}" | ${WGRIB2} -i "${new_infile}" -append -grib "${outfile}" - else - echo "WARNING: ${infile} does not exist in ${com_dir}." - fi - done - - check_atmos "${infile1}" "${infile2}" "${varlist}" "${fnh}" - copy_to_comout "${outfile}" "${ARC_RFCST_PROD_ATMOS}" - - # Compute daily average for a subset of variables - if (( nh % 6 == 0 )) && (( nh != 0 )) && [[ "${outtype}" == "f3d" ]]; then - outfile=${subdata}/vartmp_raw_vari_ldy${dcnt}.grib2 - for infile in "${infile1}" "${infile2}"; do - if [[ -f "${infile}" ]]; then # check if input file exists before extraction - new_infile="${outdirpre}/$(basename "${infile}")_ext" - if ! cpfs "${infile}" "${new_infile}"; then - echo "FATAL ERROR: Failed to copy ${infile} to ${new_infile}." - exit 1 - fi - # shellcheck disable=SC2312 - ${WGRIB2} "${new_infile}" | grep -F -f "${varlist_d}" | ${WGRIB2} -i "${new_infile}" -append -grib "${outfile}" - else - echo "WARNING: ${infile} does not exist in ${com_dir}." + + if [[ "${outtype}" == "f2d" ]]; then + if ((nh < FHMAX_HF_GFS)); then + outfreq=${FHOUT_HF_GFS} + else + outfreq=${FHOUT_GFS} + fi + elif [[ "${outtype}" == "f3d" ]]; then + outfreq=${FHOUT_GFS} fi - done - if [[ ${fcnt} -eq 4 ]]; then - daily_avg_atmos "${outfile}" "${dcnt}" "${outres}" - copy_to_comout "${davg_file}" "${ARC_RFCST_PROD_ATMOS}" - fcnt=1 - dcnt=$(( dcnt + 1 )) - else - fcnt=$(( fcnt + 1 )) - fi # If at final lead hour of a given day - fi # if lead hour is divisible by 6 and outtype is f3d - - nh=$(( nh + outfreq )) - done # nh + + com_var="COMIN_ATMOS_GRIB_${outres}" + infile1="${!com_var}/${RUN}.t${cyc}z.pres_a.${outres}.f${fnh}.grib2" + infile2="${!com_var}/${RUN}.t${cyc}z.pres_b.${outres}.f${fnh}.grib2" + outfile="${outdirpre}/${RUN}.t${cyc}z.pres_a.${outres}.f${fnh}.grib2" + rm -f "${outfile}" #remove outfile if it already exists before extraction + + for infile in "${infile1}" "${infile2}"; do + if [[ -f "${infile}" ]]; then # check if input file exists before extraction + new_infile="${outdirpre}/$(basename "${infile}")_ext" + if ! cpfs "${infile}" "${new_infile}"; then + echo "FATAL ERROR: Failed to copy ${infile} to ${new_infile}." + exit 1 + fi + # shellcheck disable=SC2312 + ${WGRIB2} "${new_infile}" | grep -F -f "${varlist}" | ${WGRIB2} -i "${new_infile}" -append -grib "${outfile}" + else + echo "WARNING: ${infile} does not exist in ${com_dir}." + fi + done + + check_atmos "${infile1}" "${infile2}" "${varlist}" "${fnh}" + copy_to_comout "${outfile}" "${ARC_RFCST_PROD_ATMOS}" + + # Compute daily average for a subset of variables + if ((nh % 6 == 0)) && ((nh != 0)) && [[ "${outtype}" == "f3d" ]]; then + outfile=${subdata}/vartmp_raw_vari_ldy${dcnt}.grib2 + for infile in "${infile1}" "${infile2}"; do + if [[ -f "${infile}" ]]; then # check if input file exists before extraction + new_infile="${outdirpre}/$(basename "${infile}")_ext" + if ! cpfs "${infile}" "${new_infile}"; then + echo "FATAL ERROR: Failed to copy ${infile} to ${new_infile}." + exit 1 + fi + # shellcheck disable=SC2312 + ${WGRIB2} "${new_infile}" | grep -F -f "${varlist_d}" | ${WGRIB2} -i "${new_infile}" -append -grib "${outfile}" + else + echo "WARNING: ${infile} does not exist in ${com_dir}." + fi + done + if [[ ${fcnt} -eq 4 ]]; then + daily_avg_atmos "${outfile}" "${dcnt}" "${outres}" + copy_to_comout "${davg_file}" "${ARC_RFCST_PROD_ATMOS}" + fcnt=1 + dcnt=$((dcnt + 1)) + else + fcnt=$((fcnt + 1)) + fi # If at final lead hour of a given day + fi # if lead hour is divisible by 6 and outtype is f3d + + nh=$((nh + outfreq)) + done # nh done # f2d,f3d diff --git a/ush/bash_utils.sh b/ush/bash_utils.sh index fc69a79131a..48007623351 100755 --- a/ush/bash_utils.sh +++ b/ush/bash_utils.sh @@ -42,14 +42,14 @@ function declare_from_tmpl() { while getopts "rx" option; do opts="${opts}${option}" done - shift $((OPTIND-1)) + shift $((OPTIND - 1)) for input in "$@"; do IFS=':' read -ra args <<< "${input}" local com_var="${args[0]}" local template local value - if (( ${#args[@]} > 1 )); then + if ((${#args[@]} > 1)); then template="${args[1]}" else template="${com_var}_TMPL" @@ -99,7 +99,7 @@ function wait_for_file() { local sleep_interval=${2:-60} local max_tries=${3:-100} - for (( iter=0; iter [use2mobs]" - echo " : conv, oz, or sat" - echo " : date string to match" - echo " : where to write the new GSI info files into" - echo " [use2mobs]: (optional, only for conv, whether to use 2m observations) YES or NO" - exit 1 + echo "Usage: ${0} [use2mobs]" + echo " : conv, oz, or sat" + echo " : date string to match" + echo " : where to write the new GSI info files into" + echo " [use2mobs]: (optional, only for conv, whether to use 2m observations) YES or NO" + exit 1 fi # Function to get the most recent data available for the target obs. # If an empty string is returned, this represents an error. # Assumes the variable date_in is set. get_usedate() { - usedate="" - # Loop over files matching date pattern. - for datex in [1-2][0-9][0-9][0-9]*; do - # Skip for loop if there are no matches. - if [[ ! -e "${datex}" ]]; then - continue - fi - - if [[ ${date_in} -ge ${datex} ]]; then - usedate=${datex} - fi - done - - echo "${usedate}" + usedate="" + # Loop over files matching date pattern. + for datex in [1-2][0-9][0-9][0-9]*; do + # Skip for loop if there are no matches. + if [[ ! -e "${datex}" ]]; then + continue + fi + + if [[ ${date_in} -ge ${datex} ]]; then + usedate=${datex} + fi + done + + echo "${usedate}" } # Get the starting directory @@ -52,88 +52,87 @@ cd "${build_dir}" || exit 1 # Get the list of satellites available if [[ "${type_in}" != "conv" ]]; then - if [[ ! -f satellites ]]; then - echo "FATAL ERROR: Satellite list file 'satellites' not found in ${build_dir}!" - exit 1 - fi + if [[ ! -f satellites ]]; then + echo "FATAL ERROR: Satellite list file 'satellites' not found in ${build_dir}!" + exit 1 + fi - satellite_list=$(grep -Ev '^ *#|readme' satellites) + satellite_list=$(grep -Ev '^ *#|readme' satellites) - if [[ -z "${satellite_list}" ]]; then - echo "FATAL ERROR: No satellites found in the satellite file list!" - exit 1 - fi + if [[ -z "${satellite_list}" ]]; then + echo "FATAL ERROR: No satellites found in the satellite file list!" + exit 1 + fi fi # Filename to write the info to info_file="${write_dir}/${type_in}info" if [[ -f "${info_file}" ]]; then - rm -f "${info_file}" + rm -f "${info_file}" fi # Function to cycle through the list of satellites (oz or sat) and build the info file. build_info_file() { - while IFS= read -r sat - do - usedate="" - # Check that the satellite directory exists - if [[ ! -d "${sat}" ]]; then - echo "FATAL ERROR: Directory ${sat} does not exist!" - exit 1 - fi - - cd "${sat}" || exit 1 - - usedate=$(get_usedate) - - cd "${build_dir}" || exit 1 - - if [[ ${usedate} != "" ]]; then - cat "${sat}/${usedate}" >> "${info_file}" - else - echo "FATAL ERROR: No valid satellite info was found for satellite target '${sat}'!" - exit 1 - fi - done <<< "${satellite_list}" + while IFS= read -r sat; do + usedate="" + # Check that the satellite directory exists + if [[ ! -d "${sat}" ]]; then + echo "FATAL ERROR: Directory ${sat} does not exist!" + exit 1 + fi + + cd "${sat}" || exit 1 + + usedate=$(get_usedate) + + cd "${build_dir}" || exit 1 + + if [[ ${usedate} != "" ]]; then + cat "${sat}/${usedate}" >> "${info_file}" + else + echo "FATAL ERROR: No valid satellite info was found for satellite target '${sat}'!" + exit 1 + fi + done <<< "${satellite_list}" } case "${type_in}" in - conv) - usedate=$(get_usedate) - if [[ ${usedate} != "" ]]; then - if [[ ${use2mobs} == "YES" ]]; then - # Turn on 2m t,q obs over land - sed -e "s/t 181 0 -1/t 181 0 1/g" \ - -e "s/t 187 0 -1/t 187 0 1/g" \ - -e "s/q 181 0 -1/q 181 0 1/g" \ - -e "s/q 187 0 -1/q 187 0 1/g" "${usedate}" >> "${info_file}" - else - cat "${usedate}" >> "${info_file}" - fi - else - echo "FATAL ERROR: No valid conventional info was found!" - exit 1 - fi - ;; - oz) - # Header lines - { - echo '! For mls data, pressure and obs errors are pulled from bufr, so not listed here' - echo '! sens/instr/sat lev use pressure gross obs b_oz pg_oz' - echo '! error error variational qc' - } >> "${info_file}" - build_info_file - ;; - - sat) - # Header line - echo '!sensor/instr/sat chan iuse error error_cld ermax var_b var_pg icld_det icloud iaerosol' >> "${info_file}" - build_info_file - ;; - *) - echo "FATAL ERROR: Unknown info file type: '${type_in}'. Must be one of: conv, oz, sat" - exit 2 - ;; + conv) + usedate=$(get_usedate) + if [[ ${usedate} != "" ]]; then + if [[ ${use2mobs} == "YES" ]]; then + # Turn on 2m t,q obs over land + sed -e "s/t 181 0 -1/t 181 0 1/g" \ + -e "s/t 187 0 -1/t 187 0 1/g" \ + -e "s/q 181 0 -1/q 181 0 1/g" \ + -e "s/q 187 0 -1/q 187 0 1/g" "${usedate}" >> "${info_file}" + else + cat "${usedate}" >> "${info_file}" + fi + else + echo "FATAL ERROR: No valid conventional info was found!" + exit 1 + fi + ;; + oz) + # Header lines + { + echo '! For mls data, pressure and obs errors are pulled from bufr, so not listed here' + echo '! sens/instr/sat lev use pressure gross obs b_oz pg_oz' + echo '! error error variational qc' + } >> "${info_file}" + build_info_file + ;; + + sat) + # Header line + echo '!sensor/instr/sat chan iuse error error_cld ermax var_b var_pg icld_det icloud iaerosol' >> "${info_file}" + build_info_file + ;; + *) + echo "FATAL ERROR: Unknown info file type: '${type_in}'. Must be one of: conv, oz, sat" + exit 2 + ;; esac # Return to starting directory diff --git a/ush/detect_machine.sh b/ush/detect_machine.sh index ee6c2c2c79b..070904eb683 100755 --- a/ush/detect_machine.sh +++ b/ush/detect_machine.sh @@ -16,49 +16,49 @@ fi # First detect w/ hostname case $(hostname -f) in - adecflow0[12].acorn.wcoss2.ncep.noaa.gov) MACHINE_ID=acorn ;; ### acorn - alogin0[12].acorn.wcoss2.ncep.noaa.gov) MACHINE_ID=acorn ;; ### acorn - clogin0[1-9].cactus.wcoss2.ncep.noaa.gov) MACHINE_ID=wcoss2 ;; ### cactus01-9 - clogin10.cactus.wcoss2.ncep.noaa.gov) MACHINE_ID=wcoss2 ;; ### cactus10 - dlogin0[1-9].dogwood.wcoss2.ncep.noaa.gov) MACHINE_ID=wcoss2 ;; ### dogwood01-9 - dlogin10.dogwood.wcoss2.ncep.noaa.gov) MACHINE_ID=wcoss2 ;; ### dogwood10 + adecflow0[12].acorn.wcoss2.ncep.noaa.gov) MACHINE_ID=acorn ;; ### acorn + alogin0[12].acorn.wcoss2.ncep.noaa.gov) MACHINE_ID=acorn ;; ### acorn + clogin0[1-9].cactus.wcoss2.ncep.noaa.gov) MACHINE_ID=wcoss2 ;; ### cactus01-9 + clogin10.cactus.wcoss2.ncep.noaa.gov) MACHINE_ID=wcoss2 ;; ### cactus10 + dlogin0[1-9].dogwood.wcoss2.ncep.noaa.gov) MACHINE_ID=wcoss2 ;; ### dogwood01-9 + dlogin10.dogwood.wcoss2.ncep.noaa.gov) MACHINE_ID=wcoss2 ;; ### dogwood10 - gaea5[1-8]) MACHINE_ID=gaeac5 ;; ### gaea51-58 - gaea5[1-8].ncrc.gov) MACHINE_ID=gaeac5 ;; ### gaea51-58 + gaea5[1-8]) MACHINE_ID=gaeac5 ;; ### gaea51-58 + gaea5[1-8].ncrc.gov) MACHINE_ID=gaeac5 ;; ### gaea51-58 - gaea6[1-8]) MACHINE_ID=gaeac6 ;; ### gaea61-68 - gaea6[1-8].ncrc.gov) MACHINE_ID=gaeac6 ;; ### gaea61-68 + gaea6[1-8]) MACHINE_ID=gaeac6 ;; ### gaea61-68 + gaea6[1-8].ncrc.gov) MACHINE_ID=gaeac6 ;; ### gaea61-68 - hfe0[1-9]) MACHINE_ID=hera ;; ### hera01-09 - hfe1[0-2]) MACHINE_ID=hera ;; ### hera10-12 - hecflow01) MACHINE_ID=hera ;; ### heraecflow01 + hfe0[1-9]) MACHINE_ID=hera ;; ### hera01-09 + hfe1[0-2]) MACHINE_ID=hera ;; ### hera10-12 + hecflow01) MACHINE_ID=hera ;; ### heraecflow01 - ufe0[1-9]) MACHINE_ID=ursa ;; ### ursa01-09 - ufe1[0-6]) MACHINE_ID=ursa ;; ### ursa10-16 - uecflow01) MACHINE_ID=ursa ;; ### ursaecflow01 + ufe0[1-9]) MACHINE_ID=ursa ;; ### ursa01-09 + ufe1[0-6]) MACHINE_ID=ursa ;; ### ursa10-16 + uecflow01) MACHINE_ID=ursa ;; ### ursaecflow01 - s4-submit.ssec.wisc.edu) MACHINE_ID=s4 ;; ### s4 + s4-submit.ssec.wisc.edu) MACHINE_ID=s4 ;; ### s4 - fe[1-8]) MACHINE_ID=jet ;; ### jet01-8 - tfe[12]) MACHINE_ID=jet ;; ### tjet1-2 + fe[1-8]) MACHINE_ID=jet ;; ### jet01-8 + tfe[12]) MACHINE_ID=jet ;; ### tjet1-2 - Orion-login-[1-4].HPC.MsState.Edu) MACHINE_ID=orion ;; ### orion1-4 + Orion-login-[1-4].HPC.MsState.Edu) MACHINE_ID=orion ;; ### orion1-4 - [Hh]ercules-login-[1-4].[Hh][Pp][Cc].[Mm]s[Ss]tate.[Ee]du) MACHINE_ID=hercules ;; ### hercules1-4 + [Hh]ercules-login-[1-4].[Hh][Pp][Cc].[Mm]s[Ss]tate.[Ee]du) MACHINE_ID=hercules ;; ### hercules1-4 - login[1-4].stampede2.tacc.utexas.edu) MACHINE_ID=stampede ;; ### stampede1-4 + login[1-4].stampede2.tacc.utexas.edu) MACHINE_ID=stampede ;; ### stampede1-4 - login0[1-2].expanse.sdsc.edu) MACHINE_ID=expanse ;; ### expanse1-2 + login0[1-2].expanse.sdsc.edu) MACHINE_ID=expanse ;; ### expanse1-2 - discover3[1-5].prv.cube) MACHINE_ID=discover ;; ### discover31-35 - *) MACHINE_ID=UNKNOWN ;; # Unknown platform + discover3[1-5].prv.cube) MACHINE_ID=discover ;; ### discover31-35 + *) MACHINE_ID=UNKNOWN ;; # Unknown platform esac if [[ ${MACHINE_ID} == "UNKNOWN" ]]; then - case ${PW_CSP:-} in - "aws" | "google" | "azure") MACHINE_ID=noaacloud ;; - *) PW_CSP="UNKNOWN" - esac + case ${PW_CSP:-} in + "aws" | "google" | "azure") MACHINE_ID=noaacloud ;; + *) PW_CSP="UNKNOWN" ;; + esac fi # Overwrite auto-detect with MACHINE if set @@ -66,50 +66,50 @@ MACHINE_ID=${MACHINE:-${MACHINE_ID}} # If MACHINE_ID is no longer UNKNNOWN, return it if [[ "${MACHINE_ID}" != "UNKNOWN" ]]; then - # TODO: make this read-only when UPP#1308 is addressed. - declare -x MACHINE_ID # Should be -rx, but the UPP system needs Gaea C6 to be ID'd as "gaea" - return + # TODO: make this read-only when UPP#1308 is addressed. + declare -x MACHINE_ID # Should be -rx, but the UPP system needs Gaea C6 to be ID'd as "gaea" + return fi # Try searching based on paths since hostname may not match on compute nodes if [[ -d /lfs/h3 ]]; then - # We are on NOAA Cactus or Dogwood - MACHINE_ID=wcoss2 + # We are on NOAA Cactus or Dogwood + MACHINE_ID=wcoss2 elif [[ -d /lfs/h1 && ! -d /lfs/h3 ]]; then - # We are on NOAA TDS Acorn - MACHINE_ID=acorn + # We are on NOAA TDS Acorn + MACHINE_ID=acorn elif [[ -d /mnt/lfs5 ]]; then - # We are on NOAA Jet - MACHINE_ID=jet + # We are on NOAA Jet + MACHINE_ID=jet elif [[ -d /scratch3 ]]; then - # We are on NOAA Hera or Ursa - mount=$(findmnt -n -o SOURCE /apps) || true # /home doesn't exist on the GitHub runners - if [[ ${mount} =~ "ursa" ]]; then - MACHINE_ID=ursa - elif [[ ${mount} =~ "hera" ]]; then - MACHINE_ID=hera - else # Assume we are on the GitHub runners, which mock Hera - MACHINE_ID=hera - fi + # We are on NOAA Hera or Ursa + mount=$(findmnt -n -o SOURCE /apps) || true # /home doesn't exist on the GitHub runners + if [[ ${mount} =~ "ursa" ]]; then + MACHINE_ID=ursa + elif [[ ${mount} =~ "hera" ]]; then + MACHINE_ID=hera + else # Assume we are on the GitHub runners, which mock Hera + MACHINE_ID=hera + fi elif [[ -d /work ]]; then - # We are on MSU Orion or Hercules - mount=$(findmnt -n -o SOURCE /home) - if [[ -n "${mount+0}" && ${mount} =~ "hercules" ]]; then - MACHINE_ID=hercules - else - MACHINE_ID=orion - fi + # We are on MSU Orion or Hercules + mount=$(findmnt -n -o SOURCE /home) + if [[ -n "${mount+0}" && ${mount} =~ "hercules" ]]; then + MACHINE_ID=hercules + else + MACHINE_ID=orion + fi elif [[ -d /gpfs/f5 ]]; then - # We are on GAEAC5. - MACHINE_ID=gaeac5 + # We are on GAEAC5. + MACHINE_ID=gaeac5 elif [[ -d /gpfs/f6 ]]; then - # We are on GAEAC6. - MACHINE_ID=gaeac6 + # We are on GAEAC6. + MACHINE_ID=gaeac6 elif [[ -d /data/prod ]]; then - # We are on SSEC's S4 - MACHINE_ID=s4 + # We are on SSEC's S4 + MACHINE_ID=s4 else - echo WARNING: UNKNOWN PLATFORM 1>&2 + echo WARNING: UNKNOWN PLATFORM 1>&2 fi # TODO: Make this read-only when UPP#1308 is addressed. -declare -x MACHINE_ID # Should be -rx, but the UPP system needs Gaea C6 to be ID'd as "gaea" +declare -x MACHINE_ID # Should be -rx, but the UPP system needs Gaea C6 to be ID'd as "gaea" diff --git a/ush/extractvars_tools.sh b/ush/extractvars_tools.sh index f351441fa53..fe7a4d34a43 100644 --- a/ush/extractvars_tools.sh +++ b/ush/extractvars_tools.sh @@ -1,59 +1,59 @@ #! /usr/bin/env bash check_atmos() { - # Function to check if there are any missing parm variables in any of the input product grib2 files - # A warning will be displayed if there is a parm variable that cannot be found in any of the given input product grib2 files - infile1p=$1 - infile2p=$2 - varlistl=$3 - fnhl=$4 - requestedvar_in_allgrb2file="${subdata}/parmvarsingribfil.txt" - rm -f "${requestedvar_in_allgrb2file}" - touch "${requestedvar_in_allgrb2file}" - for infilep in "${infile1p}" "${infile2p}"; do - # It is permitted for an empty string to return if no parmlist vars are in infilep, therefore do not return exit 1 error - # shellcheck disable=SC2312 - ${WGRIB2} "${infilep}" | grep -F -f "${varlist}" >> "${requestedvar_in_allgrb2file}" || true - done - mapfile -t requestedvar_in_allgrb2file_arr < "${requestedvar_in_allgrb2file}" - while read -r vari; do - # shellcheck disable=SC2076 - if [[ ! ${requestedvar_in_allgrb2file_arr[*]} =~ "${vari}" ]] ;then - echo "WARNING: PARM VARIABLE (${vari}) is not available in pgrb and pgrb2b for f${fnhl}." - fi - done <"${varlistl}" + # Function to check if there are any missing parm variables in any of the input product grib2 files + # A warning will be displayed if there is a parm variable that cannot be found in any of the given input product grib2 files + infile1p=$1 + infile2p=$2 + varlistl=$3 + fnhl=$4 + requestedvar_in_allgrb2file="${subdata}/parmvarsingribfil.txt" + rm -f "${requestedvar_in_allgrb2file}" + touch "${requestedvar_in_allgrb2file}" + for infilep in "${infile1p}" "${infile2p}"; do + # It is permitted for an empty string to return if no parmlist vars are in infilep, therefore do not return exit 1 error + # shellcheck disable=SC2312 + ${WGRIB2} "${infilep}" | grep -F -f "${varlist}" >> "${requestedvar_in_allgrb2file}" || true + done + mapfile -t requestedvar_in_allgrb2file_arr < "${requestedvar_in_allgrb2file}" + while read -r vari; do + # shellcheck disable=SC2076 + if [[ ! ${requestedvar_in_allgrb2file_arr[*]} =~ "${vari}" ]]; then + echo "WARNING: PARM VARIABLE (${vari}) is not available in pgrb and pgrb2b for f${fnhl}." + fi + done < "${varlistl}" } daily_avg_atmos() { - # Function to calculate the 24-hr average of a grib2 file with atmospheric fields - # The input grib2 file must contain all the time records to be averaged (e.g. 6hr, 12hr, 18hr and 24hr record in one grib2 file) - outfile_p=$1 - dcnt_p=$2 - outres_p=$3 - fnd=$(printf "%2.2d" "${dcnt_p}") - davg_file=${outdirpre}/${RUN}.t${cyc}z.pgrb2.${outres_p}.24hr_avg.ldy${fnd} - vcnt=1 #count variables in varlist_d - while read -r vari; do - davgtmp=${subdata}/atmos_tmp.ldy${fnd}.${vcnt} - # shellcheck disable=SC2312 - ${WGRIB2} "${outfile_p}" | grep "${vari}" | ${WGRIB2} -i "${outfile_p}" -fcst_ave 6hr "${davgtmp}" - # shellcheck disable=SC2312 - ${WGRIB2} "${davgtmp}" | ${WGRIB2} -i "${davgtmp}" -append -grib "${davg_file}" - rm -f "${davgtmp}" - vcnt=$(( vcnt + 1 )) - done <"${varlist_d}" # variable + # Function to calculate the 24-hr average of a grib2 file with atmospheric fields + # The input grib2 file must contain all the time records to be averaged (e.g. 6hr, 12hr, 18hr and 24hr record in one grib2 file) + outfile_p=$1 + dcnt_p=$2 + outres_p=$3 + fnd=$(printf "%2.2d" "${dcnt_p}") + davg_file=${outdirpre}/${RUN}.t${cyc}z.pgrb2.${outres_p}.24hr_avg.ldy${fnd} + vcnt=1 #count variables in varlist_d + while read -r vari; do + davgtmp=${subdata}/atmos_tmp.ldy${fnd}.${vcnt} + # shellcheck disable=SC2312 + ${WGRIB2} "${outfile_p}" | grep "${vari}" | ${WGRIB2} -i "${outfile_p}" -fcst_ave 6hr "${davgtmp}" + # shellcheck disable=SC2312 + ${WGRIB2} "${davgtmp}" | ${WGRIB2} -i "${davgtmp}" -append -grib "${davg_file}" + rm -f "${davgtmp}" + vcnt=$((vcnt + 1)) + done < "${varlist_d}" # variable } copy_to_comout() { - # Function to copy the output file with the extracted product variables to a user-defined destination directory - rundir_outfile=$1 # output data file generated in RUNDIR - comout_dir=$2 # destination directory to which to copy the data file - if [[ -f "${rundir_outfile}" ]]; then - cpfs "${rundir_outfile}" "${comout_dir}" - else - export err=1 - err_exit "Output file (${rundir_outfile}) does not exist." - fi + # Function to copy the output file with the extracted product variables to a user-defined destination directory + rundir_outfile=$1 # output data file generated in RUNDIR + comout_dir=$2 # destination directory to which to copy the data file + if [[ -f "${rundir_outfile}" ]]; then + cpfs "${rundir_outfile}" "${comout_dir}" + else + export err=1 + err_exit "Output file (${rundir_outfile}) does not exist." + fi } declare -xf check_atmos diff --git a/ush/forecast_det.sh b/ush/forecast_det.sh index cb7a3eac601..602e7d473fb 100755 --- a/ush/forecast_det.sh +++ b/ush/forecast_det.sh @@ -2,149 +2,149 @@ # Disable variable not used warnings # shellcheck disable=SC2034 -UFS_det(){ - echo "SUB ${FUNCNAME[0]}: Run type determination for UFS" - - # Determine if the current cycle is a warm start (based on the availability of restarts) - if [[ -f "${COMIN_ATMOS_RESTART_PREV}/${model_start_date_current_cycle:0:8}.${model_start_date_current_cycle:8:2}0000.coupler.res" ]]; then - warm_start=".true." - fi - - # If restarts were not available, this is likely a cold start - if [[ "${warm_start}" == ".false." ]]; then - - # Since restarts are not available from the previous cycle, this is likely a cold start - # Ensure cold start ICs are present when warm start is not set - # TODO: add checks for other cold start ICs as well - if [[ ! -f "${COMIN_ATMOS_INPUT}/gfs_ctrl.nc" ]]; then - echo "FATAL ERROR: Cold start ICs are missing from '${COMIN_ATMOS_INPUT}'" - exit 1 - fi +UFS_det() { + echo "SUB ${FUNCNAME[0]}: Run type determination for UFS" - # Since warm start is false, we cannot do IAU - DOIAU="NO" - IAU_OFFSET=0 - model_start_date_current_cycle=${current_cycle} - - DO_LAND_IAU=".false." - - # It is still possible that a restart is available from a previous forecast attempt - # So we have to continue checking for restarts - fi - - # Lets assume this is was not run before and hence this is not a RERUN - RERUN="NO" - - # RERUN is only available for RUN=gfs|gefs. It is not available for RUN=gdas|enkfgdas|enkfgfs - if [[ "${RUN}" =~ "gdas" ]] || [[ "${RUN}" == "enkfgfs" ]]; then - echo "RERUN is not available for RUN='${RUN}'" - return 0 - fi - - # However, if this was run before, a DATArestart/FV3_RESTART must exist with data in it. - local file_array nrestarts - # shellcheck disable=SC2312 - mapfile -t file_array < <(find "${DATArestart}/FV3_RESTART" -name "????????.??0000.coupler.res" | sort) - nrestarts=${#file_array[@]} - if [[ ${nrestarts} -eq 0 ]]; then - echo "No restarts found in '${DATArestart}/FV3_RESTART', RERUN='${RERUN}'" - return 0 - else - echo "Found ${nrestarts} restarts in '${DATArestart}/FV3_RESTART' to check for RERUN" - ls -1 "${DATArestart}/FV3_RESTART/"????????.??0000.coupler.res - fi - - # Look in reverse order of file_array to determine available restart times - local ii filepath filename - local rdate seconds - local fv3_rst_ok cmeps_rst_ok mom6_rst_ok cice6_rst_ok ww3_rst_ok - local hdate hdatep1 fhout_ocn_by_2 - for (( ii=nrestarts-1; ii>=0; ii-- )); do - - filepath="${file_array[ii]}" - filename=$(basename "${filepath}") # Strip path from YYYYMMDD.HH0000.coupler.res - rdate="${filename:0:8}${filename:9:2}" # match YYYYMMDD and HH of YYYYMMDD.HH0000.coupler.res - - # Assume all is well; all restarts are available - fv3_rst_ok="YES" - cmeps_rst_ok="YES" - mom6_rst_ok="YES" - cice6_rst_ok="YES" - ww3_rst_ok="YES" - - # Check for FV3 restart availability - if [[ ! -f "${DATArestart}/FV3_RESTART/${rdate:0:8}.${rdate:8:2}0000.coupler.res" ]]; then - # TODO: add checks for other FV3 restarts as well - fv3_rst_ok="NO" + # Determine if the current cycle is a warm start (based on the availability of restarts) + if [[ -f "${COMIN_ATMOS_RESTART_PREV}/${model_start_date_current_cycle:0:8}.${model_start_date_current_cycle:8:2}0000.coupler.res" ]]; then + warm_start=".true." fi - # Check for CMEPS and MOM6 restart availability - if [[ "${cplflx}" == ".true." ]]; then - seconds=$(to_seconds "${rdate:8:2}0000") - if [[ ! -f "${DATArestart}/CMEPS_RESTART/ufs.cpld.cpl.r.${rdate:0:4}-${rdate:4:2}-${rdate:6:2}-${seconds}.nc" ]]; then - cmeps_rst_ok="NO" - fi - # TODO: add checks for other MOM6 restarts as well - if [[ ! -f "${DATArestart}/MOM6_RESTART/${rdate:0:8}.${rdate:8:2}0000.MOM.res.nc" ]]; then - mom6_rst_ok="NO" - else - # Also check for MOM6 history file availability - # TODO: SFS runs with 24-hr averaging of ocean output, which causes issues with restart checks, - # TODO: so we will skip them for now, and revisit this logic later - if [[ ${FHOUT_OCN} -le 6 ]]; then - fhout_ocn_by_2=$((FHOUT_OCN / 2)) - hdate=$(date -u -d "${rdate:0:8} ${rdate:8:2} + ${fhout_ocn_by_2} hours" +"%Y%m%d%H") - if [[ ! -f "${DATAoutput}/MOM6_OUTPUT/ocn_${hdate:0:4}_${hdate:4:2}_${hdate:6:2}_${hdate:8:2}.nc" ]]; then - mom6_rst_ok="NO" - else - # Also check for the next MOM6 history file (hdate + FHOUT_OCN hours) - hdatep1=$(date -u -d "${hdate:0:8} ${hdate:8:2} + ${FHOUT_OCN} hours" +"%Y%m%d%H") - if [[ ! -f "${DATAoutput}/MOM6_OUTPUT/ocn_${hdatep1:0:4}_${hdatep1:4:2}_${hdatep1:6:2}_${hdatep1:8:2}.nc" ]]; then - mom6_rst_ok="NO" - fi - fi + # If restarts were not available, this is likely a cold start + if [[ "${warm_start}" == ".false." ]]; then + + # Since restarts are not available from the previous cycle, this is likely a cold start + # Ensure cold start ICs are present when warm start is not set + # TODO: add checks for other cold start ICs as well + if [[ ! -f "${COMIN_ATMOS_INPUT}/gfs_ctrl.nc" ]]; then + echo "FATAL ERROR: Cold start ICs are missing from '${COMIN_ATMOS_INPUT}'" + exit 1 fi - fi - MOM6_RESTART_SETTING='r' - MOM6_INIT_FROM_Z=True - MOM6_WARMSTART_FILE="none" - MOM6_INIT_UV="zero" - ODA_INCUPD="False" - fi - # Check for CICE6 restart availability - if [[ "${cplice}" == ".true." ]]; then - if [[ ! -f "${DATArestart}/CICE_RESTART/cice_model.res.${rdate:0:4}-${rdate:4:2}-${rdate:6:2}-${seconds}.nc" ]]; then - cice6_rst_ok="NO" - fi + # Since warm start is false, we cannot do IAU + DOIAU="NO" + IAU_OFFSET=0 + model_start_date_current_cycle=${current_cycle} + + DO_LAND_IAU=".false." + + # It is still possible that a restart is available from a previous forecast attempt + # So we have to continue checking for restarts fi - # Check for WW3 restart availability - if [[ "${cplwav}" == ".true." ]]; then - if [[ ! -f "${DATArestart}/WW3_RESTART/${rdate:0:8}.${rdate:8:2}0000.restart.ww3.nc" ]]; then - ww3_rst_ok="NO" - fi + # Lets assume this is was not run before and hence this is not a RERUN + RERUN="NO" + + # RERUN is only available for RUN=gfs|gefs. It is not available for RUN=gdas|enkfgdas|enkfgfs + if [[ "${RUN}" =~ "gdas" ]] || [[ "${RUN}" == "enkfgfs" ]]; then + echo "RERUN is not available for RUN='${RUN}'" + return 0 fi - # Collective check - if [[ "${fv3_rst_ok}" == "YES" ]] \ - && [[ "${cmeps_rst_ok}" == "YES" ]] \ - && [[ "${mom6_rst_ok}" == "YES" ]] \ - && [[ "${cice6_rst_ok}" == "YES" ]] \ - && [[ "${ww3_rst_ok}" == "YES" ]]; then - RERUN="YES" - RERUN_DATE="${rdate}" - - # Check if RERUN_DATE is at/after model end time; if so, this will cause the model to crash - if [[ ${RERUN_DATE} -ge ${forecast_end_cycle} ]]; then - echo "FATAL ERROR Warm start detected, but restart date (${RERUN_DATE}) is at/after model end date (${forecast_end_cycle})" - exit 1 - fi - - warm_start=".true." - echo "All restarts found for '${RERUN_DATE}', RERUN='${RERUN}', warm_start='${warm_start}'" - break + # However, if this was run before, a DATArestart/FV3_RESTART must exist with data in it. + local file_array nrestarts + # shellcheck disable=SC2312 + mapfile -t file_array < <(find "${DATArestart}/FV3_RESTART" -name "????????.??0000.coupler.res" | sort) + nrestarts=${#file_array[@]} + if [[ ${nrestarts} -eq 0 ]]; then + echo "No restarts found in '${DATArestart}/FV3_RESTART', RERUN='${RERUN}'" + return 0 + else + echo "Found ${nrestarts} restarts in '${DATArestart}/FV3_RESTART' to check for RERUN" + ls -1 "${DATArestart}/FV3_RESTART/"????????.??0000.coupler.res fi - done # loop over nrestarts + # Look in reverse order of file_array to determine available restart times + local ii filepath filename + local rdate seconds + local fv3_rst_ok cmeps_rst_ok mom6_rst_ok cice6_rst_ok ww3_rst_ok + local hdate hdatep1 fhout_ocn_by_2 + for ((ii = nrestarts - 1; ii >= 0; ii--)); do + + filepath="${file_array[ii]}" + filename=$(basename "${filepath}") # Strip path from YYYYMMDD.HH0000.coupler.res + rdate="${filename:0:8}${filename:9:2}" # match YYYYMMDD and HH of YYYYMMDD.HH0000.coupler.res + + # Assume all is well; all restarts are available + fv3_rst_ok="YES" + cmeps_rst_ok="YES" + mom6_rst_ok="YES" + cice6_rst_ok="YES" + ww3_rst_ok="YES" + + # Check for FV3 restart availability + if [[ ! -f "${DATArestart}/FV3_RESTART/${rdate:0:8}.${rdate:8:2}0000.coupler.res" ]]; then + # TODO: add checks for other FV3 restarts as well + fv3_rst_ok="NO" + fi + + # Check for CMEPS and MOM6 restart availability + if [[ "${cplflx}" == ".true." ]]; then + seconds=$(to_seconds "${rdate:8:2}0000") + if [[ ! -f "${DATArestart}/CMEPS_RESTART/ufs.cpld.cpl.r.${rdate:0:4}-${rdate:4:2}-${rdate:6:2}-${seconds}.nc" ]]; then + cmeps_rst_ok="NO" + fi + # TODO: add checks for other MOM6 restarts as well + if [[ ! -f "${DATArestart}/MOM6_RESTART/${rdate:0:8}.${rdate:8:2}0000.MOM.res.nc" ]]; then + mom6_rst_ok="NO" + else + # Also check for MOM6 history file availability + # TODO: SFS runs with 24-hr averaging of ocean output, which causes issues with restart checks, + # TODO: so we will skip them for now, and revisit this logic later + if [[ "${FHOUT_OCN}" -le 6 ]]; then + fhout_ocn_by_2=$((FHOUT_OCN / 2)) + hdate=$(date -u -d "${rdate:0:8} ${rdate:8:2} + ${fhout_ocn_by_2} hours" +"%Y%m%d%H") + if [[ ! -f "${DATAoutput}/MOM6_OUTPUT/ocn_${hdate:0:4}_${hdate:4:2}_${hdate:6:2}_${hdate:8:2}.nc" ]]; then + mom6_rst_ok="NO" + else + # Also check for the next MOM6 history file (hdate + FHOUT_OCN hours) + hdatep1=$(date -u -d "${hdate:0:8} ${hdate:8:2} + ${FHOUT_OCN} hours" +"%Y%m%d%H") + if [[ ! -f "${DATAoutput}/MOM6_OUTPUT/ocn_${hdatep1:0:4}_${hdatep1:4:2}_${hdatep1:6:2}_${hdatep1:8:2}.nc" ]]; then + mom6_rst_ok="NO" + fi + fi + fi + fi + MOM6_RESTART_SETTING='r' + MOM6_INIT_FROM_Z=True + MOM6_WARMSTART_FILE="none" + MOM6_INIT_UV="zero" + ODA_INCUPD="False" + fi + + # Check for CICE6 restart availability + if [[ "${cplice}" == ".true." ]]; then + if [[ ! -f "${DATArestart}/CICE_RESTART/cice_model.res.${rdate:0:4}-${rdate:4:2}-${rdate:6:2}-${seconds}.nc" ]]; then + cice6_rst_ok="NO" + fi + fi + + # Check for WW3 restart availability + if [[ "${cplwav}" == ".true." ]]; then + if [[ ! -f "${DATArestart}/WW3_RESTART/${rdate:0:8}.${rdate:8:2}0000.restart.ww3.nc" ]]; then + ww3_rst_ok="NO" + fi + fi + + # Collective check + if [[ "${fv3_rst_ok}" == "YES" ]] && + [[ "${cmeps_rst_ok}" == "YES" ]] && + [[ "${mom6_rst_ok}" == "YES" ]] && + [[ "${cice6_rst_ok}" == "YES" ]] && + [[ "${ww3_rst_ok}" == "YES" ]]; then + RERUN="YES" + RERUN_DATE="${rdate}" + + # Check if RERUN_DATE is at/after model end time; if so, this will cause the model to crash + if [[ "${RERUN_DATE}" -ge "${forecast_end_cycle}" ]]; then + echo "FATAL ERROR Warm start detected, but restart date (${RERUN_DATE}) is at/after model end date (${forecast_end_cycle})" + exit 1 + fi + + warm_start=".true." + echo "All restarts found for '${RERUN_DATE}', RERUN='${RERUN}', warm_start='${warm_start}'" + break + fi + + done # loop over nrestarts } diff --git a/ush/forecast_postdet.sh b/ush/forecast_postdet.sh index f4b9b9f47c6..aee9fe9bced 100755 --- a/ush/forecast_postdet.sh +++ b/ush/forecast_postdet.sh @@ -4,1025 +4,1021 @@ # shellcheck disable=SC2034 # shellcheck disable=SC2178 FV3_postdet() { - echo "SUB ${FUNCNAME[0]}: Entering for RUN = ${RUN}" - - echo "warm_start = ${warm_start}" - echo "RERUN = ${RERUN}" - - - #============================================================================ - # First copy initial conditions - # cold start case - if [[ "${warm_start}" == ".false." ]]; then - - # Get list of FV3 cold start files - local file_list - file_list=$(FV3_coldstarts) - echo "Copying FV3 cold start files for 'RUN=${RUN}' at '${current_cycle}' from '${COMIN_ATMOS_INPUT}'" - local fv3_file - for fv3_file in ${file_list}; do - cpreq "${COMIN_ATMOS_INPUT}/${fv3_file}" "${DATA}/INPUT/${fv3_file}" - done - - # warm start case - elif [[ "${warm_start}" == ".true." ]]; then - - # Determine restart date and directory containing restarts - local restart_date restart_dir - if [[ "${RERUN}" == "YES" ]]; then - restart_date="${RERUN_DATE}" - restart_dir="${DATArestart}/FV3_RESTART" - else # "${RERUN}" == "NO" - restart_date="${model_start_date_current_cycle}" - restart_dir="${COMIN_ATMOS_RESTART_PREV}" - fi + echo "SUB ${FUNCNAME[0]}: Entering for RUN = ${RUN}" + + echo "warm_start = ${warm_start}" + echo "RERUN = ${RERUN}" + + #============================================================================ + # First copy initial conditions + # cold start case + if [[ "${warm_start}" == ".false." ]]; then + + # Get list of FV3 cold start files + local file_list + file_list=$(FV3_coldstarts) + echo "Copying FV3 cold start files for 'RUN=${RUN}' at '${current_cycle}' from '${COMIN_ATMOS_INPUT}'" + local fv3_file + for fv3_file in ${file_list}; do + cpreq "${COMIN_ATMOS_INPUT}/${fv3_file}" "${DATA}/INPUT/${fv3_file}" + done - # Get list of FV3 restart files - local file_list - file_list=$(FV3_restarts) - echo "Copying FV3 restarts for 'RUN=${RUN}' at '${restart_date}' from '${restart_dir}'" - local fv3_file restart_file - for fv3_file in ${file_list}; do - restart_file="${restart_date:0:8}.${restart_date:8:2}0000.${fv3_file}" - cpreq "${restart_dir}/${restart_file}" "${DATA}/INPUT/${fv3_file}" - done + # warm start case + elif [[ "${warm_start}" == ".true." ]]; then + + # Determine restart date and directory containing restarts + local restart_date restart_dir + if [[ "${RERUN}" == "YES" ]]; then + restart_date="${RERUN_DATE}" + restart_dir="${DATArestart}/FV3_RESTART" + else # "${RERUN}" == "NO" + restart_date="${model_start_date_current_cycle}" + restart_dir="${COMIN_ATMOS_RESTART_PREV}" + fi - if [[ "${RERUN}" == "YES" ]]; then - if [[ "${DO_SPPT:-}" == "YES" || "${DO_SKEB:-}" == "YES" || \ - "${DO_SHUM:-}" == "YES" || "${DO_LAND_PERT:-}" == "YES" ]]; then - stochini=".true." - file_list=$(stoch_restarts) - echo "Copying stochastic restarts for 'RUN=${RUN}' at '${restart_date}' from '${restart_dir}'" - for stoch_file in $(stoch_restarts); do - restart_file="${restart_date:0:8}.${restart_date:8:2}0000.${stoch_file}" - cpreq "${restart_dir}/${restart_file}" "${DATA}/INPUT/${stoch_file}" + # Get list of FV3 restart files + local file_list + file_list=$(FV3_restarts) + echo "Copying FV3 restarts for 'RUN=${RUN}' at '${restart_date}' from '${restart_dir}'" + local fv3_file restart_file + for fv3_file in ${file_list}; do + restart_file="${restart_date:0:8}.${restart_date:8:2}0000.${fv3_file}" + cpreq "${restart_dir}/${restart_file}" "${DATA}/INPUT/${fv3_file}" done - fi - else - # Replace sfc_data with sfcanl_data restart files from current cycle (if found) - local nn - for (( nn = 1; nn <= ntiles; nn++ )); do - if [[ -f "${COMIN_ATMOS_RESTART}/${restart_date:0:8}.${restart_date:8:2}0000.sfcanl_data.tile${nn}.nc" ]]; then - rm -f "${DATA}/INPUT/sfc_data.tile${nn}.nc" - cpreq "${COMIN_ATMOS_RESTART}/${restart_date:0:8}.${restart_date:8:2}0000.sfcanl_data.tile${nn}.nc" \ - "${DATA}/INPUT/sfc_data.tile${nn}.nc" - # GCAFS does not run the sfcanl, only GCDAS - elif [[ ${DO_AERO_FCST} == "YES" && -f "${COMIN_TRACER_RESTART}/${restart_date:0:8}.${restart_date:8:2}0000.sfcanl_data.tile${nn}.nc" ]]; then - rm -f "${DATA}/INPUT/sfc_data.tile${nn}.nc" - cpreq "${COMIN_TRACER_RESTART}/${restart_date:0:8}.${restart_date:8:2}0000.sfcanl_data.tile${nn}.nc" \ - "${DATA}/INPUT/sfc_data.tile${nn}.nc" + + if [[ "${RERUN}" == "YES" ]]; then + if [[ "${DO_SPPT:-}" == "YES" || "${DO_SKEB:-}" == "YES" || + "${DO_SHUM:-}" == "YES" || "${DO_LAND_PERT:-}" == "YES" ]]; then + stochini=".true." + file_list=$(stoch_restarts) + echo "Copying stochastic restarts for 'RUN=${RUN}' at '${restart_date}' from '${restart_dir}'" + for stoch_file in $(stoch_restarts); do + restart_file="${restart_date:0:8}.${restart_date:8:2}0000.${stoch_file}" + cpreq "${restart_dir}/${restart_file}" "${DATA}/INPUT/${stoch_file}" + done + fi else - echo "'sfcanl_data.tile1.nc' not found in '${COMIN_ATMOS_RESTART}', using 'sfc_data.tile1.nc'" - break + # Replace sfc_data with sfcanl_data restart files from current cycle (if found) + local nn + for ((nn = 1; nn <= ntiles; nn++)); do + if [[ -f "${COMIN_ATMOS_RESTART}/${restart_date:0:8}.${restart_date:8:2}0000.sfcanl_data.tile${nn}.nc" ]]; then + rm -f "${DATA}/INPUT/sfc_data.tile${nn}.nc" + cpreq "${COMIN_ATMOS_RESTART}/${restart_date:0:8}.${restart_date:8:2}0000.sfcanl_data.tile${nn}.nc" \ + "${DATA}/INPUT/sfc_data.tile${nn}.nc" + # GCAFS does not run the sfcanl, only GCDAS + elif [[ ${DO_AERO_FCST} == "YES" && -f "${COMIN_TRACER_RESTART}/${restart_date:0:8}.${restart_date:8:2}0000.sfcanl_data.tile${nn}.nc" ]]; then + rm -f "${DATA}/INPUT/sfc_data.tile${nn}.nc" + cpreq "${COMIN_TRACER_RESTART}/${restart_date:0:8}.${restart_date:8:2}0000.sfcanl_data.tile${nn}.nc" \ + "${DATA}/INPUT/sfc_data.tile${nn}.nc" + else + echo "'sfcanl_data.tile1.nc' not found in '${COMIN_ATMOS_RESTART}', using 'sfc_data.tile1.nc'" + break + fi + done + + # If aerosol analysis is to be done, replace fv_tracer with aeroanl_fv_tracer + # restart files from current cycle (if found) + if [[ "${DO_AERO_FCST}" == "YES" ]]; then + local nn + local use_anl_aero="YES" + for ((nn = 1; nn <= ntiles; nn++)); do + test_tracer_file="${COMIN_TRACER_RESTART}/${restart_date:0:8}.${restart_date:8:2}0000.aeroanl_fv_tracer.res.tile${nn}.nc" + if [[ ! -f "${test_tracer_file}" ]]; then + use_anl_aero="NO" + echo "WARNING: File ${test_tracer_file} does not exist, will not replace any files from the aerosol analysis" + break + fi + done + if [[ "${use_anl_aero}" == "YES" ]]; then + for ((nn = 1; nn <= ntiles; nn++)); do + rm -f "${DATA}/INPUT/fv_tracer.res.tile${nn}.nc" + cpreq "${COMIN_TRACER_RESTART}/${restart_date:0:8}.${restart_date:8:2}0000.aeroanl_fv_tracer.res.tile${nn}.nc" \ + "${DATA}/INPUT/fv_tracer.res.tile${nn}.nc" + done + fi # if [[ ${use_anl_aero} == "YES" ]]; then + + fi # [[ ${DO_AERO_FCST} == "YES" ]]; then + + fi # if [[ "${RERUN}" == "YES" ]]; then + + fi # if [[ "${warm_start}" == ".true." ]]; then + + # Regardless of warm_start or not, the sfc_data and orography files should be consistent + # Check for consistency + # TODO: the checker has a --fatal option, which is not used here. This needs to be decided how to handle. + if [[ "${CHECK_LAND_RESTART_OROG:-NO}" == "YES" ]]; then + "${USHgfs}/check_land_input_orography.py" \ + --input_dir "${DATA}/INPUT" --orog_dir "${DATA}/INPUT" + err=$? + if [[ ${err} -ne 0 ]]; then + echo "FATAL ERROR: check_land_input_orography.py returned error code ${err}, ABORT!" + exit "${err}" fi - done - - # If aerosol analysis is to be done, replace fv_tracer with aeroanl_fv_tracer - # restart files from current cycle (if found) - if [[ "${DO_AERO_FCST}" == "YES" ]]; then - local nn - local use_anl_aero="YES" - for (( nn = 1; nn <= ntiles; nn++ )); do - test_tracer_file="${COMIN_TRACER_RESTART}/${restart_date:0:8}.${restart_date:8:2}0000.aeroanl_fv_tracer.res.tile${nn}.nc" - if [[ ! -f "${test_tracer_file}" ]]; then - use_anl_aero="NO" - echo "WARNING: File ${test_tracer_file} does not exist, will not replace any files from the aerosol analysis" - break - fi - done - if [[ "${use_anl_aero}" == "YES" ]]; then - for (( nn = 1; nn <= ntiles; nn++ )); do - rm -f "${DATA}/INPUT/fv_tracer.res.tile${nn}.nc" - cpreq "${COMIN_TRACER_RESTART}/${restart_date:0:8}.${restart_date:8:2}0000.aeroanl_fv_tracer.res.tile${nn}.nc" \ - "${DATA}/INPUT/fv_tracer.res.tile${nn}.nc" - done - fi # if [[ ${use_anl_aero} == "YES" ]]; then - - fi # [[ ${DO_AERO_FCST} == "YES" ]]; then - - fi # if [[ "${RERUN}" == "YES" ]]; then - - fi # if [[ "${warm_start}" == ".true." ]]; then - - # Regardless of warm_start or not, the sfc_data and orography files should be consistent - # Check for consistency - # TODO: the checker has a --fatal option, which is not used here. This needs to be decided how to handle. - if [[ "${CHECK_LAND_RESTART_OROG:-NO}" == "YES" ]]; then - "${USHgfs}/check_land_input_orography.py" \ - --input_dir "${DATA}/INPUT" --orog_dir "${DATA}/INPUT" - err=$? - if [[ ${err} -ne 0 ]]; then - echo "FATAL ERROR: check_land_input_orography.py returned error code ${err}, ABORT!" - exit "${err}" - fi - fi - - #============================================================================ - # Determine increment files when doing cold start - if [[ "${warm_start}" == ".false." ]]; then - - if [[ "${USE_ATM_ENS_PERTURB_FILES:-NO}" == "YES" ]]; then - if (( MEMBER == 0 )); then - inc_files=() - else - inc_files=("increment.atm.i006.nc") - read_increment=".true." - res_latlon_dynamics="increment.atm.i006.nc" - fi - increment_file_on_native_grid=".false." - local increment_file - for inc_file in "${inc_files[@]}"; do - increment_file="${COMIN_ATMOS_ANALYSIS}/${RUN}.t${cyc}z.${inc_file}" - cpreq "${increment_file}" "${DATA}/INPUT/${inc_file}" - done fi - # Determine IAU and increment files when doing warm start - elif [[ "${warm_start}" == ".true." ]]; then + #============================================================================ + # Determine increment files when doing cold start + if [[ "${warm_start}" == ".false." ]]; then - #-------------------------------------------------------------------------- - if [[ "${RERUN}" == "YES" ]]; then + if [[ "${USE_ATM_ENS_PERTURB_FILES:-NO}" == "YES" ]]; then + if ((MEMBER == 0)); then + inc_files=() + else + inc_files=("increment.atm.i006.nc") + read_increment=".true." + res_latlon_dynamics="increment.atm.i006.nc" + fi + increment_file_on_native_grid=".false." + local increment_file + for inc_file in "${inc_files[@]}"; do + increment_file="${COMIN_ATMOS_ANALYSIS}/${RUN}.t${cyc}z.${inc_file}" + cpreq "${increment_file}" "${DATA}/INPUT/${inc_file}" + done + fi - local restart_fhr - restart_fhr=$(nhour "${RERUN_DATE}" "${current_cycle}") - IAU_FHROT=$((IAU_OFFSET + restart_fhr)) - if [[ "${DOIAU}" == "YES" ]]; then - IAUFHRS=-1 - IAU_DELTHRS=0 - IAU_INC_FILES="''" - fi - DO_LAND_IAU=".false." - #-------------------------------------------------------------------------- - else # "${RERUN}" == "NO" - - # Need a coupler.res that is consistent with the model start time - if [[ "${DOIAU:-NO}" == "YES" ]]; then - local model_start_time="${previous_cycle}" - else - local model_start_time="${current_cycle}" - fi - local model_current_time="${model_start_date_current_cycle}" - rm -f "${DATA}/INPUT/coupler.res" - cat >> "${DATA}/INPUT/coupler.res" << EOF + # Determine IAU and increment files when doing warm start + elif [[ "${warm_start}" == ".true." ]]; then + + #-------------------------------------------------------------------------- + if [[ "${RERUN}" == "YES" ]]; then + + local restart_fhr + restart_fhr=$(nhour "${RERUN_DATE}" "${current_cycle}") + IAU_FHROT=$((IAU_OFFSET + restart_fhr)) + if [[ "${DOIAU}" == "YES" ]]; then + IAUFHRS=-1 + IAU_DELTHRS=0 + IAU_INC_FILES="''" + fi + DO_LAND_IAU=".false." + #-------------------------------------------------------------------------- + else # "${RERUN}" == "NO" + + # Need a coupler.res that is consistent with the model start time + if [[ "${DOIAU:-NO}" == "YES" ]]; then + local model_start_time="${previous_cycle}" + else + local model_start_time="${current_cycle}" + fi + local model_current_time="${model_start_date_current_cycle}" + rm -f "${DATA}/INPUT/coupler.res" + cat >> "${DATA}/INPUT/coupler.res" << EOF 3 (Calendar: no_calendar=0, thirty_day_months=1, julian=2, gregorian=3, noleap=4) ${model_start_time:0:4} ${model_start_time:4:2} ${model_start_time:6:2} ${model_start_time:8:2} 0 0 Model start time: year, month, day, hour, minute, second ${model_current_time:0:4} ${model_current_time:4:2} ${model_current_time:6:2} ${model_current_time:8:2} 0 0 Current model time: year, month, day, hour, minute, second EOF - # Create a array of increment files - local inc_files inc_file iaufhrs iaufhr - if [[ "${DOIAU}" == "YES" ]]; then - # create an array of inc_files for each IAU hour - IFS=',' read -ra iaufhrs <<< "${IAUFHRS}" - inc_files=() - delimiter="" - IAU_INC_FILES="" - for iaufhr in "${iaufhrs[@]}"; do - if [[ "${DO_JEDIATMVAR:-NO}" == "YES" ]]; then - for tile in {1..6}; do - inc_file="jedi_increment.atm.i$(printf %03i "${iaufhr}").tile${tile}.nc" - inc_files+=("${inc_file}") - IAU_INC_FILES="${IAU_INC_FILES}${delimiter}'${inc_file}'" + # Create a array of increment files + local inc_files inc_file iaufhrs iaufhr + if [[ "${DOIAU}" == "YES" ]]; then + # create an array of inc_files for each IAU hour + IFS=',' read -ra iaufhrs <<< "${IAUFHRS}" + inc_files=() + delimiter="" + IAU_INC_FILES="" + for iaufhr in "${iaufhrs[@]}"; do + if [[ "${DO_JEDIATMVAR:-NO}" == "YES" ]]; then + for tile in {1..6}; do + inc_file="jedi_increment.atm.i$(printf %03i "${iaufhr}").tile${tile}.nc" + inc_files+=("${inc_file}") + IAU_INC_FILES="${IAU_INC_FILES}${delimiter}'${inc_file}'" + done + else + inc_file="increment.atm.i$(printf %03i "${iaufhr}").nc" + inc_files+=("${inc_file}") + IAU_INC_FILES="${IAU_INC_FILES}${delimiter}'${inc_file}'" + fi + + delimiter="," + done + else # "${DOIAU}" == "NO" + read_increment=".true." + + if [[ "${DO_JEDIATMVAR:-NO}" == "YES" ]]; then + inc_files=("jedi_increment.atm.i006.tile1.nc" "jedi_increment.atm.i006.tile2.nc" "jedi_increment.atm.i006.tile3.nc" "jedi_increment.atm.i006.tile4.nc" "jedi_increment.atm.i006.tile5.nc" "jedi_increment.atm.i006.tile6.nc") + increment_file_on_native_grid=".true." + res_latlon_dynamics="jedi_increment.atm.i006" + if [[ "${DO_JEDIATMENS:-NO}" == "NO" ]]; then + inc_files=("increment.atm.i006.nc") + res_latlon_dynamics="increment.atm.i006.nc" + increment_file_on_native_grid=".false." + fi + else + inc_files=("increment.atm.i006.nc") + res_latlon_dynamics="increment.atm.i006.nc" + increment_file_on_native_grid=".false." + fi + if [[ "${USE_ATM_ENS_PERTURB_FILES:-NO}" == "YES" ]]; then + # Control member has no perturbation + if ((MEMBER == 0)); then + inc_files=() + read_increment=".false." + res_latlon_dynamics='""' + fi + fi + fi + + if [[ "${RUN}" == "enkfgfs" ]] || [[ "${RUN}" == "enkfgdas" ]]; then + prefix_atminc="recentered_" + else + prefix_atminc="" + fi + + local increment_file + for inc_file in "${inc_files[@]}"; do + if [[ "${DO_JEDIATMVAR:-NO}" == "YES" ]]; then + increment_file="${COMIN_ATMOS_ANALYSIS}/${RUN}.t${cyc}z.${prefix_atminc}${inc_file}" + if [[ "${DO_JEDIATMENS:-NO}" == "NO" ]]; then + increment_file="${COMIN_ATMOS_ANALYSIS}/${RUN}.t${cyc}z.${prefix_atminc}${inc_file}" + fi + else + if [[ "${RUN}" == "gcafs" ]]; then + increment_file="${COMIN_ATMOS_ANALYSIS}/gcdas.t${cyc}z.${prefix_atminc}${inc_file}" + else + increment_file="${COMIN_ATMOS_ANALYSIS}/${RUN}.t${cyc}z.${prefix_atminc}${inc_file}" + fi + fi + cpreq "${increment_file}" "${DATA}/INPUT/${inc_file}" done - else - inc_file="increment.atm.i$(printf %03i "${iaufhr}").nc" - inc_files+=("${inc_file}") - IAU_INC_FILES="${IAU_INC_FILES}${delimiter}'${inc_file}'" - fi - delimiter="," - done - else # "${DOIAU}" == "NO" - read_increment=".true." - - if [[ "${DO_JEDIATMVAR:-NO}" == "YES" ]]; then - inc_files=("jedi_increment.atm.i006.tile1.nc" "jedi_increment.atm.i006.tile2.nc" "jedi_increment.atm.i006.tile3.nc" "jedi_increment.atm.i006.tile4.nc" "jedi_increment.atm.i006.tile5.nc" "jedi_increment.atm.i006.tile6.nc") - increment_file_on_native_grid=".true." - res_latlon_dynamics="jedi_increment.atm.i006" - if [[ "${DO_JEDIATMENS:-NO}" == "NO" ]]; then - inc_files=("increment.atm.i006.nc") - res_latlon_dynamics="increment.atm.i006.nc" - increment_file_on_native_grid=".false." - fi - else - inc_files=("increment.atm.i006.nc") - res_latlon_dynamics="increment.atm.i006.nc" - increment_file_on_native_grid=".false." - fi - if [[ "${USE_ATM_ENS_PERTURB_FILES:-NO}" == "YES" ]]; then - # Control member has no perturbation - if (( MEMBER == 0 )); then - inc_files=() - read_increment=".false." - res_latlon_dynamics='""' - fi - fi - fi - - if [[ "${RUN}" = "enkfgfs" ]] || [[ "${RUN}" = "enkfgdas" ]]; then - prefix_atminc="recentered_" - else - prefix_atminc="" - fi - - local increment_file - for inc_file in "${inc_files[@]}"; do - if [[ "${DO_JEDIATMVAR:-NO}" == "YES" ]]; then - increment_file="${COMIN_ATMOS_ANALYSIS}/${RUN}.t${cyc}z.${prefix_atminc}${inc_file}" - if [[ "${DO_JEDIATMENS:-NO}" == "NO" ]]; then - increment_file="${COMIN_ATMOS_ANALYSIS}/${RUN}.t${cyc}z.${prefix_atminc}${inc_file}" - fi - else - if [[ "${RUN}" == "gcafs" ]]; then - increment_file="${COMIN_ATMOS_ANALYSIS}/gcdas.t${cyc}z.${prefix_atminc}${inc_file}" - else - increment_file="${COMIN_ATMOS_ANALYSIS}/${RUN}.t${cyc}z.${prefix_atminc}${inc_file}" - fi + # Land IAU increments: sfc_inc in FV3 grid, all timesteps in one file per tile + if [[ ${DO_LAND_IAU} == ".true." ]]; then + local TN sfc_increment_file + for TN in $(seq 1 "${ntiles}"); do + sfc_increment_file="${COMIN_ATMOS_ANALYSIS}/increment.sfc.tile${TN}.nc" + if [[ ! -f "${sfc_increment_file}" ]]; then + export err=1 + err_exit "FATAL ERROR: DO_LAND_IAU=${DO_LAND_IAU}, but missing increment file ${sfc_increment_file}, ABORT!" + else + cpreq "${sfc_increment_file}" "${DATA}/INPUT/sfc_inc.tile${TN}.nc" + fi + done + fi + fi # if [[ "${RERUN}" == "YES" ]]; then + #-------------------------------------------------------------------------- + fi # if [[ "${warm_start}" == ".true." ]]; then + #============================================================================ + + #============================================================================ + # If doing IAU, change forecast hours + if [[ "${DOIAU:-NO}" == "YES" ]]; then + FHMAX=$((FHMAX + 6)) + if [[ ${FHMAX_HF} -gt 0 ]]; then + FHMAX_HF=$((FHMAX_HF + 6)) fi - cpreq "${increment_file}" "${DATA}/INPUT/${inc_file}" - done - - # Land IAU increments: sfc_inc in FV3 grid, all timesteps in one file per tile - if [[ ${DO_LAND_IAU} = ".true." ]]; then - local TN sfc_increment_file - for TN in $(seq 1 "${ntiles}"); do - sfc_increment_file="${COMIN_ATMOS_ANALYSIS}/increment.sfc.tile${TN}.nc" - if [[ ! -f "${sfc_increment_file}" ]]; then - echo "FATAL ERROR: DO_LAND_IAU=${DO_LAND_IAU}, but missing increment file ${sfc_increment_file}, ABORT!" - exit 1 - else - cpreq "${sfc_increment_file}" "${DATA}/INPUT/sfc_inc.tile${TN}.nc" - fi - done + fi + #============================================================================ - fi + #============================================================================ + # If warm starting from restart files, set the following flags + if [[ "${warm_start}" == ".true." ]]; then - fi # if [[ "${RERUN}" == "YES" ]]; then - #-------------------------------------------------------------------------- + # start from restart file + nggps_ic=".false." + ncep_ic=".false." + external_ic=".false." + mountain=".true." - fi # if [[ "${warm_start}" == ".true." ]]; then - #============================================================================ + # restarts contain non-hydrostatic state + if [[ "${TYPE}" == "nh" ]]; then + make_nh=".false." + fi - #============================================================================ - # If doing IAU, change forecast hours - if [[ "${DOIAU:-NO}" == "YES" ]]; then - FHMAX=$((FHMAX + 6)) - if (( FHMAX_HF > 0 )); then - FHMAX_HF=$((FHMAX_HF + 6)) - fi - fi - #============================================================================ - - #============================================================================ - # If warm starting from restart files, set the following flags - if [[ "${warm_start}" == ".true." ]]; then - - # start from restart file - nggps_ic=".false." - ncep_ic=".false." - external_ic=".false." - mountain=".true." - - # restarts contain non-hydrostatic state - if [[ "${TYPE}" == "nh" ]]; then - make_nh=".false." + # do not pre-condition the solution + na_init=0 + + fi # warm_start == .true. + #============================================================================ + + #============================================================================ + if [[ "${QUILTING}" == ".true." ]] && [[ "${OUTPUT_GRID}" == "gaussian_grid" ]]; then + local FH2 FH3 + for fhr in ${FV3_OUTPUT_FH}; do + FH3=$(printf %03i "${fhr}") + FH2=$(printf %02i "${fhr}") + ${NLN} "${COMOUT_ATMOS_HISTORY}/${RUN}.t${cyc}z.atm.f${FH3}.nc" "${DATAoutput}/FV3ATM_OUTPUT/atmf${FH3}.nc" + ${NLN} "${COMOUT_ATMOS_HISTORY}/${RUN}.t${cyc}z.sfc.f${FH3}.nc" "${DATAoutput}/FV3ATM_OUTPUT/sfcf${FH3}.nc" + ${NLN} "${COMOUT_ATMOS_HISTORY}/${RUN}.t${cyc}z.log.f${FH3}.txt" "${DATAoutput}/FV3ATM_OUTPUT/log.atm.f${FH3}" + if [[ "${DO_JEDIATMVAR:-}" == "YES" || "${DO_HISTORY_FILE_ON_NATIVE_GRID:-"NO"}" == "YES" ]]; then + ${NLN} "${COMOUT_ATMOS_HISTORY}/${RUN}.t${cyc}z.csg_atm.f${FH3}.nc" "${DATAoutput}/FV3ATM_OUTPUT/cubed_sphere_grid_atmf${FH3}.nc" + ${NLN} "${COMOUT_ATMOS_HISTORY}/${RUN}.t${cyc}z.csg_sfc.f${FH3}.nc" "${DATAoutput}/FV3ATM_OUTPUT/cubed_sphere_grid_sfcf${FH3}.nc" + fi + if [[ "${WRITE_DOPOST}" == ".true." ]]; then + ${NLN} "${COMOUT_ATMOS_MASTER}/${RUN}.t${cyc}z.master.f${FH3}.grib2" "${DATAoutput}/FV3ATM_OUTPUT/GFSPRS.GrbF${FH2}" + ${NLN} "${COMOUT_ATMOS_MASTER}/${RUN}.t${cyc}z.sflux.f${FH3}.grib2" "${DATAoutput}/FV3ATM_OUTPUT/GFSFLX.GrbF${FH2}" + if [[ "${DO_NEST:-NO}" == "YES" ]]; then + ${NLN} "${COMOUT_ATMOS_MASTER}/${RUN}.t${cyc}z.master.nest.f${FH3}.grib2" "${DATAoutput}/FV3ATM_OUTPUT/GFSPRS.GrbF${FH2}.nest02" + ${NLN} "${COMOUT_ATMOS_MASTER}/${RUN}.t${cyc}z.sflux.nest.f${FH3}.grib2" "${DATAoutput}/FV3ATM_OUTPUT/GFSFLX.GrbF${FH2}.nest02" + fi + fi + done fi - - # do not pre-condition the solution - na_init=0 - - fi # warm_start == .true. - #============================================================================ - - #============================================================================ - if [[ "${QUILTING}" = ".true." ]] && [[ "${OUTPUT_GRID}" = "gaussian_grid" ]]; then - local FH2 FH3 - for fhr in ${FV3_OUTPUT_FH}; do - FH3=$(printf %03i "${fhr}") - FH2=$(printf %02i "${fhr}") - ${NLN} "${COMOUT_ATMOS_HISTORY}/${RUN}.t${cyc}z.atm.f${FH3}.nc" "${DATAoutput}/FV3ATM_OUTPUT/atmf${FH3}.nc" - ${NLN} "${COMOUT_ATMOS_HISTORY}/${RUN}.t${cyc}z.sfc.f${FH3}.nc" "${DATAoutput}/FV3ATM_OUTPUT/sfcf${FH3}.nc" - ${NLN} "${COMOUT_ATMOS_HISTORY}/${RUN}.t${cyc}z.log.f${FH3}.txt" "${DATAoutput}/FV3ATM_OUTPUT/log.atm.f${FH3}" - if [[ "${DO_JEDIATMVAR:-}" == "YES" || "${DO_HISTORY_FILE_ON_NATIVE_GRID:-"NO"}" == "YES" ]]; then - ${NLN} "${COMOUT_ATMOS_HISTORY}/${RUN}.t${cyc}z.csg_atm.f${FH3}.nc" "${DATAoutput}/FV3ATM_OUTPUT/cubed_sphere_grid_atmf${FH3}.nc" - ${NLN} "${COMOUT_ATMOS_HISTORY}/${RUN}.t${cyc}z.csg_sfc.f${FH3}.nc" "${DATAoutput}/FV3ATM_OUTPUT/cubed_sphere_grid_sfcf${FH3}.nc" - fi - if [[ "${WRITE_DOPOST}" == ".true." ]]; then - ${NLN} "${COMOUT_ATMOS_MASTER}/${RUN}.t${cyc}z.master.f${FH3}.grib2" "${DATAoutput}/FV3ATM_OUTPUT/GFSPRS.GrbF${FH2}" - ${NLN} "${COMOUT_ATMOS_MASTER}/${RUN}.t${cyc}z.sflux.f${FH3}.grib2" "${DATAoutput}/FV3ATM_OUTPUT/GFSFLX.GrbF${FH2}" - if [[ "${DO_NEST:-NO}" == "YES" ]]; then - ${NLN} "${COMOUT_ATMOS_MASTER}/${RUN}.t${cyc}z.master.nest.f${FH3}.grib2" "${DATAoutput}/FV3ATM_OUTPUT/GFSPRS.GrbF${FH2}.nest02" - ${NLN} "${COMOUT_ATMOS_MASTER}/${RUN}.t${cyc}z.sflux.nest.f${FH3}.grib2" "${DATAoutput}/FV3ATM_OUTPUT/GFSFLX.GrbF${FH2}.nest02" + #============================================================================ + restart_interval=${restart_interval:-${FHMAX}} + # restart_interval = 0 implies write restart at the END of the forecast i.e. at FHMAX + # Convert restart interval into an explicit list for CMEPS/CICE/MOM6/WW3 + # Note, this must be computed after determination IAU in forecast_det and fhrot. + if [[ ${restart_interval} -eq 0 ]]; then + if [[ "${DOIAU:-NO}" == "YES" ]]; then + FV3_RESTART_FH=$((FHMAX + assim_freq)) + else + FV3_RESTART_FH=("${FHMAX}") fi - fi - done - fi - #============================================================================ - restart_interval=${restart_interval:-${FHMAX}} - # restart_interval = 0 implies write restart at the END of the forecast i.e. at FHMAX - # Convert restart interval into an explicit list for CMEPS/CICE/MOM6/WW3 - # Note, this must be computed after determination IAU in forecast_det and fhrot. - if (( restart_interval == 0 )); then - if [[ "${DOIAU:-NO}" == "YES" ]]; then - FV3_RESTART_FH=$(( FHMAX + assim_freq )) - else - FV3_RESTART_FH=("${FHMAX}") - fi - else - if [[ "${DOIAU:-NO}" == "YES" ]]; then - if [[ "${MODE}" = "cycled" && "${SDATE}" = "${PDY}${cyc}" && ${EXP_WARM_START} = ".false." ]]; then - local restart_interval_start=${restart_interval} - local restart_interval_end=${FHMAX} - else - local restart_interval_start=$(( restart_interval + assim_freq )) - local restart_interval_end=$(( FHMAX + assim_freq )) - fi else - local restart_interval_start=${restart_interval} - local restart_interval_end=${FHMAX} + if [[ "${DOIAU:-NO}" == "YES" ]]; then + if [[ "${MODE}" = "cycled" && "${SDATE}" = "${PDY}${cyc}" && ${EXP_WARM_START} = ".false." ]]; then + local restart_interval_start=${restart_interval} + local restart_interval_end=${FHMAX} + else + local restart_interval_start=$((restart_interval + assim_freq)) + local restart_interval_end=$((FHMAX + assim_freq)) + fi + else + local restart_interval_start=${restart_interval} + local restart_interval_end=${FHMAX} + fi + FV3_RESTART_FH="$(seq -s ' ' "${restart_interval_start}" "${restart_interval}" "${restart_interval_end}")" fi - FV3_RESTART_FH="$(seq -s ' ' "${restart_interval_start}" "${restart_interval}" "${restart_interval_end}")" - fi - export FV3_RESTART_FH - #============================================================================ + export FV3_RESTART_FH + #============================================================================ } FV3_nml() { - # namelist output for a certain component - echo "SUB ${FUNCNAME[0]}: Creating name lists and model configure file for FV3" - - source "${USHgfs}/parsing_namelists_FV3.sh" - source "${USHgfs}/parsing_model_configure_FV3.sh" - - # Call the appropriate namelist functions - if [[ "${DO_NEST:-NO}" == "YES" ]] ; then - source "${USHgfs}/parsing_namelists_FV3_nest.sh" - FV3_namelists_nest global - FV3_namelists_nest nest - else - FV3_namelists - fi - FV3_model_configure - - echo "SUB ${FUNCNAME[0]}: FV3 name lists and model configure file created" + # namelist output for a certain component + echo "SUB ${FUNCNAME[0]}: Creating name lists and model configure file for FV3" + + source "${USHgfs}/parsing_namelists_FV3.sh" + source "${USHgfs}/parsing_model_configure_FV3.sh" + + # Call the appropriate namelist functions + if [[ "${DO_NEST:-NO}" == "YES" ]]; then + source "${USHgfs}/parsing_namelists_FV3_nest.sh" + FV3_namelists_nest global + FV3_namelists_nest nest + else + FV3_namelists + fi + FV3_model_configure + + echo "SUB ${FUNCNAME[0]}: FV3 name lists and model configure file created" } FV3_out() { - echo "SUB ${FUNCNAME[0]}: copying output data for FV3" - - # Copy configuration files - cpfs "${DATA}/input.nml" "${COMOUT_CONF}/ufs.input.nml" - cpfs "${DATA}/model_configure" "${COMOUT_CONF}/ufs.model_configure" - cpfs "${DATA}/ufs.configure" "${COMOUT_CONF}/ufs.ufs.configure" - cpfs "${DATA}/diag_table" "${COMOUT_CONF}/ufs.diag_table" - - - # Determine the dates for restart files to be copied to COM - local restart_date restart_dates - restart_dates=() - - case ${RUN} in - gdas|enkfgdas|enkfgfs|enkfgcafs|gcdas) # Copy restarts in the assimilation window for RUN=gdas|enkfgdas|enkfgfs - restart_date="${model_start_date_next_cycle}" - while (( restart_date <= forecast_end_cycle )); do - restart_dates+=("${restart_date:0:8}.${restart_date:8:2}0000") - restart_date=$(date --utc -d "${restart_date:0:8} ${restart_date:8:2} + ${restart_interval} hours" +%Y%m%d%H) - done - ;; - gfs|gefs|sfs|gcafs) # Copy restarts at the end of the forecast segment for RUN=gfs|gefs|sfs|gcafs - if [[ "${COPY_FINAL_RESTARTS}" == "YES" ]]; then - restart_dates+=("${forecast_end_cycle:0:8}.${forecast_end_cycle:8:2}0000") - fi - ;; - *) - echo "FATAL ERROR: Not sure how to copy restart files for RUN ${RUN}" - exit 25 - ;; - esac - - ### Check that there are restart files to copy - if [[ ${#restart_dates[@]} -gt 0 ]]; then - # Get list of FV3 restart files - local file_list fv3_file - file_list=$(FV3_restarts) - - # Copy restarts for the dates collected above to COM - for restart_date in "${restart_dates[@]}"; do - echo "Copying FV3 restarts for 'RUN=${RUN}' at ${restart_date}" - for fv3_file in ${file_list}; do - cpfs "${DATArestart}/FV3_RESTART/${restart_date}.${fv3_file}" \ - "${COMOUT_ATMOS_RESTART}/${restart_date}.${fv3_file}" - done - done + echo "SUB ${FUNCNAME[0]}: copying output data for FV3" + + # Copy configuration files + cpfs "${DATA}/input.nml" "${COMOUT_CONF}/ufs.input.nml" + cpfs "${DATA}/model_configure" "${COMOUT_CONF}/ufs.model_configure" + cpfs "${DATA}/ufs.configure" "${COMOUT_CONF}/ufs.ufs.configure" + cpfs "${DATA}/diag_table" "${COMOUT_CONF}/ufs.diag_table" + + # Determine the dates for restart files to be copied to COM + local restart_date restart_dates + restart_dates=() + + case ${RUN} in + gdas | enkfgdas | enkfgfs | enkfgcafs | gcdas) # Copy restarts in the assimilation window for RUN=gdas|enkfgdas|enkfgfs + restart_date="${model_start_date_next_cycle}" + while ((restart_date <= forecast_end_cycle)); do + restart_dates+=("${restart_date:0:8}.${restart_date:8:2}0000") + restart_date=$(date --utc -d "${restart_date:0:8} ${restart_date:8:2} + ${restart_interval} hours" +%Y%m%d%H) + done + ;; + gfs | gefs | sfs | gcafs) # Copy restarts at the end of the forecast segment for RUN=gfs|gefs|sfs|gcafs + if [[ "${COPY_FINAL_RESTARTS}" == "YES" ]]; then + restart_dates+=("${forecast_end_cycle:0:8}.${forecast_end_cycle:8:2}0000") + fi + ;; + *) + echo "FATAL ERROR: Not sure how to copy restart files for RUN ${RUN}" + exit 25 + ;; + esac + + ### Check that there are restart files to copy + if [[ ${#restart_dates[@]} -gt 0 ]]; then + # Get list of FV3 restart files + local file_list fv3_file + file_list=$(FV3_restarts) + + # Copy restarts for the dates collected above to COM + for restart_date in "${restart_dates[@]}"; do + echo "Copying FV3 restarts for 'RUN=${RUN}' at ${restart_date}" + for fv3_file in ${file_list}; do + cpfs "${DATArestart}/FV3_RESTART/${restart_date}.${fv3_file}" \ + "${COMOUT_ATMOS_RESTART}/${restart_date}.${fv3_file}" + done + done - echo "SUB ${FUNCNAME[0]}: Output data for FV3 copied" - fi + echo "SUB ${FUNCNAME[0]}: Output data for FV3 copied" + fi } # Disable variable not used warnings # shellcheck disable=SC2034 WW3_postdet() { - echo "SUB ${FUNCNAME[0]}: Linking input data for WW3" - # Copy initial condition files: - local restart_date restart_dir - if [[ "${RERUN}" == "YES" ]]; then - restart_date="${RERUN_DATE}" - restart_dir="${DATArestart}/WW3_RESTART" - else - restart_date="${model_start_date_current_cycle}" - restart_dir="${COMIN_WAVE_RESTART_PREV}" - fi - - echo "Copying WW3 restarts for 'RUN=${RUN}' at '${restart_date}' from '${restart_dir}'" - - local ww3_restart_file ww3_restart_dest_file seconds - seconds=$(to_seconds "${restart_date:8:2}0000") # convert HHMMSS to seconds - ww3_restart_file="${restart_dir}/${restart_date:0:8}.${restart_date:8:2}0000.restart.ww3" - ww3_restart_dest_file="ufs.cpld.ww3.r.${restart_date:0:4}-${restart_date:4:2}-${restart_date:6:2}-${seconds}" - if [[ -s "${ww3_restart_file}.nc" ]]; then # First check to see if netcdf restart exists: - export WW3_restart_from_binary=false - cpreq "${ww3_restart_file}.nc" "${DATA}/${ww3_restart_dest_file}.nc" - elif [[ -s "${ww3_restart_file}" ]]; then # If not, check to see if binary restart exists: - export WW3_restart_from_binary=true - cpreq "${ww3_restart_file}" "${DATA}/${ww3_restart_dest_file}" - else - if [[ "${RERUN}" == "YES" ]] || [[ -f "${DATA}/ufs.cpld.cpl.r.nc" ]]; then # The || part requires CMEPS_postdet to be called before WW3_postdet - # In the case of a RERUN, the WW3 restart file is required - # In the case of runtype=continue, if no wave restart when using PIO, the model will fail - echo "FATAL ERROR: WW3 binary | netcdf restart file '${ww3_restart_file}' | '${ww3_restart_file}.nc' not found for RERUN='${RERUN}' or runtype=continue, ABORT!" - exit 1 + echo "SUB ${FUNCNAME[0]}: Linking input data for WW3" + # Copy initial condition files: + local restart_date restart_dir + if [[ "${RERUN}" == "YES" ]]; then + restart_date="${RERUN_DATE}" + restart_dir="${DATArestart}/WW3_RESTART" else - export WW3_restart_from_binary=false - echo "WARNING: WW3 binary | netcdf restart file '${ww3_restart_file}' | '${ww3_restart_file}.nc' not found for warm_start='${warm_start}', will start from rest!" + restart_date="${model_start_date_current_cycle}" + restart_dir="${COMIN_WAVE_RESTART_PREV}" fi - fi - - local first_ww3_restart_out - first_ww3_restart_out=$(date --utc -d "${restart_date:0:8} ${restart_date:8:2} + ${restart_interval} hours" +%Y%m%d%H) - if [[ "${DOIAU:-NO}" == "YES" ]]; then - first_ww3_restart_out=$(date --utc -d "${first_ww3_restart_out:0:8} ${first_ww3_restart_out:8:2} + ${half_window} hours" +%Y%m%d%H) - fi - - # Link restart files to their expected names in DATArestart/WW3_RESTART - # TODO: Have the UFSWM write out the WW3 restart files in the expected format of 'YYYYMMDD.HHmmSS.restart.ww3.nc' - local cwd vdate ww3_ufs_restart_file ww3_netcdf_restart_file - cwd="${PWD}" - cd "${DATArestart}/WW3_RESTART" || exit 1 - for (( vdate = first_ww3_restart_out; vdate <= forecast_end_cycle; - vdate = $(date --utc -d "${vdate:0:8} ${vdate:8:2} + ${restart_interval} hours" +%Y%m%d%H) )); do - seconds=$(to_seconds "${vdate:8:2}0000") # convert HHMMSS to seconds - ww3_ufs_restart_file="ufs.cpld.ww3.r.${vdate:0:4}-${vdate:4:2}-${vdate:6:2}-${seconds}.nc" # UFS restart file name - ww3_netcdf_restart_file="${vdate:0:8}.${vdate:8:2}0000.restart.ww3.nc" # WW3 restart file name in COM - ${NLN} "${ww3_netcdf_restart_file}" "${ww3_ufs_restart_file}" - done - - # TODO: link GEFS restart for next cycle IC - #if [[ "${RUN}" == "gefs" ]]; then - # vdate=${model_start_date_next_cycle} - # seconds=$(to_seconds "${vdate:8:2}0000") # convert HHMMSS to seconds - # ww3_ufs_restart_file="ufs.cpld.ww3.r.${vdate:0:4}-${vdate:4:2}-${vdate:6:2}-${seconds}.nc" - # ww3_netcdf_restart_file="${vdate:0:8}.${vdate:8:2}0000.restart.ww3.nc" - # ${NLN} "${ww3_netcdf_restart_file}" "${ww3_ufs_restart_file}" - #fi - cd "${cwd}" || exit 1 - - # Link output files - ${NLN} "${COMOUT_WAVE_HISTORY}/${RUN}.t${cyc}z.${waveGRD}.${PDY}${cyc}.log" "log.ww3" - - # Loop for gridded output (uses FHINC) - local fhr fhr3 FHINC - fhr=${FHMIN_WAV} - if [[ ${FHMAX_HF_WAV} -gt 0 && ${FHOUT_HF_WAV} -gt 0 && ${fhr} -lt ${FHMAX_HF_WAV} ]]; then - fhinc=${FHOUT_HF_WAV} - else - fhinc=${FHOUT_WAV} - fi - while [[ ${fhr} -le ${FHMAX_WAV} ]]; do - fhr3=$(printf '%03d' "${fhr}") - vdate=$(date --utc -d "${current_cycle:0:8} ${current_cycle:8:2} + ${fhr} hours" +%Y%m%d.%H0000) - ${NLN} "${COMOUT_WAVE_HISTORY}/${RUN}.t${cyc}z.${waveGRD}.f${fhr3}.bin" "${DATAoutput}/WW3_OUTPUT/${vdate}.out_grd.ww3" - ${NLN} "${COMOUT_WAVE_HISTORY}/${RUN}.t${cyc}z.${waveGRD}.f${fhr3}.log" "${DATAoutput}/WW3_OUTPUT/log.${vdate}.out_grd.ww3.txt" - - if [[ ${fhr} -ge ${FHMAX_HF_WAV} ]]; then - fhinc=${FHOUT_WAV} + + echo "Copying WW3 restarts for 'RUN=${RUN}' at '${restart_date}' from '${restart_dir}'" + + local ww3_restart_file ww3_restart_dest_file seconds + seconds=$(to_seconds "${restart_date:8:2}0000") # convert HHMMSS to seconds + ww3_restart_file="${restart_dir}/${restart_date:0:8}.${restart_date:8:2}0000.restart.ww3" + ww3_restart_dest_file="ufs.cpld.ww3.r.${restart_date:0:4}-${restart_date:4:2}-${restart_date:6:2}-${seconds}" + if [[ -s "${ww3_restart_file}.nc" ]]; then # First check to see if netcdf restart exists: + export WW3_restart_from_binary=false + cpreq "${ww3_restart_file}.nc" "${DATA}/${ww3_restart_dest_file}.nc" + elif [[ -s "${ww3_restart_file}" ]]; then # If not, check to see if binary restart exists: + export WW3_restart_from_binary=true + cpreq "${ww3_restart_file}" "${DATA}/${ww3_restart_dest_file}" + else + if [[ "${RERUN}" == "YES" ]] || [[ -f "${DATA}/ufs.cpld.cpl.r.nc" ]]; then # The || part requires CMEPS_postdet to be called before WW3_postdet + # In the case of a RERUN, the WW3 restart file is required + # In the case of runtype=continue, if no wave restart when using PIO, the model will fail + echo "FATAL ERROR: WW3 binary | netcdf restart file '${ww3_restart_file}' | '${ww3_restart_file}.nc' not found for RERUN='${RERUN}' or runtype=continue, ABORT!" + exit 1 + else + export WW3_restart_from_binary=false + echo "WARNING: WW3 binary | netcdf restart file '${ww3_restart_file}' | '${ww3_restart_file}.nc' not found for warm_start='${warm_start}', will start from rest!" + fi + fi + + local first_ww3_restart_out + first_ww3_restart_out=$(date --utc -d "${restart_date:0:8} ${restart_date:8:2} + ${restart_interval} hours" +%Y%m%d%H) + if [[ "${DOIAU:-NO}" == "YES" ]]; then + first_ww3_restart_out=$(date --utc -d "${first_ww3_restart_out:0:8} ${first_ww3_restart_out:8:2} + ${half_window} hours" +%Y%m%d%H) + fi + + # Link restart files to their expected names in DATArestart/WW3_RESTART + # TODO: Have the UFSWM write out the WW3 restart files in the expected format of 'YYYYMMDD.HHmmSS.restart.ww3.nc' + local cwd vdate ww3_ufs_restart_file ww3_netcdf_restart_file + cwd="${PWD}" + cd "${DATArestart}/WW3_RESTART" || exit 1 + for ((vdate = first_ww3_restart_out; vdate <= forecast_end_cycle; \ + vdate = $(date --utc -d "${vdate:0:8} ${vdate:8:2} + ${restart_interval} hours" +%Y%m%d%H))); do + seconds=$(to_seconds "${vdate:8:2}0000") # convert HHMMSS to seconds + ww3_ufs_restart_file="ufs.cpld.ww3.r.${vdate:0:4}-${vdate:4:2}-${vdate:6:2}-${seconds}.nc" # UFS restart file name + ww3_netcdf_restart_file="${vdate:0:8}.${vdate:8:2}0000.restart.ww3.nc" # WW3 restart file name in COM + ${NLN} "${ww3_netcdf_restart_file}" "${ww3_ufs_restart_file}" + done + + # TODO: link GEFS restart for next cycle IC + #if [[ "${RUN}" == "gefs" ]]; then + # vdate=${model_start_date_next_cycle} + # seconds=$(to_seconds "${vdate:8:2}0000") # convert HHMMSS to seconds + # ww3_ufs_restart_file="ufs.cpld.ww3.r.${vdate:0:4}-${vdate:4:2}-${vdate:6:2}-${seconds}.nc" + # ww3_netcdf_restart_file="${vdate:0:8}.${vdate:8:2}0000.restart.ww3.nc" + # ${NLN} "${ww3_netcdf_restart_file}" "${ww3_ufs_restart_file}" + #fi + cd "${cwd}" || exit 1 + + # Link output files + ${NLN} "${COMOUT_WAVE_HISTORY}/${RUN}.t${cyc}z.${waveGRD}.${PDY}${cyc}.log" "log.ww3" + + # Loop for gridded output (uses FHINC) + local fhr fhr3 FHINC + # shellcheck disable=SC2153 + fhr="${FHMIN_WAV}" + if [[ ${FHMAX_HF_WAV} -gt 0 && ${FHOUT_HF_WAV} -gt 0 && ${fhr} -lt ${FHMAX_HF_WAV} ]]; then + fhinc=${FHOUT_HF_WAV} + else + fhinc=${FHOUT_WAV} fi - fhr=$((fhr + fhinc)) - done - - # Loop for point output (uses DTPNT) - fhr=${FHMIN_WAV} - fhinc=${FHINCP_WAV} - while [[ ${fhr} -le ${FHMAX_WAV} ]]; do - fhr3=$(printf '%03d' "${fhr}") - vdate=$(date --utc -d "${current_cycle:0:8} ${current_cycle:8:2} + ${fhr} hours" +%Y%m%d.%H0000) - ${NLN} "${COMOUT_WAVE_HISTORY}/${RUN}.t${cyc}z.points.f${fhr3}.nc" "${DATAoutput}/WW3_OUTPUT/${vdate}.out_pnt.ww3.nc" - ${NLN} "${COMOUT_WAVE_HISTORY}/${RUN}.t${cyc}z.points.f${fhr3}.log" "${DATAoutput}/WW3_OUTPUT/log.${vdate}.out_pnt.ww3.txt" - - fhr=$((fhr + fhinc)) - done + while [[ ${fhr} -le ${FHMAX_WAV} ]]; do + fhr3=$(printf '%03d' "${fhr}") + vdate=$(date --utc -d "${current_cycle:0:8} ${current_cycle:8:2} + ${fhr} hours" +%Y%m%d.%H0000) + ${NLN} "${COMOUT_WAVE_HISTORY}/${RUN}.t${cyc}z.${waveGRD}.f${fhr3}.bin" "${DATAoutput}/WW3_OUTPUT/${vdate}.out_grd.ww3" + ${NLN} "${COMOUT_WAVE_HISTORY}/${RUN}.t${cyc}z.${waveGRD}.f${fhr3}.log" "${DATAoutput}/WW3_OUTPUT/log.${vdate}.out_grd.ww3.txt" + + if [[ ${fhr} -ge ${FHMAX_HF_WAV} ]]; then + fhinc=${FHOUT_WAV} + fi + fhr=$((fhr + fhinc)) + done + + # Loop for point output (uses DTPNT) + fhr=${FHMIN_WAV} + fhinc=${FHINCP_WAV} + while [[ ${fhr} -le ${FHMAX_WAV} ]]; do + fhr3=$(printf '%03d' "${fhr}") + vdate=$(date --utc -d "${current_cycle:0:8} ${current_cycle:8:2} + ${fhr} hours" +%Y%m%d.%H0000) + ${NLN} "${COMOUT_WAVE_HISTORY}/${RUN}.t${cyc}z.points.f${fhr3}.nc" "${DATAoutput}/WW3_OUTPUT/${vdate}.out_pnt.ww3.nc" + ${NLN} "${COMOUT_WAVE_HISTORY}/${RUN}.t${cyc}z.points.f${fhr3}.log" "${DATAoutput}/WW3_OUTPUT/log.${vdate}.out_pnt.ww3.txt" + + fhr=$((fhr + fhinc)) + done } WW3_nml() { - echo "SUB ${FUNCNAME[0]}: Copying input files for WW3" - source "${USHgfs}/parsing_namelists_WW3.sh" - WW3_namelists + echo "SUB ${FUNCNAME[0]}: Copying input files for WW3" + source "${USHgfs}/parsing_namelists_WW3.sh" + WW3_namelists } WW3_out() { - echo "SUB ${FUNCNAME[0]}: Copying output data for WW3" - - # Copy wave namelist from DATA to COMOUT_CONF after the forecast is run (and successfull) - cpfs "${DATA}/ww3_shel.nml" "${COMOUT_CONF}/ufs.ww3_shel.nml" - - # Copy WW3 restarts at the end of the forecast segment to COM for RUN=gfs|gefs - if [[ "${COPY_FINAL_RESTARTS}" == "YES" ]]; then - local restart_file - if [[ "${RUN}" == "gfs" || "${RUN}" == "gefs" || "${RUN}" == "gcafs" ]]; then - echo "Copying WW3 restarts for 'RUN=${RUN}' at ${forecast_end_cycle}" - restart_file="${forecast_end_cycle:0:8}.${forecast_end_cycle:8:2}0000.restart.ww3.nc" - cpfs "${DATArestart}/WW3_RESTART/${restart_file}" \ - "${COMOUT_WAVE_RESTART}/${restart_file}" + echo "SUB ${FUNCNAME[0]}: Copying output data for WW3" + + # Copy wave namelist from DATA to COMOUT_CONF after the forecast is run (and successfull) + cpfs "${DATA}/ww3_shel.nml" "${COMOUT_CONF}/ufs.ww3_shel.nml" + + # Copy WW3 restarts at the end of the forecast segment to COM for RUN=gfs|gefs + if [[ "${COPY_FINAL_RESTARTS}" == "YES" ]]; then + local restart_file + if [[ "${RUN}" == "gfs" || "${RUN}" == "gefs" || "${RUN}" == "gcafs" ]]; then + echo "Copying WW3 restarts for 'RUN=${RUN}' at ${forecast_end_cycle}" + restart_file="${forecast_end_cycle:0:8}.${forecast_end_cycle:8:2}0000.restart.ww3.nc" + cpfs "${DATArestart}/WW3_RESTART/${restart_file}" \ + "${COMOUT_WAVE_RESTART}/${restart_file}" + fi fi - fi - - # Copy restarts for next cycle for RUN=gdas|gefs - # TODO: GEFS needs to be added here - if [[ "${RUN}" == "gdas" ]]; then - local restart_date restart_file - restart_date="${model_start_date_next_cycle}" - echo "Copying WW3 restarts for 'RUN=${RUN}' at ${restart_date}" - restart_file="${restart_date:0:8}.${restart_date:8:2}0000.restart.ww3.nc" - cpfs "${DATArestart}/WW3_RESTART/${restart_file}" \ - "${COMOUT_WAVE_RESTART}/${restart_file}" - fi - - # Copy restarts for downstream usage in HAFS - if [[ "${RUN}" == "gdas" ]]; then - local restart_date restart_file - restart_date="${next_cycle}" - echo "Copying WW3 restarts for 'RUN=${RUN}' at ${restart_date}" - restart_file="${restart_date:0:8}.${restart_date:8:2}0000.restart.ww3.nc" - cpfs "${DATArestart}/WW3_RESTART/${restart_file}" \ - "${COMOUT_WAVE_RESTART}/${restart_file}" - fi -} + # Copy restarts for next cycle for RUN=gdas|gefs + # TODO: GEFS needs to be added here + if [[ "${RUN}" == "gdas" ]]; then + local restart_date restart_file + restart_date="${model_start_date_next_cycle}" + echo "Copying WW3 restarts for 'RUN=${RUN}' at ${restart_date}" + restart_file="${restart_date:0:8}.${restart_date:8:2}0000.restart.ww3.nc" + cpfs "${DATArestart}/WW3_RESTART/${restart_file}" \ + "${COMOUT_WAVE_RESTART}/${restart_file}" + fi + # Copy restarts for downstream usage in HAFS + if [[ "${RUN}" == "gdas" ]]; then + local restart_date restart_file + restart_date="${next_cycle}" + echo "Copying WW3 restarts for 'RUN=${RUN}' at ${restart_date}" + restart_file="${restart_date:0:8}.${restart_date:8:2}0000.restart.ww3.nc" + cpfs "${DATArestart}/WW3_RESTART/${restart_file}" \ + "${COMOUT_WAVE_RESTART}/${restart_file}" + fi -CPL_out() { - echo "SUB ${FUNCNAME[0]}: Copying output data for general cpl fields" - if [[ "${esmf_profile:-.false.}" == ".true." ]]; then - cpfs "${DATA}/ESMF_Profile.summary" "${COMOUT_ATMOS_HISTORY}/ESMF_Profile.summary" - fi } -MOM6_postdet() { - echo "SUB ${FUNCNAME[0]}: MOM6 after run type determination" - - local restart_dir restart_date - if [[ "${RERUN}" == "YES" ]]; then - restart_dir="${DATArestart}/MOM6_RESTART" - restart_date="${RERUN_DATE}" - else # "${RERUN}" == "NO" - restart_dir="${COMIN_OCEAN_RESTART_PREV}" - restart_date="${model_start_date_current_cycle}" - fi - - # Copy MOM6 ICs - cpreq "${restart_dir}/${restart_date:0:8}.${restart_date:8:2}0000.MOM.res.nc" "${DATA}/INPUT/MOM.res.nc" - case ${OCNRES} in - "025") - local nn - for (( nn = 1; nn <= 4; nn++ )); do - if [[ -f "${restart_dir}/${restart_date:0:8}.${restart_date:8:2}0000.MOM.res_${nn}.nc" ]]; then - cpreq "${restart_dir}/${restart_date:0:8}.${restart_date:8:2}0000.MOM.res_${nn}.nc" "${DATA}/INPUT/MOM.res_${nn}.nc" - fi - done - ;; - *) ;; - esac - - # Copy increment (only when RERUN=NO) - if [[ "${RERUN}" == "NO" ]]; then - if [[ "${DO_JEDIOCNVAR:-NO}" == "YES" ]] || [[ ${MEMBER} -gt 0 && "${ODA_INCUPD:-False}" == "True" ]]; then - cpreq "${COMIN_OCEAN_ANALYSIS}/${RUN}.t${cyc}z.mom6_increment.i006.nc" "${DATA}/INPUT/mom6_increment.nc" +CPL_out() { + echo "SUB ${FUNCNAME[0]}: Copying output data for general cpl fields" + if [[ "${esmf_profile:-.false.}" == ".true." ]]; then + cpfs "${DATA}/ESMF_Profile.summary" "${COMOUT_ATMOS_HISTORY}/ESMF_Profile.summary" fi - fi # if [[ "${RERUN}" == "NO" ]]; then - - # Link output files - case ${RUN} in - gfs|enkfgfs|gefs|sfs|gcafs) # Link output files for RUN=gfs|enkfgfs|gefs|sfs - # Looping over MOM6 output hours - local fhr fhr3 last_fhr interval midpoint vdate vdate_mid source_file dest_file - for fhr in ${MOM6_OUTPUT_FH}; do - fhr3=$(printf %03i "${fhr}") +} - if [[ -z ${last_fhr:-} ]]; then - last_fhr=${fhr} - continue - fi +MOM6_postdet() { + echo "SUB ${FUNCNAME[0]}: MOM6 after run type determination" - (( interval = fhr - last_fhr )) - (( midpoint = last_fhr + interval/2 )) + local restart_dir restart_date + if [[ "${RERUN}" == "YES" ]]; then + restart_dir="${DATArestart}/MOM6_RESTART" + restart_date="${RERUN_DATE}" + else # "${RERUN}" == "NO" + restart_dir="${COMIN_OCEAN_RESTART_PREV}" + restart_date="${model_start_date_current_cycle}" + fi - vdate=$(date --utc -d "${current_cycle:0:8} ${current_cycle:8:2} + ${fhr} hours" +%Y%m%d%H) - #If OFFSET_START_HOUR is greater than 0, OFFSET_START_HOUR should be added to the midpoint for first lead time - if (( OFFSET_START_HOUR > 0 )) && (( fhr == FHOUT_OCN ));then - vdate_mid=$(date --utc -d "${current_cycle:0:8} ${current_cycle:8:2} + $(( midpoint + OFFSET_START_HOUR )) hours" +%Y%m%d%H) - else - vdate_mid=$(date --utc -d "${current_cycle:0:8} ${current_cycle:8:2} + ${midpoint} hours" +%Y%m%d%H) - fi + # Copy MOM6 ICs + cpreq "${restart_dir}/${restart_date:0:8}.${restart_date:8:2}0000.MOM.res.nc" "${DATA}/INPUT/MOM.res.nc" + case ${OCNRES} in + "025") + local nn + for ((nn = 1; nn <= 4; nn++)); do + if [[ -f "${restart_dir}/${restart_date:0:8}.${restart_date:8:2}0000.MOM.res_${nn}.nc" ]]; then + cpreq "${restart_dir}/${restart_date:0:8}.${restart_date:8:2}0000.MOM.res_${nn}.nc" "${DATA}/INPUT/MOM.res_${nn}.nc" + fi + done + ;; + *) ;; + esac - # Native model output uses window midpoint in the filename, but we are mapping that to the end of the period for COM - if (( OFFSET_START_HOUR > 0 )) && (( fhr == FHOUT_OCN ));then - source_file="ocn_lead1_${vdate_mid:0:4}_${vdate_mid:4:2}_${vdate_mid:6:2}_${vdate_mid:8:2}.nc" - else - source_file="ocn_${vdate_mid:0:4}_${vdate_mid:4:2}_${vdate_mid:6:2}_${vdate_mid:8:2}.nc" + # Copy increment (only when RERUN=NO) + if [[ "${RERUN}" == "NO" ]]; then + if [[ "${DO_JEDIOCNVAR:-NO}" == "YES" ]] || [[ ${MEMBER} -gt 0 && "${ODA_INCUPD:-False}" == "True" ]]; then + cpreq "${COMIN_OCEAN_ANALYSIS}/${RUN}.t${cyc}z.mom6_increment.i006.nc" "${DATA}/INPUT/mom6_increment.nc" fi - dest_file="${RUN}.t${cyc}z.${interval}hr_avg.f${fhr3}.nc" - ${NLN} "${COMOUT_OCEAN_HISTORY}/${dest_file}" "${DATAoutput}/MOM6_OUTPUT/${source_file}" + fi # if [[ "${RERUN}" == "NO" ]]; then + + # Link output files + case ${RUN} in + gfs | enkfgfs | gefs | sfs | gcafs) # Link output files for RUN=gfs|enkfgfs|gefs|sfs + # Looping over MOM6 output hours + local fhr fhr3 last_fhr interval midpoint vdate vdate_mid source_file dest_file + for fhr in ${MOM6_OUTPUT_FH}; do + fhr3=$(printf %03i "${fhr}") + + if [[ -z ${last_fhr:-} ]]; then + last_fhr=${fhr} + continue + fi + + ((interval = fhr - last_fhr)) + ((midpoint = last_fhr + interval / 2)) + + vdate=$(date --utc -d "${current_cycle:0:8} ${current_cycle:8:2} + ${fhr} hours" +%Y%m%d%H) + #If OFFSET_START_HOUR is greater than 0, OFFSET_START_HOUR should be added to the midpoint for first lead time + if ((OFFSET_START_HOUR > 0)) && ((fhr == FHOUT_OCN)); then + vdate_mid=$(date --utc -d "${current_cycle:0:8} ${current_cycle:8:2} + $((midpoint + OFFSET_START_HOUR)) hours" +%Y%m%d%H) + else + vdate_mid=$(date --utc -d "${current_cycle:0:8} ${current_cycle:8:2} + ${midpoint} hours" +%Y%m%d%H) + fi + + # Native model output uses window midpoint in the filename, but we are mapping that to the end of the period for COM + if ((OFFSET_START_HOUR > 0)) && ((fhr == FHOUT_OCN)); then + source_file="ocn_lead1_${vdate_mid:0:4}_${vdate_mid:4:2}_${vdate_mid:6:2}_${vdate_mid:8:2}.nc" + else + source_file="ocn_${vdate_mid:0:4}_${vdate_mid:4:2}_${vdate_mid:6:2}_${vdate_mid:8:2}.nc" + fi + dest_file="${RUN}.t${cyc}z.${interval}hr_avg.f${fhr3}.nc" + ${NLN} "${COMOUT_OCEAN_HISTORY}/${dest_file}" "${DATAoutput}/MOM6_OUTPUT/${source_file}" + + last_fhr=${fhr} - last_fhr=${fhr} - - done - ;; + done + ;; + + gdas | enkfgdas) # Link output files for RUN=gdas|enkfgdas + # Save (instantaneous) MOM6 backgrounds + local fhr3 vdatestr + for fhr in ${MOM6_OUTPUT_FH}; do + fhr3=$(printf %03i "${fhr}") + vdatestr=$(date --utc -d "${current_cycle:0:8} ${current_cycle:8:2} + ${fhr} hours" +%Y_%m_%d_%H) + ${NLN} "${COMOUT_OCEAN_HISTORY}/${RUN}.t${cyc}z.inst.f${fhr3}.nc" "${DATAoutput}/MOM6_OUTPUT/ocn_da_${vdatestr}.nc" + done + ;; + *) + echo "FATAL ERROR: Don't know how to copy MOM output files for RUN ${RUN}" + exit 25 + ;; + esac - gdas|enkfgdas) # Link output files for RUN=gdas|enkfgdas - # Save (instantaneous) MOM6 backgrounds - local fhr3 vdatestr - for fhr in ${MOM6_OUTPUT_FH}; do - fhr3=$(printf %03i "${fhr}") - vdatestr=$(date --utc -d "${current_cycle:0:8} ${current_cycle:8:2} + ${fhr} hours" +%Y_%m_%d_%H) - ${NLN} "${COMOUT_OCEAN_HISTORY}/${RUN}.t${cyc}z.inst.f${fhr3}.nc" "${DATAoutput}/MOM6_OUTPUT/ocn_da_${vdatestr}.nc" - done - ;; - *) - echo "FATAL ERROR: Don't know how to copy MOM output files for RUN ${RUN}" - exit 25 - ;; - esac - - echo "SUB ${FUNCNAME[0]}: MOM6 input data linked/copied" + echo "SUB ${FUNCNAME[0]}: MOM6 input data linked/copied" } MOM6_nml() { - echo "SUB ${FUNCNAME[0]}: Creating name list for MOM6" - source "${USHgfs}/parsing_namelists_MOM6.sh" - MOM6_namelists + echo "SUB ${FUNCNAME[0]}: Creating name list for MOM6" + source "${USHgfs}/parsing_namelists_MOM6.sh" + MOM6_namelists } MOM6_out() { - echo "SUB ${FUNCNAME[0]}: Copying output data for MOM6" - - # Copy MOM_input from DATA to COMOUT_CONF after the forecast is run (and successfull) - cpfs "${DATA}/INPUT/MOM_input" "${COMOUT_CONF}/ufs.MOM_input" - # Copy runtime configuration of MOM: MOM_parameter_doc.all that was used in the forecast - if [[ -f "${DATA}/MOM6_OUTPUT/MOM_parameter_doc.all" ]]; then - cpfs "${DATA}/MOM6_OUTPUT/MOM_parameter_doc.all" "${COMOUT_CONF}/MOM_parameter_doc.all" - fi - - # Create a list of MOM6 restart files - # Coarser than 1/2 degree has a single MOM restart - local mom6_restart_files mom6_restart_file restart_file - mom6_restart_files=(MOM.res.nc) - # 1/4 degree resolution has 3 additional restarts - case "${OCNRES}" in - "025") - local nn - for (( nn = 1; nn <= 3; nn++ )); do - mom6_restart_files+=("MOM.res_${nn}.nc") - done - ;; - *) ;; - esac - - case ${RUN} in - gdas|enkfgdas|enkfgfs) # Copy restarts for the next cycle for RUN=gdas|enkfgdas|enkfgfs - local restart_date - restart_date="${model_start_date_next_cycle}" - echo "Copying MOM6 restarts for 'RUN=${RUN}' at ${restart_date}" - for mom6_restart_file in "${mom6_restart_files[@]}"; do - restart_file="${restart_date:0:8}.${restart_date:8:2}0000.${mom6_restart_file}" - cpfs "${DATArestart}/MOM6_RESTART/${restart_file}" \ - "${COMOUT_OCEAN_RESTART}/${restart_file}" - done - ;; - gfs|gefs|sfs|gcafs) # Copy MOM6 restarts at the end of the forecast segment to COM for RUN=gfs|gefs|sfs - if [[ "${COPY_FINAL_RESTARTS}" == "YES" ]]; then - local restart_file - echo "Copying MOM6 restarts for 'RUN=${RUN}' at ${forecast_end_cycle}" - for mom6_restart_file in "${mom6_restart_files[@]}"; do - restart_file="${forecast_end_cycle:0:8}.${forecast_end_cycle:8:2}0000.${mom6_restart_file}" - cpfs "${DATArestart}/MOM6_RESTART/${restart_file}" \ - "${COMOUT_OCEAN_RESTART}/${restart_file}" - done - fi - ;; - *) - echo "FATAL ERROR: Not sure how to copy restart files for RUN ${RUN}" - exit 25 - ;; - esac + echo "SUB ${FUNCNAME[0]}: Copying output data for MOM6" + + # Copy MOM_input from DATA to COMOUT_CONF after the forecast is run (and successfull) + cpfs "${DATA}/INPUT/MOM_input" "${COMOUT_CONF}/ufs.MOM_input" + # Copy runtime configuration of MOM: MOM_parameter_doc.all that was used in the forecast + if [[ -f "${DATA}/MOM6_OUTPUT/MOM_parameter_doc.all" ]]; then + cpfs "${DATA}/MOM6_OUTPUT/MOM_parameter_doc.all" "${COMOUT_CONF}/MOM_parameter_doc.all" + fi + + # Create a list of MOM6 restart files + # Coarser than 1/2 degree has a single MOM restart + local mom6_restart_files mom6_restart_file restart_file + mom6_restart_files=(MOM.res.nc) + # 1/4 degree resolution has 3 additional restarts + case "${OCNRES}" in + "025") + local nn + for ((nn = 1; nn <= 3; nn++)); do + mom6_restart_files+=("MOM.res_${nn}.nc") + done + ;; + *) ;; + esac + + case ${RUN} in + gdas | enkfgdas | enkfgfs) # Copy restarts for the next cycle for RUN=gdas|enkfgdas|enkfgfs + local restart_date + restart_date="${model_start_date_next_cycle}" + echo "Copying MOM6 restarts for 'RUN=${RUN}' at ${restart_date}" + for mom6_restart_file in "${mom6_restart_files[@]}"; do + restart_file="${restart_date:0:8}.${restart_date:8:2}0000.${mom6_restart_file}" + cpfs "${DATArestart}/MOM6_RESTART/${restart_file}" \ + "${COMOUT_OCEAN_RESTART}/${restart_file}" + done + ;; + gfs | gefs | sfs | gcafs) # Copy MOM6 restarts at the end of the forecast segment to COM for RUN=gfs|gefs|sfs + if [[ "${COPY_FINAL_RESTARTS}" == "YES" ]]; then + local restart_file + echo "Copying MOM6 restarts for 'RUN=${RUN}' at ${forecast_end_cycle}" + for mom6_restart_file in "${mom6_restart_files[@]}"; do + restart_file="${forecast_end_cycle:0:8}.${forecast_end_cycle:8:2}0000.${mom6_restart_file}" + cpfs "${DATArestart}/MOM6_RESTART/${restart_file}" \ + "${COMOUT_OCEAN_RESTART}/${restart_file}" + done + fi + ;; + *) + echo "FATAL ERROR: Not sure how to copy restart files for RUN ${RUN}" + exit 25 + ;; + esac } CICE_postdet() { - echo "SUB ${FUNCNAME[0]}: CICE after run type determination" - - local restart_date cice_restart_file - if [[ "${RERUN}" == "YES" ]]; then - restart_date="${RERUN_DATE}" - local seconds - seconds=$(to_seconds "${restart_date:8:2}0000") # convert HHMMSS to seconds - cice_restart_file="${DATArestart}/CICE_RESTART/cice_model.res.${restart_date:0:4}-${restart_date:4:2}-${restart_date:6:2}-${seconds}.nc" - else # "${RERUN}" == "NO" - restart_date="${model_start_date_current_cycle}" - cice_restart_file="${COMIN_ICE_RESTART_PREV}/${restart_date:0:8}.${restart_date:8:2}0000.cice_model.res.nc" - if [[ "${DO_JEDIOCNVAR:-NO}" == "YES" ]]; then - if [[ ${MEMBER} -eq 0 ]]; then - # Start the deterministic from the JEDI/SOCA analysis if the Marine DA in ON - cice_restart_file="${COMIN_ICE_ANALYSIS}/${restart_date:0:8}.${restart_date:8:2}0000.analysis.cice_model.res.nc" - elif [[ ${MEMBER} -gt 0 && "${DO_STARTMEM_FROM_JEDIICE:-NO}" == "YES" ]]; then - # Ignore the JEDI/SOCA ensemble analysis for the ensemble members if DO_START_FROM_JEDIICE is OFF - cice_restart_file="${COMIN_ICE_ANALYSIS}/${restart_date:0:8}.${restart_date:8:2}0000.analysis.cice_model.res.nc" - fi + echo "SUB ${FUNCNAME[0]}: CICE after run type determination" + + local restart_date cice_restart_file + if [[ "${RERUN}" == "YES" ]]; then + restart_date="${RERUN_DATE}" + local seconds + seconds=$(to_seconds "${restart_date:8:2}0000") # convert HHMMSS to seconds + cice_restart_file="${DATArestart}/CICE_RESTART/cice_model.res.${restart_date:0:4}-${restart_date:4:2}-${restart_date:6:2}-${seconds}.nc" + else # "${RERUN}" == "NO" + restart_date="${model_start_date_current_cycle}" + cice_restart_file="${COMIN_ICE_RESTART_PREV}/${restart_date:0:8}.${restart_date:8:2}0000.cice_model.res.nc" + if [[ "${DO_JEDIOCNVAR:-NO}" == "YES" ]]; then + if [[ "${MEMBER}" -eq 0 ]]; then + # Start the deterministic from the JEDI/SOCA analysis if the Marine DA in ON + cice_restart_file="${COMIN_ICE_ANALYSIS}/${restart_date:0:8}.${restart_date:8:2}0000.analysis.cice_model.res.nc" + elif [[ "${MEMBER}" -gt 0 ]] && [[ "${DO_STARTMEM_FROM_JEDIICE:-NO}" == "YES" ]]; then + # Ignore the JEDI/SOCA ensemble analysis for the ensemble members if DO_START_FROM_JEDIICE is OFF + cice_restart_file="${COMIN_ICE_ANALYSIS}/${restart_date:0:8}.${restart_date:8:2}0000.analysis.cice_model.res.nc" + fi + fi fi - fi - # Copy CICE ICs - cpreq "${cice_restart_file}" "${DATA}/cice_model.res.nc" + # Copy CICE ICs + cpreq "${cice_restart_file}" "${DATA}/cice_model.res.nc" - # Link iceh_ic file to COM. This is the initial condition file from CICE (f000) - # TODO: Is this file needed in COM? Is this going to be used for generating any products? - local vdate seconds vdatestr fhr fhr3 interval last_fhr - seconds=$(to_seconds "${model_start_date_current_cycle:8:2}0000") # convert HHMMSS to seconds - vdatestr="${model_start_date_current_cycle:0:4}-${model_start_date_current_cycle:4:2}-${model_start_date_current_cycle:6:2}-${seconds}" - ${NLN} "${COMOUT_ICE_HISTORY}/${RUN}.t${cyc}z.ic.nc" "${DATAoutput}/CICE_OUTPUT/iceh_ic.${vdatestr}.nc" + # Link iceh_ic file to COM. This is the initial condition file from CICE (f000) + # TODO: Is this file needed in COM? Is this going to be used for generating any products? + local vdate seconds vdatestr fhr fhr3 interval last_fhr + seconds=$(to_seconds "${model_start_date_current_cycle:8:2}0000") # convert HHMMSS to seconds + vdatestr="${model_start_date_current_cycle:0:4}-${model_start_date_current_cycle:4:2}-${model_start_date_current_cycle:6:2}-${seconds}" + ${NLN} "${COMOUT_ICE_HISTORY}/${RUN}.t${cyc}z.ic.nc" "${DATAoutput}/CICE_OUTPUT/iceh_ic.${vdatestr}.nc" - # Link CICE forecast output files from DATAoutput/CICE_OUTPUT to COM - local source_file dest_file - for fhr in "${CICE_OUTPUT_FH[@]}"; do + # Link CICE forecast output files from DATAoutput/CICE_OUTPUT to COM + local source_file dest_file + for fhr in "${CICE_OUTPUT_FH[@]}"; do - if [[ -z ${last_fhr:-} ]]; then - last_fhr=${fhr} - continue - fi + if [[ -z ${last_fhr:-} ]]; then + last_fhr=${fhr} + continue + fi - fhr3=$(printf %03i "${fhr}") - (( interval = fhr - last_fhr )) - - vdate=$(date --utc -d "${current_cycle:0:8} ${current_cycle:8:2} + ${fhr} hours" +%Y%m%d%H) - seconds=$(to_seconds "${vdate:8:2}0000") # convert HHMMSS to seconds - vdatestr="${vdate:0:4}-${vdate:4:2}-${vdate:6:2}-${seconds}" - - case "${RUN}" in - gdas|enkfgdas) - source_file="iceh_inst.${vdatestr}.nc" - dest_file="${RUN}.t${cyc}z.inst.f${fhr3}.nc" - ;; - gfs|enkfgfs|sfs|gcafs) - source_file="iceh_$(printf "%0.2d" "${FHOUT_ICE}")h.${vdatestr}.nc" - dest_file="${RUN}.t${cyc}z.${interval}hr_avg.f${fhr3}.nc" - ;; - gefs) - source_file="iceh.${vdatestr}.nc" - dest_file="${RUN}.t${cyc}z.${interval}hr_avg.f${fhr3}.nc" - ;; - *) - echo "FATAL ERROR: Unsupported RUN ${RUN} in CICE postdet" - exit 10 - esac + fhr3=$(printf %03i "${fhr}") + ((interval = fhr - last_fhr)) - ${NLN} "${COMOUT_ICE_HISTORY}/${dest_file}" "${DATAoutput}/CICE_OUTPUT/${source_file}" + vdate=$(date --utc -d "${current_cycle:0:8} ${current_cycle:8:2} + ${fhr} hours" +%Y%m%d%H) + seconds=$(to_seconds "${vdate:8:2}0000") # convert HHMMSS to seconds + vdatestr="${vdate:0:4}-${vdate:4:2}-${vdate:6:2}-${seconds}" + + case "${RUN}" in + gdas | enkfgdas) + source_file="iceh_inst.${vdatestr}.nc" + dest_file="${RUN}.t${cyc}z.inst.f${fhr3}.nc" + ;; + gfs | enkfgfs | sfs | gcafs) + source_file="iceh_$(printf "%0.2d" "${FHOUT_ICE}")h.${vdatestr}.nc" + dest_file="${RUN}.t${cyc}z.${interval}hr_avg.f${fhr3}.nc" + ;; + gefs) + source_file="iceh.${vdatestr}.nc" + dest_file="${RUN}.t${cyc}z.${interval}hr_avg.f${fhr3}.nc" + ;; + *) + echo "FATAL ERROR: Unsupported RUN ${RUN} in CICE postdet" + exit 10 + ;; + esac + + ${NLN} "${COMOUT_ICE_HISTORY}/${dest_file}" "${DATAoutput}/CICE_OUTPUT/${source_file}" - last_fhr=${fhr} - done + last_fhr=${fhr} + done } CICE_nml() { - echo "SUB ${FUNCNAME[0]}: Creating name list for CICE" - source "${USHgfs}/parsing_namelists_CICE.sh" - CICE_namelists + echo "SUB ${FUNCNAME[0]}: Creating name list for CICE" + source "${USHgfs}/parsing_namelists_CICE.sh" + CICE_namelists } CICE_out() { - echo "SUB ${FUNCNAME[0]}: Copying output data for CICE" - - # Copy ice_in namelist from DATA to COMOUT_CONF after the forecast is run (and successfull) - cpfs "${DATA}/ice_in" "${COMOUT_CONF}/ufs.ice_in" - - case ${RUN} in - gdas|enkfgdas|enkfgfs) # Copy restarts for next cycle for RUN=gdas|enkfgdas|enkfgfs - local restart_date - restart_date="${model_start_date_next_cycle}" - echo "Copying CICE restarts for 'RUN=${RUN}' at ${restart_date}" - seconds=$(to_seconds "${restart_date:8:2}0000") # convert HHMMSS to seconds - source_file="cice_model.res.${restart_date:0:4}-${restart_date:4:2}-${restart_date:6:2}-${seconds}.nc" - target_file="${restart_date:0:8}.${restart_date:8:2}0000.cice_model.res.nc" - cpfs "${DATArestart}/CICE_RESTART/${source_file}" \ - "${COMOUT_ICE_RESTART}/${target_file}" - ;; - gfs|gefs|sfs|gcafs) # Copy CICE restarts at the end of the forecast segment to COM for RUN=gfs|gefs|sfs|gcafs - if [[ "${COPY_FINAL_RESTARTS}" == "YES" ]]; then - local seconds source_file target_file - echo "Copying CICE restarts for 'RUN=${RUN}' at ${forecast_end_cycle}" - seconds=$(to_seconds "${forecast_end_cycle:8:2}0000") # convert HHMMSS to seconds - source_file="cice_model.res.${forecast_end_cycle:0:4}-${forecast_end_cycle:4:2}-${forecast_end_cycle:6:2}-${seconds}.nc" - target_file="${forecast_end_cycle:0:8}.${forecast_end_cycle:8:2}0000.cice_model.res.nc" - cpfs "${DATArestart}/CICE_RESTART/${source_file}" \ - "${COMOUT_ICE_RESTART}/${target_file}" - fi - ;; - *) - echo "FATAL ERROR: Not sure how to copy restart files for RUN ${RUN}" - exit 25 - ;; - esac + echo "SUB ${FUNCNAME[0]}: Copying output data for CICE" + + # Copy ice_in namelist from DATA to COMOUT_CONF after the forecast is run (and successfull) + cpfs "${DATA}/ice_in" "${COMOUT_CONF}/ufs.ice_in" + + case ${RUN} in + gdas | enkfgdas | enkfgfs) # Copy restarts for next cycle for RUN=gdas|enkfgdas|enkfgfs + local restart_date + restart_date="${model_start_date_next_cycle}" + echo "Copying CICE restarts for 'RUN=${RUN}' at ${restart_date}" + seconds=$(to_seconds "${restart_date:8:2}0000") # convert HHMMSS to seconds + source_file="cice_model.res.${restart_date:0:4}-${restart_date:4:2}-${restart_date:6:2}-${seconds}.nc" + target_file="${restart_date:0:8}.${restart_date:8:2}0000.cice_model.res.nc" + cpfs "${DATArestart}/CICE_RESTART/${source_file}" \ + "${COMOUT_ICE_RESTART}/${target_file}" + ;; + gfs | gefs | sfs | gcafs) # Copy CICE restarts at the end of the forecast segment to COM for RUN=gfs|gefs|sfs|gcafs + if [[ "${COPY_FINAL_RESTARTS}" == "YES" ]]; then + local seconds source_file target_file + echo "Copying CICE restarts for 'RUN=${RUN}' at ${forecast_end_cycle}" + seconds=$(to_seconds "${forecast_end_cycle:8:2}0000") # convert HHMMSS to seconds + source_file="cice_model.res.${forecast_end_cycle:0:4}-${forecast_end_cycle:4:2}-${forecast_end_cycle:6:2}-${seconds}.nc" + target_file="${forecast_end_cycle:0:8}.${forecast_end_cycle:8:2}0000.cice_model.res.nc" + cpfs "${DATArestart}/CICE_RESTART/${source_file}" \ + "${COMOUT_ICE_RESTART}/${target_file}" + fi + ;; + *) + echo "FATAL ERROR: Not sure how to copy restart files for RUN ${RUN}" + exit 25 + ;; + esac } GOCART_rc() { - echo "SUB ${FUNCNAME[0]}: Linking input data and copying config files for GOCART" - # set input directory containing GOCART input data and configuration files - # this variable is platform-dependent and should be set via a YAML file - - # link directory containing GOCART input dataset, if provided - if [[ -n "${AERO_INPUTS_DIR}" ]]; then - ${NLN} "${AERO_INPUTS_DIR}" "${DATA}/ExtData" - status=$? - if [[ ${status} -ne 0 ]]; then - exit "${status}" + echo "SUB ${FUNCNAME[0]}: Linking input data and copying config files for GOCART" + # set input directory containing GOCART input data and configuration files + # this variable is platform-dependent and should be set via a YAML file + + # link directory containing GOCART input dataset, if provided + if [[ -n "${AERO_INPUTS_DIR}" ]]; then + ${NLN} "${AERO_INPUTS_DIR}" "${DATA}/ExtData" + status=$? + if [[ ${status} -ne 0 ]]; then + exit "${status}" + fi fi - fi - source "${USHgfs}/parsing_namelists_GOCART.sh" - GOCART_namelists + source "${USHgfs}/parsing_namelists_GOCART.sh" + GOCART_namelists } GOCART_postdet() { - echo "SUB ${FUNCNAME[0]}: Linking output data for GOCART" - - local vdate - for fhr in $(GOCART_output_fh); do - vdate=$(date --utc -d "${current_cycle:0:8} ${current_cycle:8:2} + ${fhr} hours" +%Y%m%d%H) - - # Temporarily delete existing files due to noclobber in GOCART - local file_types=("inst_aod" "inst_du_ss" "inst_ca" "inst_ni" "inst_su" \ - "inst_du_bin" "inst_ss_bin" "inst_ca_bin" "inst_ni_bin" "inst_su_bin" \ - "inst_2d" "inst_3d" "tavg_du_ss" "tavg_du_bin" "tavg_2d_rad" "tavg_3d_rad") - for file_type in "${file_types[@]}"; do - if [[ -e "${COMOUT_CHEM_HISTORY}/gocart.${file_type}.${vdate:0:8}_${vdate:8:2}00z.nc4" ]]; then - rm -f "${COMOUT_CHEM_HISTORY}/gocart.${file_type}.${vdate:0:8}_${vdate:8:2}00z.nc4" - fi - done + echo "SUB ${FUNCNAME[0]}: Linking output data for GOCART" - #TODO: Temporarily removing this as this will crash gocart, adding copy statement at the end - #${NLN} "${COMOUT_CHEM_HISTORY}/gocart.inst_aod.${vdate:0:8}_${vdate:8:2}00z.nc4" \ - # "${DATA}/gocart.inst_aod.${vdate:0:8}_${vdate:8:2}00z.nc4" - done + local vdate + for fhr in $(GOCART_output_fh); do + vdate=$(date --utc -d "${current_cycle:0:8} ${current_cycle:8:2} + ${fhr} hours" +%Y%m%d%H) + + # Temporarily delete existing files due to noclobber in GOCART + local file_types=("inst_aod" "inst_du_ss" "inst_ca" "inst_ni" "inst_su" + "inst_du_bin" "inst_ss_bin" "inst_ca_bin" "inst_ni_bin" "inst_su_bin" + "inst_2d" "inst_3d" "tavg_du_ss" "tavg_du_bin" "tavg_2d_rad" "tavg_3d_rad") + for file_type in "${file_types[@]}"; do + if [[ -e "${COMOUT_CHEM_HISTORY}/gocart.${file_type}.${vdate:0:8}_${vdate:8:2}00z.nc4" ]]; then + rm -f "${COMOUT_CHEM_HISTORY}/gocart.${file_type}.${vdate:0:8}_${vdate:8:2}00z.nc4" + fi + done + + #TODO: Temporarily removing this as this will crash gocart, adding copy statement at the end + #${NLN} "${COMOUT_CHEM_HISTORY}/gocart.inst_aod.${vdate:0:8}_${vdate:8:2}00z.nc4" \ + # "${DATA}/gocart.inst_aod.${vdate:0:8}_${vdate:8:2}00z.nc4" + done } GOCART_output_fh() { - # This has to be called during postdet after FHROT has been set - local aero_min - local gocart_output_fh - # GOCART produces no AOD files at the initial forecast time, so start the time - # after the forecast start (accounting for FHROT) - aero_min=$(( ${IAU_FHROT:-0} > FHMIN ? IAU_FHROT + FHOUT_AERO : FHMIN + FHOUT_AERO )) - gocart_output_fh=$(seq -s ' ' "$(( aero_min ))" "${FHOUT_AERO}" "${GOCART_MAX}") - - echo "${gocart_output_fh}" + # This has to be called during postdet after FHROT has been set + local aero_min + local gocart_output_fh + # GOCART produces no AOD files at the initial forecast time, so start the time + # after the forecast start (accounting for FHROT) + aero_min=$((${IAU_FHROT:-0} > FHMIN ? IAU_FHROT + FHOUT_AERO : FHMIN + FHOUT_AERO)) + gocart_output_fh=$(seq -s ' ' "$((aero_min))" "${FHOUT_AERO}" "${GOCART_MAX}") + + echo "${gocart_output_fh}" } GOCART_out() { - echo "SUB ${FUNCNAME[0]}: Copying output data for GOCART" - - # Copy gocart.inst_aod after the forecast is run (and successfull) - # TODO: this should be linked but there are issues where gocart crashing if it is linked - local fhr - local vdate - - local file_types=("inst_aod" "inst_du_ss" "inst_ca" "inst_ni" "inst_su" \ - "inst_du_bin" "inst_ss_bin" "inst_ca_bin" "inst_ni_bin" "inst_su_bin" \ - "inst_2d" "inst_3d" "tavg_du_ss" "tavg_du_bin" "tavg_2d_rad" "tavg_3d_rad") - - for fhr in $(GOCART_output_fh); do - vdate=$(date --utc -d "${current_cycle:0:8} ${current_cycle:8:2} + ${fhr} hours" +%Y%m%d%H) - for file_type in "${file_types[@]}"; do - if [[ -e "${DATA}/gocart.${file_type}.${vdate:0:8}_${vdate:8:2}00z.nc4" ]]; then - cpfs "${DATA}/gocart.${file_type}.${vdate:0:8}_${vdate:8:2}00z.nc4" \ - "${COMOUT_CHEM_HISTORY}/gocart.${file_type}.${vdate:0:8}_${vdate:8:2}00z.nc4" - fi + echo "SUB ${FUNCNAME[0]}: Copying output data for GOCART" + + # Copy gocart.inst_aod after the forecast is run (and successfull) + # TODO: this should be linked but there are issues where gocart crashing if it is linked + local fhr + local vdate + + local file_types=("inst_aod" "inst_du_ss" "inst_ca" "inst_ni" "inst_su" + "inst_du_bin" "inst_ss_bin" "inst_ca_bin" "inst_ni_bin" "inst_su_bin" + "inst_2d" "inst_3d" "tavg_du_ss" "tavg_du_bin" "tavg_2d_rad" "tavg_3d_rad") + + for fhr in $(GOCART_output_fh); do + vdate=$(date --utc -d "${current_cycle:0:8} ${current_cycle:8:2} + ${fhr} hours" +%Y%m%d%H) + for file_type in "${file_types[@]}"; do + if [[ -e "${DATA}/gocart.${file_type}.${vdate:0:8}_${vdate:8:2}00z.nc4" ]]; then + cpfs "${DATA}/gocart.${file_type}.${vdate:0:8}_${vdate:8:2}00z.nc4" \ + "${COMOUT_CHEM_HISTORY}/gocart.${file_type}.${vdate:0:8}_${vdate:8:2}00z.nc4" + fi + done done - done } # shellcheck disable=SC2178 CMEPS_postdet() { - echo "SUB ${FUNCNAME[0]}: Linking output data for CMEPS mediator" - - if [[ "${warm_start}" == ".true." ]]; then - - # Determine the appropriate restart file - local restart_date cmeps_restart_file - if [[ "${RERUN}" == "YES" ]]; then - restart_date="${RERUN_DATE}" - local seconds - seconds=$(to_seconds "${restart_date:8:2}0000") # convert HHMMSS to seconds - cmeps_restart_file="${DATArestart}/CMEPS_RESTART/ufs.cpld.cpl.r.${restart_date:0:4}-${restart_date:4:2}-${restart_date:6:2}-${seconds}.nc" - else # "${RERUN}" == "NO" - restart_date="${model_start_date_current_cycle}" - cmeps_restart_file="${COMIN_MED_RESTART_PREV}/${restart_date:0:8}.${restart_date:8:2}0000.ufs.cpld.cpl.r.nc" - fi - - # Copy CMEPS restarts - if [[ -f "${cmeps_restart_file}" ]]; then - cpreq "${cmeps_restart_file}" "${DATA}/ufs.cpld.cpl.r.nc" - rm -f "${DATA}/rpointer.cpl" - touch "${DATA}/rpointer.cpl" - echo "ufs.cpld.cpl.r.nc" >> "${DATA}/rpointer.cpl" - else - # We have a choice to make here. - # Either we can FATAL ERROR out, or we can let the coupling fields initialize from zero - # cmeps_run_type is determined based on the availability of the CMEPS restart file - echo "WARNING: CMEPS restart file '${cmeps_restart_file}' not found for warm_start='${warm_start}', will initialize!" - if [[ "${RERUN}" == "YES" ]]; then - # In the case of a RERUN, the CMEPS restart file is required - echo "FATAL ERROR: CMEPS restart file '${cmeps_restart_file}' not found for RERUN='${RERUN}', ABORT!" - exit 1 - fi - fi + echo "SUB ${FUNCNAME[0]}: Linking output data for CMEPS mediator" + + if [[ "${warm_start}" == ".true." ]]; then + + # Determine the appropriate restart file + local restart_date cmeps_restart_file + if [[ "${RERUN}" == "YES" ]]; then + restart_date="${RERUN_DATE}" + local seconds + seconds=$(to_seconds "${restart_date:8:2}0000") # convert HHMMSS to seconds + cmeps_restart_file="${DATArestart}/CMEPS_RESTART/ufs.cpld.cpl.r.${restart_date:0:4}-${restart_date:4:2}-${restart_date:6:2}-${seconds}.nc" + else # "${RERUN}" == "NO" + restart_date="${model_start_date_current_cycle}" + cmeps_restart_file="${COMIN_MED_RESTART_PREV}/${restart_date:0:8}.${restart_date:8:2}0000.ufs.cpld.cpl.r.nc" + fi - fi # [[ "${warm_start}" == ".true." ]]; + # Copy CMEPS restarts + if [[ -f "${cmeps_restart_file}" ]]; then + cpreq "${cmeps_restart_file}" "${DATA}/ufs.cpld.cpl.r.nc" + rm -f "${DATA}/rpointer.cpl" + touch "${DATA}/rpointer.cpl" + echo "ufs.cpld.cpl.r.nc" >> "${DATA}/rpointer.cpl" + else + # We have a choice to make here. + # Either we can FATAL ERROR out, or we can let the coupling fields initialize from zero + # cmeps_run_type is determined based on the availability of the CMEPS restart file + echo "WARNING: CMEPS restart file '${cmeps_restart_file}' not found for warm_start='${warm_start}', will initialize!" + if [[ "${RERUN}" == "YES" ]]; then + # In the case of a RERUN, the CMEPS restart file is required + echo "FATAL ERROR: CMEPS restart file '${cmeps_restart_file}' not found for RERUN='${RERUN}', ABORT!" + exit 1 + fi + fi - # For CMEPS, CICE, MOM6 and WW3 determine restart writes - # Note FV3 has its own restart intervals - cmeps_restart_interval=${restart_interval:-${FHMAX}} - # restart_interval = 0 implies write restart at the END of the forecast i.e. at FHMAX - # Convert restart interval into an explicit list for CMEPS/CICE/MOM6/WW3 - # Note, this must be computed after determination IAU in forecast_det and fhrot. - if (( cmeps_restart_interval == 0 )); then - if [[ "${DOIAU:-NO}" == "YES" ]]; then - CMEPS_RESTART_FH=$(( FHMAX + half_window )) - else - CMEPS_RESTART_FH=("${FHMAX}") - fi - else - if [[ "${DOIAU:-NO}" == "YES" ]]; then - if [[ "${MODE}" = "cycled" && "${SDATE}" = "${PDY}${cyc}" && ${EXP_WARM_START} = ".false." ]]; then - local restart_interval_start=${cmeps_restart_interval} - local restart_interval_end=${FHMAX} - else - local restart_interval_start=$(( cmeps_restart_interval + half_window )) - local restart_interval_end=$(( FHMAX + half_window )) - fi + fi # [[ "${warm_start}" == ".true." ]]; + + # For CMEPS, CICE, MOM6 and WW3 determine restart writes + # Note FV3 has its own restart intervals + cmeps_restart_interval=${restart_interval:-${FHMAX}} + # restart_interval = 0 implies write restart at the END of the forecast i.e. at FHMAX + # Convert restart interval into an explicit list for CMEPS/CICE/MOM6/WW3 + # Note, this must be computed after determination IAU in forecast_det and fhrot. + if ((cmeps_restart_interval == 0)); then + if [[ "${DOIAU:-NO}" == "YES" ]]; then + CMEPS_RESTART_FH=$((FHMAX + half_window)) + else + CMEPS_RESTART_FH=("${FHMAX}") + fi else - local restart_interval_start=${cmeps_restart_interval} - local restart_interval_end=${FHMAX} + if [[ "${DOIAU:-NO}" == "YES" ]]; then + if [[ "${MODE}" = "cycled" && "${SDATE}" = "${PDY}${cyc}" && ${EXP_WARM_START} = ".false." ]]; then + local restart_interval_start=${cmeps_restart_interval} + local restart_interval_end=${FHMAX} + else + local restart_interval_start=$((cmeps_restart_interval + half_window)) + local restart_interval_end=$((FHMAX + half_window)) + fi + else + local restart_interval_start=${cmeps_restart_interval} + local restart_interval_end=${FHMAX} + fi + CMEPS_RESTART_FH="$(seq -s ' ' "${restart_interval_start}" "${cmeps_restart_interval}" "${restart_interval_end}")" fi - CMEPS_RESTART_FH="$(seq -s ' ' "${restart_interval_start}" "${cmeps_restart_interval}" "${restart_interval_end}")" - fi - export CMEPS_RESTART_FH - # TODO: For GEFS, once cycling waves "self-cycles" and therefore needs to have a restart at 6 hour + export CMEPS_RESTART_FH + # TODO: For GEFS, once cycling waves "self-cycles" and therefore needs to have a restart at 6 hour } CMEPS_out() { - echo "SUB ${FUNCNAME[0]}: Copying output data for CMEPS mediator" - - case ${RUN} in - gdas|enkfgdas|enkfgfs) # Copy restarts for the next cycle to COM - local restart_date - restart_date="${model_start_date_next_cycle}" - echo "Copying mediator restarts for 'RUN=${RUN}' at ${restart_date}" - seconds=$(to_seconds "${restart_date:8:2}"0000) - source_file="ufs.cpld.cpl.r.${restart_date:0:4}-${restart_date:4:2}-${restart_date:6:2}-${seconds}.nc" - target_file="${restart_date:0:8}.${restart_date:8:2}0000.ufs.cpld.cpl.r.nc" - if [[ -f "${DATArestart}/CMEPS_RESTART/${source_file}" ]]; then - cpfs "${DATArestart}/CMEPS_RESTART/${source_file}" \ - "${COMOUT_MED_RESTART}/${target_file}" - else - echo "Mediator restart '${DATArestart}/CMEPS_RESTART/${source_file}' not found." - fi - ;; - gfs|gefs|sfs|gcafs) # Copy mediator restarts at the end of the forecast segment - if [[ "${COPY_FINAL_RESTARTS}" == "YES" ]]; then - echo "Copying mediator restarts for 'RUN=${RUN}' at ${forecast_end_cycle}" - local seconds source_file target_file - seconds=$(to_seconds "${forecast_end_cycle:8:2}"0000) - source_file="ufs.cpld.cpl.r.${forecast_end_cycle:0:4}-${forecast_end_cycle:4:2}-${forecast_end_cycle:6:2}-${seconds}.nc" - target_file="${forecast_end_cycle:0:8}.${forecast_end_cycle:8:2}0000.ufs.cpld.cpl.r.nc" - if [[ -f "${DATArestart}/CMEPS_RESTART/${source_file}" ]]; then - cpfs "${DATArestart}/CMEPS_RESTART/${source_file}" \ - "${COMOUT_MED_RESTART}/${target_file}" - else - echo "Mediator restart '${DATArestart}/CMEPS_RESTART/${source_file}' not found." - fi - fi - ;; - *) - echo "FATAL ERROR: Not sure how to copy restart files for RUN ${RUN}" - exit 25 - ;; - esac + echo "SUB ${FUNCNAME[0]}: Copying output data for CMEPS mediator" + + case ${RUN} in + gdas | enkfgdas | enkfgfs) # Copy restarts for the next cycle to COM + local restart_date + restart_date="${model_start_date_next_cycle}" + echo "Copying mediator restarts for 'RUN=${RUN}' at ${restart_date}" + seconds=$(to_seconds "${restart_date:8:2}"0000) + source_file="ufs.cpld.cpl.r.${restart_date:0:4}-${restart_date:4:2}-${restart_date:6:2}-${seconds}.nc" + target_file="${restart_date:0:8}.${restart_date:8:2}0000.ufs.cpld.cpl.r.nc" + if [[ -f "${DATArestart}/CMEPS_RESTART/${source_file}" ]]; then + cpfs "${DATArestart}/CMEPS_RESTART/${source_file}" \ + "${COMOUT_MED_RESTART}/${target_file}" + else + echo "Mediator restart '${DATArestart}/CMEPS_RESTART/${source_file}' not found." + fi + ;; + gfs | gefs | sfs | gcafs) # Copy mediator restarts at the end of the forecast segment + if [[ "${COPY_FINAL_RESTARTS}" == "YES" ]]; then + echo "Copying mediator restarts for 'RUN=${RUN}' at ${forecast_end_cycle}" + local seconds source_file target_file + seconds=$(to_seconds "${forecast_end_cycle:8:2}"0000) + source_file="ufs.cpld.cpl.r.${forecast_end_cycle:0:4}-${forecast_end_cycle:4:2}-${forecast_end_cycle:6:2}-${seconds}.nc" + target_file="${forecast_end_cycle:0:8}.${forecast_end_cycle:8:2}0000.ufs.cpld.cpl.r.nc" + if [[ -f "${DATArestart}/CMEPS_RESTART/${source_file}" ]]; then + cpfs "${DATArestart}/CMEPS_RESTART/${source_file}" \ + "${COMOUT_MED_RESTART}/${target_file}" + else + echo "Mediator restart '${DATArestart}/CMEPS_RESTART/${source_file}' not found." + fi + fi + ;; + *) + echo "FATAL ERROR: Not sure how to copy restart files for RUN ${RUN}" + exit 25 + ;; + esac } diff --git a/ush/forecast_predet.sh b/ush/forecast_predet.sh index 905ae85b351..3a59f8b7889 100755 --- a/ush/forecast_predet.sh +++ b/ush/forecast_predet.sh @@ -1,757 +1,755 @@ #! /usr/bin/env bash to_seconds() { - # Function to convert HHMMSS to seconds since 00Z - local hhmmss hh mm ss seconds padded_seconds - hhmmss=${1:?} - hh=${hhmmss:0:2} - mm=${hhmmss:2:2} - ss=${hhmmss:4:2} - seconds=$((10#${hh}*3600+10#${mm}*60+10#${ss})) - padded_seconds=$(printf "%05d" "${seconds}") - echo "${padded_seconds}" + # Function to convert HHMMSS to seconds since 00Z + local hhmmss hh mm ss seconds padded_seconds + hhmmss=${1:?} + hh=${hhmmss:0:2} + mm=${hhmmss:2:2} + ss=${hhmmss:4:2} + seconds=$((10#${hh} * 3600 + 10#${mm} * 60 + 10#${ss})) + padded_seconds=$(printf "%05d" "${seconds}") + echo "${padded_seconds}" } -middle_date(){ - # Function to calculate mid-point date in YYYYMMDDHH between two dates also in YYYYMMDDHH - local date1 date2 date1s date2s dtsecsby2 mid_date - date1=${1:?} - date2=${2:?} - date1s=$(date --utc -d "${date1:0:8} ${date1:8:2}:00:00" +%s) - date2s=$(date --utc -d "${date2:0:8} ${date2:8:2}:00:00" +%s) - dtsecsby2=$(( $((date2s - date1s)) / 2 )) - mid_date=$(date --utc -d "${date1:0:8} ${date1:8:2} + ${dtsecsby2} seconds" +%Y%m%d%H%M%S) - echo "${mid_date:0:10}" +middle_date() { + # Function to calculate mid-point date in YYYYMMDDHH between two dates also in YYYYMMDDHH + local date1 date2 date1s date2s dtsecsby2 mid_date + date1=${1:?} + date2=${2:?} + date1s=$(date --utc -d "${date1:0:8} ${date1:8:2}:00:00" +%s) + date2s=$(date --utc -d "${date2:0:8} ${date2:8:2}:00:00" +%s) + dtsecsby2=$(($((date2s - date1s)) / 2)) + mid_date=$(date --utc -d "${date1:0:8} ${date1:8:2} + ${dtsecsby2} seconds" +%Y%m%d%H%M%S) + echo "${mid_date:0:10}" } -nhour(){ - # Function to calculate hours between two dates (This replicates prod-util NHOUR) - local date1 date2 seconds1 seconds2 hours - date1=${1:?} - date2=${2:?} - # Convert dates to UNIX timestamps - seconds1=$(date --utc -d "${date1:0:8} ${date1:8:2}:00:00" +%s) - seconds2=$(date --utc -d "${date2:0:8} ${date2:8:2}:00:00" +%s) - hours=$(( $((seconds1 - seconds2)) / 3600 )) # Calculate the difference in seconds and convert to hours - echo "${hours}" +nhour() { + # Function to calculate hours between two dates (This replicates prod-util NHOUR) + local date1 date2 seconds1 seconds2 hours + date1=${1:?} + date2=${2:?} + # Convert dates to UNIX timestamps + seconds1=$(date --utc -d "${date1:0:8} ${date1:8:2}:00:00" +%s) + seconds2=$(date --utc -d "${date2:0:8} ${date2:8:2}:00:00" +%s) + hours=$(($((seconds1 - seconds2)) / 3600)) # Calculate the difference in seconds and convert to hours + echo "${hours}" } -FV3_coldstarts(){ - # Function to return an comma-separated string of cold-start input files for FV3 - # Create an array of chgres-ed FV3 files - local fv3_input_files tile_files - fv3_input_files=(gfs_ctrl.nc) - tile_files=(gfs_data sfc_data) - local nn tt - for (( nn = 1; nn <= ntiles; nn++ )); do - for tt in "${tile_files[@]}"; do - fv3_input_files+=("${tt}.tile${nn}.nc") +FV3_coldstarts() { + # Function to return an comma-separated string of cold-start input files for FV3 + # Create an array of chgres-ed FV3 files + local fv3_input_files tile_files + fv3_input_files=(gfs_ctrl.nc) + tile_files=(gfs_data sfc_data) + local nn tt + for ((nn = 1; nn <= ntiles; nn++)); do + for tt in "${tile_files[@]}"; do + fv3_input_files+=("${tt}.tile${nn}.nc") + done done - done - # Create a comma separated string from array using IFS - IFS=, echo "${fv3_input_files[*]}" + # Create a comma separated string from array using IFS + IFS=, echo "${fv3_input_files[*]}" } -FV3_restarts(){ - # Function to return an comma-separated string of warm-start input files for FV3 - # Create an array of FV3 restart files - local fv3_restart_files tile_files - fv3_restart_files=(coupler.res fv_core.res.nc) - tile_files=(fv_core.res fv_srf_wnd.res fv_tracer.res phy_data sfc_data) - if [[ ${DO_CA:-"NO"} == "YES" ]]; then - tile_files+=(ca_data) - fi - local nn tt - for (( nn = 1; nn <= ntiles; nn++ )); do - for tt in "${tile_files[@]}"; do - fv3_restart_files+=("${tt}.tile${nn}.nc") +FV3_restarts() { + # Function to return an comma-separated string of warm-start input files for FV3 + # Create an array of FV3 restart files + local fv3_restart_files tile_files + fv3_restart_files=(coupler.res fv_core.res.nc) + tile_files=(fv_core.res fv_srf_wnd.res fv_tracer.res phy_data sfc_data) + if [[ ${DO_CA:-"NO"} == "YES" ]]; then + tile_files+=(ca_data) + fi + local nn tt + for ((nn = 1; nn <= ntiles; nn++)); do + for tt in "${tile_files[@]}"; do + fv3_restart_files+=("${tt}.tile${nn}.nc") + done done - done - # Create a comma separated string from array using IFS - IFS=, echo "${fv3_restart_files[*]}" + # Create a comma separated string from array using IFS + IFS=, echo "${fv3_restart_files[*]}" } -stoch_restarts(){ - # These only get copied for reruns - local stoch_restart_files - stoch_restart_files=( ) +stoch_restarts() { + # These only get copied for reruns + local stoch_restart_files + stoch_restart_files=() - if [[ "${DO_SPPT:-}" == "YES" || "${DO_SKEB:-}" == "YES" || \ + if [[ "${DO_SPPT:-}" == "YES" || "${DO_SKEB:-}" == "YES" || "${DO_SHUM:-}" == "YES" || "${DO_LAND_PERT:-}" == "YES" ]]; then - stoch_restart_files+=(atm_stoch.res.nc) - fi - if [[ "${DO_OCN:-}" == "YES" && ( "${DO_OCN_SPPT:-}" == "YES" || "${DO_OCN_PERT_EPBL}" == "YES" ) ]]; then - stoch_restart_files+=(ocn_stoch.res.nc) - fi - # Create a comma separated string from array using IFS - IFS=, echo "${stoch_restart_files[*]}" + stoch_restart_files+=(atm_stoch.res.nc) + fi + if [[ "${DO_OCN:-}" == "YES" && ("${DO_OCN_SPPT:-}" == "YES" || "${DO_OCN_PERT_EPBL}" == "YES") ]]; then + stoch_restart_files+=(ocn_stoch.res.nc) + fi + # Create a comma separated string from array using IFS + IFS=, echo "${stoch_restart_files[*]}" } # shellcheck disable=SC2034 -common_predet(){ - echo "SUB ${FUNCNAME[0]}: Defining variables for shared through model components" - - RUN=${RUN:-gdas} - rCDUMP=${rCDUMP:-${RUN}} - - ENSMEM=${ENSMEM:-000} - MEMBER=$(( 10#${ENSMEM:-"-1"} )) # -1: control, 0: ensemble mean, >0: ensemble member $MEMBER - - # Define significant cycles - half_window=$(( assim_freq / 2 )) - current_cycle="${PDY}${cyc}" - previous_cycle=$(date --utc -d "${current_cycle:0:8} ${current_cycle:8:2} - ${assim_freq} hours" +%Y%m%d%H) - next_cycle=$(date --utc -d "${current_cycle:0:8} ${current_cycle:8:2} + ${assim_freq} hours" +%Y%m%d%H) - current_cycle_begin=$(date --utc -d "${current_cycle:0:8} ${current_cycle:8:2} - ${half_window} hours" +%Y%m%d%H) - current_cycle_end=$(date --utc -d "${current_cycle:0:8} ${current_cycle:8:2} + ${half_window} hours" +%Y%m%d%H) - next_cycle_begin=$(date --utc -d "${next_cycle:0:8} ${next_cycle:8:2} - ${half_window} hours" +%Y%m%d%H) - forecast_end_cycle=$(date --utc -d "${current_cycle:0:8} ${current_cycle:8:2} + ${FHMAX} hours" +%Y%m%d%H) - - # Define model start date for current_cycle and next_cycle as the time the forecast will start - if [[ "${DOIAU:-NO}" == "YES" ]]; then - model_start_date_current_cycle="${current_cycle_begin}" - model_start_date_next_cycle="${next_cycle_begin}" - else - model_start_date_current_cycle=${current_cycle} - if [[ "${DO_AERO_ANL:-NO}" == "YES" ]]; then - # even without IAU we want 3-hourly restarts for FGAT - model_start_date_next_cycle="${next_cycle_begin}" +common_predet() { + echo "SUB ${FUNCNAME[0]}: Defining variables for shared through model components" + + RUN=${RUN:-gdas} + rCDUMP=${rCDUMP:-${RUN}} + + ENSMEM=${ENSMEM:-000} + MEMBER=$((10#${ENSMEM:-"-1"})) # -1: control, 0: ensemble mean, >0: ensemble member $MEMBER + + # Define significant cycles + half_window=$((assim_freq / 2)) + current_cycle="${PDY}${cyc}" + previous_cycle=$(date --utc -d "${current_cycle:0:8} ${current_cycle:8:2} - ${assim_freq} hours" +%Y%m%d%H) + next_cycle=$(date --utc -d "${current_cycle:0:8} ${current_cycle:8:2} + ${assim_freq} hours" +%Y%m%d%H) + current_cycle_begin=$(date --utc -d "${current_cycle:0:8} ${current_cycle:8:2} - ${half_window} hours" +%Y%m%d%H) + current_cycle_end=$(date --utc -d "${current_cycle:0:8} ${current_cycle:8:2} + ${half_window} hours" +%Y%m%d%H) + next_cycle_begin=$(date --utc -d "${next_cycle:0:8} ${next_cycle:8:2} - ${half_window} hours" +%Y%m%d%H) + forecast_end_cycle=$(date --utc -d "${current_cycle:0:8} ${current_cycle:8:2} + ${FHMAX} hours" +%Y%m%d%H) + + # Define model start date for current_cycle and next_cycle as the time the forecast will start + if [[ "${DOIAU:-NO}" == "YES" ]]; then + model_start_date_current_cycle="${current_cycle_begin}" + model_start_date_next_cycle="${next_cycle_begin}" else - model_start_date_next_cycle=${next_cycle} + model_start_date_current_cycle=${current_cycle} + if [[ "${DO_AERO_ANL:-NO}" == "YES" ]]; then + # even without IAU we want 3-hourly restarts for FGAT + model_start_date_next_cycle="${next_cycle_begin}" + else + model_start_date_next_cycle=${next_cycle} + fi fi - fi - FHMIN=${FHMIN:-0} - FHMAX=${FHMAX:-9} - FHOUT=${FHOUT:-3} - FHMAX_HF=${FHMAX_HF:-0} - FHOUT_HF=${FHOUT_HF:-1} + FHMIN=${FHMIN:-0} + FHMAX=${FHMAX:-9} + FHOUT=${FHOUT:-3} + FHMAX_HF=${FHMAX_HF:-0} + FHOUT_HF=${FHOUT_HF:-1} - if [[ ! -d "${COMOUT_CONF}" ]]; then mkdir -p "${COMOUT_CONF}"; fi + mkdir -p "${COMOUT_CONF}" - cd "${DATA}" && true - err=$? - if [[ ${err} -ne 0 ]]; then - echo "FATAL ERROR: Unable to 'cd ${DATA}', ABORT!" - exit 1 - fi + cd "${DATA}" && true + err=$? + if [[ ${err} -ne 0 ]]; then + echo "FATAL ERROR: Unable to 'cd ${DATA}', ABORT!" + exit 1 + fi - # Several model components share DATA/INPUT for input data - if [[ ! -d "${DATA}/INPUT" ]]; then mkdir -p "${DATA}/INPUT"; fi + # Several model components share DATA/INPUT for input data + mkdir -p "${DATA}/INPUT" } # shellcheck disable=SC2034 -FV3_predet(){ - echo "SUB ${FUNCNAME[0]}: Defining variables for FV3" - - if [[ ! -d "${COMOUT_ATMOS_HISTORY}" ]]; then mkdir -p "${COMOUT_ATMOS_HISTORY}"; fi - if [[ ! -d "${COMOUT_ATMOS_MASTER}" ]]; then mkdir -p "${COMOUT_ATMOS_MASTER}"; fi - if [[ ! -d "${COMOUT_ATMOS_RESTART}" ]]; then mkdir -p "${COMOUT_ATMOS_RESTART}"; fi - if [[ ! -d "${DATAoutput}/FV3ATM_OUTPUT" ]]; then mkdir -p "${DATAoutput}/FV3ATM_OUTPUT"; fi - if [[ ! -d "${DATArestart}/FV3_RESTART" ]]; then mkdir -p "${DATArestart}/FV3_RESTART"; fi - - # The $DATA/RESTART directory is used for writing FV3 restart files (it is hard-wired in the model) - # Link the output and restart directories to the DATA directory - ${NLN} "${DATAoutput}/FV3ATM_OUTPUT" "${DATA}/FV3ATM_OUTPUT" - ${NLN} "${DATArestart}/FV3_RESTART" "${DATA}/RESTART" - - FHZERO=${FHZERO:-6} - FHCYC=${FHCYC:-24} - - # Convert output settings into an explicit list for FV3 - # Create an FV3 fhr list to be used in the filenames - FV3_OUTPUT_FH="" - local fhr=${FHMIN} - if (( FHOUT_HF > 0 && FHMAX_HF > 0 )); then - FV3_OUTPUT_FH="${FV3_OUTPUT_FH} $(seq -s ' ' "${FHMIN}" "${FHOUT_HF}" "${FHMAX_HF}")" - fhr=${FHMAX_HF} - fi - FV3_OUTPUT_FH="${FV3_OUTPUT_FH} $(seq -s ' ' "${fhr}" "${FHOUT}" "${FHMAX}")" - - # If, FHOUT_HF == FHOUT, the FV3_OUTPUT_FH_NML can be cast as: - if [[ ${FHOUT_HF} -eq ${FHOUT} ]]; then - FV3_OUTPUT_FH_NML="${FHOUT} -1" - else - FV3_OUTPUT_FH_NML="${FV3_OUTPUT_FH}" - fi - - # IAU options - IAUFHRS=${IAUFHRS:-0} - IAU_DELTHRS=${IAU_DELTHRS:-0} - - #------------------------------------------------------------------ - # changeable parameters - # dycore definitions - res="${CASE:1}" - resh="${CASE_HIST:1}" - resp=$((res+1)) - npx=${resp} - npy=${resp} - npz=$((LEVS-1)) - io_layout="1,1" - #ncols=$(( (${npx}-1)*(${npy}-1)*3/2 )) - - # spectral truncation and regular grid resolution based on FV3 resolution - JCAP_CASE=$((2*res-2)) - LONB_CASE=$((4*res)) - LATB_CASE=$((2*res)) - - JCAP_CASE_HIST=$((2*resh-2)) - LONB_CASE_HIST=$((4*resh)) - LATB_CASE_HIST=$((2*resh)) - - JCAP=${JCAP:-${JCAP_CASE}} - LONB=${LONB:-${LONB_CASE}} - LATB=${LATB:-${LATB_CASE}} - - LONB_IMO=${LONB_IMO:-${LONB_CASE_HIST}} - LATB_JMO=${LATB_JMO:-${LATB_CASE_HIST}} - - # NSST Options - # nstf_name contains the NSST related parameters - # nstf_name(1) : NST_MODEL (NSST Model) : 0 = OFF, 1 = ON but uncoupled, 2 = ON and coupled - # nstf_name(2) : NST_SPINUP : 0 = OFF, 1 = ON, - # nstf_name(3) : NST_RESV (Reserved, NSST Analysis) : 0 = OFF, 1 = ON - # nstf_name(4) : ZSEA1 (in mm) : 0 - # nstf_name(5) : ZSEA2 (in mm) : 0 - # nst_anl : .true. or .false., NSST analysis over lake - NST_MODEL=${NST_MODEL:-0} - NST_SPINUP=${NST_SPINUP:-0} - NST_RESV=${NST_RESV-0} - ZSEA1=${ZSEA1:-0} - ZSEA2=${ZSEA2:-0} - nstf_name=${nstf_name:-"${NST_MODEL},${NST_SPINUP},${NST_RESV},${ZSEA1},${ZSEA2}"} - nst_anl=${nst_anl:-".false."} - - # blocking factor used for threading and general physics performance - #nyblocks=$(expr \( $npy - 1 \) \/ $layout_y ) - #nxblocks=$(expr \( $npx - 1 \) \/ $layout_x \/ 32) - #if [ $nxblocks -le 0 ]; then nxblocks=1 ; fi - blocksize=${blocksize:-32} - - # variables for controlling initialization of NCEP/NGGPS ICs - filtered_terrain=${filtered_terrain:-".true."} - gfs_dwinds=${gfs_dwinds:-".true."} - - # various debug options - no_dycore=${no_dycore:-".false."} - dycore_only=${adiabatic:-".false."} - chksum_debug=${chksum_debug:-".false."} - print_freq=${print_freq:-6} - - # the pre-conditioning of the solution - # =0 implies no pre-conditioning - # >0 means new adiabatic pre-conditioning - # <0 means older adiabatic pre-conditioning - na_init=${na_init:-1} - - local suite_file="${HOMEgfs}/sorc/ufs_model.fd/UFSATM/ccpp/suites/suite_${CCPP_SUITE}.xml" - if [[ ! -f "${suite_file}" ]]; then - echo "FATAL ERROR: CCPP Suite file ${suite_file} does not exist, ABORT!" - exit 2 - fi - - # Scan suite file to determine whether it uses Noah-MP - local num_noahmpdrv - num_noahmpdrv=$(grep -c noahmpdrv "${suite_file}") - if (( num_noahmpdrv > 0 )); then - lsm="2" - lheatstrg=".false." - landice=".false." - iopt_dveg=${iopt_dveg:-"4"} - iopt_crs=${iopt_crs:-"2"} - iopt_btr=${iopt_btr:-"1"} - iopt_run=${iopt_run:-"1"} - iopt_sfc=${iopt_sfc:-"1"} - iopt_frz=${iopt_frz:-"1"} - iopt_inf=${iopt_inf:-"1"} - iopt_rad=${iopt_rad:-"3"} - iopt_alb=${iopt_alb:-"1"} - iopt_snf=${iopt_snf:-"4"} - iopt_tbot=${iopt_tbot:-"2"} - iopt_stc=${iopt_stc:-"3"} - IALB=${IALB:-2} - IEMS=${IEMS:-2} - else - lsm="1" - lheatstrg=".true." - landice=".true." - iopt_dveg=${iopt_dveg:-"1"} - iopt_crs=${iopt_crs:-"1"} - iopt_btr=${iopt_btr:-"1"} - iopt_run=${iopt_run:-"1"} - iopt_sfc=${iopt_sfc:-"1"} - iopt_frz=${iopt_frz:-"1"} - iopt_inf=${iopt_inf:-"1"} - iopt_rad=${iopt_rad:-"1"} - iopt_alb=${iopt_alb:-"2"} - iopt_snf=${iopt_snf:-"4"} - iopt_tbot=${iopt_tbot:-"2"} - iopt_stc=${iopt_stc:-"1"} - IALB=${IALB:-1} - IEMS=${IEMS:-1} - fi - - if [[ "${TYPE}" == "nh" ]]; then # non-hydrostatic options - hydrostatic=".false." - phys_hydrostatic=".false." # enable heating in hydrostatic balance in non-hydrostatic simulation - use_hydro_pressure=".false." # use hydrostatic pressure for physics - make_nh=".true." # running in non-hydrostatic mode - pass_full_omega_to_physics_in_non_hydrostatic_mode=".true." - else # hydrostatic options - hydrostatic=".true." - phys_hydrostatic=".false." # ignored when hydrostatic = T - use_hydro_pressure=".false." # ignored when hydrostatic = T - make_nh=".false." # running in hydrostatic mode - fi - - # Conserve total energy as heat globally - consv_te=${consv_te:-1.} # range 0.-1., 1. will restore energy to orig. val. before physics - if [[ "${DO_NEST:-NO}" == "YES" ]] ; then - consv_te=0 - k_split=${k_split:-1} - k_split_nest=${k_split_nest:-4} - else +FV3_predet() { + echo "SUB ${FUNCNAME[0]}: Defining variables for FV3" + + if [[ ! -d "${COMOUT_ATMOS_HISTORY}" ]]; then mkdir -p "${COMOUT_ATMOS_HISTORY}"; fi + if [[ ! -d "${COMOUT_ATMOS_MASTER}" ]]; then mkdir -p "${COMOUT_ATMOS_MASTER}"; fi + if [[ ! -d "${COMOUT_ATMOS_RESTART}" ]]; then mkdir -p "${COMOUT_ATMOS_RESTART}"; fi + if [[ ! -d "${DATAoutput}/FV3ATM_OUTPUT" ]]; then mkdir -p "${DATAoutput}/FV3ATM_OUTPUT"; fi + if [[ ! -d "${DATArestart}/FV3_RESTART" ]]; then mkdir -p "${DATArestart}/FV3_RESTART"; fi + + # The $DATA/RESTART directory is used for writing FV3 restart files (it is hard-wired in the model) + # Link the output and restart directories to the DATA directory + ${NLN} "${DATAoutput}/FV3ATM_OUTPUT" "${DATA}/FV3ATM_OUTPUT" + ${NLN} "${DATArestart}/FV3_RESTART" "${DATA}/RESTART" + + FHZERO=${FHZERO:-6} + FHCYC=${FHCYC:-24} + + # Convert output settings into an explicit list for FV3 + # Create an FV3 fhr list to be used in the filenames + FV3_OUTPUT_FH="" + local fhr=${FHMIN} + if [[ "${FHOUT_HF}" -gt 0 && "${FHMAX_HF}" -gt 0 ]]; then + FV3_OUTPUT_FH="${FV3_OUTPUT_FH} $(seq -s ' ' "${FHMIN}" "${FHOUT_HF}" "${FHMAX_HF}")" + fhr=${FHMAX_HF} + fi + FV3_OUTPUT_FH="${FV3_OUTPUT_FH} $(seq -s ' ' "${fhr}" "${FHOUT}" "${FHMAX}")" + + if [[ "${FHOUT_HF}" -eq "${FHOUT}" ]]; then + FV3_OUTPUT_FH_NML="${FHOUT} -1" + else + FV3_OUTPUT_FH_NML="${FV3_OUTPUT_FH}" + fi + + # IAU options + IAUFHRS=${IAUFHRS:-0} + IAU_DELTHRS=${IAU_DELTHRS:-0} + + #------------------------------------------------------------------ + # changeable parameters + # dycore definitions + res="${CASE:1}" + resh="${CASE_HIST:1}" + resp=$((res + 1)) + npx=${resp} + npy=${resp} + npz=$((LEVS - 1)) + io_layout="1,1" + #ncols=$(( (${npx}-1)*(${npy}-1)*3/2 )) + + # spectral truncation and regular grid resolution based on FV3 resolution + JCAP_CASE=$((2 * res - 2)) + LONB_CASE=$((4 * res)) + LATB_CASE=$((2 * res)) + + JCAP_CASE_HIST=$((2 * resh - 2)) + LONB_CASE_HIST=$((4 * resh)) + LATB_CASE_HIST=$((2 * resh)) + + JCAP=${JCAP:-${JCAP_CASE}} + LONB=${LONB:-${LONB_CASE}} + LATB=${LATB:-${LATB_CASE}} + + LONB_IMO=${LONB_IMO:-${LONB_CASE_HIST}} + LATB_JMO=${LATB_JMO:-${LATB_CASE_HIST}} + + # NSST Options + # nstf_name contains the NSST related parameters + # nstf_name(1) : NST_MODEL (NSST Model) : 0 = OFF, 1 = ON but uncoupled, 2 = ON and coupled + # nstf_name(2) : NST_SPINUP : 0 = OFF, 1 = ON, + # nstf_name(3) : NST_RESV (Reserved, NSST Analysis) : 0 = OFF, 1 = ON + # nstf_name(4) : ZSEA1 (in mm) : 0 + # nstf_name(5) : ZSEA2 (in mm) : 0 + # nst_anl : .true. or .false., NSST analysis over lake + NST_MODEL=${NST_MODEL:-0} + NST_SPINUP=${NST_SPINUP:-0} + NST_RESV=${NST_RESV-0} + ZSEA1=${ZSEA1:-0} + ZSEA2=${ZSEA2:-0} + nstf_name=${nstf_name:-"${NST_MODEL},${NST_SPINUP},${NST_RESV},${ZSEA1},${ZSEA2}"} + nst_anl=${nst_anl:-".false."} + + # blocking factor used for threading and general physics performance + #nyblocks=$(expr \( $npy - 1 \) \/ $layout_y ) + #nxblocks=$(expr \( $npx - 1 \) \/ $layout_x \/ 32) + #if [[ $nxblocks -le 0 ]]; then nxblocks=1 ; fi + blocksize=${blocksize:-32} + + # variables for controlling initialization of NCEP/NGGPS ICs + filtered_terrain=${filtered_terrain:-".true."} + gfs_dwinds=${gfs_dwinds:-".true."} + + # various debug options + no_dycore=${no_dycore:-".false."} + dycore_only=${adiabatic:-".false."} + chksum_debug=${chksum_debug:-".false."} + print_freq=${print_freq:-6} + + # the pre-conditioning of the solution + # =0 implies no pre-conditioning + # >0 means new adiabatic pre-conditioning + # <0 means older adiabatic pre-conditioning + na_init=${na_init:-1} + + local suite_file="${HOMEgfs}/sorc/ufs_model.fd/UFSATM/ccpp/suites/suite_${CCPP_SUITE}.xml" + if [[ ! -f "${suite_file}" ]]; then + echo "FATAL ERROR: CCPP Suite file ${suite_file} does not exist, ABORT!" + exit 2 + fi + + # Scan suite file to determine whether it uses Noah-MP + local num_noahmpdrv + num_noahmpdrv=$(grep -c noahmpdrv "${suite_file}") + if [[ "${num_noahmpdrv}" -gt 0 ]]; then + lsm="2" + lheatstrg=".false." + landice=".false." + iopt_dveg=${iopt_dveg:-"4"} + iopt_crs=${iopt_crs:-"2"} + iopt_btr=${iopt_btr:-"1"} + iopt_run=${iopt_run:-"1"} + iopt_sfc=${iopt_sfc:-"1"} + iopt_frz=${iopt_frz:-"1"} + iopt_inf=${iopt_inf:-"1"} + iopt_rad=${iopt_rad:-"3"} + iopt_alb=${iopt_alb:-"1"} + iopt_snf=${iopt_snf:-"4"} + iopt_tbot=${iopt_tbot:-"2"} + iopt_stc=${iopt_stc:-"3"} + IALB=${IALB:-2} + IEMS=${IEMS:-2} + else + lsm="1" + lheatstrg=".true." + landice=".true." + iopt_dveg=${iopt_dveg:-"1"} + iopt_crs=${iopt_crs:-"1"} + iopt_btr=${iopt_btr:-"1"} + iopt_run=${iopt_run:-"1"} + iopt_sfc=${iopt_sfc:-"1"} + iopt_frz=${iopt_frz:-"1"} + iopt_inf=${iopt_inf:-"1"} + iopt_rad=${iopt_rad:-"1"} + iopt_alb=${iopt_alb:-"2"} + iopt_snf=${iopt_snf:-"4"} + iopt_tbot=${iopt_tbot:-"2"} + iopt_stc=${iopt_stc:-"1"} + IALB=${IALB:-1} + IEMS=${IEMS:-1} + fi + + if [[ "${TYPE}" == "nh" ]]; then # non-hydrostatic options + hydrostatic=".false." + phys_hydrostatic=".false." # enable heating in hydrostatic balance in non-hydrostatic simulation + use_hydro_pressure=".false." # use hydrostatic pressure for physics + make_nh=".true." # running in non-hydrostatic mode + pass_full_omega_to_physics_in_non_hydrostatic_mode=".true." + else # hydrostatic options + hydrostatic=".true." + phys_hydrostatic=".false." # ignored when hydrostatic = T + use_hydro_pressure=".false." # ignored when hydrostatic = T + make_nh=".false." # running in hydrostatic mode + fi + + # Conserve total energy as heat globally consv_te=${consv_te:-1.} # range 0.-1., 1. will restore energy to orig. val. before physics - k_split=${k_split:-2} - fi - - # time step parameters in FV3 - n_split=${n_split:-5} - - if [[ "${MONO:0:4}" == "mono" ]]; then # monotonic options - d_con=${d_con_mono:-"0."} - do_vort_damp=".false." - if [[ "${TYPE}" == "nh" ]]; then # monotonic and non-hydrostatic - hord_mt=${hord_mt_nh_mono:-"10"} - hord_xx=${hord_xx_nh_mono:-"10"} - hord_dp=${hord_xx_nh_mono:-"10"} - else # monotonic and hydrostatic - hord_mt=${hord_mt_hydro_mono:-"10"} - hord_xx=${hord_xx_hydro_mono:-"10"} - hord_dp=${hord_xx_hydro_mono:-"10"} - kord_tm=${kord_tm_hydro_mono:-"-12"} - kord_mt=${kord_mt_hydro_mono:-"12"} - kord_wz=${kord_wz_hydro_mono:-"12"} - kord_tr=${kord_tr_hydro_mono:-"12"} - fi - else # non-monotonic options - d_con=${d_con_nonmono:-"1."} - do_vort_damp=".true." - if [[ "${TYPE}" == "nh" ]]; then # non-monotonic and non-hydrostatic - hord_mt=${hord_mt_nh_nonmono:-"5"} - hord_xx=${hord_xx_nh_nonmono:-"5"} - hord_dp=${hord_dp_nh_nonmono:-"-5"} - else # non-monotonic and hydrostatic - hord_mt=${hord_mt_hydro_nonmono:-"10"} - hord_xx=${hord_xx_hydro_nonmono:-"10"} - hord_dp=${hord_xx_hydro_nonmono:-"10"} - fi - fi - - if [[ "${MONO:0:4}" != "mono" && "${TYPE}" == "nh" ]]; then - vtdm4=${vtdm4_nh_nonmono:-"0.06"} - else - vtdm4=${vtdm4:-"0.05"} - fi - - # Initial conditions are chgres-ed from GFS analysis file - nggps_ic=${nggps_ic:-".true."} - ncep_ic=${ncep_ic:-".false."} - external_ic=".true." - mountain=".false." - warm_start=".false." - read_increment=".false." - res_latlon_dynamics='""' - increment_file_on_native_grid=".false." - - # Stochastic Physics Options - do_skeb=".false." - do_shum=".false." - do_sppt=".false." - do_ca=".false." - ISEED=0 - local imem=${MEMBER#0} - local base_seed=$((current_cycle*10000 + imem*100)) - - if [[ "${DO_SKEB:-}" == "YES" ]]; then - do_skeb=".true." - ISEED_SKEB=$((base_seed + 1)) - fi - - if [[ "${DO_SHUM:-}" == "YES" ]]; then - do_shum=".true." - ISEED_SHUM=$((base_seed + 2)) - fi - - if [[ "${DO_SPPT:-}" == "YES" ]]; then - do_sppt=".true." - ISEED_SPPT=$((base_seed + 3)),$((base_seed + 4)),$((base_seed + 5)),$((base_seed + 6)),$((base_seed + 7)) - fi - - if [[ "${DO_CA:-}" == "YES" ]]; then - do_ca=".true." - ISEED_CA=$(( (base_seed + 18) % 2147483647 )) - fi - - if [[ "${DO_LAND_PERT:-}" == "YES" ]]; then - lndp_type=${lndp_type:-2} - ISEED_LNDP=$(( (base_seed + 5) % 2147483647 )) - LNDP_TAU=${LNDP_TAU:-21600} - LNDP_SCALE=${LNDP_SCALE:-500000} - lndp_var_list=${lndp_var_list:-"'smc', 'vgf',"} - lndp_prt_list=${lndp_prt_list:-"0.2,0.1"} - n_var_lndp=$(echo "${lndp_var_list}" | wc -w) - fi - - #-------------------------------------------------------------------------- - - # Fix files - FNGLAC=${FNGLAC:-"${FIXgfs}/am/global_glacier.2x2.grb"} - FNMXIC=${FNMXIC:-"${FIXgfs}/am/global_maxice.2x2.grb"} - FNTSFC=${FNTSFC:-"${FIXgfs}/am/RTGSST.1982.2012.monthly.clim.grb"} - FNSNOC=${FNSNOC:-"${FIXgfs}/am/global_snoclim.1.875.grb"} - FNZORC=${FNZORC:-"igbp"} - FNAISC=${FNAISC:-"${FIXgfs}/am/IMS-NIC.blended.ice.monthly.clim.grb"} - FNALBC2=${FNALBC2:-"${FIXorog}/${CASE}/sfc/${CASE}.mx${OCNRES}.facsf.tileX.nc"} - FNTG3C=${FNTG3C:-"${FIXorog}/${CASE}/sfc/${CASE}.mx${OCNRES}.substrate_temperature.tileX.nc"} - FNVEGC=${FNVEGC:-"${FIXorog}/${CASE}/sfc/${CASE}.mx${OCNRES}.vegetation_greenness.tileX.nc"} - FNMSKH=${FNMSKH:-"${FIXgfs}/am/global_slmask.t1534.3072.1536.grb"} - FNVMNC=${FNVMNC:-"${FIXorog}/${CASE}/sfc/${CASE}.mx${OCNRES}.vegetation_greenness.tileX.nc"} - FNVMXC=${FNVMXC:-"${FIXorog}/${CASE}/sfc/${CASE}.mx${OCNRES}.vegetation_greenness.tileX.nc"} - FNSLPC=${FNSLPC:-"${FIXorog}/${CASE}/sfc/${CASE}.mx${OCNRES}.slope_type.tileX.nc"} - FNALBC=${FNALBC:-"${FIXorog}/${CASE}/sfc/${CASE}.mx${OCNRES}.snowfree_albedo.tileX.nc"} - FNVETC=${FNVETC:-"${FIXorog}/${CASE}/sfc/${CASE}.mx${OCNRES}.vegetation_type.tileX.nc"} - FNSOTC=${FNSOTC:-"${FIXorog}/${CASE}/sfc/${CASE}.mx${OCNRES}.soil_type.tileX.nc"} - FNSOCC=${FNSOCC:-"${FIXorog}/${CASE}/sfc/${CASE}.mx${OCNRES}.soil_color.tileX.nc"} - FNABSC=${FNABSC:-"${FIXorog}/${CASE}/sfc/${CASE}.mx${OCNRES}.maximum_snow_albedo.tileX.nc"} - FNSMCC=${FNSMCC:-"${FIXgfs}/am/global_soilmgldas.statsgo.t${JCAP}.${LONB}.${LATB}.grb"} - - # If the appropriate resolution fix file is not present, use the highest resolution available (T1534) - if [[ ! -f "${FNSMCC}" ]]; then - FNSMCC="${FIXgfs}/am/global_soilmgldas.statsgo.t1534.3072.1536.grb" - fi - - # Grid and orography data - if [[ "${cplflx}" == ".false." ]] ; then - cpreq "${FIXorog}/${CASE}/${CASE}_mosaic.nc" "${DATA}/INPUT/grid_spec.nc" - else - cpreq "${FIXorog}/${CASE}/${CASE}_mosaic.nc" "${DATA}/INPUT/${CASE}_mosaic.nc" - fi - - # Files for GWD - cpreq "${FIXugwd}/ugwp_limb_tau.nc" "${DATA}/ugwp_limb_tau.nc" - - # Files for orography, GWD tiles - local tt - for (( tt = 1; tt <= ntiles; tt++ )); do - cpreq "${FIXorog}/${CASE}/${CASE}.mx${OCNRES}_oro_data.tile${tt}.nc" "${DATA}/INPUT/oro_data.tile${tt}.nc" - cpreq "${FIXorog}/${CASE}/${CASE}_grid.tile${tt}.nc" "${DATA}/INPUT/${CASE}_grid.tile${tt}.nc" - cpreq "${FIXugwd}/${CASE}/${CASE}_oro_data_ls.tile${tt}.nc" "${DATA}/INPUT/oro_data_ls.tile${tt}.nc" - cpreq "${FIXugwd}/${CASE}/${CASE}_oro_data_ss.tile${tt}.nc" "${DATA}/INPUT/oro_data_ss.tile${tt}.nc" - done - if [[ "${DO_NEST:-NO}" == "YES" ]] ; then - ${NLN} "${DATA}/INPUT/oro_data.tile7.nc" "${DATA}/INPUT/oro_data.nest02.tile7.nc" - ${NLN} "${DATA}/INPUT/${CASE}_grid.tile7.nc" "${DATA}/INPUT/${CASE}_grid.nest02.tile7.nc" - ${NLN} "${DATA}/INPUT/${CASE}_grid.tile7.nc" "${DATA}/INPUT/grid.nest02.tile7.nc" - ${NLN} "${DATA}/INPUT/oro_data_ls.tile7.nc" "${DATA}/INPUT/oro_data_ls.nest02.tile7.nc" - ${NLN} "${DATA}/INPUT/oro_data_ss.tile7.nc" "${DATA}/INPUT/oro_data_ss.nest02.tile7.nc" - fi - - # NoahMP table - local noahmptablefile="${PARMgfs}/ufs/noahmptable.tbl" - cpreq "${noahmptablefile}" "${DATA}/noahmptable.tbl" - - # Thompson microphysics fix files - if (( imp_physics == 8 )); then - cpreq "${FIXgfs}/am/CCN_ACTIVATE.BIN" "${DATA}/CCN_ACTIVATE.BIN" - cpreq "${FIXgfs}/am/freezeH2O.dat" "${DATA}/freezeH2O.dat" - cpreq "${FIXgfs}/am/qr_acr_qgV2.dat" "${DATA}/qr_acr_qgV2.dat" - cpreq "${FIXgfs}/am/qr_acr_qsV2.dat" "${DATA}/qr_acr_qsV2.dat" - fi - - if [[ "${new_o3forc:-YES}" == "YES" ]]; then - if [[ "${o3forc_params:-McCormack}" == "McCormack-empirical-sh-ozh" ]]; then - O3FORC="ozprdlos_2015_new_sbuvO3_tclm15_nuchem_shozhvlogp.f77" + if [[ "${DO_NEST:-NO}" == "YES" ]]; then + consv_te=0 + k_split=${k_split:-1} + k_split_nest=${k_split_nest:-4} else - O3FORC="ozprdlos_2015_new_sbuvO3_tclm15_nuchem.f77" - fi - else - O3FORC="global_o3prdlos.f77" - fi - H2OFORC=${H2OFORC:-"global_h2o_pltc.f77"} - cpreq "${FIXgfs}/am/${O3FORC}" "${DATA}/global_o3prdlos.f77" - cpreq "${FIXgfs}/am/${H2OFORC}" "${DATA}/global_h2oprdlos.f77" - - # GFS standard input data - - ISOL=${ISOL:-2} - - cpreq "${FIXgfs}/am/global_solarconstant_noaa_an.txt" "${DATA}/solarconstant_noaa_an.txt" - cpreq "${FIXgfs}/am/global_sfc_emissivity_idx.txt" "${DATA}/sfc_emissivity_idx.txt" - - # Aerosol options - IAER=${IAER:-1011} - MERRA2_6ym=${MERRA2_6ym:-".false."} - ## merra2 aerosol climo - if (( IAER == 1011 )); then - if [[ "${MERRA2_6ym}" == ".false." ]]; then -# local month mm - for (( month = 1; month <=12; month++ )); do - mm=$(printf %02d "${month}") - cpreq "${FIXgfs}/aer/merra2.aerclim.2014-2023.m${mm}.nc" "aeroclim.m${mm}.nc" - done - elif [[ "${MERRA2_6ym}" == ".true." ]]; then - year=${current_cycle:0:4} - for i in {1980..2300..5} - do - if [[ ${year} -le ${i} ]] - then - Eyear=$(printf %04d "${i}") - Syear=$(( i - 5 )) - break + consv_te=${consv_te:-1.} # range 0.-1., 1. will restore energy to orig. val. before physics + k_split=${k_split:-2} + fi + + # time step parameters in FV3 + n_split=${n_split:-5} + + if [[ "${MONO:0:4}" == "mono" ]]; then # monotonic options + d_con=${d_con_mono:-"0."} + do_vort_damp=".false." + if [[ "${TYPE}" == "nh" ]]; then # monotonic and non-hydrostatic + hord_mt=${hord_mt_nh_mono:-"10"} + hord_xx=${hord_xx_nh_mono:-"10"} + hord_dp=${hord_xx_nh_mono:-"10"} + else # monotonic and hydrostatic + hord_mt=${hord_mt_hydro_mono:-"10"} + hord_xx=${hord_xx_hydro_mono:-"10"} + hord_dp=${hord_xx_hydro_mono:-"10"} + kord_tm=${kord_tm_hydro_mono:-"-12"} + kord_mt=${kord_mt_hydro_mono:-"12"} + kord_wz=${kord_wz_hydro_mono:-"12"} + kord_tr=${kord_tr_hydro_mono:-"12"} fi - done - for (( month = 1; month <=12; month++ )); do - mm=$(printf %02d "${month}") - cpreq "${FIXgfs}/aer/y${Syear}-${Eyear}/merra2_${Syear}-${Eyear}_${mm}.nc" "aeroclim.m${mm}.nc" - done - fi # if [[ "${MERRA2_6ym}" == ".true." ]]; - fi # if (( IAER == 1011 )) - - cpreq "${FIXgfs}/am/global_climaeropac_global.txt" "${DATA}/aerosol.dat" - if (( IAER > 0 )) ; then - local file - for file in "${FIXgfs}/am/global_volcanic_aerosols"* ; do - cpreq "${file}" "${DATA}/$(basename "${file//global_}")" - done - fi - - cpreq "${FIXgfs}/lut/optics_BC.v1_3.dat" "${DATA}/optics_BC.dat" - cpreq "${FIXgfs}/lut/optics_OC.v1_3.dat" "${DATA}/optics_OC.dat" - cpreq "${FIXgfs}/lut/optics_DU.v15_3.dat" "${DATA}/optics_DU.dat" - cpreq "${FIXgfs}/lut/optics_SS.v3_3.dat" "${DATA}/optics_SS.dat" - cpreq "${FIXgfs}/lut/optics_SU.v1_3.dat" "${DATA}/optics_SU.dat" - - # CO2 options - ICO2=${ICO2:-2} - - cpreq "${FIXgfs}/am/global_co2historicaldata_glob.txt" "${DATA}/co2historicaldata_glob.txt" - cpreq "${FIXgfs}/am/co2monthlycyc.txt" "${DATA}/co2monthlycyc.txt" - # Set historical CO2 values based on whether this is a reforecast run or not - # Ref. issue 2403 - local co2dir - co2dir="fix_co2_proj" - if [[ "${reforecast:-}" == "YES" ]]; then - co2dir="co2dat_4a" - fi - if (( ICO2 > 0 )); then - local file - for file in "${FIXgfs}/am/${co2dir}/global_co2historicaldata"* ; do - cpreq "${file}" "${DATA}/$(basename "${file//global_}")" - done - fi - - # Inline UPP fix files - if [[ "${WRITE_DOPOST:-}" == ".true." ]]; then - cpreq "${POSTGRB2TBL:-${PARMgfs}/post/params_grib2_tbl_new}" "${DATA}/params_grib2_tbl_new" - cpreq "${PARMgfs}/ufs/post_itag_gfs" "${DATA}/itag" # TODO: Need a GEFS version when available in the UFS-weather-model - # TODO: These should be replaced with ones from the ufs-weather-model when available there - case ${NET} in - gfs|gcafs) - cpreq "${PARMgfs}/post/gfs/postxconfig-NT-gfs-two.txt" "${DATA}/postxconfig-NT.txt" - cpreq "${PARMgfs}/post/gfs/postxconfig-NT-gfs-f00-two.txt" "${DATA}/postxconfig-NT_FH00.txt" - ;; - gefs) - cpreq "${PARMgfs}/post/gefs/postxconfig-NT-gefs.txt" "${DATA}/postxconfig-NT.txt" - cpreq "${PARMgfs}/post/gefs/postxconfig-NT-gefs-f00.txt" "${DATA}/postxconfig-NT_FH00.txt" - # Provide ensemble header information for GEFS - if [[ "${ENSMEM}" == "000" ]]; then - export e1=1 - else - export e1=3 + else # non-monotonic options + d_con=${d_con_nonmono:-"1."} + do_vort_damp=".true." + if [[ "${TYPE}" == "nh" ]]; then # non-monotonic and non-hydrostatic + hord_mt=${hord_mt_nh_nonmono:-"5"} + hord_xx=${hord_xx_nh_nonmono:-"5"} + hord_dp=${hord_dp_nh_nonmono:-"-5"} + else # non-monotonic and hydrostatic + hord_mt=${hord_mt_hydro_nonmono:-"10"} + hord_xx=${hord_xx_hydro_nonmono:-"10"} + hord_dp=${hord_xx_hydro_nonmono:-"10"} fi - export e2="${ENSMEM:1:2}" - export e3="${NMEM_ENS}" - ;; - sfs) - cpreq "${PARMgfs}/post/sfs/postxconfig-NT-sfs.txt" "${DATA}/postxconfig-NT.txt" - cpreq "${PARMgfs}/post/sfs/postxconfig-NT-sfs.txt" "${DATA}/postxconfig-NT_FH00.txt" - # Provide ensemble header information for SFS - if [[ "${ENSMEM}" == "000" ]]; then - export e1=1 + fi + + if [[ "${MONO:0:4}" != "mono" && "${TYPE}" == "nh" ]]; then + vtdm4=${vtdm4_nh_nonmono:-"0.06"} + else + vtdm4=${vtdm4:-"0.05"} + fi + + # Initial conditions are chgres-ed from GFS analysis file + nggps_ic=${nggps_ic:-".true."} + ncep_ic=${ncep_ic:-".false."} + external_ic=".true." + mountain=".false." + warm_start=".false." + read_increment=".false." + res_latlon_dynamics='""' + increment_file_on_native_grid=".false." + + # Stochastic Physics Options + do_skeb=".false." + do_shum=".false." + do_sppt=".false." + do_ca=".false." + ISEED=0 + local imem=${MEMBER#0} + local base_seed=$((current_cycle * 10000 + imem * 100)) + + if [[ "${DO_SKEB:-}" == "YES" ]]; then + do_skeb=".true." + ISEED_SKEB=$((base_seed + 1)) + fi + + if [[ "${DO_SHUM:-}" == "YES" ]]; then + do_shum=".true." + ISEED_SHUM=$((base_seed + 2)) + fi + + if [[ "${DO_SPPT:-}" == "YES" ]]; then + do_sppt=".true." + ISEED_SPPT=$((base_seed + 3)),$((base_seed + 4)),$((base_seed + 5)),$((base_seed + 6)),$((base_seed + 7)) + fi + + if [[ "${DO_CA:-}" == "YES" ]]; then + do_ca=".true." + ISEED_CA=$(((base_seed + 18) % 2147483647)) + fi + + if [[ "${DO_LAND_PERT:-}" == "YES" ]]; then + lndp_type=${lndp_type:-2} + ISEED_LNDP=$(((base_seed + 5) % 2147483647)) + LNDP_TAU=${LNDP_TAU:-21600} + LNDP_SCALE=${LNDP_SCALE:-500000} + lndp_var_list=${lndp_var_list:-"'smc', 'vgf',"} + lndp_prt_list=${lndp_prt_list:-"0.2,0.1"} + n_var_lndp=$(echo "${lndp_var_list}" | wc -w) + fi + + #-------------------------------------------------------------------------- + + # Fix files + FNGLAC=${FNGLAC:-"${FIXgfs}/am/global_glacier.2x2.grb"} + FNMXIC=${FNMXIC:-"${FIXgfs}/am/global_maxice.2x2.grb"} + FNTSFC=${FNTSFC:-"${FIXgfs}/am/RTGSST.1982.2012.monthly.clim.grb"} + FNSNOC=${FNSNOC:-"${FIXgfs}/am/global_snoclim.1.875.grb"} + FNZORC=${FNZORC:-"igbp"} + FNAISC=${FNAISC:-"${FIXgfs}/am/IMS-NIC.blended.ice.monthly.clim.grb"} + FNALBC2=${FNALBC2:-"${FIXorog}/${CASE}/sfc/${CASE}.mx${OCNRES}.facsf.tileX.nc"} + FNTG3C=${FNTG3C:-"${FIXorog}/${CASE}/sfc/${CASE}.mx${OCNRES}.substrate_temperature.tileX.nc"} + FNVEGC=${FNVEGC:-"${FIXorog}/${CASE}/sfc/${CASE}.mx${OCNRES}.vegetation_greenness.tileX.nc"} + FNMSKH=${FNMSKH:-"${FIXgfs}/am/global_slmask.t1534.3072.1536.grb"} + FNVMNC=${FNVMNC:-"${FIXorog}/${CASE}/sfc/${CASE}.mx${OCNRES}.vegetation_greenness.tileX.nc"} + FNVMXC=${FNVMXC:-"${FIXorog}/${CASE}/sfc/${CASE}.mx${OCNRES}.vegetation_greenness.tileX.nc"} + FNSLPC=${FNSLPC:-"${FIXorog}/${CASE}/sfc/${CASE}.mx${OCNRES}.slope_type.tileX.nc"} + FNALBC=${FNALBC:-"${FIXorog}/${CASE}/sfc/${CASE}.mx${OCNRES}.snowfree_albedo.tileX.nc"} + FNVETC=${FNVETC:-"${FIXorog}/${CASE}/sfc/${CASE}.mx${OCNRES}.vegetation_type.tileX.nc"} + FNSOTC=${FNSOTC:-"${FIXorog}/${CASE}/sfc/${CASE}.mx${OCNRES}.soil_type.tileX.nc"} + FNSOCC=${FNSOCC:-"${FIXorog}/${CASE}/sfc/${CASE}.mx${OCNRES}.soil_color.tileX.nc"} + FNABSC=${FNABSC:-"${FIXorog}/${CASE}/sfc/${CASE}.mx${OCNRES}.maximum_snow_albedo.tileX.nc"} + FNSMCC=${FNSMCC:-"${FIXgfs}/am/global_soilmgldas.statsgo.t${JCAP}.${LONB}.${LATB}.grb"} + + # If the appropriate resolution fix file is not present, use the highest resolution available (T1534) + if [[ ! -f "${FNSMCC}" ]]; then + FNSMCC="${FIXgfs}/am/global_soilmgldas.statsgo.t1534.3072.1536.grb" + fi + + # Grid and orography data + if [[ "${cplflx}" == ".false." ]]; then + cpreq "${FIXorog}/${CASE}/${CASE}_mosaic.nc" "${DATA}/INPUT/grid_spec.nc" + else + cpreq "${FIXorog}/${CASE}/${CASE}_mosaic.nc" "${DATA}/INPUT/${CASE}_mosaic.nc" + fi + + # Files for GWD + cpreq "${FIXugwd}/ugwp_limb_tau.nc" "${DATA}/ugwp_limb_tau.nc" + + # Files for orography, GWD tiles + local tt + for ((tt = 1; tt <= ntiles; tt++)); do + cpreq "${FIXorog}/${CASE}/${CASE}.mx${OCNRES}_oro_data.tile${tt}.nc" "${DATA}/INPUT/oro_data.tile${tt}.nc" + cpreq "${FIXorog}/${CASE}/${CASE}_grid.tile${tt}.nc" "${DATA}/INPUT/${CASE}_grid.tile${tt}.nc" + cpreq "${FIXugwd}/${CASE}/${CASE}_oro_data_ls.tile${tt}.nc" "${DATA}/INPUT/oro_data_ls.tile${tt}.nc" + cpreq "${FIXugwd}/${CASE}/${CASE}_oro_data_ss.tile${tt}.nc" "${DATA}/INPUT/oro_data_ss.tile${tt}.nc" + done + if [[ "${DO_NEST:-NO}" == "YES" ]]; then + ${NLN} "${DATA}/INPUT/oro_data.tile7.nc" "${DATA}/INPUT/oro_data.nest02.tile7.nc" + ${NLN} "${DATA}/INPUT/${CASE}_grid.tile7.nc" "${DATA}/INPUT/${CASE}_grid.nest02.tile7.nc" + ${NLN} "${DATA}/INPUT/${CASE}_grid.tile7.nc" "${DATA}/INPUT/grid.nest02.tile7.nc" + ${NLN} "${DATA}/INPUT/oro_data_ls.tile7.nc" "${DATA}/INPUT/oro_data_ls.nest02.tile7.nc" + ${NLN} "${DATA}/INPUT/oro_data_ss.tile7.nc" "${DATA}/INPUT/oro_data_ss.nest02.tile7.nc" + fi + + # NoahMP table + local noahmptablefile="${PARMgfs}/ufs/noahmptable.tbl" + cpreq "${noahmptablefile}" "${DATA}/noahmptable.tbl" + + # Thompson microphysics fix files + if ((imp_physics == 8)); then + cpreq "${FIXgfs}/am/CCN_ACTIVATE.BIN" "${DATA}/CCN_ACTIVATE.BIN" + cpreq "${FIXgfs}/am/freezeH2O.dat" "${DATA}/freezeH2O.dat" + cpreq "${FIXgfs}/am/qr_acr_qgV2.dat" "${DATA}/qr_acr_qgV2.dat" + cpreq "${FIXgfs}/am/qr_acr_qsV2.dat" "${DATA}/qr_acr_qsV2.dat" + fi + + if [[ "${new_o3forc:-YES}" == "YES" ]]; then + if [[ "${o3forc_params:-McCormack}" == "McCormack-empirical-sh-ozh" ]]; then + O3FORC="ozprdlos_2015_new_sbuvO3_tclm15_nuchem_shozhvlogp.f77" else - export e1=3 + O3FORC="ozprdlos_2015_new_sbuvO3_tclm15_nuchem.f77" fi - export e2="${ENSMEM:1:2}" - export e3="${NMEM_ENS}" - ;; - *) - echo "FATAL ERROR: Unknown NET ${NET}, unable to determine appropriate post files" - exit 20 - esac - fi + else + O3FORC="global_o3prdlos.f77" + fi + H2OFORC=${H2OFORC:-"global_h2o_pltc.f77"} + cpreq "${FIXgfs}/am/${O3FORC}" "${DATA}/global_o3prdlos.f77" + cpreq "${FIXgfs}/am/${H2OFORC}" "${DATA}/global_h2oprdlos.f77" + + # GFS standard input data + + ISOL=${ISOL:-2} + + cpreq "${FIXgfs}/am/global_solarconstant_noaa_an.txt" "${DATA}/solarconstant_noaa_an.txt" + cpreq "${FIXgfs}/am/global_sfc_emissivity_idx.txt" "${DATA}/sfc_emissivity_idx.txt" + + # Aerosol options + IAER=${IAER:-1011} + MERRA2_6ym=${MERRA2_6ym:-".false."} + ## merra2 aerosol climo + if ((IAER == 1011)); then + if [[ "${MERRA2_6ym}" == ".false." ]]; then + # local month mm + for ((month = 1; month <= 12; month++)); do + mm=$(printf %02d "${month}") + cpreq "${FIXgfs}/aer/merra2.aerclim.2014-2023.m${mm}.nc" "aeroclim.m${mm}.nc" + done + elif [[ "${MERRA2_6ym}" == ".true." ]]; then + year=${current_cycle:0:4} + for i in {1980..2300..5}; do + if [[ ${year} -le ${i} ]]; then + Eyear=$(printf %04d "${i}") + Syear=$((i - 5)) + break + fi + done + for ((month = 1; month <= 12; month++)); do + mm=$(printf %02d "${month}") + cpreq "${FIXgfs}/aer/y${Syear}-${Eyear}/merra2_${Syear}-${Eyear}_${mm}.nc" "aeroclim.m${mm}.nc" + done + fi # if [[ "${MERRA2_6ym}" == ".true." ]]; + fi # if (( IAER == 1011 )) + + cpreq "${FIXgfs}/am/global_climaeropac_global.txt" "${DATA}/aerosol.dat" + if ((IAER > 0)); then + local file + for file in "${FIXgfs}/am/global_volcanic_aerosols"*; do + cpreq "${file}" "${DATA}/$(basename "${file//global_/}")" + done + fi + + cpreq "${FIXgfs}/lut/optics_BC.v1_3.dat" "${DATA}/optics_BC.dat" + cpreq "${FIXgfs}/lut/optics_OC.v1_3.dat" "${DATA}/optics_OC.dat" + cpreq "${FIXgfs}/lut/optics_DU.v15_3.dat" "${DATA}/optics_DU.dat" + cpreq "${FIXgfs}/lut/optics_SS.v3_3.dat" "${DATA}/optics_SS.dat" + cpreq "${FIXgfs}/lut/optics_SU.v1_3.dat" "${DATA}/optics_SU.dat" + + # CO2 options + ICO2=${ICO2:-2} + + cpreq "${FIXgfs}/am/global_co2historicaldata_glob.txt" "${DATA}/co2historicaldata_glob.txt" + cpreq "${FIXgfs}/am/co2monthlycyc.txt" "${DATA}/co2monthlycyc.txt" + # Set historical CO2 values based on whether this is a reforecast run or not + # Ref. issue 2403 + local co2dir + co2dir="fix_co2_proj" + if [[ "${reforecast:-}" == "YES" ]]; then + co2dir="co2dat_4a" + fi + if ((ICO2 > 0)); then + local file + for file in "${FIXgfs}/am/${co2dir}/global_co2historicaldata"*; do + cpreq "${file}" "${DATA}/$(basename "${file//global_/}")" + done + fi + + # Inline UPP fix files + if [[ "${WRITE_DOPOST:-}" == ".true." ]]; then + cpreq "${POSTGRB2TBL:-${PARMgfs}/post/params_grib2_tbl_new}" "${DATA}/params_grib2_tbl_new" + cpreq "${PARMgfs}/ufs/post_itag_gfs" "${DATA}/itag" # TODO: Need a GEFS version when available in the UFS-weather-model + # TODO: These should be replaced with ones from the ufs-weather-model when available there + case ${NET} in + gfs | gcafs) + cpreq "${PARMgfs}/post/gfs/postxconfig-NT-gfs-two.txt" "${DATA}/postxconfig-NT.txt" + cpreq "${PARMgfs}/post/gfs/postxconfig-NT-gfs-f00-two.txt" "${DATA}/postxconfig-NT_FH00.txt" + ;; + gefs) + cpreq "${PARMgfs}/post/gefs/postxconfig-NT-gefs.txt" "${DATA}/postxconfig-NT.txt" + cpreq "${PARMgfs}/post/gefs/postxconfig-NT-gefs-f00.txt" "${DATA}/postxconfig-NT_FH00.txt" + # Provide ensemble header information for GEFS + if [[ "${ENSMEM}" == "000" ]]; then + export e1=1 + else + export e1=3 + fi + export e2="${ENSMEM:1:2}" + export e3="${NMEM_ENS}" + ;; + sfs) + cpreq "${PARMgfs}/post/sfs/postxconfig-NT-sfs.txt" "${DATA}/postxconfig-NT.txt" + cpreq "${PARMgfs}/post/sfs/postxconfig-NT-sfs.txt" "${DATA}/postxconfig-NT_FH00.txt" + # Provide ensemble header information for SFS + if [[ "${ENSMEM}" == "000" ]]; then + export e1=1 + else + export e1=3 + fi + export e2="${ENSMEM:1:2}" + export e3="${NMEM_ENS}" + ;; + *) + echo "FATAL ERROR: Unknown NET ${NET}, unable to determine appropriate post files" + exit 20 + ;; + esac + fi } # Disable variable not used warnings # shellcheck disable=SC2034 -WW3_predet(){ - echo "SUB ${FUNCNAME[0]}: WW3 before run type determination" - - if [[ ! -d "${COMOUT_WAVE_HISTORY}" ]]; then mkdir -p "${COMOUT_WAVE_HISTORY}"; fi - if [[ ! -d "${COMOUT_WAVE_RESTART}" ]]; then mkdir -p "${COMOUT_WAVE_RESTART}"; fi - if [[ ! -d "${DATAoutput}/WW3_OUTPUT" ]]; then mkdir -p "${DATAoutput}/WW3_OUTPUT"; fi - if [[ ! -d "${DATArestart}/WW3_RESTART" ]]; then mkdir -p "${DATArestart}/WW3_RESTART"; fi - - # Link the output and restart directories to the DATA directory - ${NLN} "${DATAoutput}/WW3_OUTPUT" "${DATA}/WW3_OUTPUT" - ${NLN} "${DATArestart}/WW3_RESTART" "${DATA}/WW3_RESTART" - - # Files from wave prep and wave init jobs - # Copy mod_def files for wave grids - local ww3_grid - #if shel, only 1 waveGRD which is linked to mod_def.ww3 - cpreq "${COMIN_WAVE_PREP}/${RUN}.t${cyc}z.mod_def.${waveGRD}.bin" "${DATA}/mod_def.ww3" - - #If pnt_wght file exists, use it to speed up initialization for unstructured grids - # this file does not exist for structured, and the model can run without it (just slower init) - if [[ -f "${FIXgfs}/wave/pnt_wght.${waveGRD}.nc" ]]; then - cpreq "${FIXgfs}/wave/pnt_wght.${waveGRD}.nc" "${DATA}/pnt_wght.ww3.nc" - fi - - # TODO: These are generated by waveprep job, but that job is not used in v17 - # so these files are not generated. - # TODO: Remove these lines or enable waveprep job - if [[ "${WW3ICEINP}" == "YES" ]]; then - local wavicefile="${COMIN_WAVE_PREP}/${RUN}.${WAVEICE_FID}.t${current_cycle:8:2}z.ice" - if [[ ! -f "${wavicefile}" ]]; then - echo "FATAL ERROR: WW3ICEINP='${WW3ICEINP}', but missing ice file '${wavicefile}', ABORT!" - exit 1 - fi - cpreq "${wavicefile}" "${DATA}/ice.${WAVEICE_FID}" - fi - - if [[ "${WW3CURINP}" == "YES" ]]; then - local wavcurfile="${COMIN_WAVE_PREP}/${RUN}.${WAVECUR_FID}.t${current_cycle:8:2}z.cur" - if [[ ! -f "${wavcurfile}" ]]; then - echo "FATAL ERROR: WW3CURINP='${WW3CURINP}', but missing current file '${wavcurfile}', ABORT!" - exit 1 - fi - cpreq "${wavcurfile}" "${DATA}/current.${WAVECUR_FID}" - fi - - # Fix files - #if wave mesh is not the same as the ocean mesh, copy it in the file - if [[ "${MESH_WAV}" == "${MESH_OCN:-mesh.mx${OCNRES}.nc}" ]]; then - echo "Wave is on the same mesh as ocean" - else - echo "Wave is NOT on the same mesh as ocean" - cpreq "${FIXgfs}/wave/${MESH_WAV}" "${DATA}/" - fi +WW3_predet() { + echo "SUB ${FUNCNAME[0]}: WW3 before run type determination" + + if [[ ! -d "${COMOUT_WAVE_HISTORY}" ]]; then mkdir -p "${COMOUT_WAVE_HISTORY}"; fi + if [[ ! -d "${COMOUT_WAVE_RESTART}" ]]; then mkdir -p "${COMOUT_WAVE_RESTART}"; fi + if [[ ! -d "${DATAoutput}/WW3_OUTPUT" ]]; then mkdir -p "${DATAoutput}/WW3_OUTPUT"; fi + if [[ ! -d "${DATArestart}/WW3_RESTART" ]]; then mkdir -p "${DATArestart}/WW3_RESTART"; fi + + # Link the output and restart directories to the DATA directory + ${NLN} "${DATAoutput}/WW3_OUTPUT" "${DATA}/WW3_OUTPUT" + ${NLN} "${DATArestart}/WW3_RESTART" "${DATA}/WW3_RESTART" + + # Files from wave prep and wave init jobs + # Copy mod_def files for wave grids + local ww3_grid + #if shel, only 1 waveGRD which is linked to mod_def.ww3 + cpreq "${COMIN_WAVE_PREP}/${RUN}.t${cyc}z.mod_def.${waveGRD}.bin" "${DATA}/mod_def.ww3" + + #If pnt_wght file exists, use it to speed up initialization for unstructured grids + # this file does not exist for structured, and the model can run without it (just slower init) + if [[ -f "${FIXgfs}/wave/pnt_wght.${waveGRD}.nc" ]]; then + cpreq "${FIXgfs}/wave/pnt_wght.${waveGRD}.nc" "${DATA}/pnt_wght.ww3.nc" + fi + + # TODO: These are generated by waveprep job, but that job is not used in v17 + # so these files are not generated. + # TODO: Remove these lines or enable waveprep job + if [[ "${WW3ICEINP}" == "YES" ]]; then + local wavicefile="${COMIN_WAVE_PREP}/${RUN}.${WAVEICE_FID}.t${current_cycle:8:2}z.ice" + if [[ ! -f "${wavicefile}" ]]; then + echo "FATAL ERROR: WW3ICEINP='${WW3ICEINP}', but missing ice file '${wavicefile}', ABORT!" + exit 1 + fi + cpreq "${wavicefile}" "${DATA}/ice.${WAVEICE_FID}" + fi + + if [[ "${WW3CURINP}" == "YES" ]]; then + local wavcurfile="${COMIN_WAVE_PREP}/${RUN}.${WAVECUR_FID}.t${current_cycle:8:2}z.cur" + if [[ ! -f "${wavcurfile}" ]]; then + echo "FATAL ERROR: WW3CURINP='${WW3CURINP}', but missing current file '${wavcurfile}', ABORT!" + exit 1 + fi + cpreq "${wavcurfile}" "${DATA}/current.${WAVECUR_FID}" + fi + + # Fix files + #if wave mesh is not the same as the ocean mesh, copy it in the file + if [[ "${MESH_WAV}" == "${MESH_OCN:-mesh.mx${OCNRES}.nc}" ]]; then + echo "Wave is on the same mesh as ocean" + else + echo "Wave is NOT on the same mesh as ocean" + cpreq "${FIXgfs}/wave/${MESH_WAV}" "${DATA}/" + fi } # shellcheck disable=SC2034 -CICE_predet(){ - echo "SUB ${FUNCNAME[0]}: CICE before run type determination" +CICE_predet() { + echo "SUB ${FUNCNAME[0]}: CICE before run type determination" - if [[ ! -d "${COMOUT_ICE_HISTORY}" ]]; then mkdir -p "${COMOUT_ICE_HISTORY}"; fi - if [[ ! -d "${COMOUT_ICE_RESTART}" ]]; then mkdir -p "${COMOUT_ICE_RESTART}"; fi - if [[ ! -d "${COMIN_ICE_INPUT}" ]]; then mkdir -p "${COMIN_ICE_INPUT}"; fi - if [[ ! -d "${DATAoutput}/CICE_OUTPUT" ]]; then mkdir -p "${DATAoutput}/CICE_OUTPUT"; fi - if [[ ! -d "${DATArestart}/CICE_RESTART" ]]; then mkdir -p "${DATArestart}/CICE_RESTART"; fi + if [[ ! -d "${COMOUT_ICE_HISTORY}" ]]; then mkdir -p "${COMOUT_ICE_HISTORY}"; fi + if [[ ! -d "${COMOUT_ICE_RESTART}" ]]; then mkdir -p "${COMOUT_ICE_RESTART}"; fi + if [[ ! -d "${COMIN_ICE_INPUT}" ]]; then mkdir -p "${COMIN_ICE_INPUT}"; fi + if [[ ! -d "${DATAoutput}/CICE_OUTPUT" ]]; then mkdir -p "${DATAoutput}/CICE_OUTPUT"; fi + if [[ ! -d "${DATArestart}/CICE_RESTART" ]]; then mkdir -p "${DATArestart}/CICE_RESTART"; fi - # Link the output and restart directories to the DATA directory - ${NLN} "${DATAoutput}/CICE_OUTPUT" "${DATA}/CICE_OUTPUT" - ${NLN} "${DATArestart}/CICE_RESTART" "${DATA}/CICE_RESTART" + # Link the output and restart directories to the DATA directory + ${NLN} "${DATAoutput}/CICE_OUTPUT" "${DATA}/CICE_OUTPUT" + ${NLN} "${DATArestart}/CICE_RESTART" "${DATA}/CICE_RESTART" - # CICE does not have a concept of high frequency output like FV3 - # Convert output settings into an explicit list for CICE - # shellcheck disable=SC2312 - mapfile -t CICE_OUTPUT_FH < <(seq "${FHMIN}" "${FHOUT_ICE}" "${FHMAX}") || exit 10 + # CICE does not have a concept of high frequency output like FV3 + # Convert output settings into an explicit list for CICE + # shellcheck disable=SC2312 + mapfile -t CICE_OUTPUT_FH < <(seq "${FHMIN}" "${FHOUT_ICE}" "${FHMAX}") || exit 10 - # Fix files - cpreq "${FIXgfs}/cice/${ICERES}/${CICE_GRID}" "${DATA}/" - cpreq "${FIXgfs}/cice/${ICERES}/${CICE_MASK}" "${DATA}/" - cpreq "${FIXgfs}/cice/${ICERES}/${MESH_ICE}" "${DATA}/" + # Fix files + cpreq "${FIXgfs}/cice/${ICERES}/${CICE_GRID}" "${DATA}/" + cpreq "${FIXgfs}/cice/${ICERES}/${CICE_MASK}" "${DATA}/" + cpreq "${FIXgfs}/cice/${ICERES}/${MESH_ICE}" "${DATA}/" } # shellcheck disable=SC2034 -MOM6_predet(){ - echo "SUB ${FUNCNAME[0]}: MOM6 before run type determination" - - if [[ ! -d "${COMOUT_OCEAN_HISTORY}" ]]; then mkdir -p "${COMOUT_OCEAN_HISTORY}"; fi - if [[ ! -d "${COMOUT_OCEAN_RESTART}" ]]; then mkdir -p "${COMOUT_OCEAN_RESTART}"; fi - if [[ ! -d "${COMIN_OCEAN_INPUT}" ]]; then mkdir -p "${COMIN_OCEAN_INPUT}"; fi - if [[ ! -d "${DATAoutput}/MOM6_OUTPUT" ]]; then mkdir -p "${DATAoutput}/MOM6_OUTPUT"; fi - if [[ ! -d "${DATArestart}/MOM6_RESTART" ]]; then mkdir -p "${DATArestart}/MOM6_RESTART"; fi - - # Link the output and restart directories to the DATA directory - ${NLN} "${DATAoutput}/MOM6_OUTPUT" "${DATA}/MOM6_OUTPUT" - ${NLN} "${DATArestart}/MOM6_RESTART" "${DATA}/MOM6_RESTART" - - # MOM6 does not have a concept of high frequency output like FV3 - # Convert output settings into an explicit list for MOM6 - MOM6_OUTPUT_FH=$(seq -s ' ' "${FHMIN}" "${FHOUT_OCN}" "${FHMAX}") - - # If using stochastic parameterizations, create a seed that does not exceed the - # largest signed integer - local imem=${MEMBER#0} - local base_seed=$((current_cycle*10000 + imem*100)) - - if [[ "${DO_OCN_SPPT:-}" == "YES" ]]; then - ISEED_OCNSPPT=$((base_seed + 8)),$((base_seed + 9)),$((base_seed + 10)),$((base_seed + 11)),$((base_seed + 12)) - fi - - if [[ "${DO_OCN_PERT_EPBL:-}" == "YES" ]]; then - ISEED_EPBL=$((base_seed + 13)),$((base_seed + 14)),$((base_seed + 15)),$((base_seed + 16)),$((base_seed + 17)) - fi - - # Fix files for ocean; ocean_hgrid, ocean_mosaic, ocean_mask, etc. - # MOM_channels is configurable based on resolution, but is treated as a fix file - # MOM_override is a template that allows user to override default namelist settings, but is also treated as a fix file - cpreq "${FIXgfs}/mom6/${OCNRES}/"* "${DATA}/INPUT/" # TODO: These need to be explicit - - # Add to the MOM_override file, to have ISO timestamp - cat >> "${DATA}/INPUT/MOM_override" << EOF +MOM6_predet() { + echo "SUB ${FUNCNAME[0]}: MOM6 before run type determination" + + if [[ ! -d "${COMOUT_OCEAN_HISTORY}" ]]; then mkdir -p "${COMOUT_OCEAN_HISTORY}"; fi + if [[ ! -d "${COMOUT_OCEAN_RESTART}" ]]; then mkdir -p "${COMOUT_OCEAN_RESTART}"; fi + if [[ ! -d "${COMIN_OCEAN_INPUT}" ]]; then mkdir -p "${COMIN_OCEAN_INPUT}"; fi + if [[ ! -d "${DATAoutput}/MOM6_OUTPUT" ]]; then mkdir -p "${DATAoutput}/MOM6_OUTPUT"; fi + if [[ ! -d "${DATArestart}/MOM6_RESTART" ]]; then mkdir -p "${DATArestart}/MOM6_RESTART"; fi + + # Link the output and restart directories to the DATA directory + ${NLN} "${DATAoutput}/MOM6_OUTPUT" "${DATA}/MOM6_OUTPUT" + ${NLN} "${DATArestart}/MOM6_RESTART" "${DATA}/MOM6_RESTART" + + # MOM6 does not have a concept of high frequency output like FV3 + # Convert output settings into an explicit list for MOM6 + MOM6_OUTPUT_FH=$(seq -s ' ' "${FHMIN}" "${FHOUT_OCN}" "${FHMAX}") + + # If using stochastic parameterizations, create a seed that does not exceed the + # largest signed integer + local imem=${MEMBER#0} + local base_seed=$((current_cycle * 10000 + imem * 100)) + + if [[ "${DO_OCN_SPPT:-}" == "YES" ]]; then + ISEED_OCNSPPT=$((base_seed + 8)),$((base_seed + 9)),$((base_seed + 10)),$((base_seed + 11)),$((base_seed + 12)) + fi + + if [[ "${DO_OCN_PERT_EPBL:-}" == "YES" ]]; then + ISEED_EPBL=$((base_seed + 13)),$((base_seed + 14)),$((base_seed + 15)),$((base_seed + 16)),$((base_seed + 17)) + fi + + # Fix files for ocean; ocean_hgrid, ocean_mosaic, ocean_mask, etc. + # MOM_channels is configurable based on resolution, but is treated as a fix file + # MOM_override is a template that allows user to override default namelist settings, but is also treated as a fix file + cpreq "${FIXgfs}/mom6/${OCNRES}/"* "${DATA}/INPUT/" # TODO: These need to be explicit + + # Add to the MOM_override file, to have ISO timestamp + cat >> "${DATA}/INPUT/MOM_override" << EOF !#Write ISO date stamped output with 3-hourly (0.125) frequency to ocean.stats ascii file #override ISO_DATE_STAMPED_STDOUT = True #override ENERGYSAVEDAYS = 0.125 EOF - # Copy coupled grid_spec - local spec_file - spec_file="${FIXgfs}/cpl/a${CASE}o${OCNRES}/grid_spec.nc" - # Test that the file exists and is not zero-sized - if [[ -s "${spec_file}" ]]; then - cpreq "${spec_file}" "${DATA}/INPUT/" - else - echo "FATAL ERROR: coupled grid_spec file '${spec_file}' does not exist or is size 0" - exit 3 - fi + # Copy coupled grid_spec + local spec_file + spec_file="${FIXgfs}/cpl/a${CASE}o${OCNRES}/grid_spec.nc" + # Test that the file exists and is not zero-sized + if [[ -s "${spec_file}" ]]; then + cpreq "${spec_file}" "${DATA}/INPUT/" + else + echo "FATAL ERROR: coupled grid_spec file '${spec_file}' does not exist or is size 0" + exit 3 + fi } # shellcheck disable=SC2178 -CMEPS_predet(){ - echo "SUB ${FUNCNAME[0]}: CMEPS before run type determination" +CMEPS_predet() { + echo "SUB ${FUNCNAME[0]}: CMEPS before run type determination" - if [[ ! -d "${COMOUT_MED_RESTART}" ]]; then mkdir -p "${COMOUT_MED_RESTART}"; fi - if [[ ! -d "${DATArestart}/CMEPS_RESTART" ]]; then mkdir -p "${DATArestart}/CMEPS_RESTART"; fi + if [[ ! -d "${COMOUT_MED_RESTART}" ]]; then mkdir -p "${COMOUT_MED_RESTART}"; fi + if [[ ! -d "${DATArestart}/CMEPS_RESTART" ]]; then mkdir -p "${DATArestart}/CMEPS_RESTART"; fi - # Link the restart directory to the DATA directory - ${NLN} "${DATArestart}/CMEPS_RESTART" "${DATA}/CMEPS_RESTART" + # Link the restart directory to the DATA directory + ${NLN} "${DATArestart}/CMEPS_RESTART" "${DATA}/CMEPS_RESTART" } # shellcheck disable=SC2034 -GOCART_predet(){ - echo "SUB ${FUNCNAME[0]}: GOCART before run type determination" +GOCART_predet() { + echo "SUB ${FUNCNAME[0]}: GOCART before run type determination" - if [[ ! -d "${COMOUT_CHEM_HISTORY}" ]]; then mkdir -p "${COMOUT_CHEM_HISTORY}"; fi + if [[ ! -d "${COMOUT_CHEM_HISTORY}" ]]; then mkdir -p "${COMOUT_CHEM_HISTORY}"; fi - # FHMAX gets modified when IAU is on, so keep origianl value for GOCART output - GOCART_MAX=${FHMAX} + # FHMAX gets modified when IAU is on, so keep origianl value for GOCART output + GOCART_MAX=${FHMAX} - # GOCART output times can't be computed here because they may depend on FHROT + # GOCART output times can't be computed here because they may depend on FHROT } diff --git a/ush/fv3gfs_remap_weights.sh b/ush/fv3gfs_remap_weights.sh index 15dfc73e3f0..518b51c2767 100755 --- a/ush/fv3gfs_remap_weights.sh +++ b/ush/fv3gfs_remap_weights.sh @@ -10,54 +10,74 @@ #BSUB -extsched 'CRAYLINUX[]' set -ax - . $MODULESHOME/init/sh +source "${MODULESHOME}/init/sh" module load PrgEnv-intel #-------------------------------------------------- -export home_dir=/gpfs/hps3/emc/global/noscrub/$LOGNAME/git/fv3gfs/gfs.v15.0.0 -export script_dir=$home_dir/ush -export exec_dir=$home_dir/exec -export fix_fv3_dir=$home_dir/fix -export fregrid=$home_dir/exec/fregrid_parallel -export TMPDIR=/gpfs/hps/ptmp/$LOGNAME/fv3_weight - +export home_dir="/gpfs/hps3/emc/global/noscrub/${LOGNAME}/git/fv3gfs/gfs.v15.0.0" +export script_dir="${home_dir}/ush" +export exec_dir="${home_dir}/exec" +export fix_fv3_dir="${home_dir}/fix" +export fregrid="${home_dir}/exec/fregrid_parallel" +export TMPDIR="/gpfs/hps/ptmp/${LOGNAME}/fv3_weight" #--global lat-lon array size #---------------------------------------------------------- for GG in 1deg 0p5deg 0p25deg 0p125deg; do -#---------------------------------------------------------- + #---------------------------------------------------------- -if [ $GG = 1deg ]; then export nlon=360 ; export nlat=180 ;fi -if [ $GG = 0p5deg ]; then export nlon=720 ; export nlat=360 ;fi -if [ $GG = 0p25deg ]; then export nlon=1440 ; export nlat=720 ;fi -if [ $GG = 0p125deg ]; then export nlon=2880 ; export nlat=1440 ;fi + case "${GG}" in + 1deg) + export nlon=360 + export nlat=180 + ;; + 0p5deg) + export nlon=720 + export nlat=360 + ;; + 0p25deg) + export nlon=1440 + export nlat=720 + ;; + 0p125deg) + export nlon=2880 + export nlat=1440 + ;; + *) + msg="FATAL: Unsupported grid name ${GG}" + export err=100 + err_exit "${msg}" + ;; + esac -#---------------------------------------------------------- -for CASE in C48 C96 C192 C384 C768 C1152 C3072; do -#---------------------------------------------------------- -max_core=24 -export NODES=3; export thread=1 -##if [ $CASE = C3072 ]; then exportNODES=21; export thread=4; fi -export npes=$(((NODES-1)*max_core/thread)) - -export workdir=$TMPDIR/${CASE}_${GG} -mkdir -p $workdir; cd $workdir ||exit 8 - -export native_grid=$fix_fv3_dir/$CASE/${CASE}_mosaic.nc -export remap_file=$fix_fv3_dir/$CASE/remap_weights_${CASE}_${GG}.nc - -#NOTE: we are placing the first process on a node by itself to get the memory it needs -# these npes will be tightly packed on the remaining nodes - -aprun -n 1 -d 24 $fregrid --input_mosaic $native_grid \ - --nlon $nlon --nlat $nlat \ - --remap_file $remap_file \ - --debug : \ - -n $npes -d $thread $fregrid --input_mosaic $native_grid \ - --nlon $nlon --nlat $nlat \ - --remap_file $remap_file \ - --debug + #---------------------------------------------------------- + for CASE in C48 C96 C192 C384 C768 C1152 C3072; do + #---------------------------------------------------------- + max_core=24 + export NODES=3 + export thread=1 + ##if [[ ${CASE} = C3072 ]]; then exportNODES=21; export thread=4; fi + export npes=$(((NODES - 1) * max_core / thread)) -done + export workdir="${TMPDIR}/${CASE}_${GG}" + mkdir -p "${workdir}" + cd "${workdir}" || exit 8 + + export native_grid="${fix_fv3_dir}/${CASE}/${CASE}_mosaic.nc" + export remap_file="${fix_fv3_dir}/${CASE}/remap_weights_${CASE}_${GG}.nc" + + #NOTE: we are placing the first process on a node by itself to get the memory it needs + # these npes will be tightly packed on the remaining nodes + + aprun -n 1 -d 24 "${fregrid}" --input_mosaic "${native_grid}" \ + --nlon "${nlon}" --nlat "${nlat}" \ + --remap_file "${remap_file}" \ + --debug : \ + -n "${npes}" -d "${thread}" "${fregrid}" --input_mosaic "${native_grid}" \ + --nlon "${nlon}" --nlat "${nlat}" \ + --remap_file "${remap_file}" \ + --debug + + done done exit diff --git a/ush/gaussian_sfcanl.sh b/ush/gaussian_sfcanl.sh index 0652c0117c5..ba692404fe5 100755 --- a/ush/gaussian_sfcanl.sh +++ b/ush/gaussian_sfcanl.sh @@ -73,13 +73,13 @@ CASE=${CASE:-C768} CASE_HIST=${CASE_HIST:-${CASE}} resh=${CASE_HIST:1} -LONB_CASE=$((resh*4)) -LATB_CASE=$((resh*2)) +LONB_CASE=$((resh * 4)) +LATB_CASE=$((resh * 2)) LONB_SFC=${LONB_SFC:-${LONB_CASE}} LATB_SFC=${LATB_SFC:-${LATB_CASE}} DONST=${DONST:-"NO"} LEVS=${LEVS:-64} -LEVSP1=$(( LEVS + 1 )) +LEVSP1=$((LEVS + 1)) FIXWGTS=${FIXWGTS:-${FIXorog}/${CASE}/fv3_SCRIP_${CASE}_GRIDSPEC_lon${LONB_SFC}_lat${LATB_SFC}.gaussian.neareststod.nc} # Filenames. @@ -94,6 +94,7 @@ SIGLEVEL=${SIGLEVEL:-${FIXgfs}/am/global_hyblev.l${LEVSP1}.txt} ################################################################################ # Make surface analysis + # input interpolation weights cpreq "${FIXWGTS}" "./weights.nc" @@ -132,7 +133,7 @@ if [[ "${DO_LAND_IAU:-.false.}" == ".true." ]]; then fi # Executable namelist -cat < fort.41 +cat << EOF > fort.41 &setup yy=${PDY:0:4}, mm=${PDY:4:2}, @@ -155,8 +156,8 @@ export OMP_NUM_THREADS=${OMP_NUM_THREADS_SFC:-1} ${APRUNSFC} "${GAUSFCANLEXE}" export err=$? if [[ ${err} -ne 0 ]]; then - echo "FATAL ERROR: ${GAUSFCANLEXE} returned non-zero exit status!" - exit "${err}" + echo "FATAL ERROR: ${GAUSFCANLEXE} returned non-zero exit status!" + exit "${err}" fi # output gaussian global surface analysis files diff --git a/ush/getdump.sh b/ush/getdump.sh index 7c853f21de0..55f4a9fc5ab 100755 --- a/ush/getdump.sh +++ b/ush/getdump.sh @@ -12,23 +12,23 @@ DUMP_SUFFIX=${DUMP_SUFFIX:-""} # Exit if SOURCE_DIR does not exist if [[ ! -s "${SOURCE_DIR}" ]]; then - echo "***ERROR*** DUMP SOURCE_DIR=${SOURCE_DIR} does not exist" - exit 99 + echo "***ERROR*** DUMP SOURCE_DIR=${SOURCE_DIR} does not exist" + exit 99 fi - + # Create TARGET_DIR if is does not exist if [[ ! -s "${TARGET_DIR}" ]]; then - mkdir -p "${TARGET_DIR}" + mkdir -p "${TARGET_DIR}" fi # Set file prefix prefix="${RUN}.t${HH}z." # Link dump files from SOURCE_DIR to TARGET_DIR -cd "${SOURCE_DIR}" +cd "${SOURCE_DIR}" || exit 1 if [[ -s "${prefix}updated.status.tm00.bufr_d" ]]; then - for file in $(ls ${prefix}*); do - ${NLN} "${SOURCE_DIR}/${file}" "${TARGET_DIR}/${file}" + for file in "${prefix}"*; do + ${NLN} "${SOURCE_DIR}/${file}" "${TARGET_DIR}/${file}" done else echo "***ERROR*** ${prefix}updated.status.tm00.bufr_d NOT FOUND in ${SOURCE_DIR}" diff --git a/ush/getges.sh b/ush/getges.sh index f7a6c95eaa0..2922261b267 100755 --- a/ush/getges.sh +++ b/ush/getges.sh @@ -48,123 +48,104 @@ # Example 5. Get the 24-hour GFS forecast sigma file valid at 1998100112. # getges -t sigcur -v 1998100112 -f 24 -e gfs sigfile # -# History: 1996 December Iredell Initial implementation -# 1997 March Iredell Nine new filetypes -# 1997 April Iredell Two new filetypes and -f option -# 1997 December Iredell Four new filetypes -# 1998 April Iredell 4-digit year allowed; -# sigges internal date no longer checked -# 1998 May Iredell T170L42 defaulted; four new filetypes -# and two filetypes deleted -# 1998 June Rogers Nam types added -# 1998 September Iredell high is default resolution -# 2000 March Iredell Cdas and -n option -# 2000 June Iredell Eight new filetypes -# 2002 April Treadon T254L64 defaulted; add angle dependent -# bias correction file -# 2003 March Iredell GFS network out to 384 hours -# 2003 August Iredell Hourly global guesses -# 2005 September Treadon Add satellite data count file (satcnt) -# 2006 September Gayno Add high-res snow analysis -# 2009 January Rogers Added sfluxgrb file -# 2011 April Rogers Added GFS pg2ges file -# 2016 May Menlove Changed GETGES_COM variable to $COMINmodel -# 2016 November Iredell Adapted getges for NEMS GSM -# Also removed a lot of dead wood -# ################################################################################ #------------------------------------------------------------------------------- # Set some default parameters. -fhbeg=03 # hour to begin searching backward for guess -fhinc=03 # hour to increment backward in search -fhend=384 # hour to end searching backward for guess +fhbeg=03 # hour to begin searching backward for guess +fhinc=03 # hour to increment backward in search +fhend=384 # hour to end searching backward for guess #------------------------------------------------------------------------------- # Get options and arguments. -netwk=global # default network -envir=prod # default environment -fhour=any # default forecast hour -quiet=YES # default quiet mode -resol=high # default resolution -typef=sigges # default filetype -valid=${PDY}${cyc} # default valid date +netwk=global # default network +envir=prod # default environment +fhour=any # default forecast hour +quiet=YES # default quiet mode +resol=high # default resolution +typef=sigges # default filetype +valid=${PDY}${cyc} # default valid date err=0 -while getopts n:e:f:qr:t:v: opt;do - case $opt in - n) netwk="$OPTARG";; - e) envir="$OPTARG";; - f) fhour="$OPTARG";; - q) quiet=NO;; - r) resol="$OPTARG";; - t) typef="$OPTARG";; - v) valid="$OPTARG";; - \?) err=1;; - esac +while getopts n:e:f:qr:t:v: opt; do + case "${opt}" in + n) netwk="${OPTARG}" ;; + e) envir="${OPTARG}" ;; + f) fhour="${OPTARG}" ;; + q) quiet=NO ;; + r) resol="${OPTARG}" ;; + t) typef="${OPTARG}" ;; + v) valid="${OPTARG}" ;; + \?) err=1 ;; + *) + echo: "Unknown option ${opt}!" + exit 2 + ;; + esac done -shift $(($OPTIND-1)) +shift $((OPTIND - 1)) gfile=$1 -if [[ -z $valid ]];then - echo "$0: either -v option or environment variables PDY and cyc must be set" >&2 -elif [[ $# -gt 1 ]];then - echo "$0: too many positional arguments" >&2 -elif [[ $err -ne 0 ]];then - echo "$0: invalid option" >&2 +if [[ -z "${valid}" ]]; then + echo "$0: either -v option or environment variables PDY and cyc must be set" >&2 +elif [[ $# -gt 1 ]]; then + echo "$0: too many positional arguments" >&2 +elif [[ "${err}" -ne 0 ]]; then + echo "$0: invalid option" >&2 fi -if [[ $gfile = '?' || $# -gt 1 || $err -ne 0 || -z $valid ||\ - $netwk = '?' || $envir = '?' || $fhour = '?' || $resol = '?' ||\ - $typef = '?' || $valid = '?' ]];then - echo "Usage: getges.sh [-n network] [-e environment] [-f fhour] [-q] [-r resolution]" >&2 - echo " [-t filetype] [-v valid] [gfile]" >&2 - if [[ $netwk = '?' ]];then - echo " network choices:" >&2 - echo " global (default), namopl, gdas, gfs, cdas, etc." >&2 - elif [[ $envir = '?' ]];then - echo " environment choices:" >&2 - echo " prod (default), test, para, dump, prx" >&2 - echo " (some network values allowed for compatibility)" >&2 - elif [[ $fhour = '?' ]];then - echo " fhour is optional specific forecast hour" >&2 - elif [[ $resol = '?' ]];then - echo " resolution choices:" >&2 - echo " high (default), 25464, 17042, 12628, low, 6228, namopl, any" >&2 - elif [[ $typef = '?' ]];then - echo " filetype choices:" >&2 - echo " sigges (default), siggm3, siggm2, siggm1, siggp1, siggp2, siggp3," >&2 - echo " sfcges, sfcgm3, sfcgm2, sfcgm1, sfcgp1, sfcgp2, sfcgp3," >&2 - echo " sfgges, sfggp3, biascr, satang, satcnt, gesfil" >&2 - echo " pgbges, pgiges, pgbgm6, pgigm6, pgbgm3, pgigm3, pgbgp3, pgigp3," >&2 - echo " sigcur, sfccur, pgbcur, pgicur, prepqc, tcvg12, tcvges, tcvitl," >&2 - echo " enggrb, enggri, icegrb, icegri, snogrb, snogri, sstgrb, sstgri," >&2 - echo " pg2cur, pg2ges, restrt," >&2 - echo " natges, natgm3, natgm2, natgm1, natgp1, natgp2, natgp3, natcur," >&2 - echo " nsfges, nsfgm3, nsfgm2, nsfgm1, nsfgp1, nsfgp2, nsfgp3, nsfcur," >&2 - echo " nstcur, nflges, nflgp3," >&2 - elif [[ $valid = '?' ]];then - echo " valid is the valid date in yyyymmddhh or yymmddhh form" >&2 - echo " (default is environmental variable $PDY$cyc)" >&2 - elif [[ $gfile = '?' ]];then - echo " gfile is the guess file to write" >&2 - echo " (default is to write the guess file name to stdout)" >&2 - else - echo " (Note: set a given option to '?' for more details)" >&2 - fi - exit 1 + +if [[ "${gfile}" == '?' || $# -gt 1 || "${err}" -ne 0 || -z "${valid}" || + "${netwk}" == '?' || "${envir}" == '?' || "${fhour}" == '?' || "${resol}" == '?' || + "${typef}" == '?' || "${valid}" == '?' ]]; then + echo "Usage: getges.sh [-n network] [-e environment] [-f fhour] [-q] [-r resolution]" >&2 + echo " [-t filetype] [-v valid] [gfile]" >&2 + if [[ "${netwk}" == '?' ]]; then + echo " network choices:" >&2 + echo " global (default), namopl, gdas, gfs, cdas, etc." >&2 + elif [[ "${envir}" == '?' ]]; then + echo " environment choices:" >&2 + echo " prod (default), test, para, dump, prx" >&2 + echo " (some network values allowed for compatibility)" >&2 + elif [[ "${fhour}" == '?' ]]; then + echo " fhour is optional specific forecast hour" >&2 + elif [[ "${resol}" == '?' ]]; then + echo " resolution choices:" >&2 + echo " high (default), 25464, 17042, 12628, low, 6228, namopl, any" >&2 + elif [[ "${typef}" == '?' ]]; then + echo " filetype choices:" >&2 + echo " sigges (default), siggm3, siggm2, siggm1, siggp1, siggp2, siggp3," >&2 + echo " sfcges, sfcgm3, sfcgm2, sfcgm1, sfcgp1, sfcgp2, sfcgp3," >&2 + echo " sfgges, sfggp3, biascr, satang, satcnt, gesfil" >&2 + echo " pgbges, pgiges, pgbgm6, pgigm6, pgbgm3, pgigm3, pgbgp3, pgigp3," >&2 + echo " sigcur, sfccur, pgbcur, pgicur, prepqc, tcvg12, tcvges, tcvitl," >&2 + echo " enggrb, enggri, icegrb, icegri, snogrb, snogri, sstgrb, sstgri," >&2 + echo " pg2cur, pg2ges, restrt," >&2 + echo " natges, natgm3, natgm2, natgm1, natgp1, natgp2, natgp3, natcur," >&2 + echo " nsfges, nsfgm3, nsfgm2, nsfgm1, nsfgp1, nsfgp2, nsfgp3, nsfcur," >&2 + echo " nstcur, nflges, nflgp3," >&2 + elif [[ "${valid}" == '?' ]]; then + echo " valid is the valid date in yyyymmddhh or yymmddhh form" >&2 + echo " (default is environmental variable ${PDY}${cyc})" >&2 + elif [[ "${gfile}" == '?' ]]; then + echo " gfile is the guess file to write" >&2 + echo " (default is to write the guess file name to stdout)" >&2 + else + echo " (Note: set a given option to '?' for more details)" >&2 + fi + exit 1 fi -if [[ $envir != prod && $envir != test && $envir != para && $envir != dump && $envir != pr? && $envir != dev ]];then - netwk=$envir - envir=prod - echo '************************************************************' >&2 - echo '* WARNING: Using "-e" is deprecated in this case. *' >&2 - echo '* Please use "-n" instead. *' >&2 - echo '************************************************************' >&2 +if [[ "${envir}" != prod && "${envir}" != test && "${envir}" != para && "${envir}" != dump && "${envir}" != pr? && "${envir}" != dev ]]; then + netwk="${envir}" + envir=prod + echo '************************************************************' >&2 + echo '* WARNING: Using "-e" is deprecated in this case. *' >&2 + echo '* Please use "-n" instead. *' >&2 + echo '************************************************************' >&2 fi -if [[ "$netwk" = "namopl" || "$resol" = "namopl" ]];then - netwk=namopl - typef=restrt - resol=namopl +if [[ "${netwk}" == "namopl" || "${resol}" == "namopl" ]]; then + netwk=namopl + typef=restrt + resol=namopl fi if [[ "${resol}" == "57464" || "${resol}" == "38264" || "${resol}" == "19064" || "${resol}" == "25464" || "${resol}" == "17042" || "${resol}" == "12628" ]]; then resol=high @@ -172,30 +153,27 @@ fi if [[ "${resol}" == "6228" ]]; then resol=low fi -resolsuf="" -if [[ ${resol} == *deg ]]; then - resolsuf=.$resol -fi -fhbeg=$(${NHOUR:?} $valid) -if [[ ${fhbeg} -le 0 ]]; then +fhbeg=$(${NHOUR:?} "${valid}") +if [[ "${fhbeg}" -le 0 ]]; then fhbeg=03 fi -((fhbeg=(10#${fhbeg}-1)/3*3+3)) -if [[ $fhbeg -lt 10 ]]; then +((fhbeg = (10#${fhbeg} - 1) / 3 * 3 + 3)) +if [[ "${fhbeg}" -lt 10 ]]; then fhbeg="0${fhbeg}" fi -if [[ $typef = enggrb ]];then - typef=icegrb - echo '************************************************************' >&2 - echo '* WARNING: Using "-t enggrb" is now deprecated. *' >&2 - echo '* Please use "-t icegrb". *' >&2 - echo '************************************************************' >&2 -elif [[ $typef = enggri ]];then - typef=icegri - echo '************************************************************' >&2 - echo '* WARNING: Using "-t enggri" is now deprecated. *' >&2 - echo '* Please use "-t icegri". *' >&2 - echo '************************************************************' >&2 + +if [[ "${typef}" == enggrb ]]; then + typef=icegrb + echo '************************************************************' >&2 + echo '* WARNING: Using "-t enggrb" is now deprecated. *' >&2 + echo '* Please use "-t icegrb". *' >&2 + echo '************************************************************' >&2 +elif [[ "${typef}" == enggri ]]; then + typef=icegri + echo '************************************************************' >&2 + echo '* WARNING: Using "-t enggri" is now deprecated. *' >&2 + echo '* Please use "-t icegri". *' >&2 + echo '************************************************************' >&2 fi #------------------------------------------------------------------------------- @@ -204,1209 +182,1485 @@ geslist="" getlist00="" # GDAS -if [[ "$netwk" = "gdas" ]];then - if [ -z "$COMINgdas" ]; then - echo "getges.sh ERROR: The \$COMINgdas variable must be defined." >&2 - exit 1 - fi - fhend=12 - case $typef in - biascr) geslist=' - $COMINgdas/gdas.t${cyc}z.abias' - ;; - biascr_pc) geslist=' - $COMINgdas/gdas.t${cyc}z.abias_pc' - ;; - biascr_air) geslist=' - $COMINgdas/gdas.t${cyc}z.abias_air' - ;; - radstat) geslist=' - $COMINgdas/gdas.t${cyc}z.radstat' - ;; - pgbges) geslist=' - $COMINgdas/gdas.t${cyc}z.pgrbh$fh - $COMINgdas/gdas.t${cyc}z.pgrbf$fh' - ;; - pg2ges) geslist=' - $COMINgdas/gdas.t${cyc}z.pgrb2.0p25.f$gh' - ;; - pgbgm6) geslist=' - $COMINgdas/gdas.t${cyc}z.pgrbh$fhm6 - $COMINgdas/gdas.t${cyc}z.pgrbf$fhm6' - ;; - pgbgm3) geslist=' - $COMINgdas/gdas.t${cyc}z.pgrbh$fhm3 - $COMINgdas/gdas.t${cyc}z.pgrbf$fhm3' - ;; - pgbgp3) geslist=' - $COMINgdas/gdas.t${cyc}z.pgrbh$fhp3 - $COMINgdas/gdas.t${cyc}z.pgrbf$fhp3' - ;; - pgbcur) geslist=' - $COMINgdas/gdas.t${cyc}z.pgrbh$fh - $COMINgdas/gdas.t${cyc}z.pgrbf$fh' - fhbeg=00 - ;; - pg2cur) geslist=' - $COMINgdas/gdas.t${cyc}z.pgrb2.0p25.f$gh' - fhbeg=00 - ;; - prepqc) geslist=' - $COMINgdas/gdas.t${cyc}z.prepbufr' - fhbeg=00 - fhend=00 - ;; - tcvg12) geslist=' - $COMINgdas/gdas.t${cyc}z.syndata.tcvitals.tm00' - fhbeg=12 - fhend=12 - ;; - tcvges) geslist=' - $COMINgdas/gdas.t${cyc}z.syndata.tcvitals.tm00' - fhbeg=06 - fhend=06 - ;; - tcvitl) geslist=' - $COMINgdas/gdas.t${cyc}z.syndata.tcvitals.tm00' - fhbeg=00 - fhend=00 - ;; - icegrb) geslist=' - $COMINgdas/gdas.t${cyc}z.engicegrb' - fhbeg=00 - fhinc=06 - ;; - snogrb) geslist=' - $COMINgdas/gdas.t${cyc}z.snogrb' - fhbeg=00 - fhinc=06 - ;; - snogrb_574) geslist=' - $COMINgdas/gdas.t${cyc}z.snogrb_t574.1152.576' - fhbeg=00 - fhinc=06 - ;; - snogrb_1534) geslist=' - $COMINgdas/gdas.t${cyc}z.snogrb_t1534.3072.1536' - fhbeg=00 - fhinc=06 - ;; - sstgrb) geslist=' - $COMINgdas/gdas.t${cyc}z.sstgrb' - fhbeg=00 - fhinc=06 - ;; - natges) geslist=' - $COMINgdas/gdas.t${cyc}z.atmf$gh.nemsio' - ;; - natgm3) geslist=' - $COMINgdas/gdas.t${cyc}z.atm.f$ghm3.nemsio' - ;; - natgm2) geslist=' - $COMINgdas/gdas.t${cyc}z.atmf$ghm2.nemsio' - ;; - natgm1) geslist=' - $COMINgdas/gdas.t${cyc}z.atmf$ghm1.nemsio' - ;; - natgp1) geslist=' - $COMINgdas/gdas.t${cyc}z.atmf$ghp1.nemsio' - ;; - natgp2) geslist=' - $COMINgdas/gdas.t${cyc}z.atmf$ghp2.nemsio' - ;; - natgp3) geslist=' - $COMINgdas/gdas.t${cyc}z.atmf$ghp3.nemsio' - ;; - natcur) geslist=' - $COMINgdas/gdas.t${cyc}z.atmf$gh.nemsio' - getlist00=' - $COMINgdas/gdas.t${cyc}z.atmanl.nemsio' - fhbeg=00 - ;; - nsfges) geslist=' - $COMINgdas/gdas.t${cyc}z.sfcf$gh.nemsio' - ;; - nsfgm3) geslist=' - $COMINgdas/gdas.t${cyc}z.sfcf$ghm3.nemsio' - ;; - nsfgm2) geslist=' - $COMINgdas/gdas.t${cyc}z.sfcf$ghm2.nemsio' - ;; - nsfgm1) geslist=' - $COMINgdas/gdas.t${cyc}z.sfcf$ghm1.nemsio' - ;; - nsfgp1) geslist=' - $COMINgdas/gdas.t${cyc}z.sfcf$ghp1.nemsio' - ;; - nsfgp2) geslist=' - $COMINgdas/gdas.t${cyc}z.sfcf$ghp2.nemsio' - ;; - nsfgp3) geslist=' - $COMINgdas/gdas.t${cyc}z.sfcf$ghp3.nemsio' - ;; - nsfcur) geslist=' - $COMINgdas/gdas.t${cyc}z.sfcf$gh.nemsio' - getlist00=' - $COMINgdas/gdas.t${cyc}z.sfcanl.nemsio' - fhbeg=00 - ;; - nstcur) geslist=' - $COMINgdas/gdas.t${cyc}z.nstf$gh.nemsio' - getlist00=' - $COMINgdas/gdas.t${cyc}z.nstanl.nemsio' - fhbeg=00 - ;; - nflges) geslist=' - $COMINgdas/gdas.t${cyc}z.flxf$gh.nemsio' - ;; - nflgp3) geslist=' - $COMINgdas/gdas.t${cyc}z.flxf$ghp3.nemsio' - ;; - nflcur) geslist=' - $COMINgdas/gdas.t${cyc}z.flxf$gh.nemsio' - fhbeg=00 - ;; - esac +if [[ "${netwk}" == "gdas" ]]; then + if [[ -z "${COMINgdas}" ]]; then + echo "getges.sh ERROR: The \${COMINgdas} variable must be defined." >&2 + exit 1 + fi + fhend=12 + # shellcheck disable=SC2016 + case "${typef}" in + biascr) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.abias' + ;; + biascr_pc) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.abias_pc' + ;; + biascr_air) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.abias_air' + ;; + radstat) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.radstat' + ;; + pgbges) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.pgrbh${fh} + ${COMINgdas}/gdas.t${cyc}z.pgrbf${fh}' + ;; + pg2ges) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.pgrb2.0p25.f${gh}' + ;; + pgbgm6) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.pgrbh${fhm6} + ${COMINgdas}/gdas.t${cyc}z.pgrbf${fhm6}' + ;; + pgbgm3) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.pgrbh${fhm3} + ${COMINgdas}/gdas.t${cyc}z.pgrbf${fhm3}' + ;; + pgbgp3) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.pgrbh${fhp3} + ${COMINgdas}/gdas.t${cyc}z.pgrbf${fhp3}' + ;; + pgbcur) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.pgrbh${fh} + ${COMINgdas}/gdas.t${cyc}z.pgrbf${fh}' + fhbeg=00 + ;; + pg2cur) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.pgrb2.0p25.f${gh}' + fhbeg=00 + ;; + prepqc) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.prepbufr' + fhbeg=00 + fhend=00 + ;; + tcvg12) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.syndata.tcvitals.tm00' + fhbeg=12 + fhend=12 + ;; + tcvges) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.syndata.tcvitals.tm00' + fhbeg=06 + fhend=06 + ;; + tcvitl) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.syndata.tcvitals.tm00' + fhbeg=00 + fhend=00 + ;; + icegrb) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.engicegrb' + fhbeg=00 + fhinc=06 + ;; + snogrb) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.snogrb' + fhbeg=00 + fhinc=06 + ;; + snogrb_574) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.snogrb_t574.1152.576' + fhbeg=00 + fhinc=06 + ;; + snogrb_1534) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.snogrb_t1534.3072.1536' + fhbeg=00 + fhinc=06 + ;; + sstgrb) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.sstgrb' + fhbeg=00 + fhinc=06 + ;; + natges) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.atmf${gh}.nemsio' + ;; + natgm3) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.atm.f${ghm3}.nemsio' + ;; + natgm2) + geslist=' + + ${COMINgdas}/gdas.t${cyc}z.atmf${ghm2}.nemsio' + ;; + natgm1) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.atmf${ghm1}.nemsio' + ;; + natgp1) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.atmf${ghp1}.nemsio' + ;; + natgp2) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.atmf${ghp2}.nemsio' + ;; + natgp3) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.atmf${ghp3}.nemsio' + ;; + natcur) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.atmf${gh}.nemsio' + getlist00=' + ${COMINgdas}/gdas.t${cyc}z.atmanl.nemsio' + fhbeg=00 + ;; + nsfges) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.sfcf${gh}.nemsio' + ;; + nsfgm3) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.sfcf${ghm3}.nemsio' + ;; + nsfgm2) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.sfcf${ghm2}.nemsio' + ;; + nsfgm1) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.sfcf${ghm1}.nemsio' + ;; + nsfgp1) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.sfcf${ghp1}.nemsio' + ;; + nsfgp2) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.sfcf${ghp2}.nemsio' + ;; + nsfgp3) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.sfcf${ghp3}.nemsio' + ;; + nsfcur) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.sfcf${gh}.nemsio' + getlist00=' + ${COMINgdas}/gdas.t${cyc}z.sfcanl.nemsio' + fhbeg=00 + ;; + nstcur) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.nstf${gh}.nemsio' + getlist00=' + ${COMINgdas}/gdas.t${cyc}z.nstanl.nemsio' + fhbeg=00 + ;; + nflges) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.flxf${gh}.nemsio' + ;; + nflgp3) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.flxf${ghp3}.nemsio' + ;; + nflcur) + geslist=' + ${COMINgdas}/gdas.t${cyc}z.flxf${gh}.nemsio' + fhbeg=00 + ;; + *) + msg="FATAL ERROR: Unknown ${netwk} guess type ${typef}" + export err=101 + err_exit "${msg}" + ;; + esac # CFS-CDAS -elif [[ "$netwk" = "cfs-cdas" ]];then - if [ -z "$COMINcfs_cdas" ]; then - echo "getges.sh ERROR: The \$COMINcfs_cdas variable must be defined." >&2 - exit 1 - fi - fhend=12 - case $typef in - sigges) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.sf$fh' - ;; - siggm3) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.sf$fhm3' - ;; - siggm2) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.sf$fhm2' - ;; - siggm1) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.sf$fhm1' - ;; - siggp1) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.sf$fhp1' - ;; - siggp2) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.sf$fhp2' - ;; - siggp3) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.sf$fhp3' - ;; - sfcges) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.bf${fh}.LIS - $COMINcfs_cdas/cdas1.t${cyc}z.bf$fh' - ;; - sfcgm3) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.bf${fhm3}.LIS - $COMINcfs_cdas/cdas1.t${cyc}z.bf$fhm3' - ;; - sfcgm2) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.bf${fhm2}.LIS - $COMINcfs_cdas/cdas1.t${cyc}z.bf$fhm2' - ;; - sfcgm1) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.bf${fhm1}.LIS - $COMINcfs_cdas/cdas1.t${cyc}z.bf$fhm1' - ;; - sfcgp1) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.bf${fhp1}.LIS - $COMINcfs_cdas/cdas1.t${cyc}z.bf$fhp1' - ;; - sfcgp2) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.bf${fhp2}.LIS - $COMINcfs_cdas/cdas1.t${cyc}z.bf$fhp2' - ;; - sfcgp3) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.bf${fhp3}.LIS - $COMINcfs_cdas/cdas1.t${cyc}z.bf$fhp3' - ;; - biascr) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.abias' - ;; - satang) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.satang' - ;; - satcnt) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.satcnt' - ;; - gesfil) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.gesfile' - fhbeg=00 - fhend=00 - ;; - sfgges) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.sfluxgrbf$fh' - ;; - sfggp3) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.sfluxgrbf$fhp3' - ;; - pgbges) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.pgrbh$fh - $COMINcfs_cdas/cdas1.t${cyc}z.pgrbf$fh' - ;; - pgiges) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.pgrbih$fh - $COMINcfs_cdas/cdas1.t${cyc}z.pgrbif$fh' - ;; - pgbgm6) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.pgrbh$fhm6 - $COMINcfs_cdas/cdas1.t${cyc}z.pgrbf$fhm6' - ;; - pgigm6) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.pgrbih$fhm6 - $COMINcfs_cdas/cdas1.t${cyc}z.pgrbif$fhm6' - ;; - pgbgm3) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.pgrbh$fhm3 - $COMINcfs_cdas/cdas1.t${cyc}z.pgrbf$fhm3' - ;; - pgigm3) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.pgrbih$fhm3 - $COMINcfs_cdas/cdas1.t${cyc}z.pgrbif$fhm3' - ;; - pgbgp3) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.pgrbh$fhp3 - $COMINcfs_cdas/cdas1.t${cyc}z.pgrbf$fhp3' - ;; - pgigp3) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.pgrbih$fhp3 - $COMINcfs_cdas/cdas1.t${cyc}z.pgrbif$fhp3' - ;; - sigcur) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.sf$fh' - getlist00=' - $COMINcfs_cdas/cdas1.t${cyc}z.sanl' - fhbeg=00 - ;; - sfccur) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.bf$fh' - getlist00=' - $COMINcfs_cdas/cdas1.t${cyc}z.sfcanl' - fhbeg=00 - ;; - pgbcur) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.pgrbh$fh - $COMINcfs_cdas/cdas1.t${cyc}z.pgrbf$fh' - fhbeg=00 - ;; - pgicur) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.pgrbih$fh - $COMINcfs_cdas/cdas1.t${cyc}z.pgrbif$fh' - fhbeg=00 - ;; - prepqc) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.prepbufr' - fhbeg=00 - fhend=00 - ;; - tcvg12) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.syndata.tcvitals.tm00' - fhbeg=12 - fhend=12 - ;; - tcvges) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.syndata.tcvitals.tm00' - fhbeg=06 - fhend=06 - ;; - tcvitl) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.syndata.tcvitals.tm00' - fhbeg=00 - fhend=00 - ;; - icegrb) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.engicegrb' - fhbeg=00 - fhinc=06 - ;; - icegri) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.engicegrb.index' - fhbeg=00 - fhinc=06 - ;; - snogrb) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.snogrb' - fhbeg=00 - fhinc=06 - ;; - snogrb_high) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.snogrb_t574 - $COMINcfs_cdas/cdas1.t${cyc}z.snogrb_t382' - fhbeg=00 - fhinc=06 - ;; - snogrb_382) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.snogrb_t382' - fhbeg=00 - fhinc=06 - ;; - snogrb_574) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.snogrb_t574' - fhbeg=00 - fhinc=06 - ;; - snogri) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.snogrb.index' - fhbeg=00 - fhinc=06 - ;; - sstgrb) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.sstgrb' - fhbeg=00 - fhinc=06 - ;; - sstgri) geslist=' - $COMINcfs_cdas/cdas1.t${cyc}z.sstgrb.index' - fhbeg=00 - fhinc=06 - ;; - esac +elif [[ "${netwk}" == "cfs-cdas" ]]; then + if [[ -z "${COMINcfs_cdas}" ]]; then + echo "getges.sh ERROR: The \${COMINcfs_cdas} variable must be defined." >&2 + exit 1 + fi + fhend=12 + # shellcheck disable=SC2016 + case "${typef}" in + sigges) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.sf${fh}' + ;; + siggm3) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.sf${fhm3}' + ;; + siggm2) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.sf${fhm2}' + ;; + siggm1) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.sf${fhm1}' + ;; + siggp1) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.sf${fhp1}' + ;; + siggp2) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.sf${fhp2}' + ;; + siggp3) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.sf${fhp3}' + ;; + sfcges) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.bf${fh}.LIS + ${COMINcfs_cdas}/cdas1.t${cyc}z.bf${fh}' + ;; + sfcgm3) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.bf${fhm3}.LIS + ${COMINcfs_cdas}/cdas1.t${cyc}z.bf${fhm3}' + ;; + sfcgm2) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.bf${fhm2}.LIS + ${COMINcfs_cdas}/cdas1.t${cyc}z.bf${fhm2}' + ;; + sfcgm1) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.bf${fhm1}.LIS + ${COMINcfs_cdas}/cdas1.t${cyc}z.bf${fhm1}' + ;; + sfcgp1) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.bf${fhp1}.LIS + ${COMINcfs_cdas}/cdas1.t${cyc}z.bf${fhp1}' + ;; + sfcgp2) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.bf${fhp2}.LIS + ${COMINcfs_cdas}/cdas1.t${cyc}z.bf${fhp2}' + ;; + sfcgp3) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.bf${fhp3}.LIS + ${COMINcfs_cdas}/cdas1.t${cyc}z.bf${fhp3}' + ;; + biascr) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.abias' + ;; + satang) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.satang' + ;; + satcnt) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.satcnt' + ;; + gesfil) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.gesfile' + fhbeg=00 + fhend=00 + ;; + sfgges) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.sfluxgrbf${fh}' + ;; + sfggp3) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.sfluxgrbf${fhp3}' + ;; + pgbges) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.pgrbh${fh} + ${COMINcfs_cdas}/cdas1.t${cyc}z.pgrbf${fh}' + ;; + pgiges) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.pgrbih${fh} + ${COMINcfs_cdas}/cdas1.t${cyc}z.pgrbif${fh}' + ;; + pgbgm6) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.pgrbh${fhm6} + ${COMINcfs_cdas}/cdas1.t${cyc}z.pgrbf${fhm6}' + ;; + pgigm6) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.pgrbih${fhm6} + ${COMINcfs_cdas}/cdas1.t${cyc}z.pgrbif${fhm6}' + ;; + pgbgm3) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.pgrbh${fhm3} + ${COMINcfs_cdas}/cdas1.t${cyc}z.pgrbf${fhm3}' + ;; + pgigm3) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.pgrbih${fhm3} + ${COMINcfs_cdas}/cdas1.t${cyc}z.pgrbif${fhm3}' + ;; + pgbgp3) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.pgrbh${fhp3} + ${COMINcfs_cdas}/cdas1.t${cyc}z.pgrbf${fhp3}' + ;; + pgigp3) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.pgrbih${fhp3} + + ${COMINcfs_cdas}/cdas1.t${cyc}z.pgrbif${fhp3}' + ;; + sigcur) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.sf${fh}' + getlist00=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.sanl' + fhbeg=00 + ;; + sfccur) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.bf${fh}' + getlist00=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.sfcanl' + fhbeg=00 + ;; + pgbcur) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.pgrbh${fh} + ${COMINcfs_cdas}/cdas1.t${cyc}z.pgrbf${fh}' + fhbeg=00 + ;; + pgicur) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.pgrbih${fh} + + ${COMINcfs_cdas}/cdas1.t${cyc}z.pgrbif${fh}' + fhbeg=00 + ;; + prepqc) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.prepbufr' + fhbeg=00 + fhend=00 + ;; + tcvg12) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.syndata.tcvitals.tm00' + fhbeg=12 + fhend=12 + ;; + tcvges) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.syndata.tcvitals.tm00' + fhbeg=06 + fhend=06 + ;; + tcvitl) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.syndata.tcvitals.tm00' + fhbeg=00 + fhend=00 + ;; + icegrb) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.engicegrb' + fhbeg=00 + fhinc=06 + ;; + icegri) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.engicegrb.index' + fhbeg=00 + fhinc=06 + ;; + snogrb) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.snogrb' + fhbeg=00 + fhinc=06 + ;; + snogrb_high) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.snogrb_t574 + ${COMINcfs_cdas}/cdas1.t${cyc}z.snogrb_t382' + fhbeg=00 + fhinc=06 + ;; + snogrb_382) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.snogrb_t382' + fhbeg=00 + fhinc=06 + ;; + snogrb_574) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.snogrb_t574' + fhbeg=00 + fhinc=06 + ;; + snogri) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.snogrb.index' + fhbeg=00 + fhinc=06 + ;; + sstgrb) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.sstgrb' + fhbeg=00 + fhinc=06 + ;; + sstgri) + geslist=' + ${COMINcfs_cdas}/cdas1.t${cyc}z.sstgrb.index' + fhbeg=00 + fhinc=06 + ;; + *) + msg="FATAL ERROR: Unknown ${netwk} guess type ${typef}" + export err=101 + err_exit "${msg}" + ;; + esac # GFS -elif [[ "$netwk" = "gfs" ]];then - if [ -z "$COMINgfs" ]; then - echo "getges.sh ERROR: The \$COMINgfs variable must be defined." >&2 - exit 1 - fi - fhend=384 - case $typef in - pgbcur) geslist=' - $COMINgfs/gfs.t${cyc}z.pgrbf$fh' - fhbeg=00 - ;; - pg2cur) geslist=' - $COMINgfs/gfs.t${cyc}z.pgrb2.0p25.f$gh' - fhbeg=00 - ;; - prepqc) geslist=' - $COMINgfs/gfs.t${cyc}z.prepbufr' - fhbeg=00 - fhend=00 - ;; - tcvitl) geslist=' - $COMINgfs/gfs.t${cyc}z.syndata.tcvitals.tm00' - fhbeg=00 - fhend=00 - ;; - icegrb) geslist=' - $COMINgfs/gfs.t${cyc}z.engicegrb' - fhbeg=00 - fhinc=06 - ;; - snogrb) geslist=' - $COMINgfs/gfs.t${cyc}z.snogrb' - fhbeg=00 - fhinc=06 - ;; - snogrb_1534) geslist=' - $COMINgfs/gfs.t${cyc}z.snogrb_t1534.3072.1536' - fhbeg=00 - fhinc=06 - ;; - sstgrb) geslist=' - $COMINgfs/gfs.t${cyc}z.sstgrb' - fhbeg=00 - fhinc=06 - ;; - natcur) geslist=' - $COMINgfs/gfs.t${cyc}z.atm.f$gh.nemsio' - getlist00=' - $COMINgfs/gfs.t${cyc}z.atmanl.nemsio' - fhbeg=00 - ;; - nsfcur) geslist=' - $COMINgfs/gfs.t${cyc}z.sfcf$gh.nemsio' - getlist00=' - $COMINgfs/gfs.t${cyc}z.sfcanl.nemsio' - fhbeg=00 - ;; - nstcur) geslist=' - $COMINgfs/gfs.t${cyc}z.nstf$gh.nemsio' - getlist00=' - $COMINgfs/gfs.t${cyc}z.nstanl.nemsio' - fhbeg=00 - ;; - nflcur) geslist=' - $COMINgfs/gfs.t${cyc}z.flxf$gh.nemsio' - fhbeg=00 - ;; - esac +elif [[ "${netwk}" == "gfs" ]]; then + if [[ -z "${COMINgfs}" ]]; then + echo "getges.sh ERROR: The \${COMINgfs} variable must be defined." >&2 + exit 1 + fi + fhend=384 + # shellcheck disable=SC2016 + case "${typef}" in + pgbcur) + geslist=' + ${COMINgfs}/gfs.t${cyc}z.pgrbf${fh}' + fhbeg=00 + ;; + pg2cur) + geslist=' + ${COMINgfs}/gfs.t${cyc}z.pgrb2.0p25.f${gh}' + fhbeg=00 + ;; + prepqc) + geslist=' + ${COMINgfs}/gfs.t${cyc}z.prepbufr' + fhbeg=00 + fhend=00 + ;; + tcvitl) + geslist=' + ${COMINgfs}/gfs.t${cyc}z.syndata.tcvitals.tm00' + fhbeg=00 + fhend=00 + ;; + icegrb) + geslist=' + ${COMINgfs}/gfs.t${cyc}z.engicegrb' + fhbeg=00 + fhinc=06 + ;; + snogrb) + geslist=' + ${COMINgfs}/gfs.t${cyc}z.snogrb' + fhbeg=00 + fhinc=06 + ;; + snogrb_1534) + geslist=' + ${COMINgfs}/gfs.t${cyc}z.snogrb_t1534.3072.1536' + fhbeg=00 + fhinc=06 + ;; + sstgrb) + geslist=' + ${COMINgfs}/gfs.t${cyc}z.sstgrb' + fhbeg=00 + fhinc=06 + ;; + natcur) + geslist=' + ${COMINgfs}/gfs.t${cyc}z.atm.f${gh}.nemsio' + getlist00=' + + ${COMINgfs}/gfs.t${cyc}z.atmanl.nemsio' + fhbeg=00 + ;; + nsfcur) + geslist=' + ${COMINgfs}/gfs.t${cyc}z.sfcf${gh}.nemsio' + getlist00=' + ${COMINgfs}/gfs.t${cyc}z.sfcanl.nemsio' + fhbeg=00 + ;; + nstcur) + geslist=' + ${COMINgfs}/gfs.t${cyc}z.nstf${gh}.nemsio' + getlist00=' + ${COMINgfs}/gfs.t${cyc}z.nstanl.nemsio' + fhbeg=00 + ;; + nflcur) + geslist=' + ${COMINgfs}/gfs.t${cyc}z.flxf${gh}.nemsio' + fhbeg=00 + ;; + *) + msg="FATAL ERROR: Unknown ${netwk} guess type ${typef}" + export err=101 + err_exit "${msg}" + ;; + esac # CDAS -elif [[ "$netwk" = "cdas" ]];then - if [ -z "$COMINcdas" ]; then - echo "getges.sh ERROR: The \$COMINcdas variable must be defined." >&2 - exit 1 - fi - fhbeg=06 - fhend=06 - case $typef in - sigges) geslist=' - $COMINcdas/cdas.t${cyc}z.sf$fh' - ;; - siggm3) geslist=' - $COMINcdas/cdas.t${cyc}z.sf$fhm3' - ;; - siggm2) geslist=' - $COMINcdas/cdas.t${cyc}z.sf$fhm2' - ;; - siggm1) geslist=' - $COMINcdas/cdas.t${cyc}z.sf$fhm1' - ;; - siggp1) geslist=' - $COMINcdas/cdas.t${cyc}z.sf$fhp1' - ;; - siggp2) geslist=' - $COMINcdas/cdas.t${cyc}z.sf$fhp2' - ;; - siggp3) geslist=' - $COMINcdas/cdas.t${cyc}z.sf$fhp3' - ;; - sfcges) geslist=' - $COMINcdas/cdas.t${cyc}z.bf$fh' - ;; - sfcgm3) geslist=' - $COMINcdas/cdas.t${cyc}z.bf$fhm3' - ;; - sfcgm2) geslist=' - $COMINcdas/cdas.t${cyc}z.bf$fhm2' - ;; - sfcgm1) geslist=' - $COMINcdas/cdas.t${cyc}z.bf$fhm1' - ;; - sfcgp1) geslist=' - $COMINcdas/cdas.t${cyc}z.bf$fhp1' - ;; - sfcgp2) geslist=' - $COMINcdas/cdas.t${cyc}z.bf$fhp2' - ;; - sfcgp3) geslist=' - $COMINcdas/cdas.t${cyc}z.bf$fhp3' - ;; - biascr) geslist=' - $COMINcdas/cdas.t${cyc}z.abias' - ;; - satang) geslist=' - $COMINcdas/cdas.t${cyc}z.satang' - ;; - satcnt) geslist=' - $COMINcdas/cdas.t${cyc}z.satcnt' - ;; - gesfil) geslist=' - $COMINcdas/cdas.t${cyc}z.gesfile' - fhbeg=00 - fhend=00 - ;; - pgbges) geslist=' - $COMINcdas/cdas.t${cyc}z.pgrbf$fh' - ;; - pgiges) geslist=' - $COMINcdas/cdas.t${cyc}z.pgrbif$fh' - ;; - pgbgm6) geslist=' - $COMINcdas/cdas.t${cyc}z.pgrbf$fhm6' - ;; - pgigm6) geslist=' - $COMINcdas/cdas.t${cyc}z.pgrbif$fhm6' - ;; - pgbgm3) geslist=' - $COMINcdas/cdas.t${cyc}z.pgrbf$fhm3' - ;; - pgigm3) geslist=' - $COMINcdas/cdas.t${cyc}z.pgrbif$fhm3' - ;; - pgbgp3) geslist=' - $COMINcdas/cdas.t${cyc}z.pgrbf$fhp3' - ;; - pgigp3) geslist=' - $COMINcdas/cdas.t${cyc}z.pgrbif$fhp3' - ;; - sigcur) geslist=' - $COMINcdas/cdas.t${cyc}z.sf$fh' - getlist00=' - $COMINcdas/cdas.t${cyc}z.sanl' - fhbeg=00 - ;; - sfccur) geslist=' - $COMINcdas/cdas.t${cyc}z.bf$fh' - getlist00=' - $COMINcdas/cdas.t${cyc}z.sfcanl' - fhbeg=00 - ;; - pgbcur) geslist=' - $COMINcdas/cdas.t${cyc}z.pgrbf$fh' - fhbeg=00 - ;; - pgicur) geslist=' - $COMINcdas/cdas.t${cyc}z.pgrbif$fh' - fhbeg=00 - ;; - prepqc) geslist=' - $COMINcdas/cdas.t${cyc}z.prepbufr' - fhbeg=00 - fhend=00 - ;; - tcvg12) geslist=' - $COMINcdas/cdas.t${cyc}z.syndata.tcvitals.tm00' - fhbeg=12 - fhend=12 - ;; - tcvges) geslist=' - $COMINcdas/cdas.t${cyc}z.syndata.tcvitals.tm00' - fhbeg=06 - fhend=06 - ;; - tcvitl) geslist=' - $COMINcdas/cdas.t${cyc}z.syndata.tcvitals.tm00' - fhbeg=00 - fhend=00 - ;; - icegrb) geslist=' - $COMINcdas/cdas.t${cyc}z.engicegrb' - fhbeg=00 - fhinc=06 - ;; - icegri) geslist=' - $COMINcdas/cdas.t${cyc}z.engicegrb.index' - fhbeg=00 - fhinc=06 - ;; - snogrb) geslist=' - $COMINcdas/cdas.t${cyc}z.snogrb' - fhbeg=00 - fhinc=06 - ;; - snogri) geslist=' - $COMINcdas/cdas.t${cyc}z.snogrb.index' - fhbeg=00 - fhinc=06 - ;; - sstgrb) geslist=' - $COMINcdas/cdas.t${cyc}z.sstgrb' - fhbeg=00 - fhinc=06 - ;; - sstgri) geslist=' - $COMINcdas/cdas.t${cyc}z.sstgrb.index' - fhbeg=00 - fhinc=06 - ;; - esac +elif [[ "${netwk}" == "cdas" ]]; then + if [[ -z "${COMINcdas}" ]]; then + echo "getges.sh ERROR: The \${COMINcdas} variable must be defined." >&2 + exit 1 + fi + fhbeg=06 + fhend=06 + # shellcheck disable=SC2016 + case ${typef} in + sigges) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.sf${fh}' + ;; + siggm3) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.sf${fhm3}' + ;; + siggm2) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.sf${fhm2}' + ;; + siggm1) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.sf${fhm1}' + ;; + siggp1) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.sf${fhp1}' + ;; + siggp2) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.sf${fhp2}' + ;; + siggp3) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.sf${fhp3}' + ;; + sfcges) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.bf${fh}' + ;; + sfcgm3) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.bf${fhm3}' + ;; + sfcgm2) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.bf${fhm2}' + ;; + sfcgm1) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.bf${fhm1}' + ;; + sfcgp1) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.bf${fhp1}' + ;; + sfcgp2) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.bf${fhp2}' + ;; + sfcgp3) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.bf${fhp3}' + ;; + biascr) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.abias' + ;; + satang) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.satang' + ;; + satcnt) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.satcnt' + ;; + gesfil) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.gesfile' + fhbeg=00 + fhend=00 + ;; + pgbges) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.pgrbf${fh}' + ;; + pgiges) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.pgrbif${fh}' + ;; + pgbgm6) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.pgrbf${fhm6}' + ;; + pgigm6) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.pgrbif${fhm6}' + ;; + pgbgm3) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.pgrbf${fhm3}' + ;; + pgigm3) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.pgrbif${fhm3}' + ;; + pgbgp3) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.pgrbf${fhp3}' + ;; + pgigp3) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.pgrbif${fhp3}' + ;; + sigcur) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.sf${fh}' + getlist00=' + ${COMINcdas}/cdas.t${cyc}z.sanl' + fhbeg=00 + ;; + sfccur) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.bf${fh}' + getlist00=' + ${COMINcdas}/cdas.t${cyc}z.sfcanl' + fhbeg=00 + ;; + pgbcur) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.pgrbf${fh}' + fhbeg=00 + ;; + pgicur) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.pgrbif${fh}' + fhbeg=00 + ;; + prepqc) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.prepbufr' + fhbeg=00 + fhend=00 + ;; + tcvg12) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.syndata.tcvitals.tm00' + fhbeg=12 + fhend=12 + ;; + tcvges) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.syndata.tcvitals.tm00' + fhbeg=06 + fhend=06 + ;; + tcvitl) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.syndata.tcvitals.tm00' + fhbeg=00 + fhend=00 + ;; + icegrb) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.engicegrb' + fhbeg=00 + fhinc=06 + ;; + icegri) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.engicegrb.index' + fhbeg=00 + fhinc=06 + ;; + snogrb) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.snogrb' + fhbeg=00 + fhinc=06 + ;; + snogri) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.snogrb.index' + fhbeg=00 + fhinc=06 + ;; + sstgrb) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.sstgrb' + fhbeg=00 + fhinc=06 + ;; + sstgri) + geslist=' + ${COMINcdas}/cdas.t${cyc}z.sstgrb.index' + fhbeg=00 + fhinc=06 + ;; + *) + msg="FATAL ERROR: Unknown ${netwk} guess type ${typef}" + export err=101 + err_exit "${msg}" + ;; + esac # CDC CDAS -elif [[ "$netwk" = "cdc" ]];then - if [ -z "$COMINcdc" ]; then - echo "getges.sh ERROR: The \$COMINcdc variable must be defined." >&2 - exit 1 - fi - fhbeg=06 - fhend=06 - case $typef in - sigges) geslist=' - $COMINcdc/cdas.t${cyc}z.sf$fh' - ;; - siggm3) geslist=' - $COMINcdc/cdas.t${cyc}z.sf$fhm3' - ;; - siggm2) geslist=' - $COMINcdc/cdas.t${cyc}z.sf$fhm2' - ;; - siggm1) geslist=' - $COMINcdc/cdas.t${cyc}z.sf$fhm1' - ;; - siggp1) geslist=' - $COMINcdc/cdas.t${cyc}z.sf$fhp1' - ;; - siggp2) geslist=' - $COMINcdc/cdas.t${cyc}z.sf$fhp2' - ;; - siggp3) geslist=' - $COMINcdc/cdas.t${cyc}z.sf$fhp3' - ;; - sfcges) geslist=' - $COMINcdc/cdas.t${cyc}z.bf$fh' - ;; - sfcgm3) geslist=' - $COMINcdc/cdas.t${cyc}z.bf$fhm3' - ;; - sfcgm2) geslist=' - $COMINcdc/cdas.t${cyc}z.bf$fhm2' - ;; - sfcgm1) geslist=' - $COMINcdc/cdas.t${cyc}z.bf$fhm1' - ;; - sfcgp1) geslist=' - $COMINcdc/cdas.t${cyc}z.bf$fhp1' - ;; - sfcgp2) geslist=' - $COMINcdc/cdas.t${cyc}z.bf$fhp2' - ;; - sfcgp3) geslist=' - $COMINcdc/cdas.t${cyc}z.bf$fhp3' - ;; - biascr) geslist=' - $COMINcdc/cdas.t${cyc}z.abias' - ;; - satang) geslist=' - $COMINcdc/cdas.t${cyc}z.satang' - ;; - satcnt) geslist=' - $COMINcdc/cdas.t${cyc}z.satcnt' - ;; - gesfil) geslist=' - $COMINcdc/cdas.t${cyc}z.gesfile' - fhbeg=00 - fhend=00 - ;; - pgbges) geslist=' - $COMINcdc/cdas.t${cyc}z.pgrbf$fh' - ;; - pgiges) geslist=' - $COMINcdc/cdas.t${cyc}z.pgrbif$fh' - ;; - pgbgm6) geslist=' - $COMINcdc/cdas.t${cyc}z.pgrbf$fhm6' - ;; - pgigm6) geslist=' - $COMINcdc/cdas.t${cyc}z.pgrbif$fhm6' - ;; - pgbgm3) geslist=' - $COMINcdc/cdas.t${cyc}z.pgrbf$fhm3' - ;; - pgigm3) geslist=' - $COMINcdc/cdas.t${cyc}z.pgrbif$fhm3' - ;; - pgbgp3) geslist=' - $COMINcdc/cdas.t${cyc}z.pgrbf$fhp3' - ;; - pgigp3) geslist=' - $COMINcdc/cdas.t${cyc}z.pgrbif$fhp3' - ;; - sigcur) geslist=' - $COMINcdc/cdas.t${cyc}z.sf$fh' - getlist00=' - $COMINcdc/cdas.t${cyc}z.sanl' - fhbeg=00 - ;; - sfccur) geslist=' - $COMINcdc/cdas.t${cyc}z.bf$fh' - getlist00=' - $COMINcdc/cdas.t${cyc}z.sfcanl' - fhbeg=00 - ;; - pgbcur) geslist=' - $COMINcdc/cdas.t${cyc}z.pgrbf$fh' - fhbeg=00 - ;; - pgicur) geslist=' - $COMINcdc/cdas.t${cyc}z.pgrbif$fh' - fhbeg=00 - ;; - prepqc) geslist=' - $COMINcdc/cdas.t${cyc}z.prepbufr' - fhbeg=00 - fhend=00 - ;; - tcvg12) geslist=' - $COMINcdc/cdas.t${cyc}z.syndata.tcvitals.tm00' - fhbeg=12 - fhend=12 - ;; - tcvges) geslist=' - $COMINcdc/cdas.t${cyc}z.syndata.tcvitals.tm00' - fhbeg=06 - fhend=06 - ;; - tcvitl) geslist=' - $COMINcdc/cdas.t${cyc}z.syndata.tcvitals.tm00' - fhbeg=00 - fhend=00 - ;; - icegrb) geslist=' - $COMINcdc/cdas.t${cyc}z.engicegrb' - fhbeg=00 - fhinc=06 - ;; - icegri) geslist=' - $COMINcdc/cdas.t${cyc}z.engicegrb.index' - fhbeg=00 - fhinc=06 - ;; - snogrb) geslist=' - $COMINcdc/cdas.t${cyc}z.snogrb' - fhbeg=00 - fhinc=06 - ;; - snogri) geslist=' - $COMINcdc/cdas.t${cyc}z.snogrb.index' - fhbeg=00 - fhinc=06 - ;; - sstgrb) geslist=' - $COMINcdc/cdas.t${cyc}z.sstgrb' - fhbeg=00 - fhinc=06 - ;; - sstgri) geslist=' - $COMINcdc/cdas.t${cyc}z.sstgrb.index' - fhbeg=00 - fhinc=06 - ;; - esac +elif [[ "${netwk}" == "cdc" ]]; then + if [[ -z "${COMINcdc}" ]]; then + echo "getges.sh ERROR: The \${COMINcdc} variable must be defined." >&2 + exit 1 + fi + fhbeg=06 + fhend=06 + # shellcheck disable=SC2016 + case "${typef}" in + sigges) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.sf${fh}' + ;; + siggm3) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.sf${fhm3}' + ;; + siggm2) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.sf${fhm2}' + ;; + siggm1) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.sf${fhm1}' + ;; + siggp1) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.sf${fhp1}' + ;; + siggp2) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.sf${fhp2}' + ;; + siggp3) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.sf${fhp3}' + ;; + sfcges) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.bf${fh}' + ;; + sfcgm3) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.bf${fhm3}' + ;; + sfcgm2) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.bf${fhm2}' + ;; + sfcgm1) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.bf${fhm1}' + ;; + sfcgp1) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.bf${fhp1}' + ;; + sfcgp2) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.bf${fhp2}' + ;; + sfcgp3) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.bf${fhp3}' + ;; + biascr) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.abias' + ;; + satang) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.satang' + ;; + satcnt) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.satcnt' + ;; + gesfil) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.gesfile' + fhbeg=00 + fhend=00 + ;; + pgbges) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.pgrbf${fh}' + ;; + pgiges) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.pgrbif${fh}' + ;; + pgbgm6) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.pgrbf${fhm6}' + ;; + pgigm6) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.pgrbif${fhm6}' + ;; + pgbgm3) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.pgrbf${fhm3}' + ;; + pgigm3) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.pgrbif${fhm3}' + ;; + pgbgp3) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.pgrbf${fhp3}' + ;; + pgigp3) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.pgrbif${fhp3}' + ;; + sigcur) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.sf${fh}' + getlist00=' + ${COMINcdc}/cdas.t${cyc}z.sanl' + fhbeg=00 + ;; + sfccur) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.bf${fh}' + getlist00=' + ${COMINcdc}/cdas.t${cyc}z.sfcanl' + fhbeg=00 + ;; + pgbcur) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.pgrbf${fh}' + fhbeg=00 + ;; + pgicur) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.pgrbif${fh}' + fhbeg=00 + ;; + prepqc) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.prepbufr' + fhbeg=00 + fhend=00 + ;; + tcvg12) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.syndata.tcvitals.tm00' + fhbeg=12 + fhend=12 + ;; + tcvges) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.syndata.tcvitals.tm00' + fhbeg=06 + fhend=06 + ;; + tcvitl) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.syndata.tcvitals.tm00' + fhbeg=00 + fhend=00 + ;; + icegrb) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.engicegrb' + fhbeg=00 + fhinc=06 + ;; + icegri) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.engicegrb.index' + fhbeg=00 + fhinc=06 + ;; + snogrb) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.snogrb' + fhbeg=00 + fhinc=06 + ;; + snogri) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.snogrb.index' + fhbeg=00 + fhinc=06 + ;; + sstgrb) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.sstgrb' + fhbeg=00 + fhinc=06 + ;; + sstgri) + geslist=' + ${COMINcdc}/cdas.t${cyc}z.sstgrb.index' + fhbeg=00 + fhinc=06 + ;; + *) + msg="FATAL ERROR: Unknown ${netwk} guess type ${typef}" + export err=101 + err_exit "${msg}" + ;; + esac # Any resolution production -elif [[ "$netwk" = "global" ]];then - if [ -z "$COMINgdas" ]; then - echo "getges.sh ERROR: The \$COMINgdas variable must be defined." >&2 - exit 1 - fi - if [ -z "$COMINgfs" ]; then - echo "getges.sh ERROR: The \$COMINgfs variable must be defined." >&2 - exit 1 - fi - GETGES_NWG=${GETGES_NWG:-${GESROOT:?}} - case $typef in - biascr) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.abias - $COMINgdas/gdas.t${cyc}z.abias - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.abias - $COMINgfs/gfs.t${cyc}z.abias' - fhbeg=06 - fhinc=06 - ;; - pgbges) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.pgrbh$fh - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.pgrbf$fh - $COMINgdas/gdas.t${cyc}z.pgrbh$fh - $COMINgdas/gdas.t${cyc}z.pgrbf$fh - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.pgrbf$fh - $COMINgfs/gfs.t${cyc}z.pgrbf$fh' - ;; - pgbgm6) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.pgrbh$fhm6 - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.pgrbf$fhm6 - $COMINgdas/gdas.t${cyc}z.pgrbh$fhm6 - $COMINgdas/gdas.t${cyc}z.pgrbf$fhm6 - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.pgrbf$fhm6 - $COMINgfs/gfs.t${cyc}z.pgrbf$fhm6' - ;; - pgbgm3) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.pgrbh$fhm3 - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.pgrbf$fhm3 - $COMINgdas/gdas.t${cyc}z.pgrbh$fhm3 - $COMINgdas/gdas.t${cyc}z.pgrbf$fhm3 - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.pgrbf$fhm3 - $COMINgfs/gfs.t${cyc}z.pgrbf$fhm3' - ;; - pgbgp3) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.pgrbh$fhp3 - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.pgrbf$fhp3 - $COMINgdas/gdas.t${cyc}z.pgrbh$fhp3 - $COMINgdas/gdas.t${cyc}z.pgrbf$fhp3 - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.pgrbf$fhp3 - $COMINgfs/gfs.t${cyc}z.pgrbf$fhp3' - ;; - pg2ges) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.pgrb2.0p25.f$gh - $COMINgdas/gdas.t${cyc}z.pgrb2.0p25.f$gh - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.pgrb2.0p25.f$gh - $COMINgfs/gfs.t${cyc}z.pgrb2.0p25.f$gh' - ;; - pg2gm6) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.pgrb2.0p25.f$ghm6 - $COMINgdas/gdas.t${cyc}z.pgrb2.0p25.f$ghm6 - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.pgrb2.0p25.f$ghm6 - $COMINgfs/gfs.t${cyc}z.pgrb2.0p25.f$ghm6' - ;; - pg2gm5) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.pgrb2.0p25.f$ghm5 - $COMINgdas/gdas.t${cyc}z.pgrb2.0p25.f$ghm5 - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.pgrb2.0p25.f$ghm5 - $COMINgfs/gfs.t${cyc}z.pgrb2.0p25.f$ghm5' - ;; - pg2gm4) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.pgrb2.0p25.f$ghm4 - $COMINgdas/gdas.t${cyc}z.pgrb2.0p25.f$ghm4 - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.pgrb2.0p25.f$ghm4 - $COMINgfs/gfs.t${cyc}z.pgrb2.0p25.f$ghm4' - ;; - pg2gm3) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.pgrb2.0p25.f$ghm3 - $COMINgdas/gdas.t${cyc}z.pgrb2.0p25.f$ghm3 - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.pgrb2.0p25.f$ghm3 - $COMINgfs/gfs.t${cyc}z.pgrb2.0p25.f$ghm3' - ;; - pg2gm2) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.pgrb2.0p25.f$ghm2 - $COMINgdas/gdas.t${cyc}z.pgrb2.0p25.f$ghm2 - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.pgrb2.0p25.f$ghm2 - $COMINgfs/gfs.t${cyc}z.pgrb2.0p25.f$ghm2' - ;; - pg2gm1) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.pgrb2.0p25.f$ghm1 - $COMINgdas/gdas.t${cyc}z.pgrb2.0p25.f$ghm1 - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.pgrb2.0p25.f$ghm1 - $COMINgfs/gfs.t${cyc}z.pgrb2.0p25.f$ghm1' - ;; - pg2gp1) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.pgrb2.0p25.f$ghp1 - $COMINgdas/gdas.t${cyc}z.pgrb2.0p25.f$ghp1 - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.pgrb2.0p25.f$ghp1 - $COMINgfs/gfs.t${cyc}z.pgrb2.0p25.f$ghp1' - ;; - pg2gp2) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.pgrb2.0p25.f$ghp2 - $COMINgdas/gdas.t${cyc}z.pgrb2.0p25.f$ghp2 - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.pgrb2.0p25.f$ghp2 - $COMINgfs/gfs.t${cyc}z.pgrb2.0p25.f$ghp2' - ;; - pg2gp3) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.pgrb2.0p25.f$ghp3 - $COMINgdas/gdas.t${cyc}z.pgrb2.0p25.f$ghp3 - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.pgrb2.0p25.f$ghp3 - $COMINgfs/gfs.t${cyc}z.pgrb2.0p25.f$ghp3' - ;; - pgbcur) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.pgrbh$fh - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.pgrbf$fh - $COMINgdas/gdas.t${cyc}z.pgrbh$fh - $COMINgdas/gdas.t${cyc}z.pgrbf$fh - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.pgrbf$fh - $COMINgfs/gfs.t${cyc}z.pgrbf$fh' - fhbeg=00 - ;; - pg2cur) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.pgrb2.0p50.f$gh - $COMINgdas/gdas.t${cyc}z.pgrb2.0p50.f$gh - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.pgrb2.0p50.f$gh - $COMINgfs/gfs.t${cyc}z.pgrb2.0p50.f$gh' - fhbeg=00 - ;; - prepqc) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.prepbufr - $COMINgdas/gdas.t${cyc}z.prepbufr - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.prepbufr - $COMINgfs/gfs.t${cyc}z.prepbufr' - fhbeg=00 - fhend=00 - ;; - tcvg12) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.syndata.tcvitals.tm00 - $COMINgdas/gdas.t${cyc}z.syndata.tcvitals.tm00 - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.syndata.tcvitals.tm00 - $COMINgfs/gfs.t${cyc}z.syndata.tcvitals.tm00' - fhbeg=12 - fhend=12 - ;; - tcvges) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.syndata.tcvitals.tm00 - $COMINgdas/gdas.t${cyc}z.syndata.tcvitals.tm00 - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.syndata.tcvitals.tm00 - $COMINgfs/gfs.t${cyc}z.syndata.tcvitals.tm00' - fhbeg=06 - fhend=06 - ;; - tcvitl) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.syndata.tcvitals.tm00 - $COMINgdas/gdas.t${cyc}z.syndata.tcvitals.tm00 - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.syndata.tcvitals.tm00 - $COMINgfs/gfs.t${cyc}z.syndata.tcvitals.tm00' - fhbeg=00 - fhend=00 - ;; - icegrb) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.engicegrb - $COMINgdas/gdas.t${cyc}z.engicegrb - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.engicegrb - $COMINgfs/gfs.t${cyc}z.engicegrb' - fhbeg=00 - fhinc=06 - ;; - snogrb) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.snogrb - $COMINgdas/gdas.t${cyc}z.snogrb - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.snogrb - $COMINgfs/gfs.t${cyc}z.snogrb' - fhbeg=00 - fhinc=06 - ;; - snogrb_574) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.snogrb_t574.1152.576 - $COMINgdas/gdas.t${cyc}z.snogrb_t574.1152.576 - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.snogrb_t574.1152.576 - $COMINgfs/gfs.t${cyc}z.snogrb_t574.1152.576' - fhbeg=00 - fhinc=06 - ;; - snogrb_1534) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.snogrb_t1534.3072.1536 - $COMINgdas/gdas.t${cyc}z.snogrb_t1534.3072.1536 - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.snogrb_t1534.3072.1536 - $COMINgfs/gfs.t${cyc}z.snogrb_t1534.3072.1536' - fhbeg=00 - fhinc=06 - ;; - sstgrb) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.sstgrb - $COMINgdas/gdas.t${cyc}z.sstgrb - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.sstgrb - $COMINgfs/gfs.t${cyc}z.sstgrb' - fhbeg=00 - fhinc=06 - ;; - natges) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.atmf$gh.nemsio - $COMINgdas/gdas.t${cyc}z.atmf$gh.nemsio - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.atmf$gh.nemsio - $COMINgfs/gfs.t${cyc}z.atmf$gh.nemsio' - ;; - natgm3) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.atm.f$ghm3.nemsio - $COMINgdas/gdas.t${cyc}z.atmf$ghm3.nemsio - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.atm.f$ghm3.nemsio - $COMINgfs/gfs.t${cyc}z.atmf$ghm3.nemsio' - ;; - natgm2) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.atmf$ghm2.nemsio - $COMINgdas/gdas.t${cyc}z.atmf$ghm2.nemsio - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.atmf$ghm2.nemsio - $COMINgfs/gfs.t${cyc}z.atmf$ghm2.nemsio' - ;; - natgm1) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.atmf$ghm1.nemsio - $COMINgdas/gdas.t${cyc}z.atmf$ghm1.nemsio - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.atmf$ghm1.nemsio - $COMINgfs/gfs.t${cyc}z.atmf$ghm1.nemsio' - ;; - natgp1) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.atmf$ghp1.nemsio - $COMINgdas/gdas.t${cyc}z.atmf$ghp1.nemsio - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.atmf$ghp1.nemsio - $COMINgfs/gfs.t${cyc}z.atmf$ghp1.nemsio' - ;; - natgp2) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.atmf$ghp2.nemsio - $COMINgdas/gdas.t${cyc}z.atmf$ghp2.nemsio - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.atmf$ghp2.nemsio - $COMINgfs/gfs.t${cyc}z.atmf$ghp2.nemsio' - ;; - natgp3) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.atmf$ghp3.nemsio - $COMINgdas/gdas.t${cyc}z.atmf$ghp3.nemsio - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.atmf$ghp3.nemsio - $COMINgfs/gfs.t${cyc}z.atmf$ghp3.nemsio' - ;; - natcur) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.atmf$gh.nemsio - $COMINgdas/gdas.t${cyc}z.atmf$gh.nemsio - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.atmf$gh.nemsio - $COMINgfs/gfs.t${cyc}z.atmf$gh.nemsio' - getlist00=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.atmanl.nemsio - $COMINgdas/gdas.t${cyc}z.atmanl.nemsio - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.atmanl.nemsio - $COMINgfs/gfs.t${cyc}z.atmanl.nemsio' - fhbeg=00 - ;; - nsfges) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.sfcf$gh.nemsio - $COMINgdas/gdas.t${cyc}z.sfcf$gh.nemsio - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.sfcf$gh.nemsio - $COMINgfs/gfs.t${cyc}z.sfcf$gh.nemsio' - ;; - nsfgm3) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.sfcf$ghm3.nemsio - $COMINgdas/gdas.t${cyc}z.sfcf$ghm3.nemsio - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.sfcf$ghm3.nemsio - $COMINgfs/gfs.t${cyc}z.sfcf$ghm3.nemsio' - ;; - nsfgm2) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.sfcf$ghm2.nemsio - $COMINgdas/gdas.t${cyc}z.sfcf$ghm2.nemsio - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.sfcf$ghm2.nemsio - $COMINgfs/gfs.t${cyc}z.sfcf$ghm2.nemsio' - ;; - nsfgm1) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.sfcf$ghm1.nemsio - $COMINgdas/gdas.t${cyc}z.sfcf$ghm1.nemsio - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.sfcf$ghm1.nemsio - $COMINgfs/gfs.t${cyc}z.sfcf$ghm1.nemsio' - ;; - nsfgp1) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.sfcf$ghp1.nemsio - $COMINgdas/gdas.t${cyc}z.sfcf$ghp1.nemsio - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.sfcf$ghp1.nemsio - $COMINgfs/gfs.t${cyc}z.sfcf$ghp1.nemsio' - ;; - nsfgp2) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.sfcf$ghp2.nemsio - $COMINgdas/gdas.t${cyc}z.sfcf$ghp2.nemsio - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.sfcf$ghp2.nemsio - $COMINgfs/gfs.t${cyc}z.sfcf$ghp2.nemsio' - ;; - nsfgp3) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.sfcf$ghp3.nemsio - $COMINgdas/gdas.t${cyc}z.sfcf$ghp3.nemsio - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.sfcf$ghp3.nemsio - $COMINgfs/gfs.t${cyc}z.sfcf$ghp3.nemsio' - ;; - nsfcur) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.sfcf$gh.nemsio - $COMINgdas/gdas.t${cyc}z.sfcf$gh.nemsio - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.sfcf$gh.nemsio - $COMINgfs/gfs.t${cyc}z.sfcf$gh.nemsio' - getlist00=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.sfcanl.nemsio - $COMINgdas/gdas.t${cyc}z.sfcanl.nemsio - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.sfcanl.nemsio - $COMINgfs/gfs.t${cyc}z.sfcanl.nemsio' - fhbeg=00 - ;; - nstcur) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.nstf$gh.nemsio - $COMINgdas/gdas.t${cyc}z.nstf$gh.nemsio - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.nstf$gh.nemsio - $COMINgfs/gfs.t${cyc}z.nstf$gh.nemsio' - getlist00=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.nstanl.nemsio - $COMINgdas/gdas.t${cyc}z.nstanl.nemsio - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.nstanl.nemsio - $COMINgfs/gfs.t${cyc}z.nstanl.nemsio' - fhbeg=00 - ;; - nflges) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.flxf$gh.nemsio - $COMINgdas/gdas.t${cyc}z.flxf$gh.nemsio - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.flxf$gh.nemsio - $COMINgfs/gfs.t${cyc}z.flxf$gh.nemsio' - ;; - nflgp3) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.flxf$ghp3.nemsio - $COMINgdas/gdas.t${cyc}z.flxf$ghp3.nemsio - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.flxf$ghp3.nemsio - $COMINgfs/gfs.t${cyc}z.flxf$ghp3.nemsio' - ;; - nflcur) geslist=' - $GETGES_NWG/$envir/gdas.$day/gdas.t${cyc}z.flxf$gh.nemsio - $COMINgdas/gdas.t${cyc}z.flxf$gh.nemsio - $GETGES_NWG/$envir/gfs.$day/gfs.t${cyc}z.flxf$gh.nemsio - $COMINgfs/gfs.t${cyc}z.flxf$gh.nemsio' - fhbeg=00 - ;; - esac +elif [[ "${netwk}" == "global" ]]; then + if [[ -z "${COMINgdas}" ]]; then + echo "getges.sh ERROR: The \${COMINgdas} variable must be defined." >&2 + exit 1 + fi + if [[ -z "${COMINgfs}" ]]; then + echo "getges.sh ERROR: The \${COMINgfs} variable must be defined." >&2 + exit 1 + fi + GETGES_NWG=${GETGES_NWG:-${GESROOT:?}} + # shellcheck disable=SC2016 + case "${typef}" in + biascr) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.abias + ${COMINgdas}/gdas.t${cyc}z.abias + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.abias + ${COMINgfs}/gfs.t${cyc}z.abias' + fhbeg=06 + fhinc=06 + ;; + pgbges) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.pgrbh${fh} + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.pgrbf${fh} + ${COMINgdas}/gdas.t${cyc}z.pgrbh${fh} + ${COMINgdas}/gdas.t${cyc}z.pgrbf${fh} + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.pgrbf${fh} + ${COMINgfs}/gfs.t${cyc}z.pgrbf${fh}' + ;; + pgbgm6) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.pgrbh${fhm6} + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.pgrbf${fhm6} + ${COMINgdas}/gdas.t${cyc}z.pgrbh${fhm6} + ${COMINgdas}/gdas.t${cyc}z.pgrbf${fhm6} + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.pgrbf${fhm6} + ${COMINgfs}/gfs.t${cyc}z.pgrbf${fhm6}' + ;; + pgbgm3) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.pgrbh${fhm3} + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.pgrbf${fhm3} + ${COMINgdas}/gdas.t${cyc}z.pgrbh${fhm3} + ${COMINgdas}/gdas.t${cyc}z.pgrbf${fhm3} + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.pgrbf${fhm3} + ${COMINgfs}/gfs.t${cyc}z.pgrbf${fhm3}' + ;; + pgbgp3) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.pgrbh${fhp3} + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.pgrbf${fhp3} + ${COMINgdas}/gdas.t${cyc}z.pgrbh${fhp3} + ${COMINgdas}/gdas.t${cyc}z.pgrbf${fhp3} + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.pgrbf${fhp3} + ${COMINgfs}/gfs.t${cyc}z.pgrbf${fhp3}' + ;; + pg2ges) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.pgrb2.0p25.f${gh} + ${COMINgdas}/gdas.t${cyc}z.pgrb2.0p25.f${gh} + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.pgrb2.0p25.f${gh} + ${COMINgfs}/gfs.t${cyc}z.pgrb2.0p25.f${gh}' + ;; + pg2gm6) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.pgrb2.0p25.f${ghm6} + ${COMINgdas}/gdas.t${cyc}z.pgrb2.0p25.f${ghm6} + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.pgrb2.0p25.f${ghm6} + ${COMINgfs}/gfs.t${cyc}z.pgrb2.0p25.f${ghm6}' + ;; + pg2gm5) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.pgrb2.0p25.f${ghm5} + ${COMINgdas}/gdas.t${cyc}z.pgrb2.0p25.f${ghm5} + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.pgrb2.0p25.f${ghm5} + ${COMINgfs}/gfs.t${cyc}z.pgrb2.0p25.f${ghm5}' + ;; + pg2gm4) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.pgrb2.0p25.f${ghm4} + ${COMINgdas}/gdas.t${cyc}z.pgrb2.0p25.f${ghm4} + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.pgrb2.0p25.f${ghm4} + ${COMINgfs}/gfs.t${cyc}z.pgrb2.0p25.f${ghm4}' + ;; + pg2gm3) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.pgrb2.0p25.f${ghm3} + ${COMINgdas}/gdas.t${cyc}z.pgrb2.0p25.f${ghm3} + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.pgrb2.0p25.f${ghm3} + ${COMINgfs}/gfs.t${cyc}z.pgrb2.0p25.f${ghm3}' + ;; + pg2gm2) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.pgrb2.0p25.f${ghm2} + ${COMINgdas}/gdas.t${cyc}z.pgrb2.0p25.f${ghm2} + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.pgrb2.0p25.f${ghm2} + ${COMINgfs}/gfs.t${cyc}z.pgrb2.0p25.f${ghm2}' + ;; + pg2gm1) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.pgrb2.0p25.f${ghm1} + ${COMINgdas}/gdas.t${cyc}z.pgrb2.0p25.f${ghm1} + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.pgrb2.0p25.f${ghm1} + ${COMINgfs}/gfs.t${cyc}z.pgrb2.0p25.f${ghm1}' + ;; + pg2gp1) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.pgrb2.0p25.f${ghp1} + ${COMINgdas}/gdas.t${cyc}z.pgrb2.0p25.f${ghp1} + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.pgrb2.0p25.f${ghp1} + ${COMINgfs}/gfs.t${cyc}z.pgrb2.0p25.f${ghp1}' + ;; + pg2gp2) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.pgrb2.0p25.f${ghp2} + ${COMINgdas}/gdas.t${cyc}z.pgrb2.0p25.f${ghp2} + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.pgrb2.0p25.f${ghp2} + ${COMINgfs}/gfs.t${cyc}z.pgrb2.0p25.f${ghp2}' + ;; + pg2gp3) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.pgrb2.0p25.f${ghp3} + ${COMINgdas}/gdas.t${cyc}z.pgrb2.0p25.f${ghp3} + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.pgrb2.0p25.f${ghp3} + ${COMINgfs}/gfs.t${cyc}z.pgrb2.0p25.f${ghp3}' + ;; + pgbcur) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.pgrbh${fh} + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.pgrbf${fh} + ${COMINgdas}/gdas.t${cyc}z.pgrbh${fh} + ${COMINgdas}/gdas.t${cyc}z.pgrbf${fh} + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.pgrbf${fh} + ${COMINgfs}/gfs.t${cyc}z.pgrbf${fh}' + fhbeg=00 + ;; + pg2cur) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.pgrb2.0p50.f${gh} + ${COMINgdas}/gdas.t${cyc}z.pgrb2.0p50.f${gh} + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.pgrb2.0p50.f${gh} + ${COMINgfs}/gfs.t${cyc}z.pgrb2.0p50.f${gh}' + fhbeg=00 + ;; + prepqc) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.prepbufr + ${COMINgdas}/gdas.t${cyc}z.prepbufr + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.prepbufr + ${COMINgfs}/gfs.t${cyc}z.prepbufr' + fhbeg=00 + fhend=00 + ;; + tcvg12) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.syndata.tcvitals.tm00 + ${COMINgdas}/gdas.t${cyc}z.syndata.tcvitals.tm00 + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.syndata.tcvitals.tm00 + ${COMINgfs}/gfs.t${cyc}z.syndata.tcvitals.tm00' + fhbeg=12 + fhend=12 + ;; + tcvges) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.syndata.tcvitals.tm00 + ${COMINgdas}/gdas.t${cyc}z.syndata.tcvitals.tm00 + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.syndata.tcvitals.tm00 + ${COMINgfs}/gfs.t${cyc}z.syndata.tcvitals.tm00' + fhbeg=06 + fhend=06 + ;; + tcvitl) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.syndata.tcvitals.tm00 + ${COMINgdas}/gdas.t${cyc}z.syndata.tcvitals.tm00 + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.syndata.tcvitals.tm00 + ${COMINgfs}/gfs.t${cyc}z.syndata.tcvitals.tm00' + fhbeg=00 + fhend=00 + ;; + icegrb) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.engicegrb + ${COMINgdas}/gdas.t${cyc}z.engicegrb + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.engicegrb + ${COMINgfs}/gfs.t${cyc}z.engicegrb' + fhbeg=00 + fhinc=06 + ;; + snogrb) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.snogrb + ${COMINgdas}/gdas.t${cyc}z.snogrb + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.snogrb + ${COMINgfs}/gfs.t${cyc}z.snogrb' + fhbeg=00 + fhinc=06 + ;; + snogrb_574) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.snogrb_t574.1152.576 + ${COMINgdas}/gdas.t${cyc}z.snogrb_t574.1152.576 + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.snogrb_t574.1152.576 + ${COMINgfs}/gfs.t${cyc}z.snogrb_t574.1152.576' + fhbeg=00 + fhinc=06 + ;; + snogrb_1534) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.snogrb_t1534.3072.1536 + ${COMINgdas}/gdas.t${cyc}z.snogrb_t1534.3072.1536 + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.snogrb_t1534.3072.1536 + ${COMINgfs}/gfs.t${cyc}z.snogrb_t1534.3072.1536' + fhbeg=00 + fhinc=06 + ;; + sstgrb) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.sstgrb + ${COMINgdas}/gdas.t${cyc}z.sstgrb + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.sstgrb + ${COMINgfs}/gfs.t${cyc}z.sstgrb' + fhbeg=00 + fhinc=06 + ;; + natges) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.atmf${gh}.nemsio + ${COMINgdas}/gdas.t${cyc}z.atmf${gh}.nemsio + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.atmf${gh}.nemsio + ${COMINgfs}/gfs.t${cyc}z.atmf${gh}.nemsio' + ;; + natgm3) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.atm.f${ghm3}.nemsio + ${COMINgdas}/gdas.t${cyc}z.atmf${ghm3}.nemsio + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.atm.f${ghm3}.nemsio + ${COMINgfs}/gfs.t${cyc}z.atmf${ghm3}.nemsio' + ;; + natgm2) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.atmf${ghm2}.nemsio + ${COMINgdas}/gdas.t${cyc}z.atmf${ghm2}.nemsio + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.atmf${ghm2}.nemsio + ${COMINgfs}/gfs.t${cyc}z.atmf${ghm2}.nemsio' + ;; + natgm1) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.atmf${ghm1}.nemsio + ${COMINgdas}/gdas.t${cyc}z.atmf${ghm1}.nemsio + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.atmf${ghm1}.nemsio + ${COMINgfs}/gfs.t${cyc}z.atmf${ghm1}.nemsio' + ;; + natgp1) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.atmf${ghp1}.nemsio + ${COMINgdas}/gdas.t${cyc}z.atmf${ghp1}.nemsio + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.atmf${ghp1}.nemsio + ${COMINgfs}/gfs.t${cyc}z.atmf${ghp1}.nemsio' + ;; + natgp2) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.atmf${ghp2}.nemsio + ${COMINgdas}/gdas.t${cyc}z.atmf${ghp2}.nemsio + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.atmf${ghp2}.nemsio + ${COMINgfs}/gfs.t${cyc}z.atmf${ghp2}.nemsio' + ;; + natgp3) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.atmf${ghp3}.nemsio + ${COMINgdas}/gdas.t${cyc}z.atmf${ghp3}.nemsio + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.atmf${ghp3}.nemsio + ${COMINgfs}/gfs.t${cyc}z.atmf${ghp3}.nemsio' + ;; + natcur) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.atmf${gh}.nemsio + ${COMINgdas}/gdas.t${cyc}z.atmf${gh}.nemsio + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.atmf${gh}.nemsio + ${COMINgfs}/gfs.t${cyc}z.atmf${gh}.nemsio' + getlist00=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.atmanl.nemsio + ${COMINgdas}/gdas.t${cyc}z.atmanl.nemsio + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.atmanl.nemsio + ${COMINgfs}/gfs.t${cyc}z.atmanl.nemsio' + fhbeg=00 + ;; + nsfges) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.sfcf${gh}.nemsio + ${COMINgdas}/gdas.t${cyc}z.sfcf${gh}.nemsio + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.sfcf${gh}.nemsio + ${COMINgfs}/gfs.t${cyc}z.sfcf${gh}.nemsio' + ;; + nsfgm3) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.sfcf${ghm3}.nemsio + ${COMINgdas}/gdas.t${cyc}z.sfcf${ghm3}.nemsio + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.sfcf${ghm3}.nemsio + ${COMINgfs}/gfs.t${cyc}z.sfcf${ghm3}.nemsio' + ;; + nsfgm2) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.sfcf${ghm2}.nemsio + ${COMINgdas}/gdas.t${cyc}z.sfcf${ghm2}.nemsio + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.sfcf${ghm2}.nemsio + ${COMINgfs}/gfs.t${cyc}z.sfcf${ghm2}.nemsio' + ;; + nsfgm1) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.sfcf${ghm1}.nemsio + ${COMINgdas}/gdas.t${cyc}z.sfcf${ghm1}.nemsio + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.sfcf${ghm1}.nemsio + ${COMINgfs}/gfs.t${cyc}z.sfcf${ghm1}.nemsio' + ;; + nsfgp1) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.sfcf${ghp1}.nemsio + ${COMINgdas}/gdas.t${cyc}z.sfcf${ghp1}.nemsio + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.sfcf${ghp1}.nemsio + ${COMINgfs}/gfs.t${cyc}z.sfcf${ghp1}.nemsio' + ;; + nsfgp2) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.sfcf${ghp2}.nemsio + ${COMINgdas}/gdas.t${cyc}z.sfcf${ghp2}.nemsio + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.sfcf${ghp2}.nemsio + ${COMINgfs}/gfs.t${cyc}z.sfcf${ghp2}.nemsio' + ;; + nsfgp3) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.sfcf${ghp3}.nemsio + ${COMINgdas}/gdas.t${cyc}z.sfcf${ghp3}.nemsio + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.sfcf${ghp3}.nemsio + ${COMINgfs}/gfs.t${cyc}z.sfcf${ghp3}.nemsio' + ;; + nsfcur) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.sfcf${gh}.nemsio + ${COMINgdas}/gdas.t${cyc}z.sfcf${gh}.nemsio + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.sfcf${gh}.nemsio + ${COMINgfs}/gfs.t${cyc}z.sfcf${gh}.nemsio' + getlist00=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.sfcanl.nemsio + ${COMINgdas}/gdas.t${cyc}z.sfcanl.nemsio + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.sfcanl.nemsio + ${COMINgfs}/gfs.t${cyc}z.sfcanl.nemsio' + fhbeg=00 + ;; + nstcur) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.nstf${gh}.nemsio + ${COMINgdas}/gdas.t${cyc}z.nstf${gh}.nemsio + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.nstf${gh}.nemsio + ${COMINgfs}/gfs.t${cyc}z.nstf${gh}.nemsio' + # shellcheck disable=SC2034 + getlist00=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.nstanl.nemsio + ${COMINgdas}/gdas.t${cyc}z.nstanl.nemsio + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.nstanl.nemsio + ${COMINgfs}/gfs.t${cyc}z.nstanl.nemsio' + fhbeg=00 + ;; + nflges) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.flxf${gh}.nemsio + ${COMINgdas}/gdas.t${cyc}z.flxf${gh}.nemsio + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.flxf${gh}.nemsio + ${COMINgfs}/gfs.t${cyc}z.flxf${gh}.nemsio' + ;; + nflgp3) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.flxf${ghp3}.nemsio + ${COMINgdas}/gdas.t${cyc}z.flxf${ghp3}.nemsio + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.flxf${ghp3}.nemsio + ${COMINgfs}/gfs.t${cyc}z.flxf${ghp3}.nemsio' + ;; + nflcur) + geslist=' + ${GETGES_NWG}/${envir}/gdas.${day}/gdas.t${cyc}z.flxf${gh}.nemsio + ${COMINgdas}/gdas.t${cyc}z.flxf${gh}.nemsio + ${GETGES_NWG}/${envir}/gfs.${day}/gfs.t${cyc}z.flxf${gh}.nemsio + ${COMINgfs}/gfs.t${cyc}z.flxf${gh}.nemsio' + fhbeg=00 + ;; + *) + msg="FATAL ERROR: Unknown ${netwk} guess type ${typef}" + export err=101 + err_exit "${msg}" + ;; + esac fi # Check validity of options. -if [[ $fhour != any ]];then - fhbeg=$fhour - fhend=$fhour +if [[ "${fhour}" != any ]]; then + fhbeg="${fhour}" + fhend="${fhour}" fi -if [[ $valid -lt 20000000 ]];then - valid=20$valid - echo '************************************************************' >&2 - echo '* WARNING: A 2-digit year was converted to a 4-digit year. *' >&2 - echo '* Please use full a 4-digit year in this utility. *' >&2 - echo '************************************************************' >&2 +if [[ "${valid}" -lt 20000000 ]]; then + valid="20${valid}" + echo '************************************************************' >&2 + echo '* WARNING: A 2-digit year was converted to a 4-digit year. *' >&2 + echo '* Please use full a 4-digit year in this utility. *' >&2 + echo '************************************************************' >&2 fi -if [[ -z "$geslist" ]];then - echo getges.sh: filetype $typef or resolution $resol not recognized >&2 - exit 2 +if [[ -z "${geslist}" ]]; then + echo "getges.sh: filetype ${typef} or resolution ${resol} not recognized" >&2 + exit 2 fi #------------------------------------------------------------------------------- # Loop until guess is found. -fh=$fhbeg -if [ -z "$PDY" ];then echo "getges.sh WARNING: \$PDY variable not set" >&2; fi -while [[ $fh -le $fhend ]];do - ((fhm6=10#${fh}-6)) - if [[ ${fhm6} -lt 10 && ${fhm6} -ge 0 ]]; then - fhm6=0${fhm6} - fi - ((fhm5=10#${fh}-5)) - if [[ ${fhm5} -lt 10 && ${fhm5} -ge 0 ]]; then - fhm5=0${fhm5} - fi - ((fhm4=10#${fh}-4)) - if [[ ${fhm4} -lt 10 && ${fhm4} -ge 0 ]]; then - fhm4=0${fhm4} - fi - ((fhm3=10#${fh}-3)) - if [[ ${fhm3} -lt 10 && ${fhm3} -ge 0 ]]; then - fhm3=0${fhm3} - fi - ((fhm2=10#${fh}-2)) - if [[ ${fhm2} -lt 10 && ${fhm2} -ge 0 ]]; then - fhm2=0${fhm2} - fi - ((fhm1=10#${fh}-1)) - if [[ ${fhm1} -lt 10 && ${fhm1} -ge 0 ]]; then - fhm1=0${fhm1} - fi - ((fhp1=10#${fh}+1)) - if [[ ${fhp1} -lt 10 ]]; then - fhp1=0${fhp1} - fi - ((fhp2=10#${fh}+2)) - if [[ ${fhp2} -lt 10 ]]; then - fhp2=0${fhp2} - fi - ((fhp3=10#${fh}+3)) - if [[ ${fhp3} -lt 10 ]]; then - fhp3=0${fhp3} - fi - gh=$fh;[[ $gh -lt 100 ]]&&gh=0$gh - ghm6=$fhm6;[[ $ghm6 -lt 100 ]]&&ghm6=0$ghm6 - ghm5=$fhm5;[[ $ghm5 -lt 100 ]]&&ghm5=0$ghm5 - ghm4=$fhm4;[[ $ghm4 -lt 100 ]]&&ghm4=0$ghm4 - ghm3=$fhm3;[[ $ghm3 -lt 100 ]]&&ghm3=0$ghm3 - ghm2=$fhm2;[[ $ghm2 -lt 100 ]]&&ghm2=0$ghm2 - ghm1=$fhm1;[[ $ghm1 -lt 100 ]]&&ghm1=0$ghm1 - ghp1=$fhp1;[[ $ghp1 -lt 100 ]]&&ghp1=0$ghp1 - ghp2=$fhp2;[[ $ghp2 -lt 100 ]]&&ghp2=0$ghp2 - ghp3=$fhp3;[[ $ghp3 -lt 100 ]]&&ghp3=0$ghp3 - id=$(date --utc +%Y%m%d%H -d "${valid:0:8} ${valid:8:2} - ${fh} hours") +fh=${fhbeg} +if [[ -z "${PDY}" ]]; then echo "getges.sh WARNING: \${PDY} variable not set" >&2; fi +while [[ "${fh}" -le "${fhend}" ]]; do + ((fhm6 = 10#${fh} - 6)) + if [[ ${fhm6} -lt 10 && ${fhm6} -ge 0 ]]; then + fhm6=0${fhm6} + fi + ((fhm5 = 10#${fh} - 5)) + if [[ ${fhm5} -lt 10 && ${fhm5} -ge 0 ]]; then + fhm5=0${fhm5} + fi + ((fhm4 = 10#${fh} - 4)) + if [[ ${fhm4} -lt 10 && ${fhm4} -ge 0 ]]; then + fhm4=0${fhm4} + fi + ((fhm3 = 10#${fh} - 3)) + if [[ ${fhm3} -lt 10 && ${fhm3} -ge 0 ]]; then + fhm3=0${fhm3} + fi + ((fhm2 = 10#${fh} - 2)) + if [[ ${fhm2} -lt 10 && ${fhm2} -ge 0 ]]; then + fhm2=0${fhm2} + fi + ((fhm1 = 10#${fh} - 1)) + if [[ ${fhm1} -lt 10 && ${fhm1} -ge 0 ]]; then + fhm1=0${fhm1} + fi + ((fhp1 = 10#${fh} + 1)) + if [[ ${fhp1} -lt 10 ]]; then + fhp1=0${fhp1} + fi + ((fhp2 = 10#${fh} + 2)) + if [[ ${fhp2} -lt 10 ]]; then + fhp2=0${fhp2} + fi + ((fhp3 = 10#${fh} + 3)) + if [[ ${fhp3} -lt 10 ]]; then + fhp3=0${fhp3} + fi + gh="${fh}" + [[ "${gh}" -lt 100 ]] && gh="0${gh}" + ghm6="${fhm6}" + [[ "${ghm6}" -lt 100 ]] && ghm6="0${ghm6}" + ghm5="${fhm5}" + [[ "${ghm5}" -lt 100 ]] && ghm5="0${ghm5}" + ghm4="${fhm4}" + [[ "${ghm4}" -lt 100 ]] && ghm4="0${ghm4}" + ghm3="${fhm3}" + [[ "${ghm3}" -lt 100 ]] && ghm3="0${ghm3}" + ghm2="${fhm2}" + [[ "${ghm2}" -lt 100 ]] && ghm2="0${ghm2}" + ghm1="${fhm1}" + [[ "${ghm1}" -lt 100 ]] && ghm1="0${ghm1}" + ghp1="${fhp1}" + [[ "${ghp1}" -lt 100 ]] && ghp1="0${ghp1}" + ghp2="${fhp2}" + [[ "${ghp2}" -lt 100 ]] && ghp2="0${ghp2}" + ghp3="${fhp3}" + [[ "${ghp3}" -lt 100 ]] && ghp3="0${ghp3}" + id=$(date --utc +%Y%m%d%H -d "${valid:0:8} ${valid:8:2} - ${fh} hours") - day=$(echo $id | xargs | cut -c8) - cyc=$(echo $id | xargs | rev | cut -c1-2 | rev) - eval list=\$getlist$fh - if [[ -z "${list}" ]]; then - list=${geslist} - fi - for ges_var in $list;do - # Replace variables in guess with their values - eval ges_val=$ges_var - # Replace the current PDY with the valid date - ges=${ges_val/$PDY\//$day/} - if [[ "${quiet}" == "NO" ]]; then - echo Checking: "${ges}" >&2 - fi - if [[ -r "${ges}" ]]; then - break 2 - fi - done - fh=$((10#${fh}+10#${fhinc})) - if [[ ${fh} -lt 10 ]]; then - fh=0${fh} - fi + day="${id:0:8}" + cyc="${id:8:2}" + list_name="getlist${fh}" + list="${!list_name}" + if [[ -z "${list}" ]]; then + list=${geslist} + fi + for ges_var in ${list}; do + # Replace variables in guess with their values + eval ges_val="${ges_var}" + # Replace the current PDY with the valid date + ges=${ges_val/${PDY}\//${day}/} + if [[ "${quiet}" == "NO" ]]; then + echo Checking: "${ges}" >&2 + fi + if [[ -r "${ges}" ]]; then + break 2 + fi + done + fh=$((10#${fh} + 10#${fhinc})) + if [[ ${fh} -lt 10 ]]; then + fh=0${fh} + fi done -if [[ $fh -gt $fhend ]];then - echo getges.sh: unable to find $netwk.$envir.$typef.$resol.$valid >&2 - exit 8 +if [[ "${fh}" -gt "${fhend}" ]]; then + echo "getges.sh: unable to find ${netwk}.${envir}.${typef}.${resol}.${valid}" >&2 + exit 8 fi +err= #------------------------------------------------------------------------------- # Either copy guess to a file or write guess name to standard output. -if [[ -z "$gfile" ]];then - echo ${ges} - err=$? +if [[ -z "${gfile}" ]]; then + echo "${ges}" + err=0 else - cpfs ${ges} ${gfile} - err=$? + cpfs "${ges}" "${gfile}" + err=$? fi -exit ${err} +exit "${err}" diff --git a/ush/getioda.sh b/ush/getioda.sh index 417f6e4c4d1..f2db4d0a434 100755 --- a/ush/getioda.sh +++ b/ush/getioda.sh @@ -10,20 +10,20 @@ DUMP_SUFFIX=${DUMP_SUFFIX:-""} # Exit if SOURCE_DIR does not exist if [[ ! -s "${SOURCE_DIR}" ]]; then - echo "FATAL ERROR: DUMP SOURCE_DIR=${SOURCE_DIR} does not exist" - exit 99 + echo "FATAL ERROR: DUMP SOURCE_DIR=${SOURCE_DIR} does not exist" + exit 99 fi - + # Create TARGET_DIR if is does not exist if [[ ! -s "${TARGET_DIR}" ]]; then - mkdir -p "${TARGET_DIR}" + mkdir -p "${TARGET_DIR}" fi # Set file prefix prefix="${RUN}.t${HH}z." # loop through top level component directories (e.g. atmos, ocean, land, ice) -for compdir in "${SOURCE_DIR}"/*/ ; do +for compdir in "${SOURCE_DIR}"/*/; do compdir=${compdir%*/} compdir=${compdir##*/} # Skip if not a directory @@ -42,7 +42,7 @@ for compdir in "${SOURCE_DIR}"/*/ ; do set -f # Create component directory in TARGET_DIR if it does not exist if [[ ! -s "${TARGET_DIR}/${compdir}" ]]; then - mkdir -p "${TARGET_DIR}/${compdir}" + mkdir -p "${TARGET_DIR}/${compdir}" fi # Link files from SOURCE_DIR to TARGET_DIR if [[ ! -d "${SOURCE_DIR}/${compdir}" ]]; then @@ -54,11 +54,11 @@ for compdir in "${SOURCE_DIR}"/*/ ; do set +f shopt -s nullglob for source_file in "${SOURCE_DIR}/${compdir}/${prefix}"*; do - if [[ ! -e "${source_file}" ]]; then - continue - fi - targ_file=$(basename "${source_file}") - cpreq "${source_file}" "${TARGET_DIR}/${compdir}/${targ_file}" + if [[ ! -e "${source_file}" ]]; then + continue + fi + targ_file=$(basename "${source_file}") + cpreq "${source_file}" "${TARGET_DIR}/${compdir}/${targ_file}" done shopt -u nullglob set -f diff --git a/ush/gfs_bfr2gpk.sh b/ush/gfs_bfr2gpk.sh index 1e0ea9224aa..4123fe2408d 100755 --- a/ush/gfs_bfr2gpk.sh +++ b/ush/gfs_bfr2gpk.sh @@ -9,7 +9,7 @@ # # # Log: # # K. Brill/HPC 04/12/05 # -######################################################################### +######################################################################### # Set GEMPAK paths. @@ -55,7 +55,7 @@ cpfs "${snd}" "${COMOUT_ATMOS_GEMPAK}/${snd_out}" cpfs "${sfc}" "${COMOUT_ATMOS_GEMPAK}/${sfc_out}" if [[ ${SENDDBN} == "YES" ]]; then - "${DBNROOT}/bin/dbn_alert" MODEL GFS_PTYP_SFC "${job}" "${COMOUT_ATMOS_GEMPAK}/${sfc_out}" - "${DBNROOT}/bin/dbn_alert" MODEL GFS_PTYP_SND "${job}" "${COMOUT_ATMOS_GEMPAK}/${snd_out}" + "${DBNROOT}/bin/dbn_alert" MODEL GFS_PTYP_SFC "${job}" "${COMOUT_ATMOS_GEMPAK}/${sfc_out}" + "${DBNROOT}/bin/dbn_alert" MODEL GFS_PTYP_SND "${job}" "${COMOUT_ATMOS_GEMPAK}/${snd_out}" fi echo "done" > "${DATA}/gembufr.done" diff --git a/ush/gfs_bufr.sh b/ush/gfs_bufr.sh index 63f94493b54..e1b880b9ea3 100755 --- a/ush/gfs_bufr.sh +++ b/ush/gfs_bufr.sh @@ -31,33 +31,33 @@ workdir="${5}" cd "${workdir}" || exit 2 if [[ "${F00FLAG}" == "YES" ]]; then - f00flag=".true." + f00flag=".true." else - f00flag=".false." + f00flag=".false." fi export pgm="gfs_bufr.x" #. prep_step if [[ "${MAKEBUFR}" == "YES" ]]; then - bufrflag=".true." + bufrflag=".true." else - bufrflag=".false." + bufrflag=".false." fi # check if read in bufr_ij_gfs_${CASE}.txt export CASE=${CASE_HIST:-${CASE}} -if [[ -s "${PARMgfs}/product/bufr_ij_gfs_${CASE}.txt" ]]; then - # use predetermined grid point(i,j) in bufr_gfs_${CASE}.txt - ${NLN} "${PARMgfs}/product/bufr_ij_gfs_${CASE}.txt" fort.7 - np1=0 +if [[ -s "${PARMgfs}/product/bufr_ij_gfs_${CASE}.txt" ]]; then + # use predetermined grid point(i,j) in bufr_gfs_${CASE}.txt + ${NLN} "${PARMgfs}/product/bufr_ij_gfs_${CASE}.txt" fort.7 + np1=0 else - # find the nearest neighbor grid point(i,j) in the code - np1=1 - echo "No bufr_ij_gfs_${CASE}.txt For CASE ${CASE}" - echo "Find the nearest neighbor grid (i,j) in the code" + # find the nearest neighbor grid point(i,j) in the code + np1=1 + echo "No bufr_ij_gfs_${CASE}.txt For CASE ${CASE}" + echo "Find the nearest neighbor grid (i,j) in the code" fi ##fformat="netcdf" @@ -81,14 +81,14 @@ EOF filename="${COMIN_ATMOS_HISTORY}/${RUN}.${cycle}.log.f${fhr}.${logfm}" if [[ -z ${filename} ]]; then - echo "FATAL ERROR: COULD NOT LOCATE logf${fhr} file" - exit 2 + echo "FATAL ERROR: COULD NOT LOCATE logf${fhr} file" + exit 2 fi filename="${COMIN_ATMOS_HISTORY}/${RUN}.${cycle}.log.f${fhr_p}.${logfm}" if [[ -z ${filename} ]]; then - echo "FATAL ERROR: COULD NOT LOCATE logf${fhr_p} file" - exit 2 + echo "FATAL ERROR: COULD NOT LOCATE logf${fhr_p} file" + exit 2 fi #------------------------------------------------------------------ @@ -100,17 +100,16 @@ ${NLN} "${COMIN_ATMOS_HISTORY}/${RUN}.${cycle}.sfc.f${fhr_p}.${atmfm}" "flxf${fh ${NLN} "${PARMgfs}/product/bufr_gfs_${CLASS}.tbl" fort.1 ${NLN} "${STNLIST:-${PARMgfs}/product/bufr_stalist.meteo.gfs}" fort.8 - #------------------------------------------------------------------ "${EXECgfs}/${pgm}" < gfsparm > "out_gfs_bufr_${fhr}" export err=$? if [[ ${err} -ne 0 ]]; then - echo "WARNING GFS postsnd job error, Please check files " - echo "${COMIN_ATMOS_HISTORY}/${RUN}.${cycle}.atm.f${fhr}.${atmfm}" - echo "${COMIN_ATMOS_HISTORY}/${RUN}.${cycle}.sfc.f${fhr}.${atmfm}" - exit "${err}" + echo "FATAL ERROR: GFS postsnd job error, Please check files " + echo "${COMIN_ATMOS_HISTORY}/${RUN}.${cycle}.atm.f${fhr}.${atmfm}" + echo "${COMIN_ATMOS_HISTORY}/${RUN}.${cycle}.sfc.f${fhr}.${atmfm}" + err_exit fi exit 0 diff --git a/ush/gfs_bufr_netcdf.sh b/ush/gfs_bufr_netcdf.sh deleted file mode 100755 index 9b905acbaa6..00000000000 --- a/ush/gfs_bufr_netcdf.sh +++ /dev/null @@ -1,103 +0,0 @@ -#! /usr/bin/env bash - -# -# UTILITY SCRIPT NAME : gfsbufr.sh -# AUTHOR : Hua-Lu Pan -# DATE WRITTEN : 02/03/97 -# -# Abstract: This utility script produces BUFR file of -# station forecasts from the GFS suite. -# -# Input: none -# Script History Log: -# 2016-10-30 H Chuang: Tranistion to read nems output. -# Change to read flux file fields in gfs_bufr -# so remove excution of gfs_flux -# 2018-03-22 Guang Ping Lou: Making it works for either 1 hourly or 3 hourly output -# 2018-05-22 Guang Ping Lou: Making it work for both GFS and FV3GFS -# 2018-05-30 Guang Ping Lou: Make sure all files are available. -# 2019-10-10 Guang Ping Lou: Read in NetCDF files -# echo "History: February 2003 - First implementation of this utility script" -# - -if test "$F00FLAG" = "YES" -then - f00flag=".true." -else - f00flag=".false." -fi - -hh=$FSTART -while test $hh -le $FEND -do - hh=$( expr $hh + $FINT ) - if test $hh -lt 10 - then - hh=0$hh - fi -done - -export pgm="gfs_bufr.x" -#. prep_step - -if test "$MAKEBUFR" = "YES" -then - bufrflag=".true." -else - bufrflag=".false." -fi - -CLASS="class1fv3" -cat << EOF > gfsparm - &NAMMET - levs=$LEVS,makebufr=$bufrflag, - dird="$COMOUT/bufr.${cycle}/bufr", - nstart=$FSTART,nend=$FEND,nint=$FINT, - nend1=$NEND1,nint1=$NINT1,nint3=$NINT3, - nsfc=80,f00=$f00flag, -/ -EOF - -hh=$FSTART - if test $hh -lt 100 - then - hh1=$(echo "${hh#"${hh%??}"}") - hh=$hh1 - fi - -sleep_interval=10 -max_tries=360 -while test $hh -le $FEND -do - if test $hh -lt 100 - then - hh2=0$hh - else - hh2=$hh - fi - - filename="${COMIN}/${RUN}.${cycle}.logf${hh2}.txt" - if ! wait_for_file "${filename}" "${sleep_interval}" "${max_tries}" ; then - err_exit "FATAL ERROR COULD NOT LOCATE logf${hh2} file" - fi - -#------------------------------------------------------------------ - ${NLN} $COMIN/${RUN}.${cycle}.atm.f${hh2}.nc sigf${hh} - ${NLN} $COMIN/${RUN}.${cycle}.sfc.f${hh2}.nc flxf${hh} - - hh=$( expr $hh + $FINT ) - if test $hh -lt 10 - then - hh=0$hh - fi -done - -# define input BUFR table file. -${NLN} ${PARMgfs}/product/bufr_gfs_${CLASS}.tbl fort.1 -${NLN} ${STNLIST:-${PARMgfs}/product/bufr_stalist.meteo.gfs} fort.8 -${NLN} ${PARMgfs}/product/bufr_ij13km.txt fort.7 - -${APRUN_POSTSND} "${EXECgfs}/${pgm}" < gfsparm > "out_gfs_bufr_${FEND}" -export err=$? - -exit ${err} diff --git a/ush/gfs_sndp.sh b/ush/gfs_sndp.sh index af09e175dd7..5ebd81c121c 100755 --- a/ush/gfs_sndp.sh +++ b/ush/gfs_sndp.sh @@ -7,55 +7,52 @@ # 1) 2004-09-10 Steve Gilbert First Implementation ################################################################ - # Create "collectives" consisting of groupings of the soundings - # into files designated by geographical region. Each input - # file gfs_collective*.list (1-9) contains the list of stations to - # put in a particular collective output file. +# Create "collectives" consisting of groupings of the soundings +# into files designated by geographical region. Each input +# file gfs_collective*.list (1-9) contains the list of stations to +# put in a particular collective output file. export m=$1 -mkdir $DATA/$m -cd $DATA/$m - cpreq ${FIXgfs}/product/gfs_collective${m}.list $DATA/$m/. - CCCC=KWBC - file_list=gfs_collective${m}.list +mkdir -p "${DATA}/${m}" +cd "${DATA}/${m}" || exit 2 +cpreq "${FIXgfs}/product/gfs_collective${m}.list" "${DATA}/${m}/" +CCCC=KWBC +file_list=gfs_collective${m}.list - if [ $m -le 2 ] - then - WMOHEAD=JUSA4$m - elif [ $m -le 6 ] - then - WMOHEAD=JUSB4$m - else - WMOHEAD=JUSX4$m - fi +if [[ ${m} -le 2 ]]; then + WMOHEAD="JUSA4${m}" +elif [[ ${m} -le 6 ]]; then + WMOHEAD="JUSB4${m}" +else + WMOHEAD="JUSX4${m}" +fi - for stn in $(cat $file_list) - do - cpreq "${COMIN_ATMOS_BUFR}/bufr.${stn}.${PDY}${cyc}" "${DATA}/${m}/bufrin" - export pgm=tocsbufr.x - #. prep_step - export FORT11=$DATA/${m}/bufrin - export FORT51=./bufrout - ${EXECgfs}/${pgm} << EOF +while IFS= read -r stn; do + cpreq "${COMIN_ATMOS_BUFR}/bufr.${stn}.${PDY}${cyc}" "${DATA}/${m}/bufrin" + export pgm=tocsbufr.x + #. prep_step + export FORT11="${DATA}/${m}/bufrin" + export FORT51=./bufrout + "${EXECgfs}/${pgm}" << EOF &INPUT - BULHED="$WMOHEAD",KWBX="$CCCC", + BULHED="${WMOHEAD}",KWBX="${CCCC}", NCEP2STD=.TRUE., SEPARATE=.TRUE., MAXFILESIZE=600000 / EOF - export err=$?; - if [[ ${err} -ne 0 ]]; then - echo "FATAL ERROR Failed during execution of ${pgm}" - exit "${err}" - fi + export err=$? + if [[ ${err} -ne 0 ]]; then + echo "FATAL ERROR Failed during execution of ${pgm}" + exit "${err}" + fi - cat "${DATA}/${m}/bufrout" >> "${DATA}/${m}/gfs_collective${m}.fil" - rm -f "${DATA}/${m}/bufrin" "${DATA}/${m}/bufrout" - done + cat "${DATA}/${m}/bufrout" >> "${DATA}/${m}/gfs_collective${m}.fil" + rm -f "${DATA}/${m}/bufrin" "${DATA}/${m}/bufrout" +done < "${file_list}" - if [[ ${SENDDBN} == 'YES' ]] ; then - cpfs "${DATA}/${m}/gfs_collective${m}.fil" "${COMOUT_ATMOS_WMO}/gfs_collective${m}.postsnd_${cyc}" - "${DBNROOT}/bin/dbn_alert" NTC_LOW BUFR "${job}" \ - "${COMOUT_ATMOS_WMO}/gfs_collective${m}.postsnd_${cyc}" - fi - cpfs "${DATA}/${m}/gfs_collective${m}.fil" "${COMOUT_ATMOS_BUFR}/." +if [[ "${SENDDBN}" == 'YES' ]]; then + cpfs "${DATA}/${m}/gfs_collective${m}.fil" "${COMOUT_ATMOS_WMO}/gfs_collective${m}.postsnd_${cyc}" + "${DBNROOT}/bin/dbn_alert" NTC_LOW BUFR "${job}" \ + "${COMOUT_ATMOS_WMO}/gfs_collective${m}.postsnd_${cyc}" +fi +cpfs "${DATA}/${m}/gfs_collective${m}.fil" "${COMOUT_ATMOS_BUFR}/." diff --git a/ush/gfs_truncate_enkf.sh b/ush/gfs_truncate_enkf.sh deleted file mode 100755 index 7225b4e5925..00000000000 --- a/ush/gfs_truncate_enkf.sh +++ /dev/null @@ -1,52 +0,0 @@ -#! /usr/bin/env bash - -member=$1 -export SIGINP=$2 -export SIGOUT=$3 -export JCAP=$4 -export LATB=$5 -export LONB=$6 - -DATATMP=$DATA/$member -mkdir -p $DATATMP -cd $DATATMP - -export LEVS=${LEVS_LORES:-64} - -export CHGRESSH=${CHGRESSH:-${USHgfs}/global_chgres.sh} -export CHGRESEXEC=${CHGRESEXEC-${EXECgfs}/global_chgres} -export OROGRAPHY=${OROGRAPHY_LORES:-${FIXgfs}/am/global_orography.t$JCAP.$LONB.$LATB.grb} -export OROGRAPHY_UF=${OROGRAPHY_UF_LORES:-${FIXgfs}/am/global_orography_uf.t$JCAP.$LONB.$LATB.grb} -export LONSPERLAT=${LONSPERLAT_LORES:-${FIXgfs}/am/global_lonsperlat.t${JCAP}.$LONB.$LATB.txt} -export SLMASK=${SLMASK_LORES:-${FIXgfs}/am/global_slmask.t$JCAP.$LONB.$LATB.grb} -export MTNVAR=${MTNVAR_LORES:-${FIXgfs}/am/global_mtnvar.t$JCAP.$LONB.$LATB.f77} -export SIGLEVEL=${SIGLEVEL_LORES:-${FIXgfs}/am/global_hyblev.l${LEVS}.txt} -export O3CLIM=${O3CLIM:-${FIXgfs}/am/global_o3clim.txt} - -use_ufo=.true. - -NTRAC=3 -IALB=0 -idvc_a=2 -idvt=21 -IDSL=1 -IDVM=0 -LATCH=8 -OUTTYP=2 -export CHGRESTHREAD=${CHGRESTHREAD_LORES:-2} -export CHGRESVARS="use_ufo=$use_ufo,IALB=$ialb,ntrac=$NTRAC,idvc=$idvc_a,idvt=$idvt,idsl=$IDSL,IDVM=$IDVM,OUTTYP=$OUTTYP," - -export DATA=$DATATMP - -export APRUNC=${APRUNC:-""} -export VERBOSE=YES - -echo "execute $CHGRESSH for $member" -$CHGRESSH -rc=$? - -export ERR=$rc -export err=$ERR - -exit $err - diff --git a/ush/global_cycle.sh b/ush/global_cycle.sh index 661833898bb..0918e943a11 100755 --- a/ush/global_cycle.sh +++ b/ush/global_cycle.sh @@ -205,9 +205,9 @@ CYCLEXEC=${CYCLEXEC:-${EXECgfs}/global_cycle${XC}} FHOUR=${FHOUR:-00} CRES=${CASE:1} -JCAP_CASE=$((2*CRES-2)) -LONB_CASE=$((4*CRES)) -LATB_CASE=$((2*CRES)) +JCAP_CASE=$((2 * CRES - 2)) +LONB_CASE=$((4 * CRES)) +LATB_CASE=$((2 * CRES)) DELTSFC=${DELTSFC:-0} LSOIL=${LSOIL:-4} @@ -225,10 +225,10 @@ DONST=${DONST:-"NO"} DO_SFCCYCLE=${DO_SFCCYCLE:-.true.} GCYCLE_DO_SOILINCR=${GCYCLE_DO_SOILINCR:-.false.} GCYCLE_DO_SNOWINCR=${GCYCLE_DO_SNOWINCR:-.false.} -if [[ "${GCYCLE_DO_SOILINCR}" == ".true." ]] || [[ "${GCYCLE_DO_SNOWINCR}" == ".true." ]] ; then - DO_LANDINCR=".true." +if [[ "${GCYCLE_DO_SOILINCR}" == ".true." ]] || [[ "${GCYCLE_DO_SNOWINCR}" == ".true." ]]; then + DO_LANDINCR=".true." else - DO_LANDINCR=".false." + DO_LANDINCR=".false." fi GCYCLE_INTERP_LANDINCR=${GCYCLE_INTERP_LANDINCR:-.false.} zsea1=${zsea1:-0} @@ -330,7 +330,6 @@ cat << EOF > fort.36 / EOF - cat << EOF > fort.37 &NAMSFCD NST_FILE="${NST_FILE}", @@ -341,7 +340,7 @@ cat << EOF > fort.37 / EOF -${APRUNCY} "${CYCLEXEC}" 1>"${PGMOUT}" 2>"${PGMERR}" +${APRUNCY} "${CYCLEXEC}" 1> "${PGMOUT}" 2> "${PGMERR}" export err=$? diff --git a/ush/global_savefits.sh b/ush/global_savefits.sh index da62bf6ad9e..b23f1f694db 100755 --- a/ush/global_savefits.sh +++ b/ush/global_savefits.sh @@ -1,5 +1,5 @@ #! /usr/bin/env bash - + ######################################################## # save fit and horiz files for all analysis cycles ######################################################## @@ -10,7 +10,7 @@ export fh1=06 export fh2=00 # #dir=${FIT_DIR}/${EXP} -dir=${FIT_DIR} +dir="${FIT_DIR}" mkdir -p "${dir}" cd "${dir}" || exit 8 cpreq "${COMOUT}/f${fh1}.raob.${PDY}${cyc}" . @@ -24,8 +24,8 @@ cpreq "${COMOUT}/f${fh2}.acft.${PDY}${cyc}" . export typ=anl #dir=${HORZ_DIR}/${EXP}/${typ} -dir=${HORZ_DIR}/${typ} -mkdir -p ${dir} +dir="${HORZ_DIR}/${typ}" +mkdir -p "${dir}" cd "${dir}" || exit 8 cpreq "${COMOUT}/adpupa.mand.${typ}.${PDY}${cyc}" "adpupa.mand.${PDY}${cyc}" cpreq "${COMOUT}/adpsfc.${typ}.${PDY}${cyc}" "adpsfc.${PDY}${cyc}" @@ -36,35 +36,35 @@ cpreq "${COMOUT}/aircft.${typ}.${PDY}${cyc}" "aircft.${PDY}${cyc}" # save fit and horiz files for forecasts verifying at 00Z and 12Z cycles ######################################################################### if [[ "${cyc}" == "00" || "${cyc}" == "12" ]]; then - if [[ "${cyc}" == "00" ]]; then - export fh1=24 - export fh2=48 - fi - if [[ "${cyc}" == "12" ]]; then - export fh1=12 - export fh2=36 - fi - #dir=${FIT_DIR}/${EXP} - dir=${FIT_DIR} - mkdir -p "${dir}" - cd "${dir}" || exit 8 - cpreq "${COMOUT}/f${fh1}.raob.${PDY}${cyc}" . - cpreq "${COMOUT}/f${fh2}.raob.${PDY}${cyc}" . - cpreq "${COMOUT}/f${fh1}.sfc.${PDY}${cyc}" . - cpreq "${COMOUT}/f${fh2}.sfc.${PDY}${cyc}" . - cpreq "${COMOUT}/f${fh1}.acar.${PDY}${cyc}" . - cpreq "${COMOUT}/f${fh2}.acar.${PDY}${cyc}" . - cpreq "${COMOUT}/f${fh1}.acft.${PDY}${cyc}" . - cpreq "${COMOUT}/f${fh2}.acft.${PDY}${cyc}" . - export typ=fcs - #dir=${HORZ_DIR}/${EXP}/${typ} - dir=${HORZ_DIR}/${typ} - mkdir -p "${dir}" - cd "${dir}" || exit 8 - cpreq "${COMOUT}/adpupa.mand.${typ}.${PDY}${cyc}" "adpupa.mand.${PDY}${cyc}" - cpreq "${COMOUT}/adpsfc.${typ}.${PDY}${cyc}" "adpsfc.${PDY}${cyc}" - cpreq "${COMOUT}/sfcshp.${typ}.${PDY}${cyc}" "sfcshp.${PDY}${cyc}" - cpreq "${COMOUT}/aircar.${typ}.${PDY}${cyc}" "aircar.${PDY}${cyc}" - cpreq "${COMOUT}/aircft.${typ}.${PDY}${cyc}" "aircft.${PDY}${cyc}" + if [[ "${cyc}" == "00" ]]; then + export fh1=24 + export fh2=48 + fi + if [[ "${cyc}" == "12" ]]; then + export fh1=12 + export fh2=36 + fi + #dir=${FIT_DIR}/${EXP} + dir="${FIT_DIR}" + mkdir -p "${dir}" + cd "${dir}" || exit 8 + cpreq "${COMOUT}/f${fh1}.raob.${PDY}${cyc}" . + cpreq "${COMOUT}/f${fh2}.raob.${PDY}${cyc}" . + cpreq "${COMOUT}/f${fh1}.sfc.${PDY}${cyc}" . + cpreq "${COMOUT}/f${fh2}.sfc.${PDY}${cyc}" . + cpreq "${COMOUT}/f${fh1}.acar.${PDY}${cyc}" . + cpreq "${COMOUT}/f${fh2}.acar.${PDY}${cyc}" . + cpreq "${COMOUT}/f${fh1}.acft.${PDY}${cyc}" . + cpreq "${COMOUT}/f${fh2}.acft.${PDY}${cyc}" . + export typ=fcs + #dir=${HORZ_DIR}/${EXP}/${typ} + dir="${HORZ_DIR}/${typ}" + mkdir -p "${dir}" + cd "${dir}" || exit 8 + cpreq "${COMOUT}/adpupa.mand.${typ}.${PDY}${cyc}" "adpupa.mand.${PDY}${cyc}" + cpreq "${COMOUT}/adpsfc.${typ}.${PDY}${cyc}" "adpsfc.${PDY}${cyc}" + cpreq "${COMOUT}/sfcshp.${typ}.${PDY}${cyc}" "sfcshp.${PDY}${cyc}" + cpreq "${COMOUT}/aircar.${typ}.${PDY}${cyc}" "aircar.${PDY}${cyc}" + cpreq "${COMOUT}/aircft.${typ}.${PDY}${cyc}" "aircft.${PDY}${cyc}" fi ######################################################################### diff --git a/ush/interp_atmos_master.sh b/ush/interp_atmos_master.sh index 00bbde65043..b43b05c889b 100755 --- a/ush/interp_atmos_master.sh +++ b/ush/interp_atmos_master.sh @@ -4,9 +4,9 @@ # Generate 0.25 / 0.5 / 1 degree interpolated grib2 files for each input grib2 file # trim's RH and tweaks sea-ice cover -input_file=${1:-"pgb2file_in"} # Input pressure grib2 file -output_file_prefix=${2:-"pgb2file_out"} # Prefix for output grib2 file; the prefix is appended by resolution e.g. _0p25 -grid_string=${3:-"0p25"} # Target grids; e.g. "0p25" or "0p25:0p50"; If multiple, they need to be ":" seperated +input_file=${1:-"pgb2file_in"} # Input pressure grib2 file +output_file_prefix=${2:-"pgb2file_out"} # Prefix for output grib2 file; the prefix is appended by resolution e.g. _0p25 +grid_string=${3:-"0p25"} # Target grids; e.g. "0p25" or "0p25:0p50"; If multiple, they need to be ":" seperated # wgrib2 options for regridding defaults="-set_grib_type same -set_bitmap 1 -set_grib_max_bits 16" @@ -32,42 +32,42 @@ IFS=':' read -ra grids <<< "${grid_string}" output_grids="" for grid in "${grids[@]}"; do - gridopt="grid${grid}" - output_grids="${output_grids} -new_grid ${!gridopt} ${output_file_prefix}_${grid}" + gridopt="grid${grid}" + output_grids="${output_grids} -new_grid ${!gridopt} ${output_file_prefix}_${grid}" done #shellcheck disable=SC2086 ${WGRIB2} "${input_file}" ${defaults} \ - ${interp_winds} \ - ${interp_bilinear} \ - ${interp_neighbor} \ - ${interp_budget} \ - ${increased_bits} \ - ${output_grids} + ${interp_winds} \ + ${interp_bilinear} \ + ${interp_neighbor} \ + ${interp_budget} \ + ${increased_bits} \ + ${output_grids} export err=$? if [[ ${err} -ne 0 ]]; then - echo "FATAL ERROR: WGRIB2 failed to generate interpolated grib2 file!" - exit "${err}" + echo "FATAL ERROR: WGRIB2 failed to generate interpolated grib2 file!" + exit "${err}" fi # trim and mask for all grids for grid in "${grids[@]}"; do - trim_rh "${output_file_prefix}_${grid}" - export err=$? - if [[ ${err} -ne 0 ]]; then - echo "FATAL ERROR: Failed during the execution of trim_rh" - exit "${err}" - fi - # shellcheck disable=SC2312 - var_count=$(${WGRIB2} "${output_file_prefix}_${grid}" -match "LAND|ICEC" |wc -l) - if [[ "${var_count}" -eq 2 ]]; then - mod_icec "${output_file_prefix}_${grid}" + trim_rh "${output_file_prefix}_${grid}" export err=$? if [[ ${err} -ne 0 ]]; then - echo "FATAL ERROR: Failed during execution of mod_icec" - exit "${err}" + echo "FATAL ERROR: Failed during the execution of trim_rh" + exit "${err}" + fi + # shellcheck disable=SC2312 + var_count=$(${WGRIB2} "${output_file_prefix}_${grid}" -match "LAND|ICEC" | wc -l) + if [[ "${var_count}" -eq 2 ]]; then + mod_icec "${output_file_prefix}_${grid}" + export err=$? + if [[ ${err} -ne 0 ]]; then + echo "FATAL ERROR: Failed during execution of mod_icec" + exit "${err}" + fi fi - fi done exit 0 diff --git a/ush/interp_atmos_sflux.sh b/ush/interp_atmos_sflux.sh index 2aff2cc58aa..859691cdf73 100755 --- a/ush/interp_atmos_sflux.sh +++ b/ush/interp_atmos_sflux.sh @@ -3,9 +3,9 @@ # This script takes in a master flux file and creates interpolated flux files at various interpolated resolutions # Generate 0.25 / 0.5 / 1 degree interpolated grib2 flux files for each input sflux grib2 file -input_file=${1:-"sfluxfile_in"} # Input sflux grib2 file -output_file_prefix=${2:-"sfluxfile_out"} # Prefix for output sflux grib2 file; the prefix is appended by resolution e.g. _0p25 -grid_string=${3:-"1p00"} # Target grids; e.g. "0p25" or "0p25:0p50"; If multiple, they need to be ":" seperated +input_file=${1:-"sfluxfile_in"} # Input sflux grib2 file +output_file_prefix=${2:-"sfluxfile_out"} # Prefix for output sflux grib2 file; the prefix is appended by resolution e.g. _0p25 +grid_string=${3:-"1p00"} # Target grids; e.g. "0p25" or "0p25:0p50"; If multiple, they need to be ":" seperated # wgrib2 options for regridding defaults="-set_grib_type same -set_bitmap 1 -set_grib_max_bits 16" @@ -28,22 +28,22 @@ IFS=':' read -ra grids <<< "${grid_string}" output_grids="" for grid in "${grids[@]}"; do - gridopt="grid${grid}" - output_grids="${output_grids} -new_grid ${!gridopt} ${output_file_prefix}_${grid}" + gridopt="grid${grid}" + output_grids="${output_grids} -new_grid ${!gridopt} ${output_file_prefix}_${grid}" done #shellcheck disable=SC2086 ${WGRIB2} "${input_file}" ${defaults} \ - ${interp_winds} \ - ${interp_bilinear} \ - ${interp_neighbor} \ - ${interp_budget} \ - ${increased_bits} \ - ${output_grids} + ${interp_winds} \ + ${interp_bilinear} \ + ${interp_neighbor} \ + ${interp_budget} \ + ${increased_bits} \ + ${output_grids} export err=$? if [[ ${err} -ne 0 ]]; then - echo "FATAL ERROR: WGRIB2 failed to interpolate surface flux parameters to a new grib2 file" - exit "${err}" + echo "FATAL ERROR: WGRIB2 failed to interpolate surface flux parameters to a new grib2 file" + exit "${err}" fi exit 0 diff --git a/ush/jjob_header.sh b/ush/jjob_header.sh index 5de17f73a49..f69524b732a 100755 --- a/ush/jjob_header.sh +++ b/ush/jjob_header.sh @@ -46,8 +46,8 @@ source "${HOMEgfs}/ush/preamble.sh" OPTIND=1 while getopts "c:e:" option; do case "${option}" in - c) read -ra configs <<< "${OPTARG}" ;; - e) env_job=${OPTARG} ;; + c) read -ra configs <<< "${OPTARG}" ;; + e) env_job=${OPTARG} ;; :) export err=1 err_exit "[${BASH_SOURCE[0]}]: ${option} requires an argument" @@ -58,7 +58,7 @@ while getopts "c:e:" option; do ;; esac done -shift $((OPTIND-1)) +shift $((OPTIND - 1)) if [[ -z ${env_job} ]]; then export err=1 @@ -74,11 +74,10 @@ if [[ ${WIPE_DATA:-YES} == "YES" ]]; then fi mkdir -p "${DATA}" if ! cd "${DATA}"; then - export err=1 - err_exit "[${BASH_SOURCE[0]}]: ${DATA} does not exist" + export err=1 + err_exit "[${BASH_SOURCE[0]}]: ${DATA} does not exist" fi - ############################################## # Determine Job Output Name on System ############################################## @@ -89,7 +88,6 @@ export pgmerr=errfile # Needs to be set for err_chk/err_exit export pgm=${pgm:-} - ############################################## # Run setpdy and initialize PDY variables ############################################## @@ -97,7 +95,6 @@ export cycle="t${cyc}z" setpdy.sh || true source ./PDY || true - ############################# # Source relevant config files ############################# @@ -106,16 +103,15 @@ for config in "${configs[@]:-''}"; do source "${EXPDIR}/config.${config}" && true export err=$? if [[ ${err} -ne 0 ]]; then - err_exit "[${BASH_SOURCE[0]}]: Unable to load config config.${config}" + err_exit "[${BASH_SOURCE[0]}]: Unable to load config config.${config}" fi done - ########################################## # Source machine runtime environment ########################################## source "${HOMEgfs}/env/${machine}.env" "${env_job}" && true export err=$? if [[ ${err} -ne 0 ]]; then - err_exit "[${BASH_SOURCE[0]}]: Error while sourcing machine environment ${machine}.env for job ${env_job}" + err_exit "[${BASH_SOURCE[0]}]: Error while sourcing machine environment ${machine}.env for job ${env_job}" fi diff --git a/ush/link_crtm_fix.sh b/ush/link_crtm_fix.sh index 7a3654b8405..9f0d583b94f 100755 --- a/ush/link_crtm_fix.sh +++ b/ush/link_crtm_fix.sh @@ -6,30 +6,30 @@ # 3. Nowhere. Give up. Whine. CRTM_FIX="${1:-${CRTM_FIX:-MISSING}}" -if [[ "${CRTM_FIX}" == "MISSING" ]] ; then - echo "Please specify CRTM fix location. Giving up." 1>&2 - exit 19 +if [[ "${CRTM_FIX}" == "MISSING" ]]; then + echo "Please specify CRTM fix location. Giving up." 1>&2 + exit 19 fi -if [[ ! -d "${CRTM_FIX}" ]] ; then - echo "${CRTM_FIX}: \${CRTM_FIX} is not a directory. Giving up." 1>&2 - exit 38 +if [[ ! -d "${CRTM_FIX}" ]]; then + echo "${CRTM_FIX}: \${CRTM_FIX} is not a directory. Giving up." 1>&2 + exit 38 fi for what in "amsre_aqua" "imgr_g11" "imgr_g12" "imgr_g13" \ - "imgr_g15" "imgr_mt1r" "imgr_mt2" "seviri_m10" \ - "ssmi_f13" "ssmi_f14" "ssmi_f15" "ssmis_f16" \ - "ssmis_f17" "ssmis_f18" "ssmis_f19" "ssmis_f20" \ - "tmi_trmm" "v.seviri_m10" "imgr_insat3d" "abi_gr" "ahi_himawari8" ; do - ${NLN} "${CRTM_FIX}/${what}.TauCoeff.bin" "${what}.TauCoeff.bin" - ${NLN} "${CRTM_FIX}/${what}.SpcCoeff.bin" "${what}.SpcCoeff.bin" + "imgr_g15" "imgr_mt1r" "imgr_mt2" "seviri_m10" \ + "ssmi_f13" "ssmi_f14" "ssmi_f15" "ssmis_f16" \ + "ssmis_f17" "ssmis_f18" "ssmis_f19" "ssmis_f20" \ + "tmi_trmm" "v.seviri_m10" "imgr_insat3d" "abi_gr" "ahi_himawari8"; do + ${NLN} "${CRTM_FIX}/${what}.TauCoeff.bin" "${what}.TauCoeff.bin" + ${NLN} "${CRTM_FIX}/${what}.SpcCoeff.bin" "${what}.SpcCoeff.bin" done -for what in 'Aerosol' 'Cloud' ; do - ${NLN} "${CRTM_FIX}/${what}Coeff.bin" "${what}Coeff.bin" +for what in 'Aerosol' 'Cloud'; do + ${NLN} "${CRTM_FIX}/${what}Coeff.bin" "${what}Coeff.bin" done -for what in "${CRTM_FIX}/"*Emis* ; do - ${NLN} "${what}" "$(basename "${what}")" +for what in "${CRTM_FIX}/"*Emis*; do + ${NLN} "${what}" "$(basename "${what}")" done exit 0 diff --git a/ush/make_tif.sh b/ush/make_tif.sh index b5adfdc6f3b..70987cf51ec 100755 --- a/ush/make_tif.sh +++ b/ush/make_tif.sh @@ -15,15 +15,15 @@ ORIG=KWBC PDYHH="${PDY}${cyc}" if [[ "${HEADER}" == "YES" ]]; then - INPATH="${DATA}/${outname}" - SUB=DFAX1064 - "${HOMEgfs}/ush/make_NTC_file.pl" "${WMO}" "${ORIG}" "${PDYHH}" "${SUB}" "${INPATH}" "${OUTPATH}" -# -# Send the graphic to TOC + INPATH="${DATA}/${outname}" + SUB=DFAX1064 + "${HOMEgfs}/ush/make_NTC_file.pl" "${WMO}" "${ORIG}" "${PDYHH}" "${SUB}" "${INPATH}" "${OUTPATH}" + # + # Send the graphic to TOC - cpfs "${OUTPATH}" "${COMOUT_ATMOS_WMO}/gfs_500_hgt_tmp_nh_anl_${cyc}.tif" - if [[ "${SENDDBN}" == "YES" ]]; then + cpfs "${OUTPATH}" "${COMOUT_ATMOS_WMO}/gfs_500_hgt_tmp_nh_anl_${cyc}.tif" + if [[ "${SENDDBN}" == "YES" ]]; then - "${DBNROOT}/bin/dbn_alert" GRIB_LOW "${NET}" "${job}" "${COMOUT_ATMOS_WMO}/gfs_500_hgt_tmp_nh_anl_${cyc}.tif" - fi + "${DBNROOT}/bin/dbn_alert" GRIB_LOW "${NET}" "${job}" "${COMOUT_ATMOS_WMO}/gfs_500_hgt_tmp_nh_anl_${cyc}.tif" + fi fi diff --git a/ush/module-setup.sh b/ush/module-setup.sh index 4065c67e4cd..13e41879804 100755 --- a/ush/module-setup.sh +++ b/ush/module-setup.sh @@ -3,9 +3,9 @@ set -u source "${HOMEgfs}/ush/detect_machine.sh" -if [[ ${MACHINE_ID} = hera* ]] ; then +if [[ ${MACHINE_ID} = hera* ]]; then # We are on NOAA Hera - if ( ! eval module help > /dev/null 2>&1 ) ; then + if (! eval module help > /dev/null 2>&1); then source /apps/lmod/lmod/init/bash fi export LMOD_SYSTEM_DEFAULT_MODULES=contrib @@ -13,9 +13,9 @@ if [[ ${MACHINE_ID} = hera* ]] ; then module reset set -u -elif [[ ${MACHINE_ID} = ursa* ]] ; then +elif [[ ${MACHINE_ID} = ursa* ]]; then # We are on NOAA Ursa - if ( ! eval module help > /dev/null 2>&1 ) ; then + if (! eval module help > /dev/null 2>&1); then source /apps/lmod/lmod/init/bash fi export LMOD_SYSTEM_DEFAULT_MODULES=lmod @@ -23,9 +23,9 @@ elif [[ ${MACHINE_ID} = ursa* ]] ; then module reset set -u -elif [[ ${MACHINE_ID} = hercules* ]] ; then +elif [[ ${MACHINE_ID} = hercules* ]]; then # We are on Hercules - if ( ! eval module help > /dev/null 2>&1 ) ; then + if (! eval module help > /dev/null 2>&1); then source /apps/other/lmod/lmod/init/bash fi export LMOD_SYSTEM_DEFAULT_MODULES=contrib @@ -33,9 +33,9 @@ elif [[ ${MACHINE_ID} = hercules* ]] ; then module reset set -u -elif [[ ${MACHINE_ID} = orion* ]] ; then +elif [[ ${MACHINE_ID} = orion* ]]; then # We are on Orion - if ( ! eval module help > /dev/null 2>&1 ) ; then + if (! eval module help > /dev/null 2>&1); then source /apps/lmod/lmod/init/bash fi #export LMOD_SYSTEM_DEFAULT_MODULES=git/2.28.0 # contrib has a lot of stuff we shouldn't put in MODULEPATH @@ -43,30 +43,29 @@ elif [[ ${MACHINE_ID} = orion* ]] ; then module purge # reset causes issues on Orion sometimes. #set -u - elif [[ ${MACHINE_ID} = wcoss2 ]]; then # We are on WCOSS2 # Ignore default modules of the same version lower in the search path (req'd by spack-stack) #export LMOD_TMOD_FIND_FIRST=yes #TODO: Uncomment this when using spack-stack for the entire workflow module reset -elif [[ ${MACHINE_ID} = cheyenne* ]] ; then +elif [[ ${MACHINE_ID} = cheyenne* ]]; then # We are on NCAR Cheyenne - if ( ! eval module help > /dev/null 2>&1 ) ; then + if (! eval module help > /dev/null 2>&1); then source /glade/u/apps/ch/modulefiles/default/localinit/localinit.sh fi module purge -elif [[ ${MACHINE_ID} = stampede* ]] ; then +elif [[ ${MACHINE_ID} = stampede* ]]; then # We are on TACC Stampede - if ( ! eval module help > /dev/null 2>&1 ) ; then + if (! eval module help > /dev/null 2>&1); then source /opt/apps/lmod/lmod/init/bash fi module purge -elif [[ ${MACHINE_ID} = gaeac5 ]] ; then +elif [[ ${MACHINE_ID} = gaeac5 ]]; then # We are on GAEA C5. - if ( ! eval module help > /dev/null 2>&1 ) ; then + if (! eval module help > /dev/null 2>&1); then # We cannot simply load the module command. The GAEA # /etc/profile modifies a number of module-related variables # before loading the module command. Without those variables, @@ -77,14 +76,14 @@ elif [[ ${MACHINE_ID} = gaeac5 ]] ; then module reset elif [[ ${MACHINE_ID} = gaeac6 ]]; then # We are on GAEA C6. - if ( ! eval module help > /dev/null 2>&1 ) ; then + if (! eval module help > /dev/null 2>&1); then source /opt/cray/pe/lmod/lmod/init/bash fi module reset elif [[ ${MACHINE_ID} = expanse* ]]; then # We are on SDSC Expanse - if ( ! eval module help > /dev/null 2>&1 ) ; then + if (! eval module help > /dev/null 2>&1); then source /etc/profile.d/modules.sh fi module purge @@ -109,7 +108,7 @@ fi # If this function exists in the environment, run it; else do not ftype=$(type -t set_strict || echo "") if [[ "${ftype}" == "function" ]]; then - set_strict + set_strict else - set +u + set +u fi diff --git a/ush/month_name.sh b/ush/month_name.sh index 02af45149d7..c84133356a5 100755 --- a/ush/month_name.sh +++ b/ush/month_name.sh @@ -5,7 +5,7 @@ # SCRIPT: month_name.sh # # This script returns the name/abreviation of a month -# in a small text file, month_name.txt. It also echos the +# in a small text file, month_name.txt. It also echos the # name/abreviation to stdout. The form of the returned # name/abreviation is specified by the script arguments. # @@ -17,7 +17,7 @@ # ----------- ------ ---------------------------- # # 6/06 Mon Jun -# 8/08 Month August +# 8/08 Month August # 9/09 MON SEP # 11 MONTH NOVEMBER # @@ -26,7 +26,7 @@ # by either of the following methods: # # MM=`cat month_name.txt` after executing month_name.sh -# - OR - +# - OR - # MM=`month_name.sh 5 MON` (for example) # # @@ -36,77 +36,100 @@ # #################################################################### - typeset -Z2 month_num - - - month_num=$1 - month_spec=$2 - - case ${month_num} in - - 01) Mon=Jan - Month=January ;; - - 02) Mon=Feb - Month=February ;; - - 03) Mon=Mar - Month=March ;; - - 04) Mon=Apr - Month=April ;; - - 05) Mon=May - Month=May ;; - - 06) Mon=Jun - Month=June ;; - - 07) Mon=Jul - Month=July ;; - - 08) Mon=Aug - Month=August ;; - - 09) Mon=Sep - Month=September ;; - - 10) Mon=Oct - Month=October ;; - - 11) Mon=Nov - Month=November ;; - - 12) Mon=Dec - Month=December ;; +typeset -Z2 month_num + +month_num=$1 +month_spec=$2 + +case ${month_num} in + + 01) + Mon=Jan + Month=January + ;; + + 02) + Mon=Feb + Month=February + ;; + + 03) + Mon=Mar + Month=March + ;; + + 04) + Mon=Apr + Month=April + ;; + + 05) + Mon=May + Month=May + ;; + + 06) + Mon=Jun + Month=June + ;; + + 07) + Mon=Jul + Month=July + ;; + + 08) + Mon=Aug + Month=August + ;; + + 09) + Mon=Sep + Month=September + ;; + + 10) + Mon=Oct + Month=October + ;; + + 11) + Mon=Nov + Month=November + ;; + + 12) + Mon=Dec + Month=December + ;; *) echo "FATAL ERROR input month number (${month_num}) is invalid" exit 2 + ;; - esac - +esac - if [[ "${month_spec}" == "Mon" ]]; then +if [[ "${month_spec}" == "Mon" ]]; then echo "${Mon}" echo "${Mon}" > month_name.txt - elif [[ "${month_spec}" == "Month" ]]; then +elif [[ "${month_spec}" == "Month" ]]; then echo "${Month}" echo "${Month}" > month_name.txt - elif [[ "${month_spec}" == "MON" ]]; then +elif [[ "${month_spec}" == "MON" ]]; then MON="${Mon^^}" echo "${MON}" echo "${MON}" > month_name.txt - elif [[ "${month_spec}" == "MONTH" ]]; then +elif [[ "${month_spec}" == "MONTH" ]]; then MONTH="${Month^^}" echo "${MONTH}" echo "${MONTH}" > month_name.txt - fi +fi diff --git a/ush/ocnice_extractvars.sh b/ush/ocnice_extractvars.sh index 96f6558d07b..2e6eb0237ea 100755 --- a/ush/ocnice_extractvars.sh +++ b/ush/ocnice_extractvars.sh @@ -18,69 +18,69 @@ fhout_ocnice=${5} comout_rfcst_prod_ocnice=${6} if [[ ! -d "${subdata}" ]]; then - mkdir -p "${subdata}" + mkdir -p "${subdata}" fi -for (( nh = FHMIN_GFS + fhout_ocnice; nh <= FHMAX_GFS; nh = nh + fhout_ocnice )); do - fnh=$(printf "%3.3d" "${nh}") +for ((nh = FHMIN_GFS + fhout_ocnice; nh <= FHMAX_GFS; nh = nh + fhout_ocnice)); do + fnh=$(printf "%3.3d" "${nh}") - if [[ ${component_name} == "ocn" ]]; then - if [[ "${datares}" == "native" ]]; then - com_dir=${COMIN_OCEAN_HISTORY} - infile="${com_dir}/${RUN}.ocean.t${cyc}z.${fhout_ocnice}hr_avg.f${fnh}.nc" - new_infile=${subdata}/${RUN}.ocean.t${cyc}z.${fhout_ocnice}hr_avg.f${fnh}_ext.nc - else - com_dir=${COMIN_OCEAN_NETCDF} - infile="${com_dir}/${datares}/${RUN}.ocean.t${cyc}z.${datares}.f${fnh}.nc" - new_infile=${subdata}/${RUN}.ocean.t${cyc}z.${datares}.f${fnh}_ext.nc - fi - # For ocean products, add an argument to extract a subset of levels - otherargs=(-d "${depthvar_name},""${zmin},""${zmax}") - elif [[ ${component_name} == "ice" ]]; then - if [[ "${datares}" == "native" ]]; then - com_dir=${COMIN_ICE_HISTORY} - infile="${com_dir}/${RUN}.ice.t${cyc}z.${fhout_ocnice}hr_avg.f${fnh}.nc" - new_infile=${subdata}/${RUN}.ice.t${cyc}z.${fhout_ocnice}hr_avg.f${fnh}_ext.nc - else - com_dir=${COMIN_ICE_NETCDF} - infile="${com_dir}/${datares}/${RUN}.ice.t${cyc}z.${datares}.f${fnh}.nc" - new_infile=${subdata}/${RUN}.ice.t${cyc}z.${datares}.f${fnh}_ext.nc + if [[ ${component_name} == "ocn" ]]; then + if [[ "${datares}" == "native" ]]; then + com_dir=${COMIN_OCEAN_HISTORY} + infile="${com_dir}/${RUN}.ocean.t${cyc}z.${fhout_ocnice}hr_avg.f${fnh}.nc" + new_infile=${subdata}/${RUN}.ocean.t${cyc}z.${fhout_ocnice}hr_avg.f${fnh}_ext.nc + else + com_dir=${COMIN_OCEAN_NETCDF} + infile="${com_dir}/${datares}/${RUN}.ocean.t${cyc}z.${datares}.f${fnh}.nc" + new_infile=${subdata}/${RUN}.ocean.t${cyc}z.${datares}.f${fnh}_ext.nc + fi + # For ocean products, add an argument to extract a subset of levels + otherargs=(-d "${depthvar_name},""${zmin},""${zmax}") + elif [[ ${component_name} == "ice" ]]; then + if [[ "${datares}" == "native" ]]; then + com_dir=${COMIN_ICE_HISTORY} + infile="${com_dir}/${RUN}.ice.t${cyc}z.${fhout_ocnice}hr_avg.f${fnh}.nc" + new_infile=${subdata}/${RUN}.ice.t${cyc}z.${fhout_ocnice}hr_avg.f${fnh}_ext.nc + else + com_dir=${COMIN_ICE_NETCDF} + infile="${com_dir}/${datares}/${RUN}.ice.t${cyc}z.${datares}.f${fnh}.nc" + new_infile=${subdata}/${RUN}.ice.t${cyc}z.${datares}.f${fnh}_ext.nc + fi + otherargs=() fi - otherargs=() - fi - outfile=${subdata}/${RUN}.${component_name}.t${cyc}z.${datares}.f${fnh}.nc + outfile=${subdata}/${RUN}.${component_name}.t${cyc}z.${datares}.f${fnh}.nc - if [[ -f "${infile}" ]]; then #check if input file exists before extraction - if ! cpfs "${infile}" "${new_infile}"; then - echo "FATAL ERROR: Failed to copy ${infile} to ${new_infile}." - exit 1 - fi - varsrequested=$(paste -s "${varlist}") - varsinfile=$(cdo -showname "${new_infile}") - varsavailable="" - for i in ${varsrequested}; do - # Check if variable from parm file is available in netcdf file. If variable is not in netcdf file, do not try to extract that variable. - if [[ ${varsinfile} == *"${i}"* ]]; then - varsavailable+="${i}," - else - echo "WARNING: ${i} is not available in ${new_infile}." - fi - done - if [[ -z "${varsavailable}" ]]; then - echo "WARNING: No variables from parm file ${varlist} are available in netcdf file ${new_infile}." - else - ocnice_vars=${varsavailable::-1} - ncks -v "${ocnice_vars}" "${otherargs[@]}" "${new_infile}" "${outfile}" - fi - if [[ ${datacompress} -eq 1 ]]; then - ${COMPRSCMD} "${outfile}" - copy_to_comout "${outfile}.bz2" "${comout_rfcst_prod_ocnice}" + if [[ -f "${infile}" ]]; then #check if input file exists before extraction + if ! cpfs "${infile}" "${new_infile}"; then + echo "FATAL ERROR: Failed to copy ${infile} to ${new_infile}." + exit 1 + fi + varsrequested=$(paste -s "${varlist}") + varsinfile=$(cdo -showname "${new_infile}") + varsavailable="" + for i in ${varsrequested}; do + # Check if variable from parm file is available in netcdf file. If variable is not in netcdf file, do not try to extract that variable. + if [[ ${varsinfile} == *"${i}"* ]]; then + varsavailable+="${i}," + else + echo "WARNING: ${i} is not available in ${new_infile}." + fi + done + if [[ -z "${varsavailable}" ]]; then + echo "WARNING: No variables from parm file ${varlist} are available in netcdf file ${new_infile}." + else + ocnice_vars=${varsavailable::-1} + ncks -v "${ocnice_vars}" "${otherargs[@]}" "${new_infile}" "${outfile}" + fi + if [[ ${datacompress} -eq 1 ]]; then + ${COMPRSCMD} "${outfile}" + copy_to_comout "${outfile}.bz2" "${comout_rfcst_prod_ocnice}" + else + copy_to_comout "${outfile}" "${comout_rfcst_prod_ocnice}" + fi else - copy_to_comout "${outfile}" "${comout_rfcst_prod_ocnice}" + echo "WARNING: ${infile} does not exist in ${com_dir}." fi - else - echo "WARNING: ${infile} does not exist in ${com_dir}." - fi done # nh exit 0 diff --git a/ush/ozn_xtrct.sh b/ush/ozn_xtrct.sh index a84c00f45b7..d45674bdb12 100755 --- a/ush/ozn_xtrct.sh +++ b/ush/ozn_xtrct.sh @@ -5,16 +5,16 @@ # # This script performs the data extraction from the oznstat # diagnostic files. The resulting data (*.ieee_d) files, GrADS -# control files and stdout files will be moved to the +# control files and stdout files will be moved to the # $TANKverf_ozn. # -# Calling scripts must define: +# Calling scripts must define: # $TANKverf_ozn # $PDY # $cyc # -# Return values are -# 0 = normal +# Return values are +# 0 = normal # 2 = unable to generate satype list; may indicate no diag # files found in oznstat file #------------------------------------------------------------------ @@ -22,33 +22,32 @@ #-------------------------------------------------- # check_diag_files # -# Compare $satype (which contains the contents of +# Compare $satype (which contains the contents of # gdas_oznmon_satype.txt to $avail_satype which is # determined by the contents of the oznstat file. # Report any missing diag files in a file named # bad_diag.$PDY$cyc # check_diag_files() { - pdate=$1 - found_satype=$2 - avail_satype=$3 + pdate=$1 + found_satype=$2 + avail_satype=$3 - out_file="bad_diag.${pdate}" + out_file="bad_diag.${pdate}" - printf "\n\n--> check_diag_files\n" + printf "\n\n--> check_diag_files\n" - for type in ${found_satype}; do - len_check=$(echo "${avail_satype}" | grep "${type}" | wc -c) + for type in ${found_satype}; do + if ! grep -q "${type}" <<< "${avail_satype}"; then + echo "missing diag file -- diag_${type}_ges.${pdate}.gz not found" >> "./${out_file}" + fi + done - if [[ ${len_check} -le 1 ]]; then - echo "missing diag file -- diag_${type}_ges.${pdate}.gz not found" >> "./${out_file}" - fi - done - - echo "<-- check_diag_files"; echo ""; echo "" + echo "<-- check_diag_files" + echo "" + echo "" } - iret=0 VALIDATE_DATA=${VALIDATE_DATA:-0} nregion=${nregion:-6} @@ -56,13 +55,13 @@ DO_DATA_RPT=${DO_DATA_RPT:-0} netcdf_boolean=".false." if [[ ${OZNMON_NETCDF} -eq 1 ]]; then - netcdf_boolean=".true." + netcdf_boolean=".true." fi OZNMON_NEW_HDR=${OZNMON_NEW_HDR:-0} new_hdr="F" if [[ ${OZNMON_NEW_HDR} -eq 1 ]]; then - new_hdr="T" + new_hdr="T" fi #------------------------------------------------------------------ @@ -70,28 +69,25 @@ fi # validate=".FALSE." if [[ ${VALIDATE_DATA} -eq 1 ]]; then - if [[ ! -e ${ozn_val_file} && ! -h ${ozn_val_file} ]]; then - echo "WARNING: VALIDATE_DATA set to 1, but unable to locate ${ozn_val_file}" - echo " Setting VALIDATE_DATA to 0/OFF" - VALIDATE_DATA=0 - else - validate=".TRUE." - val_file=$(basename "${ozn_val_file}") - cpreq "${ozn_val_file}" "${val_file}" - tar -xvf "${val_file}" - fi + if [[ ! -e ${ozn_val_file} && ! -L ${ozn_val_file} ]]; then + echo "WARNING: VALIDATE_DATA set to 1, but unable to locate ${ozn_val_file}" + echo " Setting VALIDATE_DATA to 0/OFF" + VALIDATE_DATA=0 + else + validate=".TRUE." + val_file=$(basename "${ozn_val_file}") + cpreq "${ozn_val_file}" "${val_file}" + tar -xvf "${val_file}" + fi fi echo "VALIDATE_DATA, validate = ${VALIDATE_DATA}, ${validate} " - - #------------------------------------------------------------------ -# ozn_ptype here is the processing type which is intended to be "ges" +# ozn_ptype here is the processing type which is intended to be "ges" # or "anl". Default is "ges". # ozn_ptype=${ozn_ptype:-"ges anl"} - #--------------------------------------------------------------------------- # Build satype list from the available diag files. # @@ -99,58 +95,63 @@ ozn_ptype=${ozn_ptype:-"ges anl"} # a problem, reported by an iret value of 2 # -avail_satype=$(ls -1 d*ges* | sed -e 's/_/ /g;s/\./ /' | gawk '{ print $2 "_" $3 }') +declare -a avail_satype +ges_file_pattern='(diag_)(.*)(_ges)' +for ges_file in *; do + if [[ "${ges_file}" =~ ${ges_file_pattern} ]]; then + avail_satype+=("${BASH_REMATCH[2]}") + fi +done if [[ ${DO_DATA_RPT} -eq 1 ]]; then - if [[ -e ${SATYPE_FILE} ]]; then - satype=$(cat "${SATYPE_FILE}") - check_diag_files "${PDY}${cyc}" "${satype}" "${avail_satype}" - else - echo "WARNING: missing ${SATYPE_FILE}" - fi + if [[ -e ${SATYPE_FILE} ]]; then + satype=$(cat "${SATYPE_FILE}") + check_diag_files "${PDY}${cyc}" "${satype}" "${avail_satype[*]}" + else + echo "WARNING: missing ${SATYPE_FILE}" + fi fi len_satype=$(echo -n "${satype}" | wc -c) if [[ ${len_satype} -le 1 ]]; then - satype=${avail_satype} + satype="${avail_satype[*]}" fi echo "${satype}" - len_satype=$(echo -n "${satype}" | wc -c) if [[ ${DO_DATA_RPT} -eq 1 && ${len_satype} -lt 1 ]]; then - iret=2 + iret=2 else - #-------------------------------------------------------------------- - # Copy extraction programs to working directory - # - cpreq "${EXECgfs}/oznmon_time.x" ./oznmon_time.x - cpreq "${EXECgfs}/oznmon_horiz.x" ./oznmon_horiz.x - - #--------------------------------------------------------------------------- - # Outer loop over $ozn_ptype (default values 'ges', 'anl') - # - for ptype in ${ozn_ptype}; do - - iyy="${PDY:0:4}" - imm="${PDY:4:2}" - idd="${PDY:6:2}" - ihh=${cyc} - - for type in ${avail_satype}; do - if [[ -f "diag_${type}_${ptype}.${PDY}${cyc}.gz" ]]; then - mv "diag_${type}_${ptype}.${PDY}${cyc}.gz" "${type}.${ptype}.gz" - gunzip "./${type}.${ptype}.gz" - - echo "processing ptype, type: ${ptype}, ${type}" - rm -f input - -cat << EOF > input + #-------------------------------------------------------------------- + # Copy extraction programs to working directory + # + cpreq "${EXECgfs}/oznmon_time.x" ./oznmon_time.x + cpreq "${EXECgfs}/oznmon_horiz.x" ./oznmon_horiz.x + + #--------------------------------------------------------------------------- + # Outer loop over $ozn_ptype (default values 'ges', 'anl') + # + for ptype in ${ozn_ptype}; do + + iyy="${PDY:0:4}" + imm="${PDY:4:2}" + idd="${PDY:6:2}" + ihh=${cyc} + + for type in "${avail_satype[@]}"; do + if [[ -f "diag_${type}_${ptype}.${PDY}${cyc}.gz" ]]; then + mv "diag_${type}_${ptype}.${PDY}${cyc}.gz" "${type}.${ptype}.gz" + gunzip "./${type}.${ptype}.gz" + + echo "processing ptype, type: ${ptype}, ${type}" + rm -f input + + cat << EOF > input &INPUT satname='${type}', iyy=${iyy}, @@ -173,28 +174,27 @@ cat << EOF > input / EOF + echo "oznmon_time.x HAS STARTED ${type}" - echo "oznmon_time.x HAS STARTED ${type}" - - ./oznmon_time.x < input > "stdout.time.${type}.${ptype}" + ./oznmon_time.x < input > "stdout.time.${type}.${ptype}" - echo "oznmon_time.x HAS ENDED ${type}" + echo "oznmon_time.x HAS ENDED ${type}" - if [[ ! -d ${TANKverf_ozn}/time ]]; then - mkdir -p "${TANKverf_ozn}/time" - fi - cpfs "${type}.${ptype}.ctl" "${TANKverf_ozn}/time/" - cpfs "${type}.${ptype}.${PDY}${cyc}.ieee_d" "${TANKverf_ozn}/time/" - - if compgen -G "bad*" > /dev/null; then - for bad_file in bad*; do - cpfs "${bad_file}" "${TANKverf_ozn}/time/" - done - fi - - rm -f input + if [[ ! -d ${TANKverf_ozn}/time ]]; then + mkdir -p "${TANKverf_ozn}/time" + fi + cpfs "${type}.${ptype}.ctl" "${TANKverf_ozn}/time/" + cpfs "${type}.${ptype}.${PDY}${cyc}.ieee_d" "${TANKverf_ozn}/time/" -cat << EOF > input + if compgen -G "bad*" > /dev/null; then + for bad_file in bad*; do + cpfs "${bad_file}" "${TANKverf_ozn}/time/" + done + fi + + rm -f input + + cat << EOF > input &INPUT satname='${type}', iyy=${iyy}, @@ -209,38 +209,37 @@ cat << EOF > input / EOF - echo "oznmon_horiz.x HAS STARTED ${type}" - - ./oznmon_horiz.x < input > "stdout.horiz.${type}.${ptype}" + echo "oznmon_horiz.x HAS STARTED ${type}" - echo "oznmon_horiz.x HAS ENDED ${type}" + ./oznmon_horiz.x < input > "stdout.horiz.${type}.${ptype}" - if [[ ! -d ${TANKverf_ozn}/horiz ]]; then - mkdir -p "${TANKverf_ozn}/horiz" - fi - cpfs "${type}.${ptype}.ctl" "${TANKverf_ozn}/horiz/" + echo "oznmon_horiz.x HAS ENDED ${type}" - ${COMPRESS} "${type}.${ptype}.${PDY}${cyc}.ieee_d" - cpfs "${type}.${ptype}.${PDY}${cyc}.ieee_d.${Z}" "${TANKverf_ozn}/horiz/" + if [[ ! -d ${TANKverf_ozn}/horiz ]]; then + mkdir -p "${TANKverf_ozn}/horiz" + fi + cpfs "${type}.${ptype}.ctl" "${TANKverf_ozn}/horiz/" + ${COMPRESS} "${type}.${ptype}.${PDY}${cyc}.ieee_d" + cpfs "${type}.${ptype}.${PDY}${cyc}.ieee_d.${Z}" "${TANKverf_ozn}/horiz/" - echo "finished processing ptype, type: ${ptype}, ${type}" + echo "finished processing ptype, type: ${ptype}, ${type}" - else - echo "diag file for ${type}.${ptype} not found" - fi + else + echo "diag file for ${type}.${ptype} not found" + fi - done # type in satype + done # type in satype - done # ptype in $ozn_ptype + done # ptype in $ozn_ptype - tar -cvf stdout.horiz.tar stdout.horiz* - ${COMPRESS} stdout.horiz.tar - cpfs "stdout.horiz.tar.${Z}" "${TANKverf_ozn}/horiz/" + tar -cvf stdout.horiz.tar stdout.horiz* + ${COMPRESS} stdout.horiz.tar + cpfs "stdout.horiz.tar.${Z}" "${TANKverf_ozn}/horiz/" - tar -cvf stdout.time.tar stdout.time* - ${COMPRESS} stdout.time.tar - cpfs "stdout.time.tar.${Z}" "${TANKverf_ozn}/time/" + tar -cvf stdout.time.tar stdout.time* + ${COMPRESS} stdout.time.tar + cpfs "stdout.time.tar.${Z}" "${TANKverf_ozn}/time/" fi -exit ${iret} +exit "${iret}" diff --git a/ush/parsing_model_configure_FV3.sh b/ush/parsing_model_configure_FV3.sh index c8d2d00f8a8..a5f141cd253 100755 --- a/ush/parsing_model_configure_FV3.sh +++ b/ush/parsing_model_configure_FV3.sh @@ -3,78 +3,78 @@ # parsing model_configure for UFSWM FV3 # shellcheck disable=SC2034 -FV3_model_configure(){ +FV3_model_configure() { -local restile=${CASE_HIST:1} + local restile=${CASE_HIST:1} -# Prepare local variables for use in model_configure.IN from UFSWM -# The ones already defined are left commented as a reminder + # Prepare local variables for use in model_configure.IN from UFSWM + # The ones already defined are left commented as a reminder -local model_start_date -if [[ "${DOIAU}" == "YES" ]]; then - model_start_date="${previous_cycle}" -else - model_start_date="${current_cycle}" -fi + local model_start_date + if [[ "${DOIAU}" == "YES" ]]; then + model_start_date="${previous_cycle}" + else + model_start_date="${current_cycle}" + fi -local SYEAR=${model_start_date:0:4} -local SMONTH=${model_start_date:4:2} -local SDAY=${model_start_date:6:2} -local SHOUR=${model_start_date:8:2} -# FHMAX -local FHROT=${IAU_FHROT:-0} -local DT_ATMOS=${DELTIM} -local RESTART_INTERVAL="${FV3_RESTART_FH[*]}" -local RESTART_FH="${CMEPS_RESTART_FH:-" "}" -# QUILTING -local QUILTING_RESTART="${QUILTING_RESTART:-${QUILTING}}" -local WRITE_GROUP=${WRITE_GROUP:-1} -local WRTTASK_PER_GROUP=${WRTTASK_PER_GROUP:-24} -local ITASKS=1 -local OUTPUT_HISTORY=${OUTPUT_HISTORY:-".true."} -if [[ "${DO_JEDIATMVAR:-}" == "YES" || "${DO_HISTORY_FILE_ON_NATIVE_GRID:-"NO"}" == "YES" ]]; then - local HISTORY_FILE_ON_NATIVE_GRID=".true." -else - local HISTORY_FILE_ON_NATIVE_GRID=".false." -fi -local WRITE_DOPOST=${WRITE_DOPOST:-".false."} -local WRITE_NSFLIP=${WRITE_NSFLIP:-".false."} -local NUM_FILES=${NUM_FILES:-2} -local FILENAME_BASE="'atm' 'sfc'" -# OUTPUT_GRID -local OUTPUT_FILE="'${OUTPUT_FILETYPE_ATM}' '${OUTPUT_FILETYPE_SFC}'" -local ZSTANDARD_LEVEL=${zstandard_level:-0} -local IDEFLATE=${ideflate:-0} # netCDF zlib lossless compression (0-9); 0: no compression -local QUANTIZE_NSD=${quantize_nsd:-0} # netCDF compression -local ICHUNK2D=$((4*restile)) -local JCHUNK2D=$((2*restile)) -local ICHUNK3D=$((4*restile)) -local JCHUNK3D=$((2*restile)) -local KCHUNK3D=1 -local IMO=${LONB_IMO} -local JMO=${LATB_JMO} -local OUTPUT_FH=${FV3_OUTPUT_FH_NML} -local IAU_OFFSET=${IAU_OFFSET:-0} -local USE_FV3_ROUTEHANDLES=.false. + local SYEAR=${model_start_date:0:4} + local SMONTH=${model_start_date:4:2} + local SDAY=${model_start_date:6:2} + local SHOUR=${model_start_date:8:2} + # FHMAX + local FHROT=${IAU_FHROT:-0} + local DT_ATMOS=${DELTIM} + local RESTART_INTERVAL="${FV3_RESTART_FH[*]}" + local RESTART_FH="${CMEPS_RESTART_FH:-" "}" + # QUILTING + local QUILTING_RESTART="${QUILTING_RESTART:-${QUILTING}}" + local WRITE_GROUP=${WRITE_GROUP:-1} + local WRTTASK_PER_GROUP=${WRTTASK_PER_GROUP:-24} + local ITASKS=1 + local OUTPUT_HISTORY=${OUTPUT_HISTORY:-".true."} + if [[ "${DO_JEDIATMVAR:-}" == "YES" || "${DO_HISTORY_FILE_ON_NATIVE_GRID:-"NO"}" == "YES" ]]; then + local HISTORY_FILE_ON_NATIVE_GRID=".true." + else + local HISTORY_FILE_ON_NATIVE_GRID=".false." + fi + local WRITE_DOPOST=${WRITE_DOPOST:-".false."} + local WRITE_NSFLIP=${WRITE_NSFLIP:-".false."} + local NUM_FILES=${NUM_FILES:-2} + local FILENAME_BASE="'atm' 'sfc'" + # OUTPUT_GRID + local OUTPUT_FILE="'${OUTPUT_FILETYPE_ATM}' '${OUTPUT_FILETYPE_SFC}'" + local ZSTANDARD_LEVEL=${zstandard_level:-0} + local IDEFLATE=${ideflate:-0} # netCDF zlib lossless compression (0-9); 0: no compression + local QUANTIZE_NSD=${quantize_nsd:-0} # netCDF compression + local ICHUNK2D=$((4 * restile)) + local JCHUNK2D=$((2 * restile)) + local ICHUNK3D=$((4 * restile)) + local JCHUNK3D=$((2 * restile)) + local KCHUNK3D=1 + local IMO=${LONB_IMO} + local JMO=${LATB_JMO} + local OUTPUT_FH=${FV3_OUTPUT_FH_NML} + local IAU_OFFSET=${IAU_OFFSET:-0} + local USE_FV3_ROUTEHANDLES=.false. -#set FV3 output directory: -local FV3ATM_OUTPUT_DIR="./FV3ATM_OUTPUT" + #set FV3 output directory: + local FV3ATM_OUTPUT_DIR="./FV3ATM_OUTPUT" -# Ensure the template exists -if [[ "${DO_NEST:-NO}" == "YES" ]] ; then - local NEST_IMO=${npx_nest} - local NEST_JMO=${npy_nest} - template="${PARMgfs}/ufs/input_global_nest.nml.IN" -else - template="${PARMgfs}/ufs/model_configure.IN" -fi -if [[ ! -f ${template} ]]; then - echo "FATAL ERROR: template '${template}' does not exist, ABORT!" - exit 1 -fi -rm -f "${DATA}/model_configure" -atparse < "${template}" >> "${DATA}/model_configure" -echo "Rendered model_configure" -cat "${DATA}/model_configure" + # Ensure the template exists + if [[ "${DO_NEST:-NO}" == "YES" ]]; then + local NEST_IMO=${npx_nest} + local NEST_JMO=${npy_nest} + template="${PARMgfs}/ufs/input_global_nest.nml.IN" + else + template="${PARMgfs}/ufs/model_configure.IN" + fi + if [[ ! -f ${template} ]]; then + echo "FATAL ERROR: template '${template}' does not exist, ABORT!" + exit 1 + fi + rm -f "${DATA}/model_configure" + atparse < "${template}" >> "${DATA}/model_configure" + echo "Rendered model_configure" + cat "${DATA}/model_configure" } diff --git a/ush/parsing_namelists_CICE.sh b/ush/parsing_namelists_CICE.sh index b2b0a97aca3..2815db5a022 100755 --- a/ush/parsing_namelists_CICE.sh +++ b/ush/parsing_namelists_CICE.sh @@ -4,149 +4,147 @@ # Disable variable not used warnings # shellcheck disable=SC2034 -CICE_namelists(){ +CICE_namelists() { -# "warm_start" here refers to whether CICE model is warm starting or not. -# Per JM, in the case of the Prototypes, the sea-ice ICs were obtained from CPC. -# CPC sea-ice initial conditions are created from SIS2 sea-ice model. -# Hence, the prototypes always set this to "initial" -# in order for the CICE model to _initialize_ from the SIS2 ICs. -# However, in the SOCA cycled system, if starting from a previously cycled SOCA run, -# the CICE ICs are obtained from the previous cycle of the UFS S2S, -# so the CICE namelist should be set to "continue" -# TODO: Is there a way to interrogate the restart file to know if this is a -# SIS2 restart or a CICE restart, instead of relying on "${warm_start}" -if [[ "${warm_start}" = ".true." ]]; then - local runtype="continue" - local use_restart_time=".true." -else - local runtype="initial" - local use_restart_time=".false." -fi + # "warm_start" here refers to whether CICE model is warm starting or not. + # Per JM, in the case of the Prototypes, the sea-ice ICs were obtained from CPC. + # CPC sea-ice initial conditions are created from SIS2 sea-ice model. + # Hence, the prototypes always set this to "initial" + # in order for the CICE model to _initialize_ from the SIS2 ICs. + # However, in the SOCA cycled system, if starting from a previously cycled SOCA run, + # the CICE ICs are obtained from the previous cycle of the UFS S2S, + # so the CICE namelist should be set to "continue" + # TODO: Is there a way to interrogate the restart file to know if this is a + # SIS2 restart or a CICE restart, instead of relying on "${warm_start}" + if [[ "${warm_start}" = ".true." ]]; then + local runtype="continue" + local use_restart_time=".true." + else + local runtype="initial" + local use_restart_time=".false." + fi -# Get correct MPI options for NPROC and grid -local processor_shape=${cice6_processor_shape:-'slenderX2'} -local shape=${processor_shape#${processor_shape%?}} -local NPX=$(( ntasks_cice6 / shape )) #number of processors in x direction -local NPY=$(( ntasks_cice6 / NPX )) #number of processors in y direction -if (( $(( NX_GLB % NPX )) == 0 )); then - local block_size_x=$(( NX_GLB / NPX )) -else - local block_size_x=$(( (NX_GLB / NPX) + 1 )) -fi -if (( $(( NY_GLB % NPY )) == 0 )); then - local block_size_y=$(( NY_GLB / NPY )) -else - local block_size_y=$(( (NY_GLB / NPY) + 1 )) -fi + # Get correct MPI options for NPROC and grid + local processor_shape=${cice6_processor_shape:-'slenderX2'} + local shape=${processor_shape#"${processor_shape%?}"} + local NPX=$((ntasks_cice6 / shape)) #number of processors in x direction + local NPY=$((ntasks_cice6 / NPX)) #number of processors in y direction + if (($((NX_GLB % NPX)) == 0)); then + local block_size_x=$((NX_GLB / NPX)) + else + local block_size_x=$(((NX_GLB / NPX) + 1)) + fi + if (($((NY_GLB % NPY)) == 0)); then + local block_size_y=$((NY_GLB / NPY)) + else + local block_size_y=$(((NY_GLB / NPY) + 1)) + fi -local sec stepsperhr npt -sec=$(to_seconds "${current_cycle:8:2}0000") -stepsperhr=$((3600/ICETIM)) -npt=$((FHMAX*stepsperhr)) # Need this in order for dump_last to work + local sec stepsperhr npt + sec=$(to_seconds "${current_cycle:8:2}0000") + stepsperhr=$((3600 / ICETIM)) + npt=$((FHMAX * stepsperhr)) # Need this in order for dump_last to work -# Prepare local variables for use in ice_in_template from UFSWM -# The ones already defined are left commented as a reminder -# setup_nml section -local SYEAR=${current_cycle:0:4} -local SMONTH=${current_cycle:4:2} -local SDAY=${current_cycle:6:2} -local SECS=${sec} -local DT_CICE=${ICETIM} -local CICE_NPT=${npt} -local CICE_RUNTYPE=${runtype} -local CICE_RUNID="unknown" -local CICE_USE_RESTART_TIME=${use_restart_time} -local CICE_RESTART_DIR="./CICE_RESTART/" -local CICE_RESTART_FILE="cice_model.res" -local CICE_ICE_IC='cice_model.res.nc' -local CICE_RESTART_DEFLATE=0 -local CICE_RESTART_CHUNK=0,0 -local CICE_RESTART_STRIDE=-99 -local CICE_RESTART_ROOT=-99 -local CICE_RESTART_REARR="box" -local CICE_RESTART_IOTASKS=-99 -local CICE_RESTART_FORMAT="pnetcdf2" -local CICE_DUMPFREQ="y" # "h","d","m" or "y" for restarts at intervals of "hours", "days", "months" or "years" -local CICE_DUMPFREQ_N=10000 # Set this to a really large value, as cice, mom6 and cmeps restart interval is controlled by ufs.configure -local CICE_DIAGFREQ=$(( 86400 / DT_CICE )) # frequency of diagnostic output in timesteps, recommended for 1x per day -if [[ "${RUN}" == "gefs" ]]; then - local CICE_DIAGFREQ1=$((( FHOUT_ICE * 3600 )/ DT_CICE )) # Number of timesteps within FHOUT_ICE - local CICE_HISTFREQ_N="0, 0, 0, ${CICE_DIAGFREQ1}, 1" -else - local CICE_HISTFREQ_N="0, 0, ${FHOUT_ICE}, 0, 1" -fi -local CICE_hist_suffix="'x','x','x','x','x'" -if [[ "${RUN}" =~ "gdas" ]]; then - local CICE_HIST_AVG=".false., .false., .false., .false., .false." # DA needs instantaneous -else - local CICE_HIST_AVG=".true., .true., .true., .true., .true." # GFS long forecaset wants averaged over CICE_HISTFREQ_N -fi -local CICE_HISTORY_FORMAT="pnetcdf2" -local CICE_HISTORY_DIR="./CICE_OUTPUT/" -local CICE_INCOND_DIR="./CICE_OUTPUT/" -local CICE_HISTORY_IOTASKS=-99 -local CICE_HISTORY_REARR="box" -local CICE_HISTORY_ROOT=-99 -local CICE_HISTORY_STRIDE=-99 -local CICE_HISTORY_CHUNK=0,0 -local CICE_HISTORY_DEFLATE=0 -local CICE_HISTORY_PREC=4 -# grid_nml section -# CICE_GRID -# CICE_MASK -local CICE_GRIDATM="A" # A-grid for atmosphere (FV3) -local CICE_GRIDOCN="A" # A-grid for ocean (MOM6) -local CICE_GRIDICE="B" # B-grid for seaice (CICE6) -# tracer_nml section -local CICE_TR_POND_LVL=".true." # Use level melt ponds -# (if CICE_TR_POND_LVL=true): - # -- if true, initialize the level ponds from restart (if runtype=continue) - # -- if false, re-initialize level ponds to zero (if runtype=initial or continue) -local CICE_RESTART_POND_LVL=".false." # Restart level ponds from restart file (if runtype=continue) -# thermo_nml section -local CICE_KTHERM=2 # 0=zero-layer thermodynamics, 1=fixed-salinity profile, 2=mushy thermodynamics -# dynamics_nml section -# NONE -# shortwave_nml section -# NONE -# ponds_nml section -# NONE -# snow_nml section -# NONE -# forcing_nml section -local CICE_FRAZIL_FWSALT=${FRAZIL_FWSALT:-".true."} -local CICE_TFREEZE_OPTION=${tfrz_option:-"mushy"} -# domain_nml section -local CICE_NPROC=${ntasks_cice6} -# NX_GLB -# NY_GLB -local CICE_BLCKX=${block_size_x} -local CICE_BLCKY=${block_size_y} -local CICE_DECOMP=${processor_shape} -# ice_prescribed_nml section -local CICE_PRESCRIBED="false" -local MESH_DICE="none" -local stream_files_dice="none" + # Prepare local variables for use in ice_in_template from UFSWM + # The ones already defined are left commented as a reminder + # setup_nml section + local SYEAR=${current_cycle:0:4} + local SMONTH=${current_cycle:4:2} + local SDAY=${current_cycle:6:2} + local SECS=${sec} + local DT_CICE=${ICETIM} + local CICE_NPT=${npt} + local CICE_RUNTYPE=${runtype} + local CICE_RUNID="unknown" + local CICE_USE_RESTART_TIME=${use_restart_time} + local CICE_RESTART_DIR="./CICE_RESTART/" + local CICE_RESTART_FILE="cice_model.res" + local CICE_ICE_IC='cice_model.res.nc' + local CICE_RESTART_DEFLATE=0 + local CICE_RESTART_CHUNK=0,0 + local CICE_RESTART_STRIDE=-99 + local CICE_RESTART_ROOT=-99 + local CICE_RESTART_REARR="box" + local CICE_RESTART_IOTASKS=-99 + local CICE_RESTART_FORMAT="pnetcdf2" + local CICE_DUMPFREQ="y" # "h","d","m" or "y" for restarts at intervals of "hours", "days", "months" or "years" + local CICE_DUMPFREQ_N=10000 # Set this to a really large value, as cice, mom6 and cmeps restart interval is controlled by ufs.configure + local CICE_DIAGFREQ=$((86400 / DT_CICE)) # frequency of diagnostic output in timesteps, recommended for 1x per day + if [[ "${RUN}" == "gefs" ]]; then + local CICE_DIAGFREQ1=$(((FHOUT_ICE * 3600) / DT_CICE)) # Number of timesteps within FHOUT_ICE + local CICE_HISTFREQ_N="0, 0, 0, ${CICE_DIAGFREQ1}, 1" + else + local CICE_HISTFREQ_N="0, 0, ${FHOUT_ICE}, 0, 1" + fi + local CICE_hist_suffix="'x','x','x','x','x'" + if [[ "${RUN}" =~ "gdas" ]]; then + local CICE_HIST_AVG=".false., .false., .false., .false., .false." # DA needs instantaneous + else + local CICE_HIST_AVG=".true., .true., .true., .true., .true." # GFS long forecaset wants averaged over CICE_HISTFREQ_N + fi + local CICE_HISTORY_FORMAT="pnetcdf2" + local CICE_HISTORY_DIR="./CICE_OUTPUT/" + local CICE_INCOND_DIR="./CICE_OUTPUT/" + local CICE_HISTORY_IOTASKS=-99 + local CICE_HISTORY_REARR="box" + local CICE_HISTORY_ROOT=-99 + local CICE_HISTORY_STRIDE=-99 + local CICE_HISTORY_CHUNK=0,0 + local CICE_HISTORY_DEFLATE=0 + local CICE_HISTORY_PREC=4 + # grid_nml section + # CICE_GRID + # CICE_MASK + local CICE_GRIDATM="A" # A-grid for atmosphere (FV3) + local CICE_GRIDOCN="A" # A-grid for ocean (MOM6) + local CICE_GRIDICE="B" # B-grid for seaice (CICE6) + # tracer_nml section + local CICE_TR_POND_LVL=".true." # Use level melt ponds + # (if CICE_TR_POND_LVL=true): + # -- if true, initialize the level ponds from restart (if runtype=continue) + # -- if false, re-initialize level ponds to zero (if runtype=initial or continue) + local CICE_RESTART_POND_LVL=".false." # Restart level ponds from restart file (if runtype=continue) + # thermo_nml section + local CICE_KTHERM=2 # 0=zero-layer thermodynamics, 1=fixed-salinity profile, 2=mushy thermodynamics + # dynamics_nml section + # NONE + # shortwave_nml section + # NONE + # ponds_nml section + # NONE + # snow_nml section + # NONE + # forcing_nml section + local CICE_FRAZIL_FWSALT=${FRAZIL_FWSALT:-".true."} + local CICE_TFREEZE_OPTION=${tfrz_option:-"mushy"} + # domain_nml section + local CICE_NPROC=${ntasks_cice6} + # NX_GLB + # NY_GLB + local CICE_BLCKX=${block_size_x} + local CICE_BLCKY=${block_size_y} + local CICE_DECOMP=${processor_shape} + # ice_prescribed_nml section + local CICE_PRESCRIBED="false" + local MESH_DICE="none" + local stream_files_dice="none" + # Ensure the template exists + local template=${CICE_TEMPLATE:-"${PARMgfs}/ufs/ice_in.IN"} + if [[ ! -f "${template}" ]]; then + echo "FATAL ERROR: template '${template}' does not exist, ABORT!" + exit 1 + fi + rm -f "${DATA}/ice_in" + atparse < "${template}" >> "${DATA}/ice_in" + echo "Rendered ice_in:" + cat "${DATA}/ice_in" - -# Ensure the template exists -local template=${CICE_TEMPLATE:-"${PARMgfs}/ufs/ice_in.IN"} -if [[ ! -f "${template}" ]]; then - echo "FATAL ERROR: template '${template}' does not exist, ABORT!" - exit 1 -fi -rm -f "${DATA}/ice_in" -atparse < "${template}" >> "${DATA}/ice_in" -echo "Rendered ice_in:" -cat "${DATA}/ice_in" - -# Create a ice.restart_file when runtype is "continue" -# This file is not needed when runtype is "initial" -rm -f "${DATA}/ice.restart_file" -if [[ "${runtype}" == "continue" ]]; then - echo "${DATA}/cice_model.res.nc" > "${DATA}/ice.restart_file" -fi + # Create a ice.restart_file when runtype is "continue" + # This file is not needed when runtype is "initial" + rm -f "${DATA}/ice.restart_file" + if [[ "${runtype}" == "continue" ]]; then + echo "${DATA}/cice_model.res.nc" > "${DATA}/ice.restart_file" + fi } diff --git a/ush/parsing_namelists_FV3.sh b/ush/parsing_namelists_FV3.sh index 4b6bfff80fe..dfdfecacb52 100755 --- a/ush/parsing_namelists_FV3.sh +++ b/ush/parsing_namelists_FV3.sh @@ -4,495 +4,495 @@ # Disable variable not used warnings # shellcheck disable=SC2034 -FV3_namelists(){ - -# setup the tables -DIAG_TABLE=${DIAG_TABLE:-${PARMgfs}/ufs/fv3/diag_table} -DIAG_TABLE_APPEND=${DIAG_TABLE_APPEND:-${PARMgfs}/ufs/fv3/diag_table_aod} -DATA_TABLE=${DATA_TABLE:-${PARMgfs}/ufs/MOM6_data_table.IN} -FIELD_TABLE=${FIELD_TABLE:-${PARMgfs}/ufs/fv3/field_table} - -# set cdmbgwd -if (( gwd_opt == 2 )) && [[ ${do_gsl_drag_ls_bl} == ".true." ]]; then - cdmbgwd=${cdmbgwd_gsl} -fi - -# ensure non-prognostic tracers are set -dnats=${dnats:-0} - -# build the diag_table -{ -echo "UFS_Weather_Model_Forecast" -if [[ "${DOIAU}" = "YES" ]]; then - echo "${previous_cycle:0:4} ${previous_cycle:4:2} ${previous_cycle:6:2} ${previous_cycle:8:2} 0 0" -else - echo "${current_cycle:0:4} ${current_cycle:4:2} ${current_cycle:6:2} ${current_cycle:8:2} 0 0" -fi -cat "${DIAG_TABLE}" -if [[ -n "${AERO_DIAG_TABLE:-}" ]]; then - cat "${AERO_DIAG_TABLE}" -fi -cat "${DIAG_TABLE_APPEND}" -} >> diag_table_template - -local template=diag_table_template -local SYEAR=${current_cycle:0:4} -local SMONTH=${current_cycle:4:2} -local SDAY=${current_cycle:6:2} -local CHOUR=${current_cycle:8:2} -local MOM6_OUTPUT_DIR="./MOM6_OUTPUT" - -atparse < "${template}" >> "diag_table" - - -# copy data table -cpreq "${DATA_TABLE}" data_table - -# build field_table -if [[ -n "${AERO_FIELD_TABLE:-}" ]]; then - nrec=$(wc -l < "${FIELD_TABLE}") - prec=${nrec} - if (( dnats > 0 )); then - prec=$( grep -F -n TRACER "${FIELD_TABLE}" 2> /dev/null | tail -n "${dnats}" | head -1 | cut -d: -f1 ) - prec=${prec:-0} - prec=$(( prec > 0 ? prec - 1 : prec )) - fi - { \ - head -n "${prec}" "${FIELD_TABLE}" ; \ - cat "${AERO_FIELD_TABLE}" ; \ - tail -n $(( nrec - prec )) "${FIELD_TABLE}" ; \ - } > field_table - # add non-prognostic tracers from additional table - dnats=$(( dnats + dnats_aero )) -else - cpreq "${FIELD_TABLE}" field_table -fi - -# Set variables for global_control.nml template - -local BLOCKSIZE=${blocksize} -local CHKSUM_DEBUG=${chksum_debug} -local DYCORE_ONLY=${dycore_only} -local CCPP_SUITE=${CCPP_SUITE} - -local MAX_OUTPUT_FIELDS=300 - -local DOMAINS_STACK_SIZE=${domains_stack_size:-3000000} -local PRINT_MEMORY_USAGE=${print_memory_usage:-".false."} - -local INPES=${layout_x} -local JNPES=${layout_y} -local IO_LAYOUT=${io_layout} -local NPX=${npx} -local NPY=${npy} -local NTILES=${ntiles} -local NPZ=${npz} -local DZ_MIN=${dz_min:-"6"} -local PSM_BC=${psm_bc:-"0"} -local MAKE_NH=${make_nh} -local FV_DEBUG=${fv_debug:-".false."} -local RANGE_WARN=${range_warn:-".true."} -local N_SPONGE=${n_sponge:-"10"} -local NUDGE_QV=${nudge_qv:-".false."} -local NUDGE_DZ=${nudge_dz:-".false."} -local TAU=${tau:-10.} -local FAST_TAU_W_SEC=${fast_tau_w_sec:-"0.2"} -local RF_CUTOFF=${rf_cutoff:-"7.5e2"} -local D2_BG_K1=${d2_bg_k1:-"0.15"} -local D2_BG_K2=${d2_bg_k2:-"0.02"} -local KORD_TM=${kord_tm:-"-9"} -local KORD_MT=${kord_mt:-"9"} -local KORD_WZ=${kord_wz:-"9"} -local KORD_TR=${kord_tr:-"9"} -local HYDROSTATIC=${hydrostatic} -local PHYS_HYDROSTATIC=${phys_hydrostatic} -local USE_HYDRO_PRESSURE=${use_hydro_pressure} -local UPDATE_FULL_OMEGA=${pass_full_omega_to_physics_in_non_hydrostatic_mode:-".false."} -local K_SPLIT=${k_split} -local N_SPLIT=${n_split} -local NWAT=${nwat:-2} -local NA_INIT=${na_init} -local DNATS=${dnats} -local FV_SG_ADJ=${fv_sg_adj:-"450"} -local NORD=${nord:-3} -local DDDMP=${dddmp:-0.1} -local D4_BG=${d4_bg:-0.15} -local VTDM4=${vtdm4} -local DELT_MAX=${delt_max:-"0.002"} -local DO_VORT_DAMP=${do_vort_damp} -local EXTERNAL_IC=${external_ic} -local EXTERNAL_ETA=${external_eta:-.true.} -local GFS_PHIL=${gfs_phil:-".false."} -local NGGPS_IC=${nggps_ic} -local MOUNTAIN=${mountain} -local NCEP_IC=${ncep_ic} -local D_CON=${d_con} -local HORD_MT=${hord_mt} -local HORD_VT=${hord_xx} -local HORD_TM=${hord_xx} -local HORD_DP=${hord_dp} -local HORD_TR=${hord_tr:-"8"} -local ADJUST_DRY_MASS=${adjust_dry_mass:-".true."} -local DRY_MASS=${dry_mass:-98320.0} -local CONSV_TE=${consv_te} -local DO_SAT_ADJ=${do_sat_adj:-".false."} -local PRINT_FREQ=${print_freq} -local WARM_START=${warm_start} -local NO_DYCORE=${no_dycore} -local AGRID_VEL_RST=${agrid_vel_rst:-".true."} -local READ_INCREMENT=${read_increment} -local RES_LATLON_DYNAMICS=${res_latlon_dynamics} -local ATM_IGNORE_RST_CKSUM=.false. -local INCREMENT_FILE_ON_NATIVE_GRID=${increment_file_on_native_grid:-.false.} - -local FILTERED_TERRAIN=${filtered_terrain} -local NPZP=${LEVS} #levp -local GFS_DWINDS=${gfs_dwinds} - -local FHZERO=${FHZERO:-6} -local H2O_PHYS=${h2o_phys:-".true."} -local LDIAG3D=${ldiag3d:-".false."} -local QDIAG3D=${qdiag3d:-".false."} -local PRINT_DIFF_PGR=${print_diff_pgr:-".false."} -local FHCYC=${FHCYC} -local USE_UFO=${use_ufo:-".true."} -local PRE_RAD=${pre_rad:-".false."} -local IMP_PHYSICS=${imp_physics:-"99"} - -local default_dt_inner=$(( DELTIM/2 )) -local IOVR=${iovr:-"3"} -local LTAEROSOL=${ltaerosol:-".false."} -local MRAEROSOL=.false. -local LTHAILAWARE=.false. -local LRADAR=${lradar:-".true."} -local TTENDLIM=${ttendlim:-"-999"} -local DT_INNER=${dt_inner:-"${default_dt_inner}"} -local SEDI_SEMI=${sedi_semi:-".true."} -local DECFL=${decfl:-"10"} -local OZ_PHYS_NEW=${oz_phys:-".false."} -local OZ_PHYS_OLD=${oz_phys_2015:-".true."} -local LSOIL_LSM=${lsoil_lsm:-"4"} -local DO_MYNNEDMF=${do_mynnedmf:-".false."} -local DO_MYNNSFCLAY=${do_mynnsfclay:-".false."} -local ICLOUD_BL=${icloud_bl:-"1"} -local BL_MYNN_EDMF=${bl_mynn_edmf:-"1"} -local BL_MYNN_TKEADVECT=${bl_mynn_tkeadvect:-".true."} -local BL_MYNN_EDMF_MOM=${bl_mynn_edmf_mom:-"1"} -local TTE_EDMF=${tte_edmf:-".false."} -local CSCALE=${cscale:-"1.0"} -local DO_NGW_EC=${do_ngw_ec:-".false."} -local DO_UGWP=${do_ugwp:-".false."} -local DO_TOFD=${do_tofd:-".false."} -local GWD_OPT=${gwd_opt:-"2"} -local DO_UGWP_V0=${do_ugwp_v0:-".false."} -local DO_UGWP_V1=${do_ugwp_v1:-".true."} -local DO_UGWP_V0_OROG_ONLY=${do_ugwp_v0_orog_only:-".false."} -local DO_UGWP_V0_NST_ONLY=${do_ugwp_v0_nst_only:-".false."} -local DO_GSL_DRAG_LS_BL=${do_gsl_drag_ls_bl:-".true."} -local DO_GSL_DRAG_SS=${do_gsl_drag_ss:-".true."} -local DO_GSL_DRAG_TOFD=${do_gsl_drag_tofd:-".true."} -local DO_GWD_OPT_PSL=${do_gwd_opt_psl:-".false."} -local DO_UGWP_V1_OROG_ONLY=${do_ugwp_v1_orog_only:-".false."} -local MIN_LAKEICE=${min_lakeice:-"0.15"} -local MIN_SEAICE=${min_seaice:-"0.15"} -local USE_CICE_ALB=${use_cice_alb:-".false."} - -local PDFCLD=${pdfcld:-".false."} -local FHSWR=${FHSWR:-"3600."} -local FHLWR=${FHLWR:-"3600."} -local IALB=${IALB:-"1"} -local IEMS=${IEMS:-"1"} -local IAER=${IAER} -local ICLIQ_SW=${icliq_sw:-"2"} -local ICO2=${ICO2} -local ISUBC_SW=${isubc_sw:-"2"} -local ISUBC_LW=${isubc_lw:-"2"} -local ISOL=${ISOL:-"2"} -local LWHTR=${lwhtr:-".true."} -local SWHTR=${swhtr:-".true."} -local CNVGWD=${cnvgwd:-".true."} -local SHAL_CNV=${shal_cnv:-".true."} -local CAL_PRE=${cal_pre:-".true."} -local REDRAG=${redrag:-".true."} -local DSPHEAT=${dspheat:-".true."} -local HYBEDMF=${hybedmf:-".false."} -local SATMEDMF=${satmedmf:-".true."} -local ISATMEDMF=${isatmedmf:-"1"} -local LHEATSTRG=${lheatstrg:-".false."} -local LSEASPRAY=${lseaspray:-".true."} -local RANDOM_CLDS=${random_clds:-".true."} -local TRANS_TRAC=${trans_trac:-".true."} -local CNVCLD=${cnvcld:-".true."} -local XR_CNVCLD=${xr_cnvcld:-".true."} -local IMFSHALCNV=${imfshalcnv:-"2"} -local IMFDEEPCNV=${imfdeepcnv:-"2"} -local PROGSIGMA=${progsigma:-".true."} -local BETASCU=${betascu:-"8.0"} -local BETAMCU=${betamcu:-"1.0"} -local BETADCU=${betadcu:-"2.0"} -local RAS=${ras:-".false."} -local CDMBGWD=${cdmbgwd:-"3.5,0.25"} -local PSL_GWD_DX_FACTOR=${psl_gwd_dx_factor:-"6.0"} -local PRSLRD0=${prslrd0:-"0."} -local IVEGSRC=${ivegsrc:-"1"} -local ISOT=${isot:-"1"} -local LSOIL=${lsoil:-"4"} -local LSM=${lsm:-"2"} -local IOPT_DVEG=${iopt_dveg:-"1"} -local IOPT_CRS=${iopt_crs:-"1"} -local IOPT_BTR=${iopt_btr:-"1"} -local IOPT_RUN=${iopt_run:-"1"} -local IOPT_SFC=${iopt_sfc:-"1"} -local IOPT_TRS=${iopt_trs:-"2"} -local IOPT_DIAG=${iopt_diag:-"2"} -local IOPT_FRZ=${iopt_frz:-"1"} -local IOPT_INF=${iopt_inf:-"1"} -local IOPT_RAD=${iopt_rad:-"1"} -local IOPT_ALB=${iopt_alb:-"2"} -local IOPT_SNF=${iopt_snf:-"4"} -local IOPT_TBOT=${iopt_tbot:-"2"} -local IOPT_STC=${iopt_stc:-"1"} -local DEBUG=${gfs_phys_debug:-".false."} -local NSTF_NAME=${nstf_name} -local NST_ANL=${nst_anl} -local PSAUTCO=${psautco:-"0.0008,0.0005"} -local PRAUTCO=${prautco:-"0.00015,0.00015"} -local LGFDLMPRAD=${lgfdlmprad:-".false."} -local EFFR_IN=${effr_in:-".false."} -local LDIAG_UGWP=${ldiag_ugwp:-".false."} -local DO_RRTMGP=${do_RRTMGP:-".false."} -local ACTIVE_GASES=${active_gases:-"'h2o_co2_o3_n2o_ch4_o2'"} -local NGASES=${ngases:-"6"} -local LW_FILE_GAS=${lw_file_gas:-"'rrtmgp-data-lw-g128-210809.nc'"} -local LW_FILE_CLOUDS=${lw_file_clouds:-"'rrtmgp-cloud-optics-coeffs-lw.nc'"} -local SW_FILE_GAS=${sw_file_gas:-"'rrtmgp-data-sw-g112-210809.nc'"} -local SW_FILE_CLOUDS=${sw_file_clouds:-"'rrtmgp-cloud-optics-coeffs-sw.nc'"} -local RRTMGP_NGPTSSW=${rrtmgp_nGptsSW:-"112"} -local RRTMGP_NGPTSLW=${rrtmgp_nGptsLW:-"128"} -local RRTMGP_NBANDSLW=${rrtmgp_nBandsLW:-"16"} -local RRTMGP_NBANDSSW=${rrtmgp_nBandsSW:-"14"} -local DOGP_CLDOPTICS_LUT=${doGP_cldoptics_LUT:-".false."} -local DOGP_LWSCAT=${doGP_lwscat:-".false."} -local DOGP_SGS_CNV=.true. - -local DO_SPPT=${do_sppt:-".false."} -local DO_SHUM=${do_shum:-".false."} -local DO_SKEB=${do_skeb:-".false."} -local FRAC_GRID=${FRAC_GRID:-".true."} -local CPLCHM=${cplchm:-".false."} -local CPLFLX=${cplflx:-".false."} -local CPLICE=${cplice:-".false."} -local CPLWAV=${cplwav:-".false."} -local CPLWAV2ATM=${cplwav2atm:-".false."} -local USE_MED_FLUX=${use_med_flux:-".false."} -local CPLLND=${cpllnd:-".false."} -local CPLLND2ATM=${cpllnd2atm:-".false."} -local USE_OCEANUV=${use_oceanuv:-".false."} - -# CPL CHM options -if [[ ${cplchm} = ".true." ]]; then - local FSCAV_AERO=${fscav_aero:-'*:0.0'} -else - local FSCAV_AERO='"*:0.3","so2:0.0","msa:0.0","dms:0.0","nh3:0.4","nh4:0.6","bc1:0.6","bc2:0.6","oc1:0.4","oc2:0.4","dust1:0.6","dust2:0.6","dust3:0.6","dust4:0.6","dust5:0.6","seas1:0.5","seas2:0.5","seas3:0.5","seas4:0.5","seas5:0.5"' -fi - -local IAUFHRS=${IAUFHRS} -local IAU_DELTHRS=${IAU_DELTHRS} -local IAU_INC_FILES=${IAU_INC_FILES:-"''"} -local IAU_DRYMASSFIXER=.false. -local IAU_FILTER_INCREMENTS=${IAU_FILTER_INCREMENTS:-".false."} - -# CA options -local DO_CA=".true." -local CA_GLOBAL=${ca_global:-".false."} -local CA_SGS=${ca_sgs:-".true."} -local NCA=${nca:-"1"} -local NCELLS=${ncells:-"5"} -local NLIVES=${nlives:-"12"} -local NSEED=${nseed:-"1"} -local NFRACSEED=${nfracseed:-"0.5"} -local NTHRESH=${nthresh:-"18"} -local CA_TRIGGER=${ca_trigger:-".true."} -local NSPINUP=${nspinup:-"1"} -local ISEED_CA=${ISEED_CA:-"12345"} - -# Land pert options -local LNDP_TYPE=${lndp_type:-2} -local N_VAR_LNDP=${n_var_lndp:-0} - -local LCNORM=${lcnorm:-".false."} -local PERT_MP=${PERT_MP:-".false."} -local PERT_RADTEND=${PERT_RADTEND:-".false."} -local PERT_CLDS=${PERT_CLDS:-".false."} - -if [[ ${DO_SPPT} = ".true." ]]; then - local PERT_CLDS=".true." -fi - -if [[ "${DOIAU}" = "YES" ]]; then - local HIDE_AIAU=" " -else - local HIDE_AIAU="!" -fi - -#GWP options -if [[ ${knob_ugwp_version} -eq 0 ]]; then - local HIDE_UGWPV0=" " - local HIDE_UGWPV1="!" -elif [[ ${knob_ugwp_version} -eq 1 ]]; then - local HIDE_UGWPV0="!" - local HIDE_UGWPV1=" " -else - local HIDE_UGWPV0="!" - local HIDE_UGWPV1="!" -fi - -# Common GWP options -local KNOB_UGWP_SOLVER=${knob_ugwp_solver:-2} -local KNOB_UGWP_SOURCE=${knob_ugwp_source:-1,1,0,0} -local KNOB_UGWP_WVSPEC=${knob_ugwp_wvspec:-1,25,25,25} -local KNOB_UGWP_AZDIR=${knob_ugwp_azdir:-2,4,4,4} -local KNOB_UGWP_STOCH=${knob_ugwp_stoch:-0,0,0,0} -local KNOB_UGWP_EFFAC=${knob_ugwp_effac:-1,1,1,1} -local KNOB_UGWP_DOAXYZ=${knob_ugwp_doaxyz:-1} -local KNOB_UGWP_DOHEAT=${knob_ugwp_doheat:-1} -# UGWP Version 0 options -local KNOB_UGWP_DOKDIS=${knob_ugwp_dokdis:-1} -local KNOB_UGWP_NDX4LH=${knob_ugwp_ndx4lh:-1} -local KNOB_UGWP_VERSION=${knob_ugwp_version:-0} -local LAUNCH_LEVEL=${launch_level:-54} -# UGWP Version 1 options -local KNOB_UGWP_DOKDIS=${knob_ugwp_dokdis:-2} -local KNOB_UGWP_NDX4LH=${knob_ugwp_ndx4lh:-4} -local KNOB_UGWP_VERSION=${knob_ugwp_version:-1} -local KNOB_UGWP_PALAUNCH=${knob_ugwp_palaunch:-275.0e2} -local KNOB_UGWP_NSLOPE=${knob_ugwp_nslope:-1} -local KNOB_UGWP_LZMAX=${knob_ugwp_lzmax:-15.750e3} -local KNOB_UGWP_LZMIN=${knob_ugwp_lzmin:-0.75e3} -local KNOB_UGWP_LZSTAR=${knob_ugwp_lzstar:-2.0e3} -local KNOB_UGWP_TAUMIN=${knob_ugwp_taumin:-0.25e-3} -local KNOB_UGWP_TAUAMP=${knob_ugwp_tauamp:-3.0e-3} -local KNOB_UGWP_LHMET=${knob_ugwp_lhmet:-200.0e3} -local KNOB_UGWP_OROSOLV=${knob_ugwp_orosolv:-\'pss-1986\'} - -# gfdl_cloud_microphysics options -local REIFLAG=${reiflag:-"2"} - -# interpolator_nml options - -# nam sfc options -local FNGLAC="'${FNGLAC}'" -local FNMXIC="'${FNMXIC}'" -local FNTSFC="'${FNTSFC}'" -local FNSNOC="'${FNSNOC}'" -local FNZORC="'${FNZORC}'" -local FNALBC="'${FNALBC}'" -local FNALBC2="'${FNALBC2}'" -local FNAISC="'${FNAISC}'" -local FNTG3C="'${FNTG3C}'" -local FNVEGC="'${FNVEGC}'" -local FNVETC="'${FNVETC}'" -local FNSOTC="'${FNSOTC}'" -local FNSOCC="'${FNSOCC}'" -local FNSMCC="'${FNSMCC}'" -local FNMSKH="'${FNMSKH}'" -local FNTSFA="'${FNTSFA}'" -local FNACNA="'${FNACNA:-}'" -local FNSNOA="'${FNSNOA:-}'" -local FNVMNC="'${FNVMNC:-}'" -local FNVMXC="'${FNVMXC:-}'" -local FNSLPC="'${FNSLPC:-}'" -local FNABSC="'${FNABSC:-}'" -local LDEBUG=${LDEBUG:-".false."} -local FSMCL2=${FSMCL2:+\'${FSMCL2}\'}${FSMCL2:-99999} -local FSMCL3=${FSMCL3:+\'${FSMCL3}\'}${FSMCL3:-99999} -local FSMCL4=${FSMCL4:+\'${FSMCL4}\'}${FSMCL4:-99999} -local LANDICE=${landice:-".true."} -local FTSFS=${FTSFS:-90} -local FAISL=${FAISL:+\'${FAISL}\'}${FAISL:-99999} -local FAISS=${FAISS:+\'${FAISS}\'}${FAISS:-99999} -local FSNOL=${FSNOL:+\'${FSNOL}\'}${FSNOL:-99999} -local FSNOS=${FSNOS:+\'${FSNOS}\'}${FSNOS:-99999} -local FSICL=${FSICL:-99999} -local FSICS=${FSICS:-99999} -local FTSFL=${FTSFL:+\'${FTSFL}\'}${FTSFL:-99999} -local FVETL=${FVETL:+\'${FVETL}\'}${FVETL:-99999} -local FSOTL=${FSOTL:+\'${FSOTL}\'}${FSOTL:-99999} -local FVMNL=${FvmnL:+\'${FvmnL}\'}${FvmnL:-99999} -local FVMXL=${FvmxL:+\'${FvmxL}\'}${FvmxL:-99999} -local FSLPL=${FSLPL:+\'${FSLPL}\'}${FSLPL:-99999} -local FABSL=${FABSL:+\'${FABSL}\'}${FABSL:-99999} -local FNTSFA="'${FNTSFA:-}'" - -#fv_grid_nml options - -#nam stochy options -local NEW_LSCALE=${new_lscale:-".false."} -local STOCHINI=${stochini:-".false."} -local SKEB=${SKEB:-0} -local ISEED_SKEB=${ISEED_SKEB:-${ISEED}} -local SKEB_TAU=${SKEB_TAU:-"-999."} -local SKEB_LSCALE=${SKEB_LSCALE:-"-999."} -local SKEBNORM=${SKEBNORM:-"1"} -local SKEB_NPASS=${SKEB_NPASS:-"30"} -local SKEB_VDOF=${SKEB_VDOF:-"5"} -local SKEBINT=${SKEBINT:-"0"} -local SHUM=${SHUM:-"-999."} -local ISEED_SHUM=${ISEED_SHUM:-${ISEED}} -local SHUM_TAU=${SHUM_TAU:-"-999."} -local SHUM_LSCALE=${SHUM_LSCALE:-"-999."} -local SHUMINT=${SHUMINT:-"0"} -local SPPT=${SPPT:-"-999."} -local ISEED_SPPT=${ISEED_SPPT:-${ISEED}} -local SPPT_TAU=${SPPT_TAU:-"-999."} -local SPPT_LSCALE=${SPPT_LSCALE:-"-999."} -local SPPT_LOGIT=${SPPT_LOGIT:-".true."} -local SPPT_SFCLIMIT=${SPPT_SFCLIMIT:-".true."} -local USE_ZMTNBLCK=${use_zmtnblck:-".true."} -local SPPTINT=${SPPTINT:-"0"} -local PBL_TAPER=${pbl_taper:-"0,0,0,0.125,0.25,0.5,0.75"} -local OCNSPPT=${OCNSPPT:-"0.8,0.4,0.2,0.08,0.04"} -local OCNSPPT_LSCALE=${OCNSPPT_LSCALE:-"500.E3,1000.E3,2000.E3,2000.E3,2000.E3"} -local OCNSPPT_TAU=${OCNSPPT_TAU:-"2.16E4,2.592E5,2.592E6,7.776E6,3.1536E7"} -local ISEED_OCNSPPT=${ISEED_OCNSPPT:-${ISEED}} -local EPBL=${EPBL:-"0.8,0.4,0.2,0.08,0.04"} -local EPBL_LSCALE=${EPBL_LSCALE:-"500.E3,1000.E3,2000.E3,2000.E3,2000.E3"} -local EPBL_TAU=${EPBL_TAU:-"2.16E4,2.592E5,2.592E6,7.776E6,3.1536E7"} -local ISEED_EPBL=${ISEED_EPBL:-${ISEED}} -local LNDP_TYPE=${lndp_type:-"0"} -local LNDP_MODEL_TYPE=${lndp_model_type:-"0"} -local LNDP_TAU=${LNDP_TAU:-"21600"} -local LNDP_LSCALE=${LNDP_SCALE:-"500000"} -local ISEED_LNDP=${ISEED_LNDP:-${ISEED}} -local LNDP_VAR_LIST=${lndp_var_list:-"'XXX'"} -local LNDP_PRT_LIST=${lndp_prt_list:-"-999"} - -local MOM6_OUTPUT_DIR=MOM6_OUTPUT/ -local MOM6_RESTART_SETTING=${MOM6_RESTART_SETTING:-'n'} -local MOM6_RESTART_DIR=MOM6_RESTART/ - -# Land IAU defaults -local DO_LAND_IAU=${DO_LAND_IAU:-".false."} -local LAND_IAU_FHRS=${IAUFHRS} -local LAND_IAU_DELHRS=${IAU_DELTHRS} -local LAND_IAU_INC_FILES="'sfc_inc',''" -local LSOIL_INCR=${LSOIL_INCR:-2} -local LAND_IAU_FILTER_INC=".false." -local LAND_IAU_UPD_STC=".true." -local LAND_IAU_UPD_SLC=".true." -local LAND_IAU_DO_STCSMC_ADJ=".true." -local LAND_IAU_MIN_T_INC=0.0001 -local LAND_IAU_MIN_SLC_INC=0.000001 - -# Check will need to be modified in the future -# once GW is ready to add in land IAU -if [[ "${DO_LAND_IAU}" = ".true." ]]; then - local HIDE_LIAU=" " -else - local HIDE_LIAU="!" -fi - -local global_template="${HOMEgfs}/parm/ufs/global_control.nml.IN" -atparse < "${global_template}" >> "input.nml" +FV3_namelists() { + + # setup the tables + DIAG_TABLE=${DIAG_TABLE:-${PARMgfs}/ufs/fv3/diag_table} + DIAG_TABLE_APPEND=${DIAG_TABLE_APPEND:-${PARMgfs}/ufs/fv3/diag_table_aod} + DATA_TABLE=${DATA_TABLE:-${PARMgfs}/ufs/MOM6_data_table.IN} + FIELD_TABLE=${FIELD_TABLE:-${PARMgfs}/ufs/fv3/field_table} + + # set cdmbgwd + if ((gwd_opt == 2)) && [[ ${do_gsl_drag_ls_bl} == ".true." ]]; then + cdmbgwd=${cdmbgwd_gsl} + fi + + # ensure non-prognostic tracers are set + dnats=${dnats:-0} + + # build the diag_table + { + echo "UFS_Weather_Model_Forecast" + if [[ "${DOIAU}" = "YES" ]]; then + echo "${previous_cycle:0:4} ${previous_cycle:4:2} ${previous_cycle:6:2} ${previous_cycle:8:2} 0 0" + else + echo "${current_cycle:0:4} ${current_cycle:4:2} ${current_cycle:6:2} ${current_cycle:8:2} 0 0" + fi + cat "${DIAG_TABLE}" + if [[ -n "${AERO_DIAG_TABLE:-}" ]]; then + cat "${AERO_DIAG_TABLE}" + fi + cat "${DIAG_TABLE_APPEND}" + } >> diag_table_template + + local template=diag_table_template + local SYEAR=${current_cycle:0:4} + local SMONTH=${current_cycle:4:2} + local SDAY=${current_cycle:6:2} + local CHOUR=${current_cycle:8:2} + local MOM6_OUTPUT_DIR="./MOM6_OUTPUT" + + atparse < "${template}" >> "diag_table" + + # copy data table + cpreq "${DATA_TABLE}" data_table + + # build field_table + if [[ -n "${AERO_FIELD_TABLE:-}" ]]; then + nrec=$(wc -l < "${FIELD_TABLE}") + prec=${nrec} + if ((dnats > 0)); then + # shellcheck disable=SC2312 + prec=$(grep -F -n TRACER "${FIELD_TABLE}" 2> /dev/null | tail -n "${dnats}" | head -1 | cut -d: -f1) + prec=${prec:-0} + prec=$((prec > 0 ? prec - 1 : prec)) + fi + { + head -n "${prec}" "${FIELD_TABLE}" + cat "${AERO_FIELD_TABLE}" + tail -n $((nrec - prec)) "${FIELD_TABLE}" + } > field_table + # add non-prognostic tracers from additional table + dnats=$((dnats + dnats_aero)) + else + cpreq "${FIELD_TABLE}" field_table + fi + + # Set variables for global_control.nml template + + local BLOCKSIZE=${blocksize} + local CHKSUM_DEBUG=${chksum_debug} + local DYCORE_ONLY=${dycore_only} + local CCPP_SUITE=${CCPP_SUITE} + + local MAX_OUTPUT_FIELDS=300 + + local DOMAINS_STACK_SIZE=${domains_stack_size:-3000000} + local PRINT_MEMORY_USAGE=${print_memory_usage:-".false."} + + local INPES=${layout_x} + local JNPES=${layout_y} + local IO_LAYOUT=${io_layout} + local NPX=${npx} + local NPY=${npy} + local NTILES=${ntiles} + local NPZ=${npz} + local DZ_MIN=${dz_min:-"6"} + local PSM_BC=${psm_bc:-"0"} + local MAKE_NH=${make_nh} + local FV_DEBUG=${fv_debug:-".false."} + local RANGE_WARN=${range_warn:-".true."} + local N_SPONGE=${n_sponge:-"10"} + local NUDGE_QV=${nudge_qv:-".false."} + local NUDGE_DZ=${nudge_dz:-".false."} + local TAU=${tau:-10.} + local FAST_TAU_W_SEC=${fast_tau_w_sec:-"0.2"} + local RF_CUTOFF=${rf_cutoff:-"7.5e2"} + local D2_BG_K1=${d2_bg_k1:-"0.15"} + local D2_BG_K2=${d2_bg_k2:-"0.02"} + local KORD_TM=${kord_tm:-"-9"} + local KORD_MT=${kord_mt:-"9"} + local KORD_WZ=${kord_wz:-"9"} + local KORD_TR=${kord_tr:-"9"} + local HYDROSTATIC=${hydrostatic} + local PHYS_HYDROSTATIC=${phys_hydrostatic} + local USE_HYDRO_PRESSURE=${use_hydro_pressure} + local UPDATE_FULL_OMEGA=${pass_full_omega_to_physics_in_non_hydrostatic_mode:-".false."} + local K_SPLIT=${k_split} + local N_SPLIT=${n_split} + local NWAT=${nwat:-2} + local NA_INIT=${na_init} + local DNATS=${dnats} + local FV_SG_ADJ=${fv_sg_adj:-"450"} + local NORD=${nord:-3} + local DDDMP=${dddmp:-0.1} + local D4_BG=${d4_bg:-0.15} + local VTDM4=${vtdm4} + local DELT_MAX=${delt_max:-"0.002"} + local DO_VORT_DAMP=${do_vort_damp} + local EXTERNAL_IC=${external_ic} + local EXTERNAL_ETA=${external_eta:-.true.} + local GFS_PHIL=${gfs_phil:-".false."} + local NGGPS_IC=${nggps_ic} + local MOUNTAIN=${mountain} + local NCEP_IC=${ncep_ic} + local D_CON=${d_con} + local HORD_MT=${hord_mt} + local HORD_VT=${hord_xx} + local HORD_TM=${hord_xx} + local HORD_DP=${hord_dp} + local HORD_TR=${hord_tr:-"8"} + local ADJUST_DRY_MASS=${adjust_dry_mass:-".true."} + local DRY_MASS=${dry_mass:-98320.0} + local CONSV_TE=${consv_te} + local DO_SAT_ADJ=${do_sat_adj:-".false."} + local PRINT_FREQ=${print_freq} + local WARM_START=${warm_start} + local NO_DYCORE=${no_dycore} + local AGRID_VEL_RST=${agrid_vel_rst:-".true."} + local READ_INCREMENT=${read_increment} + local RES_LATLON_DYNAMICS=${res_latlon_dynamics} + local ATM_IGNORE_RST_CKSUM=.false. + local INCREMENT_FILE_ON_NATIVE_GRID=${increment_file_on_native_grid:-.false.} + + local FILTERED_TERRAIN=${filtered_terrain} + local NPZP=${LEVS} #levp + local GFS_DWINDS=${gfs_dwinds} + + local FHZERO=${FHZERO:-6} + local H2O_PHYS=${h2o_phys:-".true."} + local LDIAG3D=${ldiag3d:-".false."} + local QDIAG3D=${qdiag3d:-".false."} + local PRINT_DIFF_PGR=${print_diff_pgr:-".false."} + local FHCYC=${FHCYC} + local USE_UFO=${use_ufo:-".true."} + local PRE_RAD=${pre_rad:-".false."} + local IMP_PHYSICS=${imp_physics:-"99"} + + local default_dt_inner=$((DELTIM / 2)) + local IOVR=${iovr:-"3"} + local LTAEROSOL=${ltaerosol:-".false."} + local MRAEROSOL=.false. + local LTHAILAWARE=.false. + local LRADAR=${lradar:-".true."} + local TTENDLIM=${ttendlim:-"-999"} + local DT_INNER=${dt_inner:-"${default_dt_inner}"} + local SEDI_SEMI=${sedi_semi:-".true."} + local DECFL=${decfl:-"10"} + local OZ_PHYS_NEW=${oz_phys:-".false."} + local OZ_PHYS_OLD=${oz_phys_2015:-".true."} + local LSOIL_LSM=${lsoil_lsm:-"4"} + local DO_MYNNEDMF=${do_mynnedmf:-".false."} + local DO_MYNNSFCLAY=${do_mynnsfclay:-".false."} + local ICLOUD_BL=${icloud_bl:-"1"} + local BL_MYNN_EDMF=${bl_mynn_edmf:-"1"} + local BL_MYNN_TKEADVECT=${bl_mynn_tkeadvect:-".true."} + local BL_MYNN_EDMF_MOM=${bl_mynn_edmf_mom:-"1"} + local TTE_EDMF=${tte_edmf:-".false."} + local CSCALE=${cscale:-"1.0"} + local DO_NGW_EC=${do_ngw_ec:-".false."} + local DO_UGWP=${do_ugwp:-".false."} + local DO_TOFD=${do_tofd:-".false."} + local GWD_OPT=${gwd_opt:-"2"} + local DO_UGWP_V0=${do_ugwp_v0:-".false."} + local DO_UGWP_V1=${do_ugwp_v1:-".true."} + local DO_UGWP_V0_OROG_ONLY=${do_ugwp_v0_orog_only:-".false."} + local DO_UGWP_V0_NST_ONLY=${do_ugwp_v0_nst_only:-".false."} + local DO_GSL_DRAG_LS_BL=${do_gsl_drag_ls_bl:-".true."} + local DO_GSL_DRAG_SS=${do_gsl_drag_ss:-".true."} + local DO_GSL_DRAG_TOFD=${do_gsl_drag_tofd:-".true."} + local DO_GWD_OPT_PSL=${do_gwd_opt_psl:-".false."} + local DO_UGWP_V1_OROG_ONLY=${do_ugwp_v1_orog_only:-".false."} + local MIN_LAKEICE=${min_lakeice:-"0.15"} + local MIN_SEAICE=${min_seaice:-"0.15"} + local USE_CICE_ALB=${use_cice_alb:-".false."} + + local PDFCLD=${pdfcld:-".false."} + local FHSWR=${FHSWR:-"3600."} + local FHLWR=${FHLWR:-"3600."} + local IALB=${IALB:-"1"} + local IEMS=${IEMS:-"1"} + local IAER=${IAER} + local ICLIQ_SW=${icliq_sw:-"2"} + local ICO2=${ICO2} + local ISUBC_SW=${isubc_sw:-"2"} + local ISUBC_LW=${isubc_lw:-"2"} + local ISOL=${ISOL:-"2"} + local LWHTR=${lwhtr:-".true."} + local SWHTR=${swhtr:-".true."} + local CNVGWD=${cnvgwd:-".true."} + local SHAL_CNV=${shal_cnv:-".true."} + local CAL_PRE=${cal_pre:-".true."} + local REDRAG=${redrag:-".true."} + local DSPHEAT=${dspheat:-".true."} + local HYBEDMF=${hybedmf:-".false."} + local SATMEDMF=${satmedmf:-".true."} + local ISATMEDMF=${isatmedmf:-"1"} + local LHEATSTRG=${lheatstrg:-".false."} + local LSEASPRAY=${lseaspray:-".true."} + local RANDOM_CLDS=${random_clds:-".true."} + local TRANS_TRAC=${trans_trac:-".true."} + local CNVCLD=${cnvcld:-".true."} + local XR_CNVCLD=${xr_cnvcld:-".true."} + local IMFSHALCNV=${imfshalcnv:-"2"} + local IMFDEEPCNV=${imfdeepcnv:-"2"} + local PROGSIGMA=${progsigma:-".true."} + local BETASCU=${betascu:-"8.0"} + local BETAMCU=${betamcu:-"1.0"} + local BETADCU=${betadcu:-"2.0"} + local RAS=${ras:-".false."} + local CDMBGWD=${cdmbgwd:-"3.5,0.25"} + local PSL_GWD_DX_FACTOR=${psl_gwd_dx_factor:-"6.0"} + local PRSLRD0=${prslrd0:-"0."} + local IVEGSRC=${ivegsrc:-"1"} + local ISOT=${isot:-"1"} + local LSOIL=${lsoil:-"4"} + local LSM=${lsm:-"2"} + local IOPT_DVEG=${iopt_dveg:-"1"} + local IOPT_CRS=${iopt_crs:-"1"} + local IOPT_BTR=${iopt_btr:-"1"} + local IOPT_RUN=${iopt_run:-"1"} + local IOPT_SFC=${iopt_sfc:-"1"} + local IOPT_TRS=${iopt_trs:-"2"} + local IOPT_DIAG=${iopt_diag:-"2"} + local IOPT_FRZ=${iopt_frz:-"1"} + local IOPT_INF=${iopt_inf:-"1"} + local IOPT_RAD=${iopt_rad:-"1"} + local IOPT_ALB=${iopt_alb:-"2"} + local IOPT_SNF=${iopt_snf:-"4"} + local IOPT_TBOT=${iopt_tbot:-"2"} + local IOPT_STC=${iopt_stc:-"1"} + local DEBUG=${gfs_phys_debug:-".false."} + local NSTF_NAME=${nstf_name} + local NST_ANL=${nst_anl} + local PSAUTCO=${psautco:-"0.0008,0.0005"} + local PRAUTCO=${prautco:-"0.00015,0.00015"} + local LGFDLMPRAD=${lgfdlmprad:-".false."} + local EFFR_IN=${effr_in:-".false."} + local LDIAG_UGWP=${ldiag_ugwp:-".false."} + local DO_RRTMGP=${do_RRTMGP:-".false."} + local ACTIVE_GASES=${active_gases:-"'h2o_co2_o3_n2o_ch4_o2'"} + local NGASES=${ngases:-"6"} + local LW_FILE_GAS=${lw_file_gas:-"'rrtmgp-data-lw-g128-210809.nc'"} + local LW_FILE_CLOUDS=${lw_file_clouds:-"'rrtmgp-cloud-optics-coeffs-lw.nc'"} + local SW_FILE_GAS=${sw_file_gas:-"'rrtmgp-data-sw-g112-210809.nc'"} + local SW_FILE_CLOUDS=${sw_file_clouds:-"'rrtmgp-cloud-optics-coeffs-sw.nc'"} + local RRTMGP_NGPTSSW=${rrtmgp_nGptsSW:-"112"} + local RRTMGP_NGPTSLW=${rrtmgp_nGptsLW:-"128"} + local RRTMGP_NBANDSLW=${rrtmgp_nBandsLW:-"16"} + local RRTMGP_NBANDSSW=${rrtmgp_nBandsSW:-"14"} + local DOGP_CLDOPTICS_LUT=${doGP_cldoptics_LUT:-".false."} + local DOGP_LWSCAT=${doGP_lwscat:-".false."} + local DOGP_SGS_CNV=.true. + + local DO_SPPT=${do_sppt:-".false."} + local DO_SHUM=${do_shum:-".false."} + local DO_SKEB=${do_skeb:-".false."} + local FRAC_GRID=${FRAC_GRID:-".true."} + local CPLCHM=${cplchm:-".false."} + local CPLFLX=${cplflx:-".false."} + local CPLICE=${cplice:-".false."} + local CPLWAV=${cplwav:-".false."} + local CPLWAV2ATM=${cplwav2atm:-".false."} + local USE_MED_FLUX=${use_med_flux:-".false."} + local CPLLND=${cpllnd:-".false."} + local CPLLND2ATM=${cpllnd2atm:-".false."} + local USE_OCEANUV=${use_oceanuv:-".false."} + + # CPL CHM options + if [[ "${cplchm}" = ".true." ]]; then + local FSCAV_AERO=${fscav_aero:-'*:0.0'} + else + local FSCAV_AERO='"*:0.3","so2:0.0","msa:0.0","dms:0.0","nh3:0.4","nh4:0.6","bc1:0.6","bc2:0.6","oc1:0.4","oc2:0.4","dust1:0.6","dust2:0.6","dust3:0.6","dust4:0.6","dust5:0.6","seas1:0.5","seas2:0.5","seas3:0.5","seas4:0.5","seas5:0.5"' + fi + + local IAUFHRS=${IAUFHRS} + local IAU_DELTHRS=${IAU_DELTHRS} + local IAU_INC_FILES=${IAU_INC_FILES:-"''"} + local IAU_DRYMASSFIXER=.false. + local IAU_FILTER_INCREMENTS=${IAU_FILTER_INCREMENTS:-".false."} + + # CA options + local DO_CA=".true." + local CA_GLOBAL=${ca_global:-".false."} + local CA_SGS=${ca_sgs:-".true."} + local NCA=${nca:-"1"} + local NCELLS=${ncells:-"5"} + local NLIVES=${nlives:-"12"} + local NSEED=${nseed:-"1"} + local NFRACSEED=${nfracseed:-"0.5"} + local NTHRESH=${nthresh:-"18"} + local CA_TRIGGER=${ca_trigger:-".true."} + local NSPINUP=${nspinup:-"1"} + local ISEED_CA=${ISEED_CA:-"12345"} + + # Land pert options + local LNDP_TYPE=${lndp_type:-2} + local N_VAR_LNDP=${n_var_lndp:-0} + + local LCNORM=${lcnorm:-".false."} + local PERT_MP=${PERT_MP:-".false."} + local PERT_RADTEND=${PERT_RADTEND:-".false."} + local PERT_CLDS=${PERT_CLDS:-".false."} + + if [[ "${DO_SPPT}" = ".true." ]]; then + local PERT_CLDS=".true." + fi + + if [[ "${DOIAU}" = "YES" ]]; then + local HIDE_AIAU=" " + else + local HIDE_AIAU="!" + fi + + #GWP options + if [[ "${knob_ugwp_version}" -eq 0 ]]; then + local HIDE_UGWPV0=" " + local HIDE_UGWPV1="!" + elif [[ "${knob_ugwp_version}" -eq 1 ]]; then + local HIDE_UGWPV0="!" + local HIDE_UGWPV1=" " + else + local HIDE_UGWPV0="!" + local HIDE_UGWPV1="!" + fi + + # Common GWP options + local KNOB_UGWP_SOLVER=${knob_ugwp_solver:-2} + local KNOB_UGWP_SOURCE=${knob_ugwp_source:-1,1,0,0} + local KNOB_UGWP_WVSPEC=${knob_ugwp_wvspec:-1,25,25,25} + local KNOB_UGWP_AZDIR=${knob_ugwp_azdir:-2,4,4,4} + local KNOB_UGWP_STOCH=${knob_ugwp_stoch:-0,0,0,0} + local KNOB_UGWP_EFFAC=${knob_ugwp_effac:-1,1,1,1} + local KNOB_UGWP_DOAXYZ=${knob_ugwp_doaxyz:-1} + local KNOB_UGWP_DOHEAT=${knob_ugwp_doheat:-1} + # UGWP Version 0 options + local KNOB_UGWP_DOKDIS=${knob_ugwp_dokdis:-1} + local KNOB_UGWP_NDX4LH=${knob_ugwp_ndx4lh:-1} + local KNOB_UGWP_VERSION=${knob_ugwp_version:-0} + local LAUNCH_LEVEL=${launch_level:-54} + # UGWP Version 1 options + local KNOB_UGWP_DOKDIS=${knob_ugwp_dokdis:-2} + local KNOB_UGWP_NDX4LH=${knob_ugwp_ndx4lh:-4} + local KNOB_UGWP_VERSION=${knob_ugwp_version:-1} + local KNOB_UGWP_PALAUNCH=${knob_ugwp_palaunch:-275.0e2} + local KNOB_UGWP_NSLOPE=${knob_ugwp_nslope:-1} + local KNOB_UGWP_LZMAX=${knob_ugwp_lzmax:-15.750e3} + local KNOB_UGWP_LZMIN=${knob_ugwp_lzmin:-0.75e3} + local KNOB_UGWP_LZSTAR=${knob_ugwp_lzstar:-2.0e3} + local KNOB_UGWP_TAUMIN=${knob_ugwp_taumin:-0.25e-3} + local KNOB_UGWP_TAUAMP=${knob_ugwp_tauamp:-3.0e-3} + local KNOB_UGWP_LHMET=${knob_ugwp_lhmet:-200.0e3} + local KNOB_UGWP_OROSOLV=${knob_ugwp_orosolv:-\'pss-1986\'} + + # gfdl_cloud_microphysics options + local REIFLAG=${reiflag:-"2"} + + # interpolator_nml options + + # nam sfc options + local FNGLAC="'${FNGLAC}'" + local FNMXIC="'${FNMXIC}'" + local FNTSFC="'${FNTSFC}'" + local FNSNOC="'${FNSNOC}'" + local FNZORC="'${FNZORC}'" + local FNALBC="'${FNALBC}'" + local FNALBC2="'${FNALBC2}'" + local FNAISC="'${FNAISC}'" + local FNTG3C="'${FNTG3C}'" + local FNVEGC="'${FNVEGC}'" + local FNVETC="'${FNVETC}'" + local FNSOTC="'${FNSOTC}'" + local FNSOCC="'${FNSOCC}'" + local FNSMCC="'${FNSMCC}'" + local FNMSKH="'${FNMSKH}'" + local FNTSFA="'${FNTSFA}'" + local FNACNA="'${FNACNA:-}'" + local FNSNOA="'${FNSNOA:-}'" + local FNVMNC="'${FNVMNC:-}'" + local FNVMXC="'${FNVMXC:-}'" + local FNSLPC="'${FNSLPC:-}'" + local FNABSC="'${FNABSC:-}'" + local LDEBUG=${LDEBUG:-".false."} + local FSMCL2=${FSMCL2:+\'${FSMCL2}\'}${FSMCL2:-99999} + local FSMCL3=${FSMCL3:+\'${FSMCL3}\'}${FSMCL3:-99999} + local FSMCL4=${FSMCL4:+\'${FSMCL4}\'}${FSMCL4:-99999} + local LANDICE=${landice:-".true."} + local FTSFS=${FTSFS:-90} + local FAISL=${FAISL:+\'${FAISL}\'}${FAISL:-99999} + local FAISS=${FAISS:+\'${FAISS}\'}${FAISS:-99999} + local FSNOL=${FSNOL:+\'${FSNOL}\'}${FSNOL:-99999} + local FSNOS=${FSNOS:+\'${FSNOS}\'}${FSNOS:-99999} + local FSICL=${FSICL:-99999} + local FSICS=${FSICS:-99999} + local FTSFL=${FTSFL:+\'${FTSFL}\'}${FTSFL:-99999} + local FVETL=${FVETL:+\'${FVETL}\'}${FVETL:-99999} + local FSOTL=${FSOTL:+\'${FSOTL}\'}${FSOTL:-99999} + local FVMNL=${FvmnL:+\'${FvmnL}\'}${FvmnL:-99999} + local FVMXL=${FvmxL:+\'${FvmxL}\'}${FvmxL:-99999} + local FSLPL=${FSLPL:+\'${FSLPL}\'}${FSLPL:-99999} + local FABSL=${FABSL:+\'${FABSL}\'}${FABSL:-99999} + local FNTSFA="'${FNTSFA:-}'" + + #fv_grid_nml options + + #nam stochy options + local NEW_LSCALE=${new_lscale:-".false."} + local STOCHINI=${stochini:-".false."} + local SKEB=${SKEB:-0} + local ISEED_SKEB=${ISEED_SKEB:-${ISEED}} + local SKEB_TAU=${SKEB_TAU:-"-999."} + local SKEB_LSCALE=${SKEB_LSCALE:-"-999."} + local SKEBNORM=${SKEBNORM:-"1"} + local SKEB_NPASS=${SKEB_NPASS:-"30"} + local SKEB_VDOF=${SKEB_VDOF:-"5"} + local SKEBINT=${SKEBINT:-"0"} + local SHUM=${SHUM:-"-999."} + local ISEED_SHUM=${ISEED_SHUM:-${ISEED}} + local SHUM_TAU=${SHUM_TAU:-"-999."} + local SHUM_LSCALE=${SHUM_LSCALE:-"-999."} + local SHUMINT=${SHUMINT:-"0"} + local SPPT=${SPPT:-"-999."} + local ISEED_SPPT=${ISEED_SPPT:-${ISEED}} + local SPPT_TAU=${SPPT_TAU:-"-999."} + local SPPT_LSCALE=${SPPT_LSCALE:-"-999."} + local SPPT_LOGIT=${SPPT_LOGIT:-".true."} + local SPPT_SFCLIMIT=${SPPT_SFCLIMIT:-".true."} + local USE_ZMTNBLCK=${use_zmtnblck:-".true."} + local SPPTINT=${SPPTINT:-"0"} + local PBL_TAPER=${pbl_taper:-"0,0,0,0.125,0.25,0.5,0.75"} + local OCNSPPT=${OCNSPPT:-"0.8,0.4,0.2,0.08,0.04"} + local OCNSPPT_LSCALE=${OCNSPPT_LSCALE:-"500.E3,1000.E3,2000.E3,2000.E3,2000.E3"} + local OCNSPPT_TAU=${OCNSPPT_TAU:-"2.16E4,2.592E5,2.592E6,7.776E6,3.1536E7"} + local ISEED_OCNSPPT=${ISEED_OCNSPPT:-${ISEED}} + local EPBL=${EPBL:-"0.8,0.4,0.2,0.08,0.04"} + local EPBL_LSCALE=${EPBL_LSCALE:-"500.E3,1000.E3,2000.E3,2000.E3,2000.E3"} + local EPBL_TAU=${EPBL_TAU:-"2.16E4,2.592E5,2.592E6,7.776E6,3.1536E7"} + local ISEED_EPBL=${ISEED_EPBL:-${ISEED}} + local LNDP_TYPE=${lndp_type:-"0"} + local LNDP_MODEL_TYPE=${lndp_model_type:-"0"} + local LNDP_TAU=${LNDP_TAU:-"21600"} + local LNDP_LSCALE=${LNDP_SCALE:-"500000"} + local ISEED_LNDP=${ISEED_LNDP:-${ISEED}} + local LNDP_VAR_LIST=${lndp_var_list:-"'XXX'"} + local LNDP_PRT_LIST=${lndp_prt_list:-"-999"} + + local MOM6_OUTPUT_DIR=MOM6_OUTPUT/ + local MOM6_RESTART_SETTING=${MOM6_RESTART_SETTING:-'n'} + local MOM6_RESTART_DIR=MOM6_RESTART/ + + # Land IAU defaults + local DO_LAND_IAU=${DO_LAND_IAU:-".false."} + local LAND_IAU_FHRS=${IAUFHRS} + local LAND_IAU_DELHRS=${IAU_DELTHRS} + local LAND_IAU_INC_FILES="'sfc_inc',''" + local LSOIL_INCR=${LSOIL_INCR:-2} + local LAND_IAU_FILTER_INC=".false." + local LAND_IAU_UPD_STC=".true." + local LAND_IAU_UPD_SLC=".true." + local LAND_IAU_DO_STCSMC_ADJ=".true." + local LAND_IAU_MIN_T_INC=0.0001 + local LAND_IAU_MIN_SLC_INC=0.000001 + + # Check will need to be modified in the future + # once GW is ready to add in land IAU + if [[ "${DO_LAND_IAU}" = ".true." ]]; then + local HIDE_LIAU=" " + else + local HIDE_LIAU="!" + fi + + local global_template="${HOMEgfs}/parm/ufs/global_control.nml.IN" + atparse < "${global_template}" >> "input.nml" } diff --git a/ush/parsing_namelists_FV3_nest.sh b/ush/parsing_namelists_FV3_nest.sh index 325021e7c38..89e16efca30 100755 --- a/ush/parsing_namelists_FV3_nest.sh +++ b/ush/parsing_namelists_FV3_nest.sh @@ -5,105 +5,104 @@ # Disable variable not used warnings and 'masking return value' warnings # shellcheck disable=SC2034 # shellcheck disable=SC2312 -FV3_namelists_nest(){ - -# First argument tells us which namelist we're writing: -# global = writing input.nml for running global with a nest -# nest = writing input_nest02.nml for running the nest -namelist_mode="${1:-global}" - -if [[ "${namelist_mode}" == "nest" ]] ; then - nml_file=input_nest02.nml - only_input_nml="YES" -else - nml_file=input.nml - only_input_nml="NO" -fi - -# setup the tables -DIAG_TABLE=${DIAG_TABLE:-${PARMgfs}/ufs/fv3/diag_table} -DIAG_TABLE_APPEND=${DIAG_TABLE_APPEND:-${PARMgfs}/ufs/fv3/diag_table_aod} -DATA_TABLE=${DATA_TABLE:-${PARMgfs}/ufs/MOM6_data_table.IN} -FIELD_TABLE=${FIELD_TABLE:-${PARMgfs}/ufs/fv3/field_table} - -# set cdmbgwd -if (( gwd_opt == 2 )) && [[ ${do_gsl_drag_ls_bl} == ".true." ]]; then - cdmbgwd=${cdmbgwd_gsl} -fi - -# ensure non-prognostic tracers are set -dnats=${dnats:-0} - -if [[ "${only_input_nml:-NO}" == "NO" ]] ; then -# build the diag_table -{ -echo "UFS_Weather_Model_Forecast" -if [[ "${DOIAU}" = "YES" ]]; then - echo "${previous_cycle:0:4} ${previous_cycle:4:2} ${previous_cycle:6:2} ${previous_cycle:8:2} 0 0" -else - echo "${current_cycle:0:4} ${current_cycle:4:2} ${current_cycle:6:2} ${current_cycle:8:2} 0 0" -fi -cat "${DIAG_TABLE}" -if [[ -n "${AERO_DIAG_TABLE:-}" ]]; then - cat "${AERO_DIAG_TABLE}" -fi -cat "${DIAG_TABLE_APPEND}" -} >> diag_table_template - -local template=diag_table_template -local SYEAR=${current_cycle:0:4} -local SMONTH=${current_cycle:4:2} -local SDAY=${current_cycle:6:2} -local CHOUR=${current_cycle:8:2} -local MOM6_OUTPUT_DIR="./MOM6_OUTPUT" - -atparse < "${template}" >> "diag_table" - - -# copy data table -cpreq "${DATA_TABLE}" data_table - -# build field_table -if [[ -n "${AERO_FIELD_TABLE:-}" ]]; then - nrec=$(wc -l < "${FIELD_TABLE}") - prec=${nrec} - if (( dnats > 0 )); then - prec=$( grep -F -n TRACER "${FIELD_TABLE}" 2> /dev/null | tail -n "${dnats}" | head -1 | cut -d: -f1 ) - prec=${prec:-0} - prec=$(( prec > 0 ? prec - 1 : prec )) - fi - { \ - head -n "${prec}" "${FIELD_TABLE}" ; \ - cat "${AERO_FIELD_TABLE}" ; \ - tail -n $(( nrec - prec )) "${FIELD_TABLE}" ; \ - } > field_table - # add non-prognostic tracers from additional table - dnats=$(( dnats + dnats_aero )) -else - cpreq "${FIELD_TABLE}" field_table -fi -fi # only_input_nml - -if [[ "${namelist_mode}" == "global" ]] ; then - layout_x_here=${layout_x} - layout_y_here=${layout_y} - ntiles_here=6 - npx_here=${npx} - npy_here=${npy} - k_split_here=${k_split} -else - layout_x_here=${layout_x_nest} - layout_y_here=${layout_y_nest} - ntiles_here=1 - nested_here=.true. - twowaynest_here=${twowaynest:-.true.} - nestupdate_here=${nestupdate:-7} - npx_here=${npx_nest} - npy_here=${npy_nest} - k_split_here=${k_split_nest} -fi - -cat > "${nml_file}" <> diag_table_template + + local template=diag_table_template + local SYEAR=${current_cycle:0:4} + local SMONTH=${current_cycle:4:2} + local SDAY=${current_cycle:6:2} + local CHOUR=${current_cycle:8:2} + local MOM6_OUTPUT_DIR="./MOM6_OUTPUT" + + atparse < "${template}" >> "diag_table" + + # copy data table + cpreq "${DATA_TABLE}" data_table + + # build field_table + if [[ -n "${AERO_FIELD_TABLE:-}" ]]; then + nrec=$(wc -l < "${FIELD_TABLE}") + prec=${nrec} + if ((dnats > 0)); then + prec=$(grep -F -n TRACER "${FIELD_TABLE}" 2> /dev/null | tail -n "${dnats}" | head -1 | cut -d: -f1) + prec=${prec:-0} + prec=$((prec > 0 ? prec - 1 : prec)) + fi + { + head -n "${prec}" "${FIELD_TABLE}" + cat "${AERO_FIELD_TABLE}" + tail -n $((nrec - prec)) "${FIELD_TABLE}" + } > field_table + # add non-prognostic tracers from additional table + dnats=$((dnats + dnats_aero)) + else + cpreq "${FIELD_TABLE}" field_table + fi + fi # only_input_nml + + if [[ "${namelist_mode}" == "global" ]]; then + layout_x_here=${layout_x} + layout_y_here=${layout_y} + ntiles_here=6 + npx_here=${npx} + npy_here=${npy} + k_split_here=${k_split} + else + layout_x_here=${layout_x_nest} + layout_y_here=${layout_y_nest} + ntiles_here=1 + nested_here=.true. + twowaynest_here=${twowaynest:-.true.} + nestupdate_here=${nestupdate:-7} + npx_here=${npx_nest} + npy_here=${npy_nest} + k_split_here=${k_split_nest} + fi + + cat > "${nml_file}" << EOF &atmos_model_nml blocksize = ${blocksize} chksum_debug = ${chksum_debug} @@ -209,24 +208,24 @@ cat > "${nml_file}" <> "${nml_file}" <> "${nml_file}" << EOF do_schmidt = .true. target_lat = ${TARGET_LAT} target_lon = ${TARGET_LON} stretch_fac = ${stretch_fac} EOF -fi + fi -if [[ "${DO_NEST:-NO}" == "YES" && "${namelist_mode}" == "nest" ]] ; then - cat >> "${nml_file}" <> "${nml_file}" << EOF nested = .true. twowaynest = ${twowaynest:-.true.} ! .true. nestupdate = 7 EOF -fi + fi -cat >> "${nml_file}" <> "${nml_file}" << EOF / &external_ic_nml @@ -250,15 +249,15 @@ cat >> "${nml_file}" <> "${nml_file}" << EOF + case "${CCPP_SUITE:-}" in + "FV3_GFS_v15p2_coupled") + cat >> "${nml_file}" << EOF oz_phys = .false. oz_phys_2015 = .true. EOF - ;; - "FV3_GSD_v0") - cat >> "${nml_file}" << EOF + ;; + "FV3_GSD_v0") + cat >> "${nml_file}" << EOF iovr = ${iovr:-"3"} ltaerosol = ${ltaerosol:-".false."} lradar = ${lradar:-".false."} @@ -276,9 +275,9 @@ EOF min_seaice = ${min_seaice:-"0.15"} use_cice_alb = ${use_cice_alb:-".false."} EOF - ;; - FV3_GFS_v16_coupled*) - cat >> "${nml_file}" << EOF + ;; + FV3_GFS_v16_coupled*) + cat >> "${nml_file}" << EOF iovr = ${iovr:-"3"} ltaerosol = ${ltaerosol:-".false."} lradar = ${lradar:-".false."} @@ -294,9 +293,9 @@ EOF min_lakeice = ${min_lakeice:-"0.15"} min_seaice = ${min_seaice:-"0.15"} EOF - ;; - FV3_GFS_v16*) - cat >> "${nml_file}" << EOF + ;; + FV3_GFS_v16*) + cat >> "${nml_file}" << EOF iovr = ${iovr:-"3"} ltaerosol = ${ltaerosol:-".false."} lradar = ${lradar:-".false."} @@ -313,10 +312,10 @@ EOF min_lakeice = ${min_lakeice:-"0.15"} min_seaice = ${min_seaice:-"0.15"} EOF - ;; - FV3_GFS_v17*) - local default_dt_inner=$(( DELTIM/2 )) - cat >> "${nml_file}" << EOF + ;; + FV3_GFS_v17*) + local default_dt_inner=$((DELTIM / 2)) + cat >> "${nml_file}" << EOF iovr = ${iovr:-"3"} ltaerosol = ${ltaerosol:-".false."} lradar = ${lradar:-".true."} @@ -349,10 +348,10 @@ EOF min_seaice = ${min_seaice:-"0.15"} use_cice_alb = ${use_cice_alb:-".false."} EOF - ;; - FV3_global_nest*) - local default_dt_inner=$(( DELTIM/2 )) - cat >> "${nml_file}" << EOF + ;; + FV3_global_nest*) + local default_dt_inner=$((DELTIM / 2)) + cat >> "${nml_file}" << EOF iovr = ${iovr:-"3"} lcnorm = ${lcnorm:-".false."} ltaerosol = ${ltaerosol:-".false."} @@ -385,15 +384,15 @@ EOF min_seaice = ${min_seaice:-"0.15"} use_cice_alb = ${use_cice_alb:-".false."} EOF - ;; - *) - cat >> "${nml_file}" << EOF + ;; + *) + cat >> "${nml_file}" << EOF iovr = ${iovr:-"3"} EOF - ;; -esac + ;; + esac -cat >> "${nml_file}" <> "${nml_file}" << EOF pdfcld = ${pdfcld:-".false."} fhswr = ${FHSWR:-"3600."} fhlwr = ${FHLWR:-"3600."} @@ -471,13 +470,13 @@ cat >> "${nml_file}" <> "${nml_file}" << EOF + if [[ ${cplchm} = ".true." ]]; then + cat >> "${nml_file}" << EOF fscav_aero = ${fscav_aero:-'*:0.0'} EOF -fi + fi -cat >> "${nml_file}" <> "${nml_file}" << EOF do_sppt = ${do_sppt:-".false."} do_shum = ${do_shum:-".false."} do_skeb = ${do_skeb:-".false."} @@ -489,27 +488,27 @@ cat >> "${nml_file}" <> "${nml_file}" <> "${nml_file}" << EOF pert_mp = .false. pert_radtend = .false. pert_clds = .true. EOF -fi + fi -# Add namelist for IAU -if [[ ${DOIAU} = "YES" ]]; then - cat >> "${nml_file}" << EOF + # Add namelist for IAU + if [[ ${DOIAU} = "YES" ]]; then + cat >> "${nml_file}" << EOF iaufhrs = ${IAUFHRS} iau_delthrs = ${IAU_DELTHRS} iau_inc_files= ${IAU_INC_FILES} iau_drymassfixer = .false. iau_filter_increments = ${IAU_FILTER_INCREMENTS:-".false."} EOF -fi + fi -if [[ ${DO_CA:-"NO"} = "YES" ]]; then - cat >> "${nml_file}" << EOF + if [[ ${DO_CA:-"NO"} = "YES" ]]; then + cat >> "${nml_file}" << EOF do_ca = .true. ca_global = ${ca_global:-".false."} ca_sgs = ${ca_sgs:-".true."} @@ -523,24 +522,24 @@ if [[ ${DO_CA:-"NO"} = "YES" ]]; then nspinup = ${nspinup:-"1"} iseed_ca = ${ISEED_CA:-"12345"} EOF -fi + fi -if [[ "${DO_LAND_PERT:-NO}" == "YES" ]]; then - cat >> "${nml_file}" << EOF + if [[ "${DO_LAND_PERT:-NO}" == "YES" ]]; then + cat >> "${nml_file}" << EOF lndp_type = ${lndp_type:-2} n_var_lndp = ${n_var_lndp:-0} EOF -fi + fi -# Close &gfs_physics_nml section -cat >> "${nml_file}" << EOF + # Close &gfs_physics_nml section + cat >> "${nml_file}" << EOF / EOF -if [[ "${namelist_mode}" == "global" ]] ; then - cat >> "${nml_file}" << EOF + if [[ "${namelist_mode}" == "global" ]]; then + cat >> "${nml_file}" << EOF &fv_nest_nml - grid_pes = $(( layout_x * layout_y * 6 )),$(( layout_x_nest * layout_y_nest )) + grid_pes = $((layout_x * layout_y * 6)),$((layout_x_nest * layout_y_nest)) tile_coarse = 0,6 num_tile_top = 6 p_split = 1 @@ -549,10 +548,10 @@ if [[ "${namelist_mode}" == "global" ]] ; then nest_joffsets = 0,${nest_joffset} / EOF -fi + fi -if [[ ${knob_ugwp_version} -eq 0 ]]; then - cat >> "${nml_file}" << EOF + if [[ ${knob_ugwp_version} -eq 0 ]]; then + cat >> "${nml_file}" << EOF &cires_ugwp_nml knob_ugwp_solver = ${knob_ugwp_solver:-2} knob_ugwp_source = ${knob_ugwp_source:-1,1,0,0} @@ -568,10 +567,10 @@ if [[ ${knob_ugwp_version} -eq 0 ]]; then launch_level = ${launch_level:-54} / EOF -fi + fi -if [[ ${knob_ugwp_version} -eq 1 ]]; then - cat >> "${nml_file}" << EOF + if [[ ${knob_ugwp_version} -eq 1 ]]; then + cat >> "${nml_file}" << EOF &cires_ugwp_nml knob_ugwp_solver = ${knob_ugwp_solver:-2} knob_ugwp_source = ${knob_ugwp_source:-1,1,0,0} @@ -595,11 +594,11 @@ if [[ ${knob_ugwp_version} -eq 1 ]]; then knob_ugwp_orosolv = ${knob_ugwp_orosolv:-'pss-1986'} / EOF -fi + fi -echo "" >> "${nml_file}" + echo "" >> "${nml_file}" -cat >> "${nml_file}" <> "${nml_file}" << EOF &gfdl_cloud_microphysics_nml sedi_transport = .true. do_sedi_heat = .false. @@ -704,28 +703,28 @@ cat >> "${nml_file}" <> "${nml_file}" <> "${nml_file}" << EOF grid_file = 'INPUT/grid_spec.nc' EOF -fi + fi -cat >> "${nml_file}" <> "${nml_file}" << EOF ${fv_grid_nml:-} / EOF -# Add namelist for stochastic physics options -echo "" >> "${nml_file}" -#if [ $MEMBER -gt 0 ]; then -if [[ "${DO_SPPT}" = "YES" || "${DO_SHUM}" = "YES" || "${DO_SKEB}" = "YES" || "${DO_LAND_PERT}" = "YES" ]]; then + # Add namelist for stochastic physics options + echo "" >> "${nml_file}" + #if [[ $MEMBER -gt 0 ]]; then + if [[ "${DO_SPPT}" = "YES" || "${DO_SHUM}" = "YES" || "${DO_SKEB}" = "YES" || "${DO_LAND_PERT}" = "YES" ]]; then - cat >> "${nml_file}" << EOF + cat >> "${nml_file}" << EOF &nam_stochy EOF - if [[ ${DO_SKEB} = "YES" ]]; then - cat >> "${nml_file}" << EOF + if [[ ${DO_SKEB} = "YES" ]]; then + cat >> "${nml_file}" << EOF skeb = ${SKEB} iseed_skeb = ${ISEED_SKEB:-${ISEED}} skeb_tau = ${SKEB_TAU:-"-999."} @@ -734,19 +733,19 @@ EOF skeb_npass = ${SKEB_NPASS:-"30"} skeb_vdof = ${SKEB_VDOF:-"5"} EOF - fi + fi - if [[ ${DO_SHUM} = "YES" ]]; then - cat >> "${nml_file}" << EOF + if [[ ${DO_SHUM} = "YES" ]]; then + cat >> "${nml_file}" << EOF shum = ${SHUM} iseed_shum = ${ISEED_SHUM:-${ISEED}} shum_tau = ${SHUM_TAU:-"-999."} shum_lscale = ${SHUM_LSCALE:-"-999."} EOF - fi + fi - if [[ ${DO_SPPT} = "YES" ]]; then - cat >> "${nml_file}" << EOF + if [[ ${DO_SPPT} = "YES" ]]; then + cat >> "${nml_file}" << EOF sppt = ${SPPT} iseed_sppt = ${ISEED_SPPT:-${ISEED}} sppt_tau = ${SPPT_TAU:-"-999."} @@ -756,50 +755,50 @@ EOF use_zmtnblck = ${use_zmtnblck:-".true."} pbl_taper = ${pbl_taper:-"0,0,0,0.125,0.25,0.5,0.75"} EOF - fi + fi - if [[ "${DO_OCN_SPPT:-NO}" == "YES" ]]; then - cat >> "${nml_file}" <> "${nml_file}" << EOF OCNSPPT=${OCNSPPT} OCNSPPT_LSCALE=${OCNSPPT_LSCALE} OCNSPPT_TAU=${OCNSPPT_TAU} ISEED_OCNSPPT=${ISEED_OCNSPPT:-${ISEED}} EOF - fi + fi - if [[ "${DO_OCN_PERT_EPBL:-NO}" == "YES" ]]; then - cat >> "${nml_file}" <> "${nml_file}" << EOF EPBL=${EPBL} EPBL_LSCALE=${EPBL_LSCALE} EPBL_TAU=${EPBL_TAU} ISEED_EPBL=${ISEED_EPBL:-${ISEED}} EOF - fi + fi - if [[ "${DO_OCN_SPPT:-NO}" == "YES" ]]; then - cat >> "${nml_file}" <> "${nml_file}" << EOF OCNSPPT=${OCNSPPT} OCNSPPT_LSCALE=${OCNSPPT_LSCALE} OCNSPPT_TAU=${OCNSPPT_TAU} ISEED_OCNSPPT=${ISEED_OCNSPPT:-${ISEED}} EOF - fi + fi - if [[ "${DO_OCN_PERT_EPBL:-NO}" == "YES" ]]; then - cat >> "${nml_file}" <> "${nml_file}" << EOF EPBL=${EPBL} EPBL_LSCALE=${EPBL_LSCALE} EPBL_TAU=${EPBL_TAU} ISEED_EPBL=${ISEED_EPBL:-${ISEED}} EOF - fi + fi - cat >> "${nml_file}" << EOF + cat >> "${nml_file}" << EOF / EOF - if [[ ${DO_LAND_PERT} = "YES" ]]; then - cat >> "${nml_file}" << EOF + if [[ ${DO_LAND_PERT} = "YES" ]]; then + cat >> "${nml_file}" << EOF &nam_sfcperts lndp_type = ${lndp_type} LNDP_TAU = ${LNDP_TAU} @@ -809,27 +808,27 @@ EOF lndp_prt_list = ${lndp_prt_list} / EOF - else - cat >> "${nml_file}" << EOF + else + cat >> "${nml_file}" << EOF &nam_sfcperts / EOF - fi + fi -else + else - cat >> "${nml_file}" << EOF + cat >> "${nml_file}" << EOF &nam_stochy / &nam_sfcperts / EOF -fi + fi -# Echo out formatted ""${nml_file}"" -echo "====================================" -echo "FV3_namelists_nest(): '${nml_file}'" -cat "${nml_file}" -echo "====================================" + # Echo out formatted ""${nml_file}"" + echo "====================================" + echo "FV3_namelists_nest(): '${nml_file}'" + cat "${nml_file}" + echo "====================================" } diff --git a/ush/parsing_namelists_GOCART.sh b/ush/parsing_namelists_GOCART.sh index 2a08a90b0bc..26399356407 100755 --- a/ush/parsing_namelists_GOCART.sh +++ b/ush/parsing_namelists_GOCART.sh @@ -3,52 +3,52 @@ # Disable variable not used warnings # shellcheck disable=SC2034 GOCART_namelists() { - # copying GOCART configuration files - if [[ -n "${AERO_CONFIG_DIR}" ]]; then + # copying GOCART configuration files + if [[ -n "${AERO_CONFIG_DIR}" ]]; then - local base_in - local fhout_aero_padded - fhout_aero_padded=$(printf "%02d" "${FHOUT_AERO}") - # Only instantaneous AOD is output right now - local inst_aod_freq="${fhout_aero_padded}0000" + local base_in + local fhout_aero_padded + fhout_aero_padded=$(printf "%02d" "${FHOUT_AERO}") + # Only instantaneous AOD is output right now + local inst_aod_freq="${fhout_aero_padded}0000" - # Other gocart fields not currently used - local inst_du_ss_freq="120000" - local tavg_du_ss_freq="120000" - local inst_ca_freq="120000" - local inst_ni_freq="120000" - local inst_su_freq="120000" - local inst_du_bin_freq="010000" - local tavg_du_bin_freq="030000" - local inst_ss_bin_freq="060000" - local inst_ca_bin_freq="120000" - local inst_ni_bin_freq="120000" - local inst_su_bin_freq="120000" - local inst_2d_freq="030000" - local inst_3d_freq="060000" - local tavg_2d_rad_freq="120000" - local tavg_3d_rad_freq="120000" + # Other gocart fields not currently used + local inst_du_ss_freq="120000" + local tavg_du_ss_freq="120000" + local inst_ca_freq="120000" + local inst_ni_freq="120000" + local inst_su_freq="120000" + local inst_du_bin_freq="010000" + local tavg_du_bin_freq="030000" + local inst_ss_bin_freq="060000" + local inst_ca_bin_freq="120000" + local inst_ni_bin_freq="120000" + local inst_su_bin_freq="120000" + local inst_2d_freq="030000" + local inst_3d_freq="060000" + local tavg_2d_rad_freq="120000" + local tavg_3d_rad_freq="120000" - for template_in in "${AERO_CONFIG_DIR}/"*.rc; do - base_in="$(basename "${template_in}")" - atparse < "${template_in}" >> "${DATA}/${base_in}" - status=$? - if [[ ${status} -ne 0 ]]; then - exit "${status}" - fi - done + for template_in in "${AERO_CONFIG_DIR}/"*.rc; do + base_in="$(basename "${template_in}")" + atparse < "${template_in}" >> "${DATA}/${base_in}" + status=$? + if [[ ${status} -ne 0 ]]; then + exit "${status}" + fi + done - # attempt to generate ExtData configuration file if not provided - if [[ ! -f "${DATA}/AERO_ExtData.rc" ]]; then - { \ - echo "PrimaryExports%%" ; \ - cat "${AERO_CONFIG_DIR}/ExtData.other" ; \ - cat "${AERO_CONFIG_DIR}/ExtData.${AERO_EMIS_FIRE:-none}" ; \ - echo "%%" ; \ - } > "${DATA}/AERO_ExtData.rc" - # shellcheck disable=SC2320 - status=$? - if (( status != 0 )); then exit "${status}"; fi + # attempt to generate ExtData configuration file if not provided + if [[ ! -f "${DATA}/AERO_ExtData.rc" ]]; then + { + echo "PrimaryExports%%" + cat "${AERO_CONFIG_DIR}/ExtData.other" + cat "${AERO_CONFIG_DIR}/ExtData.${AERO_EMIS_FIRE:-none}" + echo "%%" + } > "${DATA}/AERO_ExtData.rc" + # shellcheck disable=SC2320 + status=$? + if ((status != 0)); then exit "${status}"; fi + fi fi - fi } diff --git a/ush/parsing_namelists_MOM6.sh b/ush/parsing_namelists_MOM6.sh index bb810b60f7e..b8c7293681c 100755 --- a/ush/parsing_namelists_MOM6.sh +++ b/ush/parsing_namelists_MOM6.sh @@ -2,90 +2,90 @@ # Disable variable not used warnings # shellcheck disable=SC2034 -MOM6_namelists(){ +MOM6_namelists() { -# ================================================================ -# MOM_input -# --------- -# Prepare local variables for use in MOM_input.IN from UFSWM -# The ones already defined are left commented as a reminder -# == MOM options to start from coarsed grained restarts, set to off by default -# options only available for 05 and 1 degree grids -# as restarts are coarsed grained/interpolated from the 0.25 degrees grid -local MOM6_INIT_FROM_Z=${MOM6_INIT_FROM_Z:-True} -local MOM6_WARMSTART_FILE=${MOM6_WARMSTART_FILE:-"none"} -local MOM6_INIT_UV=${MOM6_INIT_UV:-"zero"} -# == MOM_domains section == -# NX_GLB -# NY_GLB -# == MOM section == -# DT_DYNAM_MOM6 -# DT_THERM_MOM6 -# MOM6_THERMO_SPAN -# == MOM_grid_init section == -local MOM6_TOPOEDITS=${TOPOEDITS} -# MOM6_ALLOW_LANDMASK_CHANGES -# == MOM_diag_mediator section == -# MOM6_DIAG_COORD_DEF_Z_FILE -# MOM6_DIAG_MISVAL -# == MOM_diabatic_aux section == -local MOM6_CHLCLIM=${CHLCLIM} -# == MOM_energetic_PBL section == -# MOM6_USE_LI2016 -if [[ "${cplwav}" == ".true." ]] ; then - local MOM6_USE_WAVES="True" -else - local MOM6_USE_WAVES="False" -fi -# == MOM_oda_incupd section == -local ODA_TEMPINC_VAR=${ODA_TEMPINC_VAR:-"Temp"} -local ODA_SALTINC_VAR=${ODA_SALTINC_VAR:-"Salt"} -local ODA_THK_VAR=${ODA_THK_VAR:-"h"} -local ODA_INCUPD_UV="True" -local ODA_UINC_VAR=${ODA_UINC_VAR:-"u"} -local ODA_VINC_VAR=${ODA_VINC_VAR:-"v"} -# ODA_INCUPD -# ODA_INCUPD_NHOURS -# == MOM_surface_forcing section == -# MOM6_RIVER_RUNOFF -# == ocean_stochastics section == -if [[ "${DO_OCN_SPPT}" == "YES" ]]; then - local DO_OCN_SPPT="True" # TODO: This is problematic if DO_OCN_SPPT is going to be used elsewhere -else - local DO_OCN_SPPT="False" -fi -if [[ "${DO_OCN_PERT_EPBL}" == "YES" ]]; then - local PERT_EPBL="True" -else - local PERT_EPBL="False" -fi -local MOM6_HFREEZE=20.0 -# Ensure the template exists -local template=${MOM6_INPUT_TEMPLATE:-"${PARMgfs}/ufs/MOM_input_${OCNRES}.IN"} -if [[ ! -f "${template}" ]]; then - echo "FATAL ERROR: template '${template}' does not exist, ABORT!" - exit 1 -fi -rm -f "${DATA}/INPUT/MOM_input" -atparse < "${template}" >> "${DATA}/INPUT/MOM_input" -echo "Rendered MOM_input:" -cat "${DATA}/INPUT/MOM_input" + # ---------------------------------------------------------------- + # MOM_input + # --------- + # Prepare local variables for use in MOM_input.IN from UFSWM + # The ones already defined are left commented as a reminder + # == MOM options to start from coarsed grained restarts, set to off by default + # options only available for 05 and 1 degree grids + # as restarts are coarsed grained/interpolated from the 0.25 degrees grid + local MOM6_INIT_FROM_Z=${MOM6_INIT_FROM_Z:-True} + local MOM6_WARMSTART_FILE=${MOM6_WARMSTART_FILE:-"none"} + local MOM6_INIT_UV=${MOM6_INIT_UV:-"zero"} + # == MOM_domains section == + # NX_GLB + # NY_GLB + # == MOM section == + # DT_DYNAM_MOM6 + # DT_THERM_MOM6 + # MOM6_THERMO_SPAN + # == MOM_grid_init section == + local MOM6_TOPOEDITS=${TOPOEDITS} + # MOM6_ALLOW_LANDMASK_CHANGES + # == MOM_diag_mediator section == + # MOM6_DIAG_COORD_DEF_Z_FILE + # MOM6_DIAG_MISVAL + # == MOM_diabatic_aux section == + local MOM6_CHLCLIM=${CHLCLIM} + # == MOM_energetic_PBL section == + # MOM6_USE_LI2016 + if [[ "${cplwav}" == ".true." ]]; then + local MOM6_USE_WAVES="True" + else + local MOM6_USE_WAVES="False" + fi + # == MOM_oda_incupd section == + local ODA_TEMPINC_VAR=${ODA_TEMPINC_VAR:-"Temp"} + local ODA_SALTINC_VAR=${ODA_SALTINC_VAR:-"Salt"} + local ODA_THK_VAR=${ODA_THK_VAR:-"h"} + local ODA_INCUPD_UV="True" + local ODA_UINC_VAR=${ODA_UINC_VAR:-"u"} + local ODA_VINC_VAR=${ODA_VINC_VAR:-"v"} + # ODA_INCUPD + # ODA_INCUPD_NHOURS + # == MOM_surface_forcing section == + # MOM6_RIVER_RUNOFF + # == ocean_stochastics section == + if [[ "${DO_OCN_SPPT}" == "YES" ]]; then + local DO_OCN_SPPT="True" # TODO: This is problematic if DO_OCN_SPPT is going to be used elsewhere + else + local DO_OCN_SPPT="False" + fi + if [[ "${DO_OCN_PERT_EPBL}" == "YES" ]]; then + local PERT_EPBL="True" + else + local PERT_EPBL="False" + fi + local MOM6_HFREEZE=20.0 + # Ensure the template exists + local template=${MOM6_INPUT_TEMPLATE:-"${PARMgfs}/ufs/MOM_input_${OCNRES}.IN"} + if [[ ! -f "${template}" ]]; then + echo "FATAL ERROR: template '${template}' does not exist, ABORT!" + exit 1 + fi + rm -f "${DATA}/INPUT/MOM_input" + atparse < "${template}" >> "${DATA}/INPUT/MOM_input" + echo "Rendered MOM_input:" + cat "${DATA}/INPUT/MOM_input" -# ================================================================ -# data_table -# ---------- -# Prepare local variables for use in MOM6_data_table.IN from UFSWM -local MOM6_FRUNOFF=${FRUNOFF} + # ---------------------------------------------------------------- + # data_table + # ---------- + # Prepare local variables for use in MOM6_data_table.IN from UFSWM + local MOM6_FRUNOFF=${FRUNOFF} -# Ensure the template exists -local template=${MOM6_DATA_TABLE_TEMPLATE:-"${PARMgfs}/ufs/MOM6_data_table.IN"} -if [[ ! -f "${template}" ]]; then - echo "FATAL ERROR: template '${template}' does not exist, ABORT!" - exit 1 -fi -rm -f "${DATA}/data_table" -atparse < "${template}" >> "${DATA}/data_table" -echo "Rendered data_table:" -cat "${DATA}/data_table" + # Ensure the template exists + local template=${MOM6_DATA_TABLE_TEMPLATE:-"${PARMgfs}/ufs/MOM6_data_table.IN"} + if [[ ! -f "${template}" ]]; then + echo "FATAL ERROR: template '${template}' does not exist, ABORT!" + exit 1 + fi + rm -f "${DATA}/data_table" + atparse < "${template}" >> "${DATA}/data_table" + echo "Rendered data_table:" + cat "${DATA}/data_table" } diff --git a/ush/parsing_namelists_WW3.sh b/ush/parsing_namelists_WW3.sh index ddcfdb47a26..5f19fdfc58a 100755 --- a/ush/parsing_namelists_WW3.sh +++ b/ush/parsing_namelists_WW3.sh @@ -1,70 +1,82 @@ #! /usr/bin/env bash -WW3_namelists(){ +WW3_namelists() { -# WW3 namelists/input generation + # WW3 namelists/input generation - FHMAX_WAV="${FHMAX_WAV:-384}" + FHMAX_WAV="${FHMAX_WAV:-384}" -# --------------------------------------------------------------------------- # -# Buoy location file + # --------------------------------------------------------------------------- # + # Buoy location file - if [ -f "${PARMgfs}/wave/wave_${NET}.buoys" ] - then - cpreq "${PARMgfs}/wave/wave_${NET}.buoys" "${DATA}/ww3_points.list" - fi + if [[ -f "${PARMgfs}/wave/wave_${NET}.buoys" ]]; then + cpreq "${PARMgfs}/wave/wave_${NET}.buoys" "${DATA}/ww3_points.list" + fi - if [ -f "${DATA}/ww3_points.list" ] - then - set +x - echo "ww3_points.list copied (${PARMgfs}/wave/wave_${NET}.buoys)." - set_trace - else - echo "FATAL ERROR : ww3_points.list (${PARMgfs}/wave/wave_${NET}.buoys) NOT FOUND" - exit 12 - fi + if [[ -f "${DATA}/ww3_points.list" ]]; then + set +x + echo "ww3_points.list copied (${PARMgfs}/wave/wave_${NET}.buoys)." + set_trace + else + echo "FATAL ERROR : ww3_points.list (${PARMgfs}/wave/wave_${NET}.buoys) NOT FOUND" + exit 12 + fi - #set coupling to ice/current - WW3_ICE="F" - WW3_CUR="F" + #set coupling to ice/current + WW3_ICE="F" + WW3_CUR="F" - case ${WW3ICEINP} in - 'YES' ) - WW3_ICE="T";; - 'CPL' ) - WW3_ICE="C";; - esac + case ${WW3ICEINP} in + 'YES') + WW3_ICE="T" + ;; + 'CPL') + WW3_ICE="C" + ;; + *) + msg="FATAL: Unknown WW3ICEIMP ${WW3ICEINP}" + export err=100 + err_exit "${msg}" + ;; + esac - case ${WW3CURINP} in - 'YES' ) - WW3_CUR="T";; - 'CPL' ) - WW3_CUR="C";; - esac + case ${WW3CURINP} in + 'YES') + WW3_CUR="T" + ;; + 'CPL') + WW3_CUR="C" + ;; + *) + msg="FATAL: Unknown WW3CURINP ${WW3CURINP}" + export err=100 + err_exit "${msg}" + ;; + esac - # Variables used in atparse of shel template - export WW3_IC1="F" - export WW3_IC5="F" - export WW3_WLEV="F" - export WW3_ICE - export WW3_CUR - export WW3_OUTPARS="${OUTPARS_WAV}" - export WW3_DTFLD="${DTFLD_WAV}" - export WW3_DTPNT="${DTPNT_WAV}" + # Variables used in atparse of shel template + export WW3_IC1="F" + export WW3_IC5="F" + export WW3_WLEV="F" + export WW3_ICE + export WW3_CUR + export WW3_OUTPARS="${OUTPARS_WAV}" + export WW3_DTFLD="${DTFLD_WAV}" + export WW3_DTPNT="${DTPNT_WAV}" - export WW3_GRD_OUTDIR="./WW3_OUTPUT/" - export WW3_PNT_OUTDIR="./WW3_OUTPUT/" - export WW3_RST_OUTDIR="./WW3_RESTART/" + export WW3_GRD_OUTDIR="./WW3_OUTPUT/" + export WW3_PNT_OUTDIR="./WW3_OUTPUT/" + export WW3_RST_OUTDIR="./WW3_RESTART/" - # Ensure the template exists - local template=${WW3_INPUT_TEMPLATE:-"${PARMgfs}/ufs/ww3_shel.nml.IN"} - if [[ ! -f "${template}" ]]; then - echo "FATAL ERROR: template '${template}' does not exist, ABORT!" - exit 1 - fi - rm -f "${DATA}/ww3_shel.nml" - atparse < "${template}" >> "${DATA}/ww3_shel.nml" - echo "Rendered ww3_shel.nml:" - cat "${DATA}/ww3_shel.nml" + # Ensure the template exists + local template=${WW3_INPUT_TEMPLATE:-"${PARMgfs}/ufs/ww3_shel.nml.IN"} + if [[ ! -f "${template}" ]]; then + echo "FATAL ERROR: template '${template}' does not exist, ABORT!" + exit 1 + fi + rm -f "${DATA}/ww3_shel.nml" + atparse < "${template}" >> "${DATA}/ww3_shel.nml" + echo "Rendered ww3_shel.nml:" + cat "${DATA}/ww3_shel.nml" } diff --git a/ush/parsing_ufs_configure.sh b/ush/parsing_ufs_configure.sh index 75b2cae2264..c860d855b9a 100755 --- a/ush/parsing_ufs_configure.sh +++ b/ush/parsing_ufs_configure.sh @@ -9,124 +9,124 @@ # shellcheck disable=SC2034 UFS_configure() { -echo "SUB ${FUNCNAME[0]}: ufs.configure begins" - -# Setup ufs.configure -local esmf_logkind=${esmf_logkind:-"ESMF_LOGKIND_MULTI"} #options: ESMF_LOGKIND_MULTI_ON_ERROR, ESMF_LOGKIND_MULTI, ESMF_LOGKIND_NONE -local DumpFields=${DumpFields:-false} -local cap_dbug_flag=${cap_dbug_flag:-0} - -# Determine "cmeps_run_type" based on the availability of the mediator restart file -# If it is a warm_start, we already copied the mediator restart to DATA, if it was present -# If the mediator restart was not present, despite being a "warm_start", we put out a WARNING -# in forecast_postdet.sh function CMEPS_postdet -if [[ -f "${DATA}/ufs.cpld.cpl.r.nc" ]]; then - local cmeps_run_type='continue' -else - local cmeps_run_type='startup' -fi - -# Atm-related -local atm_model="fv3" -local atm_petlist_bounds="0 $(( ATMPETS-1 ))" -local atm_omp_num_threads="${ATMTHREADS}" - -local med_model="cmeps" -local med_petlist_bounds="0 $(( MEDPETS-1 ))" -local med_omp_num_threads="${MEDTHREADS}" - -# vector remapping -local MAPUV3D=true - -if [[ "${cpl}" = ".true." ]]; then - local coupling_interval_slow_sec="${CPL_SLOW}" -fi - -local WRITE_ENDOFRUN_RESTART=.false. - -if [[ "${cplflx}" = ".true." ]]; then - - local use_coldstart=${use_coldstart:-".false."} - local use_mommesh=${USE_MOMMESH:-"true"} - - local ocn_model="mom6" - local ocn_petlist_bounds="${ATMPETS} $(( ATMPETS+OCNPETS-1 ))" - local ocn_omp_num_threads="${OCNTHREADS}" - local RUNTYPE="${cmeps_run_type}" - local CMEPS_RESTART_DIR="CMEPS_RESTART/" - local CPLMODE="${cplmode}" - local CMEPS_PIO_FORMAT='pnetcdf' - local CMEPS_PIO_STRIDE=4 - local CMEPS_PIO_IOTASKS=-99 - local CMEPS_PIO_REARR='box' - local CMEPS_PIO_ROOT=-99 - local coupling_interval_fast_sec="${CPL_FAST}" - local RESTART_N=999999 - local ocean_albedo_limit=0.06 - local ATMTILESIZE="${CASE:1}" - local ocean_albedo_limit=0.06 - local pio_rearranger=${pio_rearranger:-"box"} - local MED_history_n=1000000 - - local histaux_enabled=".false." -fi - -if [[ "${cplice}" = ".true." ]]; then - - local ice_model="cice6" - local ice_petlist_bounds="$(( ATMPETS+OCNPETS )) $(( ATMPETS+OCNPETS+ICEPETS-1 ))" - local ice_omp_num_threads="${ICETHREADS}" - local FHMAX="${FHMAX_GFS}" # TODO: How did this get in here hard-wired to FHMAX_GFS? -fi - -if [[ "${cplwav}" = ".true." ]]; then - - local wav_model="ww3" - local wav_petlist_bounds="$(( ATMPETS+OCNPETS+ICEPETS )) $(( ATMPETS+OCNPETS+ICEPETS+WAVPETS-1 ))" - local wav_omp_num_threads="${WAVTHREADS}" - - local WW3_user_histname="false" - local WW3_historync="false" - local WW3_restartnc="true" - local WW3_PIO_FORMAT="pnetcdf" - local WW3_PIO_IOTASKS=-99 - local WW3_PIO_STRIDE=4 - local WW3_PIO_REARR="box" - local WW3_PIO_ROOT=-99 - -fi - -if [[ "${cplchm}" = ".true." ]]; then - - local chm_model="gocart" - local chm_petlist_bounds="0 $(( CHMPETS-1 ))" - local chm_omp_num_threads="${CHMTHREADS}" - local coupling_interval_sec="${CPL_FAST}" - -fi - -#Set ESMF_THREADING variable for ufs configure -if [[ "${USE_ESMF_THREADING}" = "YES" ]]; then - local ESMF_THREADING="true" -else - local ESMF_THREADING="false" -fi - -# Ensure the template exists -if [[ ! -r "${ufs_configure_template}" ]]; then - echo "FATAL ERROR: template '${ufs_configure_template}' does not exist, ABORT!" - exit 1 -else - echo "INFO: using ufs.configure template: '${ufs_configure_template}'" -fi - -rm -f "${DATA}/ufs.configure" -atparse < "${ufs_configure_template}" >> "${DATA}/ufs.configure" -echo "Rendered ufs.configure:" -cat ufs.configure - -cpreq "${HOMEgfs}/sorc/ufs_model.fd/tests/parm/fd_ufs.yaml" fd_ufs.yaml - -echo "SUB ${FUNCNAME[0]}: ufs.configure ends" + echo "SUB ${FUNCNAME[0]}: ufs.configure begins" + + # Setup ufs.configure + local esmf_logkind=${esmf_logkind:-"ESMF_LOGKIND_MULTI"} #options: ESMF_LOGKIND_MULTI_ON_ERROR, ESMF_LOGKIND_MULTI, ESMF_LOGKIND_NONE + local DumpFields=${DumpFields:-false} + local cap_dbug_flag=${cap_dbug_flag:-0} + + # Determine "cmeps_run_type" based on the availability of the mediator restart file + # If it is a warm_start, we already copied the mediator restart to DATA, if it was present + # If the mediator restart was not present, despite being a "warm_start", we put out a WARNING + # in forecast_postdet.sh function CMEPS_postdet + if [[ -f "${DATA}/ufs.cpld.cpl.r.nc" ]]; then + local cmeps_run_type='continue' + else + local cmeps_run_type='startup' + fi + + # Atm-related + local atm_model="fv3" + local atm_petlist_bounds="0 $((ATMPETS - 1))" + local atm_omp_num_threads="${ATMTHREADS}" + + local med_model="cmeps" + local med_petlist_bounds="0 $((MEDPETS - 1))" + local med_omp_num_threads="${MEDTHREADS}" + + # vector remapping + local MAPUV3D=true + + if [[ "${cpl}" = ".true." ]]; then + local coupling_interval_slow_sec="${CPL_SLOW}" + fi + + local WRITE_ENDOFRUN_RESTART=.false. + + if [[ "${cplflx}" = ".true." ]]; then + + local use_coldstart=${use_coldstart:-".false."} + local use_mommesh=${USE_MOMMESH:-"true"} + + local ocn_model="mom6" + local ocn_petlist_bounds="${ATMPETS} $((ATMPETS + OCNPETS - 1))" + local ocn_omp_num_threads="${OCNTHREADS}" + local RUNTYPE="${cmeps_run_type}" + local CMEPS_RESTART_DIR="CMEPS_RESTART/" + local CPLMODE="${cplmode}" + local CMEPS_PIO_FORMAT='pnetcdf' + local CMEPS_PIO_STRIDE=4 + local CMEPS_PIO_IOTASKS=-99 + local CMEPS_PIO_REARR='box' + local CMEPS_PIO_ROOT=-99 + local coupling_interval_fast_sec="${CPL_FAST}" + local RESTART_N=999999 + local ocean_albedo_limit=0.06 + local ATMTILESIZE="${CASE:1}" + local ocean_albedo_limit=0.06 + local pio_rearranger=${pio_rearranger:-"box"} + local MED_history_n=1000000 + + local histaux_enabled=".false." + fi + + if [[ "${cplice}" = ".true." ]]; then + + local ice_model="cice6" + local ice_petlist_bounds="$((ATMPETS + OCNPETS)) $((ATMPETS + OCNPETS + ICEPETS - 1))" + local ice_omp_num_threads="${ICETHREADS}" + local FHMAX="${FHMAX_GFS}" # TODO: How did this get in here hard-wired to FHMAX_GFS? + fi + + if [[ "${cplwav}" = ".true." ]]; then + + local wav_model="ww3" + local wav_petlist_bounds="$((ATMPETS + OCNPETS + ICEPETS)) $((ATMPETS + OCNPETS + ICEPETS + WAVPETS - 1))" + local wav_omp_num_threads="${WAVTHREADS}" + + local WW3_user_histname="false" + local WW3_historync="false" + local WW3_restartnc="true" + local WW3_PIO_FORMAT="pnetcdf" + local WW3_PIO_IOTASKS=-99 + local WW3_PIO_STRIDE=4 + local WW3_PIO_REARR="box" + local WW3_PIO_ROOT=-99 + + fi + + if [[ "${cplchm}" = ".true." ]]; then + + local chm_model="gocart" + local chm_petlist_bounds="0 $((CHMPETS - 1))" + local chm_omp_num_threads="${CHMTHREADS}" + local coupling_interval_sec="${CPL_FAST}" + + fi + + #Set ESMF_THREADING variable for ufs configure + if [[ "${USE_ESMF_THREADING}" = "YES" ]]; then + local ESMF_THREADING="true" + else + local ESMF_THREADING="false" + fi + + # Ensure the template exists + if [[ ! -r "${ufs_configure_template}" ]]; then + echo "FATAL ERROR: template '${ufs_configure_template}' does not exist, ABORT!" + exit 1 + else + echo "INFO: using ufs.configure template: '${ufs_configure_template}'" + fi + + rm -f "${DATA}/ufs.configure" + atparse < "${ufs_configure_template}" >> "${DATA}/ufs.configure" + echo "Rendered ufs.configure:" + cat ufs.configure + + cpreq "${HOMEgfs}/sorc/ufs_model.fd/tests/parm/fd_ufs.yaml" fd_ufs.yaml + + echo "SUB ${FUNCNAME[0]}: ufs.configure ends" } diff --git a/ush/preamble.sh b/ush/preamble.sh index aac23c4b39b..df24338ac83 100755 --- a/ush/preamble.sh +++ b/ush/preamble.sh @@ -80,7 +80,7 @@ postamble() { # if [[ -v 'POSTAMBLE_CMD' ]]; then - ${POSTAMBLE_CMD} + ${POSTAMBLE_CMD} fi # Calculate the elapsed time @@ -111,10 +111,10 @@ function err_exit() { msg1=${*:-Job ${jobid} failed} if [[ -n "${pgm}" ]]; then - msg1+=", ERROR IN ${pgm}" + msg1+=", ERROR IN ${pgm}" fi if [[ -n "${err}" ]]; then - msg1+=" RETURN CODE ${err}" + msg1+=" RETURN CODE ${err}" fi msg2=" @@ -134,38 +134,38 @@ function err_exit() { # list files in temporary working directory if [[ -n "${DATA}" ]]; then - >&2 echo "${DATA}" - >&2 ls -ltr "${DATA}" + >&2 echo "${DATA}" + >&2 ls -ltr "${DATA}" else - >&2 echo "WARNING: DATA variable not defined" + >&2 echo "WARNING: DATA variable not defined" fi # save standard output if [[ -n "${pgmout}" ]]; then - if [[ -s errfile ]]; then - echo "----- contents of errfile -----" >> "${pgmout}" - cat errfile >> "${pgmout}" - fi - >&2 cat "${pgmout}" + if [[ -s errfile ]]; then + echo "----- contents of errfile -----" >> "${pgmout}" + cat errfile >> "${pgmout}" + fi + >&2 cat "${pgmout}" elif [[ -s errfile ]]; then - >&2 cat errfile + >&2 cat errfile fi # Write to ecflow log: if [[ "${SENDECF}" == "YES" ]]; then - timeout 30 ecflow_client --msg "${ECF_NAME}: ${msg1}" - timeout 30 ssh "${ECF_HOST}" "echo \"${msg}2\" >> ${ECF_JOBOUT:?}" + timeout 30 ecflow_client --msg "${ECF_NAME}: ${msg1}" + timeout 30 ssh "${ECF_HOST}" "echo \"${msg}2\" >> ${ECF_JOBOUT:?}" fi # KILL THE JOB: if [[ "${SENDECF}" == "YES" ]]; then - ecflow_client --kill="${ECF_NAME:?}" + ecflow_client --kill="${ECF_NAME:?}" fi if [[ -n "${PBS_JOBID}" ]]; then - qdel "${PBS_JOBID}" + qdel "${PBS_JOBID}" elif [[ -n "${SLURM_JOB_ID}" ]]; then - scancel "${SLURM_JOB_ID}" + scancel "${SLURM_JOB_ID}" fi } diff --git a/ush/prep_sfc_ice_blend.sh b/ush/prep_sfc_ice_blend.sh index a60adfeb91c..19a411312d3 100755 --- a/ush/prep_sfc_ice_blend.sh +++ b/ush/prep_sfc_ice_blend.sh @@ -66,13 +66,13 @@ pgmout=${pgmout:-"OUTPUT"} #------------------------------------------------------------------------ if [[ -f "${IMS_FILE}" ]]; then - cpfs "${IMS_FILE}" ./ims.grib2 - ${WGRIB2} ims.grib2 -match "ICEC" -grib ims.icec.grib2 - grid173="0 0 0 0 0 0 0 0 4320 2160 0 0 89958000 42000 48 -89958000 359958000 83000 83000 0" - ${COPYGB2} -x -i3 -g "${grid173}" ims.icec.grib2 ims.icec.5min.grib2 + cpfs "${IMS_FILE}" ./ims.grib2 + ${WGRIB2} ims.grib2 -match "ICEC" -grib ims.icec.grib2 + grid173="0 0 0 0 0 0 0 0 4320 2160 0 0 89958000 42000 48 -89958000 359958000 83000 83000 0" + ${COPYGB2} -x -i3 -g "${grid173}" ims.icec.grib2 ims.icec.5min.grib2 else - echo "WARNING: IMS ${IMS_FILE} ice data missing. Can not run program ${pgm}." - exit 3 + echo "WARNING: IMS ${IMS_FILE} ice data missing. Can not run program ${pgm}." + exit 3 fi #------------------------------------------------------------------------ @@ -80,10 +80,9 @@ fi # Copy old blended data to current directory. #------------------------------------------------------------------------ -if [[ ! -f "${FIVE_MIN_ICE_FILE}" ]] -then - echo "WARNING: ${FIVE_MIN_ICE_FILE} data missing. Can not run program ${pgm}." - exit 5 +if [[ ! -f "${FIVE_MIN_ICE_FILE}" ]]; then + echo "WARNING: ${FIVE_MIN_ICE_FILE} data missing. Can not run program ${pgm}." + exit 5 fi #------------------------------------------------------------------------ @@ -118,16 +117,16 @@ export err=$? #------------------------------------------------------------------------ if [[ "${err}" -ne 0 ]]; then - echo "WARNING: ${pgm} completed abnormally. The old ice blend file will be used." - # Exit but do not call err_exit. Calling script will handle use of older file - exit "${err}" + echo "WARNING: ${pgm} completed abnormally. The old ice blend file will be used." + # Exit but do not call err_exit. Calling script will handle use of older file + exit "${err}" else - ${WGRIB2} -set_int 3 51 42000 "${BLENDED_ICE_FILE}" -grib "${BLENDED_ICE_FILE}.corner" - ${CNVGRIB} -g21 "${BLENDED_ICE_FILE}.corner" "${BLENDED_ICE_FILE}.bitmap" - rm -f "${BLENDED_ICE_FILE}" - ${COPYGB} -M "#1.57" -x "${BLENDED_ICE_FILE}.bitmap" "${BLENDED_ICE_FILE}" - cpfs "${BLENDED_ICE_FILE}" "${COMOUT_OBS}" - rm -f "${BLENDED_ICE_FILE}.corner" "${BLENDED_ICE_FILE}.bitmap" + ${WGRIB2} -set_int 3 51 42000 "${BLENDED_ICE_FILE}" -grib "${BLENDED_ICE_FILE}.corner" + ${CNVGRIB} -g21 "${BLENDED_ICE_FILE}.corner" "${BLENDED_ICE_FILE}.bitmap" + rm -f "${BLENDED_ICE_FILE}" + ${COPYGB} -M "#1.57" -x "${BLENDED_ICE_FILE}.bitmap" "${BLENDED_ICE_FILE}" + cpfs "${BLENDED_ICE_FILE}" "${COMOUT_OBS}" + rm -f "${BLENDED_ICE_FILE}.corner" "${BLENDED_ICE_FILE}.bitmap" fi exit 0 diff --git a/ush/prep_sfc_snow.sh b/ush/prep_sfc_snow.sh index 0e017011005..edd523abc17 100755 --- a/ush/prep_sfc_snow.sh +++ b/ush/prep_sfc_snow.sh @@ -44,7 +44,7 @@ # ######################################################################### -source "${USHgfs}/atparse.bash" # include function atparse for parsing @[XYZ] templated files +source "${USHgfs}/atparse.bash" # include function atparse for parsing @[XYZ] templated files #------------------------------------------------------------------------ # The snow2mdl executable and namelist @@ -84,7 +84,7 @@ CLIMO_QC=${CLIMO_QC:-"${FIXgfs}/am/emcsfc_snow_cover_climo.grib2"} #------------------------------------------------------------------------ MODEL_SNOW_FILE=${MODEL_SNOW_FILE:-"snogrb_model"} -OUTPUT_GRIB2=${OUTPUT_GRIB2:-".false."} # grib 1 when false. +OUTPUT_GRIB2=${OUTPUT_GRIB2:-".false."} # grib 1 when false. #------------------------------------------------------------------------ # Do a quick check of the ims data to ensure it exists and is not corrupt. @@ -92,10 +92,10 @@ OUTPUT_GRIB2=${OUTPUT_GRIB2:-".false."} # grib 1 when false. #------------------------------------------------------------------------ if [[ -f ${IMS_FILE} ]]; then - cpreq "${IMS_FILE}" "${DATA}/imssnow96.grib2" + cpreq "${IMS_FILE}" "${DATA}/imssnow96.grib2" else - echo "WARNING: Missing IMS data. Will not run ${SNOW2MDLEXEC}." - exit 7 + echo "WARNING: Missing IMS data. Will not run ${SNOW2MDLEXEC}." + exit 7 fi #------------------------------------------------------------------------ @@ -106,11 +106,11 @@ fi ${WGRIB2} -d 1 "imssnow96.grib2" err=$? if [[ ${err} -ne 0 ]]; then - echo "WARNING: Corrupt IMS data. Will not run ${SNOW2MDLEXEC}." - exit 9 + echo "WARNING: Corrupt IMS data. Will not run ${SNOW2MDLEXEC}." + exit 9 else - tempdate=$(${WGRIB2} -t "imssnow96.grib2" | head -1) || true - IMSDATE=${tempdate#*d=} + tempdate=$(${WGRIB2} -t "imssnow96.grib2" | head -1) || true + IMSDATE=${tempdate#*d=} fi #------------------------------------------------------------------------ @@ -119,24 +119,24 @@ fi #------------------------------------------------------------------------ if [[ ! -f ${AFWA_GLOBAL_FILE} ]]; then - echo "WARNING: Missing AFWS data. Will not run ${SNOW2MDLEXEC}." - exit 3 + echo "WARNING: Missing AFWS data. Will not run ${SNOW2MDLEXEC}." + exit 3 else - cpreq "${AFWA_GLOBAL_FILE}" "${DATA}/snow.usaf.grib2" - ${WGRIB2} -d 1 "snow.usaf.grib2" - err=$? - if [[ ${err} -ne 0 ]]; then - echo "WARNING: Corrupt AFWS data. Will not run ${SNOW2MDLEXEC}." - exit "${err}" - else - tempdate=$(${WGRIB2} -d 1 -t "snow.usaf.grib2") - AFWADATE=${tempdate#*d=} - two_days_ago=$(date --utc -d "${IMSDATE:0:8} ${IMSDATE:8:2} - 48 hours" +%Y%m%d%H) - if [[ ${AFWADATE} -lt ${two_days_ago} ]]; then - echo "WARNING: Found old AFWA data. Will not run ${SNOW2MDLEXEC}." - exit 4 + cpreq "${AFWA_GLOBAL_FILE}" "${DATA}/snow.usaf.grib2" + ${WGRIB2} -d 1 "snow.usaf.grib2" + err=$? + if [[ ${err} -ne 0 ]]; then + echo "WARNING: Corrupt AFWS data. Will not run ${SNOW2MDLEXEC}." + exit "${err}" + else + tempdate=$(${WGRIB2} -d 1 -t "snow.usaf.grib2") + AFWADATE=${tempdate#*d=} + two_days_ago=$(date --utc -d "${IMSDATE:0:8} ${IMSDATE:8:2} - 48 hours" +%Y%m%d%H) + if [[ ${AFWADATE} -lt ${two_days_ago} ]]; then + echo "WARNING: Found old AFWA data. Will not run ${SNOW2MDLEXEC}." + exit 4 + fi fi - fi fi #------------------------------------------------------------------------ @@ -145,12 +145,12 @@ fi export IMSYEAR=${IMSDATE:0:4} export IMSMONTH=${IMSDATE:4:2} export IMSDAY=${IMSDATE:6:2} -export IMSHOUR=0 # emc convention is to use 00Z. +export IMSHOUR=0 # emc convention is to use 00Z. # Render the namelist template if [[ ! -f "${SNOW2MDLNMLTMPL}" ]]; then - echo "FATAL ERROR: template '${SNOW2MDLNMLTMPL}' does not exist, ABORT!" - exit 1 + echo "FATAL ERROR: template '${SNOW2MDLNMLTMPL}' does not exist, ABORT!" + exit 1 fi rm -f ./fort.41 atparse < "${SNOW2MDLNMLTMPL}" >> "./fort.41" @@ -166,12 +166,12 @@ source prep_step err=$? if [[ ${err} -ne 0 ]]; then - echo "WARNING: ${pgm} completed abnormally." - exit "${err}" + echo "WARNING: ${pgm} completed abnormally." + exit "${err}" else - echo "${pgm} completed normally." - cpfs "${MODEL_SNOW_FILE}" "${COMOUT_OBS}" - rm -f "${MODEL_SNOW_FILE}" + echo "${pgm} completed normally." + cpfs "${MODEL_SNOW_FILE}" "${COMOUT_OBS}" + rm -f "${MODEL_SNOW_FILE}" fi rm -f ./fort.41 diff --git a/ush/product_functions.sh b/ush/product_functions.sh index 05b23fbee2b..300bf003927 100755 --- a/ush/product_functions.sh +++ b/ush/product_functions.sh @@ -1,40 +1,40 @@ #! /usr/bin/env bash function trim_rh() { - # trim RH values larger than 100. - local filename=$1 - ${WGRIB2} "${filename}" \ + # trim RH values larger than 100. + local filename=$1 + ${WGRIB2} "${filename}" \ -not_if ':RH:' -grib "${filename}.new" \ -if ':RH:' -rpn "10:*:0.5:+:floor:1000:min:10:/" -set_grib_type same \ -set_scaling -1 0 -grib_out "${filename}.new" - rc=$? - if (( rc == 0 )); then mv "${filename}.new" "${filename}"; fi - return "${rc}" + rc=$? + if ((rc == 0)); then mv "${filename}.new" "${filename}"; fi + return "${rc}" } function mod_icec() { - # modify icec based on land-sea mask - local filename=$1 - ${WGRIB2} "${filename}" \ - -if 'LAND' -rpn 'sto_1' -fi \ - -if 'ICEC' -rpn 'rcl_1:0:==:*' -fi \ - -set_grib_type same \ - -set_scaling same same \ - -grib_out "${filename}.new" - rc=$? - if (( rc == 0 )); then mv "${filename}.new" "${filename}"; fi - return "${rc}" + # modify icec based on land-sea mask + local filename=$1 + ${WGRIB2} "${filename}" \ + -if 'LAND' -rpn 'sto_1' -fi \ + -if 'ICEC' -rpn 'rcl_1:0:==:*' -fi \ + -set_grib_type same \ + -set_scaling same same \ + -grib_out "${filename}.new" + rc=$? + if ((rc == 0)); then mv "${filename}.new" "${filename}"; fi + return "${rc}" } function scale_dec() { - # change the scaling for temperature, precipitable water, and water-equivalent accumlated snow depth - local filename=$1 - ${WGRIB2} "${filename}" -not_if ':(TMP|PWAT|WEASD):' -grib "${filename}.new" \ - -if ':(TMP|PWAT):' -set_grib_type same \ - -set_scaling -1 0 -grib_out "${filename}.new" \ - -if ':(WEASD):' -set_grib_type same \ - -set_scaling 0 0 -grib_out "${filename}.new" - rc=$? - if (( rc == 0 )); then mv "${filename}.new" "${filename}"; fi - return "${rc}" + # change the scaling for temperature, precipitable water, and water-equivalent accumlated snow depth + local filename=$1 + ${WGRIB2} "${filename}" -not_if ':(TMP|PWAT|WEASD):' -grib "${filename}.new" \ + -if ':(TMP|PWAT):' -set_grib_type same \ + -set_scaling -1 0 -grib_out "${filename}.new" \ + -if ':(WEASD):' -set_grib_type same \ + -set_scaling 0 0 -grib_out "${filename}.new" + rc=$? + if ((rc == 0)); then mv "${filename}.new" "${filename}"; fi + return "${rc}" } diff --git a/ush/radmon_diag_ck.sh b/ush/radmon_diag_ck.sh index ca9129b6df4..a8e65a57fe5 100755 --- a/ush/radmon_diag_ck.sh +++ b/ush/radmon_diag_ck.sh @@ -2,173 +2,162 @@ #---------------------------------------------------------------- # Check the contents of the radstat file and compare to -# the ${run}_radmon_satype.txt file. Report any missing +# the ${run}_radmon_satype.txt file. Report any missing # or zero sized diag files. -# - - function usage { - echo "Usage: radmon_diag_ck.sh -rad radstat --sat satype --out output " - echo "" - echo " -r,--rad radstat file (required)" - echo " File name or path to radstat file." - echo "" - echo " -s,--sat satype file (required)" - echo " File name or path to satype file." - echo "" - echo " -o,--out output file name (required)" - echo " File name for missing diag file report." - } +# +function usage { + echo "Usage: radmon_diag_ck.sh -rad radstat --sat satype --out output " + echo "" + echo " -r,--rad radstat file (required)" + echo " File name or path to radstat file." + echo "" + echo " -s,--sat satype file (required)" + echo " File name or path to satype file." + echo "" + echo " -o,--out output file name (required)" + echo " File name for missing diag file report." +} echo "--> radmon_diag_ck.sh" - #-------------------------- # Process input arguments # - nargs=$# - if [[ ${nargs} -ne 6 ]]; then - usage - exit 1 - fi - - while [[ $# -ge 1 ]] - do - key="$1" - echo "${key}" - - case ${key} in - -r|--rad) +nargs=$# +if [[ ${nargs} -ne 6 ]]; then + usage + exit 1 +fi + +while [[ $# -ge 1 ]]; do + key="$1" + echo "${key}" + + case ${key} in + -r | --rad) radstat_file="$2" shift # past argument - ;; - -s|--sat) + ;; + -s | --sat) satype_file="$2" shift # past argument - ;; - -o|--out) + ;; + -o | --out) output_file="$2" shift # past argument - ;; - *) - #unspecified key + ;; + *) + #unspecified key echo " unsupported key = ${key}" - ;; - esac + ;; + esac - shift - done + shift +done # set -ax - echo " radstat_file = ${radstat_file}" - echo " satype_file = ${satype_file}" - echo " output_file = ${output_file}" - - missing_diag="" - zero_len_diag="" - - #--------------------------------------------- - # get list of diag files in the radstat file - # - radstat_contents=`tar -tf "${radstat_file}" | grep '_ges' | - gawk -F"diag_" '{print $2}' | - gawk -F"_ges" '{print $1}'` - - - #--------------------------------------------- - # load contents of satype_file into an array - # - satype_contents=$(cat "${satype_file}") - - - #------------------------------------------------- - # compare $satype_contents and $radstat_contents - # report anything missing - # - for sat in ${satype_contents}; do - content_count=$(echo "${radstat_contents}" | grep -c "${sat}" || true) - - if (( content_count <= 0 )); then +echo " radstat_file = ${radstat_file}" +echo " satype_file = ${satype_file}" +echo " output_file = ${output_file}" + +missing_diag="" +zero_len_diag="" + +#--------------------------------------------- +# get list of diag files in the radstat file +# +# shellcheck disable=SC2312 +radstat_contents=$(tar -tf "${radstat_file}" | grep -Po '(?<=diag_).*(?=_ges.*)') + +#--------------------------------------------- +# load contents of satype_file into an array +# +readarray -t satype_contents < "${satype_file}" + +#------------------------------------------------- +# compare $satype_contents and $radstat_contents +# report anything missing +# +for sat in "${satype_contents[@]}"; do + content_count=$(echo "${radstat_contents}" | grep -c "${sat}") + + if [[ "${content_count}" -le 0 ]]; then missing_diag="${missing_diag} ${sat}" - fi - - done - - echo "" - echo "missing_diag = ${missing_diag}" - echo "" - - - #--------------------------------------------------------- - # Check for zero sized diag files. The diag files in - # the radstat file (which is a tar file) are gzipped. - # I find that 0 sized, gzipped file has a size of ~52 - # (I assume that's for header and block size). - # - # So for this check we'll assume anything in the radstat - # file with a size of > 1000 bytes is suspect. (That's - # overkill, 100 is probably sufficient, but I'm the - # nervous type.) So we'll extract, uncompress, and check - # the actual file size of those. Anything with an - # uncompressed size of 0 goes on the zero_len_diag list. - # - - # TODO Rewrite these array parsing commands to avoid using Bash's sloppy word splitting - # File sizes contain only digits and immediately precede the date - # shellcheck disable=SC2207 - sizes=($(tar -vtf "${radstat_file}" --wildcards '*_ges*' | grep -P -o '(\d)+(?= \d{4}-\d{2}-\d{2})')) - # Filenames are the last group of non-whitespace characters - # shellcheck disable=SC2207 - filenames=($(tar -vtf "${radstat_file}" --wildcards '*_ges*' | grep -P -o '\S+$')) - # shellcheck disable= - - - for file_num in "${!filenames[@]}"; do - file_name="${filenames[${file_num}]}" - file_size="${sizes[${file_num}]}" - - if (( file_size <= 1000 )); then - tar -xf "${radstat_file}" "${file_name}" - gunzip "${file_name}" - uz_file_name="${file_name%.*}" - uz_file_size=$(stat -c "%s" "${uz_file_name}") - - - if (( uz_file_size <= 0 )); then + fi + +done + +echo "" +echo "missing_diag = ${missing_diag}" +echo "" + +#--------------------------------------------------------- +# Check for zero sized diag files. The diag files in +# the radstat file (which is a tar file) are gzipped. +# I find that 0 sized, gzipped file has a size of ~52 +# (I assume that's for header and block size). +# +# So for this check we'll assume anything in the radstat +# file with a size of > 1000 bytes is suspect. (That's +# overkill, 100 is probably sufficient, but I'm the +# nervous type.) So we'll extract, uncompress, and check +# the actual file size of those. Anything with an +# uncompressed size of 0 goes on the zero_len_diag list. +# + +declare -A file_sizes + +# Parse the filename and filesize from tar's verbose output and store in an associative array +# Field $6 of verbose tar output is the filename, field $3 is the size +# Caution: this method is not robust if the filename contains spaces +# shellcheck disable=SC2312 +while IFS='|' read -r name size; do + file_sizes[${name}]=${size} +done < <(tar -vtf "${radstat_file}" --wildcards '*_ges*' | awk '$3 ~ /^[0-9]+$/ { print $6 "|" $3 }') + +for file_name in "${!file_sizes[@]}"; do + file_size="${file_sizes["${file_name}"]}" + + if ((file_size <= 1000)); then + tar -xf "${radstat_file}" "${file_name}" + gunzip "${file_name}" + uz_file_name="${file_name%.*}" + uz_file_size=$(stat -c "%s" "${uz_file_name}") + + if ((uz_file_size <= 0)); then # Remove leading diag_ sat=${uz_file_name#diag_} # Remove trailing _ges* sat=${sat%_ges*} zero_len_diag="${zero_len_diag} ${sat}" - fi - - rm -f "${uz_file_name}" - fi + fi - done + rm -f "${uz_file_name}" + fi - echo "" - echo "zero_len_diag = ${zero_len_diag}" - echo "" +done +echo "" +echo "zero_len_diag = ${zero_len_diag}" +echo "" - #----------------------------------------- - # Write results to $output_file - # - if [[ ${#zero_len_diag} -gt 0 ]]; then - for zld in ${zero_len_diag}; do - echo " Zero Length diagnostic file: ${zld}" >> "${output_file}" - done - fi - - if [[ ${#missing_diag} -gt 0 ]]; then - for md in ${missing_diag}; do - echo " Missing diagnostic file : ${md}" >> "${output_file}" - done - fi - +#----------------------------------------- +# Write results to $output_file +# +if [[ ${#zero_len_diag} -gt 0 ]]; then + for zld in ${zero_len_diag}; do + echo " Zero Length diagnostic file: ${zld}" >> "${output_file}" + done +fi + +if [[ ${#missing_diag} -gt 0 ]]; then + for md in ${missing_diag}; do + echo " Missing diagnostic file : ${md}" >> "${output_file}" + done +fi echo "<-- radmon_diag_ck.sh" exit diff --git a/ush/radmon_err_rpt.sh b/ush/radmon_err_rpt.sh index c288f5f3518..7f85f4cfb80 100755 --- a/ush/radmon_err_rpt.sh +++ b/ush/radmon_err_rpt.sh @@ -4,7 +4,7 @@ #### UNIX Script Documentation Block # . . # Script name: radmon_err_rpt.sh -# Script description: Compare the contents of error files from two different +# Script description: Compare the contents of error files from two different # cycles. # # Author: Ed Safford Org: NP23 Date: 2012-02-02 @@ -15,7 +15,7 @@ # in both files are reported. # # This script is run as a child script of radmon_verf_time.sh. The parent -# script creates/copies the error files into a temporary working +# script creates/copies the error files into a temporary working # directory before invoking this script. # # @@ -55,135 +55,130 @@ outfile=${7:-${outfile:?}} # Other variables err=0 -RADMON_SUFFIX=${RADMON_SUFFIX} have_diag_rpt=0 if [[ -s "${diag_rpt}" ]]; then - have_diag_rpt=1 + have_diag_rpt=1 else - err=1 + err=1 fi echo "have_diag_rpt = ${have_diag_rpt}" #----------------------------------------------------------------------------- -# read each line in the $file1 -# search $file2 for the same satname, channel, and region +# read each line in the $file1 +# search $file2 for the same satname, channel, and region # if same combination is in both files, add the values to the output file -# -{ while read myline; do - echo "myline = ${myline}" - bound="" - - echo "${myline}" - satname=$(echo "${myline}" | gawk '{print $1}') - channel=$(echo "${myline}" | gawk '{print $3}') - region=$(echo "${myline}" | gawk '{print $5}') - value1=$(echo "${myline}" | gawk '{print $7}') - bound=$(echo "${myline}" | gawk '{print $9}') - -# -# Check findings against diag_report. If the satellite/instrument is on the -# diagnostic report it means the diagnostic file file for the -# satelite/instrument is missing for this cycle, so skip any additional -# error checking for that source. Otherwise, evaluate as per normal. # - - diag_match="" - diag_match_len=0 - - if [[ ${have_diag_rpt} == 1 ]]; then - diag_match=$(gawk "/${satname}/" "${diag_rpt}") - diag_match_len=$(echo ${#diag_match}) - fi - - - if [[ ${diag_match_len} == 0 ]]; then - - if [[ ${type} == "chan" ]]; then - echo "looking for match for ${satname} and ${channel}" - { while read myline2; do - satname2=$(echo "${myline2}" | gawk '{print $1}') - channel2=$(echo "${myline2}" | gawk '{print $3}') - - if [[ ${satname} == ${satname2} && ${channel} == ${channel2} ]]; then - match="${satname} channel= ${channel}" - echo "match from gawk = ${match}" - break; - else - match="" +{ while read -r myline; do + echo "myline = ${myline}" + bound="" + + echo "${myline}" + satname=$(echo "${myline}" | gawk '{print $1}') + channel=$(echo "${myline}" | gawk '{print $3}') + region=$(echo "${myline}" | gawk '{print $5}') + value1=$(echo "${myline}" | gawk '{print $7}') + bound=$(echo "${myline}" | gawk '{print $9}') + + # + # Check findings against diag_report. If the satellite/instrument is on the + # diagnostic report it means the diagnostic file file for the + # satelite/instrument is missing for this cycle, so skip any additional + # error checking for that source. Otherwise, evaluate as per normal. + # + + diag_match="" + diag_match_len=0 + + if [[ "${have_diag_rpt}" -eq 1 ]]; then + diag_match=$(gawk "/${satname}/" "${diag_rpt}") + diag_match_len=${#diag_match} + fi + + if [[ "${diag_match_len}" -eq 0 ]]; then + + if [[ "${type}" == "chan" ]]; then + echo "looking for match for ${satname} and ${channel}" + { while read -r myline2; do + satname2=$(echo "${myline2}" | gawk '{print $1}') + channel2=$(echo "${myline2}" | gawk '{print $3}') + + if [[ "${satname}" == "${satname2}" && "${channel}" == "${channel2}" ]]; then + match="${satname} channel= ${channel}" + echo "match from gawk = ${match}" + break + else + match="" + fi + + done; } < "${file2}" + + else + match=$(gawk "/${satname}/ && /channel= ${channel} / && /region= ${region} /" "${file2}") + echo match = "${match}" + + match_len=${#match} + if ((match_len > 0)); then + channel2=$(echo "${match}" | gawk '{print $3}') + + if [[ "${channel2}" != "${channel}" ]]; then + match="" + fi fi - done } < "${file2}" - + fi + match_len=${#match} - else - match=$(gawk "/${satname}/ && /channel= ${channel} / && /region= ${region} /" "${file2}") - echo match = "${match}" + if [[ "${match_len}" -gt 0 ]]; then - match_len=$(echo ${#match}) - if (( match_len > 0 )); then - channel2=$(echo "${match}" | gawk '{print $3}') - - if [[ ${channel2} != ${channel} ]]; then - match="" - fi - fi + value2=$(echo "${match}" | gawk '{print $7}') + bound2=$(echo "${match}" | gawk '{print $9}') - fi - match_len=$(echo ${#match}) - - if (( match_len > 0 )); then + if [[ ${type} == "chan" ]]; then + tmpa=" ${satname} channel= ${channel}" + tmpb="" - value2=$(echo "${match}" | gawk '{print $7}') - bound2=$(echo "${match}" | gawk '{print $9}') + elif [[ ${type} == "pen" ]]; then + tmpa="${satname} channel= ${channel} region= ${region}" + tmpb="${cycle1} ${value1} ${bound}" - if [[ ${type} == "chan" ]]; then - tmpa=" ${satname} channel= ${channel}" - tmpb="" + elif [[ ${type} == "cnt" ]]; then + tmpa="${satname} channel= ${channel} region= ${region}" + tmpb="${cycle1} ${value1} ${bound}" - elif [[ ${type} == "pen" ]]; then - tmpa="${satname} channel= ${channel} region= ${region}" - tmpb="${cycle1} ${value1} ${bound}" - - elif [[ ${type} == "cnt" ]]; then - tmpa="${satname} channel= ${channel} region= ${region}" - tmpb="${cycle1} ${value1} ${bound}" - - else - tmpa="${satname} channel= ${channel} region= ${region}" - tmpb="${cycle1}: ${type}= ${value1}" - fi + else + tmpa="${satname} channel= ${channel} region= ${region}" + tmpb="${cycle1}: ${type}= ${value1}" + fi - line1="${tmpa} ${tmpb}" - echo "${line1}" >> "${outfile}" + line1="${tmpa} ${tmpb}" + echo "${line1}" >> "${outfile}" - if [[ ${type} != "chan" ]]; then - tmpc=$(echo "${tmpa}" |sed 's/[a-z]/ /g' | sed 's/[0-9]/ /g' | sed 's/=/ /g' | sed 's/_/ /g' | sed 's/-/ /g') + if [[ ${type} != "chan" ]]; then + tmpc="${tmpa//[a-z0-9\-_\=]/}" - if [[ ${type} == "pen" || ${type} == "cnt" ]]; then - line2=" ${tmpc} ${cycle2} ${value2} ${bound2}" - else - line2=" ${tmpc} ${cycle2}: ${type}= ${value2}" - fi + if [[ ${type} == "pen" || ${type} == "cnt" ]]; then + line2=" ${tmpc} ${cycle2} ${value2} ${bound2}" + else + line2=" ${tmpc} ${cycle2}: ${type}= ${value2}" + fi - echo "${line2}" >> "${outfile}" - fi - - #----------------------------------------- - # add hyperlink to warning entry - # - line3=" http://www.emc.ncep.noaa.gov/gmb/gdas/radiance/es_rad/${RADMON_SUFFIX}/index.html?sat=${satname}®ion=${region}&channel=${channel}&stat=${type}" - if [[ ${channel} -gt 0 ]]; then - echo "${line3}" >> "${outfile}" - echo "" >> "${outfile}" - fi - fi - fi -done } < "${file1}" + echo "${line2}" >> "${outfile}" + fi + #----------------------------------------- + # add hyperlink to warning entry + # + line3=" http://www.emc.ncep.noaa.gov/gmb/gdas/radiance/es_rad/${RADMON_SUFFIX}/index.html?sat=${satname}®ion=${region}&channel=${channel}&stat=${type}" + if [[ "${channel}" -gt 0 ]]; then + echo "${line3}" >> "${outfile}" + echo "" >> "${outfile}" + fi + fi + fi +done; } < "${file1}" ################################################################################ # Post processing -exit ${err} - +exit "${err}" diff --git a/ush/radmon_verf_angle.sh b/ush/radmon_verf_angle.sh index 79046fae44f..1a4d8d5aa3c 100755 --- a/ush/radmon_verf_angle.sh +++ b/ush/radmon_verf_angle.sh @@ -69,14 +69,11 @@ rgnTM=${rgnTM:-} echo " REGIONAL_RR, rgnHH, rgnTM = ${REGIONAL_RR}, ${rgnHH}, ${rgnTM}" netcdf_boolean=".false." -if [[ ${RADMON_NETCDF} -eq 1 ]]; then - netcdf_boolean=".true." +if [[ "${RADMON_NETCDF}" -eq 1 ]]; then + netcdf_boolean=".true." fi echo " RADMON_NETCDF, netcdf_boolean = ${RADMON_NETCDF}, ${netcdf_boolean}" -which prep_step -which startmsg - # File names touch "${pgmout}" @@ -86,11 +83,10 @@ VERBOSE=${VERBOSE:-NO} LITTLE_ENDIAN=${LITTLE_ENDIAN:-0} USE_ANL=${USE_ANL:-0} - if [[ ${USE_ANL} -eq 1 ]]; then - gesanl="ges anl" + gesanl="ges anl" else - gesanl="ges" + gesanl="ges" fi angle_exec=radmon_angle.x @@ -101,12 +97,12 @@ scaninfo=scaninfo.txt # Copy extraction program and supporting files to working directory cpreq "${EXECgfs}/${angle_exec}" ./ -cpreq "${shared_scaninfo}" ./${scaninfo} +cpreq "${shared_scaninfo}" "./${scaninfo}" #-------------------------------------------------------------------- # Run program for given time -export pgm=${angle_exec} +export pgm="${angle_exec}" iyy="${PDY:0:4}" imm="${PDY:4:2}" @@ -117,39 +113,38 @@ touch "./errfile" for type in ${SATYPE}; do - if [[ ! -s ${type} ]]; then - echo "ZERO SIZED: ${type}" - continue - fi - - for dtype in ${gesanl}; do - - echo "pgm = ${pgm}" - echo "pgmout = ${pgmout}" - source prep_step - - if [[ ${dtype} == "anl" ]]; then - data_file="${type}_anl.${PDY}${cyc}.ieee_d" - ctl_file=${type}_anl.ctl - angl_ctl=angle.${ctl_file} - else - data_file="${type}.${PDY}${cyc}.ieee_d" - ctl_file=${type}.ctl - angl_ctl=angle.${ctl_file} - fi - - angl_file="" - if [[ ${REGIONAL_RR} -eq 1 ]]; then - angl_file=${rgnHH}.${data_file}.${rgnTM} - fi - - - if [[ -f input ]]; then - rm -f input - fi - - nchanl=-999 - cat << EOF > input + if [[ ! -s "${type}" ]]; then + echo "ZERO SIZED: ${type}" + continue + fi + + for dtype in ${gesanl}; do + + echo "pgm = ${pgm}" + echo "pgmout = ${pgmout}" + source prep_step + + if [[ "${dtype}" == "anl" ]]; then + data_file="${type}_anl.${PDY}${cyc}.ieee_d" + ctl_file="${type}_anl.ctl" + angl_ctl="angle.${ctl_file}" + else + data_file="${type}.${PDY}${cyc}.ieee_d" + ctl_file="${type}.ctl" + angl_ctl="angle.${ctl_file}" + fi + + angl_file="" + if [[ "${REGIONAL_RR}" -eq 1 ]]; then + angl_file="${rgnHH}.${data_file}.${rgnTM}" + fi + + if [[ -f input ]]; then + rm -f input + fi + + nchanl=-999 + cat << EOF > input &INPUT satname='${type}', iyy=${iyy}, @@ -167,44 +162,42 @@ for type in ${SATYPE}; do / EOF - startmsg - ./${angle_exec} < input >> "${pgmout}" 2>>errfile - export err=$? - - if [[ ${err} -ne 0 ]]; then - echo "FATAL ERROR: ${angle_exec} failed for instrument ${type} and datatype ${dtype}!" - exit "${err}" - fi - - if [[ -s ${angl_file} ]]; then - ${COMPRESS} -f "${angl_file}" - fi + startmsg + "./${angle_exec}" < input >> "${pgmout}" 2>> errfile + export err=$? - if [[ -s ${angl_ctl} ]]; then - ${COMPRESS} -f "${angl_ctl}" - fi + if [[ ${err} -ne 0 ]]; then + echo "FATAL ERROR: ${angle_exec} failed for instrument ${type} and datatype ${dtype}!" + exit "${err}" + fi + if [[ -s "${angl_file}" ]]; then + ${COMPRESS} -f "${angl_file}" + fi - done # for dtype in ${gesanl} loop + if [[ -s "${angl_ctl}" ]]; then + ${COMPRESS} -f "${angl_ctl}" + fi -done # for type in ${SATYPE} loop + done # for dtype in ${gesanl} loop +done # for type in ${SATYPE} loop "${USHgfs}/rstprod.sh" tar_file=radmon_angle.tar if compgen -G "angle*.ieee_d*" > /dev/null || compgen -G "angle*.ctl*" > /dev/null; then - tar -cf "${tar_file}" angle*.ieee_d* angle*.ctl* - ${COMPRESS} ${tar_file} - mv "${tar_file}.${Z}" "${TANKverf_rad}/." - - if [[ ${RAD_AREA} = "rgn" ]]; then - cwd=$(pwd) - cd "${TANKverf_rad}" - tar -xf "${tar_file}.${Z}" - rm -f "${tar_file}.${Z}" - cd "${cwd}" - fi + tar -cf "${tar_file}" angle*.ieee_d* angle*.ctl* + ${COMPRESS} "${tar_file}" + mv "${tar_file}.${Z}" "${TANKverf_rad}/." + + if [[ "${RAD_AREA}" == "rgn" ]]; then + cwd=$(pwd) + cd "${TANKverf_rad}" || exit 1 + tar -xf "${tar_file}.${Z}" + rm -f "${tar_file}.${Z}" + cd "${cwd}" || exit 1 + fi fi ################################################################################ diff --git a/ush/radmon_verf_bcoef.sh b/ush/radmon_verf_bcoef.sh index a4af9155d14..fa92f0d0432 100755 --- a/ush/radmon_verf_bcoef.sh +++ b/ush/radmon_verf_bcoef.sh @@ -4,13 +4,13 @@ #### UNIX Script Documentation Block # . . # Script name: radmon_verf_bcoef.sh -# Script description: Extract bias correction coefficients data from radiance +# Script description: Extract bias correction coefficients data from radiance # diagnostic files. # # Author: Ed Safford Org: NP23 Date: 2012-02-02 # -# Abstract: This script extracts bias correction coefficient related data from -# radiance diagnostic files (which are an output from GSI runs), +# Abstract: This script extracts bias correction coefficient related data from +# radiance diagnostic files (which are an output from GSI runs), # storing the extracted data in small binary files. # # This script is a child script of exgdas_vrfyrad.sh.sms. The parent @@ -35,11 +35,11 @@ # defaults to none # LITTLE_ENDIAN flag for LE machine # defaults to 0 (big endian) -# USE_ANL use analysis files as inputs in addition to +# USE_ANL use analysis files as inputs in addition to # the ges files. Default is 0 (ges only) # # Modules and files referenced: -# scripts : +# scripts : # # programs : $bcoef_exec # @@ -60,8 +60,8 @@ #################################################################### netcdf_boolean=".false." -if [[ ${RADMON_NETCDF} -eq 1 ]]; then - netcdf_boolean=".true." +if [[ "${RADMON_NETCDF}" -eq 1 ]]; then + netcdf_boolean=".true." fi echo " RADMON_NETCDF, netcdf_boolean = ${RADMON_NETCDF}, ${netcdf_boolean}" @@ -77,25 +77,24 @@ SATYPE=${SATYPE:-} LITTLE_ENDIAN=${LITTLE_ENDIAN:-0} USE_ANL=${USE_ANL:-0} - bcoef_exec=radmon_bcoef.x -if [[ ${USE_ANL} -eq 1 ]]; then - gesanl="ges anl" +if [[ "${USE_ANL}" -eq 1 ]]; then + gesanl="ges anl" else - gesanl="ges" + gesanl="ges" fi #-------------------------------------------------------------------- # Copy extraction program and supporting files to working directory -cpreq "${EXECgfs}/${bcoef_exec}" ./${bcoef_exec} -cpreq "${biascr}" ./biascr.txt +cpreq "${EXECgfs}/${bcoef_exec}" "./${bcoef_exec}" +cpreq "${biascr}" ./biascr.txt #-------------------------------------------------------------------- # Run program for given time -export pgm=${bcoef_exec} +export pgm="${bcoef_exec}" iyy="${PDY:0:4}" imm="${PDY:4:2}" @@ -107,39 +106,36 @@ npredr=5 for type in ${SATYPE}; do - if [[ ! -s ${type} ]]; then - echo "ZERO SIZED: ${type}" - continue - fi - - for dtype in ${gesanl}; do - - source prep_step + if [[ ! -s "${type}" ]]; then + echo "ZERO SIZED: ${type}" + continue + fi - if [[ ${dtype} == "anl" ]]; then - data_file="${type}_anl.${PDY}${cyc}.ieee_d" - ctl_file=${type}_anl.ctl - bcoef_ctl=bcoef.${ctl_file} - else - data_file="${type}.${PDY}${cyc}.ieee_d" - ctl_file=${type}.ctl - bcoef_ctl=bcoef.${ctl_file} - fi + for dtype in ${gesanl}; do - if [[ ${REGIONAL_RR} -eq 1 ]]; then - bcoef_file=${rgnHH}.bcoef.${data_file}.${rgnTM} - else - bcoef_file=bcoef.${data_file} - fi + source prep_step + if [[ "${dtype}" == "anl" ]]; then + data_file="${type}_anl.${PDY}${cyc}.ieee_d" + ctl_file="${type}_anl.ctl" + bcoef_ctl="bcoef.${ctl_file}" + else + data_file="${type}.${PDY}${cyc}.ieee_d" + ctl_file="${type}.ctl" + bcoef_ctl="bcoef.${ctl_file}" + fi - if [[ -f input ]]; - then - rm -f input - fi + if [[ "${REGIONAL_RR}" -eq 1 ]]; then + bcoef_file="${rgnHH}.bcoef.${data_file}.${rgnTM}" + else + bcoef_file="bcoef.${data_file}" + fi + if [[ -f input ]]; then + rm -f input + fi - cat << EOF > input + cat << EOF > input &INPUT satname='${type}', npredr=${npredr}, @@ -156,50 +152,46 @@ for type in ${SATYPE}; do netcdf=${netcdf_boolean}, / EOF - startmsg - ./${bcoef_exec} < input >>"${pgmout}" 2>>errfile - export err=$? - if [[ ${err} -ne 0 ]]; then - echo "FATAL ERROR: ${bcoef_exec} failed for instrument ${type} and datatype ${dtype}" - exit "${err}" - fi - - -#------------------------------------------------------------------- -# move data, control, and stdout files to $TANKverf_rad and compress -# - - if [[ -s ${bcoef_file} ]]; then - ${COMPRESS} "${bcoef_file}" - fi - - if [[ -s ${bcoef_ctl} ]]; then - ${COMPRESS} "${bcoef_ctl}" - fi - - - done # dtype in $gesanl loop + startmsg + "./${bcoef_exec}" < input >> "${pgmout}" 2>> errfile + export err=$? + if [[ "${err}" -ne 0 ]]; then + echo "FATAL ERROR: ${bcoef_exec} failed for instrument ${type} and datatype ${dtype}" + exit "${err}" + fi + + #------------------------------------------------------------------- + # move data, control, and stdout files to $TANKverf_rad and compress + # + + if [[ -s "${bcoef_file}" ]]; then + ${COMPRESS} "${bcoef_file}" + fi + + if [[ -s "${bcoef_ctl}" ]]; then + ${COMPRESS} "${bcoef_ctl}" + fi + + done # dtype in $gesanl loop done # type in $SATYPE loop - "${USHgfs}/rstprod.sh" if compgen -G "bcoef*.ieee_d*" > /dev/null || compgen -G "bcoef*.ctl*" > /dev/null; then - tar_file=radmon_bcoef.tar - tar -cf ${tar_file} bcoef*.ieee_d* bcoef*.ctl* - ${COMPRESS} ${tar_file} - mv "${tar_file}.${Z}" "${TANKverf_rad}" - - if [[ ${RAD_AREA} = "rgn" ]]; then - cwd=$(pwd) - cd "${TANKverf_rad}" || exit 1 - tar -xf "${tar_file}.${Z}" - rm -f "${tar_file}.${Z}" - cd "${cwd}" || exit 1 - fi + tar_file=radmon_bcoef.tar + tar -cf "${tar_file}" bcoef*.ieee_d* bcoef*.ctl* + ${COMPRESS} "${tar_file}" + mv "${tar_file}.${Z}" "${TANKverf_rad}" + + if [[ ${RAD_AREA} = "rgn" ]]; then + cwd=$(pwd) + cd "${TANKverf_rad}" || exit 1 + tar -xf "${tar_file}.${Z}" + rm -f "${tar_file}.${Z}" + cd "${cwd}" || exit 1 + fi fi - ################################################################################ # Post processing diff --git a/ush/radmon_verf_bcor.sh b/ush/radmon_verf_bcor.sh index 134f0d1dd1a..dcf9e2d2ec0 100755 --- a/ush/radmon_verf_bcor.sh +++ b/ush/radmon_verf_bcor.sh @@ -73,26 +73,25 @@ USE_ANL=${USE_ANL:-0} bcor_exec=radmon_bcor.x netcdf_boolean=".false." -if [[ ${RADMON_NETCDF} -eq 1 ]]; then - netcdf_boolean=".true." +if [[ "${RADMON_NETCDF}" -eq 1 ]]; then + netcdf_boolean=".true." fi -if [[ ${USE_ANL} -eq 1 ]]; then - gesanl="ges anl" +if [[ "${USE_ANL}" -eq 1 ]]; then + gesanl="ges anl" else - gesanl="ges" + gesanl="ges" fi - #-------------------------------------------------------------------- # Copy extraction program to working directory -cpreq "${EXECgfs}/${bcor_exec}" ./${bcor_exec} +cpreq "${EXECgfs}/${bcor_exec}" "./${bcor_exec}" #-------------------------------------------------------------------- # Run program for given time -export pgm=${bcor_exec} +export pgm="${bcor_exec}" iyy="${PDY:0:4}" imm="${PDY:4:2}" @@ -103,39 +102,35 @@ touch "./errfile" for type in ${SATYPE}; do - for dtype in ${gesanl}; do - - source prep_step - - if [[ ${dtype} == "anl" ]]; then - data_file="${type}_anl.${PDY}${cyc}.ieee_d" - bcor_file=bcor.${data_file} - ctl_file=${type}_anl.ctl - bcor_ctl=bcor.${ctl_file} - stdout_file=stdout.${type}_anl - bcor_stdout=bcor.${stdout_file} - input_file=${type}_anl - else - data_file="${type}.${PDY}${cyc}.ieee_d" - bcor_file=bcor.${data_file} - ctl_file=${type}.ctl - bcor_ctl=bcor.${ctl_file} - stdout_file=stdout.${type} - bcor_stdout=bcor.${stdout_file} - input_file=${type} - fi - - if [[ -f input ]]; then - rm -f input - fi - - # Check for 0 length input file here and avoid running - # the executable if $input_file doesn't exist or is 0 bytes - # - if [[ -s "${input_file}" ]]; then - nchanl=-999 - - cat << EOF > input + for dtype in ${gesanl}; do + + source prep_step + + if [[ ${dtype} == "anl" ]]; then + data_file="${type}_anl.${PDY}${cyc}.ieee_d" + bcor_file=bcor.${data_file} + ctl_file=${type}_anl.ctl + bcor_ctl=bcor.${ctl_file} + input_file=${type}_anl + else + data_file="${type}.${PDY}${cyc}.ieee_d" + bcor_file=bcor.${data_file} + ctl_file=${type}.ctl + bcor_ctl=bcor.${ctl_file} + input_file=${type} + fi + + if [[ -f input ]]; then + rm -f input + fi + + # Check for 0 length input file here and avoid running + # the executable if $input_file doesn't exist or is 0 bytes + # + if [[ -s "${input_file}" ]]; then + nchanl=-999 + + cat << EOF > input &INPUT satname='${type}', iyy=${iyy}, @@ -153,47 +148,45 @@ for type in ${SATYPE}; do / EOF - startmsg - ./${bcor_exec} < input >> "${pgmout}" 2>>errfile - export err=$? - if [[ ${err} -ne 0 ]]; then - echo "FATAL ERROR: ${bcor_exec} failed for instrument ${type} and datatype ${dtype}!" - exit "${err}" - fi - + startmsg + "./${bcor_exec}" < input >> "${pgmout}" 2>> errfile + export err=$? + if [[ "${err}" -ne 0 ]]; then + msg="FATAL ERROR: ${bcor_exec} failed for instrument ${type} and datatype ${dtype}!" + err_exit "${msg}" + fi -#------------------------------------------------------------------- -# move data, control, and stdout files to $TANKverf_rad and compress -# + #------------------------------------------------------------------- + # move data, control, and stdout files to $TANKverf_rad and compress + # - if [[ -s ${bcor_file} ]]; then - ${COMPRESS} "${bcor_file}" - fi + if [[ -s "${bcor_file}" ]]; then + ${COMPRESS} "${bcor_file}" + fi - if [[ -s ${bcor_ctl} ]]; then - ${COMPRESS} "${bcor_ctl}" - fi + if [[ -s "${bcor_ctl}" ]]; then + ${COMPRESS} "${bcor_ctl}" + fi - fi - done # dtype in $gesanl loop + fi + done # dtype in $gesanl loop done # type in $SATYPE loop - "${USHgfs}/rstprod.sh" tar_file=radmon_bcor.tar if compgen -G "bcor*.ieee_d*" > /dev/null || compgen -G "bcor*.ctl*" > /dev/null; then - tar -cf "${tar_file}" bcor*.ieee_d* bcor*.ctl* - ${COMPRESS} ${tar_file} - mv "${tar_file}.${Z}" "${TANKverf_rad}/." - - if [[ ${RAD_AREA} = "rgn" ]]; then - cwd=$(pwd) - cd "${TANKverf_rad}" || exit 1 - tar -xf "${tar_file}.${Z}" - rm -f "${tar_file}.${Z}" - cd "${cwd}" || exit 1 - fi + tar -cf "${tar_file}" bcor*.ieee_d* bcor*.ctl* + ${COMPRESS} "${tar_file}" + mv "${tar_file}.${Z}" "${TANKverf_rad}/." + + if [[ ${RAD_AREA} = "rgn" ]]; then + cwd=$(pwd) + cd "${TANKverf_rad}" || exit 1 + tar -xf "${tar_file}.${Z}" + rm -f "${tar_file}.${Z}" + cd "${cwd}" || exit 1 + fi fi ################################################################################ diff --git a/ush/radmon_verf_time.sh b/ush/radmon_verf_time.sh index 0158697304c..9f9ab5471df 100755 --- a/ush/radmon_verf_time.sh +++ b/ush/radmon_verf_time.sh @@ -81,7 +81,6 @@ diag_hdr=diag_hdr.txt diag=diag.txt obs_err=obs_err.txt -obs_hdr=obs_hdr.txt pen_err=pen_err.txt pen_hdr=pen_hdr.txt @@ -91,8 +90,8 @@ count_hdr=count_hdr.txt count_err=count_err.txt netcdf_boolean=".false." -if [[ ${RADMON_NETCDF} -eq 1 ]]; then - netcdf_boolean=".true." +if [[ "${RADMON_NETCDF}" -eq 1 ]]; then + netcdf_boolean=".true." fi DO_DATA_RPT=${DO_DATA_RPT:-1} @@ -108,13 +107,12 @@ LITTLE_ENDIAN=${LITTLE_ENDIAN:-0} time_exec=radmon_time.x USE_ANL=${USE_ANL:-0} -if [[ ${USE_ANL} -eq 1 ]]; then - gesanl="ges anl" +if [[ "${USE_ANL}" -eq 1 ]]; then + gesanl="ges anl" else - gesanl="ges" + gesanl="ges" fi - #-------------------------------------------------------------------- # Copy extraction program and base files to working directory #------------------------------------------------------------------- @@ -126,22 +124,22 @@ idd="${PDY:6:2}" ihh=${cyc} local_base="local_base" -if [[ ${DO_DATA_RPT} -eq 1 ]]; then - - if [[ -e ${base_file}.${Z} ]]; then - cpreq "${base_file}.${Z}" "./${local_base}.${Z}" - ${UNCOMPRESS} "${local_base}.${Z}" - else - cpreq "${base_file}" ./${local_base} - fi - - if [[ ! -s ./${local_base} ]]; then - echo "RED LIGHT: local_base file not found" - else - echo "Confirming local_base file is good = ${local_base}" - tar -xf ./${local_base} - echo "local_base is untarred" - fi +if [[ "${DO_DATA_RPT}" -eq 1 ]]; then + + if [[ -e "${base_file}.${Z}" ]]; then + cpreq "${base_file}.${Z}" "./${local_base}.${Z}" + ${UNCOMPRESS} "${local_base}.${Z}" + else + cpreq "${base_file}" "./${local_base}" + fi + + if [[ ! -s "./${local_base}" ]]; then + echo "RED LIGHT: local_base file not found" + else + echo "Confirming local_base file is good = ${local_base}" + tar -xf "./${local_base}" + echo "local_base is untarred" + fi fi export pgm=${time_exec} @@ -150,41 +148,40 @@ export pgm=${time_exec} #-------------------------------------------------------------------- for type in ${SATYPE}; do - if [[ ! -s ${type} ]]; then - echo "ZERO SIZED: ${type}" - continue - fi - - source prep_step - - for dtype in ${gesanl}; do - - if [[ -f input ]] - then - rm -f input - fi - - if [[ ${dtype} == "anl" ]]; then - data_file="${type}_anl.${PDY}${cyc}.ieee_d" - ctl_file=${type}_anl.ctl - time_ctl=time.${ctl_file} - else - data_file="${type}.${PDY}${cyc}.ieee_d" - ctl_file=${type}.ctl - time_ctl=time.${ctl_file} - fi - - if [[ ${REGIONAL_RR} -eq 1 ]]; then - time_file=${rgnHH}.time.${data_file}.${rgnTM} - else - time_file=time.${data_file} - fi - -#-------------------------------------------------------------------- -# Run program for given satellite/instrument -#-------------------------------------------------------------------- - nchanl=-999 - cat << EOF > input + if [[ ! -s ${type} ]]; then + echo "ZERO SIZED: ${type}" + continue + fi + + source prep_step + + for dtype in ${gesanl}; do + + if [[ -f input ]]; then + rm -f input + fi + + if [[ "${dtype}" == "anl" ]]; then + data_file="${type}_anl.${PDY}${cyc}.ieee_d" + ctl_file="${type}_anl.ctl" + time_ctl="time.${ctl_file}" + else + data_file="${type}.${PDY}${cyc}.ieee_d" + ctl_file="${type}.ctl" + time_ctl="time.${ctl_file}" + fi + + if [[ "${REGIONAL_RR}" -eq 1 ]]; then + time_file="${rgnHH}.time.${data_file}.${rgnTM}" + else + time_file="time.${data_file}" + fi + + #-------------------------------------------------------------------- + # Run program for given satellite/instrument + #-------------------------------------------------------------------- + nchanl=-999 + cat << EOF > input &INPUT satname='${type}', iyy=${iyy}, @@ -202,62 +199,59 @@ for type in ${SATYPE}; do / EOF - ./${time_exec} < input >> stdout."${type}" 2>>errfile - export err=$? + "./${time_exec}" < input >> "stdout.${type}" 2>> errfile + export err=$? - if [[ ${err} -ne 0 ]]; then - echo "FATAL ERROR: failed to calculate radiance time statistics for instrument ${type} and datatype ${dtype}!" - exit "${err}" - fi + if [[ "${err}" -ne 0 ]]; then + echo "FATAL ERROR: failed to calculate radiance time statistics for instrument ${type} and datatype ${dtype}!" + exit "${err}" + fi -#------------------------------------------------------------------- -# move data, control, and stdout files to $TANKverf_rad and compress -#------------------------------------------------------------------- - cat "stdout.${type}" >> stdout.time + #------------------------------------------------------------------- + # move data, control, and stdout files to $TANKverf_rad and compress + #------------------------------------------------------------------- + cat "stdout.${type}" >> stdout.time - if [[ -s ${time_file} ]]; then - ${COMPRESS} "${time_file}" - fi + if [[ -s "${time_file}" ]]; then + ${COMPRESS} "${time_file}" + fi - if [[ -s ${time_ctl} ]]; then - ${COMPRESS} "${time_ctl}" - fi + if [[ -s "${time_ctl}" ]]; then + ${COMPRESS} "${time_ctl}" + fi - done + done done - "${USHgfs}/rstprod.sh" if compgen -G "time*.ieee_d*" > /dev/null || compgen -G "time*.ctl*" > /dev/null; then - tar_file=radmon_time.tar - tar -cf "${tar_file}" time*.ieee_d* time*.ctl* - ${COMPRESS} ${tar_file} - mv "${tar_file}.${Z}" "${TANKverf_rad}/." - - if [[ ${RAD_AREA} = "rgn" ]]; then - cwd=$(pwd) - cd "${TANKverf_rad}" || exit 1 - tar -xf "${tar_file}.${Z}" - rm -f "${tar_file}.${Z}" - cd "${cwd}" || exit 1 - fi + tar_file=radmon_time.tar + tar -cf "${tar_file}" time*.ieee_d* time*.ctl* + ${COMPRESS} "${tar_file}" + mv "${tar_file}.${Z}" "${TANKverf_rad}/." + + if [[ "${RAD_AREA}" == "rgn" ]]; then + cwd=$(pwd) + cd "${TANKverf_rad}" || exit 1 + tar -xf "${tar_file}.${Z}" + rm -f "${tar_file}.${Z}" + cd "${cwd}" || exit 1 + fi fi - - #################################################################### #------------------------------------------------------------------- # Begin error analysis and reporting #------------------------------------------------------------------- #################################################################### -if [[ ${DO_DATA_RPT} -eq 1 ]]; then +if [[ "${DO_DATA_RPT}" -eq 1 ]]; then -#--------------------------- -# build report disclaimer -# - cat << EOF > ${disclaimer} + #--------------------------- + # build report disclaimer + # + cat << EOF > "${disclaimer}" *********************** WARNING *************************** @@ -266,16 +260,15 @@ RECEIVED. PLEASE DIRECT REPLIES TO edward.safford@noaa.gov *********************** WARNING *************************** EOF + #------------------------------------------------------------------- + # Check for missing diag files + # + tmp_satype="./tmp_satype.txt" + echo "${SATYPE}" > "${tmp_satype}" + "${USHgfs}/radmon_diag_ck.sh" --rad "${radstat}" --sat "${tmp_satype}" --out "${diag}" -#------------------------------------------------------------------- -# Check for missing diag files -# - tmp_satype="./tmp_satype.txt" - echo "${SATYPE}" > ${tmp_satype} - "${USHgfs}/radmon_diag_ck.sh" --rad "${radstat}" --sat "${tmp_satype}" --out "${diag}" - - if [[ -s ${diag} ]]; then - cat << EOF > ${diag_hdr} + if [[ -s "${diag}" ]]; then + cat << EOF > "${diag_hdr}" Problem Reading Diagnostic File @@ -285,137 +278,134 @@ EOF EOF - cat ${diag_hdr} >> ${diag_report} - cat ${diag} >> ${diag_report} - - echo >> ${diag_report} - - rm -f "${diag_hdr}" - fi - -#------------------------------------------------------------------- -# move warning notification to TANKverf -# - if [[ -s ${diag} ]]; then - lines=$(wc -l <${diag}) - echo "lines in diag = ${lines}" - - if [[ ${lines} -gt 0 ]]; then - cat "${diag_report}" - cpfs "${diag}" "${TANKverf_rad}/bad_diag.${PDY}${cyc}" - else - rm -f "${diag_report}" - fi - fi - - - - #---------------------------------------------------------------- - # Identify bad_pen and bad_chan files for this cycle and - # previous cycle - - bad_pen=bad_pen.${PDY}${cyc} - bad_chan=bad_chan.${PDY}${cyc} - low_count=low_count.${PDY}${cyc} - - qdate=$(date --utc +%Y%m%d%H -d "${PDY} ${cyc} - ${assim_freq} hours") - pday="${qdate:0:8}" - - prev_bad_pen=bad_pen.${qdate} - prev_bad_chan=bad_chan.${qdate} - prev_low_count=low_count.${qdate} - - prev_bad_pen=${TANKverf_radM1}/${prev_bad_pen} - prev_bad_chan=${TANKverf_radM1}/${prev_bad_chan} - prev_low_count=${TANKverf_radM1}/${prev_low_count} - - if [[ -s ${bad_pen} ]]; then - echo "pad_pen = ${bad_pen}" - fi - if [[ -s ${prev_bad_pen} ]]; then - echo "prev_pad_pen = ${prev_bad_pen}" - fi - - if [[ -s ${bad_chan} ]]; then - echo "bad_chan = ${bad_chan}" - fi - if [[ -s ${prev_bad_chan} ]]; then - echo "prev_bad_chan = ${prev_bad_chan}" - fi - if [[ -s ${low_count} ]]; then - echo "low_count = ${low_count}" - fi - if [[ -s ${prev_low_count} ]]; then - echo "prev_low_count = ${prev_low_count}" - fi - - do_pen=0 - do_chan=0 - do_cnt=0 - - if [[ -s ${bad_pen} && -s ${prev_bad_pen} ]]; then - do_pen=1 - fi - - if [[ -s ${low_count} && -s ${prev_low_count} ]]; then - do_cnt=1 - fi - - #-------------------------------------------------------------------- - # avoid doing the bad_chan report for REGIONAL_RR sources -- because - # they run hourly they often have 0 count channels for off-hour runs. - # - if [[ -s ${bad_chan} && -s ${prev_bad_chan} && REGIONAL_RR -eq 0 ]]; then - do_chan=1 - fi - - #-------------------------------------------------------------------- - # Remove extra spaces in new bad_pen & low_count files - # - if [[ -s ${bad_pen} ]]; then - gawk '{$1=$1}1' "${bad_pen}" > tmp.bad_pen - mv -f tmp.bad_pen "${bad_pen}" - fi - if [[ -s ${low_count} ]]; then - gawk '{$1=$1}1' "${low_count}" > tmp.low_count - mv -f tmp.low_count "${low_count}" - fi - - echo " do_pen, do_chan, do_cnt = ${do_pen}, ${do_chan}, ${do_cnt}" - echo " diag_report = ${diag_report} " - if [[ ${do_pen} -eq 1 || ${do_chan} -eq 1 || ${do_cnt} -eq 1 || -s ${diag_report} ]]; then - - if [[ ${do_pen} -eq 1 ]]; then - - echo "calling radmon_err_rpt for pen" - ${radmon_err_rpt} "${prev_bad_pen}" "${bad_pen}" pen "${qdate}" \ - "${PDY}${cyc}" ${diag_report} ${pen_err} - fi - - if [[ ${do_chan} -eq 1 ]]; then - - echo "calling radmon_err_rpt for chan" - ${radmon_err_rpt} "${prev_bad_chan}" "${bad_chan}" chan "${qdate}" \ - "${PDY}${cyc}" ${diag_report} ${chan_err} - fi - - if [[ ${do_cnt} -eq 1 ]]; then - - echo "calling radmon_err_rpt for cnt" - ${radmon_err_rpt} "${prev_low_count}" "${low_count}" cnt "${qdate}" \ - "${PDY}${cyc}" ${diag_report} ${count_err} - fi - - #------------------------------------------------------------------- - # put together the unified error report with any obs, chan, and - # penalty problems and mail it - - if [[ -s ${obs_err} || -s ${pen_err} || -s ${chan_err} || -s ${count_err} || -s ${diag_report} ]]; then - - echo DOING ERROR REPORTING - - - cat << EOF > ${report} + { + cat "${diag_hdr}" + cat "${diag}" + echo + } >> "${diag_report}" + + rm -f "${diag_hdr}" + fi + + #------------------------------------------------------------------- + # move warning notification to TANKverf + # + if [[ -s "${diag}" ]]; then + lines=$(wc -l < "${diag}") + echo "lines in diag = ${lines}" + + if [[ "${lines}" -gt 0 ]]; then + cat "${diag_report}" + cpfs "${diag}" "${TANKverf_rad}/bad_diag.${PDY}${cyc}" + else + rm -f "${diag_report}" + fi + fi + + #---------------------------------------------------------------- + # Identify bad_pen and bad_chan files for this cycle and + # previous cycle + + bad_pen="bad_pen.${PDY}${cyc}" + bad_chan="bad_chan.${PDY}${cyc}" + low_count="low_count.${PDY}${cyc}" + + qdate=$(date --utc +%Y%m%d%H -d "${PDY} ${cyc} - ${assim_freq} hours") + + prev_bad_pen=bad_pen.${qdate} + prev_bad_chan=bad_chan.${qdate} + prev_low_count=low_count.${qdate} + + prev_bad_pen=${TANKverf_radM1}/${prev_bad_pen} + prev_bad_chan=${TANKverf_radM1}/${prev_bad_chan} + prev_low_count=${TANKverf_radM1}/${prev_low_count} + + if [[ -s "${bad_pen}" ]]; then + echo "pad_pen = ${bad_pen}" + fi + if [[ -s "${prev_bad_pen}" ]]; then + echo "prev_pad_pen = ${prev_bad_pen}" + fi + + if [[ -s "${bad_chan}" ]]; then + echo "bad_chan = ${bad_chan}" + fi + if [[ -s "${prev_bad_chan}" ]]; then + echo "prev_bad_chan = ${prev_bad_chan}" + fi + if [[ -s "${low_count}" ]]; then + echo "low_count = ${low_count}" + fi + if [[ -s "${prev_low_count}" ]]; then + echo "prev_low_count = ${prev_low_count}" + fi + + do_pen=0 + do_chan=0 + do_cnt=0 + + if [[ -s "${bad_pen}" && -s "${prev_bad_pen}" ]]; then + do_pen=1 + fi + + if [[ -s "${low_count}" && -s "${prev_low_count}" ]]; then + do_cnt=1 + fi + + #-------------------------------------------------------------------- + # avoid doing the bad_chan report for REGIONAL_RR sources -- because + # they run hourly they often have 0 count channels for off-hour runs. + # + if [[ -s "${bad_chan}" && -s "${prev_bad_chan}" && "${REGIONAL_RR}" -eq 0 ]]; then + do_chan=1 + fi + + #-------------------------------------------------------------------- + # Remove extra spaces in new bad_pen & low_count files + # + if [[ -s "${bad_pen}" ]]; then + gawk '{$1=$1}1' "${bad_pen}" > tmp.bad_pen + mv -f tmp.bad_pen "${bad_pen}" + fi + if [[ -s "${low_count}" ]]; then + gawk '{$1=$1}1' "${low_count}" > tmp.low_count + mv -f tmp.low_count "${low_count}" + fi + + echo " do_pen, do_chan, do_cnt = ${do_pen}, ${do_chan}, ${do_cnt}" + echo " diag_report = ${diag_report} " + if [[ "${do_pen}" -eq 1 || "${do_chan}" -eq 1 || "${do_cnt}" -eq 1 || -s "${diag_report}" ]]; then + + if [[ ${do_pen} -eq 1 ]]; then + + echo "calling radmon_err_rpt for pen" + ${radmon_err_rpt} "${prev_bad_pen}" "${bad_pen}" pen "${qdate}" \ + "${PDY}${cyc}" "${diag_report}" "${pen_err}" + fi + + if [[ "${do_chan}" -eq 1 ]]; then + + echo "calling radmon_err_rpt for chan" + ${radmon_err_rpt} "${prev_bad_chan}" "${bad_chan}" chan "${qdate}" \ + "${PDY}${cyc}" "${diag_report}" "${chan_err}" + fi + + if [[ "${do_cnt}" -eq 1 ]]; then + + echo "calling radmon_err_rpt for cnt" + ${radmon_err_rpt} "${prev_low_count}" "${low_count}" cnt "${qdate}" \ + "${PDY}${cyc}" "${diag_report}" "${count_err}" + fi + + #------------------------------------------------------------------- + # put together the unified error report with any obs, chan, and + # penalty problems and mail it + + if [[ -s "${obs_err}" || -s "${pen_err}" || -s "${chan_err}" || -s "${count_err}" || -s "${diag_report}" ]]; then + + echo DOING ERROR REPORTING + + cat << EOF > "${report}" Radiance Monitor warning report Net: ${RADMON_SUFFIX} @@ -424,16 +414,16 @@ Radiance Monitor warning report EOF - if [[ -s ${diag_report} ]]; then - echo OUTPUTING DIAG_REPORT - cat ${diag_report} >> ${report} - fi + if [[ -s "${diag_report}" ]]; then + echo OUTPUTING DIAG_REPORT + cat "${diag_report}" >> "${report}" + fi - if [[ -s ${chan_err} ]]; then + if [[ -s "${chan_err}" ]]; then - echo OUTPUTING CHAN_ERR + echo OUTPUTING CHAN_ERR - cat << EOF > ${chan_hdr} + cat << EOF > "${chan_hdr}" The following channels report 0 observational counts over the past two cycles: @@ -442,14 +432,14 @@ EOF EOF - cat ${chan_hdr} >> ${report} - cat ${chan_err} >> ${report} + cat "${chan_hdr}" >> "${report}" + cat "${chan_err}" >> "${report}" - fi + fi - if [[ -s ${count_err} ]]; then + if [[ -s "${count_err}" ]]; then - cat << EOF > ${count_hdr} + cat << EOF > "${count_hdr}" @@ -460,14 +450,13 @@ Satellite/Instrument Obs Count Avg Count EOF - cat ${count_hdr} >> ${report} - cat ${count_err} >> ${report} - fi + cat "${count_hdr}" >> "${report}" + cat "${count_err}" >> "${report}" + fi + if [[ -s "${pen_err}" ]]; then - if [[ -s ${pen_err} ]]; then - - cat << EOF > ${pen_hdr} + cat << EOF > "${pen_hdr}" Penalty values outside of the established normal range were found @@ -477,51 +466,53 @@ EOF ============ ======= ====== Cycle Penalty Bound ----- ------- ----- EOF - cat "${pen_hdr}" >> "${report}" - cat "${pen_err}" >> "${report}" - rm -f "${pen_hdr}" - rm -f "${pen_err}" - fi - - echo >> ${report} - cat ${disclaimer} >> ${report} - echo >> ${report} - fi - - #------------------------------------------------------------------- - # dump report to log file - # - if [[ -s ${report} ]]; then - lines=$(wc -l <${report}) - if [[ ${lines} -gt 2 ]]; then - cat ${report} - - cpfs ${report} "${TANKverf_rad}/warning.${PDY}${cyc}" - fi - fi - - fi - - #------------------------------------------------------------------- - # copy new bad_pen, bad_chan, and low_count files to $TANKverf_rad - # - if [[ -s ${bad_chan} ]]; then - mv "${bad_chan}" "${TANKverf_rad}/." - fi - - if [[ -s ${bad_pen} ]]; then - mv "${bad_pen}" "${TANKverf_rad}/." - fi - - if [[ -s ${low_count} ]]; then - mv "${low_count}" "${TANKverf_rad}/." - fi + cat "${pen_hdr}" >> "${report}" + cat "${pen_err}" >> "${report}" + rm -f "${pen_hdr}" + rm -f "${pen_err}" + fi + + { + echo + cat "${disclaimer}" + echo + } >> "${report}" + fi + + #------------------------------------------------------------------- + # dump report to log file + # + if [[ -s "${report}" ]]; then + lines=$(wc -l < "${report}") + if [[ "${lines}" -gt 2 ]]; then + cat "${report}" + + cpfs "${report}" "${TANKverf_rad}/warning.${PDY}${cyc}" + fi + fi + + fi + + #------------------------------------------------------------------- + # copy new bad_pen, bad_chan, and low_count files to $TANKverf_rad + # + if [[ -s "${bad_chan}" ]]; then + mv "${bad_chan}" "${TANKverf_rad}/." + fi + + if [[ -s "${bad_pen}" ]]; then + mv "${bad_pen}" "${TANKverf_rad}/." + fi + + if [[ -s "${low_count}" ]]; then + mv "${low_count}" "${TANKverf_rad}/." + fi fi - for type in ${SATYPE}; do - rm -f "stdout.${type}" - done +for type in ${SATYPE}; do + rm -f "stdout.${type}" +done ################################################################################ #------------------------------------------------------------------- diff --git a/ush/regrid_gsiSfcIncr_to_tile.sh b/ush/regrid_gsiSfcIncr_to_tile.sh index 5e2fe1cf59f..ffc3d9b8200 100755 --- a/ush/regrid_gsiSfcIncr_to_tile.sh +++ b/ush/regrid_gsiSfcIncr_to_tile.sh @@ -14,8 +14,8 @@ CASE_IN=${CASE_IN:-${CASE_ENS}} LFHR=${LFHR:-6} # get resolutions -LONB_CASE_IN=$((4*${CASE_IN:1})) -LATB_CASE_IN=$((2*${CASE_IN:1})) +LONB_CASE_IN=$((4 * ${CASE_IN:1})) +LATB_CASE_IN=$((2 * ${CASE_IN:1})) ntiles=6 @@ -23,7 +23,7 @@ APREFIX_ENS="enkfgdas.t${cyc}z." LSOIL_INCR=${LSOIL_INCR:-2} -export n_vars=$(( LSOIL_INCR*2 )) +export n_vars=$((LSOIL_INCR * 2)) soilt_incr_vars=$(seq -s ',' -f '"soilt%g_inc"' 1 "${LSOIL_INCR}") slc_incr_vars=$(seq -s ',' -f '"slc%g_inc"' 1 "${LSOIL_INCR}") @@ -46,10 +46,10 @@ regrid_nml_tmpl="${PARMgfs}/regrid_sfc/regrid.nml_tmpl" if [[ "${LFHR}" -ge 0 ]]; then soilinc_fhrs=("${LFHR}") -else # construct restart times for deterministic member - soilinc_fhrs=("${assim_freq}") # increment file at middle of window - if [[ "${DOIAU:-}" == "YES" ]]; then # Update surface restarts at beginning of window - half_window=$(( assim_freq / 2 )) +else # construct restart times for deterministic member + soilinc_fhrs=("${assim_freq}") # increment file at middle of window + if [[ "${DOIAU:-}" == "YES" ]]; then # Update surface restarts at beginning of window + half_window=$((assim_freq / 2)) soilinc_fhrs+=("${half_window}") fi fi @@ -65,22 +65,22 @@ chmod 755 cmdfile_in.0 # Append fixed files command file to master command file { -echo "#!/bin/bash" + echo "#!/bin/bash" -# input, fixed files -echo "cpreq ${FIXorog}/${CASE_IN}/gaussian.${LONB_CASE_IN}.${LATB_CASE_IN}.nc \ + # input, fixed files + echo "cpreq ${FIXorog}/${CASE_IN}/gaussian.${LONB_CASE_IN}.${LATB_CASE_IN}.nc \ ${DATA}/gaussian_scrip.nc" -# output, fixed files -echo "cpreq ${FIXorog}/${CASE_OUT}/${CASE_OUT}_mosaic.nc \ + # output, fixed files + echo "cpreq ${FIXorog}/${CASE_OUT}/${CASE_OUT}_mosaic.nc \ ${DATA}/${CASE_OUT}_mosaic.nc" -for n in $(seq 1 "${ntiles}"); do - echo "cpreq ${FIXorog}/${CASE_OUT}/sfc/${CASE_OUT}.mx${OCNRES_OUT}.vegetation_type.tile${n}.nc \ + for n in $(seq 1 "${ntiles}"); do + echo "cpreq ${FIXorog}/${CASE_OUT}/sfc/${CASE_OUT}.mx${OCNRES_OUT}.vegetation_type.tile${n}.nc \ ${DATA}/vegetation_type.tile${n}.nc" - echo "cpreq ${FIXorog}/${CASE_OUT}/${CASE_OUT}_grid.tile${n}.nc \ + echo "cpreq ${FIXorog}/${CASE_OUT}/${CASE_OUT}_grid.tile${n}.nc \ ${DATA}/${CASE_OUT}_grid.tile${n}.nc" -done + done } >> cmdfile_in.0 if [[ "${NMEM_REGRID}" -gt 1 ]]; then @@ -101,64 +101,64 @@ if [[ "${NMEM_REGRID}" -gt 1 ]]; then # Create commands to stage input files { - echo "#!/bin/bash" - - echo "mkdir -p ${DATA}/${memdir}" + echo "#!/bin/bash" - for FHR in "${soilinc_fhrs[@]}"; do - echo "cpreq ${COMIN_SOIL_ANALYSIS_MEM}/${APREFIX_ENS}increment.sfc.i00${FHR}.nc \ - ${DATA}/${memdir}/sfci00${FHR}.nc" - done + echo "mkdir -p ${DATA}/${memdir}" - if [[ "${DO_LAND_IAU}" = ".true." ]]; then - for FHI in "${landifhrs[@]}"; do - echo "cpreq ${COMIN_SOIL_ANALYSIS_MEM}/${APREFIX_ENS}increment.sfc.i00${FHI}.nc \ - ${DATA}/${memdir}/sfci00${FHI}.nc" + for FHR in "${soilinc_fhrs[@]}"; do + echo "cpreq ${COMIN_SOIL_ANALYSIS_MEM}/${APREFIX_ENS}increment.sfc.i00${FHR}.nc \ + ${DATA}/${memdir}/sfci00${FHR}.nc" done - fi + + if [[ "${DO_LAND_IAU}" = ".true." ]]; then + for FHI in "${landifhrs[@]}"; do + echo "cpreq ${COMIN_SOIL_ANALYSIS_MEM}/${APREFIX_ENS}increment.sfc.i00${FHI}.nc \ + ${DATA}/${memdir}/sfci00${FHI}.nc" + done + fi } >> "cmdfile_in.${imem}" # Create commands to copy output files { - echo "#!/bin/bash" + echo "#!/bin/bash" + + if [[ "${DO_LAND_IAU}" = ".false." || "${RUN}" == "gdas" || "${RUN}" == "gfs" ]]; then + for FHR in "${soilinc_fhrs[@]}"; do + for n in $(seq 1 "${ntiles}"); do + echo "cpfs ${DATA}/${memdir}/sfci00${FHR}.mem${imem}.tile${n}.nc \ + ${COMOUT_ATMOS_ANALYSIS_MEM}/increment.sfc.i00${FHR}.tile${n}.nc" + done + done + fi - if [[ "${DO_LAND_IAU}" = ".false." || "${RUN}" == "gdas" || "${RUN}" == "gfs" ]]; then - for FHR in "${soilinc_fhrs[@]}"; do + if [[ "${DO_LAND_IAU}" = ".true." ]]; then for n in $(seq 1 "${ntiles}"); do - echo "cpfs ${DATA}/${memdir}/sfci00${FHR}.mem${imem}.tile${n}.nc \ - ${COMOUT_ATMOS_ANALYSIS_MEM}/increment.sfc.i00${FHR}.tile${n}.nc" + echo "cpfs ${DATA}/${memdir}/sfci.mem${imem}.tile${n}.nc \ + ${COMOUT_ATMOS_ANALYSIS_MEM}/increment.sfc.tile${n}.nc" done - done - fi - - if [[ "${DO_LAND_IAU}" = ".true." ]]; then - for n in $(seq 1 "${ntiles}"); do - echo "cpfs ${DATA}/${memdir}/sfci.mem${imem}.tile${n}.nc \ - ${COMOUT_ATMOS_ANALYSIS_MEM}/increment.sfc.tile${n}.nc" - done - fi + fi } >> "cmdfile_out.${imem}" - done # for imem in $(seq 1 "${NMEM_REGRID}"); do + done # for imem in $(seq 1 "${NMEM_REGRID}"); do in_dir=$(seq -s ", " -f "'./mem%03g/'" 1 "${NMEM_REGRID}") -else # deterministic member only (NMEM_REGRID=1) +else # deterministic member only (NMEM_REGRID=1) echo "INFO: Preparing to regrid surface increments for deterministic member." # Create commands to stage input files and append to the cmdfile.0 { - for FHR in "${soilinc_fhrs[@]}"; do - echo "cpreq ${COMIN_SOIL_ANALYSIS_MEM}/${APREFIX_ENS}ensmean_increment.sfc.i00${FHR}.nc \ - ${DATA}/sfci00${FHR}.nc" - done - - if [[ "${DO_LAND_IAU}" = ".true." ]]; then - for FHI in "${landifhrs[@]}"; do - echo "cpreq ${COMIN_SOIL_ANALYSIS_MEM}/${APREFIX_ENS}ensmean_increment.sfc.i00${FHI}.nc \ - ${DATA}/sfci00${FHI}.nc" + for FHR in "${soilinc_fhrs[@]}"; do + echo "cpreq ${COMIN_SOIL_ANALYSIS_MEM}/${APREFIX_ENS}ensmean_increment.sfc.i00${FHR}.nc \ + ${DATA}/sfci00${FHR}.nc" done - fi + + if [[ "${DO_LAND_IAU}" = ".true." ]]; then + for FHI in "${landifhrs[@]}"; do + echo "cpreq ${COMIN_SOIL_ANALYSIS_MEM}/${APREFIX_ENS}ensmean_increment.sfc.i00${FHI}.nc \ + ${DATA}/sfci00${FHI}.nc" + done + fi } >> "cmdfile_in.0" in_dir="'./'" @@ -167,26 +167,25 @@ else # deterministic member only (NMEM_REGRID=1) touch cmdfile_out.0 chmod 755 cmdfile_out.0 { - echo "#!/bin/bash" + echo "#!/bin/bash" - if [[ "${DO_LAND_IAU}" = ".false." || "${RUN}" == "gdas" || "${RUN}" == "gfs" ]]; then - for FHR in "${soilinc_fhrs[@]}"; do - for n in $(seq 1 "${ntiles}"); do - echo "cpfs ${DATA}/sfci00${FHR}.mem1.tile${n}.nc \ - ${COMOUT_ATMOS_ANALYSIS_MEM}/increment.sfc.i00${FHR}.tile${n}.nc" + if [[ "${DO_LAND_IAU}" = ".false." || "${RUN}" == "gdas" || "${RUN}" == "gfs" ]]; then + for FHR in "${soilinc_fhrs[@]}"; do + for n in $(seq 1 "${ntiles}"); do + echo "cpfs ${DATA}/sfci00${FHR}.mem1.tile${n}.nc \ + ${COMOUT_ATMOS_ANALYSIS_MEM}/increment.sfc.i00${FHR}.tile${n}.nc" + done done - done - fi + fi - if [[ "${DO_LAND_IAU}" = ".true." ]]; then - for n in $(seq 1 "${ntiles}"); do - echo "cpfs ${DATA}/sfci.mem1.tile${n}.nc \ - ${COMOUT_ATMOS_ANALYSIS_MEM}/increment.sfc.tile${n}.nc" - done - fi + if [[ "${DO_LAND_IAU}" = ".true." ]]; then + for n in $(seq 1 "${ntiles}"); do + echo "cpfs ${DATA}/sfci.mem1.tile${n}.nc \ + ${COMOUT_ATMOS_ANALYSIS_MEM}/increment.sfc.tile${n}.nc" + done + fi } >> "cmdfile_out.0" - fi # Create master MPMD command files for input and output @@ -240,10 +239,10 @@ if [[ "${DO_LAND_IAU}" = ".false." || "${RUN}" == "gdas" || "${RUN}" == "gfs" ]] # Run regrid executable export pgm="${REGRID_EXEC}" ${APRUN_REGRID} "${REGRID_EXEC}" - export err=$? - if [[ ${err} -ne 0 ]]; then - err_exit "${REGRID_EXEC} failed to regrid soil increments (without LANDIAU), ABORT!" - fi + export err=$? + if [[ ${err} -ne 0 ]]; then + err_exit "${REGRID_EXEC} failed to regrid soil increments (without LANDIAU), ABORT!" + fi done fi @@ -261,11 +260,11 @@ if [[ "${DO_LAND_IAU}" = ".true." ]]; then # Run regrid executable export pgm="${REGRID_EXEC}" - ${APRUN_REGRID} "${REGRID_EXEC}" - export err=$? - if [[ ${err} -ne 0 ]]; then - err_exit "${pgm} failed to regrid soil increments (with LANDIAU), ABORT!" - fi + ${APRUN_REGRID} "${REGRID_EXEC}" + export err=$? + if [[ ${err} -ne 0 ]]; then + err_exit "${pgm} failed to regrid soil increments (with LANDIAU), ABORT!" + fi fi # Run MPMD to save output files diff --git a/ush/rstprod.sh b/ush/rstprod.sh index 8370c79fa8c..56936eda221 100755 --- a/ush/rstprod.sh +++ b/ush/rstprod.sh @@ -3,15 +3,15 @@ #--------------------------------------------------------- # rstprod.sh # -# Restrict data from select sensors and satellites +# Restrict data from select sensors and satellites #--------------------------------------------------------- # Restrict select sensors and satellites export CHGRP_CMD=${CHGRP_CMD:-"chgrp ${group_name:-rstprod}"} rlist="saphir abi_g16" -for rtype in $rlist; do +for rtype in ${rlist}; do if compgen -G "*${rtype}*" > /dev/null; then - ${CHGRP_CMD} *${rtype}* + ${CHGRP_CMD} ./*"${rtype}"* fi done diff --git a/ush/run_mpmd.sh b/ush/run_mpmd.sh index 6ffbd3106d1..89e65daaa97 100755 --- a/ush/run_mpmd.sh +++ b/ush/run_mpmd.sh @@ -34,12 +34,12 @@ cmdfile=${1:?"run_mpmd requires an input file containing commands to execute in # If USE_CFP is not set, run in serial mode if [[ "${USE_CFP:-}" != "YES" ]]; then - echo "INFO: Using serial mode for MPMD job" - chmod 755 "${cmdfile}" - bash +x "${cmdfile}" > mpmd.out 2>&1 - rc=$? - cat mpmd.out - exit "${rc}" + echo "INFO: Using serial mode for MPMD job" + chmod 755 "${cmdfile}" + bash +x "${cmdfile}" > mpmd.out 2>&1 + rc=$? + cat mpmd.out + exit "${rc}" fi # Set OMP_NUM_THREADS to 1 to avoid oversubscription when doing MPMD @@ -58,56 +58,56 @@ cat << EOF INFO: The proc_num corresponds to the line in '${mpmd_cmdfile}' EOF -if [[ "${launcher:-}" =~ ^srun.* ]]; then # srun-based system e.g. Hera, Orion, etc. - - # Slurm requires a counter in front of each line in the script - # Read the incoming cmdfile and create srun usable cmdfile - nm=0 - # shellcheck disable=SC2312 - while IFS= read -r line; do - echo "${nm} ${line}" >> "${mpmd_cmdfile}" - ((nm=nm+1)) - done < "${cmdfile}" - - set +e - # shellcheck disable=SC2086 - ${launcher:-} ${mpmd_opt:-} -n ${nprocs} "${mpmd_cmdfile}" - err=$? - set_strict - -elif [[ "${launcher:-}" =~ ^mpiexec.* ]]; then # mpiexec - - # Redirect output from each process to its own stdout - # Read the incoming cmdfile and create mpiexec usable cmdfile - nm=0 - echo "#!/bin/bash" >> "${mpmd_cmdfile}" - # shellcheck disable=SC2312 - while IFS= read -r line; do - echo "${line} > mpmd.${nm}.out" >> "${mpmd_cmdfile}" - ((nm=nm+1)) - done < "${cmdfile}" - chmod 755 "${mpmd_cmdfile}" - - # shellcheck disable=SC2086 - ${launcher:-} -np ${nprocs} ${mpmd_opt:-} "${mpmd_cmdfile}" - err=$? +if [[ "${launcher:-}" =~ ^srun.* ]]; then # srun-based system e.g. Hera, Orion, etc. + + # Slurm requires a counter in front of each line in the script + # Read the incoming cmdfile and create srun usable cmdfile + nm=0 + # shellcheck disable=SC2312 + while IFS= read -r line; do + echo "${nm} ${line}" >> "${mpmd_cmdfile}" + ((nm = nm + 1)) + done < "${cmdfile}" + + set +e + # shellcheck disable=SC2086 + ${launcher:-} ${mpmd_opt:-} -n ${nprocs} "${mpmd_cmdfile}" + err=$? + set_strict + +elif [[ "${launcher:-}" =~ ^mpiexec.* ]]; then # mpiexec + + # Redirect output from each process to its own stdout + # Read the incoming cmdfile and create mpiexec usable cmdfile + nm=0 + echo "#!/bin/bash" >> "${mpmd_cmdfile}" + # shellcheck disable=SC2312 + while IFS= read -r line; do + echo "${line} > mpmd.${nm}.out" >> "${mpmd_cmdfile}" + ((nm = nm + 1)) + done < "${cmdfile}" + chmod 755 "${mpmd_cmdfile}" + + # shellcheck disable=SC2086 + ${launcher:-} -np ${nprocs} ${mpmd_opt:-} "${mpmd_cmdfile}" + err=$? else - echo "FATAL ERROR: CFP is not usable with launcher: '${launcher:-}'" - err=1 + echo "FATAL ERROR: CFP is not usable with launcher: '${launcher:-}'" + err=1 fi # On success concatenate processor specific output into a single mpmd.out if [[ ${err} -eq 0 ]]; then - rm -f "${mpmd_cmdfile}" - out_files=$(find . -name 'mpmd.*.out') - for file in ${out_files}; do - cat "${file}" >> mpmd.out - rm -f "${file}" - done - cat mpmd.out + rm -f "${mpmd_cmdfile}" + out_files=$(find . -name 'mpmd.*.out') + for file in ${out_files}; do + cat "${file}" >> mpmd.out + rm -f "${file}" + done + cat mpmd.out fi exit "${err}" diff --git a/ush/syndat_getjtbul.sh b/ush/syndat_getjtbul.sh index 16c41b21efe..0ce21ef7efd 100755 --- a/ush/syndat_getjtbul.sh +++ b/ush/syndat_getjtbul.sh @@ -7,7 +7,7 @@ # 2-digit year starting in column 20 or a 4-digit year # starting in column 20. # Mar 2013, DStokes - modified for WCOSS. Added option to email developer. -# Oct 2013, DStokes - Add check of stormname length and truncate if needed +# Oct 2013, DStokes - Add check of stormname length and truncate if needed # in response to recent problems with JTWC reports. # Remove option to email developer. # @@ -17,142 +17,136 @@ # Imported variables that must be passed in: # DATA - path to working directory -# pgmout - string indicating path to for standard output file # TANK_TROPCY - path to home directory containing tropical cyclone record # data base -cd $DATA +cd "${DATA}" || exit 1 -if [ "$#" -ne '1' ]; then - echo "**NON-FATAL ERROR PROGRAM SYNDAT_GETJTBUL run date not in \ +if [[ "$#" -ne '1' ]]; then + echo "**NON-FATAL ERROR PROGRAM SYNDAT_GETJTBUL run date not in \ positional parameter 1" - -echo "Leaving sub-shell syndat_getjtbul.sh to recover JTWC Bulletins" \ - >> $pgmout -echo " " >> $pgmout - - exit + exit fi run_date=$1 ymd=${run_date:2:6} -echo $PDYm1 -pdym1=$PDYm1 - -echo " " >> $pgmout -echo "Entering sub-shell syndat_getjtbul.sh to recover JTWC Bulletins" \ - >> $pgmout -echo " " >> $pgmout +echo "${PDYm1}" +pdym1=${PDYm1} +echo +echo "Entering sub-shell syndat_getjtbul.sh to recover JTWC Bulletins" +echo -if test ${cyc} -eq "00" -then +if [[ "${cyc}" -eq "00" ]]; then -# For 00Z cycle, need to go to prior day's tank -# --------------------------------------------- + # For 00Z cycle, need to go to prior day's tank + # --------------------------------------------- - jtwcdir=$TANK_TROPCY/${PDY}/wtxtbul - jtwcdirm1=$TANK_TROPCY/$pdym1/wtxtbul + jtwcdir="${TANK_TROPCY}/${PDY}/wtxtbul" + jtwcdirm1="${TANK_TROPCY}/${pdym1}/wtxtbul" else - jtwcdir=$TANK_TROPCY/${PDY}/wtxtbul + jtwcdir="${TANK_TROPCY}/${PDY}/wtxtbul" fi - set +x echo echo " Run date is ${run_date}" echo echo " PDY is ${PDY}" echo -echo " pdym1 is $pdym1" +echo " pdym1 is ${pdym1}" echo echo " ymddir is ${PDY}" echo set_trace -find=$ymd" "${cyc} -echo "looking for string $find in $jtwcdir/tropcyc" >> $pgmout +find="${ymd} ${cyc}" +echo "looking for string ${find} in ${jtwcdir}/tropcyc" rm -f jtwcbul -grep "$ymd ${cyc}" $jtwcdir/tropcyc | grep JTWC > jtwcbul -if [ -s jtwcbul ]; then - echo "String found: contents of JTWC bulletin are:" >> $pgmout - cat jtwcbul >> $pgmout +# shellcheck disable=SC2312 +grep "${ymd} ${cyc}" "${jtwcdir}/tropcyc" | grep JTWC > jtwcbul +if [[ -s jtwcbul ]]; then + echo "String found: contents of JTWC bulletin are:" + cat jtwcbul else - echo "String not found: no JTWC bulletins available for this run" >> $pgmout + echo "String not found: no JTWC bulletins available for this run" fi -if test ${cyc} -eq "00" -then - grep "$ymd ${cyc}" $jtwcdirm1/tropcyc | grep JTWC >> jtwcbul - if [ -s jtwcbul ]; then - echo "String found: contents of JTWC bulletin are:" >> $pgmout - cat jtwcbul >> $pgmout - else - echo "String not found: no JTWC bulletins available for this run" >> $pgmout - fi +if [[ "${cyc}" == "00" ]]; then + # shellcheck disable=SC2312 + grep "${ymd} ${cyc}" "${jtwcdirm1}/tropcyc" | grep JTWC >> jtwcbul + if [[ -s jtwcbul ]]; then + echo "String found: contents of JTWC bulletin are:" + cat jtwcbul + else + echo "String not found: no JTWC bulletins available for this run" + fi fi # Check for and truncate stormnames with length greater than nine characters and leave rest of record intact. # This spell makes no attempt to correct any other potential errors in the record format. perl -wpi.ORIG -e 's/(^.... ... )(\S{9,9})(\S{1,})/$1$2/' jtwcbul diff jtwcbul.ORIG jtwcbul > jtwcbul_changes.txt -if [ -s jtwcbul_changes.txt ]; then - echo "***WARNING: SOME JTWC VITALS SEGMENTS REQUIRED PRELIMINARY MODIFICATION!" - cat jtwcbul_changes.txt +if [[ -s jtwcbul_changes.txt ]]; then + echo "***WARNING: SOME JTWC VITALS SEGMENTS REQUIRED PRELIMINARY MODIFICATION!" + cat jtwcbul_changes.txt fi # Execute bulletin processing -[ -s jtwcbul ] && echo "Processing JTWC bulletin halfs into tcvitals records" >> $pgmout +if [[ -s jtwcbul ]]; then + echo "Processing JTWC bulletin halfs into tcvitals records" +fi -pgm=$(basename ${EXECgfs}/syndat_getjtbul.x) +pgm=$(basename "${EXECgfs}/syndat_getjtbul.x") export pgm -if [ -s prep_step ]; then - set +u - source prep_step - set -u +if [[ -s prep_step ]]; then + set +u + source prep_step + set -u else - [ -f errfile ] && rm errfile - unset FORT00 $(env | grep "^FORT[0-9]\{1,\}=" | awk -F= '{print $1}') + [[ -f errfile ]] && rm errfile + # shellcheck disable=SC2046,SC2312 + unset FORT00 $(env | grep "^FORT[0-9]\{1,\}=" | awk -F= '{print $1}') fi rm -f fnoc export FORT11=jtwcbul export FORT51=fnoc -time -p ${EXECgfs}/${pgm} >> $pgmout 2> errfile +# shellcheck disable=SC2312 +time -p "${EXECgfs}/${pgm}" 2> errfile errget=$? -###cat errfile -cat errfile >> $pgmout +cat errfile rm errfile set +x echo -echo 'The foreground exit status for SYNDAT_GETJTBUL is ' $errget +echo "The foreground exit status for SYNDAT_GETJTBUL is ${errget}" echo set_trace -if [ "$errget" -gt '0' ];then - if [ "$errget" -eq '1' ];then - msg="No JTWC bulletins in $jtwcdir/tropcyc, no JTWC tcvitals \ -available for qctropcy for ${run_date}" - if [[ "$RUN" == "gfs" ]]; then - if [[ "${SENDSDM}" == "YES" ]]; then - export ecf_family=$(echo $ECF_NAME |awk 'BEGIN {FS="/j"} {print $1}') - echo $msg > $COMOUT/${NET}_${RUN}.t${cyc}z.emailbody - echo "export subject='No JTWC bulletins available for ${run_date} ${RUN} run'" >$COMOUT/${NET}_${RUN}.t${cyc}z.emailvar - # JY echo "export maillist='sdm@noaa.gov'" >> $COMOUT/${NET}_${RUN}.t${cyc}z.emailvar - echo "export maillist=$maillist" >> $COMOUT/${NET}_${RUN}.t${cyc}z.emailvar - ecflow_client --run ${ecf_family}/j${RUN}_jtwc_bull_email +if [[ "${errget}" -gt '0' ]]; then + if [[ "${errget}" -eq '1' ]]; then + msg="No JTWC bulletins in ${jtwcdir}/tropcyc, no JTWC tcvitals available for qctropcy for ${run_date}" + if [[ "${RUN}" == "gfs" ]]; then + if [[ "${SENDSDM}" == "YES" ]]; then + ecf_family=$(echo "${ECF_NAME}" | awk 'BEGIN {FS="/j"} {print $1}') + export ecf_family + echo "${msg}" > "${COMOUT}/${NET}_${RUN}.t${cyc}z.emailbody" + echo "export subject='No JTWC bulletins available for ${run_date} ${RUN} run'" > "${COMOUT}/${NET}_${RUN}.t${cyc}z.emailvar" + # JY echo "export maillist='sdm@noaa.gov'" >> $COMOUT/${NET}_${RUN}.t${cyc}z.emailvar + echo "export maillist=${maillist}" >> "${COMOUT}/${NET}_${RUN}.t${cyc}z.emailvar" + ecflow_client --run "${ecf_family}/j${RUN}_jtwc_bull_email" + fi fi - fi - else - echo "**NON-FATAL ERROR PROGRAM SYNDAT_GETJTBUL FOR ${run_date} \ -RETURN CODE $errget" - fi + else + echo "**NON-FATAL ERROR PROGRAM SYNDAT_GETJTBUL FOR ${run_date} \ +RETURN CODE ${errget}" + fi else - echo "program SYNDAT_GETJTBUL completed normally for ${run_date}, JTWC \ + echo "program SYNDAT_GETJTBUL completed normally for ${run_date}, JTWC \ rec. passed to qctropcy" fi set +x @@ -163,13 +157,13 @@ echo "----------------------------------------------------------" echo set_trace -if [ "$errget" -eq '0' ];then - echo "Completed JTWC tcvitals records are:" >> $pgmout - cat fnoc >> $pgmout +if [[ "${errget}" -eq '0' ]]; then + echo "Completed JTWC tcvitals records are:" + cat fnoc fi -echo "Leaving sub-shell syndat_getjtbul.sh to recover JTWC Bulletins" \ - >> $pgmout -echo " " >> "${pgmout}" +echo "Leaving sub-shell syndat_getjtbul.sh to recover JTWC Bulletins" + +echo " " exit diff --git a/ush/syndat_qctropcy.sh b/ush/syndat_qctropcy.sh index 022851c3e45..deef9ad515a 100755 --- a/ush/syndat_qctropcy.sh +++ b/ush/syndat_qctropcy.sh @@ -63,7 +63,7 @@ # (Default: not set) # TIMEIT - optional time and resource reporting (Default: not set) -ARCHSYND=${ARCHSYND:-$COMROOTp3/gfs/prod/syndat} +ARCHSYND=${ARCHSYND:-${COMROOTp3}/gfs/prod/syndat} HOMENHC=${HOMENHC:-/gpfs/dell2/nhc/save/guidance/storm-data/ncep} TANK_TROPCY=${TANK_TROPCY:-${DCOMROOT}/us007003} @@ -71,47 +71,41 @@ slmask=${slmask:-${FIXgfs}/am/syndat_slmask.t126.gaussian} copy_back=${copy_back:-YES} files_override=${files_override:-""} -cd $DATA +cd "${DATA}" || exit 2 msg="Tropical Cyclone tcvitals QC processing has begun" set +x echo -echo $msg +echo "${msg}" echo set_trace -echo $msg >> $pgmout -if [ "$#" -ne '1' ]; then - msg="**NON-FATAL ERROR PROGRAM SYNDAT_QCTROPCY run date not in \ +if [[ "$#" -ne '1' ]]; then + msg="**NON-FATAL ERROR PROGRAM SYNDAT_QCTROPCY run date not in \ positional parameter 1" - set +x - echo - echo $msg - echo - set_trace - echo $msg >> $pgmout - msg="**NO TROPICAL CYCLONE tcvitals processed --> non-fatal" - set +x - echo - echo $msg - echo - set_trace - echo $msg >> $pgmout - -# Copy null files into "${COMOUT_OBS}/${RUN}.${cycle}.syndata.tcvitals.$tmmark" and -# "${COMOUT_OBS}/${RUN}.${cycle}.jtwc-fnoc.tcvitals.$tmmark" so later ftp attempts will find and -# copy the zero-length file and avoid wasting time with multiple attempts -# to remote machine(s) -# (Note: Only do so if files don't already exist) - - if [[ ! -s "${COMOUT_OBS}/${RUN}.${cycle}.syndata.tcvitals.${tmmark}" ]]; then - touch "${COMOUT_OBS}/${RUN}.${cycle}.syndata.tcvitals.${tmmark}" - fi - if [[ ! -s "${COMOUT_OBS}/${RUN}.${cycle}.jtwc-fnoc.tcvitals.${tmmark}" ]]; then - touch "${COMOUT_OBS}/${RUN}.${cycle}.jtwc-fnoc.tcvitals.${tmmark}" - fi - - exit + set +x + echo + echo "${msg}" + echo + msg="**NO TROPICAL CYCLONE tcvitals processed --> non-fatal" + echo + echo "${msg}" + echo + + # Copy null files into "${COMOUT_OBS}/${RUN}.${cycle}.syndata.tcvitals.$tmmark" and + # "${COMOUT_OBS}/${RUN}.${cycle}.jtwc-fnoc.tcvitals.$tmmark" so later ftp attempts will find and + # copy the zero-length file and avoid wasting time with multiple attempts + # to remote machine(s) + # (Note: Only do so if files don't already exist) + + if [[ ! -s "${COMOUT_OBS}/${RUN}.${cycle}.syndata.tcvitals.${tmmark}" ]]; then + touch "${COMOUT_OBS}/${RUN}.${cycle}.syndata.tcvitals.${tmmark}" + fi + if [[ ! -s "${COMOUT_OBS}/${RUN}.${cycle}.jtwc-fnoc.tcvitals.${tmmark}" ]]; then + touch "${COMOUT_OBS}/${RUN}.${cycle}.jtwc-fnoc.tcvitals.${tmmark}" + fi + + exit fi run_date=$1 @@ -124,29 +118,30 @@ set_trace year=${run_date:0:4} - # Copy the seasonal statistics from archive directory to local -cpreq $ARCHSYND/syndat_akavit akavit; touch akavit -cpreq $ARCHSYND/syndat_dateck dateck -cpreq $ARCHSYND/syndat_stmcat.scr stmcat.scr; touch stmcat.scr -cpreq $ARCHSYND/syndat_stmcat stmcat; touch stmcat -cpreq $ARCHSYND/syndat_sthisto sthisto -cpreq $ARCHSYND/syndat_sthista sthista +cpreq "${ARCHSYND}/syndat_akavit" akavit +touch akavit +cpreq "${ARCHSYND}/syndat_dateck" dateck +cpreq "${ARCHSYND}/syndat_stmcat.scr" stmcat.scr +touch stmcat.scr +cpreq "${ARCHSYND}/syndat_stmcat" stmcat +touch stmcat +cpreq "${ARCHSYND}/syndat_sthisto" sthisto +cpreq "${ARCHSYND}/syndat_sthista" sthista touch dateck -dateck_size=$(ls -l dateck | awk '{ print $5 }') -if [ $dateck_size -lt 10 ]; then - msg="***WARNING: Archive run date check file not available or shorter than expected.\ +dateck_size=$(find ./ -name dateck -printf "%s") + +if [[ ${dateck_size} -lt 10 ]]; then + msg="WARNING: Archive run date check file not available or shorter than expected.\ Using dummy date 1900010100 to allow code to continue" - echo 1900010100 > dateck - set +x - echo -e "\n${msg}\n" - set_trace - echo $msg >> $pgmout + echo 1900010100 > dateck + set +x + echo -e "\n${msg}\n" + set_trace fi - # Generate the correct RUNID and FILES value based on $NET, $RUN and $cyc # Copy this into parm file, then cat the remaining switches in the parm file # Note: FILES=T for 00Z GDAS at tm00 (last run of day centered on 00Z) @@ -154,136 +149,133 @@ fi # 12Z GDAS at tm00 (last run of day centered on 12Z) # 18Z GDAS at tm00 (last run of day centered on 18Z) -net=$NET +net="${NET}" files=F, -if [ "$RUN" = 'ndas' ]; then - net=ndas -elif [ "$RUN" = 'gdas' ]; then - files=T, +if [[ "${RUN}" == 'ndas' ]]; then + net=ndas +elif [[ "${RUN}" == 'gdas' ]]; then + files=T, fi -if [ -n "$files_override" ]; then # for testing, typically want FILES=F - files_override=$(echo "$files_override" | tr [a-z] [A-Z] | tr -d [.] | cut -c 1) - if [ "$files_override" = 'T' -o "$files_override" = 'F' ]; then - msg="***WARNING: Variable files setting will be overriden from $files to $files_override. Override expected if testing." - files=$files_override - else - msg="***WARNING: Invalid attempt to override files setting. Will stay with default for this job" - fi - set +x - echo -e "\n${msg}\n" - set_trace - echo $msg >> $pgmout + +if [[ -n "${files_override}" ]]; then # for testing, typically want FILES=F + files_override=${files_override^^} + files_override=${files_override//./} + files_override=${files_override:0:1} + if [[ "${files_override}" == 'T' || "${files_override}" == 'F' ]]; then + msg="WARNING: Variable files setting will be overriden from ${files} to ${files_override}. Override expected if testing." + files=${files_override} + else + msg="WARNING: Invalid attempt to override files setting. Will stay with default for this job" + fi + set +x + echo -e "\n${msg}\n" + set_trace fi -echo " &INPUT RUNID = '${net}_${tmmark}_${cyc}', FILES = $files " > vitchk.inp -cat ${PARMgfs}/relo/syndat_qctropcy.${RUN}.parm >> vitchk.inp +echo " &INPUT RUNID = '${net}_${tmmark}_${cyc}', FILES = ${files} " > vitchk.inp +cat "${PARMgfs}/relo/syndat_qctropcy.${RUN}.parm" >> vitchk.inp # Copy the fixed fields -cpreq ${FIXgfs}/am/syndat_fildef.vit fildef.vit -cpreq ${FIXgfs}/am/syndat_stmnames stmnames - +cpreq "${FIXgfs}/am/syndat_fildef.vit" fildef.vit +cpreq "${FIXgfs}/am/syndat_stmnames" stmnames rm -f nhc fnoc lthistry - ######################################################################### # There are five possible sources of tropical cyclone bogus messages # All are input to program syndat_qctropcy # ------------------------------------------------------------------ -if [ -s ${HOMENHC}/tcvitals ]; then - echo "tcvitals found" >> $pgmout - cpreq ${HOMENHC}/tcvitals nhc +if [[ -s "${HOMENHC}/tcvitals" ]]; then + echo "tcvitals found" + cpreq "${HOMENHC}/tcvitals" nhc else - echo "WARNING: tcvitals not found, create empty tcvitals" >> $pgmout - > nhc + echo "WARNING: tcvitals not found, create empty tcvitals" fi # NHC ... copy into working directory as nhc; copy to archive touch nhc -[ "$copy_back" = 'YES' ] && cat nhc >> $ARCHSYND/syndat_tcvitals.$year +if [[ "${copy_back}" == 'YES' ]]; then + cat nhc >> "${ARCHSYND}/syndat_tcvitals.${year}" +fi mv -f nhc nhc1 -${USHgfs}/parse-storm-type.pl nhc1 > nhc +"${USHgfs}/parse-storm-type.pl" nhc1 > nhc cpreq -p nhc nhc.ORIG # JTWC/FNOC ... execute syndat_getjtbul script to write into working directory # as fnoc; copy to archive -${USHgfs}/syndat_getjtbul.sh ${run_date} +"${USHgfs}/syndat_getjtbul.sh" "${run_date}" touch fnoc -[ "$copy_back" = 'YES' ] && cat fnoc >> $ARCHSYND/syndat_tcvitals.$year +if [[ "${copy_back}" == 'YES' ]]; then + cat fnoc >> "${ARCHSYND}/syndat_tcvitals.${year}" +fi mv -f fnoc fnoc1 -${USHgfs}/parse-storm-type.pl fnoc1 > fnoc +"${USHgfs}/parse-storm-type.pl" fnoc1 > fnoc if [[ "${SENDDBN}" == "YES" ]]; then - $DBNROOT/bin/dbn_alert MODEL SYNDAT_TCVITALS $job $ARCHSYND/syndat_tcvitals.$year + "${DBNROOT}/bin/dbn_alert" MODEL SYNDAT_TCVITALS "${job}" "${ARCHSYND}/syndat_tcvitals.${year}" fi ######################################################################### - -cpreq $slmask slmask.126 - +cpreq "${slmask}" slmask.126 # Execute program syndat_qctropcy -pgm=$(basename ${EXECgfs}/syndat_qctropcy.x) +pgm=$(basename "${EXECgfs}/syndat_qctropcy.x") export pgm -if [ -s prep_step ]; then - set +u - source prep_step - set -u +if [[ -s prep_step ]]; then + set +u + source prep_step + set -u else - [ -f errfile ] && rm errfile - unset FORT00 $(env | grep "^FORT[0-9]\{1,\}=" | awk -F= '{print $1}') + [[ -f errfile ]] && rm errfile + # shellcheck disable=SC2046,SC2312 + unset FORT00 $(env | grep "^FORT[0-9]\{1,\}=" | awk -F= '{print $1}') fi -echo "${run_date}" > run_date.dat +echo "${run_date}" > run_date.dat export FORT11=slmask.126 export FORT12=run_date.dat -${EXECgfs}/${pgm} >> $pgmout 2> errfile +"${EXECgfs}/${pgm}" errqct=$? -###cat errfile -cat errfile >> $pgmout -rm errfile set +x echo -echo "The foreground exit status for SYNDAT_QCTROPCY is " $errqct +echo "The foreground exit status for SYNDAT_QCTROPCY is ${errqct}" echo set_trace -if [ "$errqct" -gt '0' ];then - msg="**NON-FATAL ERROR PROGRAM SYNDAT_QCTROPCY RETURN CODE $errqct" - set +x - echo - echo $msg - echo - set_trace - echo $msg >> $pgmout - msg="**NO TROPICAL CYCLONE tcvitals processed --> non-fatal" - set +x - echo - echo $msg - echo - set_trace - echo $msg >> $pgmout - -# In the event of a ERROR in PROGRAM SYNDAT_QCTROPCY, copy null files into -# "${COMOUT_OBS}/${RUN}.${cycle}.syndata.tcvitals.$tmmark" and "${COMOUT_OBS}/${RUN}.${cycle}.jtwc-fnoc.tcvitals.$tmmark" -# so later ftp attempts will find and copy the zero-length file and avoid -# wasting time with multiple attempts to remote machine(s) -# (Note: Only do so if files don't already exist) - - if [[ ! -s "${COMOUT_OBS}/${RUN}.${cycle}.syndata.tcvitals.${tmmark}" ]]; then - touch "${COMOUT_OBS}/${RUN}.${cycle}.syndata.tcvitals.${tmmark}" - fi - if [[ ! -s ${COMOUT_OBS}/${RUN}.${cycle}.jtwc-fnoc.tcvitals.${tmmark} ]]; then - touch "${COMOUT_OBS}/${RUN}.${cycle}.jtwc-fnoc.tcvitals.${tmmark}" - fi - - exit +if [[ "${errqct}" -gt '0' ]]; then + msg="**NON-FATAL ERROR PROGRAM SYNDAT_QCTROPCY RETURN CODE ${errqct}" + set +x + echo + echo "${msg}" + echo + set_trace + msg="**NO TROPICAL CYCLONE tcvitals processed --> non-fatal" + set +x + echo + echo "${msg}" + echo + set_trace + + # In the event of a ERROR in PROGRAM SYNDAT_QCTROPCY, copy null files into + # "${COMOUT_OBS}/${RUN}.${cycle}.syndata.tcvitals.$tmmark" and "${COMOUT_OBS}/${RUN}.${cycle}.jtwc-fnoc.tcvitals.$tmmark" + # so later ftp attempts will find and copy the zero-length file and avoid + # wasting time with multiple attempts to remote machine(s) + # (Note: Only do so if files don't already exist) + + if [[ ! -s "${COMOUT_OBS}/${RUN}.${cycle}.syndata.tcvitals.${tmmark}" ]]; then + touch "${COMOUT_OBS}/${RUN}.${cycle}.syndata.tcvitals.${tmmark}" + fi + if [[ ! -s ${COMOUT_OBS}/${RUN}.${cycle}.jtwc-fnoc.tcvitals.${tmmark} ]]; then + touch "${COMOUT_OBS}/${RUN}.${cycle}.jtwc-fnoc.tcvitals.${tmmark}" + fi + + exit fi set +x echo @@ -293,17 +285,16 @@ echo "----------------------------------------------------------" echo set_trace -if [ "$copy_back" = 'YES' ]; then - cat lthistry>>$ARCHSYND/syndat_lthistry.$year - cpfs akavit $ARCHSYND/syndat_akavit - cpfs dateck $ARCHSYND/syndat_dateck - cpfs stmcat.scr $ARCHSYND/syndat_stmcat.scr - cpfs stmcat $ARCHSYND/syndat_stmcat - cpfs sthisto $ARCHSYND/syndat_sthisto - cpfs sthista $ARCHSYND/syndat_sthista +if [[ "${copy_back}" == 'YES' ]]; then + cat lthistry >> "${ARCHSYND}/syndat_lthistry.${year}" + cpfs akavit "${ARCHSYND}/syndat_akavit" + cpfs dateck "${ARCHSYND}/syndat_dateck" + cpfs stmcat.scr "${ARCHSYND}/syndat_stmcat.scr" + cpfs stmcat "${ARCHSYND}/syndat_stmcat" + cpfs sthisto "${ARCHSYND}/syndat_sthisto" + cpfs sthista "${ARCHSYND}/syndat_sthista" fi - diff nhc nhc.ORIG > /dev/null errdiff=$? @@ -311,54 +302,50 @@ errdiff=$? # Update NHC file in ${HOMENHC} ################################### -if test "$errdiff" -ne '0' -then +if [[ "${errdiff}" -ne 0 ]]; then - if [ "$copy_back" = 'YES' -a ${envir} = 'prod' ]; then - if [ -s ${HOMENHC}/tcvitals ]; then - cpfs nhc ${HOMENHC}/tcvitals - fi + if [[ "${copy_back}" == 'YES' && ${envir} == 'prod' ]]; then + if [[ -s "${HOMENHC}/tcvitals" ]]; then + cpfs nhc "${HOMENHC}/tcvitals" + fi - err=$? + err=$? - if [ "$err" -ne '0' ]; then - msg="###ERROR: Previous NHC Synthetic Data Record File \ + if [[ "${err}" -ne 0 ]]; then + msg="###ERROR: Previous NHC Synthetic Data Record File \ ${HOMENHC}/tcvitals not updated by syndat_qctropcy" - else - msg="Previous NHC Synthetic Data Record File \ + else + msg="Previous NHC Synthetic Data Record File \ ${HOMENHC}/tcvitals successfully updated by syndat_qctropcy" - fi + fi - set +x - echo - echo $msg - echo - set_trace - echo $msg >> $pgmout - fi + set +x + echo + echo "${msg}" + echo + set_trace + fi else - msg="Previous NHC Synthetic Data Record File ${HOMENHC}/tcvitals \ + msg="Previous NHC Synthetic Data Record File ${HOMENHC}/tcvitals \ not changed by syndat_qctropcy" - set +x - echo - echo $msg - echo - set_trace - echo $msg >> $pgmout + set +x + echo + echo "${msg}" + echo + set_trace fi ################################### - # This is the file that connects to the later RELOCATE and/or PREP scripts cpfs current "${COMOUT_OBS}/${RUN}.${cycle}.syndata.tcvitals.${tmmark}" # Create the DBNet alert if [[ "${SENDDBN}" == "YES" ]]; then - "${DBNROOT}/bin/dbn_alert" "MODEL" "GDAS_TCVITALS" "${job}" "${COMOUT_OBS}/${RUN}.${cycle}.syndata.tcvitals.${tmmark}" + "${DBNROOT}/bin/dbn_alert" "MODEL" "GDAS_TCVITALS" "${job}" "${COMOUT_OBS}/${RUN}.${cycle}.syndata.tcvitals.${tmmark}" fi # Write JTWC/FNOC Tcvitals to /com path since not saved anywhere else diff --git a/ush/tropcy_relocate.sh b/ush/tropcy_relocate.sh index 38caecba3b6..d7b21daba56 100755 --- a/ush/tropcy_relocate.sh +++ b/ush/tropcy_relocate.sh @@ -168,53 +168,46 @@ # #### -qid=$$ - # obtain the center date/time for relocation processing # ----------------------------------------------------- -if [ $# -ne 1 ] ; then - err0=1 +if [[ $# -ne 1 ]]; then + err0=1 else - run_date=$1 - if [ "${#run_date}" -ne '10' ]; then - err0=1 - else - cycle="t${run_date:8:2}z" - err0=0 - fi + run_date=$1 + if [[ "${#run_date}" -ne '10' ]]; then + err0=1 + else + cycle="t${run_date:8:2}z" + err0=0 + fi fi -if test $err0 -ne 0 -then -# problem with obtaining date record so exit - set +x - echo - echo "problem with obtaining date record;" - echo "ABNORMAL EXIT!!!!!!!!!!!" - echo - set_trace - exit 9 +if [[ "${err0}" -ne 0 ]]; then + # problem with obtaining date record so exit + export err="${err0}" + msg="FATAL ERROR: problem with obtaining date record" + err_exit "${msg}" fi -modhr=$(expr ${cyc} % 3) +modhr=$((cyc % 3)) + +cat << EOF + +"CENTER DATE/TIME FOR RELOCATION PROCESSING IS ${run_date}" -set +x -echo -echo "CENTER DATE/TIME FOR RELOCATION PROCESSING IS ${run_date}" -echo -set_trace +EOF #---------------------------------------------------------------------------- # Create variables needed for this script and its children # -------------------------------------------------------- -envir_getges=${envir_getges:-$envir} -if [ $modhr -eq 0 ]; then - network_getges=${network_getges:-global} +envir_getges=${envir_getges:-${envir}} +if [[ "${modhr}" -eq 0 ]]; then + network_getges=${network_getges:-global} else - network_getges=${network_getges:-gfs} + network_getges=${network_getges:-gfs} fi GRIBVERSION=${GRIBVERSION:-"grib2"} @@ -235,173 +228,159 @@ GETTX=${GETTX:-${EXECgfs}/gettrk} echo "Attempt to perform tropical cyclone relocation for ${run_date}" -if [ $modhr -ne 0 ]; then +if [[ "${modhr}" -ne 0 ]]; then -# if center date/time for relocation processing isn't a multiple of 3-hrs, exit -# ----------------------------------------------------------------------------- - - set +x - echo - echo "cannot perform tropical cyclone processing because cycle hour is not a multiple of 3-hrs;" - echo "ABNORMAL EXIT!!!!!!!!!!!" - echo - set_trace - exit 9 + # if center date/time for relocation processing isn't a multiple of 3-hrs, exit + # ----------------------------------------------------------------------------- + export err=9 + msg="FATAL ERROR: cannot perform tropical cyclone processing because cycle hour is not a multiple of 3-hrs" + err_exit "${msg}" fi -for fhr in 6 12 ;do - if [ ! -s tcvitals.m${fhr} ]; then # This should never exist, right ???? - -# create a null tcvitals file for 06 or 12 hours ago -# use getges to overwrite with any found - - >tcvitals.m${fhr} - set +x - echo -echo "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV" -echo " Get TCVITALS file valid for -$fhr hrs relative to center" -echo " relocation processing date/time" -echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" - echo - set_trace - ${USHgfs}/getges.sh -e $envir_getges -n $network_getges \ - -v ${run_date} -f $fhr -t tcvges tcvitals.m${fhr} - set +x - echo -echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" - echo - set_trace - fi +for fhr in 6 12; do + if [[ ! -s "tcvitals.m${fhr}" ]]; then # This should never exist, right ???? + + # create a null tcvitals file for 06 or 12 hours ago + # use getges to overwrite with any found + + rm -f "tcvitals.m${fhr}" + touch "tcvitals.m${fhr}" + cat << EOF + +VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV + Get TCVITALS file valid for -${fhr} hrs relative to center + relocation processing date/time +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + +EOF + "${USHgfs}/getges.sh" -e "${envir_getges}" -n "${network_getges}" \ + -v "${run_date}" -f "${fhr}" -t tcvges "tcvitals.m${fhr}" + cat << EOF + +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + +EOF + fi done # Next line needed to assure that only an analysis file will have the # relocation codes run on it export CMODEL=gdas -if [ "$GRIBVERSION" = "grib1" ]; then - export gribver=1 - pgpref=pgbg +if [[ "${GRIBVERSION}" == "grib1" ]]; then + export gribver=1 + pgpref=pgbg else - export gribver=2 # default - pgpref=pg2g + export gribver=2 # default + pgpref=pg2g fi -for fhr in $( seq -6 $BKGFREQ 3 ) ; do - - if [ $fhr -lt 0 ]; then - tpref=m$(expr $fhr \* -1) - elif [ $fhr -eq 0 ]; then - tpref=es - elif [ $fhr -gt 0 ]; then - tpref=p$fhr - fi - - sges=sg${tpref}prep - if [[ ${fhr} -lt -3 ]]; then - sges=NULL - fi - echo $sges -# stype=sigg${tpref} - stype=natg${tpref} - if [[ "${RUN}" = cdas1 ]]; then - stype="sigg${tpref}" ## for cfs - fi - pges=pg${tpref}prep - ptype=${pgpref}${tpref} - - if [ $sges != NULL -a ! -s $sges ]; then - set +x - echo -echo "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV" -echo " Get global sigma GUESS valid for $fhr hrs relative to center" -echo " relocation processing date/time" -echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" - echo - set_trace - ${USHgfs}/getges.sh -e $envir_getges -n $network_getges \ - -v ${run_date} -t $stype $sges - errges=$? - if test $errges -ne 0; then -# problem obtaining global sigma first guess so exit - set +x - echo - echo "problem obtaining global sigma guess valid $fhr hrs relative \ -to center relocation date/time;" - echo "ABNORMAL EXIT!!!!!!!!!!!" - echo - set_trace - exit 9 - fi - -# For center time sigma guess file obtained via getges, store pathname from -# getges into ${COMOUT_OBS}/${RUN}.${cycle}.sgesprep_pre-relocate_pathname.$tmmark and, for now, -# also in ${COMOUT_OBS}/${RUN}.${cycle}.sgesprep_pathname.$tmmark - if relocation processing stops -# due to an error or due to no input tcvitals records found, then the center -# time sigma guess will not be modified and this getges file will be read in -# subsequent PREP processing; if relocation processing continues and the -# center sigma guess is modified, then ${COMOUT_OBS}/${RUN}.${cycle}.sgesprep_pathname.$tmmark will -# be removed later in this script {the subsequent PREP step will correctly -# update ${COMOUT_OBS}/${RUN}.${cycle}.sgesprep_pathname.$tmmark to point to the sgesprep file -# updated here by the relocation} -# ---------------------------------------------------------------------------- - - if [ $fhr = "0" ]; then - "${USHgfs}/getges.sh" -e "${envir_getges}" -n "${network_getges}" -v "${run_date}" \ - -t "${stype}" > "${COMOUT_OBS}/${RUN}.${cycle}.sgesprep_pre-relocate_pathname.${tmmark}" - cpfs "${COMOUT_OBS}/${RUN}.${cycle}.sgesprep_pre-relocate_pathname.${tmmark}" \ - "${COMOUT_OBS}/${RUN}.${cycle}.sgesprep_pathname.${tmmark}" - fi - set +x - echo -echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" - echo - set_trace - fi - if [ ! -s $pges ]; then - set +x - echo -echo "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV" -echo " Get global pressure grib GUESS valid for $fhr hrs relative to center" -echo " relocation processing date/time" -echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" - echo - set_trace - ${USHgfs}/getges.sh -e $envir_getges -n $network_getges \ - -v ${run_date} -t $ptype $pges - errges=$? - if test $errges -ne 0; then -# problem obtaining global pressure grib guess so exit - set +x - echo - echo "problem obtaining global pressure grib guess valid $fhr hrs \ -relative to center relocation date/time;" - echo "ABNORMAL EXIT!!!!!!!!!!!" - echo - set_trace - exit 9 - fi - set +x - echo -echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" - echo - set_trace - fi +for fhr in $(seq -6 "${BKGFREQ}" 3); do + + if [[ "${fhr}" -lt 0 ]]; then + tpref="m$((-fhr))" + elif [[ ${fhr} -eq 0 ]]; then + tpref=es + elif [[ ${fhr} -gt 0 ]]; then + tpref="p${fhr}" + fi + + sges="sg${tpref}prep" + if [[ "${fhr}" -lt -3 ]]; then + sges=NULL + fi + echo "${sges}" + # stype=sigg${tpref} + stype="natg${tpref}" + if [[ "${RUN}" == cdas1 ]]; then + stype="sigg${tpref}" ## for cfs + fi + pges="pg${tpref}prep" + ptype="${pgpref}${tpref}" + + if [[ "${sges}" != NULL && ! -s "${sges}" ]]; then + cat << EOF + +VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV + Get global sigma GUESS valid for ${fhr} hrs relative to center + relocation processing date/time +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + +EOF + "${USHgfs}/getges.sh" -e "${envir_getges}" -n "${network_getges}" \ + -v "${run_date}" -t "${stype}" "${sges}" + errges=$? + if [[ "${errges}" -ne 0 ]]; then + # problem obtaining global sigma first guess so exit + export err="${errges}" + msg="FATAL ERROR: problem obtaining global sigma guess valid ${fhr} hrs relative to center relocation date/time" + err_exit "${msg}" + fi + + # For center time sigma guess file obtained via getges, store pathname from + # getges into ${COMOUT_OBS}/${RUN}.${cycle}.sgesprep_pre-relocate_pathname.$tmmark and, for now, + # also in ${COMOUT_OBS}/${RUN}.${cycle}.sgesprep_pathname.$tmmark - if relocation processing stops + # due to an error or due to no input tcvitals records found, then the center + # time sigma guess will not be modified and this getges file will be read in + # subsequent PREP processing; if relocation processing continues and the + # center sigma guess is modified, then ${COMOUT_OBS}/${RUN}.${cycle}.sgesprep_pathname.$tmmark will + # be removed later in this script {the subsequent PREP step will correctly + # update ${COMOUT_OBS}/${RUN}.${cycle}.sgesprep_pathname.$tmmark to point to the sgesprep file + # updated here by the relocation} + # ---------------------------------------------------------------------------- + + if [[ ${fhr} -eq 0 ]]; then + "${USHgfs}/getges.sh" -e "${envir_getges}" -n "${network_getges}" -v "${run_date}" \ + -t "${stype}" > "${COMOUT_OBS}/${RUN}.${cycle}.sgesprep_pre-relocate_pathname.${tmmark}" + cpfs "${COMOUT_OBS}/${RUN}.${cycle}.sgesprep_pre-relocate_pathname.${tmmark}" \ + "${COMOUT_OBS}/${RUN}.${cycle}.sgesprep_pathname.${tmmark}" + fi + cat << EOF + +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + +EOF + fi + if [[ ! -s "${pges}" ]]; then + cat << EOF + +VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV + Get global pressure grib GUESS valid for ${fhr} hrs relative to center + relocation processing date/time +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + +EOF + "${USHgfs}/getges.sh" -e "${envir_getges}" -n "${network_getges}" \ + -v "${run_date}" -t "${ptype}" "${pges}" + errges=$? + if [[ "${errges}" -ne 0 ]]; then + # problem obtaining global pressure grib guess so exit + export err="${errges}" + msg="FATAL ERROR: problem obtaining global pressure grib guess valid ${fhr} hrs relative to center relocation date/time;" + err_exit "${msg}" + fi + cat << EOF + +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + +EOF + fi done -if [ -f ${tstsp}syndata.tcvitals.$tmmark ]; then - cpreq ${tstsp}syndata.tcvitals.$tmmark tcvitals.now +if [[ -f "${tstsp}syndata.tcvitals.${tmmark}" ]]; then + cpreq "${tstsp}syndata.tcvitals.${tmmark}" tcvitals.now else - cpreq "${COMOUT_OBS}/${RUN}.${cycle}.syndata.tcvitals.${tmmark}" "tcvitals.now" + cpreq "${COMOUT_OBS}/${RUN}.${cycle}.syndata.tcvitals.${tmmark}" "tcvitals.now" fi +if [[ -s tcvitals.m12 ]]; then cat tcvitals.m12 > VITL; fi +if [[ -s tcvitals.m6 ]]; then cat tcvitals.m6 >> VITL; fi +if [[ -s tcvitals.now ]]; then cat tcvitals.now >> VITL; fi -[ -s tcvitals.m12 ] && cat tcvitals.m12 > VITL -[ -s tcvitals.m6 ] && cat tcvitals.m6 >> VITL -[ -s tcvitals.now ] && cat tcvitals.now >> VITL - -MP_PULSE=0 -MP_TIMEOUT=600 +export MP_PULSE=0 +export MP_TIMEOUT=600 GDATE10=$(date --utc +%Y%m%d%H -d "${run_date:0:8} ${run_date:8:2} - 6 hours") +export GDATE10 # make unique combined tcvitals file for t-12, t-6 and t+0 -- # if tcvitals does not contains record from current time, skip relocation @@ -410,199 +389,179 @@ GDATE10=$(date --utc +%Y%m%d%H -d "${run_date:0:8} ${run_date:8:2} - 6 hours") grep "${PDY} ${cyc}" VITL errgrep=$? -> tcvitals -if [ $errgrep -ne 0 ] ; then - echo "NO TCVITAL RECORDS FOUND FOR ${run_date} - EXIT TROPICAL CYCLONE \ +rm -f tcvitals +touch tcvitals +if [[ "${errgrep}" -ne 0 ]]; then + echo "NO TCVITAL RECORDS FOUND FOR ${run_date} - EXIT TROPICAL CYCLONE \ RELOCATION PROCESSING" -# The existence of ${COMOUT_OBS}/${RUN}.${cycle}.tropcy_relocation_status.$tmmark file will tell the -# subsequent PREP processing that RELOCATION processing occurred, echo -# "NO RECORDS to process" into it to further tell PREP processing that records -# were not processed by relocation and the global sigma guess was NOT -# modified by tropical cyclone relocation (because no tcvitals records were -# found) -# Note: When tropical cyclone relocation does run to completion and the -# global sigma guess is modified, the parent script to this will echo -# "RECORDS PROCESSED" into ${COMOUT_OBS}/${RUN}.${cycle}.tropcy_relocation_status.$tmmark -# assuming it doesn't already exist (meaning "NO RECORDS to process" -# was NOT echoed into it here) -# ---------------------------------------------------------------------------- - - echo "NO RECORDS to process" > "${COMOUT_OBS}/${RUN}.${cycle}.tropcy_relocation_status.${tmmark}" - if [[ ! -s "${COMOUT_OBS}/${RUN}.${cycle}.tcvitals.relocate.${tmmark}" ]]; then - touch "${COMOUT_OBS}/${RUN}.${cycle}.tcvitals.relocate.${tmmark}" - fi + # The existence of ${COMOUT_OBS}/${RUN}.${cycle}.tropcy_relocation_status.$tmmark file will tell the + # subsequent PREP processing that RELOCATION processing occurred, echo + # "NO RECORDS to process" into it to further tell PREP processing that records + # were not processed by relocation and the global sigma guess was NOT + # modified by tropical cyclone relocation (because no tcvitals records were + # found) + # Note: When tropical cyclone relocation does run to completion and the + # global sigma guess is modified, the parent script to this will echo + # "RECORDS PROCESSED" into ${COMOUT_OBS}/${RUN}.${cycle}.tropcy_relocation_status.$tmmark + # assuming it doesn't already exist (meaning "NO RECORDS to process" + # was NOT echoed into it here) + # ---------------------------------------------------------------------------- + + echo "NO RECORDS to process" > "${COMOUT_OBS}/${RUN}.${cycle}.tropcy_relocation_status.${tmmark}" + if [[ ! -s "${COMOUT_OBS}/${RUN}.${cycle}.tcvitals.relocate.${tmmark}" ]]; then + touch "${COMOUT_OBS}/${RUN}.${cycle}.tcvitals.relocate.${tmmark}" + fi else - cat VITL >>tcvitals - grep "${PDY} ${cyc}" VITL > tcvitals.now1 - - -# create model forecast track location file -# $DATA/$RUN.$cycle.relocate.model_track.tm00 -# -------------------------------------------- - - ${USHgfs}/tropcy_relocate_extrkr.sh - err=$? - if [ $err -ne 0 ]; then - -# problem: script tropcy_relocate_extrkr.sh failed -# ------------------------------------------------ - - set +x - echo - echo "${USHgfs}/tropcy_relocate_extrkr.sh failed" - echo "ABNORMAL EXIT!!!!!!!!!!!" - echo - set_trace - exit 9 - fi - -# relocate model tropical cyclone vortices in ges sigma files -# ----------------------------------------------------------- - - rm -f fort.* - - ${NLN} $DATA/tcvitals.now1 fort.11 - ${NLN} $DATA/model_track.all fort.30 - ${NLN} $DATA/rel_inform1 fort.62 - ${NLN} $DATA/tcvitals.relocate0 fort.65 - - i1=20 - i2=53 - for fhr in $( seq -3 $BKGFREQ 3 ) ; do - - if [ $fhr -lt 0 ]; then - tpref=m$(expr $fhr \* -1) - elif [ $fhr -eq 0 ]; then - tpref=es - elif [ $fhr -gt 0 ]; then - tpref=p$fhr - fi - - ${NLN} $DATA/sg${tpref}prep fort.$i1 - ${NLN} $DATA/sg${tpref}prep.relocate fort.$i2 - - i1=$((i1+1)) - i2=$((i2+BKGFREQ)) - - done - -# if LATB or LONB is unset or <= 0, the sigma header values are used -# ------------------------------------------------------------------ - - set +u - [ -z "$LONB" ] && LONB=0 - [ -z "$LATB" ] && LATB=0 - set -u - - i1=0 - for gesfhr in $( seq 3 $BKGFREQ 9 ) ; do - - echo ${gesfhr} ${LONB} ${LATB} ${BKGFREQ} > "parm.${i1}" - - i1=$((i1+1)) - - done - -# setup and run the mpi relocation code -# ------------------------------------- - - export MP_EUILIB=us - export MP_EUIDEVICE=sn_all - export MP_USE_BULK_XFER=yes - export RELOX_threads=${RELOX_threads:-16} - export KMP_STACKSIZE=1024m - export OMP_NUM_THREADS=$RELOX_threads - export MP_TASK_AFFINITY=core:$RELOX_threads - - ${APRNRELOC:-mpirun.lsf} $RELOX >stdo.prints - errSTATUS=$? - -# copy relocation print output here and there -# ------------------------------------------- - - cat $DATA/stdo.prints >> $pgmout - cat $DATA/stdo.[0-9]* >> $pgmout - cat $DATA/stdo.prints >> relocate.out - cat $DATA/stdo.[0-9]* >> relocate.out - -# check for success -# ----------------- - - echo; set_trace - if [ "$errSTATUS" -gt '0' ]; then - exit 9 - fi - -# further check for success -# ------------------------- - - for fhr in $( seq -3 $BKGFREQ 3 ) ; do - - if [ $fhr -lt 0 ]; then - tpref=m$(expr $fhr \* -1) - elif [ $fhr -eq 0 ]; then - tpref=es - elif [ $fhr -gt 0 ]; then - tpref=p$fhr - fi - - sges=sg${tpref}prep - - if [ -s $sges.relocate ] ; then - mv $sges.relocate $sges - else - -# problem: $sges.relocate does not exist -# -------------------------------------- - - echo "FATAL ERROR: The file ${sges}.relocate does not exist" - exit 9 - fi - done - - if [ -s tcvitals.relocate0 ]; then - mv tcvitals.relocate0 tcvitals - else - >tcvitals - fi - rm -f RELOCATE_GES cmd - - - cpfs "rel_inform1" "${COMOUT_OBS}/${RUN}.${cycle}.inform.relocate.${tmmark}" - cpfs "tcvitals" "${COMOUT_OBS}/${RUN}.${cycle}.tcvitals.relocate.${tmmark}" - if [[ "${SENDDBN}" == "YES" ]]; then - if test "$RUN" = "gdas1" - then - "${DBNROOT}/bin/dbn_alert" "MODEL" "GDAS1_TCI" "${job}" "${COMOUT_OBS}/${RUN}.${cycle}.inform.relocate.${tmmark}" - "${DBNROOT}/bin/dbn_alert" "MODEL" "GDAS1_TCI" "${job}" "${COMOUT_OBS}/${RUN}.${cycle}.tcvitals.relocate.${tmmark}" - fi - if test "$RUN" = "gfs" - then - "${DBNROOT}/bin/dbn_alert" "MODEL" "GFS_TCI" "${job}" "${COMOUT_OBS}/${RUN}.${cycle}.inform.relocate.${tmmark}" - "${DBNROOT}/bin/dbn_alert" "MODEL" "GFS_TCI" "${job}" "${COMOUT_OBS}/${RUN}.${cycle}.tcvitals.relocate.${tmmark}" - fi - fi - -# -------------------------------------------------------------------------- -# Since relocation processing has ended sucessfully (and the center sigma -# guess has been modified), remove ${COMOUT_OBS}/${RUN}.${cycle}.sgesprep_pathname.$tmmark (which -# had earlier had getges center sigma guess pathname written into it - in -# case of error or no input tcvitals records found) - the subsequent PREP -# step will correctly update ${COMOUT_OBS}/${RUN}.${cycle}.sgesprep_pathname.$tmmark to point to -# the sgesprep file updated here by the relocation -# -------------------------------------------------------------------------- - - rm -f "${COMOUT_OBS}/${RUN}.${cycle}.sgesprep_pathname.${tmmark}" - - echo "TROPICAL CYCLONE RELOCATION PROCESSING SUCCESSFULLY COMPLETED FOR ${run_date}" + cat VITL >> tcvitals + grep "${PDY} ${cyc}" VITL > tcvitals.now1 + + # create model forecast track location file + # $DATA/$RUN.$cycle.relocate.model_track.tm00 + # -------------------------------------------- + + "${USHgfs}/tropcy_relocate_extrkr.sh" + err=$? + if [[ "${err}" -ne 0 ]]; then + + # problem: script tropcy_relocate_extrkr.sh failed + # ------------------------------------------------ + export err + echo "FATAL ERROR: ${USHgfs}/tropcy_relocate_extrkr.sh failed" + err_exit "${msg}" + fi + + # relocate model tropical cyclone vortices in ges sigma files + # ----------------------------------------------------------- + + rm -f fort.* + + ${NLN} "${DATA}/tcvitals.now1" fort.11 + ${NLN} "${DATA}/model_track.all" fort.30 + ${NLN} "${DATA}/rel_inform1" fort.62 + ${NLN} "${DATA}/tcvitals.relocate0" fort.65 + + i1=20 + i2=53 + for ((fhr = -3; fhr <= 3; fhr += BKGFREQ)); do + if [[ "${fhr}" -lt 0 ]]; then + tpref="m$((-fhr))" + elif [[ "${fhr}" -eq 0 ]]; then + tpref=es + elif [[ "${fhr}" -gt 0 ]]; then + tpref="p${fhr}" + fi + + ${NLN} "${DATA}/sg${tpref}prep" "fort.${i1}" + ${NLN} "${DATA}/sg${tpref}prep.relocate" "fort.${i2}" + + i1=$((i1 + 1)) + i2=$((i2 + BKGFREQ)) + + done + + # if LATB or LONB is unset or <= 0, the sigma header values are used + # ------------------------------------------------------------------ + + if [[ -z "${LONB}" ]]; then LONB=0; fi + if [[ -z "${LATB}" ]]; then LATB=0; fi + + i1=0 + for ((gesfhr = 3; gesfhr <= 0; gesfhr += BKGFREQ)); do + echo "${gesfhr} ${LONB} ${LATB} ${BKGFREQ}" > "parm.${i1}" + i1=$((i1 + 1)) + done + + # setup and run the mpi relocation code + # ------------------------------------- + + export MP_EUILIB=us + export MP_EUIDEVICE=sn_all + export MP_USE_BULK_XFER=yes + export RELOX_threads=${RELOX_threads:-16} + export KMP_STACKSIZE=1024m + export OMP_NUM_THREADS=${RELOX_threads} + export MP_TASK_AFFINITY=core:${RELOX_threads} + + ${APRNRELOC:-mpirun.lsf} "${RELOX}" > stdo.prints + errSTATUS=$? + + # copy relocation print output here and there + # ------------------------------------------- + + cat "${DATA}/stdo.prints" + cat "${DATA}/stdo.[0-9]"* + cat "${DATA}/stdo.prints" >> relocate.out + cat "${DATA}/stdo.[0-9]"* >> relocate.out + + # check for success + # ----------------- + + echo + if [[ "${errSTATUS}" -gt '0' ]]; then + export err="${errSTATUS}" + err_exit + fi + + # further check for success + # ------------------------- + + for ((fhr = -3; fhr <= 3; fhr += BKGFREQ)); do + if [[ "${fhr}" -lt 0 ]]; then + tpref="m$((-fhr))" + elif [[ "${fhr}" -eq 0 ]]; then + tpref=es + elif [[ "${fhr}" -gt 0 ]]; then + tpref="p${fhr}" + fi + + sges="sg${tpref}prep" + + if [[ -s "${sges}.relocate" ]]; then + mv "${sges}.relocate" "${sges}" + else + + # problem: $sges.relocate does not exist + # -------------------------------------- + + export err=9 + msg="FATAL ERROR: The file ${sges}.relocate does not exist" + err_exit "${msg}" + fi + done + + if [[ -s tcvitals.relocate0 ]]; then + mv tcvitals.relocate0 tcvitals + else + rm -f tcvitals + touch tcvitals + fi + rm -f RELOCATE_GES cmd + + cpfs "rel_inform1" "${COMOUT_OBS}/${RUN}.${cycle}.inform.relocate.${tmmark}" + cpfs "tcvitals" "${COMOUT_OBS}/${RUN}.${cycle}.tcvitals.relocate.${tmmark}" + if [[ "${SENDDBN}" == "YES" ]]; then + "${DBNROOT}/bin/dbn_alert" "MODEL" "${RUN^^}_TCI" "${job}" "${COMOUT_OBS}/${RUN}.${cycle}.inform.relocate.${tmmark}" + "${DBNROOT}/bin/dbn_alert" "MODEL" "${RUN^^}_TCI" "${job}" "${COMOUT_OBS}/${RUN}.${cycle}.tcvitals.relocate.${tmmark}" + fi + + # -------------------------------------------------------------------------- + # Since relocation processing has ended sucessfully (and the center sigma + # guess has been modified), remove ${COMOUT_OBS}/${RUN}.${cycle}.sgesprep_pathname.$tmmark (which + # had earlier had getges center sigma guess pathname written into it - in + # case of error or no input tcvitals records found) - the subsequent PREP + # step will correctly update ${COMOUT_OBS}/${RUN}.${cycle}.sgesprep_pathname.$tmmark to point to + # the sgesprep file updated here by the relocation + # -------------------------------------------------------------------------- + + rm -f "${COMOUT_OBS}/${RUN}.${cycle}.sgesprep_pathname.${tmmark}" + + echo "TROPICAL CYCLONE RELOCATION PROCESSING SUCCESSFULLY COMPLETED FOR ${run_date}" # end GFDL ges manipulation # ------------------------- fi - exit 0 - diff --git a/ush/tropcy_relocate_extrkr.sh b/ush/tropcy_relocate_extrkr.sh index 42b53df4cf1..8427908ba6b 100755 --- a/ush/tropcy_relocate_extrkr.sh +++ b/ush/tropcy_relocate_extrkr.sh @@ -3,18 +3,13 @@ # This script is executed by the script tropcy_relocate.sh # -------------------------------------------------------- -export machine=${machine:-ZEUS} -export machine=$(echo $machine|tr '[a-z]' '[A-Z]') -#if [ $machine = ZEUS ] ; then -# module load intel -# module load mpt -#fi +export machine=${machine^^} +export err pgm # Variable "gribver" defines if input GRIB data is in # GRIB1 (gribver=1) or GRIB2 (gribver=2) format. export gribver=${gribver:-1} -user=$LOGNAME # PDYcyc - 10 digit date # RUN - network run (gfs, gdas, etc) # DATA - working directory @@ -24,14 +19,14 @@ user=$LOGNAME export APRNGETTX=${APRNGETTX:-""} TIMEIT="" -[ -s $DATA/timex ] && TIMEIT=$DATA/timex - -vdir=${vdir:-$DATA/trakout} -if [ ! -d ${vdir} ]; then - mkdir -p ${vdir} +if [[ -s "${DATA}/timex" ]]; then + TIMEIT="${DATA}/timex" fi -cd $vdir +vdir=${vdir:-${DATA}/trakout} +mkdir -p "${vdir}" + +cd "${vdir}" || exit 1 # This script kicks off the hurricane tracker system. You have the option of # running the tracker on several operational models (the system will @@ -40,7 +35,6 @@ cd $vdir # will ONLY be able to read GRIB data. To run the tracker, fill in the # required fields below on the "export" lines, then llsubmit this script. - # ------------------- # 1. ENTER MODEL TYPE # ------------------- @@ -55,8 +49,7 @@ cd $vdir # # Example: export CMODEL=gfs -export CMODEL=${CMODEL:-$RUN} - +export CMODEL=${CMODEL:-${RUN}} # ------------------- # 2. ENTER FILE NAME @@ -81,7 +74,6 @@ export CMODEL=${CMODEL:-$RUN} export INPFILE=${INPFILE:-} - # ------------------------------- # 3. ENTER FORECAST HOUR INTERVAL # ------------------------------- @@ -105,8 +97,7 @@ export FHINT=${FHINT:-03} # # Enter the starting date, in yyyymmddhh format, of the forecast: -export YYYYMMDDHH=$GDATE10 - +export YYYYMMDDHH=${GDATE10} # ------------------------- # 5. ENTER STORM IDENTIFIER @@ -118,7 +109,6 @@ export YYYYMMDDHH=$GDATE10 export INPSTORM= - # ----------------------------------------- # 6. ENTER NAME OF AUXILIARY TC VITALS FILE # ----------------------------------------- @@ -143,7 +133,6 @@ export INPSTORM= export AUXTCVIT= - # ----------------------------------------------------- # ENTER THRESHOLDS FOR USE IN VERIFYING STORM STRUCTURE # ----------------------------------------------------- @@ -175,7 +164,6 @@ export V850THRESH=3.000 # Set the default for background files to be 3 hourly export BKGFREQ=${BKGFREQ:-1} - # This script is the second in a set of 2 that starts the tracker for either # operational or user-defined model output. This script makes sure that the # data files exist, it also pulls all of the needed data records out of the @@ -184,29 +172,24 @@ export BKGFREQ=${BKGFREQ:-1} # updates the TC Vitals (if necessary). It then executes the gettrk # executable, which actually does the tracking. - -inpstorm=${INPSTORM} inpfile=${INPFILE} fhint=${FHINT} cmodel=${CMODEL} symdh=${YYYYMMDDHH} -auxtcvit=${AUXTCVIT} -user=$LOGNAME -#export TMPDIR=/nfstmp/${user}/trak/${RANDOM} -export TMPDIR=$DATA/trak/${RANDOM} -if [ ! -d $TMPDIR ]; then mkdir -p $TMPDIR; fi -if [ -s ${TMPDIR}/tmpsynvit ]; then rm ${TMPDIR}/tmpsynvit; fi -if [ -s ${TMPDIR}/tmprawvit ]; then rm ${TMPDIR}/tmprawvit; fi +export TMPDIR=${DATA}/trak/${RANDOM} +mkdir -p "${TMPDIR}" +rm -f "${TMPDIR}/tmpsynvit" +rm -f "${TMPDIR}/tmprawvit" export flag_pgb=${flag_pgb:-q} -wgrib_parmlist=" HGT:850 HGT:700 UGRD:850 UGRD:700 UGRD:500 VGRD:850 VGRD:700 VGRD:500 SurfaceU SurfaceV ABSV:850 ABSV:700 PRMSL:MSL MSLET" +wgrib_parmlist="HGT:850 HGT:700 UGRD:850 UGRD:700 UGRD:500 VGRD:850 VGRD:700 VGRD:500 SurfaceU SurfaceV ABSV:850 ABSV:700 PRMSL:MSL MSLET" -export maxtime=22 # Max number of forecast time levels +export maxtime=22 # Max number of forecast time levels -if [ ! -d ${vdir} ]; then mkdir -p ${vdir}; fi -if [ ! -d ${TMPDIR} ]; then mkdir -p ${TMPDIR}; fi +mkdir -p "${vdir}" +mkdir -p "${TMPDIR}" scc=${symdh:0:2} syy=${symdh:2:2} @@ -216,100 +199,124 @@ shh=${symdh:8:2} dishh=${shh} symd=${symdh:0:8} -case ${shh} in - 0|00) dishh="00";; - 3|03) dishh="03";; - 6|06) dishh="06";; - 12) dishh="12";; - 15) dishh="15";; - 18) dishh="18";; -esac - #---------------------------------------------------# # Convert the input model to lowercase letters and # check to see if it's a valid model, and assign a # model ID number to it. #---------------------------------------------------# -cmodel=$(echo ${cmodel} | tr "[A-Z]" "[a-z]") +cmodel=${cmodel,,} case ${cmodel} in - gdas) set +x; echo " "; echo " ++ operational GDAS chosen"; set_trace; - fcstlen=9 ; - fcsthrs="" - for fhr in $( seq 0 $BKGFREQ 9); do - fhrchar=$(printf %02d $fhr) - fcsthrs="$fcsthrs $fhrchar" - done - atcfnum=72 ; - atcfname="gdas" ; - atcfout="gdas" ; - if [ $BKGFREQ -eq 1 ]; then - atcffreq=100 - elif [ $BKGFREQ -eq 3 ]; then - atcffreq=300 - fi - mslpthresh=0.0015 - v850thresh=1.5000 - modtyp='global' - file_sequence="onebig" - lead_time_units='hours' - export PHASEFLAG=n - export WCORE_DEPTH=1.0 - #export PHASE_SCHEME=vtt - #export PHASE_SCHEME=cps - export PHASE_SCHEME=both - export STRUCTFLAG=n - export IKEFLAG=n - export trkrtype='tracker' - # g2_jpdtn sets the variable that will be used as "JPDTN" for - # the call to getgb2, if gribver=2. jpdtn=1 for ens data, - # jpdtn=0 for deterministic data. - g2_jpdtn=0 - model=8;; - gfs) set +x; echo " "; echo " ++ operational GFS chosen"; set_trace; - fcsthrsgfs=' 00 06 12 18 24 30 36 42 48 54 60 66 72 78'; - gfsdir=$COMIN; - gfsgfile=gfs.t${dishh}z.pgrbf; - model=1;; - mrf) set +x; echo " "; echo " ++ operational MRF chosen"; set_trace; - fcsthrsmrf=' 00 12 24 36 48 60 72'; - mrfdir=$COMIN; - mrfgfile=drfmr.t${dishh}z.pgrbf; - model=2;; - ukmet) set +x; echo " "; echo " ++ operational UKMET chosen"; set_trace; - fcsthrsukmet=' 00 12 24 36 48 60 72'; - ukmetdir=$COMIN; - ukmetgfile=ukmet.t${dishh}z.ukmet; - model=3;; - ecmwf) set +x; echo " "; echo " ++ operational ECMWF chosen"; set_trace; - fcsthrsecmwf=' 00 24 48 72'; - ecmwfdir=$COMIN; - ecmwfgfile=ecmgrb25.t12z; - model=4;; - ngm) set +x; echo " "; echo " ++ operational NGM chosen"; set_trace; - fcsthrsngm=' 00 06 12 18 24 30 36 42 48'; - ngmdir=$COMIN; - ngmgfile=ngm.t${dishh}z.pgrb.f; - model=5;; - nam) set +x; echo " "; echo " ++ operational Early NAM chosen"; set_trace; - fcsthrsnam=' 00 06 12 18 24 30 36 42 48'; - namdir=$COMIN; - namgfile=nam.t${dishh}z.awip32; - model=6;; - ngps) set +x; echo " "; echo " ++ operational NAVGEM chosen"; set_trace; - fcsthrsngps=' 00 12 24 36 48 60 72'; - #ngpsdir=/com/hourly/prod/hourly.${symd}; - ngpsdir=$OMIN; - ngpsgfile=fnoc.t${dishh}z; - model=7;; - other) set +x; echo " "; echo " Model selected by user is ${cmodel}, which is a "; - echo "user-defined model, NOT operational...."; echo " "; set_trace; - model=9;; - *) set +x; echo " "; echo " !!! Model selected is not recognized."; - echo " Model= ---> ${cmodel} <--- ..... Please submit the script again...."; - echo " "; set_trace; exit 8;; + gdas) + echo " " + echo " ++ operational GDAS chosen" + fcsthrs="" + for fhr in $(seq 0 "${BKGFREQ}" 9); do + fhrchar=$(printf %02d "${fhr}") + fcsthrs="${fcsthrs} ${fhrchar}" + done + atcfnum=72 + atcfname="gdas" + if [[ "${BKGFREQ}" -eq 1 ]]; then + atcffreq=100 + elif [[ "${BKGFREQ}" -eq 3 ]]; then + atcffreq=300 + fi + modtyp='global' + file_sequence="onebig" + lead_time_units='hours' + export PHASEFLAG=n + export WCORE_DEPTH=1.0 + export PHASE_SCHEME=both + export STRUCTFLAG=n + export IKEFLAG=n + export trkrtype='tracker' + # g2_jpdtn sets the variable that will be used as "JPDTN" for + # the call to getgb2, if gribver=2. jpdtn=1 for ens data, + # jpdtn=0 for deterministic data. + g2_jpdtn=0 + model=8 + ;; + gfs) + echo " " + echo " ++ operational GFS chosen" + fcsthrsgfs='00 06 12 18 24 30 36 42 48 54 60 66 72 78' + gfsdir="${COMIN}" + gfsgfile=gfs.t${dishh}z.pgrbf + model=1 + ;; + mrf) + echo " " + echo " ++ operational MRF chosen" + fcsthrsmrf='00 12 24 36 48 60 72' + mrfdir="${COMIN}" + mrfgfile=drfmr.t${dishh}z.pgrbf + model=2 + ;; + ukmet) + echo " " + echo " ++ operational UKMET chosen" + fcsthrsukmet='00 12 24 36 48 60 72' + ukmetdir="${COMIN}" + ukmetgfile=ukmet.t${dishh}z.ukmet + model=3 + ;; + ecmwf) + echo " " + echo " ++ operational ECMWF chosen" + ecmwfdir="${COMIN}" + ecmwfgfile=ecmgrb25.t12z + model=4 + ;; + ngm) + set +x + echo " " + echo " ++ operational NGM chosen" + set_trace + fcsthrsngm='00 06 12 18 24 30 36 42 48' + ngmdir="${COMIN}" + ngmgfile=ngm.t${dishh}z.pgrb.f + model=5 + ;; + nam) + echo " " + echo " ++ operational Early NAM chosen" + fcsthrsnam='00 06 12 18 24 30 36 42 48' + namdir="${COMIN}" + namgfile=nam.t${dishh}z.awip32 + model=6 + ;; + ngps) + echo " " + echo " ++ operational NAVGEM chosen" + fcsthrsngps='00 12 24 36 48 60 72' + #ngpsdir=/com/hourly/prod/hourly.${symd}; + ngpsdir="${COMIN}" + ngpsgfile=fnoc.t${dishh}z + model=7 + ;; + other) + cat << EOF +Model selected by user is ${cmodel}, which is a +user-defined model, NOT operational.... + +EOF + model=9 + ;; + *) + msg=$( + cat << EOF + +FATAL ERROR: Model selected is not recognized. +Model= ---> ${cmodel} <--- ..... Please submit the script again.... + +EOF + ) + err=8 + err_exit "${msg}" + ;; esac @@ -323,14 +330,11 @@ esac # if the model is user-defined. #------------------------------------------------- -fct=1 -while [ ${fct} -le 14 ]; -do - fh[${fct}]=99 - let fct=fct+1 +export fh +for ((fct = 1; fct <= 14; fct++)); do + fh[fct]=99 done - #------------------------------------------------------# # Set the directories for the operational files. For # a user-specified model, we need to process the @@ -338,142 +342,125 @@ done # data directory, etc..... #------------------------------------------------------# -if [ ${cmodel} = 'other' ]; then - -# This next bit of code tears apart the input file name to get the -# data directory and data file names. pos1, pos2, pos3 and pos4 -# refer to character string positions in the filename string. The -# idea of this next bit of code is to pull the file name apart to -# get a shell for the file name, so that if a user has a file -# name such as pgbf00.97090100, the script knows where in the -# string to substitute the forecast hours. IMPORTANT NOTE: The -# file name that the user enters must have the characters "XX" in -# in place of the forecast hour characters "00" in order for this -# to work. -# -# pos1= character position immediately before "00" starts -# pos2= character position at which "00" starts -# pos3= character position immediately after "00" -# pos4= character position of last character in name - - otherdir=$(dirname ${inpfile}) - fname=$(basename ${inpfile}) - - pos2=$(echo ${fname} | awk '{ match($0,/XX/); print RSTART }') - pos4=$(echo ${fname} | awk '{ match($0,/$/); print RSTART }') - let pos4=pos4-1 - let pos1=pos2-1 - let pos3=pos2+2 - - if [ ${pos2} -eq 0 ]; then - set +x - echo " " - echo " !!! ERROR! Something wrong with name of input file name for the" - echo " analysis file. Either the input file is missing, or you did not" - echo " replace the forecast hour characters 00 with XX. Please check the" - echo " name in the kickoff script and qsub it again. Exiting....." - echo " " - set_trace - exit 8 - fi - - fnamebeg=$(echo ${fname} | cut -c1-${pos1}) - if [ ${pos4} -ge ${pos3} ]; then - fnameend=$(echo ${fname} | cut -c${pos3}-${pos4}) - else - fnameend="" - fi - - fflag='y' - fhour=0 - fcsthrsother='' - fhrct=0 - while [ ${fflag} = 'y' ]; - do - - if [ ${fhrct} -eq 14 ]; then - set +x - echo " " - echo " !!! Exiting loop, only processing 14 forecast files ...." - echo " " - set_trace - break +if [[ "${cmodel}" == 'other' ]]; then + + # This next bit of code tears apart the input file name to get the + # data directory and data file names. pos1, pos2, pos3 and pos4 + # refer to character string positions in the filename string. The + # idea of this next bit of code is to pull the file name apart to + # get a shell for the file name, so that if a user has a file + # name such as pgbf00.97090100, the script knows where in the + # string to substitute the forecast hours. IMPORTANT NOTE: The + # file name that the user enters must have the characters "XX" in + # in place of the forecast hour characters "00" in order for this + # to work. + # + # pos1= character position immediately before "00" starts + # pos2= character position at which "00" starts + # pos3= character position immediately after "00" + # pos4= character position of last character in name + + otherdir=$(dirname "${inpfile}") + fname=$(basename "${inpfile}") + + fnamebeg=$(grep -Po '.*(?=XX)' <<< "${fname}") + fnameend=$(grep -Po '(?<=XX).*($)' <<< "${fname}") + + if [[ -z "${fnamebeg}" ]]; then + read -r -d '' msg << EOF +FATAL ERROR: Something wrong with name of input file name for the +analysis file. Either the input file is missing, or you did not +replace the forecast hour characters 00 with XX. Please check the +name in the kickoff script and qsub it again. +EOF + err=8 + err_exit "${msg}" fi - if [ ${fhour} -lt 10 ]; then - fhour=0${fhour} - fi + fflag='y' + fhour=0 + fcsthrsother='' + fhrct=0 + while [[ ${fflag} == 'y' ]]; do - if [ -s ${otherdir}/${fnamebeg}${fhour}${fnameend} ]; then - maxhour=${fhour} - fcsthrsother=${fcsthrsother}" ${fhour}" - set +x - echo " " - echo " +++ Found file ${fnamebeg}${fhour}${fnameend}" - echo " " - set_trace - let fhrct=fhrct+1 - else - fflag='n' - fi + if [[ "${fhrct}" -eq 14 ]]; then + cat << EOF - let fhour=fhour+fhint - - done - - if [ ! -s ${otherdir}/${fnamebeg}00${fnameend} ]; then - set +x - echo " " - echo " !!! ERROR in $(basename $0)" - echo " !!! Input analysis file cannot be found." - echo " !!! The tracker is looking for this file in: " - echo " !!! ----> ${otherdir}/${fnamebeg}00${fnameend}" - echo " !!! Please check the directory to make sure the file" - echo " !!! is there and then submit this job again." - echo " " - set_trace - exit 8 - fi - - set +x - echo " " - echo " Max forecast hour is $maxhour" - echo " List of forecast hours: $fcsthrsother" - echo " " - set_trace - -# -------------------------------------------------- -# In order for the fortran program to know how many -# forecast times there are and what those forecast -# hours are, we need to include this information in -# the namelist file. So first, put this information -# into an array, then at the end of this script, -# we'll put it into the namelist file. - - fhour=0 - fct=1 - while [ ${fct} -le 14 ]; - do - - if [ ${fhour} -le ${maxhour} ]; then - fh[${fct}]=${fhour} - else - fh[${fct}]=99 +!!! Exiting loop, only processing 14 forecast files .... + +EOF + break + fi + + fhour=$(printf '%02d' "${fhour}") + + if [[ -s "${otherdir}/${fnamebeg}${fhour}${fnameend}" ]]; then + maxhour=${fhour} + fcsthrsother="${fcsthrsother} ${fhour}" + cat << EOF + ++++ Found file ${fnamebeg}${fhour}${fnameend} + +EOF + fhrct=$((fhrct + 1)) + else + fflag='n' + fi + + fhour=$((fhour + fhint)) + + done + + if [[ ! -s "${otherdir}/${fnamebeg}00${fnameend}" ]]; then + msg=$( + cat << EOF + +!!! FATAL ERROR in $(basename "$0"): +!!! Input analysis file cannot be found. +!!! The tracker is looking for this file in: +!!! ----> ${otherdir}/${fnamebeg}00${fnameend} +!!! Please check the directory to make sure the file +!!! is there and then submit this job again. + +EOF + ) + err=8 + err_exit "${msg}" fi - let fct=fct+1 - let fhour=fhour+fhint + cat << EOF - done +Max forecast hour is ${maxhour} +List of forecast hours: ${fcsthrsother} +EOF + + # -------------------------------------------------- + # In order for the fortran program to know how many + # forecast times there are and what those forecast + # hours are, we need to include this information in + # the namelist file. So first, put this information + # into an array, then at the end of this script, + # we'll put it into the namelist file. + + fhour=0 + for ((fcnt = 1; fcnt <= 14; fcnt++)); do + if [[ "${fhour}" -le "${maxhour}" ]]; then + fh[fct]=${fhour} + else + fh[fct]=99 + fi + fhour=$((fhour + fhint)) + done fi -cpfs $DATA/tcvitals ${vdir}/vitals.${symd}${dishh} +cpfs "${DATA}/tcvitals" "${vdir}/vitals.${symd}${dishh}" -grep -v TEST ${vdir}/vitals.${symd}${dishh} | \ - awk 'substr($0,6,1) !~ /[8-9]/ {print $0}' >${vdir}/tempvit.nonameless +# shellcheck disable=SC2312 +grep -v TEST "${vdir}/vitals.${symd}${dishh}" | + awk 'substr($0,6,1) !~ /[8-9]/ {print $0}' > "${vdir}/tempvit.nonameless" -mv ${vdir}/tempvit.nonameless ${vdir}/vitals.${symd}${dishh} +mv "${vdir}/tempvit.nonameless" "${vdir}/vitals.${symd}${dishh}" #--------------------------------------------------------------# # Now run a fortran program that will read all the TC vitals @@ -492,18 +479,16 @@ syy6=${ymdh6ago:2:2} smm6=${ymdh6ago:4:2} sdd6=${ymdh6ago:6:2} shh6=${ymdh6ago:8:2} -symd6=${ymdh6ago:2:6} ymdh6ahead=$(date --utc +%Y%m%d%H -d "${symd} ${dishh} + 6 hours") syyp6=${ymdh6ahead:2:2} smmp6=${ymdh6ahead:4:2} sddp6=${ymdh6ahead:6:2} shhp6=${ymdh6ahead:8:2} -symdp6=${ymdh6ahead:2:6} vit_incr=6 -cat<$TMPDIR/suv_input +cat << EOF > "${TMPDIR}/suv_input" &datenowin dnow%yy=${syy}, dnow%mm=${smm}, dnow%dd=${sdd}, dnow%hh=${dishh}/ &dateoldin dold%yy=${syy6}, dold%mm=${smm6}, @@ -513,17 +498,20 @@ cat<$TMPDIR/suv_input &hourinfo vit_hr_incr=${vit_incr}/ EOF -numvitrecs=$(cat ${vdir}/vitals.${symd}${dishh} | wc -l) -if [ ${numvitrecs} -eq 0 ]; then - set +x - echo " " - echo "!!! ERROR -- There are no vitals records for this time period." - echo "!!! File ${vdir}/vitals.${symd}${dishh} is empty." - echo "!!! It could just be that there are no storms for the current" - echo "!!! time. Please check the dates and submit this job again...." - echo " " - set_trace - exit 8 +numvitrecs=$(wc -l "${vdir}/vitals.${symd}${dishh}") +if [[ ${numvitrecs} -eq 0 ]]; then + msg=$( + cat << EOF + +!!! FATAL ERROR: There are no vitals records for this time period. +!!! File ${vdir}/vitals.${symd}${dishh} is empty. +!!! It could just be that there are no storms for the current +!!! time. Please check the dates and submit this job again.... + +EOF + ) + err=8 + err_exit "${msg}" fi # - - - - - - - - - - - - - @@ -543,8 +531,8 @@ fi # was messing up the "(length($4) == 8)" statement logic. # - - - - - - - - - - - - - -sed -e "s/\:/ /g" ${vdir}/vitals.${symd}${dishh} > ${TMPDIR}/tempvit -mv ${TMPDIR}/tempvit ${vdir}/vitals.${symd}${dishh} +sed -e "s/\:/ /g" "${vdir}/vitals.${symd}${dishh}" > "${TMPDIR}/tempvit" +mv "${TMPDIR}/tempvit" "${vdir}/vitals.${symd}${dishh}" awk ' { @@ -560,78 +548,61 @@ awk ' printf ("%s19%s\n",substr($0,1,19),substr($0,20)) } } -} ' ${vdir}/vitals.${symd}${dishh} >${TMPDIR}/vitals.${symd}${dishh}.y4 - -mv ${TMPDIR}/vitals.${symd}${dishh}.y4 ${vdir}/vitals.${symd}${dishh} +} ' "${vdir}/vitals.${symd}${dishh}" > "${TMPDIR}/vitals.${symd}${dishh}.y4" -#cpfs $auxtcvit ${vdir}/vitals.${symd}${dishh} +mv "${TMPDIR}/vitals.${symd}${dishh}.y4" "${vdir}/vitals.${symd}${dishh}" -pgm=$(basename $SUPVX) -if [ -s $DATA/prep_step ]; then - set +e - . $DATA/prep_step - set_strict +pgm=$(basename "${SUPVX}") +if [[ -s "${DATA}/prep_step" ]]; then + source "${DATA}/prep_step" else - [ -f errfile ] && rm errfile - export XLFUNITS=0 - unset $(env | grep XLFUNIT | awk -F= '{print $1}') - - if [ -z "${XLFRTEOPTS:-}" ]; then - export XLFRTEOPTS="unit_vars=yes" - else - export XLFRTEOPTS="${XLFRTEOPTS}:unit_vars=yes" - fi - -fi - -if [ -s fort.* ]; then - rm fort.* + [[ -f errfile ]] && rm errfile + export XLFUNITS=0 + # shellcheck disable=SC2046,SC2312 + unset $(env | grep XLFUNIT | awk -F= '{print $1}') + export XLFRTEOPTS="${XLFRTEOPTS:+${XLFRTEOPTS}:}unit_vars=yes" fi -${NLN} ${vdir}/vitals.${symd}${dishh} fort.31 -${NLN} ${vdir}/vitals.upd.${cmodel}.${symd}${dishh} fort.51 +rm -f fort.* -##$XLF_LINKSSH -#if [ -z $XLF_LINKSSH ] ; then -#if [ -s $XLF_LINKSSH ; then $XLF_LINKSSH ; fi -#fi +${NLN} "${vdir}/vitals.${symd}${dishh}" fort.31 +${NLN} "${vdir}/vitals.upd.${cmodel}.${symd}${dishh}" fort.51 -$TIMEIT $SUPVX <$TMPDIR/suv_input > outout 2> errfile +${TIMEIT} "${SUPVX}" < "${TMPDIR}/suv_input" > outout 2> errfile err=$? -###cat errfile cat errfile >> outout cat outout >> supvit.out -set +u -[ -n "../$pgmout" ] && cat outout >> ../$pgmout -set -u +if [[ -n "${pgmout}" ]]; then + cat outout >> "../${pgmout}" +fi rm outout -set +x -echo -echo 'The foreground exit status for SUPVIT is ' $err -echo -set_trace - -if [ $err -eq 0 ]; then - set +x - echo " " - echo " Normal end for program supvitql (which updates TC vitals file)." - echo " " - set_trace +cat << EOF + +The foreground exit status for SUPVIT is ${err} + +EOF + +if [[ "${err}" -eq 0 ]]; then + cat << EOF + +Normal end for program supvitql (which updates TC vitals file). + +EOF else - set +x - echo " " - echo "!!! ERROR -- An error occurred while running supvitql, " - echo "!!! which is the program that updates the TC Vitals file." - echo "!!! Return code from supvitql = ${err}" - echo "!!! model= ${cmodel}, forecast initial time = ${symd}${dishh}" - echo "!!! Exiting...." - echo " " - set_trace -fi -if [[ ${err} -gt 0 ]]; then - exit 9 -fi + msg=$( + cat << EOF +!!! FATAL ERROR: An error occurred while running supvitql, +!!! which is the program that updates the TC Vitals file. +!!! Return code from supvitql = ${err} +!!! model= ${cmodel}, forecast initial time = ${symd}${dishh} +!!! Exiting.... + +EOF + ) + err=9 + err_exit "${msg}" +fi #------------------------------------------------------------------# # Now select all storms to be processed, that is, process every @@ -640,57 +611,52 @@ fi # then exit. #------------------------------------------------------------------# -numvitrecs=$(cat ${vdir}/vitals.upd.${cmodel}.${symd}${dishh} | wc -l) -if [ ${numvitrecs} -eq 0 ]; then - set +x - echo " " - echo "!!! ERROR -- There are no vitals records for this time period " - echo "!!! in the UPDATED vitals file." - echo "!!! File ${vdir}/vitals.upd.${cmodel}.${symd}${dishh} is empty." - echo "!!! Please check the dates and submit this job again...." - echo " " - set_trace - exit 8 +numvitrecs=$(wc -l "${vdir}/vitals.upd.${cmodel}.${symd}${dishh}") +if [[ "${numvitrecs}" -eq 0 ]]; then + cat << EOF + +!!! ERROR -- There are no vitals records for this time period +!!! in the UPDATED vitals file. +!!! File ${vdir}/vitals.upd.${cmodel}.${symd}${dishh} is empty. +!!! Please check the dates and submit this job again.... + +EOF + err=8 + err_exit fi -set +x -echo " " | tee storm_list -echo " " | tee -a storm_list -echo " " | tee -a storm_list -echo " *--------------------------------*" | tee -a storm_list -echo " | STORM SELECTION |" | tee -a storm_list -echo " *--------------------------------*" | tee -a storm_list -echo " " | tee -a storm_list -echo " Below is a list of the storms to be processed: " | tee -a storm_list -echo " " | tee -a storm_list -cat ${vdir}/vitals.upd.${cmodel}.${symd}${dishh} | tee -a storm_list -echo " " | tee -a storm_list -set_trace - -set +u -[ -n "../$pgmout" ] && cat storm_list >> ../$pgmout -set -u +# shellcheck disable=SC2312 +cat << EOF | tee stormlist + + + +*--------------------------------* +| STORM SELECTION | +*--------------------------------* + +Below is a list of the storms to be processed: + +$(cat "${vdir}/vitals.upd.${cmodel}.${symd}${dishh}") + +EOF + +if [[ -n "${pgmout}" ]]; then + cat storm_list >> "../${pgmout}" +fi rm storm_list -ict=1 -while [ $ict -le 15 ] -do - stormflag[${ict}]=3 - let ict=ict+1 +for ((ict = 1; ict <= 15; ict++)); do + stormflag[ict]=3 done dtg_current="${symd} ${dishh}00" -smax=$( grep "${dtg_current}" ${vdir}/vitals.upd.${cmodel}.${symd}${dishh} | wc -l) +smax=$(grep -c "${dtg_current}" "${vdir}/vitals.upd.${cmodel}.${symd}${dishh}") -sct=1 -while [ ${sct} -le ${smax} ] -do - stormflag[${sct}]=1 - let sct=sct+1 +for ((ict = 1; ict <= smax; ict++)); do + stormflag[sct]=1 done - #-----------------------------------------------------------------# # # ------ CUT APART INPUT GRIB FILES ------- @@ -711,201 +677,214 @@ done # sure to check the lbms in your fortran program after getgb). #-----------------------------------------------------------------# -set +x -echo " " -echo " -----------------------------------------" -echo " NOW CUTTING APART INPUT GRIB FILES TO " -echo " CREATE 1 BIG GRIB INPUT FILE " -echo " -----------------------------------------" -echo " " -set_trace +cat << EOF + +----------------------------------------- + NOW CUTTING APART INPUT GRIB FILES TO + CREATE 1 BIG GRIB INPUT FILE +----------------------------------------- + +EOF #grid='255 0 151 71 70000 190000 128 0000 340000 1000 1000 64' #grid='255 0 360 181 90000 0000 128 -90000 -1000 1000 1000 64' #grid='255 0 360 181 90000 0000 128 -90000 -1000 1000 1000 0' -regflag=$(grep NHC ${vdir}/vitals.upd.${cmodel}.${symd}${dishh} | wc -l) +regflag=$(grep -c NHC "${vdir}/vitals.upd.${cmodel}.${symd}${dishh}") # ---------------------------- # Process NGM, if selected # ---------------------------- -if [ ${model} -eq 5 ]; then - - grid='255 0 151 71 70000 190000 128 0000 340000 1000 1000 64' - - if [ ${regflag} = 'n' ]; then - set +x - echo " " - echo " *******************************************************************" - echo " !!! NGM model has been selected, but there are no storms in the" - echo " !!! TC Vitals file that are from NHC. Therefore, unless you have" - echo " !!! entered your own auxiliary TC vitals file that has a storm " - echo " !!! within the NGM domain, the tracker will exit after reading " - echo " !!! in the analysis data." - echo " *******************************************************************" - echo " " - set_trace - fi - - if [ -s ${vdir}/ngmlatlon.pgrb.${symd}${dishh} ]; then - rm ${vdir}/ngmlatlon.pgrb.${symd}${dishh} - fi - - for fhour in ${fcsthrsngm} - do - - if [ ! -s ${ngmdir}/${ngmgfile}${fhour} ]; then - set +x - echo " " - echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo " !!! NGM File missing: ${ngmdir}/${ngmgfile}${fhour}" - echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - set_trace - continue - fi - if [ -s $TMPDIR/tmpixfile ]; then rm $TMPDIR/tmpixfile; fi - ${GRBINDEX:?} ${ngmdir}/${ngmgfile}${fhour} $TMPDIR/tmpixfile - x1=$TMPDIR/tmpixfile - - set +x - echo " " - echo " Extracting NGM GRIB data for forecast hour = $fhour" - echo " " - set_trace - - g1=${ngmdir}/${ngmgfile}${fhour} - - ${COPYGB:?} -g"$grid" -k'2*-1 104 -1 33 100 850' $g1 $x1 $TMPDIR/ngmllu850.grb.f${fhour}; rcc1=$? - ${COPYGB:?} -g"$grid" -k'2*-1 104 -1 33 100 700' $g1 $x1 $TMPDIR/ngmllu700.grb.f${fhour}; rcc2=$? - ${COPYGB:?} -g"$grid" -k'2*-1 104 -1 33 100 500' $g1 $x1 $TMPDIR/ngmllu500.grb.f${fhour}; rcc3=$? - ${COPYGB:?} -g"$grid" -k'2*-1 104 -1 33 105 10' $g1 $x1 $TMPDIR/ngmllu10m.grb.f${fhour}; rcc4=$? - ${COPYGB:?} -g"$grid" -k'2*-1 104 -1 41 100 850' $g1 $x1 $TMPDIR/ngmllav850.grb.f${fhour}; rcc5=$? - ${COPYGB:?} -g"$grid" -k'2*-1 104 -1 41 100 700' $g1 $x1 $TMPDIR/ngmllav700.grb.f${fhour}; rcc6=$? - ${COPYGB:?} -g"$grid" -k'2*-1 104 -1 7 100 850' $g1 $x1 $TMPDIR/ngmllz850.grb.f${fhour}; rcc7=$? - ${COPYGB:?} -g"$grid" -k'2*-1 104 -1 7 100 700' $g1 $x1 $TMPDIR/ngmllz700.grb.f${fhour}; rcc8=$? - ${COPYGB:?} -g"$grid" -k'2*-1 104 -1 2 102 0' $g1 $x1 $TMPDIR/ngmllmslp.grb.f${fhour}; rcc9=$? - - if [ $rcc1 -eq 134 -o $rcc2 -eq 134 -o $rcc3 -eq 134 -o $rcc4 -eq 134 -o $rcc5 -eq 134 -o \ - $rcc6 -eq 134 -o $rcc7 -eq 134 -o $rcc8 -eq 134 -o $rcc9 -eq 134 ]; then - set +x - echo " " - echo "!!! ERROR using $COPYGB to interpolate ngm data. We will stop execution because" - echo "!!! some variables may have been copied okay, while some obviously have not, " - echo "!!! and that could lead to unreliable results from the tracker. Check to make" - echo "!!! sure you've allocated enough memory for this job (error 134 using $COPYGB is " - echo "!!! typically due to using more memory than you've allocated). Exiting....." - echo " " - set_trace - exit 8 +if [[ "${model}" -eq 5 ]]; then + + grid='255 0 151 71 70000 190000 128 0000 340000 1000 1000 64' + + if [[ "${regflag}" == 'n' ]]; then + cat << EOF + +******************************************************************* +!!! NGM model has been selected, but there are no storms in the +!!! TC Vitals file that are from NHC. Therefore, unless you have +!!! entered your own auxiliary TC vitals file that has a storm +!!! within the NGM domain, the tracker will exit after reading +!!! in the analysis data. +******************************************************************* + +EOF fi - cat $TMPDIR/ngmllu850.grb.f${fhour} $TMPDIR/ngmllu700.grb.f${fhour} \ - $TMPDIR/ngmllu500.grb.f${fhour} $TMPDIR/ngmllz850.grb.f${fhour} \ - $TMPDIR/ngmllz700.grb.f${fhour} $TMPDIR/ngmllmslp.grb.f${fhour} \ - $TMPDIR/ngmllav850.grb.f${fhour} $TMPDIR/ngmllav700.grb.f${fhour} \ - $TMPDIR/ngmllu10m.grb.f${fhour} \ - >>${vdir}/ngmlatlon.pgrb.${symd}${dishh} + rm -f "${vdir}/ngmlatlon.pgrb.${symd}${dishh}" - done + for fhour in ${fcsthrsngm}; do - ${GRBINDEX:?} ${vdir}/ngmlatlon.pgrb.${symd}${dishh} ${vdir}/ngmlatlon.pgrb.ix.${symd}${dishh} - gribfile=${vdir}/ngmlatlon.pgrb.${symd}${dishh} - ixfile=${vdir}/ngmlatlon.pgrb.ix.${symd}${dishh} + if [[ ! -s "${ngmdir}/${ngmgfile}${fhour}" ]]; then + cat << EOF -fi +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!!! NGM File missing: ${ngmdir}/${ngmgfile}${fhour} +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +EOF + continue + fi + rm -f "${TMPDIR}/tmpixfile" + ${GRBINDEX:?} "${ngmdir}/${ngmgfile}${fhour}" "${TMPDIR}/tmpixfile" + x1="${TMPDIR}/tmpixfile" + + cat << EOF +Extracting NGM GRIB data for forecast hour = ${fhour} + +EOF + + g1="${ngmdir}/${ngmgfile}${fhour}" + + ${COPYGB:?} -g"${grid}" -k'2*-1 104 -1 33 100 850' "${g1}" "${x1}" "${TMPDIR}/ngmllu850.grb.f${fhour}" + rcc1=$? + ${COPYGB:?} -g"${grid}" -k'2*-1 104 -1 33 100 700' "${g1}" "${x1}" "${TMPDIR}/ngmllu700.grb.f${fhour}" + rcc2=$? + ${COPYGB:?} -g"${grid}" -k'2*-1 104 -1 33 100 500' "${g1}" "${x1}" "${TMPDIR}/ngmllu500.grb.f${fhour}" + rcc3=$? + ${COPYGB:?} -g"${grid}" -k'2*-1 104 -1 33 105 10' "${g1}" "${x1}" "${TMPDIR}/ngmllu10m.grb.f${fhour}" + rcc4=$? + ${COPYGB:?} -g"${grid}" -k'2*-1 104 -1 41 100 850' "${g1}" "${x1}" "${TMPDIR}/ngmllav850.grb.f${fhour}" + rcc5=$? + ${COPYGB:?} -g"${grid}" -k'2*-1 104 -1 41 100 700' "${g1}" "${x1}" "${TMPDIR}/ngmllav700.grb.f${fhour}" + rcc6=$? + ${COPYGB:?} -g"${grid}" -k'2*-1 104 -1 7 100 850' "${g1}" "${x1}" "${TMPDIR}/ngmllz850.grb.f${fhour}" + rcc7=$? + ${COPYGB:?} -g"${grid}" -k'2*-1 104 -1 7 100 700' "${g1}" "${x1}" "${TMPDIR}/ngmllz700.grb.f${fhour}" + rcc8=$? + ${COPYGB:?} -g"${grid}" -k'2*-1 104 -1 2 102 0' "${g1}" "${x1}" "${TMPDIR}/ngmllmslp.grb.f${fhour}" + rcc9=$? + + if [[ ${rcc1} -eq 134 || ${rcc2} -eq 134 || ${rcc3} -eq 134 || ${rcc4} -eq 134 || ${rcc5} -eq 134 || + ${rcc6} -eq 134 || ${rcc7} -eq 134 || ${rcc8} -eq 134 || ${rcc9} -eq 134 ]]; then + msg=$( + cat << EOF + +!!! FATAL ERROR using ${COPYGB} to interpolate ngm data. We will stop execution because +!!! some variables may have been copied okay, while some obviously have not, +!!! and that could lead to unreliable results from the tracker. Check to make +!!! sure you've allocated enough memory for this job (error 134 using ${COPYGB} is +!!! typically due to using more memory than you've allocated). Exiting..... + +EOF + ) + err=8 + err_exit "${msg}" + fi + + cat "${TMPDIR}/ngmllu850.grb.f${fhour}" "${TMPDIR}/ngmllu700.grb.f${fhour}" \ + "${TMPDIR}/ngmllu500.grb.f${fhour}" "${TMPDIR}/ngmllz850.grb.f${fhour}" \ + "${TMPDIR}/ngmllz700.grb.f${fhour}" "${TMPDIR}/ngmllmslp.grb.f${fhour}" \ + "${TMPDIR}/ngmllav850.grb.f${fhour}" "${TMPDIR}/ngmllav700.grb.f${fhour}" \ + "${TMPDIR}/ngmllu10m.grb.f${fhour}" \ + >> "${vdir}/ngmlatlon.pgrb.${symd}${dishh}" + + done + + ${GRBINDEX:?} "${vdir}/ngmlatlon.pgrb.${symd}${dishh}" "${vdir}/ngmlatlon.pgrb.ix.${symd}${dishh}" + gribfile="${vdir}/ngmlatlon.pgrb.${symd}${dishh}" + ixfile="${vdir}/ngmlatlon.pgrb.ix.${symd}${dishh}" + +fi # ---------------------------------- # Process Early NAM, if selected # ---------------------------------- -if [ ${model} -eq 6 ]; then - - grid='255 0 301 141 70000 190000 128 0000 340000 500 500 64' - - if [ ${regflag} = 'n' ]; then - set +x - echo " " - echo " *******************************************************************" - echo " !!! NAM model has been selected, but there are no storms in the" - echo " !!! TC Vitals file that are from NHC. Therefore, unless you have" - echo " !!! entered your own auxiliary TC vitals file that has a storm " - echo " !!! within the NAM domain, the tracker will exit after reading " - echo " !!! in the analysis data." - echo " *******************************************************************" - echo " " - set_trace - fi - - if [ -s ${vdir}/namlatlon.pgrb.${symd}${dishh} ]; then - rm ${vdir}/namlatlon.pgrb.${symd}${dishh} - fi - - for fhour in ${fcsthrsnam} - do - - if [ ! -s ${namdir}/${namgfile}${fhour}.tm00 ]; then - set +x - echo " " - echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo " !!! Early NAM File missing: ${namdir}/${namgfile}${fhour}.tm00" - echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - set_trace - continue - fi - if [ -s $TMPDIR/tmpixfile ]; then rm $TMPDIR/tmpixfile; fi - ${GRBINDEX:?} ${namdir}/${namgfile}${fhour}.tm00 $TMPDIR/tmpixfile - x1=$TMPDIR/tmpixfile - - set +x - echo " " - echo " Extracting Early NAM GRIB data for forecast hour = $fhour" - echo " " - set_trace - - g1=${namdir}/${namgfile}${fhour}.tm00 - - if [ -s $TMPDIR/namlatlon.pgrb ]; then rm $TMPDIR/namlatlon.pgrb; fi - ${COPYGB:?} -g"$grid" -k'4*-1 33 100 850' $g1 $x1 $TMPDIR/namllu850.grb.f${fhour}; rcc1=$? - ${COPYGB:?} -g"$grid" -k'4*-1 33 100 700' $g1 $x1 $TMPDIR/namllu700.grb.f${fhour}; rcc2=$? - ${COPYGB:?} -g"$grid" -k'4*-1 33 100 500' $g1 $x1 $TMPDIR/namllu500.grb.f${fhour}; rcc3=$? - ${COPYGB:?} -g"$grid" -k'4*-1 33 105 10' $g1 $x1 $TMPDIR/namllu10m.grb.f${fhour}; rcc4=$? - ${COPYGB:?} -g"$grid" -k'4*-1 41 100 850' $g1 $x1 $TMPDIR/namllav850.grb.f${fhour}; rcc5=$? - ${COPYGB:?} -g"$grid" -k'4*-1 41 100 700' $g1 $x1 $TMPDIR/namllav700.grb.f${fhour}; rcc6=$? - ${COPYGB:?} -g"$grid" -k'4*-1 7 100 850' $g1 $x1 $TMPDIR/namllz850.grb.f${fhour}; rcc7=$? - ${COPYGB:?} -g"$grid" -k'4*-1 7 100 700' $g1 $x1 $TMPDIR/namllz700.grb.f${fhour}; rcc8=$? - ${COPYGB:?} -g"$grid" -k'4*-1 2 102 0' $g1 $x1 $TMPDIR/namllmslp.grb.f${fhour}; rcc9=$? - - if [ $rcc1 -eq 134 -o $rcc2 -eq 134 -o $rcc3 -eq 134 -o $rcc4 -eq 134 -o $rcc5 -eq 134 -o \ - $rcc6 -eq 134 -o $rcc7 -eq 134 -o $rcc8 -eq 134 -o $rcc9 -eq 134 ]; then - set +x - echo " " - echo "!!! ERROR using $COPYGB to interpolate nam data. We will stop execution because" - echo "!!! some variables may have been copied okay, while some obviously have not, " - echo "!!! and that could lead to unreliable results from the tracker. Check to make" - echo "!!! sure you've allocated enough memory for this job (error 134 using $COPYGB is " - echo "!!! typically due to using more memory than you've allocated). Exiting....." - echo " " - set_trace - exit 8 +if [[ "${model}" -eq 6 ]]; then + + grid='255 0 301 141 70000 190000 128 0000 340000 500 500 64' + + if [[ "${regflag}" == 'n' ]]; then + cat << EOF + +******************************************************************* +!!! NAM model has been selected, but there are no storms in the +!!! TC Vitals file that are from NHC. Therefore, unless you have +!!! entered your own auxiliary TC vitals file that has a storm +!!! within the NAM domain, the tracker will exit after reading +!!! in the analysis data. +******************************************************************* + +EOF fi - cat $TMPDIR/namllu850.grb.f${fhour} $TMPDIR/namllu700.grb.f${fhour} \ - $TMPDIR/namllu500.grb.f${fhour} $TMPDIR/namllz850.grb.f${fhour} \ - $TMPDIR/namllz700.grb.f${fhour} $TMPDIR/namllmslp.grb.f${fhour} \ - $TMPDIR/namllav850.grb.f${fhour} $TMPDIR/namllav700.grb.f${fhour} \ - $TMPDIR/namllu10m.grb.f${fhour} \ - >>${vdir}/namlatlon.pgrb.${symd}${dishh} + rm -f "${vdir}/namlatlon.pgrb.${symd}${dishh}" - done + for fhour in ${fcsthrsnam}; do + if [[ ! -s "${namdir}/${namgfile}${fhour}.tm00" ]]; then + cat << EOF - ${GRBINDEX:?} ${vdir}/namlatlon.pgrb.${symd}${dishh} ${vdir}/namlatlon.pgrb.ix.${symd}${dishh} - gribfile=${vdir}/namlatlon.pgrb.${symd}${dishh} - ixfile=${vdir}/namlatlon.pgrb.ix.${symd}${dishh} +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!!! Early NAM File missing: ${namdir}/${namgfile}${fhour}.tm00 +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +EOF + continue + fi + rm -f "${TMPDIR}/tmpixfile" + ${GRBINDEX:?} "${namdir}/${namgfile}${fhour}.tm00" "${TMPDIR}/tmpixfile" + x1="${TMPDIR}/tmpixfile" -fi + cat << EOF + +Extracting Early NAM GRIB data for forecast hour = ${fhour} + +EOF + g1="${namdir}/${namgfile}${fhour}.tm00" + + rm -f "${TMPDIR}/namlatlon.pgrb" + ${COPYGB:?} -g"${grid}" -k'4*-1 33 100 850' "${g1}" "${x1}" "${TMPDIR}/namllu850.grb.f${fhour}" + rcc1=$? + ${COPYGB:?} -g"${grid}" -k'4*-1 33 100 700' "${g1}" "${x1}" "${TMPDIR}/namllu700.grb.f${fhour}" + rcc2=$? + ${COPYGB:?} -g"${grid}" -k'4*-1 33 100 500' "${g1}" "${x1}" "${TMPDIR}/namllu500.grb.f${fhour}" + rcc3=$? + ${COPYGB:?} -g"${grid}" -k'4*-1 33 105 10' "${g1}" "${x1}" "${TMPDIR}/namllu10m.grb.f${fhour}" + rcc4=$? + ${COPYGB:?} -g"${grid}" -k'4*-1 41 100 850' "${g1}" "${x1}" "${TMPDIR}/namllav850.grb.f${fhour}" + rcc5=$? + ${COPYGB:?} -g"${grid}" -k'4*-1 41 100 700' "${g1}" "${x1}" "${TMPDIR}/namllav700.grb.f${fhour}" + rcc6=$? + ${COPYGB:?} -g"${grid}" -k'4*-1 7 100 850' "${g1}" "${x1}" "${TMPDIR}/namllz850.grb.f${fhour}" + rcc7=$? + ${COPYGB:?} -g"${grid}" -k'4*-1 7 100 700' "${g1}" "${x1}" "${TMPDIR}/namllz700.grb.f${fhour}" + rcc8=$? + ${COPYGB:?} -g"${grid}" -k'4*-1 2 102 0' "${g1}" "${x1}" "${TMPDIR}/namllmslp.grb.f${fhour}" + rcc9=$? + + if [[ "${rcc1}" -eq 134 || "${rcc2}" -eq 134 || "${rcc3}" -eq 134 || "${rcc4}" -eq 134 || "${rcc5}" -eq 134 || + "${rcc6}" -eq 134 || "${rcc7}" -eq 134 || "${rcc8}" -eq 134 || "${rcc9}" -eq 134 ]]; then + cat << EOF + +!!! FATAL ERROR using ${COPYGB} to interpolate nam data. We will stop execution because +!!! some variables may have been copied okay, while some obviously have not, +!!! and that could lead to unreliable results from the tracker. Check to make +!!! sure you've allocated enough memory for this job (error 134 using ${COPYGB} is +!!! typically due to using more memory than you've allocated). Exiting..... + +EOF + err=8 + err_exit + fi + + cat "${TMPDIR}/namllu850.grb.f${fhour}" "${TMPDIR}/namllu700.grb.f${fhour}" \ + "${TMPDIR}/namllu500.grb.f${fhour}" "${TMPDIR}/namllz850.grb.f${fhour}" \ + "${TMPDIR}/namllz700.grb.f${fhour}" "${TMPDIR}/namllmslp.grb.f${fhour}" \ + "${TMPDIR}/namllav850.grb.f${fhour}" "${TMPDIR}/namllav700.grb.f${fhour}" \ + "${TMPDIR}/namllu10m.grb.f${fhour}" \ + >> "${vdir}/namlatlon.pgrb.${symd}${dishh}" + + done + + ${GRBINDEX:?} "${vdir}/namlatlon.pgrb.${symd}${dishh}" "${vdir}/namlatlon.pgrb.ix.${symd}${dishh}" + gribfile="${vdir}/namlatlon.pgrb.${symd}${dishh}" + ixfile="${vdir}/namlatlon.pgrb.ix.${symd}${dishh}" + +fi # ------------------------------ # Process ECMWF, if selected @@ -924,643 +903,575 @@ fi # be taken out, and the data should then be processed as the other normal # full-coverage global models (ukmet, mrf, gfs, NAVGEM) currently are. -if [ ${model} -eq 4 ]; then - - if [ ! -s ${ecmwfdir}/${ecmwfgfile} ]; then - set +x - echo " " - echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo " !!! ECMWF GRIB or Index File missing from directory: ${ecmwfdir}" - echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo " " - echo " !!! Due to missing ECMWF file, execution is ending...." - echo " " - set_trace - exit 8 - fi - - ${GRBINDEX:?} ${ecmwfdir}/${ecmwfgfile} $TMPDIR/${ecmwfgfile}.ix - x1=$TMPDIR/${ecmwfgfile}.ix - - if [ -s ${vdir}/ecmwf.bufzone.grb.${symd}${dishh} ]; then - rm ${vdir}/ecmwf.bufzone.grb.${symd}${dishh} - fi - if [ -s ${vdir}/ecmwf.bufzone.ix.${symd}${dishh} ]; then - rm ${vdir}/ecmwf.bufzone.ix.${symd}${dishh} - fi - - g1=${ecmwfdir}/${ecmwfgfile} - ecgrid='255 0 144 33 40000 0000 128 -40000 357500 2500 2500 64' - ${COPYGB:?} -g"$ecgrid" $g1 $x1 ${vdir}/ecmwf.bufzone.grb.${symd}${dishh} - ${GRBINDEX:?} ${vdir}/ecmwf.bufzone.grb.${symd}${dishh} ${vdir}/ecmwf.bufzone.ix.${symd}${dishh} - gribfile=${vdir}/ecmwf.bufzone.grb.${symd}${dishh} - ixfile=${vdir}/ecmwf.bufzone.ix.${symd}${dishh} +if [[ "${model}" -eq 4 ]]; then + if [[ ! -s "${ecmwfdir}/${ecmwfgfile}" ]]; then + msg=$( + cat << EOF -fi +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!!! ECMWF GRIB or Index File missing from directory: ${ecmwfdir} +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +!!! Due to missing ECMWF file, execution is ending.... + +EOF + ) + err=8 + err_exit "${msg}" + fi + + ${GRBINDEX:?} "${ecmwfdir}/${ecmwfgfile}" "${TMPDIR}/${ecmwfgfile}.ix" + x1="${TMPDIR}/${ecmwfgfile}.ix" + rm -f "${vdir}/ecmwf.bufzone.grb.${symd}${dishh}" + rm -f "${vdir}/ecmwf.bufzone.ix.${symd}${dishh}" + + g1="${ecmwfdir}/${ecmwfgfile}" + ecgrid='255 0 144 33 40000 0000 128 -40000 357500 2500 2500 64' + ${COPYGB:?} -g"${ecgrid}" "${g1}" "${x1}" "${vdir}/ecmwf.bufzone.grb.${symd}${dishh}" + ${GRBINDEX:?} "${vdir}/ecmwf.bufzone.grb.${symd}${dishh}" "${vdir}/ecmwf.bufzone.ix.${symd}${dishh}" + gribfile="${vdir}/ecmwf.bufzone.grb.${symd}${dishh}" + ixfile="${vdir}/ecmwf.bufzone.ix.${symd}${dishh}" + +fi # ------------------------------ # Process GFS, if selected # ------------------------------ -if [ ${model} -eq 1 ]; then +if [[ "${model}" -eq 1 ]]; then - if [ -s ${vdir}/gfsgribfile.${symd}${dishh} ]; then - rm ${vdir}/gfsgribfile.${symd}${dishh} - fi + rm -f "${vdir}/gfsgribfile.${symd}${dishh}" - for fhour in ${fcsthrsgfs} - do + for fhour in ${fcsthrsgfs}; do + if [[ ! -s "${gfsdir}/${gfsgfile}${fhour}" ]]; then + cat << EOF - if [ ! -s ${gfsdir}/${gfsgfile}${fhour} ]; then - set +x - echo " " - echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo " !!! GFS File missing: ${gfsdir}/${gfsgfile}${fhour}" - echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - set_trace - continue - fi - - gfile=${gfsdir}/${gfsgfile}${fhour} - ${WGRIB:?} -s $gfile >$TMPDIR/gfs.ix - - for parm in ${wgrib_parmlist} - do - case ${parm} in - "SurfaceU") - grep "UGRD:10 m " $TMPDIR/gfs.ix | ${WGRIB:?} -s $gfile -i -grib -append \ - -o ${vdir}/gfsgribfile.${symd}${dishh} ;; - "SurfaceV") - grep "VGRD:10 m " $TMPDIR/gfs.ix | ${WGRIB:?} -s $gfile -i -grib -append \ - -o ${vdir}/gfsgribfile.${symd}${dishh} ;; - *) - grep "${parm}" $TMPDIR/gfs.ix | ${WGRIB:?} -s $gfile -i -grib -append \ - -o ${vdir}/gfsgribfile.${symd}${dishh} ;; - esac +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!!! GFS File missing: ${gfsdir}/${gfsgfile}${fhour} +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +EOF + continue + fi + + gfile="${gfsdir}/${gfsgfile}${fhour}" + ${WGRIB:?} -s "${gfile}" > "${TMPDIR}/gfs.ix" + + for parm in ${wgrib_parmlist}; do + case "${parm}" in + "SurfaceU") parm="UGRD:10 m" ;; + "SurfaceV") parm="VGRD:10 m" ;; + *) ;; + esac + # shellcheck disable=SC2312 + grep "${parm}" "${TMPDIR}/gfs.ix" | ${WGRIB:?} -s "${gfile}" -i -grib -append \ + -o "${vdir}/gfsgribfile.${symd}${dishh}" + done done - done - - ${GRBINDEX:?} ${vdir}/gfsgribfile.${symd}${dishh} ${vdir}/gfsixfile.${symd}${dishh} - gribfile=${vdir}/gfsgribfile.${symd}${dishh} - ixfile=${vdir}/gfsixfile.${symd}${dishh} + ${GRBINDEX:?} "${vdir}/gfsgribfile.${symd}${dishh}" "${vdir}/gfsixfile.${symd}${dishh}" + gribfile="${vdir}/gfsgribfile.${symd}${dishh}" + ixfile="${vdir}/gfsixfile.${symd}${dishh}" fi - # ------------------------------ # Process GDAS, if selected # ------------------------------ -if [ ${model} -eq 8 ]; then +if [[ "${model}" -eq 8 ]]; then - export nest_type="fixed" - export trkrebd=360.0 - export trkrwbd=0.0 - export trkrnbd=85.0 - export trkrsbd=-85.0 - rundescr="xxxx" - atcfdescr="xxxx" + export nest_type="fixed" + export trkrebd=360.0 + export trkrwbd=0.0 + export trkrnbd=85.0 + export trkrsbd=-85.0 + rundescr="xxxx" + atcfdescr="xxxx" - if [ -s ${vdir}/gdasgribfile.${symd}${dishh} ]; then - rm ${vdir}/gdasgribfile.${symd}${dishh} - fi + rm -f "${vdir}/gdasgribfile.${symd}${dishh}" - if [ ${gribver} -eq 1 ]; then + if [[ "${gribver}" -eq 1 ]]; then - # Use GRIB1 input data + # Use GRIB1 input data - for fhr in $( seq -6 $BKGFREQ 3 ); do - if [ $fhr -lt 0 ]; then - fpref=pgm$(expr $fhr \* -1) - elif [ $fhr -eq 0 ]; then - fpref=pges - elif [ $fhr -gt 0 ]; then - fpref=pgp$fhr - fi - gfile=$DATA/${fpref}prep + for ((fhr = -6; fhr <= 3; fhr += BKGFREQ)); do + if [[ "${fhr}" -lt 0 ]]; then + fpref="pgm$((-fhr))" + elif [[ "${fhr}" -eq 0 ]]; then + fpref=pges + elif [[ "${fhr}" -gt 0 ]]; then + fpref="pgp${fhr}" + fi + gfile="${DATA}/${fpref}prep" - if [ ! -s $gfile ]; then - set +x - echo " " - echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo " !!! gdas File missing: $gfile" - echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo " " - set_trace - continue - fi + if [[ ! -s "${gfile}" ]]; then + cat << EOF - ${WGRIB:?} -s $gfile >$TMPDIR/gdas.ix +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!!! gdas File missing: ${gfile} +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - for parm in ${wgrib_parmlist} - do +EOF + continue + fi - case ${parm} in - "SurfaceU") - grep "UGRD:10 m " $TMPDIR/gdas.ix | ${WGRIB:?} -s $gfile -i -grib -append \ - -o ${vdir}/gdasgribfile.${symd}${dishh} ;; - "SurfaceV") - grep "VGRD:10 m " $TMPDIR/gdas.ix | ${WGRIB:?} -s $gfile -i -grib -append \ - -o ${vdir}/gdasgribfile.${symd}${dishh} ;; - *) - grep "${parm}" $TMPDIR/gdas.ix | ${WGRIB:?} -s $gfile -i -grib -append \ - -o ${vdir}/gdasgribfile.${symd}${dishh} ;; - esac + ${WGRIB:?} -s "${gfile}" > "${TMPDIR}/gdas.ix" - done + for parm in ${wgrib_parmlist}; do + case "${parm}" in + "SurfaceU") parm="UGRD:10 m" ;; + "SurfaceV") parm="VGRD:10 m" ;; + *) ;; + esac + # shellcheck disable=SC2312 + grep "${parm}" "${TMPDIR}/gdas.ix" | ${WGRIB:?} -s "${gfile}" -i -grib -append \ + -o "${vdir}/gdasgribfile.${symd}${dishh}" + done - done + done - else + else - # Use GRIB2 input data.... + # Use GRIB2 input data.... + for ((fhr = -6; fhr <= 3; fhr += BKGFREQ)); do + if [[ "${fhr}" -lt 0 ]]; then + fhour="0$((-fhr))" + fpref=pgm$((-fhr)) + elif [[ "${fhr}" -eq 0 ]]; then + fhour=00 + fpref=pges + elif [[ "${fhr}" -gt 0 ]]; then + fhour="0${fhr}" + fpref="pgp${fhr}" + fi + gfile="${DATA}/${fpref}prep" + + if [[ ! -s "${gfile}" ]]; then + cat << EOF + +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!!! gdas File missing: ${gfile} +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - for fhr in $( seq -6 $BKGFREQ 3 ); do - if [ $fhr -lt 0 ]; then - fhour=0$(expr $fhr \* -1) - fpref=pgm$(expr $fhr \* -1) - elif [ $fhr -eq 0 ]; then - fhour=00 - fpref=pges - elif [ $fhr -gt 0 ]; then - fhour=0$fhr - fpref=pgp$fhr - fi - gfile=$DATA/${fpref}prep +EOF + continue + fi - if [ ! -s $gfile ]; then - set +x - echo " " - echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo " !!! gdas File missing: $gfile" - echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo " " - set_trace - continue - fi - - ${WGRIB2:?} -s $gfile >$TMPDIR/gdas.ix - - for parm in ${wgrib_parmlist} - do - case ${parm} in - "SurfaceU") - grep "UGRD:10 m " $TMPDIR/gdas.ix | ${WGRIB2:?} -i $gfile -append -grib \ - ${vdir}/gdasgribfile.${symd}${dishh} ;; - "SurfaceV") - grep "VGRD:10 m " $TMPDIR/gdas.ix | ${WGRIB2:?} -i $gfile -append -grib \ - ${vdir}/gdasgribfile.${symd}${dishh} ;; - *) - grep "${parm}" $TMPDIR/gdas.ix | ${WGRIB2:?} -i $gfile -append -grib \ - ${vdir}/gdasgribfile.${symd}${dishh} ;; - esac - done + ${WGRIB2:?} -s "${gfile}" > "${TMPDIR}/gdas.ix" - done + for parm in ${wgrib_parmlist}; do + case "${parm}" in + "SurfaceU") parm="UGRD:10 m" ;; + "SurfaceV") parm="VGRD:10 m" ;; + *) ;; + esac + # shellcheck disable=SC2312 + grep "${parm}" "${TMPDIR}/gdas.ix" | ${WGRIB2:?} -i "${gfile}" -append -grib \ + "${vdir}/gdasgribfile.${symd}${dishh}" + done - fi + done - if [ ${gribver} -eq 1 ]; then - ${GRBINDEX:?} ${vdir}/gdasgribfile.${symd}${dishh} ${vdir}/gdasixfile.${symd}${dishh} - else - ${GRB2INDEX:?} ${vdir}/gdasgribfile.${symd}${dishh} ${vdir}/gdasixfile.${symd}${dishh} - fi + fi - gribfile=${vdir}/gdasgribfile.${symd}${dishh} - ixfile=${vdir}/gdasixfile.${symd}${dishh} + if [[ "${gribver}" -eq 1 ]]; then + ${GRBINDEX:?} "${vdir}/gdasgribfile.${symd}${dishh}" "${vdir}/gdasixfile.${symd}${dishh}" + else + ${GRB2INDEX:?} "${vdir}/gdasgribfile.${symd}${dishh}" "${vdir}/gdasixfile.${symd}${dishh}" + fi + + gribfile="${vdir}/gdasgribfile.${symd}${dishh}" + ixfile="${vdir}/gdasixfile.${symd}${dishh}" fi + # ------------------------------ # Process MRF, if selected # ------------------------------ -if [ ${model} -eq 2 ]; then +if [[ "${model}" -eq 2 ]]; then - if [ -s ${vdir}/mrfgribfile.${symd}${dishh} ]; then - rm ${vdir}/mrfgribfile.${symd}${dishh} - fi + rm -f "${vdir}/mrfgribfile.${symd}${dishh}" - for fhour in ${fcsthrsmrf} - do + for fhour in ${fcsthrsmrf}; do + if [[ ! -s "${mrfdir}/${mrfgfile}${fhour}" ]]; then + cat << EOF - if [ ! -s ${mrfdir}/${mrfgfile}${fhour} ]; then - set +x - echo " " - echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo " !!! MRF File missing: ${mrfdir}/${mrfgfile}${fhour}" - echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo " " - set_trace - continue - fi +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!!! MRF File missing: ${mrfdir}/${mrfgfile}${fhour} +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - gfile=${mrfdir}/${mrfgfile}${fhour} - ${WGRIB:?} -s $gfile >$TMPDIR/mrf.ix - - for parm in ${wgrib_parmlist} - do - - case ${parm} in - "SurfaceU") - grep "UGRD:10 m " $TMPDIR/mrf.ix | ${WGRIB:?} -s $gfile -i -grib -append \ - -o ${vdir}/mrfgribfile.${symd}${dishh} ;; - "SurfaceV") - grep "VGRD:10 m " $TMPDIR/mrf.ix | ${WGRIB:?} -s $gfile -i -grib -append \ - -o ${vdir}/mrfgribfile.${symd}${dishh} ;; - *) - grep "${parm}" $TMPDIR/mrf.ix | ${WGRIB:?} -s $gfile -i -grib -append \ - -o ${vdir}/mrfgribfile.${symd}${dishh} ;; - esac +EOF + continue + fi + + gfile="${mrfdir}/${mrfgfile}${fhour}" + ${WGRIB:?} -s "${gfile}" > "${TMPDIR}/mrf.ix" + + for parm in ${wgrib_parmlist}; do + case "${parm}" in + "SurfaceU") parm="UGRD:10 m" ;; + "SurfaceV") parm="VGRD:10 m" ;; + *) ;; + esac + # shellcheck disable=SC2312 + grep "${parm}" "${TMPDIR}/mrf.ix" | ${WGRIB:?} -s "${gfile}" -i -grib -append \ + -o "${vdir}/mrfgribfile.${symd}${dishh}" + done done - done - - ${GRBINDEX:?} ${vdir}/mrfgribfile.${symd}${dishh} ${vdir}/mrfixfile.${symd}${dishh} - gribfile=${vdir}/mrfgribfile.${symd}${dishh} - ixfile=${vdir}/mrfixfile.${symd}${dishh} + ${GRBINDEX:?} "${vdir}/mrfgribfile.${symd}${dishh}" "${vdir}/mrfixfile.${symd}${dishh}" + gribfile="${vdir}/mrfgribfile.${symd}${dishh}" + ixfile="${vdir}/mrfixfile.${symd}${dishh}" fi - # ------------------------------ # Process UKMET, if selected # ------------------------------ -if [ ${model} -eq 3 ]; then +if [[ "${model}" -eq 3 ]]; then - if [ -s ${vdir}/ukmetgribfile.${symd}${dishh} ]; then - rm ${vdir}/ukmetgribfile.${symd}${dishh} - fi + rm -f "${vdir}/ukmetgribfile.${symd}${dishh}" - wgrib_parmlist=' HGT:850 HGT:700 UGRD:850 UGRD:700 UGRD:500 VGRD:850 VGRD:700 VGRD:500 UGRD:sfc VGRD:sfc ABSV:850 ABSV:700 PRMSL:MSL ' + wgrib_parmlist='HGT:850 HGT:700 UGRD:850 UGRD:700 UGRD:500 VGRD:850 VGRD:700 VGRD:500 UGRD:sfc VGRD:sfc ABSV:850 ABSV:700 PRMSL:MSL ' - for fhour in ${fcsthrsukmet} - do + for fhour in ${fcsthrsukmet}; do + if [[ ! -s "${ukmetdir}/${ukmetgfile}${fhour}" ]]; then + cat << EOF - if [ ! -s ${ukmetdir}/${ukmetgfile}${fhour} ]; then - set +x - echo " " - echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo " !!! UKMET File missing: ${ukmetdir}/${ukmetgfile}${fhour}" - echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo " " - set_trace - continue - fi +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!!! UKMET File missing: ${ukmetdir}/${ukmetgfile}${fhour} +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - gfile=${ukmetdir}/${ukmetgfile}${fhour} - ${WGRIB:?} -s $gfile >$TMPDIR/ukmet.ix +EOF + continue + fi - for parm in ${wgrib_parmlist} - do - grep "${parm}" $TMPDIR/ukmet.ix | ${WGRIB:?} -s $gfile -i -grib -append \ - -o ${vdir}/ukmetgribfile.${symd}${dishh} - done + gfile="${ukmetdir}/${ukmetgfile}${fhour}" + ${WGRIB:?} -s "${gfile}" > "${TMPDIR}/ukmet.ix" - done + for parm in ${wgrib_parmlist}; do + # shellcheck disable=SC2312 + grep "${parm}" "${TMPDIR}/ukmet.ix" | ${WGRIB:?} -s "${gfile}" -i -grib -append \ + -o "${vdir}/ukmetgribfile.${symd}${dishh}" + done - ${GRBINDEX:?} ${vdir}/ukmetgribfile.${symd}${dishh} ${vdir}/ukmetixfile.${symd}${dishh} - gribfile=${vdir}/ukmetgribfile.${symd}${dishh} - ixfile=${vdir}/ukmetixfile.${symd}${dishh} + done -fi + ${GRBINDEX:?} "${vdir}/ukmetgribfile.${symd}${dishh}" "${vdir}/ukmetixfile.${symd}${dishh}" + gribfile="${vdir}/ukmetgribfile.${symd}${dishh}" + ixfile="${vdir}/ukmetixfile.${symd}${dishh}" +fi # ------------------------------ # Process NAVGEM, if selected # ------------------------------ -if [ ${model} -eq 7 ]; then - - if [ -s ${vdir}/ngpsgribfile.${symd}${dishh} ]; then - rm ${vdir}/ngpsgribfile.${symd}${dishh} - fi - - if [ ! -s ${ngpsdir}/${ngpsgfile} ]; then - set +x - echo " " - echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo " !!! NAVGEM File missing: ${ngpsdir}/${ngpsgfile}" - echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo " " - echo " !!! Due to missing NAVGEM file, execution is ending...." - echo " " - set_trace - exit 8 - fi - - gfile=${ngpsdir}/${ngpsgfile} - ${WGRIB:?} -s $gfile >$TMPDIR/ngps.ix - - for fhour in ${fcsthrsngps} - do - - if [ $fhour = '00' ]; then - vtstring=":anl:" - else - vtstring="${fhour}hr" +if [[ "${model}" -eq 7 ]]; then + + rm -f "${vdir}/ngpsgribfile.${symd}${dishh}" + + if [[ ! -s "${ngpsdir}/${ngpsgfile}" ]]; then + msg=$( + cat << EOF + +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!!! NAVGEM File missing: ${ngpsdir}/${ngpsgfile} +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +!!! Due to missing NAVGEM file, execution is ending.... + +EOF + ) + err=8 + err_exit "${msg}" fi - for parm in ${wgrib_parmlist} - do - case ${parm} in - "SurfaceU") - grep "UGRD:19 m " $TMPDIR/ngps.ix | grep ${vtstring} | \ - ${WGRIB:?} -s $gfile -i -grib -append -o ${vdir}/ngpsgribfile.${symd}${dishh} ;; - "SurfaceV") - grep "VGRD:19 m " $TMPDIR/ngps.ix | grep ${vtstring} | \ - ${WGRIB:?} -s $gfile -i -grib -append -o ${vdir}/ngpsgribfile.${symd}${dishh} ;; - *) - grep "${parm}" $TMPDIR/ngps.ix | grep ${vtstring} | \ - ${WGRIB:?} -s $gfile -i -grib -append -o ${vdir}/ngpsgribfile.${symd}${dishh} ;; - esac - done + gfile="${ngpsdir}/${ngpsgfile}" + ${WGRIB:?} -s "${gfile}" > "${TMPDIR}/ngps.ix" + + for fhour in ${fcsthrsngps}; do + if [[ "${fhour}" == '00' ]]; then + vtstring=":anl:" + else + vtstring="${fhour}hr" + fi + + for parm in ${wgrib_parmlist}; do + case "${parm}" in + "SurfaceU") parm="UGRD:19 m" ;; + "SurfaceV") parm="VGRD:19 m" ;; + *) ;; + esac + # shellcheck disable=SC2312 + grep "${parm}" "${TMPDIR}/ngps.ix" | grep "${vtstring}" | + ${WGRIB:?} -s "${gfile}" -i -grib -append -o "${vdir}/ngpsgribfile.${symd}${dishh}" + done - done + done - ${GRBINDEX:?} ${vdir}/ngpsgribfile.${symd}${dishh} ${vdir}/ngpsixfile.${symd}${dishh} - gribfile=${vdir}/ngpsgribfile.${symd}${dishh} - ixfile=${vdir}/ngpsixfile.${symd}${dishh} + ${GRBINDEX:?} "${vdir}/ngpsgribfile.${symd}${dishh}" "${vdir}/ngpsixfile.${symd}${dishh}" + gribfile="${vdir}/ngpsgribfile.${symd}${dishh}" + ixfile="${vdir}/ngpsixfile.${symd}${dishh}" fi - # --------------------------------------------- # Process User-specified Model, if selected # --------------------------------------------- -if [ ${model} -eq 9 ]; then +if [[ "${model}" -eq 9 ]]; then -# We need to first check whether or not the data in the file are stored -# on a lat/lon grid or not. We do this by scanning the analysis file -# with Wesley's grib utility, and checking the value of the "Data -# Representation Type", which is stored in byte #6 in the GDS of each -# grib file. A value of 0 indicates an equidistant lat/lon grid. + # We need to first check whether or not the data in the file are stored + # on a lat/lon grid or not. We do this by scanning the analysis file + # with Wesley's grib utility, and checking the value of the "Data + # Representation Type", which is stored in byte #6 in the GDS of each + # grib file. A value of 0 indicates an equidistant lat/lon grid. - if [ -s ${vdir}/otherlatlon.pgrb.${symdh} ]; then - rm ${vdir}/otherlatlon.pgrb.${symdh} - fi + rm -f "${vdir}/otherlatlon.pgrb.${symdh}" - gridtyp=$(${WGRIB:?} -GDS10 ${otherdir}/${fnamebeg}00${fnameend} | \ - awk -FGDS10= '{print $2}' | awk '{print $6}' | sed -n 1p) + # shellcheck disable=SC2312 + gridtyp=$(${WGRIB:?} -GDS10 "${otherdir}/${fnamebeg}00${fnameend}" | + awk -FGDS10= '{print $2}' | awk '{print $6}' | sed -n 1p) - if [ ${gridtyp} -eq 0 ]; then + if [[ "${gridtyp}" -eq 0 ]]; then -# The data are already on a lat/lon grid, we do not need to -# interpolate the data, just pull out the records that we need -# using wgrib. + # The data are already on a lat/lon grid, we do not need to + # interpolate the data, just pull out the records that we need + # using wgrib. - for fhour in ${fcsthrsother} - do + for fhour in ${fcsthrsother}; do + if [[ ! -s "${otherdir}/${fnamebeg}${fhour}${fnameend}" ]]; then + cat << EOF - if [ ! -s ${otherdir}/${fnamebeg}${fhour}${fnameend} ]; then - set +x - echo " " - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo "!!! Forecast File missing: ${otherdir}/${fnamebeg}00${fnameend}" - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo " " - set_trace - continue - fi +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!!! Forecast File missing: ${otherdir}/${fnamebeg}00${fnameend} +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - gfile=${otherdir}/${fnamebeg}${fhour}${fnameend} - ${WGRIB:?} -s $gfile >$TMPDIR/other.ix +EOF + continue + fi - for parm in ${wgrib_parmlist} - do + gfile="${otherdir}/${fnamebeg}${fhour}${fnameend}" + ${WGRIB:?} -s "${gfile}" > "${TMPDIR}/other.ix" - case ${parm} in - "SurfaceU") - grep "UGRD:10 m " $TMPDIR/other.ix | ${WGRIB:?} -s $gfile -i -grib -append \ - -o ${vdir}/otherlatlon.pgrb.${symdh} ;; - "SurfaceV") - grep "VGRD:10 m " $TMPDIR/other.ix | ${WGRIB:?} -s $gfile -i -grib -append \ - -o ${vdir}/otherlatlon.pgrb.${symdh} ;; - *) - grep "${parm}" $TMPDIR/other.ix | ${WGRIB:?} -s $gfile -i -grib -append \ - -o ${vdir}/otherlatlon.pgrb.${symdh} ;; - esac + for parm in ${wgrib_parmlist}; do + case "${parm}" in + "SurfaceU") parm="UGRD:10 m" ;; + "SurfaceV") parm="VGRD:10 m" ;; + *) ;; + esac + # shellcheck disable=SC2312 + grep "${parm}" "${TMPDIR}/other.ix" | ${WGRIB:?} -s "${gfile}" -i -grib -append \ + -o "${vdir}/otherlatlon.pgrb.${symdh}" + done - done + done - done + else - else + # The data are on a grid that is something other than a lat/lon grid. + # Use Mark Iredell's interpolator to interpolate the data to a lat/lon + # grid and pull out the records that we need. -# The data are on a grid that is something other than a lat/lon grid. -# Use Mark Iredell's interpolator to interpolate the data to a lat/lon -# grid and pull out the records that we need. + othergrid='255 0 360 181 90000 0000 128 -90000 -1000 1000 1000 64' - othergrid='255 0 360 181 90000 0000 128 -90000 -1000 1000 1000 64' + for fhour in ${fcsthrsother}; do - for fhour in ${fcsthrsother} - do + if [[ ! -s "${otherdir}/${fnamebeg}${fhour}${fnameend}" ]]; then + cat << EOF - if [ ! -s ${otherdir}/${fnamebeg}${fhour}${fnameend} ]; then - set +x - echo " " - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo "!!! Forecast File missing: ${otherdir}/${fnamebeg}00${fnameend}" - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo " " - set +x - continue - fi - - if [ -s $TMPDIR/tmpixfile ]; then rm $TMPDIR/tmpixfile; fi - ${GRBINDEX:?} ${otherdir}/${fnamebeg}${fhour}${fnameend} $TMPDIR/tmpixfile - x1=$TMPDIR/tmpixfile - - g1=${otherdir}/${fnamebeg}${fhour}${fnameend} - - ${COPYGB:?} -g"$othergrid" -k'4*-1 33 100 850' $g1 $x1 $TMPDIR/otherllu850.grb.f${fhour}; rcc1=$? - ${COPYGB:?} -g"$othergrid" -k'4*-1 33 100 700' $g1 $x1 $TMPDIR/otherllu700.grb.f${fhour}; rcc2=$? - ${COPYGB:?} -g"$othergrid" -k'4*-1 33 100 500' $g1 $x1 $TMPDIR/otherllu500.grb.f${fhour}; rcc3=$? - ${COPYGB:?} -g"$othergrid" -k'4*-1 33 105 10' $g1 $x1 $TMPDIR/otherllu10m.grb.f${fhour}; rcc4=$? - ${COPYGB:?} -g"$othergrid" -k'4*-1 41 100 850' $g1 $x1 $TMPDIR/otherllav850.grb.f${fhour}; rcc5=$? - ${COPYGB:?} -g"$othergrid" -k'4*-1 41 100 700' $g1 $x1 $TMPDIR/otherllav700.grb.f${fhour}; rcc6=$? - ${COPYGB:?} -g"$othergrid" -k'4*-1 7 100 850' $g1 $x1 $TMPDIR/otherllz850.grb.f${fhour}; rcc7=$? - ${COPYGB:?} -g"$othergrid" -k'4*-1 7 100 700' $g1 $x1 $TMPDIR/otherllz700.grb.f${fhour}; rcc8=$? - ${COPYGB:?} -g"$othergrid" -k'4*-1 2 102 0' $g1 $x1 $TMPDIR/otherllmslp.grb.f${fhour}; rcc9=$? - - if [ $rcc1 -eq 134 -o $rcc2 -eq 134 -o $rcc3 -eq 134 -o $rcc4 -eq 134 -o $rcc5 -eq 134 -o \ - $rcc6 -eq 134 -o $rcc7 -eq 134 -o $rcc8 -eq 134 -o $rcc9 -eq 134 ]; then - set +x - echo " " - echo "!!! ERROR using $COPYGB to interpolate data. We will stop execution because" - echo "!!! some variables may have been copied okay, while some obviously have not, " - echo "!!! and that could lead to unreliable results from the tracker. Check to make" - echo "!!! sure you've allocated enough memory for this job (error 134 using $COPYGB is " - echo "!!! typically due to using more memory than you've allocated). Exiting....." - echo " " - set_trace - exit 8 - fi +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!!! Forecast File missing: ${otherdir}/${fnamebeg}00${fnameend} +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - cat $TMPDIR/otherllu850.grb.f${fhour} $TMPDIR/otherllu700.grb.f${fhour} \ - $TMPDIR/otherllu500.grb.f${fhour} $TMPDIR/otherllz850.grb.f${fhour} \ - $TMPDIR/otherllz700.grb.f${fhour} $TMPDIR/otherllmslp.grb.f${fhour} \ - $TMPDIR/otherllav850.grb.f${fhour} $TMPDIR/otherllav700.grb.f${fhour} \ - $TMPDIR/otherllu10m.grb.f${fhour} \ - >>${vdir}/otherlatlon.pgrb.${symdh} +EOF + continue + fi + + rm -f "${TMPDIR}/tmpixfile" + ${GRBINDEX:?} "${otherdir}/${fnamebeg}${fhour}${fnameend}" "${TMPDIR}/tmpixfile" + x1="${TMPDIR}/tmpixfile" + + g1="${otherdir}/${fnamebeg}${fhour}${fnameend}" + + ${COPYGB:?} -g"${othergrid}" -k'4*-1 33 100 850' "${g1}" "${x1}" "${TMPDIR}/otherllu850.grb.f${fhour}" + rcc1=$? + ${COPYGB:?} -g"${othergrid}" -k'4*-1 33 100 700' "${g1}" "${x1}" "${TMPDIR}/otherllu700.grb.f${fhour}" + rcc2=$? + ${COPYGB:?} -g"${othergrid}" -k'4*-1 33 100 500' "${g1}" "${x1}" "${TMPDIR}/otherllu500.grb.f${fhour}" + rcc3=$? + ${COPYGB:?} -g"${othergrid}" -k'4*-1 33 105 10' "${g1}" "${x1}" "${TMPDIR}/otherllu10m.grb.f${fhour}" + rcc4=$? + ${COPYGB:?} -g"${othergrid}" -k'4*-1 41 100 850' "${g1}" "${x1}" "${TMPDIR}/otherllav850.grb.f${fhour}" + rcc5=$? + ${COPYGB:?} -g"${othergrid}" -k'4*-1 41 100 700' "${g1}" "${x1}" "${TMPDIR}/otherllav700.grb.f${fhour}" + rcc6=$? + ${COPYGB:?} -g"${othergrid}" -k'4*-1 7 100 850' "${g1}" "${x1}" "${TMPDIR}/otherllz850.grb.f${fhour}" + rcc7=$? + ${COPYGB:?} -g"${othergrid}" -k'4*-1 7 100 700' "${g1}" "${x1}" "${TMPDIR}/otherllz700.grb.f${fhour}" + rcc8=$? + ${COPYGB:?} -g"${othergrid}" -k'4*-1 2 102 0' "${g1}" "${x1}" "${TMPDIR}/otherllmslp.grb.f${fhour}" + rcc9=$? + + if [[ "${rcc1}" -eq 134 || "${rcc2}" -eq 134 || "${rcc3}" -eq 134 || "${rcc4}" -eq 134 || "${rcc5}" -eq 134 || + "${rcc6}" -eq 134 || "${rcc7}" -eq 134 || "${rcc8}" -eq 134 || "${rcc9}" -eq 134 ]]; then + msg=$( + cat << EOF + +!!! FATAL ERROR using ${COPYGB} to interpolate data. We will stop execution because +!!! some variables may have been copied okay, while some obviously have not, +!!! and that could lead to unreliable results from the tracker. Check to make +!!! sure you've allocated enough memory for this job (error 134 using ${COPYGB} is +!!! typically due to using more memory than you've allocated). Exiting..... - done +EOF + ) + err=8 + err_exit "${msg}" + fi - fi + cat "${TMPDIR}/otherllu850.grb.f${fhour}" "${TMPDIR}/otherllu700.grb.f${fhour}" \ + "${TMPDIR}/otherllu500.grb.f${fhour}" "${TMPDIR}/otherllz850.grb.f${fhour}" \ + "${TMPDIR}/otherllz700.grb.f${fhour}" "${TMPDIR}/otherllmslp.grb.f${fhour}" \ + "${TMPDIR}/otherllav850.grb.f${fhour}" "${TMPDIR}/otherllav700.grb.f${fhour}" \ + "${TMPDIR}/otherllu10m.grb.f${fhour}" \ + >> "${vdir}/otherlatlon.pgrb.${symdh}" - ${GRBINDEX:?} ${vdir}/otherlatlon.pgrb.${symdh} ${vdir}/otherlatlon.pgrb.ix.${symdh} - gribfile=${vdir}/otherlatlon.pgrb.${symdh} - ixfile=${vdir}/otherlatlon.pgrb.ix.${symdh} + done -fi + fi + + ${GRBINDEX:?} "${vdir}/otherlatlon.pgrb.${symdh}" "${vdir}/otherlatlon.pgrb.ix.${symdh}" + gribfile="${vdir}/otherlatlon.pgrb.${symdh}" + ixfile="${vdir}/otherlatlon.pgrb.ix.${symdh}" +fi #-------------------------------------------# # Now qsub the jobs to run the tracker # #-------------------------------------------# -ist=1 -while [ $ist -le 15 ] -do - if [ ${stormflag[${ist}]} -ne 1 ] - then - set +x; echo "Storm number $ist NOT selected for processing"; set_trace - else - set +x; echo "Storm number $ist IS selected for processing...."; set_trace - fi - let ist=ist+1 +for ((ist = 1; ist <= 15; ist++)); do + if [[ "${stormflag[ist]}" -ne 1 ]]; then + echo "Storm number ${ist} NOT selected for processing" + else + echo "Storm number ${ist} IS selected for processing...." + fi done # Load the forecast hours for this particular model into an array # that will be passed into the executable via a namelist.... -ifh=1 -while [ $ifh -le ${maxtime} ] -do - fh[${ifh}]=$( echo ${fcsthrs} | awk '{print $n}' n=$ifh) - let ifh=ifh+1 +for ((ifh = 1; ifh <= mattime; ifh++)); do + fh[ifh]=$(echo "${fcsthrs}" | awk '{print $n}' n="${ifh}") done -namelist=${vdir}/gettrk.input.${cmodel}.${symdh} -ATCFNAME=$( echo "${atcfname}" | tr '[a-z]' '[A-Z]') +namelist="${vdir}/gettrk.input.${cmodel}.${symdh}" + +export atcfymdh="${scc}${syy}${smm}${sdd}${shh}" -export atcfymdh=${scc}${syy}${smm}${sdd}${shh} contour_interval=100.0 write_vit=n want_oci=.TRUE. -echo "&datein inp%bcc=${scc},inp%byy=${syy},inp%bmm=${smm}," >${namelist} -echo " inp%bdd=${sdd},inp%bhh=${shh},inp%model=${model}," >>${namelist} -echo " inp%modtyp='${modtyp}'," >>${namelist} -echo " inp%lt_units='${lead_time_units}'," >>${namelist} -echo " inp%file_seq='${file_sequence}'," >>${namelist} -echo " inp%nesttyp='${nest_type}'/" >>${namelist} -echo "&atcfinfo atcfnum=${atcfnum},atcfname='${ATCFNAME}'," >>${namelist} -echo " atcfymdh=${atcfymdh},atcffreq=${atcffreq}/" >>${namelist} -echo "&trackerinfo trkrinfo%westbd=${trkrwbd}," >>${namelist} -echo " trkrinfo%eastbd=${trkrebd}," >>${namelist} -echo " trkrinfo%northbd=${trkrnbd}," >>${namelist} -echo " trkrinfo%southbd=${trkrsbd}," >>${namelist} -echo " trkrinfo%type='${trkrtype}'," >>${namelist} -echo " trkrinfo%mslpthresh=${MSLPTHRESH}," >>${namelist} -echo " trkrinfo%v850thresh=${V850THRESH}," >>${namelist} -echo " trkrinfo%gridtype='${modtyp}'," >>${namelist} -echo " trkrinfo%contint=${contour_interval}," >>${namelist} -echo " trkrinfo%want_oci=${want_oci}," >>${namelist} -echo " trkrinfo%out_vit='${write_vit}'," >>${namelist} -echo " trkrinfo%gribver=${gribver}," >>${namelist} -echo " trkrinfo%g2_jpdtn=${g2_jpdtn}/" >>${namelist} -echo "&phaseinfo phaseflag='${PHASEFLAG}'," >>${namelist} -echo " phasescheme='${PHASE_SCHEME}'," >>${namelist} -echo " wcore_depth=${WCORE_DEPTH}/" >>${namelist} -echo "&structinfo structflag='${STRUCTFLAG}'," >>${namelist} -echo " ikeflag='${IKEFLAG}'/" >>${namelist} -echo "&fnameinfo gmodname='${atcfname}'," >>${namelist} -echo " rundescr='${rundescr}'," >>${namelist} -echo " atcfdescr='${atcfdescr}'/" >>${namelist} -echo "&verbose verb=3/" >>${namelist} -echo "&waitinfo use_waitfor='n'," >>${namelist} -echo " wait_min_age=10," >>${namelist} -echo " wait_min_size=100," >>${namelist} -echo " wait_max_wait=1800," >>${namelist} -echo " wait_sleeptime=5," >>${namelist} -echo " per_fcst_command=''/" >>${namelist} - -pgm=$(basename $GETTX) -if [ -s $DATA/prep_step ]; then - . $DATA/prep_step -else - [ -f errfile ] && rm errfile - export XLFUNITS=0 - unset $(env | grep XLFUNIT | awk -F= '{print $1}') - - set +u - if [ -z "$XLFRTEOPTS" ]; then - export XLFRTEOPTS="unit_vars=yes" - else - export XLFRTEOPTS="${XLFRTEOPTS}:unit_vars=yes" - fi - set -u +cat << EOF > "${namelist}" +&datein inp%bcc=${scc},inp%byy=${syy},inp%bmm=${smm}, + inp%bdd=${sdd},inp%bhh=${shh},inp%model=${model}, + inp%modtyp='${modtyp}', + inp%lt_units='${lead_time_units}', + inp%file_seq='${file_sequence}', + inp%nesttyp='${nest_type}'/ +&atcfinfo atcfnum=${atcfnum},atcfname='${atcfname^^}', + atcfymdh=${atcfymdh},atcffreq=${atcffreq}/ +&trackerinfo trkrinfo%westbd=${trkrwbd}, + trkrinfo%eastbd=${trkrebd}, + trkrinfo%northbd=${trkrnbd}, + trkrinfo%southbd=${trkrsbd}, + trkrinfo%type='${trkrtype}', + trkrinfo%mslpthresh=${MSLPTHRESH}, + trkrinfo%v850thresh=${V850THRESH}, + trkrinfo%gridtype='${modtyp}', + trkrinfo%contint=${contour_interval}, + trkrinfo%want_oci=${want_oci}, + trkrinfo%out_vit='${write_vit}', + trkrinfo%gribver=${gribver}, + trkrinfo%g2_jpdtn=${g2_jpdtn}/ +&phaseinfo phaseflag='${PHASEFLAG}', + phasescheme='${PHASE_SCHEME}', + wcore_depth=${WCORE_DEPTH}/ +&structinfo structflag='${STRUCTFLAG}', + ikeflag='${IKEFLAG}'/ +&fnameinfo gmodname='${atcfname}', + rundescr='${rundescr}', + atcfdescr='${atcfdescr}'/ +&verbose verb=3/ +&waitinfo use_waitfor='n', + wait_min_age=10, + wait_min_size=100, + wait_max_wait=1800, + wait_sleeptime=5, + per_fcst_command=''/ +EOF +pgm=$(basename "${GETTX}") +if [[ -s "${DATA}/prep_step" ]]; then + source "${DATA}/prep_step" +else + rm -f errfile + export XLFUNITS=0 + # shellcheck disable=SC2046,SC2312 + unset $(env | grep XLFUNIT | awk -F= '{print $1}') + export XLFRTEOPTS="${XLFRTEOPTS:+${XLFRTEOPTS}:}unit_vars=yes" fi -touch ${vdir}/tmp.gfs.atcfunix.${symdh} +touch "${vdir}/tmp.gfs.atcfunix.${symdh}" #---------------------------------- -if [ -s fort.* ]; then - rm fort.* +rm -f fort.* + +${NLN} "${gribfile}" fort.11 +${NLN} "${vdir}/tmp.gfs.atcfunix.${symdh}" fort.14 +${NLN} "${vdir}/vitals.upd.${cmodel}.${symd}${dishh}" fort.12 +${NLN} "${ixfile}" fort.31 +${NLN} "${vdir}/trak.${cmodel}.all.${symdh}" fort.61 +${NLN} "${vdir}/trak.${cmodel}.atcf.${symdh}" fort.62 +${NLN} "${vdir}/trak.${cmodel}.radii.${symdh}" fort.63 +${NLN} "${vdir}/trak.${cmodel}.atcfunix.${symdh}" fort.64 + +if [[ "${BKGFREQ}" -eq 1 ]]; then + ${NLN} "${FIXgfs}/am/${cmodel}.tracker_leadtimes_hrly" "fort.15" +elif [[ "${BKGFREQ}" -eq 3 ]]; then + ${NLN} "${FIXgfs}/am/${cmodel}.tracker_leadtimes" "fort.15" fi -${NLN} ${gribfile} fort.11 -${NLN} ${vdir}/tmp.gfs.atcfunix.${symdh} fort.14 -${NLN} ${vdir}/vitals.upd.${cmodel}.${symd}${dishh} fort.12 -${NLN} ${ixfile} fort.31 -${NLN} ${vdir}/trak.${cmodel}.all.${symdh} fort.61 -${NLN} ${vdir}/trak.${cmodel}.atcf.${symdh} fort.62 -${NLN} ${vdir}/trak.${cmodel}.radii.${symdh} fort.63 -${NLN} ${vdir}/trak.${cmodel}.atcfunix.${symdh} fort.64 - -if [ $BKGFREQ -eq 1 ]; then - ${NLN} ${FIXgfs}/am/${cmodel}.tracker_leadtimes_hrly fort.15 -elif [ $BKGFREQ -eq 3 ]; then - ${NLN} ${FIXgfs}/am/${cmodel}.tracker_leadtimes fort.15 -fi - -##$XLF_LINKSSH -#if [ -z $XLF_LINKSSH ] ; then -###if [ -s $XLF_LINKSSH ; then $XLF_LINKSSH ; fi -#fi - -$TIMEIT ${APRNGETTX} $GETTX <${namelist} > outout 2> errfile +${TIMEIT} "${APRNGETTX}" "${GETTX}" < "${namelist}" > outout 2> errfile err=$? -###cat errfile cat errfile >> outout -cat outout > ${DATA}/model_track.out -set +u -[ -n "../$pgmout" ] && cat outout >> ../$pgmout -set -u -rm outout -set +x -echo -echo 'The foreground exit status for GETTRK is ' $err -echo -set_trace - -if [[ ${err} -gt 0 ]]; then - exit 9 +cat outout > "${DATA}/model_track.out" +if [[ -n "${pgmout}" ]]; then + cat outout >> "../${pgmout}" fi +rm outout +cat << EOF + +"The foreground exit status for GETTRK is ${err}" + +EOF -if [ -s fort.* ]; then - rm fort.* +if [[ "${err}" -gt 0 ]]; then + err=9 + err_exit fi -cpreq "${vdir}/trak.${cmodel}.all.${symdh}" "${DATA}/model_track.all" +rm -f fort.* +cpreq "${vdir}/trak.${cmodel}.all.${symdh}" "${DATA}/model_track.all" exit 0 diff --git a/ush/wave_domain_grid.sh b/ush/wave_domain_grid.sh index 753e3045d8f..7ca92790bea 100644 --- a/ush/wave_domain_grid.sh +++ b/ush/wave_domain_grid.sh @@ -10,34 +10,135 @@ ####################### process_grdID() { - grdID=$1 - case ${grdID} in - glo_10m) GRDREGION='global' ; GRDRES=0p16 ; GRIDNR=255 ; MODNR=11 ;; - glo_15mxt) GRDREGION='global' ; GRDRES=0p25 ; GRIDNR=255 ; MODNR=11 ;; - glo_30mxt) GRDREGION='global' ; GRDRES=0p50 ; GRIDNR=255 ; MODNR=11 ;; - glo_30m) GRDREGION='global' ; GRDRES=0p50 ; GRIDNR=255 ; MODNR=11 ;; - glo_025) GRDREGION='global' ; GRDRES=0p25 ; GRIDNR=255 ; MODNR=11 ;; - glo_100) GRDREGION='global' ; GRDRES=1p00 ; GRIDNR=255 ; MODNR=11 ;; - glo_200) GRDREGION='global' ; GRDRES=2p00 ; GRIDNR=255 ; MODNR=11 ;; - glo_500) GRDREGION='global' ; GRDRES=5p00 ; GRIDNR=255 ; MODNR=11 ;; - at_10m) GRDREGION='atlocn' ; GRDRES=0p16 ; GRIDNR=255 ; MODNR=11 ;; - ep_10m) GRDREGION='epacif' ; GRDRES=0p16 ; GRIDNR=255 ; MODNR=11 ;; - wc_10m) GRDREGION='wcoast' ; GRDRES=0p16 ; GRIDNR=255 ; MODNR=11 ;; - ak_10m) GRDREGION='alaska' ; GRDRES=0p16 ; GRIDNR=255 ; MODNR=11 ;; - aoc_9km) GRDREGION='arctic' ; GRDRES=9km ; GRIDNR=255 ; MODNR=11 ;; - ant_9km) GRDREGION='antarc' ; GRDRES=9km ; GRIDNR=255 ; MODNR=11 ;; - gnh_10m) GRDREGION='global' ; GRDRES=0p16 ; GRIDNR=255 ; MODNR=11 ;; - gsh_15m) GRDREGION='gsouth' ; GRDRES=0p25 ; GRIDNR=255 ; MODNR=11 ;; - ao_20m) GRDREGION='arctic' ; GRDRES=0p33 ; GRIDNR=255 ; MODNR=11 ;; - so_20m) GRDREGION='antarc' ; GRDRES=0p33 ; GRIDNR=255 ; MODNR=11 ;; - reg025) GRDREGION='global' ; GRDRES=0p25 ; GRIDNR=255 ; MODNR=11 ;; - gwes_30m) GRDREGION='global' ; GRDRES=0p50 ; GRIDNR=255 ; MODNR=10 ;; - *) - echo "FATAL ERROR: No grid specific wave config values exist for ${grdID}. Aborting." - exit 1 ;; - esac - grdNAME="${GRDREGION}.${GRDRES}" - echo "grdNAME=${grdNAME}" - echo "GRIDNR=${GRIDNR}" - echo "MODNR=${MODNR}" + grdID=$1 + case ${grdID} in + glo_10m) + GRDREGION='global' + GRDRES=0p16 + GRIDNR=255 + MODNR=11 + ;; + glo_15mxt) + GRDREGION='global' + GRDRES=0p25 + GRIDNR=255 + MODNR=11 + ;; + glo_30mxt) + GRDREGION='global' + GRDRES=0p50 + GRIDNR=255 + MODNR=11 + ;; + glo_30m) + GRDREGION='global' + GRDRES=0p50 + GRIDNR=255 + MODNR=11 + ;; + glo_025) + GRDREGION='global' + GRDRES=0p25 + GRIDNR=255 + MODNR=11 + ;; + glo_100) + GRDREGION='global' + GRDRES=1p00 + GRIDNR=255 + MODNR=11 + ;; + glo_200) + GRDREGION='global' + GRDRES=2p00 + GRIDNR=255 + MODNR=11 + ;; + glo_500) + GRDREGION='global' + GRDRES=5p00 + GRIDNR=255 + MODNR=11 + ;; + at_10m) + GRDREGION='atlocn' + GRDRES=0p16 + GRIDNR=255 + MODNR=11 + ;; + ep_10m) + GRDREGION='epacif' + GRDRES=0p16 + GRIDNR=255 + MODNR=11 + ;; + wc_10m) + GRDREGION='wcoast' + GRDRES=0p16 + GRIDNR=255 + MODNR=11 + ;; + ak_10m) + GRDREGION='alaska' + GRDRES=0p16 + GRIDNR=255 + MODNR=11 + ;; + aoc_9km) + GRDREGION='arctic' + GRDRES=9km + GRIDNR=255 + MODNR=11 + ;; + ant_9km) + GRDREGION='antarc' + GRDRES=9km + GRIDNR=255 + MODNR=11 + ;; + gnh_10m) + GRDREGION='global' + GRDRES=0p16 + GRIDNR=255 + MODNR=11 + ;; + gsh_15m) + GRDREGION='gsouth' + GRDRES=0p25 + GRIDNR=255 + MODNR=11 + ;; + ao_20m) + GRDREGION='arctic' + GRDRES=0p33 + GRIDNR=255 + MODNR=11 + ;; + so_20m) + GRDREGION='antarc' + GRDRES=0p33 + GRIDNR=255 + MODNR=11 + ;; + reg025) + GRDREGION='global' + GRDRES=0p25 + GRIDNR=255 + MODNR=11 + ;; + gwes_30m) + GRDREGION='global' + GRDRES=0p50 + GRIDNR=255 + MODNR=10 + ;; + *) + echo "FATAL ERROR: No grid specific wave config values exist for ${grdID}. Aborting." + exit 1 + ;; + esac + grdNAME="${GRDREGION}.${GRDRES}" + echo "grdNAME=${grdNAME}" + echo "GRIDNR=${GRIDNR}" + echo "MODNR=${MODNR}" } diff --git a/ush/wave_extractvars.sh b/ush/wave_extractvars.sh index 37551358b28..dde21a2c690 100755 --- a/ush/wave_extractvars.sh +++ b/ush/wave_extractvars.sh @@ -18,28 +18,28 @@ com_dir=${!com_varname} subdata=${1} if [[ ! -d "${subdata}" ]]; then - mkdir -p "${subdata}" + mkdir -p "${subdata}" fi -for (( nh = FHOUT_WAV_EXTRACT; nh <= FHMAX_WAV; nh = nh + FHOUT_WAV_EXTRACT )); do - fnh=$(printf "%3.3d" "${nh}") - - infile=${com_dir}/${RUN}.wave.t${cyc}z.global.${wavres}.f${fnh}.grib2 - new_infile=${subdata}/${RUN}.wave.t${cyc}z.global.${wavres}.f${fnh}_ext.grib2 - outfile=${subdata}/${RUN}.wave.t${cyc}z.global.${wavres}.f${fnh}.grib2 - rm -f "${outfile}" # Remove outfile if it already exists before extraction - - if [[ -f "${infile}" ]]; then # Check if input file exists before extraction - if ! cpfs "${infile}" "${new_infile}"; then - echo "FATAL ERROR: Failed to copy ${infile} to ${new_infile}." - exit 1 +for ((nh = FHOUT_WAV_EXTRACT; nh <= FHMAX_WAV; nh = nh + FHOUT_WAV_EXTRACT)); do + fnh=$(printf "%3.3d" "${nh}") + + infile=${com_dir}/${RUN}.wave.t${cyc}z.global.${wavres}.f${fnh}.grib2 + new_infile=${subdata}/${RUN}.wave.t${cyc}z.global.${wavres}.f${fnh}_ext.grib2 + outfile=${subdata}/${RUN}.wave.t${cyc}z.global.${wavres}.f${fnh}.grib2 + rm -f "${outfile}" # Remove outfile if it already exists before extraction + + if [[ -f "${infile}" ]]; then # Check if input file exists before extraction + if ! cpfs "${infile}" "${new_infile}"; then + echo "FATAL ERROR: Failed to copy ${infile} to ${new_infile}." + exit 1 + fi + # shellcheck disable=SC2312 + ${WGRIB2} "${new_infile}" | grep -F -f "${varlist_wav}" | ${WGRIB2} -i "${new_infile}" -append -grib "${outfile}" + else + echo "WARNING: ${infile} does not exist in ${com_dir}." fi - # shellcheck disable=SC2312 - ${WGRIB2} "${new_infile}" | grep -F -f "${varlist_wav}" | ${WGRIB2} -i "${new_infile}" -append -grib "${outfile}" - else - echo "WARNING: ${infile} does not exist in ${com_dir}." - fi - copy_to_comout "${outfile}" "${ARC_RFCST_PROD_WAV}" + copy_to_comout "${outfile}" "${ARC_RFCST_PROD_WAV}" done # nh exit 0 diff --git a/ush/wave_grib2_sbs.sh b/ush/wave_grib2_sbs.sh index b112248f6f8..d36b7d25632 100755 --- a/ush/wave_grib2_sbs.sh +++ b/ush/wave_grib2_sbs.sh @@ -25,7 +25,6 @@ # --------------------------------------------------------------------------- # # 0. Preparations - # Script inputs grdID=$1 GRIDNR=$2 @@ -56,8 +55,8 @@ outfile="${RUN}.t${cyc}z.${grid_region}.${grid_res}.f${FH3}.grib2" # Check if outfile exists in COM if [[ -s "${com_dir}/${outfile}" ]] && [[ -s "${com_dir}/${outfile}.idx" ]]; then - echo "File ${com_dir}/${outfile}[.idx] found, skipping generation process" - exit 0 + echo "File ${com_dir}/${outfile}[.idx] found, skipping generation process" + exit 0 fi # Copy template files to grib_DATA (required for ww3_grib.x) @@ -70,8 +69,8 @@ ${NLN} "${DATA}/mod_def.${grdID}" "./mod_def.ww3" ${NLN} "${DATA}/out_grd.${grdID}" "./out_grd.ww3" # Create the input file for the ww3_grib2 code -ngrib=1 # only one time slice -dtgrib=3600 # only one time slice +ngrib=1 # only one time slice +dtgrib=3600 # only one time slice tstart="${valid_time:0:8} ${valid_time:8:2}0000" sed -e "s/TIME/${tstart}/g" \ @@ -89,28 +88,28 @@ source prep_step "${EXECgfs}/${pgm}" > "grib2_${grid_region}_${FH3}.out" 2>&1 export err=$? if [[ ${err} -ne 0 ]]; then - echo "FATAL ERROR: ${pgm} returned non-zero status: ${err}; exiting!" - exit "${err}" + echo "FATAL ERROR: ${pgm} returned non-zero status: ${err}; exiting!" + exit "${err}" fi cat "grib2_${grid_region}_${FH3}.out" if [[ ! -s gribfile ]]; then - echo "FATAL ERROR: '${pgm}' failed!" - exit 2 + echo "FATAL ERROR: '${pgm}' failed!" + exit 2 fi if [[ ${fhr} -gt 0 ]]; then - ${WGRIB2} gribfile -set_date "${PDY}${cyc}" -set_ftime "${fhr} hour fcst" -grib "${outfile}" - err=$? + ${WGRIB2} gribfile -set_date "${PDY}${cyc}" -set_ftime "${fhr} hour fcst" -grib "${outfile}" + err=$? else - ${WGRIB2} gribfile -set_date "${PDY}${cyc}" -set_ftime "${fhr} hour fcst" \ - -set table_1.4 1 -set table_1.2 1 -grib "${outfile}" - err=$? + ${WGRIB2} gribfile -set_date "${PDY}${cyc}" -set_ftime "${fhr} hour fcst" \ + -set table_1.4 1 -set table_1.2 1 -grib "${outfile}" + err=$? fi if [[ ${err} -ne 0 ]]; then - echo "FATAL ERROR: Error creating '${outfile}' with '${WGRIB2}'" - exit 3 + echo "FATAL ERROR: Error creating '${outfile}' with '${WGRIB2}'" + exit 3 fi # Create index @@ -118,41 +117,41 @@ ${WGRIB2} -s "${outfile}" > "${outfile}.idx" # Move grib files to COM directory if [[ -s "${outfile}" && -s "${outfile}.idx" ]]; then - cpfs "${outfile}" "${com_dir}/${outfile}" - cpfs "${outfile}.idx" "${com_dir}/${outfile}.idx" - echo "INFO: Copied ${outfile} and ${outfile}.idx from ${grib_DATA} to COM" + cpfs "${outfile}" "${com_dir}/${outfile}" + cpfs "${outfile}.idx" "${com_dir}/${outfile}.idx" + echo "INFO: Copied ${outfile} and ${outfile}.idx from ${grib_DATA} to COM" else - echo "FATAL ERROR: ${outfile} and ${outfile}.idx not found in ${grib_DATA} to copy to COM" - exit 4 + echo "FATAL ERROR: ${outfile} and ${outfile}.idx not found in ${grib_DATA} to copy to COM" + exit 4 fi # Create grib2 subgrid if this is the source grid if [[ "${grdID}" == "${WAV_SUBGRBSRC}" ]]; then - for subgrb in ${WAV_SUBGRB}; do - subgrbref=$(echo ${!subgrb} | cut -d " " -f 1-20) - subgrbnam=$(echo ${!subgrb} | cut -d " " -f 21) - subgrbres=$(echo ${!subgrb} | cut -d " " -f 22) - subfnam="${RUN}.t${cyc}z.${subgrbnam}.${subgrbres}.f${FH3}.grib2" - - ${COPYGB2} -g "${subgrbref}" -i0 -x "${outfile}" "${subfnam}" - ${WGRIB2} -s "${subfnam}" > "${subfnam}.idx" - - if [[ -s "${subfnam}" && -s "${subfnam}.idx" ]]; then - cpfs "${subfnam}" "${com_dir}/${subfnam}" - cpfs "${subfnam}.idx" "${com_dir}/${subfnam}.idx" - echo "INFO: Copied ${subfnam} and ${subfnam}.idx from ${GRIBDATA} to COM" - else - echo "FATAL ERROR: ${subfnam} and ${subfnam}.idx not found in ${grib_DATA} to copy to COM" - exit 5 - fi - done + for subgrb in ${WAV_SUBGRB}; do + subgrbref=$(echo "${!subgrb}" | cut -d " " -f 1-20) + subgrbnam=$(echo "${!subgrb}" | cut -d " " -f 21) + subgrbres=$(echo "${!subgrb}" | cut -d " " -f 22) + subfnam="${RUN}.t${cyc}z.${subgrbnam}.${subgrbres}.f${FH3}.grib2" + + ${COPYGB2} -g "${subgrbref}" -i0 -x "${outfile}" "${subfnam}" + ${WGRIB2} -s "${subfnam}" > "${subfnam}.idx" + + if [[ -s "${subfnam}" && -s "${subfnam}.idx" ]]; then + cpfs "${subfnam}" "${com_dir}/${subfnam}" + cpfs "${subfnam}.idx" "${com_dir}/${subfnam}.idx" + echo "INFO: Copied ${subfnam} and ${subfnam}.idx from ${GRIBDATA} to COM" + else + echo "FATAL ERROR: ${subfnam} and ${subfnam}.idx not found in ${grib_DATA} to copy to COM" + exit 5 + fi + done fi if [[ "${SENDDBN}" == 'YES' && "${outfile}" != *global.0p50* ]]; then - echo "INFO: Alerting GRIB file as ${outfile}" - echo "INFO: Alerting GRIB index file as ${outfile}.idx" - "${DBNROOT}/bin/dbn_alert" MODEL "${RUN^^}_WAVE_GB2" "${job}" "${com_dir}/${outfile}" - "${DBNROOT}/bin/dbn_alert" MODEL "${RUN^^}_WAVE_GB2_WIDX" "${job}" "${com_dir}/${outfile}.idx" + echo "INFO: Alerting GRIB file as ${outfile}" + echo "INFO: Alerting GRIB index file as ${outfile}.idx" + "${DBNROOT}/bin/dbn_alert" MODEL "${RUN^^}_WAVE_GB2" "${job}" "${com_dir}/${outfile}" + "${DBNROOT}/bin/dbn_alert" MODEL "${RUN^^}_WAVE_GB2_WIDX" "${job}" "${com_dir}/${outfile}.idx" else - echo "INFO: ${outfile} is global.0p50 or SENDDBN is NO, no alert sent" + echo "INFO: ${outfile} is global.0p50 or SENDDBN is NO, no alert sent" fi diff --git a/ush/wave_grid_interp_sbs.sh b/ush/wave_grid_interp_sbs.sh index ed41b813610..3e4fc585687 100755 --- a/ush/wave_grid_interp_sbs.sh +++ b/ush/wave_grid_interp_sbs.sh @@ -41,18 +41,18 @@ ${NLN} "${DATA}/out_grd.${waveGRD}" "./out_grd.${waveGRD}" # Link mod_def files from DATA into interp_DATA for ID in ${waveGRD} ${grdID}; do - ${NLN} "${DATA}/mod_def.${ID}" "./mod_def.${ID}" + ${NLN} "${DATA}/mod_def.${ID}" "./mod_def.${ID}" done # Check if there is an interpolation weights file available, and copy it if so if [[ -f "${FIXgfs}/wave/ww3_gint.WHTGRIDINT.bin.${waveGRD}.${grdID}" ]]; then - echo "INFO: Interpolation weights found at: '${FIXgfs}/wave/ww3_gint.WHTGRIDINT.bin.${waveGRD}.${grdID}'" - cpreq "${FIXgfs}/wave/ww3_gint.WHTGRIDINT.bin.${waveGRD}.${grdID}" "./WHTGRIDINT.bin" - weights_found=1 + echo "INFO: Interpolation weights found at: '${FIXgfs}/wave/ww3_gint.WHTGRIDINT.bin.${waveGRD}.${grdID}'" + cpreq "${FIXgfs}/wave/ww3_gint.WHTGRIDINT.bin.${waveGRD}.${grdID}" "./WHTGRIDINT.bin" + weights_found=1 else - echo "WARNING: No weights file found at: '${FIXgfs}/wave/ww3_gint.WHTGRIDINT.bin.${waveGRD}.${grdID}'" - echo "INFO: Interpolation will create a new weights file" - weights_found=0 + echo "WARNING: No weights file found at: '${FIXgfs}/wave/ww3_gint.WHTGRIDINT.bin.${waveGRD}.${grdID}'" + echo "INFO: Interpolation will create a new weights file" + weights_found=0 fi # Create the input file for the interpolation code @@ -69,26 +69,26 @@ cat ww3_gint.inp export pgm="${NET,,}_ww3_gint.x" source prep_step echo "INFO: Executing '${pgm}'" -"${EXECgfs}/${pgm}" > grid_interp.${grdID}.out 2>&1 +"${EXECgfs}/${pgm}" > "grid_interp.${grdID}.out" 2>&1 cat "grid_interp.${grdID}.out" if [[ ${err} -ne 0 ]]; then - echo "FATAL ERROR: '${pgm}' failed!" - exit 3 + echo "FATAL ERROR: '${pgm}' failed!" + exit 3 fi if [[ ${weights_found} -eq 0 ]]; then - echo "INFO: Interpolation created a new weights file at: '${interp_DATA}/WHTGRIDINT.bin'" + echo "INFO: Interpolation created a new weights file at: '${interp_DATA}/WHTGRIDINT.bin'" fi # Link output file (interpolated output) within DATA (this program generates this file) if [[ -f "./out_grd.${grdID}" ]]; then - if [[ -f "${DATA}/out_grd.${grdID}" ]]; then - echo "FATAL ERROR: '${DATA}/out_grd.${grdID}' already exists, ABORT!" - exit 4 - else - ${NLN} "${interp_DATA}/out_grd.${grdID}" "${DATA}/out_grd.${grdID}" - fi + if [[ -f "${DATA}/out_grd.${grdID}" ]]; then + echo "FATAL ERROR: '${DATA}/out_grd.${grdID}' already exists, ABORT!" + exit 4 + else + ${NLN} "${interp_DATA}/out_grd.${grdID}" "${DATA}/out_grd.${grdID}" + fi else - echo "FATAL ERROR: '${pgm}' failed to generate output file at: '${interp_DATA}/out_grd.${grdID}'" - exit 4 + echo "FATAL ERROR: '${pgm}' failed to generate output file at: '${interp_DATA}/out_grd.${grdID}'" + exit 4 fi diff --git a/ush/wave_grid_moddef.sh b/ush/wave_grid_moddef.sh index 7cf6d3aa20b..65ee1550337 100755 --- a/ush/wave_grid_moddef.sh +++ b/ush/wave_grid_moddef.sh @@ -21,44 +21,43 @@ # 0. Preparations # 0.a Basic modes of operation - grdID=${1?Must provide grdID} +grdID=${1?Must provide grdID} - echo "INFO: Generating mod_def file for ${grdID}" +echo "INFO: Generating mod_def file for ${grdID}" - mkdir -p "moddef_${grdID}" - cd "moddef_${grdID}" || exit 2 +mkdir -p "moddef_${grdID}" +cd "moddef_${grdID}" || exit 2 # --------------------------------------------------------------------------- # # 2. Create mod_def file +rm -f "ww3_grid.inp" +${NLN} "../ww3_grid.inp.${grdID}" "ww3_grid.inp" - rm -f "ww3_grid.inp" - ${NLN} "../ww3_grid.inp.${grdID}" "ww3_grid.inp" +if [[ -f "../${grdID}.msh" ]]; then + rm -f "${grdID}.msh" + ${NLN} "../${grdID}.msh" "${grdID}.msh" +fi - if [[ -f "../${grdID}.msh" ]]; then - rm -f "${grdID}.msh" - ${NLN} "../${grdID}.msh" "${grdID}.msh" - fi +export pgm="${NET,,}_ww3_grid.x" - export pgm="${NET,,}_ww3_grid.x" +echo "INFO: Executing ${EXECgfs}/${NET,,}_ww3_grid.x" - echo "INFO: Executing ${EXECgfs}/${NET,,}_ww3_grid.x" +"${EXECgfs}/${pgm}" +export err=$? - "${EXECgfs}/${pgm}" - export err=$? - - if [[ "${err}" != '0' ]]; then +if [[ "${err}" != '0' ]]; then echo "FATAL ERROR: Error in ${pgm}" exit "${err}" - fi +fi - if [[ -f mod_def.ww3 ]];then +if [[ -f mod_def.ww3 ]]; then cpfs "mod_def.ww3" "${COMOUT_WAVE_PREP}/${RUN}.t${cyc}z.mod_def.${grdID}.bin" mv "mod_def.ww3" "../mod_def.${grdID}" - else +else echo "FATAL ERROR: Mod def file not created for ${grdID}" exit 4 - fi +fi # --------------------------------------------------------------------------- # # 3. Clean up diff --git a/ush/wave_outp_cat.sh b/ush/wave_outp_cat.sh index b4482497666..b7200516425 100755 --- a/ush/wave_outp_cat.sh +++ b/ush/wave_outp_cat.sh @@ -29,16 +29,16 @@ specdir=$3 # 0.b Check if buoy location set if [[ $# -lt 1 ]]; then - echo 'FATAL ERROR: LOCATION ID IN ww3_outp_spec.sh NOT SET ***' - exit 1 + echo 'FATAL ERROR: LOCATION ID IN ww3_outp_spec.sh NOT SET ***' + exit 1 fi # 0.c Define directories and the search path. # The tested variables should be exported by the postprocessor script. if [[ -z "${DTPNT_WAV+0}" || -z "${FHMIN_WAV+0}" || -z "${WAV_MOD_TAG+0}" || -z "${STA_DIR+0}" ]]; then - echo 'FATAL ERROR: EXPORTED VARIABLES IN ww3_outp_cat.sh NOT SET ***' - exit 3 + echo 'FATAL ERROR: EXPORTED VARIABLES IN ww3_outp_cat.sh NOT SET ***' + exit 3 fi # --------------------------------------------------------------------------- # @@ -47,53 +47,53 @@ fi echo " Generate input file for ww3_outp." if [[ "${specdir}" == "bull" ]]; then - outfile="${STA_DIR}/${specdir}/${WAV_MOD_TAG}.${buoy}.bull" - coutfile="${STA_DIR}/c${specdir}/${WAV_MOD_TAG}.${buoy}.cbull" - rm -f "${outfile}" "${coutfile}" + outfile="${STA_DIR}/${specdir}/${WAV_MOD_TAG}.${buoy}.bull" + coutfile="${STA_DIR}/c${specdir}/${WAV_MOD_TAG}.${buoy}.cbull" + rm -f "${outfile}" "${coutfile}" else - outfile="${STA_DIR}/${specdir}/${WAV_MOD_TAG}.${buoy}.spec" - rm -f "${outfile}" + outfile="${STA_DIR}/${specdir}/${WAV_MOD_TAG}.${buoy}.spec" + rm -f "${outfile}" fi fhr=${FHMIN_WAV} fhrp=${fhr} while [[ ${fhr} -le ${MAXHOUR} ]]; do - ymdh=$(date --utc +%Y%m%d%H -d "${PDY} ${cyc} + ${fhr} hours") - if [[ "${specdir}" == "bull" ]]; then - outfilefhr="${STA_DIR}/${specdir}fhr/${WAV_MOD_TAG}.${ymdh}.${buoy}.bull" - coutfilefhr="${STA_DIR}/c${specdir}fhr/${WAV_MOD_TAG}.${ymdh}.${buoy}.cbull" - else - outfilefhr="${STA_DIR}/${specdir}fhr/${WAV_MOD_TAG}.${ymdh}.${buoy}.spec" - fi - - if [[ -f "${outfilefhr}" ]]; then - if [[ "$specdir" == "bull" ]]; then - cat "${outfilefhr}" >> "${STA_DIR}/${specdir}/${WAV_MOD_TAG}.${buoy}.bull" - cat "${coutfilefhr}" >> "${STA_DIR}/c${specdir}/${WAV_MOD_TAG}.${buoy}.cbull" - rm -f "${outfilefhr}" "${coutfilefhr}" + ymdh=$(date --utc +%Y%m%d%H -d "${PDY} ${cyc} + ${fhr} hours") + if [[ "${specdir}" == "bull" ]]; then + outfilefhr="${STA_DIR}/${specdir}fhr/${WAV_MOD_TAG}.${ymdh}.${buoy}.bull" + coutfilefhr="${STA_DIR}/c${specdir}fhr/${WAV_MOD_TAG}.${ymdh}.${buoy}.cbull" else - cat "${outfilefhr}" >> "${STA_DIR}/${specdir}/${WAV_MOD_TAG}.${buoy}.spec" - #rm -f "${outfilefhr}" + outfilefhr="${STA_DIR}/${specdir}fhr/${WAV_MOD_TAG}.${ymdh}.${buoy}.spec" fi - else - echo "FATAL ERROR: OUTPUT DATA FILE FOR BUOY ${buoy} at ${ymdh} NOT FOUND" - exit 9 - fi - FHINCP=$(( DTPNT_WAV / 3600 )) - if [[ ${fhr} -eq ${fhrp} ]]; then - fhrp=$((fhr+FHINCP)) - fi - echo "${fhrp}" + if [[ -f "${outfilefhr}" ]]; then + if [[ "${specdir}" == "bull" ]]; then + cat "${outfilefhr}" >> "${STA_DIR}/${specdir}/${WAV_MOD_TAG}.${buoy}.bull" + cat "${coutfilefhr}" >> "${STA_DIR}/c${specdir}/${WAV_MOD_TAG}.${buoy}.cbull" + rm -f "${outfilefhr}" "${coutfilefhr}" + else + cat "${outfilefhr}" >> "${STA_DIR}/${specdir}/${WAV_MOD_TAG}.${buoy}.spec" + #rm -f "${outfilefhr}" + fi + else + echo "FATAL ERROR: OUTPUT DATA FILE FOR BUOY ${buoy} at ${ymdh} NOT FOUND" + exit 9 + fi + + FHINCP=$((DTPNT_WAV / 3600)) + if [[ ${fhr} -eq ${fhrp} ]]; then + fhrp=$((fhr + FHINCP)) + fi + echo "${fhrp}" - fhr=${fhrp} # no gridded output, loop with out_pnt stride + fhr=${fhrp} # no gridded output, loop with out_pnt stride done if [[ ! -f "${outfile}" ]]; then - echo "FATAL ERROR: OUTPUTFILE ${outfile} not created " - exit 2 + echo "FATAL ERROR: OUTPUTFILE ${outfile} not created " + exit 2 fi # End of ww3_outp_cat.sh ---------------------------------------------------- # diff --git a/ush/wave_outp_spec.sh b/ush/wave_outp_spec.sh index e365741809f..96bfc196d9c 100755 --- a/ush/wave_outp_spec.sh +++ b/ush/wave_outp_spec.sh @@ -31,31 +31,31 @@ workdir=$4 # 0.b Check if buoy location set if [[ $# -lt 1 ]]; then - echo 'FATAL ERROR: LOCATION ID IN wave_outp_spec.sh NOT SET' - exit 1 + echo 'FATAL ERROR: LOCATION ID IN wave_outp_spec.sh NOT SET' + exit 1 else - point=$(awk "{if (\$2 == \"${buoy}\"){print \$1; exit} }" "${DATA}/buoy_log.ww3") - if [[ -z "${point}" ]]; then - echo 'FATAL ERROR: LOCATION ID IN ww3_outp_spec.sh NOT RECOGNIZED' - exit 2 - else - printf "\n Location ID/# : %s (%s) ${buoy} (${point})\n Spectral output start time : %s" "${buoy}" "${point}" "${ymdh}" - fi + point=$(awk "{if (\$2 == \"${buoy}\"){print \$1; exit} }" "${DATA}/buoy_log.ww3") + if [[ -z "${point}" ]]; then + echo 'FATAL ERROR: LOCATION ID IN ww3_outp_spec.sh NOT RECOGNIZED' + exit 2 + else + printf "\n Location ID/# : %s (%s) ${buoy} (${point})\n Spectral output start time : %s" "${buoy}" "${point}" "${ymdh}" + fi fi # 0.c Define directories and the search path. # The tested variables should be exported by the postprocessor script. if [[ -z "${PDY+0}" || -z "${cyc+0}" || -z "${dtspec+0}" || -z "${EXECgfs+0}" || -z "${WAV_MOD_TAG+0}" || -z "${STA_DIR+0}" ]]; then - echo 'FATAL ERROR: EXPORTED VARIABLES IN ww3_outp_spec.sh NOT SET' - exit 3 + echo 'FATAL ERROR: EXPORTED VARIABLES IN ww3_outp_spec.sh NOT SET' + exit 3 fi -cd "${workdir}" +cd "${workdir}" || exit 1 rm -rf "${specdir}_${buoy}" mkdir -p "${specdir}_${buoy}" -cd "${specdir}_${buoy}" +cd "${specdir}_${buoy}" || exit 1 cat << EOF @@ -86,22 +86,22 @@ tstart="${ymdh:0:8} ${ymdh:8:2}0000" printf " Output starts at %s.\n" "${tstart}" if [[ "${specdir}" == "bull" ]]; then - truntime="${PDY} ${cyc}0000" - sed -e "s/TIME/${tstart}/g" \ - -e "s/DT/${dtspec}/g" \ - -e "s/POINT/${point}/g" \ - -e "s/REFT/${truntime}/g" \ - "${DATA}/ww3_outp_bull.inp.tmpl" > ww3_outp.inp - outfile="${buoy}.bull" - coutfile="${buoy}.cbull" + truntime="${PDY} ${cyc}0000" + sed -e "s/TIME/${tstart}/g" \ + -e "s/DT/${dtspec}/g" \ + -e "s/POINT/${point}/g" \ + -e "s/REFT/${truntime}/g" \ + "${DATA}/ww3_outp_bull.inp.tmpl" > ww3_outp.inp + outfile="${buoy}.bull" + coutfile="${buoy}.cbull" else - sed -e "s/TIME/${tstart}/g" \ - -e "s/DT/${dtspec}/g" \ - -e "s/POINT/${point}/g" \ - -e "s/ITYPE/1/g" \ - -e "s/FORMAT/F/g" \ - "${DATA}/ww3_outp_spec.inp.tmpl" > ww3_outp.inp - outfile="ww3.${tstart:2:5}${tstart:9:2}.spc" + sed -e "s/TIME/${tstart}/g" \ + -e "s/DT/${dtspec}/g" \ + -e "s/POINT/${point}/g" \ + -e "s/ITYPE/1/g" \ + -e "s/FORMAT/F/g" \ + "${DATA}/ww3_outp_spec.inp.tmpl" > ww3_outp.inp + outfile="ww3.${tstart:2:5}${tstart:9:2}.spc" fi # 2.b Run the postprocessor @@ -114,8 +114,8 @@ echo " Executing ${EXECgfs}/${pgm}" "${EXECgfs}/${pgm}" 1> "outp_${specdir}_${buoy}.out" 2>&1 export err=$? if [[ ${err} -ne 0 ]]; then - echo "FATAL ERROR : ERROR IN ${pgm} *** " - exit 4 + echo "FATAL ERROR : ERROR IN ${pgm} *** " + exit 4 fi # --------------------------------------------------------------------------- # @@ -126,31 +126,31 @@ YMDHE=$(date --utc +%Y%m%d%H -d "${PDY} ${cyc} + ${FHMAX_WAV_PNT} hours") model_start_date=$(date --utc +%Y%m%d%H -d "${PDY} ${cyc} + ${OFFSET_START_HOUR} hours") if [[ -f "${outfile}" ]]; then - if [[ "${ymdh}" == "${model_start_date}" ]]; then - if [[ "${specdir}" == "bull" ]]; then - sed '9,$d' "${outfile}" >> "${STA_DIR}/${specdir}fhr/${WAV_MOD_TAG}.${ymdh}.${buoy}.bull" - sed '8,$d' "${coutfile}" >> "${STA_DIR}/c${specdir}fhr/${WAV_MOD_TAG}.${ymdh}.${buoy}.cbull" - else - cat "${outfile}" >> "${STA_DIR}/${specdir}fhr/${WAV_MOD_TAG}.${ymdh}.${buoy}.spec" - fi - elif [[ "${ymdh}" == "${YMDHE}" ]]; then - if [[ "${specdir}" == "bull" ]]; then - sed '1,7d' "${outfile}" >> "${STA_DIR}/${specdir}fhr/${WAV_MOD_TAG}.${ymdh}.${buoy}.bull" - sed '1,6d' "${coutfile}" >> "${STA_DIR}/c${specdir}fhr/${WAV_MOD_TAG}.${ymdh}.${buoy}.cbull" - else - sed -n "/^${ymdh:0:8} ${ymdh:8:2}0000$/,\$p" "${outfile}" >> "${STA_DIR}/${specdir}fhr/${WAV_MOD_TAG}.${ymdh}.${buoy}.spec" - fi - else - if [[ "${specdir}" == "bull" ]]; then - sed '8q;d' "${outfile}" >> "${STA_DIR}/${specdir}fhr/${WAV_MOD_TAG}.${ymdh}.${buoy}.bull" - sed '7q;d' "${coutfile}" >> "${STA_DIR}/c${specdir}fhr/${WAV_MOD_TAG}.${ymdh}.${buoy}.cbull" - else - sed -n "/^${ymdh:0:8} ${ymdh:8:2}0000$/,\$p" "${outfile}" >> "${STA_DIR}/${specdir}fhr/${WAV_MOD_TAG}.${ymdh}.${buoy}.spec" - fi - fi + if [[ "${ymdh}" == "${model_start_date}" ]]; then + if [[ "${specdir}" == "bull" ]]; then + sed '9,$d' "${outfile}" >> "${STA_DIR}/${specdir}fhr/${WAV_MOD_TAG}.${ymdh}.${buoy}.bull" + sed '8,$d' "${coutfile}" >> "${STA_DIR}/c${specdir}fhr/${WAV_MOD_TAG}.${ymdh}.${buoy}.cbull" + else + cat "${outfile}" >> "${STA_DIR}/${specdir}fhr/${WAV_MOD_TAG}.${ymdh}.${buoy}.spec" + fi + elif [[ "${ymdh}" == "${YMDHE}" ]]; then + if [[ "${specdir}" == "bull" ]]; then + sed '1,7d' "${outfile}" >> "${STA_DIR}/${specdir}fhr/${WAV_MOD_TAG}.${ymdh}.${buoy}.bull" + sed '1,6d' "${coutfile}" >> "${STA_DIR}/c${specdir}fhr/${WAV_MOD_TAG}.${ymdh}.${buoy}.cbull" + else + sed -n "/^${ymdh:0:8} ${ymdh:8:2}0000$/,\$p" "${outfile}" >> "${STA_DIR}/${specdir}fhr/${WAV_MOD_TAG}.${ymdh}.${buoy}.spec" + fi + else + if [[ "${specdir}" == "bull" ]]; then + sed '8q;d' "${outfile}" >> "${STA_DIR}/${specdir}fhr/${WAV_MOD_TAG}.${ymdh}.${buoy}.bull" + sed '7q;d' "${coutfile}" >> "${STA_DIR}/c${specdir}fhr/${WAV_MOD_TAG}.${ymdh}.${buoy}.cbull" + else + sed -n "/^${ymdh:0:8} ${ymdh:8:2}0000$/,\$p" "${outfile}" >> "${STA_DIR}/${specdir}fhr/${WAV_MOD_TAG}.${ymdh}.${buoy}.spec" + fi + fi else - echo "FATAL ERROR: OUTPUT DATA FILE FOR BUOY '${buoy}' NOT FOUND" - exit 5 + echo "FATAL ERROR: OUTPUT DATA FILE FOR BUOY '${buoy}' NOT FOUND" + exit 5 fi # 3.b Clean up the rest diff --git a/ush/wave_prnc_cur.sh b/ush/wave_prnc_cur.sh index cdeecc1f7c5..a52b9336dc6 100755 --- a/ush/wave_prnc_cur.sh +++ b/ush/wave_prnc_cur.sh @@ -31,10 +31,10 @@ fext='f' # Timing has to be made relative to the single 00z RTOFS cycle for that PDY -mkdir -p rtofs_${ymdh_rtofs} -cd rtofs_${ymdh_rtofs} +mkdir -p "rtofs_${ymdh_rtofs}" +cd "rtofs_${ymdh_rtofs}" || exit 1 -ncks -x -v sst,sss,layer_density "${curfile} cur_uv_${PDY}_${fext}${fh3}.nc" +ncks -x -v sst,sss,layer_density "${curfile}" "cur_uv_${PDY}_${fext}${fh3}.nc" ncks -O -a -h -x -v Layer "cur_uv_${PDY}_${fext}${fh3}.nc" "cur_temp1.nc" ncwa -h -O -a Layer cur_temp1.nc cur_temp2.nc ncrename -h -O -v MT,time -d MT,time cur_temp2.nc @@ -44,28 +44,27 @@ mv -f "cur_temp3.nc" "cur_uv_${PDY}_${fext}${fh3}_flat.nc" # Convert to regular lat lon file # If weights need to be regenerated due to CDO ver change, use: # $CDO genbil,r4320x2160 rtofs_glo_2ds_f000_3hrly_prog.nc weights.nc -cpreq ${FIXgfs}/wave/weights_rtofs_to_r4320x2160.nc ./weights.nc +cpreq "${FIXgfs}/wave/weights_rtofs_to_r4320x2160.nc" ./weights.nc # Interpolate to regular 5 min grid ${CDO} remap,r4320x2160,weights.nc "cur_uv_${PDY}_${fext}${fh3}_flat.nc" "cur_5min_01.nc" # Perform 9-point smoothing twice to make RTOFS data less noisy when # interpolating from 1/12 deg RTOFS grid to 1/6 deg wave grid -if [ "WAV_CUR_CDO_SMOOTH" = "YES" ]; then - ${CDO} -f nc -smooth9 "cur_5min_01.nc" "cur_5min_02.nc" - ${CDO} -f nc -smooth9 "cur_5min_02.nc" "cur_glo_uv_${PDY}_${fext}${fh3}_5min.nc" +if [[ "${WAV_CUR_CDO_SMOOTH}" == "YES" ]]; then + ${CDO} -f nc -smooth9 "cur_5min_01.nc" "cur_5min_02.nc" + ${CDO} -f nc -smooth9 "cur_5min_02.nc" "cur_glo_uv_${PDY}_${fext}${fh3}_5min.nc" else - mv "cur_5min_01.nc" "cur_glo_uv_${PDY}_${fext}${fh3}_5min.nc" + mv "cur_5min_01.nc" "cur_glo_uv_${PDY}_${fext}${fh3}_5min.nc" fi # Cleanup rm -f cur_temp[123].nc cur_5min_??.nc "cur_glo_uv_${PDY}_${fext}${fh3}.nc weights.nc" -if [ ${flagfirst} = "T" ] -then - sed -e "s/HDRFL/T/g" ${PARMgfs}/wave/ww3_prnc.cur.${WAVECUR_FID}.inp.tmpl > ww3_prnc.inp +if [[ "${flagfirst}" = "T" ]]; then + sed -e "s/HDRFL/T/g" "${PARMgfs}/wave/ww3_prnc.cur.${WAVECUR_FID}.inp.tmpl" > ww3_prnc.inp else - sed -e "s/HDRFL/F/g" ${PARMgfs}/wave/ww3_prnc.cur.${WAVECUR_FID}.inp.tmpl > ww3_prnc.inp + sed -e "s/HDRFL/F/g" "${PARMgfs}/wave/ww3_prnc.cur.${WAVECUR_FID}.inp.tmpl" > ww3_prnc.inp fi rm -f cur.nc @@ -75,22 +74,15 @@ ${NLN} "${DATA}/mod_def.${WAVECUR_FID}" ./mod_def.ww3 export pgm="${NET,,}_ww3_prnc.x" source prep_step -"${EXECgfs}/${pgm}" 1> prnc_${WAVECUR_FID}_${ymdh_rtofs}.out 2>&1 -export err=$?; err_chk -if [ "$err" != '0' ] -then - cat prnc_${WAVECUR_FID}_${ymdh_rtofs}.out - set $setoff - echo ' ' - echo '******************************************** ' - echo "*** WARNING: NON-FATAL ERROR IN ${pgm} *** " - echo '******************************************** ' - echo ' ' - set $seton - echo "WARNING: NON-FATAL ERROR IN ${pgm}." - exit 4 +"${EXECgfs}/${pgm}" 1> "prnc_${WAVECUR_FID}_${ymdh_rtofs}.out" 2>&1 +export err=$? +err_chk +if [[ "${err}" -ne 0 ]]; then + cat "prnc_${WAVECUR_FID}_${ymdh_rtofs}.out" + echo "WARNING: NON-FATAL ERROR IN ${pgm}." + exit 4 fi -mv -f current.ww3 ${DATA}/rtofs.${ymdh_rtofs} +mv -f current.ww3 "${DATA}/rtofs.${ymdh_rtofs}" -cd ${DATA} +cd "${DATA}" || exit 1 diff --git a/ush/wave_prnc_ice.sh b/ush/wave_prnc_ice.sh index 3812b5e8120..caeba3a0d05 100755 --- a/ush/wave_prnc_ice.sh +++ b/ush/wave_prnc_ice.sh @@ -29,100 +29,96 @@ # 0.a Basic modes of operation - rm -rf ice - mkdir ice - cd ice - ${NLN} "${DATA}/postmsg" postmsg +rm -rf ice +mkdir ice +cd ice || exit 1 +${NLN} "${DATA}/postmsg" postmsg # 0.b Define directories and the search path. # The tested variables should be exported by the postprocessor script. - set +x - cat << EOF +set +x +cat << EOF +--------------------------------+ ! Make ice fields | +--------------------------------+ - Model TAG : $WAV_MOD_TAG + Model TAG : ${WAV_MOD_TAG} Model ID : ${RUN}.wave - Ice grid ID : $WAVEICE_FID - Ice file : $WAVICEFILE + Ice grid ID : ${WAVEICE_FID} + Ice file : ${WAVICEFILE} Making ice fields. EOF - if [[ -z "${YMDH}" ]] || [[ -z "${cycle}" ]] || \ - [[ -z "${COMOUT_WAVE_PREP}" ]] || [[ -z "${FIXgfs}" ]] || [[ -z "${EXECgfs}" ]] || \ - [[ -z "${WAV_MOD_TAG}" ]] || [[ -z "${WAVEICE_FID}" ]] || [[ -z "${COMIN_OBS}" ]]; then +if [[ -z "${YMDH}" ]] || [[ -z "${cycle}" ]] || + [[ -z "${COMOUT_WAVE_PREP}" ]] || [[ -z "${FIXgfs}" ]] || [[ -z "${EXECgfs}" ]] || + [[ -z "${WAV_MOD_TAG}" ]] || [[ -z "${WAVEICE_FID}" ]] || [[ -z "${COMIN_OBS}" ]]; then echo 'ERROR: EXPORTED VARIABLES IN preprocessor NOT SET ***' exit 1 - fi +fi # 0.c Links to working directory - ${NLN} ${DATA}/mod_def.$WAVEICE_FID mod_def.ww3 +${NLN} "${DATA}/mod_def.${WAVEICE_FID}" mod_def.ww3 # --------------------------------------------------------------------------- # # 1. Get the necessary files # 1.a Copy the ice data file - file=${COMIN_OBS}/${WAVICEFILE} +file="${COMIN_OBS}/${WAVICEFILE}" - if [ -f $file ] - then - cpreq $file ice.grib - fi +if [[ -f "${file}" ]]; then + cpreq "${file}" ice.grib +fi - if [ -f ice.grib ] - then - echo " ice.grib copied ($file)." - else - echo "ERROR: NO ICE FILE $file" - exit 2 - fi +if [[ -f ice.grib ]]; then + echo " ice.grib copied (${file})." +else + msg="FATAL ERROR: NO ICE FILE ${file}" + export err=2 + err_exit "${msg}" +fi # --------------------------------------------------------------------------- # # 2. Process the GRIB packed ice file # 2.a Unpack data - echo ' Extracting data from ice.grib ...' +echo ' Extracting data from ice.grib ...' - $WGRIB2 ice.grib -netcdf icean_5m.nc 2>&1 > wgrib.out +${WGRIB2} ice.grib -netcdf icean_5m.nc wgrib.out 2>&1 - err=$? +err=$? - if [ "$err" != '0' ] - then +if [[ "${err}" -ne 0 ]]; then cat wgrib.out echo 'ERROR: FAILURE WHILE UNPACKING GRIB ICE FILE *** ' exit 3 - fi - - rm -f wgrib.out - rm -f ice.grib - rm -f ice.index +fi +rm -f wgrib.out +rm -f ice.grib +rm -f ice.index # 2.d Run through preprocessor wave_prep - printf " Run through preprocessor ...\n" +printf " Run through preprocessor ...\n" - cpreq -f ${DATA}/ww3_prnc.ice.$WAVEICE_FID.inp.tmpl ww3_prnc.inp +cpreq -f "${DATA}/ww3_prnc.ice.${WAVEICE_FID}.inp.tmpl" ww3_prnc.inp - export pgm="${NET,,}_ww3_prnc.x" - source prep_step +export pgm="${NET,,}_ww3_prnc.x" +source prep_step - "${EXECgfs}/${pgm}" 1> prnc_${WAVEICE_FID}_${cycle}.out 2>&1 - export err=$? - if [[ ${err} -ne 0 ]] - then - cat prnc_${WAVEICE_FID}_${cycle}.out - echo "ERROR: failure in ${pgm}" - exit 4 - fi +"${EXECgfs}/${pgm}" 1> "prnc_${WAVEICE_FID}_${cycle}.out" 2>&1 +export err=$? +if [[ ${err} -ne 0 ]]; then + cat "prnc_${WAVEICE_FID}_${cycle}.out" + msg="FATAL ERROR: failure in ${pgm}" + err_exit "${msg}" +fi - rm -f wave_prep.out ww3_prep.inp ice.raw mod_def.ww3 +rm -f wave_prep.out ww3_prep.inp ice.raw mod_def.ww3 # --------------------------------------------------------------------------- # # 3. Save the ice file @@ -130,17 +126,15 @@ EOF # Ice file name will have ensemble member number if WW3ATMIENS=T # and only WAV_MOD_ID if WW3ATMIENS=F # - if [ "${WW3ATMIENS}" = "T" ] - then - icefile=${WAV_MOD_TAG}.${WAVEICE_FID}.$cycle.ice - elif [ "${WW3ATMIENS}" = "F" ] - then - icefile=${RUN}.wave.${WAVEICE_FID}.$cycle.ice - fi - - echo " Saving ice.ww3 as ${COMOUT_WAVE_PREP}/${icefile}" - cpfs ice.ww3 "${COMOUT_WAVE_PREP}/${icefile}" - rm -f ice.ww3 +if [[ "${WW3ATMIENS}" == "T" ]]; then + icefile="${WAV_MOD_TAG}.${WAVEICE_FID}.${cycle}.ice" +elif [[ "${WW3ATMIENS}" == "F" ]]; then + icefile="${RUN}.wave.${WAVEICE_FID}.${cycle}.ice" +fi + +echo " Saving ice.ww3 as ${COMOUT_WAVE_PREP}/${icefile}" +cpfs ice.ww3 "${COMOUT_WAVE_PREP}/${icefile}" +rm -f ice.ww3 # --------------------------------------------------------------------------- # # 4. Clean up the directory diff --git a/ush/wave_tar.sh b/ush/wave_tar.sh index 9e278c79b02..e24def1e11f 100755 --- a/ush/wave_tar.sh +++ b/ush/wave_tar.sh @@ -27,25 +27,23 @@ # 0.a Basic modes of operation - cd "${DATA}" - echo "Making TAR FILE" - - alertName=$(echo $RUN|tr [a-z] [A-Z]) - +cd "${DATA}" || exit 1 +echo "Making TAR FILE" +export err # 0.b Check if type set - if [[ "$#" -lt '3' ]] - then - echo 'FATAL ERROR: VARIABLES IN ww3_tar.sh NOT SET' - exit 1 - else +if [[ "$#" -lt '3' ]]; then + msg='FATAL ERROR: VARIABLES IN ww3_tar.sh NOT SET' + err=1 + err_exit "${msg}" +else ID=$1 type=$2 nb=$3 - fi +fi - cat << EOF +cat << EOF +--------------------------------+ ! Make tar file | @@ -55,122 +53,120 @@ Number of files : $3 EOF - filext=$type - if [[ "$type" == "ibp" ]]; then - filext='spec' - fi - if [[ "$type" == "ibpbull" ]]; then - filext='bull' - fi - if [[ "$type" == "ibpcbull" ]]; then - filext='cbull' - fi - - rm -rf TAR_${filext}_$ID - mkdir TAR_${filext}_$ID +filext=${type} +if [[ "${type}" == "ibp" ]]; then + filext='spec' +fi +if [[ "${type}" == "ibpbull" ]]; then + filext='bull' +fi +if [[ "${type}" == "ibpcbull" ]]; then + filext='cbull' +fi + +rm -rf "TAR_${filext}_${ID}" +mkdir "TAR_${filext}_${ID}" # this directory is used only for error capturing # 0.c Define directories and the search path. # The tested variables should be exported by the postprocessor script. - if [[ -z "${COMOUT_WAVE_STATION+x}" || -z "${SENDDBN+x}" || -z "${STA_DIR+x}" ]]; then - echo 'FATAL ERROR: EXPORTED VARIABLES IN ww3_tar.sh NOT SET' - exit 2 - fi +if [[ -z "${COMOUT_WAVE_STATION+x}" || -z "${SENDDBN+x}" || -z "${STA_DIR+x}" ]]; then + msg='FATAL ERROR: EXPORTED VARIABLES IN ww3_tar.sh NOT SET' + err=2 + err_exit "${msg}" +fi # --------------------------------------------------------------------------- # # 2. Generate tar file (spectral files are compressed) - printf "\n Making tar file ..." - - countMAX=5 - tardone='no' - sleep_interval=10 - - while [[ "${tardone}" = "no" ]] - do - - nf=$(find . -maxdepth 1 -type f -name "*.$filext" | wc -l) - nbm2=$(( $nb - 2 )) - if [[ ${nf} -ge ${nbm2} ]] - then - - tar -cf "${ID}.${type}.tar" ./*."${filext}" - err=$? - - if [[ ${err} -ne 0 ]] - then - echo 'FATAL ERROR: TAR CREATION FAILED *** ' - exit 3 - fi +printf "\n Making tar file ..." + +countMAX=5 +tardone='no' +sleep_interval=10 + +while [[ "${tardone}" == "no" ]]; do + # shellcheck disable=SC2312 + nf=$(find . -maxdepth 1 -type f -name "*.${filext}" -printf '.' | wc -c) + nbm2=$((nb - 2)) + if [[ ${nf} -ge ${nbm2} ]]; then + + tar -cf "${ID}.${type}.tar" ./*."${filext}" + err=$? + + if [[ ${err} -ne 0 ]]; then + msg='FATAL ERROR: TAR CREATION FAILED *** ' + err=3 + err_exit "${msg}" + fi + + filename="${ID}.${type}.tar" + if ! wait_for_file "${filename}" "${sleep_interval}" "${countMAX}"; then + msg="FATAL ERROR: File ${filename} not found after waiting $((sleep_interval * (countMAX + 1))) secs" + err=3 + err_exit "${msg}" + fi + + if [[ -f "${ID}.${type}.tar" ]]; then + tardone='yes' + fi + fi - filename="${ID}.${type}.tar" - if ! wait_for_file "${filename}" "${sleep_interval}" "${countMAX}" ; then - echo "FATAL ERROR: File ${filename} not found after waiting $(( sleep_interval * (countMAX + 1) )) secs" - exit 3 - fi +done - if [[ -f "${ID}.${type}.tar" ]] - then - tardone='yes' - fi - fi +if [[ "${tardone}" == 'no' ]]; then + msg='FATAL ERROR: TAR CREATION FAILED *** ' + err=3 + err_exit "${msg}" +fi - done - - if [[ "${tardone}" == 'no' ]] - then - echo 'FATAL ERROR: TAR CREATION FAILED *** ' - exit 3 - fi - - if [[ "${type}" == 'spec' ]] - then - if [[ -s "${ID}.${type}.tar" ]] - then - file_name="${ID}.${type}.tar.gz" - /usr/bin/gzip -c "${ID}.${type}.tar" > "${file_name}" - err=$? - - if [[ ${err} -ne 0 ]] - then - echo 'FATAL ERROR: SPECTRAL TAR COMPRESSION FAILED *** ' - exit 4 - fi +if [[ "${type}" == 'spec' ]]; then + if [[ -s "${ID}.${type}.tar" ]]; then + file_name="${ID}.${type}.tar.gz" + /usr/bin/gzip -c "${ID}.${type}.tar" > "${file_name}" + err=$? + + if [[ ${err} -ne 0 ]]; then + msg='FATAL ERROR: SPECTRAL TAR COMPRESSION FAILED *** ' + err=4 + err_exit + fi fi - else +else file_name="${ID}.${type}.tar" - fi +fi # --------------------------------------------------------------------------- # # 3. Move data to /com - echo " Moving tar file ${file_name} to ${COMOUT_WAVE_STATION} ..." +echo " Moving tar file ${file_name} to ${COMOUT_WAVE_STATION} ..." - cpfs "${file_name}" "${COMOUT_WAVE_STATION}/." +cpfs "${file_name}" "${COMOUT_WAVE_STATION}/." - err=$? +err=$? - if [[ ${err} -ne 0 ]]; then - echo 'FATAL ERROR: TAR COPY FAILED *** ' - exit 4 - fi +if [[ ${err} -ne 0 ]]; then + msg='FATAL ERROR: TAR COPY FAILED *** ' + export err=4 + err_exit "${msg}" +fi - if [[ "${SENDDBN}" == "YES" ]]; then +if [[ "${SENDDBN}" == "YES" ]]; then echo " Alerting TAR file as ${COMOUT_WAVE_STATION}/${file_name}" - "${DBNROOT}/bin/dbn_alert MODEL" "${alertName}_WAVE_TAR" "${job}" \ - "${COMOUT_WAVE_STATION}/${file_name}" - fi + "${DBNROOT}/bin/dbn_alert MODEL" "${RUN^^}_WAVE_TAR" "${job}" \ + "${COMOUT_WAVE_STATION}/${file_name}" +fi # --------------------------------------------------------------------------- # # 4. Final clean up -cd "${DATA}" +cd "${DATA}" || exit 1 -if [[ ${KEEPDATA:-NO} == "NO" ]]; then - set -v - rm -rf ${STA_DIR}/${type} - set +v +if [[ "${KEEPDATA:-NO}" == "NO" ]]; then + set -v + rm -rf "${STA_DIR:?}/${type}" + set +v fi # End of ww3_tar.sh ----------------------------------------------------- #