diff --git a/jobs/JREGIONAL_MAKE_OROG b/jobs/JREGIONAL_MAKE_OROG deleted file mode 100755 index d3226b90c8..0000000000 --- a/jobs/JREGIONAL_MAKE_OROG +++ /dev/null @@ -1,130 +0,0 @@ -#!/usr/bin/env bash - -# -#----------------------------------------------------------------------- -# -# The J-Job that generates input NetCDF orography files for running the -# regional configuration of FV3 -# -# Run-time environment variables: -# -# GLOBAL_VAR_DEFNS_FP -# -# Experiment variables -# -# user: -# SCRIPTSdir -# USHdir -# -# task_make_orog: -# OROG_DIR -# -#----------------------------------------------------------------------- -# - -# -#----------------------------------------------------------------------- -# -# Source the variable definitions file and the bash utility functions. -# -#----------------------------------------------------------------------- -# -. $USHdir/source_util_funcs.sh -sections=( - user - nco - workflow - task_make_orog -) -for sect in ${sections[*]} ; do - source_yaml ${GLOBAL_VAR_DEFNS_FP} ${sect} -done -. $USHdir/job_preamble.sh -# -#----------------------------------------------------------------------- -# -# Save current shell options (in a global array). Then set new options -# for this script/function. -# -#----------------------------------------------------------------------- -# -{ save_shell_opts; . $USHdir/preamble.sh; } > /dev/null 2>&1 -# -#----------------------------------------------------------------------- -# -# Get the full path to the file in which this script/function is located -# (scrfunc_fp), the name of that file (scrfunc_fn), and the directory in -# which the file is located (scrfunc_dir). -# -#----------------------------------------------------------------------- -# -scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) -scrfunc_fn=$( basename "${scrfunc_fp}" ) -scrfunc_dir=$( dirname "${scrfunc_fp}" ) -# -#----------------------------------------------------------------------- -# -# Print message indicating entry into script. -# -#----------------------------------------------------------------------- -# -print_info_msg " -======================================================================== -Entering script: \"${scrfunc_fn}\" -In directory: \"${scrfunc_dir}\" - -This is the J-job script for the task that generates orography files. -========================================================================" -# -#----------------------------------------------------------------------- -# -# Call the ex-script for this J-job and pass to it the necessary varia- -# bles. -# -#----------------------------------------------------------------------- -# -${SCRIPTSdir}/exregional_make_orog.sh || \ -print_err_msg_exit "\ -Call to ex-script corresponding to J-job \"${scrfunc_fn}\" failed." -# -#----------------------------------------------------------------------- -# -# Create a flag file to make rocoto aware that the make_orog task has -# successfully completed (so that other tasks that depend on it can be -# launched). -# -# Although we can use the tag to make other tasks depend on -# the successful completion of make_orog, it turns out that the tag assumes that the task it specifies (in this case make_orog) -# runs for the same set of cycles as the one in which it appears as a -# dependency. Thus, if we use in a cycle-dependent task in -# the workflow to make it depend on the make_orog, then the workflow -# will wait for make_orog to run for each cycle for which that cycle-de- -# pendent task is defined before running the task. But since make_orog -# will not run for each cycle (except possibly for the very first one), -# the cycle-dependent task will not be able to run for any of the cycles -# except the first one. For this reason, we cannot use the -# tag to make other cycle-dependent tasks depend on make_orog and must -# instead use a flag file. -# -#----------------------------------------------------------------------- -# -touch "$OROG_DIR/make_orog_task_complete.txt" -# -#----------------------------------------------------------------------- -# -# Run job postamble. -# -#----------------------------------------------------------------------- -# -job_postamble -# -#----------------------------------------------------------------------- -# -# Restore the shell options saved at the beginning of this script/func- -# tion. -# -#----------------------------------------------------------------------- -# -{ restore_shell_opts; } > /dev/null 2>&1 - diff --git a/jobs/JREGIONAL_MAKE_SFC_CLIMO b/jobs/JREGIONAL_MAKE_SFC_CLIMO deleted file mode 100755 index f5b8cc9128..0000000000 --- a/jobs/JREGIONAL_MAKE_SFC_CLIMO +++ /dev/null @@ -1,156 +0,0 @@ -#!/usr/bin/env bash - -# -#----------------------------------------------------------------------- -# -# The J-job to run chgres_cube for preparing lateral boundary conditions -# for the FV3 forecast -# -# Run-time environment variables: -# -# GLOBAL_VAR_DEFNS_FP -# -# Experiment variables -# -# user: -# SCRIPTSdir -# USHdir -# -# workflow: -# PREEXISTING_DIR_METHOD -# -# task_make_sfc_climo: -# SFC_CLIMO_DIR -# -#----------------------------------------------------------------------- -# - -# -#----------------------------------------------------------------------- -# -# Source the variable definitions file and the bash utility functions. -# -#----------------------------------------------------------------------- -# -. $USHdir/source_util_funcs.sh -sections=( - user - nco - workflow - task_make_sfc_climo -) -for sect in ${sections[*]} ; do - source_yaml ${GLOBAL_VAR_DEFNS_FP} ${sect} -done -. $USHdir/job_preamble.sh -# -#----------------------------------------------------------------------- -# -# Save current shell options (in a global array). Then set new options -# for this script/function. -# -#----------------------------------------------------------------------- -# -{ save_shell_opts; . $USHdir/preamble.sh; } > /dev/null 2>&1 -# -#----------------------------------------------------------------------- -# -# Get the full path to the file in which this script/function is located -# (scrfunc_fp), the name of that file (scrfunc_fn), and the directory in -# which the file is located (scrfunc_dir). -# -#----------------------------------------------------------------------- -# -scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) -scrfunc_fn=$( basename "${scrfunc_fp}" ) -scrfunc_dir=$( dirname "${scrfunc_fp}" ) -# -#----------------------------------------------------------------------- -# -# Print message indicating entry into script. -# -#----------------------------------------------------------------------- -# -print_info_msg " -======================================================================== -Entering script: \"${scrfunc_fn}\" -In directory: \"${scrfunc_dir}\" - -This is the J-job script for the task that generates surface fields from -climatology. -========================================================================" -# -#----------------------------------------------------------------------- -# -# Create the output directory for the surface climatology files. If it -# already exists, deal with it as specified by PREEXISTING_DIR_METHOD. -# -#----------------------------------------------------------------------- -# -check_for_preexist_dir_file "${SFC_CLIMO_DIR}" "${PREEXISTING_DIR_METHOD}" -mkdir -p "${SFC_CLIMO_DIR}" -# -#----------------------------------------------------------------------- -# -# Create a work directory. If it already exists, delete it. -# -#----------------------------------------------------------------------- -# -DATA="${DATA:-${SFC_CLIMO_DIR}/tmp}" -if [ $RUN_ENVIR != "nco" ]; then - check_for_preexist_dir_file "$DATA" "delete" - mkdir $DATA -fi -# -#----------------------------------------------------------------------- -# -# Call the ex-script for this J-job and pass to it the necessary varia- -# bles. -# -#----------------------------------------------------------------------- -# -${SCRIPTSdir}/exregional_make_sfc_climo.sh || \ -print_err_msg_exit "\ -Call to ex-script corresponding to J-job \"${scrfunc_fn}\" failed." -# -#----------------------------------------------------------------------- -# -# Create a flag file to make rocoto aware that the make_sfc_climo task -# has successfully completed (so that other tasks that depend on it can -# be launched). -# -# Although we can use the tag to make other tasks depend on -# the successful completion of make_sfc_climo, it turns out that the -# tag assumes that the task it specifies (in this case make_- -# sfc_climo) runs for the same set of cycles as the one in which it ap- -# pears as a dependency. Thus, if we use in a cycle-dependent -# task in the workflow to make it depend on the make_sfc_climo, then the -# workflow will wait for make_sfc_climo to run for each cycle for which -# that cycle-dependent task is defined before running the task. But -# since make_sfc_climo will not run for each cycle (except possibly for -# the very first one), the cycle-dependent task will not be able to run -# for any of the cycles except the first one. For this reason, we can- -# not use the tag to make other cycle-dependent tasks depend -# on make_sfc_climo and must instead use a flag file. -# -#----------------------------------------------------------------------- -# -touch "$SFC_CLIMO_DIR/make_sfc_climo_task_complete.txt" -# -#----------------------------------------------------------------------- -# -# Run job postamble. -# -#----------------------------------------------------------------------- -# -job_postamble -# -#----------------------------------------------------------------------- -# -# Restore the shell options saved at the beginning of this script/func- -# tion. -# -#----------------------------------------------------------------------- -# -{ restore_shell_opts; } > /dev/null 2>&1 - diff --git a/parm/wflow/prep.yaml b/parm/wflow/prep.yaml index 41940f5c7e..afa1009a8b 100644 --- a/parm/wflow/prep.yaml +++ b/parm/wflow/prep.yaml @@ -29,7 +29,7 @@ task_make_grid: task_make_orog: <<: *default_task - command: !cycstr 'source &USHdir;/load_modules_wflow.sh hera ; &SCRIPTSdir;/make_orog.py + command: !cycstr 'source &USHdir;/load_modules_wflow.sh {{ user.MACHINE }} ; &SCRIPTSdir;/make_orog.py -c &GLOBAL_VAR_DEFNS_FP; --key-path task_make_orog' join: !cycstr '&LOGDIR;/{{ jobname }}_@Y@m@d@H&LOGEXT;' @@ -50,12 +50,19 @@ task_make_orog: text: '{{ task_make_grid.GRID_DIR }}/make_grid_task_complete.txt' task_make_sfc_climo: - <<: *default_task - command: '&LOAD_MODULES_RUN_TASK; "make_sfc_climo" "&JOBSdir;/JREGIONAL_MAKE_SFC_CLIMO"' - envars: - <<: *default_envars + account: '&ACCOUNT;' + attrs: + cycledefs: at_start + maxtries: '2' + command: 'source &USHdir;/load_modules_wflow.sh {{ user.MACHINE }}; &SCRIPTSdir;/make_sfc_climo.py + -c &GLOBAL_VAR_DEFNS_FP; + --key-path task_make_sfc_climo' join: !cycstr '&LOGDIR;/{{ jobname }}_@Y@m@d@H&LOGEXT;' - nnodes: 2 + nodes: "{{ task_make_sfc_climo.sfc_climo_gen.execution.batchargs.nodes }}:ppn={{ task_make_sfc_climo.sfc_climo_gen.execution.batchargs.tasks_per_node }}" + + partition: '{% if platform.get("PARTITION_DEFAULT") %}&PARTITION_DEFAULT;{% else %}None{% endif %}' + queue: '&QUEUE_DEFAULT;' + walltime: "{{ task_make_sfc_climo.sfc_climo_gen.execution.batchargs.walltime }}" dependency: and: or_make_grid: diff --git a/scripts/exregional_make_orog.sh b/scripts/exregional_make_orog.sh deleted file mode 100755 index 836ceb3ccc..0000000000 --- a/scripts/exregional_make_orog.sh +++ /dev/null @@ -1,624 +0,0 @@ -#!/usr/bin/env bash - -# -#----------------------------------------------------------------------- -# -# This ex-script is responsible for creating orography files for the FV3 -# forecast. -# -# The output of this script is placed in a directory defined by OROG_DIR -# -# More about the orog for the regional configuration of the FV3: -# -# a) Only the tile 7 orography file is created. -# -# b) This orography file contains a halo of the same width (NHW) -# as the grid file for tile 7 generated by the make_grid script -# -# c) Filtered versions of the orogoraphy files are created with the -# same width (NHW) as the unfiltered orography file and the grid -# file. FV3 requires two filtered orography files, one with no -# halo cells and one with 4 halo cells. -# -# This script does the following: -# -# - Create the raw orography files by running the orog executable. -# - Run the orog_gsl executable if any of several GSL-developed -# physics suites is chosen by the user. -# - Run the filter_topo executable on the raw orography files -# - Run the shave executable for the 0- and 4-cell halo orography -# files -# -# Run-time environment variables: -# -# DATA -# GLOBAL_VAR_DEFNS_FP -# REDIRECT_OUT_ERR -# -# Experiment variables -# -# user: -# EXECdir -# USHdir -# -# platform: -# FIXorg -# PRE_TASK_CMDS -# RUN_CMD_SERIAL -# -# workflow: -# CCPP_PHYS_SUITE -# CRES -# DOT_OR_USCORE -# FIXam -# FIXlam -# GRID_GEN_METHOD -# PREEXISTING_DIR_METHOD -# VERBOSE -# -# task_make_orog: -# KMP_AFFINITY_MAKE_OROG -# OMP_NUM_THREADS_MAKE_OROG -# OMP_STACKSIZE_MAKE_OROG -# OROG_DIR -# -# task_make_grid: -# GFDLgrid_NUM_CELLS -# GFDLgrid_STRETCH_FAC -# GFDLgrid_REFINE_RATIO -# -# constants: -# NH0 -# NH4 -# TILE_RGNL -# -# grid_params: -# NHW -# NX -# NY -# STRETCH_FAC -# -#----------------------------------------------------------------------- -# - -# -#----------------------------------------------------------------------- -# -# Source the variable definitions file and the bash utility functions. -# -#----------------------------------------------------------------------- -# -. $USHdir/source_util_funcs.sh -sections=( - user - nco - platform - workflow - constants - grid_params - task_make_grid - task_make_orog -) -for sect in ${sections[*]} ; do - source_yaml ${GLOBAL_VAR_DEFNS_FP} ${sect} -done - -# -#----------------------------------------------------------------------- -# -# Save current shell options (in a global array). Then set new options -# for this script/function. -# -#----------------------------------------------------------------------- -# -{ save_shell_opts; . $USHdir/preamble.sh; } > /dev/null 2>&1 -# -#----------------------------------------------------------------------- -# -# Get the full path to the file in which this script/function is located -# (scrfunc_fp), the name of that file (scrfunc_fn), and the directory in -# which the file is located (scrfunc_dir). -# -#----------------------------------------------------------------------- -# -scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) -scrfunc_fn=$( basename "${scrfunc_fp}" ) -scrfunc_dir=$( dirname "${scrfunc_fp}" ) - -print_info_msg " -======================================================================== -Entering script: \"${scrfunc_fn}\" -In directory: \"${scrfunc_dir}\" - -This is the ex-script for the task that generates orography files. -========================================================================" -# -#----------------------------------------------------------------------- -# -# Set OpenMP variables. The orog executable runs with OMP. -# -#----------------------------------------------------------------------- -# -export KMP_AFFINITY=${KMP_AFFINITY_MAKE_OROG} -export OMP_NUM_THREADS=${OMP_NUM_THREADS_MAKE_OROG} -export OMP_STACKSIZE=${OMP_STACKSIZE_MAKE_OROG} - -eval ${PRE_TASK_CMDS} - -if [ -z "${RUN_CMD_SERIAL:-}" ] ; then - print_err_msg_exit "\ - Run command was not set in machine file. \ - Please set RUN_CMD_SERIAL for your platform" -else - print_info_msg "$VERBOSE" " - All executables will be submitted with command \'${RUN_CMD_SERIAL}\'." -fi -# -#----------------------------------------------------------------------- -# -# Create the (cycle-independent) subdirectories under the experiment -# directory (EXPTDIR) that are needed by the various steps and substeps -# in this script. -# -#----------------------------------------------------------------------- -# -check_for_preexist_dir_file "${OROG_DIR}" "${PREEXISTING_DIR_METHOD}" -mkdir -p "${OROG_DIR}" - -raw_dir="${OROG_DIR}/raw_topo" -mkdir -p "${raw_dir}" - -filter_dir="${OROG_DIR}/filtered_topo" -mkdir -p "${filter_dir}" - -shave_dir="${OROG_DIR}/shave_tmp" -mkdir -p "${shave_dir}" -# -# -#----------------------------------------------------------------------- -# -# Preparatory steps before calling raw orography generation code. -# -#----------------------------------------------------------------------- -# -exec_fn="orog" -exec_fp="$EXECdir/${exec_fn}" -if [ ! -f "${exec_fp}" ]; then - print_err_msg_exit "\ -The executable (exec_fp) for generating the orography file does not exist: - exec_fp = \"${exec_fp}\" -Please ensure that you've built this executable." -fi - -DATA="${DATA:-${raw_dir}/tmp}" -mkdir -p "${DATA}" -cd "${DATA}" -# -# Copy topography and related data files from the system directory (FIXorg) -# to the temporary directory. -# -cp ${FIXorg}/thirty.second.antarctic.new.bin fort.15 -cp ${FIXorg}/landcover30.fixed . -cp ${FIXorg}/gmted2010.30sec.int fort.235 -# -#----------------------------------------------------------------------- -# -# Get the grid file info from the mosaic file -# -#----------------------------------------------------------------------- -# -mosaic_fn="${CRES}${DOT_OR_USCORE}mosaic.halo${NHW}.nc" -mosaic_fp="${FIXlam}/${mosaic_fn}" - -grid_fn=$( get_charvar_from_netcdf "${mosaic_fp}" "gridfiles" ) || print_err_msg_exit "\ - get_charvar_from_netcdf function failed." -grid_fp="${FIXlam}/${grid_fn}" -# -#----------------------------------------------------------------------- -# -# Set input parameters for the orog executable in a formatted text file. -# The executable takes its parameters via the command line. -# -# Note: lonb and latb are placeholders in this case since the program -# uses the ones obtained from the grid file. -# -#----------------------------------------------------------------------- -# -mtnres=1 -lonb=0 -latb=0 -jcap=0 -NR=0 -NF1=0 -NF2=0 -efac=0 -blat=0 - -input_redirect_fn="INPS" -orogfile="none" - -echo $mtnres $lonb $latb $jcap $NR $NF1 $NF2 $efac $blat > "${input_redirect_fn}" -# -# The following two inputs are read in as strings, so they must be quoted -# in the input file. -# -echo "\"${grid_fp}\"" >> "${input_redirect_fn}" -echo "\"$orogfile\"" >> "${input_redirect_fn}" -echo ".false." >> "${input_redirect_fn}" #MASK_ONLY -echo "none" >> "${input_redirect_fn}" #MERGE_FILE -cat "${input_redirect_fn}" -# -#----------------------------------------------------------------------- -# -# Call the executable to generate the raw orography file corresponding -# to tile 7 (the regional domain) only. -# -# The script moves the output file from its temporary directory to the -# OROG_DIR and names it: -# -# ${CRES}_raw_orog.tile7.halo${NHW}.nc -# -# Note that this file will include orography for a halo of width NHW -# cells around tile 7. -# -#----------------------------------------------------------------------- -# -print_info_msg "$VERBOSE" "\ -Starting orography file generation..." - -PREP_STEP -eval ${RUN_CMD_SERIAL} "${exec_fp}" < "${input_redirect_fn}" ${REDIRECT_OUT_ERR} || \ - print_err_msg_exit "\ -Call to executable (exec_fp) that generates the raw orography file returned -with nonzero exit code: - exec_fp = \"${exec_fp}\"" -POST_STEP - -# -# Change location to the original directory. -# -cd - -# -#----------------------------------------------------------------------- -# -# Move the raw orography file and rename it. -# -#----------------------------------------------------------------------- -# -raw_orog_fp_orig="${DATA}/out.oro.nc" -raw_orog_fn_prefix="${CRES}${DOT_OR_USCORE}raw_orog" -fn_suffix_with_halo="tile${TILE_RGNL}.halo${NHW}.nc" -raw_orog_fn="${raw_orog_fn_prefix}.${fn_suffix_with_halo}" -raw_orog_fp="${raw_dir}/${raw_orog_fn}" -mv "${raw_orog_fp_orig}" "${raw_orog_fp}" -# -#----------------------------------------------------------------------- -# -# Call the orog_gsl executable to generate the two orography statistics -# files (large- and small-scale) needed for the drag suite in certain -# GSL physics suites. -# -#----------------------------------------------------------------------- -# -suites=( "FV3_RAP" "FV3_HRRR" "FV3_GFS_v15_thompson_mynn_lam3km" "FV3_GFS_v17_p8" ) -if [[ ${suites[@]} =~ "${CCPP_PHYS_SUITE}" ]] ; then - DATA="${DATA:-${OROG_DIR}/temp_orog_data}" - mkdir -p ${DATA} - cd ${DATA} - mosaic_fn_gwd="${CRES}${DOT_OR_USCORE}mosaic.halo${NH4}.nc" - mosaic_fp_gwd="${FIXlam}/${mosaic_fn_gwd}" - grid_fn_gwd=$( get_charvar_from_netcdf "${mosaic_fp_gwd}" "gridfiles" ) || \ - print_err_msg_exit "get_charvar_from_netcdf function failed." - grid_fp_gwd="${FIXlam}/${grid_fn_gwd}" - ls_fn="geo_em.d01.lat-lon.2.5m.HGT_M.nc" - ss_fn="HGT.Beljaars_filtered.lat-lon.30s_res.nc" - create_symlink_to_file ${grid_fp_gwd} ${DATA}/${grid_fn_gwd} TRUE - create_symlink_to_file ${FIXam}/${ls_fn} ${DATA}/${ls_fn} TRUE - create_symlink_to_file ${FIXam}/${ss_fn} ${DATA}/${ss_fn} TRUE - - input_redirect_fn="grid_info.dat" - cat > "${input_redirect_fn}" < "${filter_dir}/input.nml" < ${ascii_fn} - -PREP_STEP -eval ${RUN_CMD_SERIAL} ${exec_fp} < ${ascii_fn} ${REDIRECT_OUT_ERR} || \ -print_err_msg_exit "\ -Call to executable (exec_fp) to generate a (filtered) orography file with -a ${NH0}-cell-wide halo from the orography file with a {NHW}-cell-wide halo -returned with nonzero exit code: - exec_fp = \"${exec_fp}\" -The config file (ascii_fn) used in this call is in directory shave_dir: - ascii_fn = \"${ascii_fn}\" - shave_dir = \"${shave_dir}\"" -POST_STEP -mv ${shaved_fp} ${OROG_DIR} -# -# Create an input config file for the shave executable to generate an -# orography file with a 4-cell-wide halo from the one with a wide halo. -# Then call the shave executable. Finally, move the resultant file to -# the OROG_DIR directory. -# -print_info_msg "$VERBOSE" " -\"Shaving\" filtered orography file with a ${NHW}-cell-wide halo to obtain -a filtered orography file with a ${NH4}-cell-wide halo..." - -ascii_fn="input.shave.orog.halo${NH4}" -shaved_fp="${shave_dir}/${CRES}${DOT_OR_USCORE}oro_data.tile${TILE_RGNL}.halo${NH4}.nc" -printf "%s %s %s %s %s\n" \ - $NX $NY ${NH4} \"${unshaved_fp}\" \"${shaved_fp}\" \ - > ${ascii_fn} - -PREP_STEP -eval ${RUN_CMD_SERIAL} ${exec_fp} < ${ascii_fn} ${REDIRECT_OUT_ERR} || \ -print_err_msg_exit "\ -Call to executable (exec_fp) to generate a (filtered) orography file with -a ${NH4}-cell-wide halo from the orography file with a {NHW}-cell-wide halo -returned with nonzero exit code: - exec_fp = \"${exec_fp}\" -The namelist file (ascii_fn) used in this call is in directory shave_dir: - ascii_fn = \"${ascii_fn}\" - shave_dir = \"${shave_dir}\"" -POST_STEP -mv "${shaved_fp}" "${OROG_DIR}" -# -# Change location to the original directory. -# -cd - -# -#----------------------------------------------------------------------- -# -# Add link in OROG_DIR directory to the orography file with a 4-cell-wide -# halo such that the link name does not contain the halo width. These links -# are needed by the make_sfc_climo task. -# -# NOTE: It would be nice to modify the sfc_climo_gen_code to read in -# files that have the halo size in their names. -# -#----------------------------------------------------------------------- -# -python3 $USHdir/link_fix.py \ - --path-to-defns ${GLOBAL_VAR_DEFNS_FP} \ - --file-group "orog" || \ -print_err_msg_exit "\ -Call to function to create links to orography files failed." - -print_info_msg " -======================================================================== -Orography files with various halo widths generated successfully!!! - -Exiting script: \"${scrfunc_fn}\" -In directory: \"${scrfunc_dir}\" -========================================================================" -# -#----------------------------------------------------------------------- -# -# Restore the shell options saved at the beginning of this script/func- -# tion. -# -#----------------------------------------------------------------------- -# -{ restore_shell_opts; } > /dev/null 2>&1 - - diff --git a/scripts/exregional_make_sfc_climo.sh b/scripts/exregional_make_sfc_climo.sh deleted file mode 100755 index f779250180..0000000000 --- a/scripts/exregional_make_sfc_climo.sh +++ /dev/null @@ -1,296 +0,0 @@ -#!/usr/bin/env bash - -# -#----------------------------------------------------------------------- -# -# This ex-script generates surface climatology files needed to run FV3 -# forecasts. -# -# The script runs the sfc_climo_gen UFS Utils program, and links the -# output to the SFC_CLIMO_GEN directory -# -# Run-time environment variables: -# -# DATA -# GLOBAL_VAR_DEFNS_FP -# REDIRECT_OUT_ERR -# -# Experiment variables -# -# user: -# EXECdir -# USHdir -# -# platform: -# FIXsfc -# PRE_TASK_CMDS -# RUN_CMD_UTILS -# -# workflow: -# CRES -# DOT_OR_USCORE -# FIXlam -# VERBOSE -# -# task_make_sfc_climo: -# KMP_AFFINITY_MAKE_SFC_CLIMO -# OMP_NUM_THREADS_MAKE_SFC_CLIMO -# OMP_STACKSIZE_MAKE_SFC_CLIMO -# SFC_CLIMO_DIR -# -# constants: -# GTYPE -# NH0 -# NH4 -# TILE_RGNL -# -#----------------------------------------------------------------------- -# - -# -#----------------------------------------------------------------------- -# -# Source the variable definitions file and the bash utility functions. -# -#----------------------------------------------------------------------- -# -. $USHdir/source_util_funcs.sh -sections=( - user - nco - platform - workflow - constants - task_make_sfc_climo -) -for sect in ${sections[*]} ; do - source_yaml ${GLOBAL_VAR_DEFNS_FP} ${sect} -done -# -#----------------------------------------------------------------------- -# -# Save current shell options (in a global array). Then set new options -# for this script/function. -# -#----------------------------------------------------------------------- -# -{ save_shell_opts; . $USHdir/preamble.sh; } > /dev/null 2>&1 -# -#----------------------------------------------------------------------- -# -# Get the full path to the file in which this script/function is located -# (scrfunc_fp), the name of that file (scrfunc_fn), and the directory in -# which the file is located (scrfunc_dir). -# -#----------------------------------------------------------------------- -# -scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) -scrfunc_fn=$( basename "${scrfunc_fp}" ) -scrfunc_dir=$( dirname "${scrfunc_fp}" ) -# -#----------------------------------------------------------------------- -# -# Print message indicating entry into script. -# -#----------------------------------------------------------------------- -# -print_info_msg " -======================================================================== -Entering script: \"${scrfunc_fn}\" -In directory: \"${scrfunc_dir}\" - -This is the ex-script for the task that generates surface fields from -climatology. -========================================================================" -# -#----------------------------------------------------------------------- -# -# Set OpenMP variables. -# -#----------------------------------------------------------------------- -# -export KMP_AFFINITY=${KMP_AFFINITY_MAKE_SFC_CLIMO} -export OMP_NUM_THREADS=${OMP_NUM_THREADS_MAKE_SFC_CLIMO} -export OMP_STACKSIZE=${OMP_STACKSIZE_MAKE_SFC_CLIMO} -# -#----------------------------------------------------------------------- -# -# Are these machine dependent?? -# -#----------------------------------------------------------------------- -# -ulimit -s unlimited -# -#----------------------------------------------------------------------- -# -# Change location to the temporary directory. -# -#----------------------------------------------------------------------- -# -cd $DATA -# -#----------------------------------------------------------------------- -# -# Create the namelist that the sfc_climo_gen code will read in. -# -# Question: Should this instead be created from a template file? -# -#----------------------------------------------------------------------- -# -cat << EOF > ./fort.41 -&config -input_facsf_file="${FIXsfc}/facsf.1.0.nc" -input_substrate_temperature_file="${FIXsfc}/substrate_temperature.2.6x1.5.nc" -input_maximum_snow_albedo_file="${FIXsfc}/maximum_snow_albedo.0.05.nc" -input_snowfree_albedo_file="${FIXsfc}/snowfree_albedo.4comp.0.05.nc" -input_slope_type_file="${FIXsfc}/slope_type.1.0.nc" -input_soil_type_file="${FIXsfc}/soil_type.statsgo.0.05.nc" -input_vegetation_type_file="${FIXsfc}/vegetation_type.igbp.0.05.nc" -input_vegetation_greenness_file="${FIXsfc}/vegetation_greenness.0.144.nc" -mosaic_file_mdl="${FIXlam}/${CRES}${DOT_OR_USCORE}mosaic.halo${NH4}.nc" -orog_dir_mdl="${FIXlam}" -orog_files_mdl="${CRES}${DOT_OR_USCORE}oro_data.tile${TILE_RGNL}.halo${NH4}.nc" -halo=${NH4} -maximum_snow_albedo_method="bilinear" -snowfree_albedo_method="bilinear" -vegetation_greenness_method="bilinear" -/ -EOF -# -#----------------------------------------------------------------------- -# -# Set the machine-dependent run command. -# -#----------------------------------------------------------------------- -# -eval ${PRE_TASK_CMDS} - -if [ -z "${RUN_CMD_UTILS:-}" ] ; then - print_err_msg_exit "\ - Run command was not set in machine file. \ - Please set RUN_CMD_UTILS for your platform" -else - print_info_msg "$VERBOSE" " - All executables will be submitted with command \'${RUN_CMD_UTILS}\'." -fi -# -#----------------------------------------------------------------------- -# -# Generate the surface climatology files. -# -#----------------------------------------------------------------------- -# -# Set the name and path to the executable and make sure that it exists. -# -exec_fn="sfc_climo_gen" -exec_fp="$EXECdir/${exec_fn}" -if [ ! -f "${exec_fp}" ]; then - print_err_msg_exit "\ -The executable (exec_fp) for generating the surface climatology files -does not exist: - exec_fp = \"${exec_fp}\" -Please ensure that you've built this executable." -fi - -PREP_STEP -eval ${RUN_CMD_UTILS} ${exec_fp} ${REDIRECT_OUT_ERR} || \ -print_err_msg_exit "\ -Call to executable (exec_fp) to generate surface climatology files returned -with nonzero exit code: - exec_fp = \"${exec_fp}\"" -POST_STEP -# -#----------------------------------------------------------------------- -# -# Move output files out of the temporary directory. -# -#----------------------------------------------------------------------- -# -case "$GTYPE" in - -# -# Consider, global, stetched, and nested grids. -# -"global" | "stretch" | "nested") -# -# Move all files ending with ".nc" to the SFC_CLIMO_DIR directory. -# In the process, rename them so that the file names start with the C- -# resolution (followed by an underscore). -# - for fn in *.nc; do - if [[ -f $fn ]]; then - mv $fn ${SFC_CLIMO_DIR}/${CRES}_${fn} - fi - done - ;; - -# -# Consider regional grids. -# -"regional") -# -# Move all files ending with ".halo.nc" (which are the files for a grid -# that includes the specified non-zero-width halo) to the WORKDIR_SFC_- -# CLIMO directory. In the process, rename them so that the file names -# start with the C-resolution (followed by a dot) and contain the (non- -# zero) halo width (in units of number of grid cells). -# - for fn in *.halo.nc; do - if [ -f $fn ]; then - bn="${fn%.halo.nc}" - mv $fn ${SFC_CLIMO_DIR}/${CRES}.${bn}.halo${NH4}.nc - fi - done -# -# Move all remaining files ending with ".nc" (which are the files for a -# grid that doesn't include a halo) to the SFC_CLIMO_DIR directory. -# In the process, rename them so that the file names start with the C- -# resolution (followed by a dot) and contain the string "halo0" to indi- -# cate that the grids in these files do not contain a halo. -# - for fn in *.nc; do - if [ -f $fn ]; then - bn="${fn%.nc}" - mv $fn ${SFC_CLIMO_DIR}/${CRES}.${bn}.halo${NH0}.nc - fi - done - ;; - -esac -# -#----------------------------------------------------------------------- -# -# Can these be moved to stage_static if this script is called before -# stage_static.sh???? -# These have been moved. Can delete the following after testing. -# -#----------------------------------------------------------------------- -# -python3 $USHdir/link_fix.py \ - --path-to-defns ${GLOBAL_VAR_DEFNS_FP} \ - --file-group "sfc_climo" || \ -print_err_msg_exit "\ -Call to function to create links to surface climatology files failed." -# -#----------------------------------------------------------------------- -# -# Print message indicating successful completion of script. -# -#----------------------------------------------------------------------- -# -print_info_msg " -======================================================================== -All surface climatology files generated successfully!!! - -Exiting script: \"${scrfunc_fn}\" -In directory: \"${scrfunc_dir}\" -========================================================================" -# -#----------------------------------------------------------------------- -# -# Restore the shell options saved at the beginning of this script/func- -# tion. -# -#----------------------------------------------------------------------- -# -{ restore_shell_opts; } > /dev/null 2>&1 diff --git a/scripts/make_orog.py b/scripts/make_orog.py index b386f291de..2b9849c051 100755 --- a/scripts/make_orog.py +++ b/scripts/make_orog.py @@ -10,13 +10,13 @@ from argparse import ArgumentParser from pathlib import Path +from uwtools.api.config import get_yaml_config from uwtools.api.driver import Driver from uwtools.api.filter_topo import FilterTopo from uwtools.api.logging import use_uwtools_logger from uwtools.api.orog import Orog from uwtools.api.orog_gsl import OrogGSL from uwtools.api.shave import Shave -from uwtools.api.config import get_yaml_config def link_files(dest_dir, files): @@ -71,7 +71,7 @@ def make_orog(config_file, key_path): logging.info(f"Will run make_orog in {task_rundir}") # The experiment config will have {{ CRES | env }} expressions in it that need to be - # dereferenced during driver initialization. + # dereferenced during driver initialization cres = expt_config["workflow"]["CRES"] os.environ["CRES"] = cres @@ -116,7 +116,7 @@ def make_orog(config_file, key_path): files=glob.glob(str(task_rundir / f"{cres}*.nc")), ) - # Mark the successful completion of the script on disk. + # Mark the successful completion of the script on disk Path(task_rundir / "make_orog_task_complete.txt").touch() diff --git a/scripts/make_sfc_climo.py b/scripts/make_sfc_climo.py new file mode 100755 index 0000000000..95b840d236 --- /dev/null +++ b/scripts/make_sfc_climo.py @@ -0,0 +1,118 @@ +#!/usr/bin/env python +""" +The run script for sfc_climo_gen +""" + +import glob +import os +import sys +from argparse import ArgumentParser +from pathlib import Path + +from uwtools.api.config import get_yaml_config +from uwtools.api.fs import link as uwlink +from uwtools.api.logging import use_uwtools_logger +from uwtools.api.sfc_climo_gen import SfcClimoGen + + +def _link_files(dest_dir, files, cres): + """ + Link a given list of files to the destination directory updating the file names. + """ + for fpath in files: + path = Path(fpath) + fn = Path(fpath).name + + if "halo" in fn: + fn = f"{cres}.{(fn.replace('halo', 'halo4'))}" + no_halo_fn = fn.replace("halo4.", "") + for link in (fn, no_halo_fn): + link = Path(link) + if (linkname := dest_dir / link.name).is_symlink(): + linkname.unlink() + linkname.symlink_to(path) + + else: + basename = path.stem + halo0_fn = f"{cres}.{basename}.halo0.nc" + tile1_fn = halo0_fn.replace("tile7.halo0", "tile1") + for link in (halo0_fn, tile1_fn): + link = Path(link) + if (linkname := dest_dir / link.name).is_symlink(): + linkname.unlink() + linkname.symlink_to(path) + +def parse_args(argv): + parser = ArgumentParser( + description="Script that runs sfc_climo_gen via uwtools API.", + ) + parser.add_argument( + "-c", + "--config-file", + metavar="PATH", + required=True, + help="Path to experiment config file.", + type=Path, + ) + parser.add_argument( + "--key-path", + help="Dot-separated path of keys leading through the config to the driver's YAML block.", + metavar="KEY[.KEY...]", + required=True, + type=lambda s: s.split("."), + ) + + return parser.parse_args(argv) + + +def make_sfc_climo(config_file, key_path): + """ + Run the sfc_climo_gen driver. + """ + expt_config = get_yaml_config(config_file) + + # The experiment config will have {{ CRES | env }} expressions in it that need to be + # dereferenced during driver initialization + cres = expt_config["workflow"]["CRES"] + os.environ["CRES"] = cres + expt_config.dereference( + context={ + **os.environ, + **expt_config, + } + ) + sfc_climo_gen_driver = SfcClimoGen( + config=config_file, + key_path=key_path, + ) + rundir = Path(sfc_climo_gen_driver.config["rundir"]) + print(f"Will run sfc_climo_gen in {rundir}") + sfc_climo_gen_driver.run() + + if not (rundir / "runscript.sfc_climo_gen.done").is_file(): + print("Error occurred running sfc_climo_gen. Please see component error logs.") + sys.exit(1) + + + # Destination of important files from this process + fix_lam_path = Path(expt_config["workflow"]["FIXlam"]) + # Link sfc_climo_gen output data to fix directory + _link_files( + dest_dir=fix_lam_path, + files=glob.glob(str(rundir / f"*.nc")), + cres=cres, + ) + + # Mark the successful completion of the script on disk + Path(rundir / "make_sfc_climo_task_complete.txt").touch() + + +if __name__ == "__main__": + + use_uwtools_logger() + + args = parse_args(sys.argv[1:]) + make_sfc_climo( + config_file=args.config_file, + key_path=args.key_path, + ) diff --git a/ush/config_defaults.yaml b/ush/config_defaults.yaml index 52b2b952bc..600c170a6c 100644 --- a/ush/config_defaults.yaml +++ b/ush/config_defaults.yaml @@ -1461,10 +1461,43 @@ task_make_orog: rundir: "{{ task_make_orog.rundir }}/shave4" filtered_output: "{{ task_make_orog.filter_topo.rundir }}/{{ task_make_orog.filter_topo.config.filtered_orog }}" task_make_sfc_climo: - KMP_AFFINITY_MAKE_SFC_CLIMO: "scatter" - OMP_NUM_THREADS_MAKE_SFC_CLIMO: 1 - OMP_STACKSIZE_MAKE_SFC_CLIMO: "1024m" SFC_CLIMO_DIR: '{{ workflow.EXPTDIR + "/sfc_climo" if rocoto.tasks.get("task_make_sfc_climo") else "" }}' + sfc_climo_gen: + execution: + batchargs: + export: NONE + nodes: 1 + tasks_per_node: 24 + stdout: "{{ user.HOMEdir }}/scripts" + walltime: 00:05:00 + envcmds: + - module load build_{{ user.MACHINE|lower() }}_{{ workflow.COMPILER }} + - module use {{ user.HOMEdir }}/modulefiles + executable: "{{ user.EXECdir }}/sfc_climo_gen" + mpicmd: '{{ platform.BATCH_RUN_CMD }}' + namelist: + update_values: + config: + halo: !int '{{ constants.NH4 }}' + input_facsf_file: "{{ platform.FIXsfc}}/facsf.1.0.nc" + input_maximum_snow_albedo_file: "{{ platform.FIXsfc }}/maximum_snow_albedo.0.05.nc" + input_slope_type_file: "{{ platform.FIXsfc }}/slope_type.1.0.nc" + input_snowfree_albedo_file: "{{ platform.FIXsfc }}/snowfree_albedo.4comp.0.05.nc" + input_soil_type_file: "{{ platform.FIXsfc }}/soil_type.statsgo.0.05.nc" + input_substrate_temperature_file: "{{ platform.FIXsfc }}/substrate_temperature.2.6x1.5.nc" + input_vegetation_greenness_file: "{{ platform.FIXsfc }}/vegetation_greenness.0.144.nc" + input_vegetation_type_file: "{{ platform.FIXsfc }}/vegetation_type.igbp.0.05.nc" + maximum_snow_albedo_method: "bilinear" + mosaic_file_mdl: "{{ workflow.FIXlam }}/{{ 'CRES' | env }}{{ workflow.DOT_OR_USCORE }}mosaic.halo{{ constants.NH4 }}.nc" + orog_dir_mdl: "{{ workflow.FIXlam }}" + orog_files_mdl: + - "{{ 'CRES' | env }}{{ workflow.DOT_OR_USCORE }}oro_data.tile{{ constants.TILE_RGNL }}.halo{{ constants.NH4 }}.nc" + snowfree_albedo_method: "bilinear" + vegetation_greenness_method: "bilinear" + rundir: '{{ workflow.EXPTDIR }}/sfc_climo' + platform: + account: "{{ user.ACCOUNT }}" + scheduler: "{{ platform.SCHED }}" #---------------------------- # EXTRN ICS config parameters