From a60d8e5e51a643e7448f80fea1b94e8cfb94db74 Mon Sep 17 00:00:00 2001 From: Marcos Longo Date: Fri, 23 Jan 2026 14:49:53 -0300 Subject: [PATCH 01/15] Multiple edits to the CD-CT scripts, mostly minor. 1. All bash scripts in scripts_CD-CT/scripts now use dash-based flags to specify the settings. For example, when the previous configuration for script 3.run_model.bash used to be: - Original:: ./3.run_model.bash GFS 1024002 2024010100 48 - Proposed: ./3.run_model.bash -e GFS -r 1024002 -i 2024010100 -f 48 [...] The main advantage of the proposed is that it is more transparent, and also does not require any specific order for the arguments. 2. Multiple settings that were hardcoded across multiple scripts are now arguments: -d OUTPUT_DIAG_INTERVAL: this specifies how frequently output variables should be generated. -i INPUT_PATH: if provided, this replaces the default input data path with specific paths in setenv.bash. This can be useful when testing new datasets. -l NLEV: the number of vertical levels -v VARTABLE: if provided, the suffix for specific variable tables (e.g., OPER, GFS) -z: this deletes all paths containing compiled code and output paths (sources, execs, datain, dataout and run.*) 3. Script 0.run_all.bash was rewritten such that all settings can be specified by editing the beginning of the script (as it used to be), or through the dash-based flags. This is the only script that has default settings. In addition, a new flag step (-s [0-4]) can be used to specify which step to run. Options are 1-4 for the numbered scripts, and 0 to run all steps. This change eliminates the need for commenting/uncommenting steps. Ultimately, the idea is for most users to call 0.run_all.bash only and use the step argument to control the steps, and let 0.run_all.bash parse arguments to the other numbered scripts. 4. Script 2.pre_processing.bash now accepts an optionial flag for overwriting the static file (-o). If this flag is provided, the step will generate the static file again even if the file already exists. This option is relevant for when testing MONAN developments that change the contents of the static file (e.g., soil colour maps). 5. All scripts were revised so all the standard resolutions (10, 15, 24, 120 km) were consistent and supported in all steps. In addition, the number of grid cells when reprojecting MONAN's output to regular longitude/latitude grids was slightly revised in scripts 4.run_post.bash and make_template.bash. The original calculation assumed 1 degree ~ 100 km, which makes the reprojected grid a bit coarser than it needs to be. The new calculation uses the Earth's total surface area and the number of grid cells as follows: - delta = sqrt ( 4 * pi * (180 /pi)^2 / NumberOfGridCells ) - PointsPerDegree = round (1/Delta) 6. A few minor additional bug fixes and edits for clarity. --- scripts/0.run_all.bash | 376 ++++++++++++++++++++++++++++---- scripts/1.install_monan.bash | 120 ++++++++--- scripts/2.pre_processing.bash | 146 +++++++++---- scripts/3.run_model.bash | 271 ++++++++++++++++------- scripts/4.run_post.bash | 389 ++++++++++++++++++++++++---------- scripts/make_degrib.bash | 154 +++++++++----- scripts/make_initatmos.bash | 160 +++++++++----- scripts/make_static.bash | 160 +++++++++----- scripts/make_template.bash | 227 +++++++++++++++----- scripts/run_past2now.bash | 236 +++++++++++++++++---- scripts/setenv.bash | 87 +++++--- 11 files changed, 1738 insertions(+), 588 deletions(-) diff --git a/scripts/0.run_all.bash b/scripts/0.run_all.bash index 4fa50e4..1a5bca1 100755 --- a/scripts/0.run_all.bash +++ b/scripts/0.run_all.bash @@ -1,32 +1,174 @@ #!/bin/bash -#if [ $# -ne 5 ] -#then -# echo "" -# echo "Instructions: execute the command below" -# echo "" -# echo "${0} GitHubUserRepo EXP_NAME RESOLUTION LABELI FCST" -# echo "" -# echo "GitHubUserRepo :: GitHub link for your personal fork, eg: https://github.com/MYUSER/MONAN-Model.git" -# echo "EXP_NAME :: Forcing: GFS" -# echo "RESOLUTION :: number of points in resolution model grid, e.g: 1024002 (24 km)" -# echo "LABELI :: Initial date YYYYMMDDHH, e.g.: 2024010100" -# echo "FCST :: Forecast hours, e.g.: 24 or 36, etc." -# echo "" -# echo "24 hour forcast example:" -# echo "${0} https://github.com/MYUSER/MONAN-Model.git GFS 1024002 2024010100 24" -# echo "" -# exit -#fi - -# Set environment variables exports: -echo "" -echo -e "\033[1;32m==>\033[0m Moduling environment for MONAN model...\n" + + +#--- Function that shows usage. +function show_usage() { + echo " Usage: " + echo "" + echo " ${0} [-o] [-z] [-bc TAG_CONVERT_MPAS] [ -bm TAG_MONAN ] [-d OUTPUT_DIAG_INT] \\" + echo " [-e EXP ] [-f FCST] [-gc GIT_CONVERT_MPAS] [-gm GIT_MONAN ] [-i INPUT_PATH] \\" + echo " [-l NLEV] [-r RES] [-s STEP] [-t YYYYMMDDHH] [-v VARTABLE]" + echo "" + echo " List of optional flags: " + echo "" + echo " -bc TAG_CONVERT -- branch or tag name of the MONAN repository. For example:" + echo " \"develop\". This is used only by step 1." + echo " -bm TAG_MONAN -- branch or tag name of the MONAN repository. For example:" + echo " \"develop\". This is used only by step 1." + echo " -d OUTPUT_DIAG_INT -- Output interval for diagnostic. The format must be" + echo " \"HH:MM:SS\". This is used by steps 3 and 4." + echo " -e EXP -- Meteorological drivers. For example, GFS" + echo " -f FCST -- Simulation length in hours, e.g., 24 or 48." + echo " -gc GIT_CONVERT -- GitHub handle for MONAN. For example:" + echo " https://github.com/monanadmin/MONAN-Model.git" + echo " This is used only by step 1." + echo " -gm GIT_MONAN -- GitHub handle for MONAN. For example:" + echo " https://github.com/monanadmin/MONAN-Model.git" + echo " This is used only by step 1." + echo " -i INPUT_PATH -- Path containing input data for MONAN. If left empty, the" + echo " default path defined in setenv.bash will be used" + echo " -l NLEV -- Number of vertical levels for the output. This is used" + echo " by steps 3 and 4." + echo " -o -- Overwrite static files. This is used only by step 2." + echo " -r RES -- grid resolution. Supported options are:" + echo " 65536002 (~ 3 km)" + echo " 5898242 (~ 10 km)" + echo " 2621442 (~ 15 km)" + echo " 1024002 (~ 24 km)" + echo " 655362 (~ 30 km)" + echo " 163842 (~ 60 km)" + echo " 40962 (~ 120 km)" + echo " -s STEP -- Step to run. Options are:" + echo " 1 - Compile MONAN executables." + echo " 2 - Run pre-processing." + echo " 3 - Run atmospheric model." + echo " 4 - Run post-processing." + echo " 0 - Run all steps 1-4." + echo " -t YYYYMMDDHH -- Initial time. For example if 22 Sept 2025 00 UTC, the" + echo " argument should be 2025092200. This is used by steps" + echo " 2, 3 and 4." + echo " -v VARTABLE -- Suffix for defining which version of the" + echo " stream_list_atmosphere.diagnostics template to use." + echo " The default is to not use any suffix. This is used only" + echo " by steps 3 and 4." + echo " -z -- This will remove all files generated by all scripts and" + echo " reset the directory to the original state, except for" + echo " directory \"scripts\"." + echo "" + echo " All settings can be defined directly in the script." + echo "" +} +#---~--- + + +#--- Set environment variables exports: . setenv.bash +#---~--- + + + + +#--- Default input variables: +STEP=1 +OVERWRITE="" +github_link_MONAN="https://github.com/monanadmin/MONAN-Model.git" +tag_or_branch_name_MONAN="release/1.4.3-rc" +github_link_CONVERT_MPAS="https://github.com/monanadmin/convert_mpas.git" +tag_or_branch_name_CONVERT_MPAS="release/1.2.0" +EXP="GFS" +INPUT_PATH="" +RES=1024002 +YYYYMMDDHHi=2026012000 +FCST=24 +NLEV=55 +OUTPUT_DIAG_INTERVAL="03:00:00" +VARTABLE="" +ZERO_STATE=false +#---~--- + + +#--- Parse arguments. +while [[ ${#} > 0 ]] +do + key="${1}" + case ${key} in + -bc) + tag_or_branch_name_CONVERT_MPAS="${2}" + shift 2 # past flag and argument + ;; + -bm) + tag_or_branch_name_MONAN="${2}" + shift 2 # past flag and argument + ;; + -d) + OUTPUT_DIAG_INTERVAL="${2}" + shift 2 # Past flag and argument + ;; + -e) + EXP="${2}" + shift 2 # past flag and argument + ;; + -f) + FCST="${2}" + shift 2 # past flag and argument + ;; + -gc) + github_link_CONVERT_MPAS="${2}" + shift 2 # past flag and argument + ;; + -gm) + github_link_MONAN="${2}" + shift 2 # past flag and argument + ;; + -i) + INPUT_PATH="${2}" + shift 2 # Past flag and argument + ;; + -l) + NLEV="${2}" + shift 2 # Past flag and argument + ;; + -o) + OVERWRITE="-o" + shift 1 # past flag + ;; + -r) + RES="${2}" + shift 2 # past flag and argument + ;; + -s) + STEP="${2}" + shift 2 # past flag and argument + ;; + -t) + YYYYMMDDHHi="${2}" + shift 2 # past flag and argument + ;; + -v) + VFIRST=$(echo ${2} | cut -c 1-1) + case "${VFIRST}" in + .) VARTABLE="${2}" ;; + *) VARTABLE=".${2}" ;; + esac + shift 2 # past flag and argument + ;; + -z) + ZERO_STATE=true + shift 1 # past flag + ;; + *) + echo "Unknown key-value argument pair." + show_usage + exit 2 + ;; + esac +done +#---~--- -# Standart directories variables:--------------------------------------- +#--- Set and create standard directories DIRHOMES=${DIR_SCRIPTS}/scripts_CD-CT; mkdir -p ${DIRHOMES} DIRHOMED=${DIR_DADOS}/scripts_CD-CT; mkdir -p ${DIRHOMED} SCRIPTS=${DIRHOMES}/scripts; mkdir -p ${SCRIPTS} @@ -34,31 +176,175 @@ DATAIN=${DIRHOMED}/datain; mkdir -p ${DATAIN} DATAOUT=${DIRHOMED}/dataout; mkdir -p ${DATAOUT} SOURCES=${DIRHOMES}/sources; mkdir -p ${SOURCES} EXECS=${DIRHOMED}/execs; mkdir -p ${EXECS} -#---------------------------------------------------------------------- +#---~--- -# Input variables:----------------------------------------------------- -github_link="https://github.com/monanadmin/MONAN-Model.git" -monan_branch=1.4.3-rc -convertmpas_branch=1.2.0 -EXP=GFS -RES=1024002 #Options: 40962=120km;163842=60km;655362=30Km;1024002=24km;2621442=15Km;5898242=10Km -YYYYMMDDHHi=2026012000 -FCST=24 -#---------------------------------------------------------------------- -# STEP 1: Installing and compiling the A-MONAN model and utility programs: -time ${SCRIPTS}/1.install_monan.bash ${github_link} ${monan_branch} ${convertmpas_branch} -#exit -# STEP 2: Executing the pre-processing fase. Preparing all CI/CC files needed: -time ${SCRIPTS}/2.pre_processing.bash ${EXP} ${RES} ${YYYYMMDDHHi} ${FCST} -#exit +#---~--- +# If the user has set -z, we ask for confirmation before all work is deleted... +#---~--- +if ${ZERO_STATE} +then + echo -e "" + echo -e "${ORANGE}!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!${NC}" + echo -e "${ORANGE}!!! WARNING !!! WARNING !!! WARNING !!! WARNING !!!${NC}" + echo -e "${ORANGE}!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!${NC}" + echo -e "${ORANGE}==>${NC} This script is about to reset this working case." + read -p " Are you sure about this? [y|N] " proceed + proceed=$(echo ${proceed:-N} | tr [:upper:] [:lower:]) + case "${proceed}" in + y|yes) + #---~--- + # Give one last chance to avoid accidental file deletion. + #---~--- + echo -e "" + echo -e "" + echo -e "${ORANGE}==>${NC} Alright, but mind that this cannot be undone." + echo -e "${ORANGE}==>${NC} I am giving you a few seconds to cancel this script" + echo -e " in case you change your mind. Hit Ctrl+C before the countdown ends." + echo -e "" + echo -e "" + count=11 + while [[ ${count} -gt 1 ]] + do + let count=${count}-1 + echo -e "${ORANGE}==>${NC} File deletion will begin in ${count} seconds." + sleep 1 + done + /bin/rm -frv ${DATAIN} + /bin/rm -frv ${DATAOUT} + /bin/rm -frv ${SOURCES} + /bin/rm -frv ${EXECS} + /bin/rm -frv ${DIR_SCRIPTS}/run.?????????? + ;; + *) + #--- Keep files. + echo -e "" + echo -e "${GREEN}==>${NC} Keeping all files. To run MONAN, call this script again" + echo -e " without the \"-z\" option." + #---~--- + ;; + esac + + #---~--- + # We do not run the scripts when -z is set. + #---~--- + exit 0 + #---~--- +fi +#---~--- + + +#--- If INPUT_PATH is provided, replace the path in setenv.bash +if [[ "${INPUT_PATH}" != "" ]] && [[ -d "${INPUT_PATH}" ]] +then + sed -i.bck "s,^export DIRDADOS=.*,export DIRDADOS=${INPUT_PATH},g" ${SCRIPTS}/setenv.bash + /bin/rm -f ${SCRIPTS}/setenv.bash.bck +fi +#---~--- + + +#---~--- +# Make sure the grid resolution settings are valid. +#---~--- +case "${RES}" in +65536002) + echo -e "${GREEN}==>${NC} Grid resolution ${RES} (~ 3 km).\n" + ;; +5898242) + echo -e "${GREEN}==>${NC} Grid resolution ${RES} (~ 10 km).\n" + ;; +2621442) + echo -e "${GREEN}==>${NC} Grid resolution ${RES} (~ 15 km).\n" + ;; +1024002) + echo -e "${GREEN}==>${NC} Grid resolution ${RES} (~ 24 km).\n" + ;; +655362) + echo -e "${GREEN}==>${NC} Grid resolution ${RES} (~ 30 km).\n" + ;; +163842) + echo -e "${GREEN}==>${NC} Grid resolution ${RES} (~ 60 km).\n" + ;; +40962) + echo -e "${GREEN}==>${NC} Grid resolution ${RES} (~ 120 km).\n" + ;; +*) + echo -e "${ORANGE}****** WARNING ******${NC} \n" + echo -e "${ORANGE}==>${NC} Provided grid resolution (${RES}) is not recognised.\n" + echo -e "${ORANGE}==>${NC} We cannot guarantee that MONAN will run fine.\n" + ;; +esac +#---~--- + + +#--- Make sure VARTABLE has the leading "-v" if not empty. +if [[ "${VARTABLE}" == "" ]] +then + dv_VARTABLE="" +else + dv_VARTABLE="-v ${VARTABLE}" +fi +#---~--- + + +#---~--- +# Select step. +#---~--- +case ${STEP} in +0) + #---~--- + # Call the script itself four times, passing all the configuration. + #---~--- + step_now=0 + while [[ ${step_now} -lt 4 ]] + do + #--- Update step + let step_now=${step_now}+1 + #---~--- -# STEP 3: Executing the Model run: -time ${SCRIPTS}/3.run_model.bash ${EXP} ${RES} ${YYYYMMDDHHi} ${FCST} -#exit -# STEP 4: Executing the Post of Model run: -time ${SCRIPTS}/4.run_post.bash ${EXP} ${RES} ${YYYYMMDDHHi} ${FCST} -#exit + #--- Run step + time ${0} ${OVERWRITE} ${dv_VARTABLE} -bc ${tag_or_branch_name_CONVERT_MPAS} \ + -bm ${tag_or_branch_name_MONAN} -d ${OUTPUT_DIAG_INTERVAL} -e ${EXP} -f ${FCST} \ + -gc ${github_link_CONVERT_MPAS} -gm ${github_link_MONAN} -l ${NLEV} -r ${RES} \ + -s ${step_now} -t ${YYYYMMDDHHi} + #---~--- + done + #---~--- + ;; +1) + #---~--- + # STEP 1: Install and compile MONAN and its utility programs. + #---~--- + time 1.install_monan.bash -bc ${tag_or_branch_name_CONVERT_MPAS} \ + -bm ${tag_or_branch_name_MONAN} -gc ${github_link_CONVERT_MPAS} \ + -gm ${github_link_MONAN} + #---~--- + ;; +2) + #---~--- + # STEP 2: Run the pre-processing step, and make initial/boundary conditions if needed. + #---~--- + time 2.pre_processing.bash ${OVERWRITE} -e ${EXP} -f ${FCST} -r ${RES} -t ${YYYYMMDDHHi} + #---~--- + ;; +3) + #---~--- + # STEP 3: Run the model. + #---~--- + time 3.run_model.bash ${dv_VARTABLE} -d ${OUTPUT_DIAG_INTERVAL} -e ${EXP} -f ${FCST} \ + -l ${NLEV} -r ${RES} -t ${YYYYMMDDHHi} + #---~--- + ;; +4) + #---~--- + # STEP 4: Run the post-processing step. + #---~--- + time 4.run_post.bash ${dv_VARTABLE} -d ${OUTPUT_DIAG_INTERVAL} -e ${EXP} -f ${FCST} \ + -l ${NLEV} -r ${RES} -t ${YYYYMMDDHHi} + #---~--- + ;; +esac +#---~--- diff --git a/scripts/1.install_monan.bash b/scripts/1.install_monan.bash index a797ca1..613b556 100755 --- a/scripts/1.install_monan.bash +++ b/scripts/1.install_monan.bash @@ -17,21 +17,41 @@ umask 022 # #-----------------------------------------------------------------------------# -#Fixed parameters ------------------------------------------------------------# -github_link_CONVERT_MPAS="https://github.com/monanadmin/convert_mpas.git" -#-----------------------------------------------------------------------------# + +#--- Function that shows usage. +function show_usage() { + echo " Usage: " + echo "" + echo " ${0} -bc TAG_CONVERT_MPAS -bm TAG_MONAN -gm GIT_MONAN -gc GIT_CONVERT_MPAS" + echo "" + echo " List of **required** flags: " + echo "" + echo " -bc TAG_CONVERT -- branch or tag name of the MONAN repository. For example:" + echo " \"develop\"." + echo " -bm TAG_MONAN -- branch or tag name of the MONAN repository. For example:" + echo " \"develop\"." + echo " -gc GIT_CONVERT -- GitHub handle for MONAN. For example:" + echo " https://github.com/monanadmin/MONAN-Model.git" + echo " -gm GIT_MONAN -- GitHub handle for MONAN. For example:" + echo " https://github.com/monanadmin/MONAN-Model.git" + echo "" +} +#---~--- + + + #Functions -------------------------------------------------------------------# function checkout_system() { local source_dir=$1 local github_link=$2 local tag_or_branch_name=$3 - if [ -d "${source_dir}" ]; then + if [[ -d "${source_dir}" ]]; then echo -e "${GREEN}==>${NC} Source dir already exists, updating it ...\n" else echo -e "${GREEN}==>${NC} Cloning your fork repository...\n" git clone ${github_link} ${source_dir} - if [ ! -d "${source_dir}" ]; then + if [[ ! -d "${source_dir}" ]]; then echo -e "${RED}==>${NC} An error occurred while cloning your fork. Possible causes: wrong URL, user or password.\n" exit -1 fi @@ -51,30 +71,74 @@ function checkout_system() { #-----------------------------------------------------------------------------# -if [ $# -lt 1 ] +#---~--- +# Retrieve configuration. +#---~--- +#--- Default settings (all empty) +github_link_MONAN="" +tag_or_branch_name_MONAN="" +github_link_CONVERT_MPAS="" +tag_or_branch_name_CONVERT_MPAS="" +#---~--- + + +#---~--- +# Parse arguments +#---~--- +while [[ ${#} > 0 ]] +do + key="${1}" + case ${key} in + -bc) + tag_or_branch_name_CONVERT_MPAS="${2}" + shift 2 # past flag and argument + ;; + -bm) + tag_or_branch_name_MONAN="${2}" + shift 2 # past flag and argument + ;; + -gc) + github_link_CONVERT_MPAS="${2}" + shift 2 # past flag and argument + ;; + -gm) + github_link_MONAN="${2}" + shift 2 # past flag and argument + ;; + *) + echo "Unknown key-value argument pair." + show_usage + exit 2 + ;; + esac +done +#---~--- + +#---~--- +# Stop if any variable remains unset +#---~--- +if [[ "${tag_or_branch_name_CONVERT_MPAS}" == "" ]] || + [[ "${tag_or_branch_name_MONAN}" == "" ]] || + [[ "${github_link_CONVERT_MPAS}" == "" ]] || + [[ "${github_link_MONAN}" == "" ]] then - echo "" - echo "Instructions: execute the command below" - echo "" - echo "${0} [G] [M] [C]" - echo "" - echo "G :: MONAN GitHub link of your personal fork, eg: https://github.com/MYUSER/MONAN-Model.git" - echo "M :: MONAN tag or branch name of your personal fork. (will be used 'develop' if not informed)" - echo "C :: Convert_MPAS tag from ${github_link_CONVERT_MPAS} (will be used 'develop' if not informed)" - echo "" - exit + echo " This script requires arguments to be set through flags." + show_usage + exit 2 fi +#---~--- -# Set environment variables exports: -echo "" -echo -e "\033[1;32m==>\033[0m Moduling environment for MONAN model...\n" +#--- Set environment variables exports: . setenv.bash +#---~--- + echo "" echo "---- Installing the Model ----" echo "" -# Standart directories variables:--------------------------------------- + +#--- Set and create standard directories DIRHOMES=${DIR_SCRIPTS}/scripts_CD-CT; mkdir -p ${DIRHOMES} DIRHOMED=${DIR_DADOS}/scripts_CD-CT; mkdir -p ${DIRHOMED} SCRIPTS=${DIRHOMES}/scripts; mkdir -p ${SCRIPTS} @@ -86,13 +150,9 @@ EXECS=${DIRHOMED}/execs; mkdir -p ${EXECS} # Input variables:----------------------------------------------------- -github_link_MONAN=${1}; #github_link=https://github.com/monanadmin/MONAN-Model.git -tag_or_branch_name_MONAN=${2} -tag_or_branch_name_MONAN=${tag_or_branch_name_MONAN:="1.4.3-rc"} +tag_or_branch_name_MONAN=${tag_or_branch_name_MONAN:="release/1.4.3-rc"} +tag_or_branch_name_CONVERT_MPAS=${tag_or_branch_name_CONVERT_MPAS:="release/1.2.0"} echo "MONAN branch name in use: ${tag_or_branch_name_MONAN}" - -tag_or_branch_name_CONVERT_MPAS=${3} -tag_or_branch_name_CONVERT_MPAS=${tag_or_branch_name_CONVERT_MPAS:="1.2.0"} echo "convert_mpas branch name in use: ${tag_or_branch_name_CONVERT_MPAS}" #---------------------------------------------------------------------- @@ -244,7 +304,7 @@ mv ${MONANDIR}/init_atmosphere_model ${EXECS} make clean CORE=init_atmosphere -if [ -s "${EXECS}/init_atmosphere_model" ] && [ -e "${EXECS}/atmosphere_model" ]; then +if [[ -s "${EXECS}/init_atmosphere_model" ]] && [[ -e "${EXECS}/atmosphere_model" ]]; then echo "" echo -e "${GREEN}==>${NC} Files init_atmosphere_model and atmosphere_model generated Successfully in ${EXECS} !" echo @@ -261,14 +321,14 @@ echo -e "${GREEN}==>${NC} Installing init_atmosphere_model and atmosphere_model echo "" . ${MONANDIR}/make-all.sh -if [ "$HOSTNAME" == "ian" ]; then +if [[ "$HOSTNAME" == "ian" ]]; then # echo "hostname=$HOSTNAME" export PATH=$NETCDF/bin:$PATH fi # install convert_mpas echo "" -echo -e "${GREEN}==>${NC} Moduling environment for convert_mpas...\n" +echo -e "${GREEN}==>${NC} Loading modules needed by convert_mpas...\n" cd ${CONVERT_MPAS_DIR} make clean @@ -279,7 +339,7 @@ mv ${CONVERT_MPAS_DIR}/convert_mpas ${EXECS}/ cp ${CONVERT_MPAS_DIR}/VERSION.txt ${EXECS}/CONVMPAS-VERSION.txt -if [ -s "${EXECS}/convert_mpas" ] ; then +if [[ -s "${EXECS}/convert_mpas" ]] ; then echo "" echo -e "${GREEN}==>${NC} File convert_mpas generated Sucessfully in ${CONVERT_MPAS_DIR} and copied to ${EXECS} !" echo diff --git a/scripts/2.pre_processing.bash b/scripts/2.pre_processing.bash index baba5e6..989d8e7 100755 --- a/scripts/2.pre_processing.bash +++ b/scripts/2.pre_processing.bash @@ -18,33 +18,97 @@ umask 022 # #-----------------------------------------------------------------------------# -if [ $# -ne 4 -a $# -ne 1 ] -then + + +#--- Function that shows usage. +function show_usage() { + echo " Usage: " + echo "" + echo " ${0} [-o] [-e EXP ] [-f FCST] [-r RES] [-t YYYYMMDDHH]" echo "" - echo "Instructions: execute the command below" + echo " List of optional flags: " echo "" - echo "${0} EXP_NAME/OP RESOLUTION LABELI FCST" + echo " -o -- Overwrite static files." echo "" - echo "EXP_NAME :: Forcing: GFS" - echo " :: Others options to be added later..." - echo "RESOLUTION :: number of points in resolution model grid, e.g: 1024002 (24 km)" - echo " 40962 (120 km)" - echo "LABELI :: Initial date YYYYMMDDHH, e.g.: 2024010100" - echo "FCST :: Forecast hours, e.g.: 24 or 36, etc." + echo " List of **required** flags when -c is not set: " echo "" - echo "24 hour forecast example for 24km:" - echo "${0} GFS 1024002 2024010100 24" - echo "48 hour forecast example for 120km:" - echo "${0} GFS 40962 2024010100 48" + echo " -e EXP -- meteorological drivers. For example, GFS" + echo " -f FCST -- Simulation length in hours, e.g., 24 or 48." + echo " -r RES -- grid resolution. Options are:" + echo " 5898242 (~ 10 km)" + echo " 2621442 (~ 15 km)" + echo " 1024002 (~ 24 km)" + echo " 40962 (~ 120 km)" + echo " -t YYYYMMDDHH -- Initial time. For example if 22 Sept 2025 00 UTC, set it to:" + echo " 2025092200" echo "" +} +#---~--- - exit -fi -# Set environment variables exports: -echo "" -echo -e "\033[1;32m==>\033[0m Moduling environment for MONAN model...\n" +#--- Set environment variables exports: . setenv.bash +#---~--- + + + + +#--- Default input variables: +OVERWRITE=true +EXP="" +RES="" +YYYYMMDDHHi="" +FCST="" +#---~--- + + +#--- Parse arguments. +while [[ ${#} > 0 ]] +do + key="${1}" + case ${key} in + -e) + EXP="${2}" + shift 2 # past flag and argument + ;; + -f) + FCST="${2}" + shift 2 # past flag and argument + ;; + -o) + OVERWRITE=true + shift 1 # past flag + ;; + -r) + RES="${2}" + shift 2 # past flag and argument + ;; + -t) + YYYYMMDDHHi="${2}" + shift 2 # past flag and argument + ;; + *) + echo "Unknown key-value argument pair." + show_usage + exit 2 + ;; + esac +done +#---~--- + + + +#---~--- +# Make sure all settings were provided. +#---~--- +if [[ "${EXP}" == "" ]] || [[ "${RES}" == "" ]] || + [[ "${YYYYMMDDHHi}" == "" ]] || [[ "${FCST}" == "" ]] +then + echo " This script requires some arguments to be set through flags." + show_usage + exit 2 +fi +#---~--- echo "" @@ -52,7 +116,7 @@ echo "---- Pre Processing ----" echo "" -# Standart directories variables:--------------------------------------- +#--- Set and create standard directories DIRHOMES=${DIR_SCRIPTS}/scripts_CD-CT; mkdir -p ${DIRHOMES} DIRHOMED=${DIR_DADOS}/scripts_CD-CT; mkdir -p ${DIRHOMED} SCRIPTS=${DIRHOMES}/scripts; mkdir -p ${SCRIPTS} @@ -60,15 +124,7 @@ DATAIN=${DIRHOMED}/datain; mkdir -p ${DATAIN} DATAOUT=${DIRHOMED}/dataout; mkdir -p ${DATAOUT} SOURCES=${DIRHOMES}/sources; mkdir -p ${SOURCES} EXECS=${DIRHOMED}/execs; mkdir -p ${EXECS} -#---------------------------------------------------------------------- - - -# Input variables:-------------------------------------- -EXP=${1}; #EXP=GFS -RES=${2}; #RES=1024002 -YYYYMMDDHHi=${3}; #YYYYMMDDHHi=2024012000 -FCST=${4}; #FCST=24 -#------------------------------------------------------- +#---~--- # Local variables-------------------------------------- @@ -86,7 +142,7 @@ echo -e "${GREEN}==>${NC} Scripts_CD-CT last commit: \n" git log | head -1 -if [ ! -d ${DATAIN}/fixed ] +if [[ ! -d ${DATAIN}/fixed ]] then echo -e "${GREEN}==>${NC} copying and linking fixed input data ${SYSTEM_KEYC}... \n" mkdir -p ${DATAIN} @@ -96,29 +152,31 @@ then fi -# Creating the x1.${RES}.static.nc file once, if does not exist yet:--------------- -if [ ! -s ${DATAIN}/fixed/x1.${RES}.static.nc ] +#---~--- +# Create the x1.${RES}.static.nc file. This is normally needed only once, when the file +# does not exist. However, if the files must be recreated for whichever reason, option +# OVERWRITE forces creation. +#---~--- +if ${OVERWRITE} || [[ ! -s ${DATAIN}/fixed/x1.${RES}.static.nc ]] then echo -e "${GREEN}==>${NC} Creating static.bash for submiting init_atmosphere to create x1.${RES}.static.nc...\n" - time ./make_static.bash ${EXP} ${RES} ${YYYYMMDDHHi} ${FCST} + time ./make_static.bash -e ${EXP} -f ${FCST} -r ${RES} -t ${YYYYMMDDHHi} else echo -e "${GREEN}==>${NC} File x1.${RES}.static.nc already exist in ${DATAIN}/fixed.\n" fi -#---------------------------------------------------------------------------------- - - -# Degrib phase:--------------------------------------------------------------------- -echo -e "${GREEN}==>${NC} Running Degrib:\n" -time ./make_degrib.bash ${EXP} ${RES} ${YYYYMMDDHHi} ${FCST} -#---------------------------------------------------------------------------------- +#---~--- +#--- Run the degrib step. +echo -e "${GREEN}==>${NC} Submitting Degrib...\n" +time ./make_degrib.bash -e ${EXP} -f ${FCST} -r ${RES} -t ${YYYYMMDDHHi} +#---~--- -# Init Atmosphere phase:------------------------------------------------------------ -echo -e "${GREEN}==>${NC} Running Init Atmosphere...\n" -time ./make_initatmos.bash ${EXP} ${RES} ${YYYYMMDDHHi} ${FCST} -#---------------------------------------------------------------------------------- +#--- Run the atmosphere initialisation step. +echo -e "${GREEN}==>${NC} Submitting Init Atmosphere...\n" +time ./make_initatmos.bash -e ${EXP} -f ${FCST} -r ${RES} -t ${YYYYMMDDHHi} +#---~--- diff --git a/scripts/3.run_model.bash b/scripts/3.run_model.bash index 0165d95..2484120 100755 --- a/scripts/3.run_model.bash +++ b/scripts/3.run_model.bash @@ -16,38 +16,124 @@ umask 022 # #-----------------------------------------------------------------------------# -if [ $# -ne 4 -a $# -ne 1 ] -then + +#--- Function that shows usage. +function show_usage() { + echo " Usage: " echo "" - echo "Instructions: execute the command below" + echo " ${0} [-v VARTABLE] [-d OUTPUT_DIAG_INT] [-e EXP ] [-f FCST] [-l NLEV] \\" + echo " [-r RES] [-t YYYYMMDDHH]" echo "" - echo "${0} [EXP_NAME/OP] RESOLUTION LABELI FCST" + echo " List of optional flags: " echo "" - echo "EXP_NAME :: Forcing: GFS" - echo "RESOLUTION :: number of points in resolution model grid, e.g: 1024002 (24 km)" - echo "LABELI :: Initial date YYYYMMDDHH, e.g.: 2024010100" - echo "FCST :: Forecast hours, e.g.: 24 or 36, etc." + echo " -v VARTABLE -- Suffix for defining which version of the" + echo " stream_list_atmosphere.diagnostics template to use." + echo " The default is to not use any suffix." echo "" - echo "24 hour forecast example for 24km:" - echo "${0} GFS 1024002 2024010100 24" - echo "48 hour forecast example for 120km:" - echo "${0} GFS 40962 2024010100 48" + echo " List of **required** flags when -c is not set: " echo "" + echo " -d OUTPUT_DIAG_INT -- Output interval for diagnostic. The format must be" + echo " \"HH:MM:SS\"" + echo " -e EXP -- meteorological drivers. For example, GFS" + echo " -f FCST -- Simulation length in hours, e.g., 24 or 48." + echo " -l NLEV -- Number of vertical levels for the output." + echo " -r RES -- grid resolution. Options are:" + echo " 5898242 (~ 10 km)" + echo " 2621442 (~ 15 km)" + echo " 1024002 (~ 24 km)" + echo " 40962 (~ 120 km)" + echo " -t YYYYMMDDHH -- Initial time. For example if 22 Sept 2025 00 UTC," + echo " set it to: 2025092200" + echo "" +} +#---~--- - exit -fi -# Set environment variables exports: -echo "" -echo -e "\033[1;32m==>\033[0m Moduling environment for MONAN model...\n" +#--- Set environment variables exports: . setenv.bash +#---~--- + + + + +#--- Default input variables: +EXP="" +RES="" +YYYYMMDDHHi="" +FCST="" +NLEV="" +OUTPUT_DIAG_INTERVAL="" +VARTABLE="" +#---~--- + + +#--- Parse arguments. +while [[ ${#} > 0 ]] +do + key="${1}" + case ${key} in + -d) + OUTPUT_DIAG_INTERVAL="${2}" + shift 2 # Past flag and argument + ;; + -e) + EXP="${2}" + shift 2 # past flag and argument + ;; + -f) + FCST="${2}" + shift 2 # past flag and argument + ;; + -l) + NLEV="${2}" + shift 2 # Past flag and argument + ;; + -r) + RES="${2}" + shift 2 # past flag and argument + ;; + -t) + YYYYMMDDHHi="${2}" + shift 2 # past flag and argument + ;; + -v) + VFIRST=$(echo ${2} | cut -c 1-1) + case "${VFIRST}" in + .) VARTABLE="${2}" ;; + *) VARTABLE=".${2}" ;; + esac + shift 2 # past flag and argument + ;; + *) + echo "Unknown key-value argument pair." + show_usage + exit 2 + ;; + esac +done +#---~--- + + + +#---~--- +# Make sure all settings were provided (unless this will be to clean up runs). +#---~--- +if [[ "${EXP}" == "" ]] || [[ "${RES}" == "" ]] || + [[ "${YYYYMMDDHHi}" == "" ]] || [[ "${FCST}" == "" ]] || + [[ "${NLEV}" == "" ]] || [[ "${OUTPUT_DIAG_INTERVAL}" == "" ]] +then + echo " This script requires some arguments to be set through flags." + show_usage + exit 2 +fi +#---~--- echo "" echo "---- Run Model ----" echo "" -# Standart directories variables:--------------------------------------- +#--- Set and create standard directories DIRHOMES=${DIR_SCRIPTS}/scripts_CD-CT; mkdir -p ${DIRHOMES} DIRHOMED=${DIR_DADOS}/scripts_CD-CT; mkdir -p ${DIRHOMED} SCRIPTS=${DIRHOMES}/scripts; mkdir -p ${SCRIPTS} @@ -55,32 +141,22 @@ DATAIN=${DIRHOMED}/datain; mkdir -p ${DATAIN} DATAOUT=${DIRHOMED}/dataout; mkdir -p ${DATAOUT} SOURCES=${DIRHOMES}/sources; mkdir -p ${SOURCES} EXECS=${DIRHOMED}/execs; mkdir -p ${EXECS} -#---------------------------------------------------------------------- - - -# Input variables:-------------------------------------- -EXP=${1}; #EXP=GFS -RES=${2}; #RES=1024002 -YYYYMMDDHHi=${3}; #YYYYMMDDHHi=2024012000 -FCST=${4}; #FCST=6 -#------------------------------------------------------- mkdir -p ${DATAOUT}/${YYYYMMDDHHi}/Model/logs +export DIRRUN=${DIRHOMED}/run.${YYYYMMDDHHi}; rm -fr ${DIRRUN}; mkdir -p ${DIRRUN} +#---~--- # Local variables-------------------------------------- start_date=${YYYYMMDDHHi:0:4}-${YYYYMMDDHHi:4:2}-${YYYYMMDDHHi:6:2}_${YYYYMMDDHHi:8:2}:00:00 cores=${MODEL_ncores} hhi=${YYYYMMDDHHi:8:2} -NLEV=55 CONFIG_CONV_INTERVAL="00:30:00" -VARTABLE=".OPER" -export DIRRUN=${DIRHOMED}/run.${YYYYMMDDHHi}; rm -fr ${DIRRUN}; mkdir -p ${DIRRUN} #------------------------------------------------------------------------------------ -# Variables for flex outpout interval from streams.atmosphere------------------------ -t_strout=$(cat ${SCRIPTS}/namelists/streams.atmosphere.TEMPLATE | sed -n '//s/.*output_interval="\([^"]*\)".*/\1/p') +# Variables for flex outpout interval ------------------------ +t_strout=${OUTPUT_DIAG_INTERVAL} t_stroutsec=$(echo ${t_strout} | awk -F: '{print ($1 * 3600) + ($2 * 60) + $3}') -t_strouthor=$(echo "scale=4; (${t_stroutsec}/60)/60" | bc) +t_strouthor=`echo "scale=4; (${t_stroutsec}/60)/60" | bc` #------------------------------------------------------------------------------------ # Format to HH:MM:SS t_strout (output_interval) @@ -88,42 +164,64 @@ IFS=":" read -r h m s <<< "${t_strout}" printf -v t_strout "%02d:%02d:%02d" "$h" "$m" "$s" # From now on, CONFI_LEN_DISP becames cte = 0.0, pickin up this value from static file. -# Calculating default parameters for different resolutions -if [ $RES -eq 1024002 ]; then #24Km - CONFIG_DT=150.0 +#---~--- +# Set default parameters according to the requested resolution. +#---~--- +case ${RES} in +65536002) #3km + CONFIG_DT=18.0 + CONFIG_LEN_DISP=3000.0 CONFIG_CONV_INTERVAL="00:15:00" -elif [ $RES -eq 2621442 ]; then #15Km - CONFIG_DT=90.0 + ;; +5898242) #10km + CONFIG_DT=60.0 + CONFIG_LEN_DISP=10000.0 CONFIG_CONV_INTERVAL="00:15:00" -elif [ $RES -eq 40962 ]; then #120Km - CONFIG_DT=600.0 + ;; +2621442) #15Km + CONFIG_DT=90.0 + CONFIG_LEN_DISP=15000.0 CONFIG_CONV_INTERVAL="00:15:00" -elif [ $RES -eq 163842 ]; then #60Km - CONFIG_DT=300.0 + ;; +1024002) #24Km + CONFIG_DT=150.0 + CONFIG_LEN_DISP=24000.0 CONFIG_CONV_INTERVAL="00:15:00" -elif [ $RES -eq 655362 ]; then #30Km + ;; +655362) #30Km CONFIG_DT=150.0 + CONFIG_LEN_DISP=30000.0 CONFIG_CONV_INTERVAL="00:15:00" -elif [ $RES -eq 5898242 ]; then #10Km - CONFIG_DT=60.0 + ;; +163842) #60Km + CONFIG_DT=300.0 + CONFIG_LEN_DISP=60000.0 CONFIG_CONV_INTERVAL="00:15:00" -elif [ $RES -eq 65536002 ]; then #3Km - CONFIG_DT=18.0 + ;; +40962) #120Km + CONFIG_DT=600.0 + CONFIG_LEN_DISP=120000.0 CONFIG_CONV_INTERVAL="00:15:00" -fi -#------------------------------------------------------- + ;; +*) + echo -e "${ORANGE}****** WARNING ******${NC} \n" + echo -e "${ORANGE}==>${NC} Provided grid resolution (${RES}) is not recognised.\n" + echo -e "${ORANGE}==>${NC} We cannot guarantee that MONAN will run fine.\n" + ;; +esac +#---~--- # Calculating final forecast dates in model namelist format: DD_HH:MM:SS # using: start_date(yyyymmdd) + FCST(hh) : -ind=$(printf "%02d\n" $(echo "${FCST}/24" | bc)) -inh=$(printf "%02.0f\n" $(echo "((${FCST}/24)-${ind})*24" | bc -l)) +ind=`printf "%02d\n" $(echo "${FCST}/24" | bc)` +inh=`printf "%02.0f\n" $(echo "((${FCST}/24)-${ind})*24" | bc -l)` DD_HHMMSS_forecast=$(echo "${ind}_${inh}:00:00") -if [ ! -s ${DATAIN}/fixed/x1.${RES}.graph.info.part.${cores} ] +if [[ ! -s ${DATAIN}/fixed/x1.${RES}.graph.info.part.${cores} ]] then - if [ ! -s ${DATAIN}/fixed/x1.${RES}.graph.info ] + if [[ ! -s ${DATAIN}/fixed/x1.${RES}.graph.info ]] then cd ${DATAIN}/fixed echo -e "${GREEN}==>${NC} downloading meshes tgz files ... \n" @@ -142,7 +240,7 @@ fi files_needed=("${SCRIPTS}/namelists/stream_list.atmosphere.output" ""${SCRIPTS}/namelists/stream_list.atmosphere.diagnostics${VARTABLE} "${SCRIPTS}/namelists/stream_list.atmosphere.surface" "${EXECS}/atmosphere_model" "${DATAIN}/fixed/x1.${RES}.static.nc" "${DATAIN}/fixed/x1.${RES}.graph.info.part.${cores}" "${DATAOUT}/${YYYYMMDDHHi}/Pre/x1.${RES}.init.nc" "${DATAIN}/fixed/Vtable.GFS") for file in "${files_needed[@]}" do - if [ ! -s "${file}" ] + if [[ ! -s "${file}" ]] then echo -e "\n${RED}==>${NC} ***** ATTENTION *****\n" echo -e "${RED}==>${NC} [${0}] At least the file ${file} was not generated. \n" @@ -160,13 +258,14 @@ cp -f ${DATAOUT}/${YYYYMMDDHHi}/Pre/x1.${RES}.init.nc ${DIRRUN} cp -f ${DATAIN}/fixed/Vtable.GFS ${DIRRUN} -if [ ${EXP} = "GFS" ] +if [[ ${EXP} = "GFS" ]] then sed -e "s,#LABELI#,${start_date},g;s,#FCSTS#,${DD_HHMMSS_forecast},g;s,#RES#,${RES},g; s,#CONFIG_DT#,${CONFIG_DT},g;s,#CONFIG_LEN_DISP#,${CONFIG_LEN_DISP},g;s,#CONFIG_CONV_INTERVAL#,${CONFIG_CONV_INTERVAL},g" \ ${SCRIPTS}/namelists/namelist.atmosphere.TEMPLATE > ${DIRRUN}/namelist.atmosphere - - sed -e "s,#RES#,${RES},g;s,#CIORIG#,${EXP},g;s,#LABELI#,${YYYYMMDDHHi},g;s,#NLEV#,${NLEV},g" \ + + sed -e "s,#RES#,${RES},g;s,#CIORIG#,${EXP},g;s,#LABELI#,${YYYYMMDDHHi},g;s,#NLEV#,${NLEV},g; +s,#OUTPUT_DIAG_INTERVAL#,${OUTPUT_DIAG_INTERVAL},g" \ ${SCRIPTS}/namelists/streams.atmosphere.TEMPLATE > ${DIRRUN}/streams.atmosphere fi cp -f ${SCRIPTS}/namelists/stream_list.atmosphere.output ${DIRRUN} @@ -179,7 +278,7 @@ chmod 755 ${DIRRUN} rm -f ${DIRRUN}/model.bash -if [ ${SCHEDULER_SYSTEM} != "GENERIC" ] +if [[ ${SCHEDULER_SYSTEM} != "GENERIC" ]] then sed -e "s,#JOBNAME#,${MODEL_jobname},g; s,#NNODES#,${MODEL_nnodes},g; @@ -210,13 +309,21 @@ cd ${DIRRUN} date beg_secs=\`date +"%s"\` -if [ "$HOSTNAME" = "egeon" ]; then +#ML: Replace HOSTNAME with SCHEDULER_SYSTEM so this can be expanded to other HPC environments more easily. +case "${SCHEDULER_SYSTEM}" in +SLURM) echo "-- SLURM_JOB_ID: \$SLURM_JOB_ID" time mpirun -np ${MODEL_ncores} ./\${executable} -else + ;; +PBS) echo "-- PBS_JOBID: \$PBS_JOBID" time mpirun --ppn ${MODEL_ncpn} -np ${MODEL_ncores} --depth=${MODEL_nthreads} --cpu-bind depth ./\${executable} -fi + ;; +*) + echo "-- GENERIC:" + time mpirun -np ${MODEL_ncores} ./\${executable} + ;; +esac date end_secs=\`date +"%s"\` @@ -240,25 +347,25 @@ chmod a+x ${DIRRUN}/model.bash case "${SCHEDULER_SYSTEM}" in - SLURM) - echo -e "${GREEN}==>${NC} Submitting MONAN atmosphere model and waiting for finish before exit... \n" - echo -e "${GREEN}==>${NC} Logs being generated at ${DATAOUT}/logs... \n" - echo -e "sbatch ${SCRIPTS}/model.bash" - cd ${DIRRUN} - sbatch --wait ${DIRRUN}/model.bash - ;; - PBS) - echo -e "${GREEN}==>${NC} Submitting MONAN atmosphere model and waiting for finish before exit... \n" - echo -e "${GREEN}==>${NC} Logs being generated at ${DATAOUT}/logs... \n" - echo -e "${GREEN}==>${NC} qsub model.bash...\n" - cd ${DIRRUN} - qsub -W block=true ${DIRRUN}/model.bash - ;; -# GENERIC) -# echo "Nenhum gerenciador detectado" -# cd ${DIRRUN} -# ${DIRRUN}/model.bash -# ;; +SLURM) + echo -e "${GREEN}==>${NC} Submitting MONAN atmosphere model and waiting for finish before exit... \n" + echo -e "${GREEN}==>${NC} Logs being generated at ${DATAOUT}/logs... \n" + echo -e "sbatch ${SCRIPTS}/model.bash" + cd ${DIRRUN} + sbatch --wait ${DIRRUN}/model.bash + ;; +PBS) + echo -e "${GREEN}==>${NC} Submitting MONAN atmosphere model and waiting for finish before exit... \n" + echo -e "${GREEN}==>${NC} Logs being generated at ${DATAOUT}/logs... \n" + echo -e "${GREEN}==>${NC} qsub model.bash...\n" + cd ${DIRRUN} + qsub -W block=true ${DIRRUN}/model.bash + ;; +#GENERIC) +# echo "Nenhum gerenciador detectado" +# cd ${DIRRUN} +# ${DIRRUN}/model.bash +# ;; esac mv ${DIRRUN}/model.bash ${DATAOUT}/${YYYYMMDDHHi}/Model/logs @@ -273,9 +380,9 @@ do currentdate=$(date -d "${YYYYMMDDHHi:0:8} ${hh}:00:00 $(echo "(${i}-1)*${t_strout:0:2}" | bc) hours $(echo "(${i}-1)*${t_strout:3:2}" | bc) minutes $(echo "(${i}-1)*${t_strout:6:2}" | bc) seconds" +"%Y%m%d%H.%M.%S") file=MONAN_DIAG_G_MOD_${EXP}_${YYYYMMDDHHi}_${currentdate}.x${RES}L${NLEV}.nc - if [ ! -s ${DATAOUT}/${YYYYMMDDHHi}/Model/${file} ] + if [[ ! -s ${DATAOUT}/${YYYYMMDDHHi}/Model/${file} ]] then - echo -e "\n${RED}==>${NC} ***** ATTENTION *****\n" + echo -e "\n${RED}==>${NC} ***** FATAL ERROR *****\n" echo -e "${RED}==>${NC} [${0}] At least the file ${DATAOUT}/${YYYYMMDDHHi}/Model/${file} was not generated. \n" exit -1 fi diff --git a/scripts/4.run_post.bash b/scripts/4.run_post.bash index a65efb8..adb7117 100755 --- a/scripts/4.run_post.bash +++ b/scripts/4.run_post.bash @@ -16,54 +16,133 @@ umask 022 # #-----------------------------------------------------------------------------# -if [ $# -ne 4 -a $# -ne 1 ] -then +#--- Function that shows usage. +function show_usage() { + echo " Usage: " + echo "" + echo " ${0} [-v VARTABLE] [-d OUTPUT_DIAG_INT] [-e EXP ] [-f FCST] \\" + echo " [-l N_MODEL_LEV] [-r RES] [-t YYYYMMDDHH]" echo "" - echo "Instructions: execute the command below" + echo " List of optional flags: " echo "" - echo "${0} ]EXP_NAME/OP] RESOLUTION LABELI FCST" + echo " -v VARTABLE -- Suffix for defining which version of the" + echo " stream_list_atmosphere.diagnostics template to use." + echo " The default is to not use any suffix." echo "" - echo "EXP_NAME :: Forcing: GFS" - echo "RESOLUTION :: number of points in resolution model grid, e.g: 1024002 (24 km)" - echo "LABELI :: Initial date YYYYMMDDHH, e.g.: 2024010100" - echo "FCST :: Forecast hours, e.g.: 24 or 36, etc." + echo " List of **required** flags when -c is not set: " echo "" - echo "24 hour forcast example:" - echo "${0} GFS 1024002 2024010100 24" - echo "${0} GFS 40962 2024010100 48" + echo " -d OUTPUT_DIAG_INT -- Output interval for diagnostic. The format must be" + echo " \"HH:MM:SS\"" + echo " -e EXP -- meteorological drivers. For example, GFS" + echo " -f FCST -- Simulation length in hours, e.g., 24 or 48." + echo " -l N_MODEL_LEV -- Number of vertical levels for the output." + echo " -r RES -- grid resolution. Options are:" + echo " 5898242 (~ 10 km)" + echo " 2621442 (~ 15 km)" + echo " 1024002 (~ 24 km)" + echo " 40962 (~ 120 km)" + echo " -t YYYYMMDDHH -- Initial time. For example if 22 Sept 2025 00 UTC," + echo " set it to: 2025092200" echo "" +} +#---~--- - exit -fi -# Set environment variables exports: -echo "" -echo -e "\033[1;32m==>\033[0m Moduling environment for MONAN model...\n" +#--- Set environment variables exports: . setenv.bash +#---~--- + + + + +#--- Default input variables: +EXP="" +RES="" +YYYYMMDDHHi="" +FCST="" +N_MODEL_LEV="" +OUTPUT_DIAG_INTERVAL="" +VARTABLE="" +#---~--- + + +#--- Parse arguments. +while [[ ${#} > 0 ]] +do + key="${1}" + case ${key} in + -d) + OUTPUT_DIAG_INTERVAL="${2}" + shift 2 # Past flag and argument + ;; + -e) + EXP="${2}" + shift 2 # past flag and argument + ;; + -f) + FCST="${2}" + shift 2 # past flag and argument + ;; + -l) + N_MODEL_LEV="${2}" + shift 2 # Past flag and argument + ;; + -r) + RES="${2}" + shift 2 # past flag and argument + ;; + -t) + YYYYMMDDHHi="${2}" + shift 2 # past flag and argument + ;; + -v) + VFIRST=$(echo ${2} | cut -c 1-1) + case "${VFIRST}" in + .) VARTABLE="${2}" ;; + *) VARTABLE=".${2}" ;; + esac + shift 2 # past flag and argument + ;; + *) + echo "Unknown key-value argument pair." + show_usage + exit 2 + ;; + esac +done +#---~--- + + + +#---~--- +# Make sure all settings were provided. +#---~--- +if [[ "${EXP}" == "" ]] || [[ "${RES}" == "" ]] || + [[ "${YYYYMMDDHHi}" == "" ]] || [[ "${FCST}" == "" ]] || + [[ "${N_MODEL_LEV}" == "" ]] || [[ "${OUTPUT_DIAG_INTERVAL}" == "" ]] +then + echo " This script requires some arguments to be set through flags." + show_usage + exit 2 +fi +#---~--- echo "" echo "---- Run Post ----" echo "" -# Standart directories variables:--------------------------------------- -DIRHOMES=$(dirname "$(pwd)"); mkdir -p ${DIRHOMES} +#--- Set and create standard directories +DIRHOMES=`dirname "$(pwd)"`; mkdir -p ${DIRHOMES} DIRHOMED=${DIR_DADOS}/scripts_CD-CT; mkdir -p ${DIRHOMED} export SCRIPTS=${DIRHOMES}/scripts; mkdir -p ${SCRIPTS} DATAIN=${DIRHOMED}/datain; mkdir -p ${DATAIN} DATAOUT=${DIRHOMED}/dataout; mkdir -p ${DATAOUT} SOURCES=${DIRHOMES}/sources; mkdir -p ${SOURCES} EXECS=${DIRHOMED}/execs; mkdir -p ${EXECS} -#---------------------------------------------------------------------- - - -# Input variables:-------------------------------------- -EXP=${1}; #EXP=GFS -RES=${2}; #RES=1024002 -YYYYMMDDHHi=${3}; #YYYYMMDDHHi=2024042000 -FCST=${4}; #FCST=40 -#------------------------------------------------------- mkdir -p ${DATAOUT}/${YYYYMMDDHHi}/Post/logs +export DIRRUN=${DIRHOMED}/run.${YYYYMMDDHHi}; rm -fr ${DIRRUN}; mkdir -p ${DIRRUN} +#---~--- @@ -71,100 +150,167 @@ mkdir -p ${DATAOUT}/${YYYYMMDDHHi}/Post/logs START_DATE_YYYYMMDD="${YYYYMMDDHHi:0:4}-${YYYYMMDDHHi:4:2}-${YYYYMMDDHHi:6:2}" START_HH="${YYYYMMDDHHi:8:2}" maxpostpernode=30 # <------ qtde max de convert_mpas por no! -VARTABLE=".OPER" -export DIRRUN=${DIRHOMED}/run.${YYYYMMDDHHi}; rm -fr ${DIRRUN}; mkdir -p ${DIRRUN} -N_MODEL_LEV=55 -NLEV=18 #------------------------------------------------------- -# Variables for flex outpout interval from streams.atmosphere------------------------ -t_strout=$(cat ${SCRIPTS}/namelists/streams.atmosphere.TEMPLATE | sed -n '//s/.*output_interval="\([^"]*\)".*/\1/p') -t_stroutsec=$(echo ${t_strout} | awk -F: '{print ($1 * 3600) + ($2 * 60) + $3}') -t_strouthor=$(echo "scale=4; (${t_stroutsec}/60)/60" | bc) +# Variables for flex output interval ------------------------ +t_strout=${OUTPUT_DIAG_INTERVAL} +t_stroutsec=`echo ${t_strout} | awk -F: '{print ($1 * 3600) + ($2 * 60) + $3}'` +t_strouthor=`echo "scale=4; (${t_stroutsec}/60)/60" | bc` #------------------------------------------------------------------------------------ # Format to HH:MM:SS t_strout (output_interval) IFS=":" read -r h m s <<< "${t_strout}" printf -v t_strout "%02d:%02d:%02d" "$h" "$m" "$s" -# Calculating default parameters for different resolutions -if [ $RES -eq 1024002 ]; then #24Km - NLAT=721 #180/0.25 - NLON=1441 #360/0.25 + +#---~--- +# Calculate default parameters for different resolutions. +# ML: The original numbers assumed 1 degree ~ 100 km. Across latitude and near the +# Equator, 1 degree ~ 111.2 km, so the regridded data ended up being slightly coarser +# than it needed to be. To ensure an average grid mesh in regular lon/lat that is +# close to the original resolution, we determine the average resolution based on +# the number of points in a full sphere (4*pi steradians), and pick the nearest +# integer number of points per degree. +# delta_xy = sqrt( 4*pi * (180/pi)^2 / NumberOfPoints) +# PointsPerDegree = round(1/delta_xy) +# NLON = 360 * PointsPerDegree + 1 +# NLAT = 180 * PointsPerDegree + 1 +#---~--- +case ${RES} in +65536002) + #---~--- + # 3 km, use 40 points per degree + #---~--- + NLAT=7201 + NLON=14401 STARTLAT=-90.0 STARTLON=0.0 ENDLAT=90.0 ENDLON=360.0 -elif [ $RES -eq 2621442 ]; then #15Km - NLAT=1201 #180/0.15 - NLON=2401 #360/0.15 + #---~--- + ;; +5898242) + #---~--- + # 10 km, use 12 points per degree + #---~--- + NLAT=2161 + NLON=4321 STARTLAT=-90.0 STARTLON=0.0 ENDLAT=90.0 ENDLON=360.0 -elif [ $RES -eq 40962 ]; then #120Km - NLAT=150 #180/1.2 - NLON=300 #360/1.2 + #---~--- + ;; +2621442) + #---~--- + # 15 km, use 8 points per degree + #---~--- + NLAT=1441 + NLON=2881 STARTLAT=-90.0 STARTLON=0.0 ENDLAT=90.0 ENDLON=360.0 -elif [ $RES -eq 163842 ]; then #60Km - NLAT=301 #180/0.6 - NLON=601 #360/0.6 + #---~--- + ;; +1024002) + #---~--- + # 24 km, use 5 points per degree + #---~--- + NLAT=901 + NLON=1801 STARTLAT=-90.0 STARTLON=0.0 ENDLAT=90.0 ENDLON=360.0 -elif [ $RES -eq 655362 ]; then #30Km - NLAT=601 #180/0.3 - NLON=1201 #360/0.3 + #---~--- + ;; +655362) + #---~--- + # 30 km, use 4 points per degree + #---~--- + NLAT=721 + NLON=1441 STARTLAT=-90.0 STARTLON=0.0 ENDLAT=90.0 ENDLON=360.0 -elif [ $RES -eq 5898242 ]; then #10Km - NLAT=1801 #180/0.10 (+1) - NLON=3601 #360/0.10 (+1) + #---~--- + ;; +163842) + #---~--- + # 60 km, use 2 points per degree + #---~--- + NLAT=361 + NLON=721 STARTLAT=-90.0 STARTLON=0.0 ENDLAT=90.0 ENDLON=360.0 -elif [ $RES -eq 65536002 ]; then #3Km - NLAT=6001 #180/0.03 - NLON=12001 #360/0.03 + #---~--- + ;; +40962) + #---~--- + # 120 km, use 1 points per degree + #---~--- + NLAT=181 + NLON=361 STARTLAT=-90.0 STARTLON=0.0 ENDLAT=90.0 ENDLON=360.0 + #---~--- + ;; +*) + #---~--- + # Unrecognised resolution + #---~--- + echo -e "${RED}****** FATAL ERROR ******${NC} \n" + echo -e "${RED}==>${NC} Provided grid resolution (${RES}) is not recognised.\n" + echo -e "${RED}==>${NC} ${0} cannot post-process this MONAN simulation.\n" + exit -1 + #---~--- + ;; +esac +#---~--- + +# Retrieve N_ISOBARIC_LEV from t_iso_levels in Registry_isobaric.xml: +if [[ -s ${MONANDIR}/src/core_atmosphere/diagnostics/Registry_isobaric.xml ]] +then + N_ISOBARIC_LEV=$(grep "t_iso_levels" ${MONANDIR}/src/core_atmosphere/diagnostics/Registry_isobaric.xml | grep definition | cut -d\" -f4) +else + N_ISOBARIC_LEV=18 fi -#------------------------------------------------------- files_needed=("${SCRIPTS}/namelists/include_fields.diag${VARTABLE}" "${SCRIPTS}/namelists/convert_mpas.nml" "${SCRIPTS}/namelists/target_domain.TEMPLATE" "${EXECS}/convert_mpas" "${DATAOUT}/${YYYYMMDDHHi}/Pre/x1.${RES}.init.nc") for file in "${files_needed[@]}" do - if [ ! -s "${file}" ] + if [[ ! -s "${file}" ]] then - echo -e "\n${RED}==>${NC} ***** ATTENTION *****\n" + echo -e "\n${RED}==>${NC} ***** FATAL ERROR *****\n" echo -e "${RED}==>${NC} [${0}] At least the file ${file} was not generated. \n" exit -1 fi done - -# Captura quantos arquivos do modelo tiverem para serem pos-processados e -# quando nos serao necessarios para executar ${maxpostpernode} convert_mpas por no: +#---~--- +# Tally the number of model output files to be postprocessed, and find out how +# many nodes are needed to process ${maxpostpernode} convert_mpas runs per node: #nfiles=$(ls -l ${DATAOUT}/${YYYYMMDDHHi}/Model/MONAN*nc | wc -l) # from streams.atmosphere.TEMPLATE in diagnostics the output_interval is flexible +#---~--- output_interval=${t_strouthor} #nfiles=FCST/output_interval + 1(time zero file) nfiles=$(echo "$FCST/$output_interval + 1" | bc) echo "${nfiles} post to submit." echo "Max ${maxpostpernode} submits per nodes." how_many_nodes ${nfiles} ${maxpostpernode} +#---~--- -# Cria os diretorios e arquivos/links para cada saida do convert_mpas: +#---~--- +# Make paths and create files/links for each convert_mpas output: +#---~--- cd ${DIRRUN} for ii in $(seq 1 ${nfiles}) @@ -174,30 +320,36 @@ do cp -f ${SCRIPTS}/setenv.bash ${DIRRUN}/dir.${i} cp -f ${SCRIPTS}/namelists/include_fields.diag${VARTABLE} ${DIRRUN}/dir.${i}/include_fields.diag${VARTABLE} cp -f ${DIRRUN}/dir.${i}/include_fields.diag${VARTABLE} ${DIRRUN}/dir.${i}/include_fields - sed -e "s,#NISOLEV#,${NLEV},g;s,#NMODELLEV#,${N_MODEL_LEV},g" \ + sed -e "s,#NISOLEV#,${N_ISOBARIC_LEV},g;s,#NMODELLEV#,${N_MODEL_LEV},g" \ ${SCRIPTS}/namelists/convert_mpas.nml > ${DIRRUN}/dir.${i}/convert_mpas.nml sed -e "s,#NLAT#,${NLAT},g;s,#NLON#,${NLON},g;s,#STARTLAT#,${STARTLAT},g;s,#ENDLAT#,${ENDLAT},g;s,#STARTLON#,${STARTLON},g;s,#ENDLON#,${ENDLON},g;" \ ${SCRIPTS}/namelists/target_domain.TEMPLATE > ${DIRRUN}/dir.${i}/target_domain done +#---~--- cd ${DIRRUN} chmod -R 755 ${DIRRUN}/* -# Laco para criar os arquivos de submissao com os blocos de convertmpas para cada node: echo "scheduler system = " ${SCHEDULER_SYSTEM} echo "system key = " ${SYSTEM_KEY} echo "" -# Laco para criar os arquivos de submissao com os blocos de convertmpas para cada node: +#---~--- +# Loop that generates submission files that distributes chunks of convertmpas runs to +# each node: +#---~--- node=1 inicio=1 fim=$((maxpostpernode <= nfiles ? maxpostpernode : nfiles)) -while [ ${inicio} -le ${nfiles} ] +while [[ ${inicio} -le ${nfiles} ]] do rm -f ${DIRRUN}/PostAtmos_node.${node}.sh - if [ ${SCHEDULER_SYSTEM} != "GENERIC" ] - then + case "${SCHEDULER_SYSTEM}" in + GENERIC) + echo "#!/bin/bash " > ${DIRRUN}/PostAtmos_node.${node}.sh + ;; + *) sed -e "s,#JOBNAME#,MO.Pos${node},g; s,#NNODES#,${POST_nnodes},g; s,#NCPUS#,${POST_ncpus},g; @@ -210,9 +362,8 @@ do s,#ERRORJOB#,${DATAOUT}/${YYYYMMDDHHi}/Post/logs/PostAtmos_node.${node}.e,g" \ ${SCRIPTS}/stools/submit_${SYSTEM_KEY}.bash_TEMPLATE > \ ${DIRRUN}/PostAtmos_node.${node}.sh - else - echo "#!/bin/bash " > ${DIRRUN}/PostAtmos_node.${node}.sh - fi + ;; + esac cat << EOSH >> ${DIRRUN}/PostAtmos_node.${node}.sh @@ -220,7 +371,7 @@ cd ${DIRRUN} . ${SCRIPTS}/setenv.bash chmod 755 ${DIRRUN}/* -echo "Executing posts ${inicio} to ${fim} in node Node ${node}." +echo "Submitting posts ${inicio} to ${fim} to node Node ${node}." for ii in \$(seq ${inicio} ${fim}) do @@ -256,8 +407,8 @@ do i=\$(printf "%04d" \${ii}) hh=${YYYYMMDDHHi:8:2} currentdate=\$(date -d "${YYYYMMDDHHi:0:8} \${hh}:00:00 \$(echo "(\${i}-1)*${t_strout:0:2}" | bc) hours \$(echo "(\${i}-1)*${t_strout:3:2}" | bc) minutes \$(echo "(\${i}-1)*${t_strout:6:2}" | bc) seconds" +"%Y%m%d%H.%M.%S") - diag_name_post=MONAN_DIAG_G_POS_${EXP}_${YYYYMMDDHHi}_\${currentdate}.x${RES}L${N_MODEL_LEV}.nc - + diag_name_post=MONAN_DIAG_G_POS_${EXP}_${YYYYMMDDHHi}_\${currentdate}.x${RES}L${N_ISOBARIC_LEV}.nc + cd ${DIRRUN}/dir.\${i} chmod 755 * cp latlon.nc ${DATAOUT}/${YYYYMMDDHHi}/Post/\${diag_name_post} >> convert_mpas.output & @@ -275,22 +426,22 @@ EOSH cp -f ${DIRRUN}/PostAtmos_node.${node}.sh ${DATAOUT}/${YYYYMMDDHHi}/Post/logs chmod 755 ${DATAOUT}/${YYYYMMDDHHi}/Post/* case "${SCHEDULER_SYSTEM}" in - SLURM) - echo "Sbatch PostAtmos_node.${node}.sh" - jobid[${node}]=$(sbatch --parsable ${DIRRUN}/PostAtmos_node.${node}.sh) - echo "JobId node ${node} = ${jobid[${node}]} , convert_mpas ${inicio} to ${fim}" - echo "" - ;; - PBS) - echo "Rodando em PBS" - echo -e "${GREEN}==>${NC} qsub PostAtmos_node.${node}.sh...\n" - cd ${DIRRUN} - jobid[${node}]=$(qsub ${DIRRUN}/PostAtmos_node.${node}.sh | cut -d '.' -f1) - ;; -# GENERIC) -# echo "Nenhum gerenciador detectado" -# ${DIRRUN}/PostAtmos_node.${node}.sh -# ;; + SLURM) + echo "Sbatch PostAtmos_node.${node}.sh" + jobid[${node}]=$(sbatch --parsable ${DIRRUN}/PostAtmos_node.${node}.sh) + echo "JobId node ${node} = ${jobid[${node}]} , convert_mpas ${inicio} to ${fim}" + echo "" + ;; + PBS) + echo "Rodando em PBS" + echo -e "${GREEN}==>${NC} qsub PostAtmos_node.${node}.sh...\n" + cd ${DIRRUN} + jobid[${node}]=$(qsub ${DIRRUN}/PostAtmos_node.${node}.sh | cut -d '.' -f1) + ;; +# GENERIC) +# echo "Nenhum gerenciador detectado" +# ${DIRRUN}/PostAtmos_node.${node}.sh +# ;; esac @@ -315,8 +466,11 @@ done node=0 rm -f ${DIRRUN}/PostAtmos_node.${node}.sh -if [ ${SCHEDULER_SYSTEM} != "GENERIC" ] -then +case "${SCHEDULER_SYSTEM}" in +GENERIC) + echo "#!/bin/bash " > ${DIRRUN}/PostAtmos_node.${node}.sh + ;; +*) sed -e "s,#JOBNAME#,MO.Pos${node},g; s,#NNODES#,${POST_nnodes},g; s,#NCPUS#,${POST_ncpus},g; @@ -329,9 +483,8 @@ then s,#ERRORJOB#,${DATAOUT}/${YYYYMMDDHHi}/Post/logs/PostAtmos_node.${node}.e,g" \ ${SCRIPTS}/stools/submit_${SYSTEM_KEY}.bash_TEMPLATE > \ ${DIRRUN}/PostAtmos_node.${node}.sh -else - echo "#!/bin/bash " > ${DIRRUN}/PostAtmos_node.${node}.sh -fi + ;; +esac cat << EOSH >> ${DIRRUN}/PostAtmos_node.${node}.sh @@ -359,24 +512,34 @@ chmod a+x ${DIRRUN}/PostAtmos_node.${node}.sh case "${SCHEDULER_SYSTEM}" in - SLURM) - echo "Sbatch PostAtmos_node.${node}.sh" - sbatch --wait --dependency=${dependency} ${DIRRUN}/PostAtmos_node.${node}.sh - ;; - PBS) - echo "Rodando em PBS" - echo -e "${GREEN}==>${NC} qsub PostAtmos_node.${node}.sh...\n" - cd ${DIRRUN} - qsub -W depend=${dependency} -W block=true ${DIRRUN}/PostAtmos_node.${node}.sh - ;; -# GENERIC) -# echo "Nenhum gerenciador detectado" -# ${DIRRUN}/PostAtmos_node.${node}.sh -# ;; +SLURM) + echo "Sbatch PostAtmos_node.${node}.sh" + sbatch --wait --dependency=${dependency} ${DIRRUN}/PostAtmos_node.${node}.sh + ;; +PBS) + echo "Rodando em PBS" + echo -e "${GREEN}==>${NC} qsub PostAtmos_node.${node}.sh...\n" + cd ${DIRRUN} + qsub -W depend=${dependency} -W block=true ${DIRRUN}/PostAtmos_node.${node}.sh + ;; +#GENERIC) +# echo "Nenhum gerenciador detectado" +# ${DIRRUN}/PostAtmos_node.${node}.sh +# ;; esac -#CR: passar este scriptpara dentro do script PostAtmos_node.0.sh, submetido. +#--- Make sure VARTABLE has the leading "-v" if not empty. +if [[ "${VARTABLE}" == "" ]] +then + dv_VARTABLE="" +else + dv_VARTABLE="-v ${VARTABLE}" +fi +#---~--- + +#CR: Append this script to script PostAtmos_node.0.sh, which has been submitted. cd ${SCRIPTS} chmod 755 ${DATAOUT}/${YYYYMMDDHHi}/Post/* -time ${SCRIPTS}/make_template.bash ${EXP} ${RES} ${YYYYMMDDHHi} ${FCST} +time ${SCRIPTS}/make_template.bash ${dv_VARTABLE} -d ${OUTPUT_DIAG_INTERVAL} -e ${EXP} \ + -f ${FCST} -r ${RES} -t ${YYYYMMDDHHi} diff --git a/scripts/make_degrib.bash b/scripts/make_degrib.bash index 8d7bd11..cc45ba2 100755 --- a/scripts/make_degrib.bash +++ b/scripts/make_degrib.bash @@ -2,37 +2,92 @@ umask 022 -if [ $# -ne 4 ] -then - echo "" - echo "Instructions: execute the command below" +#--- Function that shows usage. +function show_usage() { + echo " Usage: " echo "" - echo "${0} EXP_NAME RESOLUTION LABELI FCST" + echo " ${0} [-e EXP ] [-f FCST] [-r RES] [-t YYYYMMDDHH]" echo "" - echo "EXP_NAME :: Forcing: GFS" - echo " :: Others options to be added later..." - echo "RESOLUTION :: number of points in resolution model grid, e.g: 1024002 (24 km)" - echo "LABELI :: Initial date YYYYMMDDHH, e.g.: 2024010100" - echo "FCST :: Forecast hours, e.g.: 24 or 36, etc." + echo " List of **required** flags: " echo "" - echo "24 hour forcast example:" - echo "${0} GFS 1024002 2024010100 24" - echo "${0} GFS 40962 2024010100 48" + echo " -e EXP -- meteorological drivers. For example, GFS" + echo " -f FCST -- Simulation length in hours, e.g., 24 or 48." + echo " -r RES -- grid resolution. Options are:" + echo " 5898242 (~ 10 km)" + echo " 2621442 (~ 15 km)" + echo " 1024002 (~ 24 km)" + echo " 40962 (~ 120 km)" + echo " -t YYYYMMDDHH -- Initial time. For example if 22 Sept 2025 00 UTC, set it to:" + echo " 2025092200" echo "" +} +#---~--- - exit -fi -# Set environment variables exports: -echo "" -echo -e "\033[1;32m==>\033[0m Moduling environment for MONAN model...\n" +#--- Set environment variables exports: . setenv.bash +#---~--- + + + + +#--- Default input variables: +EXP="" +RES="" +YYYYMMDDHHi="" +FCST="" +#---~--- + + +#--- Parse arguments. +while [[ ${#} > 0 ]] +do + key="${1}" + case ${key} in + -e) + EXP="${2}" + shift 2 # past flag and argument + ;; + -f) + FCST="${2}" + shift 2 # past flag and argument + ;; + -r) + RES="${2}" + shift 2 # past flag and argument + ;; + -t) + YYYYMMDDHHi="${2}" + shift 2 # past flag and argument + ;; + *) + echo "Unknown key-value argument pair." + show_usage + exit 2 + ;; + esac +done +#---~--- + + + +#---~--- +# Make sure all settings were provided (unless this will be to clean up runs). +#---~--- +if [[ "${EXP}" == "" ]] || [[ "${RES}" == "" ]] || + [[ "${YYYYMMDDHHi}" == "" ]] || [[ "${FCST}" == "" ]] +then + echo " This script requires some arguments to be set through flags." + show_usage + exit 2 +fi +#---~--- echo "" echo "---- Make Degrib ----" echo "" -# Standart directories variables:--------------------------------------- +#--- Set and create standard directories DIRHOMES=${DIR_SCRIPTS}/scripts_CD-CT; mkdir -p ${DIRHOMES} DIRHOMED=${DIR_DADOS}/scripts_CD-CT; mkdir -p ${DIRHOMED} SCRIPTS=${DIRHOMES}/scripts; mkdir -p ${SCRIPTS} @@ -40,15 +95,7 @@ DATAIN=${DIRHOMED}/datain; mkdir -p ${DATAIN} DATAOUT=${DIRHOMED}/dataout; mkdir -p ${DATAOUT} SOURCES=${DIRHOMES}/sources; mkdir -p ${SOURCES} EXECS=${DIRHOMED}/execs; mkdir -p ${EXECS} -#---------------------------------------------------------------------- - - -# Input variables:-------------------------------------- -EXP=${1}; #EXP=GFS -RES=${2}; #RES=1024002 -YYYYMMDDHHi=${3}; #YYYYMMDDHHi=2024012000 -FCST=${4}; #FCST=24 -#------------------------------------------------------- +#---~--- @@ -60,30 +107,35 @@ export DIRRUN=${DIRHOMED}/run.${YYYYMMDDHHi}; rm -fr ${DIRRUN}; mkdir -p ${DIRRU mkdir -p ${DATAIN}/${YYYYMMDDHHi} mkdir -p ${DATAOUT}/${YYYYMMDDHHi}/Pre/logs -if [ "$HOSTNAME" = "egeon" ]; then - mkdir -p ${HOME}/local/lib64 - cp -f /usr/lib64/libjasper.so* ${HOME}/local/lib64 - cp -f /usr/lib64/libjpeg.so* ${HOME}/local/lib64 -fi - -#Se nao existir CI no diretorio do IO, -# busca no nosso dir /beegfs/monan/CIs, se nao existir tbm, aborta! -#CR: BNDDIR should be setted just for EGEON machine -#CR: some local variables were mobed into the SLURM section, particularly for egeon +#---~--- +# Machine-specific configurations. +#---~--- +case "${HOSTNAME}" in +egeon) + mkdir -p ${HOME}/local/lib64 + cp -f /usr/lib64/libjasper.so* ${HOME}/local/lib64 + cp -f /usr/lib64/libjpeg.so* ${HOME}/local/lib64 + ;; +esac +#---~--- +#--- Set path for potential location of boundary conditions. OPERDIREXP=${OPERDIR}/${EXP} BNDDIR=${OPERDIREXP}/0p25/brutos/${YYYYMMDDHHi:0:4}/${YYYYMMDDHHi:4:2}/${YYYYMMDDHHi:6:2}/${YYYYMMDDHHi:8:2} +#---~--- -# Se nao existir CI no diretorio do IO, -# busca no nosso dir /beegfs/monan/CIs (Egeon) , /p/monan/CIs (xd2000) se nao existir tbm, aborta! -#CR: maybe this if should belong to the SLURM kind of running... -if [ ! -s ${BNDDIR}/gfs.t${YYYYMMDDHHi:8:2}z.pgrb2.0p25.f000.${YYYYMMDDHHi}.grib2 ] +#---~--- +# Retrieve boundary conditions, starting with the I/O path. If not found, look for them +# at default paths, /beegfs/monan/CIs (Egeon), /p/monan/CIs (Jaci). +# If files are not found at these locations, abort the run. +#---~--- +if [[ ! -s ${BNDDIR}/gfs.t${YYYYMMDDHHi:8:2}z.pgrb2.0p25.f000.${YYYYMMDDHHi}.grib2 ]] then - if [ ! -s ${GCCCIS}/${EXP}/${YYYYMMDDHHi:0:4}/${YYYYMMDDHHi}/gfs.t${YYYYMMDDHHi:8:2}z.pgrb2.0p25.f000.${YYYYMMDDHHi}.grib2 ] + if [[ ! -s ${GCCCIS}/${EXP}/${YYYYMMDDHHi:0:4}/${YYYYMMDDHHi}/gfs.t${YYYYMMDDHHi:8:2}z.pgrb2.0p25.f000.${YYYYMMDDHHi}.grib2 ]] then - echo -e "${RED}==>${NC}Condicao de contorno inexistente !" - echo -e "${RED}==>${NC}Check ${BNDDIR} or." + echo -e "${RED}==>${NC}Failed to find boundary conditions!" + echo -e "${RED}==>${NC}Check ${BNDDIR} or" echo -e "${RED}==>${NC}Check ${GCCCIS}/${EXP}" exit 1 else @@ -98,9 +150,9 @@ files_needed=("${DATAIN}/fixed/x1.${RES}.static.nc" "${DATAIN}/fixed/Vtable.${EX for file in "${files_needed[@]}" do - if [ ! -s "${file}" ] + if [[ ! -s "${file}" ]] then - echo -e "\n${RED}==>${NC} ***** ATTENTION *****\n" + echo -e "\n${RED}==>${NC} ***** ATTENTION *****\n" echo -e "${RED}==>${NC} [${0}] At least the file ${file} was not generated. \n" exit -1 fi @@ -117,7 +169,7 @@ cp -f ${SCRIPTS}/link_grib.csh ${DIRRUN} rm -f ${DIRRUN}/degrib.bash -if [ ${SCHEDULER_SYSTEM} != "GENERIC" ] +if [[ ${SCHEDULER_SYSTEM} != "GENERIC" ]] then sed -e "s,#JOBNAME#,${DEGRIB_jobname},g; s,#NNODES#,${DEGRIB_nnodes},g; @@ -172,7 +224,7 @@ date grep "Successful completion of program ungrib.exe" ${DIRRUN}/ungrib.log >& /dev/null -if [ \$? -ne 0 ]; then +if [[ \$? -ne 0 ]]; then echo " BUMMER: Ungrib generation failed for some yet unknown reason." echo " " tail -10 ${DIRRUN}/ungrib.log @@ -217,9 +269,9 @@ esac files_ungrib=("${EXP}:${YYYYMMDDHHi:0:4}-${YYYYMMDDHHi:4:2}-${YYYYMMDDHHi:6:2}_${YYYYMMDDHHi:8:2}") for file in "${files_ungrib[@]}" do - if [ ! -s ${DATAOUT}/${YYYYMMDDHHi}/Pre/${file} ] + if [[ ! -s ${DATAOUT}/${YYYYMMDDHHi}/Pre/${file} ]] then - echo -e "\n${RED}==>${NC} ***** ATTENTION *****\n" + echo -e "\n${RED}==>${NC} ***** ATTENTION *****\n" echo -e "${RED}==>${NC} Degrib fails! At least the file ${file} was not generated at ${DATAIN}/${YYYYMMDDHHi}. \n" echo -e "${RED}==>${NC} Check logs at ${DATAOUT}/logs/degrib.* .\n" echo -e "${RED}==>${NC} Exiting script. \n" diff --git a/scripts/make_initatmos.bash b/scripts/make_initatmos.bash index 822c183..f767a42 100755 --- a/scripts/make_initatmos.bash +++ b/scripts/make_initatmos.bash @@ -2,36 +2,90 @@ umask 022 -if [ $# -ne 4 ] -then - echo "" - echo "Instructions: execute the command below" + + +#--- Function that shows usage. +function show_usage() { + echo " Usage: " echo "" - echo "${0} EXP_NAME RESOLUTION LABELI FCST" + echo " ${0} [-e EXP ] [-f FCST] [-r RES] [-t YYYYMMDDHH]" echo "" - echo "EXP_NAME :: Forcing: GFS" - echo " :: Others options to be added later..." - echo "RESOLUTION :: number of points in resolution model grid, e.g: 1024002 (24 km)" - echo "LABELI :: Initial date YYYYMMDDHH, e.g.: 2024010100" - echo "FCST :: Forecast hours, e.g.: 24 or 36, etc." + echo " List of **required** flags: " echo "" - echo "24 hour forcast example:" - echo "${0} GFS 1024002 2024010100 24" + echo " -e EXP -- meteorological drivers. For example, GFS" + echo " -f FCST -- Simulation length in hours, e.g., 24 or 48." + echo " -r RES -- grid resolution. Options are:" + echo " 5898242 (~ 10 km)" + echo " 2621442 (~ 15 km)" + echo " 1024002 (~ 24 km)" + echo " 40962 (~ 120 km)" + echo " -t YYYYMMDDHH -- Initial time. For example if 22 Sept 2025 00 UTC, set it to:" + echo " 2025092200" echo "" +} +#---~--- - exit -fi -# Set environment variables exports: -echo "" -echo -e "\033[1;32m==>\033[0m Moduling environment for MONAN model...\n" +#--- Set environment variables exports: . setenv.bash +#---~--- + + + +#--- Default input variables: +EXP="" +RES="" +YYYYMMDDHHi="" +FCST="" +#---~--- -echo "" -echo "---- Make Init Atmosphere ----" -echo "" -# Standart directories variables:--------------------------------------- +#--- Parse arguments. +while [[ ${#} > 0 ]] +do + key="${1}" + case ${key} in + -e) + EXP="${2}" + shift 2 # past flag and argument + ;; + -f) + FCST="${2}" + shift 2 # past flag and argument + ;; + -r) + RES="${2}" + shift 2 # past flag and argument + ;; + -t) + YYYYMMDDHHi="${2}" + shift 2 # past flag and argument + ;; + *) + echo "Unknown key-value argument pair." + show_usage + exit 2 + ;; + esac +done +#---~--- + + + +#---~--- +# Make sure all settings were provided (unless this will be to clean up runs). +#---~--- +if [[ "${EXP}" == "" ]] || [[ "${RES}" == "" ]] || + [[ "${YYYYMMDDHHi}" == "" ]] || [[ "${FCST}" == "" ]] +then + echo " This script requires some arguments to be set through flags." + show_usage + exit 2 +fi +#---~--- + + +#--- Set and create standard directories DIRHOMES=${DIR_SCRIPTS}/scripts_CD-CT; mkdir -p ${DIRHOMES} DIRHOMED=${DIR_DADOS}/scripts_CD-CT; mkdir -p ${DIRHOMED} SCRIPTS=${DIRHOMES}/scripts; mkdir -p ${SCRIPTS} @@ -39,15 +93,7 @@ DATAIN=${DIRHOMED}/datain; mkdir -p ${DATAIN} DATAOUT=${DIRHOMED}/dataout; mkdir -p ${DATAOUT} SOURCES=${DIRHOMES}/sources; mkdir -p ${SOURCES} EXECS=${DIRHOMED}/execs; mkdir -p ${EXECS} -#---------------------------------------------------------------------- - - -# Input variables:-------------------------------------- -EXP=${1}; #EXP=GFS -RES=${2}; #RES=1024002 -YYYYMMDDHHi=${3}; #YYYYMMDDHHi=2024012000 -FCST=${4}; #FCST=24 -#------------------------------------------------------- +#---~--- # Local variables-------------------------------------- @@ -61,9 +107,9 @@ mkdir -p ${DATAOUT}/${YYYYMMDDHHi}/Pre/logs -if [ ! -s ${DATAIN}/fixed/x1.${RES}.graph.info.part.${cores} ] +if [[ ! -s ${DATAIN}/fixed/x1.${RES}.graph.info.part.${cores} ]] then - if [ ! -s ${DATAIN}/fixed/x1.${RES}.graph.info ] + if [[ ! -s ${DATAIN}/fixed/x1.${RES}.graph.info ]] then cd ${DATAIN}/fixed echo -e "${GREEN}==>${NC} downloading meshes tgz files ... \n" @@ -83,7 +129,7 @@ fi files_needed=("${SCRIPTS}/namelists/namelist.init_atmosphere.TEMPLATE" "${SCRIPTS}/namelists/streams.init_atmosphere.TEMPLATE" "${DATAIN}/fixed/x1.${RES}.graph.info.part.${cores}" "${DATAIN}/fixed/x1.${RES}.static.nc" "${DATAOUT}/${YYYYMMDDHHi}/Pre/${EXP}:${start_date:0:13}" "${EXECS}/init_atmosphere_model") for file in "${files_needed[@]}" do - if [ ! -s "${file}" ] + if [[ ! -s "${file}" ]] then echo -e "\n${RED}==>${NC} ***** ATTENTION *****\n" echo -e "${RED}==>${NC} [${0}] At least the file ${file} was not generated. \n" @@ -111,7 +157,7 @@ chmod 755 ${DATAOUT}/${YYYYMMDDHHi}/Pre/* rm -f ${DIRRUN}/initatmos.bash -if [ ${SCHEDULER_SYSTEM} != "GENERIC" ] +if [[ ${SCHEDULER_SYSTEM} != "GENERIC" ]] then sed -e "s,#JOBNAME#,${INITATMOS_jobname},g; s,#NNODES#,${INITATMOS_nnodes},g; @@ -144,13 +190,21 @@ cd ${DIRRUN} date beg_secs=\`date +"%s"\` -if [ "$HOSTNAME" = "egeon" ]; then +#ML: Replace HOSTNAME with SCHEDULER_SYSTEM so this can be expanded to other HPC environments more easily. +case "${SCHEDULER_SYSTEM}" in +SLURM) echo "-- SLURM_JOB_ID: \$SLURM_JOB_ID" time mpirun -np ${INITATMOS_ncores} ./\${executable} -else + ;; +PBS) echo "-- PBS_JOBID: \$PBS_JOBID" time mpirun --ppn ${INITATMOS_ncpn} -np ${INITATMOS_ncores} --depth=${INITATMOS_nthreads} --cpu-bind depth ./\${executable} -fi + ;; +#*) +# echo "-- GENERIC:" +# time mpirun -np ${INITATMOS_ncores} ./\${executable} +# ;; +esac date end_secs=\`date +"%s"\` @@ -168,27 +222,27 @@ EOF0 chmod a+x ${DIRRUN}/initatmos.bash case "${SCHEDULER_SYSTEM}" in - SLURM) - echo -e "${GREEN}==>${NC} Sbatch initatmos.bash...\n" - cd ${DIRRUN} - sbatch --wait ${DIRRUN}/initatmos.bash - ;; - PBS) - echo -e "${GREEN}==>${NC} qsub initatmos.bash...\n" - cd ${DIRRUN} - qsub -W block=true ${DIRRUN}/initatmos.bash - ;; -# GENERIC) -# echo "Nenhum gerenciador detectado" -# cd ${DIRRUN} -# ${DIRRUN}/initatmos.bash -# ;; +SLURM) + echo -e "${GREEN}==>${NC} Sbatch initatmos.bash...\n" + cd ${DIRRUN} + sbatch --wait ${DIRRUN}/initatmos.bash + ;; +PBS) + echo -e "${GREEN}==>${NC} qsub initatmos.bash...\n" + cd ${DIRRUN} + qsub -W block=true ${DIRRUN}/initatmos.bash + ;; +#GENERIC) +# echo -e "${ORANGE}==>${NC} No scheduler system detected...\n" +# cd ${DIRRUN} +# ${DIRRUN}/initatmos.bash +# ;; esac mv ${DIRRUN}/initatmos.bash ${DATAOUT}/${YYYYMMDDHHi}/Pre/logs -if [ ! -s ${DATAOUT}/${YYYYMMDDHHi}/Pre/x1.${RES}.init.nc ] +if [[ ! -s ${DATAOUT}/${YYYYMMDDHHi}/Pre/x1.${RES}.init.nc ]] then echo -e "\n${RED}==>${NC} ***** ATTENTION *****\n" echo -e "${RED}==>${NC} Init Atmosphere phase fails! Check logs at ${DATAOUT}/logs/initatmos.* .\n" diff --git a/scripts/make_static.bash b/scripts/make_static.bash index 82f079f..054c314 100755 --- a/scripts/make_static.bash +++ b/scripts/make_static.bash @@ -2,36 +2,92 @@ umask 022 -if [ $# -ne 4 ] -then - echo "" - echo "Instructions: execute the command below" +#--- Function that shows usage. +function show_usage() { + echo " Usage: " echo "" - echo "${0} EXP_NAME RESOLUTION LABELI FCST" + echo " ${0} [-e EXP ] [-f FCST] [-r RES] [-t YYYYMMDDHH]" echo "" - echo "EXP_NAME :: Forcing: GFS" - echo " :: Others options to be added later..." - echo "RESOLUTION :: number of points in resolution model grid, e.g: 1024002 (24 km)" - echo "LABELI :: Initial date YYYYMMDDHH, e.g.: 2024010100" - echo "FCST :: Forecast hours, e.g.: 24 or 36, etc." + echo " List of **required** flags: " echo "" - echo "24 hour forcast example:" - echo "${0} GFS 1024002 2024010100 24" + echo " -e EXP -- meteorological drivers. For example, GFS" + echo " -f FCST -- Simulation length in hours, e.g., 24 or 48." + echo " -r RES -- grid resolution. Options are:" + echo " 5898242 (~ 10 km)" + echo " 2621442 (~ 15 km)" + echo " 1024002 (~ 24 km)" + echo " 40962 (~ 120 km)" + echo " -t YYYYMMDDHH -- Initial time. For example if 22 Sept 2025 00 UTC, set it to:" + echo " 2025092200" echo "" +} +#---~--- - exit -fi -# Set environment variables exports: -echo "" -echo -e "\033[1;32m==>\033[0m Moduling environment for MONAN model...\n" + +#--- Set environment variables exports: . setenv.bash +#---~--- + + + +#--- Default input variables: +EXP="" +RES="" +YYYYMMDDHHi="" +FCST="" +#---~--- + + +#--- Parse arguments. +while [[ ${#} > 0 ]] +do + key="${1}" + case ${key} in + -e) + EXP="${2}" + shift 2 # past flag and argument + ;; + -f) + FCST="${2}" + shift 2 # past flag and argument + ;; + -r) + RES="${2}" + shift 2 # past flag and argument + ;; + -t) + YYYYMMDDHHi="${2}" + shift 2 # past flag and argument + ;; + *) + echo "Unknown key-value argument pair." + show_usage + exit 2 + ;; + esac +done +#---~--- + + + +#---~--- +# Make sure all settings were provided (unless this will be to clean up runs). +#---~--- +if [[ "${EXP}" == "" ]] || [[ "${RES}" == "" ]] || + [[ "${YYYYMMDDHHi}" == "" ]] || [[ "${FCST}" == "" ]] +then + echo " This script requires some arguments to be set through flags." + show_usage + exit 2 +fi +#---~--- echo "" echo "---- Make Static ----" echo "" -# Standart directories variables:--------------------------------------- +#--- Set and create standard directories DIRHOMES=${DIR_SCRIPTS}/scripts_CD-CT; mkdir -p ${DIRHOMES} DIRHOMED=${DIR_DADOS}/scripts_CD-CT; mkdir -p ${DIRHOMED} SCRIPTS=${DIRHOMES}/scripts; mkdir -p ${SCRIPTS} @@ -39,15 +95,7 @@ DATAIN=${DIRHOMED}/datain; mkdir -p ${DATAIN} DATAOUT=${DIRHOMED}/dataout; mkdir -p ${DATAOUT} SOURCES=${DIRHOMES}/sources; mkdir -p ${SOURCES} EXECS=${DIRHOMED}/execs; mkdir -p ${EXECS} -#---------------------------------------------------------------------- - - -# Input variables:-------------------------------------- -EXP=${1}; #EXP=GFS -RES=${2}; #RES=1024002 -YYYYMMDDHHi=${3}; #YYYYMMDDHHi=2024012000 -FCST=${4}; #FCST=24 -#------------------------------------------------------- +#---~--- # Local variables-------------------------------------- @@ -59,9 +107,9 @@ export DIRRUN=${DIRHOMED}/run.${YYYYMMDDHHi}; rm -fr ${DIRRUN}; mkdir -p ${DIRRU -if [ ! -s ${DATAIN}/fixed/x1.${RES}.graph.info.part.${cores} ] +if [[ ! -s ${DATAIN}/fixed/x1.${RES}.graph.info.part.${cores} ]] then - if [ ! -s ${DATAIN}/fixed/x1.${RES}.graph.info ] + if [[ ! -s ${DATAIN}/fixed/x1.${RES}.graph.info ]] then mkdir -p ${DATAIN}/fixed cd ${DATAIN}/fixed @@ -82,9 +130,9 @@ fi files_needed=("${EXECS}/init_atmosphere_model" "${DATAIN}/fixed/x1.${RES}.graph.info.part.${cores}" "${DATAIN}/fixed/x1.${RES}.grid.nc" "${SCRIPTS}/namelists/namelist.init_atmosphere.STATIC" "${SCRIPTS}/namelists/streams.init_atmosphere.STATIC") for file in "${files_needed[@]}" do - if [ ! -s "${file}" ] + if [[ ! -s "${file}" ]] then - echo -e "\n${RED}==>${NC} ***** ATTENTION *****\n" + echo -e "\n${RED}==>${NC} ***** FATAL ERROR *****\n" echo -e "${RED}==>${NC} [${0}] At least the file ${file} was not generated. \n" exit -1 fi @@ -109,7 +157,7 @@ cp -f ${SCRIPTS}/setenv.bash ${DIRRUN} mkdir -p ${DATAOUT}/logs rm -f ${DIRRUN}/static.bash -if [ ${SCHEDULER_SYSTEM} != "GENERIC" ] +if [[ ${SCHEDULER_SYSTEM} != "GENERIC" ]] then sed -e "s,#JOBNAME#,${STATIC_jobname},g; s,#NNODES#,${STATIC_nnodes},g; @@ -145,13 +193,21 @@ chmod 755 * date beg_secs=\`date +"%s"\` -if [ "$HOSTNAME" = "egeon" ]; then +#ML: Replace HOSTNAME with SCHEDULER_SYSTEM so this can be expanded to other HPC environments more easily. +case "${SCHEDULER_SYSTEM}" in +SLURM) echo "-- SLURM_JOB_ID: \$SLURM_JOB_ID" time mpirun -np ${STATIC_ncores} ./\${executable} -else + ;; +PBS) echo "-- PBS_JOBID: \$PBS_JOBID" time mpirun --ppn ${STATIC_ncpn} -np ${STATIC_ncores} --depth=${STATIC_nthreads} --cpu-bind depth ./\${executable} -fi + ;; +#*) +# echo "-- GENERIC: " +# time mpirun -np ${STATIC_ncores} ./\${executable} +# ;; +esac date end_secs=\`date +"%s"\` @@ -161,7 +217,7 @@ echo "STATIC time taken by run in seconds is " \$wallsecs grep "Finished running" log.init_atmosphere.0000.out >& /dev/null -if [ \$? -ne 0 ]; then +if [[ \$? -ne 0 ]]; then echo " BUMMER: Static generation failed for some yet unknown reason." echo " " tail -10 ${STATICPATH}/log.init_atmosphere.0000.out @@ -181,21 +237,21 @@ rm -fr ${DATAIN}/fixed/x1.${RES}.static.nc case "${SCHEDULER_SYSTEM}" in - SLURM) - echo -e "${GREEN}==>${NC} Sbatch static.bash...\n" - cd ${DIRRUN} - sbatch --wait ${DIRRUN}/static.bash - ;; - PBS) - echo -e "${GREEN}==>${NC} qsub static.bash...\n" - cd ${DIRRUN} - qsub -W block=true ${DIRRUN}/static.bash - ;; -# GENERIC) -# echo "Nenhum gerenciador detectado" -# cd ${DIRRUN} -# ${DIRRUN}/model.bash -# ;; +SLURM) + echo -e "${GREEN}==>${NC} Sbatch static.bash...\n" + cd ${DIRRUN} + sbatch --wait ${DIRRUN}/static.bash + ;; +PBS) + echo -e "${GREEN}==>${NC} qsub static.bash...\n" + cd ${DIRRUN} + qsub -W block=true ${DIRRUN}/static.bash + ;; +#GENERIC) +# echo "No job manager found" +# cd ${DIRRUN} +# ${DIRRUN}/model.bash +# ;; esac mv ${DIRRUN}/static.bash ${DATAOUT}/logs/ @@ -204,7 +260,7 @@ mv ${DIRRUN}/namelist.init_atmosphere ${DATAOUT}/logs/ mv log.init_atmosphere.* ${DATAOUT}/logs/ -if [ -s ${DIRRUN}/x1.${RES}.static.nc ] +if [[ -s ${DIRRUN}/x1.${RES}.static.nc ]] then mv ${DIRRUN}/x1.${RES}.static.nc ${DATAIN}/fixed chmod 755 ${DATAIN}/fixed/* diff --git a/scripts/make_template.bash b/scripts/make_template.bash index 2d6abf4..8ae8b96 100755 --- a/scripts/make_template.bash +++ b/scripts/make_template.bash @@ -16,70 +16,143 @@ umask 022 # #-----------------------------------------------------------------------------# -if [ $# -ne 4 -a $# -ne 1 ] -then +#--- Function that shows usage. +function show_usage() { + echo " Usage: " echo "" - echo "Instructions: execute the command below" + echo " ${0} [-v VARTABLE] [-d OUTPUT_DIAG_INT] [-e EXP ] [-f FCST] \\" + echo " [-r RES] [-t YYYYMMDDHH]" echo "" - echo "${0} ]EXP_NAME/OP] RESOLUTION LABELI FCST" + echo " List of optional flags: " echo "" - echo "EXP_NAME :: Forcing: GFS" - echo "RESOLUTION :: number of points in resolution model grid, e.g: 1024002 (24 km)" - echo "LABELI :: Initial date YYYYMMDDHH, e.g.: 2024010100" - echo "FCST :: Forecast hours, e.g.: 24 or 36, etc." + echo " -v VARTABLE -- Suffix for defining which version of the" + echo " stream_list_atmosphere.diagnostics template to use." + echo " The default is to not use any suffix." echo "" - echo "24 hour forcast example:" - echo "${0} GFS 1024002 2024010100 24" - echo "${0} GFS 40962 2024010100 48" + echo " List of **required** flags: " echo "" - - exit -fi + echo " -d OUTPUT_DIAG_INT -- Output interval for diagnostic. The format must be" + echo " \"HH:MM:SS\"" + echo " -e EXP -- meteorological drivers. For example, GFS" + echo " -f FCST -- Simulation length in hours, e.g., 24 or 48." + echo " -r RES -- grid resolution. Options are:" + echo " 5898242 (~ 10 km)" + echo " 2621442 (~ 15 km)" + echo " 1024002 (~ 24 km)" + echo " 40962 (~ 120 km)" + echo " -t YYYYMMDDHH -- Initial time. For example if 22 Sept 2025 00 UTC," + echo " set it to: 2025092200" + echo "" +} +#---~--- # Set environment variables exports: -echo "" -echo -e "\033[1;32m==>\033[0m Moduling environment for MONAN model...\n" . setenv.bash + + + +#--- Default input variables: +CLEAN=false +EXP="" +RES="" +YYYYMMDDHHi="" +FCST="" +OUTPUT_DIAG_INTERVAL="" +VARTABLE="" +#---~--- + + +#--- Parse arguments. +while [[ ${#} > 0 ]] +do + key="${1}" + case ${key} in + -c) + CLEAN=true + shift 1 # Past flag + ;; + -d) + OUTPUT_DIAG_INTERVAL="${2}" + shift 2 # Past flag and argument + ;; + -e) + EXP="${2}" + shift 2 # past flag and argument + ;; + -f) + FCST="${2}" + shift 2 # past flag and argument + ;; + -r) + RES="${2}" + shift 2 # past flag and argument + ;; + -t) + YYYYMMDDHHi="${2}" + shift 2 # past flag and argument + ;; + -v) + VFIRST=$(echo ${2} | cut -c 1-1) + case "${VFIRST}" in + .) VARTABLE="${2}" ;; + *) VARTABLE=".${2}" ;; + esac + shift 2 # past flag and argument + ;; + *) + echo "Unknown key-value argument pair." + show_usage + exit 2 + ;; + esac +done +#---~--- + + + +#---~--- +# Make sure all settings were provided (unless this will be to clean up runs). +#---~--- +if [[ "${EXP}" == "" ]] || [[ "${RES}" == "" ]] || + [[ "${YYYYMMDDHHi}" == "" ]] || [[ "${FCST}" == "" ]] || + [[ "${OUTPUT_DIAG_INTERVAL}" == "" ]] +then + echo " This script requires some arguments to be set through flags." + show_usage + exit 2 +fi +#---~--- + echo "" echo "---- Make Template ----" echo "" -# Standart directories variables:--------------------------------------- -DIRHOMES=$(dirname "$(pwd)"); mkdir -p ${DIRHOMES} +#--- Set and create standard directories +DIRHOMES=`dirname "$(pwd)"`; mkdir -p ${DIRHOMES} DIRHOMED=${DIR_DADOS}/scripts_CD-CT; mkdir -p ${DIRHOMED} export SCRIPTS=${DIRHOMES}/scripts; mkdir -p ${SCRIPTS} DATAIN=${DIRHOMED}/datain; mkdir -p ${DATAIN} DATAOUT=${DIRHOMED}/dataout; mkdir -p ${DATAOUT} SOURCES=${DIRHOMES}/sources; mkdir -p ${SOURCES} EXECS=${DIRHOMED}/execs; mkdir -p ${EXECS} -#---------------------------------------------------------------------- - - -# Input variables:-------------------------------------- -EXP=${1}; #EXP=GFS -RES=${2}; #RES=1024002 -YYYYMMDDHHi=${3}; #YYYYMMDDHHi=2024042000 -FCST=${4}; #FCST=40 -#------------------------------------------------------- mkdir -p ${DATAOUT}/${YYYYMMDDHHi}/Post/logs +#---~--- # Local variables-------------------------------------- START_DATE_YYYYMMDD="${YYYYMMDDHHi:0:4}-${YYYYMMDDHHi:4:2}-${YYYYMMDDHHi:6:2}" START_HH="${YYYYMMDDHHi:8:2}" maxpostpernode=20 # <------ qtde max de convert_mpas por no! -VARTABLE=".OPER" export DIRRUN=${DIRHOMED}/run.${YYYYMMDDHHi}; rm -fr ${DIRRUN}; mkdir -p ${DIRRUN} -N_MODEL_LEV=55 #------------------------------------------------------- -# Variables for flex outpout interval from streams.atmosphere------------------------ -t_strout=$(cat ${SCRIPTS}/namelists/streams.atmosphere.TEMPLATE | sed -n '//s/.*output_interval="\([^"]*\)".*/\1/p') -t_stroutsec=$(echo ${t_strout} | awk -F: '{print ($1 * 3600) + ($2 * 60) + $3}') -t_strouthor=$(echo "scale=4; (${t_stroutsec}/60)/60" | bc) -t_stroutmin=$(echo "${t_stroutsec}/60" | bc) +#--- Variables for flexible output intervals. +t_strout=${OUTPUT_DIAG_INTERVAL} +t_stroutsec=`echo ${t_strout} | awk -F: '{print ($1 * 3600) + ($2 * 60) + $3}'` +t_strouthor=`echo "scale=4; (${t_stroutsec}/60)/60" | bc` +t_stroutmin=`echo "${t_stroutsec}/60" | bc` #------------------------------------------------------------------------------------ cd ${DIRRUN} @@ -89,44 +162,94 @@ cd ${DIRRUN} IFS=":" read -r h m s <<< "${t_strout}" printf -v t_strout "%02d:%02d:%02d" "$h" "$m" "$s" -# Calculating default parameters for different resolutions -if [ $RES -eq 1024002 ]; then #24Km - NLAT=721 #180/0.25 - NLON=1441 #360/0.25 +#---~--- +# Calculate default parameters for different resolutions. +# ML: The original numbers assumed 1 degree ~ 100 km. Across latitude and near the +# Equator, 1 degree ~ 111.2 km, so the regridded data ended up being slightly coarser +# than it needed to be. To ensure an average grid mesh in regular lon/lat that is +# close to the original resolution, we determine the average resolution based on +# the number of points in a full sphere (4*pi steradians), and pick the nearest +# integer number of points per degree. +# delta_xy = sqrt( 4*pi * (180/pi)^2 / NumberOfPoints) +# PointsPerDegree = round(1/delta_xy) +# NLON = 360 * PointsPerDegree + 1 +# NLAT = 180 * PointsPerDegree + 1 +#---~--- +case ${RES} in +5898242) + #---~--- + # 10 km, use 12 points per degree + #---~--- + NLAT=2161 + NLON=4321 STARTLAT=-90.0 STARTLON=0.0 ENDLAT=90.0 ENDLON=360.0 -elif [ $RES -eq 2621442 ]; then #15Km - NLAT=1201 #180/0.15 - NLON=2401 #360/0.15 + #---~--- + ;; +2621442) + #---~--- + # 15 km, use 8 points per degree + #---~--- + NLAT=1441 + NLON=2881 STARTLAT=-90.0 STARTLON=0.0 ENDLAT=90.0 ENDLON=360.0 -elif [ $RES -eq 40962 ]; then #120Km - NLAT=150 #180/1.2 - NLON=300 #360/1.2 + #---~--- + ;; +1024002) + #---~--- + # 24 km, use 5 points per degree + #---~--- + NLAT=901 + NLON=1801 STARTLAT=-90.0 STARTLON=0.0 ENDLAT=90.0 ENDLON=360.0 -fi -#------------------------------------------------------- - -# NLEVS get from t_iso_levels in Registry_isobaric.xml: + #---~--- + ;; +40962) + #---~--- + # 120 km, use 1 points per degree + #---~--- + NLAT=181 + NLON=361 + STARTLAT=-90.0 + STARTLON=0.0 + ENDLAT=90.0 + ENDLON=360.0 + #---~--- + ;; +*) + #---~--- + # Unrecognised resolution. + #---~--- + echo -e "${RED}****** FATAL ERROR ******${NC} \n" + echo -e "${RED}==>${NC} Provided grid resolution (${RES}) is not recognised.\n" + echo -e "${RED}==>${NC} ${0} cannot post-process this MONAN simulation.\n" + exit -1 + #---~--- + ;; +esac +#---~--- + +# Retrieve N_ISOBARIC_LEV from t_iso_levels in Registry_isobaric.xml: if [ -s ${MONANDIR}/src/core_atmosphere/diagnostics/Registry_isobaric.xml ] then - NLEV=$(grep "t_iso_levels" ${MONANDIR}/src/core_atmosphere/diagnostics/Registry_isobaric.xml | grep definition | cut -d\" -f4) + N_ISOBARIC_LEV=$(grep "t_iso_levels" ${MONANDIR}/src/core_atmosphere/diagnostics/Registry_isobaric.xml | grep definition | cut -d\" -f4) else - NLEV=18 + N_ISOBARIC_LEV=18 fi output_interval=${t_strouthor} nfiles=$(echo "$FCST/$output_interval + 1" | bc) -diag_name_post=MONAN_DIAG_G_POS_${EXP}_${YYYYMMDDHHi}_${YYYYMMDDHHi}.00.00.x${RES}L${N_MODEL_LEV}.nc -diag_name_templ=MONAN_DIAG_G_POS_${EXP}_${YYYYMMDDHHi}_%y4%m2%d2%h2.%n2.00.x${RES}L${N_MODEL_LEV}.nc +diag_name_post=MONAN_DIAG_G_POS_${EXP}_${YYYYMMDDHHi}_${YYYYMMDDHHi}.00.00.x${RES}L${N_ISOBARIC_LEV}.nc +diag_name_templ=MONAN_DIAG_G_POS_${EXP}_${YYYYMMDDHHi}_%y4%m2%d2%h2.%n2.00.x${RES}L${N_ISOBARIC_LEV}.nc diff --git a/scripts/run_past2now.bash b/scripts/run_past2now.bash index 8b93e86..91879e1 100755 --- a/scripts/run_past2now.bash +++ b/scripts/run_past2now.bash @@ -1,54 +1,212 @@ #!/bin/bash -yyyymmddi=20241001 -yyyymmddf=20241005 -yyyymmdd=${yyyymmddi} +#--- Function that shows usage. +function show_usage() { + echo " Usage: " + echo "" + echo " ${0} [-o] [-d OUTPUT_DIAG_INT] [-e EXP ] [-f00 FCST_ZERO] [-f12 FCST_TWELVE] \\" + echo " [-i INPUT_PATH] [-l NLEV] [-r RES] [-ti YYYYMMDDi] [-tf YYYYMMDDf] \\" + echo " [-v VARTABLE]" + echo "" + echo " List of optional flags: " + echo " -d OUTPUT_DIAG_INT -- Output interval for diagnostic. The format must be" + echo " \"HH:MM:SS\"." + echo " -e EXP -- Meteorological drivers. For example, GFS" + echo " -f00 FCST_ZERO -- Simulation length in hours for runs starting at 00 UTC" + echo " e.g., 24 or 48." + echo " -f12 FCST_TWELVE -- Simulation length in hours for runs starting at 12 UTC" + echo " e.g., 24 or 48." + echo " -i INPUT_PATH -- Path containing input data for MONAN. If left empty, the" + echo " default path defined in setenv.bash will be used" + echo " -l NLEV -- Number of vertical levels for the output." + echo " -o -- Overwrite static files. If set, this will be done only" + echo " once." + echo " -r RES -- grid resolution. Supported options are:" + echo " 5898242 (~ 10 km)" + echo " 2621442 (~ 15 km)" + echo " 1024002 (~ 24 km)" + echo " 40962 (~ 120 km)" + echo " -ti YYYYMMDDi -- First initial date to run the script. For example if the" + echo " first run's initial time is on 22 Sept 2025, the" + echo " argument should be 20250922." + echo " -tf YYYYMMDDf -- Last initial date to run the script. For example if the" + echo " last run's initial time is on 31 Dec 2025, the" + echo " argument should be 20251231." + echo " -v VARTABLE -- Suffix for defining which version of the" + echo " stream_list_atmosphere.diagnostics template to use." + echo " The default is to not use any suffix." + echo "" + echo " All settings can be defined directly in the script." + echo "" +} +#---~--- + + +#--- Set environment variables exports: +. setenv.bash +#---~--- + + + + +#--- Default input variables: +STEP=1 +CLEAN="" +OVERWRITE="" +github_link_MONAN="https://github.com/monanadmin/MONAN-Model.git" +tag_or_branch_name_MONAN="release/1.4.1-rc" +github_link_CONVERT_MPAS="https://github.com/monanadmin/convert_mpas.git" +tag_or_branch_name_CONVERT_MPAS="release/1.2.0" +EXP="GFS" +INPUT_PATH="" +RES=1024002 +YYYYMMDDi=2024100100 +YYYYMMDDf=2024100500 +FCST_ZERO=240 +FCST_TWELVE=120 +NLEV=55 +OUTPUT_DIAG_INTERVAL="03:00:00" +VARTABLE="" +#---~--- + + +#--- Parse arguments. +while [[ ${#} > 0 ]] +do + key="${1}" + case ${key} in + -c) + CLEAN="-c" + shift 1 # Past flag + ;; + -d) + OUTPUT_DIAG_INTERVAL="${2}" + shift 2 # Past flag and argument + ;; + -e) + EXP="${2}" + shift 2 # past flag and argument + ;; + -f00) + FCST_ZERO="${2}" + shift 2 # past flag and argument + ;; + -f12) + FCST_TWELVE="${2}" + shift 2 # past flag and argument + ;; + -i) + INPUT_PATH="${2}" + shift 2 # Past flag and argument + ;; + -l) + NLEV="${2}" + shift 2 # Past flag and argument + ;; + -o) + OVERWRITE="-o" + shift 1 # past flag + ;; + -r) + RES="${2}" + shift 2 # past flag and argument + ;; + -s) + STEP="${2}" + shift 2 # past flag and argument + ;; + -ti) + YYYYMMDDHHi="${2}" + shift 2 # past flag and argument + ;; + -tf) + YYYYMMDDHHf="${2}" + shift 2 # past flag and argument + ;; + -v) + VFIRST=$(echo ${2} | cut -c 1-1) + case "${VFIRST}" in + .) VARTABLE="${2}" ;; + *) VARTABLE=".${2}" ;; + esac + shift 2 # past flag and argument + ;; + *) + echo "Unknown key-value argument pair." + show_usage + exit 2 + ;; + esac +done +#---~--- + + + +#--- If INPUT_PATH is provided, replace the path in setenv.bash +if [[ "${INPUT_PATH}" != "" ]] && [[ -d "${INPUT_PATH}" ]] +then + sed -i.bck "s,^export DIRDADOS=.*,export DIRDADOS=${INPUT_PATH},g" ${SCRIPTS}/setenv.bash + /bin/rm -f ${SCRIPTS}/setenv.bash.bck +fi +#---~--- # Input variables:----------------------------------------------------- DIR_DADOS=/mnt/beegfs/monan/users/renato/issues/ecflow-PREOPER/SCRATCHOUT; mkdir -p ${DIR_DADOS} DIRFLUSHOUT=/mnt/beegfs/monan/users/renato/issues/trashout; mkdir -p ${DIRFLUSHOUT} -EXP=GFS -RES=1024002 -FCST=240 #---------------------------------------------------------------------- -while [ ${yyyymmdd} -le ${yyyymmddf} ] +#--- Make sure VARTABLE has the leading "-v" if not empty. +if [[ "${VARTABLE}" == "" ]] +then + dv_VARTABLE="" +else + dv_VARTABLE="-v ${VARTABLE}" +fi +#---~--- + + +YYYYMMDD=${YYYYMMDDi} +while [ ${YYYYMMDD} -le ${YYYYMMDDf} ] do + HH_LIST="00 12" + for HH in ${HH_LIST} + do + YYYYMMDDHHi="${YYYYMMDD}${HH}" + case ${HH} in + 00) FCST=${FCST_ZERO} ;; + 12) FCST=${FCST_TWELVE} ;; + esac - echo "${SCRIPTS}/2.pre_processing.bash ${EXP} ${RES} ${yyyymmdd}00 240" - ${SCRIPTS}/2.pre_processing.bash ${EXP} ${RES} ${yyyymmdd}00 240 - echo "${SCRIPTS}/3.run_model.bash ${EXP} ${RES} ${yyyymmdd}00 240" - ${SCRIPTS}/3.run_model.bash ${EXP} ${RES} ${yyyymmdd}00 240 - echo "${SCRIPTS}/4.run_post.bash ${EXP} ${RES} ${yyyymmdd}00 240" - ${SCRIPTS}/4.run_post.bash ${EXP} ${RES} ${yyyymmdd}00 240 - - # Final data output directory: - mkdir -p ${DIRFLUSHOUT}/${yyyymmdd}00/ - # Copy post: - cp -fr ${DIRSCRIPTDADOS}/dataout/${yyyymmdd}00/Post/* ${DIRFLUSHOUT}/${yyyymmdd}00/ - # Remove all output files from the original output diretory dataout: - rm -fr ${DIRSCRIPTDADOS}/dataout/${yyyymmdd}00 - rm -fr ${DIRSCRIPTDADOS}/datain/${yyyymmdd}00 - + # Set arguments. + ARGS_TWO="${OVERWRITE} -e ${EXP} -f ${FCST} -r ${RES} -t ${YYYYMMDDHHi}" + ARGS_THREE="${dv_VARTABLE} -d ${OUTPUT_DIAG_INTERVAL} -e ${EXP}" + ARGS_THREE="${ARGS_THREE} -f ${FCST} -l ${NLEV} -r ${RES} -t ${YYYYMMDDHHi}" + ARGS_FOUR="${dv_VARTABLE} -d ${OUTPUT_DIAG_INTERVAL} -e ${EXP} -f ${FCST}" + ARGS_FOUR="${ARGS_FOUR} -l ${NLEV} -r ${RES} -t ${YYYYMMDDHHi}" - - echo "${SCRIPTS}/2.pre_processing.bash ${EXP} ${RES} ${yyyymmdd}12 120" - ${SCRIPTS}/2.pre_processing.bash ${EXP} ${RES} ${yyyymmdd}12 120 - echo "${SCRIPTS}/3.run_model.bash ${EXP} ${RES} ${yyyymmdd}12 120" - ${SCRIPTS}/3.run_model.bash ${EXP} ${RES} ${yyyymmdd}12 120 - echo "${SCRIPTS}/4.run_post.bash ${EXP} ${RES} ${yyyymmdd}12 120" - ${SCRIPTS}/4.run_post.bash ${EXP} ${RES} ${yyyymmdd}12 120 - - # Final data output directory: - mkdir -p ${DIRFLUSHOUT}/${yyyymmdd}12/ - # Copy post: - cp -fr ${DIRSCRIPTDADOS}/dataout/${yyyymmdd}12/Post/* ${DIRFLUSHOUT}/${yyyymmdd}12/ - # Remove all output files from the original output diretory dataout: - rm -fr ${DIRSCRIPTDADOS}/dataout/${yyyymmdd}12 - rm -fr ${DIRSCRIPTDADOS}/datain/${yyyymmdd}12 - - yyyymmdd=$(date -u +%Y%m%d -d "${yyyymmdd} 1 day") + # Run scripts + echo "${SCRIPTS}/2.pre_processing.bash ${ARGS_TWO}" + ${SCRIPTS}/2.pre_processing.bash ${ARGS_TWO} + echo "${SCRIPTS}/3.run_model.bash ${ARGS_THREE}" + ${SCRIPTS}/3.run_model.bash ${ARGS_THREE} + echo "${SCRIPTS}/4.run_post.bash ${ARGS_FOUR}" + ${SCRIPTS}/4.run_post.bash ${ARGS_FOUR} + + # Final data output directory: + mkdir -p ${DIRFLUSHOUT}/${YYYYMMDDHHi}/ + # Copy post: + cp -fr ${DIRSCRIPTDADOS}/dataout/${YYYYMMDDHHi}/Post/* ${DIRFLUSHOUT}/${YYYYMMDDHHi}/ + # Remove all output files from the original output diretory dataout: + rm -fr ${DIRSCRIPTDADOS}/dataout/${YYYYMMDDHHi} + rm -fr ${DIRSCRIPTDADOS}/datain/${YYYYMMDDHHi} + + # No need to overwrite static fields after the first iteration + OVERWRITE="" + done + + # Update time + YYYYMMDD=$(date -u +%Y%m%d -d "${YYYYMMDD} 1 day") done diff --git a/scripts/setenv.bash b/scripts/setenv.bash index 3452832..a563932 100755 --- a/scripts/setenv.bash +++ b/scripts/setenv.bash @@ -1,6 +1,25 @@ #!/bin/bash umask 022 +#---~---- +# Colors. Please refrain from changing these variables. +#---~---- +export GREEN='\033[1;32m' # Green +export RED='\033[1;31m' # Red +export NC='\033[0m' # No Color +export BLUE='\033[01;34m' # Blue +export ORANGE='\033[01;91m' # Orange +#---~---- + +#---~---- +# Notify users that this script is being called. +# Please refrain from changing these commands. +#---~---- +echo "" +echo -e "${GREEN}==>${NC} Load MONAN settings (setenv.bash).\n" +#---~---- + + # Choose your compiler here (only on Jaci; on Egeon the compiler is fixed to ‘gnu’): export COMPILER=intel #export COMPILER=gnu @@ -24,24 +43,45 @@ fi # Detect hostname THOSTNAME=$(hostname -s) -# Identifying several names of the egeon: +#---~--- +# Identify which machine is being used based on the host name. Most HPC systems have +# multiple login nodes, but they share a common configuration system. +#---~--- case ${THOSTNAME} in - egeon-login|headnode|n[0-9]|n[1-2][0-9]|n3[0-3]) - export HOSTNAME="egeon" - export MAKE_TARG=gfortran - export MAKE_TARG2=gfortran - COMPILER=gnu +egeon-login|headnode|n[0-9]|n[1-2][0-9]|n3[0-3]) + #---~--- + # Egeon. Use gnu + #---~--- + export HOSTNAME="egeon" + export MAKE_TARG=gfortran + export MAKE_TARG2=gfortran + COMPILER=gnu + #---~--- + ;; +ian[0-9]*|cn-0[0-9][0-9][0-9]) + #---~--- + # Jaci. Decide which compiler to use based on variable COMPILER + #---~--- + export HOSTNAME="ian" + case "${COMPILER}" in + intel) + export MAKE_TARG=intel-xd2000 + export MAKE_TARG2=intel2-xd2000 ;; - ian[0-9]*|cn-0[0-9][0-9][0-9]) - export HOSTNAME="ian" - if [ "$COMPILER" == "intel" ]; then - export MAKE_TARG=intel-xd2000 - export MAKE_TARG2=intel2-xd2000 - elif [ "$COMPILER" == "gnu" ]; then - export MAKE_TARG=gfortran-xd2000 - export MAKE_TARG2=gfortran-xd2000 - fi + gnu) + export MAKE_TARG=gfortran-xd2000 + export MAKE_TARG2=gfortran-xd2000 ;; + esac + #---~--- + ;; +*) + #---~--- + # Generic variable, use the hostname and hope for the best. + #---~--- + export HOSTNAME="${THOSTNAME}" + ;; + #---~--- esac # Make the same for other machines/systems... echo "Host detected: $HOSTNAME" @@ -77,13 +117,6 @@ export MONANDIR=$MONANDIR # Others variables: -# Colors: -# -export GREEN='\033[1;32m' # Green -export RED='\033[1;31m' # Red -export NC='\033[0m' # No Color -export BLUE='\033[01;34m' # Blue - # Functions: ====================================================================================================== @@ -92,11 +125,11 @@ how_many_nodes () { deno=${2} num=$(echo "${nume}/${deno}" | bc -l) how_many_nodes_int=$(echo "${num}/1" | bc) - dif=$(echo "scale=0; (${num}-${how_many_nodes_int})*100/1" | bc) - rest=$(echo "scale=0; (((${num}-${how_many_nodes_int})*${deno})+0.5)/1" | bc -l) - if [ ${dif} -eq 0 ]; then how_many_nodes_left=0; else how_many_nodes_left=1; fi - if [ ${how_many_nodes_int} -eq 0 ]; then how_many_nodes_int=1; how_many_nodes_left=0; rest=0; fi - how_many_nodes=$(echo "${how_many_nodes_int}+${how_many_nodes_left}" | bc ) + dif=`echo "scale=0; (${num}-${how_many_nodes_int})*100/1" | bc` + rest=`echo "scale=0; (((${num}-${how_many_nodes_int})*${deno})+0.5)/1" | bc -l` + if [[ ${dif} -eq 0 ]]; then how_many_nodes_left=0; else how_many_nodes_left=1; fi + if [[ ${how_many_nodes_int} -eq 0 ]]; then how_many_nodes_int=1; how_many_nodes_left=0; rest=0; fi + how_many_nodes=`echo "${how_many_nodes_int}+${how_many_nodes_left}" | bc ` #echo "INT number of nodes needed: \${how_many_nodes_int} = ${how_many_nodes_int}" #echo "number of nodes left: \${how_many_nodes_left} = ${how_many_nodes_left}" echo "The number of nodes needed: \${how_many_nodes} = ${how_many_nodes}" From 2163e7d61f36eb06e40f8d79ad2f61a0d3f502b0 Mon Sep 17 00:00:00 2001 From: Marcos Longo Date: Tue, 27 Jan 2026 08:41:20 -0300 Subject: [PATCH 02/15] Some additional features: 1. Added option -h to show usage to all scripts. 2. Added option -m12 to try to run older versions of MONAN (based on 1.2.0-rc) on Jaci. If this runs, I will make another commit to add some post-processing code too. --- scripts/0.run_all.bash | 61 ++++++++++++++++++++---------- scripts/1.install_monan.bash | 25 ++++++++++-- scripts/2.pre_processing.bash | 50 ++++++++++++++++-------- scripts/3.run_model.bash | 45 +++++++++++++++------- scripts/4.run_post.bash | 49 ++++++++++++++++-------- scripts/make_degrib.bash | 44 ++++++++++++++++------ scripts/make_initatmos.bash | 44 ++++++++++++++++------ scripts/make_static.bash | 46 ++++++++++++++++------- scripts/make_template.bash | 46 +++++++++++++++-------- scripts/setenv.bash | 71 +++++++++++++++++++++++++++++------ 10 files changed, 351 insertions(+), 130 deletions(-) diff --git a/scripts/0.run_all.bash b/scripts/0.run_all.bash index 1a5bca1..89112ba 100755 --- a/scripts/0.run_all.bash +++ b/scripts/0.run_all.bash @@ -7,9 +7,10 @@ function show_usage() { echo " Usage: " echo "" - echo " ${0} [-o] [-z] [-bc TAG_CONVERT_MPAS] [ -bm TAG_MONAN ] [-d OUTPUT_DIAG_INT] \\" - echo " [-e EXP ] [-f FCST] [-gc GIT_CONVERT_MPAS] [-gm GIT_MONAN ] [-i INPUT_PATH] \\" - echo " [-l NLEV] [-r RES] [-s STEP] [-t YYYYMMDDHH] [-v VARTABLE]" + echo " ${0} [-h] [-m12] [-o] [-z] [-bc TAG_CONVERT_MPAS] [ -bm TAG_MONAN ] \\" + echo " [-d OUTPUT_DIAG_INT] [-e EXP ] [-f FCST] [-gc GIT_CONVERT_MPAS] \\" + echo " [-gm GIT_MONAN ] [-i INPUT_PATH] [-l NLEV] [-r RES] [-s STEP] \\" + echo " [-t YYYYMMDDHH] [-v VARTABLE]" echo "" echo " List of optional flags: " echo "" @@ -27,10 +28,17 @@ function show_usage() { echo " -gm GIT_MONAN -- GitHub handle for MONAN. For example:" echo " https://github.com/monanadmin/MONAN-Model.git" echo " This is used only by step 1." + echo " -h -- Shows this message." echo " -i INPUT_PATH -- Path containing input data for MONAN. If left empty, the" echo " default path defined in setenv.bash will be used" echo " -l NLEV -- Number of vertical levels for the output. This is used" echo " by steps 3 and 4." + echo " -m12 -- Is this a MONAN run based on 1.2.0-rc and branches" + echo " derived from this version (e.g., feature/monan-757-NF)?" + echo " This is a temporary flag that will be removed once" + echo " the versions containing Noah-MP are merged into the new" + echo " release. This allows the script to manage older code and" + echo " still run on jaci." echo " -o -- Overwrite static files. This is used only by step 2." echo " -r RES -- grid resolution. Supported options are:" echo " 65536002 (~ 3 km)" @@ -63,16 +71,12 @@ function show_usage() { #---~--- -#--- Set environment variables exports: -. setenv.bash -#---~--- - - #--- Default input variables: STEP=1 OVERWRITE="" +MONAN_ONETWO="" github_link_MONAN="https://github.com/monanadmin/MONAN-Model.git" tag_or_branch_name_MONAN="release/1.4.3-rc" github_link_CONVERT_MPAS="https://github.com/monanadmin/convert_mpas.git" @@ -122,6 +126,10 @@ do github_link_MONAN="${2}" shift 2 # past flag and argument ;; + -h) + show_usage + exit 0 + ;; -i) INPUT_PATH="${2}" shift 2 # Past flag and argument @@ -130,8 +138,12 @@ do NLEV="${2}" shift 2 # Past flag and argument ;; + -m12) + MONAN_ONETWO="${key}" + shift 1 # past flag + ;; -o) - OVERWRITE="-o" + OVERWRITE="${key}" shift 1 # past flag ;; -r) @@ -159,7 +171,10 @@ do shift 1 # past flag ;; *) - echo "Unknown key-value argument pair." + echo " *** FATAL ERROR! ***" + echo "" + echo " Unknown key-value argument pair." + echo "" show_usage exit 2 ;; @@ -168,6 +183,11 @@ done #---~--- +#--- Set environment variables exports: +. setenv.bash ${MONAN_ONETWO} +#---~--- + + #--- Set and create standard directories DIRHOMES=${DIR_SCRIPTS}/scripts_CD-CT; mkdir -p ${DIRHOMES} DIRHOMED=${DIR_DADOS}/scripts_CD-CT; mkdir -p ${DIRHOMED} @@ -306,10 +326,10 @@ case ${STEP} in #--- Run step - time ${0} ${OVERWRITE} ${dv_VARTABLE} -bc ${tag_or_branch_name_CONVERT_MPAS} \ - -bm ${tag_or_branch_name_MONAN} -d ${OUTPUT_DIAG_INTERVAL} -e ${EXP} -f ${FCST} \ - -gc ${github_link_CONVERT_MPAS} -gm ${github_link_MONAN} -l ${NLEV} -r ${RES} \ - -s ${step_now} -t ${YYYYMMDDHHi} + time ${0} ${OVERWRITE} ${dv_VARTABLE} ${MONAN_ONETWO} \ + -bc ${tag_or_branch_name_CONVERT_MPAS} -bm ${tag_or_branch_name_MONAN} \ + -d ${OUTPUT_DIAG_INTERVAL} -e ${EXP} -f ${FCST} -gc ${github_link_CONVERT_MPAS} \ + -gm ${github_link_MONAN} -l ${NLEV} -r ${RES} -s ${step_now} -t ${YYYYMMDDHHi} #---~--- done #---~--- @@ -318,7 +338,7 @@ case ${STEP} in #---~--- # STEP 1: Install and compile MONAN and its utility programs. #---~--- - time 1.install_monan.bash -bc ${tag_or_branch_name_CONVERT_MPAS} \ + time 1.install_monan.bash ${MONAN_ONETWO} -bc ${tag_or_branch_name_CONVERT_MPAS} \ -bm ${tag_or_branch_name_MONAN} -gc ${github_link_CONVERT_MPAS} \ -gm ${github_link_MONAN} #---~--- @@ -327,23 +347,24 @@ case ${STEP} in #---~--- # STEP 2: Run the pre-processing step, and make initial/boundary conditions if needed. #---~--- - time 2.pre_processing.bash ${OVERWRITE} -e ${EXP} -f ${FCST} -r ${RES} -t ${YYYYMMDDHHi} + time 2.pre_processing.bash ${OVERWRITE} ${MONAN_ONETWO} -e ${EXP} -f ${FCST} -r ${RES} \ + -t ${YYYYMMDDHHi} #---~--- ;; 3) #---~--- # STEP 3: Run the model. #---~--- - time 3.run_model.bash ${dv_VARTABLE} -d ${OUTPUT_DIAG_INTERVAL} -e ${EXP} -f ${FCST} \ - -l ${NLEV} -r ${RES} -t ${YYYYMMDDHHi} + time 3.run_model.bash ${dv_VARTABLE} ${MONAN_ONETWO} -d ${OUTPUT_DIAG_INTERVAL} \ + -e ${EXP} -f ${FCST} -l ${NLEV} -r ${RES} -t ${YYYYMMDDHHi} #---~--- ;; 4) #---~--- # STEP 4: Run the post-processing step. #---~--- - time 4.run_post.bash ${dv_VARTABLE} -d ${OUTPUT_DIAG_INTERVAL} -e ${EXP} -f ${FCST} \ - -l ${NLEV} -r ${RES} -t ${YYYYMMDDHHi} + time 4.run_post.bash ${dv_VARTABLE} ${MONAN_ONETWO} -d ${OUTPUT_DIAG_INTERVAL} \ + -e ${EXP} -f ${FCST} -l ${NLEV} -r ${RES} -t ${YYYYMMDDHHi} #---~--- ;; esac diff --git a/scripts/1.install_monan.bash b/scripts/1.install_monan.bash index 613b556..89f35c3 100755 --- a/scripts/1.install_monan.bash +++ b/scripts/1.install_monan.bash @@ -22,7 +22,17 @@ umask 022 function show_usage() { echo " Usage: " echo "" - echo " ${0} -bc TAG_CONVERT_MPAS -bm TAG_MONAN -gm GIT_MONAN -gc GIT_CONVERT_MPAS" + echo " ${0} [-h] [-m12] [-bc TAG_CONVERT_MPAS] [-bm TAG_MONAN] [-gm GIT_MONAN] \\" + echo " [-gc GIT_CONVERT_MPAS]" + echo "" + echo " List of optional flags: " + echo "" + echo " -h -- Shows this message." + echo " -m12 -- Is this a MONAN run based on 1.2.0-rc and branches derived" + echo " from this version (e.g., feature/monan-757-NF)? This is a" + echo " temporary flag that will be removed once the versions" + echo " containing Noah-MP are merged into the new release. This" + echo " allows the script to manage older code and still run on jaci." echo "" echo " List of **required** flags: " echo "" @@ -75,6 +85,7 @@ function checkout_system() { # Retrieve configuration. #---~--- #--- Default settings (all empty) +MONAN_ONETWO="" github_link_MONAN="" tag_or_branch_name_MONAN="" github_link_CONVERT_MPAS="" @@ -105,6 +116,14 @@ do github_link_MONAN="${2}" shift 2 # past flag and argument ;; + -h) + show_usage + exit 0 + ;; + -m12) + MONAN_ONETWO="${key}" + shift 1 # past flag + ;; *) echo "Unknown key-value argument pair." show_usage @@ -115,7 +134,7 @@ done #---~--- #---~--- -# Stop if any variable remains unset +# Make sure all required settings were provided. #---~--- if [[ "${tag_or_branch_name_CONVERT_MPAS}" == "" ]] || [[ "${tag_or_branch_name_MONAN}" == "" ]] || @@ -130,7 +149,7 @@ fi #--- Set environment variables exports: -. setenv.bash +. setenv.bash ${MONAN_ONETWO} #---~--- echo "" diff --git a/scripts/2.pre_processing.bash b/scripts/2.pre_processing.bash index 989d8e7..1f9cf62 100755 --- a/scripts/2.pre_processing.bash +++ b/scripts/2.pre_processing.bash @@ -24,21 +24,30 @@ umask 022 function show_usage() { echo " Usage: " echo "" - echo " ${0} [-o] [-e EXP ] [-f FCST] [-r RES] [-t YYYYMMDDHH]" + echo " ${0} [-h] [-m12] [-o] [-e EXP ] [-f FCST] [-r RES] [-t YYYYMMDDHH]" echo "" echo " List of optional flags: " echo "" + echo " -h -- Shows this message." + echo " -m12 -- Is this a MONAN run based on 1.2.0-rc and branches derived" + echo " from this version (e.g., feature/monan-757-NF)? This is a" + echo " temporary flag that will be removed once the versions" + echo " containing Noah-MP are merged into the new release. This" + echo " allows the script to manage older code and still run on jaci." echo " -o -- Overwrite static files." echo "" echo " List of **required** flags when -c is not set: " echo "" echo " -e EXP -- meteorological drivers. For example, GFS" echo " -f FCST -- Simulation length in hours, e.g., 24 or 48." - echo " -r RES -- grid resolution. Options are:" - echo " 5898242 (~ 10 km)" - echo " 2621442 (~ 15 km)" - echo " 1024002 (~ 24 km)" - echo " 40962 (~ 120 km)" + echo " -r RES -- grid resolution. Supported options are:" + echo " 65536002 (~ 3 km)" + echo " 5898242 (~ 10 km)" + echo " 2621442 (~ 15 km)" + echo " 1024002 (~ 24 km)" + echo " 655362 (~ 30 km)" + echo " 163842 (~ 60 km)" + echo " 40962 (~ 120 km)" echo " -t YYYYMMDDHH -- Initial time. For example if 22 Sept 2025 00 UTC, set it to:" echo " 2025092200" echo "" @@ -46,15 +55,11 @@ function show_usage() { #---~--- -#--- Set environment variables exports: -. setenv.bash -#---~--- - - #--- Default input variables: -OVERWRITE=true +OVERWRITE=false +MONAN_ONETWO="" EXP="" RES="" YYYYMMDDHHi="" @@ -75,6 +80,14 @@ do FCST="${2}" shift 2 # past flag and argument ;; + -h) + show_usage + exit 0 + ;; + -m12) + MONAN_ONETWO="${key}" + shift 1 # past flag + ;; -o) OVERWRITE=true shift 1 # past flag @@ -99,7 +112,7 @@ done #---~--- -# Make sure all settings were provided. +# Make sure all required settings were provided. #---~--- if [[ "${EXP}" == "" ]] || [[ "${RES}" == "" ]] || [[ "${YYYYMMDDHHi}" == "" ]] || [[ "${FCST}" == "" ]] @@ -111,6 +124,11 @@ fi #---~--- +#--- Set environment variables exports: +. setenv.bash ${MONAN_ONETWO} +#---~--- + + echo "" echo "---- Pre Processing ----" echo "" @@ -160,7 +178,7 @@ fi if ${OVERWRITE} || [[ ! -s ${DATAIN}/fixed/x1.${RES}.static.nc ]] then echo -e "${GREEN}==>${NC} Creating static.bash for submiting init_atmosphere to create x1.${RES}.static.nc...\n" - time ./make_static.bash -e ${EXP} -f ${FCST} -r ${RES} -t ${YYYYMMDDHHi} + time ./make_static.bash ${MONAN_ONETWO} -e ${EXP} -f ${FCST} -r ${RES} -t ${YYYYMMDDHHi} else echo -e "${GREEN}==>${NC} File x1.${RES}.static.nc already exist in ${DATAIN}/fixed.\n" fi @@ -169,13 +187,13 @@ fi #--- Run the degrib step. echo -e "${GREEN}==>${NC} Submitting Degrib...\n" -time ./make_degrib.bash -e ${EXP} -f ${FCST} -r ${RES} -t ${YYYYMMDDHHi} +time ./make_degrib.bash ${MONAN_ONETWO} -e ${EXP} -f ${FCST} -r ${RES} -t ${YYYYMMDDHHi} #---~--- #--- Run the atmosphere initialisation step. echo -e "${GREEN}==>${NC} Submitting Init Atmosphere...\n" -time ./make_initatmos.bash -e ${EXP} -f ${FCST} -r ${RES} -t ${YYYYMMDDHHi} +time ./make_initatmos.bash ${MONAN_ONETWO} -e ${EXP} -f ${FCST} -r ${RES} -t ${YYYYMMDDHHi} #---~--- diff --git a/scripts/3.run_model.bash b/scripts/3.run_model.bash index 2484120..61bd512 100755 --- a/scripts/3.run_model.bash +++ b/scripts/3.run_model.bash @@ -21,11 +21,18 @@ umask 022 function show_usage() { echo " Usage: " echo "" - echo " ${0} [-v VARTABLE] [-d OUTPUT_DIAG_INT] [-e EXP ] [-f FCST] [-l NLEV] \\" - echo " [-r RES] [-t YYYYMMDDHH]" + echo " ${0} [-h] [-m12] [-v VARTABLE] [-d OUTPUT_DIAG_INT] [-e EXP ] [-f FCST] \\" + echo " [-l NLEV] [-r RES] [-t YYYYMMDDHH]" echo "" echo " List of optional flags: " echo "" + echo " -h -- Shows this message." + echo " -m12 -- Is this a MONAN run based on 1.2.0-rc and branches" + echo " derived from this version (e.g., feature/monan-757-NF)?" + echo " This is a temporary flag that will be removed once the" + echo " versions containing Noah-MP are merged into the new" + echo " release. This allows the script to manage older code and" + echo " still run on jaci." echo " -v VARTABLE -- Suffix for defining which version of the" echo " stream_list_atmosphere.diagnostics template to use." echo " The default is to not use any suffix." @@ -37,11 +44,14 @@ function show_usage() { echo " -e EXP -- meteorological drivers. For example, GFS" echo " -f FCST -- Simulation length in hours, e.g., 24 or 48." echo " -l NLEV -- Number of vertical levels for the output." - echo " -r RES -- grid resolution. Options are:" - echo " 5898242 (~ 10 km)" - echo " 2621442 (~ 15 km)" - echo " 1024002 (~ 24 km)" - echo " 40962 (~ 120 km)" + echo " -r RES -- grid resolution. Supported options are:" + echo " 65536002 (~ 3 km)" + echo " 5898242 (~ 10 km)" + echo " 2621442 (~ 15 km)" + echo " 1024002 (~ 24 km)" + echo " 655362 (~ 30 km)" + echo " 163842 (~ 60 km)" + echo " 40962 (~ 120 km)" echo " -t YYYYMMDDHH -- Initial time. For example if 22 Sept 2025 00 UTC," echo " set it to: 2025092200" echo "" @@ -49,14 +59,10 @@ function show_usage() { #---~--- -#--- Set environment variables exports: -. setenv.bash -#---~--- - - #--- Default input variables: +MONAN_ONETWO="" EXP="" RES="" YYYYMMDDHHi="" @@ -84,10 +90,18 @@ do FCST="${2}" shift 2 # past flag and argument ;; + -h) + show_usage + exit 0 + ;; -l) NLEV="${2}" shift 2 # Past flag and argument ;; + -m12) + MONAN_ONETWO="${key}" + shift 1 # past flag + ;; -r) RES="${2}" shift 2 # past flag and argument @@ -116,7 +130,7 @@ done #---~--- -# Make sure all settings were provided (unless this will be to clean up runs). +# Make sure all required settings were provided. #---~--- if [[ "${EXP}" == "" ]] || [[ "${RES}" == "" ]] || [[ "${YYYYMMDDHHi}" == "" ]] || [[ "${FCST}" == "" ]] || @@ -128,6 +142,11 @@ then fi #---~--- + +#--- Set environment variables exports: +. setenv.bash ${LEGACY} +#---~--- + echo "" echo "---- Run Model ----" echo "" diff --git a/scripts/4.run_post.bash b/scripts/4.run_post.bash index adb7117..a038c3e 100755 --- a/scripts/4.run_post.bash +++ b/scripts/4.run_post.bash @@ -20,11 +20,18 @@ umask 022 function show_usage() { echo " Usage: " echo "" - echo " ${0} [-v VARTABLE] [-d OUTPUT_DIAG_INT] [-e EXP ] [-f FCST] \\" + echo " ${0} [-h] [-m12] [-v VARTABLE] [-d OUTPUT_DIAG_INT] [-e EXP ] [-f FCST] \\" echo " [-l N_MODEL_LEV] [-r RES] [-t YYYYMMDDHH]" echo "" echo " List of optional flags: " echo "" + echo " -h -- Shows this message." + echo " -m12 -- Is this a MONAN run based on 1.2.0-rc and branches" + echo " derived from this version (e.g., feature/monan-757-NF)?" + echo " This is a temporary flag that will be removed once the" + echo " versions containing Noah-MP are merged into the new" + echo " release. This allows the script to manage older code and" + echo " still run on jaci." echo " -v VARTABLE -- Suffix for defining which version of the" echo " stream_list_atmosphere.diagnostics template to use." echo " The default is to not use any suffix." @@ -36,11 +43,14 @@ function show_usage() { echo " -e EXP -- meteorological drivers. For example, GFS" echo " -f FCST -- Simulation length in hours, e.g., 24 or 48." echo " -l N_MODEL_LEV -- Number of vertical levels for the output." - echo " -r RES -- grid resolution. Options are:" - echo " 5898242 (~ 10 km)" - echo " 2621442 (~ 15 km)" - echo " 1024002 (~ 24 km)" - echo " 40962 (~ 120 km)" + echo " -r RES -- grid resolution. Supported options are:" + echo " 65536002 (~ 3 km)" + echo " 5898242 (~ 10 km)" + echo " 2621442 (~ 15 km)" + echo " 1024002 (~ 24 km)" + echo " 655362 (~ 30 km)" + echo " 163842 (~ 60 km)" + echo " 40962 (~ 120 km)" echo " -t YYYYMMDDHH -- Initial time. For example if 22 Sept 2025 00 UTC," echo " set it to: 2025092200" echo "" @@ -48,14 +58,10 @@ function show_usage() { #---~--- -#--- Set environment variables exports: -. setenv.bash -#---~--- - - #--- Default input variables: +MONAN_ONETWO="" EXP="" RES="" YYYYMMDDHHi="" @@ -83,10 +89,18 @@ do FCST="${2}" shift 2 # past flag and argument ;; + -h) + show_usage + exit 0 + ;; -l) N_MODEL_LEV="${2}" shift 2 # Past flag and argument ;; + -m12) + MONAN_ONETWO="${key}" + shift 1 # past flag + ;; -r) RES="${2}" shift 2 # past flag and argument @@ -113,9 +127,14 @@ done #---~--- +#--- Set environment variables exports: +. setenv.bash ${MONAN_ONETWO} +#---~--- + + #---~--- -# Make sure all settings were provided. +# Make sure all required settings were provided. #---~--- if [[ "${EXP}" == "" ]] || [[ "${RES}" == "" ]] || [[ "${YYYYMMDDHHi}" == "" ]] || [[ "${FCST}" == "" ]] || @@ -433,7 +452,7 @@ EOSH echo "" ;; PBS) - echo "Rodando em PBS" + echo "Running with PBS" echo -e "${GREEN}==>${NC} qsub PostAtmos_node.${node}.sh...\n" cd ${DIRRUN} jobid[${node}]=$(qsub ${DIRRUN}/PostAtmos_node.${node}.sh | cut -d '.' -f1) @@ -541,5 +560,5 @@ fi #CR: Append this script to script PostAtmos_node.0.sh, which has been submitted. cd ${SCRIPTS} chmod 755 ${DATAOUT}/${YYYYMMDDHHi}/Post/* -time ${SCRIPTS}/make_template.bash ${dv_VARTABLE} -d ${OUTPUT_DIAG_INTERVAL} -e ${EXP} \ - -f ${FCST} -r ${RES} -t ${YYYYMMDDHHi} +time ${SCRIPTS}/make_template.bash ${MONAN_ONETWO} ${dv_VARTABLE} \ + -d ${OUTPUT_DIAG_INTERVAL} -e ${EXP}-f ${FCST} -r ${RES} -t ${YYYYMMDDHHi} diff --git a/scripts/make_degrib.bash b/scripts/make_degrib.bash index cc45ba2..ee6a59c 100755 --- a/scripts/make_degrib.bash +++ b/scripts/make_degrib.bash @@ -6,17 +6,28 @@ umask 022 function show_usage() { echo " Usage: " echo "" - echo " ${0} [-e EXP ] [-f FCST] [-r RES] [-t YYYYMMDDHH]" + echo " ${0} [-h] [-m12] [-e EXP ] [-f FCST] [-r RES] [-t YYYYMMDDHH]" + echo "" + echo " List of optional flags: " + echo " -h -- Shows this message." + echo " -m12 -- Is this a MONAN run based on 1.2.0-rc and branches derived" + echo " from this version (e.g., feature/monan-757-NF)? This is a" + echo " temporary flag that will be removed once the versions" + echo " containing Noah-MP are merged into the new release. This" + echo " allows the script to manage older code and still run on jaci." echo "" echo " List of **required** flags: " echo "" echo " -e EXP -- meteorological drivers. For example, GFS" echo " -f FCST -- Simulation length in hours, e.g., 24 or 48." - echo " -r RES -- grid resolution. Options are:" - echo " 5898242 (~ 10 km)" - echo " 2621442 (~ 15 km)" - echo " 1024002 (~ 24 km)" - echo " 40962 (~ 120 km)" + echo " -r RES -- grid resolution. Supported options are:" + echo " 65536002 (~ 3 km)" + echo " 5898242 (~ 10 km)" + echo " 2621442 (~ 15 km)" + echo " 1024002 (~ 24 km)" + echo " 655362 (~ 30 km)" + echo " 163842 (~ 60 km)" + echo " 40962 (~ 120 km)" echo " -t YYYYMMDDHH -- Initial time. For example if 22 Sept 2025 00 UTC, set it to:" echo " 2025092200" echo "" @@ -24,14 +35,10 @@ function show_usage() { #---~--- -#--- Set environment variables exports: -. setenv.bash -#---~--- - - #--- Default input variables: +MONAN_ONETWO="" EXP="" RES="" YYYYMMDDHHi="" @@ -52,6 +59,14 @@ do FCST="${2}" shift 2 # past flag and argument ;; + -h) + show_usage + exit 0 + ;; + -m12) + MONAN_ONETWO="${key}" + shift 1 # past flag + ;; -r) RES="${2}" shift 2 # past flag and argument @@ -72,7 +87,7 @@ done #---~--- -# Make sure all settings were provided (unless this will be to clean up runs). +# Make sure all required settings were provided. #---~--- if [[ "${EXP}" == "" ]] || [[ "${RES}" == "" ]] || [[ "${YYYYMMDDHHi}" == "" ]] || [[ "${FCST}" == "" ]] @@ -83,6 +98,11 @@ then fi #---~--- + +#--- Set environment variables exports: +. setenv.bash ${MONAN_ONETWO} +#---~--- + echo "" echo "---- Make Degrib ----" echo "" diff --git a/scripts/make_initatmos.bash b/scripts/make_initatmos.bash index f767a42..a0d5e12 100755 --- a/scripts/make_initatmos.bash +++ b/scripts/make_initatmos.bash @@ -8,17 +8,28 @@ umask 022 function show_usage() { echo " Usage: " echo "" - echo " ${0} [-e EXP ] [-f FCST] [-r RES] [-t YYYYMMDDHH]" + echo " ${0} [-h] [-m12] [-e EXP ] [-f FCST] [-r RES] [-t YYYYMMDDHH]" + echo "" + echo " List of optional flags: " + echo " -h -- Shows this message." + echo " -m12 -- Is this a MONAN run based on 1.2.0-rc and branches derived" + echo " from this version (e.g., feature/monan-757-NF)? This is a" + echo " temporary flag that will be removed once the versions" + echo " containing Noah-MP are merged into the new release. This" + echo " allows the script to manage older code and still run on jaci." echo "" echo " List of **required** flags: " echo "" echo " -e EXP -- meteorological drivers. For example, GFS" echo " -f FCST -- Simulation length in hours, e.g., 24 or 48." - echo " -r RES -- grid resolution. Options are:" - echo " 5898242 (~ 10 km)" - echo " 2621442 (~ 15 km)" - echo " 1024002 (~ 24 km)" - echo " 40962 (~ 120 km)" + echo " -r RES -- grid resolution. Supported options are:" + echo " 65536002 (~ 3 km)" + echo " 5898242 (~ 10 km)" + echo " 2621442 (~ 15 km)" + echo " 1024002 (~ 24 km)" + echo " 655362 (~ 30 km)" + echo " 163842 (~ 60 km)" + echo " 40962 (~ 120 km)" echo " -t YYYYMMDDHH -- Initial time. For example if 22 Sept 2025 00 UTC, set it to:" echo " 2025092200" echo "" @@ -26,13 +37,9 @@ function show_usage() { #---~--- -#--- Set environment variables exports: -. setenv.bash -#---~--- - - #--- Default input variables: +MONAN_ONETWO="" EXP="" RES="" YYYYMMDDHHi="" @@ -53,6 +60,14 @@ do FCST="${2}" shift 2 # past flag and argument ;; + -h) + show_usage + exit 0 + ;; + -m12) + MONAN_ONETWO="${key}" + shift 1 # past flag + ;; -r) RES="${2}" shift 2 # past flag and argument @@ -73,7 +88,7 @@ done #---~--- -# Make sure all settings were provided (unless this will be to clean up runs). +# Make sure all required settings were provided. #---~--- if [[ "${EXP}" == "" ]] || [[ "${RES}" == "" ]] || [[ "${YYYYMMDDHHi}" == "" ]] || [[ "${FCST}" == "" ]] @@ -85,6 +100,11 @@ fi #---~--- +#--- Set environment variables exports: +. setenv.bash ${MONAN_ONETWO} +#---~--- + + #--- Set and create standard directories DIRHOMES=${DIR_SCRIPTS}/scripts_CD-CT; mkdir -p ${DIRHOMES} DIRHOMED=${DIR_DADOS}/scripts_CD-CT; mkdir -p ${DIRHOMED} diff --git a/scripts/make_static.bash b/scripts/make_static.bash index 054c314..b8de81f 100755 --- a/scripts/make_static.bash +++ b/scripts/make_static.bash @@ -6,17 +6,28 @@ umask 022 function show_usage() { echo " Usage: " echo "" - echo " ${0} [-e EXP ] [-f FCST] [-r RES] [-t YYYYMMDDHH]" + echo " ${0} [-h] [-m12] [-e EXP ] [-f FCST] [-r RES] [-t YYYYMMDDHH]" + echo "" + echo " List of optional flags: " + echo " -h -- Shows this message." + echo " -m12 -- Is this a MONAN run based on 1.2.0-rc and branches derived" + echo " from this version (e.g., feature/monan-757-NF)? This is a" + echo " temporary flag that will be removed once the versions" + echo " containing Noah-MP are merged into the new release. This" + echo " allows the script to manage older code and still run on jaci." echo "" echo " List of **required** flags: " echo "" echo " -e EXP -- meteorological drivers. For example, GFS" echo " -f FCST -- Simulation length in hours, e.g., 24 or 48." - echo " -r RES -- grid resolution. Options are:" - echo " 5898242 (~ 10 km)" - echo " 2621442 (~ 15 km)" - echo " 1024002 (~ 24 km)" - echo " 40962 (~ 120 km)" + echo " -r RES -- grid resolution. Supported options are:" + echo " 65536002 (~ 3 km)" + echo " 5898242 (~ 10 km)" + echo " 2621442 (~ 15 km)" + echo " 1024002 (~ 24 km)" + echo " 655362 (~ 30 km)" + echo " 163842 (~ 60 km)" + echo " 40962 (~ 120 km)" echo " -t YYYYMMDDHH -- Initial time. For example if 22 Sept 2025 00 UTC, set it to:" echo " 2025092200" echo "" @@ -25,13 +36,8 @@ function show_usage() { -#--- Set environment variables exports: -. setenv.bash -#---~--- - - - #--- Default input variables: +MONAN_ONETWO="" EXP="" RES="" YYYYMMDDHHi="" @@ -52,6 +58,14 @@ do FCST="${2}" shift 2 # past flag and argument ;; + -h) + show_usage + exit 0 + ;; + -m12) + MONAN_ONETWO="${key}" + shift 1 # past flag + ;; -r) RES="${2}" shift 2 # past flag and argument @@ -72,7 +86,7 @@ done #---~--- -# Make sure all settings were provided (unless this will be to clean up runs). +# Make sure all required settings were provided. #---~--- if [[ "${EXP}" == "" ]] || [[ "${RES}" == "" ]] || [[ "${YYYYMMDDHHi}" == "" ]] || [[ "${FCST}" == "" ]] @@ -83,6 +97,12 @@ then fi #---~--- + + +#--- Set environment variables exports: +. setenv.bash ${MONAN_ONETWO} +#---~--- + echo "" echo "---- Make Static ----" echo "" diff --git a/scripts/make_template.bash b/scripts/make_template.bash index 8ae8b96..8dc008d 100755 --- a/scripts/make_template.bash +++ b/scripts/make_template.bash @@ -20,11 +20,18 @@ umask 022 function show_usage() { echo " Usage: " echo "" - echo " ${0} [-v VARTABLE] [-d OUTPUT_DIAG_INT] [-e EXP ] [-f FCST] \\" + echo " ${0} [-h] [-m12] [-v VARTABLE] [-d OUTPUT_DIAG_INT] [-e EXP ] [-f FCST] \\" echo " [-r RES] [-t YYYYMMDDHH]" echo "" echo " List of optional flags: " echo "" + echo " -h -- Shows this message." + echo " -m12 -- Is this a MONAN run based on 1.2.0-rc and branches" + echo " derived from this version (e.g., feature/monan-757-NF)?" + echo " This is a temporary flag that will be removed once the" + echo " versions containing Noah-MP are merged into the new" + echo " release. This allows the script to manage older code and" + echo " still run on jaci." echo " -v VARTABLE -- Suffix for defining which version of the" echo " stream_list_atmosphere.diagnostics template to use." echo " The default is to not use any suffix." @@ -35,25 +42,25 @@ function show_usage() { echo " \"HH:MM:SS\"" echo " -e EXP -- meteorological drivers. For example, GFS" echo " -f FCST -- Simulation length in hours, e.g., 24 or 48." - echo " -r RES -- grid resolution. Options are:" - echo " 5898242 (~ 10 km)" - echo " 2621442 (~ 15 km)" - echo " 1024002 (~ 24 km)" - echo " 40962 (~ 120 km)" + echo " -r RES -- grid resolution. Supported options are:" + echo " 65536002 (~ 3 km)" + echo " 5898242 (~ 10 km)" + echo " 2621442 (~ 15 km)" + echo " 1024002 (~ 24 km)" + echo " 655362 (~ 30 km)" + echo " 163842 (~ 60 km)" + echo " 40962 (~ 120 km)" echo " -t YYYYMMDDHH -- Initial time. For example if 22 Sept 2025 00 UTC," echo " set it to: 2025092200" echo "" } #---~--- -# Set environment variables exports: -. setenv.bash - #--- Default input variables: -CLEAN=false +MONAN_ONETWO="" EXP="" RES="" YYYYMMDDHHi="" @@ -68,10 +75,6 @@ while [[ ${#} > 0 ]] do key="${1}" case ${key} in - -c) - CLEAN=true - shift 1 # Past flag - ;; -d) OUTPUT_DIAG_INTERVAL="${2}" shift 2 # Past flag and argument @@ -84,6 +87,14 @@ do FCST="${2}" shift 2 # past flag and argument ;; + -h) + show_usage + exit 0 + ;; + -m12) + MONAN_ONETWO="${key}" + shift 1 # past flag + ;; -r) RES="${2}" shift 2 # past flag and argument @@ -112,7 +123,7 @@ done #---~--- -# Make sure all settings were provided (unless this will be to clean up runs). +# Make sure all required settings were provided. #---~--- if [[ "${EXP}" == "" ]] || [[ "${RES}" == "" ]] || [[ "${YYYYMMDDHHi}" == "" ]] || [[ "${FCST}" == "" ]] || @@ -124,6 +135,11 @@ then fi #---~--- + +#--- Set environment variables exports: +. setenv.bash ${MONAN_ONETWO} +#---~--- + echo "" echo "---- Make Template ----" echo "" diff --git a/scripts/setenv.bash b/scripts/setenv.bash index a563932..487e2fb 100755 --- a/scripts/setenv.bash +++ b/scripts/setenv.bash @@ -11,6 +11,7 @@ export BLUE='\033[01;34m' # Blue export ORANGE='\033[01;91m' # Orange #---~---- + #---~---- # Notify users that this script is being called. # Please refrain from changing these commands. @@ -20,6 +21,39 @@ echo -e "${GREEN}==>${NC} Load MONAN settings (setenv.bash).\n" #---~---- +#--- Parse arguments. +MONAN_ONETWO=false +while [[ ${#} > 0 ]] +do + key="${1}" + case ${key} in + -m12) + MONAN_ONETWO=true + shift 1 # past flag + ;; + *) + echo "" + echo " Unknown key-value argument pair." + echo " Usage: " + echo "" + echo " . ${BASH_SOURCE[0]} [-m12]" + echo "" + echo " List of optional flags: " + echo "" + echo " -m12 -- Is this a MONAN run based on 1.2.0-rc and branches" + echo " derived from this version (e.g., feature/monan-757-NF)?" + echo " This is a temporary flag that will be removed once the" + echo " versions containing Noah-MP are merged into the new" + echo " release. This allows the script to manage older code and" + echo " still run on jaci." + echo "" + return + ;; + esac +done +#---~--- + + # Choose your compiler here (only on Jaci; on Egeon the compiler is fixed to ‘gnu’): export COMPILER=intel #export COMPILER=gnu @@ -60,19 +94,34 @@ egeon-login|headnode|n[0-9]|n[1-2][0-9]|n3[0-3]) ;; ian[0-9]*|cn-0[0-9][0-9][0-9]) #---~--- - # Jaci. Decide which compiler to use based on variable COMPILER + # Jaci. Decide which compiler to use based on variable COMPILER and the MONAN + # version we are running. #---~--- export HOSTNAME="ian" - case "${COMPILER}" in - intel) - export MAKE_TARG=intel-xd2000 - export MAKE_TARG2=intel2-xd2000 - ;; - gnu) - export MAKE_TARG=gfortran-xd2000 - export MAKE_TARG2=gfortran-xd2000 - ;; - esac + if ${MONAN_ONETWO} + then + case "${COMPILER}" in + intel) + export MAKE_TARG=intel + export MAKE_TARG2=intel + ;; + gnu) + export MAKE_TARG=gfortran + export MAKE_TARG2=gfortran + ;; + esac + else + case "${COMPILER}" in + intel) + export MAKE_TARG=intel-xd2000 + export MAKE_TARG2=intel2-xd2000 + ;; + gnu) + export MAKE_TARG=gfortran-xd2000 + export MAKE_TARG2=gfortran-xd2000 + ;; + esac + fi #---~--- ;; *) From 36c2faacd9436052b442620405b413e0c2bb8912 Mon Sep 17 00:00:00 2001 From: Marcos Longo Date: Tue, 27 Jan 2026 09:14:47 -0300 Subject: [PATCH 03/15] Some options do not seem to be working. Add more context to the error message. --- scripts/0.run_all.bash | 7 +++++-- scripts/1.install_monan.bash | 8 +++++++- scripts/2.pre_processing.bash | 8 +++++++- scripts/3.run_model.bash | 8 +++++++- scripts/4.run_post.bash | 8 +++++++- scripts/make_degrib.bash | 8 +++++++- scripts/make_initatmos.bash | 8 +++++++- scripts/make_static.bash | 8 +++++++- scripts/make_template.bash | 8 +++++++- 9 files changed, 61 insertions(+), 10 deletions(-) diff --git a/scripts/0.run_all.bash b/scripts/0.run_all.bash index 89112ba..b2a7e5f 100755 --- a/scripts/0.run_all.bash +++ b/scripts/0.run_all.bash @@ -171,11 +171,14 @@ do shift 1 # past flag ;; *) - echo " *** FATAL ERROR! ***" echo "" - echo " Unknown key-value argument pair." + echo " Option \"${key}\" is not valid." echo "" show_usage + echo "" + echo " *** FATAL ERROR! ***" + echo " Unknown key or key-value argument pair." + echo "" exit 2 ;; esac diff --git a/scripts/1.install_monan.bash b/scripts/1.install_monan.bash index 89f35c3..60c7759 100755 --- a/scripts/1.install_monan.bash +++ b/scripts/1.install_monan.bash @@ -125,8 +125,14 @@ do shift 1 # past flag ;; *) - echo "Unknown key-value argument pair." + echo "" + echo " Option \"${key}\" is not valid." + echo "" show_usage + echo "" + echo " *** FATAL ERROR! ***" + echo " Unknown key or key-value argument pair." + echo "" exit 2 ;; esac diff --git a/scripts/2.pre_processing.bash b/scripts/2.pre_processing.bash index 1f9cf62..b362a9b 100755 --- a/scripts/2.pre_processing.bash +++ b/scripts/2.pre_processing.bash @@ -101,8 +101,14 @@ do shift 2 # past flag and argument ;; *) - echo "Unknown key-value argument pair." + echo "" + echo " Option \"${key}\" is not valid." + echo "" show_usage + echo "" + echo " *** FATAL ERROR! ***" + echo " Unknown key or key-value argument pair." + echo "" exit 2 ;; esac diff --git a/scripts/3.run_model.bash b/scripts/3.run_model.bash index 61bd512..6919ea8 100755 --- a/scripts/3.run_model.bash +++ b/scripts/3.run_model.bash @@ -119,8 +119,14 @@ do shift 2 # past flag and argument ;; *) - echo "Unknown key-value argument pair." + echo "" + echo " Option \"${key}\" is not valid." + echo "" show_usage + echo "" + echo " *** FATAL ERROR! ***" + echo " Unknown key or key-value argument pair." + echo "" exit 2 ;; esac diff --git a/scripts/4.run_post.bash b/scripts/4.run_post.bash index a038c3e..5aa3217 100755 --- a/scripts/4.run_post.bash +++ b/scripts/4.run_post.bash @@ -118,8 +118,14 @@ do shift 2 # past flag and argument ;; *) - echo "Unknown key-value argument pair." + echo "" + echo " Option \"${key}\" is not valid." + echo "" show_usage + echo "" + echo " *** FATAL ERROR! ***" + echo " Unknown key or key-value argument pair." + echo "" exit 2 ;; esac diff --git a/scripts/make_degrib.bash b/scripts/make_degrib.bash index ee6a59c..da6827d 100755 --- a/scripts/make_degrib.bash +++ b/scripts/make_degrib.bash @@ -76,8 +76,14 @@ do shift 2 # past flag and argument ;; *) - echo "Unknown key-value argument pair." + echo "" + echo " Option \"${key}\" is not valid." + echo "" show_usage + echo "" + echo " *** FATAL ERROR! ***" + echo " Unknown key or key-value argument pair." + echo "" exit 2 ;; esac diff --git a/scripts/make_initatmos.bash b/scripts/make_initatmos.bash index a0d5e12..b51d587 100755 --- a/scripts/make_initatmos.bash +++ b/scripts/make_initatmos.bash @@ -77,8 +77,14 @@ do shift 2 # past flag and argument ;; *) - echo "Unknown key-value argument pair." + echo "" + echo " Option \"${key}\" is not valid." + echo "" show_usage + echo "" + echo " *** FATAL ERROR! ***" + echo " Unknown key or key-value argument pair." + echo "" exit 2 ;; esac diff --git a/scripts/make_static.bash b/scripts/make_static.bash index b8de81f..723c1d9 100755 --- a/scripts/make_static.bash +++ b/scripts/make_static.bash @@ -75,8 +75,14 @@ do shift 2 # past flag and argument ;; *) - echo "Unknown key-value argument pair." + echo "" + echo " Option \"${key}\" is not valid." + echo "" show_usage + echo "" + echo " *** FATAL ERROR! ***" + echo " Unknown key or key-value argument pair." + echo "" exit 2 ;; esac diff --git a/scripts/make_template.bash b/scripts/make_template.bash index 8dc008d..1a06f8b 100755 --- a/scripts/make_template.bash +++ b/scripts/make_template.bash @@ -112,8 +112,14 @@ do shift 2 # past flag and argument ;; *) - echo "Unknown key-value argument pair." + echo "" + echo " Option \"${key}\" is not valid." + echo "" show_usage + echo "" + echo " *** FATAL ERROR! ***" + echo " Unknown key or key-value argument pair." + echo "" exit 2 ;; esac From 3ef8a38f3e255d2aecf43622e3c0d1e3ddf97d8a Mon Sep 17 00:00:00 2001 From: Marcos Longo Date: Tue, 27 Jan 2026 09:24:24 -0300 Subject: [PATCH 04/15] I edited every setenv.bash call so all of them load the MONAN_ONETWO flag, and edited setenv.bash to provide a unique name for the true/false version of the -m12 flag. --- scripts/0.run_all.bash | 6 +++--- scripts/1.install_monan.bash | 4 ++-- scripts/3.run_model.bash | 4 ++-- scripts/4.run_post.bash | 4 ++-- scripts/make_degrib.bash | 2 +- scripts/make_initatmos.bash | 2 +- scripts/make_static.bash | 2 +- scripts/make_template.bash | 2 +- scripts/setenv.bash | 6 +++--- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/scripts/0.run_all.bash b/scripts/0.run_all.bash index b2a7e5f..26ac77e 100755 --- a/scripts/0.run_all.bash +++ b/scripts/0.run_all.bash @@ -350,7 +350,7 @@ case ${STEP} in #---~--- # STEP 2: Run the pre-processing step, and make initial/boundary conditions if needed. #---~--- - time 2.pre_processing.bash ${OVERWRITE} ${MONAN_ONETWO} -e ${EXP} -f ${FCST} -r ${RES} \ + time 2.pre_processing.bash ${MONAN_ONETWO} ${OVERWRITE} -e ${EXP} -f ${FCST} -r ${RES} \ -t ${YYYYMMDDHHi} #---~--- ;; @@ -358,7 +358,7 @@ case ${STEP} in #---~--- # STEP 3: Run the model. #---~--- - time 3.run_model.bash ${dv_VARTABLE} ${MONAN_ONETWO} -d ${OUTPUT_DIAG_INTERVAL} \ + time 3.run_model.bash ${MONAN_ONETWO} ${dv_VARTABLE} -d ${OUTPUT_DIAG_INTERVAL} \ -e ${EXP} -f ${FCST} -l ${NLEV} -r ${RES} -t ${YYYYMMDDHHi} #---~--- ;; @@ -366,7 +366,7 @@ case ${STEP} in #---~--- # STEP 4: Run the post-processing step. #---~--- - time 4.run_post.bash ${dv_VARTABLE} ${MONAN_ONETWO} -d ${OUTPUT_DIAG_INTERVAL} \ + time 4.run_post.bash ${MONAN_ONETWO} ${dv_VARTABLE} -d ${OUTPUT_DIAG_INTERVAL} \ -e ${EXP} -f ${FCST} -l ${NLEV} -r ${RES} -t ${YYYYMMDDHHi} #---~--- ;; diff --git a/scripts/1.install_monan.bash b/scripts/1.install_monan.bash index 60c7759..3fd4d97 100755 --- a/scripts/1.install_monan.bash +++ b/scripts/1.install_monan.bash @@ -190,7 +190,7 @@ CONVERT_MPAS_DIR=${SOURCES}/convert_mpas_${tag_or_branch_name_CONVERT_MPAS} #$(sed -i "s;DIR_DADOS=.*$;DIR_DADOS=$(dirname $(dirname $(pwd)));" setenv.bash) $(sed -i "s;MONANDIR=.*$;MONANDIR=$MONANDIR;" setenv.bash) chmod 755 ${SCRIPTS}/setenv.bash -. ${SCRIPTS}/setenv.bash +. ${SCRIPTS}/setenv.bash ${MONAN_ONETWO} #---------------------------------------------------------------------- @@ -285,7 +285,7 @@ cat << EOF > make-all.sh # SHAREDLIB=true - generate position-independent code suitable for use in a shared library. Default is false. cd ${SCRIPTS} -. ${SCRIPTS}/setenv.bash +. ${SCRIPTS}/setenv.bash ${MONAN_ONETWO} cd $MONANDIR rm -rf $MONANDIR/default_inputs/ $MONANDIR/src/core_atmosphere/physics/physics_wrf/files diff --git a/scripts/3.run_model.bash b/scripts/3.run_model.bash index 6919ea8..b6f0325 100755 --- a/scripts/3.run_model.bash +++ b/scripts/3.run_model.bash @@ -150,7 +150,7 @@ fi #--- Set environment variables exports: -. setenv.bash ${LEGACY} +. setenv.bash ${MONAN_ONETWO} #---~--- echo "" @@ -329,7 +329,7 @@ ulimit -v unlimited ulimit -s unlimited cd ${DIRRUN} -. ${SCRIPTS}/setenv.bash +. ${SCRIPTS}/setenv.bash ${MONAN_ONETWO} date beg_secs=\`date +"%s"\` diff --git a/scripts/4.run_post.bash b/scripts/4.run_post.bash index 5aa3217..5e18a91 100755 --- a/scripts/4.run_post.bash +++ b/scripts/4.run_post.bash @@ -393,7 +393,7 @@ do cat << EOSH >> ${DIRRUN}/PostAtmos_node.${node}.sh cd ${DIRRUN} -. ${SCRIPTS}/setenv.bash +. ${SCRIPTS}/setenv.bash ${MONAN_ONETWO} chmod 755 ${DIRRUN}/* echo "Submitting posts ${inicio} to ${fim} to node Node ${node}." @@ -514,7 +514,7 @@ esac cat << EOSH >> ${DIRRUN}/PostAtmos_node.${node}.sh cd ${DIRRUN} -. ${SCRIPTS}/setenv.bash +. ${SCRIPTS}/setenv.bash ${MONAN_ONETWO} # Saving important files to the logs directory: cp -f ${EXECS}/CONVMPAS-VERSION.txt ${DATAOUT}/${YYYYMMDDHHi}/Post diff --git a/scripts/make_degrib.bash b/scripts/make_degrib.bash index da6827d..1aef8c6 100755 --- a/scripts/make_degrib.bash +++ b/scripts/make_degrib.bash @@ -224,7 +224,7 @@ export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:${HOME}/local/lib64 cd ${DIRRUN} -. ${SCRIPTS}/setenv.bash +. ${SCRIPTS}/setenv.bash ${MONAN_ONETWO} ldd ungrib.exe diff --git a/scripts/make_initatmos.bash b/scripts/make_initatmos.bash index b51d587..f8c0a69 100755 --- a/scripts/make_initatmos.bash +++ b/scripts/make_initatmos.bash @@ -210,7 +210,7 @@ ulimit -s unlimited cd ${DIRRUN} -. ${SCRIPTS}/setenv.bash +. ${SCRIPTS}/setenv.bash ${MONAN_ONETWO} date diff --git a/scripts/make_static.bash b/scripts/make_static.bash index 723c1d9..98d43ee 100755 --- a/scripts/make_static.bash +++ b/scripts/make_static.bash @@ -211,7 +211,7 @@ ulimit -c unlimited ulimit -v unlimited -. ${SCRIPTS}/setenv.bash +. ${SCRIPTS}/setenv.bash ${MONAN_ONETWO} cd ${DIRRUN} chmod 755 * diff --git a/scripts/make_template.bash b/scripts/make_template.bash index 1a06f8b..f42939b 100755 --- a/scripts/make_template.bash +++ b/scripts/make_template.bash @@ -292,7 +292,7 @@ EOGS cd ${DIRRUN} -. ${SCRIPTS}/setenv.bash +. ${SCRIPTS}/setenv.bash ${MONAN_ONETWO} chmod 755 * diff --git a/scripts/setenv.bash b/scripts/setenv.bash index 487e2fb..2323e2a 100755 --- a/scripts/setenv.bash +++ b/scripts/setenv.bash @@ -22,13 +22,13 @@ echo -e "${GREEN}==>${NC} Load MONAN settings (setenv.bash).\n" #--- Parse arguments. -MONAN_ONETWO=false +USE_ONETWO=false while [[ ${#} > 0 ]] do key="${1}" case ${key} in -m12) - MONAN_ONETWO=true + USE_ONETWO=true shift 1 # past flag ;; *) @@ -98,7 +98,7 @@ ian[0-9]*|cn-0[0-9][0-9][0-9]) # version we are running. #---~--- export HOSTNAME="ian" - if ${MONAN_ONETWO} + if ${USE_ONETWO} then case "${COMPILER}" in intel) From 494e94d0421ed8724ae1176fb6953b07ea7395a4 Mon Sep 17 00:00:00 2001 From: Marcos Longo Date: Tue, 27 Jan 2026 12:48:52 -0300 Subject: [PATCH 05/15] Remove if statement from setenv.bash, and try to edit MONAN's Makefile instead. --- scripts/setenv.bash | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/scripts/setenv.bash b/scripts/setenv.bash index 2323e2a..2cf692c 100755 --- a/scripts/setenv.bash +++ b/scripts/setenv.bash @@ -98,30 +98,16 @@ ian[0-9]*|cn-0[0-9][0-9][0-9]) # version we are running. #---~--- export HOSTNAME="ian" - if ${USE_ONETWO} - then - case "${COMPILER}" in - intel) - export MAKE_TARG=intel - export MAKE_TARG2=intel - ;; - gnu) - export MAKE_TARG=gfortran - export MAKE_TARG2=gfortran - ;; - esac - else - case "${COMPILER}" in - intel) - export MAKE_TARG=intel-xd2000 - export MAKE_TARG2=intel2-xd2000 - ;; - gnu) - export MAKE_TARG=gfortran-xd2000 - export MAKE_TARG2=gfortran-xd2000 - ;; - esac - fi + case "${COMPILER}" in + intel) + export MAKE_TARG=intel-xd2000 + export MAKE_TARG2=intel2-xd2000 + ;; + gnu) + export MAKE_TARG=gfortran-xd2000 + export MAKE_TARG2=gfortran-xd2000 + ;; + esac #---~--- ;; *) From 10cf56b2d266be8cea2a47c94868d3d57c1aaf23 Mon Sep 17 00:00:00 2001 From: Marcos Longo Date: Tue, 27 Jan 2026 13:06:03 -0300 Subject: [PATCH 06/15] Bug fix, variable DIRDADOS is no longer defined in setenv.bash, so INPUT_PATH must update the system-specific setenv.bash --- scripts/0.run_all.bash | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/0.run_all.bash b/scripts/0.run_all.bash index 26ac77e..6208777 100755 --- a/scripts/0.run_all.bash +++ b/scripts/0.run_all.bash @@ -262,8 +262,9 @@ fi #--- If INPUT_PATH is provided, replace the path in setenv.bash if [[ "${INPUT_PATH}" != "" ]] && [[ -d "${INPUT_PATH}" ]] then - sed -i.bck "s,^export DIRDADOS=.*,export DIRDADOS=${INPUT_PATH},g" ${SCRIPTS}/setenv.bash - /bin/rm -f ${SCRIPTS}/setenv.bash.bck + SYSTEM_SETENV="${DIR_SCRIPTS}/scripts_CD-CT/scripts/stools/setenv_${SYSTEM_KEYC}.bash" + sed -i.bck "s,^export DIRDADOS=.*,export DIRDADOS=${INPUT_PATH},g" ${SYSTEM_SETENV} + /bin/rm -f ${SYSTEM_SETENV}.bck fi #---~--- From 856b26bcf0bcbffe1690d078df00c05f75a43514 Mon Sep 17 00:00:00 2001 From: Marcos Longo Date: Tue, 27 Jan 2026 15:05:00 -0300 Subject: [PATCH 07/15] Somehow step 2 is not running due to paths being incorrect on jaci. It could be a PBS problem. I attempted to fix by defining the paths DIR_SCRIPTS and DIR_DADOS based on the actual location of setenv.bash instead of $(pwd) --- scripts/3.run_model.bash | 2 +- scripts/make_degrib.bash | 4 ++-- scripts/make_initatmos.bash | 4 ++-- scripts/make_static.bash | 3 ++- scripts/setenv.bash | 4 +++- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/scripts/3.run_model.bash b/scripts/3.run_model.bash index b6f0325..76edcfb 100755 --- a/scripts/3.run_model.bash +++ b/scripts/3.run_model.bash @@ -267,7 +267,7 @@ for file in "${files_needed[@]}" do if [[ ! -s "${file}" ]] then - echo -e "\n${RED}==>${NC} ***** ATTENTION *****\n" + echo -e "\n${RED}==>${NC} ***** FATAL ERROR *****\n" echo -e "${RED}==>${NC} [${0}] At least the file ${file} was not generated. \n" exit -1 fi diff --git a/scripts/make_degrib.bash b/scripts/make_degrib.bash index 1aef8c6..525892e 100755 --- a/scripts/make_degrib.bash +++ b/scripts/make_degrib.bash @@ -178,7 +178,7 @@ for file in "${files_needed[@]}" do if [[ ! -s "${file}" ]] then - echo -e "\n${RED}==>${NC} ***** ATTENTION *****\n" + echo -e "\n${RED}==>${NC} ***** FATAL ERROR *****\n" echo -e "${RED}==>${NC} [${0}] At least the file ${file} was not generated. \n" exit -1 fi @@ -297,7 +297,7 @@ for file in "${files_ungrib[@]}" do if [[ ! -s ${DATAOUT}/${YYYYMMDDHHi}/Pre/${file} ]] then - echo -e "\n${RED}==>${NC} ***** ATTENTION *****\n" + echo -e "\n${RED}==>${NC} ***** FATAL ERROR *****\n" echo -e "${RED}==>${NC} Degrib fails! At least the file ${file} was not generated at ${DATAIN}/${YYYYMMDDHHi}. \n" echo -e "${RED}==>${NC} Check logs at ${DATAOUT}/logs/degrib.* .\n" echo -e "${RED}==>${NC} Exiting script. \n" diff --git a/scripts/make_initatmos.bash b/scripts/make_initatmos.bash index f8c0a69..6ef695b 100755 --- a/scripts/make_initatmos.bash +++ b/scripts/make_initatmos.bash @@ -157,7 +157,7 @@ for file in "${files_needed[@]}" do if [[ ! -s "${file}" ]] then - echo -e "\n${RED}==>${NC} ***** ATTENTION *****\n" + echo -e "\n${RED}==>${NC} ***** FATAL ERROR *****\n" echo -e "${RED}==>${NC} [${0}] At least the file ${file} was not generated. \n" exit -1 fi @@ -270,7 +270,7 @@ mv ${DIRRUN}/initatmos.bash ${DATAOUT}/${YYYYMMDDHHi}/Pre/logs if [[ ! -s ${DATAOUT}/${YYYYMMDDHHi}/Pre/x1.${RES}.init.nc ]] then - echo -e "\n${RED}==>${NC} ***** ATTENTION *****\n" + echo -e "\n${RED}==>${NC} ***** FATAL ERROR *****\n" echo -e "${RED}==>${NC} Init Atmosphere phase fails! Check logs at ${DATAOUT}/logs/initatmos.* .\n" echo -e "${RED}==>${NC} Exiting script. \n" exit -1 diff --git a/scripts/make_static.bash b/scripts/make_static.bash index 98d43ee..153b36f 100755 --- a/scripts/make_static.bash +++ b/scripts/make_static.bash @@ -264,7 +264,7 @@ rm -fr ${DATAIN}/fixed/x1.${RES}.static.nc case "${SCHEDULER_SYSTEM}" in SLURM) - echo -e "${GREEN}==>${NC} Sbatch static.bash...\n" + echo -e "${GREEN}==>${NC} sbatch static.bash...\n" cd ${DIRRUN} sbatch --wait ${DIRRUN}/static.bash ;; @@ -291,6 +291,7 @@ then mv ${DIRRUN}/x1.${RES}.static.nc ${DATAIN}/fixed chmod 755 ${DATAIN}/fixed/* else + echo -e "${RED}==>${NC} ****** FATAL ERROR ******\n" echo -e "${RED}==>${NC} File ${DIRRUN}/x1.${RES}.static.nc was not created. \n" exit -1 fi diff --git a/scripts/setenv.bash b/scripts/setenv.bash index 2cf692c..2d8a28a 100755 --- a/scripts/setenv.bash +++ b/scripts/setenv.bash @@ -132,7 +132,9 @@ export SYSTEM_KEYC="${SCHEDULER_SYSTEM}_${HOSTNAME}_${COMPILER}" # MONAN-suite install root directories: # Put your directories: -export DIR_SCRIPTS=$(dirname $(dirname $(pwd))) +#ML slightly edited the logic in here, somehow using pwd was leading to errors on Jaci. +export THIS_PATH=`(cd "$(dirname ${BASH_SOURCE[0]})" && pwd)` +export DIR_SCRIPTS=$(dirname $(dirname ${THIS_PATH})) export DIR_DADOS=${DIR_SCRIPTS} export MONANDIR=$MONANDIR From 2ddb0e85a0c5241a505beb2a8fe51a33700efe76 Mon Sep 17 00:00:00 2001 From: Marcos Longo Date: Tue, 27 Jan 2026 16:51:22 -0300 Subject: [PATCH 08/15] Add config_lsm_scheme to the default namelist (so it is easier to change when switching to another model) --- scripts/namelists/namelist.atmosphere.TEMPLATE | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/namelists/namelist.atmosphere.TEMPLATE b/scripts/namelists/namelist.atmosphere.TEMPLATE index 72952b9..11d4b70 100755 --- a/scripts/namelists/namelist.atmosphere.TEMPLATE +++ b/scripts/namelists/namelist.atmosphere.TEMPLATE @@ -63,6 +63,7 @@ config_conv_interval = '#CONFIG_CONV_INTERVAL#' config_bucket_update = 'none' config_physics_suite = 'mesoscale_reference_monan' + config_lsm_scheme = 'sf_noah' config_mynn_edmf = 0 / &gf_monan From b886961ac47cf455357b08aedbfdb865e968e1ca Mon Sep 17 00:00:00 2001 From: Marcos Longo Date: Wed, 28 Jan 2026 08:05:39 -0300 Subject: [PATCH 09/15] Add a bit more information on MONAN when checking for compatibility with scripts_CD-CT. --- scripts/1.install_monan.bash | 16 ++++++++-------- scripts/2.pre_processing.bash | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/1.install_monan.bash b/scripts/1.install_monan.bash index 3fd4d97..82f7f4d 100755 --- a/scripts/1.install_monan.bash +++ b/scripts/1.install_monan.bash @@ -177,7 +177,6 @@ EXECS=${DIRHOMED}/execs; mkdir -p ${EXECS} # Input variables:----------------------------------------------------- tag_or_branch_name_MONAN=${tag_or_branch_name_MONAN:="release/1.4.3-rc"} tag_or_branch_name_CONVERT_MPAS=${tag_or_branch_name_CONVERT_MPAS:="release/1.2.0"} -echo "MONAN branch name in use: ${tag_or_branch_name_MONAN}" echo "convert_mpas branch name in use: ${tag_or_branch_name_CONVERT_MPAS}" #---------------------------------------------------------------------- @@ -219,22 +218,23 @@ echo "*" echo "********************************************************************************" echo "" +echo -e "${GREEN}==>${NC} github_link_MONAN = ${github_link_MONAN}" echo -e "${GREEN}==>${NC} tag_or_branch_name_MONAN = ${tag_or_branch_name_MONAN}" echo "" read -p "Are you sure you are installing the right versions scripts x MONAN-Model ? [Y/n]" confirma -confirma=${confirma:-Y} - -if [[ "${confirma}" =~ ^[Yy]$ ]] -then +confirma=$(echo ${confirma:-Y} | tr [:upper:] [:lower:]) +case "${confirma}" in +y|yes) echo "" - echo -e "${GREEN}==>${NC} OK, so keep going." + echo -e "${GREEN}==>${NC} OK, proceeding to installation." echo "" -else + ;; +*) echo "" echo -e " ${RED}==>${NC} Please, make the right versions and try again." exit echo "" -fi +esac checkout_system ${MONANDIR} ${github_link_MONAN} ${tag_or_branch_name_MONAN} diff --git a/scripts/2.pre_processing.bash b/scripts/2.pre_processing.bash index b362a9b..30f1dba 100755 --- a/scripts/2.pre_processing.bash +++ b/scripts/2.pre_processing.bash @@ -183,7 +183,7 @@ fi #---~--- if ${OVERWRITE} || [[ ! -s ${DATAIN}/fixed/x1.${RES}.static.nc ]] then - echo -e "${GREEN}==>${NC} Creating static.bash for submiting init_atmosphere to create x1.${RES}.static.nc...\n" + echo -e "${GREEN}==>${NC} Creating static.bash for submitting init_atmosphere to create x1.${RES}.static.nc...\n" time ./make_static.bash ${MONAN_ONETWO} -e ${EXP} -f ${FCST} -r ${RES} -t ${YYYYMMDDHHi} else echo -e "${GREEN}==>${NC} File x1.${RES}.static.nc already exist in ${DATAIN}/fixed.\n" From ad1fbb15e305e0e71bee4012c71a8af300b29bd9 Mon Sep 17 00:00:00 2001 From: Marcos Longo Date: Thu, 29 Jan 2026 08:59:25 -0300 Subject: [PATCH 10/15] Temporarily adding back some python code, so the latest version of scripts_CD-CT can handle MONAN versions based on 1.2.0-rc. These can be removed again once the versions containing Noah-MP are fully integrated into later releases. --- scripts/1.install_monan.bash | 11 ---- scripts/2.pre_processing.bash | 11 ---- scripts/3.run_model.bash | 7 --- scripts/4.run_post.bash | 106 ++++++++++++++++++++++++++----- scripts/group_levels.py | 113 ++++++++++++++++++++++++++++++++++ scripts/make_degrib.bash | 10 --- scripts/make_initatmos.bash | 11 ---- scripts/make_static.bash | 10 --- scripts/make_template.bash | 7 --- scripts/requirements.txt | 2 + scripts/setenv.bash | 14 ++++- scripts/setenv_python.bash | 23 +++++++ 12 files changed, 242 insertions(+), 83 deletions(-) create mode 100644 scripts/group_levels.py create mode 100644 scripts/requirements.txt create mode 100644 scripts/setenv_python.bash diff --git a/scripts/1.install_monan.bash b/scripts/1.install_monan.bash index 82f7f4d..8326cda 100755 --- a/scripts/1.install_monan.bash +++ b/scripts/1.install_monan.bash @@ -163,17 +163,6 @@ echo "---- Installing the Model ----" echo "" -#--- Set and create standard directories -DIRHOMES=${DIR_SCRIPTS}/scripts_CD-CT; mkdir -p ${DIRHOMES} -DIRHOMED=${DIR_DADOS}/scripts_CD-CT; mkdir -p ${DIRHOMED} -SCRIPTS=${DIRHOMES}/scripts; mkdir -p ${SCRIPTS} -DATAIN=${DIRHOMED}/datain; mkdir -p ${DATAIN} -DATAOUT=${DIRHOMED}/dataout; mkdir -p ${DATAOUT} -SOURCES=${DIRHOMES}/sources; mkdir -p ${SOURCES} -EXECS=${DIRHOMED}/execs; mkdir -p ${EXECS} -#---------------------------------------------------------------------- - - # Input variables:----------------------------------------------------- tag_or_branch_name_MONAN=${tag_or_branch_name_MONAN:="release/1.4.3-rc"} tag_or_branch_name_CONVERT_MPAS=${tag_or_branch_name_CONVERT_MPAS:="release/1.2.0"} diff --git a/scripts/2.pre_processing.bash b/scripts/2.pre_processing.bash index 30f1dba..aed2e5b 100755 --- a/scripts/2.pre_processing.bash +++ b/scripts/2.pre_processing.bash @@ -140,17 +140,6 @@ echo "---- Pre Processing ----" echo "" -#--- Set and create standard directories -DIRHOMES=${DIR_SCRIPTS}/scripts_CD-CT; mkdir -p ${DIRHOMES} -DIRHOMED=${DIR_DADOS}/scripts_CD-CT; mkdir -p ${DIRHOMED} -SCRIPTS=${DIRHOMES}/scripts; mkdir -p ${SCRIPTS} -DATAIN=${DIRHOMED}/datain; mkdir -p ${DATAIN} -DATAOUT=${DIRHOMED}/dataout; mkdir -p ${DATAOUT} -SOURCES=${DIRHOMES}/sources; mkdir -p ${SOURCES} -EXECS=${DIRHOMED}/execs; mkdir -p ${EXECS} -#---~--- - - # Local variables-------------------------------------- # Calculating CIs and final forecast dates in model namelist format: yyyymmddi=${YYYYMMDDHHi:0:8} diff --git a/scripts/3.run_model.bash b/scripts/3.run_model.bash index 76edcfb..1329932 100755 --- a/scripts/3.run_model.bash +++ b/scripts/3.run_model.bash @@ -159,13 +159,6 @@ echo "" #--- Set and create standard directories -DIRHOMES=${DIR_SCRIPTS}/scripts_CD-CT; mkdir -p ${DIRHOMES} -DIRHOMED=${DIR_DADOS}/scripts_CD-CT; mkdir -p ${DIRHOMED} -SCRIPTS=${DIRHOMES}/scripts; mkdir -p ${SCRIPTS} -DATAIN=${DIRHOMED}/datain; mkdir -p ${DATAIN} -DATAOUT=${DIRHOMED}/dataout; mkdir -p ${DATAOUT} -SOURCES=${DIRHOMES}/sources; mkdir -p ${SOURCES} -EXECS=${DIRHOMED}/execs; mkdir -p ${EXECS} mkdir -p ${DATAOUT}/${YYYYMMDDHHi}/Model/logs export DIRRUN=${DIRHOMED}/run.${YYYYMMDDHHi}; rm -fr ${DIRRUN}; mkdir -p ${DIRRUN} #---~--- diff --git a/scripts/4.run_post.bash b/scripts/4.run_post.bash index 5e18a91..7f8eb50 100755 --- a/scripts/4.run_post.bash +++ b/scripts/4.run_post.bash @@ -158,13 +158,6 @@ echo "" #--- Set and create standard directories -DIRHOMES=`dirname "$(pwd)"`; mkdir -p ${DIRHOMES} -DIRHOMED=${DIR_DADOS}/scripts_CD-CT; mkdir -p ${DIRHOMED} -export SCRIPTS=${DIRHOMES}/scripts; mkdir -p ${SCRIPTS} -DATAIN=${DIRHOMED}/datain; mkdir -p ${DATAIN} -DATAOUT=${DIRHOMED}/dataout; mkdir -p ${DATAOUT} -SOURCES=${DIRHOMES}/sources; mkdir -p ${SOURCES} -EXECS=${DIRHOMED}/execs; mkdir -p ${EXECS} mkdir -p ${DATAOUT}/${YYYYMMDDHHi}/Post/logs export DIRRUN=${DIRHOMED}/run.${YYYYMMDDHHi}; rm -fr ${DIRRUN}; mkdir -p ${DIRRUN} #---~--- @@ -174,7 +167,7 @@ export DIRRUN=${DIRHOMED}/run.${YYYYMMDDHHi}; rm -fr ${DIRRUN}; mkdir -p ${DIRRU # Local variables-------------------------------------- START_DATE_YYYYMMDD="${YYYYMMDDHHi:0:4}-${YYYYMMDDHHi:4:2}-${YYYYMMDDHHi:6:2}" START_HH="${YYYYMMDDHHi:8:2}" -maxpostpernode=30 # <------ qtde max de convert_mpas por no! +maxpostpernode=30 # <------ maximum number of convert_mpas processes per node! #------------------------------------------------------- # Variables for flex output interval ------------------------ @@ -313,7 +306,7 @@ for file in "${files_needed[@]}" do if [[ ! -s "${file}" ]] then - echo -e "\n${RED}==>${NC} ***** FATAL ERROR *****\n" + echo -e "\n${RED}==>${NC} ***** FATAL ERROR *****\n" echo -e "${RED}==>${NC} [${0}] At least the file ${file} was not generated. \n" exit -1 fi @@ -333,6 +326,14 @@ echo "Max ${maxpostpernode} submits per nodes." how_many_nodes ${nfiles} ${maxpostpernode} #---~--- +#--- Set the python environment +case "${MONAN_ONETWO}" in +-m12) + . ${SCRIPTS}/setenv_python.bash + ;; +esac + + #---~--- # Make paths and create files/links for each convert_mpas output: #---~--- @@ -353,6 +354,7 @@ do done #---~--- + cd ${DIRRUN} chmod -R 755 ${DIRRUN}/* @@ -418,15 +420,53 @@ do currentdate=\$(date -d "${YYYYMMDDHHi:0:8} \${hh}:00:00 \$(echo "(\${i}-1)*${t_strout:0:2}" | bc) hours \$(echo "(\${i}-1)*${t_strout:3:2}" | bc) minutes \$(echo "(\${i}-1)*${t_strout:6:2}" | bc) seconds" +"%Y%m%d%H.%M.%S") diag_name=MONAN_DIAG_G_MOD_${EXP}_${YYYYMMDDHHi}_\${currentdate}.x${RES}L${N_MODEL_LEV}.nc echo "" - echo "executando convert mpas" + echo " = Running convert_mpas" chmod 755 ${DATAOUT}/${YYYYMMDDHHi}/Model/* time ./convert_mpas x1.${RES}.init.nc ${DATAOUT}/${YYYYMMDDHHi}/Model/\${diag_name} > convert_mpas.output & echo "./convert_mpas x1.${RES}.init.nc ${DATAOUT}/${YYYYMMDDHHi}/Model/\${diag_name} > convert_mpas.output" done -# necessario aguardar as rodadas em background +# Make sure that the job remains active whilst convert_mpas runs in the background wait +#---~--- +# For the older MONAN versions, we must group variables by levels. This code is being +# temporarily added back here until Noah-MP is fully integrated to a stable MONAN release. +#---~--- +case "${MONAN_ONETWO}" in +-m12) + + . ${SCRIPTS}/../.venv/bin/activate + + #---~--- + # Group vertical levels. + #---~--- + for ii in \$(seq ${inicio} ${fim}) + do + i=\$(printf "%04d" \${ii}) + cd ${DIRRUN}/dir.\${i} + python ${SCRIPTS}/group_levels.py ${DIRRUN}/dir.\${i} latlon.nc latlon_\${i}.nc \ + 1> ${DATAOUT}/${YYYYMMDDHHi}/Post/logs/out_group_levels_\${i}.log 2>&1 & + + #--- Move file to the default latlon.nc + /bin/rm latlon.nc + /bin/mv latlon_\${i}.nc latlon.nc + #---~--- + + done + #---~--- + + #--- Make sure that the job remains active whilst convert_mpas runs in the background. + wait + #---~--- + + #--- Unload python. + deactivate + #---~--- + ;; +esac +#---~--- + for ii in \$(seq ${inicio} ${fim}) do i=\$(printf "%04d" \${ii}) @@ -479,15 +519,18 @@ done -# Dependencias JobId: +#--- Set JobId dependencies: dependency="afterok" for job_id in "${jobid[@]}" do dependency="${dependency}:${job_id}" done +#---~--- - -# Script final , para conferir todos os arquivos, criar o template final e apagar o diretorio DIRRUN +#---~--- +# Final script, which will check every file, make the final template and remove +# directory ${DIRRUN} +#---~--- node=0 rm -f ${DIRRUN}/PostAtmos_node.${node}.sh @@ -516,6 +559,39 @@ cat << EOSH >> ${DIRRUN}/PostAtmos_node.${node}.sh cd ${DIRRUN} . ${SCRIPTS}/setenv.bash ${MONAN_ONETWO} +#---~--- +# For older versions, we group data into a single file, fix the time units and shift the +# bounding box so it goes from 180W to 180E (as opposed to 0-360). +#---~--- +case "${MONAN_ONETWO}" in +-m12) + #--- Merge all files. + cdo mergetime \ + ${DATAOUT}/${YYYYMMDDHHi}/Post/MONAN_DIAG_G_POS_${EXP}_${YYYYMMDDHHi}_??????????.??.??.x${RES}L${N_ISOBARIC_LEV}.nc \ + ${DATAOUT}/${YYYYMMDDHHi}/Post/mergetime.nc + sleep 5 + #---~--- + + #--- Fix time increment so it is consistent with the output. + cdo settunits,seconds -settaxis,${START_DATE_YYYYMMDD},${START_HH}:00,${t_stroutsec}second \ + ${DATAOUT}/${YYYYMMDDHHi}/Post/mergetime.nc \ + ${DATAOUT}/${YYYYMMDDHHi}/Post/timeunits.nc + sleep 5 + #---~--- + + #--- Shift the bounding box to -180:180. + cdo sellonlatbox,-180,180,-90,90 ${DATAOUT}/${YYYYMMDDHHi}/Post/timeunits.nc \ + ${DATAOUT}/${YYYYMMDDHHi}/Post/MONAN_DIAG_G_POS_${EXP}_${YYYYMMDDHHi}_AllTimes.x${RES}L${N_ISOBARIC_LEV}.nc + sleep 5 + #---~--- + + #--- Delete temporary files. + /bin/rm -f ${DATAOUT}/${YYYYMMDDHHi}/Post/mergetime.nc + /bin/rm -f ${DATAOUT}/${YYYYMMDDHHi}/Post/timeunits.nc + #---~--- + ;; +esac + # Saving important files to the logs directory: cp -f ${EXECS}/CONVMPAS-VERSION.txt ${DATAOUT}/${YYYYMMDDHHi}/Post cp -f ${EXECS}/CONVMPAS-VERSION.txt ${DATAOUT}/${YYYYMMDDHHi}/Post/logs @@ -542,7 +618,7 @@ SLURM) sbatch --wait --dependency=${dependency} ${DIRRUN}/PostAtmos_node.${node}.sh ;; PBS) - echo "Rodando em PBS" + echo "Qsub PostAtmos_node.${node}.sh" echo -e "${GREEN}==>${NC} qsub PostAtmos_node.${node}.sh...\n" cd ${DIRRUN} qsub -W depend=${dependency} -W block=true ${DIRRUN}/PostAtmos_node.${node}.sh diff --git a/scripts/group_levels.py b/scripts/group_levels.py new file mode 100644 index 0000000..e425f7c --- /dev/null +++ b/scripts/group_levels.py @@ -0,0 +1,113 @@ +#!/usr/bin/env python + +import netCDF4 as nc +import numpy as np +import re +import sys + + +def main(data_dir, file_in, file_out, levels=[1000, 975, 950, 925, 900, 875, 850, 825, 700, 600, 500, 400, \ + 300, 250, 200, 150, 100, 70, 50, 30, 20, 15]): + """ + This function takes in the data directory, input file name, and output file name. + It reads the input NetCDF file, groups variables based on their names, + creates a new NetCDF file with dimensions and variables copied from the input file, + and saves the concatenated variables to the new NetCDF file. + + Parameters: + data_dir (str): The directory where the input and output NetCDF files are located. + file_in (str): The name of the input NetCDF file. + file_out (str): The name of the output NetCDF file. + + Returns: + None + """ + + nc_file_in = nc.Dataset(f'{data_dir}/{file_in}', 'r') + # Save the concatenated variables to a new NetCDF file + nc_file_out = nc.Dataset(f'{data_dir}/{file_out}', 'w') + + dimensions_4D = ('time', 'level', 'latitude', 'longitude') + # Group variables based on their names + variable_groups = {} + first_hpa_variable = '' + for name, variable in reversed(list(nc_file_in.variables.items())): # reverse to be consistent to levels + # if 'hPa' in name or name in dimensions_4D: + if 'hPa' in name: + variable_type = re.split('_.\d*hPa', name)[0] # Extract the variable type (e.g., '15hPa', '20hPa') + first_hpa_variable = variable_type if first_hpa_variable == '' else first_hpa_variable + else: + variable_type = name.lower() + if variable_type not in variable_groups: + variable_groups[variable_type] = [variable] + else: + variable_groups[variable_type].append(variable) + + # if there isn't any hPa variable - set default 22 levels + if not first_hpa_variable: + print("Nenhuma variável com nível isobárico ('hPa') foi encontrada no arquivo.") + level_dimension_size = 22 + else: + level_dimension_size = len(variable_groups[first_hpa_variable]) + + # Copy dimensions Time, latitude, longitude + for dim_name, dim_type in nc_file_in.dimensions.items(): + if dim_name.lower() in ['time', 'latitude', 'longitude']: + nc_file_out.createDimension(dim_name.lower(), dim_type.size) + nc_file_out.createDimension('level', level_dimension_size) + + + # Copy variables + for variable_type, variables in variable_groups.items(): + print(f'Creating var {variable_type}') + if variable_type == 'level': + new_variable = nc_file_out.createVariable(variable_type, variables[0].dtype, (variable_type) ) + new_variable.setncatts({k: variables[0].getncattr(k) for k in variables[0].ncattrs()}) + new_variable[:] = range(level_dimension_size, 0, -1) if levels is None else levels + new_variable.setncattr('positive', "down") + new_variable.setncattr('units', "hPa") + # if its variables with on isobaric level per variable + elif len(variables) == level_dimension_size: + new_variable = nc_file_out.createVariable(variable_type, variables[0].dtype, dimensions_4D) + new_variable.setncatts({k: variables[0].getncattr(k) for k in variables[0].ncattrs()}) + if 'vertically interpolated' in new_variable.getncattr('long_name'): + new_long_name = new_variable.getncattr('long_name').split('vertically interpolated')[0].strip() + elif 'interpolated' in new_variable.getncattr('long_name'): + new_long_name = new_variable.getncattr('long_name').split('interpolated')[0].strip() + elif '1000 hPa' in new_variable.getncattr('long_name'): + new_long_name = new_variable.getncattr('long_name').split('1000 hPa')[0].strip() + else: + new_long_name = new_variable.getncattr('long_name') + new_long_name += ' interpolated' + new_variable.setncattr('long_name', new_long_name) + + for i in range(level_dimension_size): + new_variable[:,i,:,:] = variables[i][:] + else: + # Create an empty list to store lowercase dimensions + lowercase_dimensions = [] + + # Iterate through each object in the tuple + for obj in variables[0].dimensions: + # Access the 'dimensions' attribute and convert to lowercase + lowercase_dimensions.append(obj.lower()) + # Convert the list of lowercase dimensions to a tuple + + lowercase_dimensions_tuple = tuple(lowercase_dimensions) + # variable_type in ('latitude', 'longitude', 'Time'): + new_variable = nc_file_out.createVariable(variable_type, variables[0].dtype, lowercase_dimensions_tuple) + new_variable.setncatts({k: variables[0].getncattr(k) for k in variables[0].ncattrs()}) + new_variable[:] = variables[0][:] + + nc_file_out.close() + nc_file_in.close() + + +if __name__ == "__main__": + import sys + + if len(sys.argv) != 4: + print(f"Usage: python {sys.argv[0]} ") + sys.exit(1) + + main(sys.argv[1], sys.argv[2], sys.argv[3]) diff --git a/scripts/make_degrib.bash b/scripts/make_degrib.bash index 525892e..5fd44b3 100755 --- a/scripts/make_degrib.bash +++ b/scripts/make_degrib.bash @@ -113,16 +113,6 @@ echo "" echo "---- Make Degrib ----" echo "" -#--- Set and create standard directories -DIRHOMES=${DIR_SCRIPTS}/scripts_CD-CT; mkdir -p ${DIRHOMES} -DIRHOMED=${DIR_DADOS}/scripts_CD-CT; mkdir -p ${DIRHOMED} -SCRIPTS=${DIRHOMES}/scripts; mkdir -p ${SCRIPTS} -DATAIN=${DIRHOMED}/datain; mkdir -p ${DATAIN} -DATAOUT=${DIRHOMED}/dataout; mkdir -p ${DATAOUT} -SOURCES=${DIRHOMES}/sources; mkdir -p ${SOURCES} -EXECS=${DIRHOMED}/execs; mkdir -p ${EXECS} -#---~--- - diff --git a/scripts/make_initatmos.bash b/scripts/make_initatmos.bash index 6ef695b..937a1a6 100755 --- a/scripts/make_initatmos.bash +++ b/scripts/make_initatmos.bash @@ -111,17 +111,6 @@ fi #---~--- -#--- Set and create standard directories -DIRHOMES=${DIR_SCRIPTS}/scripts_CD-CT; mkdir -p ${DIRHOMES} -DIRHOMED=${DIR_DADOS}/scripts_CD-CT; mkdir -p ${DIRHOMED} -SCRIPTS=${DIRHOMES}/scripts; mkdir -p ${SCRIPTS} -DATAIN=${DIRHOMED}/datain; mkdir -p ${DATAIN} -DATAOUT=${DIRHOMED}/dataout; mkdir -p ${DATAOUT} -SOURCES=${DIRHOMES}/sources; mkdir -p ${SOURCES} -EXECS=${DIRHOMED}/execs; mkdir -p ${EXECS} -#---~--- - - # Local variables-------------------------------------- start_date=${YYYYMMDDHHi:0:4}-${YYYYMMDDHHi:4:2}-${YYYYMMDDHHi:6:2}_${YYYYMMDDHHi:8:2}:00:00 GEODATA=${DATAIN}/WPS_GEOG diff --git a/scripts/make_static.bash b/scripts/make_static.bash index 153b36f..0099d78 100755 --- a/scripts/make_static.bash +++ b/scripts/make_static.bash @@ -113,16 +113,6 @@ echo "" echo "---- Make Static ----" echo "" -#--- Set and create standard directories -DIRHOMES=${DIR_SCRIPTS}/scripts_CD-CT; mkdir -p ${DIRHOMES} -DIRHOMED=${DIR_DADOS}/scripts_CD-CT; mkdir -p ${DIRHOMED} -SCRIPTS=${DIRHOMES}/scripts; mkdir -p ${SCRIPTS} -DATAIN=${DIRHOMED}/datain; mkdir -p ${DATAIN} -DATAOUT=${DIRHOMED}/dataout; mkdir -p ${DATAOUT} -SOURCES=${DIRHOMES}/sources; mkdir -p ${SOURCES} -EXECS=${DIRHOMED}/execs; mkdir -p ${EXECS} -#---~--- - # Local variables-------------------------------------- GEODATA=${DATAIN}/WPS_GEOG diff --git a/scripts/make_template.bash b/scripts/make_template.bash index f42939b..b662783 100755 --- a/scripts/make_template.bash +++ b/scripts/make_template.bash @@ -152,13 +152,6 @@ echo "" #--- Set and create standard directories -DIRHOMES=`dirname "$(pwd)"`; mkdir -p ${DIRHOMES} -DIRHOMED=${DIR_DADOS}/scripts_CD-CT; mkdir -p ${DIRHOMED} -export SCRIPTS=${DIRHOMES}/scripts; mkdir -p ${SCRIPTS} -DATAIN=${DIRHOMED}/datain; mkdir -p ${DATAIN} -DATAOUT=${DIRHOMED}/dataout; mkdir -p ${DATAOUT} -SOURCES=${DIRHOMES}/sources; mkdir -p ${SOURCES} -EXECS=${DIRHOMED}/execs; mkdir -p ${EXECS} mkdir -p ${DATAOUT}/${YYYYMMDDHHi}/Post/logs #---~--- diff --git a/scripts/requirements.txt b/scripts/requirements.txt new file mode 100644 index 0000000..cdd49f5 --- /dev/null +++ b/scripts/requirements.txt @@ -0,0 +1,2 @@ +netCDF4>=1.6.5 +numpy>=1.26.4 diff --git a/scripts/setenv.bash b/scripts/setenv.bash index 2d8a28a..7d85034 100755 --- a/scripts/setenv.bash +++ b/scripts/setenv.bash @@ -119,7 +119,7 @@ ian[0-9]*|cn-0[0-9][0-9][0-9]) #---~--- esac # Make the same for other machines/systems... -echo "Host detected: $HOSTNAME" +echo "Host detected: ${HOSTNAME}" echo "Compiler to be used: ${COMPILER}" # Set unique key: scheduler + host: @@ -154,6 +154,18 @@ export MONANDIR=$MONANDIR # Others variables: +#--- Set and create standard directories +export DIRHOMES=${DIR_SCRIPTS}/scripts_CD-CT; mkdir -p ${DIRHOMES} +export DIRHOMED=${DIR_DADOS}/scripts_CD-CT; mkdir -p ${DIRHOMED} +export SCRIPTS=${DIRHOMES}/scripts; mkdir -p ${SCRIPTS} +export DATAIN=${DIRHOMED}/datain; mkdir -p ${DATAIN} +export DATAOUT=${DIRHOMED}/dataout; mkdir -p ${DATAOUT} +export SOURCES=${DIRHOMES}/sources; mkdir -p ${SOURCES} +export EXECS=${DIRHOMED}/execs; mkdir -p ${EXECS} +#---~--- + + + # Functions: ====================================================================================================== diff --git a/scripts/setenv_python.bash b/scripts/setenv_python.bash new file mode 100644 index 0000000..f10eaa5 --- /dev/null +++ b/scripts/setenv_python.bash @@ -0,0 +1,23 @@ +#!/bin/bash + +case "${HOSTNAME}" in +egeon) + echo "Load python ..." + module load python-3.9.13-gcc-9.4.0-moxjnc6 + ;; +esac + +echo "scripts folder is set to \"${SCRIPTS}\"." + +echo "Create python environment at ${SCRIPTS}/../.venv" +python3 -m venv ${SCRIPTS}/../.venv + +echo "Activate python environment" +source ${SCRIPTS}/../.venv/bin/activate + +echo "Install python libraries" +pip install --upgrade pip +pip install -r ${SCRIPTS}/requirements.txt + +export PYTHONPATH=${PYTHONPATH}:${SCRIPTS} +echo "export PYTHONPATH=${PYTHONPATH}" From 5ca2236537ac6609f2f218713a67ec4faefb7611 Mon Sep 17 00:00:00 2001 From: Marcos Longo Date: Thu, 29 Jan 2026 09:03:04 -0300 Subject: [PATCH 11/15] The previous commit also moved the definition of multiple directories to setenv.bash. The same directory names were set in every bash script, so defining them in setenv.bash helps streamline the code and avoids inconsistencies. --- scripts/0.run_all.bash | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/scripts/0.run_all.bash b/scripts/0.run_all.bash index 6208777..09c7e29 100755 --- a/scripts/0.run_all.bash +++ b/scripts/0.run_all.bash @@ -191,17 +191,6 @@ done #---~--- -#--- Set and create standard directories -DIRHOMES=${DIR_SCRIPTS}/scripts_CD-CT; mkdir -p ${DIRHOMES} -DIRHOMED=${DIR_DADOS}/scripts_CD-CT; mkdir -p ${DIRHOMED} -SCRIPTS=${DIRHOMES}/scripts; mkdir -p ${SCRIPTS} -DATAIN=${DIRHOMED}/datain; mkdir -p ${DATAIN} -DATAOUT=${DIRHOMED}/dataout; mkdir -p ${DATAOUT} -SOURCES=${DIRHOMES}/sources; mkdir -p ${SOURCES} -EXECS=${DIRHOMED}/execs; mkdir -p ${EXECS} -#---~--- - - #---~--- From 86ac34de8af80b15d2f52d0a613a86b44e4cd33b Mon Sep 17 00:00:00 2001 From: Marcos Longo Date: Thu, 29 Jan 2026 11:23:46 -0300 Subject: [PATCH 12/15] I had forgotten to add the place holder for output interval in this branch, so the output was not properly set. I also slightly edited the logic for reporting the error, so all expected files that were missing are listed in the output. --- scripts/1.install_monan.bash | 2 +- scripts/3.run_model.bash | 36 +++++++++++++------ scripts/namelists/streams.atmosphere.TEMPLATE | 2 +- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/scripts/1.install_monan.bash b/scripts/1.install_monan.bash index 8326cda..2c95507 100755 --- a/scripts/1.install_monan.bash +++ b/scripts/1.install_monan.bash @@ -210,7 +210,7 @@ echo "" echo -e "${GREEN}==>${NC} github_link_MONAN = ${github_link_MONAN}" echo -e "${GREEN}==>${NC} tag_or_branch_name_MONAN = ${tag_or_branch_name_MONAN}" echo "" -read -p "Are you sure you are installing the right versions scripts x MONAN-Model ? [Y/n]" confirma +read -p "Are you sure you are installing the right versions scripts x MONAN-Model ? [Y/n] " confirma confirma=$(echo ${confirma:-Y} | tr [:upper:] [:lower:]) case "${confirma}" in y|yes) diff --git a/scripts/3.run_model.bash b/scripts/3.run_model.bash index 1329932..9db902d 100755 --- a/scripts/3.run_model.bash +++ b/scripts/3.run_model.bash @@ -276,8 +276,11 @@ cp -f ${DATAOUT}/${YYYYMMDDHHi}/Pre/x1.${RES}.init.nc ${DIRRUN} cp -f ${DATAIN}/fixed/Vtable.GFS ${DIRRUN} -if [[ ${EXP} = "GFS" ]] -then +# ML: I replaced the if construction with a case one, as this is a case selection, but I +# wonder if the sed commands should be applied in all cases instead of only when EXP +# is set to GFS... +case "${EXP}" in +GFS) sed -e "s,#LABELI#,${start_date},g;s,#FCSTS#,${DD_HHMMSS_forecast},g;s,#RES#,${RES},g; s,#CONFIG_DT#,${CONFIG_DT},g;s,#CONFIG_LEN_DISP#,${CONFIG_LEN_DISP},g;s,#CONFIG_CONV_INTERVAL#,${CONFIG_CONV_INTERVAL},g" \ ${SCRIPTS}/namelists/namelist.atmosphere.TEMPLATE > ${DIRRUN}/namelist.atmosphere @@ -285,7 +288,10 @@ s,#CONFIG_DT#,${CONFIG_DT},g;s,#CONFIG_LEN_DISP#,${CONFIG_LEN_DISP},g;s,#CONFIG_ sed -e "s,#RES#,${RES},g;s,#CIORIG#,${EXP},g;s,#LABELI#,${YYYYMMDDHHi},g;s,#NLEV#,${NLEV},g; s,#OUTPUT_DIAG_INTERVAL#,${OUTPUT_DIAG_INTERVAL},g" \ ${SCRIPTS}/namelists/streams.atmosphere.TEMPLATE > ${DIRRUN}/streams.atmosphere -fi + ;; +esac + + cp -f ${SCRIPTS}/namelists/stream_list.atmosphere.output ${DIRRUN} cp -f ${SCRIPTS}/namelists/stream_list.atmosphere.diagnostics${VARTABLE} ${DIRRUN}/stream_list.atmosphere.diagnostics cp -f ${SCRIPTS}/namelists/stream_list.atmosphere.surface ${DIRRUN} @@ -388,9 +394,12 @@ esac mv ${DIRRUN}/model.bash ${DATAOUT}/${YYYYMMDDHHi}/Model/logs -#-----Loop que verifica se os arquivos foram gerados corretamente (>0)----- +#---~--- +# Loop that checks whether the files were properly produced or not. +#---~--- output_interval=${t_strouthor} nfiles=$(echo "$FCST/$output_interval + 1" | bc) +missed=false for ii in $(seq 1 ${nfiles}) do i=$(printf "%04d" ${ii}) @@ -400,11 +409,18 @@ do if [[ ! -s ${DATAOUT}/${YYYYMMDDHHi}/Model/${file} ]] then - echo -e "\n${RED}==>${NC} ***** FATAL ERROR *****\n" - echo -e "${RED}==>${NC} [${0}] At least the file ${DATAOUT}/${YYYYMMDDHHi}/Model/${file} was not generated. \n" - exit -1 - fi + if ! ${missed} + then + echo -e "\n${RED}==>${NC} ***** FATAL ERROR *****\n" + missed=true + fi + echo -e "${RED}==>${NC} [${0}] File ${DATAOUT}/${YYYYMMDDHHi}/Model/${file} was not generated. \n" + fi done - -rm -fr ${DIRRUN} +if ${missed} +then + exit -1 +else + rm -fr ${DIRRUN} +fi diff --git a/scripts/namelists/streams.atmosphere.TEMPLATE b/scripts/namelists/streams.atmosphere.TEMPLATE index 04def1c..5432356 100755 --- a/scripts/namelists/streams.atmosphere.TEMPLATE +++ b/scripts/namelists/streams.atmosphere.TEMPLATE @@ -24,7 +24,7 @@ type="output" io_type="pnetcdf,cdf5" filename_template="MONAN_DIAG_G_MOD_#CIORIG#_#LABELI#_$Y$M$D$h.$m.$s.x#RES#L#NLEV#.nc" - output_interval="3:00:00" > + output_interval="#OUTPUT_DIAG_INTERVAL#" > From c14d61a05c895b4bc645d2531a55427467eb8adf Mon Sep 17 00:00:00 2001 From: Marcos Longo Date: Thu, 29 Jan 2026 16:10:33 -0300 Subject: [PATCH 13/15] Added options for loading a more recent python3 on Jaci, and fixed some bugs. --- scripts/4.run_post.bash | 4 ++-- scripts/setenv.bash | 12 ++++++++++++ scripts/setenv_python.bash | 15 +++++++++++---- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/scripts/4.run_post.bash b/scripts/4.run_post.bash index 7f8eb50..082b944 100755 --- a/scripts/4.run_post.bash +++ b/scripts/4.run_post.bash @@ -436,7 +436,7 @@ wait case "${MONAN_ONETWO}" in -m12) - . ${SCRIPTS}/../.venv/bin/activate + . ${PYTHON_ENV_PATH}/bin/activate #---~--- # Group vertical levels. @@ -643,4 +643,4 @@ fi cd ${SCRIPTS} chmod 755 ${DATAOUT}/${YYYYMMDDHHi}/Post/* time ${SCRIPTS}/make_template.bash ${MONAN_ONETWO} ${dv_VARTABLE} \ - -d ${OUTPUT_DIAG_INTERVAL} -e ${EXP}-f ${FCST} -r ${RES} -t ${YYYYMMDDHHi} + -d ${OUTPUT_DIAG_INTERVAL} -e ${EXP} -f ${FCST} -r ${RES} -t ${YYYYMMDDHHi} diff --git a/scripts/setenv.bash b/scripts/setenv.bash index 7d85034..14f9648 100755 --- a/scripts/setenv.bash +++ b/scripts/setenv.bash @@ -162,6 +162,18 @@ export DATAIN=${DIRHOMED}/datain; mkdir -p ${DATAIN} export DATAOUT=${DIRHOMED}/dataout; mkdir -p ${DATAOUT} export SOURCES=${DIRHOMES}/sources; mkdir -p ${SOURCES} export EXECS=${DIRHOMED}/execs; mkdir -p ${EXECS} + +echo -e "" +echo -e "${GREEN}==>${NC}*** List of paths: ***" +echo -e "" +echo -e "${GREEN}==>${NC} DIRHOMES = \"${DIRHOMES}\"" +echo -e "${GREEN}==>${NC} DIRHOMED = \"${DIRHOMED}\"" +echo -e "${GREEN}==>${NC} SCRIPTS = \"${SCRIPTS}\"" +echo -e "${GREEN}==>${NC} DATAIN = \"${DATAIN}\"" +echo -e "${GREEN}==>${NC} DATAOUT = \"${DATAOUT}\"" +echo -e "${GREEN}==>${NC} SOURCES = \"${SOURCES}\"" +echo -e "${GREEN}==>${NC} EXECS = \"${EXECS}\"" +echo -e "" #---~--- diff --git a/scripts/setenv_python.bash b/scripts/setenv_python.bash index f10eaa5..fe6e6ba 100644 --- a/scripts/setenv_python.bash +++ b/scripts/setenv_python.bash @@ -5,15 +5,22 @@ egeon) echo "Load python ..." module load python-3.9.13-gcc-9.4.0-moxjnc6 ;; +ian) + echo "Load python ..." + module load anaconda/24.1.2 + ;; esac -echo "scripts folder is set to \"${SCRIPTS}\"." -echo "Create python environment at ${SCRIPTS}/../.venv" -python3 -m venv ${SCRIPTS}/../.venv +echo "Define path for python environment" +export PYTHON_ENV_PATH="${DIRHOMES}/.venv" + + +echo "Create python environment at ${PYTHON_ENV_PATH}" +python3 -m venv ${PYTHON_ENV_PATH} echo "Activate python environment" -source ${SCRIPTS}/../.venv/bin/activate +source ${PYTHON_ENV_PATH}/bin/activate echo "Install python libraries" pip install --upgrade pip From 5f7d79d88ee35a9d4a1267325cdd6adc3b0521d7 Mon Sep 17 00:00:00 2001 From: Marcos Longo Date: Mon, 2 Feb 2026 14:21:59 -0300 Subject: [PATCH 14/15] Multiple edits to the post-processing script so it works with legacy MONAN code (and python requirements) on Jaci. --- scripts/4.run_post.bash | 130 +++++++++++++++-------- scripts/group_levels.py | 8 +- scripts/setenv.bash | 12 --- scripts/setenv_python.bash | 38 ++++--- scripts/stools/setenv_PBS_ian_gnu.bash | 2 +- scripts/stools/setenv_PBS_ian_intel.bash | 2 +- 6 files changed, 114 insertions(+), 78 deletions(-) diff --git a/scripts/4.run_post.bash b/scripts/4.run_post.bash index 082b944..632e64c 100755 --- a/scripts/4.run_post.bash +++ b/scripts/4.run_post.bash @@ -320,7 +320,7 @@ done #---~--- output_interval=${t_strouthor} #nfiles=FCST/output_interval + 1(time zero file) -nfiles=$(echo "$FCST/$output_interval + 1" | bc) +nfiles=$(echo "${FCST}/${output_interval} + 1" | bc) echo "${nfiles} post to submit." echo "Max ${maxpostpernode} submits per nodes." how_many_nodes ${nfiles} ${maxpostpernode} @@ -394,9 +394,13 @@ do cat << EOSH >> ${DIRRUN}/PostAtmos_node.${node}.sh -cd ${DIRRUN} +MONAN_ONETWO="${MONAN_ONETWO}" +DIRRUN="${DIRRUN}" + . ${SCRIPTS}/setenv.bash ${MONAN_ONETWO} -chmod 755 ${DIRRUN}/* +chmod 755 \${DIRRUN}/* + +cd \${DIRRUN} echo "Submitting posts ${inicio} to ${fim} to node Node ${node}." @@ -404,8 +408,8 @@ for ii in \$(seq ${inicio} ${fim}) do i=\$(printf "%04d" \${ii}) echo "Preparing post files \${i}" - cp -f ${DATAOUT}/${YYYYMMDDHHi}/Pre/x1.${RES}.init.nc ${DIRRUN}/dir.\${i} & - cp -f ${EXECS}/convert_mpas ${DIRRUN}/dir.\${i} & + cp -f \${DATAOUT}/${YYYYMMDDHHi}/Pre/x1.${RES}.init.nc \${DIRRUN}/dir.\${i} & + cp -f \${EXECS}/convert_mpas \${DIRRUN}/dir.\${i} & done wait @@ -421,7 +425,7 @@ do diag_name=MONAN_DIAG_G_MOD_${EXP}_${YYYYMMDDHHi}_\${currentdate}.x${RES}L${N_MODEL_LEV}.nc echo "" echo " = Running convert_mpas" - chmod 755 ${DATAOUT}/${YYYYMMDDHHi}/Model/* + chmod 755 \${DATAOUT}/${YYYYMMDDHHi}/Model/* time ./convert_mpas x1.${RES}.init.nc ${DATAOUT}/${YYYYMMDDHHi}/Model/\${diag_name} > convert_mpas.output & echo "./convert_mpas x1.${RES}.init.nc ${DATAOUT}/${YYYYMMDDHHi}/Model/\${diag_name} > convert_mpas.output" done @@ -433,10 +437,14 @@ wait # For the older MONAN versions, we must group variables by levels. This code is being # temporarily added back here until Noah-MP is fully integrated to a stable MONAN release. #---~--- -case "${MONAN_ONETWO}" in +case "\${MONAN_ONETWO}" in -m12) - . ${PYTHON_ENV_PATH}/bin/activate + # Load python configuration on node + . \${SCRIPTS}/setenv_python.bash + + + . \${PYTHON_ENV_PATH}/bin/activate #---~--- # Group vertical levels. @@ -444,15 +452,10 @@ case "${MONAN_ONETWO}" in for ii in \$(seq ${inicio} ${fim}) do i=\$(printf "%04d" \${ii}) - cd ${DIRRUN}/dir.\${i} - python ${SCRIPTS}/group_levels.py ${DIRRUN}/dir.\${i} latlon.nc latlon_\${i}.nc \ - 1> ${DATAOUT}/${YYYYMMDDHHi}/Post/logs/out_group_levels_\${i}.log 2>&1 & - - #--- Move file to the default latlon.nc - /bin/rm latlon.nc - /bin/mv latlon_\${i}.nc latlon.nc - #---~--- - + cd \${DIRRUN}/dir.\${i} + ${PYTHON_EXEC} \${SCRIPTS}/group_levels.py \${DIRRUN}/dir.\${i} latlon.nc latlon_\${i}.nc \ + 1> \${DATAOUT}/${YYYYMMDDHHi}/Post/logs/out_group_levels_${node}.log 2>&1 & + echo "${PYTHON_EXEC} \${SCRIPTS}/group_levels.py \${DIRRUN}/dir.\${i} latlon.nc latlon_\${i}.nc" done #---~--- @@ -460,6 +463,28 @@ case "${MONAN_ONETWO}" in wait #---~--- + #---~--- + # Rename files so the subsequent steps are not dependent upon the MONAN/convertmpas version. + #---~--- + for ii in \$(seq ${inicio} ${fim}) + do + i=\$(printf "%04d" \${ii}) + cd \${DIRRUN}/dir.\${i} + #--- Move file to the default latlon.nc + if [[ -s latlon_\${i}.nc ]] + then + /bin/rm latlon.nc + /bin/mv latlon_\${i}.nc latlon.nc + else + echo -e "\${RED}==>\${NC} *** FATAL ERROR ***" + echo -e "\${RED}==>\${NC} Script group_levels.py failed" + exit -1 + fi + #---~--- + + done + #---~--- + #--- Unload python. deactivate #---~--- @@ -492,17 +517,17 @@ EOSH chmod 755 ${DATAOUT}/${YYYYMMDDHHi}/Post/* case "${SCHEDULER_SYSTEM}" in SLURM) - echo "Sbatch PostAtmos_node.${node}.sh" + echo "sbatch PostAtmos_node.${node}.sh" jobid[${node}]=$(sbatch --parsable ${DIRRUN}/PostAtmos_node.${node}.sh) echo "JobId node ${node} = ${jobid[${node}]} , convert_mpas ${inicio} to ${fim}" echo "" ;; PBS) - echo "Running with PBS" + echo "qsub PostAtmos_node.${node}.sh" echo -e "${GREEN}==>${NC} qsub PostAtmos_node.${node}.sh...\n" cd ${DIRRUN} - jobid[${node}]=$(qsub ${DIRRUN}/PostAtmos_node.${node}.sh | cut -d '.' -f1) - ;; + jobid[${node}]=$(qsub ${DIRRUN}/PostAtmos_node.${node}.sh | cut -d '.' -f1) + ;; # GENERIC) # echo "Nenhum gerenciador detectado" # ${DIRRUN}/PostAtmos_node.${node}.sh @@ -556,57 +581,65 @@ esac cat << EOSH >> ${DIRRUN}/PostAtmos_node.${node}.sh -cd ${DIRRUN} -. ${SCRIPTS}/setenv.bash ${MONAN_ONETWO} +MONAN_ONETWO="${MONAN_ONETWO}" +DIRRUN="${DIRRUN}" + +. ${SCRIPTS}/setenv.bash \${MONAN_ONETWO} + +cd \${DIRRUN} #---~--- # For older versions, we group data into a single file, fix the time units and shift the # bounding box so it goes from 180W to 180E (as opposed to 0-360). #---~--- -case "${MONAN_ONETWO}" in +case "\${MONAN_ONETWO}" in -m12) + #--- Delete temporary files. + echo " - Remove existing files" + /bin/rm -f \${DATAOUT}/${YYYYMMDDHHi}/Post/mergetime.nc + /bin/rm -f \${DATAOUT}/${YYYYMMDDHHi}/Post/timeunits.nc + /bin/rm -f \${DATAOUT}/${YYYYMMDDHHi}/Post/MONAN_DIAG_G_POS_${EXP}_${YYYYMMDDHHi}_AllTimes.x${RES}L${N_ISOBARIC_LEV}.nc + #---~--- + #--- Merge all files. - cdo mergetime \ - ${DATAOUT}/${YYYYMMDDHHi}/Post/MONAN_DIAG_G_POS_${EXP}_${YYYYMMDDHHi}_??????????.??.??.x${RES}L${N_ISOBARIC_LEV}.nc \ - ${DATAOUT}/${YYYYMMDDHHi}/Post/mergetime.nc + echo " - Merge single-time files:" + cdo mergetime \${DATAOUT}/${YYYYMMDDHHi}/Post/MONAN_DIAG_G_POS_${EXP}_${YYYYMMDDHHi}_??????????.??.??.x${RES}L${N_ISOBARIC_LEV}.nc \${DATAOUT}/${YYYYMMDDHHi}/Post/mergetime.nc sleep 5 #---~--- #--- Fix time increment so it is consistent with the output. - cdo settunits,seconds -settaxis,${START_DATE_YYYYMMDD},${START_HH}:00,${t_stroutsec}second \ - ${DATAOUT}/${YYYYMMDDHHi}/Post/mergetime.nc \ - ${DATAOUT}/${YYYYMMDDHHi}/Post/timeunits.nc + echo " - Fix time interval so it matches the actual output:" + cdo settaxis,${START_DATE_YYYYMMDD},${START_HH}:00,${t_stroutsec}seconds \${DATAOUT}/${YYYYMMDDHHi}/Post/mergetime.nc \${DATAOUT}/${YYYYMMDDHHi}/Post/timeunits.nc sleep 5 #---~--- - #--- Shift the bounding box to -180:180. - cdo sellonlatbox,-180,180,-90,90 ${DATAOUT}/${YYYYMMDDHHi}/Post/timeunits.nc \ - ${DATAOUT}/${YYYYMMDDHHi}/Post/MONAN_DIAG_G_POS_${EXP}_${YYYYMMDDHHi}_AllTimes.x${RES}L${N_ISOBARIC_LEV}.nc + #--- Shift the bounding box to 180W:180E (as opposed to 0:360). + echo " - Set the bounding box to 180W:180E:" + cdo sellonlatbox,-180,180,-90,90 \${DATAOUT}/${YYYYMMDDHHi}/Post/timeunits.nc \${DATAOUT}/${YYYYMMDDHHi}/Post/MONAN_DIAG_G_POS_${EXP}_${YYYYMMDDHHi}_AllTimes.x${RES}L${N_ISOBARIC_LEV}.nc sleep 5 #---~--- #--- Delete temporary files. - /bin/rm -f ${DATAOUT}/${YYYYMMDDHHi}/Post/mergetime.nc - /bin/rm -f ${DATAOUT}/${YYYYMMDDHHi}/Post/timeunits.nc + echo " - Delete temporary files" + /bin/rm -f \${DATAOUT}/${YYYYMMDDHHi}/Post/mergetime.nc + /bin/rm -f \${DATAOUT}/${YYYYMMDDHHi}/Post/timeunits.nc #---~--- ;; esac # Saving important files to the logs directory: -cp -f ${EXECS}/CONVMPAS-VERSION.txt ${DATAOUT}/${YYYYMMDDHHi}/Post -cp -f ${EXECS}/CONVMPAS-VERSION.txt ${DATAOUT}/${YYYYMMDDHHi}/Post/logs -cp -f ${DIRRUN}/dir.0001/target_domain ${DATAOUT}/${YYYYMMDDHHi}/Post/logs -cp -f ${DIRRUN}/dir.0001/convert_mpas.nml ${DATAOUT}/${YYYYMMDDHHi}/Post/logs -cp -f ${DIRRUN}/dir.0001/include_fields ${DATAOUT}/${YYYYMMDDHHi}/Post/logs -cp -f ${DIRRUN}/dir.0001/convert_mpas.output ${DATAOUT}/${YYYYMMDDHHi}/Post/logs -cp -f ${DIRRUN}/PostAtmos_node.*.sh ${DATAOUT}/${YYYYMMDDHHi}/Post/logs -cp -f ${DATAOUT}/${YYYYMMDDHHi}/Model/logs/* ${DATAOUT}/${YYYYMMDDHHi}/Post/logs -cp -f ${DATAOUT}/${YYYYMMDDHHi}/Model/MONAN-VERSION.txt ${DATAOUT}/${YYYYMMDDHHi}/Post/logs +echo " - Save relevant files to permanent locations:" +cp -f \${EXECS}/CONVMPAS-VERSION.txt \${DATAOUT}/${YYYYMMDDHHi}/Post +cp -f \${EXECS}/CONVMPAS-VERSION.txt \${DATAOUT}/${YYYYMMDDHHi}/Post/logs +cp -f \${DIRRUN}/dir.0001/target_domain \${DATAOUT}/${YYYYMMDDHHi}/Post/logs +cp -f \${DIRRUN}/dir.0001/convert_mpas.nml \${DATAOUT}/${YYYYMMDDHHi}/Post/logs +cp -f \${DIRRUN}/dir.0001/include_fields \${DATAOUT}/${YYYYMMDDHHi}/Post/logs +cp -f \${DIRRUN}/dir.0001/convert_mpas.output \${DATAOUT}/${YYYYMMDDHHi}/Post/logs +cp -f \${DIRRUN}/PostAtmos_node.*.sh \${DATAOUT}/${YYYYMMDDHHi}/Post/logs +cp -f \${DATAOUT}/${YYYYMMDDHHi}/Model/logs/* \${DATAOUT}/${YYYYMMDDHHi}/Post/logs +cp -f \${DATAOUT}/${YYYYMMDDHHi}/Model/MONAN-VERSION.txt \${DATAOUT}/${YYYYMMDDHHi}/Post/logs -cd ${DIRRUN}/.. -rm -fr ${DIRRUN} - EOSH chmod a+x ${DIRRUN}/PostAtmos_node.${node}.sh @@ -644,3 +677,6 @@ cd ${SCRIPTS} chmod 755 ${DATAOUT}/${YYYYMMDDHHi}/Post/* time ${SCRIPTS}/make_template.bash ${MONAN_ONETWO} ${dv_VARTABLE} \ -d ${OUTPUT_DIAG_INTERVAL} -e ${EXP} -f ${FCST} -r ${RES} -t ${YYYYMMDDHHi} + +cd ${DIRRUN}/.. +rm -fr ${DIRRUN} diff --git a/scripts/group_levels.py b/scripts/group_levels.py index e425f7c..1d7d66a 100644 --- a/scripts/group_levels.py +++ b/scripts/group_levels.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import netCDF4 as nc import numpy as np @@ -34,7 +34,7 @@ def main(data_dir, file_in, file_out, levels=[1000, 975, 950, 925, 900, 875, 850 for name, variable in reversed(list(nc_file_in.variables.items())): # reverse to be consistent to levels # if 'hPa' in name or name in dimensions_4D: if 'hPa' in name: - variable_type = re.split('_.\d*hPa', name)[0] # Extract the variable type (e.g., '15hPa', '20hPa') + variable_type = re.split(r'_.\d*hPa', name)[0] # Extract the variable type (e.g., '15hPa', '20hPa') first_hpa_variable = variable_type if first_hpa_variable == '' else first_hpa_variable else: variable_type = name.lower() @@ -45,7 +45,7 @@ def main(data_dir, file_in, file_out, levels=[1000, 975, 950, 925, 900, 875, 850 # if there isn't any hPa variable - set default 22 levels if not first_hpa_variable: - print("Nenhuma variável com nível isobárico ('hPa') foi encontrada no arquivo.") + print("No isobaric variable ('hPa') found in file. Using a dummy level count.") level_dimension_size = 22 else: level_dimension_size = len(variable_groups[first_hpa_variable]) @@ -107,7 +107,7 @@ def main(data_dir, file_in, file_out, levels=[1000, 975, 950, 925, 900, 875, 850 import sys if len(sys.argv) != 4: - print(f"Usage: python {sys.argv[0]} ") + print(f"Usage: python3 {sys.argv[0]} ") sys.exit(1) main(sys.argv[1], sys.argv[2], sys.argv[3]) diff --git a/scripts/setenv.bash b/scripts/setenv.bash index 14f9648..7d85034 100755 --- a/scripts/setenv.bash +++ b/scripts/setenv.bash @@ -162,18 +162,6 @@ export DATAIN=${DIRHOMED}/datain; mkdir -p ${DATAIN} export DATAOUT=${DIRHOMED}/dataout; mkdir -p ${DATAOUT} export SOURCES=${DIRHOMES}/sources; mkdir -p ${SOURCES} export EXECS=${DIRHOMED}/execs; mkdir -p ${EXECS} - -echo -e "" -echo -e "${GREEN}==>${NC}*** List of paths: ***" -echo -e "" -echo -e "${GREEN}==>${NC} DIRHOMES = \"${DIRHOMES}\"" -echo -e "${GREEN}==>${NC} DIRHOMED = \"${DIRHOMED}\"" -echo -e "${GREEN}==>${NC} SCRIPTS = \"${SCRIPTS}\"" -echo -e "${GREEN}==>${NC} DATAIN = \"${DATAIN}\"" -echo -e "${GREEN}==>${NC} DATAOUT = \"${DATAOUT}\"" -echo -e "${GREEN}==>${NC} SOURCES = \"${SOURCES}\"" -echo -e "${GREEN}==>${NC} EXECS = \"${EXECS}\"" -echo -e "" #---~--- diff --git a/scripts/setenv_python.bash b/scripts/setenv_python.bash index fe6e6ba..1c9ca21 100644 --- a/scripts/setenv_python.bash +++ b/scripts/setenv_python.bash @@ -3,11 +3,14 @@ case "${HOSTNAME}" in egeon) echo "Load python ..." - module load python-3.9.13-gcc-9.4.0-moxjnc6 + module load python-3.9.13-gcc-9.4.0-moxjnc6 + export PYTHON_EXEC=python3 + export PIP_EXEC=pip3 ;; ian) - echo "Load python ..." - module load anaconda/24.1.2 + echo "Using the system's python ..." + export PYTHON_EXEC=python3.12 + export PIP_EXEC=pip3.12 ;; esac @@ -15,16 +18,25 @@ esac echo "Define path for python environment" export PYTHON_ENV_PATH="${DIRHOMES}/.venv" - -echo "Create python environment at ${PYTHON_ENV_PATH}" -python3 -m venv ${PYTHON_ENV_PATH} - -echo "Activate python environment" -source ${PYTHON_ENV_PATH}/bin/activate - -echo "Install python libraries" -pip install --upgrade pip -pip install -r ${SCRIPTS}/requirements.txt +echo "Define cache for PIP" +export PIP_CACHE_DIR="${DIRHOMES}/.pip-cache" +export PIP_CACHE_CONFIG="${DIRHOMES}/.pip-config" + +if [[ ! -s ${PYTHON_ENV_PATH} ]] +then + echo "Create python environment at ${PYTHON_ENV_PATH}" + ${PYTHON_EXEC} -m venv ${PYTHON_ENV_PATH} + + echo "Activate python environment" + source ${PYTHON_ENV_PATH}/bin/activate + + echo "Install python libraries" + ${PIP_EXEC} install --upgrade pip + ${PIP_EXEC} install -r ${SCRIPTS}/requirements.txt +else + echo "Activate python environment" + source ${PYTHON_ENV_PATH}/bin/activate +fi export PYTHONPATH=${PYTHONPATH}:${SCRIPTS} echo "export PYTHONPATH=${PYTHONPATH}" diff --git a/scripts/stools/setenv_PBS_ian_gnu.bash b/scripts/stools/setenv_PBS_ian_gnu.bash index 196318b..4827a46 100755 --- a/scripts/stools/setenv_PBS_ian_gnu.bash +++ b/scripts/stools/setenv_PBS_ian_gnu.bash @@ -9,7 +9,7 @@ module load cray-netcdf/4.9.0.15 module load cray-parallel-netcdf/1.12.3.15 module load xpmem/0.2.119-1.3_gef379be13330 module load grads/2.2.1.oga.1 -module load cdo/2.4.2 +module load cdo/2.5.4 module load METIS/5.1.0 module load cray-pals module list diff --git a/scripts/stools/setenv_PBS_ian_intel.bash b/scripts/stools/setenv_PBS_ian_intel.bash index 63211d8..aaffd3e 100755 --- a/scripts/stools/setenv_PBS_ian_intel.bash +++ b/scripts/stools/setenv_PBS_ian_intel.bash @@ -9,7 +9,7 @@ module load cray-netcdf/4.9.0.15 module load cray-parallel-netcdf/1.12.3.15 module load xpmem/0.2.119-1.3_gef379be13330 module load grads/2.2.1.oga.1 -module load cdo/2.4.2 +module load cdo/2.5.4 module load METIS/5.1.0 module load cray-pals module list From f9ce1e0dfbcee4cbcc58d407ed5833a51ec43cba Mon Sep 17 00:00:00 2001 From: Marcos Longo Date: Mon, 2 Feb 2026 15:42:17 -0300 Subject: [PATCH 15/15] Minor edits to avoid double deleting directory DIRRUN. --- scripts/4.run_post.bash | 4 ++-- scripts/make_template.bash | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/scripts/4.run_post.bash b/scripts/4.run_post.bash index 632e64c..b64731d 100755 --- a/scripts/4.run_post.bash +++ b/scripts/4.run_post.bash @@ -657,7 +657,7 @@ PBS) qsub -W depend=${dependency} -W block=true ${DIRRUN}/PostAtmos_node.${node}.sh ;; #GENERIC) -# echo "Nenhum gerenciador detectado" +# echo "No job manager detected." # ${DIRRUN}/PostAtmos_node.${node}.sh # ;; esac @@ -678,5 +678,5 @@ chmod 755 ${DATAOUT}/${YYYYMMDDHHi}/Post/* time ${SCRIPTS}/make_template.bash ${MONAN_ONETWO} ${dv_VARTABLE} \ -d ${OUTPUT_DIAG_INTERVAL} -e ${EXP} -f ${FCST} -r ${RES} -t ${YYYYMMDDHHi} -cd ${DIRRUN}/.. +cd ${DIRHOMES} rm -fr ${DIRRUN} diff --git a/scripts/make_template.bash b/scripts/make_template.bash index b662783..02b8b77 100755 --- a/scripts/make_template.bash +++ b/scripts/make_template.bash @@ -159,8 +159,7 @@ mkdir -p ${DATAOUT}/${YYYYMMDDHHi}/Post/logs # Local variables-------------------------------------- START_DATE_YYYYMMDD="${YYYYMMDDHHi:0:4}-${YYYYMMDDHHi:4:2}-${YYYYMMDDHHi:6:2}" START_HH="${YYYYMMDDHHi:8:2}" -maxpostpernode=20 # <------ qtde max de convert_mpas por no! -export DIRRUN=${DIRHOMED}/run.${YYYYMMDDHHi}; rm -fr ${DIRRUN}; mkdir -p ${DIRRUN} +export DIRRUN=${DIRHOMED}/run.${YYYYMMDDHHi}; mkdir -p ${DIRRUN} #------------------------------------------------------- #--- Variables for flexible output intervals. @@ -300,4 +299,3 @@ sed -i "/dset/c\dset ^${diag_name_templ}" ${DIRRUN}/qctlinfo.ctl chmod 755 ${DIRRUN}/* mv ${DIRRUN}/qctlinfo.ctl ${DATAOUT}/${YYYYMMDDHHi}/Post/${diag_name_post}.template.ctl -rm -fr ${DIRRUN}