From 9dbc973030cf9a0d78dc3645811fad4959a73470 Mon Sep 17 00:00:00 2001 From: RussTreadon-NOAA Date: Mon, 6 Feb 2023 19:30:22 +0000 Subject: [PATCH] streamline run_jedi_exe ctests (#223) --- test/atm/CMakeLists.txt | 15 +++++ test/atm/global-workflow/CMakeLists.txt | 19 ------ .../run_jedi_exe_3dhofx.sh | 62 ++++++++++--------- .../run_jedi_exe_3dvar.sh | 55 ++++++++-------- .../run_jedi_exe_letkf.sh | 59 +++++++++--------- 5 files changed, 104 insertions(+), 106 deletions(-) rename test/atm/{global-workflow => }/run_jedi_exe_3dhofx.sh (69%) rename test/atm/{global-workflow => }/run_jedi_exe_3dvar.sh (75%) rename test/atm/{global-workflow => }/run_jedi_exe_letkf.sh (74%) diff --git a/test/atm/CMakeLists.txt b/test/atm/CMakeLists.txt index 117e2ea8e..55e1dbc4c 100644 --- a/test/atm/CMakeLists.txt +++ b/test/atm/CMakeLists.txt @@ -25,6 +25,21 @@ if (BUILD_GDASBUNDLE) ENVIRONMENT "PYTHONPATH=${PROJECT_BINARY_DIR}/ush:$ENV{PYTHONPATH}" ) + # test for ush/run_jedi_exe.py 3dhofx + add_test(NAME test_gdasapp_run_jedi_exe_3dhofx + COMMAND ${PROJECT_SOURCE_DIR}/test/atm/run_jedi_exe_3dhofx.sh ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR} + WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/test/) + + # test for ush/run_jedi_exe.py 3dvar + add_test(NAME test_gdasapp_run_jedi_exe_3dvar + COMMAND ${PROJECT_SOURCE_DIR}/test/atm/run_jedi_exe_3dvar.sh ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR} + WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/test/) + + # test for ush/run_jedi_exe.py letkf + add_test(NAME test_gdasapp_run_jedi_exe_letkf + COMMAND ${PROJECT_SOURCE_DIR}/test/atm/run_jedi_exe_letkf.sh ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR} + WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/test/) + # Test exgdas scripts from the global-worflow if (WORKFLOW_TESTS) add_subdirectory(global-workflow) diff --git a/test/atm/global-workflow/CMakeLists.txt b/test/atm/global-workflow/CMakeLists.txt index d7c9fd399..c31571c58 100644 --- a/test/atm/global-workflow/CMakeLists.txt +++ b/test/atm/global-workflow/CMakeLists.txt @@ -35,22 +35,3 @@ add_test(NAME test_gdasapp_atm_jjob_ens_post COMMAND ${PROJECT_SOURCE_DIR}/test/atm/global-workflow/jjob_ens_post.sh ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR} WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/test/atm/global-workflow/testrun) - -# run_jedi_exe ctests do not require g-w. place here due to longer run time -# test for ush/run_jedi_exe.py 3dhofx -add_test(NAME test_gdasapp_run_jedi_exe_3dhofx - COMMAND ${PROJECT_SOURCE_DIR}/test/atm/global-workflow/run_jedi_exe_3dhofx.sh - ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR} - WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/test/atm/global-workflow/testrun) - -# test for ush/run_jedi_exe.py 3dvar -add_test(NAME test_gdasapp_run_jedi_exe_3dvar - COMMAND ${PROJECT_SOURCE_DIR}/test/atm/global-workflow/run_jedi_exe_3dvar.sh - ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR} - WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/test/atm/global-workflow/testrun) - -# test for ush/run_jedi_exe.py letkf -add_test(NAME test_gdasapp_run_jedi_exe_letkf - COMMAND ${PROJECT_SOURCE_DIR}/test/atm/global-workflow/run_jedi_exe_letkf.sh - ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR} - WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/test/atm/global-workflow/testrun) diff --git a/test/atm/global-workflow/run_jedi_exe_3dhofx.sh b/test/atm/run_jedi_exe_3dhofx.sh similarity index 69% rename from test/atm/global-workflow/run_jedi_exe_3dhofx.sh rename to test/atm/run_jedi_exe_3dhofx.sh index 387381f42..533d09097 100755 --- a/test/atm/global-workflow/run_jedi_exe_3dhofx.sh +++ b/test/atm/run_jedi_exe_3dhofx.sh @@ -4,6 +4,7 @@ set -x bindir=$1 srcdir=$2 +# Identify machine if [[ -d /scratch1 ]] ; then machine="hera" elif [[ -d /work ]] ; then @@ -13,12 +14,14 @@ else exit 99 fi +# Load modules set +x module use ${srcdir}/modulefiles module load GDAS/${machine} set -x module list +# Set machine dependent variables if [ "$machine" = "hera" ] ; then partition="hera" gdasfix="/scratch1/NCEPDEV/da/Cory.R.Martin/GDASApp/fix" @@ -27,9 +30,11 @@ elif [ "$machine" = "orion" ]; then gdasfix="/work2/noaa/da/cmartin/GDASApp/fix" fi +# Create test run directory mkdir -p ${bindir}/test/atm/global-workflow/testrun/gdas_single_test_hofx3d cd ${bindir}/test/atm/global-workflow/testrun/gdas_single_test_hofx3d +# Create input yaml cat > ./3dhofx_example.yaml << EOF working directory: ./ GDASApp home: ${srcdir} @@ -44,9 +49,9 @@ config: layout_x: 3 layout_y: 2 atm_window_length: PT6H - valid_time: 2021-08-01T00:00:00Z + valid_time: 2021-12-21T06:00:00Z dump: gdas - case: C768 + case: C96 levs: 128 interp_method: barycentric job options: @@ -60,42 +65,39 @@ job options: modulepath: ${srcdir}/modulefiles EOF -rm stdout.txt -${srcdir}/ush/run_jedi_exe.py -c ./3dhofx_example.yaml > stdout.txt +# Execute run_jedi_exe.py +if [ -e stdout.txt ]; then + rm -f stdout.txt +fi +${srcdir}/ush/run_jedi_exe.py -c ./3dhofx_example.yaml > stdout.txt 2>&1 rc=$? if [ $rc -ne 0 ]; then exit $rc fi -sleep 10 -jobid=$(grep "Submitted" stdout.txt | awk -F' ' '{print $4}') -echo "jobid is $jobid" +# Check for job submission error +error=$(grep -i "error" stdout.txt | wc -l) +if [ $error -ne 0 ]; then + rc=$error + exit $rc +fi -nloop=100 -n=1 -while [ $n -le $nloop ]; do - if [ -s GDASApp.o$jobid ]; then - break - fi - sleep 10 - n=$((n+1)) -done +# Cancel submitted job +jobid=$(grep "Submitted" stdout.txt | awk -F' ' '{print $4}') +scancel $jobid +rc=$? +if [ $rc -ne 0 ]; then + exit $rc +fi -rc=1 -n=1 -while [ $n -le $nloop ]; do - count=$(cat GDASApp.o$jobid | grep "OOPS_STATS Run end" | wc -l) - if [ $count -gt 0 ]; then - rc=0 - break - fi - count=$(cat GDASApp.o$jobid | grep "srun: error" | wc -l) - if [ $count -gt 0 ]; then - rc=9 - break +# Check for valid yaml files +ylist="3dhofx_example.yaml gdas_hofx.yaml" +for yfile in $ylist; do + python3 -c 'import yaml, sys; yaml.safe_load(sys.stdin)' < $yfile + rc=$? + if [ $rc -ne 0 ]; then + exit $rc fi - sleep 10 - n=$((n+1)) done exit $rc diff --git a/test/atm/global-workflow/run_jedi_exe_3dvar.sh b/test/atm/run_jedi_exe_3dvar.sh similarity index 75% rename from test/atm/global-workflow/run_jedi_exe_3dvar.sh rename to test/atm/run_jedi_exe_3dvar.sh index 28adf2c5e..8b37302f0 100755 --- a/test/atm/global-workflow/run_jedi_exe_3dvar.sh +++ b/test/atm/run_jedi_exe_3dvar.sh @@ -4,6 +4,7 @@ set -x bindir=$1 srcdir=$2 +# Identify machine if [[ -d /scratch1 ]] ; then machine="hera" elif [[ -d /work ]] ; then @@ -13,12 +14,14 @@ else exit 99 fi +# Load modules set +x module use ${srcdir}/modulefiles module load GDAS/${machine} set -x module list +# Set machine dependent variables if [ "$machine" = "hera" ] ; then partition="hera" gdasfix="/scratch1/NCEPDEV/da/Cory.R.Martin/GDASApp/fix" @@ -27,9 +30,11 @@ elif [ "$machine" = "orion" ]; then gdasfix="/work2/noaa/da/cmartin/GDASApp/fix" fi +# Create test run directory mkdir -p ${bindir}/test/atm/global-workflow/testrun/gdas_single_test_3dvar cd ${bindir}/test/atm/global-workflow/testrun/gdas_single_test_3dvar +# Create input yaml cat > ./3dvar_example.yaml << EOF working directory: ./ GDASApp home: ${srcdir} @@ -69,45 +74,39 @@ job options: modulepath: ${srcdir}/modulefiles EOF +# Execute run_jedi_exe.py if [ -e stdout.txt ]; then rm -f stdout.txt fi - -${srcdir}/ush/run_jedi_exe.py -c ./3dvar_example.yaml > stdout.txt +${srcdir}/ush/run_jedi_exe.py -c ./3dvar_example.yaml > stdout.txt 2>&1 rc=$? if [ $rc -ne 0 ]; then exit $rc fi -sleep 10 -jobid=$(grep "Submitted" stdout.txt | awk -F' ' '{print $4}') -echo "jobid is $jobid" +# Check for job submission error +error=$(grep -i "error" stdout.txt | wc -l) +if [ $error -ne 0 ]; then + rc=$error + exit $rc +fi -nloop=100 -n=1 -while [ $n -le $nloop ]; do - if [ -s GDASApp.o$jobid ]; then - break - fi - sleep 10 - n=$((n+1)) -done +# Cancel submitted job +jobid=$(grep "Submitted" stdout.txt | awk -F' ' '{print $4}') +scancel $jobid +rc=$? +if [ $rc -ne 0 ]; then + exit $rc +fi -rc=1 -n=1 -while [ $n -le $nloop ]; do - count=$(cat GDASApp.o$jobid | grep "OOPS_STATS Run end" | wc -l) - if [ $count -gt 0 ]; then - rc=0 - break - fi - count=$(cat GDASApp.o$jobid | grep "srun: error" | wc -l) - if [ $count -gt 0 ]; then - rc=9 - break +# Check for valid yaml files +ylist="3dvar_example.yaml gdas_variational.yaml" +for yfile in $ylist; do + python3 -c 'import yaml, sys; yaml.safe_load(sys.stdin)' < $yfile + rc=$? + if [ $rc -ne 0 ]; then + exit $rc fi - sleep 10 - n=$((n+1)) done exit $rc diff --git a/test/atm/global-workflow/run_jedi_exe_letkf.sh b/test/atm/run_jedi_exe_letkf.sh similarity index 74% rename from test/atm/global-workflow/run_jedi_exe_letkf.sh rename to test/atm/run_jedi_exe_letkf.sh index 6dd01ae77..7ae573716 100755 --- a/test/atm/global-workflow/run_jedi_exe_letkf.sh +++ b/test/atm/run_jedi_exe_letkf.sh @@ -4,6 +4,7 @@ set -x bindir=$1 srcdir=$2 +# Identify machine if [[ -d /scratch1 ]] ; then machine="hera" elif [[ -d /work ]] ; then @@ -13,12 +14,14 @@ else exit 99 fi +# Load modules set +x module use ${srcdir}/modulefiles module load GDAS/${machine} set -x module list +# Set machine dependent variables if [ "$machine" = "hera" ] ; then cominges="/scratch1/NCEPDEV/da/Russ.Treadon/GDASApp/cases" partition="hera" @@ -29,9 +32,11 @@ elif [ "$machine" = "orion" ]; then gdasfix="/work2/noaa/da/cmartin/GDASApp/fix" fi +# Create test run directory mkdir -p ${bindir}/test/atm/global-workflow/testrun/gdas_single_test_letkf cd ${bindir}/test/atm/global-workflow/testrun/gdas_single_test_letkf +# Create input yaml cat > ./letkf_example.yaml << EOF working directory: ./ GDASApp home: ${srcdir} @@ -71,43 +76,39 @@ job options: modulepath: ${srcdir}/modulefiles EOF -rm stdout.txt -${srcdir}/ush/run_jedi_exe.py -c ./letkf_example.yaml > stdout.txt +# Execute run_jedi_exe.py +if [ -e stdout.txt ]; then + rm -f stdout.txt +fi +${srcdir}/ush/run_jedi_exe.py -c ./letkf_example.yaml > stdout.txt 2>&1 rc=$? if [ $rc -ne 0 ]; then exit $rc fi -sleep 10 -jobid=$(grep "Submitted" stdout.txt | awk -F' ' '{print $4}') -echo "jobid is $jobid" +# Check for job submission error +error=$(grep -i "error" stdout.txt | wc -l) +if [ $error -ne 0 ]; then + rc=$error + exit $rc +fi -nloop=100 -n=1 -while [ $n -le $nloop ]; do - if [ -s GDASApp.o$jobid ]; then - break - fi - sleep 10 - n=$((n+1)) -done +# Cancel submitted job +jobid=$(grep "Submitted" stdout.txt | awk -F' ' '{print $4}') +scancel $jobid +rc=$? +if [ $rc -ne 0 ]; then + exit $rc +fi -rc=1 -n=1 -while [ $n -le $nloop ]; do - count=$(cat GDASApp.o$jobid | grep "OOPS_STATS Run end" | wc -l) - if [ $count -gt 0 ]; then - rc=0 - break - fi - count=$(cat GDASApp.o$jobid | grep "srun: error" | wc -l) - if [ $count -gt 0 ]; then - rc=9 - break +# Check for valid yaml files +ylist="letkf_example.yaml gdas_letkf.yaml" +for yfile in $ylist; do + python3 -c 'import yaml, sys; yaml.safe_load(sys.stdin)' < $yfile + rc=$? + if [ $rc -ne 0 ]; then + exit $rc fi - sleep 10 - n=$((n+1)) done exit $rc -