From 31f0e88a4591b39a90267f99587f2f426b2d60e9 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 31 Mar 2014 13:57:06 +0100 Subject: [PATCH] CMake tests --- CMakeLists.txt | 21 ++- data/CMakeLists.txt | 158 +++++++++++++++++++ data/bitmap.diff | 2 +- data/no_bitmap.diff | 2 +- data/tigge/CMakeLists.txt | 263 +++++++++++++++++++++++++++++++ examples/C/CMakeLists.txt | 130 ++++++++++++++- examples/C/include.ctest.sh.in | 16 ++ examples/C/include.sh | 63 ++++---- examples/C/sections_copy.sh | 4 +- examples/CMakeLists.txt | 2 + examples/F90/CMakeLists.txt | 89 +++++++++++ examples/F90/Makefile.am | 56 +++---- examples/F90/clone.sh | 2 +- examples/F90/copy_message.sh | 2 +- examples/F90/count_messages.sh | 2 +- examples/F90/get.sh | 2 +- examples/F90/get_data.sh | 2 +- examples/F90/get_pl.sh | 2 +- examples/F90/get_pv.sh | 2 +- examples/F90/get_set_uuid.sh | 2 +- examples/F90/include.ctest.sh.in | 16 ++ examples/F90/include.sh | 72 +++++---- examples/F90/index.sh | 4 +- examples/F90/keys_iterator.sh | 2 +- examples/F90/multi.sh | 2 +- examples/F90/multi_write.sh | 2 +- examples/F90/nearest.sh | 2 +- examples/F90/precision.sh | 2 +- examples/F90/print_data.sh | 2 +- examples/F90/read_from_file.sh | 2 +- examples/F90/read_message.sh | 2 +- examples/F90/samples.sh | 4 +- examples/F90/set.sh | 4 +- examples/F90/set_bitmap.sh | 2 +- examples/F90/set_missing.sh | 2 +- examples/F90/set_pv.sh | 2 +- fortran/CMakeLists.txt | 4 +- src/CMakeLists.txt | 18 ++- tests/CMakeLists.txt | 232 +++++++++++++++++++++++++++ tests/include.ctest.sh.in | 19 +++ tests/include.sh | 75 ++++----- tests/tigge.sh | 20 +-- tests/tigge_conversions.sh | 2 +- tigge/CMakeLists.txt | 25 +++ tigge/tigge_accumulations.c | 9 ++ tigge/tigge_check.c | 8 + tigge/tigge_name.c | 8 + tigge/tigge_split.c | 8 + tools/CMakeLists.txt | 1 - 49 files changed, 1182 insertions(+), 191 deletions(-) create mode 100644 data/CMakeLists.txt create mode 100644 data/tigge/CMakeLists.txt create mode 100644 examples/C/include.ctest.sh.in create mode 100644 examples/F90/CMakeLists.txt create mode 100644 examples/F90/include.ctest.sh.in mode change 100644 => 100755 examples/F90/read_from_file.sh create mode 100644 tests/include.ctest.sh.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 3414c5b84..36fd19bbf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,10 @@ option( ENABLE_SZIP "try to add support for SZip encoding" ON ) option( ENABLE_PYTHON "try to build the GRIB_API Python interface" ON ) option( ENABLE_FORTRAN "try to build the GRIB_API Fortran interface" ON ) +if( ENABLE_FORTRAN ) + ecbuild_enable_fortran( REQUIRED MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/fortran/modules ) +endif() + option( ENABLE_MEMORY_MANAGEMENT "enable memory management" OFF ) option( ENABLE_ALIGN_MEMORY "enable memory alignment" OFF ) @@ -192,7 +196,7 @@ endif() ############################################################################################ # contents -### define dependencies +### export package to other ecbuild packages set( GRIB_API_TPLS SZip PNG NetCDF Jasper OpenJPEG CMath ) set( GRIB_API_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/src ) @@ -201,15 +205,17 @@ set( GRIB_API_LIBRARIES grib_api ) get_directory_property( COMPILE_DEFINITIONS GRIB_API_DEFINITIONS ) foreach( _tpl ${GRIB_API_TPLS} ) - string( TOUPPER ${_tpl} TPL ) - list( APPEND GRIB_API_EXTRA_DEFINITIONS ${${TPL}_DEFINITIONS} ) - list( APPEND GRIB_API_EXTRA_INCLUDE_DIRS ${${TPL}_INCLUDE_DIRS} ) - list( APPEND GRIB_API_EXTRA_LIBRARIES ${${TPL}_LIBRARIES} ) + string( TOUPPER ${_tpl} TPL ) + if( ${TPL}_FOUND ) + list( APPEND GRIB_API_EXTRA_DEFINITIONS ${${TPL}_DEFINITIONS} ) + list( APPEND GRIB_API_EXTRA_INCLUDE_DIRS ${${TPL}_INCLUDE_DIRS} ) + list( APPEND GRIB_API_EXTRA_LIBRARIES ${${TPL}_LIBRARIES} ) + endif() endforeach() ### include directories -include_directories( ${GRIB_API_INCLUDE_DIRS} ) +include_directories( ${GRIB_API_INCLUDE_DIRS} ${GRIB_API_EXTRA_INCLUDE_DIRS} ) add_subdirectory( src ) add_subdirectory( tools ) @@ -219,6 +225,7 @@ add_subdirectory( definitions ) add_subdirectory( tests ) add_subdirectory( tigge ) add_subdirectory( examples ) +add_subdirectory( data ) add_subdirectory( samples ) add_subdirectory( ifs_samples ) # must come after samples @@ -241,6 +248,6 @@ endif() ############################################################################################ # finalize -ecbuild_install_project( NAME grib_api ) +ecbuild_install_project( NAME ${CMAKE_PROJECT_NAME} ) ecbuild_print_summary() diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt new file mode 100644 index 000000000..7aadea636 --- /dev/null +++ b/data/CMakeLists.txt @@ -0,0 +1,158 @@ +# data/CMakeLists.txt +add_subdirectory(tigge) + + + +# Download all the binary grib data from website +# +set(files_to_download + bad.grib + budg + constant_field.grib1 + constant_width_bitmap.grib + constant_width_boust_bitmap.grib + gen.grib + gen_bitmap.grib + gen_ext_bitmap.grib + gen_ext_boust_bitmap.grib + gen_ext_boust.grib + gen_ext.grib + gen_ext_spd_2_bitmap.grib + gen_ext_spd_2_boust_bitmap.grib + gen_ext_spd_2.grib + gen_ext_spd_3_boust_bitmap.grib + gen_ext_spd_3.grib + gep10.t12z.pgrb2af78.grib2 + gfs.c255.grib2 + gts.grib + index.grib + jpeg.grib2 + lfpw.grib1 + lfpw.grib2 + missing_field.grib1 + missing.grib2 + mixed.grib + multi_created.grib2 + multi.grib2 + pad.grib + reduced_gaussian_lsm.grib1 + reduced_gaussian_model_level.grib1 + reduced_gaussian_model_level.grib2 + reduced_gaussian_pressure_level_constant.grib1 + reduced_gaussian_pressure_level_constant.grib2 + reduced_gaussian_pressure_level.grib1 + reduced_gaussian_pressure_level.grib2 + reduced_gaussian_sub_area.grib1 + reduced_gaussian_sub_area.grib2 + reduced_gaussian_surface.grib1 + reduced_gaussian_surface.grib2 + reduced_gaussian_surface_jpeg.grib2 + reduced_latlon_surface_constant.grib1 + reduced_latlon_surface_constant.grib2 + reduced_latlon_surface.grib1 + reduced_latlon_surface.grib2 + reference_ensemble_mean.grib1 + reference_stdev.grib1 + regular_gaussian_model_level.grib1 + regular_gaussian_model_level.grib2 + regular_gaussian_pressure_level_constant.grib1 + regular_gaussian_pressure_level_constant.grib2 + regular_gaussian_pressure_level.grib1 + regular_gaussian_pressure_level.grib2 + regular_gaussian_surface.grib1 + regular_gaussian_surface.grib2 + regular_latlon_surface_constant.grib1 + regular_latlon_surface_constant.grib2 + regular_latlon_surface.grib1 + regular_latlon_surface.grib2 + row.grib + sample.grib2 + satellite.grib + second_ord_rbr.grib1 + simple_bitmap.grib + simple.grib + small_ensemble.grib1 + spectral_compex.grib1 + spectral_complex.grib1 + spherical_model_level.grib1 + spherical_pressure_level.grib1 + sst_globus0083.grib + test.grib1 + test_uuid.grib2 + tigge + tigge_af_ecmwf.grib2 + tigge_cf_ecmwf.grib2 + tigge_ecmwf.grib2 + tigge_pf_ecmwf.grib2 + timeRangeIndicator_0.grib + timeRangeIndicator_10.grib + timeRangeIndicator_5.grib + tp_ecmwf.grib + v.grib2 +) + +foreach (f ${files_to_download}) + set(tgt data_${f}) + # Download the file and create a dummy target for it + ecbuild_get_test_data(TARGET "${tgt}" NAME "${f}" DIRNAME ${PROJECT_NAME}/data NOCHECK) + + # Add to list of targets + LIST(APPEND tgts "${tgt}") +endforeach() + +# Copy other files - e.g. reference data, text files etc from the source data dir +LIST(APPEND other_files + 60_model_levels + bitmap.diff + filter_rules + ieee_test.good + index.ok + index_f90.ok + julian.out.good + list_points + local.good.log + ls.log + mf.rules + multi.ok + multi_level.txt + multi_step.txt + no_bitmap.diff + perf.ksh + read_any.ok + ret.sh + sample_grib.txt + scan_x_regular_gg_5_7_good.dump + scan_x_regular_ll_5_4_good.dump + scan_x_regular_ll_5_7_good.dump + scan_x_regular_ll_8_4_good.dump + scan_x_regular_ll_8_7_good.dump + scan_x_rotated_ll_5_4_good.dump + scan_x_rotated_ll_5_7_good.dump + scan_x_rotated_ll_8_4_good.dump + scan_x_rotated_ll_8_7_good.dump + scan_y_regular_ll_5_4_good.dump + scan_y_regular_ll_5_7_good.dump + scan_y_regular_ll_8_4_good.dump + scan_y_regular_ll_8_7_good.dump + scan_y_rotated_ll_5_4_good.dump + scan_y_rotated_ll_5_7_good.dump + scan_y_rotated_ll_8_4_good.dump + scan_y_rotated_ll_8_7_good.dump + spherical_model_level.grib1.good + spherical_model_level.grib1_32.good + statistics.out.good + step.log + step_grib1.filter + step_grib1.log + typeOfProcessedData.ok +) + +foreach( file ${other_files} ) + execute_process( COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/${file} ${CMAKE_CURRENT_BINARY_DIR} ) +endforeach() + +# debug_var(tgts) +# Another dummy target which depends on all previous targets +#add_custom_target( getdata ALL DEPENDS ${tgts} ) +add_custom_target( getdata DEPENDS ${tgts} ) +add_dependencies( check getdata ) diff --git a/data/bitmap.diff b/data/bitmap.diff index 5e892f241..6084db332 100644 --- a/data/bitmap.diff +++ b/data/bitmap.diff @@ -10,7 +10,7 @@ 7 gridDefinition = 255 8 section1Flags = 192 [11000000] 9 indicatorOfParameter = 130 [Temperature (K) (grib1/2.98.128.table) ] -10 indicatorOfTypeOfLevel = 109 [Hybrid level level number (2 octets) (grib1/3.table) ] +10 indicatorOfTypeOfLevel = 109 [Hybrid level level number (2 octets) (grib1/3.table , grib1/local/ecmf/3.table) ] 11-12 level = 1 13 yearOfCentury = 8 14 month = 2 diff --git a/data/no_bitmap.diff b/data/no_bitmap.diff index 0f708bead..c410f4471 100644 --- a/data/no_bitmap.diff +++ b/data/no_bitmap.diff @@ -10,7 +10,7 @@ 7 gridDefinition = 255 8 section1Flags = 128 [10000000] 9 indicatorOfParameter = 130 [Temperature (K) (grib1/2.98.128.table) ] -10 indicatorOfTypeOfLevel = 109 [Hybrid level level number (2 octets) (grib1/3.table) ] +10 indicatorOfTypeOfLevel = 109 [Hybrid level level number (2 octets) (grib1/3.table , grib1/local/ecmf/3.table) ] 11-12 level = 1 13 yearOfCentury = 8 14 month = 2 diff --git a/data/tigge/CMakeLists.txt b/data/tigge/CMakeLists.txt new file mode 100644 index 000000000..eee54c218 --- /dev/null +++ b/data/tigge/CMakeLists.txt @@ -0,0 +1,263 @@ +# Download all the TIGGE grib data from website +# +set(tigge_files_to_download + tigge_ammc_pl_gh.grib + tigge_ammc_pl_q.grib + tigge_ammc_pl_t.grib + tigge_ammc_pl_u.grib + tigge_ammc_pl_v.grib + tigge_ammc_sfc_10u.grib + tigge_ammc_sfc_10v.grib + tigge_ammc_sfc_2t.grib + tigge_ammc_sfc_lsm.grib + tigge_ammc_sfc_mn2t6.grib + tigge_ammc_sfc_msl.grib + tigge_ammc_sfc_mx2t6.grib + tigge_ammc_sfc_orog.grib + tigge_ammc_sfc_sf.grib + tigge_ammc_sfc_sp.grib + tigge_ammc_sfc_st.grib + tigge_ammc_sfc_tcc.grib + tigge_ammc_sfc_tcw.grib + tigge_ammc_sfc_tp.grib + tigge_babj_pl_gh.grib + tigge_babj_pl_q.grib + tigge_babj_pl_t.grib + tigge_babj_pl_u.grib + tigge_babj_pl_v.grib + tigge_babj_sfc_10u.grib + tigge_babj_sfc_10v.grib + tigge_babj_sfc_2d.grib + tigge_babj_sfc_2t.grib + tigge_babj_sfc_lsm.grib + tigge_babj_sfc_mn2t6.grib + tigge_babj_sfc_msl.grib + tigge_babj_sfc_mx2t6.grib + tigge_babj_sfc_orog.grib + tigge_babj_sfc_sd.grib + tigge_babj_sfc_sf.grib + tigge_babj_sfc_slhf.grib + tigge_babj_sfc_sp.grib + tigge_babj_sfc_sshf.grib + tigge_babj_sfc_ssr.grib + tigge_babj_sfc_str.grib + tigge_babj_sfc_tcc.grib + tigge_babj_sfc_tcw.grib + tigge_babj_sfc_tp.grib + tigge_cwao_pl_gh.grib + tigge_cwao_pl_q.grib + tigge_cwao_pl_t.grib + tigge_cwao_pl_u.grib + tigge_cwao_pl_v.grib + tigge_cwao_sfc_10u.grib + tigge_cwao_sfc_10v.grib + tigge_cwao_sfc_2d.grib + tigge_cwao_sfc_2t.grib + tigge_cwao_sfc_mn2t6.grib + tigge_cwao_sfc_msl.grib + tigge_cwao_sfc_mx2t6.grib + tigge_cwao_sfc_orog.grib + tigge_cwao_sfc_sd.grib + tigge_cwao_sfc_skt.grib + tigge_cwao_sfc_sp.grib + tigge_cwao_sfc_st.grib + tigge_cwao_sfc_tcc.grib + tigge_cwao_sfc_tcw.grib + tigge_cwao_sfc_tp.grib + tigge_ecmf_pl_gh.grib + tigge_ecmf_pl_q.grib + tigge_ecmf_pl_t.grib + tigge_ecmf_pl_u.grib + tigge_ecmf_pl_v.grib + tigge_ecmf_pt_pv.grib + tigge_ecmf_pv_pt.grib + tigge_ecmf_pv_u.grib + tigge_ecmf_pv_v.grib + tigge_ecmf_sfc_10u.grib + tigge_ecmf_sfc_10v.grib + tigge_ecmf_sfc_2d.grib + tigge_ecmf_sfc_2t.grib + tigge_ecmf_sfc_cap.grib + tigge_ecmf_sfc_cape.grib + tigge_ecmf_sfc_mn2t6.grib + tigge_ecmf_sfc_msl.grib + tigge_ecmf_sfc_mx2t6.grib + tigge_ecmf_sfc_sd.grib + tigge_ecmf_sfc_sf.grib + tigge_ecmf_sfc_skt.grib + tigge_ecmf_sfc_slhf.grib + tigge_ecmf_sfc_sm.grib + tigge_ecmf_sfc_sp.grib + tigge_ecmf_sfc_sshf.grib + tigge_ecmf_sfc_ssr.grib + tigge_ecmf_sfc_st.grib + tigge_ecmf_sfc_str.grib + tigge_ecmf_sfc_sund.grib + tigge_ecmf_sfc_tcc.grib + tigge_ecmf_sfc_tcw.grib + tigge_ecmf_sfc_tp.grib + tigge_ecmf_sfc_ttr.grib + tigge_egrr_pl_gh.grib + tigge_egrr_pl_q.grib + tigge_egrr_pl_t.grib + tigge_egrr_pl_u.grib + tigge_egrr_pl_v.grib + tigge_egrr_pt_pv.grib + tigge_egrr_pv_pt.grib + tigge_egrr_pv_u.grib + tigge_egrr_pv_v.grib + tigge_egrr_sfc_10u.grib + tigge_egrr_sfc_10v.grib + tigge_egrr_sfc_2d.grib + tigge_egrr_sfc_2t.grib + tigge_egrr_sfc_mn2t6.grib + tigge_egrr_sfc_msl.grib + tigge_egrr_sfc_mx2t6.grib + tigge_egrr_sfc_sd.grib + tigge_egrr_sfc_sf.grib + tigge_egrr_sfc_skt.grib + tigge_egrr_sfc_slhf.grib + tigge_egrr_sfc_sm.grib + tigge_egrr_sfc_sp.grib + tigge_egrr_sfc_sshf.grib + tigge_egrr_sfc_ssr.grib + tigge_egrr_sfc_st.grib + tigge_egrr_sfc_str.grib + tigge_egrr_sfc_tcc.grib + tigge_egrr_sfc_tcw.grib + tigge_egrr_sfc_tp.grib + tigge_egrr_sfc_ttr.grib + tigge_kwbc_pl_gh.grib + tigge_kwbc_pl_q.grib + tigge_kwbc_pl_t.grib + tigge_kwbc_pl_u.grib + tigge_kwbc_pl_v.grib + tigge_kwbc_pt_pv.grib + tigge_kwbc_pv_pt.grib + tigge_kwbc_pv_u.grib + tigge_kwbc_pv_v.grib + tigge_kwbc_sfc_10u.grib + tigge_kwbc_sfc_10v.grib + tigge_kwbc_sfc_2d.grib + tigge_kwbc_sfc_2t.grib + tigge_kwbc_sfc_cap.grib + tigge_kwbc_sfc_cape.grib + tigge_kwbc_sfc_ci.grib + tigge_kwbc_sfc_lsm.grib + tigge_kwbc_sfc_mn2t6.grib + tigge_kwbc_sfc_msl.grib + tigge_kwbc_sfc_mx2t6.grib + tigge_kwbc_sfc_sd.grib + tigge_kwbc_sfc_sf.grib + tigge_kwbc_sfc_skt.grib + tigge_kwbc_sfc_slhf.grib + tigge_kwbc_sfc_sm.grib + tigge_kwbc_sfc_sp.grib + tigge_kwbc_sfc_sshf.grib + tigge_kwbc_sfc_ssr.grib + tigge_kwbc_sfc_st.grib + tigge_kwbc_sfc_str.grib + tigge_kwbc_sfc_tcw.grib + tigge_kwbc_sfc_tp.grib + tigge_kwbc_sfc_ttr.grib + tigge_lfpw_pl_gh.grib + tigge_lfpw_pl_q.grib + tigge_lfpw_pl_t.grib + tigge_lfpw_pl_u.grib + tigge_lfpw_pl_v.grib + tigge_lfpw_pv_pt.grib + tigge_lfpw_pv_u.grib + tigge_lfpw_pv_v.grib + tigge_lfpw_sfc_10u.grib + tigge_lfpw_sfc_10v.grib + tigge_lfpw_sfc_2d.grib + tigge_lfpw_sfc_2t.grib + tigge_lfpw_sfc_cap.grib + tigge_lfpw_sfc_cape.grib + tigge_lfpw_sfc_mn2t6.grib + tigge_lfpw_sfc_msl.grib + tigge_lfpw_sfc_mx2t6.grib + tigge_lfpw_sfc_sd.grib + tigge_lfpw_sfc_sf.grib + tigge_lfpw_sfc_skt.grib + tigge_lfpw_sfc_slhf.grib + tigge_lfpw_sfc_sp.grib + tigge_lfpw_sfc_sshf.grib + tigge_lfpw_sfc_ssr.grib + tigge_lfpw_sfc_st.grib + tigge_lfpw_sfc_str.grib + tigge_lfpw_sfc_tcc.grib + tigge_lfpw_sfc_tcw.grib + tigge_lfpw_sfc_tp.grib + tigge_lfpw_sfc_ttr.grib + tigge_rjtd_pl_gh.grib + tigge_rjtd_pl_q.grib + tigge_rjtd_pl_t.grib + tigge_rjtd_pl_u.grib + tigge_rjtd_pl_v.grib + tigge_rjtd_sfc_10u.grib + tigge_rjtd_sfc_10v.grib + tigge_rjtd_sfc_2d.grib + tigge_rjtd_sfc_2t.grib + tigge_rjtd_sfc_mn2t6.grib + tigge_rjtd_sfc_msl.grib + tigge_rjtd_sfc_mx2t6.grib + tigge_rjtd_sfc_sd.grib + tigge_rjtd_sfc_skt.grib + tigge_rjtd_sfc_slhf.grib + tigge_rjtd_sfc_sm.grib + tigge_rjtd_sfc_sp.grib + tigge_rjtd_sfc_sshf.grib + tigge_rjtd_sfc_ssr.grib + tigge_rjtd_sfc_str.grib + tigge_rjtd_sfc_tcc.grib + tigge_rjtd_sfc_tcw.grib + tigge_rjtd_sfc_tp.grib + tigge_rjtd_sfc_ttr.grib + tigge_rksl_pl_gh.grib + tigge_rksl_pl_q.grib + tigge_rksl_pl_t.grib + tigge_rksl_pl_u.grib + tigge_rksl_pl_v.grib + tigge_rksl_sfc_10u.grib + tigge_rksl_sfc_10v.grib + tigge_rksl_sfc_2t.grib + tigge_rksl_sfc_msl.grib + tigge_rksl_sfc_sp.grib + tigge_sbsj_pl_gh.grib + tigge_sbsj_pl_q.grib + tigge_sbsj_pl_t.grib + tigge_sbsj_pl_u.grib + tigge_sbsj_pl_v.grib + tigge_sbsj_sfc_10u.grib + tigge_sbsj_sfc_10v.grib + tigge_sbsj_sfc_2t.grib + tigge_sbsj_sfc_msl.grib + tigge_sbsj_sfc_sf.grib + tigge_sbsj_sfc_skt.grib + tigge_sbsj_sfc_sp.grib + tigge_sbsj_sfc_ssr.grib + tigge_sbsj_sfc_st.grib + tigge_sbsj_sfc_tcc.grib + tigge_sbsj_sfc_tcw.grib + tigge_sbsj_sfc_tp.grib + tiggelam_cnmc_sfc.grib +) + +foreach (f ${tigge_files_to_download}) + set(tgt tigge_data_${f}) + # Download the file and create a dummy target for it + ecbuild_get_test_data(TARGET "${tgt}" + NAME "${f}" + DIRNAME ${PROJECT_NAME}/data/tigge + NOCHECK) + + # Add to list of targets + LIST(APPEND tgts "${tgt}") +endforeach() + +# debug_var(tgts) +# Anotehr dummy target which depends on all previous targets +add_custom_target( get_tigge_data DEPENDS ${tgts} ) +add_dependencies( check get_tigge_data ) + diff --git a/examples/C/CMakeLists.txt b/examples/C/CMakeLists.txt index f9591c58f..63b0adf45 100644 --- a/examples/C/CMakeLists.txt +++ b/examples/C/CMakeLists.txt @@ -1,11 +1,127 @@ -ecbuild_add_test( TARGET new_sample +# examples/C/CMakeLists.txt + +# Configure the file which all CMake tests will include +configure_file( include.ctest.sh.in include.ctest.sh @ONLY ) + + +# Build the executables used by test scripts +################################################ +list( APPEND test_bins + nearest + set_bitmap + iterator + get + print_data + set + set_missing + keys_iterator + set_data + mars_param + values_check + box + multi + multi2 + multi_write + precision + set_pv + list + get_data + sections_copy + iterator_bitmap + large_grib1 + clone +) +foreach( tool ${test_bins} ) + # here we use the fact that each tool has only one C file that matches its name + ecbuild_add_executable( TARGET ${tool} + NOINSTALL + SOURCES ${tool}.c + LIBS grib_api + ) +endforeach() + +# Now add each test +################################################# +ecbuild_add_test( TARGET c_iterator + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/iterator.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET c_get + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/get.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET c_print_data + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/print_data.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET c_set + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/set.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET c_keys_iterator + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/keys_iterator.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET c_multi + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/multi.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET c_multi_write + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/multi_write.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET c_precision + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/precision.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET c_list + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/list.sh + RESOURCES include.sh +) + +ecbuild_add_test( TARGET c_large_grib1 + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/large_grib1.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET c_get_data + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/get_data.sh + RESOURCES include.sh +) + +ecbuild_add_test( TARGET c_set_missing + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/set_missing.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET c_clone + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/clone.sh + RESOURCES include.sh +) + +ecbuild_add_test( TARGET c_sections_copy + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/sections_copy.sh + RESOURCES include.sh +) + + +############################################# +# Tests with no script +ecbuild_add_test( TARGET c_new_sample SOURCES new_sample.c - LIBS grib_api + LIBS grib_api ARGS "out.grib" ENVIRONMENT "GRIB_SAMPLES_PATH=${PROJECT_SOURCE_DIR}/samples" "GRIB_DEFINITION_PATH=${PROJECT_SOURCE_DIR}/definitions" ) -#ecbuild_add_test( TARGET iterator -# SOURCES iterator.c -# LIBS grib_api -# ARGS "out.grib" -# ENVIRONMENT "GRIB_SAMPLES_PATH=${PROJECT_SOURCE_DIR}/samples" "GRIB_DEFINITION_PATH=${PROJECT_SOURCE_DIR}/definitions" ) diff --git a/examples/C/include.ctest.sh.in b/examples/C/include.ctest.sh.in new file mode 100644 index 000000000..93cb78c35 --- /dev/null +++ b/examples/C/include.ctest.sh.in @@ -0,0 +1,16 @@ +# examples/C include file for CMake + +set -ea +proj_dir=@PROJECT_SOURCE_DIR@ +data_dir=@PROJECT_BINARY_DIR@/data + +def_dir="${proj_dir}/definitions" +GRIB_DEFINITION_PATH="${def_dir}" +export GRIB_DEFINITION_PATH + +tools_dir=@CMAKE_BINARY_DIR@/bin/ +examples_dir=@CMAKE_CURRENT_BINARY_DIR@/ + +samp_dir="${proj_dir}/samples" +GRIB_SAMPLES_PATH=${samp_dir} +export GRIB_SAMPLES_PATH diff --git a/examples/C/include.sh b/examples/C/include.sh index 0573319f4..f1a4c5179 100644 --- a/examples/C/include.sh +++ b/examples/C/include.sh @@ -7,38 +7,43 @@ set -ea # In applying this licence, ECMWF does not waive the privileges and immunities granted to it by # virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. -echo -echo "TEST: $0" +CMAKE_INCLUDE_FILE=include.ctest.sh +if [ -f "$CMAKE_INCLUDE_FILE" ]; then + # This is the config file for Cmake tests + . ./$CMAKE_INCLUDE_FILE -if [ -z "${data_dir}" ] -then - cd ../../ - cpath=`pwd` - GRIB_DEFINITION_PATH=$cpath/definitions - export GRIB_DEFINITION_PATH - GRIB_SAMPLES_PATH=$cpath/samples - export GRIB_SAMPLES_PATH - tools_dir=$cpath/tools/ - examples_dir=$cpath/examples/C/ - data_dir=$cpath/data else - echo "Skipping test $0" - exit -fi + # This is for autotools + echo + echo "TEST: $0" -cd ${examples_dir} + if [ -z "${data_dir}" ] + then + cd ../../ + cpath=`pwd` + GRIB_DEFINITION_PATH=$cpath/definitions + export GRIB_DEFINITION_PATH + GRIB_SAMPLES_PATH=$cpath/samples + export GRIB_SAMPLES_PATH + tools_dir=$cpath/tools/ + examples_dir=$cpath/examples/C/ + data_dir=$cpath/data + else + echo "Skipping test $0" + exit + fi -if [ -z "${GRIB_API_INCLUDE}" ] -then - GRIB_API_INCLUDE=`pwd`/src -fi + cd ${examples_dir} -if [ -z "${GRIB_API_LIB}" ] -then - GRIB_API_LIB=`pwd`/src -fi - -#${tools_dir}grib_info - -set -u + if [ -z "${GRIB_API_INCLUDE}" ] + then + GRIB_API_INCLUDE=`pwd`/src + fi + if [ -z "${GRIB_API_LIB}" ] + then + GRIB_API_LIB=`pwd`/src + fi + #${tools_dir}grib_info + set -u +fi \ No newline at end of file diff --git a/examples/C/sections_copy.sh b/examples/C/sections_copy.sh index eee32939f..e2efcdc73 100755 --- a/examples/C/sections_copy.sh +++ b/examples/C/sections_copy.sh @@ -9,8 +9,8 @@ . ./include.sh -REGUL_GRID_FILE=../../samples/regular_ll_sfc_grib2.tmpl -GAUSS_GRID_FILE=../../samples/reduced_gg_pl_640_grib2.tmpl +REGUL_GRID_FILE=${proj_dir}/samples/regular_ll_sfc_grib2.tmpl +GAUSS_GRID_FILE=${proj_dir}/samples/reduced_gg_pl_640_grib2.tmpl OUTPUT=temp.sections.grib ${examples_dir}sections_copy $REGUL_GRID_FILE $GAUSS_GRID_FILE $OUTPUT diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 5446ca349..49531ef5a 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1 +1,3 @@ add_subdirectory(C) +add_subdirectory(F90) + diff --git a/examples/F90/CMakeLists.txt b/examples/F90/CMakeLists.txt new file mode 100644 index 000000000..3f4cc1336 --- /dev/null +++ b/examples/F90/CMakeLists.txt @@ -0,0 +1,89 @@ +# examples/F90/CMakeLists.txt + +# Configure the file which all CMake tests will include +configure_file( include.ctest.sh.in include.ctest.sh @ONLY ) + + +# Build the executables used by test scripts +################################################ +list( APPEND tests + index + copy_message + get + get_data + get_pl + get_pv + keys_iterator + multi_write + multi + nearest + precision + print_data + set + set_bitmap + set_missing + set_pv + samples + count_messages + read_message + read_from_file + get_set_uuid +) + +# Simplify tests: no need to build executable and then test. All in one +# TODO +# ecbuild_add_test( TARGET test_f90_samples +# LINKER_LANGUAGE Fortran +# SOURCES samples.f90 +# LIBS grib_api_f90 grib_api +# COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/samples.sh +# CONDITION ENABLE_FORTRAN +# ) + +foreach( tool ${tests} ) + # Build the Fortran executable + ecbuild_add_executable( TARGET f_${tool} + NOINSTALL + SOURCES ${tool}.f90 + LINKER_LANGUAGE Fortran + LIBS grib_api_f90 grib_api + ) + # Add the test which depends on the above executable + ecbuild_add_test( TARGET f_${tool}_test + TYPE SCRIPT + DEPENDS f_${tool} + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${tool}.sh + RESOURCES include.sh + ) +endforeach() + +# Executables without a shell script +# TODO +ecbuild_add_executable( TARGET f_new_from_file + NOINSTALL + SOURCES new_from_file.f90 + LINKER_LANGUAGE Fortran + LIBS grib_api_f90 grib_api +) +ecbuild_add_executable( TARGET f_copy_namespace + NOINSTALL + SOURCES copy_namespace.f90 + LINKER_LANGUAGE Fortran + LIBS grib_api_f90 grib_api +) +ecbuild_add_executable( TARGET f_set_gvc + NOINSTALL + SOURCES set_gvc.f90 + LINKER_LANGUAGE Fortran + LIBS grib_api_f90 grib_api +) + + +# # Note extra dependency +# ecbuild_add_test( TARGET f_set_test +# TYPE SCRIPT +# DEPENDS set_gvc set +# COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/set.sh +# RESOURCES include.sh +# ) +# diff --git a/examples/F90/Makefile.am b/examples/F90/Makefile.am index b4051cd21..09e732f7b 100644 --- a/examples/F90/Makefile.am +++ b/examples/F90/Makefile.am @@ -5,35 +5,35 @@ TESTS = copy_message.sh get.sh get_data.sh get_pl.sh get_pv.sh keys_iterator.sh nearest.sh precision.sh multi_write.sh multi.sh print_data.sh set.sh set_bitmap.sh set_missing.sh \ set_pv.sh samples.sh count_messages.sh read_message.sh read_from_file.sh index.sh get_set_uuid.sh -noinst_PROGRAMS = index copy_message get get_data get_pl get_pv keys_iterator \ - multi_write multi nearest precision print_data set set_bitmap set_missing \ - set_pv samples count_messages read_message read_from_file new_from_file \ - copy_namespace get_set_uuid set_gvc +noinst_PROGRAMS = f_index f_copy_message f_get f_get_data f_get_pl f_get_pv f_keys_iterator \ + f_multi_write f_multi f_nearest f_precision f_print_data f_set f_set_bitmap f_set_missing \ + f_set_pv f_samples f_count_messages f_read_message f_read_from_file f_new_from_file \ + f_copy_namespace f_get_set_uuid f_set_gvc -index_SOURCES=index.f90 -copy_message_SOURCES=copy_message.f90 -get_SOURCES=get.f90 -get_data_SOURCES=get_data.f90 -get_pl_SOURCES=get_pl.f90 -get_pv_SOURCES=get_pv.f90 -keys_iterator_SOURCES=keys_iterator.f90 -multi_write_SOURCES=multi_write.f90 -multi_SOURCES=multi.f90 -nearest_SOURCES=nearest.f90 -precision_SOURCES=precision.f90 -print_data_SOURCES=print_data.f90 -set_SOURCES=set.f90 -set_bitmap_SOURCES=set_bitmap.f90 -set_missing_SOURCES=set_missing.f90 -set_pv_SOURCES=set_pv.f90 -samples_SOURCES=samples.f90 -count_messages_SOURCES=count_messages.f90 -read_message_SOURCES=read_message.f90 -read_from_file_SOURCES=read_from_file.f90 -new_from_file_SOURCES=new_from_file.f90 -copy_namespace_SOURCES=copy_namespace.f90 -get_set_uuid_SOURCES=get_set_uuid.f90 -set_gvc_SOURCES=set_gvc.f90 +f_index_SOURCES=index.f90 +f_copy_message_SOURCES=copy_message.f90 +f_get_SOURCES=get.f90 +f_get_data_SOURCES=get_data.f90 +f_get_pl_SOURCES=get_pl.f90 +f_get_pv_SOURCES=get_pv.f90 +f_keys_iterator_SOURCES=keys_iterator.f90 +f_multi_write_SOURCES=multi_write.f90 +f_multi_SOURCES=multi.f90 +f_nearest_SOURCES=nearest.f90 +f_precision_SOURCES=precision.f90 +f_print_data_SOURCES=print_data.f90 +f_set_SOURCES=set.f90 +f_set_bitmap_SOURCES=set_bitmap.f90 +f_set_missing_SOURCES=set_missing.f90 +f_set_pv_SOURCES=set_pv.f90 +f_samples_SOURCES=samples.f90 +f_count_messages_SOURCES=count_messages.f90 +f_read_message_SOURCES=read_message.f90 +f_read_from_file_SOURCES=read_from_file.f90 +f_new_from_file_SOURCES=new_from_file.f90 +f_copy_namespace_SOURCES=copy_namespace.f90 +f_get_set_uuid_SOURCES=get_set_uuid.f90 +f_set_gvc_SOURCES=set_gvc.f90 INCLUDES = -I$(top_builddir)/src diff --git a/examples/F90/clone.sh b/examples/F90/clone.sh index 6e79a9137..73f5d0e8e 100755 --- a/examples/F90/clone.sh +++ b/examples/F90/clone.sh @@ -9,4 +9,4 @@ . ./include.sh -${examples_dir}clone > /dev/null +${examples_dir}f_clone > /dev/null diff --git a/examples/F90/copy_message.sh b/examples/F90/copy_message.sh index 8222f18f0..65c340a86 100755 --- a/examples/F90/copy_message.sh +++ b/examples/F90/copy_message.sh @@ -9,5 +9,5 @@ . ./include.sh -${examples_dir}copy_message > /dev/null +${examples_dir}f_copy_message > /dev/null rm -f out.grib1 diff --git a/examples/F90/count_messages.sh b/examples/F90/count_messages.sh index 6f2123a39..c2ff52b6f 100755 --- a/examples/F90/count_messages.sh +++ b/examples/F90/count_messages.sh @@ -9,4 +9,4 @@ . ./include.sh -${examples_dir}count_messages > /dev/null +${examples_dir}f_count_messages > /dev/null diff --git a/examples/F90/get.sh b/examples/F90/get.sh index 8885f569e..3e16cb691 100755 --- a/examples/F90/get.sh +++ b/examples/F90/get.sh @@ -9,4 +9,4 @@ . ./include.sh -${examples_dir}get > /dev/null +${examples_dir}f_get > /dev/null diff --git a/examples/F90/get_data.sh b/examples/F90/get_data.sh index f3ccc719e..6bd9a8795 100755 --- a/examples/F90/get_data.sh +++ b/examples/F90/get_data.sh @@ -9,4 +9,4 @@ . ./include.sh -${examples_dir}get_data > /dev/null +${examples_dir}f_get_data > /dev/null diff --git a/examples/F90/get_pl.sh b/examples/F90/get_pl.sh index e8458cca8..bc28a8552 100755 --- a/examples/F90/get_pl.sh +++ b/examples/F90/get_pl.sh @@ -9,4 +9,4 @@ . ./include.sh -${examples_dir}get_pl > /dev/null +${examples_dir}f_get_pl > /dev/null diff --git a/examples/F90/get_pv.sh b/examples/F90/get_pv.sh index 8d132d013..0fee5a5c0 100755 --- a/examples/F90/get_pv.sh +++ b/examples/F90/get_pv.sh @@ -9,4 +9,4 @@ . ./include.sh -${examples_dir}get_pv > /dev/null +${examples_dir}f_get_pv > /dev/null diff --git a/examples/F90/get_set_uuid.sh b/examples/F90/get_set_uuid.sh index dc79c442e..437791c2e 100755 --- a/examples/F90/get_set_uuid.sh +++ b/examples/F90/get_set_uuid.sh @@ -14,7 +14,7 @@ uuid=`${tools_dir}/grib_get -w count=1 -p uuidOfVGrid:s ${data_dir}/test_uuid.gr [ "$uuid" = "08b1e836bc6911e1951fb51b5624ad8d" ] # This reads the file in data/test_uuid.grib2 and creates test_uuid.grib2 -${examples_dir}get_set_uuid > /dev/null +${examples_dir}f_get_set_uuid > /dev/null # Check output was written output=out_uuid.grib2 diff --git a/examples/F90/include.ctest.sh.in b/examples/F90/include.ctest.sh.in new file mode 100644 index 000000000..dcf474464 --- /dev/null +++ b/examples/F90/include.ctest.sh.in @@ -0,0 +1,16 @@ +# examples/F90 include file for CMake + +set -ea +proj_dir=@PROJECT_SOURCE_DIR@ +data_dir=@PROJECT_BINARY_DIR@/data + +def_dir="${proj_dir}/definitions" +GRIB_DEFINITION_PATH="${def_dir}" +export GRIB_DEFINITION_PATH + +tools_dir=@CMAKE_BINARY_DIR@/bin/ +examples_dir=@CMAKE_CURRENT_BINARY_DIR@/ + +samp_dir="${proj_dir}/samples" +GRIB_SAMPLES_PATH=${samp_dir} +export GRIB_SAMPLES_PATH diff --git a/examples/F90/include.sh b/examples/F90/include.sh index 9531e5218..bff98c5c8 100755 --- a/examples/F90/include.sh +++ b/examples/F90/include.sh @@ -5,41 +5,45 @@ # # In applying this licence, ECMWF does not waive the privileges and immunities granted to it by # virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. -set -ea -echo -echo "TEST: $0" +CMAKE_INCLUDE_FILE=include.ctest.sh +if [ -f "$CMAKE_INCLUDE_FILE" ]; then + # This is the config file for Cmake tests + . ./$CMAKE_INCLUDE_FILE -if [ -z "${data_dir}" ] -then - cd ../../ - cpath=`pwd` - GRIB_DEFINITION_PATH=$cpath/definitions - export GRIB_DEFINITION_PATH - GRIB_SAMPLES_PATH=$cpath/samples - export GRIB_SAMPLES_PATH - tools_dir=$cpath/tools/ - examples_dir=$cpath/examples/F90/ - data_dir=$cpath/data - samples_dir=$cpath/samples else - echo "Skipping test $0" - exit + set -ea + + echo + echo "TEST: $0" + + if [ -z "${data_dir}" ] + then + cd ../../ + cpath=`pwd` + GRIB_DEFINITION_PATH=$cpath/definitions + export GRIB_DEFINITION_PATH + GRIB_SAMPLES_PATH=$cpath/samples + export GRIB_SAMPLES_PATH + tools_dir=$cpath/tools/ + examples_dir=$cpath/examples/F90/ + data_dir=$cpath/data + samples_dir=$cpath/samples + else + echo "Skipping test $0" + exit + fi + + cd ${examples_dir} + + if [ -z "${GRIB_API_INCLUDE}" ] + then + GRIB_API_INCLUDE=`pwd`/src + fi + + if [ -z "${GRIB_API_LIB}" ] + then + GRIB_API_LIB=`pwd`/src + fi + set -u fi - -cd ${examples_dir} - -if [ -z "${GRIB_API_INCLUDE}" ] -then - GRIB_API_INCLUDE=`pwd`/src -fi - -if [ -z "${GRIB_API_LIB}" ] -then - GRIB_API_LIB=`pwd`/src -fi - -#${tools_dir}grib_info - -set -u - diff --git a/examples/F90/index.sh b/examples/F90/index.sh index 48ddb0dd6..592ceca98 100755 --- a/examples/F90/index.sh +++ b/examples/F90/index.sh @@ -11,11 +11,11 @@ # if an index file does not exist then # create index and save to disk -${examples_dir}index > index_f90.out +${examples_dir}f_index > index_f90.out diff index_f90.out ${data_dir}/index_f90.ok # if an index file exists then load the index from it -${examples_dir}index > index_f90.out +${examples_dir}f_index > index_f90.out diff index_f90.out ${data_dir}/index_f90.ok rm -f index.idx index_f90.out diff --git a/examples/F90/keys_iterator.sh b/examples/F90/keys_iterator.sh index 0f9dcc6b3..08dbb0f0f 100755 --- a/examples/F90/keys_iterator.sh +++ b/examples/F90/keys_iterator.sh @@ -9,4 +9,4 @@ . ./include.sh -${examples_dir}keys_iterator > /dev/null +${examples_dir}f_keys_iterator > /dev/null diff --git a/examples/F90/multi.sh b/examples/F90/multi.sh index 0478969b6..d7a07a545 100755 --- a/examples/F90/multi.sh +++ b/examples/F90/multi.sh @@ -9,6 +9,6 @@ . ./include.sh -${examples_dir}multi > multi.out +${examples_dir}f_multi > multi.out diff multi.out ${data_dir}/multi.ok rm -f multi.out diff --git a/examples/F90/multi_write.sh b/examples/F90/multi_write.sh index 09efb6ed2..f5e2dc0fd 100755 --- a/examples/F90/multi_write.sh +++ b/examples/F90/multi_write.sh @@ -9,7 +9,7 @@ . ./include.sh -${examples_dir}multi_write > /dev/null +${examples_dir}f_multi_write > /dev/null ${tools_dir}/grib_cmp ${data_dir}/multi_created.grib2 multi_created.grib2 diff --git a/examples/F90/nearest.sh b/examples/F90/nearest.sh index aa7c4a996..27dc430fb 100755 --- a/examples/F90/nearest.sh +++ b/examples/F90/nearest.sh @@ -9,4 +9,4 @@ . ./include.sh -${examples_dir}nearest > /dev/null +${examples_dir}f_nearest > /dev/null diff --git a/examples/F90/precision.sh b/examples/F90/precision.sh index 8caa651f8..2d9710707 100755 --- a/examples/F90/precision.sh +++ b/examples/F90/precision.sh @@ -9,5 +9,5 @@ . ./include.sh -${examples_dir}precision > /dev/null +${examples_dir}f_precision > /dev/null rm -f ${data_dir}/regular_latlon_surface_prec.grib1 diff --git a/examples/F90/print_data.sh b/examples/F90/print_data.sh index 2da5b203e..7625ef3f0 100755 --- a/examples/F90/print_data.sh +++ b/examples/F90/print_data.sh @@ -9,4 +9,4 @@ . ./include.sh -${examples_dir}print_data > /dev/null +${examples_dir}f_print_data > /dev/null diff --git a/examples/F90/read_from_file.sh b/examples/F90/read_from_file.sh old mode 100644 new mode 100755 index 3085a9cd9..33225ac9b --- a/examples/F90/read_from_file.sh +++ b/examples/F90/read_from_file.sh @@ -13,4 +13,4 @@ # Check program completed successfully. We have to resort to testing # the output as there is no way in Fortran to set the exit code # -${examples_dir}read_from_file | grep 'Passed' >/dev/null +${examples_dir}f_read_from_file | grep 'Passed' >/dev/null diff --git a/examples/F90/read_message.sh b/examples/F90/read_message.sh index a4bf1657f..1e61fa313 100755 --- a/examples/F90/read_message.sh +++ b/examples/F90/read_message.sh @@ -14,7 +14,7 @@ out=out.grib rm -f $out | true -${examples_dir}read_message > /dev/null +${examples_dir}f_read_message > /dev/null ${tools_dir}grib_compare $in $out diff --git a/examples/F90/samples.sh b/examples/F90/samples.sh index ceed5745d..517d06f1d 100755 --- a/examples/F90/samples.sh +++ b/examples/F90/samples.sh @@ -16,12 +16,12 @@ cp ${data_dir}/regular_latlon_surface.grib1 ${data_dir}/regular_latlon_surface.g # Change the GRIB_SAMPLES_PATH: put the data dir first GRIB_SAMPLES_PATH=${data_dir}:${samples_dir} export GRIB_SAMPLES_PATH -${examples_dir}samples > /dev/null +${examples_dir}f_samples > /dev/null # Extend the GRIB_SAMPLES_PATH: put the data dir second GRIB_SAMPLES_PATH=${samples_dir}:${data_dir} export GRIB_SAMPLES_PATH -${examples_dir}samples > /dev/null +${examples_dir}f_samples > /dev/null rm -f out.grib1 rm -f ${data_dir}/regular_latlon_surface.grib1.tmpl diff --git a/examples/F90/set.sh b/examples/F90/set.sh index 5fbe24352..5b7904082 100755 --- a/examples/F90/set.sh +++ b/examples/F90/set.sh @@ -9,9 +9,9 @@ . ./include.sh -${examples_dir}set > /dev/null +${examples_dir}f_set > /dev/null -${examples_dir}set_gvc > /dev/null +${examples_dir}f_set_gvc > /dev/null [ -f out_gvc.grib2 ] rm -f out.grib1 out_gvc.grib2 diff --git a/examples/F90/set_bitmap.sh b/examples/F90/set_bitmap.sh index 3577cbb6e..377a202c1 100755 --- a/examples/F90/set_bitmap.sh +++ b/examples/F90/set_bitmap.sh @@ -8,5 +8,5 @@ # virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. . ./include.sh -${examples_dir}set_bitmap > /dev/null +${examples_dir}f_set_bitmap > /dev/null rm -f out.grib diff --git a/examples/F90/set_missing.sh b/examples/F90/set_missing.sh index 4c06b183c..cd3cd6d1e 100755 --- a/examples/F90/set_missing.sh +++ b/examples/F90/set_missing.sh @@ -14,5 +14,5 @@ grib1File=${data_dir}/reduced_gaussian_pressure_level.grib1 grib2File=${data_dir}/reduced_gaussian_pressure_level.grib2 ${tools_dir}grib_set -s editionNumber=2 $grib1File $grib2File -${examples_dir}set_missing > /dev/null +${examples_dir}f_set_missing > /dev/null rm -f out_surface_level.grib2 $grib2File diff --git a/examples/F90/set_pv.sh b/examples/F90/set_pv.sh index 32fce248e..779918351 100755 --- a/examples/F90/set_pv.sh +++ b/examples/F90/set_pv.sh @@ -9,5 +9,5 @@ . ./include.sh -${examples_dir}set_pv > /dev/null +${examples_dir}f_set_pv > /dev/null rm -f out.grib1 diff --git a/fortran/CMakeLists.txt b/fortran/CMakeLists.txt index ded84cfe8..8f1210f04 100644 --- a/fortran/CMakeLists.txt +++ b/fortran/CMakeLists.txt @@ -1,7 +1,5 @@ if( ENABLE_FORTRAN ) - - ecbuild_enable_fortran( REQUIRED MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/fortran/modules ) - + set( srcdir ${CMAKE_CURRENT_SOURCE_DIR} ) set( bindir ${CMAKE_CURRENT_BINARY_DIR} ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 23fe1c645..5ae57213d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -300,6 +300,7 @@ list( APPEND grib_api_srcs jgribapi_GribIterator.h md5.h md5.c + # Ship our generated lex/yacc C files grib_windef.h ) @@ -316,17 +317,22 @@ list( APPEND grib_api_extra_srcs configure_file( grib_api_version.c.in grib_api_version.c @ONLY ) -ecbuild_generate_yy(YYPREFIX grib_yy - YACC griby - LEX gribl - DEPENDANT action.c ) +# Only the developer should generate the lex/yacc C files +#ecbuild_generate_yy(YYPREFIX grib_yy +# YACC griby +# LEX gribl +# FLEX_FLAGS "" +# LEX_FLAGS "" +# BISON_FLAGS "-y" +# YACC_FLAGS "-y" +# DEPENDANT action.c ) ecbuild_add_library(TARGET grib_api SOURCES grib_api_version.c - griby.c gribl.c + #griby.c gribl.c + grib_yacc.c grib_lex.c ${grib_api_srcs} GENERATED grib_api_version.c - INCLUDES ${GRIB_API_EXTRA_INCLUDE_DIRS} LIBS ${GRIB_API_EXTRA_LIBRARIES} TEMPLATES ${grib_api_extra_srcs} ${CMATH_LIBRARIES} ) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e69de29bb..29797ab8b 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -0,0 +1,232 @@ +# tests/CMakeLists.txt +# +# Configure the file which all CMake tests will include +configure_file( include.ctest.sh.in include.ctest.sh @ONLY ) + +# Build the executables used by test scripts +################################################ +list( APPEND test_bins + read_any + julian + index + multi_from_message + read_index + unit_tests + gauss_sub +) +foreach( tool ${test_bins} ) + # here we use the fact that each tool has only one C file that matches its name + ecbuild_add_executable( TARGET ${tool} + NOINSTALL + SOURCES ${tool}.c + LIBS grib_api + ) +endforeach() + +# Now add each test +################################################# +ecbuild_add_test( TARGET t_definitions + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/definitions.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET t_ieee + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/ieee.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET t_grib1to2 + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/grib1to2.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET t_grib2to1 + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/grib2to1.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET t_badgrib + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/badgrib.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET t_ls + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/ls.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET t_convert + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/convert.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET t_filter + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/filter.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET t_multi + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/multi.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET t_budg + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/budg.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET t_gridType + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/gridType.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET t_concept + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/concept.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET t_decimalPrecision + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/decimalPrecision.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET t_bitsPerValue + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bitsPerValue.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET t_get_fail + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/get_fail.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET t_missing + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/missing.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET t_local + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/local.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET t_step + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/step.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET t_set + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/set.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET t_iterator + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/iterator.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET t_compare + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/compare.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET t_level + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/level.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET t_index + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/index.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET t_bitmap + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bitmap.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET t_list + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/list.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET t_second_order + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/second_order.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET t_multi_from_message + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/multi_from_message.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET t_change_scanning + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/change_scanning.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET t_julian + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/julian.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET t_statistics + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/statistics.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET t_tigge + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tigge.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET t_tigge_conversions + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tigge_conversions.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET t_read_any + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/read_any.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET t_padding + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/padding.sh + RESOURCES include.sh +) +ecbuild_add_test( TARGET t_debug + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/debug.sh + RESOURCES include.sh +) + +ecbuild_add_test( TARGET t_unit_tests + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/unit_tests.sh + RESOURCES include.sh +) + +########################################### +# Note: the reference file is in the tests dir not data dir! +ecbuild_add_test( TARGET t_lamb_az_eq_area + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/lamb_az_eq_area.sh + RESOURCES include.sh lamb_az_eq_area.ref +) + +if ( ENABLE_NETCDF ) + ecbuild_add_test( TARGET t_grib_to_netcdf + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/grib_to_netcdf.sh + RESOURCES include.sh + ) +endif() + +if( ENABLE_JPG ) + ecbuild_add_test( TARGET t_jpeg + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/jpeg.sh + RESOURCES include.sh + ) +endif() diff --git a/tests/include.ctest.sh.in b/tests/include.ctest.sh.in new file mode 100644 index 000000000..6db1eaeb5 --- /dev/null +++ b/tests/include.ctest.sh.in @@ -0,0 +1,19 @@ +set -ea +# For CMake + +proj_dir=@PROJECT_SOURCE_DIR@ +data_dir=@PROJECT_BINARY_DIR@/data + +def_dir=@PROJECT_SOURCE_DIR@/definitions +GRIB_DEFINITION_PATH="${def_dir}" +export GRIB_DEFINITION_PATH +#echo gdp=$GRIB_DEFINITION_PATH + +tools_dir=@CMAKE_BINARY_DIR@/bin/ +tigge_dir=@CMAKE_BINARY_DIR@/bin/ +test_dir=@CMAKE_BINARY_DIR@/tests + +samp_dir="${proj_dir}/samples" +GRIB_SAMPLES_PATH=${samp_dir} +export GRIB_SAMPLES_PATH +#echo sp=$GRIB_SAMPLES_PATH diff --git a/tests/include.sh b/tests/include.sh index e7c0fa871..dd8a7d630 100644 --- a/tests/include.sh +++ b/tests/include.sh @@ -8,46 +8,49 @@ # set -ea -echo -echo "TEST: $0" +CMAKE_INCLUDE_FILE=include.ctest.sh +if [ -f "$CMAKE_INCLUDE_FILE" ]; then + # This is the config file for Cmake tests + . ./$CMAKE_INCLUDE_FILE -data_dir="" - -# save current working dir -save=`pwd` - -if [ -z "${data_dir}" ] -then - cd ../ - cpath=`pwd` - GRIB_DEFINITION_PATH=$cpath/definitions - export GRIB_DEFINITION_PATH - GRIB_SAMPLES_PATH=$cpath/samples - export GRIB_SAMPLES_PATH - tools_dir=$cpath/tools/ - tigge_dir=$cpath/tigge/ - data_dir=$cpath/data - test_dir=$cpath/tests - def_dir=$cpath/definitions else - tools_dir="" - tigge_dir="" -fi + # This is for autotools + echo + echo "TEST: $0" -if [ -z "${GRIB_API_INCLUDE}" ] -then - GRIB_API_INCLUDE=`pwd`/src -fi + data_dir="" + # save current working dir + save=`pwd` -if [ -z "${GRIB_API_LIB}" ] -then - GRIB_API_LIB=`pwd`/src -fi + if [ -z "${data_dir}" ] + then + cd ../ + cpath=`pwd` + GRIB_DEFINITION_PATH=$cpath/definitions + export GRIB_DEFINITION_PATH + GRIB_SAMPLES_PATH=$cpath/samples + export GRIB_SAMPLES_PATH + tools_dir=$cpath/tools/ + tigge_dir=$cpath/tigge/ + data_dir=$cpath/data + test_dir=$cpath/tests + def_dir=$cpath/definitions + else + tools_dir="" + tigge_dir="" + fi -#${tools_dir}grib_info + if [ -z "${GRIB_API_INCLUDE}" ] + then + GRIB_API_INCLUDE=`pwd`/src + fi -# go back to current working dir -cd $save - -set -u + if [ -z "${GRIB_API_LIB}" ] + then + GRIB_API_LIB=`pwd`/src + fi + # go back to current working dir + cd $save + set -u +fi \ No newline at end of file diff --git a/tests/tigge.sh b/tests/tigge.sh index c69110cb3..0e330c6bc 100755 --- a/tests/tigge.sh +++ b/tests/tigge.sh @@ -17,27 +17,27 @@ REDIRECT=/dev/null dir="${data_dir}/tigge/" # check tigge global -for file in `ls ${dir}/tigge_*.grib` +for file in ${dir}/tigge_*.grib do - ${tigge_dir}tigge_check ${file} 2> $REDIRECT > $REDIRECT + ${tigge_dir}tigge_check ${file} 2> $REDIRECT > $REDIRECT done # check tigge-lam -for file in `ls ${dir}/tiggelam_*.grib` +for file in ${dir}/tiggelam_*.grib do - ${tigge_dir}tigge_check -l ${file} 2> $REDIRECT > $REDIRECT + ${tigge_dir}tigge_check -l ${file} 2> $REDIRECT > $REDIRECT done # Now test non-TIGGE files too. We now expect tigge_check to fail! set +e # All the grib files in the samples are non-TIGGE -for file in `ls ${GRIB_SAMPLES_PATH}/*.tmpl` +for file in ${GRIB_SAMPLES_PATH}/*.tmpl do - ${tigge_dir}tigge_check ${file} 2> $REDIRECT > $REDIRECT - if [ $? -eq 0 ]; then - # should have failed and returned a non-zero exit code - exit 1 - fi + ${tigge_dir}tigge_check ${file} 2> $REDIRECT > $REDIRECT + if [ $? -eq 0 ]; then + # should have failed and returned a non-zero exit code + exit 1 + fi done diff --git a/tests/tigge_conversions.sh b/tests/tigge_conversions.sh index 8889e5180..28de64448 100755 --- a/tests/tigge_conversions.sh +++ b/tests/tigge_conversions.sh @@ -23,7 +23,7 @@ temp2="temp.grib2_" # --- Do I want to exclude any file pattern from the comparison ? exclusion_pattern="tcw|ssr|str|skt|cap|ci|ttr|st|sm|sd|slhf|sshf" -for file in `ls ${dir}/tigge_*.grib` +for file in ${dir}/tigge_*.grib do exclude=`echo $file | awk " /$exclusion_pattern/ {print \"found\";} "` diff --git a/tigge/CMakeLists.txt b/tigge/CMakeLists.txt index e69de29bb..081574320 100644 --- a/tigge/CMakeLists.txt +++ b/tigge/CMakeLists.txt @@ -0,0 +1,25 @@ +# tigge +ecbuild_add_executable(TARGET tigge_check + SOURCES tigge_check.c + INCLUDES ${GRIB_API_EXTRA_INCLUDE_DIRS} + LIBS grib_api + ) + + +ecbuild_add_executable(TARGET tigge_name + SOURCES tigge_name.c + INCLUDES ${GRIB_API_EXTRA_INCLUDE_DIRS} + LIBS grib_api + ) + +ecbuild_add_executable(TARGET tigge_accumulations + SOURCES tigge_accumulations.c + INCLUDES ${GRIB_API_EXTRA_INCLUDE_DIRS} + LIBS grib_api + ) + +ecbuild_add_executable(TARGET tigge_split + SOURCES tigge_split.c + INCLUDES ${GRIB_API_EXTRA_INCLUDE_DIRS} + LIBS grib_api + ) diff --git a/tigge/tigge_accumulations.c b/tigge/tigge_accumulations.c index 69f965369..e7cdaf6c9 100755 --- a/tigge/tigge_accumulations.c +++ b/tigge/tigge_accumulations.c @@ -8,7 +8,16 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ +/* cmake config header */ +#ifdef HAVE_GRIB_API_CONFIG_H +#include "grib_api_config.h" +#endif + +/* autoconf config header */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif + #include #include diff --git a/tigge/tigge_check.c b/tigge/tigge_check.c index d8a832cf2..f746e0ed8 100755 --- a/tigge/tigge_check.c +++ b/tigge/tigge_check.c @@ -8,7 +8,15 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ +/* cmake config header */ +#ifdef HAVE_GRIB_API_CONFIG_H +#include "grib_api_config.h" +#endif + +/* autoconf config header */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include #include diff --git a/tigge/tigge_name.c b/tigge/tigge_name.c index 2c8599155..76ee1051e 100755 --- a/tigge/tigge_name.c +++ b/tigge/tigge_name.c @@ -8,7 +8,15 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ +/* cmake config header */ +#ifdef HAVE_GRIB_API_CONFIG_H +#include "grib_api_config.h" +#endif + +/* autoconf config header */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include #include diff --git a/tigge/tigge_split.c b/tigge/tigge_split.c index 541f0bec8..1608c0fae 100755 --- a/tigge/tigge_split.c +++ b/tigge/tigge_split.c @@ -8,7 +8,15 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ +/* cmake config header */ +#ifdef HAVE_GRIB_API_CONFIG_H +#include "grib_api_config.h" +#endif + +/* autoconf config header */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include #include diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index ca4d18b1e..07451383a 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -21,7 +21,6 @@ foreach( tool ${grib_tools_bins} ) # here we use the fact that each tool has only one C file that matches its name ecbuild_add_executable( TARGET ${tool} SOURCES ${tool}.c - INCLUDES ${GRIB_API_EXTRA_INCLUDE_DIRS} LIBS grib_tools ) endforeach()