diff --git a/io/teca_cartesian_mesh_writer.cxx b/io/teca_cartesian_mesh_writer.cxx index 87369bd0f..530992253 100644 --- a/io/teca_cartesian_mesh_writer.cxx +++ b/io/teca_cartesian_mesh_writer.cxx @@ -395,6 +395,8 @@ const_p_teca_dataset teca_cartesian_mesh_writer::execute( = std::dynamic_pointer_cast( input_data[0]); + std::cerr << "teca_cartesian_mesh_writer::execute -- mesh: " << mesh << std::endl; + // only rank 0 is required to have data int rank = 0; #if defined(TECA_HAS_MPI) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a3cc26805..6ab91f28d 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -56,14 +56,14 @@ teca_add_test(test_cf_reader_cam5 LIBS teca_core teca_data teca_io teca_alg ${teca_test_link} COMMAND test_cf_reader -i "${TECA_DATA_ROOT}/cam5_1_amip_run2\\.cam2\\.h2\\.1991-10-[0-9][0-9]-10800\\.nc" - -o "test_cf_reader_%t%.%e%" -s 1,2 -x lon -y lat -t time U850 V850 + -o "${TECA_DATA_ROOT}/test_cf_reader_cam5.bin" -s 1,1 -x lon -y lat -t time U850 V850 FEATURES ${TECA_HAS_NETCDF} REQ_TECA_DATA) teca_add_test(test_cf_reader_cfsr COMMAND test_cf_reader -i "${TECA_DATA_ROOT}/NCEP_CFSR_0\\.5_1979\\.nc" - -o "test_cf_reader_%t%.%e%" -s 1,2 -x longitude -y latitude + -o "${TECA_DATA_ROOT}/test_cf_reader_cfsr.bin" -s 1,2 -x longitude -y latitude -b 65,110,10,55,0,0 elevation FEATURES ${TECA_HAS_NETCDF} REQ_TECA_DATA) @@ -71,14 +71,14 @@ teca_add_test(test_cf_reader_cfsr teca_add_test(test_cf_reader_era5 COMMAND test_cf_reader -i "${TECA_DATA_ROOT}/e5\.oper\.an\.vinteg\.162_072_viwvn.*\.nc" - -o "test_cf_reader_era5_%t%.%e%" -s 0,-1 -x longitude -y latitude -t time VIWVN + -o "${TECA_DATA_ROOT}/test_cf_reader_era5.bin" -s 0,-1 -x longitude -y latitude -t time VIWVN FEATURES ${TECA_HAS_NETCDF} REQ_TECA_DATA) teca_add_test(test_cf_reader_file_time COMMAND test_cf_reader -i "${TECA_DATA_ROOT}/ARTMIP_MERRA_2D_20170210_06\.nc" - -o "test_cf_reader_file_time_%t%.%e%" -s 0,-1 -x lon -y lat + -o "test_cf_reader_file_time.bin" -s 0,-1 -x lon -y lat -n "ARTMIP_MERRA_2D_%Y%m%d_%H.nc" IVT FEATURES ${TECA_HAS_NETCDF} REQ_TECA_DATA) @@ -235,7 +235,7 @@ teca_add_test(test_temporal_average LIBS teca_core teca_data teca_io teca_alg ${teca_test_link} COMMAND test_temporal_average "${TECA_DATA_ROOT}/cam5_1_amip_run2.cam2.h2.1991-10-01-10800.nc" - test_temporal_average_%t%.%e% 0 -1 3 U850 + ${TECA_DATA_ROOT}/test_temporal_average.bin 0 -1 3 U850 FEATURES ${TECA_HAS_NETCDF} REQ_TECA_DATA) @@ -500,7 +500,7 @@ teca_add_test(test_binary_segmentation SOURCES test_binary_segmentation.cpp LIBS teca_core teca_data teca_io teca_alg ${teca_test_link} COMMAND test_binary_segmentation "${TECA_DATA_ROOT}/prw_hus_day_MRI.*\\.nc$" - prw 50 75 "prw_segmentation_50-75_%t%.%e%" + prw 50 75 "${TECA_DATA_ROOT}/prw_segmentation_50-75.bin" REQ_TECA_DATA) teca_add_test(test_bayesian_ar_detect_serial diff --git a/test/python/CMakeLists.txt b/test/python/CMakeLists.txt index 93d04bc42..7d48817fa 100644 --- a/test/python/CMakeLists.txt +++ b/test/python/CMakeLists.txt @@ -1,7 +1,7 @@ teca_add_test(py_test_cf_reader COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_cf_reader.py "${TECA_DATA_ROOT}/cam5_1_amip_run2\\.cam2\\.h2\\.1991-10-0[12]-10800\\.nc" - 1 2 "py_test_cf_reader_%t%.vtk" U850 V850 + 1 1 "${TECA_DATA_ROOT}/py_test_cf_reader.bin" U850 V850 FEATURES ${TECA_HAS_NETCDF} REQ_TECA_DATA) @@ -40,7 +40,7 @@ if (TECA_DATA_ROOT AND TECA_HAS_NETCDF) add_test(NAME py_test_connected_components COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_connected_components.py "${TECA_DATA_ROOT}/cam5_1_amip_run2\\.cam2\\.h2\\.1991-10-01-10800\\.nc" - "" U850 V850 15 0 0 "py_test_connected_components_%t%.vtk" + "" U850 V850 15 0 0 "${TECA_DATA_ROOT}/py_test_connected_components.bin" WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) endif() @@ -51,7 +51,7 @@ teca_add_test(py_test_component_area_filter teca_add_test(py_test_derived_quantity COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_derived_quantity.py "${TECA_DATA_ROOT}/cam5_1_amip_run2\\.cam2\\.h2\\.1991-10-0[12]-10800\\.nc" - U850 V850 0 0 "py_test_derived_quantity_%t%.vtk" + U850 V850 0 0 "${TECA_DATA_ROOT}/py_test_derived_quantity.bin" FEATURES ${TECA_HAS_NETCDF} REQ_TECA_DATA) @@ -62,14 +62,14 @@ teca_add_test(py_test_latitude_damper teca_add_test(py_test_programmable_algorithm COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_programmable_algorithm.py "${TECA_DATA_ROOT}/cam5_1_amip_run2\\.cam2\\.h2\\.1991-10-0[12]-10800\\.nc" - U850 V850 0 0 "py_test_programmable_algorithm_%t%.vtk" + U850 V850 0 0 "${TECA_DATA_ROOT}/py_test_programmable_algorithm.bin" FEATURES ${TECA_HAS_NETCDF} REQ_TECA_DATA) teca_add_test(py_test_vector_ops COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_vector_ops.py "${TECA_DATA_ROOT}/cam5_1_amip_run2\\.cam2\\.h2\\.1991-10-01-10800\\.nc" - 0 0 py_test_vector_ops_%t%.vtk U850 V850 + 0 0 ${TECA_DATA_ROOT}/py_test_vector_ops.bin U850 V850 FEATURES ${TECA_HAS_NETCDF} REQ_TECA_DATA) diff --git a/test/python/test_cf_reader.py b/test/python/test_cf_reader.py index 6c84cccff..7e617b6a6 100644 --- a/test/python/test_cf_reader.py +++ b/test/python/test_cf_reader.py @@ -1,4 +1,5 @@ from teca import * +import os import sys set_stack_trace_on_error() @@ -34,9 +35,21 @@ exe.set_end_index(end_index) exe.set_arrays(arrays) -wri = teca_cartesian_mesh_writer.New() -wri.set_input_connection(coords.get_output_port()) -wri.set_executive(exe) -wri.set_file_name(out_file) - -wri.update() +if os.path.exists(out_file): + rea = teca_cartesian_mesh_reader.New() + rea.set_file_name(out_file) + + diff = teca_dataset_diff.New() + diff.set_input_connection(0, rea.get_output_port()) + diff.set_input_connection(1, coords.get_output_port()) + diff.set_executive(exe) + + diff.update() +else: + sys.stderr.write('generating baseline\n') + wri = teca_cartesian_mesh_writer.New() + wri.set_input_connection(coords.get_output_port()) + wri.set_executive(exe) + wri.set_file_name(out_file) + + wri.update() diff --git a/test/python/test_connected_components.py b/test/python/test_connected_components.py index 1c0418308..beb472ad6 100644 --- a/test/python/test_connected_components.py +++ b/test/python/test_connected_components.py @@ -1,4 +1,5 @@ from teca import * +import os import sys set_stack_trace_on_error() @@ -58,9 +59,21 @@ exe.set_start_index(first_step) exe.set_end_index(end_index) -wri = teca_cartesian_mesh_writer.New() -wri.set_input_connection(cc.get_output_port()) -wri.set_executive(exe) -wri.set_file_name(out_file) +if os.path.exists(out_file): + rea = teca_cartesian_mesh_reader.New() + rea.set_file_name(out_file) + + diff = teca_dataset_diff.New() + diff.set_input_connection(0, rea.get_output_port()) + diff.set_input_connection(1, cc.get_output_port()) + diff.set_executive(exe) -wri.update() + diff.update() +else: + sys.stderr.write('generating baseline\n') + wri = teca_cartesian_mesh_writer.New() + wri.set_input_connection(cc.get_output_port()) + wri.set_executive(exe) + wri.set_file_name(out_file) + + wri.update() diff --git a/test/python/test_derived_quantity.py b/test/python/test_derived_quantity.py index 2976a9df9..03222609e 100644 --- a/test/python/test_derived_quantity.py +++ b/test/python/test_derived_quantity.py @@ -1,5 +1,6 @@ from teca import * import numpy as np +import os import sys set_stack_trace_on_error() @@ -50,9 +51,21 @@ def execute(port, data_in, req): exe.set_start_index(first_step) exe.set_end_index(end_index) -wri = teca_cartesian_mesh_writer.New() -wri.set_input_connection(alg.get_output_port()) -wri.set_executive(exe) -wri.set_file_name(out_file) +if os.path.exists(out_file): + rea = teca_cartesian_mesh_reader.New() + rea.set_file_name(out_file) + + diff = teca_dataset_diff.New() + diff.set_input_connection(0, rea.get_output_port()) + diff.set_input_connection(1, alg.get_output_port()) + diff.set_executive(exe) -wri.update() + diff.update() +else: + sys.stderr.write('generating baseline\n') + wri = teca_cartesian_mesh_writer.New() + wri.set_input_connection(alg.get_output_port()) + wri.set_executive(exe) + wri.set_file_name(out_file) + + wri.update() diff --git a/test/python/test_programmable_algorithm.py b/test/python/test_programmable_algorithm.py index dfe61ada7..363c148ed 100644 --- a/test/python/test_programmable_algorithm.py +++ b/test/python/test_programmable_algorithm.py @@ -1,6 +1,7 @@ from teca import * import numpy as np import sys +import os set_stack_trace_on_error() @@ -65,9 +66,21 @@ def execute(port, data_in, req): exe.set_start_index(first_step) exe.set_end_index(end_index) -wri = teca_cartesian_mesh_writer.New() -wri.set_input_connection(alg.get_output_port()) -wri.set_executive(exe) -wri.set_file_name(out_file) +if os.path.exists(out_file): + rea = teca_cartesian_mesh_reader.New() + rea.set_file_name(out_file) + + diff = teca_dataset_diff.New() + diff.set_input_connection(0, rea.get_output_port()) + diff.set_input_connection(1, alg.get_output_port()) + diff.set_executive(exe) -wri.update() + diff.update() +else: + sys.stderr.write('generating baseline\n') + wri = teca_cartesian_mesh_writer.New() + wri.set_input_connection(alg.get_output_port()) + wri.set_file_name(out_file) + wri.set_executive(exe) + + wri.update() \ No newline at end of file diff --git a/test/python/test_vector_ops.py b/test/python/test_vector_ops.py index f293f3d8a..65d88b2b6 100644 --- a/test/python/test_vector_ops.py +++ b/test/python/test_vector_ops.py @@ -1,4 +1,5 @@ from teca import * +import os import sys set_stack_trace_on_error() @@ -46,9 +47,21 @@ exe.set_start_index(first_step) exe.set_end_index(end_index) -wri = teca_cartesian_mesh_writer.New() -wri.set_input_connection(vort.get_output_port()) -wri.set_executive(exe) -wri.set_file_name(out_file) +if os.path.exists(out_file): + rea = teca_cartesian_mesh_reader.New() + rea.set_file_name(out_file) + + diff = teca_dataset_diff.New() + diff.set_input_connection(0, rea.get_output_port()) + diff.set_input_connection(1, vort.get_output_port()) + diff.set_executive(exe) -wri.update() + diff.update() +else: + sys.stderr.write('generating baseline\n') + wri = teca_cartesian_mesh_writer.New() + wri.set_input_connection(vort.get_output_port()) + wri.set_executive(exe) + wri.set_file_name(out_file) + + wri.update() diff --git a/test/test_binary_segmentation.cpp b/test/test_binary_segmentation.cpp index cf5b4d1ca..95fa1cc4f 100644 --- a/test/test_binary_segmentation.cpp +++ b/test/test_binary_segmentation.cpp @@ -3,7 +3,12 @@ #include "teca_binary_segmentation.h" #include "teca_cartesian_mesh_writer.h" #include "teca_file_util.h" +#include "teca_cartesian_mesh_reader.h" +#include "teca_cartesian_mesh_writer.h" +#include "teca_dataset_diff.h" +#include "teca_mpi_manager.h" #include "teca_system_interface.h" +#include "teca_mpi.h" #include #include @@ -12,6 +17,9 @@ using namespace std; int main(int argc, char **argv) { + teca_mpi_manager mpi_man(argc, argv); + int rank = mpi_man.get_comm_rank(); + teca_system_interface::set_stack_trace_on_error(); if (argc != 6) @@ -26,7 +34,7 @@ int main(int argc, char **argv) std::string var = argv[2]; double low = atof(argv[3]); double high = atof(argv[4]); - std::string out_file = argv[5]; + std::string baseline = argv[5]; // build the pipeline p_teca_cf_reader cfr = teca_cf_reader::New(); @@ -39,11 +47,28 @@ int main(int argc, char **argv) seg->set_threshold_by_percentile(); seg->set_input_connection(cfr->get_output_port()); - p_teca_cartesian_mesh_writer wri = teca_cartesian_mesh_writer::New(); - wri->set_input_connection(seg->get_output_port()); - wri->set_file_name(out_file); + // regression test + if (teca_file_util::file_exists(baseline.c_str())) + { + // run the test + p_teca_cartesian_mesh_reader rea = teca_cartesian_mesh_reader::New(); + rea->set_file_name(baseline); - wri->update(); + p_teca_dataset_diff diff = teca_dataset_diff::New(); + diff->set_input_connection(0, rea->get_output_port()); + diff->set_input_connection(1, seg->get_output_port()); + diff->update(); + } + else + { + // make a baseline + if (rank == 0) + cerr << "generating baseline image " << baseline << endl; + p_teca_cartesian_mesh_writer wri = teca_cartesian_mesh_writer::New(); + wri->set_input_connection(seg->get_output_port()); + wri->set_file_name(baseline.c_str()); + wri->update(); + } return 0; } diff --git a/test/test_cf_reader.cpp b/test/test_cf_reader.cpp index 6505ee9ab..bbc4be331 100644 --- a/test/test_cf_reader.cpp +++ b/test/test_cf_reader.cpp @@ -2,7 +2,10 @@ #include "teca_cf_reader.h" #include "teca_normalize_coordinates.h" #include "teca_normalize_coordinates.h" +#include "teca_file_util.h" +#include "teca_cartesian_mesh_reader.h" #include "teca_cartesian_mesh_writer.h" +#include "teca_dataset_diff.h" #include "teca_index_executive.h" #include "teca_mpi_manager.h" #include "teca_system_interface.h" @@ -17,6 +20,7 @@ int parse_command_line( int argc, char **argv, int rank, + string &output, const p_teca_cf_reader &cf_reader, const p_teca_cartesian_mesh_writer &vtk_writer, const p_teca_index_executive exec); @@ -35,26 +39,47 @@ int main(int argc, char **argv) p_teca_cartesian_mesh_writer vtk_writer = teca_cartesian_mesh_writer::New(); p_teca_index_executive exec = teca_index_executive::New(); + string baseline; + // initialize them from command line options - if (parse_command_line(argc, argv, rank, cf_reader, vtk_writer, exec)) + if (parse_command_line(argc, argv, rank, baseline, cf_reader, vtk_writer, exec)) return -1; // build the pipeline p_teca_normalize_coordinates coords = teca_normalize_coordinates::New(); coords->set_input_connection(cf_reader->get_output_port()); - vtk_writer->set_input_connection(coords->get_output_port()); - vtk_writer->set_executive(exec); - // run the pipeline - vtk_writer->update(); + // regression test + if (teca_file_util::file_exists(baseline.c_str())) + { + // run the test + p_teca_cartesian_mesh_reader rea = teca_cartesian_mesh_reader::New(); + rea->set_file_name(baseline); + + p_teca_dataset_diff diff = teca_dataset_diff::New(); + diff->set_input_connection(0, rea->get_output_port()); + diff->set_input_connection(1, coords->get_output_port()); + diff->set_executive(exec); + + diff->update(); + } + else + { + // make a baseline + if (rank == 0) + cerr << "generating baseline image " << baseline << endl; - return 0; + vtk_writer->set_input_connection(coords->get_output_port()); + vtk_writer->set_executive(exec); + vtk_writer->update(); + } } // -------------------------------------------------------------------------- int parse_command_line(int argc, char **argv, int rank, + string &output, const p_teca_cf_reader &cf_reader, const p_teca_cartesian_mesh_writer &vtk_writer, const p_teca_index_executive exec) @@ -74,7 +99,6 @@ int parse_command_line(int argc, char **argv, int rank, } string regex; - string output; string x_ax = "lon"; string y_ax = "lat"; string z_ax = ""; diff --git a/test/test_temporal_average.cpp b/test/test_temporal_average.cpp index a4ee13b0f..b859dfd55 100644 --- a/test/test_temporal_average.cpp +++ b/test/test_temporal_average.cpp @@ -1,9 +1,16 @@ #include "teca_cf_reader.h" #include "teca_normalize_coordinates.h" #include "teca_temporal_average.h" +#include "teca_file_util.h" +#include "teca_cartesian_mesh_reader.h" #include "teca_cartesian_mesh_writer.h" +#include "teca_dataset_diff.h" +//#include "teca_dataset_capture.h" +//#include "teca_dataset_source.h" #include "teca_index_executive.h" +#include "teca_mpi_manager.h" #include "teca_system_interface.h" +#include "teca_mpi.h" #include #include @@ -15,9 +22,12 @@ using namespace std; int main(int argc, char **argv) { + teca_mpi_manager mpi_man(argc, argv); + int rank = mpi_man.get_comm_rank(); + teca_system_interface::set_stack_trace_on_error(); - if (argc < 7) + if (argc < 5) { cerr << endl << "Usage error:" << endl << "test_cf_reader [input regex] [output] [first step] [last step] [filter width] [array] [array] ..." << endl @@ -27,10 +37,12 @@ int main(int argc, char **argv) // parse command line string regex = argv[1]; - string output = argv[2]; + string baseline = argv[2]; + long first_step = atoi(argv[3]); long last_step = atoi(argv[4]); int filter_width = atoi(argv[5]); + vector arrays; arrays.push_back(argv[6]); for (int i = 7; i < argc; ++i) @@ -48,21 +60,37 @@ int main(int argc, char **argv) a->set_filter_type(teca_temporal_average::backward); a->set_input_connection(c->get_output_port()); - // create the vtk writer connected to the cf reader - p_teca_cartesian_mesh_writer w = teca_cartesian_mesh_writer::New(); - w->set_file_name(output); - w->set_input_connection(a->get_output_port()); - // set the executive on the writer to stream time steps p_teca_index_executive exec = teca_index_executive::New(); exec->set_start_index(first_step); exec->set_end_index(last_step); exec->set_arrays(arrays); - w->set_executive(exec); + // regression test + if (teca_file_util::file_exists(baseline.c_str())) + { + // run the test + p_teca_cartesian_mesh_reader rea = teca_cartesian_mesh_reader::New(); + rea->set_file_name(baseline); + + p_teca_dataset_diff diff = teca_dataset_diff::New(); + diff->set_input_connection(0, rea->get_output_port()); + diff->set_input_connection(1, a->get_output_port()); + diff->set_executive(exec); + diff->update(); + } + else + { + // make a baseline + if (rank == 0) + cerr << "generating baseline image " << baseline << endl; - // run the pipeline - w->update(); + p_teca_cartesian_mesh_writer wri = teca_cartesian_mesh_writer::New(); + wri->set_input_connection(a->get_output_port()); + wri->set_file_name(baseline.c_str()); + wri->set_executive(exec); + wri->update(); + } return 0; }