diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesSetupParamBuild/README.md b/cime_config/testdefs/testmods_dirs/clm/FatesSetupParamBuild/README.md new file mode 100644 index 0000000000..e2b225d501 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesSetupParamBuild/README.md @@ -0,0 +1,7 @@ + +User mod directory to make sure the user is setup to run the FATES modify param file script. +IF not it trys some different options and prints messages regarding what worked, and what the user +needs to do if nothing worked. + + + diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesSetupParamBuild/run_shell_commands_tests b/cime_config/testdefs/testmods_dirs/clm/FatesSetupParamBuild/run_shell_commands_tests new file mode 100755 index 0000000000..a2eb2b4b85 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesSetupParamBuild/run_shell_commands_tests @@ -0,0 +1,37 @@ +#!/bin/bash + +# Define a custom error handler function +handle_error() { + echo "An error occurred: $1" + echo "error code: $?" + # Additional error handling code can go here + return 1 +} + +# Set the error handler to be called when an error occurs +trap 'handle_error "Something went wrong!"' ERR + +host=`hostname -f` +if [[ "$host" =~ derecho*.hpc.ucar.edu || "$host" =~ d*.hpc.ucar.edu ]] ; then + echo "Running on Derecho..." >&2 + echo ".... making sure conda is loaded..." >&2 + module load conda +else + echo "Not a recognized host: $host" >&2 + exit 5 +fi +echo "Test if shell_commands will run..." +. ./shell_commands > /dev/null + +echo "Now do some tests of the bash subroutines" >&2 +unset DEBUG +$(log_msg_if_debug "Die with Error since DEBUG is unset") +if [[ "$?" -eq "0" ]]; then + echo "Should have died with an error..." >&2 + exit 1 +fi +echo "after DEBUG test" +DEBUG=0 +$(log_msg_if_debug "Die with Error since too many options are input" "another option") + +echo "Successful"