From 703ff969646bb333000778d218e95b51a2aca548 Mon Sep 17 00:00:00 2001 From: meihuisu Date: Mon, 20 Mar 2023 05:47:36 +0000 Subject: [PATCH] add a taper test to basin_query --- .../basin/run_basin_query_cvmsi_taper.sh | 55 +++++++++++++++++++ src/basin/basin_query_mpi.c | 12 ++-- test/inputs/test_latlons_taper.txt | 3 + 3 files changed, 65 insertions(+), 5 deletions(-) create mode 100755 examples/programs/basin/run_basin_query_cvmsi_taper.sh create mode 100644 test/inputs/test_latlons_taper.txt diff --git a/examples/programs/basin/run_basin_query_cvmsi_taper.sh b/examples/programs/basin/run_basin_query_cvmsi_taper.sh new file mode 100755 index 00000000..ca910d35 --- /dev/null +++ b/examples/programs/basin/run_basin_query_cvmsi_taper.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +if [ -z "$UCVM_INSTALL_PATH" ]; then + echo "Need to set UCVM_INSTALL_PATH to run >" ${0##*/} + exit +fi +source $UCVM_INSTALL_PATH/conf/ucvm_env.sh + +BIN_DIR=${UCVM_INSTALL_PATH}/bin +CONF_DIR=${UCVM_INSTALL_PATH}/conf +TEST_DIR=${UCVM_INSTALL_PATH}/tests/inputs +MODEL=cvmsi,elygtl:taper + +expect=$(mktemp) || exit 1 +result=$(mktemp) || (trap 'rm -f "$expect"'; exit 1) + +${BIN_DIR}/basin_query -m ${MODEL} -f ${CONF_DIR}/ucvm.conf -v 2500.0 < ${TEST_DIR}/test_latlons_taper.txt > $result 2>&1 + +cat > $expect << EOF_EXPECTED_RESULT_Z2500 + -117.9350 33.2550 520.000 520.000 520.000 + -119.0350 34.1100 420.000 2060.000 2120.000 + -118.7600 34.1100 500.000 1180.000 1180.000 +EOF_EXPECTED_RESULT_Z2500 + +echo "Running examples_programs_basin z2500 basin_query_cvmi_taper" +if diff $result $expect > /dev/null 2>&1 +then + echo [SUCCESS] +else + echo [FAILURE] +fi + +trap 'rm -f "$expect" "$result"' exit + +expect=$(mktemp) || exit 1 +result=$(mktemp) || (trap 'rm -f "$expect"'; exit 1) + +${BIN_DIR}/basin_query -m ${MODEL} -f ${CONF_DIR}/ucvm.conf -v 1000.0 < ${TEST_DIR}/test_latlons_taper.txt > $result 2>&1 + +cat > $expect << EOF_EXPECTED_RESULT_Z1000 + -117.9350 33.2550 140.000 140.000 140.000 + -119.0350 34.1100 320.000 320.000 320.000 + -118.7600 34.1100 160.000 320.000 320.000 +EOF_EXPECTED_RESULT_Z1000 + +echo "Running examples_programs_basin z1000 basin_query_cvmi_taper" +if diff $result $expect > /dev/null 2>&1 +then + echo [SUCCESS] +else + echo [FAILURE] +fi + +trap 'rm -f "$expect" "$result"' exit + diff --git a/src/basin/basin_query_mpi.c b/src/basin/basin_query_mpi.c index 1d233f52..82e9a7ac 100644 --- a/src/basin/basin_query_mpi.c +++ b/src/basin/basin_query_mpi.c @@ -26,6 +26,8 @@ #define WORKERREADY 99 #define DIEOFF -1 +int debug=0; + /* Get opt args */ extern char *optarg; extern int optind, opterr, optopt; @@ -267,7 +269,7 @@ int main(int argc, char **argv) { double tempDepths[2]; float *retDepths = malloc(nx * sizeof(float)); - printf("Current line: %d. Progress: %.2f\%\n", currentline, (float)currentline / (float)ny * 100.0f); + printf("Current line: %d. Progress: %.2f\\%\n", currentline, (float)currentline / (float)ny * 100.0f); for (i = 0; i < nx; i++) { pnts[0].coord[1] = (currentline * spacing) + latlon[0]; @@ -277,11 +279,11 @@ int main(int argc, char **argv) { retDepths[i] = (float)tempDepths[0]; - //printf("%f %f %f %d\n", pnts[0].coord[0], pnts[0].coord[1], retDepths[i], rank); - //if (rank == 0) { - //printf("On index: %d\n", i); - //} + if(debug) { + printf("PNTS:%f %f %f %d\n", pnts[0].coord[0], pnts[0].coord[1], retDepths[i], rank); + // if (rank == 0) { printf("On index: %d\n", i);} + } } MPI_File_set_view(fh, currentline * nx * sizeof(float), MPI_FLOAT, MPI_FLOAT, "native", MPI_INFO_NULL); diff --git a/test/inputs/test_latlons_taper.txt b/test/inputs/test_latlons_taper.txt new file mode 100644 index 00000000..4ab29678 --- /dev/null +++ b/test/inputs/test_latlons_taper.txt @@ -0,0 +1,3 @@ +-117.9350 33.2550 +-119.0350 34.1100 +-118.7600 34.1100