From 7146a0b59826780c2a4a1128065c5095618ece7d Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Wed, 18 May 2022 11:57:08 -0400 Subject: [PATCH] GitHub Issue NOAA-EMC/GSI#112. A refactor of CMake build framework. (#327) --- .gitignore | 32 + CMakeLists.txt | 368 +--- INSTALL.md | 117 ++ README.cmake | 145 -- cmake/Modules/FindBACIO.cmake | 22 - cmake/Modules/FindBUFR.cmake | 24 - cmake/Modules/FindBaselibs.cmake | 68 - cmake/Modules/FindCORELIBS.cmake | 156 -- cmake/Modules/FindCRTM.cmake | 33 - cmake/Modules/FindGSICONTROL.cmake | 54 - cmake/Modules/FindHDF5.cmake | 24 - cmake/Modules/FindIP.cmake | 31 - cmake/Modules/FindMPI.cmake | 18 - cmake/Modules/FindNDATE.cmake | 13 - cmake/Modules/FindNEMSIO.cmake | 33 - cmake/Modules/FindSFCIO.cmake | 37 - cmake/Modules/FindSIGIO.cmake | 38 - cmake/Modules/FindSP.cmake | 31 - cmake/Modules/FindW3EMC.cmake | 47 - cmake/Modules/FindW3NCO.cmake | 27 - cmake/Modules/FindWRF.cmake | 36 - .../NewCMake/CMakeParseArguments.cmake | 11 - cmake/Modules/NewCMake/FindHDF5.cmake | 934 ---------- cmake/Modules/NewCMake/FindMPI.cmake | 1514 ----------------- .../NewCMake/FindMPI/fortranparam_mpi.f90.in | 4 - cmake/Modules/NewCMake/FindMPI/libver_mpi.c | 19 - .../NewCMake/FindMPI/libver_mpi.f90.in | 7 - cmake/Modules/NewCMake/FindMPI/mpiver.f90.in | 10 - cmake/Modules/NewCMake/FindMPI/test_mpi.c | 37 - .../Modules/NewCMake/FindMPI/test_mpi.f90.in | 6 - .../FindPackageHandleStandardArgs.cmake | 386 ----- .../Modules/NewCMake/FindPackageMessage.cmake | 47 - .../SelectLibraryConfigurations.cmake | 70 - cmake/Modules/platforms/Acorn.cmake | 13 - cmake/Modules/platforms/Cheyenne.cmake | 24 - cmake/Modules/platforms/Discover.cmake | 55 - cmake/Modules/platforms/Gaea.cmake | 14 - cmake/Modules/platforms/Generic.cmake | 25 - cmake/Modules/platforms/Hera.cmake | 42 - cmake/Modules/platforms/Jet.cmake | 42 - cmake/Modules/platforms/Orion.cmake | 42 - cmake/Modules/platforms/S4.cmake | 10 - cmake/Modules/platforms/WCOSS-C.cmake | 60 - cmake/Modules/platforms/WCOSS-D.cmake | 48 - cmake/Modules/platforms/WCOSS.cmake | 61 - cmake/Modules/platforms/WCOSS2.cmake | 13 - cmake/Modules/setGNUFlags.cmake | 66 - cmake/Modules/setHOST.cmake | 105 -- cmake/Modules/setIntelFlags.cmake | 94 - cmake/Modules/setPGIFlags.cmake | 78 - cmake/Modules/setPlatformVariables.cmake | 12 - modulefiles/gsi_cheyenne.gnu.lua | 29 + modulefiles/gsi_cheyenne.intel.lua | 26 + modulefiles/gsi_common.lua | 32 + ...dulefile.ProdGSI.discover => gsi_discover} | 5 + .../{modulefile.ProdGSI.gaea => gsi_gaea} | 5 + modulefiles/gsi_hera.gnu.lua | 23 + modulefiles/gsi_hera.intel.lua | 29 + modulefiles/gsi_jet.lua | 24 + modulefiles/gsi_orion.lua | 26 + modulefiles/gsi_s4.lua | 26 + modulefiles/gsi_wcoss2.lua | 23 + ...ulefile.ProdGSI.wcoss_c => gsi_wcoss_cray} | 5 + modulefiles/gsi_wcoss_dell_p3.lua | 37 + modulefiles/modulefile.ProdGSI.cheyenne | 16 - modulefiles/modulefile.ProdGSI.hera.lua | 63 - modulefiles/modulefile.ProdGSI.jet | 45 - modulefiles/modulefile.ProdGSI.orion.lua | 61 - modulefiles/modulefile.ProdGSI.s4 | 32 - modulefiles/modulefile.ProdGSI.wcoss2.lua | 45 - modulefiles/modulefile.ProdGSI.wcoss_d | 46 - regression/.gitignore | 1 + regression/CMakeLists.txt | 82 + regression/arw_netcdf.sh | 2 +- regression/global_4denvar_T126.sh | 2 +- regression/global_4dvar_T62.sh | 2 +- regression/global_C96_fv3aero.sh | 2 +- regression/global_C96_fv3aerorad.sh | 2 +- regression/global_T62.sh | 2 +- regression/global_T62_ozonly.sh | 2 +- regression/global_enkf_T62.sh | 2 +- regression/global_fv3_4denvar_C192.sh | 2 +- regression/global_fv3_4denvar_T126.sh | 2 +- regression/global_hybrid_T126.sh | 2 +- regression/global_lanczos_T62.sh | 2 +- regression/global_nemsio_T62.sh | 2 +- regression/hwrf_nmm_d2.sh | 2 +- regression/hwrf_nmm_d3.sh | 2 +- regression/multi_regression.sh | 4 +- regression/nmm_binary.sh | 2 +- regression/nmm_netcdf.sh | 2 +- regression/nmmb_nems_4denvar.sh | 2 +- regression/regression_driver.sh | 8 +- regression/regression_var.sh | 348 ++-- regression/rtma.sh | 2 +- src/CMakeLists.txt | 19 + src/GSD/CMakeLists.txt | 2 + src/GSD/gsdcloud/CMakeLists.txt | 113 +- src/GSD/gsdcloud/cmake/PackageConfig.cmake.in | 19 + src/enkf/CMakeLists.txt | 257 ++- src/enkf/cmake/FindMKL.cmake | 91 + .../enkf/cmake}/FindNetCDF.cmake | 32 +- src/enkf/cmake/PackageConfig.cmake.in | 45 + src/enkf/cmake/enkfapp_compiler_flags.cmake | 27 + .../cmake/enkfapp_compiler_flags_GNU_C.cmake | 34 + .../enkfapp_compiler_flags_GNU_Fortran.cmake | 41 + .../enkfapp_compiler_flags_Intel_C.cmake | 34 + ...enkfapp_compiler_flags_Intel_Fortran.cmake | 35 + src/enkf/enkf_files.cmake | 65 + src/enkf/gridinfo_fv3reg.f90 | 13 +- src/enkf/gridinfo_gfs.f90 | 4 +- src/enkf/gridio_fv3reg.f90 | 12 +- src/enkf/gridio_gfs.f90 | 48 +- src/fv3gfs_ncio/CMakeLists.txt | 10 - src/fv3gfs_ncio/module_fv3gfs_ncio.f90 | 1338 --------------- src/fv3gfs_ncio/quantize_data_code.f90 | 17 - src/fv3gfs_ncio/read_attribute_code.f90 | 35 - .../read_scalar_attribute_code.f90 | 31 - src/fv3gfs_ncio/read_vardata_code_1d.f90 | 75 - src/fv3gfs_ncio/read_vardata_code_2d.f90 | 81 - src/fv3gfs_ncio/read_vardata_code_3d.f90 | 85 - src/fv3gfs_ncio/read_vardata_code_4d.f90 | 83 - src/fv3gfs_ncio/read_vardata_code_5d.f90 | 35 - src/fv3gfs_ncio/write_attribute_code.f90 | 37 - src/fv3gfs_ncio/write_vardata_code.f90 | 97 -- src/gsi/CMakeLists.txt | 382 +++-- src/gsi/cmake/FindMKL.cmake | 91 + src/gsi/cmake/FindNetCDF.cmake | 347 ++++ src/gsi/cmake/PackageConfig.cmake.in | 60 + src/gsi/cmake/gsiapp_compiler_flags.cmake | 27 + .../cmake/gsiapp_compiler_flags_GNU_C.cmake | 34 + .../gsiapp_compiler_flags_GNU_Fortran.cmake | 41 + .../cmake/gsiapp_compiler_flags_Intel_C.cmake | 34 + .../gsiapp_compiler_flags_Intel_Fortran.cmake | 35 + src/gsi/cplr_get_fv3_regional_ensperts.f90 | 1 + src/gsi/cplr_gfs_ensmod.f90 | 2 +- src/gsi/general_read_gfsatm.f90 | 6 +- src/gsi/gesinfo.F90 | 2 +- src/gsi/get_gefs_for_regional.f90 | 2 +- src/gsi/gfs_stratosphere.f90 | 4 +- src/gsi/gsi_files.cmake | 674 ++++++++ src/gsi/gsi_rfv3io_mod.f90 | 19 +- src/gsi/netcdfgfs_io.f90 | 16 +- src/gsi/read_files.f90 | 2 +- src/gsi/read_gfs_ozone_for_regional.f90 | 2 +- src/ncdiag/CMakeLists.txt | 137 +- src/ncdiag/cmake/FindNetCDF.cmake | 347 ++++ src/ncdiag/cmake/PackageConfig.cmake.in | 19 + src/ncdiag/cmake/ncdiag_compiler_flags.cmake | 15 + .../ncdiag_compiler_flags_GNU_Fortran.cmake | 41 + .../ncdiag_compiler_flags_Intel_Fortran.cmake | 35 + src/ncdiag/ncdf_string_m.f90 | 4 +- src/ncdiag/ncdiag_files.cmake | 53 + src/ncdiag/serial/CMakeLists.txt | 31 - ush/build.comgsi | 174 -- ush/build.sh | 65 + ush/build_4nco_global.sh | 39 + ush/build_all_cmake.sh | 126 -- ush/detect_machine.sh | 55 + ush/module-setup.sh | 127 ++ ush/prune_4nco_global.sh | 8 +- ush/sub_discover | 2 +- ush/sub_hera | 2 +- ush/sub_jet | 3 +- ush/sub_wcoss_c | 2 +- ush/sub_wcoss_d | 2 +- util/AeroDA/CMakeLists.txt | 1 + .../calc_increment_ens.fd/CMakeLists.txt | 43 +- util/Analysis_Utilities/CMakeLists.txt | 1 + .../read_diag/CMakeLists.txt | 40 +- util/Analysis_Utilities/read_diag/kinds.F90 | 39 + util/CMakeLists.txt | 172 ++ util/Conventional_Monitor/CMakeLists.txt | 107 +- .../image_gen/CMakeLists.txt | 1 + .../image_gen/exec/.gitignore | 2 - .../image_gen/sorc/CMakeLists.txt | 5 + .../sorc/conmon_read_ps_IG.fd/CMakeLists.txt | 36 +- .../sorc/conmon_read_ps_IG.fd/convinfo.f90 | 2 +- .../sorc/conmon_read_pw_IG.fd/CMakeLists.txt | 39 +- .../sorc/conmon_read_pw_IG.fd/convinfo.f90 | 2 +- .../sorc/conmon_read_q_IG.fd/CMakeLists.txt | 39 +- .../sorc/conmon_read_q_IG.fd/convinfo.f90 | 2 +- .../sorc/conmon_read_t_IG.fd/CMakeLists.txt | 39 +- .../sorc/conmon_read_t_IG.fd/convinfo.f90 | 2 +- .../sorc/conmon_read_uv_IG.fd/CMakeLists.txt | 40 +- .../sorc/conmon_read_uv_IG.fd/convinfo.f90 | 2 +- .../nwprod/CMakeLists.txt | 1 + .../nwprod/conmon_shared/CMakeLists.txt | 1 + .../nwprod/conmon_shared/exec/.gitignore | 2 - .../conmon_shared/modulefiles/cray/CMonBuild | 21 - .../conmon_shared/modulefiles/theia/CMonBuild | 17 - .../conmon_shared/modulefiles/wcoss/CMonBuild | 18 - .../nwprod/conmon_shared/sorc/CMakeLists.txt | 6 + .../sorc/conmon_grads_lev.fd/CMakeLists.txt | 39 +- .../conmon_grads_lev.fd/conmon_read_diag.F90 | 42 +- .../sorc/conmon_grads_lev.fd/grads_lev.f90 | 2 +- .../conmon_grads_mandlev.fd/CMakeLists.txt | 41 +- .../conmon_read_diag.F90 | 42 +- .../conmon_grads_mandlev.fd/grads_mandlev.f90 | 5 +- .../sorc/conmon_grads_sfc.fd/CMakeLists.txt | 41 +- .../conmon_grads_sfc.fd/conmon_read_diag.F90 | 42 +- .../sorc/conmon_grads_sfc.fd/grads_sfc.f90 | 2 +- .../conmon_grads_sfctime.fd/CMakeLists.txt | 52 +- .../conmon_read_diag.F90 | 42 +- .../conmon_grads_sfctime.fd/grads_sfctime.f90 | 2 +- .../sorc/conmon_grads_sig.fd/CMakeLists.txt | 43 +- .../conmon_grads_sig.fd/conmon_read_diag.F90 | 42 +- .../sorc/conmon_grads_sig.fd/grads_sig.f90 | 2 +- .../sorc/conmon_time.fd/CMakeLists.txt | 44 +- .../sorc/conmon_time.fd/conmon_read_diag.F90 | 42 +- .../sorc/conmon_time.fd/process_time_data.f90 | 10 +- util/Correlated_Obs/CMakeLists.txt | 126 +- util/EFSOI_Utilities/CMakeLists.txt | 11 + util/EFSOI_Utilities/src/CMakeLists.txt | 50 +- util/EFSOI_Utilities/src/efsoi.f90 | 9 +- util/EFSOI_Utilities/src/efsoi_main.f90 | 4 +- util/EFSOI_Utilities/src/gridio_efsoi.f90 | 8 +- util/EFSOI_Utilities/src/loadbal_efsoi.f90 | 6 +- util/EnKF/CMakeLists.txt | 18 + util/EnKF/arw/CMakeLists.txt | 1 + util/EnKF/arw/src/CMakeLists.txt | 9 +- .../src/enspreproc_regional.fd/CMakeLists.txt | 44 +- .../src/initialens_regional.fd/CMakeLists.txt | 41 +- util/EnKF/gfs/CMakeLists.txt | 1 + util/EnKF/gfs/src/CMakeLists.txt | 76 +- .../EnKF/gfs/src/adderrspec.fd/CMakeLists.txt | 28 +- util/EnKF/gfs/src/adjustps.fd/CMakeLists.txt | 26 +- .../src/calc_increment_ens.fd/CMakeLists.txt | 42 +- .../calc_increment_ens_ncio.fd/CMakeLists.txt | 41 +- .../gfs_ncio_interface.f90 | 2 +- .../src/calc_increment_ncio.fd/CMakeLists.txt | 21 +- .../calc_increment_ncio.f90 | 8 +- .../calc_increment_serial.fd/CMakeLists.txt | 38 +- .../gfs/src/getnstensmeanp.fd/CMakeLists.txt | 25 +- .../gfs/src/getsfcensmeanp.fd/CMakeLists.txt | 26 +- .../src/getsfcensmeanp.fd/getsfcensmeanp.f90 | 8 +- .../src/getsfcnstensupdp.fd/CMakeLists.txt | 38 +- .../getsigensmeanp_smooth.fd/CMakeLists.txt | 30 +- .../getsigensmeanp_smooth_ncep.f90 | 10 +- .../gfs/src/getsigensstatp.fd/CMakeLists.txt | 29 +- .../src/getsigensstatp.fd/getsigensstatp.f90 | 10 +- util/EnKF/gfs/src/gribmean.fd/CMakeLists.txt | 20 +- util/EnKF/gfs/src/preproc/CMakeLists.txt | 38 +- .../src/recenterens_ncio.fd/CMakeLists.txt | 27 +- .../recenterens_ncio.fd/recenterens_ncio.f90 | 8 +- .../recenterncio_hybgain.fd/CMakeLists.txt | 27 +- .../recenterncio_hybgain.f90 | 8 +- .../recenternemsiop_hybgain.fd/CMakeLists.txt | 23 +- .../gfs/src/recentersigp.fd/CMakeLists.txt | 26 +- .../gfs/src/recentersigp.fd/recentersigp.f90 | 8 +- util/FOV_utilities/CMakeLists.txt | 1 + util/FOV_utilities/sorc/CMakeLists.txt | 13 + util/NMC_Bkerror/CMakeLists.txt | 2 + util/NMC_Bkerror/sorc/CMakeLists.txt | 44 + util/NMC_Bkerror/sorc/initvars.f90 | 2 +- util/NMC_Bkerror/sorc/mat.f90 | 8 +- util/NMC_Bkerror/sorc_aero/CMakeLists.txt | 35 + util/NMC_Bkerror/sorc_aero/mat.f90 | 8 +- util/Ozone_Monitor/CMakeLists.txt | 98 +- util/Ozone_Monitor/data_xtrct/CMakeLists.txt | 1 + util/Ozone_Monitor/data_xtrct/exec/.gitignore | 2 - .../data_xtrct/sorc/CMakeLists.txt | 1 + .../sorc/make_base.fd/CMakeLists.txt | 28 +- .../data_xtrct/sorc/make_base.fd/makefile | 44 - util/Ozone_Monitor/nwprod/CMakeLists.txt | 1 + .../nwprod/oznmon_shared/CMakeLists.txt | 1 + .../nwprod/oznmon_shared/exec/.gitignore | 2 - .../modulefiles/cray/OznMonBuild | 18 - .../modulefiles/dell/OznMonBuild | 18 - .../modulefiles/theia/OznMonBuild | 20 - .../modulefiles/wcoss/OznMonBuild | 18 - .../nwprod/oznmon_shared/sorc/CMakeLists.txt | 2 + .../sorc/oznmon_horiz.fd/CMakeLists.txt | 39 +- .../sorc/oznmon_horiz.fd/oznmon_read_diag.f90 | 4 +- .../sorc/oznmon_time.fd/CMakeLists.txt | 41 +- .../sorc/oznmon_time.fd/oznmon_read_diag.f90 | 4 +- .../sorc/oznmon_time.fd/time.f90 | 6 +- util/Radiance_Monitor/CMakeLists.txt | 107 +- .../data_extract/CMakeLists.txt | 1 + .../data_extract/exec/.gitignore | 2 - .../data_extract/sorc/CMakeLists.txt | 2 + .../sorc/radmon_mk_base.fd/CMakeLists.txt | 28 +- .../sorc/radmon_mk_base.fd/makefile | 44 - .../sorc/radmon_validate_tm.fd/CMakeLists.txt | 34 +- .../sorc/radmon_validate_tm.fd/makefile | 62 - .../Radiance_Monitor/image_gen/CMakeLists.txt | 1 + .../image_gen/exec/.gitignore | 2 - .../image_gen/src/CMakeLists.txt | 5 + .../src/radmon_ig_angle.fd/CMakeLists.txt | 31 +- .../src/radmon_ig_angle.fd/angle.f90 | 2 +- .../src/radmon_ig_bcoef.fd/CMakeLists.txt | 31 +- .../src/radmon_ig_bcoef.fd/bcoef.f90 | 6 +- .../src/radmon_ig_horiz.fd/CMakeLists.txt | 41 +- .../src/radmon_ig_summary.fd/CMakeLists.txt | 31 +- .../src/radmon_ig_summary.fd/summary.f90 | 6 +- .../src/radmon_ig_time.fd/CMakeLists.txt | 31 +- .../image_gen/src/radmon_ig_time.fd/time.f90 | 6 +- util/Radiance_Monitor/nwprod/CMakeLists.txt | 1 + .../nwprod/radmon_shared/CMakeLists.txt | 1 + .../nwprod/radmon_shared/sorc/CMakeLists.txt | 4 + .../sorc/verf_radang.fd/CMakeLists.txt | 40 +- .../sorc/verf_radbcoef.fd/CMakeLists.txt | 40 +- .../sorc/verf_radbcor.fd/CMakeLists.txt | 41 +- .../sorc/verf_radtime.fd/CMakeLists.txt | 44 +- util/Single_Observation/CMakeLists.txt | 12 + util/bufr_tools/CMakeLists.txt | 86 +- util/cmake/FindMKL.cmake | 91 + util/cmake/FindNetCDF.cmake | 347 ++++ util/cmake/gsiutils_compiler_flags.cmake | 27 + .../cmake/gsiutils_compiler_flags_GNU_C.cmake | 34 + .../gsiutils_compiler_flags_GNU_Fortran.cmake | 41 + .../gsiutils_compiler_flags_Intel_C.cmake | 34 + ...siutils_compiler_flags_Intel_Fortran.cmake | 35 + util/ndate/CMakeLists.txt | 8 - util/ndate/ndate.f | 147 -- util/netcdf_io/CMakeLists.txt | 25 +- .../netcdf_io/calc_analysis.fd/CMakeLists.txt | 34 +- util/netcdf_io/calc_analysis.fd/inc2anl.f90 | 8 +- util/netcdf_io/calc_analysis.fd/init_io.f90 | 4 +- .../calc_analysis.fd/vars_calc_analysis.f90 | 2 +- util/netcdf_io/interp_inc.fd/CMakeLists.txt | 27 +- util/netcdf_io/interp_inc.fd/driver.f90 | 2 +- util/radar_process/CMakeLists.txt | 2 + util/radar_process/radialwind/CMakeLists.txt | 31 +- .../radar_process/reflectivity/CMakeLists.txt | 28 +- util/radar_process/reflectivity/kinds.F90 | 39 + .../reflectivity/write_bufr_ref.f90 | 3 +- util/zero_biascoeff/CMakeLists.txt | 36 +- 328 files changed, 6632 insertions(+), 9927 deletions(-) create mode 100644 INSTALL.md delete mode 100644 README.cmake delete mode 100644 cmake/Modules/FindBACIO.cmake delete mode 100644 cmake/Modules/FindBUFR.cmake delete mode 100644 cmake/Modules/FindBaselibs.cmake delete mode 100644 cmake/Modules/FindCORELIBS.cmake delete mode 100644 cmake/Modules/FindCRTM.cmake delete mode 100644 cmake/Modules/FindGSICONTROL.cmake delete mode 100644 cmake/Modules/FindHDF5.cmake delete mode 100644 cmake/Modules/FindIP.cmake delete mode 100644 cmake/Modules/FindMPI.cmake delete mode 100644 cmake/Modules/FindNDATE.cmake delete mode 100644 cmake/Modules/FindNEMSIO.cmake delete mode 100644 cmake/Modules/FindSFCIO.cmake delete mode 100644 cmake/Modules/FindSIGIO.cmake delete mode 100644 cmake/Modules/FindSP.cmake delete mode 100644 cmake/Modules/FindW3EMC.cmake delete mode 100644 cmake/Modules/FindW3NCO.cmake delete mode 100644 cmake/Modules/FindWRF.cmake delete mode 100644 cmake/Modules/NewCMake/CMakeParseArguments.cmake delete mode 100644 cmake/Modules/NewCMake/FindHDF5.cmake delete mode 100644 cmake/Modules/NewCMake/FindMPI.cmake delete mode 100644 cmake/Modules/NewCMake/FindMPI/fortranparam_mpi.f90.in delete mode 100644 cmake/Modules/NewCMake/FindMPI/libver_mpi.c delete mode 100644 cmake/Modules/NewCMake/FindMPI/libver_mpi.f90.in delete mode 100644 cmake/Modules/NewCMake/FindMPI/mpiver.f90.in delete mode 100644 cmake/Modules/NewCMake/FindMPI/test_mpi.c delete mode 100644 cmake/Modules/NewCMake/FindMPI/test_mpi.f90.in delete mode 100644 cmake/Modules/NewCMake/FindPackageHandleStandardArgs.cmake delete mode 100644 cmake/Modules/NewCMake/FindPackageMessage.cmake delete mode 100644 cmake/Modules/NewCMake/SelectLibraryConfigurations.cmake delete mode 100644 cmake/Modules/platforms/Acorn.cmake delete mode 100644 cmake/Modules/platforms/Cheyenne.cmake delete mode 100644 cmake/Modules/platforms/Discover.cmake delete mode 100644 cmake/Modules/platforms/Gaea.cmake delete mode 100644 cmake/Modules/platforms/Generic.cmake delete mode 100644 cmake/Modules/platforms/Hera.cmake delete mode 100644 cmake/Modules/platforms/Jet.cmake delete mode 100644 cmake/Modules/platforms/Orion.cmake delete mode 100644 cmake/Modules/platforms/S4.cmake delete mode 100644 cmake/Modules/platforms/WCOSS-C.cmake delete mode 100644 cmake/Modules/platforms/WCOSS-D.cmake delete mode 100644 cmake/Modules/platforms/WCOSS.cmake delete mode 100644 cmake/Modules/platforms/WCOSS2.cmake delete mode 100644 cmake/Modules/setGNUFlags.cmake delete mode 100644 cmake/Modules/setHOST.cmake delete mode 100644 cmake/Modules/setIntelFlags.cmake delete mode 100644 cmake/Modules/setPGIFlags.cmake delete mode 100644 cmake/Modules/setPlatformVariables.cmake create mode 100644 modulefiles/gsi_cheyenne.gnu.lua create mode 100644 modulefiles/gsi_cheyenne.intel.lua create mode 100644 modulefiles/gsi_common.lua rename modulefiles/{modulefile.ProdGSI.discover => gsi_discover} (87%) rename modulefiles/{modulefile.ProdGSI.gaea => gsi_gaea} (95%) create mode 100644 modulefiles/gsi_hera.gnu.lua create mode 100644 modulefiles/gsi_hera.intel.lua create mode 100644 modulefiles/gsi_jet.lua create mode 100644 modulefiles/gsi_orion.lua create mode 100644 modulefiles/gsi_s4.lua create mode 100644 modulefiles/gsi_wcoss2.lua rename modulefiles/{modulefile.ProdGSI.wcoss_c => gsi_wcoss_cray} (93%) create mode 100644 modulefiles/gsi_wcoss_dell_p3.lua delete mode 100644 modulefiles/modulefile.ProdGSI.cheyenne delete mode 100644 modulefiles/modulefile.ProdGSI.hera.lua delete mode 100644 modulefiles/modulefile.ProdGSI.jet delete mode 100644 modulefiles/modulefile.ProdGSI.orion.lua delete mode 100644 modulefiles/modulefile.ProdGSI.s4 delete mode 100644 modulefiles/modulefile.ProdGSI.wcoss2.lua delete mode 100644 modulefiles/modulefile.ProdGSI.wcoss_d create mode 100644 regression/.gitignore create mode 100644 regression/CMakeLists.txt create mode 100644 src/CMakeLists.txt create mode 100644 src/GSD/CMakeLists.txt create mode 100644 src/GSD/gsdcloud/cmake/PackageConfig.cmake.in create mode 100644 src/enkf/cmake/FindMKL.cmake rename {cmake/Modules => src/enkf/cmake}/FindNetCDF.cmake (97%) create mode 100644 src/enkf/cmake/PackageConfig.cmake.in create mode 100644 src/enkf/cmake/enkfapp_compiler_flags.cmake create mode 100644 src/enkf/cmake/enkfapp_compiler_flags_GNU_C.cmake create mode 100644 src/enkf/cmake/enkfapp_compiler_flags_GNU_Fortran.cmake create mode 100644 src/enkf/cmake/enkfapp_compiler_flags_Intel_C.cmake create mode 100644 src/enkf/cmake/enkfapp_compiler_flags_Intel_Fortran.cmake create mode 100644 src/enkf/enkf_files.cmake delete mode 100644 src/fv3gfs_ncio/CMakeLists.txt delete mode 100644 src/fv3gfs_ncio/module_fv3gfs_ncio.f90 delete mode 100644 src/fv3gfs_ncio/quantize_data_code.f90 delete mode 100644 src/fv3gfs_ncio/read_attribute_code.f90 delete mode 100644 src/fv3gfs_ncio/read_scalar_attribute_code.f90 delete mode 100644 src/fv3gfs_ncio/read_vardata_code_1d.f90 delete mode 100644 src/fv3gfs_ncio/read_vardata_code_2d.f90 delete mode 100644 src/fv3gfs_ncio/read_vardata_code_3d.f90 delete mode 100644 src/fv3gfs_ncio/read_vardata_code_4d.f90 delete mode 100644 src/fv3gfs_ncio/read_vardata_code_5d.f90 delete mode 100644 src/fv3gfs_ncio/write_attribute_code.f90 delete mode 100644 src/fv3gfs_ncio/write_vardata_code.f90 create mode 100644 src/gsi/cmake/FindMKL.cmake create mode 100644 src/gsi/cmake/FindNetCDF.cmake create mode 100644 src/gsi/cmake/PackageConfig.cmake.in create mode 100644 src/gsi/cmake/gsiapp_compiler_flags.cmake create mode 100644 src/gsi/cmake/gsiapp_compiler_flags_GNU_C.cmake create mode 100644 src/gsi/cmake/gsiapp_compiler_flags_GNU_Fortran.cmake create mode 100644 src/gsi/cmake/gsiapp_compiler_flags_Intel_C.cmake create mode 100644 src/gsi/cmake/gsiapp_compiler_flags_Intel_Fortran.cmake create mode 100644 src/gsi/gsi_files.cmake create mode 100644 src/ncdiag/cmake/FindNetCDF.cmake create mode 100644 src/ncdiag/cmake/PackageConfig.cmake.in create mode 100644 src/ncdiag/cmake/ncdiag_compiler_flags.cmake create mode 100644 src/ncdiag/cmake/ncdiag_compiler_flags_GNU_Fortran.cmake create mode 100644 src/ncdiag/cmake/ncdiag_compiler_flags_Intel_Fortran.cmake create mode 100644 src/ncdiag/ncdiag_files.cmake delete mode 100644 src/ncdiag/serial/CMakeLists.txt delete mode 100755 ush/build.comgsi create mode 100755 ush/build.sh create mode 100755 ush/build_4nco_global.sh delete mode 100755 ush/build_all_cmake.sh create mode 100755 ush/detect_machine.sh create mode 100755 ush/module-setup.sh create mode 100644 util/AeroDA/CMakeLists.txt create mode 100644 util/Analysis_Utilities/CMakeLists.txt create mode 100644 util/Analysis_Utilities/read_diag/kinds.F90 create mode 100644 util/CMakeLists.txt create mode 100644 util/Conventional_Monitor/image_gen/CMakeLists.txt delete mode 100644 util/Conventional_Monitor/image_gen/exec/.gitignore create mode 100644 util/Conventional_Monitor/image_gen/sorc/CMakeLists.txt create mode 100644 util/Conventional_Monitor/nwprod/CMakeLists.txt create mode 100644 util/Conventional_Monitor/nwprod/conmon_shared/CMakeLists.txt delete mode 100644 util/Conventional_Monitor/nwprod/conmon_shared/exec/.gitignore delete mode 100644 util/Conventional_Monitor/nwprod/conmon_shared/modulefiles/cray/CMonBuild delete mode 100644 util/Conventional_Monitor/nwprod/conmon_shared/modulefiles/theia/CMonBuild delete mode 100644 util/Conventional_Monitor/nwprod/conmon_shared/modulefiles/wcoss/CMonBuild create mode 100644 util/Conventional_Monitor/nwprod/conmon_shared/sorc/CMakeLists.txt create mode 100644 util/EFSOI_Utilities/CMakeLists.txt create mode 100644 util/EnKF/CMakeLists.txt create mode 100644 util/EnKF/arw/CMakeLists.txt create mode 100644 util/EnKF/gfs/CMakeLists.txt create mode 100644 util/FOV_utilities/CMakeLists.txt create mode 100644 util/FOV_utilities/sorc/CMakeLists.txt create mode 100644 util/NMC_Bkerror/CMakeLists.txt create mode 100644 util/NMC_Bkerror/sorc/CMakeLists.txt create mode 100644 util/NMC_Bkerror/sorc_aero/CMakeLists.txt create mode 100644 util/Ozone_Monitor/data_xtrct/CMakeLists.txt delete mode 100644 util/Ozone_Monitor/data_xtrct/exec/.gitignore create mode 100644 util/Ozone_Monitor/data_xtrct/sorc/CMakeLists.txt delete mode 100755 util/Ozone_Monitor/data_xtrct/sorc/make_base.fd/makefile create mode 100644 util/Ozone_Monitor/nwprod/CMakeLists.txt create mode 100644 util/Ozone_Monitor/nwprod/oznmon_shared/CMakeLists.txt delete mode 100644 util/Ozone_Monitor/nwprod/oznmon_shared/exec/.gitignore delete mode 100644 util/Ozone_Monitor/nwprod/oznmon_shared/modulefiles/cray/OznMonBuild delete mode 100644 util/Ozone_Monitor/nwprod/oznmon_shared/modulefiles/dell/OznMonBuild delete mode 100644 util/Ozone_Monitor/nwprod/oznmon_shared/modulefiles/theia/OznMonBuild delete mode 100644 util/Ozone_Monitor/nwprod/oznmon_shared/modulefiles/wcoss/OznMonBuild create mode 100644 util/Ozone_Monitor/nwprod/oznmon_shared/sorc/CMakeLists.txt create mode 100644 util/Radiance_Monitor/data_extract/CMakeLists.txt delete mode 100644 util/Radiance_Monitor/data_extract/exec/.gitignore create mode 100644 util/Radiance_Monitor/data_extract/sorc/CMakeLists.txt delete mode 100755 util/Radiance_Monitor/data_extract/sorc/radmon_mk_base.fd/makefile delete mode 100755 util/Radiance_Monitor/data_extract/sorc/radmon_validate_tm.fd/makefile create mode 100644 util/Radiance_Monitor/image_gen/CMakeLists.txt delete mode 100644 util/Radiance_Monitor/image_gen/exec/.gitignore create mode 100644 util/Radiance_Monitor/image_gen/src/CMakeLists.txt create mode 100644 util/Radiance_Monitor/nwprod/CMakeLists.txt create mode 100644 util/Radiance_Monitor/nwprod/radmon_shared/CMakeLists.txt create mode 100644 util/Radiance_Monitor/nwprod/radmon_shared/sorc/CMakeLists.txt create mode 100644 util/Single_Observation/CMakeLists.txt create mode 100644 util/cmake/FindMKL.cmake create mode 100644 util/cmake/FindNetCDF.cmake create mode 100644 util/cmake/gsiutils_compiler_flags.cmake create mode 100644 util/cmake/gsiutils_compiler_flags_GNU_C.cmake create mode 100644 util/cmake/gsiutils_compiler_flags_GNU_Fortran.cmake create mode 100644 util/cmake/gsiutils_compiler_flags_Intel_C.cmake create mode 100644 util/cmake/gsiutils_compiler_flags_Intel_Fortran.cmake delete mode 100644 util/ndate/CMakeLists.txt delete mode 100644 util/ndate/ndate.f create mode 100644 util/radar_process/CMakeLists.txt create mode 100644 util/radar_process/reflectivity/kinds.F90 diff --git a/.gitignore b/.gitignore index 4d3244a698..07e3831567 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,34 @@ build*/ +install*/ .*.swp +*.[aox] +*.mod +.DS_Store +exec/ +lib/ +lib64/ + +nohup.out +log* +build.log* +install.log* + +# Ensure no one adds binary files to this repo. Not even by accident. +# over-riding this file can be done in the subdirectory +*.bin +*.nc* +*.tar* +*.tgz +*.gz +*.png +*.jp*g +*.tiff + +# Python related +_pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + diff --git a/CMakeLists.txt b/CMakeLists.txt index e648d8d8a1..8573b6a1b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,327 +1,59 @@ -# disable in source builds to protect against overwriting other Makefiles -#set(CMAKE_DISABLE_IN_SOURCE_BUILD ON) -if( NOT DEFINED ENV{CC} ) - find_path( crayComp "ftn" ) - find_path( wcossIntel "mpfort" ) - find_path( intelComp "ifort" ) - find_path( pgiComp "pgf90" ) - if( crayComp ) - message("Setting CrayLinuxEnvironment") - set(CMAKE_SYSTEM_NAME "CrayLinuxEnvironment") - set(CMAKE_C_COMPILER "${crayComp}/cc") - set(CMAKE_CXX_COMPILER "${crayComp}/CC") - set(CMAKE_Fortran_COMPILER "${crayComp}/ftn") - endif() - if( intelComp ) - set(ENV{CC} "icc") - set(ENV{CXX} "icpc") - set(ENV{FC} "ifort") - endif() - if( wcossIntel ) - message("Setting env for wcoss intel") - set(ENV{CC} "mpcc") - set(ENV{CXX} "mpCC") - set(ENV{FC} "mpfort") - endif() - if( pgiComp ) - set(ENV{CC} "pgcc") - set(ENV{CXX} "pgCC") - set(ENV{FC} "pgf90") - endif() -endif() - -project(GSI) - enable_language (Fortran) - option(USE_WRF "Find WRF object files and build regional GSI model" ON) - option(USE_BASELIBS "Look for and use GMAO Baselibs" OFF) - option(BUILD_GLOBAL "Build GSI without WRF (regional) module " OFF) - option(BUILD_ENKF "Build the Enkf executable " ON) - option(USE_BASELINE "Use baseline control runs" ON) - SET(ENKF_MODE "GFS" CACHE STRING "EnKF build mode: GFS, WRF, NMMB, and FV3reg") - string(TOUPPER ${ENKF_MODE} ENKF_MODE) - if (ENKF_MODE MATCHES "^GFS$") - message("Build the EnKF with GFS module") - option(BUILD_GFS "Build the Enkf with GFS module " ON) - option(BUILD_NMMB "Build the Enkf with NMMB module " OFF) - option(BUILD_WRF "Build the Enkf with WRF module " OFF) - option(BUILD_FV3reg "Build the Enkf with FV3reg module " OFF) - elseif (ENKF_MODE MATCHES "^WRF$") - message("Build the EnKF with WRF module") - option(BUILD_GFS "Build the Enkf with GFS module " OFF) - option(BUILD_NMMB "Build the Enkf with NMMB module " OFF) - option(BUILD_WRF "Build the Enkf with WRF module " ON) - option(BUILD_FV3reg "Build the Enkf with FV3reg module " OFF) - elseif (ENKF_MODE MATCHES "^NMMB$") - message("Build the EnKF with NMMB module") - option(BUILD_GFS "Build the Enkf with GFS module " OFF) - option(BUILD_NMMB "Build the Enkf with NMMB module " ON) - option(BUILD_WRF "Build the Enkf with WRF module " OFF) - option(BUILD_FV3reg "Build the Enkf with FV3reg module " OFF) - elseif (ENKF_MODE MATCHES "^FV3REG$") - message("Build the EnKF with FV3reg module") - option(BUILD_GFS "Build the Enkf with GFS module " OFF) - option(BUILD_NMMB "Build the Enkf with NMMB module " OFF) - option(BUILD_WRF "Build the Enkf with WRF module " OFF) - option(BUILD_FV3reg "Build the Enkf with FV3reg module " ON) - else() - message("unkown ENKF_MODE: ${ENKF_MODE} !\nBuild the EnKF with GFS module by default") - option(BUILD_GFS "Build the Enkf with GFS module " ON) - option(BUILD_NMMB "Build the Enkf with NMMB module " OFF) - option(BUILD_WRF "Build the Enkf with WRF module " OFF) - option(BUILD_FV3reg "Build the Enkf with FV3reg module " OFF) - endif() - option(BUILD_UTIL "Build the Enkf utilities " OFF) - - option(BUILD_UTIL_COM "Build community utilities " OFF) - option(BUILD_ENKF_PREPROCESS_ARW "Build enkf preprocess for ARW " OFF) - option(BUILD_COV_CALC "Build the Desroziers utility" OFF) - option(BUILD_NCDIAG "Build the NCDIAG libraries" ON) - option(BUILD_FV3GFS_NCIO "Build the FV3GFS_NCIO library" ON) - option(BUILD_NCIO_UTIL "Build the NCIO Utilities" ON) - option(BUILD_NCDIAG_SERIAL "Build the serial NCDIAG libraries" ON) - option(BUILD_REG_TESTING "Build the Regression Testing Suite" ON) - option(BUILD_UNIT_TESTING "Build the Unit Testing Suite" OFF) - option(BUILD_GSDCLOUD_ARW "Build the GSD cloud analysis " OFF) - cmake_minimum_required(VERSION 3.16.1) - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") - SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) - SET(ARCHIVE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) - set(CMAKE_INCLUDE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/include") - set(CMAKE_INCLUDE_4_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/include4") - set(Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include") - set(CMAKE_Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include") - file(MAKE_DIRECTORY ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) - file(MAKE_DIRECTORY ${CMAKE_INCLUDE_4_OUTPUT_DIRECTORY}) - include(${CMAKE_SOURCE_DIR}/cmake/Modules/setPlatformVariables.cmake) - include(${CMAKE_SOURCE_DIR}/cmake/Modules/setIntelFlags.cmake) - include(${CMAKE_SOURCE_DIR}/cmake/Modules/setGNUFlags.cmake) - include(${CMAKE_SOURCE_DIR}/cmake/Modules/setPGIFlags.cmake) - include(${CMAKE_SOURCE_DIR}/cmake/Modules/setHOST.cmake) - include(${CMAKE_SOURCE_DIR}/cmake/Modules/platforms/Cheyenne.cmake) - include(${CMAKE_SOURCE_DIR}/cmake/Modules/platforms/Discover.cmake) - include(${CMAKE_SOURCE_DIR}/cmake/Modules/platforms/Generic.cmake) - include(${CMAKE_SOURCE_DIR}/cmake/Modules/platforms/Gaea.cmake) - include(${CMAKE_SOURCE_DIR}/cmake/Modules/platforms/Jet.cmake) - include(${CMAKE_SOURCE_DIR}/cmake/Modules/platforms/S4.cmake) - include(${CMAKE_SOURCE_DIR}/cmake/Modules/platforms/Hera.cmake) - include(${CMAKE_SOURCE_DIR}/cmake/Modules/platforms/Orion.cmake) - include(${CMAKE_SOURCE_DIR}/cmake/Modules/platforms/WCOSS-C.cmake) - include(${CMAKE_SOURCE_DIR}/cmake/Modules/platforms/WCOSS-D.cmake) - include(${CMAKE_SOURCE_DIR}/cmake/Modules/platforms/WCOSS.cmake) - if(BUILD_REG_TESTING) - set(CTEST_TEST_TIMEOUT 86400 ) - find_package(GSICONTROL) - include( CTest ) - endif(BUILD_REG_TESTING) - - cmake_policy(SET CMP0009 NEW) - cmake_policy(SET CMP0054 NEW) - cmake_policy(SET CMP0074 NEW) - if(CMAKE_VERSION EQUAL 3.20.2) - cmake_policy(SET CMP0110 NEW) - endif() - find_package(OpenMP) - message("found openmp with flag ${OPENMP_Fortran_FLAGS}") - -# Set Host specific flags and options - setHOST() - - MESSAGE(${CMAKE_CURRENT_SOURCE_DIR}) - # make sure that the default is a RELEASE - if (NOT CMAKE_BUILD_TYPE) - set (CMAKE_BUILD_TYPE RELEASE CACHE STRING - "Choose the type of build, options are: PRODUCTION Debug Release." - FORCE) - endif (NOT CMAKE_BUILD_TYPE) - - STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "RelWithDebInfo" BUILD_RELEASE) - STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "PRODUCTION" BUILD_PRODUCTION) - STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "PROFILE" BUILD_PROFILE) - if( BUILD_PRODUCTION ) - set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/exec ) - endif() - if( BUILD_PROFILE ) - set(CMAKE_SKIP_RPATH "TRUE") - if(NOT ENV{TAU_MAKEFILE}) - message("Must set TAU MAKEFILE environment variable to build in profiling mode") - exit() - endif() - endif() - - if(BUILD_GSDCLOUD_ARW) - set(GSDCLOUDOPT "-DRR_CLOUDANALYSIS" CACHE INTERNAL "" ) - else(BUILD_GSDCLOUD_ARW) - set( GSDCLOUDOPT "" CACHE INTERNAL "" ) - endif(BUILD_GSDCLOUD_ARW) - - set(CMAKE_Fortran_FLAGS_RELEASE "") - if (CMAKE_CXX_COMPILER_ID MATCHES "GNU*") - message("Setting GNU flags") - setGNU() - elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - message("Setting Intel flags") - setIntel() - elseif(CMAKE_C_COMPILER MATCHES "pgc*") - message("Setting PGI flags") - setPGI() - endif() +cmake_minimum_required(VERSION 3.20) +project(GSIApp + VERSION 1.0.0 + LANGUAGES C Fortran) - find_package(MPI REQUIRED) - message("MPI version is ${MPI_Fortran_VERSION}") - message("MPI f90 version is ${MPI_Fortran_HAVE_F90_MODULE}") - message("MPI f08 version is ${MPI_Fortran_HAVE_F08_MODULE}") +set(CMAKE_DIRECTORY_LABELS ${PROJECT_NAME}) - add_definitions(${MPI_Fortran_COMPILE_FLAGS}) - include_directories(${MPI_Fortran_INCLUDE_DIRS} ${MPI_INCLUDE_PATH} "./" ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) - link_directories(${MPI_Fortran_LIBRARIES} ${ARCHIVE_OUTPUT_PATH} ) -# if( (HOST-Discover) AND (NOT HOST-Generic)) - if( USE_BASELIBS ) - find_package(Baselibs REQUIRED) - else() - find_package( NetCDF COMPONENTS C Fortran REQUIRED) - endif() - if(( NOT HOST-WCOSS_D ) AND ( NOT HOST-WCOSS_C ) AND ( NOT HOST-Gaea ) ) - message(" trying to find lapack, ${host}") - find_package( LAPACK ) - endif() -# build the WRF I/O libraries - if(DEFINED ENV{WRF_IO_LIB}) - set(wrflib "$ENV{WRF_IO_LIB}" CACHE INTERNAL "WRFIO library" ) - else() - message("libsrc/wrflib not pulled from git, looking for WRF dependencies locally") - find_package( WRF ) - endif() - - # default installation - get_filename_component (default_prefix ".." ABSOLUTE) -# set (CMAKE_INSTALL_PREFIX ${default_prefix} CACHE STRING "set prefix" -# FORCE) - - - # FFLAGS depend on the compiler - get_filename_component (Fortran_COMPILER_NAME ${CMAKE_Fortran_COMPILER} NAME) - set(CFLAGS "-I. -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -O3 -Dfunder") - set (CMAKE_Fortran_INC_FLAGS "-I ./ -I ${CORE_INCS} -I ${NETCDF_INCLUDE_DIRS} ") - set (CFLAGS_N "-I. -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -O3 -Dfunder") +enable_testing() +include(GNUInstallDirs) +if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel)$") + message(STATUS "Setting build type to 'Release' as none was specified.") + set(CMAKE_BUILD_TYPE + "Release" + CACHE STRING "Choose the type of build." FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") +endif() - if(BUILD_CORELIBS ) - message("setting values for corelibs") - set(BUILD_BACIO "ON" CACHE STRING "Build the BACIO library" ) - set(BUILD_BUFR "ON" CACHE STRING "Build the BUFR library" ) - set(BUILD_SFCIO "ON" CACHE STRING "Build the SFCIO library" ) - set(BUILD_SIGIO "ON" CACHE STRING "Build the SIGIO library" ) - set(BUILD_NEMSIO "ON" CACHE STRING "Build the NEMSIO library" ) - set(BUILD_SP "ON" CACHE STRING "Build the SP library" ) - set(BUILD_CRTM "ON" CACHE STRING "Build the CRTM library" ) - set(BUILD_W3EMC "ON" CACHE STRING "Build the EMC library" ) - set(BUILD_NCO "ON" CACHE STRING "Build the NCO library" ) - endif() - find_package( BACIO ) - find_package( BUFR ) - find_package( SIGIO ) - find_package( NEMSIO ) - find_package( CRTM ) - find_package( SP ) - find_package( SFCIO ) - find_package( W3EMC ) - find_package( W3NCO ) - find_package( IP ) +if(NOT CMAKE_C_COMPILER_ID MATCHES "^(GNU|Intel|Clang|AppleClang)$") + message(WARNING "${CMAKE_C_COMPILER_ID} is not supported.") +endif() - if(BUILD_NCDIAG) - set(NCDIAG_INCS "${PROJECT_BINARY_DIR}/src/ncdiag/include") - add_subdirectory(src/ncdiag) - set(NCDIAG_LIBRARIES ncdiag ) - endif(BUILD_NCDIAG) - if(BUILD_FV3GFS_NCIO) - set(FV3GFS_NCIO_INCS "${PROJECT_BINARY_DIR}/src/fv3gfs_ncio/include") - add_subdirectory(src/fv3gfs_ncio) - set(FV3GFS_NCIO_LIBRARIES fv3gfs_ncio ) - endif(BUILD_FV3GFS_NCIO) - if(BUILD_NCIO_UTIL) - add_subdirectory(util/netcdf_io) - endif(BUILD_NCIO_UTIL) +if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU|Intel)$") + message(WARNING "${CMAKE_Fortran_COMPILER_ID} is not supported.") +endif() - find_package( BACIO ) - find_package( BUFR ) - find_package( SIGIO ) - find_package( NEMSIO ) - find_package( CRTM ) - find_package( SP ) - find_package( SFCIO ) - find_package( W3EMC ) - find_package( W3NCO ) - find_package( IP ) +# User options +option(OPENMP "Enable OpenMP Threading" OFF) +option(ENABLE_MKL "Use MKL for LAPACK implementation (if available)" ON) +option(BUILD_NCDIAG "Build GSI NetCDF Diagnostic Library" ON) +option(BUILD_GSDCLOUD "Build GSD Cloud Analysis Library" OFF) +option(BUILD_GSI "Build GSI" ON) +option(BUILD_ENKF "Build EnKF" ON) +option(BUILD_UTIL "Build Utilities" ON) +option(BUILD_REG_TESTING "Build the Regression Testing Suite" OFF) + +# Echo user options +message(STATUS "OPENMP ................. ${OPENMP}") +message(STATUS "ENABLE_MKL ............. ${ENABLE_MKL}") +message(STATUS "BUILD_NCDIAG ........... ${BUILD_NCDIAG}") +message(STATUS "BUILD_GSDCLOUD ......... ${BUILD_GSDCLOUD}") +message(STATUS "BUILD_GSI .............. ${BUILD_GSI}") +message(STATUS "BUILD_ENKF ............. ${BUILD_ENKF}") +message(STATUS "BUILD_UTIL ............. ${BUILD_UTIL}") +message(STATUS "BUILD_REG_TESTING ...... ${BUILD_REG_TESTING}") + +# Build components +add_subdirectory(src) + +if(BUILD_UTIL) + add_subdirectory(util) +endif() - if(BUILD_GSDCLOUD_ARW) - set(GSDCLOUD_DIR "${CMAKE_SOURCE_DIR}/src/GSD/gsdcloud") - set(gsdcloud gsdcloud_arw) - add_subdirectory(src/GSD/gsdcloud) - set(GSDCLOUD_LIBRARY ${gsdcloud} ) - else(BUILD_GSDCLOUD_ARW) - set(GSDCLOUD_LIBRARY "") - endif(BUILD_GSDCLOUD_ARW) +if(BUILD_REG_TESTING) + add_subdirectory(regression) +endif() - add_subdirectory(src/gsi) - if(BUILD_ENKF) - add_subdirectory(src/enkf) - endif(BUILD_ENKF) - if(BUILD_UTIL) - add_subdirectory(util/EnKF/gfs/src) - add_subdirectory(util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_horiz.fd) - add_subdirectory(util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_time.fd) - add_subdirectory(util/Radiance_Monitor/nwprod/radmon_shared/sorc/verf_radang.fd) - add_subdirectory(util/Radiance_Monitor/nwprod/radmon_shared/sorc/verf_radbcoef.fd) - add_subdirectory(util/Radiance_Monitor/nwprod/radmon_shared/sorc/verf_radbcor.fd) - add_subdirectory(util/Radiance_Monitor/nwprod/radmon_shared/sorc/verf_radtime.fd) - add_subdirectory(util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_lev.fd) - add_subdirectory(util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_mandlev.fd) - add_subdirectory(util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfc.fd) - add_subdirectory(util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfctime.fd) - add_subdirectory(util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sig.fd) - add_subdirectory(util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_time.fd) - endif(BUILD_UTIL) - find_package( NDATE ) - if( NOT NDATE ) - add_subdirectory(util/ndate) - endif() - if(BUILD_ENKF_PREPROCESS_ARW) - add_subdirectory(util/EnKF/arw/src) - endif(BUILD_ENKF_PREPROCESS_ARW) - if(BUILD_UTIL_COM) - add_subdirectory(util/Analysis_Utilities/read_diag) - add_subdirectory(util/radar_process/radialwind) - add_subdirectory(util/radar_process/reflectivity) - add_subdirectory(util/bufr_tools) - endif(BUILD_UTIL_COM) - if(BUILD_COV_CALC) - add_subdirectory(util/Correlated_Obs) - endif (BUILD_COV_CALC) - if(BUILD_UNIT_TESTING) - set(CTEST_TEST_TIMEOUT 400 ) - find_package(GSICONTROL) - include( CTest ) - add_subdirectory(unit-tests) - endif(BUILD_UNIT_TESTING) - if(BUILD_REG_TESTING) - if(USE_BASELINE) - set(BASELINE_FLAG "1") - else() - set(BASELINE_FLAG "0") - endif(USE_BASELINE) - if(USE_WRF) - file(WRITE "${PROJECT_BINARY_DIR}/regression_var.out" "${CMAKE_SOURCE_DIR}/regression/regression_var.sh ${host} ${CMAKE_SOURCE_DIR}/.. ${PROJECT_BINARY_DIR} ${CMAKE_SOURCE_DIR} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${GSIEXEC} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${ENKFEXEC} ${GSICONTROL} ${ENKFCONTROL} ${BASELINE_FLAG} ") - set( REG_TEST_NAMES "global_T62;global_T62_ozonly;global_4dvar_T62;global_4denvar_T126;global_fv3_4denvar_T126;;global_fv3_4denvar_C192;global_lanczos_T62;arw_netcdf; - arw_binary;nmm_binary;nmm_netcdf;nmmb_nems_4denvar;hwrf_nmm_d2;hwrf_nmm_d3;rtma;global_enkf_T62;netcdf_fv3_regional;global_C96_fv3aero;global_C96_fv3aerorad") - else() - file(WRITE "${PROJECT_BINARY_DIR}/regression_var.out" "${CMAKE_SOURCE_DIR}/regression/regression_var.sh ${host} ${CMAKE_SOURCE_DIR}/.. ${PROJECT_BINARY_DIR} ${CMAKE_SOURCE_DIR} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${GSIEXEC} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${ENKFEXEC} ${GSICONTROL} ${ENKFCONTROL} ${BASELINE_FLAG} ") - set( REG_TEST_NAMES "global_T62;global_T62_ozonly;global_4dvar_T62;global_lanczos_T62;global_nemsio_T62;global_C96_fv3aero;global_C96_fv3aerorad") - endif() - foreach( REG_TEST ${REG_TEST_NAMES} ) - add_test(NAME ${REG_TEST} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/regression COMMAND regression_driver.sh ${REG_TEST} ${PROJECT_BINARY_DIR}) - endforeach( REG_TEST ) - set_tests_properties( ${REG_TEST_NAMES} PROPERTIES TIMEOUT 86400 ) - endif() +#add_subdirectory(unit-tests) diff --git a/INSTALL.md b/INSTALL.md new file mode 100644 index 0000000000..3e573c9efd --- /dev/null +++ b/INSTALL.md @@ -0,0 +1,117 @@ +## Build and Install Instructions +--- + +### Prerequisites +A supported C and Fortran compiler (see table below). Other versions may work, in particular if close to the versions listed below. + +| Compiler vendor | Supported (tested) versions | +|-----------------|------------------------------------------------------------| +| Intel | 18.0.3.222 and above | +| GNU | 10.3.0 and above | + +A supported MPI library (see table below). Other versions may work, in particular if close to the versions listed below. + +| MPI library | Supported (tested) versions | +|-----------------|------------------------------------------------------------| +| MPICH | 3.3.1 and above | +| Open MPI | 3.1.5 and above | +| Intel MPI | 2018.0.4 and above | + +Third-party libraries (TPL) compiled with the same compiler and MPI library (where applicable). + +| Library | Supported (tested) versions | +|-----------------|------------------------------------------------------------| +| CMake | 3.20.1 and above | +| HDF5 | 1.10.4 and above | +| NetCDF-C | 4.7.3 and above | +| NetCDF-Fortran | 4.5.2 and above | + +NCEP Libraries (NCEPLibs) compiled with the same compiler and MPI library (where applicable). + +| Library | Supported (tested) versions | +|-----------------|------------------------------------------------------------| +| BUFR | 11.4.0 and above | +| CRTM | 2.3.0 and above | +| IP | 3.3.3 and above | +| SP | 2.3.3 and above | +| BACIO | 2.4.1 and above | +| W3EMC | 2.9.1 and above | +| SIGIO | 2.3.2 and above | +| SFCIO | 1.4.1 and above | +| NEMSIO | 2.5.2 and above | +| NCIO | 1.0.0 and above | +| WRF_IO | 1.2.0 and above | + +### Building the GSI + +`CMake` employs an out-of-source build. Create a directory for configuring the build and cd into it: + +```bash +mkdir -p build && cd build +``` + +Set the compilers, if needed, to match those being used for compiling the TPL and NCEPLibs listed above: `CC` and `FC` environment variables can be used to point to the desired C and Fortran compilers. + +Execute `cmake` from inside your build directory. + +```bash +cmake -DCMAKE_INSTALL_PREFIX= /path/to/GSI-source +``` + +If the dependencies are not located in a path recognized by `cmake` e.g. `/usr/local`, it may be necessary to provide the appropriate environment variables e.g. `` or `CMAKE_PREFIX_PATH` so that `cmake` is able to locate these dependencies. + +The installation prefix for GSI is provided by the `cmake` command-line argument `-DCMAKE_INSTALL_PREFIX=` + +To build and install: + +``` +make -j +make install +``` + +### CMake Options + +CMake allows for various options that can be specified on the command line via `-DCMAKE_OPTION=VALUE` or from within the ccmake gui. The list of options currently available is as follows: + +| Option | Description (Default) | +|---------------------|--------------------------------------------------------| +| `OPENMP` | Enable OpenMP Threading (`OFF`) | +| `ENABLE_MKL` | Use MKL (`ON`), If not found use LAPACK | +| `BUILD_NCDIAG` | Build GSI NetCDF Diagnostics Library (`ON`) | +| `BUILD_GSDCLOUD` | Build GSD Cloud Library (`OFF`) | +| `BUILD_GSI` | Build GSI library and executable (`ON`) | +| `BUILD_ENKF` | Build EnKF library and executable (`ON`) | +| `BUILD_REG_TESTING` | Enable Regression Testing (`ON`) | +| `BUILD_UTIL` | Build Utilities (`ON`) | +| `BUILD_UTIL_ALL` | Build All Utilities (`OFF`) | +| `BUILD_UTIL_AERODA` | Build Aerosol DA utility (`OFF`) | +| `BUILD_UTIL_COV_CALC` | Build Correlated Obs. Error utility (`OFF`) | +| `BUILD_UTIL_EFSOI` | Build Ensemble FSOI application (`OFF`) | +| `BUILD_UTIL_ENKF_GFS` | Build GFS ensemble utilities (`OFF`) | +| `BUILD_UTIL_ENKF_ARW` | Build ARW ensemble utilities (`OFF`) | +| `BUILD_UTIL_MON` | Build Observation Monitoring utilities (`OFF`) | +| `BUILD_UTIL_NCIO` | Build NetCDF IO utilities (`OFF`) | +| `BUILD_UTIL_COM` | Build Miscellaneous community utilities (`OFF`) | +| `BUILD_UTIL_BKGERR` | Build Background Error utility (`OFF`) | +| `BUILD_UTIL_ETC` | Build Miscellaneous utilities (`OFF`) | + +The flavor of GSI and EnKF can be defined with the use of the following options: + +| CMake Option | Description (Default) | Valid Options | +|---------------------|------------------------------|--------------------------------| +| `GSI_MODE` | GSI application mode (`GFS`) | `GFS`, `Regional` | +| `ENKF_MODE` | EnKF application mode (`GFS`)| `GFS`, `WRF`, `NMMB`, `FV3REG` | + +### Regression Testing + +When Regression tests are enabled (`-DBUILD_REG_TESTING=ON`), it is necessary to provide +the path to search for the control GSI and EnKF executables. This can be provided with the option `CONTROLPATH`. Other search variables are `GSICONTROLPATH` or `ENKFCONTROLPATH` for GSI and EnKF control executables respectively. + +If the control executables are not found, the Regression tests will be disabled. + +Once the build is complete and control executables have been found, regression testing can be launched from the build directory by executing: +```bash +ctest +``` + +Refer to the `ctest` manual for more information on `ctest` framework. diff --git a/README.cmake b/README.cmake deleted file mode 100644 index 52779c300d..0000000000 --- a/README.cmake +++ /dev/null @@ -1,145 +0,0 @@ -Quick start-- - -load desired compilers (intel recommended), desired mpi libraries/compilers, netcdf library (and hdf5 library for netcdf4) - -skip the following section unless you are compiling on a different machine or wish to link in special libraries ----------------------------------- -If not on WCOSS, Theia, or S4, ensure that the environment flags CC, CXX, and FC all point to to the C, C++, and Fortran compilers respectively - -If building on a machine other than WCOSS, Theia, or S4, several additional environment variables need to be set-- - COREPATH should be set to the root path where the core libraries are located (i.e. /nwprod/lib ) - WRFPATH should be set to the root path where WRF is install (i.e. /nwprod/sorc/wrf_shared.f ) - If libraries are in these locations, they should all be found once these environment variables are set. Please note that this is all done - automatically on WCOSS, Theia, and S4. - - Alternatively, any (or every) core library can also be specified via environment variable. So, if a desired library is in an unusual location - such as a user's home directory, it can be found by specifying the location like-- - export CRTM_LIB=/home/myname/MyCRTM/libcrtm.a (for csh and tcsh-- setenv CRTM_LIB /home/myname/MyCRTM/libcrtm.a ) - other library environment variable names are BACIO_LIB, BUFR_LIB, NEMSIO_LIB, SIGIO_LIB, SFCIO_LIB, SP_LIB, W3NCO_LIB W3EMC_LIB ---------------------------------- - - -Create a build directory somewhere outside the source tree. -cd to the build directory -run-- - - cmake (path-to-source-tree) - make -j 8 - -The above should find all the dependent libraries (tested on wcoss, theia and s4) and build the base gsi executable which will be -called gsi.x and located in the (build-dir)/bin directory. - ----- - -Detailed instructions - -CMake allows for various options that can be specified on the command line or from within the ccmake gui. The list of options -currently available is as follows-- - -BUILD_ENKF -- will build the enkf executable (default is ON) -BUILD_CORELIBS -- will attempt to find the source and build all the core libraries (nemsio, sigio, sfcio, sp, bacio, bufr, w3emc, w3nco crtm) -BUILD_GLOBAL -- will build GSI without WRF dependencies (default is OFF) -USE_WRF -- will build GSI with WRF dependencies (default is ON) -BUILD_REG_TESTING -- will build GSI with regression testing built in (default is ON) -BUILD_GFS -- will build ENKF using GFS (default is ON) -BUILD_WRF -- will build ENKF using WRF (default is OFF) -BUILD_NMMB -- will build ENKF using NMMB (default is OFF) - -If CMake cannot find the source for a given library (should not be a problem on WCOSS, Theia, or S4), the location may be specified via -environment variable. The names of those variables is as follows-- - BACIO_SRC - CRTM_SRC - BUFR_SRC - NEMSIO_SRC - SIGIO_SRC - SFCIO_SRC - SP_SRC - W3NCO_SRC - W3EMC_SRC -If specified, these variables should point to the the actual directory containing the source (i.e. export BACIO_SRC=/nwprod2/lib/bacio/v2.0.2/src ) -If the modules for the libraries are loaded on WCOSS, they will automatically be detected by CMake - -If BUILD_CORELIBS is turned on, individual libraries can be turned off using -BUILD_CRTM -BUILD_SIGIO -BUILD_SFCIO -BUILD_NEMSIO -BUILD_SP -BUILD_BUFR -BUILD_BACIO -BUILD_NCO -BUILD_EMC - -An example of configuring the GSI model to compile along with all the core libraries and the ENKF executable using WRF would be as follows - -cmake -DBUILD_WRF=ON -DBUILD_CORELIBS=ON (path-to-source-tree) - -Building only the GSI, ENKF and CRTM executables/library can be done as follows-- - -cmake -DBUILD_ENKF=ON -DBUILD_CORELIBS=ON -DBUILD_BACIO=OFF -DBUILD_SP=OFF -DBUILD_NEMSIO=OFF -DBUILD_NCO=OFF -DBUILD_EMC=OFF -DBUILD_SFCIO=OFF -DBUILD_SIGIO=OFF -DBUILD_BUFR=OFF (path-to-source-tree) - -If the core libraries desired are not located in the traditional paths, a hint can be provided to cmake via the environment variable $COREPATH. Similarly, -the environment variable $WRFPATH can give cmake a hint to find the WRF libraries and associated files (pack_utils.o, module_machine.o) - -------------- - -Using the ccmake utility - -ccmake is a text-based front end to cmake. It can be launched with the same syntax as cmake, but will provide the user with feedback and requests for more -instructions. A typical usage would be as follows-- - -from the build directory-- - -ccmake (path_to_source_tree) - -(from the menu at the bottom--press c to configure) - -Some stdout will show up on the screen and the menu will offer "Press [e] to exit help" -Press e - -Press c to configure - -(the above steps might have to be repeated) - -With no errors, the " Press [g] to generate and exit" option should show up in the menu section -Press g to generate a CMakeCache.txt file - -This should exit ccmake and leave you in the build directory. -Type make -j n to commence the parallel build (where n is the number of cores to use) -- 4 may be around the maximum number that can be utilized currently - ------ - -Background on cmake and associated files---- - -cmake and ccmake create a file called "CMakeCache.txt" and a directory called CMakeFiles in the build directory. -The CMakeCache.txt file can be edited using a text editor or by re-running ccmake and changing some of the configurations there. -In some cases, cmake will not be able to "re-find" various libraries because of conflicts in the CMakeFiles directory. If this appears to be -happening, remove CMakeCache.txt and CMakeFiles and re-run cmake/ccmake with a fresh set of requested options. - -It is also important to note that when run from the build directory, cmake will not modify any source files and it is safe to delete the entire build -tree and start over at any time. The GSI cmake build system has also been set up not to allow for in-source builds. - -Once cmake or ccmake have been run initially by pointing to the source tree, ccmake can be re-run with "ccmake ." -When run in this fashion, it will simply read the CMakeCache.txt file and allow a user to edit the desired options - ------ - -Regression Testing on WCOSS and Theia - -CMake will attempt to locate a control executable (gsi.x or global_gsi) somewhere in your source code treee. It is currently designed to look in -your source tree (up to two levels above the branch) as well as in Michael Lueken's directory. If it cannot find an executable, you can still -define the location inside the CMakeCache.txt file in your build directory. The name of the variable is GSICONTROL and it needs a full path to -the executable. - -Once a control has been found and the build is complete, regression testing can be launched by running "make test" or "ctest" from the build directory. -When run as simply "make test" or "ctest", the tests will run one at a time. However, the tests can be launched in parallel by adding the "-j N" argument -as such-- - make test "ARGS= -j N" - ctest -j N - -where N is the number of parallel jobs desired. Similarly, individual regression tests may be run by specifying them via the -I parameter. -For example, - - make test "ARGS= -I 12" - -will run only the hwrf_nmm_d2 test. See "man ctest" for further details. diff --git a/cmake/Modules/FindBACIO.cmake b/cmake/Modules/FindBACIO.cmake deleted file mode 100644 index 205f7d3157..0000000000 --- a/cmake/Modules/FindBACIO.cmake +++ /dev/null @@ -1,22 +0,0 @@ -# This module defines -# CORE_INCS -# List of include file paths for all required modules for GSI -# CORE_LIBRARIES -# Full list of libraries required to link GSI executable -if(DEFINED ENV{BACIO_VER}) - set(BACIO_VER $ENV{BACIO_VER}) - STRING(REGEX REPLACE "v" "" BACIO_VER ${BACIO_VER}) -endif() -if(NOT BUILD_BACIO ) - if(DEFINED ENV{BACIO_LIB4}) - set(BACIO_LIBRARY $ENV{BACIO_LIB4} ) - endif() -endif() -if( CORE_LIBRARIES ) - list( APPEND CORE_LIBRARIES ${BACIO_LIBRARY} ) -else() - set( CORE_LIBRARIES ${BACIO_LIBRARY} ) -endif() - -set( BACIO_LIBRARY_PATH ${BACIO_LIBRARY} CACHE STRING "BACIO Library Location" ) - diff --git a/cmake/Modules/FindBUFR.cmake b/cmake/Modules/FindBUFR.cmake deleted file mode 100644 index ce6da34e71..0000000000 --- a/cmake/Modules/FindBUFR.cmake +++ /dev/null @@ -1,24 +0,0 @@ -# This module defines -# CORE_INCS -# List of include file paths for all required modules for GSI -# CORE_LIBRARIES -# Full list of libraries required to link GSI executable -if(DEFINED ENV{BUFR_VER}) - set(BUFR_VER $ENV{BUFR_VER}) - STRING(REGEX REPLACE "v" "" BUFR_VER ${BUFR_VER}) -endif() - -set( NO_DEFAULT_PATH ) -if(NOT BUILD_BUFR ) - if(DEFINED ENV{BUFR_LIBd_DA} ) - set(BUFR_LIBRARY $ENV{BUFR_LIBd_DA} ) - message("BUFR library ${BUFR_LIBRARY} set via Environment variable") - endif() -endif() -if( CORE_LIBRARIES ) - list( APPEND CORE_LIBRARIES ${BUFR_LIBRARY} ) -else() - set( CORE_LIBRARIES ${BUFR_LIBRARY} ) -endif() -set( BUFR_LIBRARY_PATH ${BUFR_LIBRARY} CACHE STRING "BUFR Library Location" ) - diff --git a/cmake/Modules/FindBaselibs.cmake b/cmake/Modules/FindBaselibs.cmake deleted file mode 100644 index 793cb9a5d4..0000000000 --- a/cmake/Modules/FindBaselibs.cmake +++ /dev/null @@ -1,68 +0,0 @@ -if (NOT BASEDIR) - if(${COMPILER_TYPE} STREQUAL "intel" ) - string(REGEX MATCH "mpt" MPT ${MPI_Fortran_INCLUDE_PATH}) - string(REGEX MATCH "impi" IMPI ${MPI_Fortran_INCLUDE_PATH}) - message("REGEX returns ${MPT} ") - if( MPT MATCHES "mpt" ) - message("setting mpt paths ") - set(BASEDIR "/discover/swdev/mathomp4/Baselibs/GMAO-Baselibs-5_0_2/x86_64-unknown-linux-gnu/ifort_15.0.2.164-mpt_2.14/Linux") - elseif( IMPI MATCHES "impi" ) - set(BASEDIR "/discover/swdev/mathomp4/Baselibs/GMAO-Baselibs-5_0_2/x86_64-unknown-linux-gnu/ifort_16.0.3.210-intelmpi_5.1.3.210/Linux") - else() - message (FATAL_ERROR "ERROR: Could not find matching BASELIBS Must specify a value for BASEDIR with cmake ... -DBASEDIR=.") - endif() - message("compiler version is ${COMPILER_VERSION}") - endif() - if(${COMPILER_TYPE} STREQUAL "gnu" ) - string(REGEX MATCH "openmpi" OPENMPI ${MPI_Fortran_INCLUDE_PATH}) - message("REGEX returns ${OPENMPI} ") - if( OPENMPI MATCHES "openmpi" ) - message("setting openmpi paths ") - set(BASEDIR "/discover/swdev/mathomp4/Baselibs/GMAO-Baselibs-4_0_8/x86_64-unknown-linux-gnu/gfortran_7.2.0-openmpi_3.0.0/Linux") - else() - message (FATAL_ERROR "ERROR: Could not find matching BASELIBS Must specify a value for BASEDIR with cmake ... -DBASEDIR=.") - endif() - message("compiler version is ${COMPILER_VERSION}") - endif() - if(${COMPILER_TYPE} STREQUAL "pgi" ) - string(REGEX MATCH "openmpi" OPENMPI ${MPI_Fortran_INCLUDE_PATH}) - if( OPENMPI MATCHES "openmpi" ) - set(BASEDIR "/discover/swdev/mathomp4/Baselibs/GMAO-Baselibs-5_0_1/x86_64-unknown-linux-gnu/pgfortran_16.5-openmpi_1.10.3/Linux") - else() - message (FATAL_ERROR "ERROR: Could not find matching BASELIBS Must specify a value for BASEDIR with cmake ... -DBASEDIR=.") - endif() - message("compiler version is ${COMPILER_VERSION}") - endif() -endif () -if (ESMA_SDF) - message (FATAL_ERROR "ERROR: -hdf option was thought to be obsolete when CMake was crafted.") -endif () - -link_directories (${BASEDIR}/lib) - -#------------------------------------------------------------------ -# netcdf -# The following command provides the list of libraries that netcdf -# uses. Unfortunately it also includes the library path and "-l" -# prefixes, which CMake handles in a different manner. So we need so -# strip off that item from the list -execute_process ( - COMMAND ${BASEDIR}/bin/nf-config --flibs - OUTPUT_VARIABLE LIB_NETCDF - ) - -string(REGEX MATCHALL " -l[^ ]*" _full_libs "${LIB_NETCDF}") -set (NETCDF_LIBRARIES) -foreach (lib ${_full_libs}) - string (REPLACE "-l" "" _tmp ${lib}) - string (STRIP ${_tmp} _tmp) - list (APPEND NETCDF_LIBRARIES ${_tmp}) -endforeach() -#------------------------------------------------------------------ - -list(APPEND NETCDF_INCLUDES ${BASEDIR}/include/netcdf) -list(APPEND NETCDF_INCLUDES ${BASEDIR}/include/hdf5) - -message(STATUS "NETCDF_INCLUDES: ${NETCDF_INCLUDES}") -message(STATUS "NETCDF_LIBRARIES: ${NETCDF_LIBRARIES}") - diff --git a/cmake/Modules/FindCORELIBS.cmake b/cmake/Modules/FindCORELIBS.cmake deleted file mode 100644 index f653f758dc..0000000000 --- a/cmake/Modules/FindCORELIBS.cmake +++ /dev/null @@ -1,156 +0,0 @@ -# This module defines -# CORE_INCS -# List of include file paths for all required modules for GSI -# CORE_LIBRARIES -# Full list of libraries required to link GSI executable -if(DEFINED ENV{BUFR_VER}) - set(BUFR_VER $ENV{BUFR_VER}) - STRING(REGEX REPLACE "v" "" BUFR_VER ${BUFR_VER}) -endif() -if(DEFINED ENV{NEMSIO_VER}) - set(NEMSIO_VER $ENV{NEMSIO_VER}) - STRING(REGEX REPLACE "v" "" NEMSIO_VER ${NEMSIO_VER}) -endif() -if(DEFINED ENV{SFCIO_VER}) - set(SFCIO_VER $ENV{SFCIO_VER}) - STRING(REGEX REPLACE "v" "" SFCIO_VER ${SFCIO_VER}) -endif() -if(DEFINED ENV{SIGIO_VER}) - set(SIGIO_VER $ENV{SIGIO_VER}) - STRING(REGEX REPLACE "v" "" SIGIO_VER ${SIGIO_VER}) -endif() -if(DEFINED ENV{SP_VER}) - set(SP_VER $ENV{SP_VER}) - STRING(REGEX REPLACE "v" "" SP_VER ${SP_VER}) -endif() -if(DEFINED ENV{W3EMC_VER}) - set(W3EMC_VER $ENV{W3EMC_VER}) - STRING(REGEX REPLACE "v" "" W3EMC_VER ${W3EMC_VER}) -endif() -if(DEFINED ENV{W3NCO_VER}) - set(W3NCO_VER $ENV{W3NCO_VER}) - STRING(REGEX REPLACE "v" "" W3NCO_VER ${W3NCO_VER}) -endif() - -set (CORE_DEPS " ") -set( NO_DEFAULT_PATH ) -if(NOT BUILD_EMC ) - if(DEFINED ENV{W3EMC_LIBd} ) - set(W3EMC_LIBRARY $ENV{W3EMC_LIBd} ) - set(W3EMCINC $ENV{W3EMC_INCd} ) - endif() -else() - set( libsuffix "_v${W3EMC_VER}${debug_suffix}" ) - set( W3EMC_LIBRARY "${LIBRARY_OUTPUT_PATH}/libw3emc${libsuffix}.a" CACHE STRING "W3EMC Library" ) - set( w3emc "w3emc${libsuffix}") - if( DEFINED ENV{W3EMC_SRC} ) - set( W3EMC_DIR $ENV{W3EMC_SRC} CACHE STRING "W3EMC Source Directory" ) - endif() -endif() -if(NOT BUILD_NCO ) - if(DEFINED ENV{W3NCO_LIBd} ) - set(W3NCO_LIBRARY $ENV{W3NCO_LIBd} ) - endif() -else() - if( DEFINED ENV{W3NCO_SRC} ) - set( W3NCO_DIR $ENV{W3NCO_SRC} CACHE STRING "W3NCO Source Directory" ) - endif() - set( libsuffix "_v${W3NCO_VER}${debug_suffix}" ) - set( W3NCO_LIBRARY "${LIBRARY_OUTPUT_PATH}/libw3nco${libsuffix}.a" CACHE STRING "W3NCO Library" ) - set( w3nco "w3nco${libsuffix}") -endif() -if(NOT BUILD_BUFR ) - if(DEFINED ENV{BUFR_LIBd_DA} ) - set(BUFR_LIBRARY $ENV{BUFR_LIBd_DA} ) - endif() -else() - if( DEFINED ENV{BUFR_SRC} ) - set( BUFR_DIR $ENV{BUFR_SRC} CACHE STRING "BUFR Source Directory" ) - endif() - set( libsuffix "_v${BUFR_VER}${debug_suffix}" ) - set( BUFR_LIBRARY "${LIBRARY_OUTPUT_PATH}/libbufr${libsuffix}.a" CACHE STRING "BUFR Library" ) - set( bufr "bufr${libsuffix}") -endif() -if(NOT BUILD_SFCIO ) - if(DEFINED ENV{SFCIO_LIB4} ) - set(SFCIO_LIBRARY $ENV{SFCIO_LIB4} ) - set(SFCIOINC $ENV{SFCIO_INC4} ) - endif() -else() - if( DEFINED ENV{SFCIO_SRC} ) - set( SFCIO_DIR $ENV{SFCIO_SRC} CACHE STRING "SFCIO Source Directory" ) - endif() - set( libsuffix "_v${SFCIO_VER}${debug_suffix}" ) - set( SFCIO_LIBRARY "${LIBRARY_OUTPUT_PATH}/libsfcio${libsuffix}.a" CACHE STRING "SFCIO Library" ) - set( sfcio "sfcio${libsuffix}") -endif() -if(NOT BUILD_SIGIO ) - if(DEFINED ENV{SIGIO_LIB4} ) - set(SIGIO_LIBRARY $ENV{SIGIO_LIB4} ) - set(SIGIOINC $ENV{SIGIO_INC4} ) - endif() -else() - if( DEFINED ENV{SIGIO_SRC} ) - set( SIGIO_DIR $ENV{SIGIO_SRC} CACHE STRING "SIGIO Source Directory" ) - endif() - set( libsuffix "_v${SIGIO_VER}${debug_suffix}" ) - set( SIGIO_LIBRARY "${LIBRARY_OUTPUT_PATH}/libsigio${libsuffix}.a" CACHE STRING "SIGIO Library" ) - set( sigio "sigio${libsuffix}") - set( CORE_DEPS "${CORE_DEPS} ${baseName}" ) -endif() -if(NOT BUILD_NEMSIO ) - if(DEFINED ENV{NEMSIO_LIB} ) - set(NEMSIO_LIBRARY $ENV{NEMSIO_LIB} ) - set(NEMSIOINC $ENV{NEMSIO_INC} ) - endif() -else() - if( DEFINED ENV{NEMSIO_SRC} ) - set( NEMSIO_DIR $ENV{NEMSIO_SRC} CACHE STRING "NEMSIO Source Directory" ) - endif() - set( libsuffix "_v${NEMSIO_VER}${debug_suffix}" ) - set( NEMSIO_LIBRARY "${LIBRARY_OUTPUT_PATH}/libnemsio${libsuffix}.a" CACHE STRING "NEMSIO Library" ) - set( nemsio "nemsio${libsuffix}") -endif() -if(NOT BUILD_SP ) - if(DEFINED ENV{SP_LIBd} ) - set(SP_LIBRARY $ENV{SP_LIBd} ) - endif() -else() - if( DEFINED ENV{SP_SRC} ) - set( SP_DIR $ENV{SP_SRC} CACHE STRING "SP Source Directory" ) - endif() - set( libsuffix "_v${SP_VER}${debug_suffix}" ) - set( SP_LIBRARY "${LIBRARY_OUTPUT_PATH}/libsp${libsuffix}.a" CACHE STRING "SP Library" ) - set( sp "sp${libsuffix}") -endif() - -if( CORE_LIBRARIES ) - list( APPEND CORE_LIBRARIES ${SFCIO_LIBRARY} ${SIGIO_LIBRARY} - ${NEMSIO_LIBRARY} ${SP_LIBRARY} ${W3NCO_LIBRARY} ${BUFR_LIBRARY} - ${W3EMC_LIBRARY} CACHE INTERNAL "List of Core libs" ) - list( APPEND CORE_INCS ${INCLUDE_OUTPUT_PATH} ${SFCIOINC} ${SIGIOINC} ${NEMSIOINC} ${W3EMCINC} ) -else() - set( CORE_LIBRARIES ${SFCIO_LIBRARY} ${SIGIO_LIBRARY} - ${NEMSIO_LIBRARY} ${SP_LIBRARY} ${W3NCO_LIBRARY} ${BUFR_LIBRARY} - ${W3EMC_LIBRARY} CACHE INTERNAL "List of Core libs" ) - set( CORE_INCS ${INCLUDE_OUTPUT_PATH} ${SFCIOINC} ${SIGIOINC} ${NEMSIOINC} ${W3EMCINC} ) -endif() - -set( BUFR_LIBRARY_PATH ${BUFR_LIBRARY} CACHE STRING "BUFR Library Location" ) - -set( SFCIO_LIBRARY_PATH ${SFCIO_LIBRARY} CACHE STRING "SFCIO Library Location" ) -set( SFCIO_INCLUDE_PATH ${SFCIOINC} CACHE STRING "SFCIO Include Location" ) - -set( SIGIO_LIBRARY_PATH ${SIGIO_LIBRARY} CACHE STRING "SIGIO Library Location" ) -set( SIGIO_INCLUDE_PATH ${SIGIOINC} CACHE STRING "SIGIO Include Location" ) - -set( W3NCO_LIBRARY_PATH ${W3NCO_LIBRARY} CACHE STRING "W3NCO Library Location" ) - -set( W3EMC_LIBRARY_PATH ${W3EMC_LIBRARY} CACHE STRING "W3EMC Library Location" ) -set( W3EMC_INCLUDE_PATH ${W3EMCINC} CACHE STRING "W3EMC Include Location" ) - -set( NEMSIO_LIBRARY_PATH ${NEMSIO_LIBRARY} CACHE STRING "NEMSIO Library Location" ) -set( NEMSIO_INCLUDE_PATH ${NEMSIOINC} CACHE STRING "NEMSIO Include Location" ) - -set( SP_LIBRARY_PATH ${SP_LIBRARY} CACHE STRING "SP Library Location" ) - diff --git a/cmake/Modules/FindCRTM.cmake b/cmake/Modules/FindCRTM.cmake deleted file mode 100644 index 41de09bba9..0000000000 --- a/cmake/Modules/FindCRTM.cmake +++ /dev/null @@ -1,33 +0,0 @@ -# This module defines -# CORE_INCS -# List of include file paths for all required modules for GSI -# CORE_LIBRARIES -# Full list of libraries required to link GSI executable -if(DEFINED ENV{CRTM_VER}) - set(CRTM_VER $ENV{CRTM_VER}) - STRING(REGEX REPLACE "v" "" CRTM_VER ${CRTM_VER}) -endif() - -set( NO_DEFAULT_PATH ) -if(NOT BUILD_CRTM ) - if(DEFINED ENV{CRTM_LIB} ) - set(CRTM_LIBRARY $ENV{CRTM_LIB} ) - set(CRTMINC $ENV{CRTM_INC} ) - message("CRTM library ${CRTM_LIBRARY} set via Environment variable") - endif() -endif() -if( CORE_LIBRARIES ) - list( APPEND CORE_LIBRARIES ${CRTM_LIBRARY} ) -else() - set( CORE_LIBRARIES ${CRTM_LIBRARY} ) -endif() - -if( CORE_INCS ) - list( APPEND CORE_INCS ${CRTMINC} ) -else() - set( CORE_INCS ${INCLUDE_OUTPUT_PATH} ${CRTMINC} ) -endif() - -set( CRTM_LIBRARY_PATH ${CRTM_LIBRARY} CACHE STRING "CRTM Library Location" ) -set( CRTM_INCLUDE_PATH ${CRTMINC} CACHE STRING "CRTM Include Location" ) - diff --git a/cmake/Modules/FindGSICONTROL.cmake b/cmake/Modules/FindGSICONTROL.cmake deleted file mode 100644 index 3e4bd7d7dc..0000000000 --- a/cmake/Modules/FindGSICONTROL.cmake +++ /dev/null @@ -1,54 +0,0 @@ -# - Find the Control version of GSI to use for regression testing - -set( NO_DEFAULT_PATH ) -message("Control path is ${CONTROLPATH}") -find_file( CONTROL_EXE - NAMES gsi.x global_gsi ${GSIEXEC} - HINTS - ${CONTROLPATH} - ${CONTROLPATH}/bin - ${CONTROLPATH}/exec - $ENV{CONTROLPATH} - $ENV{CONTROLPATH}/bin - $ENV{CONTROLPATH}/exec - $ENV{CONTROLPATH}/src - ${CMAKE_SOURCE_DIR}/../trunk/src - ${CMAKE_SOURCE_DIR}/../../trunk/src - ${PROJECT_BINARY_DIR}/../build-trunk/bin - /da/save/Michael.Lueken/svn1/build/bin - /da/save/Michael.Lueken/svn1/src - /gpfs/dell2/emc/modeling/noscrub/Michael.Lueken/svn1/build/bin - /gpfs/hps3/emc/da/noscrub/Michael.Lueken/svn1/build/bin - /gpfs/hps3/emc/da/noscrub/Michael.Lueken/svn1/src - /scratch1/NCEPDEV/da/Michael.Lueken/svn1/build/bin - /lfs1/NESDIS/nesdis-rdo2/David.Huber/save/gsi_control/exec - - ${NO_DEFAULT_PATH}) - -set( GSICONTROL ${CONTROL_EXE} CACHE STRING "GSI control executable for regression testing" FORCE ) - -find_file( ENKF_CONTROL_EXE - NAMES enkf_gfs.x global_enkf ${ENKFEXEC} - HINTS - ${CONTROLPATH} - ${CONTROLPATH}/bin - ${CONTROLPATH}/exec - $ENV{CONTROLPATH} - $ENV{CONTROLPATH}/bin - $ENV{CONTROLPATH}/exec - ${CMAKE_SOURCE_DIR}/../trunk/src/enkf - ${PROJECT_BINARY_DIR}/../build-trunk/bin - $ENV{CONTROLPATH}/enkf - $ENV{CONTROLPATH}/src/enkf - /da/save/Michael.Lueken/svn1/build/bin - /da/save/Michael.Lueken/svn1/src/enkf - /gpfs/dell2/emc/modeling/noscrub/Michael.Lueken/svn1/build/bin - /gpfs/hps3/emc/da/noscrub/Michael.Lueken/svn1/build/bin - /gpfs/hps3/emc/da/noscrub/Michael.Lueken/svn1/src/enkf - /scratch1/NCEPDEV/da/Michael.Lueken/svn1/build/bin - /lfs1/NESDIS/nesdis-rdo2/David.Huber/save/gsi_control/exec - - ${NO_DEFAULT_PATH}) - -set( ENKFCONTROL ${ENKF_CONTROL_EXE} CACHE STRING "ENKF control executable for regression testing" FORCE ) - diff --git a/cmake/Modules/FindHDF5.cmake b/cmake/Modules/FindHDF5.cmake deleted file mode 100644 index 78e3db3678..0000000000 --- a/cmake/Modules/FindHDF5.cmake +++ /dev/null @@ -1,24 +0,0 @@ -# This extends CMake's FindHDF5.cmake to add support to include MPI include -# paths and libraries in the HDF5 ones if HDF5_IS_PARALLEL is ON -# (BUG #0014363). - -# include the default FindHDF5.cmake. -#if(CMAKE_VERSION VERSION_LESS 3.6.1) -if(CMAKE_VERSION VERSION_GREATER 3.0 ) - include(${CMAKE_CURRENT_LIST_DIR}/NewCMake/FindHDF5.cmake) -else() - include(${CMAKE_ROOT}/Modules/FindHDF5.cmake) -endif() -#endif() - -if(HDF5_FOUND AND (HDF5_IS_PARALLEL OR HDF5_ENABLE_PARALLEL)) - if(MPI_C_INCLUDE_PATH) - list(APPEND HDF5_INCLUDE_DIRS ${MPI_C_INCLUDE_PATH}) - endif() - if(MPI_C_LIBRARIES) - list(APPEND HDF5_LIBRARIES ${MPI_C_LIBRARIES}) - endif() - if(MPI_CXX_LIBRARIES) - list(APPEND HDF5_LIBRARIES ${MPI_CXX_LIBRARIES}) - endif() -endif() diff --git a/cmake/Modules/FindIP.cmake b/cmake/Modules/FindIP.cmake deleted file mode 100644 index baec28d683..0000000000 --- a/cmake/Modules/FindIP.cmake +++ /dev/null @@ -1,31 +0,0 @@ -# This module defines -# CORE_INCS -# List of include file paths for all required modules for GSI -# CORE_LIBRARIES -# Full list of libraries required to link GSI executable -if(DEFINED ENV{IP_VER}) - set(IP_VER $ENV{IP_VER}) - STRING(REGEX REPLACE "v" "" IP_VER ${IP_VER}) -endif() - -set( NO_DEFAULT_PATH ) -if(NOT BUILD_IP ) - if(DEFINED ENV{IP_LIBd} ) - set(IP_LIBRARY $ENV{IP_LIBd} ) - message("IP library ${IP_LIBRARY} set via Environment variable") - endif() - if(DEFINED ENV{IP_LIB4} ) - set(IP_4_LIBRARY $ENV{IP_LIB4} ) - message("IP 4 library ${IP_4_LIBRARY} set via Environment variable") - endif() -endif() -if( CORE_LIBRARIES ) - list( APPEND CORE_LIBRARIES ${IP_LIBRARY} ) -else() - set( CORE_LIBRARIES ${IP_LIBRARY} ) -endif() - - -set( IP_LIBRARY_PATH ${IP_LIBRARY} CACHE STRING "IP Library Location" ) -set( IP_4_LIBRARY_PATH ${IP_4_LIBRARY} CACHE STRING "IP_4 Library Location" ) - diff --git a/cmake/Modules/FindMPI.cmake b/cmake/Modules/FindMPI.cmake deleted file mode 100644 index 8e0a0c95ba..0000000000 --- a/cmake/Modules/FindMPI.cmake +++ /dev/null @@ -1,18 +0,0 @@ -# This extends CMake's FindHDF5.cmake to add support to include MPI include -# paths and libraries in the HDF5 ones if HDF5_IS_PARALLEL is ON -# (BUG #0014363). - -# include the default FindMPI.cmake. -if(CMAKE_VERSION VERSION_LESS 3.1) - include(${CMAKE_ROOT}/Modules/FindMPI.cmake) -elseif(CMAKE_VERSION VERSION_LESS 3.6) - message("Using new FindMPI") - include(${CMAKE_CURRENT_LIST_DIR}/NewCMake/FindMPI.cmake) -# set(MPI_Fortran_INCLUDE_DIRS ${MPI_Fortran_INCLUDE_PATH} CACHE INTERNAL "Deprecated Variable Name") -else() - message("Using installed FindMPI") - include(${CMAKE_ROOT}/Modules/FindMPI.cmake) -# set(MPI_Fortran_INCLUDE_DIRS ${MPI_Fortran_INCLUDE_PATH} CACHE INTERNAL "Deprecated Variable Name") - message("include dirs are ${MPI_Fortran_INCLUDE_DIRS}") - message("include PATH ${MPI_Fortran_INCLUDE_PATH}") -endif() diff --git a/cmake/Modules/FindNDATE.cmake b/cmake/Modules/FindNDATE.cmake deleted file mode 100644 index 44bf4f1cd5..0000000000 --- a/cmake/Modules/FindNDATE.cmake +++ /dev/null @@ -1,13 +0,0 @@ -# - Find the NDATE utility or build it - -set( NO_DEFAULT_PATH ) -if(DEFINED ENV{NDATE}) - set(NDATE $ENV{NDATE} ) -else() - find_file( NDATE - NAMES ndate.x ndate - HINTS - /nwprod/util/exec - $ENV{NWPROD}/util/exec - ${NO_DEFAULT_PATH}) -endif() diff --git a/cmake/Modules/FindNEMSIO.cmake b/cmake/Modules/FindNEMSIO.cmake deleted file mode 100644 index d5550bb530..0000000000 --- a/cmake/Modules/FindNEMSIO.cmake +++ /dev/null @@ -1,33 +0,0 @@ -# This module defines -# CORE_INCS -# List of include file paths for all required modules for GSI -# CORE_LIBRARIES -# Full list of libraries required to link GSI executable -if(DEFINED ENV{NEMSIO_VER}) - set(NEMSIO_VER $ENV{NEMSIO_VER}) - STRING(REGEX REPLACE "v" "" NEMSIO_VER ${NEMSIO_VER}) -endif() - -set( NO_DEFAULT_PATH ) -if(NOT BUILD_NEMSIO ) - if(DEFINED ENV{NEMSIO_LIB} ) - set(NEMSIO_LIBRARY $ENV{NEMSIO_LIB} ) - set(NEMSIOINC $ENV{NEMSIO_INC} ) - message("NEMSIO library ${NEMSIO_LIBRARY} set via Environment variable") - endif() -endif() -if( CORE_LIBRARIES ) - list( APPEND CORE_LIBRARIES ${NEMSIO_LIBRARY} ) -else() - set( CORE_LIBRARIES ${NEMSIO_LIBRARY} ) -endif() - -if( CORE_INCS ) - list( APPEND CORE_INCS ${NEMSIOINC} ) -else() - set( CORE_INCS ${INCLUDE_OUTPUT_PATH} ${NEMSIOINC} ) -endif() - -set( NEMSIO_LIBRARY_PATH ${NEMSIO_LIBRARY} CACHE STRING "NEMSIO Library Location" ) -set( NEMSIO_INCLUDE_PATH ${NEMSIOINC} CACHE STRING "NEMSIO Include Location" ) - diff --git a/cmake/Modules/FindSFCIO.cmake b/cmake/Modules/FindSFCIO.cmake deleted file mode 100644 index c137e1ca16..0000000000 --- a/cmake/Modules/FindSFCIO.cmake +++ /dev/null @@ -1,37 +0,0 @@ -# This module defines -# CORE_INCS -# List of include file paths for all required modules for GSI -# CORE_LIBRARIES -# Full list of libraries required to link GSI executable -if(DEFINED ENV{SFCIO_VER}) - set(SFCIO_VER $ENV{SFCIO_VER}) - STRING(REGEX REPLACE "v" "" SFCIO_VER ${SFCIO_VER}) -endif() - -set( NO_DEFAULT_PATH ) -if(NOT BUILD_SFCIO ) - if(DEFINED ENV{SFCIO_LIB4} ) - set(SFCIO_LIBRARY $ENV{SFCIO_LIB4} ) - set(SFCIOINC $ENV{SFCIO_INC4} ) - message("SFCIO library ${SFCIO_LIBRARY} set via Environment variable") - elseif(DEFINED ENV{SFCIO_LIB} ) - set(SFCIO_LIBRARY $ENV{SFCIO_LIB} ) - set(SFCIOINC $ENV{SFCIO_INC} ) - message("SFCIO library ${SFCIO_LIBRARY} set via Environment variable") - endif() -endif() -if( CORE_LIBRARIES ) - list( APPEND CORE_LIBRARIES ${SFCIO_LIBRARY} ) -else() - set( CORE_LIBRARIES ${SFCIO_LIBRARY} ) -endif() - -if( CORE_INCS ) - list( APPEND CORE_INCS ${SFCIOINC} ) -else() - set( CORE_INCS ${INCLUDE_OUTPUT_PATH} ${SFCIOINC} ) -endif() - -set( SFCIO_LIBRARY_PATH ${SFCIO_LIBRARY} CACHE STRING "SFCIO Library Location" ) -set( SFCIO_INCLUDE_PATH ${SFCIOINC} CACHE STRING "SFCIO Include Location" ) - diff --git a/cmake/Modules/FindSIGIO.cmake b/cmake/Modules/FindSIGIO.cmake deleted file mode 100644 index 026c1f7921..0000000000 --- a/cmake/Modules/FindSIGIO.cmake +++ /dev/null @@ -1,38 +0,0 @@ -# This module defines -# CORE_INCS -# List of include file paths for all required modules for GSI -# CORE_LIBRARIES -# Full list of libraries required to link GSI executable -if(DEFINED ENV{SIGIO_VER}) - set(SIGIO_VER $ENV{SIGIO_VER}) - STRING(REGEX REPLACE "v" "" SIGIO_VER ${SIGIO_VER}) -endif() - -set( NO_DEFAULT_PATH ) -if(NOT BUILD_SIGIO ) - if(DEFINED ENV{SIGIO_LIB4} ) - set(SIGIO_LIBRARY $ENV{SIGIO_LIB4} ) - set(SIGIOINC $ENV{SIGIO_INC4} ) - message("SIGIO library ${SIGIO_LIBRARY} set via Environment variable") - elseif(DEFINED ENV{SIGIO_LIB} ) - set(SIGIO_LIBRARY $ENV{SIGIO_LIB} ) - set(SIGIOINC $ENV{SIGIO_INC} ) - message("SIGIO library ${SIGIO_LIBRARY} set via Environment variable") - endif() -endif() -if( CORE_LIBRARIES ) - list( APPEND CORE_LIBRARIES ${SIGIO_LIBRARY} ) -else() - set( CORE_LIBRARIES ${SIGIO_LIBRARY} ) -endif() - -if( CORE_INCS ) - list( APPEND CORE_INCS ${SIGIOINC} ) -else() - set( CORE_INCS ${INCLUDE_OUTPUT_PATH} ${SIGIOINC} ) -endif() - - -set( SIGIO_LIBRARY_PATH ${SIGIO_LIBRARY} CACHE STRING "SIGIO Library Location" ) -set( SIGIO_INCLUDE_PATH ${SIGIOINC} CACHE STRING "SIGIO Include Location" ) - diff --git a/cmake/Modules/FindSP.cmake b/cmake/Modules/FindSP.cmake deleted file mode 100644 index 2844870a93..0000000000 --- a/cmake/Modules/FindSP.cmake +++ /dev/null @@ -1,31 +0,0 @@ -# This module defines -# CORE_INCS -# List of include file paths for all required modules for GSI -# CORE_LIBRARIES -# Full list of libraries required to link GSI executable -if(DEFINED ENV{SP_VER}) - set(SP_VER $ENV{SP_VER}) - STRING(REGEX REPLACE "v" "" SP_VER ${SP_VER}) -endif() - -set( NO_DEFAULT_PATH ) -if(NOT BUILD_SP ) - if(DEFINED ENV{SP_LIBd} ) - set(SP_LIBRARY $ENV{SP_LIBd} ) - message("SP library ${SP_LIBRARY} set via Environment variable") - endif() - if(DEFINED ENV{SP_LIB4} ) - set(SP_4_LIBRARY $ENV{SP_LIB4} ) - message("SP library ${SP_4_LIBRARY} set via Environment variable") - endif() -endif() -if( CORE_LIBRARIES ) - list( APPEND CORE_LIBRARIES ${SP_LIBRARY} ) -else() - set( CORE_LIBRARIES ${SP_LIBRARY} ) -endif() - - -set( SP_LIBRARY_PATH ${SP_LIBRARY} CACHE STRING "SP Library Location" ) -set( SP_4_LIBRARY_PATH ${SP_4_LIBRARY} CACHE STRING "SP_4 Library Location" ) - diff --git a/cmake/Modules/FindW3EMC.cmake b/cmake/Modules/FindW3EMC.cmake deleted file mode 100644 index b87b4e7129..0000000000 --- a/cmake/Modules/FindW3EMC.cmake +++ /dev/null @@ -1,47 +0,0 @@ -# This module defines -# CORE_INCS -# List of include file paths for all required modules for GSI -# CORE_LIBRARIES -# Full list of libraries required to link GSI executable -if(DEFINED ENV{W3EMC_VER}) - set(W3EMC_VER $ENV{W3EMC_VER}) - set(W3EMCINC $ENV{W3EMC_INCd} ) - set(W3EMC4INC $ENV{W3EMC_INC4} ) - STRING(REGEX REPLACE "v" "" W3EMC_VER ${W3EMC_VER}) -endif() -if(DEFINED ENV{W3EMC_LIBd}) - set(W3EMC_LIBRARY $ENV{W3EMC_LIBd} ) - set(W3EMCINC $ENV{W3EMC_INCd} ) - set(W3EMC_4_LIBRARY $ENV{W3EMC_LIB4} ) - set(W3EMC4INC $ENV{W3EMC_INC4} ) - message("Setting W3EMC library via environment variable ${W3EMC_LIBRARY}") -endif() - -set( NO_DEFAULT_PATH ) -if((NOT BUILD_W3EMC ) AND ( NOT DEFINED W3EMC_LIBRARY )) - if(DEFINED ENV{W3EMC_LIB} ) - set(W3EMC_LIBRARY $ENV{W3EMC_LIB} ) - set(W3EMCINC $ENV{W3EMC_INC} ) - set(W3EMC_4_LIBRARY $ENV{W3EMC_LIB4} ) - set(W3EMC4INC $ENV{W3EMC_INC4} ) - message("W3EMC library ${W3EMC_LIBRARY} set via Environment variable") - message("W3EMC_4 library ${W3EMC_4_LIBRARY} set via Environment variable") - endif() -endif() -if( CORE_LIBRARIES ) - list( APPEND CORE_LIBRARIES ${W3EMC_LIBRARY} ) -else() - set( CORE_LIBRARIES ${W3EMC_LIBRARY} ) -endif() - -if( CORE_INCS ) - list( APPEND CORE_INCS ${W3EMCINC} ) -else() - set( CORE_INCS ${INCLUDE_OUTPUT_PATH} ${W3EMCINC} ) -endif() - -set( W3EMC_LIBRARY_PATH ${W3EMC_LIBRARY} CACHE STRING "W3EMC Library Location" ) -set( W3EMC_INCLUDE_PATH ${W3EMCINC} CACHE STRING "W3EMC Include Location" ) -set( W3EMC_4_LIBRARY_PATH ${W3EMC_4_LIBRARY} CACHE STRING "W3EMC_4 Library Location" ) -set( W3EMC_INCLUDE_4_PATH ${W3EMC4INC} CACHE STRING "W3EMC_4 Include Location" ) - diff --git a/cmake/Modules/FindW3NCO.cmake b/cmake/Modules/FindW3NCO.cmake deleted file mode 100644 index 0bdc184cc7..0000000000 --- a/cmake/Modules/FindW3NCO.cmake +++ /dev/null @@ -1,27 +0,0 @@ -# This module defines -# CORE_INCS -# List of include file paths for all required modules for GSI -# CORE_LIBRARIES -# Full list of libraries required to link GSI executable -if(DEFINED ENV{W3NCO_VER}) - set(W3NCO_VER $ENV{W3NCO_VER}) - STRING(REGEX REPLACE "v" "" W3NCO_VER ${W3NCO_VER}) -endif() - -set( NO_DEFAULT_PATH ) -if(NOT BUILD_W3NCO ) - if(DEFINED ENV{W3NCO_LIBd} ) - set(W3NCO_LIBRARY $ENV{W3NCO_LIBd} ) - set(W3NCO_4_LIBRARY $ENV{W3NCO_LIB4} ) - message("W3NCO library ${W3NCO_LIBRARY} set via Environment variable") - message("W3NCO_4 library ${W3NCO_4_LIBRARY} set via Environment variable") - endif() -endif() -if( CORE_LIBRARIES ) - list( APPEND CORE_LIBRARIES ${W3NCO_LIBRARY} ) -else() - set( CORE_LIBRARIES ${W3NCO_LIBRARY} ) -endif() - -set( W3NCO_LIBRARY_PATH ${W3NCO_LIBRARY} CACHE STRING "W3NCO Library Location" ) - diff --git a/cmake/Modules/FindWRF.cmake b/cmake/Modules/FindWRF.cmake deleted file mode 100644 index 43faf46643..0000000000 --- a/cmake/Modules/FindWRF.cmake +++ /dev/null @@ -1,36 +0,0 @@ -# - Find the WRF modules - -set( NO_DEFAULT_PATH ) -find_library( IOINT_LIB - NAMES libwrfio_int.a - HINTS - ${WRFPATH}/external/io_int - $ENV{WRFPATH}/external/io_int - /usr/local/jcsda/nwprod_gdas_2014/lib/sorc/nam_nmm_real_fcst.fd/external/io_int - /scratch3/NCEPDEV/nceplibs/ext/WRF/3.7/WRFV3/external/io_int - ${NO_DEFAULT_PATH}) - -find_library( WRFNETCDF_LIB - NAMES libwrfio_nf.a - HINTS - ${WRFPATH}/external/io_netcdf /usr/local/jcsda/nwprod_gdas_2014/lib/sorc/nam_nmm_real_fcst.fd/external/io_netcdf - $ENV{WRFPATH}/external/io_netcdf /usr/local/jcsda/nwprod_gdas_2014/lib/sorc/nam_nmm_real_fcst.fd/external/io_netcdf - /scratch3/NCEPDEV/nceplibs/ext/WRF/3.7/WRFV3/external/io_netcdf - ${NO_DEFAULT_PATH}) -find_file( FRAMEPACK - NAMES pack_utils.o - HINTS - ${WRFPATH}/frame /usr/local/jcsda/nwprod_gdas_2014/lib/sorc/nam_nmm_real_fcst.fd/frame - $ENV{WRFPATH}/frame /usr/local/jcsda/nwprod_gdas_2014/lib/sorc/nam_nmm_real_fcst.fd/frame - /scratch3/NCEPDEV/nceplibs/ext/WRF/3.7/WRFV3/frame - ${NO_DEFAULT_PATH}) -find_file( FRAMEMODULE - NAMES module_machine.o - HINTS - ${WRFPATH}/frame /usr/local/jcsda/nwprod_gdas_2014/lib/sorc/nam_nmm_real_fcst.fd/frame - $ENV{WRFPATH}/frame /usr/local/jcsda/nwprod_gdas_2014/lib/sorc/nam_nmm_real_fcst.fd/frame - /scratch3/NCEPDEV/nceplibs/ext/WRF/3.7/WRFV3/frame - ${NO_DEFAULT_PATH}) - -set( WRF_LIBRARIES ${IOINT_LIB} ${WRFNETCDF_LIB} ${FRAMEPACK} ${FRAMEMODULE} ) - diff --git a/cmake/Modules/NewCMake/CMakeParseArguments.cmake b/cmake/Modules/NewCMake/CMakeParseArguments.cmake deleted file mode 100644 index 7ee2bbacef..0000000000 --- a/cmake/Modules/NewCMake/CMakeParseArguments.cmake +++ /dev/null @@ -1,11 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#.rst: -# CMakeParseArguments -# ------------------- -# -# This module once implemented the :command:`cmake_parse_arguments` command -# that is now implemented natively by CMake. It is now an empty placeholder -# for compatibility with projects that include it to get the command from -# CMake 3.4 and lower. diff --git a/cmake/Modules/NewCMake/FindHDF5.cmake b/cmake/Modules/NewCMake/FindHDF5.cmake deleted file mode 100644 index fd8891cf20..0000000000 --- a/cmake/Modules/NewCMake/FindHDF5.cmake +++ /dev/null @@ -1,934 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#.rst: -# FindHDF5 -# -------- -# -# Find HDF5, a library for reading and writing self describing array data. -# -# -# -# This module invokes the HDF5 wrapper compiler that should be installed -# alongside HDF5. Depending upon the HDF5 Configuration, the wrapper -# compiler is called either h5cc or h5pcc. If this succeeds, the module -# will then call the compiler with the -show argument to see what flags -# are used when compiling an HDF5 client application. -# -# The module will optionally accept the COMPONENTS argument. If no -# COMPONENTS are specified, then the find module will default to finding -# only the HDF5 C library. If one or more COMPONENTS are specified, the -# module will attempt to find the language bindings for the specified -# components. The only valid components are C, CXX, Fortran, HL, and -# Fortran_HL. If the COMPONENTS argument is not given, the module will -# attempt to find only the C bindings. -# -# This module will read the variable -# HDF5_USE_STATIC_LIBRARIES to determine whether or not to prefer a -# static link to a dynamic link for HDF5 and all of it's dependencies. -# To use this feature, make sure that the HDF5_USE_STATIC_LIBRARIES -# variable is set before the call to find_package. -# -# To provide the module with a hint about where to find your HDF5 -# installation, you can set the environment variable HDF5_ROOT. The -# Find module will then look in this path when searching for HDF5 -# executables, paths, and libraries. -# -# Both the serial and parallel HDF5 wrappers are considered and the first -# directory to contain either one will be used. In the event that both appear -# in the same directory the serial version is preferentially selected. This -# behavior can be reversed by setting the variable HDF5_PREFER_PARALLEL to -# true. -# -# In addition to finding the includes and libraries required to compile -# an HDF5 client application, this module also makes an effort to find -# tools that come with the HDF5 distribution that may be useful for -# regression testing. -# -# This module will define the following variables: -# -# :: -# -# HDF5_FOUND - true if HDF5 was found on the system -# HDF5_VERSION - HDF5 version in format Major.Minor.Release -# HDF5_INCLUDE_DIRS - Location of the hdf5 includes -# HDF5_INCLUDE_DIR - Location of the hdf5 includes (deprecated) -# HDF5_DEFINITIONS - Required compiler definitions for HDF5 -# HDF5_LIBRARIES - Required libraries for all requested bindings -# HDF5_HL_LIBRARIES - Required libraries for the HDF5 high level API for all -# bindings, if the HL component is enabled -# -# Available components are: C CXX Fortran and HL. For each enabled language -# binding, a corresponding HDF5_${LANG}_LIBRARIES variable, and potentially -# HDF5_${LANG}_DEFINITIONS, will be defined. -# If the HL component is enabled, then an HDF5_${LANG}_HL_LIBRARIES will -# also be defined. With all components enabled, the following variables will be defined: -# -# :: -# -# HDF5_C_DEFINITIONS -- Required compiler definitions for HDF5 C bindings -# HDF5_CXX_DEFINITIONS -- Required compiler definitions for HDF5 C++ bindings -# HDF5_Fortran_DEFINITIONS -- Required compiler definitions for HDF5 Fortran bindings -# HDF5_C_INCLUDE_DIRS -- Required include directories for HDF5 C bindings -# HDF5_CXX_INCLUDE_DIRS -- Required include directories for HDF5 C++ bindings -# HDF5_Fortran_INCLUDE_DIRS -- Required include directories for HDF5 Fortran bindings -# HDF5_C_LIBRARIES - Required libraries for the HDF5 C bindings -# HDF5_CXX_LIBRARIES - Required libraries for the HDF5 C++ bindings -# HDF5_Fortran_LIBRARIES - Required libraries for the HDF5 Fortran bindings -# HDF5_C_HL_LIBRARIES - Required libraries for the high level C bindings -# HDF5_CXX_HL_LIBRARIES - Required libraries for the high level C++ bindings -# HDF5_Fortran_HL_LIBRARIES - Required libraries for the high level Fortran -# bindings. -# -# HDF5_IS_PARALLEL - Whether or not HDF5 was found with parallel IO support -# HDF5_C_COMPILER_EXECUTABLE - the path to the HDF5 C wrapper compiler -# HDF5_CXX_COMPILER_EXECUTABLE - the path to the HDF5 C++ wrapper compiler -# HDF5_Fortran_COMPILER_EXECUTABLE - the path to the HDF5 Fortran wrapper compiler -# HDF5_C_COMPILER_EXECUTABLE_NO_INTERROGATE - path to the primary C compiler -# which is also the HDF5 wrapper -# HDF5_CXX_COMPILER_EXECUTABLE_NO_INTERROGATE - path to the primary C++ -# compiler which is also -# the HDF5 wrapper -# HDF5_Fortran_COMPILER_EXECUTABLE_NO_INTERROGATE - path to the primary -# Fortran compiler which -# is also the HDF5 wrapper -# HDF5_DIFF_EXECUTABLE - the path to the HDF5 dataset comparison tool -# -# The following variable can be set to guide the search for HDF5 libraries and includes: -# -# ``HDF5_ROOT`` -# Specify the path to the HDF5 installation to use. -# -# ``HDF5_FIND_DEBUG`` -# Set to a true value to get some extra debugging output. -# -# ``HDF5_NO_FIND_PACKAGE_CONFIG_FILE`` -# Set to a true value to skip trying to find ``hdf5-config.cmake``. - -# This module is maintained by Will Dicharry . - -include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) - -# List of the valid HDF5 components -set(HDF5_VALID_LANGUAGE_BINDINGS C CXX Fortran) - -# Validate the list of find components. -if(NOT HDF5_FIND_COMPONENTS) - set(HDF5_LANGUAGE_BINDINGS "C") -else() - set(HDF5_LANGUAGE_BINDINGS) - # add the extra specified components, ensuring that they are valid. - set(FIND_HL OFF) - foreach(component IN LISTS HDF5_FIND_COMPONENTS) - list(FIND HDF5_VALID_LANGUAGE_BINDINGS ${component} component_location) - if(NOT component_location EQUAL -1) - list(APPEND HDF5_LANGUAGE_BINDINGS ${component}) - elseif(component STREQUAL "HL") - set(FIND_HL ON) - elseif(component STREQUAL "Fortran_HL") # only for compatibility - list(APPEND HDF5_LANGUAGE_BINDINGS Fortran) - set(FIND_HL ON) - set(HDF5_FIND_REQUIRED_Fortran_HL False) - set(HDF5_FIND_REQUIRED_Fortran True) - set(HDF5_FIND_REQUIRED_HL True) - else() - message(FATAL_ERROR "${component} is not a valid HDF5 component.") - endif() - endforeach() - if(NOT HDF5_LANGUAGE_BINDINGS) - get_property(__langs GLOBAL PROPERTY ENABLED_LANGUAGES) - foreach(__lang IN LISTS __langs) - if(__lang MATCHES "^(C|CXX|Fortran)$") - list(APPEND HDF5_LANGUAGE_BINDINGS ${__lang}) - endif() - endforeach() - endif() - list(REMOVE_ITEM HDF5_FIND_COMPONENTS Fortran_HL) # replaced by Fortran and HL - list(REMOVE_DUPLICATES HDF5_LANGUAGE_BINDINGS) -endif() - -# Determine whether to search for serial or parallel executable first -if(HDF5_PREFER_PARALLEL) - set(HDF5_C_COMPILER_NAMES h5pcc h5cc) - set(HDF5_CXX_COMPILER_NAMES h5pc++ h5c++) - set(HDF5_Fortran_COMPILER_NAMES h5pfc h5fc) -else() - set(HDF5_C_COMPILER_NAMES h5cc h5pcc) - set(HDF5_CXX_COMPILER_NAMES h5c++ h5pc++) - set(HDF5_Fortran_COMPILER_NAMES h5fc h5pfc) -endif() - -# We may have picked up some duplicates in various lists during the above -# process for the language bindings (both the C and C++ bindings depend on -# libz for example). Remove the duplicates. It appears that the default -# CMake behavior is to remove duplicates from the end of a list. However, -# for link lines, this is incorrect since unresolved symbols are searched -# for down the link line. Therefore, we reverse the list, remove the -# duplicates, and then reverse it again to get the duplicates removed from -# the beginning. -macro(_HDF5_remove_duplicates_from_beginning _list_name) - if(${_list_name}) - list(REVERSE ${_list_name}) - list(REMOVE_DUPLICATES ${_list_name}) - list(REVERSE ${_list_name}) - endif() -endmacro() - - -# Test first if the current compilers automatically wrap HDF5 - -function(_HDF5_test_regular_compiler_C success version is_parallel) - set(scratch_directory - ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/hdf5) - if(NOT ${success} OR - NOT EXISTS ${scratch_directory}/compiler_has_h5_c) - set(test_file ${scratch_directory}/cmake_hdf5_test.c) - file(WRITE ${test_file} - "#include \n" - "#include \n" - "const char* info_ver = \"INFO\" \":\" H5_VERSION;\n" - "#ifdef H5_HAVE_PARALLEL\n" - "const char* info_parallel = \"INFO\" \":\" \"PARALLEL\";\n" - "#endif\n" - "int main(int argc, char **argv) {\n" - " int require = 0;\n" - " require += info_ver[argc];\n" - "#ifdef H5_HAVE_PARALLEL\n" - " require += info_parallel[argc];\n" - "#endif\n" - " hid_t fid;\n" - " fid = H5Fcreate(\"foo.h5\",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT);\n" - " return 0;\n" - "}") - try_compile(${success} ${scratch_directory} ${test_file} - COPY_FILE ${scratch_directory}/compiler_has_h5_c - ) - endif() - if(${success}) - file(STRINGS ${scratch_directory}/compiler_has_h5_c INFO_STRINGS - REGEX "^INFO:" - ) - string(REGEX MATCH "^INFO:([0-9]+\\.[0-9]+\\.[0-9]+)(-patch([0-9]+))?" - INFO_VER "${INFO_STRINGS}" - ) - set(${version} ${CMAKE_MATCH_1}) - if(CMAKE_MATCH_3) - set(${version} ${HDF5_C_VERSION}.${CMAKE_MATCH_3}) - endif() - set(${version} ${${version}} PARENT_SCOPE) - - if(INFO_STRINGS MATCHES "INFO:PARALLEL") - set(${is_parallel} TRUE PARENT_SCOPE) - else() - set(${is_parallel} FALSE PARENT_SCOPE) - endif() - endif() -endfunction() - -function(_HDF5_test_regular_compiler_CXX success version is_parallel) - set(scratch_directory ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/hdf5) - if(NOT ${success} OR - NOT EXISTS ${scratch_directory}/compiler_has_h5_cxx) - set(test_file ${scratch_directory}/cmake_hdf5_test.cxx) - file(WRITE ${test_file} - "#include \n" - "#ifndef H5_NO_NAMESPACE\n" - "using namespace H5;\n" - "#endif\n" - "const char* info_ver = \"INFO\" \":\" H5_VERSION;\n" - "#ifdef H5_HAVE_PARALLEL\n" - "const char* info_parallel = \"INFO\" \":\" \"PARALLEL\";\n" - "#endif\n" - "int main(int argc, char **argv) {\n" - " int require = 0;\n" - " require += info_ver[argc];\n" - "#ifdef H5_HAVE_PARALLEL\n" - " require += info_parallel[argc];\n" - "#endif\n" - " H5File file(\"foo.h5\", H5F_ACC_TRUNC);\n" - " return 0;\n" - "}") - try_compile(${success} ${scratch_directory} ${test_file} - COPY_FILE ${scratch_directory}/compiler_has_h5_cxx - ) - endif() - if(${success}) - file(STRINGS ${scratch_directory}/compiler_has_h5_cxx INFO_STRINGS - REGEX "^INFO:" - ) - string(REGEX MATCH "^INFO:([0-9]+\\.[0-9]+\\.[0-9]+)(-patch([0-9]+))?" - INFO_VER "${INFO_STRINGS}" - ) - set(${version} ${CMAKE_MATCH_1}) - if(CMAKE_MATCH_3) - set(${version} ${HDF5_CXX_VERSION}.${CMAKE_MATCH_3}) - endif() - set(${version} ${${version}} PARENT_SCOPE) - - if(INFO_STRINGS MATCHES "INFO:PARALLEL") - set(${is_parallel} TRUE PARENT_SCOPE) - else() - set(${is_parallel} FALSE PARENT_SCOPE) - endif() - endif() -endfunction() - -function(_HDF5_test_regular_compiler_Fortran success is_parallel) - if(NOT ${success}) - set(scratch_directory - ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/hdf5) - set(test_file ${scratch_directory}/cmake_hdf5_test.f90) - file(WRITE ${test_file} - "program hdf5_hello\n" - " use hdf5\n" - " use h5lt\n" - " use h5ds\n" - " integer error\n" - " call h5open_f(error)\n" - " call h5close_f(error)\n" - "end\n") - try_compile(${success} ${scratch_directory} ${test_file}) - if(${success}) - execute_process(COMMAND ${CMAKE_Fortran_COMPILER} -showconfig - OUTPUT_VARIABLE config_output - ERROR_VARIABLE config_error - RESULT_VARIABLE config_result - ) - if(config_output MATCHES "Parallel HDF5: yes") - set(${is_parallel} TRUE PARENT_SCOPE) - else() - set(${is_parallel} FALSE PARENT_SCOPE) - endif() - endif() - endif() -endfunction() - -# Invoke the HDF5 wrapper compiler. The compiler return value is stored to the -# return_value argument, the text output is stored to the output variable. -macro( _HDF5_invoke_compiler language output return_value version is_parallel) - set(${version}) - if(HDF5_USE_STATIC_LIBRARIES) - set(lib_type_args -noshlib) - else() - set(lib_type_args -shlib) - endif() - set(scratch_dir ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/hdf5) - if("${language}" STREQUAL "C") - set(test_file ${scratch_dir}/cmake_hdf5_test.c) - elseif("${language}" STREQUAL "CXX") - set(test_file ${scratch_dir}/cmake_hdf5_test.cxx) - elseif("${language}" STREQUAL "Fortran") - set(test_file ${scratch_dir}/cmake_hdf5_test.f90) - endif() - exec_program( ${HDF5_${language}_COMPILER_EXECUTABLE} - ARGS -show ${lib_type_args} ${test_file} - OUTPUT_VARIABLE ${output} - RETURN_VALUE ${return_value} - ) - if(NOT ${${return_value}} EQUAL 0) - message(STATUS - "Unable to determine HDF5 ${language} flags from HDF5 wrapper.") - endif() - exec_program( ${HDF5_${language}_COMPILER_EXECUTABLE} - ARGS -showconfig - OUTPUT_VARIABLE config_output - RETURN_VALUE config_return - ) - if(NOT ${return_value} EQUAL 0) - message( STATUS - "Unable to determine HDF5 ${language} version from HDF5 wrapper.") - endif() - string(REGEX MATCH "HDF5 Version: ([a-zA-Z0-9\\.\\-]*)" version_match "${config_output}") - if(version_match) - string(REPLACE "HDF5 Version: " "" ${version} "${version_match}") - string(REPLACE "-patch" "." ${version} "${${version}}") - endif() - if(config_output MATCHES "Parallel HDF5: yes") - set(${is_parallel} TRUE) - else() - set(${is_parallel} FALSE) - endif() -endmacro() - -# Parse a compile line for definitions, includes, library paths, and libraries. -macro( _HDF5_parse_compile_line - compile_line_var - include_paths - definitions - library_paths - libraries - libraries_hl) - - separate_arguments(_HDF5_COMPILE_ARGS UNIX_COMMAND "${${compile_line_var}}") - - foreach(arg IN LISTS _HDF5_COMPILE_ARGS) - if("${arg}" MATCHES "^-I(.*)$") - # include directory - list(APPEND ${include_paths} "${CMAKE_MATCH_1}") - elseif("${arg}" MATCHES "^-D(.*)$") - # compile definition - list(APPEND ${definitions} "-D${CMAKE_MATCH_1}") - elseif("${arg}" MATCHES "^-L(.*)$") - # library search path - list(APPEND ${library_paths} "${CMAKE_MATCH_1}") - elseif("${arg}" MATCHES "^-l(hdf5.*hl.*)$") - # library name (hl) - list(APPEND ${libraries_hl} "${CMAKE_MATCH_1}") - elseif("${arg}" MATCHES "^-l(.*)$") - # library name - list(APPEND ${libraries} "${CMAKE_MATCH_1}") - elseif("${arg}" MATCHES "^(.:)?[/\\].*\\.(a|so|dylib|sl|lib)$") - # library file - if(NOT EXISTS "${arg}") - continue() - endif() - get_filename_component(_HDF5_LPATH "${arg}" DIRECTORY) - get_filename_component(_HDF5_LNAME "${arg}" NAME_WE) - string(REGEX REPLACE "^lib" "" _HDF5_LNAME "${_HDF5_LNAME}") - list(APPEND ${library_paths} "${_HDF5_LPATH}") - if(_HDF5_LNAME MATCHES "hdf5.*hl") - list(APPEND ${libraries_hl} "${_HDF5_LNAME}") - else() - list(APPEND ${libraries} "${_HDF5_LNAME}") - endif() - endif() - endforeach() -endmacro() - -# Select a preferred imported configuration from a target -function(_HDF5_select_imported_config target imported_conf) - # We will first assign the value to a local variable _imported_conf, then assign - # it to the function argument at the end. - get_target_property(_imported_conf ${target} MAP_IMPORTED_CONFIG_${CMAKE_BUILD_TYPE}) - if (NOT _imported_conf) - # Get available imported configurations by examining target properties - get_target_property(_imported_conf ${target} IMPORTED_CONFIGURATIONS) - if(HDF5_FIND_DEBUG) - message(STATUS "Found imported configurations: ${_imported_conf}") - endif() - # Find the imported configuration that we prefer. - # We do this by making list of configurations in order of preference, - # starting with ${CMAKE_BUILD_TYPE} and ending with the first imported_conf - set(_preferred_confs ${CMAKE_BUILD_TYPE}) - list(GET _imported_conf 0 _fallback_conf) - list(APPEND _preferred_confs RELWITHDEBINFO RELEASE DEBUG ${_fallback_conf}) - if(HDF5_FIND_DEBUG) - message(STATUS "Start search through imported configurations in the following order: ${_preferred_confs}") - endif() - # Now find the first of these that is present in imported_conf - cmake_policy(PUSH) - cmake_policy(SET CMP0057 NEW) # support IN_LISTS - foreach (_conf IN LISTS _preferred_confs) - if (${_conf} IN_LIST _imported_conf) - set(_imported_conf ${_conf}) - break() - endif() - endforeach() - cmake_policy(POP) - endif() - if(HDF5_FIND_DEBUG) - message(STATUS "Selected imported configuration: ${_imported_conf}") - endif() - # assign value to function argument - set(${imported_conf} ${_imported_conf} PARENT_SCOPE) -endfunction() - - -if(NOT HDF5_ROOT) - set(HDF5_ROOT $ENV{HDF5_ROOT}) -endif() -if(HDF5_ROOT) - set(_HDF5_SEARCH_OPTS NO_DEFAULT_PATH) -else() - set(_HDF5_SEARCH_OPTS) -endif() - -# Try to find HDF5 using an installed hdf5-config.cmake -if(NOT HDF5_FOUND AND NOT HDF5_NO_FIND_PACKAGE_CONFIG_FILE) - find_package(HDF5 QUIET NO_MODULE - HINTS ${HDF5_ROOT} - ${_HDF5_SEARCH_OPTS} - ) - if( HDF5_FOUND) - if(HDF5_FIND_DEBUG) - message(STATUS "Found HDF5 at ${HDF5_DIR} via NO_MODULE. Now trying to extract locations etc.") - endif() - set(HDF5_IS_PARALLEL ${HDF5_ENABLE_PARALLEL}) - set(HDF5_INCLUDE_DIRS ${HDF5_INCLUDE_DIR}) - set(HDF5_LIBRARIES) - if (NOT TARGET hdf5 AND NOT TARGET hdf5-static AND NOT TARGET hdf5-shared) - # Some HDF5 versions (e.g. 1.8.18) used hdf5::hdf5 etc - set(_target_prefix "hdf5::") - endif() - set(HDF5_C_TARGET ${_target_prefix}hdf5) - set(HDF5_C_HL_TARGET ${_target_prefix}hdf5_hl) - set(HDF5_CXX_TARGET ${_target_prefix}hdf5_cpp) - set(HDF5_CXX_HL_TARGET ${_target_prefix}hdf5_hl_cpp) - set(HDF5_Fortran_TARGET ${_target_prefix}hdf5_fortran) - set(HDF5_Fortran_HL_TARGET ${_target_prefix}hdf5_hl_fortran) - set(HDF5_DEFINITIONS "") - if(HDF5_USE_STATIC_LIBRARIES) - set(_suffix "-static") - else() - set(_suffix "-shared") - endif() - foreach(_lang ${HDF5_LANGUAGE_BINDINGS}) - - #Older versions of hdf5 don't have a static/shared suffix so - #if we detect that occurrence clear the suffix - if(_suffix AND NOT TARGET ${HDF5_${_lang}_TARGET}${_suffix}) - if(NOT TARGET ${HDF5_${_lang}_TARGET}) - #cant find this component with or without the suffix - #so bail out, and let the following locate HDF5 - set(HDF5_FOUND FALSE) - break() - endif() - set(_suffix "") - endif() - - if(HDF5_FIND_DEBUG) - message(STATUS "Trying to get properties of target ${HDF5_${_lang}_TARGET}${_suffix}") - endif() - # Find library for this target. Complicated as on Windows with a DLL, we need to search for the import-lib. - _HDF5_select_imported_config(${HDF5_${_lang}_TARGET}${_suffix} _hdf5_imported_conf) - get_target_property(_hdf5_lang_location ${HDF5_${_lang}_TARGET}${_suffix} IMPORTED_IMPLIB_${_hdf5_imported_conf} ) - if (NOT _hdf5_lang_location) - # no import lib, just try LOCATION - get_target_property(_hdf5_lang_location ${HDF5_${_lang}_TARGET}${_suffix} LOCATION_${_hdf5_imported_conf}) - if (NOT _hdf5_lang_location) - get_target_property(_hdf5_lang_location ${HDF5_${_lang}_TARGET}${_suffix} LOCATION) - endif() - endif() - if( _hdf5_lang_location ) - set(HDF5_${_lang}_LIBRARY ${_hdf5_lang_location}) - list(APPEND HDF5_LIBRARIES ${HDF5_${_lang}_TARGET}${_suffix}) - set(HDF5_${_lang}_LIBRARIES ${HDF5_${_lang}_TARGET}${_suffix}) - set(HDF5_${_lang}_FOUND True) - endif() - if(FIND_HL) - get_target_property(__lang_hl_location ${HDF5_${_lang}_HL_TARGET}${_suffix} IMPORTED_IMPLIB_${_hdf5_imported_conf} ) - if (NOT _hdf5_lang_hl_location) - get_target_property(_hdf5_lang_hl_location ${HDF5_${_lang}_HL_TARGET}${_suffix} LOCATION_${_hdf5_imported_conf}) - if (NOT _hdf5_hl_lang_location) - get_target_property(_hdf5_hl_lang_location ${HDF5_${_lang}_HL_TARGET}${_suffix} LOCATION) - endif() - endif() - if( _hdf5_lang_hl_location ) - set(HDF5_${_lang}_HL_LIBRARY ${_hdf5_lang_hl_location}) - list(APPEND HDF5_HL_LIBRARIES ${HDF5_${_lang}_HL_TARGET}${_suffix}) - set(HDF5_${_lang}_HL_LIBRARIES ${HDF5_${_lang}_HL_TARGET}${_suffix}) - set(HDF5_HL_FOUND True) - endif() - unset(_hdf5_lang_hl_location) - endif() - unset(_hdf5_imported_conf) - unset(_hdf5_lang_location) - endforeach() - endif() -endif() - -if(NOT HDF5_FOUND) - set(_HDF5_NEED_TO_SEARCH False) - set(HDF5_COMPILER_NO_INTERROGATE True) - # Only search for languages we've enabled - foreach(__lang IN LISTS HDF5_LANGUAGE_BINDINGS) - # First check to see if our regular compiler is one of wrappers - if(__lang STREQUAL "C") - _HDF5_test_regular_compiler_C( - HDF5_${__lang}_COMPILER_NO_INTERROGATE - HDF5_${__lang}_VERSION - HDF5_${__lang}_IS_PARALLEL) - elseif(__lang STREQUAL "CXX") - _HDF5_test_regular_compiler_CXX( - HDF5_${__lang}_COMPILER_NO_INTERROGATE - HDF5_${__lang}_VERSION - HDF5_${__lang}_IS_PARALLEL) - elseif(__lang STREQUAL "Fortran") - _HDF5_test_regular_compiler_Fortran( - HDF5_${__lang}_COMPILER_NO_INTERROGATE - HDF5_${__lang}_IS_PARALLEL) - else() - continue() - endif() - if(HDF5_${__lang}_COMPILER_NO_INTERROGATE) - message(STATUS "HDF5: Using hdf5 compiler wrapper for all ${__lang} compiling") - set(HDF5_${__lang}_FOUND True) - set(HDF5_${__lang}_COMPILER_EXECUTABLE_NO_INTERROGATE - "${CMAKE_${__lang}_COMPILER}" - CACHE FILEPATH "HDF5 ${__lang} compiler wrapper") - set(HDF5_${__lang}_DEFINITIONS) - set(HDF5_${__lang}_INCLUDE_DIRS) - set(HDF5_${__lang}_LIBRARIES) - set(HDF5_${__lang}_HL_LIBRARIES) - - mark_as_advanced(HDF5_${__lang}_COMPILER_EXECUTABLE_NO_INTERROGATE) - - set(HDF5_${__lang}_FOUND True) - set(HDF5_HL_FOUND True) - else() - set(HDF5_COMPILER_NO_INTERROGATE False) - # If this language isn't using the wrapper, then try to seed the - # search options with the wrapper - find_program(HDF5_${__lang}_COMPILER_EXECUTABLE - NAMES ${HDF5_${__lang}_COMPILER_NAMES} NAMES_PER_DIR - HINTS ${HDF5_ROOT} - PATH_SUFFIXES bin Bin - DOC "HDF5 ${__lang} Wrapper compiler. Used only to detect HDF5 compile flags." - ${_HDF5_SEARCH_OPTS} - ) - mark_as_advanced( HDF5_${__lang}_COMPILER_EXECUTABLE ) - unset(HDF5_${__lang}_COMPILER_NAMES) - - if(HDF5_${__lang}_COMPILER_EXECUTABLE) - _HDF5_invoke_compiler(${__lang} HDF5_${__lang}_COMPILE_LINE - HDF5_${__lang}_RETURN_VALUE HDF5_${__lang}_VERSION HDF5_${__lang}_IS_PARALLEL) - if(HDF5_${__lang}_RETURN_VALUE EQUAL 0) - message(STATUS "HDF5: Using hdf5 compiler wrapper to determine ${__lang} configuration") - _HDF5_parse_compile_line( HDF5_${__lang}_COMPILE_LINE - HDF5_${__lang}_INCLUDE_DIRS - HDF5_${__lang}_DEFINITIONS - HDF5_${__lang}_LIBRARY_DIRS - HDF5_${__lang}_LIBRARY_NAMES - HDF5_${__lang}_HL_LIBRARY_NAMES - ) - set(HDF5_${__lang}_LIBRARIES) - - foreach(L IN LISTS HDF5_${__lang}_LIBRARY_NAMES) - set(_HDF5_SEARCH_NAMES_LOCAL) - if("x${L}" MATCHES "hdf5") - # hdf5 library - set(_HDF5_SEARCH_OPTS_LOCAL ${_HDF5_SEARCH_OPTS}) - if(HDF5_USE_STATIC_LIBRARIES) - if(WIN32) - set(_HDF5_SEARCH_NAMES_LOCAL lib${L}) - else() - set(_HDF5_SEARCH_NAMES_LOCAL lib${L}.a) - endif() - endif() - else() - # external library - set(_HDF5_SEARCH_OPTS_LOCAL) - endif() - find_library(HDF5_${__lang}_LIBRARY_${L} - NAMES ${_HDF5_SEARCH_NAMES_LOCAL} ${L} NAMES_PER_DIR - HINTS ${HDF5_${__lang}_LIBRARY_DIRS} - ${HDF5_ROOT} - ${_HDF5_SEARCH_OPTS_LOCAL} - ) - unset(_HDF5_SEARCH_OPTS_LOCAL) - unset(_HDF5_SEARCH_NAMES_LOCAL) - if(HDF5_${__lang}_LIBRARY_${L}) - list(APPEND HDF5_${__lang}_LIBRARIES ${HDF5_${__lang}_LIBRARY_${L}}) - else() - list(APPEND HDF5_${__lang}_LIBRARIES ${L}) - endif() - endforeach() - if(FIND_HL) - set(HDF5_${__lang}_HL_LIBRARIES) - foreach(L IN LISTS HDF5_${__lang}_HL_LIBRARY_NAMES) - set(_HDF5_SEARCH_NAMES_LOCAL) - if("x${L}" MATCHES "hdf5") - # hdf5 library - set(_HDF5_SEARCH_OPTS_LOCAL ${_HDF5_SEARCH_OPTS}) - if(HDF5_USE_STATIC_LIBRARIES) - if(WIN32) - set(_HDF5_SEARCH_NAMES_LOCAL lib${L}) - else() - set(_HDF5_SEARCH_NAMES_LOCAL lib${L}.a) - endif() - endif() - else() - # external library - set(_HDF5_SEARCH_OPTS_LOCAL) - endif() - find_library(HDF5_${__lang}_LIBRARY_${L} - NAMES ${_HDF5_SEARCH_NAMES_LOCAL} ${L} NAMES_PER_DIR - HINTS ${HDF5_${__lang}_LIBRARY_DIRS} - ${HDF5_ROOT} - ${_HDF5_SEARCH_OPTS_LOCAL} - ) - unset(_HDF5_SEARCH_OPTS_LOCAL) - unset(_HDF5_SEARCH_NAMES_LOCAL) - if(HDF5_${__lang}_LIBRARY_${L}) - list(APPEND HDF5_${__lang}_HL_LIBRARIES ${HDF5_${__lang}_LIBRARY_${L}}) - else() - list(APPEND HDF5_${__lang}_HL_LIBRARIES ${L}) - endif() - endforeach() - set(HDF5_HL_FOUND True) - endif() - - set(HDF5_${__lang}_FOUND True) - _HDF5_remove_duplicates_from_beginning(HDF5_${__lang}_DEFINITIONS) - _HDF5_remove_duplicates_from_beginning(HDF5_${__lang}_INCLUDE_DIRS) - _HDF5_remove_duplicates_from_beginning(HDF5_${__lang}_LIBRARIES) - _HDF5_remove_duplicates_from_beginning(HDF5_${__lang}_HL_LIBRARIES) - else() - set(_HDF5_NEED_TO_SEARCH True) - endif() - else() - set(_HDF5_NEED_TO_SEARCH True) - endif() - endif() - if(HDF5_${__lang}_VERSION) - if(NOT HDF5_VERSION) - set(HDF5_VERSION ${HDF5_${__lang}_VERSION}) - elseif(NOT HDF5_VERSION VERSION_EQUAL HDF5_${__lang}_VERSION) - message(WARNING "HDF5 Version found for language ${__lang}, ${HDF5_${__lang}_VERSION} is different than previously found version ${HDF5_VERSION}") - endif() - endif() - if(DEFINED HDF5_${__lang}_IS_PARALLEL) - if(NOT DEFINED HDF5_IS_PARALLEL) - set(HDF5_IS_PARALLEL ${HDF5_${__lang}_IS_PARALLEL}) - elseif(NOT HDF5_IS_PARALLEL AND HDF5_${__lang}_IS_PARALLEL) - message(WARNING "HDF5 found for language ${__lang} is parallel but previously found language is not parallel.") - elseif(HDF5_IS_PARALLEL AND NOT HDF5_${__lang}_IS_PARALLEL) - message(WARNING "HDF5 found for language ${__lang} is not parallel but previously found language is parallel.") - endif() - endif() - endforeach() -else() - set(_HDF5_NEED_TO_SEARCH True) -endif() - -if(NOT HDF5_FOUND AND HDF5_COMPILER_NO_INTERROGATE) - # No arguments necessary, all languages can use the compiler wrappers - set(HDF5_FOUND True) - set(HDF5_METHOD "Included by compiler wrappers") - set(HDF5_REQUIRED_VARS HDF5_METHOD) -elseif(NOT HDF5_FOUND AND NOT _HDF5_NEED_TO_SEARCH) - # Compiler wrappers aren't being used by the build but were found and used - # to determine necessary include and library flags - set(HDF5_INCLUDE_DIRS) - set(HDF5_LIBRARIES) - set(HDF5_HL_LIBRARIES) - foreach(__lang IN LISTS HDF5_LANGUAGE_BINDINGS) - if(HDF5_${__lang}_FOUND) - if(NOT HDF5_${__lang}_COMPILER_NO_INTERROGATE) - list(APPEND HDF5_DEFINITIONS ${HDF5_${__lang}_DEFINITIONS}) - list(APPEND HDF5_INCLUDE_DIRS ${HDF5_${__lang}_INCLUDE_DIRS}) - list(APPEND HDF5_LIBRARIES ${HDF5_${__lang}_LIBRARIES}) - if(FIND_HL) - list(APPEND HDF5_HL_LIBRARIES ${HDF5_${__lang}_HL_LIBRARIES}) - endif() - endif() - endif() - endforeach() - _HDF5_remove_duplicates_from_beginning(HDF5_DEFINITIONS) - _HDF5_remove_duplicates_from_beginning(HDF5_INCLUDE_DIRS) - _HDF5_remove_duplicates_from_beginning(HDF5_LIBRARIES) - _HDF5_remove_duplicates_from_beginning(HDF5_HL_LIBRARIES) - set(HDF5_FOUND True) - set(HDF5_REQUIRED_VARS HDF5_LIBRARIES) - if(FIND_HL) - list(APPEND HDF5_REQUIRED_VARS HDF5_HL_LIBRARIES) - endif() -endif() - -find_program( HDF5_DIFF_EXECUTABLE - NAMES h5diff - HINTS ${HDF5_ROOT} - PATH_SUFFIXES bin Bin - ${_HDF5_SEARCH_OPTS} - DOC "HDF5 file differencing tool." ) -mark_as_advanced( HDF5_DIFF_EXECUTABLE ) - -if( NOT HDF5_FOUND ) - # seed the initial lists of libraries to find with items we know we need - set(HDF5_C_LIBRARY_NAMES hdf5) - set(HDF5_C_HL_LIBRARY_NAMES hdf5_hl) - - set(HDF5_CXX_LIBRARY_NAMES hdf5_cpp ${HDF5_C_LIBRARY_NAMES}) - set(HDF5_CXX_HL_LIBRARY_NAMES hdf5_hl_cpp ${HDF5_C_HL_LIBRARY_NAMES} ${HDF5_CXX_LIBRARY_NAMES}) - - set(HDF5_Fortran_LIBRARY_NAMES hdf5_fortran ${HDF5_C_LIBRARY_NAMES}) - set(HDF5_Fortran_HL_LIBRARY_NAMES hdf5hl_fortran ${HDF5_C_HL_LIBRARY_NAMES} ${HDF5_Fortran_LIBRARY_NAMES}) - - foreach(__lang IN LISTS HDF5_LANGUAGE_BINDINGS) - # find the HDF5 include directories - if("${__lang}" STREQUAL "Fortran") - set(HDF5_INCLUDE_FILENAME hdf5.mod) - elseif("${__lang}" STREQUAL "CXX") - set(HDF5_INCLUDE_FILENAME H5Cpp.h) - else() - set(HDF5_INCLUDE_FILENAME hdf5.h) - endif() - - find_path(HDF5_${__lang}_INCLUDE_DIR ${HDF5_INCLUDE_FILENAME} - HINTS ${HDF5_ROOT} - PATHS $ENV{HOME}/.local/include - PATH_SUFFIXES include Include - ${_HDF5_SEARCH_OPTS} - ) - mark_as_advanced(HDF5_${__lang}_INCLUDE_DIR) - # set the _DIRS variable as this is what the user will normally use - set(HDF5_${__lang}_INCLUDE_DIRS ${HDF5_${__lang}_INCLUDE_DIR}) - list(APPEND HDF5_INCLUDE_DIRS ${HDF5_${__lang}_INCLUDE_DIR}) - - # find the HDF5 libraries - foreach(LIB IN LISTS HDF5_${__lang}_LIBRARY_NAMES) - if(HDF5_USE_STATIC_LIBRARIES) - # According to bug 1643 on the CMake bug tracker, this is the - # preferred method for searching for a static library. - # See https://gitlab.kitware.com/cmake/cmake/issues/1643. We search - # first for the full static library name, but fall back to a - # generic search on the name if the static search fails. - set( THIS_LIBRARY_SEARCH_DEBUG - lib${LIB}d.a lib${LIB}_debug.a lib${LIB}d lib${LIB}_D lib${LIB}_debug - lib${LIB}d-static.a lib${LIB}_debug-static.a ${LIB}d-static ${LIB}_D-static ${LIB}_debug-static ) - set( THIS_LIBRARY_SEARCH_RELEASE lib${LIB}.a lib${LIB} lib${LIB}-static.a ${LIB}-static) - else() - set( THIS_LIBRARY_SEARCH_DEBUG ${LIB}d ${LIB}_D ${LIB}_debug ${LIB}d-shared ${LIB}_D-shared ${LIB}_debug-shared) - set( THIS_LIBRARY_SEARCH_RELEASE ${LIB} ${LIB}-shared) - if(WIN32) - list(APPEND HDF5_DEFINITIONS "-DH5_BUILT_AS_DYNAMIC_LIB") - endif() - endif() - find_library(HDF5_${LIB}_LIBRARY_DEBUG - NAMES ${THIS_LIBRARY_SEARCH_DEBUG} - HINTS ${HDF5_ROOT} PATH_SUFFIXES lib Lib - ${_HDF5_SEARCH_OPTS} - ) - find_library( HDF5_${LIB}_LIBRARY_RELEASE - NAMES ${THIS_LIBRARY_SEARCH_RELEASE} - HINTS ${HDF5_ROOT} PATH_SUFFIXES lib Lib - ${_HDF5_SEARCH_OPTS} - ) - select_library_configurations( HDF5_${LIB} ) - list(APPEND HDF5_${__lang}_LIBRARIES ${HDF5_${LIB}_LIBRARY}) - endforeach() - if(HDF5_${__lang}_LIBRARIES) - set(HDF5_${__lang}_FOUND True) - endif() - - # Append the libraries for this language binding to the list of all - # required libraries. - list(APPEND HDF5_LIBRARIES ${HDF5_${__lang}_LIBRARIES}) - - if(FIND_HL) - foreach(LIB IN LISTS HDF5_${__lang}_HL_LIBRARY_NAMES) - if(HDF5_USE_STATIC_LIBRARIES) - # According to bug 1643 on the CMake bug tracker, this is the - # preferred method for searching for a static library. - # See https://gitlab.kitware.com/cmake/cmake/issues/1643. We search - # first for the full static library name, but fall back to a - # generic search on the name if the static search fails. - set( THIS_LIBRARY_SEARCH_DEBUG - lib${LIB}d.a lib${LIB}_debug.a lib${LIB}d lib${LIB}_D lib${LIB}_debug - lib${LIB}d-static.a lib${LIB}_debug-static.a lib${LIB}d-static lib${LIB}_D-static lib${LIB}_debug-static ) - set( THIS_LIBRARY_SEARCH_RELEASE lib${LIB}.a ${LIB} lib${LIB}-static.a lib${LIB}-static) - else() - set( THIS_LIBRARY_SEARCH_DEBUG ${LIB}d ${LIB}_D ${LIB}_debug ${LIB}d-shared ${LIB}_D-shared ${LIB}_debug-shared) - set( THIS_LIBRARY_SEARCH_RELEASE ${LIB} ${LIB}-shared) - endif() - find_library(HDF5_${LIB}_LIBRARY_DEBUG - NAMES ${THIS_LIBRARY_SEARCH_DEBUG} - HINTS ${HDF5_ROOT} PATH_SUFFIXES lib Lib - ${_HDF5_SEARCH_OPTS} - ) - find_library( HDF5_${LIB}_LIBRARY_RELEASE - NAMES ${THIS_LIBRARY_SEARCH_RELEASE} - HINTS ${HDF5_ROOT} PATH_SUFFIXES lib Lib - ${_HDF5_SEARCH_OPTS} - ) - select_library_configurations( HDF5_${LIB} ) - list(APPEND HDF5_${__lang}_HL_LIBRARIES ${HDF5_${LIB}_LIBRARY}) - endforeach() - - # Append the libraries for this language binding to the list of all - # required libraries. - list(APPEND HDF5_HL_LIBRARIES ${HDF5_${__lang}_HL_LIBRARIES}) - endif() - endforeach() - if(FIND_HL AND HDF5_HL_LIBRARIES) - set(HDF5_HL_FOUND True) - endif() - - _HDF5_remove_duplicates_from_beginning(HDF5_DEFINITIONS) - _HDF5_remove_duplicates_from_beginning(HDF5_INCLUDE_DIRS) - _HDF5_remove_duplicates_from_beginning(HDF5_LIBRARIES) - _HDF5_remove_duplicates_from_beginning(HDF5_HL_LIBRARIES) - - # If the HDF5 include directory was found, open H5pubconf.h to determine if - # HDF5 was compiled with parallel IO support - set( HDF5_IS_PARALLEL FALSE ) - set( HDF5_VERSION "" ) - foreach( _dir IN LISTS HDF5_INCLUDE_DIRS ) - foreach(_hdr "${_dir}/H5pubconf.h" "${_dir}/H5pubconf-64.h" "${_dir}/H5pubconf-32.h") - if( EXISTS "${_hdr}" ) - file( STRINGS "${_hdr}" - HDF5_HAVE_PARALLEL_DEFINE - REGEX "HAVE_PARALLEL 1" ) - if( HDF5_HAVE_PARALLEL_DEFINE ) - set( HDF5_IS_PARALLEL TRUE ) - endif() - unset(HDF5_HAVE_PARALLEL_DEFINE) - - file( STRINGS "${_hdr}" - HDF5_VERSION_DEFINE - REGEX "^[ \t]*#[ \t]*define[ \t]+H5_VERSION[ \t]+" ) - if( "${HDF5_VERSION_DEFINE}" MATCHES - "H5_VERSION[ \t]+\"([0-9]+\\.[0-9]+\\.[0-9]+)(-patch([0-9]+))?\"" ) - set( HDF5_VERSION "${CMAKE_MATCH_1}" ) - if( CMAKE_MATCH_3 ) - set( HDF5_VERSION ${HDF5_VERSION}.${CMAKE_MATCH_3}) - endif() - endif() - unset(HDF5_VERSION_DEFINE) - endif() - endforeach() - endforeach() - set( HDF5_IS_PARALLEL ${HDF5_IS_PARALLEL} CACHE BOOL - "HDF5 library compiled with parallel IO support" ) - mark_as_advanced( HDF5_IS_PARALLEL ) - - set(HDF5_REQUIRED_VARS HDF5_LIBRARIES HDF5_INCLUDE_DIRS) - if(FIND_HL) - list(APPEND HDF5_REQUIRED_VARS HDF5_HL_LIBRARIES) - endif() -endif() - -# For backwards compatibility we set HDF5_INCLUDE_DIR to the value of -# HDF5_INCLUDE_DIRS -if( HDF5_INCLUDE_DIRS ) - set( HDF5_INCLUDE_DIR "${HDF5_INCLUDE_DIRS}" ) -endif() - -# If HDF5_REQUIRED_VARS is empty at this point, then it's likely that -# something external is trying to explicitly pass already found -# locations -if(NOT HDF5_REQUIRED_VARS) - set(HDF5_REQUIRED_VARS HDF5_LIBRARIES HDF5_INCLUDE_DIRS) -endif() - -find_package_handle_standard_args(HDF5 - REQUIRED_VARS ${HDF5_REQUIRED_VARS} - VERSION_VAR HDF5_VERSION - HANDLE_COMPONENTS -) - -unset(_HDF5_SEARCH_OPTS) - -if( HDF5_FOUND AND NOT HDF5_DIR) - # hide HDF5_DIR for the non-advanced user to avoid confusion with - # HDF5_DIR-NOT_FOUND while HDF5 was found. - mark_as_advanced(HDF5_DIR) -endif() - -if (HDF5_FIND_DEBUG) - message(STATUS "HDF5_DIR: ${HDF5_DIR}") - message(STATUS "HDF5_DEFINITIONS: ${HDF5_DEFINITIONS}") - message(STATUS "HDF5_INCLUDE_DIRS: ${HDF5_INCLUDE_DIRS}") - message(STATUS "HDF5_LIBRARIES: ${HDF5_LIBRARIES}") - message(STATUS "HDF5_HL_LIBRARIES: ${HDF5_HL_LIBRARIES}") - foreach(__lang IN LISTS HDF5_LANGUAGE_BINDINGS) - message(STATUS "HDF5_${__lang}_DEFINITIONS: ${HDF5_${__lang}_DEFINITIONS}") - message(STATUS "HDF5_${__lang}_INCLUDE_DIR: ${HDF5_${__lang}_INCLUDE_DIR}") - message(STATUS "HDF5_${__lang}_INCLUDE_DIRS: ${HDF5_${__lang}_INCLUDE_DIRS}") - message(STATUS "HDF5_${__lang}_LIBRARY: ${HDF5_${__lang}_LIBRARY}") - message(STATUS "HDF5_${__lang}_LIBRARIES: ${HDF5_${__lang}_LIBRARIES}") - message(STATUS "HDF5_${__lang}_HL_LIBRARY: ${HDF5_${__lang}_HL_LIBRARY}") - message(STATUS "HDF5_${__lang}_HL_LIBRARIES: ${HDF5_${__lang}_HL_LIBRARIES}") - endforeach() -endif() diff --git a/cmake/Modules/NewCMake/FindMPI.cmake b/cmake/Modules/NewCMake/FindMPI.cmake deleted file mode 100644 index 5cd2a2afe7..0000000000 --- a/cmake/Modules/NewCMake/FindMPI.cmake +++ /dev/null @@ -1,1514 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#.rst: -# FindMPI -# ------- -# -# Find a Message Passing Interface (MPI) implementation. -# -# The Message Passing Interface (MPI) is a library used to write -# high-performance distributed-memory parallel applications, and is -# typically deployed on a cluster. MPI is a standard interface (defined -# by the MPI forum) for which many implementations are available. -# -# Variables for using MPI -# ^^^^^^^^^^^^^^^^^^^^^^^ -# -# The module exposes the components ``C``, ``CXX``, ``MPICXX`` and ``Fortran``. -# Each of these controls the various MPI languages to search for. -# The difference between ``CXX`` and ``MPICXX`` is that ``CXX`` refers to the -# MPI C API being usable from C++, whereas ``MPICXX`` refers to the MPI-2 C++ API -# that was removed again in MPI-3. -# -# Depending on the enabled components the following variables will be set: -# -# ``MPI_FOUND`` -# Variable indicating that MPI settings for all requested languages have been found. -# If no components are specified, this is true if MPI settings for all enabled languages -# were detected. Note that the ``MPICXX`` component does not affect this variable. -# ``MPI_VERSION`` -# Minimal version of MPI detected among the requested languages, or all enabled languages -# if no components were specified. -# -# This module will set the following variables per language in your -# project, where ```` is one of C, CXX, or Fortran: -# -# ``MPI__FOUND`` -# Variable indicating the MPI settings for ```` were found and that -# simple MPI test programs compile with the provided settings. -# ``MPI__COMPILER`` -# MPI compiler for ```` if such a program exists. -# ``MPI__COMPILE_OPTIONS`` -# Compilation options for MPI programs in ````, given as a :ref:`;-list `. -# ``MPI__COMPILE_DEFINITIONS`` -# Compilation definitions for MPI programs in ````, given as a :ref:`;-list `. -# ``MPI__INCLUDE_DIRS`` -# Include path(s) for MPI header. -# ``MPI__LINK_FLAGS`` -# Linker flags for MPI programs. -# ``MPI__LIBRARIES`` -# All libraries to link MPI programs against. -# -# Additionally, the following :prop_tgt:`IMPORTED` targets are defined: -# -# ``MPI::MPI_`` -# Target for using MPI from ````. -# -# The following variables indicating which bindings are present will be defined: -# -# ``MPI_MPICXX_FOUND`` -# Variable indicating whether the MPI-2 C++ bindings are present (introduced in MPI-2, removed with MPI-3). -# ``MPI_Fortran_HAVE_F77_HEADER`` -# True if the Fortran 77 header ``mpif.h`` is available. -# ``MPI_Fortran_HAVE_F90_MODULE`` -# True if the Fortran 90 module ``mpi`` can be used for accessing MPI (MPI-2 and higher only). -# ``MPI_Fortran_HAVE_F08_MODULE`` -# True if the Fortran 2008 ``mpi_f08`` is available to MPI programs (MPI-3 and higher only). -# -# If possible, the MPI version will be determined by this module. The facilities to detect the MPI version -# were introduced with MPI-1.2, and therefore cannot be found for older MPI versions. -# -# ``MPI__VERSION_MAJOR`` -# Major version of MPI implemented for ```` by the MPI distribution. -# ``MPI__VERSION_MINOR`` -# Minor version of MPI implemented for ```` by the MPI distribution. -# ``MPI__VERSION`` -# MPI version implemented for ```` by the MPI distribution. -# -# Note that there's no variable for the C bindings being accessible through ``mpi.h``, since the MPI standards -# always have required this binding to work in both C and C++ code. -# -# For running MPI programs, the module sets the following variables -# -# ``MPIEXEC_EXECUTABLE`` -# Executable for running MPI programs, if such exists. -# ``MPIEXEC_NUMPROC_FLAG`` -# Flag to pass to ``mpiexec`` before giving it the number of processors to run on. -# ``MPIEXEC_MAX_NUMPROCS`` -# Number of MPI processors to utilize. Defaults to the number -# of processors detected on the host system. -# ``MPIEXEC_PREFLAGS`` -# Flags to pass to ``mpiexec`` directly before the executable to run. -# ``MPIEXEC_POSTFLAGS`` -# Flags to pass to ``mpiexec`` after other flags. -# -# Variables for locating MPI -# ^^^^^^^^^^^^^^^^^^^^^^^^^^ -# -# This module performs a three step search for an MPI implementation: -# -# 1. Check if the compiler has MPI support built-in. This is the case if the user passed a -# compiler wrapper as ``CMAKE__COMPILER`` or if they're on a Cray system. -# 2. Attempt to find an MPI compiler wrapper and determine the compiler information from it. -# 3. Try to find an MPI implementation that does not ship such a wrapper by guessing settings. -# Currently, only Microsoft MPI and MPICH2 on Windows are supported. -# -# For controlling the second step, the following variables may be set: -# -# ``MPI__COMPILER`` -# Search for the specified compiler wrapper and use it. -# ``MPI__COMPILER_FLAGS`` -# Flags to pass to the MPI compiler wrapper during interrogation. Some compiler wrappers -# support linking debug or tracing libraries if a specific flag is passed and this variable -# may be used to obtain them. -# ``MPI_COMPILER_FLAGS`` -# Used to initialize ``MPI__COMPILER_FLAGS`` if no language specific flag has been given. -# Empty by default. -# ``MPI_EXECUTABLE_SUFFIX`` -# A suffix which is appended to all names that are being looked for. For instance you may set this -# to ``.mpich`` or ``.openmpi`` to prefer the one or the other on Debian and its derivatives. -# -# In order to control the guessing step, the following variable may be set: -# -# ``MPI_GUESS_LIBRARY_NAME`` -# Valid values are ``MSMPI`` and ``MPICH2``. If set, only the given library will be searched for. -# By default, ``MSMPI`` will be preferred over ``MPICH2`` if both are available. -# This also sets ``MPI_SKIP_COMPILER_WRAPPER`` to ``true``, which may be overridden. -# -# Each of the search steps may be skipped with the following control variables: -# -# ``MPI_ASSUME_NO_BUILTIN_MPI`` -# If true, the module assumes that the compiler itself does not provide an MPI implementation and -# skips to step 2. -# ``MPI_SKIP_COMPILER_WRAPPER`` -# If true, no compiler wrapper will be searched for. -# ``MPI_SKIP_GUESSING`` -# If true, the guessing step will be skipped. -# -# Additionally, the following control variable is available to change search behavior: -# -# ``MPI_CXX_SKIP_MPICXX`` -# Add some definitions that will disable the MPI-2 C++ bindings. -# Currently supported are MPICH, Open MPI, Platform MPI and derivatives thereof, -# for example MVAPICH or Intel MPI. -# -# If the find procedure fails for a variable ``MPI__WORKS``, then the settings detected by or passed to -# the module did not work and even a simple MPI test program failed to compile. -# -# If all of these parameters were not sufficient to find the right MPI implementation, a user may -# disable the entire autodetection process by specifying both a list of libraries in ``MPI__LIBRARIES`` -# and a list of include directories in ``MPI__ADDITIONAL_INCLUDE_DIRS``. -# Any other variable may be set in addition to these two. The module will then validate the MPI settings and store the -# settings in the cache. -# -# Cache variables for MPI -# ^^^^^^^^^^^^^^^^^^^^^^^ -# -# The variable ``MPI__INCLUDE_DIRS`` will be assembled from the following variables. -# For C and CXX: -# -# ``MPI__HEADER_DIR`` -# Location of the ``mpi.h`` header on disk. -# -# For Fortran: -# -# ``MPI_Fortran_F77_HEADER_DIR`` -# Location of the Fortran 77 header ``mpif.h``, if it exists. -# ``MPI_Fortran_MODULE_DIR`` -# Location of the ``mpi`` or ``mpi_f08`` modules, if available. -# -# For all languages the following variables are additionally considered: -# -# ``MPI__ADDITIONAL_INCLUDE_DIRS`` -# A :ref:`;-list ` of paths needed in addition to the normal include directories. -# ``MPI__INCLUDE_DIR`` -# Path variables for include folders referred to by ````. -# ``MPI__ADDITIONAL_INCLUDE_VARS`` -# A :ref:`;-list ` of ```` that will be added to the include locations of ````. -# -# The variable ``MPI__LIBRARIES`` will be assembled from the following variables: -# -# ``MPI__LIBRARY`` -# The location of a library called ```` for use with MPI. -# ``MPI__LIB_NAMES`` -# A :ref:`;-list ` of ```` that will be added to the include locations of ````. -# -# Usage of mpiexec -# ^^^^^^^^^^^^^^^^ -# -# When using ``MPIEXEC_EXECUTABLE`` to execute MPI applications, you should typically -# use all of the ``MPIEXEC_EXECUTABLE`` flags as follows: -# -# :: -# -# ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} -# ${MPIEXEC_PREFLAGS} EXECUTABLE ${MPIEXEC_POSTFLAGS} ARGS -# -# where ``EXECUTABLE`` is the MPI program, and ``ARGS`` are the arguments to -# pass to the MPI program. -# -# Advanced variables for using MPI -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -# -# The module can perform some advanced feature detections upon explicit request. -# -# **Important notice:** The following checks cannot be performed without *executing* an MPI test program. -# Consider the special considerations for the behavior of :command:`try_run` during cross compilation. -# Moreover, running an MPI program can cause additional issues, like a firewall notification on some systems. -# You should only enable these detections if you absolutely need the information. -# -# If the following variables are set to true, the respective search will be performed: -# -# ``MPI_DETERMINE_Fortran_CAPABILITIES`` -# Determine for all available Fortran bindings what the values of ``MPI_SUBARRAYS_SUPPORTED`` and -# ``MPI_ASYNC_PROTECTS_NONBLOCKING`` are and make their values available as ``MPI_Fortran__SUBARRAYS`` -# and ``MPI_Fortran__ASYNCPROT``, where ```` is one of ``F77_HEADER``, ``F90_MODULE`` and -# ``F08_MODULE``. -# ``MPI_DETERMINE_LIBRARY_VERSION`` -# For each language, find the output of ``MPI_Get_library_version`` and make it available as ``MPI__LIBRARY_VERSION``. -# This information is usually tied to the runtime component of an MPI implementation and might differ depending on ````. -# Note that the return value is entirely implementation defined. This information might be used to identify -# the MPI vendor and for example pick the correct one of multiple third party binaries that matches the MPI vendor. -# -# Backward Compatibility -# ^^^^^^^^^^^^^^^^^^^^^^ -# -# For backward compatibility with older versions of FindMPI, these -# variables are set, but deprecated: -# -# :: -# -# MPI_COMPILER MPI_LIBRARY MPI_EXTRA_LIBRARY -# MPI_COMPILE_FLAGS MPI_INCLUDE_PATH MPI_LINK_FLAGS -# MPI_LIBRARIES -# -# In new projects, please use the ``MPI__XXX`` equivalents. -# Additionally, the following variables are deprecated: -# -# ``MPI__COMPILE_FLAGS`` -# Use ``MPI__COMPILE_OPTIONS`` and ``MPI__COMPILE_DEFINITIONS`` instead. -# ``MPI__INCLUDE_PATH`` -# For consumption use ``MPI__INCLUDE_DIRS`` and for specifying folders use ``MPI__ADDITIONAL_INCLUDE_DIRS`` instead. -# ``MPIEXEC`` -# Use ``MPIEXEC_EXECUTABLE`` instead. - -cmake_policy(PUSH) -cmake_policy(SET CMP0057 NEW) # if IN_LIST - -include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) - -# Generic compiler names -set(_MPI_C_GENERIC_COMPILER_NAMES mpicc mpcc mpicc_r mpcc_r) -set(_MPI_CXX_GENERIC_COMPILER_NAMES mpicxx mpiCC mpcxx mpCC mpic++ mpc++ - mpicxx_r mpiCC_r mpcxx_r mpCC_r mpic++_r mpc++_r) -set(_MPI_Fortran_GENERIC_COMPILER_NAMES mpif95 mpif95_r mpf95 mpf95_r - mpif90 mpif90_r mpf90 mpf90_r - mpif77 mpif77_r mpf77 mpf77_r - mpifc) - -# GNU compiler names -set(_MPI_GNU_C_COMPILER_NAMES mpigcc mpgcc mpigcc_r mpgcc_r) -set(_MPI_GNU_CXX_COMPILER_NAMES mpig++ mpg++ mpig++_r mpg++_r mpigxx) -set(_MPI_GNU_Fortran_COMPILER_NAMES mpigfortran mpgfortran mpigfortran_r mpgfortran_r - mpig77 mpig77_r mpg77 mpg77_r) - -# Intel MPI compiler names on Windows -if(WIN32) - list(APPEND _MPI_C_GENERIC_COMPILER_NAMES mpicc.bat) - list(APPEND _MPI_CXX_GENERIC_COMPILER_NAMES mpicxx.bat) - list(APPEND _MPI_Fortran_GENERIC_COMPILER_NAMES mpifc.bat) - - # Intel MPI compiler names - set(_MPI_Intel_C_COMPILER_NAMES mpiicc.bat) - set(_MPI_Intel_CXX_COMPILER_NAMES mpiicpc.bat) - set(_MPI_Intel_Fortran_COMPILER_NAMES mpiifort.bat mpif77.bat mpif90.bat) - - # Intel MPI compiler names for MSMPI - set(_MPI_MSVC_C_COMPILER_NAMES mpicl.bat) - set(_MPI_MSVC_CXX_COMPILER_NAMES mpicl.bat) -else() - # Intel compiler names - set(_MPI_Intel_C_COMPILER_NAMES mpiicc) - set(_MPI_Intel_CXX_COMPILER_NAMES mpiicpc mpiicxx mpiic++) - set(_MPI_Intel_Fortran_COMPILER_NAMES mpiifort mpiif95 mpiif90 mpiif77) -endif() - -# PGI compiler names -set(_MPI_PGI_C_COMPILER_NAMES mpipgcc mppgcc) -set(_MPI_PGI_CXX_COMPILER_NAMES mpipgCC mppgCC) -set(_MPI_PGI_Fortran_COMPILER_NAMES mpipgf95 mpipgf90 mppgf95 mppgf90 mpipgf77 mppgf77) - -# XLC MPI Compiler names -set(_MPI_XL_C_COMPILER_NAMES mpxlc mpxlc_r mpixlc mpixlc_r) -set(_MPI_XL_CXX_COMPILER_NAMES mpixlcxx mpixlC mpixlc++ mpxlcxx mpxlc++ mpixlc++ mpxlCC - mpixlcxx_r mpixlC_r mpixlc++_r mpxlcxx_r mpxlc++_r mpixlc++_r mpxlCC_r) -set(_MPI_XL_Fortran_COMPILER_NAMES mpixlf95 mpixlf95_r mpxlf95 mpxlf95_r - mpixlf90 mpixlf90_r mpxlf90 mpxlf90_r - mpixlf77 mpixlf77_r mpxlf77 mpxlf77_r - mpixlf mpixlf_r mpxlf mpxlf_r) - -# Prepend vendor-specific compiler wrappers to the list. If we don't know the compiler, -# attempt all of them. -# By attempting vendor-specific compiler names first, we should avoid situations where the compiler wrapper -# stems from a proprietary MPI and won't know which compiler it's being used for. For instance, Intel MPI -# controls its settings via the I_MPI_CC environment variables if the generic name is being used. -# If we know which compiler we're working with, we can use the most specialized wrapper there is in order to -# pick up the right settings for it. -foreach (LANG IN ITEMS C CXX Fortran) - set(_MPI_${LANG}_COMPILER_NAMES "") - foreach (id IN ITEMS GNU Intel MSVC PGI XL) - if (NOT CMAKE_${LANG}_COMPILER_ID OR CMAKE_${LANG}_COMPILER_ID STREQUAL id) - list(APPEND _MPI_${LANG}_COMPILER_NAMES ${_MPI_${id}_${LANG}_COMPILER_NAMES}${MPI_EXECUTABLE_SUFFIX}) - endif() - unset(_MPI_${id}_${LANG}_COMPILER_NAMES) - endforeach() - list(APPEND _MPI_${LANG}_COMPILER_NAMES ${_MPI_${LANG}_GENERIC_COMPILER_NAMES}${MPI_EXECUTABLE_SUFFIX}) - unset(_MPI_${LANG}_GENERIC_COMPILER_NAMES) -endforeach() - -# Names to try for mpiexec -# Only mpiexec commands are guaranteed to behave as described in the standard, -# mpirun commands are not covered by the standard in any way whatsoever. -# lamexec is the executable for LAM/MPI, srun is for SLURM or Open MPI with SLURM support. -# srun -n X is however a valid command, so it behaves 'like' mpiexec. -set(_MPIEXEC_NAMES_BASE mpiexec mpiexec.hydra mpiexec.mpd mpirun lamexec srun) - -unset(_MPIEXEC_NAMES) -foreach(_MPIEXEC_NAME IN LISTS _MPIEXEC_NAMES_BASE) - list(APPEND _MPIEXEC_NAMES "${_MPIEXEC_NAME}${MPI_EXECUTABLE_SUFFIX}") -endforeach() -unset(_MPIEXEC_NAMES_BASE) - -function (_MPI_check_compiler LANG QUERY_FLAG OUTPUT_VARIABLE RESULT_VARIABLE) - if(DEFINED MPI_${LANG}_COMPILER_FLAGS) -# separate_arguments(_MPI_COMPILER_WRAPPER_OPTIONS NATIVE_COMMAND "${MPI_${LANG}_COMPILER_FLAGS}") - separate_arguments(_MPI_COMPILER_WRAPPER_OPTIONS "${MPI_${LANG}_COMPILER_FLAGS}") - else() - separate_arguments(_MPI_COMPILER_WRAPPER_OPTIONS NATIVE_COMMAND "${MPI_COMPILER_FLAGS}") - endif() - execute_process( - COMMAND ${MPI_${LANG}_COMPILER} ${_MPI_COMPILER_WRAPPER_OPTIONS} ${QUERY_FLAG} - OUTPUT_VARIABLE WRAPPER_OUTPUT OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_VARIABLE WRAPPER_OUTPUT ERROR_STRIP_TRAILING_WHITESPACE - RESULT_VARIABLE WRAPPER_RETURN) - # Some compiler wrappers will yield spurious zero return values, for example - # Intel MPI tolerates unknown arguments and if the MPI wrappers loads a shared - # library that has invalid or missing version information there would be warning - # messages emitted by ld.so in the compiler output. In either case, we'll treat - # the output as invalid. - if("${WRAPPER_OUTPUT}" MATCHES "undefined reference|unrecognized|need to set|no version information available") - set(WRAPPER_RETURN 255) - endif() - # Ensure that no error output might be passed upwards. - if(NOT WRAPPER_RETURN EQUAL 0) - unset(WRAPPER_OUTPUT) - endif() - set(${OUTPUT_VARIABLE} "${WRAPPER_OUTPUT}" PARENT_SCOPE) - set(${RESULT_VARIABLE} "${WRAPPER_RETURN}" PARENT_SCOPE) -endfunction() - -function (_MPI_interrogate_compiler lang) - unset(MPI_COMPILE_CMDLINE) - unset(MPI_LINK_CMDLINE) - - unset(MPI_COMPILE_OPTIONS_WORK) - unset(MPI_COMPILE_DEFINITIONS_WORK) - unset(MPI_INCLUDE_DIRS_WORK) - unset(MPI_LINK_FLAGS_WORK) - unset(MPI_LIB_NAMES_WORK) - unset(MPI_LIB_FULLPATHS_WORK) - - # Check whether the -showme:compile option works. This indicates that we have either Open MPI - # or a newer version of LAM/MPI, and implies that -showme:link will also work. - # Open MPI also supports -show, but separates linker and compiler information - _MPI_check_compiler(${LANG} "-showme:compile" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) - if (MPI_COMPILER_RETURN EQUAL 0) - _MPI_check_compiler(${LANG} "-showme:link" MPI_LINK_CMDLINE MPI_COMPILER_RETURN) - - if (NOT MPI_COMPILER_RETURN EQUAL 0) - unset(MPI_COMPILE_CMDLINE) - endif() - endif() - - # MPICH and MVAPICH offer -compile-info and -link-info. - # For modern versions, both do the same as -show. However, for old versions, they do differ - # when called for mpicxx and mpif90 and it's necessary to use them over -show in order to find the - # removed MPI C++ bindings. - if (NOT MPI_COMPILER_RETURN EQUAL 0) - _MPI_check_compiler(${LANG} "-compile-info" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) - - if (MPI_COMPILER_RETURN EQUAL 0) - _MPI_check_compiler(${LANG} "-link-info" MPI_LINK_CMDLINE MPI_COMPILER_RETURN) - - if (NOT MPI_COMPILER_RETURN EQUAL 0) - unset(MPI_COMPILE_CMDLINE) - endif() - endif() - endif() - - # MPICH, MVAPICH2 and Intel MPI just use "-show". Open MPI also offers this, but the - # -showme commands are more specialized. - if (NOT MPI_COMPILER_RETURN EQUAL 0) - _MPI_check_compiler(${LANG} "-show" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) - endif() - - # Older versions of LAM/MPI have "-showme". Open MPI also supports this. - # Unknown to MPICH, MVAPICH and Intel MPI. - if (NOT MPI_COMPILER_RETURN EQUAL 0) - _MPI_check_compiler(${LANG} "-showme" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) - endif() - - if (NOT (MPI_COMPILER_RETURN EQUAL 0) OR NOT (DEFINED MPI_COMPILE_CMDLINE)) - # Cannot interrogate this compiler, so exit. - set(MPI_${LANG}_WRAPPER_FOUND FALSE PARENT_SCOPE) - return() - endif() - unset(MPI_COMPILER_RETURN) - - # We have our command lines, but we might need to copy MPI_COMPILE_CMDLINE - # into MPI_LINK_CMDLINE, if we didn't find the link line. - if (NOT DEFINED MPI_LINK_CMDLINE) - set(MPI_LINK_CMDLINE "${MPI_COMPILE_CMDLINE}") - endif() - - # At this point, we obtained some output from a compiler wrapper that works. - # We'll now try to parse it into variables with meaning to us. - if("${LANG}" STREQUAL "Fortran") - # Some MPICH-1 and MVAPICH-1 versions return a three command answer for Fortran, consisting - # out of a symlink command for mpif.h, the actual compiler command and a deletion of the - # created symlink. We need to detect that case, remember the include path and drop the - # symlink/deletion operation to obtain the link/compile lines we'd usually expect. - if("${MPI_COMPILE_CMDLINE}" MATCHES "^ln -s ([^\" ]+|\"[^\"]+\") mpif.h") - get_filename_component(MPI_INCLUDE_DIRS_WORK "${CMAKE_MATCH_1}" DIRECTORY) - string(REGEX REPLACE "^ln -s ([^\" ]+|\"[^\"]+\") mpif.h\n" "" MPI_COMPILE_CMDLINE "${MPI_COMPILE_CMDLINE}") - string(REGEX REPLACE "^ln -s ([^\" ]+|\"[^\"]+\") mpif.h\n" "" MPI_LINK_CMDLINE "${MPI_LINK_CMDLINE}") - string(REGEX REPLACE "\nrm -f mpif.h$" "" MPI_COMPILE_CMDLINE "${MPI_COMPILE_CMDLINE}") - string(REGEX REPLACE "\nrm -f mpif.h$" "" MPI_LINK_CMDLINE "${MPI_LINK_CMDLINE}") - endif() - endif() - - # The Intel MPI wrapper on Linux will emit some objcopy commands after its compile command - # if -static_mpi was passed to the wrapper. To avoid spurious matches, we need to drop these lines. - if(UNIX) - string(REGEX REPLACE "(^|\n)objcopy[^\n]+(\n|$)" "" MPI_COMPILE_CMDLINE "${MPI_COMPILE_CMDLINE}") - string(REGEX REPLACE "(^|\n)objcopy[^\n]+(\n|$)" "" MPI_LINK_CMDLINE "${MPI_LINK_CMDLINE}") - endif() - - # Extract compile options from the compile command line. - string(REGEX MATCHALL "(^| )-f([^\" ]+|\"[^\"]+\")" MPI_ALL_COMPILE_OPTIONS "${MPI_COMPILE_CMDLINE}") - - foreach(_MPI_COMPILE_OPTION IN LISTS MPI_ALL_COMPILE_OPTIONS) - string(REGEX REPLACE "^ " "" _MPI_COMPILE_OPTION "${_MPI_COMPILE_OPTION}") - # Ignore -fstack-protector directives: These occur on MPICH and MVAPICH when the libraries - # themselves were built with this flag. However, this flag is unrelated to using MPI, and - # we won't match the accompanying --param-ssp-size and -Wp,-D_FORTIFY_SOURCE flags and therefore - # produce inconsistent results with the regularly flags. - # Similarly, aliasing flags do not belong into our flag array. - if(NOT "${_MPI_COMPILE_OPTION}" MATCHES "^-f(stack-protector|(no-|)strict-aliasing|PI[CE]|pi[ce])") - list(APPEND MPI_COMPILE_OPTIONS_WORK "${_MPI_COMPILE_OPTION}") - endif() - endforeach() - - # Same deal, with the definitions. We also treat arguments passed to the preprocessor directly. - string(REGEX MATCHALL "(^| )(-Wp,|-Xpreprocessor |)[-/]D([^\" ]+|\"[^\"]+\")" MPI_ALL_COMPILE_DEFINITIONS "${MPI_COMPILE_CMDLINE}") - - foreach(_MPI_COMPILE_DEFINITION IN LISTS MPI_ALL_COMPILE_DEFINITIONS) - string(REGEX REPLACE "^ ?(-Wp,|-Xpreprocessor )?[-/]D" "" _MPI_COMPILE_DEFINITION "${_MPI_COMPILE_DEFINITION}") - string(REPLACE "\"" "" _MPI_COMPILE_DEFINITION "${_MPI_COMPILE_DEFINITION}") - if(NOT "${_MPI_COMPILE_DEFINITION}" MATCHES "^_FORTIFY_SOURCE.*") - list(APPEND MPI_COMPILE_DEFINITIONS_WORK "${_MPI_COMPILE_DEFINITION}") - endif() - endforeach() - - # Extract include paths from compile command line - string(REGEX MATCHALL "(^| )[-/]I([^\" ]+|\"[^\"]+\")" MPI_ALL_INCLUDE_PATHS "${MPI_COMPILE_CMDLINE}") - - # If extracting failed to work, we'll try using -showme:incdirs. - if (NOT MPI_ALL_INCLUDE_PATHS) - _MPI_check_compiler(${LANG} "-showme:incdirs" MPI_INCDIRS_CMDLINE MPI_INCDIRS_COMPILER_RETURN) - if(MPI_INCDIRS_COMPILER_RETURN) - separate_arguments(MPI_ALL_INCLUDE_PATHS NATIVE_COMMAND "${MPI_INCDIRS_CMDLINE}") - endif() - endif() - - foreach(_MPI_INCLUDE_PATH IN LISTS MPI_ALL_INCLUDE_PATHS) - string(REGEX REPLACE "^ ?[-/]I" "" _MPI_INCLUDE_PATH "${_MPI_INCLUDE_PATH}") - string(REPLACE "\"" "" _MPI_INCLUDE_PATH "${_MPI_INCLUDE_PATH}") - get_filename_component(_MPI_INCLUDE_PATH "${_MPI_INCLUDE_PATH}" REALPATH) - list(APPEND MPI_INCLUDE_DIRS_WORK "${_MPI_INCLUDE_PATH}") - endforeach() - - # Extract linker paths from the link command line - string(REGEX MATCHALL "(^| )(-Wl,|-Xlinker |)(-L|[/-]LIBPATH:|[/-]libpath:)([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_PATHS "${MPI_LINK_CMDLINE}") - - # If extracting failed to work, we'll try using -showme:libdirs. - if (NOT MPI_ALL_LINK_PATHS) - _MPI_check_compiler(${LANG} "-showme:libdirs" MPI_LIBDIRS_CMDLINE MPI_LIBDIRS_COMPILER_RETURN) - if(MPI_LIBDIRS_COMPILER_RETURN) - separate_arguments(MPI_ALL_LINK_PATHS NATIVE_COMMAND "${MPI_LIBDIRS_CMDLINE}") - endif() - endif() - - foreach(_MPI_LPATH IN LISTS MPI_ALL_LINK_PATHS) - string(REGEX REPLACE "^ ?(-Wl,|-Xlinker )?(-L|[/-]LIBPATH:|[/-]libpath:)" "" _MPI_LPATH "${_MPI_LPATH}") - string(REPLACE "\"" "" _MPI_LPATH "${_MPI_LPATH}") - get_filename_component(_MPI_LPATH "${_MPI_LPATH}" REALPATH) - list(APPEND MPI_LINK_DIRECTORIES_WORK "${_MPI_LPATH}") - endforeach() - - # Extract linker flags from the link command line - string(REGEX MATCHALL "(^| )(-Wl,|-Xlinker )([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_FLAGS "${MPI_LINK_CMDLINE}") - - foreach(_MPI_LINK_FLAG IN LISTS MPI_ALL_LINK_FLAGS) - string(STRIP "${_MPI_LINK_FLAG}" _MPI_LINK_FLAG) - # MPI might be marked to build with non-executable stacks but this should not propagate. - if (NOT "${_MPI_LINK_FLAG}" MATCHES "(-Wl,|-Xlinker )-z,noexecstack") - if (MPI_LINK_FLAGS_WORK) - string(APPEND MPI_LINK_FLAGS_WORK " ${_MPI_LINK_FLAG}") - else() - set(MPI_LINK_FLAGS_WORK "${_MPI_LINK_FLAG}") - endif() - endif() - endforeach() - - # Extract the set of libraries to link against from the link command - # line - string(REGEX MATCHALL "(^| )-l([^\" ]+|\"[^\"]+\")" MPI_LIBNAMES "${MPI_LINK_CMDLINE}") - - foreach(_MPI_LIB_NAME IN LISTS MPI_LIBNAMES) - string(REGEX REPLACE "^ ?-l" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") - string(REPLACE "\"" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") - get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_NAME}" DIRECTORY) - if(NOT "${_MPI_LIB_PATH}" STREQUAL "") - list(APPEND MPI_LIB_FULLPATHS_WORK "${_MPI_LIB_NAME}") - else() - list(APPEND MPI_LIB_NAMES_WORK "${_MPI_LIB_NAME}") - endif() - endforeach() - - if(WIN32) - # A compiler wrapper on Windows will just have the name of the - # library to link on its link line, potentially with a full path - string(REGEX MATCHALL "(^| )([^\" ]+\\.lib|\"[^\"]+\\.lib\")" MPI_LIBNAMES "${MPI_LINK_CMDLINE}") - foreach(_MPI_LIB_NAME IN LISTS MPI_LIBNAMES) - string(REGEX REPLACE "^ " "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") - string(REPLACE "\"" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") - get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_NAME}" DIRECTORY) - if(NOT "${_MPI_LIB_PATH}" STREQUAL "") - list(APPEND MPI_LIB_FULLPATHS_WORK "${_MPI_LIB_NAME}") - else() - list(APPEND MPI_LIB_NAMES_WORK "${_MPI_LIB_NAME}") - endif() - endforeach() - else() - # On UNIX platforms, archive libraries can be given with full path. - string(REGEX MATCHALL "(^| )([^\" ]+\\.a|\"[^\"]+\\.a\")" MPI_LIBFULLPATHS "${MPI_LINK_CMDLINE}") - foreach(_MPI_LIB_NAME IN LISTS MPI_LIBFULLPATHS) - string(REGEX REPLACE "^ " "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") - string(REPLACE "\"" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") - get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_NAME}" DIRECTORY) - if(NOT "${_MPI_LIB_PATH}" STREQUAL "") - list(APPEND MPI_LIB_FULLPATHS_WORK "${_MPI_LIB_NAME}") - else() - list(APPEND MPI_LIB_NAMES_WORK "${_MPI_LIB_NAME}") - endif() - endforeach() - endif() - - # An MPI compiler wrapper could have its MPI libraries in the implictly - # linked directories of the compiler itself. - if(DEFINED CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES) - list(APPEND MPI_LINK_DIRECTORIES_WORK "${CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES}") - endif() - - # Determine full path names for all of the libraries that one needs - # to link against in an MPI program - unset(MPI_PLAIN_LIB_NAMES_WORK) - foreach(_MPI_LIB_NAME IN LISTS MPI_LIB_NAMES_WORK) - get_filename_component(_MPI_PLAIN_LIB_NAME "${_MPI_LIB_NAME}" NAME_WE) - list(APPEND MPI_PLAIN_LIB_NAMES_WORK "${_MPI_PLAIN_LIB_NAME}") - find_library(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY - NAMES "${_MPI_LIB_NAME}" "lib${_MPI_LIB_NAME}" - HINTS ${MPI_LINK_DIRECTORIES_WORK} - DOC "Location of the ${_MPI_PLAIN_LIB_NAME} library for MPI" - ) - mark_as_advanced(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY) - endforeach() - - # Deal with the libraries given with full path next - unset(MPI_DIRECT_LIB_NAMES_WORK) - foreach(_MPI_LIB_FULLPATH IN LISTS MPI_LIB_FULLPATHS_WORK) - get_filename_component(_MPI_PLAIN_LIB_NAME "${_MPI_LIB_FULLPATH}" NAME_WE) - get_filename_component(_MPI_LIB_NAME "${_MPI_LIB_FULLPATH}" NAME) - get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_FULLPATH}" DIRECTORY) - list(APPEND MPI_DIRECT_LIB_NAMES_WORK "${_MPI_PLAIN_LIB_NAME}") - find_library(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY - NAMES "${_MPI_LIB_NAME}" - HINTS ${_MPI_LIB_PATH} - DOC "Location of the ${_MPI_PLAIN_LIB_NAME} library for MPI" - ) - mark_as_advanced(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY) - endforeach() - if(MPI_DIRECT_LIB_NAMES_WORK) - set(MPI_PLAIN_LIB_NAMES_WORK "${MPI_DIRECT_LIB_NAMES_WORK};${MPI_PLAIN_LIB_NAMES_WORK}") - endif() - - # MPI might require pthread to work. The above mechanism wouldn't detect it, but we need to - # link it in that case. -lpthread is covered by the normal library treatment on the other hand. - if("${MPI_COMPILE_CMDLINE}" MATCHES "-pthread") - list(APPEND MPI_COMPILE_OPTIONS_WORK "-pthread") - if(MPI_LINK_FLAGS_WORK) - string(APPEND MPI_LINK_FLAGS_WORK " -pthread") - else() - set(MPI_LINK_FLAGS_WORK "-pthread") - endif() - endif() - - if(MPI_${LANG}_EXTRA_COMPILE_DEFINITIONS) - list(APPEND MPI_COMPILE_DEFINITIONS_WORK "${MPI_${LANG}_EXTRA_COMPILE_DEFINITIONS}") - endif() - if(MPI_${LANG}_EXTRA_COMPILE_OPTIONS) - list(APPEND MPI_COMPILE_OPTIONS_WORK "${MPI_${LANG}_EXTRA_COMPILE_OPTIONS}") - endif() - if(MPI_${LANG}_EXTRA_LIB_NAMES) - list(APPEND MPI_PLAIN_LIB_NAMES_WORK "${MPI_${LANG}_EXTRA_LIB_NAMES}") - endif() - - # If we found MPI, set up all of the appropriate cache entries - if(NOT MPI_${LANG}_COMPILE_OPTIONS) - set(MPI_${LANG}_COMPILE_OPTIONS ${MPI_COMPILE_OPTIONS_WORK} CACHE STRING "MPI ${LANG} compilation options" FORCE) - endif() - if(NOT MPI_${LANG}_COMPILE_DEFINITIONS) - set(MPI_${LANG}_COMPILE_DEFINITIONS ${MPI_COMPILE_DEFINITIONS_WORK} CACHE STRING "MPI ${LANG} compilation definitions" FORCE) - endif() - if(NOT MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) - set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_INCLUDE_DIRS_WORK} CACHE STRING "MPI ${LANG} additional include directories" FORCE) - endif() - if(NOT MPI_${LANG}_LINK_FLAGS) - set(MPI_${LANG}_LINK_FLAGS ${MPI_LINK_FLAGS_WORK} CACHE STRING "MPI ${LANG} linker flags" FORCE) - endif() - if(NOT MPI_${LANG}_LIB_NAMES) - set(MPI_${LANG}_LIB_NAMES ${MPI_PLAIN_LIB_NAMES_WORK} CACHE STRING "MPI ${LANG} libraries to link against" FORCE) - endif() - set(MPI_${LANG}_WRAPPER_FOUND TRUE PARENT_SCOPE) -endfunction() - -function(_MPI_guess_settings LANG) - set(MPI_GUESS_FOUND FALSE) - # Currently only MSMPI and MPICH2 on Windows are supported, so we can skip this search if we're not targeting that. - if(WIN32) - # MSMPI - - # The environment variables MSMPI_INC and MSMPILIB32/64 are the only ways of locating the MSMPI_SDK, - # which is installed separately from the runtime. Thus it's possible to have mpiexec but not MPI headers - # or import libraries and vice versa. - if(NOT MPI_GUESS_LIBRARY_NAME OR "${MPI_GUESS_LIBRARY_NAME}" STREQUAL "MSMPI") - # We first attempt to locate the msmpi.lib. Should be find it, we'll assume that the MPI present is indeed - # Microsoft MPI. - if("${CMAKE_SIZEOF_VOID_P}" EQUAL 8) - set(MPI_MSMPI_LIB_PATH "$ENV{MSMPI_LIB64}") - set(MPI_MSMPI_INC_PATH_EXTRA "$ENV{MSMPI_INC}/x64") - else() - set(MPI_MSMPI_LIB_PATH "$ENV{MSMPI_LIB32}") - set(MPI_MSMPI_INC_PATH_EXTRA "$ENV{MSMPI_INC}/x86") - endif() - - find_library(MPI_msmpi_LIBRARY - NAMES msmpi - HINTS ${MPI_MSMPI_LIB_PATH} - DOC "Location of the msmpi library for Microsoft MPI") - mark_as_advanced(MPI_msmpi_LIBRARY) - - if(MPI_msmpi_LIBRARY) - # Next, we attempt to locate the MPI header. Note that for Fortran we know that mpif.h is a way - # MSMPI can be used and therefore that header has to be present. - if(NOT MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) - get_filename_component(MPI_MSMPI_INC_DIR "$ENV{MSMPI_INC}" REALPATH) - set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_MSMPI_INC_DIR}" CACHE STRING "MPI ${LANG} additional include directories" FORCE) - unset(MPI_MSMPI_INC_DIR) - endif() - - # For MSMPI, one can compile the MPI module by building the mpi.f90 shipped with the MSMPI SDK, - # thus it might be present or provided by the user. Figuring out which is supported is done later on. - # The PGI Fortran compiler for instance ships a prebuilt set of modules in its own include folder. - # Should a user be employing PGI or have built its own set and provided it via cache variables, the - # splitting routine would have located the module files. - - # For C and C++, we're done here (MSMPI does not ship the MPI-2 C++ bindings) - however, for Fortran - # we need some extra library to glue Fortran support together: - # MSMPI ships 2-4 Fortran libraries, each for different Fortran compiler behaviors. The library names - # ending with a c are using the cdecl calling convention, whereas those ending with an s are for Fortran - # implementations using stdcall. Therefore, the 64-bit MSMPI only ships those ending in 'c', whereas the 32-bit - # has both variants available. - # The second difference is the last but one letter, if it's an e(nd), the length of a string argument is - # passed by the Fortran compiler after all other arguments on the parameter list, if it's an m(ixed), - # it's passed immediately after the string address. - - # To summarize: - # - msmpifec: CHARACTER length passed after the parameter list and using cdecl calling convention - # - msmpifmc: CHARACTER length passed directly after string address and using cdecl calling convention - # - msmpifes: CHARACTER length passed after the parameter list and using stdcall calling convention - # - msmpifms: CHARACTER length passed directly after string address and using stdcall calling convention - # 32-bit MSMPI ships all four libraries, 64-bit MSMPI ships only the first two. - - # As is, Intel Fortran and PGI Fortran both use the 'ec' variant of the calling convention, whereas - # the old Compaq Visual Fortran compiler defaulted to the 'ms' version. It's possible to make Intel Fortran - # use the CVF calling convention using /iface:cvf, but we assume - and this is also assumed in FortranCInterface - - # this isn't the case. It's also possible to make CVF use the 'ec' variant, using /iface=(cref,nomixed_str_len_arg). - - # Our strategy is now to locate all libraries, but enter msmpifec into the LIB_NAMES array. - # Should this not be adequate it's a straightforward way for a user to change the LIB_NAMES array and - # have his library found. Still, this should not be necessary outside of exceptional cases, as reasoned. - if ("${LANG}" STREQUAL "Fortran") - set(MPI_MSMPI_CALLINGCONVS c) - if("${CMAKE_SIZEOF_VOID_P}" EQUAL 4) - list(APPEND MPI_MSMPI_CALLINGCONVS s) - endif() - foreach(mpistrlenpos IN ITEMS e m) - foreach(mpicallingconv IN LISTS MPI_MSMPI_CALLINGCONVS) - find_library(MPI_msmpif${mpistrlenpos}${mpicallingconv}_LIBRARY - NAMES msmpif${mpistrlenpos}${mpicallingconv} - HINTS "${MPI_MSMPI_LIB_PATH}" - DOC "Location of the msmpi${mpistrlenpos}${mpicallingconv} library for Microsoft MPI") - mark_as_advanced(MPI_msmpif${mpistrlenpos}${mpicallingconv}_LIBRARY) - endforeach() - endforeach() - if(NOT MPI_${LANG}_LIB_NAMES) - set(MPI_${LANG}_LIB_NAMES "msmpi;msmpifec" CACHE STRING "MPI ${LANG} libraries to link against" FORCE) - endif() - - # At this point we're *not* done. MSMPI requires an additional include file for Fortran giving the value - # of MPI_AINT. This file is called mpifptr.h located in the x64 and x86 subfolders, respectively. - find_path(MPI_mpifptr_INCLUDE_DIR - NAMES "mpifptr.h" - HINTS "${MPI_MSMPI_INC_PATH_EXTRA}" - DOC "Location of the mpifptr.h extra header for Microsoft MPI") - if(NOT MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) - set(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS "mpifptr" CACHE STRING "MPI ${LANG} additional include directory variables, given in the form MPI__INCLUDE_DIR." FORCE) - endif() - mark_as_advanced(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS MPI_mpifptr_INCLUDE_DIR) - else() - if(NOT MPI_${LANG}_LIB_NAMES) - set(MPI_${LANG}_LIB_NAMES "msmpi" CACHE STRING "MPI ${LANG} libraries to link against" FORCE) - endif() - endif() - mark_as_advanced(MPI_${LANG}_LIB_NAMES) - set(MPI_GUESS_FOUND TRUE) - endif() - endif() - - # At this point there's not many MPIs that we could still consider. - # OpenMPI 1.6.x and below supported Windows, but these ship compiler wrappers that still work. - # The only other relevant MPI implementation without a wrapper is MPICH2, which had Windows support in 1.4.1p1 and older. - if(NOT MPI_GUESS_LIBRARY_NAME OR "${MPI_GUESS_LIBRARY_NAME}" STREQUAL "MPICH2") - set(MPI_MPICH_PREFIX_PATHS - "$ENV{ProgramW6432}/MPICH2/lib" - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH\\SMPD;binary]/../lib" - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH2;Path]/lib" - ) - - # All of C, C++ and Fortran will need mpi.lib, so we'll look for this first - find_library(MPI_mpi_LIBRARY - NAMES mpi - HINTS ${MPI_MPICH_PREFIX_PATHS}) - mark_as_advanced(MPI_mpi_LIBRARY) - # If we found mpi.lib, we detect the rest of MPICH2 - if(MPI_mpi_LIBRARY) - set(MPI_MPICH_LIB_NAMES "mpi") - # If MPI-2 C++ bindings are requested, we need to locate cxx.lib as well. - # Otherwise, MPICH_SKIP_MPICXX will be defined and these bindings aren't needed. - if("${LANG}" STREQUAL "CXX" AND NOT MPI_CXX_SKIP_MPICXX) - find_library(MPI_cxx_LIBRARY - NAMES cxx - HINTS ${MPI_MPICH_PREFIX_PATHS}) - mark_as_advanced(MPI_cxx_LIBRARY) - list(APPEND MPI_MPICH_LIB_NAMES "cxx") - # For Fortran, MPICH2 provides three different libraries: - # fmpich2.lib which uses uppercase symbols and cdecl, - # fmpich2s.lib which uses uppercase symbols and stdcall (32-bit only), - # fmpich2g.lib which uses lowercase symbols with double underscores and cdecl. - # fmpich2s.lib would be useful for Compaq Visual Fortran, fmpich2g.lib has to be used with GNU g77 and is also - # provided in the form of an .a archive for MinGW and Cygwin. From our perspective, fmpich2.lib is the only one - # we need to try, and if it doesn't work with the given Fortran compiler we'd find out later on during validation - elseif("${LANG}" STREQUAL "Fortran") - find_library(MPI_fmpich2_LIBRARY - NAMES fmpich2 - HINTS ${MPI_MPICH_PREFIX_PATHS}) - find_library(MPI_fmpich2s_LIBRARY - NAMES fmpich2s - HINTS ${MPI_MPICH_PREFIX_PATHS}) - find_library(MPI_fmpich2g_LIBRARY - NAMES fmpich2g - HINTS ${MPI_MPICH_PREFIX_PATHS}) - mark_as_advanced(MPI_fmpich2_LIBRARY MPI_fmpich2s_LIBRARY MPI_fmpich2g_LIBRARY) - list(APPEND MPI_MPICH_LIB_NAMES "fmpich2") - endif() - - if(NOT MPI_${LANG}_LIB_NAMES) - set(MPI_${LANG}_LIB_NAMES "${MPI_MPICH_LIB_NAMES}" CACHE STRING "MPI ${LANG} libraries to link against" FORCE) - endif() - unset(MPI_MPICH_LIB_NAMES) - - if(NOT MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) - # For MPICH2, the include folder would be in ../include relative to the library folder. - get_filename_component(MPI_MPICH_ROOT_DIR "${MPI_mpi_LIBRARY}" DIRECTORY) - get_filename_component(MPI_MPICH_ROOT_DIR "${MPI_MPICH_ROOT_DIR}" DIRECTORY) - if(IS_DIRECTORY "${MPI_MPICH_ROOT_DIR}/include") - set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_MPICH_ROOT_DIR}/include" CACHE STRING "MPI ${LANG} additional include directory variables, given in the form MPI__INCLUDE_DIR." FORCE) - endif() - unset(MPI_MPICH_ROOT_DIR) - endif() - set(MPI_GUESS_FOUND TRUE) - endif() - unset(MPI_MPICH_PREFIX_PATHS) - endif() - endif() - set(MPI_${LANG}_GUESS_FOUND "${MPI_GUESS_FOUND}" PARENT_SCOPE) -endfunction() - -function(_MPI_adjust_compile_definitions LANG) - if("${LANG}" STREQUAL "CXX") - # To disable the C++ bindings, we need to pass some definitions since the mpi.h header has to deal with both C and C++ - # bindings in MPI-2. - if(MPI_CXX_SKIP_MPICXX AND NOT MPI_${LANG}_COMPILE_DEFINITIONS MATCHES "SKIP_MPICXX") - # MPICH_SKIP_MPICXX is being used in MPICH and derivatives like MVAPICH or Intel MPI - # OMPI_SKIP_MPICXX is being used in Open MPI - # _MPICC_H is being used for IBM Platform MPI - list(APPEND MPI_${LANG}_COMPILE_DEFINITIONS "MPICH_SKIP_MPICXX" "OMPI_SKIP_MPICXX" "_MPICC_H") - set(MPI_${LANG}_COMPILE_DEFINITIONS "${MPI_${LANG}_COMPILE_DEFINITIONS}" CACHE STRING "MPI ${LANG} compilation definitions" FORCE) - endif() - endif() -endfunction() - -macro(_MPI_assemble_libraries LANG) - set(MPI_${LANG}_LIBRARIES "") - # Only for libraries do we need to check whether the compiler's linking stage is separate. - if(NOT "${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}" OR NOT MPI_${LANG}_WORKS_IMPLICIT) - foreach(mpilib IN LISTS MPI_${LANG}_LIB_NAMES) - list(APPEND MPI_${LANG}_LIBRARIES ${MPI_${mpilib}_LIBRARY}) - endforeach() - endif() -endmacro() - -macro(_MPI_assemble_include_dirs LANG) - if("${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}") - set(MPI_${LANG}_INCLUDE_DIRS "") - else() - set(MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS}") - if("${LANG}" MATCHES "(C|CXX)") - if(MPI_${LANG}_HEADER_DIR) - list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_HEADER_DIR}") - endif() - else() # Fortran - if(MPI_${LANG}_F77_HEADER_DIR) - list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_F77_HEADER_DIR}") - endif() - if(MPI_${LANG}_MODULE_DIR AND NOT "${MPI_${LANG}_MODULE_DIR}" IN_LIST MPI_${LANG}_INCLUDE_DIRS) - list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_MODULE_DIR}") - endif() - endif() - if(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) - foreach(MPI_ADDITIONAL_INC_DIR IN LISTS MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) - list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${MPI_ADDITIONAL_INC_DIR}_INCLUDE_DIR}") - endforeach() - endif() - endif() -endmacro() - -function(_MPI_split_include_dirs LANG) - if("${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}") - return() - endif() - # Backwards compatibility: Search INCLUDE_PATH if given. - if(MPI_${LANG}_INCLUDE_PATH) - list(APPEND MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_${LANG}_INCLUDE_PATH}") - endif() - - # We try to find the headers/modules among those paths (and system paths) - # For C/C++, we just need to have a look for mpi.h. - if("${LANG}" MATCHES "(C|CXX)") - find_path(MPI_${LANG}_HEADER_DIR "mpi.h" - HINTS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS} - ) - mark_as_advanced(MPI_${LANG}_HEADER_DIR) - if(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) - list(REMOVE_ITEM MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_${LANG}_HEADER_DIR}") - endif() - # Fortran is more complicated here: An implementation could provide - # any of the Fortran 77/90/2008 APIs for MPI. For example, MSMPI - # only provides Fortran 77 and - if mpi.f90 is built - potentially - # a Fortran 90 module. - elseif("${LANG}" STREQUAL "Fortran") - find_path(MPI_${LANG}_F77_HEADER_DIR "mpif.h" - HINTS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS} - ) - find_path(MPI_${LANG}_MODULE_DIR - NAMES "mpi.mod" "mpi_f08.mod" - HINTS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS} - ) - if(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) - list(REMOVE_ITEM MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS - "${MPI_${LANG}_F77_HEADER_DIR}" - "${MPI_${LANG}_MODULE_DIR}" - ) - endif() - mark_as_advanced(MPI_${LANG}_F77_HEADER_DIR MPI_${LANG}_MODULE_DIR) - endif() - # Remove duplicates and default system directories from the list. - if(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) - list(REMOVE_DUPLICATES MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) - foreach(MPI_IMPLICIT_INC_DIR IN LISTS CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES) - list(REMOVE_ITEM MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_IMPLICIT_INC_DIR}) - endforeach() - endif() - set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS} CACHE STRING "MPI ${LANG} additional include directories" FORCE) -endfunction() - -macro(_MPI_create_imported_target LANG) - if(NOT TARGET MPI::MPI_${LANG}) - add_library(MPI::MPI_${LANG} INTERFACE IMPORTED) - endif() - - set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_COMPILE_OPTIONS "${MPI_${LANG}_COMPILE_OPTIONS}") - set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_COMPILE_DEFINITIONS "${MPI_${LANG}_COMPILE_DEFINITIONS}") - - set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_LINK_LIBRARIES "") - if(MPI_${LANG}_LINK_FLAGS) - set_property(TARGET MPI::MPI_${LANG} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${MPI_${LANG}_LINK_FLAGS}") - endif() - # If the compiler links MPI implicitly, no libraries will be found as they're contained within - # CMAKE__IMPLICIT_LINK_LIBRARIES already. - if(MPI_${LANG}_LIBRARIES) - set_property(TARGET MPI::MPI_${LANG} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${MPI_${LANG}_LIBRARIES}") - endif() - # Given the new design of FindMPI, INCLUDE_DIRS will always be located, even under implicit linking. - set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${MPI_${LANG}_INCLUDE_DIRS}") -endmacro() - -function(_MPI_try_staged_settings LANG MPI_TEST_FILE_NAME MODE RUN_BINARY) - set(WORK_DIR "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindMPI") - set(SRC_DIR "${CMAKE_CURRENT_LIST_DIR}/FindMPI") - set(BIN_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindMPI/${MPI_TEST_FILE_NAME}_${LANG}.bin") - unset(MPI_TEST_COMPILE_DEFINITIONS) - if("${LANG}" STREQUAL "Fortran") - if("${MODE}" STREQUAL "F90_MODULE") - set(MPI_Fortran_INCLUDE_LINE "use mpi\n implicit none") - elseif("${MODE}" STREQUAL "F08_MODULE") - set(MPI_Fortran_INCLUDE_LINE "use mpi_f08\n implicit none") - else() # F77 header - set(MPI_Fortran_INCLUDE_LINE "implicit none\n include 'mpif.h'") - endif() - configure_file("${SRC_DIR}/${MPI_TEST_FILE_NAME}.f90.in" "${WORK_DIR}/${MPI_TEST_FILE_NAME}.f90" @ONLY) - set(MPI_TEST_SOURCE_FILE "${WORK_DIR}/${MPI_TEST_FILE_NAME}.f90") - elseif("${LANG}" STREQUAL "CXX") - configure_file("${SRC_DIR}/${MPI_TEST_FILE_NAME}.c" "${WORK_DIR}/${MPI_TEST_FILE_NAME}.cpp" COPYONLY) - set(MPI_TEST_SOURCE_FILE "${WORK_DIR}/${MPI_TEST_FILE_NAME}.cpp") - if("${MODE}" STREQUAL "TEST_MPICXX") - set(MPI_TEST_COMPILE_DEFINITIONS TEST_MPI_MPICXX) - endif() - else() # C - set(MPI_TEST_SOURCE_FILE "${SRC_DIR}/${MPI_TEST_FILE_NAME}.c") - endif() - if(RUN_BINARY) - try_run(MPI_RUN_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} MPI_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} - "${CMAKE_BINARY_DIR}" SOURCES "${MPI_TEST_SOURCE_FILE}" - COMPILE_DEFINITIONS ${MPI_TEST_COMPILE_DEFINITIONS} - LINK_LIBRARIES MPI::MPI_${LANG} - RUN_OUTPUT_VARIABLE MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE}) - set(MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} "${MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE}}" PARENT_SCOPE) - else() - try_compile(MPI_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} - "${CMAKE_BINARY_DIR}" SOURCES "${MPI_TEST_SOURCE_FILE}" - COMPILE_DEFINITIONS ${MPI_TEST_COMPILE_DEFINITIONS} - LINK_LIBRARIES MPI::MPI_${LANG} - COPY_FILE "${BIN_FILE}") - endif() -endfunction() - -macro(_MPI_check_lang_works LANG) - # For Fortran we may have by the MPI-3 standard an implementation that provides: - # - the mpi_f08 module - # - *both*, the mpi module and 'mpif.h' - # Since older MPI standards (MPI-1) did not define anything but 'mpif.h', we need to check all three individually. - if( NOT MPI_${LANG}_WORKS ) - if("${LANG}" STREQUAL "Fortran") - set(MPI_Fortran_INTEGER_LINE "(kind=MPI_INTEGER_KIND)") - _MPI_try_staged_settings(${LANG} test_mpi F77_HEADER FALSE) - _MPI_try_staged_settings(${LANG} test_mpi F90_MODULE FALSE) - _MPI_try_staged_settings(${LANG} test_mpi F08_MODULE FALSE) - - set(MPI_${LANG}_WORKS FALSE) - - foreach(mpimethod IN ITEMS F77_HEADER F08_MODULE F90_MODULE) - if(MPI_RESULT_${LANG}_test_mpi_${mpimethod}) - set(MPI_${LANG}_WORKS TRUE) - set(MPI_${LANG}_HAVE_${mpimethod} TRUE) - else() - set(MPI_${LANG}_HAVE_${mpimethod} FALSE) - endif() - endforeach() - # MPI-1 versions had no MPI_INTGER_KIND defined, so we need to try without it. - # However, MPI-1 also did not define the Fortran 90 and 08 modules, so we only try the F77 header. - unset(MPI_Fortran_INTEGER_LINE) - if(NOT MPI_${LANG}_WORKS) - _MPI_try_staged_settings(${LANG} test_mpi F77_HEADER_NOKIND FALSE) - if(MPI_RESULT_${LANG}_test_mpi_F77_HEADER_NOKIND) - set(MPI_${LANG}_WORKS TRUE) - set(MPI_${LANG}_HAVE_F77_HEADER TRUE) - endif() - endif() - else() - _MPI_try_staged_settings(${LANG} test_mpi normal FALSE) - # If 'test_mpi' built correctly, we've found valid MPI settings. There might not be MPI-2 C++ support, but there can't - # be MPI-2 C++ support without the C bindings being present, so checking for them is sufficient. - set(MPI_${LANG}_WORKS "${MPI_RESULT_${LANG}_test_mpi_normal}") - endif() - endif() -endmacro() - -# Some systems install various MPI implementations in separate folders in some MPI prefix -# This macro enumerates all such subfolders and adds them to the list of hints that will be searched. -macro(MPI_search_mpi_prefix_folder PREFIX_FOLDER) - if(EXISTS "${PREFIX_FOLDER}") - file(GLOB _MPI_folder_children RELATIVE "${PREFIX_FOLDER}" "${PREFIX_FOLDER}/*") - foreach(_MPI_folder_child IN LISTS _MPI_folder_children) - if(IS_DIRECTORY "${PREFIX_FOLDER}/${_MPI_folder_child}") - list(APPEND MPI_HINT_DIRS "${PREFIX_FOLDER}/${_MPI_folder_child}") - endif() - endforeach() - endif() -endmacro() - -set(MPI_HINT_DIRS ${MPI_HOME} $ENV{MPI_ROOT} $ENV{MPI_HOME} $ENV{I_MPI_ROOT}) -if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux") - # SUSE Linux Enterprise Server stores its MPI implementations under /usr/lib64/mpi/gcc/ - # We enumerate the subfolders and append each as a prefix - MPI_search_mpi_prefix_folder("/usr/lib64/mpi/gcc") -elseif("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows") - # MSMPI stores its runtime in a special folder, this adds the possible locations to the hints. - list(APPEND MPI_HINT_DIRS $ENV{MSMPI_BIN} "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MPI;InstallRoot]") -elseif("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "FreeBSD") - # FreeBSD ships mpich under the normal system paths - but available openmpi implementations - # will be found in /usr/local/mpi/ - MPI_search_mpi_prefix_folder("/usr/local/mpi") -endif() - -# Most MPI distributions have some form of mpiexec or mpirun which gives us something we can look for. -# The MPI standard does not mandate the existence of either, but instead only makes requirements if a distribution -# ships an mpiexec program (mpirun executables are not regulated by the standard). -find_program(MPIEXEC_EXECUTABLE - NAMES ${_MPIEXEC_NAMES} - PATH_SUFFIXES bin sbin - HINTS ${MPI_HINT_DIRS} - DOC "Executable for running MPI programs.") - -# call get_filename_component twice to remove mpiexec and the directory it exists in (typically bin). -# This gives us a fairly reliable base directory to search for /bin /lib and /include from. -get_filename_component(_MPI_BASE_DIR "${MPIEXEC_EXECUTABLE}" PATH) -get_filename_component(_MPI_BASE_DIR "${_MPI_BASE_DIR}" PATH) - -# According to the MPI standard, section 8.8 -n is a guaranteed, and the only guaranteed way to -# launch an MPI process using mpiexec if such a program exists. -set(MPIEXEC_NUMPROC_FLAG "-n" CACHE STRING "Flag used by MPI to specify the number of processes for mpiexec; the next option will be the number of processes.") -set(MPIEXEC_PREFLAGS "" CACHE STRING "These flags will be directly before the executable that is being run by mpiexec.") -set(MPIEXEC_POSTFLAGS "" CACHE STRING "These flags will be placed after all flags passed to mpiexec.") - -# Set the number of processes to the physical processor count -cmake_host_system_information(RESULT _MPIEXEC_NUMPROCS QUERY NUMBER_OF_PHYSICAL_CORES) -set(MPIEXEC_MAX_NUMPROCS "${_MPIEXEC_NUMPROCS}" CACHE STRING "Maximum number of processors available to run MPI applications.") -unset(_MPIEXEC_NUMPROCS) -mark_as_advanced(MPIEXEC_EXECUTABLE MPIEXEC_NUMPROC_FLAG MPIEXEC_PREFLAGS MPIEXEC_POSTFLAGS MPIEXEC_MAX_NUMPROCS) - -#============================================================================= -# Backward compatibility input hacks. Propagate the FindMPI hints to C and -# CXX if the respective new versions are not defined. Translate the old -# MPI_LIBRARY and MPI_EXTRA_LIBRARY to respective MPI_${LANG}_LIBRARIES. -# -# Once we find the new variables, we translate them back into their old -# equivalents below. -if(NOT MPI_IGNORE_LEGACY_VARIABLES) - foreach (LANG IN ITEMS C CXX) - # Old input variables. - set(_MPI_OLD_INPUT_VARS COMPILER COMPILE_FLAGS INCLUDE_PATH LINK_FLAGS) - - # Set new vars based on their old equivalents, if the new versions are not already set. - foreach (var ${_MPI_OLD_INPUT_VARS}) - if (NOT MPI_${LANG}_${var} AND MPI_${var}) - set(MPI_${LANG}_${var} "${MPI_${var}}") - endif() - endforeach() - - # Chop the old compile flags into options and definitions - - unset(MPI_${LANG}_EXTRA_COMPILE_DEFINITIONS) - unset(MPI_${LANG}_EXTRA_COMPILE_OPTIONS) - if(MPI_${LANG}_COMPILE_FLAGS) - separate_arguments(MPI_SEPARATE_FLAGS NATIVE_COMMAND "${MPI_${LANG}_COMPILE_FLAGS}") - foreach(_MPI_FLAG IN LISTS MPI_SEPARATE_FLAGS) - if("${_MPI_FLAG}" MATCHES "^ *[-/D]([^ ]+)") - list(APPEND MPI_${LANG}_EXTRA_COMPILE_DEFINITIONS "${CMAKE_MATCH_1}") - else() - list(APPEND MPI_${LANG}_EXTRA_COMPILE_OPTIONS "${_MPI_FLAG}") - endif() - endforeach() - unset(MPI_SEPARATE_FLAGS) - endif() - - # If a list of libraries was given, we'll split it into new-style cache variables - unset(MPI_${LANG}_EXTRA_LIB_NAMES) - if(NOT MPI_${LANG}_LIB_NAMES) - foreach(_MPI_LIB IN LISTS MPI_${LANG}_LIBRARIES MPI_LIBRARY MPI_EXTRA_LIBRARY) - if(_MPI_LIB) - get_filename_component(_MPI_PLAIN_LIB_NAME "${_MPI_LIB}" NAME_WE) - get_filename_component(_MPI_LIB_NAME "${_MPI_LIB}" NAME) - get_filename_component(_MPI_LIB_DIR "${_MPI_LIB}" DIRECTORY) - list(APPEND MPI_${LANG}_EXTRA_LIB_NAMES "${_MPI_PLAIN_LIB_NAME}") - find_library(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY - NAMES "${_MPI_LIB_NAME}" "lib${_MPI_LIB_NAME}" - HINTS ${_MPI_LIB_DIR} $ENV{MPI_LIB} - DOC "Location of the ${_MPI_PLAIN_LIB_NAME} library for MPI" - ) - mark_as_advanced(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY) - endif() - endforeach() - endif() - endforeach() -endif() -#============================================================================= - -unset(MPI_VERSION) -unset(MPI_VERSION_MAJOR) -unset(MPI_VERSION_MINOR) - -unset(_MPI_MIN_VERSION) - -# If the user specified a library name we assume they prefer that library over a wrapper. If not, they can disable skipping manually. -if(NOT DEFINED MPI_SKIP_COMPILER_WRAPPER AND MPI_GUESS_LIBRARY_NAME) - set(MPI_SKIP_COMPILER_WRAPPER TRUE) -endif() - -# This loop finds the compilers and sends them off for interrogation. -foreach(LANG IN ITEMS C CXX Fortran) - if(CMAKE_${LANG}_COMPILER_LOADED) - if(NOT MPI_FIND_COMPONENTS) - set(_MPI_FIND_${LANG} TRUE) - elseif( ${LANG} IN_LIST MPI_FIND_COMPONENTS) - set(_MPI_FIND_${LANG} TRUE) - elseif( ${LANG} STREQUAL CXX AND NOT MPI_CXX_SKIP_MPICXX AND MPICXX IN_LIST MPI_FIND_COMPONENTS ) - set(_MPI_FIND_${LANG} TRUE) - else() - set(_MPI_FIND_${LANG} FALSE) - endif() - else() - set(_MPI_FIND_${LANG} FALSE) - endif() - if(_MPI_FIND_${LANG}) - if( ${LANG} STREQUAL CXX AND NOT MPICXX IN_LIST MPI_FIND_COMPONENTS ) - set(MPI_CXX_SKIP_MPICXX FALSE CACHE BOOL "If true, the MPI-2 C++ bindings are disabled using definitions.") - mark_as_advanced(MPI_CXX_SKIP_MPICXX) - endif() - if(NOT (MPI_${LANG}_LIB_NAMES AND (MPI_${LANG}_INCLUDE_PATH OR MPI_${LANG}_INCLUDE_DIRS OR MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS))) - set(MPI_${LANG}_TRIED_IMPLICIT FALSE) - set(MPI_${LANG}_WORKS_IMPLICIT FALSE) - if(NOT MPI_${LANG}_COMPILER AND NOT MPI_ASSUME_NO_BUILTIN_MPI) - # Should the imported targets be empty, we effectively try whether the compiler supports MPI on its own, which is the case on e.g. - # Cray PrgEnv. - _MPI_create_imported_target(${LANG}) - _MPI_check_lang_works(${LANG}) - - # If the compiler can build MPI code on its own, it functions as an MPI compiler and we'll set the variable to point to it. - if(MPI_${LANG}_WORKS) - set(MPI_${LANG}_COMPILER "${CMAKE_${LANG}_COMPILER}" CACHE FILEPATH "MPI compiler for ${LANG}" FORCE) - set(MPI_${LANG}_WORKS_IMPLICIT TRUE) - endif() - set(MPI_${LANG}_TRIED_IMPLICIT TRUE) - endif() - - if(NOT "${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}" OR NOT MPI_${LANG}_WORKS) - set(MPI_${LANG}_WRAPPER_FOUND FALSE) - set(MPI_PINNED_COMPILER FALSE) - - if(NOT MPI_SKIP_COMPILER_WRAPPER) - if(MPI_${LANG}_COMPILER) - # If the user supplies a compiler *name* instead of an absolute path, assume that we need to find THAT compiler. - if (NOT IS_ABSOLUTE "${MPI_${LANG}_COMPILER}") - # Get rid of our default list of names and just search for the name the user wants. - set(_MPI_${LANG}_COMPILER_NAMES "${MPI_${LANG}_COMPILER}") - unset(MPI_${LANG}_COMPILER CACHE) - endif() - # If the user specifies a compiler, we don't want to try to search libraries either. - set(MPI_PINNED_COMPILER TRUE) - endif() - - # If we have an MPI base directory, we'll try all compiler names in that one first. - # This should prevent mixing different MPI environments - if(_MPI_BASE_DIR) - find_program(MPI_${LANG}_COMPILER - NAMES ${_MPI_${LANG}_COMPILER_NAMES} - PATH_SUFFIXES bin sbin - HINTS ${_MPI_BASE_DIR} - NO_DEFAULT_PATH - DOC "MPI compiler for ${LANG}" - ) - endif() - - # If the base directory did not help (for example because the mpiexec isn't in the same directory as the compilers), - # we shall try searching in the default paths. - find_program(MPI_${LANG}_COMPILER - NAMES ${_MPI_${LANG}_COMPILER_NAMES} - PATH_SUFFIXES bin sbin - DOC "MPI compiler for ${LANG}" - ) - - if("${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}") - set(MPI_PINNED_COMPILER TRUE) - - # If we haven't made the implicit compiler test yet, perform it now. - if(NOT MPI_${LANG}_TRIED_IMPLICIT) - _MPI_create_imported_target(${LANG}) - _MPI_check_lang_works(${LANG}) - endif() - - # Should the MPI compiler not work implicitly for MPI, still interrogate it. - # Otherwise, MPI compilers for which CMake has separate linking stages, e.g. Intel MPI on Windows where link.exe is being used - # directly during linkage instead of CMAKE__COMPILER will not work. - if(NOT MPI_${LANG}_WORKS) - set(MPI_${LANG}_WORKS_IMPLICIT FALSE) - _MPI_interrogate_compiler(${LANG}) - else() - set(MPI_${LANG}_WORKS_IMPLICIT TRUE) - endif() - elseif(MPI_${LANG}_COMPILER) - _MPI_interrogate_compiler(${LANG}) - endif() - endif() - - if(NOT MPI_SKIP_GUESSING AND NOT MPI_${LANG}_WRAPPER_FOUND AND NOT MPI_PINNED_COMPILER) - # For C++, we may use the settings for C. Should a given compiler wrapper for C++ not exist, but one for C does, we copy over the - # settings for C. An MPI distribution that is in this situation would be IBM Platform MPI. - if("${LANG}" STREQUAL "CXX" AND MPI_C_WRAPPER_FOUND) - set(MPI_${LANG}_COMPILE_OPTIONS ${MPI_C_COMPILE_OPTIONS} CACHE STRING "MPI ${LANG} compilation options" ) - set(MPI_${LANG}_COMPILE_DEFINITIONS ${MPI_C_COMPILE_DEFINITIONS} CACHE STRING "MPI ${LANG} compilation definitions" ) - set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_C_INCLUDE_DIRS} CACHE STRING "MPI ${LANG} additional include directories") - set(MPI_${LANG}_LINK_FLAGS ${MPI_C_LINK_FLAGS} CACHE STRING "MPI ${LANG} linker flags" ) - set(MPI_${LANG}_LIB_NAMES ${MPI_C_LIB_NAMES} CACHE STRING "MPI ${LANG} libraries to link against" ) - else() - _MPI_guess_settings(${LANG}) - endif() - endif() - endif() - endif() - - _MPI_split_include_dirs(${LANG}) - _MPI_assemble_include_dirs(${LANG}) - _MPI_assemble_libraries(${LANG}) - - _MPI_adjust_compile_definitions(${LANG}) - # We always create imported targets even if they're empty - _MPI_create_imported_target(${LANG}) - - if(NOT MPI_${LANG}_WORKS) - _MPI_check_lang_works(${LANG}) - endif() - - # Next, we'll initialize the MPI variables that have not been previously set. - set(MPI_${LANG}_COMPILE_OPTIONS "" CACHE STRING "MPI ${LANG} compilation flags" ) - set(MPI_${LANG}_COMPILE_DEFINITIONS "" CACHE STRING "MPI ${LANG} compilation definitions" ) - set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "" CACHE STRING "MPI ${LANG} additional include directories") - set(MPI_${LANG}_LINK_FLAGS "" CACHE STRING "MPI ${LANG} linker flags" ) - if(NOT MPI_${LANG}_COMPILER STREQUAL CMAKE_${LANG}_COMPILER) - set(MPI_${LANG}_LIB_NAMES "" CACHE STRING "MPI ${LANG} libraries to link against" ) - endif() - mark_as_advanced(MPI_${LANG}_COMPILE_OPTIONS MPI_${LANG}_COMPILE_DEFINITIONS MPI_${LANG}_LINK_FLAGS - MPI_${LANG}_LIB_NAMES MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS MPI_${LANG}_COMPILER) - - # If we've found MPI, then we'll perform additional analysis: Determine the MPI version, MPI library version, supported - # MPI APIs (i.e. MPI-2 C++ bindings). For Fortran we also need to find specific parameters if we're under MPI-3. - if(MPI_${LANG}_WORKS) - if("${LANG}" STREQUAL "CXX" AND NOT DEFINED MPI_MPICXX_FOUND) - if(NOT MPI_CXX_SKIP_MPICXX AND NOT MPI_CXX_VALIDATE_SKIP_MPICXX) - _MPI_try_staged_settings(${LANG} test_mpi MPICXX FALSE) - if(MPI_RESULT_${LANG}_test_mpi_MPICXX) - set(MPI_MPICXX_FOUND TRUE) - else() - set(MPI_MPICXX_FOUND FALSE) - endif() - else() - set(MPI_MPICXX_FOUND FALSE) - endif() - endif() - - # At this point, we know the bindings present but not the MPI version or anything else. - if(NOT DEFINED MPI_${LANG}_VERSION) - unset(MPI_${LANG}_VERSION_MAJOR) - unset(MPI_${LANG}_VERSION_MINOR) - endif() - set(MPI_BIN_FOLDER ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindMPI) - - # For Fortran, we'll want to use the most modern MPI binding to test capabilities other than the - # Fortran parameters, since those depend on the method of consumption. - # For C++, we can always use the C bindings, and should do so, since the C++ bindings do not exist in MPI-3 - # whereas the C bindings do, and the C++ bindings never offered any feature advantage over their C counterparts. - if("${LANG}" STREQUAL "Fortran") - if(MPI_${LANG}_HAVE_F08_MODULE) - set(MPI_${LANG}_HIGHEST_METHOD F08_MODULE) - elseif(MPI_${LANG}_HAVE_F90_MODULE) - set(MPI_${LANG}_HIGHEST_METHOD F90_MODULE) - else() - set(MPI_${LANG}_HIGHEST_METHOD F77_HEADER) - endif() - - # Another difference between C and Fortran is that we can't use the preprocessor to determine whether MPI_VERSION - # and MPI_SUBVERSION are provided. These defines did not exist in MPI 1.0 and 1.1 and therefore might not - # exist. For C/C++, test_mpi.c will handle the MPI_VERSION extraction, but for Fortran, we need mpiver.f90. - if(NOT DEFINED MPI_${LANG}_VERSION) - _MPI_try_staged_settings(${LANG} mpiver ${MPI_${LANG}_HIGHEST_METHOD} FALSE) - if(MPI_RESULT_${LANG}_mpiver_${MPI_${LANG}_HIGHEST_METHOD}) - file(STRINGS ${MPI_BIN_FOLDER}/mpiver_${LANG}.bin _MPI_VERSION_STRING LIMIT_COUNT 1 REGEX "INFO:MPI-VER") - if("${_MPI_VERSION_STRING}" MATCHES ".*INFO:MPI-VER\\[([0-9]+)\\.([0-9]+)\\].*") - set(MPI_${LANG}_VERSION_MAJOR "${CMAKE_MATCH_1}") - set(MPI_${LANG}_VERSION_MINOR "${CMAKE_MATCH_2}") - set(MPI_${LANG}_VERSION "${MPI_${LANG}_VERSION_MAJOR}.${MPI_${LANG}_VERSION_MINOR}") - endif() - endif() - endif() - - # Finally, we want to find out which capabilities a given interface supports, compare the MPI-3 standard. - # This is determined by interface specific parameters MPI_SUBARRAYS_SUPPORTED and MPI_ASYNC_PROTECTS_NONBLOCKING - # and might vary between the different methods of consumption. - if(MPI_DETERMINE_Fortran_CAPABILITIES AND NOT MPI_Fortran_CAPABILITIES_DETERMINED) - foreach(mpimethod IN ITEMS F08_MODULE F90_MODULE F77_HEADER) - if(MPI_${LANG}_HAVE_${mpimethod}) - set(MPI_${LANG}_${mpimethod}_SUBARRAYS FALSE) - set(MPI_${LANG}_${mpimethod}_ASYNCPROT FALSE) - _MPI_try_staged_settings(${LANG} fortranparam_mpi ${mpimethod} TRUE) - if(MPI_RESULT_${LANG}_fortranparam_mpi_${mpimethod} AND - NOT "${MPI_RUN_RESULT_${LANG}_fortranparam_mpi_${mpimethod}}" STREQUAL "FAILED_TO_RUN") - if("${MPI_RUN_OUTPUT_${LANG}_fortranparam_mpi_${mpimethod}}" MATCHES - ".*INFO:SUBARRAYS\\[ *([TF]) *\\]-ASYNCPROT\\[ *([TF]) *\\].*") - if("${CMAKE_MATCH_1}" STREQUAL "T") - set(MPI_${LANG}_${mpimethod}_SUBARRAYS TRUE) - endif() - if("${CMAKE_MATCH_2}" STREQUAL "T") - set(MPI_${LANG}_${mpimethod}_ASYNCPROT TRUE) - endif() - endif() - endif() - endif() - endforeach() - set(MPI_Fortran_CAPABILITIES_DETERMINED TRUE) - endif() - else() - set(MPI_${LANG}_HIGHEST_METHOD normal) - - # By the MPI-2 standard, MPI_VERSION and MPI_SUBVERSION are valid for both C and C++ bindings. - if(NOT DEFINED MPI_${LANG}_VERSION) - file(STRINGS ${MPI_BIN_FOLDER}/test_mpi_${LANG}.bin _MPI_VERSION_STRING LIMIT_COUNT 1 REGEX "INFO:MPI-VER") - if("${_MPI_VERSION_STRING}" MATCHES ".*INFO:MPI-VER\\[([0-9]+)\\.([0-9]+)\\].*") - set(MPI_${LANG}_VERSION_MAJOR "${CMAKE_MATCH_1}") - set(MPI_${LANG}_VERSION_MINOR "${CMAKE_MATCH_2}") - set(MPI_${LANG}_VERSION "${MPI_${LANG}_VERSION_MAJOR}.${MPI_${LANG}_VERSION_MINOR}") - endif() - endif() - endif() - - unset(MPI_BIN_FOLDER) - - # At this point, we have dealt with determining the MPI version and parameters for each Fortran method available. - # The one remaining issue is to determine which MPI library is installed. - # Determining the version and vendor of the MPI library is only possible via MPI_Get_library_version() at runtime, - # and therefore we cannot do this while cross-compiling (a user may still define MPI__LIBRARY_VERSION_STRING - # themselves and we'll attempt splitting it, which is equivalent to provide the try_run output). - # It's also worth noting that the installed version string can depend on the language, or on the system the binary - # runs on if MPI is not statically linked. - if(MPI_DETERMINE_LIBRARY_VERSION AND NOT MPI_${LANG}_LIBRARY_VERSION_STRING) - _MPI_try_staged_settings(${LANG} libver_mpi ${MPI_${LANG}_HIGHEST_METHOD} TRUE) - if(MPI_RESULT_${LANG}_libver_mpi_${MPI_${LANG}_HIGHEST_METHOD} AND - "${MPI_RUN_RESULT_${LANG}_libver_mpi_${MPI_${LANG}_HIGHEST_METHOD}}" EQUAL "0") - string(STRIP "${MPI_RUN_OUTPUT_${LANG}_libver_mpi_${MPI_${LANG}_HIGHEST_METHOD}}" - MPI_${LANG}_LIBRARY_VERSION_STRING) - else() - set(MPI_${LANG}_LIBRARY_VERSION_STRING "NOTFOUND") - endif() - endif() - endif() - - set(MPI_${LANG}_FIND_QUIETLY ${MPI_FIND_QUIETLY}) - set(MPI_${LANG}_FIND_VERSION ${MPI_FIND_VERSION}) - set(MPI_${LANG}_FIND_VERSION_EXACT ${MPI_FIND_VERSION_EXACT}) - - unset(MPI_${LANG}_REQUIRED_VARS) - if (NOT "${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}") - foreach(mpilibname IN LISTS MPI_${LANG}_LIB_NAMES) - list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${mpilibname}_LIBRARY") - endforeach() - list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_LIB_NAMES") - if("${LANG}" STREQUAL "Fortran") - # For Fortran we only need one of the module or header directories to have *some* support for MPI. - if(NOT MPI_${LANG}_MODULE_DIR) - list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_F77_HEADER_DIR") - endif() - if(NOT MPI_${LANG}_F77_HEADER_DIR) - list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_MODULE_DIR") - endif() - else() - list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_HEADER_DIR") - endif() - if(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) - foreach(mpiincvar IN LISTS MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) - list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${mpiincvar}_INCLUDE_DIR") - endforeach() - endif() - # Append the works variable now. If the settings did not work, this will show up properly. - list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_WORKS") - else() - # If the compiler worked implicitly, use its path as output. - # Should the compiler variable be set, we also require it to work. - list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_COMPILER") - if(MPI_${LANG}_COMPILER) - list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_WORKS") - endif() - endif() - find_package_handle_standard_args(MPI_${LANG} REQUIRED_VARS ${MPI_${LANG}_REQUIRED_VARS} - VERSION_VAR MPI_${LANG}_VERSION) - - if(DEFINED MPI_${LANG}_VERSION) - if(NOT _MPI_MIN_VERSION OR _MPI_MIN_VERSION VERSION_GREATER MPI_${LANG}_VERSION) - set(_MPI_MIN_VERSION MPI_${LANG}_VERSION) - endif() - endif() - endif() -endforeach() - -unset(_MPI_REQ_VARS) -foreach(LANG IN ITEMS C CXX Fortran) - if((NOT MPI_FIND_COMPONENTS AND CMAKE_${LANG}_COMPILER_LOADED) OR LANG IN_LIST MPI_FIND_COMPONENTS) - list(APPEND _MPI_REQ_VARS "MPI_${LANG}_FOUND") - endif() -endforeach() - -if(MPICXX IN_LIST MPI_FIND_COMPONENTS) - list(APPEND _MPI_REQ_VARS "MPI_MPICXX_FOUND") -endif() - -find_package_handle_standard_args(MPI - REQUIRED_VARS ${_MPI_REQ_VARS} - VERSION_VAR ${_MPI_MIN_VERSION} - HANDLE_COMPONENTS) - -#============================================================================= -# More backward compatibility stuff - -# For compatibility reasons, we also define MPIEXEC -set(MPIEXEC "${MPIEXEC_EXECUTABLE}") - -# Copy over MPI__INCLUDE_PATH from the assembled INCLUDE_DIRS. -foreach(LANG IN ITEMS C CXX Fortran) - if(MPI_${LANG}_FOUND) - set(MPI_${LANG}_INCLUDE_PATH "${MPI_${LANG}_INCLUDE_DIRS}") - unset(MPI_${LANG}_COMPILE_FLAGS) - if(MPI_${LANG}_COMPILE_OPTIONS) - set(MPI_${LANG}_COMPILE_FLAGS "${MPI_${LANG}_COMPILE_OPTIONS}") - endif() - if(MPI_${LANG}_COMPILE_DEFINITIONS) - foreach(_MPI_DEF IN LISTS MPI_${LANG}_COMPILE_DEFINITIONS) - string(APPEND MPI_${LANG}_COMPILE_FLAGS " -D${_MPI_DEF}") - endforeach() - endif() - endif() -endforeach() - -# Bare MPI sans ${LANG} vars are set to CXX then C, depending on what was found. -# This mimics the behavior of the old language-oblivious FindMPI. -set(_MPI_OLD_VARS COMPILER INCLUDE_PATH COMPILE_FLAGS LINK_FLAGS LIBRARIES) -if (MPI_CXX_FOUND) - foreach (var ${_MPI_OLD_VARS}) - set(MPI_${var} ${MPI_CXX_${var}}) - endforeach() -elseif (MPI_C_FOUND) - foreach (var ${_MPI_OLD_VARS}) - set(MPI_${var} ${MPI_C_${var}}) - endforeach() -endif() - -# Chop MPI_LIBRARIES into the old-style MPI_LIBRARY and MPI_EXTRA_LIBRARY, and set them in cache. -if (MPI_LIBRARIES) - list(GET MPI_LIBRARIES 0 MPI_LIBRARY_WORK) - set(MPI_LIBRARY "${MPI_LIBRARY_WORK}") - unset(MPI_LIBRARY_WORK) -else() - set(MPI_LIBRARY "MPI_LIBRARY-NOTFOUND") -endif() - -list(LENGTH MPI_LIBRARIES MPI_NUMLIBS) -if (MPI_NUMLIBS GREATER 1) - set(MPI_EXTRA_LIBRARY_WORK "${MPI_LIBRARIES}") - list(REMOVE_AT MPI_EXTRA_LIBRARY_WORK 0) - set(MPI_EXTRA_LIBRARY "${MPI_EXTRA_LIBRARY_WORK}") - unset(MPI_EXTRA_LIBRARY_WORK) -else() - set(MPI_EXTRA_LIBRARY "MPI_EXTRA_LIBRARY-NOTFOUND") -endif() -set(MPI_IGNORE_LEGACY_VARIABLES TRUE) -#============================================================================= - -# unset these vars to cleanup namespace -unset(_MPI_OLD_VARS) -unset(_MPI_PREFIX_PATH) -unset(_MPI_BASE_DIR) -foreach (lang C CXX Fortran) - unset(_MPI_${LANG}_COMPILER_NAMES) -endforeach() - -cmake_policy(POP) diff --git a/cmake/Modules/NewCMake/FindMPI/fortranparam_mpi.f90.in b/cmake/Modules/NewCMake/FindMPI/fortranparam_mpi.f90.in deleted file mode 100644 index 30f912c627..0000000000 --- a/cmake/Modules/NewCMake/FindMPI/fortranparam_mpi.f90.in +++ /dev/null @@ -1,4 +0,0 @@ - program mpi_ver - @MPI_Fortran_INCLUDE_LINE@ - print *, 'INFO:SUBARRAYS[', MPI_SUBARRAYS_SUPPORTED, ']-ASYNCPROT[', MPI_ASYNC_PROTECTS_NONBLOCKING, ']' - end program mpi_ver diff --git a/cmake/Modules/NewCMake/FindMPI/libver_mpi.c b/cmake/Modules/NewCMake/FindMPI/libver_mpi.c deleted file mode 100644 index be9d19d435..0000000000 --- a/cmake/Modules/NewCMake/FindMPI/libver_mpi.c +++ /dev/null @@ -1,19 +0,0 @@ -#include - -#ifdef __cplusplus -#include -#else -#include -#endif - -int main(int argc, char* argv[]) -{ - char mpilibver_str[MPI_MAX_LIBRARY_VERSION_STRING]; - int mpilibver_len; - MPI_Get_library_version(mpilibver_str, &mpilibver_len); -#ifdef __cplusplus - std::puts(mpilibver_str); -#else - puts(mpilibver_str); -#endif -} diff --git a/cmake/Modules/NewCMake/FindMPI/libver_mpi.f90.in b/cmake/Modules/NewCMake/FindMPI/libver_mpi.f90.in deleted file mode 100644 index 7938587168..0000000000 --- a/cmake/Modules/NewCMake/FindMPI/libver_mpi.f90.in +++ /dev/null @@ -1,7 +0,0 @@ - program mpi_ver - @MPI_Fortran_INCLUDE_LINE@ - character(len=MPI_MAX_LIBRARY_VERSION_STRING) :: mpilibver_str - integer(kind=MPI_INTEGER_KIND) :: ierror, reslen - call MPI_GET_LIBRARY_VERSION(mpilibver_str, reslen, ierror) - print *, mpilibver_str - end program mpi_ver diff --git a/cmake/Modules/NewCMake/FindMPI/mpiver.f90.in b/cmake/Modules/NewCMake/FindMPI/mpiver.f90.in deleted file mode 100644 index a254523853..0000000000 --- a/cmake/Modules/NewCMake/FindMPI/mpiver.f90.in +++ /dev/null @@ -1,10 +0,0 @@ - program mpi_ver - @MPI_Fortran_INCLUDE_LINE@ - integer(kind=kind(MPI_VERSION)), parameter :: zero = ichar('0') - character, dimension(17), parameter :: mpiver_str =& - (/ 'I', 'N', 'F', 'O', ':', 'M', 'P', 'I', '-', 'V', 'E', 'R', '[', & - char(zero + MPI_VERSION), & - '.', & - char(zero + MPI_SUBVERSION), ']' /) - print *, mpiver_str - end program mpi_ver diff --git a/cmake/Modules/NewCMake/FindMPI/test_mpi.c b/cmake/Modules/NewCMake/FindMPI/test_mpi.c deleted file mode 100644 index b8a308a4b0..0000000000 --- a/cmake/Modules/NewCMake/FindMPI/test_mpi.c +++ /dev/null @@ -1,37 +0,0 @@ -#include - -#ifdef __cplusplus -#include -#else -#include -#endif - -#if defined(MPI_VERSION) && defined(MPI_SUBVERSION) -const char mpiver_str[] = { 'I', 'N', - 'F', 'O', - ':', 'M', - 'P', 'I', - '-', 'V', - 'E', 'R', - '[', ('0' + MPI_VERSION), - '.', ('0' + MPI_SUBVERSION), - ']', '\0' }; -#endif - -int main(int argc, char* argv[]) -{ -#if defined(MPI_VERSION) && defined(MPI_SUBVERSION) -#ifdef __cplusplus - std::puts(mpiver_str); -#else - puts(mpiver_str); -#endif -#endif -#ifdef TEST_MPI_MPICXX - MPI::MPI_Init(&argc, &argv); - MPI::MPI_Finalize(); -#else - MPI_Init(&argc, &argv); - MPI_Finalize(); -#endif -} diff --git a/cmake/Modules/NewCMake/FindMPI/test_mpi.f90.in b/cmake/Modules/NewCMake/FindMPI/test_mpi.f90.in deleted file mode 100644 index 4d43a04d65..0000000000 --- a/cmake/Modules/NewCMake/FindMPI/test_mpi.f90.in +++ /dev/null @@ -1,6 +0,0 @@ - program hello - @MPI_Fortran_INCLUDE_LINE@ - integer@MPI_Fortran_INTEGER_LINE@ ierror - call MPI_INIT(ierror) - call MPI_FINALIZE(ierror) - end program diff --git a/cmake/Modules/NewCMake/FindPackageHandleStandardArgs.cmake b/cmake/Modules/NewCMake/FindPackageHandleStandardArgs.cmake deleted file mode 100644 index 67f6bd6f2b..0000000000 --- a/cmake/Modules/NewCMake/FindPackageHandleStandardArgs.cmake +++ /dev/null @@ -1,386 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#[=======================================================================[.rst: -FindPackageHandleStandardArgs ------------------------------ - -This module provides a function intended to be used in :ref:`Find Modules` -implementing :command:`find_package()` calls. It handles the -``REQUIRED``, ``QUIET`` and version-related arguments of ``find_package``. -It also sets the ``_FOUND`` variable. The package is -considered found if all variables listed contain valid results, e.g. -valid filepaths. - -.. command:: find_package_handle_standard_args - - There are two signatures:: - - find_package_handle_standard_args( - (DEFAULT_MSG|) - ... - ) - - find_package_handle_standard_args( - [FOUND_VAR ] - [REQUIRED_VARS ...] - [VERSION_VAR ] - [HANDLE_COMPONENTS] - [CONFIG_MODE] - [FAIL_MESSAGE ] - ) - - The ``_FOUND`` variable will be set to ``TRUE`` if all - the variables ``...`` are valid and any optional - constraints are satisfied, and ``FALSE`` otherwise. A success or - failure message may be displayed based on the results and on - whether the ``REQUIRED`` and/or ``QUIET`` option was given to - the :command:`find_package` call. - - The options are: - - ``(DEFAULT_MSG|)`` - In the simple signature this specifies the failure message. - Use ``DEFAULT_MSG`` to ask for a default message to be computed - (recommended). Not valid in the full signature. - - ``FOUND_VAR `` - Obsolete. Specifies either ``_FOUND`` or - ``_FOUND`` as the result variable. This exists only - for compatibility with older versions of CMake and is now ignored. - Result variables of both names are always set for compatibility. - - ``REQUIRED_VARS ...`` - Specify the variables which are required for this package. - These may be named in the generated failure message asking the - user to set the missing variable values. Therefore these should - typically be cache entries such as ``FOO_LIBRARY`` and not output - variables like ``FOO_LIBRARIES``. - - ``VERSION_VAR `` - Specify the name of a variable that holds the version of the package - that has been found. This version will be checked against the - (potentially) specified required version given to the - :command:`find_package` call, including its ``EXACT`` option. - The default messages include information about the required - version and the version which has been actually found, both - if the version is ok or not. - - ``HANDLE_COMPONENTS`` - Enable handling of package components. In this case, the command - will report which components have been found and which are missing, - and the ``_FOUND`` variable will be set to ``FALSE`` - if any of the required components (i.e. not the ones listed after - the ``OPTIONAL_COMPONENTS`` option of :command:`find_package`) are - missing. - - ``CONFIG_MODE`` - Specify that the calling find module is a wrapper around a - call to ``find_package( NO_MODULE)``. This implies - a ``VERSION_VAR`` value of ``_VERSION``. The command - will automatically check whether the package configuration file - was found. - - ``FAIL_MESSAGE `` - Specify a custom failure message instead of using the default - generated message. Not recommended. - -Example for the simple signature: - -.. code-block:: cmake - - find_package_handle_standard_args(LibXml2 DEFAULT_MSG - LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR) - -The ``LibXml2`` package is considered to be found if both -``LIBXML2_LIBRARY`` and ``LIBXML2_INCLUDE_DIR`` are valid. -Then also ``LibXml2_FOUND`` is set to ``TRUE``. If it is not found -and ``REQUIRED`` was used, it fails with a -:command:`message(FATAL_ERROR)`, independent whether ``QUIET`` was -used or not. If it is found, success will be reported, including -the content of the first ````. On repeated CMake runs, -the same message will not be printed again. - -Example for the full signature: - -.. code-block:: cmake - - find_package_handle_standard_args(LibArchive - REQUIRED_VARS LibArchive_LIBRARY LibArchive_INCLUDE_DIR - VERSION_VAR LibArchive_VERSION) - -In this case, the ``LibArchive`` package is considered to be found if -both ``LibArchive_LIBRARY`` and ``LibArchive_INCLUDE_DIR`` are valid. -Also the version of ``LibArchive`` will be checked by using the version -contained in ``LibArchive_VERSION``. Since no ``FAIL_MESSAGE`` is given, -the default messages will be printed. - -Another example for the full signature: - -.. code-block:: cmake - - find_package(Automoc4 QUIET NO_MODULE HINTS /opt/automoc4) - find_package_handle_standard_args(Automoc4 CONFIG_MODE) - -In this case, a ``FindAutmoc4.cmake`` module wraps a call to -``find_package(Automoc4 NO_MODULE)`` and adds an additional search -directory for ``automoc4``. Then the call to -``find_package_handle_standard_args`` produces a proper success/failure -message. -#]=======================================================================] - -include(${CMAKE_CURRENT_LIST_DIR}/FindPackageMessage.cmake) - -# internal helper macro -macro(_FPHSA_FAILURE_MESSAGE _msg) - if (${_NAME}_FIND_REQUIRED) - message(FATAL_ERROR "${_msg}") - else () - if (NOT ${_NAME}_FIND_QUIETLY) - message(STATUS "${_msg}") - endif () - endif () -endmacro() - - -# internal helper macro to generate the failure message when used in CONFIG_MODE: -macro(_FPHSA_HANDLE_FAILURE_CONFIG_MODE) - # _CONFIG is set, but FOUND is false, this means that some other of the REQUIRED_VARS was not found: - if(${_NAME}_CONFIG) - _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: missing:${MISSING_VARS} (found ${${_NAME}_CONFIG} ${VERSION_MSG})") - else() - # If _CONSIDERED_CONFIGS is set, the config-file has been found, but no suitable version. - # List them all in the error message: - if(${_NAME}_CONSIDERED_CONFIGS) - set(configsText "") - list(LENGTH ${_NAME}_CONSIDERED_CONFIGS configsCount) - math(EXPR configsCount "${configsCount} - 1") - foreach(currentConfigIndex RANGE ${configsCount}) - list(GET ${_NAME}_CONSIDERED_CONFIGS ${currentConfigIndex} filename) - list(GET ${_NAME}_CONSIDERED_VERSIONS ${currentConfigIndex} version) - string(APPEND configsText " ${filename} (version ${version})\n") - endforeach() - if (${_NAME}_NOT_FOUND_MESSAGE) - string(APPEND configsText " Reason given by package: ${${_NAME}_NOT_FOUND_MESSAGE}\n") - endif() - _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} ${VERSION_MSG}, checked the following files:\n${configsText}") - - else() - # Simple case: No Config-file was found at all: - _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: found neither ${_NAME}Config.cmake nor ${_NAME_LOWER}-config.cmake ${VERSION_MSG}") - endif() - endif() -endmacro() - - -function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) - -# Set up the arguments for `cmake_parse_arguments`. - set(options CONFIG_MODE HANDLE_COMPONENTS) - set(oneValueArgs FAIL_MESSAGE VERSION_VAR FOUND_VAR) - set(multiValueArgs REQUIRED_VARS) - -# Check whether we are in 'simple' or 'extended' mode: - set(_KEYWORDS_FOR_EXTENDED_MODE ${options} ${oneValueArgs} ${multiValueArgs} ) - list(FIND _KEYWORDS_FOR_EXTENDED_MODE "${_FIRST_ARG}" INDEX) - - if(${INDEX} EQUAL -1) - set(FPHSA_FAIL_MESSAGE ${_FIRST_ARG}) - set(FPHSA_REQUIRED_VARS ${ARGN}) - set(FPHSA_VERSION_VAR) - else() - cmake_parse_arguments(FPHSA "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${ARGN}) - - if(FPHSA_UNPARSED_ARGUMENTS) - message(FATAL_ERROR "Unknown keywords given to FIND_PACKAGE_HANDLE_STANDARD_ARGS(): \"${FPHSA_UNPARSED_ARGUMENTS}\"") - endif() - - if(NOT FPHSA_FAIL_MESSAGE) - set(FPHSA_FAIL_MESSAGE "DEFAULT_MSG") - endif() - - # In config-mode, we rely on the variable _CONFIG, which is set by find_package() - # when it successfully found the config-file, including version checking: - if(FPHSA_CONFIG_MODE) - list(INSERT FPHSA_REQUIRED_VARS 0 ${_NAME}_CONFIG) - list(REMOVE_DUPLICATES FPHSA_REQUIRED_VARS) - set(FPHSA_VERSION_VAR ${_NAME}_VERSION) - endif() - - if(NOT FPHSA_REQUIRED_VARS) - message(FATAL_ERROR "No REQUIRED_VARS specified for FIND_PACKAGE_HANDLE_STANDARD_ARGS()") - endif() - endif() - -# now that we collected all arguments, process them - - if("x${FPHSA_FAIL_MESSAGE}" STREQUAL "xDEFAULT_MSG") - set(FPHSA_FAIL_MESSAGE "Could NOT find ${_NAME}") - endif() - - list(GET FPHSA_REQUIRED_VARS 0 _FIRST_REQUIRED_VAR) - - string(TOUPPER ${_NAME} _NAME_UPPER) - string(TOLOWER ${_NAME} _NAME_LOWER) - - if(FPHSA_FOUND_VAR) - if(FPHSA_FOUND_VAR MATCHES "^${_NAME}_FOUND$" OR FPHSA_FOUND_VAR MATCHES "^${_NAME_UPPER}_FOUND$") - set(_FOUND_VAR ${FPHSA_FOUND_VAR}) - else() - message(FATAL_ERROR "The argument for FOUND_VAR is \"${FPHSA_FOUND_VAR}\", but only \"${_NAME}_FOUND\" and \"${_NAME_UPPER}_FOUND\" are valid names.") - endif() - else() - set(_FOUND_VAR ${_NAME_UPPER}_FOUND) - endif() - - # collect all variables which were not found, so they can be printed, so the - # user knows better what went wrong (#6375) - set(MISSING_VARS "") - set(DETAILS "") - # check if all passed variables are valid - set(FPHSA_FOUND_${_NAME} TRUE) - foreach(_CURRENT_VAR ${FPHSA_REQUIRED_VARS}) - if(NOT ${_CURRENT_VAR}) - set(FPHSA_FOUND_${_NAME} FALSE) - string(APPEND MISSING_VARS " ${_CURRENT_VAR}") - else() - string(APPEND DETAILS "[${${_CURRENT_VAR}}]") - endif() - endforeach() - if(FPHSA_FOUND_${_NAME}) - set(${_NAME}_FOUND TRUE) - set(${_NAME_UPPER}_FOUND TRUE) - else() - set(${_NAME}_FOUND FALSE) - set(${_NAME_UPPER}_FOUND FALSE) - endif() - - # component handling - unset(FOUND_COMPONENTS_MSG) - unset(MISSING_COMPONENTS_MSG) - - if(FPHSA_HANDLE_COMPONENTS) - foreach(comp ${${_NAME}_FIND_COMPONENTS}) - if(${_NAME}_${comp}_FOUND) - - if(NOT DEFINED FOUND_COMPONENTS_MSG) - set(FOUND_COMPONENTS_MSG "found components: ") - endif() - string(APPEND FOUND_COMPONENTS_MSG " ${comp}") - - else() - - if(NOT DEFINED MISSING_COMPONENTS_MSG) - set(MISSING_COMPONENTS_MSG "missing components: ") - endif() - string(APPEND MISSING_COMPONENTS_MSG " ${comp}") - - if(${_NAME}_FIND_REQUIRED_${comp}) - set(${_NAME}_FOUND FALSE) - string(APPEND MISSING_VARS " ${comp}") - endif() - - endif() - endforeach() - set(COMPONENT_MSG "${FOUND_COMPONENTS_MSG} ${MISSING_COMPONENTS_MSG}") - string(APPEND DETAILS "[c${COMPONENT_MSG}]") - endif() - - # version handling: - set(VERSION_MSG "") - set(VERSION_OK TRUE) - - # check with DEFINED here as the requested or found version may be "0" - if (DEFINED ${_NAME}_FIND_VERSION) - if(DEFINED ${FPHSA_VERSION_VAR}) - set(_FOUND_VERSION ${${FPHSA_VERSION_VAR}}) - - if(${_NAME}_FIND_VERSION_EXACT) # exact version required - # count the dots in the version string - string(REGEX REPLACE "[^.]" "" _VERSION_DOTS "${_FOUND_VERSION}") - # add one dot because there is one dot more than there are components - string(LENGTH "${_VERSION_DOTS}." _VERSION_DOTS) - if (_VERSION_DOTS GREATER ${_NAME}_FIND_VERSION_COUNT) - # Because of the C++ implementation of find_package() ${_NAME}_FIND_VERSION_COUNT - # is at most 4 here. Therefore a simple lookup table is used. - if (${_NAME}_FIND_VERSION_COUNT EQUAL 1) - set(_VERSION_REGEX "[^.]*") - elseif (${_NAME}_FIND_VERSION_COUNT EQUAL 2) - set(_VERSION_REGEX "[^.]*\\.[^.]*") - elseif (${_NAME}_FIND_VERSION_COUNT EQUAL 3) - set(_VERSION_REGEX "[^.]*\\.[^.]*\\.[^.]*") - else () - set(_VERSION_REGEX "[^.]*\\.[^.]*\\.[^.]*\\.[^.]*") - endif () - string(REGEX REPLACE "^(${_VERSION_REGEX})\\..*" "\\1" _VERSION_HEAD "${_FOUND_VERSION}") - unset(_VERSION_REGEX) - if (NOT ${_NAME}_FIND_VERSION VERSION_EQUAL _VERSION_HEAD) - set(VERSION_MSG "Found unsuitable version \"${_FOUND_VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"") - set(VERSION_OK FALSE) - else () - set(VERSION_MSG "(found suitable exact version \"${_FOUND_VERSION}\")") - endif () - unset(_VERSION_HEAD) - else () - if (NOT ${_NAME}_FIND_VERSION VERSION_EQUAL _FOUND_VERSION) - set(VERSION_MSG "Found unsuitable version \"${_FOUND_VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"") - set(VERSION_OK FALSE) - else () - set(VERSION_MSG "(found suitable exact version \"${_FOUND_VERSION}\")") - endif () - endif () - unset(_VERSION_DOTS) - - else() # minimum version specified: - if (${_NAME}_FIND_VERSION VERSION_GREATER _FOUND_VERSION) - set(VERSION_MSG "Found unsuitable version \"${_FOUND_VERSION}\", but required is at least \"${${_NAME}_FIND_VERSION}\"") - set(VERSION_OK FALSE) - else () - set(VERSION_MSG "(found suitable version \"${_FOUND_VERSION}\", minimum required is \"${${_NAME}_FIND_VERSION}\")") - endif () - endif() - - else() - - # if the package was not found, but a version was given, add that to the output: - if(${_NAME}_FIND_VERSION_EXACT) - set(VERSION_MSG "(Required is exact version \"${${_NAME}_FIND_VERSION}\")") - else() - set(VERSION_MSG "(Required is at least version \"${${_NAME}_FIND_VERSION}\")") - endif() - - endif() - else () - # Check with DEFINED as the found version may be 0. - if(DEFINED ${FPHSA_VERSION_VAR}) - set(VERSION_MSG "(found version \"${${FPHSA_VERSION_VAR}}\")") - endif() - endif () - - if(VERSION_OK) - string(APPEND DETAILS "[v${${FPHSA_VERSION_VAR}}(${${_NAME}_FIND_VERSION})]") - else() - set(${_NAME}_FOUND FALSE) - endif() - - - # print the result: - if (${_NAME}_FOUND) - FIND_PACKAGE_MESSAGE(${_NAME} "Found ${_NAME}: ${${_FIRST_REQUIRED_VAR}} ${VERSION_MSG} ${COMPONENT_MSG}" "${DETAILS}") - else () - - if(FPHSA_CONFIG_MODE) - _FPHSA_HANDLE_FAILURE_CONFIG_MODE() - else() - if(NOT VERSION_OK) - _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: ${VERSION_MSG} (found ${${_FIRST_REQUIRED_VAR}})") - else() - _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} (missing:${MISSING_VARS}) ${VERSION_MSG}") - endif() - endif() - - endif () - - set(${_NAME}_FOUND ${${_NAME}_FOUND} PARENT_SCOPE) - set(${_NAME_UPPER}_FOUND ${${_NAME}_FOUND} PARENT_SCOPE) -endfunction() diff --git a/cmake/Modules/NewCMake/FindPackageMessage.cmake b/cmake/Modules/NewCMake/FindPackageMessage.cmake deleted file mode 100644 index 6821cee4f7..0000000000 --- a/cmake/Modules/NewCMake/FindPackageMessage.cmake +++ /dev/null @@ -1,47 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#.rst: -# FindPackageMessage -# ------------------ -# -# -# -# FIND_PACKAGE_MESSAGE( "message for user" "find result details") -# -# This macro is intended to be used in FindXXX.cmake modules files. It -# will print a message once for each unique find result. This is useful -# for telling the user where a package was found. The first argument -# specifies the name (XXX) of the package. The second argument -# specifies the message to display. The third argument lists details -# about the find result so that if they change the message will be -# displayed again. The macro also obeys the QUIET argument to the -# find_package command. -# -# Example: -# -# :: -# -# if(X11_FOUND) -# FIND_PACKAGE_MESSAGE(X11 "Found X11: ${X11_X11_LIB}" -# "[${X11_X11_LIB}][${X11_INCLUDE_DIR}]") -# else() -# ... -# endif() - -function(FIND_PACKAGE_MESSAGE pkg msg details) - # Avoid printing a message repeatedly for the same find result. - if(NOT ${pkg}_FIND_QUIETLY) - string(REPLACE "\n" "" details "${details}") - set(DETAILS_VAR FIND_PACKAGE_MESSAGE_DETAILS_${pkg}) - if(NOT "${details}" STREQUAL "${${DETAILS_VAR}}") - # The message has not yet been printed. - message(STATUS "${msg}") - - # Save the find details in the cache to avoid printing the same - # message again. - set("${DETAILS_VAR}" "${details}" - CACHE INTERNAL "Details about finding ${pkg}") - endif() - endif() -endfunction() diff --git a/cmake/Modules/NewCMake/SelectLibraryConfigurations.cmake b/cmake/Modules/NewCMake/SelectLibraryConfigurations.cmake deleted file mode 100644 index dce6f99262..0000000000 --- a/cmake/Modules/NewCMake/SelectLibraryConfigurations.cmake +++ /dev/null @@ -1,70 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#.rst: -# SelectLibraryConfigurations -# --------------------------- -# -# -# -# select_library_configurations( basename ) -# -# This macro takes a library base name as an argument, and will choose -# good values for basename_LIBRARY, basename_LIBRARIES, -# basename_LIBRARY_DEBUG, and basename_LIBRARY_RELEASE depending on what -# has been found and set. If only basename_LIBRARY_RELEASE is defined, -# basename_LIBRARY will be set to the release value, and -# basename_LIBRARY_DEBUG will be set to basename_LIBRARY_DEBUG-NOTFOUND. -# If only basename_LIBRARY_DEBUG is defined, then basename_LIBRARY will -# take the debug value, and basename_LIBRARY_RELEASE will be set to -# basename_LIBRARY_RELEASE-NOTFOUND. -# -# If the generator supports configuration types, then basename_LIBRARY -# and basename_LIBRARIES will be set with debug and optimized flags -# specifying the library to be used for the given configuration. If no -# build type has been set or the generator in use does not support -# configuration types, then basename_LIBRARY and basename_LIBRARIES will -# take only the release value, or the debug value if the release one is -# not set. - -# This macro was adapted from the FindQt4 CMake module and is maintained by Will -# Dicharry . - -macro( select_library_configurations basename ) - if(NOT ${basename}_LIBRARY_RELEASE) - set(${basename}_LIBRARY_RELEASE "${basename}_LIBRARY_RELEASE-NOTFOUND" CACHE FILEPATH "Path to a library.") - endif() - if(NOT ${basename}_LIBRARY_DEBUG) - set(${basename}_LIBRARY_DEBUG "${basename}_LIBRARY_DEBUG-NOTFOUND" CACHE FILEPATH "Path to a library.") - endif() - - if( ${basename}_LIBRARY_DEBUG AND ${basename}_LIBRARY_RELEASE AND - NOT ${basename}_LIBRARY_DEBUG STREQUAL ${basename}_LIBRARY_RELEASE AND - ( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) ) - # if the generator supports configuration types or CMAKE_BUILD_TYPE - # is set, then set optimized and debug options. - set( ${basename}_LIBRARY "" ) - foreach( _libname IN LISTS ${basename}_LIBRARY_RELEASE ) - list( APPEND ${basename}_LIBRARY optimized "${_libname}" ) - endforeach() - foreach( _libname IN LISTS ${basename}_LIBRARY_DEBUG ) - list( APPEND ${basename}_LIBRARY debug "${_libname}" ) - endforeach() - elseif( ${basename}_LIBRARY_RELEASE ) - set( ${basename}_LIBRARY ${${basename}_LIBRARY_RELEASE} ) - elseif( ${basename}_LIBRARY_DEBUG ) - set( ${basename}_LIBRARY ${${basename}_LIBRARY_DEBUG} ) - else() - set( ${basename}_LIBRARY "${basename}_LIBRARY-NOTFOUND") - endif() - - set( ${basename}_LIBRARIES "${${basename}_LIBRARY}" ) - - if( ${basename}_LIBRARY ) - set( ${basename}_FOUND TRUE ) - endif() - - mark_as_advanced( ${basename}_LIBRARY_RELEASE - ${basename}_LIBRARY_DEBUG - ) -endmacro() diff --git a/cmake/Modules/platforms/Acorn.cmake b/cmake/Modules/platforms/Acorn.cmake deleted file mode 100644 index 8bb4cb94da..0000000000 --- a/cmake/Modules/platforms/Acorn.cmake +++ /dev/null @@ -1,13 +0,0 @@ -macro (setAcorn) - - message("Setting flags and paths for Cray") - option(FIND_HDF5 "Try to Find HDF5 libraries" OFF) - option(FIND_HDF5_HL "Try to Find HDF5 libraries" ON) - set(HDF5_USE_STATIC_LIBRARIES "ON" CACHE INTERNAL "HDF5_Static" ) - - set(HOST_FLAG "" CACHE INTERNAL "Host Flag") - set(MKL_FLAG "" CACHE INTERNAL "MKL flag" ) - set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -fp-model strict -assume byterecl -convert big_endian -implicitnone -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS} -O3" CACHE INTERNAL "") - set(ENKF_Platform_FLAGS "-O3 -fp-model strict -convert big_endian -assume byterecl -implicitnone -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "") - set(GSI_LDFLAGS "${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "") -endmacro() diff --git a/cmake/Modules/platforms/Cheyenne.cmake b/cmake/Modules/platforms/Cheyenne.cmake deleted file mode 100644 index 54477168e8..0000000000 --- a/cmake/Modules/platforms/Cheyenne.cmake +++ /dev/null @@ -1,24 +0,0 @@ -macro (setCheyenne) - message("Setting paths for Cheyenne") - option(FIND_HDF5 "Try to Find HDF5 libraries" OFF) - option(FIND_HDF5_HL "Try to Find HDF5 libraries" OFF) - - set(HOST_FLAG "-xHOST" CACHE INTERNAL "Host Flag") - set(MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag") - set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -O3 -fp-model source -assume byterecl -convert big_endian -g -traceback -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "GSI Fortran Flags") - set(ENKF_Platform_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert big_endian -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "ENKF Fortran Flags") - - set(BUILD_CORELIBS "ON" ) - set(BUILD_UTIL "OFF" CACHE INTERNAL "" ) - set(BUILD_BUFR "ON" CACHE INTERNAL "") - set(BUILD_SFCIO "ON" CACHE INTERNAL "") - set(BUILD_SIGIO "ON" CACHE INTERNAL "") - set(BUILD_W3EMC "ON" CACHE INTERNAL "") - set(BUILD_W3NCO "ON" CACHE INTERNAL "") - set(BUILD_BACIO "ON" CACHE INTERNAL "") - set(BUILD_CRTM "ON" CACHE INTERNAL "") - set(BUILD_SP "ON" CACHE INTERNAL "") - set(BUILD_NEMSIO "ON" CACHE INTERNAL "") - set(ENV{MPI_HOME} $ENV{MPI_ROOT} ) -endmacro() - diff --git a/cmake/Modules/platforms/Discover.cmake b/cmake/Modules/platforms/Discover.cmake deleted file mode 100644 index fe8a2dfc0e..0000000000 --- a/cmake/Modules/platforms/Discover.cmake +++ /dev/null @@ -1,55 +0,0 @@ -macro (setDiscover) - message("Setting paths for Discover") -# option(FIND_HDF5 "Try to Find HDF5 libraries" OFF) -# option(FIND_HDF5_HL "Try to Find HDF5 libraries" OFF) - set(HDF5_USE_STATIC_LIBRARIES "OFF") - - set(HOST_FLAG "-xHOST" CACHE INTERNAL "Host Flag") - set(MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag") - set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -O3 -fp-model source -assume byterecl -convert big_endian -g -traceback -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "GSI Fortran Flags") - set(ENKF_Platform_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert big_endian -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "ENKF Fortran Flags") - set(host "Discover" CACHE INTERNAL "") - - set(COREPATH $ENV{COREPATH} ) - if( NOT DEFINED ENV{NETCDF_VER} ) - set(NETCDF_VER "3.6.3" ) - endif() - if( NOT DEFINED ENV{BACIO_VER} ) - set(BACIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{BUFR_VER} ) - set(BUFR_VER "10.2.5" ) - endif() - if( NOT DEFINED ENV{CRTM_VER} ) - set(CRTM_VER "2.2.3" ) - endif() - if( NOT DEFINED ENV{NEMSIO_VER} ) - set(NEMSIO_VER "2.2.1" ) - endif() - if( NOT DEFINED ENV{SFCIO_VER} ) - set(SFCIO_VER "1.1.0" ) - endif() - if( NOT DEFINED ENV{SIGIO_VER} ) - set(SIGIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{SP_VER} ) - set(SP_VER "2.0.2" ) - endif() - if( NOT DEFINED ENV{W3EMC_VER} ) - set(W3EMC_VER "2.2.0" ) - endif() - if( NOT DEFINED ENV{W3NCO_VER} ) - set(W3NCO_VER "2.0.6" ) - endif() - - if( ENV{BASEDIR} ) - set(BASEDIR $ENV{BASEDIR}/Linux CACHE INTERNAL "") - endif() - set(BUILD_CORELIBS "ON" CACHE INTERNAL "") - set(USE_WRF "OFF" CACHE INTERNAL "") - set(BUILD_GLOBAL "ON" CACHE INTERNAL "") - - set(ENV{MPI_HOME} $ENV{MPI_ROOT} ) - -endmacro() - diff --git a/cmake/Modules/platforms/Gaea.cmake b/cmake/Modules/platforms/Gaea.cmake deleted file mode 100644 index d6929b8f03..0000000000 --- a/cmake/Modules/platforms/Gaea.cmake +++ /dev/null @@ -1,14 +0,0 @@ -macro (setGaea) - - message("Setting flags and paths for Cray") - option(FIND_HDF5 "Try to Find HDF5 libraries" OFF) - option(FIND_HDF5_HL "Try to Find HDF5 libraries" ON) - set(HDF5_USE_STATIC_LIBRARIES "ON" CACHE INTERNAL "HDF5_Static" ) - - set(HOST_FLAG "-xCORE-AVX2" CACHE INTERNAL "Host Flag") # for Haswell (C4) - set(MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag" ) - set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -fp-model strict -assume byterecl -convert big_endian -implicitnone -D_REAL8_ -traceback ${HOST_FLAG} ${MKL_FLAG} ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS} -O3" CACHE INTERNAL "") - set(ENKF_Platform_FLAGS "-O3 -fp-model strict -convert big_endian -assume byterecl -implicitnone -DGFS -D_REAL8_ -traceback ${HOST_FLAG} ${MKL_FLAG} ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "") - set(GSI_LDFLAGS "${MKL_FLAG} ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "") - set(BUILD_CORELIBS "OFF" ) -endmacro() diff --git a/cmake/Modules/platforms/Generic.cmake b/cmake/Modules/platforms/Generic.cmake deleted file mode 100644 index 24f40107d5..0000000000 --- a/cmake/Modules/platforms/Generic.cmake +++ /dev/null @@ -1,25 +0,0 @@ -macro (setGeneric) - message("Setting paths for Generic System") - option(FIND_HDF5 "Try to Find HDF5 libraries" OFF) - option(FIND_HDF5_HL "Try to Find HDF5 libraries" OFF) - if(EXISTS /jetmon) - set(HOST_FLAG "" CACHE INTERNAL "Host Flag") ## default, no host_flag required - else() - set(HOST_FLAG "" CACHE INTERNAL "Host Flag") ## default, no host_flag required - endif() - set(MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag") - set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -O3 -fp-model source -assume byterecl -convert big_endian -g -traceback -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "GSI Fortran Flags") - set(ENKF_Platform_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert big_endian -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "ENKF Fortran Flags") - - message("setting values for corelibs") - set(BUILD_BUFR "OFF" CACHE INTERNAL "Build the BUFR library" ) - set(BUILD_BACIO "OFF" CACHE INTERNAL "Build the BACIO library" ) - set(BUILD_SFCIO "OFF" CACHE INTERNAL "Build the SFCIO library" ) - set(BUILD_SIGIO "OFF" CACHE INTERNAL "Build the SIGIO library" ) - set(BUILD_NEMSIO "OFF" CACHE INTERNAL "Build the NEMSIO library" ) - set(BUILD_SP "OFF" CACHE INTERNAL "Build the SP library" ) - set(BUILD_CRTM "OFF" CACHE INTERNAL "Build the CRTM library" ) - set(BUILD_W3EMC "OFF" CACHE INTERNAL "Build the EMC library" ) - set(BUILD_W3NCO "OFF" CACHE INTERNAL "Build the EMC library" ) - set(BUILD_NCO "OFF" CACHE INTERNAL "Build the NCO library" ) -endmacro() diff --git a/cmake/Modules/platforms/Hera.cmake b/cmake/Modules/platforms/Hera.cmake deleted file mode 100644 index d8af27696c..0000000000 --- a/cmake/Modules/platforms/Hera.cmake +++ /dev/null @@ -1,42 +0,0 @@ -macro (setHERA) - message("Setting paths for HERA") - option(FIND_HDF5 "Try to Find HDF5 libraries" ON) - option(FIND_HDF5_HL "Try to Find HDF5 libraries" OFF) - set(HOST_FLAG "-xHOST" CACHE INTERNAL "Host Flag") - set(MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag") - set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -O3 -fp-model source -assume byterecl -convert big_endian -g -traceback -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "GSI Fortran Flags") - set(ENKF_Platform_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert big_endian -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "ENKF Fortran Flags") - set(HDF5_USE_STATIC_LIBRARIES "ON") - - if( NOT DEFINED ENV{NETCDF_VER} ) - set(NETCDF_VER "3.6.3" ) - endif() - if( NOT DEFINED ENV{BACIO_VER} ) - set(BACIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{BUFR_VER} ) - set(BUFR_VER "10.2.5" ) - endif() - if( NOT DEFINED ENV{CRTM_VER} ) - set(CRTM_VER "2.2.3" ) - endif() - if( NOT DEFINED ENV{NEMSIO_VER} ) - set(NEMSIO_VER "2.2.1" ) - endif() - if( NOT DEFINED ENV{SFCIO_VER} ) - set(SFCIO_VER "1.0.0" ) - endif() - if( NOT DEFINED ENV{SIGIO_VER} ) - set(SIGIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{SP_VER} ) - set(SP_VER "2.0.2" ) - endif() - if( NOT DEFINED ENV{W3EMC_VER} ) - set(W3EMC_VER "2.0.5" ) - endif() - if( NOT DEFINED ENV{W3NCO_VER} ) - set(W3NCO_VER "2.0.6" ) - endif() -endmacro() - diff --git a/cmake/Modules/platforms/Jet.cmake b/cmake/Modules/platforms/Jet.cmake deleted file mode 100644 index 824585e366..0000000000 --- a/cmake/Modules/platforms/Jet.cmake +++ /dev/null @@ -1,42 +0,0 @@ -macro (setJet) - message("Setting paths for Jet") - option(FIND_HDF5 "Try to Find HDF5 libraries" ON) - option(FIND_HDF5_HL "Try to Find HDF5 libraries" OFF) - set(HOST_FLAG "-axSSE4.2,AVX,CORE-AVX2" CACHE INTERNAL "Host Flag") - set(MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag") - set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -O3 -fp-model source -assume byterecl -convert big_endian -g -traceback -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "GSI Fortran Flags") - set(ENKF_Platform_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert big_endian -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "ENKF Fortran Flags") - set(HDF5_USE_STATIC_LIBRARIES "ON") - - if( NOT DEFINED ENV{NETCDF_VER} ) - set(NETCDF_VER "3.6.3" ) - endif() - if( NOT DEFINED ENV{BACIO_VER} ) - set(BACIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{BUFR_VER} ) - set(BUFR_VER "10.2.5" ) - endif() - if( NOT DEFINED ENV{CRTM_VER} ) - set(CRTM_VER "2.2.3" ) - endif() - if( NOT DEFINED ENV{NEMSIO_VER} ) - set(NEMSIO_VER "2.2.1" ) - endif() - if( NOT DEFINED ENV{SFCIO_VER} ) - set(SFCIO_VER "1.0.0" ) - endif() - if( NOT DEFINED ENV{SIGIO_VER} ) - set(SIGIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{SP_VER} ) - set(SP_VER "2.0.2" ) - endif() - if( NOT DEFINED ENV{W3EMC_VER} ) - set(W3EMC_VER "2.0.5" ) - endif() - if( NOT DEFINED ENV{W3NCO_VER} ) - set(W3NCO_VER "2.0.6" ) - endif() -endmacro() - diff --git a/cmake/Modules/platforms/Orion.cmake b/cmake/Modules/platforms/Orion.cmake deleted file mode 100644 index 56ddd1f2c3..0000000000 --- a/cmake/Modules/platforms/Orion.cmake +++ /dev/null @@ -1,42 +0,0 @@ -macro (setOrion) - message("Setting paths for Orion") - option(FIND_HDF5 "Try to Find HDF5 libraries" ON) - option(FIND_HDF5_HL "Try to Find HDF5 libraries" OFF) - set(HOST_FLAG "-xHOST" CACHE INTERNAL "Host Flag") - set(MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag") - set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -O3 -fp-model source -assume byterecl -convert big_endian -g -traceback -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "GSI Fortran Flags") - set(ENKF_Platform_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert big_endian -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "ENKF Fortran Flags") - set(HDF5_USE_STATIC_LIBRARIES "ON") - - if( NOT DEFINED ENV{NETCDF_VER} ) - set(NETCDF_VER "3.6.3" ) - endif() - if( NOT DEFINED ENV{BACIO_VER} ) - set(BACIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{BUFR_VER} ) - set(BUFR_VER "10.2.5" ) - endif() - if( NOT DEFINED ENV{CRTM_VER} ) - set(CRTM_VER "2.2.3" ) - endif() - if( NOT DEFINED ENV{NEMSIO_VER} ) - set(NEMSIO_VER "2.2.1" ) - endif() - if( NOT DEFINED ENV{SFCIO_VER} ) - set(SFCIO_VER "1.0.0" ) - endif() - if( NOT DEFINED ENV{SIGIO_VER} ) - set(SIGIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{SP_VER} ) - set(SP_VER "2.0.2" ) - endif() - if( NOT DEFINED ENV{W3EMC_VER} ) - set(W3EMC_VER "2.0.5" ) - endif() - if( NOT DEFINED ENV{W3NCO_VER} ) - set(W3NCO_VER "2.0.6" ) - endif() -endmacro() - diff --git a/cmake/Modules/platforms/S4.cmake b/cmake/Modules/platforms/S4.cmake deleted file mode 100644 index 8c19f11a32..0000000000 --- a/cmake/Modules/platforms/S4.cmake +++ /dev/null @@ -1,10 +0,0 @@ -macro (setS4) - message("Setting paths for S4") - option(FIND_HDF5 "Try to Find HDF5 libraries" OFF) - option(FIND_HDF5_HL "Try to Find HDF5 libraries" OFF) - set(HOST_FLAG "-march=ivybridge" CACHE INTERNAL "Host Flag") - set(MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag") - set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -O3 -fp-model source -assume byterecl -convert big_endian -g -traceback -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "GSI Fortran Flags") - set(ENKF_Platform_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert big_endian -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "ENKF Fortran Flags") - set(HDF5_USE_STATIC_LIBRARIES "OFF") -endmacro() diff --git a/cmake/Modules/platforms/WCOSS-C.cmake b/cmake/Modules/platforms/WCOSS-C.cmake deleted file mode 100644 index 1c9cf712cd..0000000000 --- a/cmake/Modules/platforms/WCOSS-C.cmake +++ /dev/null @@ -1,60 +0,0 @@ -macro (setWCOSS_C) - - message("Setting flags and paths for Cray") - option(FIND_HDF5 "Try to Find HDF5 libraries" OFF) - option(FIND_HDF5_HL "Try to Find HDF5 libraries" ON) - set(HDF5_USE_STATIC_LIBRARIES "ON" CACHE INTERNAL "HDF5_Static" ) - - set(HOST_FLAG "-xHOST" CACHE INTERNAL "Host Flag") - set(MKL_FLAG "" CACHE INTERNAL "MKL flag" ) - set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -fp-model strict -assume byterecl -convert big_endian -implicitnone -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS} -O3" CACHE INTERNAL "") - set(ENKF_Platform_FLAGS "-O3 -fp-model strict -convert big_endian -assume byterecl -implicitnone -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "") - set(GSI_LDFLAGS "${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "") - if( NOT DEFINED ENV{COREPATH} ) - set(COREPATH "/gpfs/hps/nco/ops/nwprod/lib" ) - else() - set(COREPATH $ENV{COREPATH} ) - endif() - if( NOT DEFINED ENV{CRTM_INC} ) - set(CRTM_BASE "/gpfs/hps/nco/ops/nwprod/lib/crtm" ) - endif() - if( NOT DEFINED ENV{WRFPATH} ) - if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - set(WRFPATH "/gpfs/hps/nco/ops/nwprod/wrf_shared.v1.1.0-intel" ) - else() - set(WRFPATH "/gpfs/hps/nco/ops/nwprod/wrf_shared.v1.1.0-cray" ) - endif() - else() - set(WRFPATH $ENV{WRFPATH} ) - endif() - if( NOT DEFINED ENV{NETCDF_VER} ) - set(NETCDF_VER "3.6.3" ) - endif() - if( NOT DEFINED ENV{BACIO_VER} ) - set(BACIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{BUFR_VER} ) - set(BUFR_VER "11.0.1" ) - endif() - if( NOT DEFINED ENV{CRTM_VER} ) - set(CRTM_VER "2.2.3" ) - endif() - if( NOT DEFINED ENV{NEMSIO_VER} ) - set(NEMSIO_VER "2.2.2" ) - endif() - if( NOT DEFINED ENV{SFCIO_VER} ) - set(SFCIO_VER "1.0.0" ) - endif() - if( NOT DEFINED ENV{SIGIO_VER} ) - set(SIGIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{SP_VER} ) - set(SP_VER "2.0.2" ) - endif() - if( NOT DEFINED ENV{W3EMC_VER} ) - set(W3EMC_VER "2.2.0" ) - endif() - if( NOT DEFINED ENV{W3NCO_VER} ) - set(W3NCO_VER "2.0.6" ) - endif() -endmacro() diff --git a/cmake/Modules/platforms/WCOSS-D.cmake b/cmake/Modules/platforms/WCOSS-D.cmake deleted file mode 100644 index 19a853e609..0000000000 --- a/cmake/Modules/platforms/WCOSS-D.cmake +++ /dev/null @@ -1,48 +0,0 @@ -macro (setWCOSS_D) - message("Setting paths for Dell") - - set(HOST_FLAG "-xHOST" CACHE INTERNAL "Host Flag") - set(MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag") - set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -fp-model strict -assume byterecl -convert big_endian -implicitnone -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS} -O3" CACHE INTERNAL "GSI Fortran Flags") - set(GSI_LDFLAGS "${OpenMP_Fortran_FLAGS} ${MKL_FLAG}" CACHE INTERNAL "") - set(ENKF_Platform_FLAGS "-O3 -fp-model strict -convert big_endian -assume byterecl -implicitnone -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "ENKF Fortran Flags") - - if( NOT DEFINED ENV{COREPATH} ) - set(COREPATH "/gpfs/dell1/nco/ops/nwprod/lib" ) - else() - set(COREPATH $ENV{COREPATH} ) - endif() - if( NOT DEFINED ENV{CRTM_INC} ) - set(CRTM_BASE "/gpfs/dell1/nco/ops/nwprod/lib/crtm" ) - endif() - if( NOT DEFINED ENV{NETCDF_VER} ) - set(NETCDF_VER "3.6.3" ) - endif() - if( NOT DEFINED ENV{BACIO_VER} ) - set(BACIO_VER "2.0.2" ) - endif() - if( NOT DEFINED ENV{BUFR_VER} ) - set(BUFR_VER "11.3.0" ) - endif() - if( NOT DEFINED ENV{CRTM_VER} ) - set(CRTM_VER "2.2.5" ) - endif() - if( NOT DEFINED ENV{NEMSIO_VER} ) - set(NEMSIO_VER "2.2.3" ) - endif() - if( NOT DEFINED ENV{SFCIO_VER} ) - set(SFCIO_VER "1.0.0" ) - endif() - if( NOT DEFINED ENV{SIGIO_VER} ) - set(SIGIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{SP_VER} ) - set(SP_VER "2.0.2" ) - endif() - if( NOT DEFINED ENV{W3EMC_VER} ) - set(W3EMC_VER "2.3.0" ) - endif() - if( NOT DEFINED ENV{W3NCO_VER} ) - set(W3NCO_VER "2.0.6" ) - endif() -endmacro() diff --git a/cmake/Modules/platforms/WCOSS.cmake b/cmake/Modules/platforms/WCOSS.cmake deleted file mode 100644 index 81b1297392..0000000000 --- a/cmake/Modules/platforms/WCOSS.cmake +++ /dev/null @@ -1,61 +0,0 @@ -macro (setWCOSS) - message("Setting paths for WCOSS") - option(FIND_HDF5 "Try to Find HDF5 libraries" OFF) - option(FIND_HDF5_HL "Try to Find HDF5 libraries" OFF) - set(HDF5_USE_STATIC_LIBRARIES "OFF") - - #if ibmpe module is not loaded last, CMake tries to use intel mpi. Force use of ibmhpc - set(HOST_FLAG "-xHOST" CACHE INTERNAL "Host Flag") - set( MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag") - set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -traceback -O3 -fp-model source -convert big_endian -assume byterecl -implicitnone -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "") - set(ENKF_Platform_FLAGS "-O3 -fp-model source -convert big_endian -assume byterecl -implicitnone -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${HOST_FLAG} " CACHE INTERNAL "") - - set(MPI_Fortran_COMPILER /opt/ibmhpc/pe13010/base/bin/mpif90 CACHE FILEPATH "Forced use of ibm wrapper" FORCE ) - set(MPI_C_COMPILER /opt/ibmhpc/pe13010/base/bin/mpicc CACHE FILEPATH "Forced use of ibm wrapper" FORCE ) - set(MPI_CXX_COMPILER /opt/ibmhpc/pe13010/base/bin/mpicxx CACHE FILEPATH "Forced use of ibm wrapper" FORCE ) - - if( NOT DEFINED ENV{COREPATH} ) - set(COREPATH "/nwprod/lib" ) - else() - set(COREPATH $ENV{COREPATH} ) - endif() - if( NOT DEFINED ENV{CRTM_INC} ) - set(CRTM_BASE "/nwprod2/lib" ) - endif() - if( NOT DEFINED ENV{WRFPATH} ) - set(WRFPATH "/nwprod/sorc/wrf_shared.fd" ) - else() - set(WRFPATH $ENV{WRFPATH} ) - endif() - if( NOT DEFINED ENV{NETCDF_VER} ) - set(NETCDF_VER "3.6.3" ) - endif() - if( NOT DEFINED ENV{BACIO_VER} ) - set(BACIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{BUFR_VER} ) - set(BUFR_VER "10.2.5" ) - endif() - if( NOT DEFINED ENV{CRTM_VER} ) - set(CRTM_VER "2.2.3" ) - endif() - if( NOT DEFINED ENV{NEMSIO_VER} ) - set(NEMSIO_VER "2.2.1" ) - endif() - if( NOT DEFINED ENV{SFCIO_VER} ) - set(SFCIO_VER "1.0.0" ) - endif() - if( NOT DEFINED ENV{SIGIO_VER} ) - set(SIGIO_VER "2.0.1" ) - endif() - if( NOT DEFINED ENV{SP_VER} ) - set(SP_VER "2.0.2" ) - endif() - if( NOT DEFINED ENV{W3EMC_VER} ) - set(W3EMC_VER "2.0.5" ) - endif() - if( NOT DEFINED ENV{W3NCO_VER} ) - set(W3NCO_VER "2.0.6" ) - endif() - -endmacro() diff --git a/cmake/Modules/platforms/WCOSS2.cmake b/cmake/Modules/platforms/WCOSS2.cmake deleted file mode 100644 index d1306d9389..0000000000 --- a/cmake/Modules/platforms/WCOSS2.cmake +++ /dev/null @@ -1,13 +0,0 @@ -macro (setWCOSS2) - message("Setting flags and paths for WCOSS2") - - option(FIND_HDF5 "Try to Find HDF5 libraries" OFF) - option(FIND_HDF5_HL "Try to Find HDF5 libraries" ON) - set(HDF5_USE_STATIC_LIBRARIES "ON" CACHE INTERNAL "HDF5_Static" ) - - set(HOST_FLAG "" CACHE INTERNAL "Host Flag") - set(MKL_FLAG "" CACHE INTERNAL "MKL flag" ) - set(GSI_Intel_Platform_FLAGS "-DPOUND_FOR_STRINGIFY -fp-model strict -assume byterecl -convert big_endian -implicitnone -g -traceback -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS} -O3" CACHE INTERNAL "") - set(ENKF_Platform_FLAGS "-O3 -fp-model strict -convert big_endian -assume byterecl -implicitnone -g -traceback -DGFS -D_REAL8_ ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "") - set(GSI_LDFLAGS "${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "") -endmacro() diff --git a/cmake/Modules/setGNUFlags.cmake b/cmake/Modules/setGNUFlags.cmake deleted file mode 100644 index e4ef2d9ade..0000000000 --- a/cmake/Modules/setGNUFlags.cmake +++ /dev/null @@ -1,66 +0,0 @@ -function (setGNU) - set(COMPILER_TYPE "gnu" CACHE INTERNAL "Compiler brand") - message("Setting GNU Compiler Flags") - if( (BUILD_RELEASE) OR (BUILD_PRODUCTION) ) - set(GSI_Fortran_FLAGS " -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -D_REAL8_ ${GSDCLOUDOPT} -fopenmp -ffree-line-length-0" CACHE INTERNAL "") - set(EXTRA_LINKER_FLAGS "-lgomp -lnetcdf -lnetcdff" CACHE INTERNAL "") - set(GSI_CFLAGS "-I. -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -g -Dfunder" CACHE INTERNAL "" ) - set(ENKF_Fortran_FLAGS " -O3 -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -DGFS -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(UTIL_Fortran_FLAGS " -O3 -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -DWRF -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(UTIL_COM_Fortran_FLAGS " -O3 -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check" CACHE INTERNAL "") - set(BUFR_Fortran_FLAGS " -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(BUFR_Fortran_PP_FLAGS " -P " CACHE INTERNAL "") - set(BUFR_C_FLAGS " -O3 -g -DUNDERSCORE -DDYNAMIC_ALLOCATION -DNFILES=32 -DMAXCD=250 -DMAXNC=600 -DMXNAF=3" CACHE INTERNAL "" ) - set(BACIO_Fortran_FLAGS " -O3 -fconvert=big-endian -ffree-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(CRTM_Fortran_FLAGS " -g -std=f2003 -fdollar-ok -O3 -fconvert=big-endian -ffree-form -fno-second-underscore -frecord-marker=4 -funroll-loops -static -Wall " CACHE INTERNAL "") - set(NEMSIO_Fortran_FLAGS " -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(SIGIO_Fortran_FLAGS " -O3 -fconvert=big-endian -ffree-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(SFCIO_Fortran_FLAGS " -O3 -ffree-form -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(SP_Fortran_FLAGS " -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ -fopenmp -DLINUX" CACHE INTERNAL "") - set(SP_Fortran_4_FLAGS " -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -fopenmp -DLINUX" CACHE INTERNAL "") - set(SP_F77_FLAGS " -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ -fopenmp -DLINUX" CACHE INTERNAL "") - set(SP_F77_4_FLAGS " -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -fopenmp -DLINUX" CACHE INTERNAL "") - set(W3EMC_Fortran_FLAGS " -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(W3EMC_4_Fortran_FLAGS " -O3 -fconvert=big-endian -ffixed-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check " CACHE INTERNAL "") - set(W3NCO_Fortran_FLAGS " -O3 -fconvert=big-endian -ffixed-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ " CACHE INTERNAL "") - set(W3NCO_4_Fortran_FLAGS " -O3 -fconvert=big-endian -ffixed-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check " CACHE INTERNAL "") - set(W3NCO_C_FLAGS " -DLINUX -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(WRFLIB_Fortran_FLAGS " -O3 -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp -ffree-line-length-0" CACHE INTERNAL "") - set( NCDIAG_Fortran_FLAGS "-ffree-line-length-none" CACHE INTERNAL "" ) - set( FV3GFS_NCIO_Fortran_FLAGS "-ffree-line-length-none" CACHE INTERNAL "" ) - set( NDATE_Fortran_FLAGS "-fconvert=big-endian -DCOMMCODE -DLINUX -DUPPLITTLEENDIAN -O3 -Wl,-noinhibit-exec" CACHE INTERNAL "") - set( COV_CALC_FLAGS "-c -O3 -fconvert=little-endian -ffast-math -ffree-form -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fopenmp" CACHE INTERNAL "") - set(GSDCLOUD_Fortran_FLAGS "-O3 -fconvert=big-endian" CACHE INTERNAL "") - else( ) #DEBUG - set(GSI_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -D_REAL8_ ${GSDCLOUDOPT} -fopenmp -ffree-line-length-0" CACHE INTERNAL "") - set(EXTRA_LINKER_FLAGS "-lgomp -lnetcdf -lnetcdff" CACHE INTERNAL "") - set(GSI_CFLAGS "-I. -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -g -fbacktrace -Dfunder" CACHE INTERNAL "" ) - set(ENKF_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -DGFS -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(UTIL_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -DWRF -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(UTIL_COM_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check" CACHE INTERNAL "") - set(BUFR_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(BUFR_Fortran_PP_FLAGS " -P " CACHE INTERNAL "") - set(BUFR_C_FLAGS " -g -fbacktrace -g -fbacktrace -DUNDERSCORE -DDYNAMIC_ALLOCATION -DNFILES=32 -DMAXCD=250 -DMAXNC=600 -DMXNAF=3" CACHE INTERNAL "" ) - set(BACIO_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffree-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(CRTM_Fortran_FLAGS " -g -fbacktrace -std=f2003 -fdollar-ok -g -fbacktrace -fconvert=big-endian -ffree-form -fno-second-underscore -frecord-marker=4 -funroll-loops -static -Wall " CACHE INTERNAL "") - set(NEMSIO_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(SIGIO_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffree-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(SFCIO_Fortran_FLAGS " -g -fbacktrace -ffree-form -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(SP_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ -fopenmp -DLINUX" CACHE INTERNAL "") - set(SP_Fortran_4_FLAGS " -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -fopenmp -DLINUX" CACHE INTERNAL "") - set(SP_F77_FLAGS " -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ -fopenmp -DLINUX" CACHE INTERNAL "") - set(SP_F77_4_FLAGS " -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -fopenmp -DLINUX" CACHE INTERNAL "") - set(W3EMC_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(W3EMC_4_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffixed-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check " CACHE INTERNAL "") - set(W3NCO_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffixed-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -fdefault-real-8 -D_REAL8_ " CACHE INTERNAL "") - set(W3NCO_4_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffixed-form -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check " CACHE INTERNAL "") - set(W3NCO_C_FLAGS " -DLINUX -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp" CACHE INTERNAL "") - set(WRFLIB_Fortran_FLAGS " -g -fbacktrace -fconvert=big-endian -ffast-math -fno-second-underscore -frecord-marker=4 -funroll-loops -g -ggdb -static -Wall -fno-range-check -D_REAL8_ -fopenmp -ffree-line-length-0" CACHE INTERNAL "") - set( NCDIAG_Fortran_FLAGS "-ffree-line-length-none" CACHE INTERNAL "" ) - set( FV3GFS_NCIO_Fortran_FLAGS "-ffree-line-length-none" CACHE INTERNAL "" ) - set( NDATE_Fortran_FLAGS "-fconvert=big-endian -DCOMMCODE -DLINUX -DUPPLITTLEENDIAN -g -fbacktrace -Wl,-noinhibit-exec" CACHE INTERNAL "") - set( COV_CALC_FLAGS "-c -O3 -fconvert=little-endian -ffast-math -ffree-form -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -static -Wall -fopenmp" CACHE INTERNAL "") - set(GSDCLOUD_Fortran_FLAGS "-O3 -fconvert=big-endian" CACHE INTERNAL "") - endif( (BUILD_RELEASE) OR (BUILD_PRODUCTION) ) -endfunction() - diff --git a/cmake/Modules/setHOST.cmake b/cmake/Modules/setHOST.cmake deleted file mode 100644 index 289ea86f20..0000000000 --- a/cmake/Modules/setHOST.cmake +++ /dev/null @@ -1,105 +0,0 @@ -macro( setHOST ) - site_name(HOSTNAME) - message("The hostname is ${HOSTNAME}" ) - string(REGEX MATCH "s4-" HOST-S4 ${HOSTNAME} ) - string(REGEX MATCH "gaea" HOST-Gaea ${HOSTNAME} ) - string(REGEX MATCH "hfe[0-9]" HOST-Hera ${HOSTNAME} ) - string(REGEX MATCH "Orion" HOST-Orion ${HOSTNAME} ) - if(EXISTS /jetmon) - set(HOST-Jet "True" ) - endif() - string(REGEX MATCH "g[0-9][0-9]a" HOST-WCOSS ${HOSTNAME} ) - if( HOST-WCOSS ) - message("host is WCOSS") - endif() - string(REGEX MATCH "g[0-9][0-9]a" HOST-WCOSS ${HOSTNAME} ) - if( NOT HOST-WCOSS ) # don't overwrite if we are on gyre - string(REGEX MATCH "t[0-9][0-9]a" HOST-WCOSS ${HOSTNAME} ) - endif() - string(REGEX MATCH "v[0-9][0-9]a" HOST-WCOSS_D ${HOSTNAME} ) - if( NOT HOST-WCOSS_D )# don't overwrite if we are on venus Phase 3 - string(REGEX MATCH "v[0-9][0-9][0-9]a" HOST-WCOSS_D ${HOSTNAME} ) - endif() - if( NOT HOST-WCOSS_D )# don't overwrite if we are on venus/Phase 3.5 - string(REGEX MATCH "m[0-9][0-9]a" HOST-WCOSS_D ${HOSTNAME} ) - if( NOT HOST-WCOSS_D )# don't overwrite if we are on mars Phase 3 - string(REGEX MATCH "m[0-9][0-9][0-9]a" HOST-WCOSS_D ${HOSTNAME} ) - endif() - endif() - string(REGEX MATCH "llogin" HOST-WCOSS_C ${HOSTNAME} ) - if( NOT HOST-WCOSS_C )# don't overwrite if we are on luna - string(REGEX MATCH "slogin" HOST-WCOSS_C ${HOSTNAME} ) - endif() - string(REGEX MATCH "clogin" HOST-WCOSS2 ${HOSTNAME} ) - if( NOT HOST-WCOSS2 )# don't overwrite if we are on Cactus - string(REGEX MATCH "dlogin" HOST-WCOSS2 ${HOSTNAME} ) - endif() - string(REGEX MATCH "discover" HOST-Discover ${HOSTNAME} ) - string(REGEX MATCH "cheyenne" HOST-Cheyenne ${HOSTNAME} ) - message("done figuring out host--${HOSTNAME}") - if ( COMGSI ) - set( host "GENERIC" ) - set( HOST-Generic "TRUE" ) - setGeneric() - elseif(HOST-Jet) - option(BUILD_CORELIBS "Build the Core libraries " OFF) - set( host "Jet" ) - set( HOST-Jet "TRUE" ) - setJet() - elseif( HOST-S4 ) - option(BUILD_CORELIBS "Build the Core libraries " OFF) - set( host "S4" ) - set( HOST-S4 "TRUE" ) - setS4() - elseif( HOST-WCOSS ) - option(BUILD_CORELIBS "Build the Core libraries " OFF) - set( host "WCOSS" ) - set( HOST-WCOSS "TRUE" ) - setWCOSS() - elseif( HOST-Hera ) - set( host "Hera" ) - option(BUILD_CORELIBS "Build the Core libraries " OFF) - setHERA() - set( HOST-Hera "TRUE" ) - elseif( HOST-Orion ) - set( host "Orion" ) - option(BUILD_CORELIBS "Build the Core libraries " OFF) - setOrion() - set( HOST-Orion "TRUE" ) - elseif( HOST-Gaea ) - set( host "Gaea" ) - option(BUILD_CORELIBS "Build the Core libraries " On) - setGaea() - set( HOST-Gaea "TRUE" ) - elseif( HOST-Cheyenne ) - option(BUILD_CORELIBS "Build the Core libraries " ON) - set( host "Cheyenne" ) - setCheyenne() - set( HOST-Cheyenne "TRUE" ) - elseif( HOST-WCOSS_C ) - set( host "WCOSS_C" ) - option(BUILD_CORELIBS "Build the Core libraries " OFF) - setWCOSS_C() - set( HOST-WCOSS_C "TRUE" ) - elseif( HOST-WCOSS_D ) - set( host "WCOSS_D" ) - option(BUILD_CORELIBS "Build the Core libraries " OFF) - setWCOSS_D() - set( HOST-WCOSS_D "TRUE" ) - elseif( HOST-Discover ) - set(host "Discover" ) - setDiscover() - set( HOST-Discover "TRUE" ) - elseif( HOST-WCOSS2 ) - set( host "WCOSS2" ) - option(BUILD_CORELIBS "Build the Core libraries " OFF) - setWCOSS2() - set( HOST-WCOSS2 "TRUE" ) - else( ) - set( host "GENERIC" ) - option(BUILD_CORELIBS "Build the Core libraries " ON) - setGeneric() - set( HOST-Generic "TRUE" ) - endif() - message("Host is set to ${host}") -endmacro() diff --git a/cmake/Modules/setIntelFlags.cmake b/cmake/Modules/setIntelFlags.cmake deleted file mode 100644 index 3a23012828..0000000000 --- a/cmake/Modules/setIntelFlags.cmake +++ /dev/null @@ -1,94 +0,0 @@ -set(intsize 4) -function(set_LIBRARY_UTIL_Intel) - set(BACIO_Fortran_FLAGS "-O3 -free -assume nocc_omp ${HOST_FLAG} " CACHE INTERNAL "" ) - set(BUFR_Fortran_FLAGS "-O2 -r8 -fp-model strict -traceback -O3 ${HOST_FLAG} ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set(BUFR_C_FLAGS "-DSTATIC_ALLOCATION -DUNDERSCORE -DNFILES=32 -DMAXCD=250 -DMAXNC=600 -DMXNAF=3" CACHE INTERNAL "" ) - set(BUFR_Fortran_PP_FLAGS " -P -traditional-cpp -C " CACHE INTERNAL "" ) - set(WRFLIB_Fortran_FLAGS "-DPOUND_FOR_STRINGIFY -O3 -fp-model source -assume byterecl -convert big_endian -g -traceback -D_REAL8_ ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "") - set(WRFLIB_C_FLAGS "-I. -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -O3 -Dfunder" CACHE INTERNAL "" ) - set (CRTM_Fortran_FLAGS " -O3 -convert big_endian -free -assume byterecl -fp-model source -traceback ${HOST_FLAG}" CACHE INTERNAL "" ) - set (NEMSIO_Fortran_FLAGS " -O2 -convert big_endian -free -assume byterecl -fp-model strict -traceback ${HOST_FLAG} -g ${MKL_FLAG} ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set (SFCIO_Fortran_FLAGS " -O2 -convert big_endian -free -assume byterecl -fp-model strict -traceback ${HOST_FLAG} -g ${MKL_FLAG} ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set (SIGIO_Fortran_FLAGS " -O2 -convert big_endian -free -assume byterecl -fp-model strict -traceback ${HOST_FLAG} -g ${MKL_FLAG} ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set (SP_Fortran_FLAGS " -O2 -ip -fp-model strict -assume byterecl -convert big_endian -fpp -i${intsize} -r8 -convert big_endian -assume byterecl -DLINUX ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set (SP_Fortran_4_FLAGS " -O2 -ip -fp-model strict -assume byterecl -convert big_endian -fpp -i${intsize} -convert big_endian -assume byterecl -DLINUX ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set (SP_F77_FLAGS " -DLINUX -O2 -ip -fp-model strict -assume byterecl -convert big_endian -fpp -i${intsize} -r8 -convert big_endian -assume byterecl -DLINUX ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set (W3EMC_Fortran_FLAGS " -O3 -auto -assume nocc_omp -i${intsize} -r8 -convert big_endian -assume byterecl -fp-model strict ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set (W3EMC_4_Fortran_FLAGS " -O3 -auto -assume nocc_omp -i${intsize} -convert big_endian -assume byterecl -fp-model strict ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set (W3NCO_Fortran_FLAGS " -O3 -auto -assume nocc_omp -i${intsize} -r8 -convert big_endian -assume byterecl -fp-model strict ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set (W3NCO_4_Fortran_FLAGS " -O3 -auto -assume nocc_omp -i${intsize} -convert big_endian -assume byterecl -fp-model strict ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set (W3NCO_C_FLAGS "-O0 -DUNDERSCORE -DLINUX -D__linux__ " CACHE INTERNAL "" ) - set (NDATE_Fortran_FLAGS "${HOST_FLAG} -fp-model source -ftz -assume byterecl -convert big_endian -heap-arrays -DCOMMCODE -DLINUX -DUPPLITTLEENDIAN -O3 -Wl,-noinhibit-exec" CACHE INTERNAL "" ) - set(NCDIAG_Fortran_FLAGS "-free -assume byterecl -convert big_endian -g -traceback" CACHE INTERNAL "" ) - set(FV3GFS_NCIO_Fortran_FLAGS "-free -g -traceback" CACHE INTERNAL "" ) - set(UTIL_Fortran_FLAGS "-O3 ${HOST_FLAG} -implicitnone -g -traceback -fp-model strict -convert big_endian -DWRF -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "") - set(UTIL_COM_Fortran_FLAGS "-O3 -fp-model source -convert big_endian -assume byterecl -implicitnone -g -traceback" CACHE INTERNAL "") -# set(COV_CALC_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -traceback -fp-model strict -convert little_endian -D_REAL8_ -openmp -fpp -auto" CACHE INTERNAL "" ) - set(COV_CALC_FLAGS "-O3 ${HOST_FLAG} -implicitnone -g -traceback -fp-model strict -convert little_endian ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "") -# set(COV_CALC_FLAGS ${GSI_Intel_Platform_FLAGS} CACHE INTERNAL "Full GSI Fortran FLAGS" ) -endfunction(set_LIBRARY_UTIL_Intel) - -function(set_LIBRARY_UTIL_Debug_Intel) - set (BACIO_Fortran_FLAGS "-g -free -assume nocc_omp " CACHE INTERNAL "" ) - set(BUFR_Fortran_FLAGS " -c -g -traceback -O3 -axCORE-AVX2 -r8 " CACHE INTERNAL "" ) - set(BUFR_C_FLAGS "-g -traceback -DUNDERSCORE -O3 -axCORE-AVX2 -DDYNAMIC_ALLOCATION -DNFILES=32 -DMAXCD=250 -DMAXNC=600 -DMXNAF=3" CACHE INTERNAL "" ) - set(BUFR_Fortran_PP_FLAGS " -P -traditional-cpp -C " CACHE INTERNAL "" ) - set(CRTM_Fortran_FLAGS " -convert big_endian -free -assume byterecl -xHOST -fp-model strict -traceback -g ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set(SFCIO_Fortran_FLAGS " -convert big_endian -free -assume byterecl -xHOST -fp-model strict -traceback -g ${MKL_FLAG} ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set(SIGIO_Fortran_FLAGS " -convert big_endian -free -assume byterecl -xHOST -fp-model strict -traceback -g ${MKL_FLAG} ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set(SP_Fortran_FLAGS " -g -ip -fp-model strict -assume byterecl -fpp -i${intsize} -r8 -convert big_endian -DLINUX ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set(SP_Fortran_4_FLAGS " -g -ip -fp-model strict -assume byterecl -fpp -i${intsize} -convert big_endian -DLINUX ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set(SP_F77_FLAGS " -g -ip -fp-model strict -assume byterecl -convert big_endian -fpp -i${intsize} -r8 -DLINUX ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set(W3EMC_Fortran_FLAGS " -g -auto -assume nocc_omp -i${intsize} -r8 -convert big_endian -assume byterecl -fp-model strict ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set(W3EMC_4_Fortran_FLAGS " -g -auto -assume nocc_omp -i${intsize} -convert big_endian -assume byterecl -fp-model strict ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set(NEMSIO_Fortran_FLAGS " -convert big_endian -free -assume byterecl -xHOST -fp-model strict -traceback -g ${MKL_FLAG} ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set(W3NCO_Fortran_FLAGS " -g -auto -assume nocc_omp -i${intsize} -r8 -convert big_endian -assume byterecl -fp-model strict ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set(W3NCO_4_Fortran_FLAGS " -g -auto -assume nocc_omp -i${intsize} -convert big_endian -assume byterecl -fp-model strict ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set(W3NCO_C_FLAGS "-O0 -g -DUNDERSCORE -DLINUX -D__linux__ " CACHE INTERNAL "" ) - set(NCDIAG_Fortran_FLAGS "-free -assume byterecl -convert big_endian" CACHE INTERNAL "" ) - set(FV3GFS_NCIO_Fortran_FLAGS "-free" CACHE INTERNAL "" ) - set(WRFLIB_Fortran_FLAGS "-DPOUND_FOR_STRINGIFY -O1 -g -fp-model source -assume byterecl -convert big_endian -g -traceback -D_REAL8_ ${MPI_Fortran_COMPILE_FLAGS}" CACHE INTERNAL "") - set(NDATE_Fortran_FLAGS "${HOST_FLAG} -fp-model source -ftz -assume byterecl -convert big_endian -heap-arrays -DCOMMCODE -DLINUX -DUPPLITTLEENDIAN -g -Wl,-noinhibit-exec" CACHE INTERNAL "" ) - set(WRFLIB_C_FLAGS "-I. -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -g -Dfunder" CACHE INTERNAL "" ) - set(UTIL_Fortran_FLAGS "-O0 ${HOST_FLAG} -warn all -implicitnone -traceback -g -debug full -fp-model strict -convert big_endian -D_REAL8_ ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "") - set(UTIL_COM_Fortran_FLAGS "-O0 -warn all -implicitnone -traceback -g -debug full -fp-model strict -convert big_endian" CACHE INTERNAL "") - set(COV_CALC_FLAGS "-O3 ${HOST_FLAG} -implicitnone -traceback -fp-model strict -convert little_endian ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) -endfunction(set_LIBRARY_UTIL_Debug_Intel) - -function(set_GSI_ENKF_Intel) - #Common release/production flags - set(GSI_CFLAGS "-I. -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -O3 -Dfunder" CACHE INTERNAL "" ) - set(GSI_Fortran_FLAGS "${GSI_Intel_Platform_FLAGS} ${GSDCLOUDOPT}" CACHE INTERNAL "Full GSI Fortran FLAGS" ) - set(ENKF_Fortran_FLAGS "${ENKF_Platform_FLAGS} ${GSDCLOUDOPT}" CACHE INTERNAL "Full ENKF Fortran FLAGS" ) - set(GSDCLOUD_Fortran_FLAGS "-O3 -convert big_endian" CACHE INTERNAL "") -endfunction(set_GSI_ENKF_Intel) - -function (set_GSI_ENKF_Debug_Intel) - set(GSI_Fortran_FLAGS "-DPOUND_FOR_STRINGIFY -O0 -fp-model source -convert big_endian -assume byterecl -implicitnone -g -traceback -debug -ftrapuv -check all,noarg_temp_created -fp-stack-check -fstack-protector -warn all,nointerfaces -convert big_endian -implicitnone -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAGS} ${GSDCLOUDOPT}" CACHE INTERNAL "") - set(ENKF_Fortran_FLAGS "-O0 ${HOST_FLAG} -warn all -implicitnone -traceback -g -debug all -check all,noarg_temp_created -fp-model strict -convert big_endian -assume byterecl -D_REAL8_ ${OpenMP_Fortran_FLAGS} ${GSDCLOUDOPT}" CACHE INTERNAL "") - set(GSDCLOUD_Fortran_FLAGS "-DPOUND_FOR_STRINGIFY -O3 -convert big_endian" CACHE INTERNAL "") - #Common debug flags - set(GSI_CFLAGS "-I. -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -g -Dfunder" CACHE INTERNAL "" ) -endfunction (set_GSI_ENKF_Debug_Intel) - -function (setIntel) - string(REPLACE "." ";" COMPILER_VERSION_LIST ${CMAKE_C_COMPILER_VERSION}) - list(GET COMPILER_VERSION_LIST 0 MAJOR_VERSION) - list(GET COMPILER_VERSION_LIST 1 MINOR_VERSION) - list(GET COMPILER_VERSION_LIST 2 PATCH_VERSION) - set(COMPILER_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}" CACHE INTERNAL "Compiler Version") - set(COMPILER_TYPE "intel" CACHE INTERNAL "Compiler brand") - STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "RELEASE" BUILD_RELEASE) - STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "PRODUCTION" BUILD_PRODUCTION) - set(EXTRA_LINKER_FLAGS ${MKL_FLAG} CACHE INTERNAL "Extra Linker flags") - if( (BUILD_RELEASE) OR (BUILD_PRODUCTION) ) - set_GSI_ENKF_Intel() - set_LIBRARY_UTIL_Intel() - else( ) #DEBUG flags - message("Building DEBUG version of GSI") - set( debug_suffix "_DBG" CACHE INTERNAL "" ) - set_GSI_ENKF_Debug_Intel() - set_LIBRARY_UTIL_Debug_Intel() - endif() -endfunction() - diff --git a/cmake/Modules/setPGIFlags.cmake b/cmake/Modules/setPGIFlags.cmake deleted file mode 100644 index 2088a7416d..0000000000 --- a/cmake/Modules/setPGIFlags.cmake +++ /dev/null @@ -1,78 +0,0 @@ -function (setPGI) - message("Setting PGI Compiler Flags") - set(COMPILER_TYPE "pgi" CACHE INTERNAL "Compiler brand") - if( (BUILD_RELEASE) OR (BUILD_PRODUCTION) ) - set(CMAKE_Fortran_FLAGS_RELEASE "") - set(Fortran_FLAGS "" CACHE INTERNAL "") - set(GSI_Fortran_FLAGS "-Minform=inform -O1 -byteswapio -D_REAL8_ ${GSDCLOUDOPT} -mp -Mfree" CACHE INTERNAL "") - set(GSI_CFLAGS "-I. -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -g -Dfunder" CACHE INTERNAL "" ) - set(ENKF_Fortran_FLAGS " -O3 -byteswapio -fast -DGFS -D_REAL8_ -mp" CACHE INTERNAL "") - set(UTIL_Fortran_FLAGS " -O3 -byteswapio -fast -DWRF -D_REAL8_ -mp" CACHE INTERNAL "") - set(UTIL_COM_Fortran_FLAGS " -O3 -byteswapio -fast" CACHE INTERNAL "") - - set(BUFR_Fortran_FLAGS "-O1 -byteswapio -D_REAL8_ -mp -r8" CACHE INTERNAL "") - set(BUFR_Fortran_PP_FLAGS " -P " CACHE INTERNAL "") - set(BUFR_C_FLAGS " -g -DUNDERSCORE -DDYNAMIC_ALLOCATION -DNFILES=32 -DMAXCD=250 -DMAXNC=600 -DMXNAF=3" CACHE INTERNAL "" ) - - set(BACIO_C_INCLUDES " -I/usr/include/malloc" CACHE INTERNAL "") - set(BACIO_Fortran_FLAGS " -O3 -byteswapio -fast -D_REAL8_ -mp -Mfree" CACHE INTERNAL "") - set(CRTM_Fortran_FLAGS " -O1 -byteswapio -module ../../include -Mfree " CACHE INTERNAL "") - set(NEMSIO_Fortran_FLAGS " -O1 -byteswapio -D_REAL8_ -mp" CACHE INTERNAL "") - set(SIGIO_Fortran_FLAGS " -O3 -Mfree -byteswapio -fast -D_REAL8_ -mp" CACHE INTERNAL "") - set(SFCIO_Fortran_FLAGS " -O3 -byteswapio -Mfree -fast -D_REAL8_ -mp" CACHE INTERNAL "") - set(SP_Fortran_FLAGS " -O1 -byteswapio -DLINUX -mp -r8 " CACHE INTERNAL "") - set(SP_Fortran_4_FLAGS " -O1 -byteswapio -DLINUX -mp " CACHE INTERNAL "") - set(SP_F77_4_FLAGS "-DLINUX -O1 -byteswapio -DLINUX -mp " CACHE INTERNAL "") - set(SP_F77_FLAGS "-DLINUX -O1 -byteswapio -DLINUX -mp -r8 " CACHE INTERNAL "") - set(W3EMC_Fortran_FLAGS " -O1 -byteswapio -D_REAL8_ -r8 " CACHE INTERNAL "") - set(W3EMC_4_Fortran_FLAGS " -O1 -byteswapio " CACHE INTERNAL "") - set(W3NCO_Fortran_FLAGS " -O1 -byteswapio -D_REAL8_ -r8 " CACHE INTERNAL "") - set(W3NCO_4_Fortran_FLAGS " -DLINUX -O1 -byteswapio " CACHE INTERNAL "") - set(W3NCO_C_FLAGS " -O1 -D_REAL8_ -mp" CACHE INTERNAL "") - set(WRFLIB_Fortran_FLAGS "-Minform=inform -O1 -byteswapio -D_REAL8_ -mp -Mfree" CACHE INTERNAL "") - set(NDATE_Fortran_FLAGS "-DCOMMCODE -DLINUX -DUPPLITTLEENDIAN -O3 " CACHE INTERNAL "") - set(COV_CALC_FLAGS "-O3 -byteswapio -mp" CACHE INTERNAL "") - set(GSDCLOUD_Fortran_FLAGS "-O3 -byteswapio" CACHE INTERNAL "") - if ( ${CMAKE_C_COMPILER_VERSION} VERSION_LESS 18.5 ) - set( NCDIAG_Fortran_FLAGS "-Mfree -DOLDPGI" CACHE INTERNAL "" ) - else() - set( NCDIAG_Fortran_FLAGS "-Mfree" CACHE INTERNAL "" ) - endif() - else() - set(Fortran_FLAGS "" CACHE INTERNAL "") - set(GSI_Fortran_FLAGS "-Minform=inform -g -traceback -byteswapio -D_REAL8_ ${GSDCLOUDOPT} -mp -Mfree" CACHE INTERNAL "") - set(GSI_CFLAGS "-I. -DFortranByte=char -DFortranInt=int -DFortranLlong='long long' -g -traceback -Dfunder" CACHE INTERNAL "" ) - set(ENKF_Fortran_FLAGS " -g -traceback -byteswapio -fast -DGFS -D_REAL8_ -mp" CACHE INTERNAL "") - set(UTIL_Fortran_FLAGS " -g -traceback -byteswapio -fast -DWRF -D_REAL8_ -mp" CACHE INTERNAL "") - set(UTIL_COM_Fortran_FLAGS " -g -traceback -byteswapio -fast" CACHE INTERNAL "") - - set(BUFR_Fortran_FLAGS "-g -traceback -byteswapio -D_REAL8_ -mp -r8" CACHE INTERNAL "") - set(BUFR_Fortran_PP_FLAGS " -P " CACHE INTERNAL "") - set(BUFR_C_FLAGS " -g -traceback -DUNDERSCORE -DDYNAMIC_ALLOCATION -DNFILES=32 -DMAXCD=250 -DMAXNC=600 -DMXNAF=3" CACHE INTERNAL "" ) - - set(BACIO_C_INCLUDES " -I/usr/include/malloc" CACHE INTERNAL "") - set(BACIO_Fortran_FLAGS " -g -traceback -byteswapio -fast -D_REAL8_ -mp -Mfree" CACHE INTERNAL "") - set(CRTM_Fortran_FLAGS " -g -traceback -byteswapio -module ../../include -Mfree " CACHE INTERNAL "") - set(NEMSIO_Fortran_FLAGS " -g -traceback -byteswapio -D_REAL8_ -mp" CACHE INTERNAL "") - set(SIGIO_Fortran_FLAGS " -g -traceback -Mfree -byteswapio -fast -D_REAL8_ -mp" CACHE INTERNAL "") - set(SFCIO_Fortran_FLAGS " -g -traceback -byteswapio -Mfree -fast -D_REAL8_ -mp" CACHE INTERNAL "") - set(SP_Fortran_FLAGS " -g -traceback -byteswapio -DLINUX -mp -r8 " CACHE INTERNAL "") - set(SP_Fortran_4_FLAGS " -g -traceback -byteswapio -DLINUX -mp " CACHE INTERNAL "") - set(SP_F77_4_FLAGS "-DLINUX -g -traceback -byteswapio -DLINUX -mp " CACHE INTERNAL "") - set(SP_F77_FLAGS "-DLINUX -g -traceback -byteswapio -DLINUX -mp -r8 " CACHE INTERNAL "") - set(W3EMC_Fortran_FLAGS " -g -traceback -byteswapio -D_REAL8_ -r8 " CACHE INTERNAL "") - set(W3EMC_4_Fortran_FLAGS " -g -traceback -byteswapio " CACHE INTERNAL "") - set(W3NCO_Fortran_FLAGS " -g -traceback -byteswapio -D_REAL8_ -r8 " CACHE INTERNAL "") - set(W3NCO_4_Fortran_FLAGS " -g -traceback -byteswapio " CACHE INTERNAL "") - set(W3NCO_C_FLAGS " -DLINUX -g -traceback -D_REAL8_ -mp" CACHE INTERNAL "") - set(WRFLIB_Fortran_FLAGS "-Minform=inform -g -traceback -byteswapio -D_REAL8_ -mp -Mfree" CACHE INTERNAL "") - set(NDATE_Fortran_FLAGS "-DCOMMCODE -DLINUX -DUPPLITTLEENDIAN -g -traceback " CACHE INTERNAL "") - set(COV_CALC_FLAGS "-O3 -byteswapio -traceback -mp" CACHE INTERNAL "") - set(GSDCLOUD_Fortran_FLAGS "-O3 -byteswapio" CACHE INTERNAL "") - if ( ${CMAKE_C_COMPILER_VERSION} VERSION_LESS 18.5 ) - set( NCDIAG_Fortran_FLAGS "-Mfree -DOLDPGI" CACHE INTERNAL "" ) - else() - set( NCDIAG_Fortran_FLAGS "-Mfree" CACHE INTERNAL "" ) - endif() - endif( (BUILD_RELEASE) OR (BUILD_PRODUCTION) ) -endfunction() diff --git a/cmake/Modules/setPlatformVariables.cmake b/cmake/Modules/setPlatformVariables.cmake deleted file mode 100644 index fc8d1501ad..0000000000 --- a/cmake/Modules/setPlatformVariables.cmake +++ /dev/null @@ -1,12 +0,0 @@ -include(${CMAKE_CURRENT_LIST_DIR}/platforms/Jet.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/platforms/WCOSS.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/platforms/WCOSS-C.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/platforms/S4.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/platforms/Hera.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/platforms/Orion.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/platforms/Gaea.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/platforms/Cheyenne.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/platforms/Discover.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/platforms/WCOSS-D.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/platforms/WCOSS2.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/platforms/Generic.cmake) diff --git a/modulefiles/gsi_cheyenne.gnu.lua b/modulefiles/gsi_cheyenne.gnu.lua new file mode 100644 index 0000000000..9cd0337520 --- /dev/null +++ b/modulefiles/gsi_cheyenne.gnu.lua @@ -0,0 +1,29 @@ +help([[ +]]) + +load("cmake/3.22.0") +load("python/3.7.9") +load("ncarenv/1.3") +load("gnu/10.1.0") +load("mpt/2.22") +load("ncarcompilers/0.5.0") +unload("netcdf") + +prepend_path("MODULEPATH", "/glade/p/ral/jntp/GMTB/tools/hpc-stack-v1.2.0/modulefiles/stack") + +load("hpc/1.2.0") +load("hpc-gnu/10.1.0") +load("hpc-mpt/2.22") + +load("gsi_common") + +local prod_util_ver=os.getenv("prod_util_ver") or "1.2.2" +load(pathJoin("prod_util", prod_util_ver)) + +pushenv("MKLROOT", "/glade/u/apps/opt/intel/2021.2/mkl/latest") + +pushenv("CC", "mpicc") +pushenv("FC", "mpif90") +pushenv("CXX", "mpicxx") + +whatis("Description: GSI environment on Cheyenne with GNU Compilers") diff --git a/modulefiles/gsi_cheyenne.intel.lua b/modulefiles/gsi_cheyenne.intel.lua new file mode 100644 index 0000000000..9a0c4f721b --- /dev/null +++ b/modulefiles/gsi_cheyenne.intel.lua @@ -0,0 +1,26 @@ +help([[ +]]) + +load("cmake/3.22.0") +load("python/3.7.9") +load("ncarenv/1.3") +load("intel/2021.2") +load("mpt/2.22") +load("ncarcompilers/0.5.0") + +prepend_path("MODULEPATH", "/glade/p/ral/jntp/GMTB/tools/hpc-stack-v1.2.0/modulefiles/stack") + +load("hpc/1.2.0") +load("hpc-intel/2021.2") +load("hpc-mpt/2.22") +load("mkl/2021.2") + +load("gsi_common") + +local prod_util_ver=os.getenv("prod_util_ver") or "1.2.2" +load(pathJoin("prod_util", prod_util_ver)) + +pushenv("CFLAGS", "-xHOST") +pushenv("FFLAGS", "-xHOST") + +whatis("Description: GSI environment on Cheyenne with Intel Compilers") diff --git a/modulefiles/gsi_common.lua b/modulefiles/gsi_common.lua new file mode 100644 index 0000000000..07442cbf23 --- /dev/null +++ b/modulefiles/gsi_common.lua @@ -0,0 +1,32 @@ +help([[ +Load common modules to build GSI on all machines +]]) + +local netcdf_ver=os.getenv("netcdf_ver") or "4.7.4" + +local bufr_ver=os.getenv("bufr_ver") or "11.5.0" +local bacio_ver=os.getenv("bacio_ver") or "2.4.1" +local w3emc_ver=os.getenv("w3emc_ver") or "2.9.1" +local sp_ver=os.getenv("sp_ver") or "2.3.3" +local ip_ver=os.getenv("ip_ver") or "3.3.3" +local sigio_ver=os.getenv("sigio_ver") or "2.3.2" +local sfcio_ver=os.getenv("sfcio_ver") or "1.4.1" +local nemsio_ver=os.getenv("nemsio_ver") or "2.5.2" +local wrf_io_ver=os.getenv("wrf_io_ver") or "1.2.0" +local ncio_ver=os.getenv("ncio_ver") or "1.0.0" +local crtm_ver=os.getenv("crtm_ver") or "2.3.0" + +load(pathJoin("netcdf", netcdf_ver)) + +load(pathJoin("bufr", bufr_ver)) +load(pathJoin("bacio", bacio_ver)) +load(pathJoin("w3emc", w3emc_ver)) +load(pathJoin("sp", sp_ver)) +load(pathJoin("ip", ip_ver)) +load(pathJoin("sigio", sigio_ver)) +load(pathJoin("sfcio", sfcio_ver)) +load(pathJoin("nemsio", nemsio_ver)) +load(pathJoin("wrf_io", wrf_io_ver)) +load(pathJoin("ncio", ncio_ver)) +load(pathJoin("crtm", crtm_ver)) + diff --git a/modulefiles/modulefile.ProdGSI.discover b/modulefiles/gsi_discover similarity index 87% rename from modulefiles/modulefile.ProdGSI.discover rename to modulefiles/gsi_discover index 2c6d32b661..4f4b04047f 100644 --- a/modulefiles/modulefile.ProdGSI.discover +++ b/modulefiles/gsi_discover @@ -13,3 +13,8 @@ module load other/comp/gcc-9.1 module load other/cmake-3.8.2 setenv BASEDIR /discover/nobackup/projects/gmao/share/gmao_ops/Baselibs/v5.1.3_build1/x86_64-unknown-linux-gnu/ifort_18.0.3.222-mpt_2.17 + +# Compiler flags specific to this platform +setenv CFLAGS "-xHOST" +setenv FFLAGS "-xHOST" + diff --git a/modulefiles/modulefile.ProdGSI.gaea b/modulefiles/gsi_gaea similarity index 95% rename from modulefiles/modulefile.ProdGSI.gaea rename to modulefiles/gsi_gaea index 163da2c707..91089895a1 100644 --- a/modulefiles/modulefile.ProdGSI.gaea +++ b/modulefiles/gsi_gaea @@ -58,3 +58,8 @@ module load crtm-intel/2.2.4 module load bacio-intel-sandybridge/2.0.2 setenv CRAYOS_VERSION $::env(CRAYPE_VERSION) #setenv CRAYOS_VERSION ${CRAYPE_VERSION} + +# Compiler flags specific to this platform +setenv CFLAGS "-xCORE-AVX2" +setenv FFLAGS "-xCORE-AVX2" + diff --git a/modulefiles/gsi_hera.gnu.lua b/modulefiles/gsi_hera.gnu.lua new file mode 100644 index 0000000000..ddf96cc84e --- /dev/null +++ b/modulefiles/gsi_hera.gnu.lua @@ -0,0 +1,23 @@ +help([[ +]]) + +prepend_path("MODULEPATH", "/scratch2/NCEPDEV/nwprod/hpc-stack/libs/hpc-stack/modulefiles/stack") + +local hpc_ver=os.getenv("hpc_ver") or "1.1.0" +local hpc_intel_ver=os.getenv("hpc_gnu_ver") or "9.2.0" +local impi_ver=os.getenv("hpc_mpich_ver") or "3.3.2" +local cmake_ver=os.getenv("cmake_ver") or "3.20.1" +local prod_util_ver=os.getenv("prod_util_ver") or "1.2.2" + +load(pathJoin("hpc", hpc_ver)) +load(pathJoin("hpc-gnu", hpc_gnu_ver)) +load(pathJoin("hpc-mpich", hpc_mpich_ver)) +load(pathJoin("cmake", cmake_ver)) + +load("gsi_common") + +load(pathJoin("prod_util", prod_util_ver)) + +pushenv("MKLROOT", "/apps/oneapi/mkl/2022.0.2") + +whatis("Description: GSI environment on Hera with GNU Compilers") diff --git a/modulefiles/gsi_hera.intel.lua b/modulefiles/gsi_hera.intel.lua new file mode 100644 index 0000000000..e1f45be71f --- /dev/null +++ b/modulefiles/gsi_hera.intel.lua @@ -0,0 +1,29 @@ +help([[ +]]) + +prepend_path("MODULEPATH", "/scratch2/NCEPDEV/nwprod/hpc-stack/libs/hpc-stack/modulefiles/stack") + +local hpc_ver=os.getenv("hpc_ver") or "1.1.0" +local hpc_intel_ver=os.getenv("hpc_intel_ver") or "18.0.5.274" +local impi_ver=os.getenv("hpc_impi_ver") or "2018.0.4" +local cmake_ver=os.getenv("cmake_ver") or "3.20.1" +local anaconda_ver=os.getenv("anaconda_ver") or "2.3.0" +local prod_util_ver=os.getenv("prod_util_ver") or "1.2.2" + +load(pathJoin("hpc", hpc_ver)) +load(pathJoin("hpc-intel", hpc_intel_ver)) +load(pathJoin("hpc-impi", hpc_impi_ver)) +load(pathJoin("cmake", cmake_ver)) + +prepend_path("MODULEPATH", "/contrib/anaconda/modulefiles") + +load(pathJoin("anaconda", anaconda_ver)) + +load("gsi_common") + +load(pathJoin("prod_util", prod_util_ver)) + +pushenv("CFLAGS", "-xHOST") +pushenv("FFLAGS", "-xHOST") + +whatis("Description: GSI environment on Hera with Intel Compilers") diff --git a/modulefiles/gsi_jet.lua b/modulefiles/gsi_jet.lua new file mode 100644 index 0000000000..df05f29476 --- /dev/null +++ b/modulefiles/gsi_jet.lua @@ -0,0 +1,24 @@ +help([[ +]]) + +load("cmake/3.20.1") + +prepend_path("MODULEPATH", "/contrib/anaconda/modulefiles") + +load("anaconda/5.3.1") + +prepend_path("MODULEPATH", "/lfs4/HFIP/hfv3gfs/nwprod/hpc-stack/libs/modulefiles/stack") + +load("hpc/1.1.0") +load("hpc-intel/18.0.5.274") +load("hpc-impi/2018.4.274") + +load("gsi_common") + +local prod_util_ver=os.getenv("prod_util_ver") or "1.2.2" +load(pathJoin("prod_util", prod_util_ver)) + +pushenv("CFLAGS", "-axSSE4.2,AVX,CORE-AVX2") +pushenv("FFLAGS", "-axSSE4.2,AVX,CORE-AVX2") + +whatis("Description: GSI environment on Jet with Intel Compilers") diff --git a/modulefiles/gsi_orion.lua b/modulefiles/gsi_orion.lua new file mode 100644 index 0000000000..bfe4dcb401 --- /dev/null +++ b/modulefiles/gsi_orion.lua @@ -0,0 +1,26 @@ +help([[ +]]) + +prepend_path("MODULEPATH", "/apps/contrib/NCEP/libs/hpc-stack/modulefiles/stack") + +local hpc_ver=os.getenv("hpc_ver") or "1.1.0" +local hpc_intel_ver=os.getenv("hpc_intel_ver") or "2018.4" +local impi_ver=os.getenv("hpc_impi_ver") or "2018.4" +local cmake_ver=os.getenv("cmake_ver") or "3.22.1" +local python_ver=os.getenv("python_ver") or "3.7.5" +local prod_util_ver=os.getenv("prod_util_ver") or "1.2.2" + +load(pathJoin("hpc", hpc_ver)) +load(pathJoin("hpc-intel", hpc_intel_ver)) +load(pathJoin("hpc-impi", hpc_impi_ver)) +load(pathJoin("cmake", cmake_ver)) +load(pathJoin("python", python_ver)) + +load("gsi_common") + +load(pathJoin("prod_util", prod_util_ver)) + +pushenv("CFLAGS", "-xHOST") +pushenv("FFLAGS", "-xHOST") + +whatis("Description: GSI environment on Orion with Intel Compilers") diff --git a/modulefiles/gsi_s4.lua b/modulefiles/gsi_s4.lua new file mode 100644 index 0000000000..cf047aae94 --- /dev/null +++ b/modulefiles/gsi_s4.lua @@ -0,0 +1,26 @@ +help([[ +]]) + +local hpc_ver=os.getenv("hpc_ver") or "1.1.0" +local hpc_intel_ver=os.getenv("hpc_intel_ver") or "18.0.4" +local impi_ver=os.getenv("hpc_impi_ver") or "18.0.4" +local miniconda_ver=os.getenv("miniconda_ver") or "3.8-s4" +local prod_util_ver=os.getenv("prod_util_ver") or "1.2.2" + +prepend_path("MODULEPATH", "/data/prod/hpc-stack/modulefiles/stack") + +load("license_intel/S4") +load(pathJoin("hpc", hpc_ver)) +load(pathJoin("hpc-intel", hpc_intel_ver)) +load(pathJoin("hpc-impi", hpc_impi_ver)) + +load(pathJoin("miniconda", miniconda_ver)) + +load("gsi_common") + +load(pathJoin("prod_util", prod_util_ver)) + +pushenv("CFLAGS", "-march=ivybridge") +pushenv("FFLAGS", "-march=ivybridge") + +whatis("Description: GSI environment on S4 with Intel Compilers") diff --git a/modulefiles/gsi_wcoss2.lua b/modulefiles/gsi_wcoss2.lua new file mode 100644 index 0000000000..138946252c --- /dev/null +++ b/modulefiles/gsi_wcoss2.lua @@ -0,0 +1,23 @@ +help([[ +]]) + +local PrgEnv_intel_ver=os.getenv("PrgEnv_intel_ver") or "8.1.0" +local intel_ver=os.getenv("intel_ver") or "19.1.3.304" +local craype_ver=os.getenv("craype_ver") or "2.7.8" +local cray_mpich_ver=os.getenv("cray_mpich_ver") or "8.1.7" +local cmake_ver= os.getenv("cmake_ver") or "3.20.2" +local python_ver=os.getenv("python_ver") or "3.8.6" +local prod_util_ver=os.getenv("prod_util_ver") or "2.0.10" + +load(pathJoin("PrgEnv-intel", PrgEnv_intel_ver)) +load(pathJoin("intel", intel_ver)) +load(pathJoin("craype", craype_ver)) +load(pathJoin("cray-mpich", cray_mpich_ver)) +load(pathJoin("cmake", cmake_ver)) +load(pathJoin("python", python_ver)) + +load(pathJoin("prod_util", prod_util_ver)) + +load("gsi_common") + +whatis("Description: GSI environment on WCOSS2") diff --git a/modulefiles/modulefile.ProdGSI.wcoss_c b/modulefiles/gsi_wcoss_cray similarity index 93% rename from modulefiles/modulefile.ProdGSI.wcoss_c rename to modulefiles/gsi_wcoss_cray index f02f4ded73..6d98a926f8 100644 --- a/modulefiles/modulefile.ProdGSI.wcoss_c +++ b/modulefiles/gsi_wcoss_cray @@ -50,3 +50,8 @@ module load crtm-intel/2.3.0 # Loading python module load python/3.6.3 + +# Compiler flags specific to this platform +setenv CFLAGS "-xHOST" +setenv FFLAGS "-xHOST" + diff --git a/modulefiles/gsi_wcoss_dell_p3.lua b/modulefiles/gsi_wcoss_dell_p3.lua new file mode 100644 index 0000000000..1db53e3081 --- /dev/null +++ b/modulefiles/gsi_wcoss_dell_p3.lua @@ -0,0 +1,37 @@ +help([[ +]]) + +local hpc_ver=os.getenv("hpc_ver") or "1.1.0" +local hpc_intel_ver=os.getenv("hpc_ips_ver") or "18.0.1.163" +local impi_ver=os.getenv("hpc_impi_ver") or "18.0.1" +local cmake_ver=os.getenv("cmake_ver") or "3.20.0" +local lsf_ver=os.getenv("lsf_ver") or "10.1" +local jasper_ver=os.getenv("jasper_ver") or "2.0.22" +local zlib_ver=os.getenv("zlib_ver") or "1.2.11" +local png_ver=os.getenv("png_ver") or "1.6.35" +local python_ver=os.getenv("python_ver") or "3.6.3" +local prod_util_ver=os.getenv("prod_util_ver") or "1.2.2" + +load(pathJoin("python", python_ver)) +load(pathJoin("lsf", lsf_ver)) + +prepend_path("MODULEPATH", "/usrx/local/nceplibs/dev/hpc-stack/libs/hpc-stack/modulefiles/stack") + +load(pathJoin("hpc", hpc_ver)) +load(pathJoin("hpc-ips", hpc_ips_ver)) +load(pathJoin("hpc-impi", hpc_impi_ver)) + +load(pathJoin("cmake", cmake_ver)) + +load(pathJoin("jasper", jasper_ver)) +load(pathJoin("zlib", zlib_ver)) +load(pathJoin("png", png_ver)) + +load("gsi_common") + +load(pathJoin("prod_util", prod_util_ver)) + +pushenv("CFLAGS", "-xHOST") +pushenv("FFLAGS", "-xHOST") + +whatis("Description: GSI environment on WCOSS Dell") diff --git a/modulefiles/modulefile.ProdGSI.cheyenne b/modulefiles/modulefile.ProdGSI.cheyenne deleted file mode 100644 index 211b681ad7..0000000000 --- a/modulefiles/modulefile.ProdGSI.cheyenne +++ /dev/null @@ -1,16 +0,0 @@ -#%Module###################################################################### -## Mark.Potts@noaa.gov -## NOAA/NWS/NCEP/EMC -## NOAA-EMC/GSI -##_____________________________________________________ - -module purge -module load ncarenv/1.2 -module load cmake/3.9.1 -module load intel/18.0.1 -module load impi/2018.1.163 -module load mkl/2018.0.1 -module load netcdf/4.5.0 -module list - -echo "done loading modules" diff --git a/modulefiles/modulefile.ProdGSI.hera.lua b/modulefiles/modulefile.ProdGSI.hera.lua deleted file mode 100644 index ff73a3c513..0000000000 --- a/modulefiles/modulefile.ProdGSI.hera.lua +++ /dev/null @@ -1,63 +0,0 @@ -help([[ -Load environment to compile GSI on Hera -]]) - -prepend_path("MODULEPATH", "/scratch2/NCEPDEV/nwprod/hpc-stack/libs/hpc-stack/modulefiles/stack") - -hpc_ver=os.getenv("hpc_ver") or "1.1.0" -load(pathJoin("hpc", hpc_ver)) - -hpc_intel_ver=os.getenv("hpc_intel_ver") or "18.0.5.274" -load(pathJoin("hpc-intel", hpc_intel_ver)) - -impi_ver=os.getenv("hpc_impi_ver") or "2018.0.4" -load(pathJoin("hpc-impi", hpc_impi_ver)) - -cmake_ver=os.getenv("cmake_ver") or "3.16.1" -load(pathJoin("cmake", cmake_ver)) - -prepend_path("MODULEPATH", "/contrib/anaconda/modulefiles") - -anaconda_ver=os.getenv("anaconda_ver") or "2.3.0" -load(pathJoin("anaconda", anaconda_ver)) - -prod_util_ver=os.getenv("prod_util_ver") or "1.2.2" -load(pathJoin("prod_util", prod_util_ver)) - -bufr_ver=os.getenv("bufr_ver") or "11.4.0" -load(pathJoin("bufr", bufr_ver)) - -ip_ver=os.getenv("ip_ver") or "3.3.3" -load(pathJoin("ip", ip_ver)) - -nemsio_ver=os.getenv("nemsio_ver") or "2.5.2" -load(pathJoin("nemsio", nemsio_ver)) - -sfcio_ver=os.getenv("sfcio_ver") or "1.4.1" -load(pathJoin("sfcio", sfcio_ver)) - -sigio_ver=os.getenv("sigio_ver") or "2.3.2" -load(pathJoin("sigio", sigio_ver)) - -sp_ver=os.getenv("sp_ver") or "2.3.3" -load(pathJoin("sp", sp_ver)) - -w3nco_ver=os.getenv("w3nco_ver") or "2.4.1" -load(pathJoin("w3nco", w3nco_ver)) - -w3emc_ver=os.getenv("w3emc_ver") or "2.9.2" -load(pathJoin("w3emc", w3emc_ver)) - -bacio_ver=os.getenv("bacio_ver") or "2.4.1" -load(pathJoin("bacio", bacio_ver)) - -crtm_ver=os.getenv("crtm_ver") or "2.3.0" -load(pathJoin("crtm", crtm_ver)) - -netcdf_ver=os.getenv("netcdf_ver") or "4.7.4" -load(pathJoin("netcdf", netcdf_ver)) - -wrf_io_ver=os.getenv("wrf_io_ver") or "1.2.0" -load(pathJoin("wrf_io", wrf_io_ver)) - -whatis("Description: GSI build environment") diff --git a/modulefiles/modulefile.ProdGSI.jet b/modulefiles/modulefile.ProdGSI.jet deleted file mode 100644 index 1b97300d01..0000000000 --- a/modulefiles/modulefile.ProdGSI.jet +++ /dev/null @@ -1,45 +0,0 @@ -#%Module###################################################################### -# NOAA-EMC/GSI -#_____________________________________________________ -#proc ModulesHelp { } { -#puts stderr "Set environment variables for NOAA-EMC/GSI" -#puts stderr "This module initializes the environment " -#puts stderr "for the Intel Compiler Suite $version\n" -##} -#module-whatis " NOAA-EMC/GSI whatis description" -# -# - -setenv CRTM_FIX /lfs4/HFIP/hfv3gfs/glopara/crtm_v2.3.0 - -# Load cmake -module load cmake/3.16.1 - -# Load python -module use /contrib/anaconda/modulefiles -module load anaconda/5.3.1 - -# Load hpc-stack -module use /lfs4/HFIP/hfv3gfs/nwprod/hpc-stack/libs/modulefiles/stack -module load hpc/1.1.0 - -# Load intel compiler and mpi -module load hpc-intel/18.0.5.274 -module load hpc-impi/2018.4.274 - -# Load production utilities -module load prod_util/1.2.2 - -# Load nceplibs -module load bufr/11.4.0 -module load ip/3.3.3 -module load nemsio/2.5.2 -module load sfcio/1.4.1 -module load sigio/2.3.2 -module load sp/2.3.3 -module load w3nco/2.4.1 -module load w3emc/2.7.3 -module load bacio/2.4.1 -module load crtm/2.3.0 -module load netcdf/4.7.4 -module load wrf_io/1.2.0 diff --git a/modulefiles/modulefile.ProdGSI.orion.lua b/modulefiles/modulefile.ProdGSI.orion.lua deleted file mode 100644 index 9f20e325e5..0000000000 --- a/modulefiles/modulefile.ProdGSI.orion.lua +++ /dev/null @@ -1,61 +0,0 @@ -help([[ -Load environment to compile GSI on Orion -]]) - -prepend_path("MODULEPATH", "/apps/contrib/NCEP/libs/hpc-stack/modulefiles/stack") - -hpc_ver=os.getenv("hpc_ver") or "1.1.0" -load(pathJoin("hpc", hpc_ver)) - -hpc_intel_ver=os.getenv("hpc_intel_ver") or "2018.4" -load(pathJoin("hpc-intel", hpc_intel_ver)) - -impi_ver=os.getenv("hpc_impi_ver") or "2018.4" -load(pathJoin("hpc-impi", hpc_impi_ver)) - -cmake_ver=os.getenv("cmake_ver") or "3.17.3" -load(pathJoin("cmake", cmake_ver)) - -python_ver=os.getenv("python_ver") or "3.7.5" -load(pathJoin("python", python_ver)) - -prod_util_ver=os.getenv("prod_util_ver") or "1.2.2" -load(pathJoin("prod_util", prod_util_ver)) - -bufr_ver=os.getenv("bufr_ver") or "11.4.0" -load(pathJoin("bufr", bufr_ver)) - -ip_ver=os.getenv("ip_ver") or "3.3.3" -load(pathJoin("ip", ip_ver)) - -nemsio_ver=os.getenv("nemsio_ver") or "2.5.2" -load(pathJoin("nemsio", nemsio_ver)) - -sfcio_ver=os.getenv("sfcio_ver") or "1.4.1" -load(pathJoin("sfcio", sfcio_ver)) - -sigio_ver=os.getenv("sigio_ver") or "2.3.2" -load(pathJoin("sigio", sigio_ver)) - -sp_ver=os.getenv("sp_ver") or "2.3.3" -load(pathJoin("sp", sp_ver)) - -w3nco_ver=os.getenv("w3nco_ver") or "2.4.1" -load(pathJoin("w3nco", w3nco_ver)) - -w3emc_ver=os.getenv("w3emc_ver") or "2.9.2" -load(pathJoin("w3emc", w3emc_ver)) - -bacio_ver=os.getenv("bacio_ver") or "2.4.1" -load(pathJoin("bacio", bacio_ver)) - -crtm_ver=os.getenv("crtm_ver") or "2.3.0" -load(pathJoin("crtm", crtm_ver)) - -netcdf_ver=os.getenv("netcdf_ver") or "4.7.4" -load(pathJoin("netcdf", netcdf_ver)) - -wrf_io_ver=os.getenv("wrf_io_ver") or "1.2.0" -load(pathJoin("wrf_io", wrf_io_ver)) - -whatis("Description: GSI build environment") diff --git a/modulefiles/modulefile.ProdGSI.s4 b/modulefiles/modulefile.ProdGSI.s4 deleted file mode 100644 index 6f48ad578f..0000000000 --- a/modulefiles/modulefile.ProdGSI.s4 +++ /dev/null @@ -1,32 +0,0 @@ -#%Module###################################################################### -## NOAA-EMC/GSI -##_____________________________________________________ - -setenv CRTM_FIX /data/prod/hpc-stack/fix/crtm/2.3.0 - -module load license_intel/S4 -module use /data/prod/hpc-stack/modulefiles/stack -module load hpc/1.1.0 - -# Load intel compiler and mpi -module load hpc-intel/18.0.4 -module load hpc-impi/18.0.4 -# Load python -module load miniconda/3.8-s4 - -# Load production utilities -module load prod_util/1.2.2 - -# Load nceplibs -module load bufr/11.4.0 -module load ip/3.3.3 -module load nemsio/2.5.2 -module load sfcio/1.4.1 -module load sigio/2.3.2 -module load sp/2.3.3 -module load w3nco/2.4.1 -module load w3emc/2.7.3 -module load bacio/2.4.1 -module load crtm/2.3.0 -module load netcdf/4.7.4 -module load wrf_io/1.2.0 diff --git a/modulefiles/modulefile.ProdGSI.wcoss2.lua b/modulefiles/modulefile.ProdGSI.wcoss2.lua deleted file mode 100644 index c61bdc0f88..0000000000 --- a/modulefiles/modulefile.ProdGSI.wcoss2.lua +++ /dev/null @@ -1,45 +0,0 @@ -help([[ -Load environment to run GSI on WCOSS2 -]]) - -local PrgEnv_intel_ver=os.getenv("PrgEnv_intel_ver") or "8.1.0" -local intel_ver=os.getenv("intel_ver") or "19.1.3.304" -local craype_ver=os.getenv("craype_ver") or "2.7.8" -local cray_mpich_ver=os.getenv("cray_mpich_ver") or "8.1.7" -local cmake_ver= os.getenv("cmake_ver") or "3.20.2" -local python_ver=os.getenv("python_ver") or "3.8.6" -local bacio_ver=os.getenv("bacio_ver") or "2.4.1" -local bufr_ver= os.getenv("bufr_ver") or "11.5.0" -local crtm_ver=os.getenv("crtm_ver") or "2.3.0" -local ip_ver=os.getenv("ip_ver") or "3.3.3" -local nemsio_ver=os.getenv("nemsio_ver") or "2.5.2" -local prod_util_ver= os.getenv("prod_util_ver") or "2.0.10" -local sfcio_ver=os.getenv("sfcio_ver") or "1.4.1" -local sigio_ver=os.getenv("sigio_ver") or "2.3.2" -local sp_ver=os.getenv("sp_ver") or "2.3.3" -local w3emc_ver=os.getenv("w3emc_ver") or "2.9.2" -local w3nco_ver=os.getenv("w3nco_ver") or "2.4.1" -local netcdf_ver=os.getenv("netcdf_ver") or "4.7.4" -local wrf_io_ver=os.getenv("wrf_io_ver") or "1.2.0" - -load(pathJoin("PrgEnv-intel", PrgEnv_intel_ver)) -load(pathJoin("intel", intel_ver)) -load(pathJoin("craype", craype_ver)) -load(pathJoin("cray-mpich", cray_mpich_ver)) -load(pathJoin("cmake", cmake_ver)) -load(pathJoin("python", python_ver)) -load(pathJoin("bacio", bacio_ver)) -load(pathJoin("bufr", bufr_ver)) -load(pathJoin("crtm", crtm_ver)) -load(pathJoin("ip", ip_ver)) -load(pathJoin("nemsio", nemsio_ver)) -load(pathJoin("prod_util", prod_util_ver)) -load(pathJoin("sfcio", sfcio_ver)) -load(pathJoin("sigio", sigio_ver)) -load(pathJoin("sp", sp_ver)) -load(pathJoin("w3emc", w3emc_ver)) -load(pathJoin("w3nco", w3nco_ver)) -load(pathJoin("netcdf", netcdf_ver)) -load(pathJoin("wrf_io", wrf_io_ver)) - -whatis("Description: GSI run environment") diff --git a/modulefiles/modulefile.ProdGSI.wcoss_d b/modulefiles/modulefile.ProdGSI.wcoss_d deleted file mode 100644 index 30207c297d..0000000000 --- a/modulefiles/modulefile.ProdGSI.wcoss_d +++ /dev/null @@ -1,46 +0,0 @@ -#%Module###################################################################### -# NOAA-EMC/GSI -#_____________________________________________________ -#proc ModulesHelp { } { -#puts stderr "Set environment variables for NOAA-EMC/GSI" -#puts stderr "This module initializes the environment " -#puts stderr "for the Intel Compiler Suite $version\n" -##} -#module-whatis " NOAA-EMC/GSI whatis description" - -setenv CRTM_FIX /gpfs/dell1/nco/ops/nwprod/lib/crtm/v2.3.0/fix - - -# Load cmake -module load cmake/3.16.2 - -# Load python -module load python/3.6.3 - -# Load hpc-stack -module use /usrx/local/nceplibs/dev/hpc-stack/libs/hpc-stack/modulefiles/stack -module load hpc/1.1.0 - -# Load pe environment -module load lsf/10.1 - -# Load intel compiler and mpi -module load hpc-ips/18.0.1.163 -module load hpc-impi/18.0.1 - -# Load production utilities -module load prod_util/1.2.2 - -# Load nceplibs -module load bufr/11.4.0 -module load ip/3.3.3 -module load nemsio/2.5.2 -module load sfcio/1.4.1 -module load sigio/2.3.2 -module load sp/2.3.3 -module load w3nco/2.4.1 -module load w3emc/2.7.3 -module load bacio/2.4.1 -module load crtm/2.3.0 -module load netcdf/4.7.4 -module load wrf_io/1.2.0 diff --git a/regression/.gitignore b/regression/.gitignore new file mode 100644 index 0000000000..f47cb2045f --- /dev/null +++ b/regression/.gitignore @@ -0,0 +1 @@ +*.out diff --git a/regression/CMakeLists.txt b/regression/CMakeLists.txt new file mode 100644 index 0000000000..5082de2a0b --- /dev/null +++ b/regression/CMakeLists.txt @@ -0,0 +1,82 @@ +# Find the GSI and EnKF control executables +find_program(GSICONTROLEXEC + NAMES gsi.x + PATHS ${CONTROLPATH} ENV CONTROLPATH + ${GSICONTROLPATH} ENV GSICONTROLPATH + PATH_SUFFIXES bin exec + DOC "Searching for gsi.x" + NO_DEFAULT_PATH +) + +if (GSICONTROLEXEC) + message(STATUS "RT: Control GSIexec Found: ${GSICONTROLEXEC}") +else() + message(WARNING "RT: Control GSIexec Not Found, GSI Regression Tests Disabled!") +endif() + +find_program(ENKFCONTROLEXEC + NAMES enkf.x enkf_gfs.x + PATHS ${CONTROLPATH} ENV CONTROLPATH + ${ENKFCONTROLPATH} ENV ENKFCONTROLPATH + PATH_SUFFIXES bin exec + DOC "Searching for enkf.x" + NO_DEFAULT_PATH +) + +if (ENKFCONTROLEXEC) + message(STATUS "RT: Control EnKFexec Found: ${ENKFCONTROLEXEC}") +else() + message(WARNING "RT: Control EnKFexec Not Found, EnKF Regression Tests Disabled!") +endif() + +# If neither are found, nothing to do; simply return +if(NOT (GSICONTROLEXEC AND ENKFCONTROLEXEC)) + message(WARNING "RT: Unable to find Control Executables. Regression Tests Disabled!") + set(BUILD_REG_TESTING OFF CACHE BOOL "Regression testing disabled" FORCE) + return() +endif() + +# GSI regression test names +list(APPEND GSI_REG_TEST_NAMES + global_T62 global_T62_ozonly global_4dvar_T62 global_4denvar_T126 + global_fv3_4denvar_T126 global_fv3_4denvar_C192 global_lanczos_T62 + arw_netcdf arw_binary nmm_binary nmm_netcdf + nmmb_nems_4denvar + hwrf_nmm_d2 hwrf_nmm_d3 + rtma + netcdf_fv3_regional + global_C96_fv3aero global_C96_fv3aerorad +) + +# EnKF regression test names +list(APPEND ENKF_REG_TEST_NAMES + global_enkf_T62 +) + +# Add GSI regression tests to list of tests +if(GSICONTROLEXEC) + list(APPEND REG_TEST_NAMES ${GSI_REG_TEST_NAMES}) +endif() + +# Add EnKF regression tests to list of tests +if(ENKFCONTROLEXEC) + list(APPEND REG_TEST_NAMES ${ENKF_REG_TEST_NAMES}) +endif() + +# Names of the GSI and EnKF executables from this build +set(GSIUPDATEEXEC ${PROJECT_BINARY_DIR}/src/gsi/gsi.x) +set(ENKFUPDATEEXEC ${PROJECT_BINARY_DIR}/src/enkf/enkf.x) + +# Create Regression tests if list is not empty +if(REG_TEST_NAMES) + # Create regression_var.out file + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/regression_var.out" "${CMAKE_CURRENT_SOURCE_DIR}/regression_var.sh ${PROJECT_SOURCE_DIR}/.. ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR} ${GSIUPDATEEXEC} ${ENKFUPDATEEXEC} ${GSICONTROLEXEC} ${ENKFCONTROLEXEC}") + + # Run each regression test; one at a time + foreach(REG_TEST ${REG_TEST_NAMES}) + add_test(NAME ${REG_TEST} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMAND regression_driver.sh ${REG_TEST} ${CMAKE_CURRENT_BINARY_DIR}) + set_tests_properties(${REG_TEST} PROPERTIES TIMEOUT 86400) + endforeach(REG_TEST) +endif() diff --git a/regression/arw_netcdf.sh b/regression/arw_netcdf.sh index 5cccfab459..555625e9b6 100755 --- a/regression/arw_netcdf.sh +++ b/regression/arw_netcdf.sh @@ -56,7 +56,7 @@ ncp=/bin/cp # first guess comes. Extract cycle and set prefix and suffix # for guess and observation data files sdate=`echo $arw_netcdf_adate |cut -c1-8` -odate=`$ndate +6 $arw_netcdf_adate` +odate=`date +%Y%m%d%H -d "${arw_netcdf_adate:0:8} ${arw_netcdf_adate:8:2} + 6 hours"` hha=`echo $arw_netcdf_adate | cut -c9-10` hho=`echo $odate | cut -c9-10` prefixo=ndas.t${hho}z diff --git a/regression/global_4denvar_T126.sh b/regression/global_4denvar_T126.sh index 02ca7f8e54..fd6bbf9b69 100755 --- a/regression/global_4denvar_T126.sh +++ b/regression/global_4denvar_T126.sh @@ -72,7 +72,7 @@ export NLAT=$((${LATA}+2)) # Given the analysis date, compute the date from which the # first guess comes. Extract cycle and set prefix and suffix # for guess and observation data files -gdate=`$ndate -06 $global_4denvar_T126_adate` +gdate=`date +%Y%m%d%H -d "${global_4denvar_T126_adate:0:8} ${global_4denvar_T126_adate:8:2} - 6 hours"` yyg=`echo $gdate | cut -c1-8` hhg=`echo $gdate | cut -c9-10` yya=`echo $global_4denvar_T126_adate | cut -c1-8` diff --git a/regression/global_4dvar_T62.sh b/regression/global_4dvar_T62.sh index 795008c04b..46aed61319 100755 --- a/regression/global_4dvar_T62.sh +++ b/regression/global_4dvar_T62.sh @@ -49,7 +49,7 @@ export NLAT=$((${LATA}+2)) # Given the analysis date, compute the date from which the # first guess comes. Extract cycle and set prefix and suffix # for guess and observation data files -gdate=`$ndate -06 $global_4dvar_T62_adate` +gdate=`date +%Y%m%d%H -d "${global_4dvar_T62_adate:0:8} ${global_4dvar_T62_adate:8:2} - 6 hours"` hha=`echo $global_4dvar_T62_adate | cut -c9-10` hhg=`echo $gdate | cut -c9-10` prefix_obs=gdas1.t${hha}z diff --git a/regression/global_C96_fv3aero.sh b/regression/global_C96_fv3aero.sh index 006c87fbe3..438cd6dc0e 100755 --- a/regression/global_C96_fv3aero.sh +++ b/regression/global_C96_fv3aero.sh @@ -29,7 +29,7 @@ ncp=/bin/cp # for guess and observation data files PDY=`echo $global_C96_fv3aero_adate | cut -c1-8` cyc=`echo $global_C96_fv3aero_adate | cut -c9-10` -gdate=`$ndate -06 $global_C96_fv3aero_adate` +gdate=`date +%Y%m%d%H -d "${global_C96_fv3aero_adate:0:8} ${global_C96_fv3aero_adate:8:2} - 6 hours"` gPDY=`echo $gdate | cut -c1-8` gcyc=`echo $gdate | cut -c9-10` hha=`echo $global_C96_fv3aero_adate | cut -c9-10` diff --git a/regression/global_C96_fv3aerorad.sh b/regression/global_C96_fv3aerorad.sh index 14a7d58bd1..6e990be1be 100755 --- a/regression/global_C96_fv3aerorad.sh +++ b/regression/global_C96_fv3aerorad.sh @@ -28,7 +28,7 @@ ncpl="ln -fs" # for guess and observation data files PDY=`echo $global_C96_fv3aerorad_adate | cut -c1-8` cyc=`echo $global_C96_fv3aerorad_adate | cut -c9-10` -gdate=`$ndate -06 $global_C96_fv3aerorad_adate` +gdate=`date +%Y%m%d%H -d "${global_C96_fv3aerorad_adate:0:8} ${global_C96_fv3aerorad_adate:8:2} - 6 hours"` gPDY=`echo $gdate | cut -c1-8` gcyc=`echo $gdate | cut -c9-10` hha=`echo $global_C96_fv3aerorad_adate | cut -c9-10` diff --git a/regression/global_T62.sh b/regression/global_T62.sh index fded077a26..06c0ddeacb 100755 --- a/regression/global_T62.sh +++ b/regression/global_T62.sh @@ -69,7 +69,7 @@ export NLAT=$((${LATA}+2)) # Given the analysis date, compute the date from which the # first guess comes. Extract cycle and set prefix and suffix # for guess and observation data files -gdate=`$ndate -06 $global_T62_adate` +gdate=`date +%Y%m%d%H -d "${global_T62_adate:0:8} ${global_T62_adate:8:2} - 6 hours"` hha=`echo $global_T62_adate | cut -c9-10` hhg=`echo $gdate | cut -c9-10` prefix_obs=gdas1.t${hha}z. diff --git a/regression/global_T62_ozonly.sh b/regression/global_T62_ozonly.sh index 4d2ee6a4d6..6f2119fd3c 100755 --- a/regression/global_T62_ozonly.sh +++ b/regression/global_T62_ozonly.sh @@ -69,7 +69,7 @@ export NLAT=$((${LATA}+2)) # Given the analysis date, compute the date from which the # first guess comes. Extract cycle and set prefix and suffix # for guess and observation data files -gdate=`$ndate -06 $global_T62_adate` +gdate=`date +%Y%m%d%H -d "${global_T62_adate:0:8} ${global_T62_adate:8:2} - 6 hours"` hha=`echo $global_T62_adate | cut -c9-10` hhg=`echo $gdate | cut -c9-10` prefix_obs=gdas1.t${hha}z. diff --git a/regression/global_enkf_T62.sh b/regression/global_enkf_T62.sh index 23b4026884..3ddc18ba0c 100755 --- a/regression/global_enkf_T62.sh +++ b/regression/global_enkf_T62.sh @@ -59,7 +59,7 @@ fi # first guess comes. Extract cycle and set prefix and suffix # for guess and observation data files export adate=$global_enkf_T62_adate -gdate=`$ndate -06 $global_enkf_T62_adate` +gdate=`date +%Y%m%d%H -d "${global_enkf_T62_adate:0:8} ${global_enkf_T62_adate:8:2} - 6 hours"` yyg=`echo $gdate | cut -c1-8` hhg=`echo $gdate | cut -c9-10` yya=`echo $global_enkf_T62_adate | cut -c1-8` diff --git a/regression/global_fv3_4denvar_C192.sh b/regression/global_fv3_4denvar_C192.sh index ffc9a2ba79..27c6f2798d 100755 --- a/regression/global_fv3_4denvar_C192.sh +++ b/regression/global_fv3_4denvar_C192.sh @@ -81,7 +81,7 @@ ENSEND=20 # for guess and observation data files PDY=`echo $global_fv3_4denvar_C192_adate | cut -c1-8` cyc=`echo $global_fv3_4denvar_C192_adate | cut -c9-10` -GDATE=`$ndate -06 $global_fv3_4denvar_C192_adate` +GDATE=`date +%Y%m%d%H -d "${global_fv3_4denvar_C192_adate:0:8} ${global_fv3_4denvar_C192_adate:8:2} - 6 hours"` gPDY=`echo $GDATE | cut -c1-8` gcyc=`echo $GDATE | cut -c9-10` diff --git a/regression/global_fv3_4denvar_T126.sh b/regression/global_fv3_4denvar_T126.sh index 0f79fabe3e..3bcff2b674 100755 --- a/regression/global_fv3_4denvar_T126.sh +++ b/regression/global_fv3_4denvar_T126.sh @@ -77,7 +77,7 @@ ENSEND=20 # for guess and observation data files PDY=`echo $global_fv3_4denvar_T126_adate | cut -c1-8` cyc=`echo $global_fv3_4denvar_T126_adate | cut -c9-10` -GDATE=`$ndate -06 $global_fv3_4denvar_T126_adate` +GDATE=`date +%Y%m%d%H -d "${global_fv3_4denvar_T126_adate:0:8} ${global_fv3_4denvar_T126_adate:8:2} - 6 hours"` gPDY=`echo $GDATE | cut -c1-8` gcyc=`echo $GDATE | cut -c9-10` diff --git a/regression/global_hybrid_T126.sh b/regression/global_hybrid_T126.sh index 82d10e0852..6472a84911 100755 --- a/regression/global_hybrid_T126.sh +++ b/regression/global_hybrid_T126.sh @@ -68,7 +68,7 @@ export NLAT=$((${LATA}+2)) # Given the analysis date, compute the date from which the # first guess comes. Extract cycle and set prefix and suffix # for guess and observation data files -gdate=`$ndate -06 $global_hybrid_T126_adate` +gdate=`date +%Y%m%d%H -d "${global_hybrid_T126_adate:0:8} ${global_hybrid_T126_adate:8:2} - 6 hours"` yyg=`echo $gdate | cut -c1-8` hhg=`echo $gdate | cut -c9-10` yya=`echo $global_hybrid_T126_adate | cut -c1-8` diff --git a/regression/global_lanczos_T62.sh b/regression/global_lanczos_T62.sh index 3b8b0876d4..55014a58f0 100755 --- a/regression/global_lanczos_T62.sh +++ b/regression/global_lanczos_T62.sh @@ -44,7 +44,7 @@ export NLAT=$((${LATA}+2)) # Given the analysis date, compute the date from which the # first guess comes. Extract cycle and set prefix and suffix # for guess and observation data files -gdate=`$ndate -06 $global_lanczos_T62_adate` +gdate=`date +%Y%m%d%H -d "${global_lanczos_T62_adate:0:8} ${global_lanczos_T62_adate:8:2} - 6 hours"` hha=`echo $global_lanczos_T62_adate | cut -c9-10` hhg=`echo $gdate | cut -c9-10` prefix_obs=gdas1.t${hha}z diff --git a/regression/global_nemsio_T62.sh b/regression/global_nemsio_T62.sh index f597c6420a..8278bb3655 100755 --- a/regression/global_nemsio_T62.sh +++ b/regression/global_nemsio_T62.sh @@ -45,7 +45,7 @@ export NLAT=$((${LATA}+2)) # Given the analysis date, compute the date from which the # first guess comes. Extract cycle and set prefix and suffix # for guess and observation data files -gdate=`$ndate -06 $global_nemsio_T62_adate` +gdate=`date +%Y%m%d%H -d "${global_nemsio_T62_adate:0:8} ${global_nemsio_T62_adate:8:2} - 6 hours"` hha=`echo $global_nemsio_T62_adate | cut -c9-10` hhg=`echo $gdate | cut -c9-10` prefix_obs=gdas1.t${hha}z diff --git a/regression/hwrf_nmm_d2.sh b/regression/hwrf_nmm_d2.sh index 26536062d7..ba7ae25521 100755 --- a/regression/hwrf_nmm_d2.sh +++ b/regression/hwrf_nmm_d2.sh @@ -56,7 +56,7 @@ export NLON=$(( NX2 - 1 )) # Given the analysis date, compute the date from which the # first guess comes. Extract cycle and set prefix and suffix # for guess and observation data files -gdate=`$ndate -06 $adate` +gdate=`date +%Y%m%d%H -d "${adate:0:8} ${adate:8:2} - 6 hours"` hha=`echo $adate | cut -c9-10` hhg=`echo $gdate | cut -c9-10` prefixa=gfs.t${hha}z diff --git a/regression/hwrf_nmm_d3.sh b/regression/hwrf_nmm_d3.sh index 2c015db0d6..bde43050a8 100755 --- a/regression/hwrf_nmm_d3.sh +++ b/regression/hwrf_nmm_d3.sh @@ -56,7 +56,7 @@ export NLON=$(( NX3 - 1 )) # Given the analysis date, compute the date from which the # first guess comes. Extract cycle and set prefix and suffix # for guess and observation data files -gdate=`$ndate -06 $adate` +gdate=`date +%Y%m%d%H -d "${adate:0:8} ${adate:8:2} - 6 hours"` hha=`echo $adate | cut -c9-10` hhg=`echo $gdate | cut -c9-10` prefixa=gfs.t${hha}z diff --git a/regression/multi_regression.sh b/regression/multi_regression.sh index da6fcb8d46..106bfcf3ad 100755 --- a/regression/multi_regression.sh +++ b/regression/multi_regression.sh @@ -34,14 +34,14 @@ regtests_debug="global_T62 netcdf_fv3_regional hwrf_nmm_d2 hwrf_nmm_d3 + rtma + global_enkf_T62 global_C96_fv3aero global_C96_fv3aerorad" # Choose which regression test to run; by default, run all regtests=${1:-$regtests_all} -echo "`pwd`/regression_var.sh" > regression_var.out - for regtest in $regtests; do rm -f ${regtest}.out echo "Launching regression test: $regtest" diff --git a/regression/nmm_binary.sh b/regression/nmm_binary.sh index 4dcbcf5d70..abd4507283 100755 --- a/regression/nmm_binary.sh +++ b/regression/nmm_binary.sh @@ -55,7 +55,7 @@ ncp=/bin/cp # first guess comes. Extract cycle and set prefix and suffix # for guess and observation data files sdate=`echo $nmm_binary_adate |cut -c1-8` -odate=`$ndate +12 $nmm_binary_adate` +odate=`date +%Y%m%d%H -d "${nmm_binary_adate:0:8} ${nmm_binary_adate:8:2} + 12 hours"` hha=`echo $nmm_binary_adate | cut -c9-10` hho=`echo $odate | cut -c9-10` prefixo=ndas.t${hho}z diff --git a/regression/nmm_netcdf.sh b/regression/nmm_netcdf.sh index 5d3e478cb8..a1e6879104 100755 --- a/regression/nmm_netcdf.sh +++ b/regression/nmm_netcdf.sh @@ -58,7 +58,7 @@ ncp=/bin/cp # first guess comes. Extract cycle and set prefix and suffix # for guess and observation data files sdate=`echo $nmm_netcdf_adate |cut -c1-8` -odate=`$ndate +12 $nmm_netcdf_adate` +odate=`date +%Y%m%d%H -d "${nmm_netcdf_adate:0:8} ${nmm_netcdf_adate:8:2} + 12 hours"` hha=`echo $nmm_netcdf_adate | cut -c9-10` hho=`echo $odate | cut -c9-10` prefixo=ndas.t${hho}z diff --git a/regression/nmmb_nems_4denvar.sh b/regression/nmmb_nems_4denvar.sh index 0f1e4594ac..56c23a2140 100755 --- a/regression/nmmb_nems_4denvar.sh +++ b/regression/nmmb_nems_4denvar.sh @@ -213,7 +213,7 @@ cp $nmmb_nems_4denvar_ges/rtma2p5.t00z.p_rejectlist ./p_rejectlist cp $nmmb_nems_4denvar_ges/rtma2p5.t00z.q_rejectlist ./q_rejectlist ##### connect with gefs ensemble ################# -#gdate=`/nwprod/util/exec/ndate -6 $adate` +#gdate=`date +%Y%m%d%H -d "${adate:0:8} ${adate:8:2} - 6 hours"` #cycg=`echo $gdate | cut -c9-10` ls $nmmb_nems_4denvar_ges/sfg_2015060918_fhr06_ensmean > filelist06 #typeset -Z2 nsum diff --git a/regression/regression_driver.sh b/regression/regression_driver.sh index 8b35ff67df..08f0154819 100755 --- a/regression/regression_driver.sh +++ b/regression/regression_driver.sh @@ -8,10 +8,10 @@ export regtest=$1 # source the necessary files to setup if [ "$#" -eq 2 ]; then export regdir=$2 - . $(awk '{ print $1, $2, $3, $4, $5, $6, $7, $8, $9 }' $regdir/regression_var.out) + . $(awk '{ print $1, $2, $3, $4, $5, $6, $7, $8 }' $regdir/regression_var.out) else export regdir=$(pwd) - . $(awk '{ print $1, $2, $3, $4, $5, $6, $7, $8, $9 }' regression_var.out) + . $(awk '{ print $1, $2, $3, $4, $5, $6, $7, $8 }' regression_var.out) fi export scripts=${scripts_updat:-$scripts} @@ -20,10 +20,10 @@ export scripts=${scripts_updat:-$scripts} # allow regression tests to be set by environment variable if [ -z "$RSTART" ]; then export RSTART=1 -fi +fi if [ -z "$REND" ]; then export REND=4 -fi +fi # Launch the individual control and update runs, one-after-another for jn in `seq ${RSTART} ${REND}`; do diff --git a/regression/regression_var.sh b/regression/regression_var.sh index 37096edde1..4951ab31f5 100755 --- a/regression/regression_var.sh +++ b/regression/regression_var.sh @@ -4,22 +4,20 @@ # To run with hybrid ensemble option on, change HYBENS_GLOBAL and/or HYBENS_REGIONAL from "false" to "true". # These are located at the end of this script. -if [ "$#" = 8 ] ; then - export machine=$1 - export basedir=$2 - export builddir=$3 - export gsisrc=$4 - export gsiexec_updat=$5 - export enkfexec_updat=$6 - export gsiexec_contrl=$7 - export enkfexec_contrl=$8 +if [ "$#" = 7 ] ; then + export basedir=$1 + export builddir=$2 + export gsisrc=$3 + export gsiexec_updat=$4 + export enkfexec_updat=$5 + export gsiexec_contrl=$6 + export enkfexec_contrl=$7 export fixgsi="$gsisrc/fix" export scripts="$gsisrc/regression" export ush="$gsisrc/ush" export cmaketest="true" export clean="false" export ptmpName=`echo $builddir | sed -e "s/\//_/g"` - echo $ptmpName else # Name of the branch being tested updat="XXXXXXXX" @@ -28,175 +26,173 @@ else export clean="false" export ptmpName="" fi -echo "beginning regression_var.sh, machine is $machine" -# If we don't know already determine what machine are we on: -if [ -z ${machine+x} ]; then - echo "machine is unset"; - if [ -d /da ]; then # WCOSS - export machine="WCOSS" - elif [ -d /glade/scratch ]; then # Cheyenne - export machine="Cheyenne" - elif [ -d /scratch1/NCEPDEV/da ]; then # Hera - export machine="Hera" - elif [ -d /lfs1/NCEPDEV ]; then # Jet - export machine="Jet" - elif [ -d /gpfs/hps/ptmp ]; then # LUNA or SURGE - export machine="WCOSS_C" - elif [ -d /gpfs/dell1/ptmp ]; then # venus or mars - export machine="WCOSS_D" -elif [ -d /discover/nobackup ]; then # NCCS Discover - export machine="Discover" - fi -else echo "machine is set to '$machine'"; + +# Determine the machine +if [[ -d /dcom && -d /hwrf ]]; then # WCOSS + export machine="WCOSS" +elif [[ -d /glade ]]; then # Cheyenne + export machine="Cheyenne" +elif [[ -d /scratch1 ]]; then # Hera + export machine="Hera" +elif [[ -d /jetmon ]]; then # Jet + export machine="Jet" +elif [[ -d /cm ]]; then # LUNA or SURGE + export machine="WCOSS_C" +elif [[ -d /ioddev_dell ]]; then # venus or mars + export machine="WCOSS_D" +elif [[ -d /discover ]]; then # NCCS Discover + export machine="Discover" +elif [[ -d /sw/gaea ]]; then # Gaea + export machine="Gaea" +elif [[ -d /data/prod ]]; then # S4 + export machine="S4" +elif [[ -d /work ]]; then # Orion + export machine="Orion" fi +echo "Running Regression Tests on '$machine'"; case $machine in - WCOSS_D) - export noscrub=/gpfs/dell2/emc/modeling/noscrub/$LOGNAME - export group="dev" - export queue="dev" - - export ptmp="/gpfs/dell2/ptmp/$LOGNAME/$ptmpName" - - export fixcrtm="/gpfs/dell2/emc/modeling/noscrub/Michael.Lueken/fix_update" - export casesdir="/gpfs/dell2/emc/modeling/noscrub/Michael.Lueken/CASES" - export ndate=${NDATE:-"$builddir/bin/ndate.x"} - - export check_resource="yes" - - export accnt="" - ;; - WCOSS) - if [ -d /da/noscrub/$LOGNAME ]; then - export noscrub=/da/noscrub/$LOGNAME - elif [ -d /global/noscrub/$LOGNAME ]; then - export noscrub=/global/noscrub/$LOGNAME - fi - if [[ "$cmaketest" = "false" ]]; then - export basedir="/global/save/$LOGNAME/gsi" - fi - export group="dev" - export queue="dev" - - export ptmp="/ptmpp1/$LOGNAME/$ptmpName" - - export fixcrtm="/da/save/Michael.Lueken/CRTM_REL-2.2.3/crtm_v2.2.3/fix_update" - export casesdir="/da/noscrub/Michael.Lueken/CASES" - export ndate="/nwprod/util/exec/ndate" - - export check_resource="yes" - - export accnt="" - ;; - Cheyenne) - export queue="economy" - export noscrub="/glade/scratch/$LOGNAME" - export group="global" - if [[ "$cmaketest" = "false" ]]; then - export basedir="/glade/scratch/$LOGNAME/gsi" - fi - export ptmp="/glade/scratch/$LOGNAME/$ptmpName" - - export fixcrtm="/glade/p/ral/jntp/tools/crtm/2.2.3/fix_update" - export casesdir="/glade/p/ral/jntp/tools/CASES" - export ndate="$builddir/bin/ndate.x" - - export check_resource="no" - export accnt="p48503002" - ;; - Hera) - if [ -d /scratch1/NCEPDEV/da/$LOGNAME ]; then - export noscrub="/scratch1/NCEPDEV/da/$LOGNAME/noscrub" - elif [ -d /scratch1/NCEPDEV/global/$LOGNAME ]; then - export noscrub="/scratch1/NCEPDEV/global/$LOGNAME/noscrub" - elif [ -d /scratch2/BMC/gsienkf/$LOGNAME ]; then - export noscrub="/scratch2/BMC/gsienkf/$LOGNAME" - fi - - export group="global" - export queue="batch" - if [[ "$cmaketest" = "false" ]]; then - export basedir="/scratch1/NCEPDEV/da/$LOGNAME/git/gsi" - fi - - export ptmp="/scratch1/NCEPDEV/stmp2/$LOGNAME/$ptmpName" - - export fixcrtm="/scratch1/NCEPDEV/da/Michael.Lueken/CRTM_REL-2.2.3/crtm_v2.2.3/fix_update" - export casesdir="/scratch1/NCEPDEV/da/Michael.Lueken/noscrub/CASES" - export ndate=$NDATE - - export check_resource="no" - - export accnt="da-cpu" - - # On Hera, there are no scrubbers to remove old contents from stmp* directories. - # After completion of regression tests, will remove the regression test subdirecories - export clean=".true." - ;; - Jet) - - set -x - export noscrub=/lfs1/NESDIS/nesdis-rdo2/$LOGNAME/noscrub - export ptmp=/lfs1/NESDIS/nesdis-rdo2/$LOGNAME/ptmp - export fixcrtm="/lfs1/NESDIS/nesdis-rdo2/David.Huber/save/CRTM_REL-2.2.3/crtm_v2.2.3/fix_update" - export casesdir="/lfs1/NESDIS/nesdis-rdo2/David.Huber/save/CASES" - export ndate=$NDATE - export check_resource="no" - export accnt="nesdis-rdo2" - - export group="global" - export queue="batch" - if [[ "$cmaketest" = "false" ]]; then - export basedir="/lfs1/NESDIS/nesdis-rdo2/$LOGNAME/gsi" - fi - - export ptmp="/lfs1/NESDIS/nesdis-rdo2/$LOGNAME/ptmp/$ptmpName" - - # On Jet, there are no scrubbers to remove old contents from stmp* directories. - # After completion of regression tests, will remove the regression test subdirecories - export clean=".true." - set +x - ;; - WCOSS_C) - if [ -d /gpfs/hps3/emc/global/noscrub/$LOGNAME ]; then - export noscrub="/gpfs/hps3/emc/global/noscrub/$LOGNAME" - elif [ -d /gpfs/hps3/emc/da/noscrub/$LOGNAME ]; then - export noscrub="/gpfs/hps3/emc/da/noscrub/$LOGNAME" - elif [ -d /gpfs/hps3/emc/hwrf/noscrub/$LOGNAME ]; then - export noscrub="/gpfs/hps3/emc/hwrf/noscrub/$LOGNAME" - fi - if [[ "$cmaketest" = "false" ]]; then - export basedir="/gpfs/hps3/emc/global/noscrub/$LOGNAME/svn/gsi" - fi - export group="dev" - export queue="dev" - - export ptmp="/gpfs/hps/ptmp/$LOGNAME/$ptmpName" - - export fixcrtm="/gpfs/hps3/emc/da/noscrub/Michael.Lueken/CRTM_REL-2.2.3/fix_update" - export casesdir="/gpfs/hps3/emc/da/noscrub/Michael.Lueken/CASES" - export ndate=$NDATE - - export check_resource="no" - - export accnt="" - ;; - Discover) - if [[ "$cmaketest" = "false" ]]; then - echo "Regression tests on Discover need to be run via ctest" - exit 1 - fi - export ptmp=$basedir - export ptmp=$basedir - export noscrub=$basedir - export fixcrtm="/discover/nobackup/projects/gmao/share/gmao_ops/fvInput_4dvar/gsi/etc/fix_ncep20170329/REL-2.2.3-r60152_local-rev_1/CRTM_Coeffs/$endianness" - export casesdir="/discover/nobackup/projects/gmao/obsdev/wrmccart/NCEP_regression/CASES" - export ndate="/home/pchakrab/.local/bin/ndate" - export check_resource="no" - export accnt="g0613" - export queue="compute" - export clean=".false." - ;; + WCOSS_D) + export noscrub=/gpfs/dell2/emc/modeling/noscrub/$LOGNAME + export group="dev" + export queue="dev" + + export ptmp="/gpfs/dell2/ptmp/$LOGNAME/$ptmpName" + + export fixcrtm="/gpfs/dell2/emc/modeling/noscrub/Michael.Lueken/fix_update" + export casesdir="/gpfs/dell2/emc/modeling/noscrub/Michael.Lueken/CASES" + + export check_resource="yes" + + export accnt="" + ;; + WCOSS) + if [ -d /da/noscrub/$LOGNAME ]; then + export noscrub=/da/noscrub/$LOGNAME + elif [ -d /global/noscrub/$LOGNAME ]; then + export noscrub=/global/noscrub/$LOGNAME + fi + if [[ "$cmaketest" = "false" ]]; then + export basedir="/global/save/$LOGNAME/gsi" + fi + export group="dev" + export queue="dev" + + export ptmp="/ptmpp1/$LOGNAME/$ptmpName" + + export fixcrtm="/da/save/Michael.Lueken/CRTM_REL-2.2.3/crtm_v2.2.3/fix_update" + export casesdir="/da/noscrub/Michael.Lueken/CASES" + + export check_resource="yes" + + export accnt="" + ;; + Cheyenne) + export queue="economy" + export noscrub="/glade/scratch/$LOGNAME" + export group="global" + if [[ "$cmaketest" = "false" ]]; then + export basedir="/glade/scratch/$LOGNAME/gsi" + fi + export ptmp="/glade/scratch/$LOGNAME/$ptmpName" + + export fixcrtm="/glade/p/ral/jntp/tools/crtm/2.2.3/fix_update" + export casesdir="/glade/p/ral/jntp/tools/CASES" + + export check_resource="no" + export accnt="p48503002" + ;; + Hera) + if [ -d /scratch1/NCEPDEV/da/$LOGNAME ]; then + export noscrub="/scratch1/NCEPDEV/da/$LOGNAME/noscrub" + elif [ -d /scratch1/NCEPDEV/global/$LOGNAME ]; then + export noscrub="/scratch1/NCEPDEV/global/$LOGNAME/noscrub" + elif [ -d /scratch2/BMC/gsienkf/$LOGNAME ]; then + export noscrub="/scratch2/BMC/gsienkf/$LOGNAME" + fi + + export group="global" + export queue="batch" + if [[ "$cmaketest" = "false" ]]; then + export basedir="/scratch1/NCEPDEV/da/$LOGNAME/git/gsi" + fi + + export ptmp="/scratch1/NCEPDEV/stmp2/$LOGNAME/$ptmpName" + + export fixcrtm="/scratch1/NCEPDEV/da/Michael.Lueken/CRTM_REL-2.2.3/crtm_v2.2.3/fix_update" + export casesdir="/scratch1/NCEPDEV/da/Michael.Lueken/noscrub/CASES" + + export check_resource="no" + + export accnt="da-cpu" + + # On Hera, there are no scrubbers to remove old contents from stmp* directories. + # After completion of regression tests, will remove the regression test subdirecories + export clean=".true." + ;; + Jet) + + export noscrub=/lfs1/NESDIS/nesdis-rdo2/$LOGNAME/noscrub + export ptmp=/lfs1/NESDIS/nesdis-rdo2/$LOGNAME/ptmp + export fixcrtm="/lfs1/NESDIS/nesdis-rdo2/David.Huber/save/CRTM_REL-2.2.3/crtm_v2.2.3/fix_update" + export casesdir="/lfs1/NESDIS/nesdis-rdo2/David.Huber/save/CASES" + export check_resource="no" + export accnt="nesdis-rdo2" + + export group="global" + export queue="batch" + if [[ "$cmaketest" = "false" ]]; then + export basedir="/lfs1/NESDIS/nesdis-rdo2/$LOGNAME/gsi" + fi + + export ptmp="/lfs1/NESDIS/nesdis-rdo2/$LOGNAME/ptmp/$ptmpName" + + # On Jet, there are no scrubbers to remove old contents from stmp* directories. + # After completion of regression tests, will remove the regression test subdirecories + export clean=".true." + ;; + WCOSS_C) + if [ -d /gpfs/hps3/emc/global/noscrub/$LOGNAME ]; then + export noscrub="/gpfs/hps3/emc/global/noscrub/$LOGNAME" + elif [ -d /gpfs/hps3/emc/da/noscrub/$LOGNAME ]; then + export noscrub="/gpfs/hps3/emc/da/noscrub/$LOGNAME" + elif [ -d /gpfs/hps3/emc/hwrf/noscrub/$LOGNAME ]; then + export noscrub="/gpfs/hps3/emc/hwrf/noscrub/$LOGNAME" + fi + if [[ "$cmaketest" = "false" ]]; then + export basedir="/gpfs/hps3/emc/global/noscrub/$LOGNAME/svn/gsi" + fi + export group="dev" + export queue="dev" + + export ptmp="/gpfs/hps/ptmp/$LOGNAME/$ptmpName" + + export fixcrtm="/gpfs/hps3/emc/da/noscrub/Michael.Lueken/CRTM_REL-2.2.3/fix_update" + export casesdir="/gpfs/hps3/emc/da/noscrub/Michael.Lueken/CASES" + + export check_resource="no" + + export accnt="" + ;; + Discover) + if [[ "$cmaketest" = "false" ]]; then + echo "Regression tests on Discover need to be run via ctest" + exit 1 + fi + export ptmp=$basedir + export ptmp=$basedir + export noscrub=$basedir + export fixcrtm="/discover/nobackup/projects/gmao/share/gmao_ops/fvInput_4dvar/gsi/etc/fix_ncep20170329/REL-2.2.3-r60152_local-rev_1/CRTM_Coeffs/$endianness" + export casesdir="/discover/nobackup/projects/gmao/obsdev/wrmccart/NCEP_regression/CASES" + export check_resource="no" + export accnt="g0613" + export queue="compute" + export clean=".false." + ;; + *) + echo "Regression tests are not setup on '$machine', ABORT!" + exit 1 + ;; esac if [[ "$cmaketest" = "false" ]]; then diff --git a/regression/rtma.sh b/regression/rtma.sh index a189411926..a28402012a 100755 --- a/regression/rtma.sh +++ b/regression/rtma.sh @@ -37,7 +37,7 @@ ncp=/bin/cp # Given the analysis date, compute the date from which the # first guess comes. Extract cycle and set prefix and suffix # for guess and observation data files -gdate=`$ndate -12 $rtma_adate` +gdate=`date +%Y%m%d%H -d "${rtma_adate:0:8} ${rtma_adate:8:2} - 12 hours"` cya=`echo $rtma_adate | cut -c9-10` cyg=`echo $rtma_adate | cut -c9-10` cymd=`echo $rtma_adate | cut -c1-8` diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000000..04c58e2f67 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,19 @@ +if(BUILD_GSDCLOUD) + message(STATUS "Building GSD cloud analysis library") + add_subdirectory(GSD) +endif() + +if(BUILD_NCDIAG) + message(STATUS "Building GSI NetCDF diagnostic library") + add_subdirectory(ncdiag) +endif() + +if(BUILD_GSI) + message(STATUS "Building GSI") + add_subdirectory(gsi) +endif() + +if(BUILD_ENKF) + message(STATUS "Building EnKF") + add_subdirectory(enkf) +endif() diff --git a/src/GSD/CMakeLists.txt b/src/GSD/CMakeLists.txt new file mode 100644 index 0000000000..b0607b43e6 --- /dev/null +++ b/src/GSD/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory(gsdcloud) +#add_subdirectory(gsdcloud4nmmb) # There is no CMakeLists.txt in gsdcloud4nmmb diff --git a/src/GSD/gsdcloud/CMakeLists.txt b/src/GSD/gsdcloud/CMakeLists.txt index 3b2ca84f12..bba48cdeb1 100644 --- a/src/GSD/gsdcloud/CMakeLists.txt +++ b/src/GSD/gsdcloud/CMakeLists.txt @@ -1,7 +1,108 @@ -cmake_minimum_required(VERSION 2.6) -if(BUILD_GSDCLOUD_ARW) - file(GLOB GSDCLOUD_SRC ${GSDCLOUD_DIR}/*.f90) - set_source_files_properties( ${GSDCLOUD_SRC} COMPILE_FLAGS ${GSDCLOUD_Fortran_FLAGS}) - add_library( ${gsdcloud} STATIC ${GSDCLOUD_SRC} ) - set_target_properties( ${gsdcloud} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_INCLUDE_OUTPUT_DIRECTORY} ) +cmake_minimum_required(VERSION 3.15) + +project(gsdcloud + VERSION 1.0.0 + LANGUAGES Fortran) + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +set(CMAKE_DIRECTORY_LABELS ${PROJECT_NAME}) + +include(GNUInstallDirs) + +if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel)$") + message(STATUS "Setting build type to 'Release' as none was specified.") + set(CMAKE_BUILD_TYPE + "Release" + CACHE STRING "Choose the type of build." FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") endif() + +if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU|Intel)$") + message(WARNING "${CMAKE_Fortran_COMPILER_ID} is not supported.") +endif() + +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian") +endif() + +if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") + add_definitions(-DNDEBUG) +endif() + +list(APPEND GSDCLOUD_SRC +ARPS_cldLib.f90 +BackgroundCld.f90 +BckgrndCC.f90 +PrecipMxr_radar.f90 +PrecipType.f90 +TempAdjust.f90 +adaslib.f90 +build_missing_REFcone.f90 +cloudCover_NESDIS.f90 +cloudCover_Surface.f90 +cloudCover_radar.f90 +cloudLWC.f90 +cloudLayers.f90 +cloudType.f90 +cloud_saturation.f90 +constants.f90 +convert_lghtn2ref.f90 +get_sfm_1d_gnl.f90 +hydro_mxr_thompson.f90 +kinds.f90 +map_ctp.f90 +map_ctp_lar.f90 +mthermo.f90 +pbl_height.f90 +pcp_mxr_ARPSlib.f90 +radar_ref2tten.f90 +read_Lightning_cld.f90 +read_NESDIS.f90 +read_Surface.f90 +read_nasalarc_cld.f90 +read_radar_ref.f90 +smooth.f90 +vinterp_radar_ref.f90 +) + +set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/gsdcloud") +add_library(gsdcloud STATIC ${GSDCLOUD_SRC}) +add_library(${PROJECT_NAME}::gsdcloud ALIAS gsdcloud) +set_target_properties(gsdcloud PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") +target_include_directories(gsdcloud PUBLIC $ + $) + +install(DIRECTORY ${module_dir} DESTINATION ${CMAKE_INSTALL_PREFIX}/include) + +install(TARGETS gsdcloud + EXPORT ${PROJECT_NAME}Exports + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +# Package config +include(CMakePackageConfigHelpers) +set(CONFIG_INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) + +export(EXPORT ${PROJECT_NAME}Exports + NAMESPACE ${PROJECT_NAME}:: + FILE ${PROJECT_NAME}-targets.cmake) + +configure_package_config_file( + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/PackageConfig.cmake.in ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config.cmake + INSTALL_DESTINATION ${CONFIG_INSTALL_DESTINATION}) +install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config.cmake + DESTINATION ${CONFIG_INSTALL_DESTINATION}) + +write_basic_package_version_file( + ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake + VERSION ${PROJECT_VERSION} + COMPATIBILITY AnyNewerVersion) +install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake + DESTINATION ${CONFIG_INSTALL_DESTINATION}) + +install(EXPORT ${PROJECT_NAME}Exports + NAMESPACE ${PROJECT_NAME}:: + FILE ${PROJECT_NAME}-targets.cmake + DESTINATION ${CONFIG_INSTALL_DESTINATION}) diff --git a/src/GSD/gsdcloud/cmake/PackageConfig.cmake.in b/src/GSD/gsdcloud/cmake/PackageConfig.cmake.in new file mode 100644 index 0000000000..9e9d13e6a1 --- /dev/null +++ b/src/GSD/gsdcloud/cmake/PackageConfig.cmake.in @@ -0,0 +1,19 @@ +@PACKAGE_INIT@ + +#@PROJECT_NAME@-config.cmake +# +# Imported interface targets provided: +# * @PROJECT_NAME@::gsdcloud - gsdcloud library target + +# Include targets file. This will create IMPORTED target @PROJECT_NAME@ +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-config-version.cmake") +include(CMakeFindDependencyMacro) + +# Get the build type from library target +get_target_property(@PROJECT_NAME@_BUILD_TYPES @PROJECT_NAME@::@PROJECT_NAME@ IMPORTED_CONFIGURATIONS) + +check_required_components("@PROJECT_NAME@") + +get_target_property(location @PROJECT_NAME@::@PROJECT_NAME@ LOCATION) +message(STATUS "Found @PROJECT_NAME@: ${location} (found version \"${PACKAGE_VERSION}\")") diff --git a/src/enkf/CMakeLists.txt b/src/enkf/CMakeLists.txt index 62ad46c4d2..907f0c2dee 100644 --- a/src/enkf/CMakeLists.txt +++ b/src/enkf/CMakeLists.txt @@ -1,83 +1,176 @@ -cmake_minimum_required(VERSION 3.16.1) -if(BUILD_ENKF) - enable_language (Fortran) - set(Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include") - set(CMAKE_Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include") - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") - - if(BUILD_PRODUCTION) - set(ENKF_SUFFIX "gfs") - set(ENKF_BASE "global_enkf.x") - elseif(BUILD_WRF) - set(ENKF_SUFFIX "wrf") - set(ENKF_BASE "enkf_wrf") - elseif(BUILD_GFS) - set(ENKF_SUFFIX "gfs") - set(ENKF_BASE "enkf_gfs") - elseif(BUILD_NMMB) - set(ENKF_SUFFIX "nmmb") - set(ENKF_BASE "enkf_nmmb") - elseif(BUILD_FV3reg) - set(ENKF_SUFFIX "fv3reg") - set(ENKF_BASE "enkf_fv3reg") - set(ENKF_extra_src1 read_fv3reg_restarts.f90 write_fv3reg_restarts.f90) - else() - set(ENKF_SUFFIX "wrf") - set(ENKF_BASE "enkf_wrf") - endif() - set(ENKF_EXTRA_SRCS ${ENKF_extra_src1} gridio_${ENKF_SUFFIX}.f90 ) - add_library( MODS1 OBJECT gridinfo_${ENKF_SUFFIX}.f90 ) - add_library( MODS2 OBJECT ${ENKF_EXTRA_SRCS} ) - - set(ENKFMOD_SRCS - netcdf_io_wrf.f90 params.f90 covlocal.f90 fftpack.f90 genqsat1.f90 mpisetup.f90 rnorm.f90 - sorting.f90 specmod.f90 reducedgrid.f90 readozobs.f90 readsatobs.f90 readconvobs.f90 - write_logfile.f90 kdtree2.f90 mpi_readobs.f90 enkf_obsmod.f90 statevec.f90 controlvec.f90 - observer_${ENKF_SUFFIX}.f90 gridio_${ENKF_SUFFIX}.f90 gridinfo_${ENKF_SUFFIX}.f90 expand_ens.f90 - ${ENKF_extra_src1} - ) - set(ENKF_SRCS - innovstats.f90 - enkf.f90 - read_locinfo.f90 - enkf_main.f90 - inflation.f90 - letkf.f90 - quicksort.f90 - radbias.f90 - loadbal.f90 - smooth_${ENKF_SUFFIX}.f90 - gridio_${ENKF_SUFFIX}.f90 - gridinfo_${ENKF_SUFFIX}.f90 - enkf_obs_sensitivity.f90 - ) -# if( (NOT HOST-WCOSS_C) AND (NOT HOST-WCOSS_D) ) -# find_package( LAPACK REQUIRED ) -# endif() - - add_definitions(${MPI_Fortran_FLAGS}) - - include_directories(${CMAKE_CURRENT_BINARY_DIR} "${PROJECT_BINARY_DIR}/include/wrf" "${PROJECT_BINARY_DIR}/include/global" ${CMAKE_CURRENT_BINARY_DIR}/.. ${MPI_Fortran_INCLUDE_DIRS} ${MPI_Fortran_INCLUDE_PATH} ${CORE_INCS} ${NETCDF_INCLUDE_DIRS} ${NCDIAG_INCS} ${FV3GFS_NCIO_INCS}) - link_directories(${MPI_Fortran_LIBRARIES}) - - set_source_files_properties( ${ENKF_SRCS} PROPERTIES COMPILE_FLAGS ${ENKF_Fortran_FLAGS} ) - set_source_files_properties( ${ENKFMOD_SRCS} PROPERTIES COMPILE_FLAGS ${ENKF_Fortran_FLAGS} ) - set_source_files_properties( ${ENKF_EXTRA_SRCS} PROPERTIES COMPILE_FLAGS ${ENKF_Fortran_FLAGS} ) - - add_library(enkfdeplib STATIC ${ENKFMOD_SRCS} ) - add_library(enkflib STATIC ${ENKF_SRCS} $ $ ) - add_dependencies(enkfdeplib ${GSILIB} ${GSISHAREDLIB} ) - add_dependencies(MODS1 enkfdeplib ${GSILIB} ${GSISHAREDLIB} ) - add_dependencies(MODS2 MODS1 enkfdeplib ${GSILIB} ${GSISHAREDLIB} ) - add_dependencies(enkflib enkfdeplib ${GSILIB} ${GSISHAREDLIB} ) - set(ENKFEXEC "${ENKF_BASE}${debug_suffix}${GSISUFFIX}" CACHE INTERNAL "ENKF Executable name") - add_executable(${ENKFEXEC} enkf_main.f90) - target_link_libraries(${ENKFEXEC} enkflib enkfdeplib ${GSILIB} ${GSISHAREDLIB} ${CORE_LIBRARIES} - ${MPI_Fortran_LIBRARIES} ${LAPACK_LIBRARIES} ${CORE_LIBRARIES} ${CORE_BUILT} - ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${FV3GFS_NCIO_LIBRARIES} - ${EXTRA_LINKER_FLAGS} ${GSI_LDFLAGS} ${NCDIAG_LIBRARIES}) - install(TARGETS ${ENKFEXEC} enkfdeplib enkflib - RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin - LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib - ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/static) +cmake_minimum_required(VERSION 3.19) + +project(enkf + VERSION 1.0.0 + LANGUAGES C Fortran) + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +set(CMAKE_DIRECTORY_LABELS ${PROJECT_NAME}) + +include(GNUInstallDirs) + +if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel)$") + message(STATUS "Setting build type to 'Release' as none was specified.") + set(CMAKE_BUILD_TYPE + "Release" + CACHE STRING "Choose the type of build." FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") +endif() + +if(NOT CMAKE_C_COMPILER_ID MATCHES "^(GNU|Intel|Clang|AppleClang)$") + message(WARNING "${CMAKE_C_COMPILER_ID} is not supported.") endif() + +if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU|Intel)$") + message(WARNING "${CMAKE_Fortran_COMPILER_ID} is not supported.") +endif() + +# User options +option(OPENMP "Enable OpenMP Threading" OFF) +option(ENABLE_MKL "Use MKL for LAPACK implementation (if available)" ON) + +set(ENKF_VALID_MODES "GFS" "WRF" "NMMB" "FV3REG") +set(ENKF_MODE "GFS" CACHE STRING "Choose the EnKF Application.") +set_property(CACHE ENKF_MODE PROPERTY STRINGS ${ENKF_VALID_MODES}) + +# Ensure valid ENKF_MODE is selected +if(NOT ENKF_MODE IN_LIST ENKF_VALID_MODES) + message(FATAL_ERROR "ENKF_MODE must be one of ${ENKF_VALID_MODES}") +endif() + +# Echo user options +message(STATUS "EnKF: OPENMP ................. ${OPENMP}") +message(STATUS "EnKF: ENABLE_MKL ............. ${ENABLE_MKL}") +message(STATUS "EnKF: ENKF_MODE .............. ${ENKF_MODE}") + +# Dependencies +if(ENABLE_MKL) + find_package(MKL QUIET) +endif() +if(MKL_FOUND) + set(LAPACK_LIBRARIES ${MKL_LIBRARIES}) +else() + set(ENABLE_MKL OFF CACHE INTERNAL "EnKF: Disable MKL since it was NOT FOUND") + find_package(LAPACK REQUIRED) +endif() +find_package(MPI REQUIRED) +find_package(NetCDF REQUIRED Fortran) +if(OPENMP) + find_package(OpenMP REQUIRED) +endif() + +# NCEPLibs dependencies +find_package(bacio REQUIRED) +find_package(sigio REQUIRED) +find_package(sfcio REQUIRED) +find_package(nemsio REQUIRED) +find_package(ncio REQUIRED) +find_package(sp REQUIRED) +find_package(w3emc REQUIRED) +if(ENKF_MODE MATCHES "^(WRF|NMMB|FV3REG)$") + find_package(wrf_io REQUIRED) +endif() + +# See https://github.com/NOAA-EMC/NCEPLIBS-nemsio/pull/22 +target_link_libraries(nemsio::nemsio INTERFACE w3emc::w3emc_d bacio::bacio_4) + +if(NOT TARGET gsi) + find_package(gsi REQUIRED) +endif() + +# Get compiler flags for the GSI application +include(enkfapp_compiler_flags) + +# Get the list of all source files +include(enkf_files.cmake) + +# Collect common files for EnKF Fortran library +list(APPEND EnKF_SRC_Fortran + ${EnKF_SRC_srcs}) + +# Collect files for specific EnKF Application +list(APPEND EnKF_SRC_Fortran + ${EnKF_SRC_${ENKF_MODE}}) + +# Create a library of EnKF Fortran sources +set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/enkf") +add_library(enkf_fortran_obj OBJECT ${EnKF_SRC_Fortran}) +set_target_properties(enkf_fortran_obj PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") +target_include_directories(enkf_fortran_obj INTERFACE $ + $) +target_compile_definitions(enkf_fortran_obj PRIVATE "_REAL8_") +if(TARGET gsi) + add_dependencies(enkf_fortran_obj gsi) +endif() +target_link_libraries(enkf_fortran_obj PUBLIC gsi::gsi) +target_link_libraries(enkf_fortran_obj PUBLIC NetCDF::NetCDF_Fortran) +target_link_libraries(enkf_fortran_obj PUBLIC MPI::MPI_Fortran) +target_link_libraries(enkf_fortran_obj PUBLIC ${LAPACK_LIBRARIES}) +target_link_libraries(enkf_fortran_obj PUBLIC bacio::bacio_4) +target_link_libraries(enkf_fortran_obj PUBLIC sigio::sigio) +target_link_libraries(enkf_fortran_obj PUBLIC sfcio::sfcio) +target_link_libraries(enkf_fortran_obj PUBLIC nemsio::nemsio) +target_link_libraries(enkf_fortran_obj PUBLIC ncio::ncio) +target_link_libraries(enkf_fortran_obj PUBLIC w3emc::w3emc_d) +target_link_libraries(enkf_fortran_obj PUBLIC sp::sp_d) +if(OpenMP_Fortran_FOUND) + target_link_libraries(enkf_fortran_obj PRIVATE OpenMP::OpenMP_Fortran) +endif() + +# Create the EnKF library +add_library(enkf STATIC) +add_library(${PROJECT_NAME}::enkf ALIAS enkf) +set_target_properties(enkf PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") +target_include_directories(enkf PUBLIC $ + $) +target_link_libraries(enkf PUBLIC enkf_fortran_obj) +if(OpenMP_Fortran_FOUND) + target_link_libraries(enkf PRIVATE OpenMP::OpenMP_Fortran) +endif() + +# Create the EnKF executable +add_executable(enkf.x ${EnKF_SRC_main}) +add_dependencies(enkf.x enkf) +target_link_libraries(enkf.x PRIVATE enkf) +if(OpenMP_Fortran_FOUND) + target_link_libraries(enkf.x PRIVATE OpenMP::OpenMP_Fortran) +endif() + +# Install Fortran modules +install(DIRECTORY ${module_dir} DESTINATION ${CMAKE_INSTALL_PREFIX}/include) + +# Install executable targets +install(TARGETS enkf.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + +# Install and export library targets +install( + TARGETS enkf_fortran_obj enkf + EXPORT ${PROJECT_NAME}Exports + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +# Package config +include(CMakePackageConfigHelpers) +set(CONFIG_INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) + +export(EXPORT ${PROJECT_NAME}Exports + NAMESPACE ${PROJECT_NAME}:: + FILE ${PROJECT_NAME}-targets.cmake) + +configure_package_config_file( + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/PackageConfig.cmake.in ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config.cmake + INSTALL_DESTINATION ${CONFIG_INSTALL_DESTINATION}) +install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config.cmake + DESTINATION ${CONFIG_INSTALL_DESTINATION}) + +write_basic_package_version_file( + ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake + VERSION ${PROJECT_VERSION} + COMPATIBILITY AnyNewerVersion) +install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake + DESTINATION ${CONFIG_INSTALL_DESTINATION}) + +install(EXPORT ${PROJECT_NAME}Exports + NAMESPACE ${PROJECT_NAME}:: + FILE ${PROJECT_NAME}-targets.cmake + DESTINATION ${CONFIG_INSTALL_DESTINATION}) diff --git a/src/enkf/cmake/FindMKL.cmake b/src/enkf/cmake/FindMKL.cmake new file mode 100644 index 0000000000..09a1feb7d2 --- /dev/null +++ b/src/enkf/cmake/FindMKL.cmake @@ -0,0 +1,91 @@ +# (C) Copyright 2011- ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# 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. + +# - Try to find MKL +# Once done this will define +# +# MKL_FOUND - system has Intel MKL +# MKL_INCLUDE_DIRS - the MKL include directories +# MKL_LIBRARIES - link these to use MKL +# +# The following paths will be searched with priority if set in CMake or env +# +# MKLROOT - root directory of the MKL installation +# MKL_PATH - root directory of the MKL installation +# MKL_ROOT - root directory of the MKL installation + +option( MKL_PARALLEL "if mkl shoudl be parallel" OFF ) + +if( MKL_PARALLEL ) + + set( __mkl_lib_par MKL_LIB_INTEL_THREAD ) + set( __mkl_lib_name mkl_intel_thread ) + + find_package(Threads) + +else() + + set( __mkl_lib_par MKL_LIB_SEQUENTIAL ) + set( __mkl_lib_name mkl_sequential ) + +endif() + +# Search with priority for MKLROOT, MKL_PATH and MKL_ROOT if set in CMake or env +find_path(MKL_INCLUDE_DIR mkl.h + PATHS ${MKLROOT} ${MKL_PATH} ${MKL_ROOT} $ENV{MKLROOT} $ENV{MKL_PATH} $ENV{MKL_ROOT} + PATH_SUFFIXES include NO_DEFAULT_PATH) + +find_path(MKL_INCLUDE_DIR mkl.h + PATH_SUFFIXES include) + +if( MKL_INCLUDE_DIR ) # use include dir to find libs + + set( MKL_INCLUDE_DIRS ${MKL_INCLUDE_DIR} ) + + if( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" ) + set( __pathsuffix "lib/intel64") + set( __libsfx _lp64 ) + else() + set( __pathsuffix "lib/ia32") + set( __libsfx "" ) + endif() + + find_library( MKL_LIB_INTEL + PATHS ${MKLROOT} ${MKL_PATH} ${MKL_ROOT} $ENV{MKLROOT} $ENV{MKL_PATH} $ENV{MKL_ROOT} + PATH_SUFFIXES lib ${__pathsuffix} + NAMES mkl_intel${__libsfx} ) + + find_library( ${__mkl_lib_par} + PATHS ${MKLROOT} ${MKL_PATH} ${MKL_ROOT} $ENV{MKLROOT} $ENV{MKL_PATH} $ENV{MKL_ROOT} + PATH_SUFFIXES lib ${__pathsuffix} + NAMES ${__mkl_lib_name} ) + + find_library( MKL_LIB_CORE + PATHS ${MKLROOT} ${MKL_PATH} ${MKL_ROOT} $ENV{MKLROOT} $ENV{MKL_PATH} $ENV{MKL_ROOT} + PATH_SUFFIXES lib ${__pathsuffix} + NAMES mkl_core ) + + if( MKL_PARALLEL ) + find_library( MKL_LIB_IOMP5 + PATHS ${MKLROOT} ${MKL_PATH} ${MKL_ROOT} $ENV{MKLROOT} $ENV{MKL_PATH} $ENV{MKL_ROOT} + PATH_SUFFIXES lib ${__pathsuffix} + NAMES iomp5 ) + endif() + + if( MKL_LIB_INTEL AND ${__mkl_lib_par} AND MKL_LIB_CORE ) + set( MKL_LIBRARIES ${MKL_LIB_INTEL} ${${__mkl_lib_par}} ${MKL_LIB_CORE} ${MKL_LIB_IOMP5} ${CMAKE_THREAD_LIBS_INIT} ) + endif() + +endif() + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args( MKL DEFAULT_MSG + MKL_LIBRARIES MKL_INCLUDE_DIRS ) + +mark_as_advanced( MKL_INCLUDE_DIR MKL_LIB_LAPACK MKL_LIB_INTEL MKL_LIB_SEQUENTIAL MKL_LIB_CORE ) diff --git a/cmake/Modules/FindNetCDF.cmake b/src/enkf/cmake/FindNetCDF.cmake similarity index 97% rename from cmake/Modules/FindNetCDF.cmake rename to src/enkf/cmake/FindNetCDF.cmake index 1439ae8486..9e32378ff5 100644 --- a/cmake/Modules/FindNetCDF.cmake +++ b/src/enkf/cmake/FindNetCDF.cmake @@ -171,6 +171,21 @@ function(netcdf_config exec flag output_var) endif() endfunction() +## Detect additional package properties +netcdf_config(${NetCDF_C_CONFIG_EXECUTABLE} --has-parallel4 _val) +if( NOT _val MATCHES "^(yes|no)$" ) + netcdf_config(${NetCDF_C_CONFIG_EXECUTABLE} --has-parallel _val) +endif() +if( _val MATCHES "^(yes)$" ) + set(NetCDF_PARALLEL TRUE CACHE STRING "NetCDF has parallel IO capability via pnetcdf or hdf5." FORCE) +else() + set(NetCDF_PARALLEL FALSE CACHE STRING "NetCDF has no parallel IO capability." FORCE) +endif() + +if(NetCDF_PARALLEL) + find_package(MPI REQUIRED) +endif() + ## Find libraries for each component set( NetCDF_LIBRARIES ) foreach( _comp IN LISTS _search_components ) @@ -228,6 +243,12 @@ foreach( _comp IN LISTS _search_components ) IMPORTED_LOCATION ${NetCDF_${_comp}_LIBRARY} INTERFACE_INCLUDE_DIRECTORIES "${NetCDF_${_comp}_INCLUDE_DIRS}" INTERFACE_LINK_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) + if( NOT _comp MATCHES "^(C)$" ) + target_link_libraries(NetCDF::NetCDF_${_comp} INTERFACE NetCDF::NetCDF_C) + endif() + if(MPI_${_comp}_FOUND) + target_link_libraries(NetCDF::NetCDF_${_comp} INTERFACE MPI::MPI_${_comp}) + endif() endif() endif() endforeach() @@ -263,17 +284,6 @@ if (NetCDF_INCLUDE_DIRS) endif() endif () -## Detect additional package properties -netcdf_config(${NetCDF_C_CONFIG_EXECUTABLE} --has-parallel4 _val) -if( NOT _val MATCHES "^(yes|no)$" ) - netcdf_config(${NetCDF_C_CONFIG_EXECUTABLE} --has-parallel _val) -endif() -if( _val MATCHES "^(yes)$" ) - set(NetCDF_PARALLEL TRUE CACHE STRING "NetCDF has parallel IO capability via pnetcdf or hdf5." FORCE) -else() - set(NetCDF_PARALLEL FALSE CACHE STRING "NetCDF has no parallel IO capability." FORCE) -endif() - ## Finalize find_package include(FindPackageHandleStandardArgs) diff --git a/src/enkf/cmake/PackageConfig.cmake.in b/src/enkf/cmake/PackageConfig.cmake.in new file mode 100644 index 0000000000..c4062dd09c --- /dev/null +++ b/src/enkf/cmake/PackageConfig.cmake.in @@ -0,0 +1,45 @@ +@PACKAGE_INIT@ + +#@PROJECT_NAME@-config.cmake +# +# Imported interface targets provided: +# * @PROJECT_NAME@::enkf - EnKF library target + +# Include targets file. This will create IMPORTED target @PROJECT_NAME@ +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-config-version.cmake") +include(CMakeFindDependencyMacro) + +# Get the ENKF_MODE attribute +-set(ENKF_MODE @ENKF_MODE@) + +find_dependency(MPI) +find_dependency(NetCDF COMPONENTS Fortran) + +# ON|OFF implies @PROJECT_NAME@ was compiled with/without -DENABLE_MKL=ON|OFF +if(@ENABLE_MKL@) + find_dependency(MKL REQUIRED) + set(LAPACK_LIBRARIES ${MKL_LIBRARIES}) +endif() +if(NOT @ENABLE_MKL@) + find_dependency(LAPACK REQUIRED) +endif() + +# ON|OFF implies @PROJECT_NAME@ was compiled with/without OpenMP +if(@OPENMP@) + find_dependency(OpenMP COMPONENTS Fortran) +endif() + +# This gives more trouble since GSIApp is a nested project of projects +# and targets are built in the GSIApp project +#find_dependency(gsi REQUIRED) + +# Get the build type from library target +get_target_property(@PROJECT_NAME@_BUILD_TYPES @PROJECT_NAME@::@PROJECT_NAME@ IMPORTED_CONFIGURATIONS) + +check_required_components("@PROJECT_NAME@") + +get_target_property(location @PROJECT_NAME@::@PROJECT_NAME@ LOCATION) +message(STATUS "Found @PROJECT_NAME@: ${location} (found version \"${PACKAGE_VERSION}\")") +message(STATUS "FindEnKF defines targets:") +message(STATUS " - ENKF_MODE [${ENKF_MODE}]") diff --git a/src/enkf/cmake/enkfapp_compiler_flags.cmake b/src/enkf/cmake/enkfapp_compiler_flags.cmake new file mode 100644 index 0000000000..2a7d5e2cc9 --- /dev/null +++ b/src/enkf/cmake/enkfapp_compiler_flags.cmake @@ -0,0 +1,27 @@ +if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") + add_definitions(-DNDEBUG) +endif() + +####################################################################################### +# Fortran +####################################################################################### + +if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") + include(enkfapp_compiler_flags_GNU_Fortran) +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") + include(enkfapp_compiler_flags_Intel_Fortran) +else() + message(STATUS "Fortran compiler with ID ${CMAKE_Fortran_COMPILER_ID} will be used with CMake default options") +endif() + +####################################################################################### +# C +####################################################################################### + +if(CMAKE_C_COMPILER_ID MATCHES "GNU") + include(enkfapp_compiler_flags_GNU_C) +elseif(CMAKE_C_COMPILER_ID MATCHES "Intel") + include(enkfapp_compiler_flags_Intel_C) +else() + message(STATUS "C compiler with ID ${CMAKE_C_COMPILER_ID} will be used with CMake default options") +endif() diff --git a/src/enkf/cmake/enkfapp_compiler_flags_GNU_C.cmake b/src/enkf/cmake/enkfapp_compiler_flags_GNU_C.cmake new file mode 100644 index 0000000000..31135cb0a8 --- /dev/null +++ b/src/enkf/cmake/enkfapp_compiler_flags_GNU_C.cmake @@ -0,0 +1,34 @@ +#################################################################### +# FLAGS COMMON TO ALL BUILD TYPES +#################################################################### + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") + +#################################################################### +# RELEASE FLAGS +#################################################################### + +set(CMAKE_C_FLAGS_RELEASE "") + +#################################################################### +# DEBUG FLAGS +#################################################################### + +set(CMAKE_C_FLAGS_DEBUG "") + +#################################################################### +# LINK FLAGS +#################################################################### + +set(CMAKE_C_LINK_FLAGS "") + +#################################################################### +# FLAGS FOR AUTOPROFILING +#################################################################### + +set(C_AUTOPROFILING_FLAGS "") + +#################################################################### + +# Meaning of flags +# ---------------- diff --git a/src/enkf/cmake/enkfapp_compiler_flags_GNU_Fortran.cmake b/src/enkf/cmake/enkfapp_compiler_flags_GNU_Fortran.cmake new file mode 100644 index 0000000000..bf6e937882 --- /dev/null +++ b/src/enkf/cmake/enkfapp_compiler_flags_GNU_Fortran.cmake @@ -0,0 +1,41 @@ +#################################################################### +# FLAGS COMMON TO ALL BUILD TYPES +#################################################################### + +set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -fbacktrace -ffree-line-length-none -fconvert=big-endian -fno-second-underscore -ffast-math") + +if(${CMAKE_Fortran_COMPILER_VERSION} VERSION_GREATER_EQUAL 10) + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-argument-mismatch -fallow-invalid-boz") +endif() + +#################################################################### +# RELEASE FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_RELEASE "-O2 -funroll-all-loops -finline-functions") + +#################################################################### +# DEBUG FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -ggdb -Wall -fcheck=bounds -ffpe-trap=invalid,zero,overflow") + +#################################################################### +# LINK FLAGS +#################################################################### + +set(CMAKE_Fortran_LINK_FLAGS "-finstrument-functions") + +#################################################################### +# FLAGS FOR AUTOPROFILING +#################################################################### + +set(Fortran_AUTOPROFILING_FLAGS "") + +#################################################################### + +# Meaning of flags +# ---------------- +# -fstack-arrays : Allocate automatic arrays on the stack (needs large stacksize!!!) +# -funroll-all-loops : Unroll all loops +# -fcheck=bounds : Bounds checking diff --git a/src/enkf/cmake/enkfapp_compiler_flags_Intel_C.cmake b/src/enkf/cmake/enkfapp_compiler_flags_Intel_C.cmake new file mode 100644 index 0000000000..ed5d63d1de --- /dev/null +++ b/src/enkf/cmake/enkfapp_compiler_flags_Intel_C.cmake @@ -0,0 +1,34 @@ +#################################################################### +# FLAGS COMMON TO ALL BUILD TYPES +#################################################################### + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") + +#################################################################### +# RELEASE FLAGS +#################################################################### + +set(CMAKE_C_FLAGS_RELEASE "") + +#################################################################### +# DEBUG FLAGS +#################################################################### + +set(CMAKE_C_FLAGS_DEBUG "-Wall") + +#################################################################### +# LINK FLAGS +#################################################################### + +set(CMAKE_C_LINK_FLAGS "") + +#################################################################### +# FLAGS FOR AUTOPROFILING +#################################################################### + +set(C_AUTOPROFILING_FLAGS "") + +#################################################################### + +# Meaning of flags +# ---------------- diff --git a/src/enkf/cmake/enkfapp_compiler_flags_Intel_Fortran.cmake b/src/enkf/cmake/enkfapp_compiler_flags_Intel_Fortran.cmake new file mode 100644 index 0000000000..8ba2887da8 --- /dev/null +++ b/src/enkf/cmake/enkfapp_compiler_flags_Intel_Fortran.cmake @@ -0,0 +1,35 @@ +#################################################################### +# FLAGS COMMON TO ALL BUILD TYPES +#################################################################### + +set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -traceback -assume byterecl -convert big_endian -implicitnone") + +#################################################################### +# RELEASE FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -fp-model strict") + +#################################################################### +# DEBUG FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -fp-model source -debug -ftrapuv -warn all,nointerfaces -check all,noarg_temp_created -fp-stack-check -fstack-protector") + +#################################################################### +# LINK FLAGS +#################################################################### + +set(CMAKE_Fortran_LINK_FLAGS "") + +#################################################################### +# FLAGS FOR AUTOPROFILING +#################################################################### + +set(Fortran_AUTOPROFILING_FLAGS "-finstrument-functions") + +#################################################################### + +# Meaning of flags +# ---------------- +# todo diff --git a/src/enkf/enkf_files.cmake b/src/enkf/enkf_files.cmake new file mode 100644 index 0000000000..907e0495c5 --- /dev/null +++ b/src/enkf/enkf_files.cmake @@ -0,0 +1,65 @@ +list(APPEND EnKF_SRC_main + enkf_main.f90) + +list(APPEND EnKF_SRC_srcs + controlvec.f90 + covlocal.f90 + enkf.f90 + enkf_obs_sensitivity.f90 + enkf_obsmod.f90 + expand_ens.f90 + fftpack.f90 + genqsat1.f90 + inflation.f90 + innovstats.f90 + kdtree2.f90 + letkf.f90 + loadbal.f90 + mpi_readobs.f90 + mpisetup.f90 + netcdf_io_wrf.f90 + params.f90 + quicksort.f90 + radbias.f90 + read_locinfo.f90 + readconvobs.f90 + readozobs.f90 + readsatobs.f90 + reducedgrid.f90 + rnorm.f90 + sorting.f90 + specmod.f90 + statevec.f90 + write_logfile.f90) + +list(APPEND EnKF_SRC_GFS + gridinfo_gfs.f90 + gridio_gfs.f90 + observer_gfs.f90 + smooth_gfs.f90) + +list(APPEND EnKF_SRC_WRF + gridinfo_wrf.f90 + gridio_wrf.f90 + observer_reg.f90 + smooth_wrf.f90) + +list(APPEND EnKF_SRC_NMMB + gridinfo_nmmb.f90 + gridio_nmmb.f90 + observer_reg.f90 + smooth_nmmb.f90) + +list(APPEND EnKF_SRC_FV3REG + gridinfo_fv3reg.f90 + gridio_fv3reg.f90 + observer_fv3reg.f90 + read_fv3reg_restarts.f90 + smooth_fv3reg.f90 + write_fv3reg_restarts.f90) + +#Unused files +#specmod_shtns.f90 -- This is a faster alternative to specmod.f90 +#specmod_splib.f90 -- This is a copy of specmod.f90 +#observer_nmmb.f90 -- This is soft-linked to observer_reg.f90 +#observer_wrf.f90 -- This is soft-linked to observer_reg.f90 diff --git a/src/enkf/gridinfo_fv3reg.f90 b/src/enkf/gridinfo_fv3reg.f90 index a50355d4e8..cdc56c99fb 100644 --- a/src/enkf/gridinfo_fv3reg.f90 +++ b/src/enkf/gridinfo_fv3reg.f90 @@ -42,7 +42,8 @@ module gridinfo ! !$$$ -use mpisetup, only: nproc, mpi_integer, mpi_real4, mpi_comm_world +use mpi, only: mpi_real4,mpi_comm_world +use mpisetup, only: nproc use params, only: datapath,nlevs,nlons,nlats,use_gfs_nemsio, fgfileprefixes, & fv3fixpath, nx_res,ny_res, ntiles,l_fv3reg_filecombined use kinds, only: r_kind, i_kind, r_double, r_single @@ -68,9 +69,13 @@ module gridinfo integer,public :: npts integer,public :: ntrunc ! supported variable names in anavinfo -character(len=max_varname_length),public, dimension(15) :: vars3d_supported = (/'u ', 'v ', 'w ', 't ', 'q ', 'oz ', 'cw ', 'tsen', 'prse', & - 'ql ', 'qi ', 'qr', 'qs', 'qg', 'qnr'/) -character(len=max_varname_length),public, dimension(3) :: vars2d_supported = (/'ps ', 'pst', 'sst' /) +character(len=max_varname_length),public, dimension(15) :: & + vars3d_supported = [character(len=max_varname_length) :: & + 'u', 'v', 'w', 't', 'q', 'oz', 'cw', 'tsen', 'prse', & + 'ql', 'qi', 'qr', 'qs', 'qg', 'qnr'] +character(len=max_varname_length),public, dimension(3) :: & + vars2d_supported = [character(len=max_varname_length) :: & + 'ps', 'pst', 'sst'] ! supported variable names in anavinfo real(r_single), allocatable, dimension(:) :: ak,bk,eta1_ll,eta2_ll contains diff --git a/src/enkf/gridinfo_gfs.f90 b/src/enkf/gridinfo_gfs.f90 index 7fdb2f67b0..c2e2b10f57 100644 --- a/src/enkf/gridinfo_gfs.f90 +++ b/src/enkf/gridinfo_gfs.f90 @@ -78,8 +78,8 @@ subroutine getgridinfo(fileprefix, reducedgrid) use nemsio_module, only: nemsio_gfile,nemsio_open,nemsio_close,& nemsio_getfilehead,nemsio_getheadvar,& nemsio_readrecv,nemsio_init, nemsio_realkind -use module_fv3gfs_ncio, only: Dataset, Variable, Dimension, open_dataset,& - read_attribute, close_dataset, get_dim, read_vardata +use module_ncio, only: Dataset, Variable, Dimension, open_dataset,& + read_attribute, close_dataset, get_dim, read_vardata implicit none type(Dataset) :: dset diff --git a/src/enkf/gridio_fv3reg.f90 b/src/enkf/gridio_fv3reg.f90 index 930264bc26..0b780b9922 100644 --- a/src/enkf/gridio_fv3reg.f90 +++ b/src/enkf/gridio_fv3reg.f90 @@ -55,10 +55,12 @@ module gridio !------------------------------------------------------------------------- integer(i_kind) ,parameter:: ndynvarslist=6, ntracerslist=8 - character(len=max_varname_length), parameter :: vardynvars(ndynvarslist) =(/"u","v", & - "T","W","DZ","delp"/) - character(len=max_varname_length), parameter :: vartracers(ntracerslist) =(/'sphum','o3mr', & - 'liq_wat','ice_wat','rainwat','snowwat','graupel','rain_nc'/) + character(len=max_varname_length), parameter, dimension(ndynvarslist) :: & + vardynvars = [character(len=max_varname_length) :: & + 'u', 'v', 'T', 'W', 'DZ', 'delp'] + character(len=max_varname_length), parameter, dimension(ntracerslist) :: & + vartracers = [character(len=max_varname_length) :: & + 'sphum','o3mr', 'liq_wat','ice_wat','rainwat','snowwat','graupel','rain_nc'] type type_fv3lamfile logical l_filecombined character(len=max_varname_length), dimension(2):: fv3lamfilename @@ -259,7 +261,7 @@ subroutine readgriddata(nanal1,nanal2,vars3d,vars2d,n3d,n2d,levels,ndim,ntimes,f endif - if (tv_ind > 0.or.tsen_ind) then + if (tv_ind > 0 .or. tsen_ind > 0) then allocate(tsenworkvar3d(nx_res,ny_res,nlevs)) varstrname = 'T' call fv3lamfile%get_idfn(varstrname,file_id,fv3filename) diff --git a/src/enkf/gridio_gfs.f90 b/src/enkf/gridio_gfs.f90 index 8a6bd12507..fe5199e395 100644 --- a/src/enkf/gridio_gfs.f90 +++ b/src/enkf/gridio_gfs.f90 @@ -61,8 +61,8 @@ module gridio subroutine readgriddata_pnc(vars3d,vars2d,n3d,n2d,levels,ndim,ntimes, & fileprefixes,filesfcprefixes,reducedgrid,grdin,qsat) - use module_fv3gfs_ncio, only: Dataset, Variable, Dimension, open_dataset,& - quantize_data,read_attribute, close_dataset, get_dim, read_vardata + use module_ncio, only: Dataset, Variable, Dimension, open_dataset,& + quantize_data,read_attribute, close_dataset, get_dim, read_vardata implicit none character(len=max_varname_length), dimension(n2d), intent(in) :: vars2d @@ -423,8 +423,8 @@ subroutine readgriddata(nanal1,nanal2,vars3d,vars2d,n3d,n2d,levels,ndim,ntimes, use nemsio_module, only: nemsio_gfile,nemsio_open,nemsio_close,& nemsio_getfilehead,nemsio_getheadvar,nemsio_realkind,nemsio_charkind,& nemsio_readrecv,nemsio_init,nemsio_setheadvar,nemsio_writerecv - use module_fv3gfs_ncio, only: Dataset, Variable, Dimension, open_dataset,& - quantize_data,read_attribute, close_dataset, get_dim, read_vardata + use module_ncio, only: Dataset, Variable, Dimension, open_dataset,& + quantize_data,read_attribute, close_dataset, get_dim, read_vardata implicit none integer, intent(in) :: nanal1,nanal2 @@ -1032,11 +1032,11 @@ end subroutine readgriddata subroutine writegriddata_pnc(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,no_inflate_flag) use netcdf - use module_fv3gfs_ncio, only: Dataset, Variable, Dimension, open_dataset,& - read_attribute, close_dataset, get_dim, read_vardata,& - create_dataset, get_idate_from_time_units, & - get_time_units_from_idate, write_vardata, & - write_attribute, quantize_data, has_var, has_attr + use module_ncio, only: Dataset, Variable, Dimension, open_dataset,& + read_attribute, close_dataset, get_dim, read_vardata,& + create_dataset, get_idate_from_time_units, & + get_time_units_from_idate, write_vardata, & + write_attribute, quantize_data, has_var, has_attr use constants, only: grav, zero use params, only: nbackgrounds,anlfileprefixes,fgfileprefixes,reducedgrid,& nccompress @@ -1842,11 +1842,11 @@ subroutine writegriddata(nanal1,nanal2,vars3d,vars2d,n3d,n2d,levels,ndim,grdin,n nemsio_readrec,nemsio_writerec,nemsio_intkind,nemsio_charkind,& nemsio_getheadvar,nemsio_realkind,nemsio_getfilehead,& nemsio_readrecv,nemsio_init,nemsio_setheadvar,nemsio_writerecv - use module_fv3gfs_ncio, only: Dataset, Variable, Dimension, open_dataset,& - read_attribute, close_dataset, get_dim, read_vardata,& - create_dataset, get_idate_from_time_units, & - get_time_units_from_idate, write_vardata, & - write_attribute, quantize_data, has_var, has_attr + use module_ncio, only: Dataset, Variable, Dimension, open_dataset,& + read_attribute, close_dataset, get_dim, read_vardata,& + create_dataset, get_idate_from_time_units, & + get_time_units_from_idate, write_vardata, & + write_attribute, quantize_data, has_var, has_attr use constants, only: grav use params, only: nbackgrounds,anlfileprefixes,fgfileprefixes,reducedgrid,& nccompress,write_ensmean @@ -3308,11 +3308,11 @@ subroutine writeincrement(nanal1,nanal2,vars3d,vars2d,n3d,n2d,levels,ndim,grdin, datestring,nhr_anal,write_ensmean use constants, only: grav use mpi - use module_fv3gfs_ncio, only: Dataset, Variable, Dimension, open_dataset,& - read_attribute, close_dataset, get_dim, read_vardata,& - create_dataset, get_idate_from_time_units, & - get_time_units_from_idate, write_vardata, & - write_attribute, quantize_data, has_var, has_attr + use module_ncio, only: Dataset, Variable, Dimension, open_dataset,& + read_attribute, close_dataset, get_dim, read_vardata,& + create_dataset, get_idate_from_time_units, & + get_time_units_from_idate, write_vardata, & + write_attribute, quantize_data, has_var, has_attr implicit none integer, intent(in) :: nanal1,nanal2 @@ -3711,11 +3711,11 @@ subroutine writeincrement_pnc(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,no_inflate datestring,nhr_anal use constants, only: grav use mpi - use module_fv3gfs_ncio, only: Dataset, Variable, Dimension, open_dataset,& - read_attribute, close_dataset, get_dim, read_vardata,& - create_dataset, get_idate_from_time_units, & - get_time_units_from_idate, write_vardata, & - write_attribute, quantize_data, has_var, has_attr + use module_ncio, only: Dataset, Variable, Dimension, open_dataset,& + read_attribute, close_dataset, get_dim, read_vardata,& + create_dataset, get_idate_from_time_units, & + get_time_units_from_idate, write_vardata, & + write_attribute, quantize_data, has_var, has_attr implicit none character(len=max_varname_length), dimension(n2d), intent(in) :: vars2d diff --git a/src/fv3gfs_ncio/CMakeLists.txt b/src/fv3gfs_ncio/CMakeLists.txt deleted file mode 100644 index c68eda3841..0000000000 --- a/src/fv3gfs_ncio/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -cmake_minimum_required(VERSION 3.16.1) -if(BUILD_FV3GFS_NCIO) - set(Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include") - # NetCDF-4 library - include_directories( ${NETCDF_INCLUDE_DIRS} ${FV3GFS_NCIO_INCS} ) - FILE(GLOB FV3GFS_NCIO_SRC ${CMAKE_CURRENT_SOURCE_DIR}/module_fv3gfs_ncio.f90 ) - set_source_files_properties( ${FV3GFS_NCIO_SRC} PROPERTIES COMPILE_FLAGS ${FV3GFS_NCIO_Fortran_FLAGS} ) - add_library(fv3gfs_ncio STATIC ${FV3GFS_NCIO_SRC}) -endif(BUILD_FV3GFS_NCIO) - diff --git a/src/fv3gfs_ncio/module_fv3gfs_ncio.f90 b/src/fv3gfs_ncio/module_fv3gfs_ncio.f90 deleted file mode 100644 index 51b901bf88..0000000000 --- a/src/fv3gfs_ncio/module_fv3gfs_ncio.f90 +++ /dev/null @@ -1,1338 +0,0 @@ -module module_fv3gfs_ncio -! module for reading/writing netcdf global lat/lon grid files output by FV3GFS. -! assumes netcdf classic data model, nf90_format_netcdf4_classic format. -! handles 32 and 64 bit real variables, 8, 16 and 32 bit integer -! variables and char variables. Variables can have up to 5 dimensions. -! jeff whitaker 201910 - - use netcdf - use mpi - - implicit none - private - - type Variable - integer varid ! netCDF variable ID - integer ndims ! number of dimensions - integer dtype ! netCDF data type - integer natts ! number of attributes - integer deflate_level ! compression level (if > 0) - logical shuffle ! shuffle filter? - logical hasunlim ! has an unlimited dim? - character(len=nf90_max_name) :: name ! variable name - integer, allocatable, dimension(:) :: dimids ! netCDF dimension IDs - ! indices into Dataset%dimensions for associated dimensions. - integer, allocatable, dimension(:) :: dimindxs - ! names of associated dimensions. - character(len=nf90_max_name), allocatable, dimension(:) :: dimnames - ! current dimension lengths (updated after every write_vardata call) - integer, allocatable, dimension(:) :: dimlens - integer, allocatable, dimension(:) :: chunksizes - end type Variable - type Dimension - integer dimid ! netCDF dimension ID - integer len ! dimension length (updated after every write_vardata call) - logical isunlimited ! unlimited? - character(len=nf90_max_name) :: name ! name of dimension - end type Dimension - type Dataset - integer :: ncid ! netCDF ID. - integer :: nvars ! number of variables in dataset - integer :: ndims ! number of dimensions in dataset - integer :: natts ! number of dataset (global) attributes - integer :: nunlimdim ! dimension ID for unlimited dimension - logical :: ishdf5 ! is underlying disk format HDF5? - logical :: isparallel ! was file opened for parallel I/O? - character(len=500) filename ! netCDF filename - ! array of Variable instances - type(Variable), allocatable, dimension(:) :: variables - ! array of Dimension instances - type(Dimension), allocatable, dimension(:) :: dimensions - end type Dataset - - interface read_vardata - module procedure read_vardata_1d_r4, read_vardata_2d_r4, read_vardata_3d_r4,& - read_vardata_4d_r4, read_vardata_5d_r4, & - read_vardata_1d_r8, read_vardata_2d_r8, read_vardata_3d_r8,& - read_vardata_4d_r8, read_vardata_5d_r8, & - read_vardata_1d_int, read_vardata_2d_int, & - read_vardata_3d_int, read_vardata_4d_int, read_vardata_5d_int, & - read_vardata_1d_short, read_vardata_2d_short, & - read_vardata_3d_short, read_vardata_4d_short, read_vardata_5d_short , & - read_vardata_1d_byte, read_vardata_2d_byte, & - read_vardata_3d_byte, read_vardata_4d_byte, read_vardata_5d_byte, & - read_vardata_1d_char, read_vardata_2d_char, & - read_vardata_3d_char, read_vardata_4d_char, read_vardata_5d_char - end interface - - interface write_vardata - module procedure write_vardata_1d_r4, write_vardata_2d_r4, write_vardata_3d_r4,& - write_vardata_4d_r4, write_vardata_1d_r8, write_vardata_2d_r8, write_vardata_3d_r8,& - write_vardata_4d_r8, write_vardata_1d_int, write_vardata_2d_int, & - write_vardata_3d_int, write_vardata_4d_int, & - write_vardata_5d_int, write_vardata_5d_r4, write_vardata_5d_r8, & - write_vardata_1d_short, write_vardata_2d_short, write_vardata_3d_short, & - write_vardata_4d_short, write_vardata_5d_short, & - write_vardata_1d_byte, write_vardata_2d_byte, write_vardata_3d_byte, & - write_vardata_4d_byte, write_vardata_5d_byte, & - write_vardata_1d_char, write_vardata_2d_char, write_vardata_3d_char, & - write_vardata_4d_char, write_vardata_5d_char - end interface - - interface read_attribute - module procedure read_attribute_r4_scalar, read_attribute_int_scalar,& - read_attribute_r8_scalar, read_attribute_r4_1d,& - read_attribute_int_1d, read_attribute_r8_1d, read_attribute_char, & - read_attribute_short_scalar, read_attribute_short_1d, & - read_attribute_byte_scalar, read_attribute_byte_1d - end interface - - interface write_attribute - module procedure write_attribute_r4_scalar, write_attribute_int_scalar,& - write_attribute_r8_scalar, write_attribute_r4_1d,& - write_attribute_int_1d, write_attribute_r8_1d, write_attribute_char, & - write_attribute_short_scalar, write_attribute_short_1d, & - write_attribute_byte_scalar, write_attribute_byte_1d - end interface - - interface quantize_data - module procedure quantize_data_2d, quantize_data_3d, quantize_data_4d - end interface - - public :: open_dataset, create_dataset, close_dataset, Dataset, Variable, Dimension, & - read_vardata, read_attribute, write_vardata, write_attribute, get_ndim, & - get_nvar, get_var, get_dim, get_idate_from_time_units, & - get_time_units_from_idate, quantize_data, has_var, has_attr - - contains - - subroutine nccheck(status,halt,fname) - ! check return code, print error message - implicit none - integer, intent (in) :: status - logical, intent(in), optional :: halt - character(len=*), intent(in), optional :: fname - logical stopit - if (present(halt)) then - stopit = halt - else - stopit = .true. - endif - if (status /= nf90_noerr) then - write(0,*) status, trim(nf90_strerror(status)) - if (present(fname)) then - write(0,*) trim(fname) - end if - if (stopit) stop 99 - end if - end subroutine nccheck - - function get_dim(dset, dimname) result(dim) - type(Dataset) :: dset - type(Dimension) :: dim - character(len=*), intent(in) :: dimname - integer ndim - ndim = get_ndim(dset, dimname) - dim = dset%dimensions(ndim) - end function get_dim - - integer function get_ndim(dset, dimname) - ! get dimension index given name - type(Dataset), intent(in) :: dset - character(len=*), intent(in) :: dimname - integer ndim - get_ndim = -1 - do ndim=1,dset%ndims - if (trim(dset%dimensions(ndim)%name) == trim(dimname)) then - get_ndim = ndim - exit - endif - enddo - end function get_ndim - - function get_var(dset, varname) result (var) - type(Dataset) :: dset - type(Variable) :: var - character(len=*) :: varname - integer nvar - nvar = get_nvar(dset, varname) - var = dset%variables(nvar) - end function get_var - - logical function has_var(dset, varname) - ! returns .true. is varname exists in dset, otherwise .false. - type(Dataset) :: dset - character(len=*) :: varname - integer nvar - nvar = get_nvar(dset, varname) - if (nvar > 0) then - has_var=.true. - else - has_var=.false. - endif - end function has_var - - logical function has_attr(dset, attname, varname) - ! returns .true. if attribute exists in dset, otherwise .false. - ! use optional kwarg varname to check for a variable attribute. - type(Dataset) :: dset - character(len=*) :: attname - character(len=*), optional :: varname - integer nvar, varid, ncerr - nvar = get_nvar(dset, varname) - if(present(varname))then - nvar = get_nvar(dset,varname) - if (nvar < 0) then - has_attr = .false. - return - endif - varid = dset%variables(nvar)%varid - else - varid = NF90_GLOBAL - endif - ncerr = nf90_inquire_attribute(dset%ncid, varid, attname) - if (ncerr /= 0) then - has_attr=.false. - else - has_attr=.true. - endif - end function has_attr - - integer function get_nvar(dset,varname) - ! get variable index given name - type(Dataset), intent(in) :: dset - character(len=*), intent(in) :: varname - integer nvar - get_nvar = -1 - do nvar=1,dset%nvars - if (trim(dset%variables(nvar)%name) == trim(varname)) then - get_nvar = nvar - exit - endif - enddo - end function get_nvar - - subroutine set_varunlimdimlens_(dset,errcode) - ! reset dimension length (dimlens) for unlim dim for all variables - type(Dataset), intent(inout) :: dset - integer, intent(out), optional :: errcode - integer ndim,n,nvar,ncerr - logical return_errcode - if(present(errcode)) then - return_errcode=.true. - errcode = 0 - else - return_errcode=.false. - endif - ! loop over all vars - do nvar=1,dset%nvars - ! does var have unlim dimension? - if (dset%variables(nvar)%hasunlim) then - ! loop over all var dimensions - do ndim=1,dset%variables(nvar)%ndims - n = dset%variables(nvar)%dimindxs(ndim) - ! n is the dimension index for this variable dimension - ! if this dim is unlimited, update dimlens entry - if (dset%dimensions(n)%isunlimited) then - ncerr = nf90_inquire_dimension(dset%ncid,& - dset%dimensions(n)%dimid, & - len=dset%variables(nvar)%dimlens(ndim)) - if (return_errcode) then - call nccheck(ncerr,halt=.false.) - errcode=ncerr - return - else - call nccheck(ncerr) - endif - ! also update len attribute of Dimension object - dset%dimensions(n)%len = dset%variables(nvar)%dimlens(ndim) - endif - enddo - endif - enddo - end subroutine set_varunlimdimlens_ - - function open_dataset(filename,errcode,paropen, mpicomm) result(dset) - ! open existing dataset, create dataset object for reading netcdf file - ! if optional error return code errcode is not specified, - ! program will stop if a nonzero error code returned by the netcdf lib. - implicit none - character(len=*), intent(in) :: filename - type(Dataset) :: dset - integer, intent(out), optional :: errcode - logical, intent(in), optional :: paropen - integer, intent(in), optional :: mpicomm - integer ncerr,nunlimdim,ndim,nvar,n,formatnum - logical return_errcode - if(present(errcode)) then - return_errcode=.true. - errcode = 0 - else - return_errcode=.false. - endif - if (present(paropen)) then - if (paropen) then - dset%isparallel = .true. - else - dset%isparallel = .false. - end if - else - dset%isparallel = .false. - end if - ! open netcdf file, get info, populate Dataset object. - if (dset%isparallel) then - if (present(mpicomm)) then - ncerr = nf90_open(trim(filename), ior(NF90_NOWRITE, NF90_MPIIO), & - comm=mpicomm, info = mpi_info_null, ncid=dset%ncid) - else - ncerr = nf90_open(trim(filename), ior(NF90_NOWRITE, NF90_MPIIO), & - comm=mpi_comm_world, info = mpi_info_null, ncid=dset%ncid) - end if - else - ncerr = nf90_open(trim(filename), NF90_NOWRITE, ncid=dset%ncid) - end if - if (return_errcode) then - call nccheck(ncerr,halt=.false.,fname=filename) - errcode=ncerr - if (ncerr /= 0) return - else - call nccheck(ncerr,fname=filename) - endif - ncerr = nf90_inquire(dset%ncid, dset%ndims, dset%nvars, dset%natts, nunlimdim, formatnum=formatnum) - if (return_errcode) then - errcode=ncerr - call nccheck(ncerr,halt=.false.,fname=filename) - if (ncerr /= 0) return - else - call nccheck(ncerr,fname=filename) - endif - if (formatnum == nf90_format_netcdf4 .or. formatnum == nf90_format_netcdf4_classic) then - dset%ishdf5 = .true. - else - dset%ishdf5 = .false. - endif - dset%filename = trim(filename) - allocate(dset%variables(dset%nvars)) - allocate(dset%dimensions(dset%ndims)) - do ndim=1,dset%ndims - dset%dimensions(ndim)%dimid = ndim - ncerr = nf90_inquire_dimension(dset%ncid, ndim, name=dset%dimensions(ndim)%name, & - len=dset%dimensions(ndim)%len) - if (return_errcode) then - errcode=ncerr - call nccheck(ncerr,halt=.false.,fname=filename) - if (ncerr /= 0) return - else - call nccheck(ncerr,fname=filename) - endif - if (ndim == nunlimdim) then - dset%dimensions(ndim)%isunlimited = .true. - else - dset%dimensions(ndim)%isunlimited = .false. - endif - enddo - do nvar=1,dset%nvars - dset%variables(nvar)%hasunlim = .false. - dset%variables(nvar)%varid = nvar - ncerr = nf90_inquire_variable(dset%ncid, nvar,& - name=dset%variables(nvar)%name,& - natts=dset%variables(nvar)%natts,& - xtype=dset%variables(nvar)%dtype,& - ndims=dset%variables(nvar)%ndims) - if (return_errcode) then - errcode=ncerr - call nccheck(ncerr,halt=.false.,fname=filename) - if (ncerr /= 0) return - else - call nccheck(ncerr,fname=filename) - endif - allocate(dset%variables(nvar)%dimids(dset%variables(nvar)%ndims)) - allocate(dset%variables(nvar)%dimindxs(dset%variables(nvar)%ndims)) - allocate(dset%variables(nvar)%dimlens(dset%variables(nvar)%ndims)) - allocate(dset%variables(nvar)%chunksizes(dset%variables(nvar)%ndims)) - allocate(dset%variables(nvar)%dimnames(dset%variables(nvar)%ndims)) - if (dset%ishdf5) then - ncerr = nf90_inquire_variable(dset%ncid, nvar,& - dimids=dset%variables(nvar)%dimids,& - deflate_level=dset%variables(nvar)%deflate_level,& - chunksizes=dset%variables(nvar)%chunksizes,& - shuffle=dset%variables(nvar)%shuffle) - else - ncerr = nf90_inquire_variable(dset%ncid, nvar,& - dimids=dset%variables(nvar)%dimids) - endif - if (return_errcode) then - errcode=ncerr - call nccheck(ncerr,halt=.false.,fname=filename) - if (ncerr /= 0) return - else - call nccheck(ncerr,fname=filename) - endif - do ndim=1,dset%variables(nvar)%ndims - do n=1,dset%ndims - if (dset%variables(nvar)%dimids(ndim) == dset%dimensions(n)%dimid) then - exit - endif - enddo - dset%variables(nvar)%dimindxs(ndim) = n - dset%variables(nvar)%dimlens(ndim) = dset%dimensions(n)%len - dset%variables(nvar)%dimnames(ndim) = dset%dimensions(n)%name - if (dset%dimensions(n)%isunlimited) then - dset%variables(nvar)%hasunlim = .true. - endif - enddo - enddo - end function open_dataset - - function create_dataset(filename, dsetin, copy_vardata, paropen, nocompress, mpicomm, errcode) result(dset) - ! create new dataset, using an existing dataset object to define - ! variables, dimensions and attributes. - ! If copy_vardata=T, all variable data (not just coordinate - ! variable data) is copied. Default is F (only coord var data - ! copied). - ! if optional nocompress=.true., outputfile will not use compression even if input file does - ! if optional error return code errcode is not specified, - ! program will stop if a nonzero error code returned by the netcdf lib. - implicit none - character(len=*), intent(in) :: filename - character(len=nf90_max_name) :: attname, varname - logical, intent(in), optional :: copy_vardata - type(Dataset) :: dset - type(Dataset), intent(in) :: dsetin - logical, intent(in), optional :: paropen - integer, intent(in), optional :: mpicomm - logical, intent(in), optional :: nocompress - integer, intent(out), optional :: errcode - integer ncerr,ndim,nvar,n,ishuffle,natt - logical copyd, coordvar, compress - real(8), allocatable, dimension(:) :: values_1d - real(8), allocatable, dimension(:,:) :: values_2d - real(8), allocatable, dimension(:,:,:) :: values_3d - real(8), allocatable, dimension(:,:,:,:) :: values_4d - real(8), allocatable, dimension(:,:,:,:,:) :: values_5d - integer, allocatable, dimension(:) :: ivalues_1d - integer, allocatable, dimension(:,:) :: ivalues_2d - integer, allocatable, dimension(:,:,:) :: ivalues_3d - integer, allocatable, dimension(:,:,:,:) :: ivalues_4d - integer, allocatable, dimension(:,:,:,:,:) :: ivalues_5d - character, allocatable, dimension(:) :: cvalues_1d - character, allocatable, dimension(:,:) :: cvalues_2d - character, allocatable, dimension(:,:,:) :: cvalues_3d - character, allocatable, dimension(:,:,:,:) :: cvalues_4d - character, allocatable, dimension(:,:,:,:,:) :: cvalues_5d - logical return_errcode - if(present(errcode)) then - return_errcode=.true. - errcode = 0 - else - return_errcode=.false. - endif - if (present(copy_vardata)) then - copyd = .true. ! copy all variable data - else - copyd = .false. ! only copy coordinate variable data - endif - if (present(paropen)) then - if (paropen) then - dset%isparallel = .true. - else - dset%isparallel = .false. - end if - else - dset%isparallel = .false. - end if - compress = .true. - if (present(nocompress)) then - if (nocompress) then - compress = .false. - end if - end if - ! create netcdf file - if (dsetin%ishdf5) then - if (dset%isparallel) then - if (present(mpicomm)) then - ncerr = nf90_create(trim(filename), & - cmode=IOR(NF90_CLOBBER,NF90_NETCDF4), ncid=dset%ncid, & - comm = mpicomm, info = mpi_info_null) - else - ncerr = nf90_create(trim(filename), & - cmode=IOR(NF90_CLOBBER,NF90_NETCDF4), ncid=dset%ncid, & - comm = mpi_comm_world, info = mpi_info_null) - end if - else - ncerr = nf90_create(trim(filename), & - cmode=IOR(IOR(NF90_CLOBBER,NF90_NETCDF4),NF90_CLASSIC_MODEL), & - !cmode=IOR(NF90_CLOBBER,NF90_NETCDF4), & - ncid=dset%ncid) - end if - dset%ishdf5 = .true. - else - ncerr = nf90_create(trim(filename), & - cmode=IOR(IOR(NF90_CLOBBER,NF90_64BIT_OFFSET),NF90_SHARE), & - ncid=dset%ncid) - dset%ishdf5 = .false. - endif - if (return_errcode) then - errcode=ncerr - call nccheck(ncerr,halt=.false.,fname=filename) - if (ncerr /= 0) return - else - call nccheck(ncerr,fname=filename) - endif - ! copy global attributes - do natt=1,dsetin%natts - ncerr = nf90_inq_attname(dsetin%ncid, NF90_GLOBAL, natt, attname) - if (return_errcode) then - errcode=ncerr - call nccheck(ncerr,halt=.false.) - if (ncerr /= 0) return - else - call nccheck(ncerr) - endif - ncerr = nf90_copy_att(dsetin%ncid, NF90_GLOBAL, attname, dset%ncid, NF90_GLOBAL) - if (return_errcode) then - errcode=ncerr - call nccheck(ncerr,halt=.false.) - if (ncerr /= 0) return - else - call nccheck(ncerr) - endif - enddo - dset%natts = dsetin%natts - dset%filename = trim(filename) - dset%ndims = dsetin%ndims - dset%nvars = dsetin%nvars - allocate(dset%variables(dsetin%nvars)) - allocate(dset%dimensions(dsetin%ndims)) - ! create dimensions - do ndim=1,dsetin%ndims - if (dsetin%dimensions(ndim)%isunlimited) then - ncerr = nf90_def_dim(dset%ncid, trim(dsetin%dimensions(ndim)%name), & - NF90_UNLIMITED, & - dset%dimensions(ndim)%dimid) - if (return_errcode) then - errcode=ncerr - call nccheck(ncerr,halt=.false.) - if (ncerr /= 0) return - else - call nccheck(ncerr) - endif - dset%dimensions(ndim)%isunlimited = .true. - dset%nunlimdim = ndim - dset%dimensions(ndim)%len = 0 - dset%dimensions(ndim)%name = trim(dsetin%dimensions(ndim)%name) - else - ncerr = nf90_def_dim(dset%ncid, trim(dsetin%dimensions(ndim)%name),& - dsetin%dimensions(ndim)%len, & - dset%dimensions(ndim)%dimid) - if (return_errcode) then - errcode=ncerr - call nccheck(ncerr,halt=.false.) - if (ncerr /= 0) return - else - call nccheck(ncerr) - endif - dset%dimensions(ndim)%len = dsetin%dimensions(ndim)%len - dset%dimensions(ndim)%isunlimited = .false. - dset%dimensions(ndim)%name = trim(dsetin%dimensions(ndim)%name) - endif - enddo - ! create variables - do nvar=1,dsetin%nvars - dset%variables(nvar)%hasunlim = .false. - dset%variables(nvar)%ndims = dsetin%variables(nvar)%ndims - allocate(dset%variables(nvar)%dimids(dset%variables(nvar)%ndims)) - allocate(dset%variables(nvar)%dimindxs(dset%variables(nvar)%ndims)) - allocate(dset%variables(nvar)%dimnames(dset%variables(nvar)%ndims)) - allocate(dset%variables(nvar)%dimlens(dset%variables(nvar)%ndims)) - allocate(dset%variables(nvar)%chunksizes(dset%variables(nvar)%ndims)) - dset%variables(nvar)%chunksizes = dsetin%variables(nvar)%chunksizes - do ndim=1,dset%variables(nvar)%ndims - do n=1,dset%ndims - if (trim(dsetin%variables(nvar)%dimnames(ndim)) == & - trim(dset%dimensions(n)%name)) then - exit - endif - enddo - dset%variables(nvar)%dimindxs(ndim) = n - dset%variables(nvar)%dimids(ndim) = dset%dimensions(n)%dimid - dset%variables(nvar)%dimlens(ndim) = dset%dimensions(n)%len - dset%variables(nvar)%dimnames(ndim) = dset%dimensions(n)%name - if (dset%dimensions(n)%isunlimited) then - dset%variables(nvar)%hasunlim = .true. - endif - enddo - dset%variables(nvar)%name = dsetin%variables(nvar)%name - dset%variables(nvar)%dtype = dsetin%variables(nvar)%dtype - if (maxval(dset%variables(nvar)%chunksizes) > 0 .and. dset%ishdf5) then - ! workaround for older versions of netcdf-fortran that don't - ! like zero chunksize to be specified. - ncerr = nf90_def_var(dset%ncid, & - trim(dset%variables(nvar)%name),& - dset%variables(nvar)%dtype, & - dset%variables(nvar)%dimids, & - dset%variables(nvar)%varid, & - chunksizes=dset%variables(nvar)%chunksizes) - else - ncerr = nf90_def_var(dset%ncid, & - trim(dset%variables(nvar)%name),& - dset%variables(nvar)%dtype, & - dset%variables(nvar)%dimids, & - dset%variables(nvar)%varid) - endif - if (return_errcode) then - errcode=ncerr - call nccheck(ncerr,halt=.false.) - if (ncerr /= 0) return - else - call nccheck(ncerr) - endif - if (dsetin%variables(nvar)%deflate_level > 0 .and. dset%ishdf5 .and. compress) then - if (dsetin%variables(nvar)%shuffle) then - ishuffle=1 - else - ishuffle=0 - endif - ncerr = nf90_def_var_deflate(dset%ncid, dset%variables(nvar)%varid,& - ishuffle,1,dsetin%variables(nvar)%deflate_level) - if (return_errcode) then - errcode=ncerr - call nccheck(ncerr,halt=.false.) - if (ncerr /= 0) return - else - call nccheck(ncerr) - endif - dset%variables(nvar)%shuffle = dsetin%variables(nvar)%shuffle - dset%variables(nvar)%deflate_level = & - dsetin%variables(nvar)%deflate_level - endif - ! copy variable attributes - do natt=1,dsetin%variables(nvar)%natts - ncerr = nf90_inq_attname(dsetin%ncid, dsetin%variables(nvar)%varid, natt, attname) - if (return_errcode) then - errcode=ncerr - call nccheck(ncerr,halt=.false.) - if (ncerr /= 0) return - else - call nccheck(ncerr) - endif - if (.not. compress) then - if (trim(attname) == 'max_abs_compression_error' & - .or. trim(attname) == 'nbits') then - cycle - end if - end if - ncerr = nf90_copy_att(dsetin%ncid, dsetin%variables(nvar)%varid, attname, dset%ncid, dset%variables(nvar)%varid) - if (return_errcode) then - errcode=ncerr - call nccheck(ncerr,halt=.false.) - if (ncerr /= 0) return - else - call nccheck(ncerr) - endif - enddo - enddo - ncerr = nf90_enddef(dset%ncid) - if (return_errcode) then - errcode=ncerr - call nccheck(ncerr,halt=.false.) - if (ncerr /= 0) return - else - call nccheck(ncerr) - endif - ! copy variable data - ! assumes data is real (32 or 64 bit), or integer (16 or 32 bit) and 1-4d. - do nvar=1,dsetin%nvars - varname = trim(dsetin%variables(nvar)%name) - ! is this variable a coordinate variable? - coordvar = .false. - if (trim(varname) == 'lats' .or. trim(varname) == 'lons' .or. & - trim(varname) == 'lat' .or. trim(varname) == 'lon') then - coordvar = .true. - else - do ndim=1,dset%ndims - if (trim(varname) == trim(dset%dimensions(ndim)%name)) then - coordvar = .true. - endif - enddo - endif - ! if copy_data flag not given, and not a coordinate var, - ! skip to next var. - if (.not. coordvar .and. .not. copyd) cycle - ! real variable - if (dsetin%variables(nvar)%dtype == NF90_FLOAT .or.& - dsetin%variables(nvar)%dtype == NF90_DOUBLE) then - if (dsetin%variables(nvar)%ndims == 1) then - call read_vardata(dsetin, varname, values_1d) - call write_vardata(dset, varname, values_1d) - else if (dsetin%variables(nvar)%ndims == 2) then - call read_vardata(dsetin, varname, values_2d) - call write_vardata(dset, varname, values_2d) - else if (dsetin%variables(nvar)%ndims == 3) then - call read_vardata(dsetin, varname, values_3d) - call write_vardata(dset, varname, values_3d) - else if (dsetin%variables(nvar)%ndims == 4) then - call read_vardata(dsetin, varname, values_4d) - call write_vardata(dset, varname, values_4d) - else if (dsetin%variables(nvar)%ndims == 5) then - call read_vardata(dsetin, varname, values_5d) - call write_vardata(dset, varname, values_5d) - endif - ! integer var - elseif (dsetin%variables(nvar)%dtype == NF90_INT .or.& - dsetin%variables(nvar)%dtype == NF90_BYTE .or.& - dsetin%variables(nvar)%dtype == NF90_SHORT) then - if (dsetin%variables(nvar)%ndims == 1) then - call read_vardata(dsetin, varname, ivalues_1d) - call write_vardata(dset, varname, ivalues_1d) - else if (dsetin%variables(nvar)%ndims == 2) then - call read_vardata(dsetin, varname, ivalues_2d) - call write_vardata(dset, varname, ivalues_2d) - else if (dsetin%variables(nvar)%ndims == 3) then - call read_vardata(dsetin, varname, ivalues_3d) - call write_vardata(dset, varname, ivalues_3d) - else if (dsetin%variables(nvar)%ndims == 4) then - call read_vardata(dsetin, varname, ivalues_4d) - call write_vardata(dset, varname, ivalues_4d) - else if (dsetin%variables(nvar)%ndims == 5) then - call read_vardata(dsetin, varname, ivalues_5d) - call write_vardata(dset, varname, ivalues_5d) - endif - elseif (dsetin%variables(nvar)%dtype == NF90_CHAR) then - if (dsetin%variables(nvar)%ndims == 1) then - call read_vardata(dsetin, varname, cvalues_1d) - call write_vardata(dset, varname, cvalues_1d) - else if (dsetin%variables(nvar)%ndims == 2) then - call read_vardata(dsetin, varname, cvalues_2d) - call write_vardata(dset, varname, cvalues_2d) - else if (dsetin%variables(nvar)%ndims == 3) then - call read_vardata(dsetin, varname, cvalues_3d) - call write_vardata(dset, varname, cvalues_3d) - else if (dsetin%variables(nvar)%ndims == 4) then - call read_vardata(dsetin, varname, cvalues_4d) - call write_vardata(dset, varname, cvalues_4d) - else if (dsetin%variables(nvar)%ndims == 5) then - call read_vardata(dsetin, varname, cvalues_5d) - call write_vardata(dset, varname, cvalues_5d) - endif - else - print *,'not copying variable ',trim(adjustl(varname)),& - ' (unsupported data type or rank)' - endif - enddo - end function create_dataset - - subroutine close_dataset(dset,errcode) - ! close netcdf file, deallocate members of dataset object. - ! if optional error return code errcode is not specified, - ! program will stop if a nonzero error code returned by the netcdf lib. - type(Dataset), intent(inout) :: dset - integer, intent(out), optional :: errcode - integer ncerr, nvar - logical return_errcode - if(present(errcode)) then - return_errcode=.true. - errcode = 0 - else - return_errcode=.false. - endif - ncerr = nf90_close(ncid=dset%ncid) - if (return_errcode) then - errcode=ncerr - call nccheck(ncerr,halt=.false.) - if (ncerr /= 0) return - else - call nccheck(ncerr) - endif - do nvar=1,dset%nvars - deallocate(dset%variables(nvar)%dimids) - deallocate(dset%variables(nvar)%dimindxs) - deallocate(dset%variables(nvar)%dimlens) - deallocate(dset%variables(nvar)%chunksizes) - deallocate(dset%variables(nvar)%dimnames) - enddo - deallocate(dset%variables,dset%dimensions) - end subroutine close_dataset - - !subroutine read_vardata(dset,varname,values,nslice,slicedim,errcode) - ! read data from variable varname in dataset dset, return in it array values. - ! dset: Input dataset instance returned by open_dataset/create_dataset. - ! varname: Input string name of variable. - ! values: Array to hold variable data. Must be - ! an allocatable array with same rank - ! as variable varname (or 1 dimension less). - ! nslice: optional index along dimension slicedim - ! slicedim: optional, if nslice is set, index of which dimension to slice with - ! nslice, default is ndims - ! ncstart: optional, if ncstart and nccount are set, manually specify the - ! start and count of netCDF read - ! nccount: optional, if ncstart and nccount are set, manually specify the - ! start and count of netCDF read - ! errcode: optional error return code. If not specified, - ! program will stop if a nonzero error code returned - ! from netcdf library. - - !subroutine write_vardata(dset,varname,values,nslice,slicedim,errcode) - ! write data (in array values) to variable varname in dataset dset. - ! dset: Input dataset instance returned by open_dataset/create_dataset. - ! varname: Input string name of variable. - ! values: Array with variable data. Must be - ! an allocatable array with same rank - ! as variable varname (or 1 dimension less). - ! nslice: optional index along dimension slicedim - ! slicedim: optional, if nslice is set, index of which dimension to slice with - ! nslice, default is ndims - ! ncstart: optional, if ncstart and nccount are set, manually specify the - ! start and count of netCDF write - ! nccount: optional, if ncstart and nccount are set, manually specify the - ! start and count of netCDF write - ! errcode: optional error return code. If not specified, - ! program will stop if a nonzero error code returned - ! from netcdf library. - - !subroutine read_attribute(dset, attname, values, varname, errcode) - ! read attribute 'attname' return in 'values'. If optional - ! argument 'varname' is given, a variable attribute is returned. - ! if the attribute is a 1d array, values should be an allocatable 1d - ! array of the correct type. - - !subroutine write_attribute(dset, attname, values, varname, errcode) - ! write attribute 'attname' with data in 'values'. If optional - ! argument 'varname' is given, a variable attribute is written. - ! values can be a real(4), real(8), integer, string or 1d array. - - subroutine read_vardata_1d_r4(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - real(4), allocatable, dimension(:), intent(inout) :: values - include "read_vardata_code_1d.f90" - end subroutine read_vardata_1d_r4 - - subroutine read_vardata_2d_r4(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - real(4), allocatable, dimension(:,:), intent(inout) :: values - include "read_vardata_code_2d.f90" - end subroutine read_vardata_2d_r4 - - subroutine read_vardata_3d_r4(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - real(4), allocatable, dimension(:,:,:), intent(inout) :: values - include "read_vardata_code_3d.f90" - end subroutine read_vardata_3d_r4 - - subroutine read_vardata_4d_r4(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - real(4), allocatable, dimension(:,:,:,:), intent(inout) :: values - include "read_vardata_code_4d.f90" - end subroutine read_vardata_4d_r4 - - subroutine read_vardata_5d_r4(dset, varname, values, errcode) - real(4), allocatable, dimension(:,:,:,:,:), intent(inout) :: values - include "read_vardata_code_5d.f90" - end subroutine read_vardata_5d_r4 - - subroutine read_vardata_1d_r8(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - real(8), allocatable, dimension(:), intent(inout) :: values - include "read_vardata_code_1d.f90" - end subroutine read_vardata_1d_r8 - - subroutine read_vardata_2d_r8(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - real(8), allocatable, dimension(:,:), intent(inout) :: values - include "read_vardata_code_2d.f90" - end subroutine read_vardata_2d_r8 - - subroutine read_vardata_3d_r8(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - real(8), allocatable, dimension(:,:,:), intent(inout) :: values - include "read_vardata_code_3d.f90" - end subroutine read_vardata_3d_r8 - - subroutine read_vardata_4d_r8(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - real(8), allocatable, dimension(:,:,:,:), intent(inout) :: values - include "read_vardata_code_4d.f90" - end subroutine read_vardata_4d_r8 - - subroutine read_vardata_5d_r8(dset, varname, values, errcode) - real(8), allocatable, dimension(:,:,:,:,:), intent(inout) :: values - include "read_vardata_code_5d.f90" - end subroutine read_vardata_5d_r8 - - subroutine read_vardata_1d_int(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer, allocatable, dimension(:), intent(inout) :: values - include "read_vardata_code_1d.f90" - end subroutine read_vardata_1d_int - - subroutine read_vardata_2d_int(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer, allocatable, dimension(:,:), intent(inout) :: values - include "read_vardata_code_2d.f90" - end subroutine read_vardata_2d_int - - subroutine read_vardata_3d_int(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer, allocatable, dimension(:,:,:), intent(inout) :: values - include "read_vardata_code_3d.f90" - end subroutine read_vardata_3d_int - - subroutine read_vardata_4d_int(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer, allocatable, dimension(:,:,:,:), intent(inout) :: values - include "read_vardata_code_4d.f90" - end subroutine read_vardata_4d_int - - subroutine read_vardata_5d_int(dset, varname, values, errcode) - integer, allocatable, dimension(:,:,:,:,:), intent(inout) :: values - include "read_vardata_code_5d.f90" - end subroutine read_vardata_5d_int - - subroutine read_vardata_1d_short(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer(2), allocatable, dimension(:), intent(inout) :: values - include "read_vardata_code_1d.f90" - end subroutine read_vardata_1d_short - - subroutine read_vardata_2d_short(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer(2), allocatable, dimension(:,:), intent(inout) :: values - include "read_vardata_code_2d.f90" - end subroutine read_vardata_2d_short - - subroutine read_vardata_3d_short(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer(2), allocatable, dimension(:,:,:), intent(inout) :: values - include "read_vardata_code_3d.f90" - end subroutine read_vardata_3d_short - - subroutine read_vardata_4d_short(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer(2), allocatable, dimension(:,:,:,:), intent(inout) :: values - include "read_vardata_code_4d.f90" - end subroutine read_vardata_4d_short - - subroutine read_vardata_5d_short(dset, varname, values, errcode) - integer(2), allocatable, dimension(:,:,:,:,:), intent(inout) :: values - include "read_vardata_code_5d.f90" - end subroutine read_vardata_5d_short - - subroutine read_vardata_1d_byte(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer(1), allocatable, dimension(:), intent(inout) :: values - include "read_vardata_code_1d.f90" - end subroutine read_vardata_1d_byte - - subroutine read_vardata_2d_byte(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer(1), allocatable, dimension(:,:), intent(inout) :: values - include "read_vardata_code_2d.f90" - end subroutine read_vardata_2d_byte - - subroutine read_vardata_3d_byte(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer(1), allocatable, dimension(:,:,:), intent(inout) :: values - include "read_vardata_code_3d.f90" - end subroutine read_vardata_3d_byte - - subroutine read_vardata_4d_byte(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer(1), allocatable, dimension(:,:,:,:), intent(inout) :: values - include "read_vardata_code_4d.f90" - end subroutine read_vardata_4d_byte - - subroutine read_vardata_5d_byte(dset, varname, values, errcode) - integer(1), allocatable, dimension(:,:,:,:,:), intent(inout) :: values - include "read_vardata_code_5d.f90" - end subroutine read_vardata_5d_byte - - subroutine read_vardata_1d_char(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - character, allocatable, dimension(:), intent(inout) :: values - include "read_vardata_code_1d.f90" - end subroutine read_vardata_1d_char - - subroutine read_vardata_2d_char(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - character, allocatable, dimension(:,:), intent(inout) :: values - include "read_vardata_code_2d.f90" - end subroutine read_vardata_2d_char - - subroutine read_vardata_3d_char(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - character, allocatable, dimension(:,:,:), intent(inout) :: values - include "read_vardata_code_3d.f90" - end subroutine read_vardata_3d_char - - subroutine read_vardata_4d_char(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - character, allocatable, dimension(:,:,:,:), intent(inout) :: values - include "read_vardata_code_4d.f90" - end subroutine read_vardata_4d_char - - subroutine read_vardata_5d_char(dset, varname, values, errcode) - character, allocatable, dimension(:,:,:,:,:), intent(inout) :: values - include "read_vardata_code_5d.f90" - end subroutine read_vardata_5d_char - - subroutine write_vardata_1d_r4(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - real(4), dimension(:), intent(in) :: values - integer, intent(in), optional :: ncstart(1) - integer, intent(in), optional :: nccount(1) - include "write_vardata_code.f90" - end subroutine write_vardata_1d_r4 - - subroutine write_vardata_2d_r4(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - real(4), dimension(:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(2) - integer, intent(in), optional :: nccount(2) - include "write_vardata_code.f90" - end subroutine write_vardata_2d_r4 - - subroutine write_vardata_3d_r4(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - real(4), dimension(:,:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(3) - integer, intent(in), optional :: nccount(3) - include "write_vardata_code.f90" - end subroutine write_vardata_3d_r4 - - subroutine write_vardata_4d_r4(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - real(4), dimension(:,:,:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(4) - integer, intent(in), optional :: nccount(4) - include "write_vardata_code.f90" - end subroutine write_vardata_4d_r4 - - subroutine write_vardata_5d_r4(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - real(4), dimension(:,:,:,:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(5) - integer, intent(in), optional :: nccount(5) - include "write_vardata_code.f90" - end subroutine write_vardata_5d_r4 - - subroutine write_vardata_1d_r8(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - real(8), dimension(:), intent(in) :: values - integer, intent(in), optional :: ncstart(1) - integer, intent(in), optional :: nccount(1) - include "write_vardata_code.f90" - end subroutine write_vardata_1d_r8 - - subroutine write_vardata_2d_r8(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - real(8), dimension(:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(2) - integer, intent(in), optional :: nccount(2) - include "write_vardata_code.f90" - end subroutine write_vardata_2d_r8 - - subroutine write_vardata_3d_r8(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - real(8), dimension(:,:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(3) - integer, intent(in), optional :: nccount(3) - include "write_vardata_code.f90" - end subroutine write_vardata_3d_r8 - - subroutine write_vardata_4d_r8(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - real(8), dimension(:,:,:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(4) - integer, intent(in), optional :: nccount(4) - include "write_vardata_code.f90" - end subroutine write_vardata_4d_r8 - - subroutine write_vardata_5d_r8(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - real(8), dimension(:,:,:,:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(5) - integer, intent(in), optional :: nccount(5) - include "write_vardata_code.f90" - end subroutine write_vardata_5d_r8 - - subroutine write_vardata_1d_int(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer, dimension(:), intent(in) :: values - integer, intent(in), optional :: ncstart(1) - integer, intent(in), optional :: nccount(1) - include "write_vardata_code.f90" - end subroutine write_vardata_1d_int - - subroutine write_vardata_2d_int(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer, dimension(:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(2) - integer, intent(in), optional :: nccount(2) - include "write_vardata_code.f90" - end subroutine write_vardata_2d_int - - subroutine write_vardata_3d_int(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer, dimension(:,:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(3) - integer, intent(in), optional :: nccount(3) - include "write_vardata_code.f90" - end subroutine write_vardata_3d_int - - subroutine write_vardata_4d_int(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer, dimension(:,:,:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(4) - integer, intent(in), optional :: nccount(4) - include "write_vardata_code.f90" - end subroutine write_vardata_4d_int - - subroutine write_vardata_5d_int(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer, dimension(:,:,:,:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(5) - integer, intent(in), optional :: nccount(5) - include "write_vardata_code.f90" - end subroutine write_vardata_5d_int - - subroutine write_vardata_1d_short(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer(2), dimension(:), intent(in) :: values - integer, intent(in), optional :: ncstart(1) - integer, intent(in), optional :: nccount(1) - include "write_vardata_code.f90" - end subroutine write_vardata_1d_short - - subroutine write_vardata_2d_short(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer(2), dimension(:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(2) - integer, intent(in), optional :: nccount(2) - include "write_vardata_code.f90" - end subroutine write_vardata_2d_short - - subroutine write_vardata_3d_short(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer(2), dimension(:,:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(3) - integer, intent(in), optional :: nccount(3) - include "write_vardata_code.f90" - end subroutine write_vardata_3d_short - - subroutine write_vardata_4d_short(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer(2), dimension(:,:,:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(4) - integer, intent(in), optional :: nccount(4) - include "write_vardata_code.f90" - end subroutine write_vardata_4d_short - - subroutine write_vardata_5d_short(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer(2), dimension(:,:,:,:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(5) - integer, intent(in), optional :: nccount(5) - include "write_vardata_code.f90" - end subroutine write_vardata_5d_short - - subroutine write_vardata_1d_byte(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer(1), dimension(:), intent(in) :: values - integer, intent(in), optional :: ncstart(1) - integer, intent(in), optional :: nccount(1) - include "write_vardata_code.f90" - end subroutine write_vardata_1d_byte - - subroutine write_vardata_2d_byte(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer(1), dimension(:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(2) - integer, intent(in), optional :: nccount(2) - include "write_vardata_code.f90" - end subroutine write_vardata_2d_byte - - subroutine write_vardata_3d_byte(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer(1), dimension(:,:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(3) - integer, intent(in), optional :: nccount(3) - include "write_vardata_code.f90" - end subroutine write_vardata_3d_byte - - subroutine write_vardata_4d_byte(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer(1), dimension(:,:,:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(4) - integer, intent(in), optional :: nccount(4) - include "write_vardata_code.f90" - end subroutine write_vardata_4d_byte - - subroutine write_vardata_5d_byte(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - integer(1), dimension(:,:,:,:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(5) - integer, intent(in), optional :: nccount(5) - include "write_vardata_code.f90" - end subroutine write_vardata_5d_byte - - subroutine write_vardata_1d_char(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - character, dimension(:), intent(in) :: values - integer, intent(in), optional :: ncstart(1) - integer, intent(in), optional :: nccount(1) - include "write_vardata_code.f90" - end subroutine write_vardata_1d_char - - subroutine write_vardata_2d_char(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - character, dimension(:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(2) - integer, intent(in), optional :: nccount(2) - include "write_vardata_code.f90" - end subroutine write_vardata_2d_char - - subroutine write_vardata_3d_char(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - character, dimension(:,:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(3) - integer, intent(in), optional :: nccount(3) - include "write_vardata_code.f90" - end subroutine write_vardata_3d_char - - subroutine write_vardata_4d_char(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - character, dimension(:,:,:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(4) - integer, intent(in), optional :: nccount(4) - include "write_vardata_code.f90" - end subroutine write_vardata_4d_char - - subroutine write_vardata_5d_char(dset, varname, values, nslice, slicedim, ncstart, nccount, errcode) - character, dimension(:,:,:,:,:), intent(in) :: values - integer, intent(in), optional :: ncstart(5) - integer, intent(in), optional :: nccount(5) - include "write_vardata_code.f90" - end subroutine write_vardata_5d_char - - subroutine read_attribute_int_scalar(dset, attname, values, varname, errcode) - integer, intent(inout) :: values - include "read_scalar_attribute_code.f90" - end subroutine read_attribute_int_scalar - - subroutine read_attribute_short_scalar(dset, attname, values, varname, errcode) - integer(2), intent(inout) :: values - include "read_scalar_attribute_code.f90" - end subroutine read_attribute_short_scalar - - subroutine read_attribute_byte_scalar(dset, attname, values, varname, errcode) - integer(1), intent(inout) :: values - include "read_scalar_attribute_code.f90" - end subroutine read_attribute_byte_scalar - - subroutine read_attribute_r4_scalar(dset, attname, values, varname, errcode) - real(4), intent(inout) :: values - include "read_scalar_attribute_code.f90" - end subroutine read_attribute_r4_scalar - - subroutine read_attribute_r8_scalar(dset, attname, values, varname, errcode) - real(8), intent(inout) :: values - include "read_scalar_attribute_code.f90" - end subroutine read_attribute_r8_scalar - - subroutine read_attribute_r4_1d(dset, attname, values, varname, errcode) - real(4), intent(inout), allocatable, dimension(:) :: values - include "read_attribute_code.f90" - end subroutine read_attribute_r4_1d - - subroutine read_attribute_r8_1d(dset, attname, values, varname, errcode) - real(8), intent(inout), allocatable, dimension(:) :: values - include "read_attribute_code.f90" - end subroutine read_attribute_r8_1d - - subroutine read_attribute_int_1d(dset, attname, values, varname, errcode) - integer, intent(inout), allocatable, dimension(:) :: values - include "read_attribute_code.f90" - end subroutine read_attribute_int_1d - - subroutine read_attribute_short_1d(dset, attname, values, varname, errcode) - integer(2), intent(inout), allocatable, dimension(:) :: values - include "read_attribute_code.f90" - end subroutine read_attribute_short_1d - - subroutine read_attribute_byte_1d(dset, attname, values, varname, errcode) - integer(1), intent(inout), allocatable, dimension(:) :: values - include "read_attribute_code.f90" - end subroutine read_attribute_byte_1d - - subroutine read_attribute_char(dset, attname, values, varname, errcode) - character(len=*), intent(inout) :: values - include "read_scalar_attribute_code.f90" - end subroutine read_attribute_char - - subroutine write_attribute_int_scalar(dset, attname, values, varname, errcode) - integer, intent(in) :: values - include "write_attribute_code.f90" - end subroutine write_attribute_int_scalar - - subroutine write_attribute_short_scalar(dset, attname, values, varname, errcode) - integer(2), intent(in) :: values - include "write_attribute_code.f90" - end subroutine write_attribute_short_scalar - - subroutine write_attribute_byte_scalar(dset, attname, values, varname, errcode) - integer(1), intent(in) :: values - include "write_attribute_code.f90" - end subroutine write_attribute_byte_scalar - - subroutine write_attribute_r4_scalar(dset, attname, values, varname, errcode) - real(4), intent(in) :: values - include "write_attribute_code.f90" - end subroutine write_attribute_r4_scalar - - subroutine write_attribute_r8_scalar(dset, attname, values, varname, errcode) - real(8), intent(in) :: values - include "write_attribute_code.f90" - end subroutine write_attribute_r8_scalar - - subroutine write_attribute_r4_1d(dset, attname, values, varname, errcode) - real(4), intent(in), allocatable, dimension(:) :: values - include "write_attribute_code.f90" - end subroutine write_attribute_r4_1d - - subroutine write_attribute_r8_1d(dset, attname, values, varname, errcode) - real(8), intent(in), allocatable, dimension(:) :: values - include "write_attribute_code.f90" - end subroutine write_attribute_r8_1d - - subroutine write_attribute_int_1d(dset, attname, values, varname, errcode) - integer, intent(in), allocatable, dimension(:) :: values - include "write_attribute_code.f90" - end subroutine write_attribute_int_1d - - subroutine write_attribute_short_1d(dset, attname, values, varname, errcode) - integer(2), intent(in), allocatable, dimension(:) :: values - include "write_attribute_code.f90" - end subroutine write_attribute_short_1d - - subroutine write_attribute_byte_1d(dset, attname, values, varname, errcode) - integer(1), intent(in), allocatable, dimension(:) :: values - include "write_attribute_code.f90" - end subroutine write_attribute_byte_1d - - subroutine write_attribute_char(dset, attname, values, varname, errcode) - character(len=*), intent(in) :: values - include "write_attribute_code.f90" - end subroutine write_attribute_char - - function get_idate_from_time_units(dset) result(idate) - ! return integer array with year,month,day,hour,minute,second - ! parsed from time units attribute. - type(Dataset), intent(in) :: dset - integer idate(6) - character(len=nf90_max_name) :: time_units - integer ipos1,ipos2 - call read_attribute(dset, 'units', time_units, 'time') - ipos1 = scan(time_units,"since",back=.true.)+1 - ipos2 = scan(time_units,"-",back=.false.)-1 - read(time_units(ipos1:ipos2),*) idate(1) - ipos1 = ipos2+2; ipos2=ipos1+1 - read(time_units(ipos1:ipos2),*) idate(2) - ipos1 = ipos2+2; ipos2=ipos1+1 - read(time_units(ipos1:ipos2),*) idate(3) - ipos1 = scan(time_units,":")-2 - ipos2 = ipos1+1 - read(time_units(ipos1:ipos2),*) idate(4) - ipos1 = ipos2+2 - ipos2 = ipos1+1 - read(time_units(ipos1:ipos2),*) idate(5) - ipos1 = ipos2+2 - ipos2 = ipos1+1 - read(time_units(ipos1:ipos2),*) idate(6) - end function get_idate_from_time_units - - function get_time_units_from_idate(idate, time_measure) result(time_units) - ! create time units attribute of form 'hours since YYYY-MM-DD HH:MM:SS' - ! from integer array with year,month,day,hour,minute,second - ! optional argument 'time_measure' can be used to change 'hours' to - ! 'days', 'minutes', 'seconds' etc. - character(len=*), intent(in), optional :: time_measure - integer, intent(in) :: idate(6) - character(len=12) :: timechar - character(len=nf90_max_name) :: time_units - if (present(time_measure)) then - timechar = trim(time_measure) - else - timechar = 'hours' - endif - write(time_units,101) idate -101 format(' since ',i4.4,'-',i2.2,'-',i2.2,' ',& - i2.2,':',i2.2,':',i2.2) - time_units = trim(adjustl(timechar))//time_units - end function get_time_units_from_idate - - subroutine quantize_data_2d(dataIn, dataOut, nbits, compress_err) - real(4), intent(in) :: dataIn(:,:) - real(4), intent(out) :: dataOut(:,:) - include "quantize_data_code.f90" - end subroutine quantize_data_2d - - subroutine quantize_data_3d(dataIn, dataOut, nbits, compress_err) - real(4), intent(in) :: dataIn(:,:,:) - real(4), intent(out) :: dataOut(:,:,:) - include "quantize_data_code.f90" - end subroutine quantize_data_3d - - subroutine quantize_data_4d(dataIn, dataOut, nbits, compress_err) - real(4), intent(in) :: dataIn(:,:,:,:) - real(4), intent(out) :: dataOut(:,:,:,:) - include "quantize_data_code.f90" - end subroutine quantize_data_4d - -end module module_fv3gfs_ncio diff --git a/src/fv3gfs_ncio/quantize_data_code.f90 b/src/fv3gfs_ncio/quantize_data_code.f90 deleted file mode 100644 index ece0f77463..0000000000 --- a/src/fv3gfs_ncio/quantize_data_code.f90 +++ /dev/null @@ -1,17 +0,0 @@ - integer, intent(in) :: nbits - real(4), intent(out) :: compress_err - real(4) dataMin, dataMax, scale_fact, offset - ! if nbits not between 1 and 31, don't do anything - if (nbits <= 0 .or. nbits > 31) then - dataOut = dataIn - compress_err = 0.0 - return - endif - dataMax = maxval(dataIn); dataMin = minval(dataIn) - ! convert data to 32 bit integers in range 0 to 2**nbits-1, then cast - ! cast back to 32 bit floats (data is then quantized in steps - ! proportional to 2**nbits so last 32-nbits in floating - ! point representation should be zero for efficient zlib compression). - scale_fact = (dataMax - dataMin) / (2**nbits-1); offset = dataMin - dataOut = scale_fact*(nint((dataIn - offset) / scale_fact)) + offset - compress_err = maxval(abs(dataIn-dataOut)) diff --git a/src/fv3gfs_ncio/read_attribute_code.f90 b/src/fv3gfs_ncio/read_attribute_code.f90 deleted file mode 100644 index 6a0bcffcd5..0000000000 --- a/src/fv3gfs_ncio/read_attribute_code.f90 +++ /dev/null @@ -1,35 +0,0 @@ - type(Dataset), intent(in) :: dset - character(len=*), intent(in), optional :: varname - character(len=*), intent(in) :: attname - integer, intent(out), optional :: errcode - integer ncerr, varid, nvar, nlen - logical return_errcode - if(present(errcode)) then - return_errcode=.true. - errcode = 0 - else - return_errcode=.false. - endif - if(present(varname))then - nvar = get_nvar(dset,varname) - varid = dset%variables(nvar)%varid - else - varid = NF90_GLOBAL - endif - ncerr = nf90_inquire_attribute(dset%ncid, varid, attname, len=nlen) - if (return_errcode) then - call nccheck(ncerr,halt=.false.) - errcode=ncerr - if (ncerr /= 0) return - else - call nccheck(ncerr) - endif - if (allocated(values)) deallocate(values) - allocate(values(nlen)) - ncerr = nf90_get_att(dset%ncid, varid, trim(attname), values) - if (return_errcode) then - call nccheck(ncerr,halt=.false.) - errcode=ncerr - else - call nccheck(ncerr) - endif diff --git a/src/fv3gfs_ncio/read_scalar_attribute_code.f90 b/src/fv3gfs_ncio/read_scalar_attribute_code.f90 deleted file mode 100644 index 2b8c6ce046..0000000000 --- a/src/fv3gfs_ncio/read_scalar_attribute_code.f90 +++ /dev/null @@ -1,31 +0,0 @@ - ! read attribute 'attname' return in 'values'. If optional - ! argument 'varname' is given, an variable attribute is returned. - ! if the attribute is an 1d array, values should be an allocatable 1d - ! array of the correct type. if values is allocated, it be deallocated - ! and reallocated. - type(Dataset), intent(in) :: dset - character(len=*), intent(in), optional :: varname - integer, intent(out), optional :: errcode - character(len=*), intent(in) :: attname - integer ncerr, varid, nvar - logical return_errcode - if(present(errcode)) then - return_errcode=.true. - errcode = 0 - else - return_errcode=.false. - endif - if(present(varname))then - nvar = get_nvar(dset,varname) - varid = dset%variables(nvar)%varid - else - varid = NF90_GLOBAL - endif - ncerr = nf90_get_att(dset%ncid, varid, trim(attname), values) - if (return_errcode) then - call nccheck(ncerr,halt=.false.) - errcode=ncerr - return - else - call nccheck(ncerr) - endif diff --git a/src/fv3gfs_ncio/read_vardata_code_1d.f90 b/src/fv3gfs_ncio/read_vardata_code_1d.f90 deleted file mode 100644 index 1a92b7fc16..0000000000 --- a/src/fv3gfs_ncio/read_vardata_code_1d.f90 +++ /dev/null @@ -1,75 +0,0 @@ - type(Dataset), intent(in) :: dset - character(len=*), intent(in) :: varname - integer, intent(in), optional :: nslice - integer, intent(in), optional :: slicedim - integer, intent(in), optional :: ncstart(1) - integer, intent(in), optional :: nccount(1) - integer, intent(out), optional :: errcode - integer ncerr, nvar, n, nd, dimlen, ncount - integer, allocatable, dimension(:) :: start, count - logical return_errcode - if(present(errcode)) then - return_errcode=.true. - errcode = 0 - else - return_errcode=.false. - endif - if (present(nslice)) then - ncount = nslice - else - ncount = 1 - endif - nvar = get_nvar(dset,varname) - allocate(start(dset%variables(nvar)%ndims),count(dset%variables(nvar)%ndims)) - start(:) = 1 - count(:) = 1 - if (present(slicedim)) then - nd = slicedim - else - nd = dset%variables(nvar)%ndims - end if - do n=1,dset%variables(nvar)%ndims - if (n == nd) then - start(n) = ncount - count(n) = 1 - else - start(n) = 1 - count(n) = dset%variables(nvar)%dimlens(n) - dimlen = dset%variables(nvar)%dimlens(n) - end if - end do - if (dset%variables(nvar)%ndims /= 1 .and. dset%variables(nvar)%ndims /= 2) then - if (return_errcode) then - call nccheck(ncerr,halt=.false.) - errcode=nf90_ebaddim - return - else - print *,'rank of data array != variable ndims (or ndims-1)' - stop 99 - endif - endif - if (allocated(values)) deallocate(values) - if (present(ncstart) .and. present(nccount)) then - allocate(values(nccount(1))) - start(1)=ncstart(1); count(1)=nccount(1) - if (dset%variables(nvar)%ndims == 2) then - start(2)=1; count(2)=1 - end if - ncerr = nf90_get_var(dset%ncid, dset%variables(nvar)%varid, values,& - start=start, count=count) - else - if (dset%variables(nvar)%ndims == 2) then - allocate(values(dimlen)) - ncerr = nf90_get_var(dset%ncid, dset%variables(nvar)%varid, values,& - start=start, count=count) - else - allocate(values(dset%variables(nvar)%dimlens(1))) - ncerr = nf90_get_var(dset%ncid, dset%variables(nvar)%varid, values) - end if - end if - if (return_errcode) then - call nccheck(ncerr,halt=.false.) - errcode=ncerr - else - call nccheck(ncerr) - endif diff --git a/src/fv3gfs_ncio/read_vardata_code_2d.f90 b/src/fv3gfs_ncio/read_vardata_code_2d.f90 deleted file mode 100644 index c0e62a6abb..0000000000 --- a/src/fv3gfs_ncio/read_vardata_code_2d.f90 +++ /dev/null @@ -1,81 +0,0 @@ - type(Dataset), intent(in) :: dset - character(len=*), intent(in) :: varname - integer, intent(in), optional :: nslice - integer, intent(in), optional :: slicedim - integer, intent(in), optional :: ncstart(2) - integer, intent(in), optional :: nccount(2) - integer, intent(out), optional :: errcode - integer ncerr, nvar, n, nd, ndim, ncount - integer, allocatable, dimension(:) :: start, count - integer :: dimlens(2) - logical return_errcode - if(present(errcode)) then - return_errcode=.true. - errcode = 0 - else - return_errcode=.false. - endif - if (present(nslice)) then - ncount = nslice - else - ncount = 1 - endif - nvar = get_nvar(dset,varname) - allocate(start(dset%variables(nvar)%ndims),count(dset%variables(nvar)%ndims)) - start(:) = 1 - count(:) = 1 - dimlens(:) = 1 - if (present(slicedim)) then - nd = slicedim - else - nd = dset%variables(nvar)%ndims - end if - ndim = 1 - do n=1,dset%variables(nvar)%ndims - if (n == nd) then - start(n) = ncount - count(n) = 1 - else - start(n) = 1 - count(n) = dset%variables(nvar)%dimlens(n) - dimlens(ndim) = dset%variables(nvar)%dimlens(n) - ndim = ndim + 1 - end if - end do - - if (dset%variables(nvar)%ndims /= 2 .and. dset%variables(nvar)%ndims /= 3) then - if (return_errcode) then - call nccheck(ncerr,halt=.false.) - errcode=nf90_ebaddim - return - else - print *,'rank of data array != variable ndims (or ndims-1)' - stop 99 - endif - endif - if (allocated(values)) deallocate(values) - if (present(ncstart) .and. present(nccount)) then - allocate(values(nccount(1),nccount(2))) - start(1)=ncstart(1); count(1)=nccount(1) - start(2)=ncstart(2); count(2)=nccount(2) - if (dset%variables(nvar)%ndims == 3) then - start(3)=1; count(3)=1 - end if - ncerr = nf90_get_var(dset%ncid, dset%variables(nvar)%varid, values,& - start=start, count=count) - else - if (dset%variables(nvar)%ndims == 3) then - allocate(values(dimlens(1),dimlens(2))) - ncerr = nf90_get_var(dset%ncid, dset%variables(nvar)%varid, values,& - start=start, count=count) - else - allocate(values(dset%variables(nvar)%dimlens(1),dset%variables(nvar)%dimlens(2))) - ncerr = nf90_get_var(dset%ncid, dset%variables(nvar)%varid, values) - end if - end if - if (return_errcode) then - call nccheck(ncerr,halt=.false.) - errcode=ncerr - else - call nccheck(ncerr) - endif diff --git a/src/fv3gfs_ncio/read_vardata_code_3d.f90 b/src/fv3gfs_ncio/read_vardata_code_3d.f90 deleted file mode 100644 index cc426b2361..0000000000 --- a/src/fv3gfs_ncio/read_vardata_code_3d.f90 +++ /dev/null @@ -1,85 +0,0 @@ - type(Dataset), intent(in) :: dset - character(len=*), intent(in) :: varname - integer, intent(in), optional :: nslice - integer, intent(in), optional :: slicedim - integer, intent(in), optional :: ncstart(3) - integer, intent(in), optional :: nccount(3) - integer, intent(out), optional :: errcode - integer ncerr, nvar, n, nd, ndim, ncount - integer, allocatable, dimension(:) :: start, count - integer :: dimlens(3) - logical return_errcode - if(present(errcode)) then - return_errcode=.true. - errcode = 0 - else - return_errcode=.false. - endif - if (present(nslice)) then - ncount = nslice - else - ncount = 1 - endif - nvar = get_nvar(dset,varname) - allocate(start(dset%variables(nvar)%ndims),count(dset%variables(nvar)%ndims)) - start(:) = 1 - count(:) = 1 - dimlens(:) = 1 - if (present(slicedim)) then - nd = slicedim - else - nd = dset%variables(nvar)%ndims - end if - ndim = 1 - do n=1,dset%variables(nvar)%ndims - if (n == nd) then - start(n) = ncount - count(n) = 1 - else - start(n) = 1 - count(n) = dset%variables(nvar)%dimlens(n) - dimlens(ndim) = dset%variables(nvar)%dimlens(n) - ndim = ndim + 1 - end if - end do - - if (dset%variables(nvar)%ndims /= 3 .and. dset%variables(nvar)%ndims /= 4) then - if (return_errcode) then - call nccheck(ncerr,halt=.false.) - errcode=nf90_ebaddim - return - else - print *,'rank of data array != variable ndims (or ndims-1)' - stop 99 - endif - endif - - if (allocated(values)) deallocate(values) - if (present(ncstart) .and. present(nccount)) then - allocate(values(nccount(1),nccount(2),nccount(3))) - start(1)=ncstart(1); count(1)=nccount(1) - start(2)=ncstart(2); count(2)=nccount(2) - start(3)=ncstart(3); count(3)=nccount(3) - if (dset%variables(nvar)%ndims == 4) then - start(4)=1; count(4)=1 - end if - ncerr = nf90_get_var(dset%ncid, dset%variables(nvar)%varid, values,& - start=start, count=count) - else - if (dset%variables(nvar)%ndims == 4) then - allocate(values(dimlens(1),dimlens(2),dimlens(3))) - ncerr = nf90_get_var(dset%ncid, dset%variables(nvar)%varid, values,& - start=start, count=count) - else - allocate(values(dset%variables(nvar)%dimlens(1),& - dset%variables(nvar)%dimlens(2),& - dset%variables(nvar)%dimlens(3))) - ncerr = nf90_get_var(dset%ncid, dset%variables(nvar)%varid, values) - end if - end if - if (return_errcode) then - call nccheck(ncerr,halt=.false.) - errcode=ncerr - else - call nccheck(ncerr) - endif diff --git a/src/fv3gfs_ncio/read_vardata_code_4d.f90 b/src/fv3gfs_ncio/read_vardata_code_4d.f90 deleted file mode 100644 index fd3dd42153..0000000000 --- a/src/fv3gfs_ncio/read_vardata_code_4d.f90 +++ /dev/null @@ -1,83 +0,0 @@ - type(Dataset), intent(in) :: dset - character(len=*), intent(in) :: varname - integer, intent(in), optional :: nslice - integer, intent(in), optional :: slicedim - integer, intent(in), optional :: ncstart(4) - integer, intent(in), optional :: nccount(4) - integer, intent(out), optional :: errcode - integer ncerr, nvar, n, nd, ndim, ncount - integer, allocatable, dimension(:) :: start, count - integer :: dimlens(4) - logical return_errcode - if(present(errcode)) then - return_errcode=.true. - errcode = 0 - else - return_errcode=.false. - endif - if (present(nslice)) then - ncount = nslice - else - ncount = 1 - endif - nvar = get_nvar(dset,varname) - allocate(start(dset%variables(nvar)%ndims),count(dset%variables(nvar)%ndims)) - start(:) = 1 - count(:) = 1 - dimlens(:) = 1 - if (present(slicedim)) then - nd = slicedim - else - nd = dset%variables(nvar)%ndims - end if - ndim = 1 - do n=1,dset%variables(nvar)%ndims - if (n == nd) then - start(n) = ncount - count(n) = 1 - else - start(n) = 1 - count(n) = dset%variables(nvar)%dimlens(n) - dimlens(ndim) = dset%variables(nvar)%dimlens(n) - ndim = ndim + 1 - end if - end do - - if (dset%variables(nvar)%ndims /= 4 .and. dset%variables(nvar)%ndims /= 5) then - if (return_errcode) then - call nccheck(ncerr,halt=.false.) - errcode=nf90_ebaddim - return - else - print *,'rank of data array != variable ndims (or ndims-1)' - stop 99 - endif - endif - - if (allocated(values)) deallocate(values) - if (present(ncstart) .and. present(nccount)) then - allocate(values(nccount(1),nccount(2),nccount(3),nccount(4))) - start(1)=ncstart(1); count(1)=nccount(1) - start(2)=ncstart(2); count(2)=nccount(2) - start(3)=ncstart(3); count(3)=nccount(3) - start(4)=ncstart(4); count(4)=nccount(4) - if (dset%variables(nvar)%ndims == 5) then - start(5)=1; count(5)=1 - end if - ncerr = nf90_get_var(dset%ncid, dset%variables(nvar)%varid, values,& - start=start, count=count) - else - allocate(values(dimlens(1),dimlens(2),dimlens(3),dimlens(4))) - if (dset%variables(nvar)%ndims == 5) then - ncerr = nf90_get_var(dset%ncid, dset%variables(nvar)%varid, values,& - start=start, count=count) - else - ncerr = nf90_get_var(dset%ncid, dset%variables(nvar)%varid, values) - end if - end if - if (return_errcode) then - call nccheck(ncerr,halt=.false.) - errcode=ncerr - else - call nccheck(ncerr) - endif diff --git a/src/fv3gfs_ncio/read_vardata_code_5d.f90 b/src/fv3gfs_ncio/read_vardata_code_5d.f90 deleted file mode 100644 index ea9bd2e2cf..0000000000 --- a/src/fv3gfs_ncio/read_vardata_code_5d.f90 +++ /dev/null @@ -1,35 +0,0 @@ - type(Dataset), intent(in) :: dset - character(len=*), intent(in) :: varname - integer, intent(out), optional :: errcode - integer ncerr, nvar, n1,n2,n3,n4,n5 - logical return_errcode - if(present(errcode)) then - return_errcode=.true. - errcode = 0 - else - return_errcode=.false. - endif - nvar = get_nvar(dset,varname) - if (dset%variables(nvar)%ndims /= 5) then - if (return_errcode) then - errcode=nf90_ebaddim - return - else - print *,'rank of data array != variable ndims (or ndims-1)' - stop 99 - endif - endif - n1 = dset%variables(nvar)%dimlens(1) - n2 = dset%variables(nvar)%dimlens(2) - n3 = dset%variables(nvar)%dimlens(3) - n4 = dset%variables(nvar)%dimlens(4) - n5 = dset%variables(nvar)%dimlens(5) - if (allocated(values)) deallocate(values) - allocate(values(n1,n2,n3,n4,n5)) - ncerr = nf90_get_var(dset%ncid, dset%variables(nvar)%varid, values) - if (return_errcode) then - call nccheck(ncerr,halt=.false.) - errcode=ncerr - else - call nccheck(ncerr) - endif diff --git a/src/fv3gfs_ncio/write_attribute_code.f90 b/src/fv3gfs_ncio/write_attribute_code.f90 deleted file mode 100644 index c700a90dc2..0000000000 --- a/src/fv3gfs_ncio/write_attribute_code.f90 +++ /dev/null @@ -1,37 +0,0 @@ - type(Dataset), intent(in) :: dset - character(len=*), intent(in), optional :: varname - character(len=*), intent(in) :: attname - integer, intent(out), optional :: errcode - integer ncerr, varid, nvar - logical return_errcode - if(present(errcode)) then - return_errcode=.true. - errcode = 0 - else - return_errcode=.false. - endif - if(present(varname))then - nvar = get_nvar(dset,varname) - varid = dset%variables(nvar)%varid - else - varid = NF90_GLOBAL - endif - ncerr = nf90_redef(dset%ncid) - if (return_errcode) then - call nccheck(ncerr,halt=.false.) - errcode=ncerr - if (ncerr /= 0) return - else - call nccheck(ncerr) - endif - ncerr = nf90_put_att(dset%ncid, varid, trim(attname), values) - if (return_errcode) then - call nccheck(ncerr,halt=.false.) - errcode=ncerr - ncerr = nf90_enddef(dset%ncid) - return - else - call nccheck(ncerr) - ncerr = nf90_enddef(dset%ncid) - call nccheck(ncerr) - endif diff --git a/src/fv3gfs_ncio/write_vardata_code.f90 b/src/fv3gfs_ncio/write_vardata_code.f90 deleted file mode 100644 index a6f8d4ffb8..0000000000 --- a/src/fv3gfs_ncio/write_vardata_code.f90 +++ /dev/null @@ -1,97 +0,0 @@ - type(Dataset), intent(inout) :: dset - character(len=*), intent(in) :: varname - integer, intent(in), optional :: nslice - integer, intent(in), optional :: slicedim - integer, intent(out), optional :: errcode - integer ncerr, nvar, ncount, ndim, nd, n - integer, allocatable, dimension(:) :: start, count, dimlens - logical is_slice - logical return_errcode - if(present(errcode)) then - return_errcode=.true. - errcode = 0 - else - return_errcode=.false. - endif - if (present(nslice)) then - ncount = nslice - is_slice = .true. - else - ncount = 1 - is_slice = .false. - endif - nvar = get_nvar(dset,varname) - allocate(start(dset%variables(nvar)%ndims),count(dset%variables(nvar)%ndims)) - allocate(dimlens(dset%variables(nvar)%ndims)) - start(:) = 1 - count(:) = 1 - dimlens(:) = 1 - if (present(slicedim)) then - nd = slicedim - else - nd = dset%variables(nvar)%ndims - end if - ndim = 1 - do n=1,dset%variables(nvar)%ndims - if (n == nd) then - start(n) = ncount - count(n) = 1 - else - start(n) = 1 - count(n) = dset%variables(nvar)%dimlens(n) - dimlens(ndim) = dset%variables(nvar)%dimlens(n) - ndim = ndim + 1 - end if - end do - - - - ncerr = nf90_var_par_access(dset%ncid, dset%variables(nvar)%varid, nf90_collective) - if (is_slice) then - if (dset%variables(nvar)%ndims == 4) then - ncerr = nf90_put_var(dset%ncid, dset%variables(nvar)%varid,values, & - start=start,count=count) - else if (dset%variables(nvar)%ndims == 3) then - ncerr = nf90_put_var(dset%ncid, dset%variables(nvar)%varid,values, & - start=start,count=count) - else if (dset%variables(nvar)%ndims == 2) then - ncerr = nf90_put_var(dset%ncid, dset%variables(nvar)%varid,values, & - start=start,count=count) - else if (dset%variables(nvar)%ndims == 1) then - if (return_errcode) then - errcode = -1 - return - else - print *,'cannot write a slice to a 1d variable' - stop 99 - endif - else if (dset%variables(nvar)%ndims > 4) then - if (return_errcode) then - errcode = -1 - return - else - print *,'only variables up to 4d supported' - stop 99 - endif - endif - else if (present(ncstart) .and. present(nccount)) then - ncerr = nf90_put_var(dset%ncid, dset%variables(nvar)%varid,values, & - start=ncstart, count=nccount) - else - ncerr = nf90_put_var(dset%ncid, dset%variables(nvar)%varid, values) - endif - if (return_errcode) then - call nccheck(ncerr,halt=.false.) - errcode=ncerr - if (ncerr /= 0) return - else - call nccheck(ncerr) - endif - ! reset unlim dim size for all variables - if (dset%variables(nvar)%hasunlim) then - if (return_errcode) then - call set_varunlimdimlens_(dset,errcode) - else - call set_varunlimdimlens_(dset) - endif - endif diff --git a/src/gsi/CMakeLists.txt b/src/gsi/CMakeLists.txt index d31327040b..6d1273a39d 100644 --- a/src/gsi/CMakeLists.txt +++ b/src/gsi/CMakeLists.txt @@ -1,156 +1,230 @@ -cmake_minimum_required(VERSION 3.16.1) -# need to set CMP0046 when using add_dependencies with cmake version 3.6.2 - if(crayComp) - cmake_policy(SET CMP0046 NEW) +cmake_minimum_required(VERSION 3.19) + +project(gsi + VERSION 1.0.0 + LANGUAGES C Fortran) + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +set(CMAKE_DIRECTORY_LABELS ${PROJECT_NAME}) + +include(GNUInstallDirs) + +if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel)$") + message(STATUS "Setting build type to 'Release' as none was specified.") + set(CMAKE_BUILD_TYPE + "Release" + CACHE STRING "Choose the type of build." FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") +endif() + +if(NOT CMAKE_C_COMPILER_ID MATCHES "^(GNU|Intel|Clang|AppleClang)$") + message(WARNING "${CMAKE_C_COMPILER_ID} is not supported.") +endif() + +if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU|Intel)$") + message(WARNING "${CMAKE_Fortran_COMPILER_ID} is not supported.") +endif() + +# User options +option(OPENMP "Enable OpenMP Threading" OFF) +option(ENABLE_MKL "Use MKL for LAPACK implementation (if available)" ON) +option(USE_GSDCLOUD "Use GSD Cloud Analysis library" OFF) + +set(GSI_VALID_MODES "GFS" "Regional") +set(GSI_MODE "GFS" CACHE STRING "Choose the GSI Application.") +set_property(CACHE GSI_MODE PROPERTY STRINGS ${GSI_VALID_MODES}) + +# Ensure valid GSI_MODE is selected +if(NOT GSI_MODE IN_LIST GSI_VALID_MODES) + message(FATAL_ERROR "GSI_MODE must be one of ${GSI_VALID_MODES}") +endif() + +# Echo user options +message(STATUS "GSI: OPENMP ................. ${OPENMP}") +message(STATUS "GSI: ENABLE_MKL ............. ${ENABLE_MKL}") +message(STATUS "GSI: USE_GSDCLOUD ........... ${USE_GSDCLOUD}") +message(STATUS "GSI: GSI_MODE ............... ${GSI_MODE}") + +# Dependencies +if(ENABLE_MKL) + find_package(MKL) +endif() +if(MKL_FOUND) + set(LAPACK_LIBRARIES ${MKL_LIBRARIES}) +else() + set(ENABLE_MKL OFF CACHE INTERNAL "GSI: Disable MKL since it was NOT FOUND") + find_package(LAPACK REQUIRED) +endif() +find_package(MPI REQUIRED) +find_package(NetCDF REQUIRED Fortran) +if(OPENMP) + find_package(OpenMP REQUIRED) +endif() + +# NCEPLibs dependencies +find_package(bacio REQUIRED) +find_package(sigio REQUIRED) +find_package(sfcio REQUIRED) +find_package(nemsio REQUIRED) +find_package(ncio REQUIRED) +find_package(sp REQUIRED) +find_package(ip REQUIRED) +find_package(w3emc REQUIRED) +find_package(bufr REQUIRED) +find_package(crtm REQUIRED) +if(GSI_MODE MATCHES "Regional") + find_package(wrf_io REQUIRED) +endif() + +# See https://github.com/NOAA-EMC/NCEPLIBS-nemsio/pull/22 +target_link_libraries(nemsio::nemsio INTERFACE w3emc::w3emc_d bacio::bacio_4) + +# NetCDF Diagnostic IO library dependency +if(NOT TARGET ncdiag) + find_package(ncdiag REQUIRED) +endif() + +# GSD Cloud Analysis library dependency +if(USE_GSDCLOUD) + if(NOT TARGET gsdcloud) + find_package(gsdcloud REQUIRED) endif() - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") -# get a list of all the fortran source files - file(GLOB GSIFORT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) -# get a list of all the c source files - file(GLOB GSI_C_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*c ) -# get a list of all cplr files - file(GLOB CLASS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/class*90 ) -# create a list of all corresponding stub files - string(REGEX REPLACE "class" "stub" STUB_SRC "${CLASS_SRC}") -# create a list of all corresponding class files - string(REGEX REPLACE "class" "cplr" CPLR_SRC "${CLASS_SRC}") - -# GSIMAIN_SRC is a list of Fortram main(s), to be used to define GSIEXEC, -# and to be excluded from GSI libraries. - set(GSIMAIN_SRC - ${CMAKE_CURRENT_SOURCE_DIR}/gsimain.f90 - ${CMAKE_CURRENT_SOURCE_DIR}/gsimod.F90 - ) - -# GSIUTIL_SRC is a list of all Fortran modules as *base level* utilities. -# This list can be extended to include any module, which depends (USEs) -# only on module(s) already included in this list, in one of CORE_LIBRARIES, -# or in one of system libraries. Any module dynamically depending on external -# libraries through configuration, such as WRF, NCDIAG, etc. should not be -# included. - - set(GSIUTIL_SRC - ${CMAKE_CURRENT_SOURCE_DIR}/mpeu_util.F90 - ${CMAKE_CURRENT_SOURCE_DIR}/mpimod.F90 - ${CMAKE_CURRENT_SOURCE_DIR}/mpeu_mpif.F90 - ${CMAKE_CURRENT_SOURCE_DIR}/kinds.F90 - ) - -# GSIFORT_SRC is a list of all Fortran modules for GSI core implementations, -# after all configuration dependent code (some stub and cplr), base level -# utilities, the main are removed from the rest of source files - -# Remove CLASS_SRC list related STUB_SRC and CPLR_SRC, as configurable -# grid components - list( REMOVE_ITEM GSIFORT_SRC - ${STUB_SRC} - ${CPLR_SRC} - ${CMAKE_CURRENT_SOURCE_DIR}/gsi_fixture_REGIONAL.F90 - ${CMAKE_CURRENT_SOURCE_DIR}/gsi_fixture_GFS.F90 - ${CMAKE_CURRENT_SOURCE_DIR}/stub_nstmod.f90 - ${GSIUTIL_SRC} - ${GSIMAIN_SRC} - ) - -# remove NCDIAG, if it is a component built somewhere else. - if( BUILD_NCDIAG ) - list( REMOVE_ITEM GSIFORT_SRC "${CMAKE_CURRENT_SOURCE_DIR}/nc_diag_read_mod.f90" ) - list( REMOVE_ITEM GSIFORT_SRC "${CMAKE_CURRENT_SOURCE_DIR}/nc_diag_write_mod.f90" ) - endif( BUILD_NCDIAG ) - -# The specific regional/WRF source files - if(USE_WRF) - list( APPEND GSIFORT_SRC - ${CPLR_SRC} - ${CMAKE_CURRENT_SOURCE_DIR}/gsi_fixture_REGIONAL.F90 - ) +endif() + +# Get compiler flags for the GSI application +include(gsiapp_compiler_flags) + +# Get the list of all source files +include(gsi_files.cmake) + +# Collect common files for GSI Fortran library +list(APPEND GSI_SRC_Fortran + ${GSI_SRC_srcs} + ${GSI_SRC_class}) + +# Collect files for specific GSI Application +if(GSI_MODE MATCHES "GFS") # GFS GSI application + list(APPEND GSI_SRC_Fortran + ${GSI_SRC_gfs_stub} + ${GSI_SRC_fixture_gfs}) +elseif(GSI_MODE MATCHES "Regional") # Regional GSI application + list(APPEND GSI_SRC_Fortran + ${GSI_SRC_regional_cplr} + ${GSI_SRC_fixture_regional}) +endif() + +# Compiler options and definitions +list(APPEND GSI_C_defs + FortranByte=char + FortranInt=int + funder + "FortranLlong=long long") + +list(APPEND GSI_Fortran_defs _REAL8_) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + list(APPEND GSI_Fortran_defs POUND_FOR_STRINGIFY) +endif() +if(USE_GSDCLOUD) + list(APPEND GSI_Fortran_defs RR_CLOUDANALYSIS) +endif() + +# Create a library of GSI C sources +add_library(gsi_c_obj OBJECT ${GSI_SRC_C}) +target_compile_definitions(gsi_c_obj PRIVATE ${GSI_C_defs}) + +# Create a library of GSI Fortran sources +set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/gsi") +add_library(gsi_fortran_obj OBJECT ${GSI_SRC_Fortran}) +set_target_properties(gsi_fortran_obj PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") +target_include_directories(gsi_fortran_obj INTERFACE $ + $ + $) +target_compile_definitions(gsi_fortran_obj PRIVATE ${GSI_Fortran_defs}) +target_link_libraries(gsi_fortran_obj PUBLIC NetCDF::NetCDF_Fortran) +target_link_libraries(gsi_fortran_obj PUBLIC MPI::MPI_Fortran) +target_link_libraries(gsi_fortran_obj PUBLIC ${LAPACK_LIBRARIES}) +target_link_libraries(gsi_fortran_obj PUBLIC bacio::bacio_4) +target_link_libraries(gsi_fortran_obj PUBLIC sigio::sigio) +target_link_libraries(gsi_fortran_obj PUBLIC sfcio::sfcio) +target_link_libraries(gsi_fortran_obj PUBLIC nemsio::nemsio) +target_link_libraries(gsi_fortran_obj PUBLIC ncio::ncio) +target_link_libraries(gsi_fortran_obj PUBLIC w3emc::w3emc_d) +target_link_libraries(gsi_fortran_obj PUBLIC sp::sp_d) +target_link_libraries(gsi_fortran_obj PUBLIC bufr::bufr_d) +target_link_libraries(gsi_fortran_obj PUBLIC crtm::crtm) +if(GSI_MODE MATCHES "Regional") + target_link_libraries(gsi_fortran_obj PUBLIC wrf_io::wrf_io) +endif() +if(TARGET ncdiag) + add_dependencies(gsi_fortran_obj ncdiag) +endif() +target_link_libraries(gsi_fortran_obj PUBLIC ncdiag::ncdiag) +if(USE_GSDCLOUD) + if(TARGET gsdcloud) + add_dependencies(gsi_fortran_obj gsdcloud) endif() - -# The specific global source files - if(BUILD_GLOBAL) - list( APPEND GSIFORT_SRC - ${STUB_SRC} - ${CMAKE_CURRENT_SOURCE_DIR}/gsi_fixture_GFS.F90 - ) - endif(BUILD_GLOBAL) - -# set up the compiler flags - set_source_files_properties( ${GSIMAIN_SRC} PROPERTIES COMPILE_FLAGS ${GSI_Fortran_FLAGS} ) - set_source_files_properties( ${GSIFORT_SRC} PROPERTIES COMPILE_FLAGS ${GSI_Fortran_FLAGS} ) - set_source_files_properties( ${GSIUTIL_SRC} PROPERTIES COMPILE_FLAGS ${GSI_Fortran_FLAGS} ) - set_source_files_properties( ${GSI_C_SRC} PROPERTIES COMPILE_FLAGS ${GSI_CFLAGS} ) - - set( GSICORE_SRC ${GSIFORT_SRC} ${GSI_C_SRC} ) - -# Add the include paths - message("MPI include PATH ${MPI_Fortran_INCLUDE_PATH}") - include_directories( ${CORE_INCS} ${NETCDF_INCLUDE_DIRS} ${MPI_Fortran_INCLUDE_PATH} ${FV3GFS_NCIO_INCS} "./" ) - -#define the name used for GSI Shared lib and add it with properties and include dirs - set(GSISHAREDLIB "gsilib_shrd${debug_suffix}" CACHE INTERNAL "") - add_library(${GSISHAREDLIB} STATIC ${GSIUTIL_SRC} ) - set_target_properties(${GSISHAREDLIB} PROPERTIES Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include") - target_include_directories(${GSISHAREDLIB} PUBLIC "${PROJECT_BINARY_DIR}/include") - -# Definte the base name of the executable - if(BUILD_PRODUCTION) - set(GSIBASE "global_gsi.x") - else() - if(BUILD_GLOBAL) - set(GSIBASE "gsi_global") - else() - set(GSIBASE "gsi") - endif() - set(GSISUFFIX ".x" CACHE INTERNAL "Executable suffix") - endif() - -# Set names, libs, and properties depending on if we are building with WRF or not - if(USE_WRF) - set(GSIEXEC "${GSIBASE}${debug_suffix}${GSISUFFIX}" CACHE INTERNAL "GSI Executable Name") - add_executable(${GSIEXEC} ${CMAKE_CURRENT_SOURCE_DIR}/gsimain.f90 ${CMAKE_CURRENT_SOURCE_DIR}/gsimod.F90 ) - set(GSILIB "gsilib_wrf${debug_suffix}" CACHE INTERNAL "") - add_library(${GSILIB} STATIC ${GSICORE_SRC} ) - set_target_properties(${GSILIB} PROPERTIES Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include") - target_include_directories(${GSILIB} PUBLIC "${PROJECT_BINARY_DIR}/include") - set_target_properties(${GSIEXEC} PROPERTIES Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include") - target_link_libraries( ${GSILIB} ${GSISHAREDLIB} ${wrflib} ) - endif() - - if(BUILD_GLOBAL) - set(GSIEXEC "${GSIBASE}${debug_suffix}${GSISUFFIX}" CACHE INTERNAL "GSI Executable Name") - add_executable( ${GSIEXEC} ${GSIMAIN_SRC} ) - set(GSILIB "gsilib_global${debug_suffix}" CACHE INTERNAL "") - set(WRF_LIBRARIES "") - add_library(${GSILIB} STATIC ${GSICORE_SRC} ) - target_link_libraries( ${GSILIB} ${GSISHAREDLIB} ) - add_dependencies(${GSILIB} ${GSISHAREDLIB} ) - target_link_libraries( ${GSISHAREDLIB} ${CORE_LIBRARIES}) - set_target_properties( ${GSILIB} PROPERTIES Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include") - target_include_directories( ${GSILIB} PUBLIC "${PROJECT_BINARY_DIR}/include") - set_target_properties(${GSIEXEC} PROPERTIES Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include") - endif() - - if( BUILD_NCDIAG ) - add_dependencies(${GSILIB} ${NCDIAG_LIBRARIES} ) - endif( BUILD_NCDIAG ) - add_dependencies(${GSILIB} ${GSISHAREDLIB} ) - -# Add dependencies if we are building the core libs or are just using pre-built libs - if(CORE_BUILT) - add_dependencies(${GSILIB} ${GSISHAREDLIB} ${CORE_BUILT} ) - add_dependencies(${GSISHAREDLIB} ${bacio} ${CORE_BUILT} ) - add_dependencies(${GSIEXEC} ${GSISHAREDLIB} ${GSILIB} ${CORE_BUILT} ) - else() - add_dependencies(${GSIEXEC} ${GSISHAREDLIB} ${GSILIB} ) - endif() -# Specify all the libraries to be linked into the executable - target_link_libraries(${GSIEXEC} ${GSISHAREDLIB} ${GSILIB} ${GSISHAREDLIB} ${WRF_LIBRARIES} - ${MPI_Fortran_LIBRARIES} ${LAPACK_LIBRARIES} - ${CORE_LIBRARIES} ${CORE_BUILT} - ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} - ${GSI_LDFLAGS} ${NCDIAG_LIBRARIES} ${GSDCLOUD_LIBRARY} ${wrflib} - ${EXTRA_LINKER_FLAGS} ${FV3GFS_NCIO_LIBRARIES}) - install(TARGETS ${GSIEXEC} - RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin - LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib - ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/static) + target_link_libraries(gsi_fortran_obj PUBLIC gsdcloud::gsdcloud) +endif() +if(OpenMP_Fortran_FOUND) + target_link_libraries(gsi_fortran_obj PRIVATE OpenMP::OpenMP_Fortran) +endif() + +# Create the GSI library +add_library(gsi STATIC) +add_library(${PROJECT_NAME}::gsi ALIAS gsi) +set_target_properties(gsi PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") +target_include_directories(gsi PUBLIC $ + $) +target_link_libraries(gsi PUBLIC gsi_c_obj) +target_link_libraries(gsi PUBLIC gsi_fortran_obj) +if(OpenMP_Fortran_FOUND) + target_link_libraries(gsi PRIVATE OpenMP::OpenMP_Fortran) +endif() + +# Create the GSI executable +add_executable(gsi.x ${GSI_SRC_main}) +add_dependencies(gsi.x gsi) +set_target_properties(gsi.x PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") +target_link_libraries(gsi.x PRIVATE gsi) +if(OpenMP_Fortran_FOUND) + target_link_libraries(gsi.x PRIVATE OpenMP::OpenMP_Fortran) +endif() + +# Install Fortran modules +install(DIRECTORY ${module_dir} DESTINATION ${CMAKE_INSTALL_PREFIX}/include) + +# Install executable targets +install(TARGETS gsi.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + +# Install and export library targets +install( + TARGETS gsi_c_obj gsi_fortran_obj gsi + EXPORT ${PROJECT_NAME}Exports + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +# Package config +include(CMakePackageConfigHelpers) +set(CONFIG_INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) + +export(EXPORT ${PROJECT_NAME}Exports + NAMESPACE ${PROJECT_NAME}:: + FILE ${PROJECT_NAME}-targets.cmake) + +configure_package_config_file( + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/PackageConfig.cmake.in ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config.cmake + INSTALL_DESTINATION ${CONFIG_INSTALL_DESTINATION}) +install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config.cmake + DESTINATION ${CONFIG_INSTALL_DESTINATION}) + +write_basic_package_version_file( + ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake + VERSION ${PROJECT_VERSION} + COMPATIBILITY AnyNewerVersion) +install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake + DESTINATION ${CONFIG_INSTALL_DESTINATION}) + +install(EXPORT ${PROJECT_NAME}Exports + NAMESPACE ${PROJECT_NAME}:: + FILE ${PROJECT_NAME}-targets.cmake + DESTINATION ${CONFIG_INSTALL_DESTINATION}) diff --git a/src/gsi/cmake/FindMKL.cmake b/src/gsi/cmake/FindMKL.cmake new file mode 100644 index 0000000000..09a1feb7d2 --- /dev/null +++ b/src/gsi/cmake/FindMKL.cmake @@ -0,0 +1,91 @@ +# (C) Copyright 2011- ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# 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. + +# - Try to find MKL +# Once done this will define +# +# MKL_FOUND - system has Intel MKL +# MKL_INCLUDE_DIRS - the MKL include directories +# MKL_LIBRARIES - link these to use MKL +# +# The following paths will be searched with priority if set in CMake or env +# +# MKLROOT - root directory of the MKL installation +# MKL_PATH - root directory of the MKL installation +# MKL_ROOT - root directory of the MKL installation + +option( MKL_PARALLEL "if mkl shoudl be parallel" OFF ) + +if( MKL_PARALLEL ) + + set( __mkl_lib_par MKL_LIB_INTEL_THREAD ) + set( __mkl_lib_name mkl_intel_thread ) + + find_package(Threads) + +else() + + set( __mkl_lib_par MKL_LIB_SEQUENTIAL ) + set( __mkl_lib_name mkl_sequential ) + +endif() + +# Search with priority for MKLROOT, MKL_PATH and MKL_ROOT if set in CMake or env +find_path(MKL_INCLUDE_DIR mkl.h + PATHS ${MKLROOT} ${MKL_PATH} ${MKL_ROOT} $ENV{MKLROOT} $ENV{MKL_PATH} $ENV{MKL_ROOT} + PATH_SUFFIXES include NO_DEFAULT_PATH) + +find_path(MKL_INCLUDE_DIR mkl.h + PATH_SUFFIXES include) + +if( MKL_INCLUDE_DIR ) # use include dir to find libs + + set( MKL_INCLUDE_DIRS ${MKL_INCLUDE_DIR} ) + + if( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" ) + set( __pathsuffix "lib/intel64") + set( __libsfx _lp64 ) + else() + set( __pathsuffix "lib/ia32") + set( __libsfx "" ) + endif() + + find_library( MKL_LIB_INTEL + PATHS ${MKLROOT} ${MKL_PATH} ${MKL_ROOT} $ENV{MKLROOT} $ENV{MKL_PATH} $ENV{MKL_ROOT} + PATH_SUFFIXES lib ${__pathsuffix} + NAMES mkl_intel${__libsfx} ) + + find_library( ${__mkl_lib_par} + PATHS ${MKLROOT} ${MKL_PATH} ${MKL_ROOT} $ENV{MKLROOT} $ENV{MKL_PATH} $ENV{MKL_ROOT} + PATH_SUFFIXES lib ${__pathsuffix} + NAMES ${__mkl_lib_name} ) + + find_library( MKL_LIB_CORE + PATHS ${MKLROOT} ${MKL_PATH} ${MKL_ROOT} $ENV{MKLROOT} $ENV{MKL_PATH} $ENV{MKL_ROOT} + PATH_SUFFIXES lib ${__pathsuffix} + NAMES mkl_core ) + + if( MKL_PARALLEL ) + find_library( MKL_LIB_IOMP5 + PATHS ${MKLROOT} ${MKL_PATH} ${MKL_ROOT} $ENV{MKLROOT} $ENV{MKL_PATH} $ENV{MKL_ROOT} + PATH_SUFFIXES lib ${__pathsuffix} + NAMES iomp5 ) + endif() + + if( MKL_LIB_INTEL AND ${__mkl_lib_par} AND MKL_LIB_CORE ) + set( MKL_LIBRARIES ${MKL_LIB_INTEL} ${${__mkl_lib_par}} ${MKL_LIB_CORE} ${MKL_LIB_IOMP5} ${CMAKE_THREAD_LIBS_INIT} ) + endif() + +endif() + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args( MKL DEFAULT_MSG + MKL_LIBRARIES MKL_INCLUDE_DIRS ) + +mark_as_advanced( MKL_INCLUDE_DIR MKL_LIB_LAPACK MKL_LIB_INTEL MKL_LIB_SEQUENTIAL MKL_LIB_CORE ) diff --git a/src/gsi/cmake/FindNetCDF.cmake b/src/gsi/cmake/FindNetCDF.cmake new file mode 100644 index 0000000000..9e32378ff5 --- /dev/null +++ b/src/gsi/cmake/FindNetCDF.cmake @@ -0,0 +1,347 @@ +# (C) Copyright 2011- ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# 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. + +# Try to find NetCDF includes and library. +# Supports static and shared libaries and allows each component to be found in sepearte prefixes. +# +# This module defines +# +# - NetCDF_FOUND - System has NetCDF +# - NetCDF_INCLUDE_DIRS - the NetCDF include directories +# - NetCDF_VERSION - the version of NetCDF +# - NetCDF_CONFIG_EXECUTABLE - the netcdf-config executable if found +# - NetCDF_PARALLEL - Boolean True if NetCDF4 has parallel IO support via hdf5 and/or pnetcdf +# - NetCDF_HAS_PNETCDF - Boolean True if NetCDF4 has pnetcdf support +# +# Deprecated Defines +# - NetCDF_LIBRARIES - [Deprecated] Use NetCDF::NetCDF_ targets instead. +# +# +# Following components are available: +# +# - C - C interface to NetCDF (netcdf) +# - CXX - CXX4 interface to NetCDF (netcdf_c++4) +# - Fortran - Fortran interface to NetCDF (netcdff) +# +# For each component the following are defined: +# +# - NetCDF__FOUND - whether the component is found +# - NetCDF__LIBRARIES - the libraries for the component +# - NetCDF__LIBRARY_SHARED - Boolean is true if libraries for component are shared +# - NetCDF__INCLUDE_DIRS - the include directories for specified component +# - NetCDF::NetCDF_ - target of component to be used with target_link_libraries() +# +# The following paths will be searched in order if set in CMake (first priority) or environment (second priority) +# +# - NetCDF_ROOT - root of NetCDF installation +# - NetCDF_PATH - root of NetCDF installation +# +# The search process begins with locating NetCDF Include headers. If these are in a non-standard location, +# set one of the following CMake or environment variables to point to the location: +# +# - NetCDF_INCLUDE_DIR or NetCDF_${comp}_INCLUDE_DIR +# - NetCDF_INCLUDE_DIRS or NetCDF_${comp}_INCLUDE_DIR +# +# Notes: +# +# - Use "NetCDF::NetCDF_" targets only. NetCDF_LIBRARIES exists for backwards compatibility and should not be used. +# - These targets have all the knowledge of include directories and library search directories, and a single +# call to target_link_libraries will provide all these transitive properties to your target. Normally all that is +# needed to build and link against NetCDF is, e.g.: +# target_link_libraries(my_c_tgt PUBLIC NetCDF::NetCDF_C) +# - "NetCDF" is always the preferred naming for this package, its targets, variables, and environment variables +# - For compatibility, some variables are also set/checked using alternate names NetCDF4, NETCDF, or NETCDF4 +# - Environments relying on these older environment variable names should move to using a "NetCDF_ROOT" environment variable +# - Preferred component capitalization follows the CMake LANGUAGES variables: i.e., C, Fortran, CXX +# - For compatibility, alternate capitalizations are supported but should not be used. +# - If no components are defined, all components will be searched +# + +list( APPEND _possible_components C CXX Fortran ) + +## Include names for each component +set( NetCDF_C_INCLUDE_NAME netcdf.h ) +set( NetCDF_CXX_INCLUDE_NAME netcdf ) +set( NetCDF_Fortran_INCLUDE_NAME netcdf.mod ) + +## Library names for each component +set( NetCDF_C_LIBRARY_NAME netcdf ) +set( NetCDF_CXX_LIBRARY_NAME netcdf_c++4 ) +set( NetCDF_Fortran_LIBRARY_NAME netcdff ) + +## Enumerate search components +foreach( _comp ${_possible_components} ) + string( TOUPPER "${_comp}" _COMP ) + set( _arg_${_COMP} ${_comp} ) + set( _name_${_COMP} ${_comp} ) +endforeach() + +set( _search_components C) +foreach( _comp ${${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS} ) + string( TOUPPER "${_comp}" _COMP ) + set( _arg_${_COMP} ${_comp} ) + list( APPEND _search_components ${_name_${_COMP}} ) + if( NOT _name_${_COMP} ) + message(SEND_ERROR "Find${CMAKE_FIND_PACKAGE_NAME}: COMPONENT ${_comp} is not a valid component. Valid components: ${_possible_components}" ) + endif() +endforeach() +list( REMOVE_DUPLICATES _search_components ) + +## Search hints for finding include directories and libraries +foreach( _comp IN ITEMS "_" "_C_" "_Fortran_" "_CXX_" ) + foreach( _name IN ITEMS NetCDF4 NetCDF NETCDF4 NETCDF ) + foreach( _var IN ITEMS ROOT PATH ) + list(APPEND _search_hints ${${_name}${_comp}${_var}} $ENV{${_name}${_comp}${_var}} ) + list(APPEND _include_search_hints + ${${_name}${_comp}INCLUDE_DIR} $ENV{${_name}${_comp}INCLUDE_DIR} + ${${_name}${_comp}INCLUDE_DIRS} $ENV{${_name}${_comp}INCLUDE_DIRS} ) + endforeach() + endforeach() +endforeach() +#Old-school HPC module env variable names +foreach( _name IN ITEMS NetCDF4 NetCDF NETCDF4 NETCDF ) + foreach( _comp IN ITEMS "_C" "_Fortran" "_CXX" ) + list(APPEND _search_hints ${${_name}} $ENV{${_name}}) + list(APPEND _search_hints ${${_name}${_comp}} $ENV{${_name}${_comp}}) + endforeach() +endforeach() + +## Find headers for each component +set(NetCDF_INCLUDE_DIRS) +set(_new_search_components) +foreach( _comp IN LISTS _search_components ) + if(NOT ${PROJECT_NAME}_NetCDF_${_comp}_FOUND) + list(APPEND _new_search_components ${_comp}) + endif() + find_file(NetCDF_${_comp}_INCLUDE_FILE + NAMES ${NetCDF_${_comp}_INCLUDE_NAME} + DOC "NetCDF ${_comp} include directory" + HINTS ${_include_search_hints} ${_search_hints} + PATH_SUFFIXES include include/netcdf + ) + mark_as_advanced(NetCDF_${_comp}_INCLUDE_FILE) + message(DEBUG "NetCDF_${_comp}_INCLUDE_FILE: ${NetCDF_${_comp}_INCLUDE_FILE}") + if( NetCDF_${_comp}_INCLUDE_FILE ) + get_filename_component(NetCDF_${_comp}_INCLUDE_FILE ${NetCDF_${_comp}_INCLUDE_FILE} ABSOLUTE) + get_filename_component(NetCDF_${_comp}_INCLUDE_DIR ${NetCDF_${_comp}_INCLUDE_FILE} DIRECTORY) + list(APPEND NetCDF_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIR}) + endif() +endforeach() +if(NetCDF_INCLUDE_DIRS) + list(REMOVE_DUPLICATES NetCDF_INCLUDE_DIRS) +endif() +set(NetCDF_INCLUDE_DIRS "${NetCDF_INCLUDE_DIRS}" CACHE STRING "NetCDF Include directory paths" FORCE) + +## Find n*-config executables for search components +foreach( _comp IN LISTS _search_components ) + if( _comp MATCHES "^(C)$" ) + set(_conf "c") + elseif( _comp MATCHES "^(Fortran)$" ) + set(_conf "f") + elseif( _comp MATCHES "^(CXX)$" ) + set(_conf "cxx4") + endif() + find_program( NetCDF_${_comp}_CONFIG_EXECUTABLE + NAMES n${_conf}-config + HINTS ${NetCDF_INCLUDE_DIRS} ${_include_search_hints} ${_search_hints} + PATH_SUFFIXES bin Bin ../bin ../../bin + DOC "NetCDF n${_conf}-config helper" ) + message(DEBUG "NetCDF_${_comp}_CONFIG_EXECUTABLE: ${NetCDF_${_comp}_CONFIG_EXECUTABLE}") +endforeach() + +set(_C_libs_flag --libs) +set(_Fortran_libs_flag --flibs) +set(_CXX_libs_flag --libs) +set(_C_includes_flag --includedir) +set(_Fortran_includes_flag --includedir) +set(_CXX_includes_flag --includedir) +function(netcdf_config exec flag output_var) + set(${output_var} False PARENT_SCOPE) + if( exec ) + execute_process( COMMAND ${exec} ${flag} RESULT_VARIABLE _ret OUTPUT_VARIABLE _val) + if( _ret EQUAL 0 ) + string( STRIP ${_val} _val ) + set( ${output_var} ${_val} PARENT_SCOPE ) + endif() + endif() +endfunction() + +## Detect additional package properties +netcdf_config(${NetCDF_C_CONFIG_EXECUTABLE} --has-parallel4 _val) +if( NOT _val MATCHES "^(yes|no)$" ) + netcdf_config(${NetCDF_C_CONFIG_EXECUTABLE} --has-parallel _val) +endif() +if( _val MATCHES "^(yes)$" ) + set(NetCDF_PARALLEL TRUE CACHE STRING "NetCDF has parallel IO capability via pnetcdf or hdf5." FORCE) +else() + set(NetCDF_PARALLEL FALSE CACHE STRING "NetCDF has no parallel IO capability." FORCE) +endif() + +if(NetCDF_PARALLEL) + find_package(MPI REQUIRED) +endif() + +## Find libraries for each component +set( NetCDF_LIBRARIES ) +foreach( _comp IN LISTS _search_components ) + string( TOUPPER "${_comp}" _COMP ) + + find_library( NetCDF_${_comp}_LIBRARY + NAMES ${NetCDF_${_comp}_LIBRARY_NAME} + DOC "NetCDF ${_comp} library" + HINTS ${NetCDF_${_comp}_INCLUDE_DIRS} ${_search_hints} + PATH_SUFFIXES lib64 lib ../lib64 ../lib ../../lib64 ../../lib ) + mark_as_advanced( NetCDF_${_comp}_LIBRARY ) + get_filename_component(NetCDF_${_comp}_LIBRARY ${NetCDF_${_comp}_LIBRARY} ABSOLUTE) + set(NetCDF_${_comp}_LIBRARY ${NetCDF_${_comp}_LIBRARY} CACHE STRING "NetCDF ${_comp} library" FORCE) + message(DEBUG "NetCDF_${_comp}_LIBRARY: ${NetCDF_${_comp}_LIBRARY}") + + if( NetCDF_${_comp}_LIBRARY ) + if( NetCDF_${_comp}_LIBRARY MATCHES ".a$" ) + set( NetCDF_${_comp}_LIBRARY_SHARED FALSE ) + set( _library_type STATIC) + else() + list( APPEND NetCDF_LIBRARIES ${NetCDF_${_comp}_LIBRARY} ) + set( NetCDF_${_comp}_LIBRARY_SHARED TRUE ) + set( _library_type SHARED) + endif() + endif() + + #Use nc-config to set per-component LIBRARIES variable if possible + netcdf_config( ${NetCDF_${_comp}_CONFIG_EXECUTABLE} ${_${_comp}_libs_flag} _val ) + if( _val ) + set( NetCDF_${_comp}_LIBRARIES ${_val} ) + if(NOT NetCDF_${_comp}_LIBRARY_SHARED AND NOT NetCDF_${_comp}_FOUND) #Static targets should use nc_config to get a proper link line with all necessary static targets. + list( APPEND NetCDF_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) + endif() + else() + set( NetCDF_${_comp}_LIBRARIES ${NetCDF_${_comp}_LIBRARY} ) + if(NOT NetCDF_${_comp}_LIBRARY_SHARED) + message(SEND_ERROR "Unable to properly find NetCDF. Found static libraries at: ${NetCDF_${_comp}_LIBRARY} but could not run nc-config: ${NetCDF_CONFIG_EXECUTABLE}") + endif() + endif() + + #Use nc-config to set per-component INCLUDE_DIRS variable if possible + netcdf_config( ${NetCDF_${_comp}_CONFIG_EXECUTABLE} ${_${_comp}_includes_flag} _val ) + if( _val ) + string( REPLACE " " ";" _val ${_val} ) + set( NetCDF_${_comp}_INCLUDE_DIRS ${_val} ) + else() + set( NetCDF_${_comp}_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIR} ) + endif() + + if( NetCDF_${_comp}_LIBRARIES AND NetCDF_${_comp}_INCLUDE_DIRS ) + set( ${CMAKE_FIND_PACKAGE_NAME}_${_arg_${_COMP}}_FOUND TRUE ) + if (NOT TARGET NetCDF::NetCDF_${_comp}) + add_library(NetCDF::NetCDF_${_comp} ${_library_type} IMPORTED) + set_target_properties(NetCDF::NetCDF_${_comp} PROPERTIES + IMPORTED_LOCATION ${NetCDF_${_comp}_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES "${NetCDF_${_comp}_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) + if( NOT _comp MATCHES "^(C)$" ) + target_link_libraries(NetCDF::NetCDF_${_comp} INTERFACE NetCDF::NetCDF_C) + endif() + if(MPI_${_comp}_FOUND) + target_link_libraries(NetCDF::NetCDF_${_comp} INTERFACE MPI::MPI_${_comp}) + endif() + endif() + endif() +endforeach() +if(NetCDF_LIBRARIES AND NetCDF_${_comp}_LIBRARY_SHARED) + list(REMOVE_DUPLICATES NetCDF_LIBRARIES) +endif() +set(NetCDF_LIBRARIES "${NetCDF_LIBRARIES}" CACHE STRING "NetCDF library targets" FORCE) + +## Find version via netcdf-config if possible +if (NetCDF_INCLUDE_DIRS) + if( NetCDF_C_CONFIG_EXECUTABLE ) + netcdf_config( ${NetCDF_C_CONFIG_EXECUTABLE} --version _vers ) + if( _vers ) + string(REGEX REPLACE ".* ((([0-9]+)\\.)+([0-9]+)).*" "\\1" NetCDF_VERSION "${_vers}" ) + endif() + else() + foreach( _dir IN LISTS NetCDF_INCLUDE_DIRS) + if( EXISTS "${_dir}/netcdf_meta.h" ) + file(STRINGS "${_dir}/netcdf_meta.h" _netcdf_version_lines + REGEX "#define[ \t]+NC_VERSION_(MAJOR|MINOR|PATCH|NOTE)") + string(REGEX REPLACE ".*NC_VERSION_MAJOR *\([0-9]*\).*" "\\1" _netcdf_version_major "${_netcdf_version_lines}") + string(REGEX REPLACE ".*NC_VERSION_MINOR *\([0-9]*\).*" "\\1" _netcdf_version_minor "${_netcdf_version_lines}") + string(REGEX REPLACE ".*NC_VERSION_PATCH *\([0-9]*\).*" "\\1" _netcdf_version_patch "${_netcdf_version_lines}") + string(REGEX REPLACE ".*NC_VERSION_NOTE *\"\([^\"]*\)\".*" "\\1" _netcdf_version_note "${_netcdf_version_lines}") + set(NetCDF_VERSION "${_netcdf_version_major}.${_netcdf_version_minor}.${_netcdf_version_patch}${_netcdf_version_note}") + unset(_netcdf_version_major) + unset(_netcdf_version_minor) + unset(_netcdf_version_patch) + unset(_netcdf_version_note) + unset(_netcdf_version_lines) + endif() + endforeach() + endif() +endif () + +## Finalize find_package +include(FindPackageHandleStandardArgs) + +if(NOT NetCDF_FOUND OR _new_search_components) + find_package_handle_standard_args( ${CMAKE_FIND_PACKAGE_NAME} + REQUIRED_VARS NetCDF_INCLUDE_DIRS NetCDF_LIBRARIES + VERSION_VAR NetCDF_VERSION + HANDLE_COMPONENTS ) +endif() + +foreach( _comp IN LISTS _search_components ) + if( NetCDF_${_comp}_FOUND ) + #Record found components to avoid duplication in NetCDF_LIBRARIES for static libraries + set(NetCDF_${_comp}_FOUND ${NetCDF_${_comp}_FOUND} CACHE BOOL "NetCDF ${_comp} Found" FORCE) + #Set a per-package, per-component found variable to communicate between multiple calls to find_package() + set(${PROJECT_NAME}_NetCDF_${_comp}_FOUND True) + endif() +endforeach() + +if( ${CMAKE_FIND_PACKAGE_NAME}_FOUND AND NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY AND _new_search_components) + message( STATUS "Find${CMAKE_FIND_PACKAGE_NAME} defines targets:" ) + message( STATUS " - NetCDF_VERSION [${NetCDF_VERSION}]") + message( STATUS " - NetCDF_PARALLEL [${NetCDF_PARALLEL}]") + foreach( _comp IN LISTS _new_search_components ) + string( TOUPPER "${_comp}" _COMP ) + message( STATUS " - NetCDF_${_comp}_CONFIG_EXECUTABLE [${NetCDF_${_comp}_CONFIG_EXECUTABLE}]") + if( ${CMAKE_FIND_PACKAGE_NAME}_${_arg_${_COMP}}_FOUND ) + get_filename_component(_root ${NetCDF_${_comp}_INCLUDE_DIR}/.. ABSOLUTE) + if( NetCDF_${_comp}_LIBRARY_SHARED ) + message( STATUS " - NetCDF::NetCDF_${_comp} [SHARED] [Root: ${_root}] Lib: ${NetCDF_${_comp}_LIBRARY} ") + else() + message( STATUS " - NetCDF::NetCDF_${_comp} [STATIC] [Root: ${_root}] Lib: ${NetCDF_${_comp}_LIBRARY} ") + endif() + endif() + endforeach() +endif() + +foreach( _prefix NetCDF NetCDF4 NETCDF NETCDF4 ${CMAKE_FIND_PACKAGE_NAME} ) + set( ${_prefix}_INCLUDE_DIRS ${NetCDF_INCLUDE_DIRS} ) + set( ${_prefix}_LIBRARIES ${NetCDF_LIBRARIES}) + set( ${_prefix}_VERSION ${NetCDF_VERSION} ) + set( ${_prefix}_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_FOUND} ) + set( ${_prefix}_CONFIG_EXECUTABLE ${NetCDF_CONFIG_EXECUTABLE} ) + set( ${_prefix}_PARALLEL ${NetCDF_PARALLEL} ) + + foreach( _comp ${_search_components} ) + string( TOUPPER "${_comp}" _COMP ) + set( _arg_comp ${_arg_${_COMP}} ) + set( ${_prefix}_${_comp}_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_${_arg_comp}_FOUND} ) + set( ${_prefix}_${_COMP}_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_${_arg_comp}_FOUND} ) + set( ${_prefix}_${_arg_comp}_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_${_arg_comp}_FOUND} ) + + set( ${_prefix}_${_comp}_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) + set( ${_prefix}_${_COMP}_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) + set( ${_prefix}_${_arg_comp}_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) + + set( ${_prefix}_${_comp}_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIRS} ) + set( ${_prefix}_${_COMP}_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIRS} ) + set( ${_prefix}_${_arg_comp}_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIRS} ) + endforeach() +endforeach() diff --git a/src/gsi/cmake/PackageConfig.cmake.in b/src/gsi/cmake/PackageConfig.cmake.in new file mode 100644 index 0000000000..1c5816e2b6 --- /dev/null +++ b/src/gsi/cmake/PackageConfig.cmake.in @@ -0,0 +1,60 @@ +@PACKAGE_INIT@ + +#@PROJECT_NAME@-config.cmake +# +# Imported interface targets provided: +# * @PROJECT_NAME@::gsi - GSI library target + +# Include targets file. This will create IMPORTED target @PROJECT_NAME@ +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-config-version.cmake") +include(CMakeFindDependencyMacro) + +# Get the GSI_MODE attribute +set(GSI_MODE @GSI_MODE@) + +find_dependency(MPI) +find_dependency(NetCDF COMPONENTS Fortran) + +# ON|OFF implies @PROJECT_NAME@ was compiled with/without -DENABLE_MKL=ON|OFF +if(@ENABLE_MKL@) + find_dependency(MKL REQUIRED) + set(LAPACK_LIBRARIES ${MKL_LIBRARIES}) +endif() +if(NOT @ENABLE_MKL@) + find_dependency(LAPACK REQUIRED) +endif() + +# ON|OFF implies @PROJECT_NAME@ was compiled with/without OpenMP +if(@OPENMP@) + find_dependency(OpenMP COMPONENTS Fortran) +endif() + +find_dependency(bacio REQUIRED) +find_dependency(sigio REQUIRED) +find_dependency(sfcio REQUIRED) +find_dependency(nemsio REQUIRED) +find_dependency(ncio REQUIRED) +find_dependency(sp REQUIRED) +find_dependency(ip REQUIRED) +find_dependency(w3emc REQUIRED) +find_dependency(bufr REQUIRED) +find_dependency(crtm REQUIRED) + +if(${GSI_MODE} MATCHES "Regional") + find_dependency(wrf_io REQUIRED) +endif() + +# This gives more trouble since GSIApp is a nested project of projects +# and targets are built in the GSIApp project +#find_dependency(ncdiag REQUIRED) + +# Get the build type from library target +get_target_property(@PROJECT_NAME@_BUILD_TYPES @PROJECT_NAME@::@PROJECT_NAME@ IMPORTED_CONFIGURATIONS) + +check_required_components("@PROJECT_NAME@") + +get_target_property(location @PROJECT_NAME@::@PROJECT_NAME@ LOCATION) +message(STATUS "Found @PROJECT_NAME@: ${location} (found version \"${PACKAGE_VERSION}\")") +message(STATUS "FindGSI defines targets:") +message(STATUS " - GSI_MODE [${GSI_MODE}]") diff --git a/src/gsi/cmake/gsiapp_compiler_flags.cmake b/src/gsi/cmake/gsiapp_compiler_flags.cmake new file mode 100644 index 0000000000..bd38b729da --- /dev/null +++ b/src/gsi/cmake/gsiapp_compiler_flags.cmake @@ -0,0 +1,27 @@ +if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") + add_definitions(-DNDEBUG) +endif() + +####################################################################################### +# Fortran +####################################################################################### + +if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") + include(gsiapp_compiler_flags_GNU_Fortran) +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") + include(gsiapp_compiler_flags_Intel_Fortran) +else() + message(STATUS "Fortran compiler with ID ${CMAKE_Fortran_COMPILER_ID} will be used with CMake default options") +endif() + +####################################################################################### +# C +####################################################################################### + +if(CMAKE_C_COMPILER_ID MATCHES "GNU") + include(gsiapp_compiler_flags_GNU_C) +elseif(CMAKE_C_COMPILER_ID MATCHES "Intel") + include(gsiapp_compiler_flags_Intel_C) +else() + message(STATUS "C compiler with ID ${CMAKE_C_COMPILER_ID} will be used with CMake default options") +endif() diff --git a/src/gsi/cmake/gsiapp_compiler_flags_GNU_C.cmake b/src/gsi/cmake/gsiapp_compiler_flags_GNU_C.cmake new file mode 100644 index 0000000000..31135cb0a8 --- /dev/null +++ b/src/gsi/cmake/gsiapp_compiler_flags_GNU_C.cmake @@ -0,0 +1,34 @@ +#################################################################### +# FLAGS COMMON TO ALL BUILD TYPES +#################################################################### + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") + +#################################################################### +# RELEASE FLAGS +#################################################################### + +set(CMAKE_C_FLAGS_RELEASE "") + +#################################################################### +# DEBUG FLAGS +#################################################################### + +set(CMAKE_C_FLAGS_DEBUG "") + +#################################################################### +# LINK FLAGS +#################################################################### + +set(CMAKE_C_LINK_FLAGS "") + +#################################################################### +# FLAGS FOR AUTOPROFILING +#################################################################### + +set(C_AUTOPROFILING_FLAGS "") + +#################################################################### + +# Meaning of flags +# ---------------- diff --git a/src/gsi/cmake/gsiapp_compiler_flags_GNU_Fortran.cmake b/src/gsi/cmake/gsiapp_compiler_flags_GNU_Fortran.cmake new file mode 100644 index 0000000000..6faa0def20 --- /dev/null +++ b/src/gsi/cmake/gsiapp_compiler_flags_GNU_Fortran.cmake @@ -0,0 +1,41 @@ +#################################################################### +# FLAGS COMMON TO ALL BUILD TYPES +#################################################################### + +set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -fbacktrace -ffree-line-length-none -fconvert=big-endian -fno-second-underscore -ffast-math") + +if(${CMAKE_Fortran_COMPILER_VERSION} VERSION_GREATER_EQUAL 10) + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-argument-mismatch -fallow-invalid-boz") +endif() + +#################################################################### +# RELEASE FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_RELEASE "-O2 -frecord-marker=4 -funroll-loops -fno-range-check") + +#################################################################### +# DEBUG FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -ggdb -Wall -fcheck=bounds -ffpe-trap=invalid,zero,overflow") + +#################################################################### +# LINK FLAGS +#################################################################### + +set(CMAKE_Fortran_LINK_FLAGS "") + +#################################################################### +# FLAGS FOR AUTOPROFILING +#################################################################### + +set(Fortran_AUTOPROFILING_FLAGS "-finstrument-functions") + +#################################################################### + +# Meaning of flags +# ---------------- +# -fstack-arrays : Allocate automatic arrays on the stack (needs large stacksize!!!) +# -funroll-all-loops : Unroll all loops +# -fcheck=bounds : Bounds checking diff --git a/src/gsi/cmake/gsiapp_compiler_flags_Intel_C.cmake b/src/gsi/cmake/gsiapp_compiler_flags_Intel_C.cmake new file mode 100644 index 0000000000..ed5d63d1de --- /dev/null +++ b/src/gsi/cmake/gsiapp_compiler_flags_Intel_C.cmake @@ -0,0 +1,34 @@ +#################################################################### +# FLAGS COMMON TO ALL BUILD TYPES +#################################################################### + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") + +#################################################################### +# RELEASE FLAGS +#################################################################### + +set(CMAKE_C_FLAGS_RELEASE "") + +#################################################################### +# DEBUG FLAGS +#################################################################### + +set(CMAKE_C_FLAGS_DEBUG "-Wall") + +#################################################################### +# LINK FLAGS +#################################################################### + +set(CMAKE_C_LINK_FLAGS "") + +#################################################################### +# FLAGS FOR AUTOPROFILING +#################################################################### + +set(C_AUTOPROFILING_FLAGS "") + +#################################################################### + +# Meaning of flags +# ---------------- diff --git a/src/gsi/cmake/gsiapp_compiler_flags_Intel_Fortran.cmake b/src/gsi/cmake/gsiapp_compiler_flags_Intel_Fortran.cmake new file mode 100644 index 0000000000..8ba2887da8 --- /dev/null +++ b/src/gsi/cmake/gsiapp_compiler_flags_Intel_Fortran.cmake @@ -0,0 +1,35 @@ +#################################################################### +# FLAGS COMMON TO ALL BUILD TYPES +#################################################################### + +set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -traceback -assume byterecl -convert big_endian -implicitnone") + +#################################################################### +# RELEASE FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -fp-model strict") + +#################################################################### +# DEBUG FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -fp-model source -debug -ftrapuv -warn all,nointerfaces -check all,noarg_temp_created -fp-stack-check -fstack-protector") + +#################################################################### +# LINK FLAGS +#################################################################### + +set(CMAKE_Fortran_LINK_FLAGS "") + +#################################################################### +# FLAGS FOR AUTOPROFILING +#################################################################### + +set(Fortran_AUTOPROFILING_FLAGS "-finstrument-functions") + +#################################################################### + +# Meaning of flags +# ---------------- +# todo diff --git a/src/gsi/cplr_get_fv3_regional_ensperts.f90 b/src/gsi/cplr_get_fv3_regional_ensperts.f90 index b54f727b71..98feb46202 100644 --- a/src/gsi/cplr_get_fv3_regional_ensperts.f90 +++ b/src/gsi/cplr_get_fv3_regional_ensperts.f90 @@ -567,6 +567,7 @@ subroutine general_read_fv3_regional(this,fv3_filenameginput,g_ps,g_u,g_v,g_tv,g use gsi_rfv3io_mod, only: gsi_fv3ncdf_readuv_v1 use gsi_rfv3io_mod, only: gsi_fv3ncdf2d_read_v1 use directDA_radaruse_mod, only: l_use_dbz_directDA + use gsi_bundlemod, only: gsi_bundle use gsi_bundlemod, only: gsi_gridcreate use gsi_bundlemod, only: gsi_grid use gsi_bundlemod, only: gsi_bundlecreate,gsi_bundledestroy diff --git a/src/gsi/cplr_gfs_ensmod.f90 b/src/gsi/cplr_gfs_ensmod.f90 index c9aba6f9f0..582574b52f 100644 --- a/src/gsi/cplr_gfs_ensmod.f90 +++ b/src/gsi/cplr_gfs_ensmod.f90 @@ -898,7 +898,7 @@ subroutine parallel_read_gfsnc_state_(en_full,m_cvars2d,m_cvars3d,nlon,nlat,nsig use constants, only: r60,r3600,zero,one,half,deg2rad use control_vectors, only: cvars2d,cvars3d,nc2d,nc3d use general_sub2grid_mod, only: sub2grid_info - use module_fv3gfs_ncio, only: Dataset, Variable, Dimension, open_dataset,& + use module_ncio, only: Dataset, Variable, Dimension, open_dataset,& close_dataset, get_dim, read_vardata implicit none diff --git a/src/gsi/general_read_gfsatm.f90 b/src/gsi/general_read_gfsatm.f90 index 57b6c6033c..39db75db73 100755 --- a/src/gsi/general_read_gfsatm.f90 +++ b/src/gsi/general_read_gfsatm.f90 @@ -1890,7 +1890,7 @@ subroutine general_read_gfsatm_nc(grd,sp_a,filename,uvflag,vordivflag,zflag, & use constants, only: two,pi,half,deg2rad,r60,r3600 use gsi_bundlemod, only: gsi_bundle use gsi_bundlemod, only: gsi_bundlegetpointer - use module_fv3gfs_ncio, only: Dataset, Variable, Dimension, open_dataset,& + use module_ncio, only: Dataset, Variable, Dimension, open_dataset,& close_dataset, get_dim, read_vardata,get_idate_from_time_units use gfsreadmod, only: general_reload @@ -2616,8 +2616,8 @@ subroutine general_read_gfsatm_allhydro_nc(grd,sp_a,filename,uvflag,vordivflag,z use constants, only: two,pi,half,deg2rad,r60,r3600 use gsi_bundlemod, only: gsi_bundle use gsi_bundlemod, only: gsi_bundlegetpointer - use module_fv3gfs_ncio, only: Dataset, Variable, Dimension, open_dataset,& - close_dataset, get_dim, read_vardata,get_idate_from_time_units + use module_ncio, only: Dataset, Variable, Dimension, open_dataset,& + close_dataset, get_dim, read_vardata,get_idate_from_time_units use gfsreadmod, only: general_reload2 use ncepnems_io, only: imp_physics diff --git a/src/gsi/gesinfo.F90 b/src/gsi/gesinfo.F90 index 5d86c04dc6..792900b628 100644 --- a/src/gsi/gesinfo.F90 +++ b/src/gsi/gesinfo.F90 @@ -84,7 +84,7 @@ subroutine gesinfo sigio_sropen use nemsio_module, only: nemsio_init,nemsio_open,nemsio_close use nemsio_module, only: nemsio_gfile,nemsio_getfilehead,nemsio_getheadvar - use module_fv3gfs_ncio, only: Dimension, Dataset, open_dataset, get_dim, & + use module_ncio, only: Dimension, Dataset, open_dataset, get_dim, & read_vardata, get_idate_from_time_units,& read_attribute, close_dataset diff --git a/src/gsi/get_gefs_for_regional.f90 b/src/gsi/get_gefs_for_regional.f90 index 4a217f2de3..b41a137b92 100644 --- a/src/gsi/get_gefs_for_regional.f90 +++ b/src/gsi/get_gefs_for_regional.f90 @@ -78,7 +78,7 @@ subroutine get_gefs_for_regional use nemsio_module, only: nemsio_init,nemsio_open,nemsio_close use ncepnems_io, only: error_msg use nemsio_module, only: nemsio_gfile,nemsio_getfilehead - use module_fv3gfs_ncio, only: Dimension, Dataset, open_dataset, get_dim, & + use module_ncio, only: Dimension, Dataset, open_dataset, get_dim, & read_vardata, get_idate_from_time_units,& read_attribute, close_dataset use get_wrf_mass_ensperts_mod, only: get_wrf_mass_ensperts_class diff --git a/src/gsi/gfs_stratosphere.f90 b/src/gsi/gfs_stratosphere.f90 index 4a855673a2..22581b2db0 100644 --- a/src/gsi/gfs_stratosphere.f90 +++ b/src/gsi/gfs_stratosphere.f90 @@ -181,7 +181,7 @@ subroutine mix_gfs_nmmb_vcoords(deta1 ,aeta1 ,eta1 ,deta2 ,aeta2 ,eta2 ,pdtop,pt use nemsio_module, only: nemsio_init,nemsio_open,nemsio_close use ncepnems_io, only: error_msg use nemsio_module, only: nemsio_gfile,nemsio_getfilehead - use module_fv3gfs_ncio, only: Dataset, Dimension, get_dim, read_vardata,& + use module_ncio, only: Dataset, Dimension, get_dim, read_vardata,& open_dataset, close_dataset, read_attribute,& get_idate_from_time_units @@ -900,7 +900,7 @@ subroutine add_gfs_stratosphere use nemsio_module, only: nemsio_init,nemsio_open,nemsio_close use ncepnems_io, only: error_msg use nemsio_module, only: nemsio_gfile,nemsio_getfilehead - use module_fv3gfs_ncio, only: Dataset,Dimension,open_dataset,close_dataset,& + use module_ncio, only: Dataset,Dimension,open_dataset,close_dataset,& read_attribute,get_dim,read_vardata,& get_idate_from_time_units diff --git a/src/gsi/gsi_files.cmake b/src/gsi/gsi_files.cmake new file mode 100644 index 0000000000..15630a3b73 --- /dev/null +++ b/src/gsi/gsi_files.cmake @@ -0,0 +1,674 @@ +list(APPEND GSI_SRC_C +blockIO.c +) + +# Class files for WRF interfaces +list(APPEND GSI_SRC_class +class_get_pseudo_ensperts.f90 +class_get_wrf_mass_ensperts.f90 +class_get_wrf_nmm_ensperts.f90 +class_read_wrf_mass_files.f90 +class_read_wrf_mass_guess.f90 +class_read_wrf_nmm_files.f90 +class_read_wrf_nmm_guess.f90 +class_regional_io.f90 +class_wrf_binary_interface.f90 +class_wrf_netcdf_interface.f90 +class_wrwrfmassa.f90 +class_wrwrfnmma.f90 +) + +# Stubs for Global interface +list(APPEND GSI_SRC_gfs_stub +stub_get_pseudo_ensperts.f90 +stub_get_wrf_mass_ensperts.f90 +stub_get_wrf_nmm_ensperts.f90 +stub_read_wrf_mass_files.f90 +stub_read_wrf_mass_guess.f90 +stub_read_wrf_nmm_files.f90 +stub_read_wrf_nmm_guess.f90 +stub_regional_io.f90 +stub_wrf_binary_interface.f90 +stub_wrf_netcdf_interface.f90 +stub_wrwrfmassa.f90 +stub_wrwrfnmma.f90 +) + +list(APPEND GSI_SRC_regional_cplr +cplr_get_pseudo_ensperts.f90 +cplr_get_wrf_mass_ensperts.f90 +cplr_get_wrf_nmm_ensperts.f90 +cplr_read_wrf_mass_files.f90 +cplr_read_wrf_mass_guess.f90 +cplr_read_wrf_nmm_files.f90 +cplr_read_wrf_nmm_guess.f90 +cplr_regional_io.f90 +cplr_wrf_binary_interface.f90 +cplr_wrf_netcdf_interface.f90 +cplr_wrwrfmassa.f90 +cplr_wrwrfnmma.f90 +) + +list(APPEND GSI_SRC_main +gsimain.f90 +gsimod.F90 +) + +list(APPEND GSI_SRC_fixture_gfs +gsi_fixture_GFS.F90 +) + +list(APPEND GSI_SRC_fixture_regional +gsi_fixture_REGIONAL.F90 +) + +# List of all includes/headers in Fortran sources +list(APPEND GSI_SRC_hdr +myassert.H +mytrace.H +) + +# All else Fortran sources that are not in above categories +list(APPEND GSI_SRC_srcs +abstract_ensmod.f90 +adjtest.f90 +adjtest_obs.f90 +adjust_cloudobs_mod.f90 +aero_guess_at_obs_locations.f90 +aeroinfo.f90 +aircraftinfo.f90 +aircraftobsqc.f90 +anberror.f90 +anbkerror.f90 +aniso_ens_util.f90 +anisofilter.f90 +anisofilter_glb.f90 +antcorr_application.f90 +antest_maps0.f90 +antest_maps0_glb.f90 +atms_spatial_average_mod.f90 +balmod.f90 +berror.f90 +bias_predictors.f90 +bicg.f90 +bicglanczos.F90 +bkerror.f90 +bkgcov.f90 +bkgvar.f90 +bkgvar_rewgt.f90 +blacklist.f90 +blendmod.f90 +buddycheck_mod.f90 +calc_fov_conical.f90 +calc_fov_crosstrk.f90 +calctends.f90 +calctends_ad.f90 +calctends_no_ad.f90 +calctends_no_tl.f90 +calctends_tl.f90 +chemmod.f90 +class_get_fv3_regional_ensperts.f90 +cloud_efr_mod.f90 +clw_mod.f90 +cmaq_routines.f90 +co_mop_ak.f90 +coinfo.f90 +combine_radobs.f90 +compact_diffs.f90 +compute_derived.f90 +compute_fact10.f90 +compute_qvar3d.f90 +constants.f90 +control2model.f90 +control2model_ad.f90 +control2state.f90 +control2state_ad.f90 +control_vectors.f90 +convb_ps.f90 +convb_q.f90 +convb_t.f90 +convb_uv.f90 +converr.f90 +converr_ps.f90 +converr_pw.f90 +converr_q.f90 +converr_t.f90 +converr_uv.f90 +convinfo.f90 +convthin.f90 +convthin_time.f90 +correlated_obsmod.F90 +cplr_get_fv3_regional_ensperts.f90 +cplr_gfs_ensmod.f90 +cplr_gfs_nstmod.f90 +crtm_interface.f90 +cvsection.f90 +cwhydromod.f90 +derivsmod.f90 +deter_sfc_mod.f90 +dtast.f90 +directDA_radaruse_mod.f90 +egrid2agrid_mod.f90 +en_perts_io.f90 +enorm_state.f90 +ens_spread_mod.f90 +ensctl2model.f90 +ensctl2model_ad.f90 +ensctl2state.f90 +ensctl2state_ad.f90 +evaljgrad.f90 +evaljo.f90 +evalqlim.f90 +fgrid2agrid_mod.f90 +fill_mass_grid2.f90 +fill_nmm_grid2.f90 +fpvsx_ad.f90 +fv3_regional_interface.f90 +general_commvars_mod.f90 +general_read_fv3atm.f90 +general_read_gfsatm.f90 +general_read_nemsaero.f90 +general_read_nmmb.f90 +general_read_nmmb_radar.f90 +general_specmod.f90 +general_spectral_transforms.f90 +general_sub2grid_mod.f90 +general_tll2xy_mod.f90 +general_transform.f90 +general_write_gfsatm.f90 +genex_mod.f90 +gengrid_vars.f90 +genqsat.f90 +genstats_gps.f90 +gesinfo.F90 +get_derivatives.f90 +get_derivatives2.f90 +get_gefs_ensperts_dualres.f90 +get_gefs_for_regional.f90 +get_nmmb_ensperts.f90 +get_semimp_mats.f90 +getcount_bufr.f90 +getprs.f90 +getsiga.f90 +getuv.f90 +getvvel.f90 +gfs_stratosphere.f90 +glbsoi.f90 +grdcrd.f90 +gridmod.F90 +grtest.f90 +gscond_ad.f90 +gsd_terrain_match_surfTobs.f90 +gsd_update_mod.f90 +gsdcloudanalysis.F90 +gsdcloudanalysis4NMMB.F90 +gsdcloudanalysis4gfs.F90 +gsdcloudlib_pseudoq_mod.f90 +gsi_4dcouplermod.f90 +gsi_4dvar.f90 +gsi_aeroOper.F90 +gsi_bias.f90 +gsi_bundlemod.F90 +gsi_chemguess_mod.F90 +gsi_cldchOper.F90 +gsi_cldtotOper.F90 +gsi_colvkOper.F90 +gsi_dbzOper.F90 +gsi_dwOper.F90 +gsi_enscouplermod.f90 +gsi_gpsbendOper.F90 +gsi_gpsrefOper.F90 +gsi_gustOper.F90 +gsi_howvOper.F90 +gsi_io.f90 +gsi_lcbasOper.F90 +gsi_lightOper.F90 +gsi_lwcpOper.F90 +gsi_metguess_mod.F90 +gsi_mitmOper.F90 +gsi_mxtmOper.F90 +gsi_nemsio_mod.f90 +gsi_nstcouplermod.f90 +gsi_o3lOper.F90 +gsi_obOper.F90 +gsi_obOperTypeManager.F90 +gsi_ozOper.F90 +gsi_pblhOper.F90 +gsi_pcpOper.F90 +gsi_pm10Oper.F90 +gsi_pm2_5Oper.F90 +gsi_pmslOper.F90 +gsi_psOper.F90 +gsi_pwOper.F90 +gsi_qOper.F90 +gsi_radOper.F90 +gsi_rfv3io_mod.f90 +gsi_rwOper.F90 +gsi_spdOper.F90 +gsi_sstOper.F90 +gsi_swcpOper.F90 +gsi_tOper.F90 +gsi_tcamtOper.F90 +gsi_tcpOper.F90 +gsi_td2mOper.F90 +gsi_unformatted.F90 +gsi_uwnd10mOper.F90 +gsi_visOper.F90 +gsi_vwnd10mOper.F90 +gsi_wOper.F90 +gsi_wspd10mOper.F90 +gsisub.F90 +guess_grids.F90 +half_nmm_grid2.f90 +hdraobmod.f90 +hilbert_curve.f90 +hybrid_ensemble_isotropic.F90 +hybrid_ensemble_parameters.f90 +inc2guess.f90 +init_jcdfi.f90 +insitu_info.f90 +intall.f90 +intaod.f90 +intcldch.f90 +intco.f90 +intdbz.f90 +intdw.f90 +intgps.f90 +intgust.f90 +inthowv.f90 +intjcmod.f90 +intjo.f90 +intlag.f90 +intlcbas.f90 +intlight.f90 +intlwcp.f90 +intmitm.f90 +intmxtm.f90 +intoz.f90 +intpblh.f90 +intpcp.f90 +intpm10.f90 +intpm2_5.f90 +intpmsl.f90 +intps.f90 +intpw.f90 +intq.f90 +intrad.f90 +intrp2a.f90 +intrp3oz.f90 +intrp_msk.f90 +intrw.f90 +intspd.f90 +intsst.f90 +intswcp.f90 +intt.f90 +inttcamt.f90 +inttcp.f90 +inttd2m.f90 +intuwnd10m.f90 +intvis.f90 +intvwnd10m.f90 +intw.f90 +intwspd10m.f90 +jcmod.f90 +jfunc.f90 +jgrad.f90 +kinds.F90 +lag_fields.f90 +lag_interp.f90 +lag_traj.f90 +lagmod.f90 +lanczos.F90 +lightinfo.f90 +logcldch_to_cldch.f90 +loglcbas_to_lcbas.f90 +logvis_to_vis.f90 +looplimits.f90 +m_aeroNode.F90 +m_aerolNode.F90 +m_berror_stats.f90 +m_berror_stats_reg.f90 +m_cldchNode.F90 +m_colvkNode.F90 +m_cvgridLookup.F90 +m_dbzNode.F90 +m_dgeevx.F90 +m_distance.f90 +m_dtime.F90 +m_dwNode.F90 +m_extOzone.F90 +m_find.f90 +m_gpsNode.F90 +m_gpsrhs.F90 +m_gsiBiases.f90 +m_gustNode.F90 +m_howvNode.F90 +m_lagNode.F90 +m_latlonRange.F90 +m_lcbasNode.F90 +m_lightNode.F90 +m_lwcpNode.F90 +m_mitmNode.F90 +m_mxtmNode.F90 +m_o3lNode.F90 +m_obsLList.F90 +m_obsNode.F90 +m_obsNodeTypeManager.F90 +m_obsdiagNode.F90 +m_obsdiags.F90 +m_ozNode.F90 +m_pblhNode.F90 +m_pcpNode.F90 +m_pm10Node.F90 +m_pm2_5Node.F90 +m_pmslNode.F90 +m_psNode.F90 +m_pwNode.F90 +m_qNode.F90 +m_radNode.F90 +m_rerank.f90 +m_rhs.F90 +m_rwNode.F90 +m_sortind.f90 +m_spdNode.F90 +m_sstNode.F90 +m_stats.f90 +m_stubTimer.f90 +m_swcpNode.F90 +m_tNode.F90 +m_tcamtNode.F90 +m_tcpNode.F90 +m_td2mNode.F90 +m_tick.F90 +m_uniq.f90 +m_uwnd10mNode.F90 +m_visNode.F90 +m_vwnd10mNode.F90 +m_wNode.F90 +m_wspd10mNode.F90 +mod_fv3_lola.f90 +mod_nmmb_to_a.f90 +mod_strong.f90 +mod_vtrans.f90 +mod_wrfmass_to_a.f90 +model_ad.F90 +model_tl.F90 +mp_compact_diffs_mod1.f90 +mp_compact_diffs_support.f90 +mpeu_util.F90 +mpeu_mpif.F90 +mpimod.F90 +mpl_allreduce.F90 +mpl_bcast.f90 +mrmsmod.f90 +native_endianness.f90 +ncepgfs_ghg.f90 +ncepgfs_io.f90 +ncepnems_io.f90 +netcdf_mod.f90 +netcdfgfs_io.f90 +nlmsas_ad.f90 +nltransf.f90 +normal_rh_to_q.f90 +nstio_module.f90 +obs_ferrscale.F90 +obs_para.f90 +obs_sensitivity.f90 +obserr_allsky_mw.f90 +observer.F90 +obsmod.F90 +omegas_ad.f90 +oneobmod.F90 +ozinfo.f90 +patch2grid_mod.f90 +pcgsoi.f90 +pcgsqrt.f90 +pcp_k.f90 +pcpinfo.f90 +penal.f90 +phil.f90 +phil0.f90 +phil1.f90 +phil2.f90 +pietc.f90 +plib8.f90 +pmat.f90 +pmat4.f90 +pmat6.f90 +polcarf.f90 +prad_bias.f90 +precond.f90 +precpd_ad.f90 +prewgt.f90 +prewgt_reg.f90 +projmethod_support.f90 +prt_guess.f90 +psichi2uv_reg.f90 +psichi2uvt_reg.f90 +psort.f90 +pvqc.f90 +pvqc_tables.f90 +q_diag.f90 +qcmod.f90 +qnewton3.f90 +radarZ_global_module.f90 +radarZ_interface.f90 +radarZ_module.f90 +radiance_mod.f90 +radinfo.f90 +raflib.f90 +rapidrefresh_cldsurf_mod.f90 +rdgrbsst.f90 +read_Lightning.f90 +read_NASA_LaRC_cloud.f90 +read_abi.f90 +read_aerosol.f90 +read_ahi.f90 +read_airs.f90 +read_amsr2.f90 +read_amsre.f90 +read_anowbufr.f90 +read_atms.f90 +read_avhrr.f90 +read_avhrr_navy.f90 +read_bufrtovs.f90 +read_co.f90 +read_cris.f90 +read_dbz_nc.f90 +read_dbz_netcdf.f90 +read_diag.f90 +read_files.f90 +read_fl_hdob.f90 +read_gfs_ozone_for_regional.f90 +read_gmi.f90 +read_goesglm.f90 +read_goesimg.f90 +read_goesimgr_skycover.f90 +read_goesndr.f90 +read_gps.f90 +read_guess.F90 +read_iasi.f90 +read_l2bufr_mod.f90 +read_lag.f90 +read_lidar.f90 +read_mitm_mxtm.f90 +read_modsbufr.f90 +read_nasa_larc.f90 +read_nsstbufr.f90 +read_obs.F90 +read_ozone.f90 +read_pblh.f90 +read_pcp.f90 +read_prepbufr.f90 +read_radar.f90 +read_radar_wind_ascii.f90 +read_radarref_mosaic.f90 +read_radarref_mosaic_directDA.f90 +read_rapidscat.f90 +read_saphir.f90 +read_satmar.f90 +read_satwnd.f90 +read_seviri.f90 +read_sfcwnd.f90 +read_ssmi.f90 +read_ssmis.f90 +read_tcps.f90 +read_viirs.f90 +read_wcpbufr.f90 +reorg_metar_cloud.f90 +rfdpar.f90 +rsearch.F90 +rtlnmc_version3.f90 +rtma_comp_fact10.f90 +satthin.F90 +set_crtm_aerosolmod.f90 +set_crtm_cloudmod.f90 +setupaod.f90 +setupbend.f90 +setupcldch.f90 +setupcldtot.F90 +setupco.f90 +setupdbz.f90 +setupdbz_lib.f90 +setupdw.f90 +setupgust.f90 +setuphowv.f90 +setuplag.f90 +setuplcbas.f90 +setuplight.f90 +setuplwcp.f90 +setupmitm.f90 +setupmxtm.f90 +setupoz.f90 +setuppblh.f90 +setuppcp.f90 +setuppm10.f90 +setuppm2_5.f90 +setuppmsl.f90 +setupps.f90 +setuppw.f90 +setupq.f90 +setuprad.f90 +setupref.f90 +setuprhsall.f90 +setuprw.f90 +setupspd.f90 +setupsst.f90 +setupswcp.f90 +setupt.f90 +setuptcamt.f90 +setuptcp.f90 +setuptd2m.f90 +setupuwnd10m.f90 +setupvis.f90 +setupvwnd10m.f90 +setupw.f90 +setupwspd10m.f90 +sfc_model.f90 +sfcobsqc.f90 +simpin1.f90 +simpin1_init.f90 +smooth_polcarf.f90 +smoothrf.f90 +smoothwwrf.f90 +smoothzrf.f90 +sparsearr.f90 +sqrtmin.f90 +ssmis_spatial_average_mod.f90 +sst_retrieval.f90 +state_vectors.f90 +statsco.f90 +statsconv.f90 +statslight.f90 +statsoz.f90 +statspcp.f90 +statsrad.f90 +stop1.f90 +stpaod.f90 +stpcalc.f90 +stpcldch.f90 +stpco.f90 +stpdbz.f90 +stpdw.f90 +stpgps.f90 +stpgust.f90 +stphowv.f90 +stpjcmod.f90 +stpjo.f90 +stplcbas.f90 +stplight.f90 +stplwcp.f90 +stpmitm.f90 +stpmxtm.f90 +stpoz.f90 +stppblh.f90 +stppcp.f90 +stppm10.f90 +stppm2_5.f90 +stppmsl.f90 +stpps.f90 +stppw.f90 +stpq.f90 +stprad.f90 +stprw.f90 +stpspd.f90 +stpsst.f90 +stpswcp.f90 +stpt.f90 +stptcamt.f90 +stptcp.f90 +stptd2m.f90 +stpuwnd10m.f90 +stpvis.f90 +stpvwnd10m.f90 +stpw.f90 +stpwspd10m.f90 +strong_bal_correction.f90 +strong_baldiag_inc.f90 +strong_fast_global_mod.f90 +stub_ensmod.f90 +stub_pertmod.F90 +sub2fslab_mod.f90 +sumslightbias.f90 +support_2dvar.f90 +tcv_mod.f90 +tendsmod.f90 +test_obsens.f90 +timermod.f90 +tintrp2a.f90 +tintrp3.f90 +tpause.f90 +tpause_t.F90 +tune_pbl_height.f90 +turbl.f90 +turbl_ad.f90 +turbl_tl.f90 +turblmod.f90 +tv_to_tsen.f90 +unfill_mass_grid2.f90 +unfill_nmm_grid2.f90 +unhalf_nmm_grid2.f90 +update_guess.f90 +ut_gsibundle.F90 +vqc_int.f90 +vqc_setup.f90 +vqc_stp.f90 +wind_fft.f90 +windht.f90 +wrf_mass_guess_mod.f90 +wrf_params_mod.f90 +wrf_vars_mod.f90 +write_all.F90 +write_bkgvars_grid.f90 +write_fv3_spread.f90 +write_incr.f90 +xhat_vordivmod.f90 +zrnmi_mod.f90 +) + +# Unused files +#nc_diag_read_mod.f90 +#nc_diag_write_mod.f90 +#stub_nstmod.f90 +#Nst_Var_ESMFMod.f90 + diff --git a/src/gsi/gsi_rfv3io_mod.f90 b/src/gsi/gsi_rfv3io_mod.f90 index 496370e7c5..bc2b4ed1f6 100644 --- a/src/gsi/gsi_rfv3io_mod.f90 +++ b/src/gsi/gsi_rfv3io_mod.f90 @@ -79,14 +79,17 @@ module gsi_rfv3io_mod type(sub2grid_info) :: grd_fv3lam_tracer_ionouv type(sub2grid_info) :: grd_fv3lam_uv integer(i_kind) ,parameter:: ndynvarslist=13, ntracerslist=8 - character(len=max_varname_length), parameter :: vardynvars(ndynvarslist) =(/"u","v","u_w","u_s", & - "v_w","v_s","t","tv","tsen","w","delp","ps","delzinc"/) - character(len=max_varname_length), parameter :: vartracers(ntracerslist) =(/'q','oz', & - 'ql','qi','qr','qs','qg','qnr'/) - character(len=max_varname_length), parameter :: varfv3name(15) =(/'u','v','W','T','delp','sphum','o3mr', & - 'liq_wat','ice_wat','rainwat','snowwat','graupel','rain_nc','ps','DZ'/) - character(len=max_varname_length), parameter :: vgsiname(15) =(/'u','v','w','tsen','delp','q','oz', & - 'ql','qi','qr','qs','qg','qnr','ps','delzinc'/) + character(len=max_varname_length), dimension(ndynvarslist), parameter :: & + vardynvars = [character(len=max_varname_length) :: & + "u","v","u_w","u_s","v_w","v_s","t","tv","tsen","w","delp","ps","delzinc"] + character(len=max_varname_length), dimension(ntracerslist), parameter :: & + vartracers = [character(len=max_varname_length) :: & + 'q','oz','ql','qi','qr','qs','qg','qnr'] + character(len=max_varname_length), dimension(15), parameter :: & + varfv3name = [character(len=max_varname_length) :: & + 'u','v','W','T','delp','sphum','o3mr','liq_wat','ice_wat','rainwat','snowwat','graupel','rain_nc','ps','DZ'], & + vgsiname = [character(len=max_varname_length) :: & + 'u','v','w','tsen','delp','q','oz','ql','qi','qr','qs','qg','qnr','ps','delzinc'] character(len=max_varname_length),dimension(:),allocatable:: name_metvars2d character(len=max_varname_length),dimension(:),allocatable:: name_metvars3d diff --git a/src/gsi/netcdfgfs_io.f90 b/src/gsi/netcdfgfs_io.f90 index 5ebf7296bd..41eb05c228 100644 --- a/src/gsi/netcdfgfs_io.f90 +++ b/src/gsi/netcdfgfs_io.f90 @@ -31,7 +31,7 @@ module netcdfgfs_io ! machine: ! ! NOTE: This module adds capability to read netCDF FV3 first guess files -! and to write netCDF FV3 analysis files using the fv3gfs_ncio interface +! and to write netCDF FV3 analysis files using the ncio interface ! Using this is controled by a namelist argument "use_gfs_ncio" ! ! @@ -461,7 +461,7 @@ subroutine read_atm_ (grd,filename,sp_a,uvflag,vordivflag,zflag, & use general_specmod, only: spec_vars use general_sub2grid_mod, only: sub2grid_info use mpimod, only: npe,mpi_comm_world,ierror,mpi_rtype,mype - use module_fv3gfs_ncio, only: Dataset, Variable, Dimension, open_dataset,& + use module_ncio, only: Dataset, Variable, Dimension, open_dataset,& quantize_data,close_dataset, get_dim, read_vardata, get_idate_from_time_units use egrid2agrid_mod,only: g_egrid2agrid,g_create_egrid2agrid,egrid2agrid_parm,destroy_egrid2agrid use constants, only: two,pi,half,deg2rad @@ -934,7 +934,7 @@ subroutine read_sfc_(sfct,soil_moi,sno,soil_temp,veg_frac,fact10,sfc_rough, & use gridmod, only: nlat_sfc,nlon_sfc use guess_grids, only: nfldsfc,ifilesfc use constants, only: zero,two - use module_fv3gfs_ncio, only: Dataset, Variable, Dimension, open_dataset,& + use module_ncio, only: Dataset, Variable, Dimension, open_dataset,& close_dataset, get_dim, read_vardata, get_idate_from_time_units implicit none @@ -1272,7 +1272,7 @@ subroutine read_sfc_anl_(isli_anl) use kinds, only: r_kind,i_kind,r_single use gridmod, only: nlat,nlon use constants, only: zero - use module_fv3gfs_ncio, only: Dataset, Variable, Dimension, open_dataset,& + use module_ncio, only: Dataset, Variable, Dimension, open_dataset,& close_dataset, get_dim, read_vardata, get_idate_from_time_units implicit none @@ -1436,7 +1436,7 @@ subroutine read_nst_ (tref,dt_cool,z_c,dt_warm,z_w,c_0,c_d,w_0,w_d) use gridmod, only: nlat_sfc,nlon_sfc use constants, only: zero,two use guess_grids, only: nfldnst,ifilenst - use module_fv3gfs_ncio, only: Dataset, Variable, Dimension, open_dataset,& + use module_ncio, only: Dataset, Variable, Dimension, open_dataset,& close_dataset, get_dim, read_vardata, get_idate_from_time_units implicit none @@ -1677,7 +1677,7 @@ subroutine write_atm_ (grd,sp_a,filename,mype_out,gfs_bundle,ibin) use cloud_efr_mod, only: cloud_calc_gfs use netcdf, only: nf90_max_name - use module_fv3gfs_ncio, only: open_dataset, close_dataset, Dimension, Dataset,& + use module_ncio, only: open_dataset, close_dataset, Dimension, Dataset,& read_attribute, write_attribute,get_dim, create_dataset, write_vardata, read_vardata,& get_idate_from_time_units,quantize_data,get_time_units_from_idate,has_attr,has_var use ncepnems_io, only: error_msg @@ -2383,7 +2383,7 @@ subroutine write_sfc_ (filename,mype_sfc,dsfct) use constants, only: zero use netcdf, only: nf90_max_name - use module_fv3gfs_ncio, only: open_dataset, close_dataset, Dimension, Dataset,& + use module_ncio, only: open_dataset, close_dataset, Dimension, Dataset,& get_dim, create_dataset, write_vardata, read_vardata,& get_time_units_from_idate, write_attribute @@ -2592,7 +2592,7 @@ subroutine write_sfc_nst_ (mype_so,dsfct) use gsi_nstcouplermod, only: nst_gsi,zsea1,zsea2 use gridmod, only: rlats,rlons,rlats_sfc,rlons_sfc - use module_fv3gfs_ncio, only: open_dataset, close_dataset, Dimension, Dataset,& + use module_ncio, only: open_dataset, close_dataset, Dimension, Dataset,& get_dim, create_dataset, write_vardata, read_vardata,& get_time_units_from_idate, write_attribute use netcdf, only: nf90_max_name diff --git a/src/gsi/read_files.f90 b/src/gsi/read_files.f90 index 6f1e7a1488..93ddd17bf7 100644 --- a/src/gsi/read_files.f90 +++ b/src/gsi/read_files.f90 @@ -98,7 +98,7 @@ subroutine read_files(mype) use nemsio_module, only: nemsio_gfile,nemsio_getfilehead,nemsio_getheadvar use read_obsmod, only: gsi_inquire use gsi_io, only: verbose - use module_fv3gfs_ncio, only: Dataset, Dimension, open_dataset, get_dim, & + use module_ncio, only: Dataset, Dimension, open_dataset, get_dim, & read_vardata, get_idate_from_time_units, & close_dataset use chemmod, only: lread_ext_aerosol diff --git a/src/gsi/read_gfs_ozone_for_regional.f90 b/src/gsi/read_gfs_ozone_for_regional.f90 index 8b2b9ffcb2..5b6acce30b 100644 --- a/src/gsi/read_gfs_ozone_for_regional.f90 +++ b/src/gsi/read_gfs_ozone_for_regional.f90 @@ -66,7 +66,7 @@ subroutine read_gfs_ozone_for_regional use nemsio_module, only: nemsio_init,nemsio_open,nemsio_close use ncepnems_io, only: error_msg use nemsio_module, only: nemsio_gfile,nemsio_getfilehead - use module_fv3gfs_ncio, only: Dataset, Dimension, get_dim, read_vardata,& + use module_ncio, only: Dataset, Dimension, get_dim, read_vardata,& open_dataset, close_dataset, read_attribute,& get_idate_from_time_units diff --git a/src/ncdiag/CMakeLists.txt b/src/ncdiag/CMakeLists.txt index 93c0ce9156..6c3c287185 100644 --- a/src/ncdiag/CMakeLists.txt +++ b/src/ncdiag/CMakeLists.txt @@ -1,26 +1,113 @@ -cmake_minimum_required(VERSION 3.16.1) -if(BUILD_NCDIAG) - if(BUILD_NCDIAG_SERIAL) - add_subdirectory(serial) - endif(BUILD_NCDIAG_SERIAL) - set(Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include") - - # NetCDF-4 library - include_directories( ${NETCDF_INCLUDE_DIRS} ${NCDIAG_INCS} ) - - # 32-bit reals, for now - add_definitions(-D_REAL4_ -DUSE_MPI) - FILE(GLOB NCDIAG_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set_source_files_properties( ${NCDIAG_SRC} PROPERTIES COMPILE_FLAGS ${NCDIAG_Fortran_FLAGS} ) - LIST(REMOVE_ITEM NCDIAG_SRC ${CMAKE_CURRENT_SOURCE_DIR}/test_nc_unlimdims.F90 ) - LIST(REMOVE_ITEM NCDIAG_SRC ${CMAKE_CURRENT_SOURCE_DIR}/nc_diag_cat.F90 ) - add_library(ncdiag STATIC ${NCDIAG_SRC}) - add_executable(test_nc_unlimdims.x ${CMAKE_CURRENT_SOURCE_DIR}/test_nc_unlimdims.F90 ) - add_executable(ncdiag_cat_mpi.x ${CMAKE_CURRENT_SOURCE_DIR}/nc_diag_cat.F90 ) - target_link_libraries(ncdiag_cat_mpi.x ncdiag ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES}) - target_link_libraries(test_nc_unlimdims.x ncdiag ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES}) -# set_target_properties(test_nc_unlimdims.x PROPERTIES Fortran_MODULE_DIRECTORY ${NCDIAG_INCS} ) -# set_target_properties(ncdiag_cat_mpi.x PROPERTIES Fortran_MODULE_DIRECTORY ${NCDIAG_INCS} ${MPI_Fortran_INCLUDE_PATH}) - -endif(BUILD_NCDIAG) +cmake_minimum_required(VERSION 3.19) +project(ncdiag + VERSION 1.0.0 + LANGUAGES Fortran) + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") + +include(${PROJECT_NAME}_compiler_flags) +include(GNUInstallDirs) + +if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel)$") + message(STATUS "Setting build type to 'Release' as none was specified.") + set(CMAKE_BUILD_TYPE + "Release" + CACHE STRING "Choose the type of build." FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") +endif() + +if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU|Intel)$") + message(WARNING "${CMAKE_Fortran_COMPILER_ID} is not supported.") +endif() + +option(ENABLE_NCDIAG_SERIAL "Enable Serial NetCDF diagnostics" ON) + +# Dependencies +find_package(MPI REQUIRED) +find_package(NetCDF REQUIRED COMPONENTS Fortran) + +# Echo user options +message(STATUS "ENABLE_NCDIAG_SERIAL ... ${ENABLE_NCDIAG_SERIAL}") + +# Get list of files +include(ncdiag_files.cmake) + +set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/ncdiag") +add_library(ncdiag STATIC ${NCDIAG_SRC_lib}) +add_library(${PROJECT_NAME}::ncdiag ALIAS ncdiag) +set_target_properties(ncdiag PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") +target_compile_definitions(ncdiag PRIVATE "_REAL4_") +target_compile_definitions(ncdiag PRIVATE "USE_MPI") +target_link_libraries(ncdiag PUBLIC NetCDF::NetCDF_Fortran) +target_link_libraries(ncdiag PUBLIC MPI::MPI_Fortran) +target_include_directories(ncdiag PUBLIC $ + $) +list(APPEND NCDIAG_Targets ncdiag) +install(DIRECTORY ${module_dir} DESTINATION ${CMAKE_INSTALL_PREFIX}/include) + +# Build applications +foreach(app ${NCDIAG_SRC_app}) + get_filename_component(app_name ${app} NAME_WLE) + add_executable(${app_name}.x ${app}) + add_dependencies(${app_name}.x ncdiag) + target_compile_definitions(${app_name}.x PRIVATE "USE_MPI") + target_link_libraries(${app_name}.x PUBLIC ncdiag) + target_link_libraries(${app_name}.x PUBLIC NetCDF::NetCDF_Fortran) + target_link_libraries(${app_name}.x PUBLIC MPI::MPI_Fortran) + list(APPEND NCDIAG_Targets ${app_name}.x) +endforeach() + +# Build serial library and applications +if(ENABLE_NCDIAG_SERIAL) + set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/ncdiag_serial") + add_library(ncdiag_serial STATIC ${NCDIAG_SRC_lib}) + add_library(${PROJECT_NAME}::ncdiag_serial ALIAS ncdiag_serial) + set_target_properties(ncdiag_serial PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") + target_compile_definitions(ncdiag_serial PRIVATE "_REAL4_") + target_link_libraries(ncdiag_serial PUBLIC NetCDF::NetCDF_Fortran) + target_include_directories(ncdiag_serial PUBLIC $ + $) + list(APPEND NCDIAG_Targets ncdiag_serial) + + set(app_name "ncdiag_cat_serial") + add_executable(${app_name}.x nc_diag_cat.F90) + add_dependencies(${app_name}.x ncdiag_serial) + target_link_libraries(${app_name}.x PUBLIC ncdiag_serial) + target_link_libraries(${app_name}.x PUBLIC NetCDF::NetCDF_Fortran) + list(APPEND NCDIAG_Targets ${app_name}.x) + install(DIRECTORY ${module_dir} DESTINATION ${CMAKE_INSTALL_PREFIX}/include) +endif() + +install( + TARGETS ${NCDIAG_Targets} + EXPORT ${PROJECT_NAME}Exports + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +# Package config +include(CMakePackageConfigHelpers) +set(CONFIG_INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) + +export(EXPORT ${PROJECT_NAME}Exports + NAMESPACE ${PROJECT_NAME}:: + FILE ${PROJECT_NAME}-targets.cmake) + +configure_package_config_file( + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/PackageConfig.cmake.in ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config.cmake + INSTALL_DESTINATION ${CONFIG_INSTALL_DESTINATION}) +install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config.cmake + DESTINATION ${CONFIG_INSTALL_DESTINATION}) + +write_basic_package_version_file( + ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake + VERSION ${PROJECT_VERSION} + COMPATIBILITY AnyNewerVersion) +install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake + DESTINATION ${CONFIG_INSTALL_DESTINATION}) + +install(EXPORT ${PROJECT_NAME}Exports + NAMESPACE ${PROJECT_NAME}:: + FILE ${PROJECT_NAME}-targets.cmake + DESTINATION ${CONFIG_INSTALL_DESTINATION}) diff --git a/src/ncdiag/cmake/FindNetCDF.cmake b/src/ncdiag/cmake/FindNetCDF.cmake new file mode 100644 index 0000000000..9e32378ff5 --- /dev/null +++ b/src/ncdiag/cmake/FindNetCDF.cmake @@ -0,0 +1,347 @@ +# (C) Copyright 2011- ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# 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. + +# Try to find NetCDF includes and library. +# Supports static and shared libaries and allows each component to be found in sepearte prefixes. +# +# This module defines +# +# - NetCDF_FOUND - System has NetCDF +# - NetCDF_INCLUDE_DIRS - the NetCDF include directories +# - NetCDF_VERSION - the version of NetCDF +# - NetCDF_CONFIG_EXECUTABLE - the netcdf-config executable if found +# - NetCDF_PARALLEL - Boolean True if NetCDF4 has parallel IO support via hdf5 and/or pnetcdf +# - NetCDF_HAS_PNETCDF - Boolean True if NetCDF4 has pnetcdf support +# +# Deprecated Defines +# - NetCDF_LIBRARIES - [Deprecated] Use NetCDF::NetCDF_ targets instead. +# +# +# Following components are available: +# +# - C - C interface to NetCDF (netcdf) +# - CXX - CXX4 interface to NetCDF (netcdf_c++4) +# - Fortran - Fortran interface to NetCDF (netcdff) +# +# For each component the following are defined: +# +# - NetCDF__FOUND - whether the component is found +# - NetCDF__LIBRARIES - the libraries for the component +# - NetCDF__LIBRARY_SHARED - Boolean is true if libraries for component are shared +# - NetCDF__INCLUDE_DIRS - the include directories for specified component +# - NetCDF::NetCDF_ - target of component to be used with target_link_libraries() +# +# The following paths will be searched in order if set in CMake (first priority) or environment (second priority) +# +# - NetCDF_ROOT - root of NetCDF installation +# - NetCDF_PATH - root of NetCDF installation +# +# The search process begins with locating NetCDF Include headers. If these are in a non-standard location, +# set one of the following CMake or environment variables to point to the location: +# +# - NetCDF_INCLUDE_DIR or NetCDF_${comp}_INCLUDE_DIR +# - NetCDF_INCLUDE_DIRS or NetCDF_${comp}_INCLUDE_DIR +# +# Notes: +# +# - Use "NetCDF::NetCDF_" targets only. NetCDF_LIBRARIES exists for backwards compatibility and should not be used. +# - These targets have all the knowledge of include directories and library search directories, and a single +# call to target_link_libraries will provide all these transitive properties to your target. Normally all that is +# needed to build and link against NetCDF is, e.g.: +# target_link_libraries(my_c_tgt PUBLIC NetCDF::NetCDF_C) +# - "NetCDF" is always the preferred naming for this package, its targets, variables, and environment variables +# - For compatibility, some variables are also set/checked using alternate names NetCDF4, NETCDF, or NETCDF4 +# - Environments relying on these older environment variable names should move to using a "NetCDF_ROOT" environment variable +# - Preferred component capitalization follows the CMake LANGUAGES variables: i.e., C, Fortran, CXX +# - For compatibility, alternate capitalizations are supported but should not be used. +# - If no components are defined, all components will be searched +# + +list( APPEND _possible_components C CXX Fortran ) + +## Include names for each component +set( NetCDF_C_INCLUDE_NAME netcdf.h ) +set( NetCDF_CXX_INCLUDE_NAME netcdf ) +set( NetCDF_Fortran_INCLUDE_NAME netcdf.mod ) + +## Library names for each component +set( NetCDF_C_LIBRARY_NAME netcdf ) +set( NetCDF_CXX_LIBRARY_NAME netcdf_c++4 ) +set( NetCDF_Fortran_LIBRARY_NAME netcdff ) + +## Enumerate search components +foreach( _comp ${_possible_components} ) + string( TOUPPER "${_comp}" _COMP ) + set( _arg_${_COMP} ${_comp} ) + set( _name_${_COMP} ${_comp} ) +endforeach() + +set( _search_components C) +foreach( _comp ${${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS} ) + string( TOUPPER "${_comp}" _COMP ) + set( _arg_${_COMP} ${_comp} ) + list( APPEND _search_components ${_name_${_COMP}} ) + if( NOT _name_${_COMP} ) + message(SEND_ERROR "Find${CMAKE_FIND_PACKAGE_NAME}: COMPONENT ${_comp} is not a valid component. Valid components: ${_possible_components}" ) + endif() +endforeach() +list( REMOVE_DUPLICATES _search_components ) + +## Search hints for finding include directories and libraries +foreach( _comp IN ITEMS "_" "_C_" "_Fortran_" "_CXX_" ) + foreach( _name IN ITEMS NetCDF4 NetCDF NETCDF4 NETCDF ) + foreach( _var IN ITEMS ROOT PATH ) + list(APPEND _search_hints ${${_name}${_comp}${_var}} $ENV{${_name}${_comp}${_var}} ) + list(APPEND _include_search_hints + ${${_name}${_comp}INCLUDE_DIR} $ENV{${_name}${_comp}INCLUDE_DIR} + ${${_name}${_comp}INCLUDE_DIRS} $ENV{${_name}${_comp}INCLUDE_DIRS} ) + endforeach() + endforeach() +endforeach() +#Old-school HPC module env variable names +foreach( _name IN ITEMS NetCDF4 NetCDF NETCDF4 NETCDF ) + foreach( _comp IN ITEMS "_C" "_Fortran" "_CXX" ) + list(APPEND _search_hints ${${_name}} $ENV{${_name}}) + list(APPEND _search_hints ${${_name}${_comp}} $ENV{${_name}${_comp}}) + endforeach() +endforeach() + +## Find headers for each component +set(NetCDF_INCLUDE_DIRS) +set(_new_search_components) +foreach( _comp IN LISTS _search_components ) + if(NOT ${PROJECT_NAME}_NetCDF_${_comp}_FOUND) + list(APPEND _new_search_components ${_comp}) + endif() + find_file(NetCDF_${_comp}_INCLUDE_FILE + NAMES ${NetCDF_${_comp}_INCLUDE_NAME} + DOC "NetCDF ${_comp} include directory" + HINTS ${_include_search_hints} ${_search_hints} + PATH_SUFFIXES include include/netcdf + ) + mark_as_advanced(NetCDF_${_comp}_INCLUDE_FILE) + message(DEBUG "NetCDF_${_comp}_INCLUDE_FILE: ${NetCDF_${_comp}_INCLUDE_FILE}") + if( NetCDF_${_comp}_INCLUDE_FILE ) + get_filename_component(NetCDF_${_comp}_INCLUDE_FILE ${NetCDF_${_comp}_INCLUDE_FILE} ABSOLUTE) + get_filename_component(NetCDF_${_comp}_INCLUDE_DIR ${NetCDF_${_comp}_INCLUDE_FILE} DIRECTORY) + list(APPEND NetCDF_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIR}) + endif() +endforeach() +if(NetCDF_INCLUDE_DIRS) + list(REMOVE_DUPLICATES NetCDF_INCLUDE_DIRS) +endif() +set(NetCDF_INCLUDE_DIRS "${NetCDF_INCLUDE_DIRS}" CACHE STRING "NetCDF Include directory paths" FORCE) + +## Find n*-config executables for search components +foreach( _comp IN LISTS _search_components ) + if( _comp MATCHES "^(C)$" ) + set(_conf "c") + elseif( _comp MATCHES "^(Fortran)$" ) + set(_conf "f") + elseif( _comp MATCHES "^(CXX)$" ) + set(_conf "cxx4") + endif() + find_program( NetCDF_${_comp}_CONFIG_EXECUTABLE + NAMES n${_conf}-config + HINTS ${NetCDF_INCLUDE_DIRS} ${_include_search_hints} ${_search_hints} + PATH_SUFFIXES bin Bin ../bin ../../bin + DOC "NetCDF n${_conf}-config helper" ) + message(DEBUG "NetCDF_${_comp}_CONFIG_EXECUTABLE: ${NetCDF_${_comp}_CONFIG_EXECUTABLE}") +endforeach() + +set(_C_libs_flag --libs) +set(_Fortran_libs_flag --flibs) +set(_CXX_libs_flag --libs) +set(_C_includes_flag --includedir) +set(_Fortran_includes_flag --includedir) +set(_CXX_includes_flag --includedir) +function(netcdf_config exec flag output_var) + set(${output_var} False PARENT_SCOPE) + if( exec ) + execute_process( COMMAND ${exec} ${flag} RESULT_VARIABLE _ret OUTPUT_VARIABLE _val) + if( _ret EQUAL 0 ) + string( STRIP ${_val} _val ) + set( ${output_var} ${_val} PARENT_SCOPE ) + endif() + endif() +endfunction() + +## Detect additional package properties +netcdf_config(${NetCDF_C_CONFIG_EXECUTABLE} --has-parallel4 _val) +if( NOT _val MATCHES "^(yes|no)$" ) + netcdf_config(${NetCDF_C_CONFIG_EXECUTABLE} --has-parallel _val) +endif() +if( _val MATCHES "^(yes)$" ) + set(NetCDF_PARALLEL TRUE CACHE STRING "NetCDF has parallel IO capability via pnetcdf or hdf5." FORCE) +else() + set(NetCDF_PARALLEL FALSE CACHE STRING "NetCDF has no parallel IO capability." FORCE) +endif() + +if(NetCDF_PARALLEL) + find_package(MPI REQUIRED) +endif() + +## Find libraries for each component +set( NetCDF_LIBRARIES ) +foreach( _comp IN LISTS _search_components ) + string( TOUPPER "${_comp}" _COMP ) + + find_library( NetCDF_${_comp}_LIBRARY + NAMES ${NetCDF_${_comp}_LIBRARY_NAME} + DOC "NetCDF ${_comp} library" + HINTS ${NetCDF_${_comp}_INCLUDE_DIRS} ${_search_hints} + PATH_SUFFIXES lib64 lib ../lib64 ../lib ../../lib64 ../../lib ) + mark_as_advanced( NetCDF_${_comp}_LIBRARY ) + get_filename_component(NetCDF_${_comp}_LIBRARY ${NetCDF_${_comp}_LIBRARY} ABSOLUTE) + set(NetCDF_${_comp}_LIBRARY ${NetCDF_${_comp}_LIBRARY} CACHE STRING "NetCDF ${_comp} library" FORCE) + message(DEBUG "NetCDF_${_comp}_LIBRARY: ${NetCDF_${_comp}_LIBRARY}") + + if( NetCDF_${_comp}_LIBRARY ) + if( NetCDF_${_comp}_LIBRARY MATCHES ".a$" ) + set( NetCDF_${_comp}_LIBRARY_SHARED FALSE ) + set( _library_type STATIC) + else() + list( APPEND NetCDF_LIBRARIES ${NetCDF_${_comp}_LIBRARY} ) + set( NetCDF_${_comp}_LIBRARY_SHARED TRUE ) + set( _library_type SHARED) + endif() + endif() + + #Use nc-config to set per-component LIBRARIES variable if possible + netcdf_config( ${NetCDF_${_comp}_CONFIG_EXECUTABLE} ${_${_comp}_libs_flag} _val ) + if( _val ) + set( NetCDF_${_comp}_LIBRARIES ${_val} ) + if(NOT NetCDF_${_comp}_LIBRARY_SHARED AND NOT NetCDF_${_comp}_FOUND) #Static targets should use nc_config to get a proper link line with all necessary static targets. + list( APPEND NetCDF_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) + endif() + else() + set( NetCDF_${_comp}_LIBRARIES ${NetCDF_${_comp}_LIBRARY} ) + if(NOT NetCDF_${_comp}_LIBRARY_SHARED) + message(SEND_ERROR "Unable to properly find NetCDF. Found static libraries at: ${NetCDF_${_comp}_LIBRARY} but could not run nc-config: ${NetCDF_CONFIG_EXECUTABLE}") + endif() + endif() + + #Use nc-config to set per-component INCLUDE_DIRS variable if possible + netcdf_config( ${NetCDF_${_comp}_CONFIG_EXECUTABLE} ${_${_comp}_includes_flag} _val ) + if( _val ) + string( REPLACE " " ";" _val ${_val} ) + set( NetCDF_${_comp}_INCLUDE_DIRS ${_val} ) + else() + set( NetCDF_${_comp}_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIR} ) + endif() + + if( NetCDF_${_comp}_LIBRARIES AND NetCDF_${_comp}_INCLUDE_DIRS ) + set( ${CMAKE_FIND_PACKAGE_NAME}_${_arg_${_COMP}}_FOUND TRUE ) + if (NOT TARGET NetCDF::NetCDF_${_comp}) + add_library(NetCDF::NetCDF_${_comp} ${_library_type} IMPORTED) + set_target_properties(NetCDF::NetCDF_${_comp} PROPERTIES + IMPORTED_LOCATION ${NetCDF_${_comp}_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES "${NetCDF_${_comp}_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) + if( NOT _comp MATCHES "^(C)$" ) + target_link_libraries(NetCDF::NetCDF_${_comp} INTERFACE NetCDF::NetCDF_C) + endif() + if(MPI_${_comp}_FOUND) + target_link_libraries(NetCDF::NetCDF_${_comp} INTERFACE MPI::MPI_${_comp}) + endif() + endif() + endif() +endforeach() +if(NetCDF_LIBRARIES AND NetCDF_${_comp}_LIBRARY_SHARED) + list(REMOVE_DUPLICATES NetCDF_LIBRARIES) +endif() +set(NetCDF_LIBRARIES "${NetCDF_LIBRARIES}" CACHE STRING "NetCDF library targets" FORCE) + +## Find version via netcdf-config if possible +if (NetCDF_INCLUDE_DIRS) + if( NetCDF_C_CONFIG_EXECUTABLE ) + netcdf_config( ${NetCDF_C_CONFIG_EXECUTABLE} --version _vers ) + if( _vers ) + string(REGEX REPLACE ".* ((([0-9]+)\\.)+([0-9]+)).*" "\\1" NetCDF_VERSION "${_vers}" ) + endif() + else() + foreach( _dir IN LISTS NetCDF_INCLUDE_DIRS) + if( EXISTS "${_dir}/netcdf_meta.h" ) + file(STRINGS "${_dir}/netcdf_meta.h" _netcdf_version_lines + REGEX "#define[ \t]+NC_VERSION_(MAJOR|MINOR|PATCH|NOTE)") + string(REGEX REPLACE ".*NC_VERSION_MAJOR *\([0-9]*\).*" "\\1" _netcdf_version_major "${_netcdf_version_lines}") + string(REGEX REPLACE ".*NC_VERSION_MINOR *\([0-9]*\).*" "\\1" _netcdf_version_minor "${_netcdf_version_lines}") + string(REGEX REPLACE ".*NC_VERSION_PATCH *\([0-9]*\).*" "\\1" _netcdf_version_patch "${_netcdf_version_lines}") + string(REGEX REPLACE ".*NC_VERSION_NOTE *\"\([^\"]*\)\".*" "\\1" _netcdf_version_note "${_netcdf_version_lines}") + set(NetCDF_VERSION "${_netcdf_version_major}.${_netcdf_version_minor}.${_netcdf_version_patch}${_netcdf_version_note}") + unset(_netcdf_version_major) + unset(_netcdf_version_minor) + unset(_netcdf_version_patch) + unset(_netcdf_version_note) + unset(_netcdf_version_lines) + endif() + endforeach() + endif() +endif () + +## Finalize find_package +include(FindPackageHandleStandardArgs) + +if(NOT NetCDF_FOUND OR _new_search_components) + find_package_handle_standard_args( ${CMAKE_FIND_PACKAGE_NAME} + REQUIRED_VARS NetCDF_INCLUDE_DIRS NetCDF_LIBRARIES + VERSION_VAR NetCDF_VERSION + HANDLE_COMPONENTS ) +endif() + +foreach( _comp IN LISTS _search_components ) + if( NetCDF_${_comp}_FOUND ) + #Record found components to avoid duplication in NetCDF_LIBRARIES for static libraries + set(NetCDF_${_comp}_FOUND ${NetCDF_${_comp}_FOUND} CACHE BOOL "NetCDF ${_comp} Found" FORCE) + #Set a per-package, per-component found variable to communicate between multiple calls to find_package() + set(${PROJECT_NAME}_NetCDF_${_comp}_FOUND True) + endif() +endforeach() + +if( ${CMAKE_FIND_PACKAGE_NAME}_FOUND AND NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY AND _new_search_components) + message( STATUS "Find${CMAKE_FIND_PACKAGE_NAME} defines targets:" ) + message( STATUS " - NetCDF_VERSION [${NetCDF_VERSION}]") + message( STATUS " - NetCDF_PARALLEL [${NetCDF_PARALLEL}]") + foreach( _comp IN LISTS _new_search_components ) + string( TOUPPER "${_comp}" _COMP ) + message( STATUS " - NetCDF_${_comp}_CONFIG_EXECUTABLE [${NetCDF_${_comp}_CONFIG_EXECUTABLE}]") + if( ${CMAKE_FIND_PACKAGE_NAME}_${_arg_${_COMP}}_FOUND ) + get_filename_component(_root ${NetCDF_${_comp}_INCLUDE_DIR}/.. ABSOLUTE) + if( NetCDF_${_comp}_LIBRARY_SHARED ) + message( STATUS " - NetCDF::NetCDF_${_comp} [SHARED] [Root: ${_root}] Lib: ${NetCDF_${_comp}_LIBRARY} ") + else() + message( STATUS " - NetCDF::NetCDF_${_comp} [STATIC] [Root: ${_root}] Lib: ${NetCDF_${_comp}_LIBRARY} ") + endif() + endif() + endforeach() +endif() + +foreach( _prefix NetCDF NetCDF4 NETCDF NETCDF4 ${CMAKE_FIND_PACKAGE_NAME} ) + set( ${_prefix}_INCLUDE_DIRS ${NetCDF_INCLUDE_DIRS} ) + set( ${_prefix}_LIBRARIES ${NetCDF_LIBRARIES}) + set( ${_prefix}_VERSION ${NetCDF_VERSION} ) + set( ${_prefix}_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_FOUND} ) + set( ${_prefix}_CONFIG_EXECUTABLE ${NetCDF_CONFIG_EXECUTABLE} ) + set( ${_prefix}_PARALLEL ${NetCDF_PARALLEL} ) + + foreach( _comp ${_search_components} ) + string( TOUPPER "${_comp}" _COMP ) + set( _arg_comp ${_arg_${_COMP}} ) + set( ${_prefix}_${_comp}_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_${_arg_comp}_FOUND} ) + set( ${_prefix}_${_COMP}_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_${_arg_comp}_FOUND} ) + set( ${_prefix}_${_arg_comp}_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_${_arg_comp}_FOUND} ) + + set( ${_prefix}_${_comp}_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) + set( ${_prefix}_${_COMP}_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) + set( ${_prefix}_${_arg_comp}_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) + + set( ${_prefix}_${_comp}_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIRS} ) + set( ${_prefix}_${_COMP}_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIRS} ) + set( ${_prefix}_${_arg_comp}_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIRS} ) + endforeach() +endforeach() diff --git a/src/ncdiag/cmake/PackageConfig.cmake.in b/src/ncdiag/cmake/PackageConfig.cmake.in new file mode 100644 index 0000000000..ba16512dfc --- /dev/null +++ b/src/ncdiag/cmake/PackageConfig.cmake.in @@ -0,0 +1,19 @@ +@PACKAGE_INIT@ + +# * @PROJECT_NAME@::@PROJECT_NAME@ - library target +# * @PROJECT_NAME@::@PROJECT_NAME@_serial - serial library target + +# Include targets file. This will create IMPORTED target @PROJECT_NAME@ +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake") +include(CMakeFindDependencyMacro) + +find_dependency(MPI REQUIRED) +find_dependency(NetCDF REQUIRED COMPONENTS Fortran) + +# Get the build type from real32 library target with dyanmic allocation +get_target_property(@PROJECT_NAME@_BUILD_TYPES @PROJECT_NAME@::@PROJECT_NAME@ IMPORTED_CONFIGURATIONS) + +check_required_components("@PROJECT_NAME@") + +get_target_property(location @PROJECT_NAME@::@PROJECT_NAME@ LOCATION) +message(STATUS "Found @PROJECT_NAME@: ${location} (found version \"@PROJECT_VERSION@\")") diff --git a/src/ncdiag/cmake/ncdiag_compiler_flags.cmake b/src/ncdiag/cmake/ncdiag_compiler_flags.cmake new file mode 100644 index 0000000000..c61631da53 --- /dev/null +++ b/src/ncdiag/cmake/ncdiag_compiler_flags.cmake @@ -0,0 +1,15 @@ +if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") + add_definitions(-DNDEBUG) +endif() + +####################################################################################### +# Fortran +####################################################################################### + +if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") + include(ncdiag_compiler_flags_GNU_Fortran) +elseif( CMAKE_Fortran_COMPILER_ID MATCHES "Intel") + include(ncdiag_compiler_flags_Intel_Fortran) +else() + message(STATUS "Fortran compiler with ID ${CMAKE_Fortran_COMPILER_ID} will be used with CMake default options") +endif() diff --git a/src/ncdiag/cmake/ncdiag_compiler_flags_GNU_Fortran.cmake b/src/ncdiag/cmake/ncdiag_compiler_flags_GNU_Fortran.cmake new file mode 100644 index 0000000000..b057c72026 --- /dev/null +++ b/src/ncdiag/cmake/ncdiag_compiler_flags_GNU_Fortran.cmake @@ -0,0 +1,41 @@ +#################################################################### +# FLAGS COMMON TO ALL BUILD TYPES +#################################################################### + +set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -fbacktrace -ffree-line-length-none") + +if(${CMAKE_Fortran_COMPILER_VERSION} VERSION_GREATER_EQUAL 10) + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-argument-mismatch -fallow-invalid-boz") +endif() + +#################################################################### +# RELEASE FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_RELEASE "-O2 -funroll-all-loops -finline-functions ") + +#################################################################### +# DEBUG FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -ggdb -Wall -fcheck=bounds -ffpe-trap=invalid,zero,overflow") + +#################################################################### +# LINK FLAGS +#################################################################### + +set(CMAKE_Fortran_LINK_FLAGS "") + +#################################################################### +# FLAGS FOR AUTOPROFILING +#################################################################### + +set(Fortran_AUTOPROFILING_FLAGS "-finstrument-functions") + +#################################################################### + +# Meaning of flags +# ---------------- +# -fstack-arrays : Allocate automatic arrays on the stack (needs large stacksize!!!) +# -funroll-all-loops : Unroll all loops +# -fcheck=bounds : Bounds checking diff --git a/src/ncdiag/cmake/ncdiag_compiler_flags_Intel_Fortran.cmake b/src/ncdiag/cmake/ncdiag_compiler_flags_Intel_Fortran.cmake new file mode 100644 index 0000000000..a25d6cc301 --- /dev/null +++ b/src/ncdiag/cmake/ncdiag_compiler_flags_Intel_Fortran.cmake @@ -0,0 +1,35 @@ +#################################################################### +# FLAGS COMMON TO ALL BUILD TYPES +#################################################################### + +set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -assume byterecl -convert big_endian -implicitnone") + +#################################################################### +# RELEASE FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -fp-model strict") + +#################################################################### +# DEBUG FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -check bounds -warn -heap-arrays -fpe-all=0 -fpe:0 -check all") + +#################################################################### +# LINK FLAGS +#################################################################### + +set(CMAKE_Fortran_LINK_FLAGS "") + +#################################################################### +# FLAGS FOR AUTOPROFILING +#################################################################### + +set(Fortran_AUTOPROFILING_FLAGS "-finstrument-functions") + +#################################################################### + +# Meaning of flags +# ---------------- +# todo diff --git a/src/ncdiag/ncdf_string_m.f90 b/src/ncdiag/ncdf_string_m.f90 index 8c6a4e1394..9f4e3321ac 100644 --- a/src/ncdiag/ncdf_string_m.f90 +++ b/src/ncdiag/ncdf_string_m.f90 @@ -28,7 +28,7 @@ module ncdf_string_m private public :: ncdf_string, ncdf_string_create, ncdf_string_destroy, ncdf_ncdf_string_length, ncdf_string_append,& - ncdf_ncdf_string_clear + ncdf_string_clear public :: ncdf_string_equals, ncdf_string_copy integer, parameter :: BLOCK_SIZE = 32 @@ -172,7 +172,7 @@ end subroutine ncdf_append_char subroutine ncdf_copy_chars(this, to) type(ncdf_string), pointer :: this character(len = *), intent(inout) :: to - integer :: length + integer :: i, length length = min(ncdf_string_length(this), len(to)) diff --git a/src/ncdiag/ncdiag_files.cmake b/src/ncdiag/ncdiag_files.cmake new file mode 100644 index 0000000000..9c166de851 --- /dev/null +++ b/src/ncdiag/ncdiag_files.cmake @@ -0,0 +1,53 @@ +list(APPEND NCDIAG_SRC_lib +nc_diag_fson.f90 +nc_diag_read_mod.F90 +nc_diag_res.f90 +nc_diag_write_mod.F90 +ncd_kinds.F90 +ncdc_cli_process.F90 +ncdc_climsg.F90 +ncdc_data.F90 +ncdc_data_MPI.F90 +ncdc_dims.F90 +ncdc_metadata.F90 +ncdc_realloc.F90 +ncdc_state.F90 +ncdc_types.f90 +ncdc_vars.F90 +ncdf_path_m.F90 +ncdf_string_m.f90 +ncdf_value_m.f90 +ncdr_alloc_assert.f90 +ncdr_attrs.f90 +ncdr_attrs_fetch.f90 +ncdr_check.f90 +ncdr_climsg.F90 +ncdr_dims.f90 +ncdr_global_attrs.f90 +ncdr_global_attrs_fetch.f90 +ncdr_realloc_mod.F90 +ncdr_state.f90 +ncdr_types.f90 +ncdr_vars.f90 +ncdr_vars_fetch.f90 +ncdres_climsg.F90 +ncdw_chaninfo.F90 +ncdw_ciresize.F90 +ncdw_climsg.F90 +ncdw_data2d.F90 +ncdw_dresize.F90 +ncdw_lheader.F90 +ncdw_metadata.F90 +ncdw_mresize.F90 +ncdw_realloc.F90 +ncdw_state.f90 +ncdw_strarrutils.F90 +ncdw_types.F90 +ncdw_varattr.F90 +netcdf_unlimdims.F90 +) + +list(APPEND NCDIAG_SRC_app +nc_diag_cat.F90 +test_nc_unlimdims.F90 +) diff --git a/src/ncdiag/serial/CMakeLists.txt b/src/ncdiag/serial/CMakeLists.txt deleted file mode 100644 index cdd6e44987..0000000000 --- a/src/ncdiag/serial/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -cmake_minimum_required(VERSION 3.16.1) -if(BUILD_NCDIAG) - - if( NOT USE_BASELIBS ) - if( BUILD_NCDIAG_SERIAL ) - set(NCDIAG_SERIAL_MODULE_DIR ${PROJECT_BINARY_DIR}/include/ncdiag_serial) - # NetCDF-4 library - set(NCDIAG_SERIAL_INCS "${PROJECT_BINARY_DIR}/include/ncdiag_serial") - - include_directories( ${NETCDF_INCLUDE_DIRS} ${NCDIAG_SERIAL_INCS} ) - - # 32-bit reals, for now - add_definitions(-D_REAL4_) - - message("HEY!!! ncdiag flags are ${NCDIAG_Fortran_FLAGS}") - FILE(GLOB NCDIAG_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../*90 ) - set_source_files_properties( ${NCDIAG_SRC} PROPERTIES COMPILE_FLAGS ${NCDIAG_Fortran_FLAGS} ) - LIST(REMOVE_ITEM NCDIAG_SRC ${CMAKE_CURRENT_SOURCE_DIR}/test_nc_unlimdims.F90 ) - LIST(REMOVE_ITEM NCDIAG_SRC ${CMAKE_CURRENT_SOURCE_DIR}/nc_diag_cat.F90 ) - add_library(ncdiag_serial STATIC ${NCDIAG_SRC}) - set_target_properties( ncdiag_serial PROPERTIES Fortran_MODULE_DIRECTORY ${NCDIAG_SERIAL_MODULE_DIR} ) - add_executable(ncdiag_cat.x ${CMAKE_CURRENT_SOURCE_DIR}/../nc_diag_cat.F90 ) - set_target_properties( ncdiag_cat.x PROPERTIES COMPILE_FLAGS ${NCDIAG_Fortran_FLAGS} ) - set_target_properties( ncdiag_cat.x PROPERTIES Fortran_MODULE_DIRECTORY ${NCDIAG_SERIAL_MODULE_DIR} ) - target_link_libraries(ncdiag_cat.x ncdiag_serial ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES}) - endif(BUILD_NCDIAG_SERIAL) - endif( NOT USE_BASELIBS ) -endif(BUILD_NCDIAG) - - - diff --git a/ush/build.comgsi b/ush/build.comgsi deleted file mode 100755 index 319d0121f7..0000000000 --- a/ush/build.comgsi +++ /dev/null @@ -1,174 +0,0 @@ -#!/bin/sh -# common modules to compile GSI/EnKF: -# Jet: source /home/rtrr/PARM_EXEC/modulefiles/modulefile.jet.GSI_UPP_WRF -# Theia: source /home/rtrr/PARM_EXEC/modulefiles/modulefile.theia.GSI_UPP_WRF -# Cheyenne: source /glade/p/ral/jntp/gge/modulefiles/modulefile.cheyenne.GSI_UPP_WRF -# -# build commands: -# cmake -DCOMGSI=ON -DENKF_MODE=WRF -DBUILD_GSDCLOUD_ARW=ON path_to_GSI -# cmake -DCOMGSI=ON -DENKF_MODE=WRF -DBUILD_GSDCLOUD_ARW=ON -DBUILD_UTIL_COM=ON -DBUILD_ENKF_PREPROCESS_ARW=ON path_to_GSI" -# (for global: cmake -DCOMGSI=ON -DENKF_MODE=GFS path_to_GSI) -# make -j8 -# - -dir_root=$(pwd) - -################# Hera #################### -if [[ "`grep -i "hera" /etc/hosts | head -n1`" != "" ]] ; then - source /etc/profile.d/modules.sh - module purge - module load cmake/3.20.1 - module load intel/18.0.5.274 - module load impi/2018.0.4 - module load netcdf/4.7.0 - - module use /scratch2/NCEPDEV/nwprod/hpc-stack/libs/hpc-stack/modulefiles/stack - module load hpc/1.1.0 - module load hpc-intel/18.0.5.274 - module load hpc-impi/2018.0.4 - module load bufr/11.4.0 - module load ip/3.3.3 - module load nemsio/2.5.2 - module load sfcio/1.4.1 - module load sigio/2.3.2 - module load sp/2.3.3 - module load w3nco/2.4.1 - module load w3emc/2.7.3 - module load bacio/2.4.1 - module load crtm/2.3.0 - module load wrf_io/1.2.0 - -################# Jet #################### -elif [[ -d /jetmon ]] ; then - source /etc/profile.d/modules.sh - module purge - module load cmake/3.16.1 - module load intel/18.0.5.274 - module load impi/2018.4.274 - module load szip/2.1 - module load hdf5parallel/1.10.6 - module load netcdf-hdf5parallel/4.7.4 - module load pnetcdf/1.11.2 - module load nco/4.9.1 - - module use /lfs4/HFIP/hfv3gfs/nwprod/hpc-stack/libs/modulefiles/stack - module load hpc/1.1.0 - module load hpc-intel/18.0.5.274 - module load hpc-impi/2018.4.274 - module load bufr/11.4.0 - module load bacio/2.4.1 - module load crtm/2.3.0 - module load ip/3.3.3 - module load nemsio/2.5.2 - module load sp/2.3.3 - module load w3emc/2.7.3 - module load w3nco/2.4.1 - module load sfcio/1.4.1 - module load sigio/2.3.2 - module load wrf_io/1.2.0 - -################# Cheyenne #################### -elif [[ -d /glade ]] ; then - source /etc/profile.d/modules.sh - module purge - module load intel/18.0.5 ncarenv ncarcompilers - module load impi/2018.4.274 - module load mkl/2018.0.5 - module load netcdf/4.7.4 - - module use /glade/p/ral/jntp/gge/hpc-stacks/modulefiles/stack - module load hpc/1.1.0 - module load hpc-intel/18.0.5 - module load hpc-impi/2018.4.274 - module load bufr/11.5.0 - module load ip/3.3.3 - module load nemsio/2.5.2 - module load sfcio/1.4.1 - module load sigio/2.3.2 - module load sp/2.3.3 - module load w3nco/2.4.1 - module load w3emc/2.7.3 - module load bacio/2.4.1 - module load crtm/2.3.0 - module load wrf_io/1.2.0 - module load cmake/3.18.2 - -################# Orion #################### -elif [[ -d /work/noaa ]] ; then ### orion - module purge - module load intel/2018.4 - module load impi/2018.4 - module load netcdf/4.7.2 - - module use /apps/contrib/NCEP/libs/hpc-stack/modulefiles/stack - module load hpc/1.1.0 - module load hpc-intel/2018.4 - module load hpc-impi/2018.4 - module load bufr/11.4.0 - module load ip/3.3.3 - module load nemsio/2.5.2 - module load sfcio/1.4.1 - module load sigio/2.3.2 - module load sp/2.3.3 - module load w3nco/2.4.1 - module load w3emc/2.7.3 - module load bacio/2.4.1 - module load crtm/2.3.0 - module load wrf_io/1.2.0 - module load cmake - -################# Generic #################### -else - echo -e "\nunknown machine" - echo "Please modify build.comgsi at this location" - echo "to load required modules" - ##follow the above examples and delete the following "exit 9" to go forward - exit 9 - source /etc/profile.d/modules.sh - #load modules from the NOAA hpc-stack -fi - -## if NETCDF4 is set to 0 or 1, unset it -if [[ "$NETCDF4" == "1" ]] || [[ "$NETCDF4" == "0" ]]; then - unset NETCDF4 -fi - -set -x -rm -rf $dir_root/build -mkdir -p $dir_root/build -cd $dir_root/build -set +x - - -echo "compiled at the node:" >> output.log -hostname >> output.log -module list >> output.log -echo -e "\nThe branch name:" >> output.log -git branch | grep "*" >> output.log -echo -e "\nThe commit ID:" >> output.log -git log -1 | head -n1 >> output.log -echo -e "\ngit status:" >> output.log -git status >> output.log -echo -e "\nCompiling commands:" >> output.log -echo " cmake -DCOMGSI=ON -DENKF_MODE=WRF -DBUILD_GSDCLOUD_ARW=ON -DBUILD_ENKF_PREPROCESS_ARW=ON -DBUILD_UTIL_COM=ON .." >> output.log -echo " make -j8" >> output.log -cat output.log - - -cmake -DCOMGSI=ON -DENKF_MODE=WRF -DBUILD_GSDCLOUD_ARW=ON -DBUILD_ENKF_PREPROCESS_ARW=ON -DBUILD_UTIL_COM=ON .. 2>&1 | tee output.cmake -make -j 8 2>&1 | tee output.compile - -###aftermath -commitID=`git log -1 | head -n1 |cut -c8-15` -repoName=`git config --get remote.origin.url | cut -d: -f2` -repoName=${repoName//\//:} -datestamp=`date +%Y%m%d` -cd bin -ln -sf gsi.x gsi.x_${repoName}_${datestamp}_${commitID} -ln -sf enkf_wrf.x enkf_wrf.x_${repoName}_${datestamp}_${commitID} -ln -sf enspreproc.x enspreproc.x_${repoName}_${datestamp}_${commitID} -###mv $dir_root/build $dir_root/build_$commitID - -echo -e "\n\nAll build results are at ./build/ \n\n" - -exit diff --git a/ush/build.sh b/ush/build.sh new file mode 100755 index 0000000000..1e85a7c6cc --- /dev/null +++ b/ush/build.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +set -eu + +# Get the root of the cloned GSI directory +readonly DIR_ROOT=$(cd "$(dirname "$(readlink -f -n "${BASH_SOURCE[0]}" )" )/.." && pwd -P) + +# User Options +BUILD_TYPE=${BUILD_TYPE:-"Release"} +CMAKE_OPTS=${CMAKE_OPTS:-} +COMPILER=${COMPILER:-"intel"} +BUILD_DIR=${BUILD_DIR:-"${DIR_ROOT}/build"} +INSTALL_PREFIX=${INSTALL_PREFIX:-"${DIR_ROOT}/install"} +GSI_MODE=${GSI_MODE:-"Regional"} # By default build Regional GSI (for regression testing) +ENKF_MODE=${ENKF_MODE:-"GFS"} # By default build Global EnKF (for regression testing) +UTIL_OPTS=${UTIL_OPTS:-"-DBUILD_UTIL_ALL=ON"} # By default build all GFS utilities +REGRESSION_TESTS=${REGRESSION_TESTS:-"YES"} # Build regression test suite + +#==============================================================================# + +# Detect machine (sets MACHINE_ID) +source $DIR_ROOT/ush/detect_machine.sh + +# Load modules +source $DIR_ROOT/ush/module-setup.sh +module use $DIR_ROOT/modulefiles +module load gsi_$MACHINE_ID +module list + +# Set CONTROLPATH variables for Regression testing on supported MACHINE_ID +if [[ $MACHINE_ID = wcoss ]] ; then + CONTROLPATH="/da/save/Michael.Lueken/svn1/build" +elif [[ $MACHINE_ID = wcoss_dell_p3 ]] ; then + CONTROLPATH="/gpfs/dell2/emc/modeling/noscrub/Michael.Lueken/svn1/install/bin" +elif [[ $MACHINE_ID = hera.intel ]] ; then + CONTROLPATH="/scratch1/NCEPDEV/da/Michael.Lueken/svn1/install/bin" +fi + +# Collect BUILD Options +CMAKE_OPTS+=" -DCMAKE_BUILD_TYPE=$BUILD_TYPE" + +# Install destination for built executables, libraries, CMake Package config +CMAKE_OPTS+=" -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX" + +# Configure for GSI and EnKF +CMAKE_OPTS+=" -DGSI_MODE=$GSI_MODE -DENKF_MODE=${ENKF_MODE}" + +# Build utilities +[[ -n ${UTIL_OPTS:-""} ]] && CMAKE_OPTS+=" $UTIL_OPTS" + +# Build regression test suite (on supported MACHINE_ID where CONTROLPATH exists) +[[ ${REGRESSION_TESTS} =~ [yYtT] ]] && CMAKE_OPTS+=" -DBUILD_REG_TESTING=ON -DCONTROLPATH=${CONTROLPATH:-}" + +# Re-use or create a new BUILD_DIR (Default: create new BUILD_DIR) +[[ ${BUILD_CLEAN:-"YES"} =~ [yYtT] ]] && rm -rf $BUILD_DIR +mkdir -p $BUILD_DIR && cd $BUILD_DIR + +# Configure, build, install +set -x +cmake $CMAKE_OPTS $DIR_ROOT +make -j ${BUILD_JOBS:-8} VERBOSE=${BUILD_VERBOSE:-} +make install +set +x + +exit diff --git a/ush/build_4nco_global.sh b/ush/build_4nco_global.sh new file mode 100755 index 0000000000..03569d024d --- /dev/null +++ b/ush/build_4nco_global.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# +# This is a wrapper script for building the GFS version of GSI for NCO +# It sets the explicit values that are passed to the general build script + +set -eu + +# Get the root of the cloned GSI directory +readonly DIR_ROOT=$(cd "$(dirname "$(readlink -f -n "${BASH_SOURCE[0]}" )" )/.." && pwd -P) + +# Set NCO explicit variables +export BUILD_TYPE="Release" +export BUILD_VERBOSE="YES" +export BUILD_DIR="$DIR_ROOT/build_4nco" +export INSTALL_PREFIX="$DIR_ROOT/install_4nco" + +export GSI_MODE="GFS" +export ENKF_MODE="GFS" +export REGRESSION_TESTS="NO" +export UTIL_OPTS="-DBUILD_UTIL_ENKF_GFS=ON" + +# Prune the directory structure per NCO liking +$DIR_ROOT/ush/prune_4nco_global.sh prune +rc=$? +[[ $rc -ne 0 ]] && (echo "Error in prune_4nco_global.sh; ABORT!"; exit $rc) + +# Call the general build script from ush/build.sh +$DIR_ROOT/ush/build.sh +rc=$? +[[ $rc -ne 0 ]] && (echo "Error in build.sh; ABORT!"; exit $rc) + +# NCO "installs" binaries in $DIR_ROOT/exec +[[ -d $DIR_ROOT/exec ]] && rm -rf $DIR_ROOT/exec +mv $INSTALL_PREFIX/bin $DIR_ROOT/exec + +# Clean up build and install directories +rm -rf $BUILD_DIR $INSTALL_PREFIX + +exit diff --git a/ush/build_all_cmake.sh b/ush/build_all_cmake.sh deleted file mode 100755 index 536242d0bc..0000000000 --- a/ush/build_all_cmake.sh +++ /dev/null @@ -1,126 +0,0 @@ -#!/bin/sh - -set -ex - -cd .. -pwd=$(pwd) - -build_type=${1:-'PRODUCTION'} -dir_root=${2:-$pwd} -mode=${3:-'EMC'} - - -# If NCO build, prune directories and files before build -if [ $mode = NCO ]; then - cd $dir_root/ush - $dir_root/ush/prune_4nco_global.sh prune -fi - - -# Initialize and load modules -if [[ -d /dcom && -d /hwrf ]] ; then - . /usrx/local/Modules/3.2.10/init/sh - target=wcoss - . $MODULESHOME/init/sh -elif [[ -d /cm ]] ; then - . $MODULESHOME/init/sh - target=wcoss_c -elif [[ -d /ioddev_dell ]]; then - . $MODULESHOME/init/sh - target=wcoss_d -elif [[ -d /scratch1 ]] ; then - . /apps/lmod/lmod/init/sh - target=hera -elif [[ -d /data/prod ]] ; then - . /usr/share/lmod/lmod/init/sh - target=s4 -elif [[ -d /jetmon ]] ; then - . $MODULESHOME/init/sh - target=jet -elif [[ -d /glade ]] ; then - . $MODULESHOME/init/sh - target=cheyenne -elif [[ -d /sw/gaea ]] ; then - . /opt/cray/pe/modules/3.2.10.5/init/sh - target=gaea -elif [[ -d /discover ]] ; then -# . /opt/cray/pe/modules/3.2.10.5/init/sh - target=discover - build_type=0 - export SPACK_ROOT=/discover/nobackup/mapotts1/spack - export PATH=$PATH:$SPACK_ROOT/bin - . $SPACK_ROOT/share/spack/setup-env.sh -elif [[ -d /work ]]; then - . $MODULESHOME/init/sh - target=orion -elif [[ -d /lfs/h2 ]] ; then - target=wcoss2 -else - echo "unknown target = $target" - exit 9 -fi - -dir_modules=$dir_root/modulefiles -if [ ! -d $dir_modules ]; then - echo "modulefiles does not exist in $dir_modules" - exit 10 -fi -[ -d $dir_root/exec ] || mkdir -p $dir_root/exec - -rm -rf $dir_root/build -mkdir -p $dir_root/build -cd $dir_root/build - -if [ $target = wcoss_d ]; then - module purge - module use -a $dir_modules - module load modulefile.ProdGSI.$target -elif [ $target = wcoss -o $target = gaea ]; then - module purge - module load $dir_modules/modulefile.ProdGSI.$target -elif [ $target = hera -o $target = orion -o $target = s4 ]; then - module purge - module use $dir_modules - module load modulefile.ProdGSI.$target -elif [ $target = jet ]; then - module purge - module use $dir_modules - module load modulefile.ProdGSI.$target -elif [ $target = cheyenne ]; then - module purge - source $dir_modules/modulefile.ProdGSI.$target -elif [ $target = wcoss_c ]; then - module purge - module load $dir_modules/modulefile.ProdGSI.$target -elif [ $target = discover ]; then - module load $dir_modules/modulefile.ProdGSI.$target -elif [ $target = wcoss2 ]; then - module reset - module use $dir_modules - module load modulefile.ProdGSI.$target - module list -else - module purge - source $dir_modules/modulefile.ProdGSI.$target -fi - -if [ $build_type = PRODUCTION -o $build_type = DEBUG ] ; then - cmake -DBUILD_UTIL=ON -DBUILD_NCDIAG_SERIAL=ON -DCMAKE_BUILD_TYPE=$build_type -DBUILD_CORELIBS=OFF .. -else - cmake .. -fi - -# Build apps. Echo extra printout for NCO build -if [ $mode = NCO ]; then - make VERBOSE=1 -j 8 -else - make -j 8 -fi -rc=$? - -# If NCO build is successful, remove build directory -if [ $mode = NCO -a $rc -eq 0 ]; then - rm -rf $dir_root/build -fi - -exit diff --git a/ush/detect_machine.sh b/ush/detect_machine.sh new file mode 100755 index 0000000000..0eae636cbc --- /dev/null +++ b/ush/detect_machine.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +case $(hostname -f) in + + llogin[1-3]) MACHINE_ID=wcoss_cray ;; ### luna + slogin[1-3]) MACHINE_ID=wcoss_cray ;; ### surge + + m7[12]a[1-3].ncep.noaa.gov) MACHINE_ID=wcoss_dell_p3 ;; ### mars + v7[12]a[1-3].ncep.noaa.gov) MACHINE_ID=wcoss_dell_p3 ;; ### venus + m109a[1-4].ncep.noaa.gov) MACHINE_ID=wcoss_dell_p3 ;; ### mars3.5 + m110a[1-4].ncep.noaa.gov) MACHINE_ID=wcoss_dell_p3 ;; ### mars3.5 + v109a[1-4].ncep.noaa.gov) MACHINE_ID=wcoss_dell_p3 ;; ### venus3.5 + v110a[1-4].ncep.noaa.gov) MACHINE_ID=wcoss_dell_p3 ;; ### venus3.5 + + adecflow0[12].acorn.wcoss2.ncep.noaa.gov) MACHINE_ID=wcoss2 ;; ### acorn + alogin0[12].acorn.wcoss2.ncep.noaa.gov) MACHINE_ID=wcoss2 ;; ### acorn + clogin0[1-9].cactus.wcoss2.ncep.noaa.gov) MACHINE_ID=wcoss2 ;; ### cactus01-9 + clogin10.cactus.wcoss2.ncep.noaa.gov) MACHINE_ID=wcoss2 ;; ### cactus10 + dlogin0[1-9].dogwood.wcoss2.ncep.noaa.gov) MACHINE_ID=wcoss2 ;; ### dogwood01-9 + dlogin10.dogwood.wcoss2.ncep.noaa.gov) MACHINE_ID=wcoss2 ;; ### dogwood10 + + gaea9) MACHINE_ID=gaea ;; ### gaea9 + gaea1[0-6]) MACHINE_ID=gaea ;; ### gaea10-16 + gaea9.ncrc.gov) MACHINE_ID=gaea ;; ### gaea9 + gaea1[0-6].ncrc.gov) MACHINE_ID=gaea ;; ### gaea10-16 + + hfe0[1-9]) MACHINE_ID=hera ;; ### hera01-9 + hfe1[0-2]) MACHINE_ID=hera ;; ### hera10-12 + hecflow01) MACHINE_ID=hera ;; ### heraecflow01 + + s4-submit.ssec.wisc.edu) MACHINE_ID=s4 ;; ### s4 + + fe[1-8]) MACHINE_ID=jet ;; ### jet01-8 + tfe[12]) MACHINE_ID=jet ;; ### tjet1-2 + + Orion-login-[1-4].HPC.MsState.Edu) MACHINE_ID=orion ;; ### orion1-4 + + cheyenne[1-6].cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne1-6 + cheyenne[1-6].ib0.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne1-6 + chadmin[1-6].ib0.cheyenne.ucar.edu) MACHINE_ID=cheyenne ;; ### cheyenne1-6 + + login[1-4].stampede2.tacc.utexas.edu) MACHINE_ID=stampede ;; ### stampede1-4 + + login0[1-2].expanse.sdsc.edu) MACHINE_ID=expanse ;; ### expanse1-2 + + discover3[1-5].prv.cube) MACHINE_ID=discover ;; ### discover31-35 +esac + +# Overwrite auto-detect with MACHINE if set +MACHINE_ID=${MACHINE:-${MACHINE_ID}} + +# Append compiler (only on machines that have multiple compilers) +if [ $MACHINE_ID = hera ] || [ $MACHINE_ID = cheyenne ]; then + MACHINE_ID=${MACHINE_ID}.${COMPILER} +fi diff --git a/ush/module-setup.sh b/ush/module-setup.sh new file mode 100755 index 0000000000..67821de821 --- /dev/null +++ b/ush/module-setup.sh @@ -0,0 +1,127 @@ +#!/bin/bash +set -eu + +if [[ $MACHINE_ID = jet* ]] ; then + # We are on NOAA Jet + if ( ! eval module help > /dev/null 2>&1 ) ; then + source /apps/lmod/lmod/init/bash + fi + module purge + +elif [[ $MACHINE_ID = hera* ]] ; then + # We are on NOAA Hera + if ( ! eval module help > /dev/null 2>&1 ) ; then + source /apps/lmod/lmod/init/bash + fi + module purge + +elif [[ $MACHINE_ID = orion* ]] ; then + # We are on Orion + if ( ! eval module help > /dev/null 2>&1 ) ; then + source /apps/lmod/init/bash + fi + module purge + +elif [[ $MACHINE_ID = s4* ]] ; then + # We are on SSEC Wisconsin S4 + if ( ! eval module help > /dev/null 2>&1 ) ; then + source /usr/share/lmod/lmod/init/bash + fi + module purge + +elif [[ $MACHINE_ID = wcoss_cray ]] ; then + # We are on NOAA Luna or Surge + if ( ! eval module help > /dev/null 2>&1 ) ; then + source /opt/modules/default/init/bash + fi + module purge + # Workaround until module issues are fixed: + unset _LMFILES_ + unset LOADEDMODULES + module use /opt/modulefiles + module use /opt/cray/ari/modulefiles + module use /opt/cray/craype/default/alt-modulefiles + module use /opt/cray/alt-modulefiles + module use /gpfs/hps/nco/ops/nwprod/modulefiles + module use /gpfs/hps/nco/ops/nwprod/lib/modulefiles + module use /usrx/local/prod/modulefiles + +elif [[ $MACHINE_ID = wcoss_dell_p3 ]] ; then + # We are on NOAA Mars or Venus + if ( ! eval module help > /dev/null 2>&1 ) ; then + source /usrx/local/prod/lmod/lmod/init/bash + fi + module purge + +elif [[ $MACHINE_ID = wcoss2 ]]; then + # We are on WCOSS2 + module reset + +elif [[ $MACHINE_ID = cheyenne* ]] ; then + # We are on NCAR Cheyenne + if ( ! eval module help > /dev/null 2>&1 ) ; then + source /glade/u/apps/ch/modulefiles/default/localinit/localinit.sh + fi + module purge + +elif [[ $MACHINE_ID = stampede* ]] ; then + # We are on TACC Stampede + if ( ! eval module help > /dev/null 2>&1 ) ; then + source /opt/apps/lmod/lmod/init/bash + fi + module purge + +elif [[ $MACHINE_ID = gaea* ]] ; then + # We are on GAEA. + if ( ! eval module help > /dev/null 2>&1 ) ; then + # We cannot simply load the module command. The GAEA + # /etc/profile modifies a number of module-related variables + # before loading the module command. Without those variables, + # the module command fails. Hence we actually have to source + # /etc/profile here. + source /etc/profile + __ms_source_etc_profile=yes + else + __ms_source_etc_profile=no + fi + module purge + # clean up after purge + unset _LMFILES_ + unset _LMFILES_000 + unset _LMFILES_001 + unset LOADEDMODULES + module load modules + if [[ -d /opt/cray/ari/modulefiles ]] ; then + module use -a /opt/cray/ari/modulefiles + fi + if [[ -d /opt/cray/pe/ari/modulefiles ]] ; then + module use -a /opt/cray/pe/ari/modulefiles + fi + if [[ -d /opt/cray/pe/craype/default/modulefiles ]] ; then + module use -a /opt/cray/pe/craype/default/modulefiles + fi + if [[ -s /etc/opt/cray/pe/admin-pe/site-config ]] ; then + source /etc/opt/cray/pe/admin-pe/site-config + fi + if [[ "$__ms_source_etc_profile" == yes ]] ; then + source /etc/profile + unset __ms_source_etc_profile + fi + +elif [[ $MACHINE_ID = expanse* ]]; then + # We are on SDSC Expanse + if ( ! eval module help > /dev/null 2>&1 ) ; then + source /etc/profile.d/modules.sh + fi + module purge + module load slurm/expanse/20.02.3 + +elif [[ $MACHINE_ID = discover* ]]; then + # We are on NCCS discover + export SPACK_ROOT=/discover/nobackup/mapotts1/spack + export PATH=$PATH:$SPACK_ROOT/bin + . $SPACK_ROOT/share/spack/setup-env.sh + +else + echo WARNING: UNKNOWN PLATFORM 1>&2 +fi diff --git a/ush/prune_4nco_global.sh b/ush/prune_4nco_global.sh index 699064a613..ec69fd4cd5 100755 --- a/ush/prune_4nco_global.sh +++ b/ush/prune_4nco_global.sh @@ -34,8 +34,8 @@ fi # Set root directory -cd .. -topdir=$(pwd) +readonly topdir=$(cd "$(dirname "$(readlink -f -n "${BASH_SOURCE[0]}" )" )/.." && pwd -P) +cd $topdir echo " " echo "Execute git $string in $topdir" @@ -107,7 +107,7 @@ done # Process ush directories and files cd $topdir/ush -rlist="build.comgsi EnKF com Get_Initial_Files gfs_truncate_enkf llsub para refactor_4nco_global run_arw rungsi sub" +rlist="Get_Initial_Files gfs_truncate_enkf llsub para refactor_4nco_global run_arw rungsi sub" for type in $rlist; do git $string ${type}* rc=$? @@ -128,7 +128,7 @@ done # Process util directories and files cd $topdir/util -rlist="Aero Analysis_Utilities Baseline Config Correlated_Obs DTC EFSOI FOV GEN_BE_V2.0 GMI_BUFR MODIS_AOD Misc NCEP NMC_Bkerror README Radar_Monitor Radiance_bias_correction_Utilities Radiance_Utilities Single_Observation bufr_tools global_angupdate gsienvreport.sh ndate python_utilities radar_process zero_biascoeff" +rlist="Aero Analysis_Utilities Baseline Config Correlated_Obs DTC EFSOI FOV GEN_BE_V2.0 GMI_BUFR MODIS_AOD Misc NCEP NMC_Bkerror README Radar_Monitor Radiance_bias_correction_Utilities Radiance_Utilities Single_Observation bufr_tools global_angupdate gsienvreport.sh python_utilities radar_process zero_biascoeff" for type in $rlist; do git $string ${type}* rc=$? diff --git a/ush/sub_discover b/ush/sub_discover index 84b410be62..835cd37ace 100755 --- a/ush/sub_discover +++ b/ush/sub_discover @@ -130,7 +130,7 @@ echo "" >>$cfile echo ". "$(awk '{ print $1, $2, $3, $4, $5, $6, $7, $8, $9 }' $regdir/regression_var.out) >>$cfile echo "" >>$cfile echo "module use -a $gsisrc/modulefiles" >> $cfile -echo "module load modulefile.ProdGSI.discover" >> $cfile +echo "module load gsi_discover" >> $cfile echo "" >>$cfile echo "jobname=$jobname" >>$cfile echo "" >>$cfile diff --git a/ush/sub_hera b/ush/sub_hera index 7aabda3dbf..d904417190 100755 --- a/ush/sub_hera +++ b/ush/sub_hera @@ -138,7 +138,7 @@ echo "" >>$cfile echo ". /apps/lmod/lmod/init/sh" >> $cfile echo "module purge" >> $cfile echo "module use $gsisrc/modulefiles" >> $cfile -echo "module load modulefile.ProdGSI.hera" >> $cfile +echo "module load gsi_hera.intel" >> $cfile echo "module list" >> $cfile echo "" >>$cfile diff --git a/ush/sub_jet b/ush/sub_jet index df6a4779d5..5bd9a6d68c 100755 --- a/ush/sub_jet +++ b/ush/sub_jet @@ -131,7 +131,8 @@ echo "" >>$cfile echo ". /apps/lmod/lmod/init/sh" >> $cfile echo "module purge" >> $cfile -echo "source $gsisrc/modulefiles/modulefile.ProdGSI.jet" >> $cfile +echo "module use $gsisrc/modulefiles" >> $cfile +echo "module load gsi_jet" >> $cfile echo "module list" >> $cfile echo "" >>$cfile diff --git a/ush/sub_wcoss_c b/ush/sub_wcoss_c index d41dc7e787..831e0a10f4 100755 --- a/ush/sub_wcoss_c +++ b/ush/sub_wcoss_c @@ -263,7 +263,7 @@ else fi echo "module purge" >> $cfile echo "module use -a $gsisrc/modulefiles" >> $cfile -echo "module load modulefile.ProdGSI.wcoss_c" >> $cfile +echo "module load modulefile.ProdGSI.wcoss_cray" >> $cfile echo "module list" >> $cfile echo "" >>$cfile diff --git a/ush/sub_wcoss_d b/ush/sub_wcoss_d index 9390f971c9..84a57226be 100755 --- a/ush/sub_wcoss_d +++ b/ush/sub_wcoss_d @@ -312,7 +312,7 @@ echo "" >>$cfile echo ". $MODULESHOME/init/bash" >> $cfile echo "module purge" >> $cfile echo "module use -a $gsisrc/modulefiles" >> $cfile -echo "module load modulefile.ProdGSI.wcoss_d" >> $cfile +echo "module load gsi_wcoss_dell_p3" >> $cfile echo "module list" >> $cfile echo "" >>$cfile diff --git a/util/AeroDA/CMakeLists.txt b/util/AeroDA/CMakeLists.txt new file mode 100644 index 0000000000..59b3a34005 --- /dev/null +++ b/util/AeroDA/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(calc_increment_ens.fd) diff --git a/util/AeroDA/calc_increment_ens.fd/CMakeLists.txt b/util/AeroDA/calc_increment_ens.fd/CMakeLists.txt index c01e2529a7..4ada1e6fbf 100644 --- a/util/AeroDA/calc_increment_ens.fd/CMakeLists.txt +++ b/util/AeroDA/calc_increment_ens.fd/CMakeLists.txt @@ -1,14 +1,31 @@ -cmake_minimum_required(VERSION 2.6) -if(BUILD_UTIL_COM) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - list( REMOVE_ITEM LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/main.f90 ) - - set(Util_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include/calc_increment_ens_aero") - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - add_executable(calc_increment_ens_aero.x ${LOCAL_SRC} ) - set_target_properties( calc_increment_ens_aero.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - set_target_properties( calc_increment_ens_aero.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIRECTORY} ) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - include_directories( ${UTIL_INC} ${NEMSIOINC} ${NETCDF_INCLUDE_DIRS} ${MPI_Fortran_INCLUDE_PATH} ) - target_link_libraries( calc_increment_ens_aero.x ${NEMSIO_LIBRARY} ${BACIO_LIBRARY} ${W3NCO_4_LIBRARY} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES}) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") endif() + +list(APPEND SRCS + calc_increment_interface.f90 + configure + constants.f90 + fv3_interface.f90 + gfs_nems_interface.f90 + kinds.f90 + namelist_def.f90 + pmain.f90 + variable_interface.f90) + +add_executable(calc_increment_ens_aero.x ${SRCS}) +target_compile_definitions(calc_increment_ens_aero.x PRIVATE "_REAL8_") +target_link_libraries(calc_increment_ens_aero.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(calc_increment_ens_aero.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(calc_increment_ens_aero.x PRIVATE bacio::bacio_4) +target_link_libraries(calc_increment_ens_aero.x PRIVATE w3emc::w3emc_d) +target_link_libraries(calc_increment_ens_aero.x PRIVATE nemsio::nemsio) +if(OpenMP_Fortran_FOUND) + target_link_libraries(calc_increment_ens_aero.x PRIVATE OpenMP::OpenMP_Fortran) +endif() + +# Install executable targets +install(TARGETS calc_increment_ens_aero.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + diff --git a/util/Analysis_Utilities/CMakeLists.txt b/util/Analysis_Utilities/CMakeLists.txt new file mode 100644 index 0000000000..d21fdeae15 --- /dev/null +++ b/util/Analysis_Utilities/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(read_diag) diff --git a/util/Analysis_Utilities/read_diag/CMakeLists.txt b/util/Analysis_Utilities/read_diag/CMakeLists.txt index 0b2c61d48a..4130c809cc 100644 --- a/util/Analysis_Utilities/read_diag/CMakeLists.txt +++ b/util/Analysis_Utilities/read_diag/CMakeLists.txt @@ -1,13 +1,27 @@ -cmake_minimum_required(VERSION 2.6) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - - add_executable(read_diag_conv.x read_diag_conv.f90 ) - set_target_properties( read_diag_conv.x PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - target_link_libraries( read_diag_conv.x ${GSISHAREDLIB} ${GSILIB} ${GSISHAREDLIB} ) - add_dependencies(read_diag_conv.x ${GSILIB} ) - - add_executable(read_diag_rad.x read_diag_rad.f90 ) - set_target_properties( read_diag_rad.x PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - target_link_libraries( read_diag_rad.x ${GSISHAREDLIB} ${GSILIB} ${GSISHAREDLIB} ) - add_dependencies(read_diag_rad.x ${GSILIB} ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include/read_diag") +add_library(kinds_obj OBJECT kinds.F90) +set_target_properties(kinds_obj PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}") +target_include_directories(kinds_obj INTERFACE + $) + +add_executable(read_diag_conv.x read_diag_conv.f90) +add_executable(read_diag_rad.x read_diag_rad.f90) + +list(APPEND _targets + read_diag_conv.x + read_diag_rad.x) + +foreach(_tgt ${_targets}) + add_dependencies(${_tgt} kinds_obj) + target_compile_definitions(${_tgt} PRIVATE "_REAL8_") + target_include_directories(${_tgt} PRIVATE $) +endforeach() + +# Install executable targets +install(TARGETS ${_targets} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Analysis_Utilities/read_diag/kinds.F90 b/util/Analysis_Utilities/read_diag/kinds.F90 new file mode 100644 index 0000000000..ac3a0903bf --- /dev/null +++ b/util/Analysis_Utilities/read_diag/kinds.F90 @@ -0,0 +1,39 @@ +module kinds +! Stripped down version of gsi/kinds.F90 for this utility +! This is to avoid building and depending on the entire GSI compiled library + implicit none + + public i_kind, i_byte, i_short, i_long, i_llong + public r_kind, r_single, r_double, r_quad + + private + integer, parameter :: default_integer = 3 ! 1=byte, + ! 2=short, + ! 3=long, + ! 4=llong + integer, parameter :: i_byte = selected_int_kind(1) ! byte integer + integer, parameter :: i_short = selected_int_kind(4) ! short integer + integer, parameter :: i_long = selected_int_kind(8) ! long integer + integer, parameter :: llong_t = selected_int_kind(16) ! llong integer + integer, parameter :: i_llong = max( llong_t, i_long ) + integer, parameter, dimension(4) :: integer_types = (/ & + i_byte, i_short, i_long, i_llong /) + integer, parameter :: i_kind = integer_types( default_integer ) + +#ifdef _REAL4_ + integer, parameter :: default_real = 1 ! 1=single +#elseif _REAL8_ + integer, parameter :: default_real = 2 ! 2=double +#elseif _REAL16_ + integer, parameter :: default_real = 3 ! 3=quad +#else + integer, parameter :: default_real = 1 ! 1=single +#endif + integer, parameter :: r_single = selected_real_kind(6) ! single precision + integer, parameter :: r_double = selected_real_kind(15) ! double precision + integer, parameter :: quad_t = selected_real_kind(20) ! quad precision + integer, parameter :: r_quad = max( quad_t, r_double ) + integer, parameter, dimension(3) :: & + real_kinds = (/ r_single, r_double, r_quad /) + integer, parameter :: r_kind = real_kinds( default_real ) +end module kinds diff --git a/util/CMakeLists.txt b/util/CMakeLists.txt new file mode 100644 index 0000000000..4a1a5e8de3 --- /dev/null +++ b/util/CMakeLists.txt @@ -0,0 +1,172 @@ +cmake_minimum_required(VERSION 3.19) + +project(gsiutils + VERSION 1.0.0 + LANGUAGES C Fortran) + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +set(CMAKE_DIRECTORY_LABELS ${PROJECT_NAME}) + +include(GNUInstallDirs) + +if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel)$") + message(STATUS "Setting build type to 'Release' as none was specified.") + set(CMAKE_BUILD_TYPE + "Release" + CACHE STRING "Choose the type of build." FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") +endif() + +if(NOT CMAKE_C_COMPILER_ID MATCHES "^(GNU|Intel|Clang|AppleClang)$") + message(WARNING "${CMAKE_C_COMPILER_ID} is not supported.") +endif() + +if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU|Intel)$") + message(WARNING "${CMAKE_Fortran_COMPILER_ID} is not supported.") +endif() + +# User options +option(OPENMP "Enable OpenMP Threading" OFF) +option(ENABLE_MKL "Use MKL for LAPACK implementation (if available)" ON) + +# Build options +option(BUILD_UTIL_ALL "Build all utilities" OFF) +option(BUILD_UTIL_AERODA "Build Aerosol DA utilities" OFF) +option(BUILD_UTIL_COV_CALC "Build Correlated Observation Error Utility" OFF) +option(BUILD_UTIL_EFSOI "Build EFSOI Utilities" OFF) +option(BUILD_UTIL_ENKF_GFS "Build EnKF GFS Utilities" OFF) +option(BUILD_UTIL_ENKF_ARW "Build EnKF ARW Utilities" OFF) +option(BUILD_UTIL_MON "Build Monitoring Utilities" OFF) +option(BUILD_UTIL_NCIO "Build NetCDF IO Utilities" OFF) +option(BUILD_UTIL_COM "Build community utilities" OFF) +option(BUILD_UTIL_BKGERR "Build Background Error Utilities" OFF) +option(BUILD_UTIL_ETC "Build Miscellaneous Utilities" OFF) + +# If building all utils, then force all options to ON +# Exception is BUILD_UTIL_ENKF_ARW, since it is incompatible with GSI_MODE=GFS +if (BUILD_UTIL_ALL) + set(BUILD_UTIL_AERODA ON CACHE BOOL "Build Aerosol DA utilities" FORCE) + set(BUILD_UTIL_COV_CALC ON CACHE BOOL "Build Correlated Observation Error Utility" FORCE) + set(BUILD_UTIL_EFSOI ON CACHE BOOL "Build EFSOI Utilities" FORCE) + set(BUILD_UTIL_ENKF_GFS ON CACHE BOOL "Build EnKF GFS Utilities" FORCE) + set(BUILD_UTIL_ENKF_ARW OFF CACHE BOOL "Build EnKF ARW Utilities" FORCE) + set(BUILD_UTIL_MON ON CACHE BOOL "Build Monitoring Utilities" FORCE) + set(BUILD_UTIL_NCIO ON CACHE BOOL "Build NetCDF IO Utilities" FORCE) + set(BUILD_UTIL_COM ON CACHE BOOL "Build community utilities" FORCE) + set(BUILD_UTIL_BKGERR ON CACHE BOOL "Build Background Error Utilities" FORCE) + set(BUILD_UTIL_ETC ON CACHE BOOL "Build Miscellaneous Utilities" FORCE) +endif() + +# Echo user options +message(STATUS "Utils: OPENMP ................. ${OPENMP}") +message(STATUS "Utils: ENABLE_MKL ............. ${ENABLE_MKL}") +message(STATUS "Utils: BUILD_UTIL_AERODA ...... ${BUILD_UTIL_AERODA}") +message(STATUS "Utils: BUILD_UTIL_COV_CALC .... ${BUILD_UTIL_COV_CALC}") +message(STATUS "Utils: BUILD_UTIL_EFSOI ....... ${BUILD_UTIL_EFSOI}") +message(STATUS "Utils: BUILD_UTIL_ENKF_GFS .... ${BUILD_UTIL_ENKF_GFS}") +message(STATUS "Utils: BUILD_UTIL_ENKF_ARW .... ${BUILD_UTIL_ENKF_ARW}") +message(STATUS "Utils: BUILD_UTIL_MON ......... ${BUILD_UTIL_MON}") +message(STATUS "Utils: BUILD_UTIL_NCIO ........ ${BUILD_UTIL_NCIO}") +message(STATUS "Utils: BUILD_UTIL_COM ......... ${BUILD_UTIL_COM}") +message(STATUS "Utils: BUILD_UTIL_BKGERR ...... ${BUILD_UTIL_BKGERR}") +message(STATUS "Utils: BUILD_UTIL_ETC ......... ${BUILD_UTIL_ETC}") + +# Dependencies +if(ENABLE_MKL) + find_package(MKL QUIET) +endif() +if(MKL_FOUND) + set(LAPACK_LIBRARIES ${MKL_LIBRARIES}) +else() + set(ENABLE_MKL OFF CACHE INTERNAL "GSI Utils: Disable MKL since it was NOT FOUND") + find_package(LAPACK REQUIRED) +endif() +find_package(MPI REQUIRED) +find_package(NetCDF REQUIRED Fortran) +if(OPENMP) + find_package(OpenMP REQUIRED) +endif() + +if(NOT TARGET ncdiag) + find_package(ncdiag QUIET) +endif() + +if(NOT TARGET gsi) + find_package(gsi QUIET) +endif() + +if(NOT TARGET enkf) + find_package(enkf QUIET) +endif() + +# NCEPLibs dependencies +find_package(bacio REQUIRED) +find_package(sigio REQUIRED) +find_package(sfcio REQUIRED) +find_package(nemsio REQUIRED) +find_package(ncio REQUIRED) +find_package(sp REQUIRED) +find_package(ip REQUIRED) +find_package(w3emc REQUIRED) +find_package(bufr REQUIRED) +find_package(wrf_io QUIET) + +# See https://github.com/NOAA-EMC/NCEPLIBS-nemsio/pull/22 +target_link_libraries(nemsio::nemsio INTERFACE w3emc::w3emc_d bacio::bacio_4) + +# Get compiler flags for the utilities +include(gsiutils_compiler_flags) + +if(BUILD_UTIL_AERODA) + add_subdirectory(AeroDA) +endif() + +if(BUILD_UTIL_COV_CALC) + add_subdirectory(Correlated_Obs) +endif() + +if(BUILD_UTIL_EFSOI) + add_subdirectory(EFSOI_Utilities) +endif() + +if(BUILD_UTIL_ENKF_GFS OR BUILD_UTIL_ENKF_ARW) + add_subdirectory(EnKF) +endif() + +if(BUILD_UTIL_NCIO) + add_subdirectory(netcdf_io) +endif() + +if(BUILD_UTIL_COM) + add_subdirectory(Analysis_Utilities) + add_subdirectory(bufr_tools) + add_subdirectory(radar_process) +endif() + +if(BUILD_UTIL_BKGERR) + add_subdirectory(NMC_Bkerror) +endif() + +if(BUILD_UTIL_MON) + add_subdirectory(Conventional_Monitor) + add_subdirectory(Ozone_Monitor) + add_subdirectory(Radiance_Monitor) +endif() + +if(BUILD_UTIL_ETC) + add_subdirectory(FOV_utilities) + add_subdirectory(Single_Observation) + add_subdirectory(zero_biascoeff) +endif() + +# These utilities do not have CMake builds and are unlikely used or usable +#add_subdirectory(Config) +#add_subdirectory(GEN_BE_V2.0) +#add_subdirectory(global_angupdate) +#add_subdirectory(GMI_BUFR_gen) +#add_subdirectory(Misc) +#add_subdirectory(MODIS_AOD) +#add_subdirectory(NCEP_bkerror) +#add_subdirectory(NCEPgsi_Coupler) +#add_subdirectory(Radiance_bias_correction_Utilities) +#add_subdirectory(Radiance_Utilities) diff --git a/util/Conventional_Monitor/CMakeLists.txt b/util/Conventional_Monitor/CMakeLists.txt index 9b66fa9a7e..efeab15bba 100644 --- a/util/Conventional_Monitor/CMakeLists.txt +++ b/util/Conventional_Monitor/CMakeLists.txt @@ -1,105 +1,2 @@ -cmake_minimum_required(VERSION 2.8) -if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) - # I am top-level project. - if( NOT DEFINED ENV{CC} ) - find_path( crayComp "ftn" ) - find_path( wcossIntel "mpfort" ) - find_path( intelComp "ifort" ) - find_path( pgiComp "pgf90" ) - if( crayComp ) - message("Setting CrayLinuxEnvironment") - set(CMAKE_SYSTEM_NAME "CrayLinuxEnvironment") - set(CMAKE_C_COMPILER "${crayComp}/cc") - set(CMAKE_CXX_COMPILER "${crayComp}/CC") - set(CMAKE_Fortran_COMPILER "${crayComp}/ftn") - endif() - if( intelComp ) - set(ENV{CC} "icc") - set(ENV{CXX} "icpc") - set(ENV{FC} "ifort") - endif() - if( wcossIntel ) - message("Setting env for wcoss intel") - set(ENV{CC} "mpcc") - set(ENV{CXX} "mpCC") - set(ENV{FC} "mpfort") - endif() - if( pgiComp ) - set(ENV{CC} "pgcc") - set(ENV{CXX} "pgCC") - set(ENV{FC} "pgf90") - endif() - endif() - project(COV_Calc) - enable_language (Fortran) - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/../../cmake/Modules/") - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setPlatformVariables.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setIntelFlags.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setGNUFlags.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setPGIFlags.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setHOST.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Cheyenne.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Discover.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Generic.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Gaea.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Jet.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/S4.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Hera.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/WCOSS-C.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/WCOSS-D.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/WCOSS.cmake) - if (NOT CMAKE_BUILD_TYPE) - set (CMAKE_BUILD_TYPE RELEASE CACHE STRING - "Choose the type of build, options are: PRODUCTION Debug Release." - FORCE) - endif (NOT CMAKE_BUILD_TYPE) - if (CMAKE_CXX_COMPILER_ID MATCHES "GNU*") - message("Setting GNU flags") - setGNU() - elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - message("Setting Intel flags") - setIntel() - elseif(CMAKE_C_COMPILER MATCHES "pgc*") - message("Setting PGI flags") - setPGI() - endif() - - cmake_policy(SET CMP0009 NEW) - cmake_policy(SET CMP0054 NEW) - find_package(OpenMP) - message("found openmp with flag ${OPENMP_Fortran_FLAGS}") - -# Set Host specific flags and options - setHOST() - - find_package( NetCDF COMPONENTS C Fortran REQUIRED) - find_package(MPI REQUIRED) - message("MPI version is ${MPI_Fortran_VERSION}") - message("MPI f90 version is ${MPI_Fortran_HAVE_F90_MODULE}") - message("MPI f08 version is ${MPI_Fortran_HAVE_F08_MODULE}") - - add_definitions(${MPI_Fortran_COMPILE_FLAGS}) - include_directories(${MPI_Fortran_INCLUDE_DIRS} ${MPI_INCLUDE_PATH} "./" ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) - link_directories(${MPI_Fortran_LIBRARIES} ${ARCHIVE_OUTPUT_PATH} ) - find_package( W3NCO ) - - set (CMAKE_Fortran_INC_FLAGS "-I ./ -I ${CORE_INCS} -I ${NETCDF_INCLUDE_DIRS} ") - set(BUILD_NCDIAG ON) - set(NCDIAG_INCS "${PROJECT_BINARY_DIR}/src/ncdiag/include") - add_subdirectory(src/ncdiag) - set(NCDIAG_LIBRARIES ncdiag ) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) -endif() - -add_subdirectory(nwprod/conmon_shared/sorc/conmon_grads_lev.fd) -add_subdirectory(nwprod/conmon_shared/sorc/conmon_grads_mandlev.fd) -add_subdirectory(nwprod/conmon_shared/sorc/conmon_grads_sfc.fd) -add_subdirectory(nwprod/conmon_shared/sorc/conmon_grads_sfctime.fd) -add_subdirectory(nwprod/conmon_shared/sorc/conmon_grads_sig.fd) -add_subdirectory(nwprod/conmon_shared/sorc/conmon_time.fd) -add_subdirectory(image_gen/sorc/conmon_read_ps_IG.fd) -add_subdirectory(image_gen/sorc/conmon_read_pw_IG.fd) -add_subdirectory(image_gen/sorc/conmon_read_q_IG.fd) -add_subdirectory(image_gen/sorc/conmon_read_t_IG.fd) -add_subdirectory(image_gen/sorc/conmon_read_uv_IG.fd) +add_subdirectory(image_gen) +add_subdirectory(nwprod) diff --git a/util/Conventional_Monitor/image_gen/CMakeLists.txt b/util/Conventional_Monitor/image_gen/CMakeLists.txt new file mode 100644 index 0000000000..ddf939af1e --- /dev/null +++ b/util/Conventional_Monitor/image_gen/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(sorc) diff --git a/util/Conventional_Monitor/image_gen/exec/.gitignore b/util/Conventional_Monitor/image_gen/exec/.gitignore deleted file mode 100644 index d6b7ef32c8..0000000000 --- a/util/Conventional_Monitor/image_gen/exec/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/util/Conventional_Monitor/image_gen/sorc/CMakeLists.txt b/util/Conventional_Monitor/image_gen/sorc/CMakeLists.txt new file mode 100644 index 0000000000..3029d34e02 --- /dev/null +++ b/util/Conventional_Monitor/image_gen/sorc/CMakeLists.txt @@ -0,0 +1,5 @@ +add_subdirectory(conmon_read_ps_IG.fd) +add_subdirectory(conmon_read_pw_IG.fd) +add_subdirectory(conmon_read_q_IG.fd) +add_subdirectory(conmon_read_t_IG.fd) +add_subdirectory(conmon_read_uv_IG.fd) diff --git a/util/Conventional_Monitor/image_gen/sorc/conmon_read_ps_IG.fd/CMakeLists.txt b/util/Conventional_Monitor/image_gen/sorc/conmon_read_ps_IG.fd/CMakeLists.txt index fd28c786f1..723322320a 100644 --- a/util/Conventional_Monitor/image_gen/sorc/conmon_read_ps_IG.fd/CMakeLists.txt +++ b/util/Conventional_Monitor/image_gen/sorc/conmon_read_ps_IG.fd/CMakeLists.txt @@ -1,15 +1,29 @@ -cmake_minimum_required(VERSION 2.6) - file(GLOB CONMON_READ_PS_IG_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(CONMON_READ_PS_IG_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set_source_files_properties( ${CONMON_READ_PS_IG_SRC} PROPERTIES COMPILE_FLAGS ${CONMON_READ_PS_IG_Fortran_FLAGS} ) - add_executable(conmon_read_ps_IG.x ${CONMON_READ_PS_IG_SRC} ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() - set_target_properties( conmon_read_ps_IG.x PROPERTIES COMPILE_FLAGS ${CONMON_READ_PS_IG_Fortran_FLAGS} ) - include_directories( ${CORE_INCS} ${NCDIAG_INCS} ) +list(APPEND SRCS + convinfo.f90 + histgram.f90 + mainread_ps.f90 + read_ps.f90 + read_ps_mor.f90 + rm_dups.f90 +) - target_link_libraries( conmon_read_ps_IG.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ) - if(BUILD_W3NCO) - add_dependencies( conmon_read_ps_IG.x ${W3NCO_4_LIBRARY} ) - endif() +add_executable(conmon_read_ps_IG.x ${SRCS}) +if(TARGET ncdiag) + add_dependencies(conmon_read_ps_IG.x ncdiag) +endif() +target_compile_definitions(conmon_read_ps_IG.x PRIVATE "_REAL8_") +target_link_libraries(conmon_read_ps_IG.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(conmon_read_ps_IG.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(conmon_read_ps_IG.x PRIVATE ncdiag::ncdiag) +target_link_libraries(conmon_read_ps_IG.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS conmon_read_ps_IG.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Conventional_Monitor/image_gen/sorc/conmon_read_ps_IG.fd/convinfo.f90 b/util/Conventional_Monitor/image_gen/sorc/conmon_read_ps_IG.fd/convinfo.f90 index 63a749f7a0..a16a81a856 100644 --- a/util/Conventional_Monitor/image_gen/sorc/conmon_read_ps_IG.fd/convinfo.f90 +++ b/util/Conventional_Monitor/image_gen/sorc/conmon_read_ps_IG.fd/convinfo.f90 @@ -12,8 +12,8 @@ subroutine convinfo_read( dtype, idtype, insubtype, ituse, ntumgrp, ntgroup, ntm !-------------- ! interface ! - character(idtype), intent(in) :: dtype integer, intent(in) :: idtype, insubtype + character(idtype), intent(in) :: dtype integer(4), intent(out) :: ituse, ntumgrp, ntgroup, ntmiter, isubtype real(4), intent(out) :: ttwind2, gtross2, etrmax2, etrmin2, vtar_b2, vtar_pg2 diff --git a/util/Conventional_Monitor/image_gen/sorc/conmon_read_pw_IG.fd/CMakeLists.txt b/util/Conventional_Monitor/image_gen/sorc/conmon_read_pw_IG.fd/CMakeLists.txt index b3e1a7be2e..0c7ccc2202 100644 --- a/util/Conventional_Monitor/image_gen/sorc/conmon_read_pw_IG.fd/CMakeLists.txt +++ b/util/Conventional_Monitor/image_gen/sorc/conmon_read_pw_IG.fd/CMakeLists.txt @@ -1,12 +1,29 @@ -cmake_minimum_required(VERSION 2.6) - file(GLOB CONMON_READ_PW_IG_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(CONMON_READ_PW_IG_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set_source_files_properties( ${CONMON_READ_PW_IG_SRC} PROPERTIES COMPILE_FLAGS ${CONMON_READ_PW_IG_Fortran_FLAGS} ) - add_executable(conmon_read_pw_IG.x ${CONMON_READ_PW_IG_SRC} ) - set_target_properties( conmon_read_pw_IG.x PROPERTIES COMPILE_FLAGS ${CONMON_READ_PW_IG_Fortran_FLAGS} ) - include_directories( ${CORE_INCS} ${NCDIAG_INCS} ) - target_link_libraries( conmon_read_pw_IG.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ) - if(BUILD_W3NCO) - add_dependencies( conmon_read_pw_IG.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + convinfo.f90 + histgram.f90 + mainread_pw.f90 + read_pw.f90 + read_pw_mor.f90 + rm_dups.f90 +) + +add_executable(conmon_read_pw_IG.x ${SRCS}) +if(TARGET ncdiag) + add_dependencies(conmon_read_pw_IG.x ncdiag) +endif() + +target_compile_definitions(conmon_read_pw_IG.x PRIVATE "_REAL8_") +target_link_libraries(conmon_read_pw_IG.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(conmon_read_pw_IG.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(conmon_read_pw_IG.x PRIVATE ncdiag::ncdiag) +target_link_libraries(conmon_read_pw_IG.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS conmon_read_pw_IG.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Conventional_Monitor/image_gen/sorc/conmon_read_pw_IG.fd/convinfo.f90 b/util/Conventional_Monitor/image_gen/sorc/conmon_read_pw_IG.fd/convinfo.f90 index 63a749f7a0..a16a81a856 100644 --- a/util/Conventional_Monitor/image_gen/sorc/conmon_read_pw_IG.fd/convinfo.f90 +++ b/util/Conventional_Monitor/image_gen/sorc/conmon_read_pw_IG.fd/convinfo.f90 @@ -12,8 +12,8 @@ subroutine convinfo_read( dtype, idtype, insubtype, ituse, ntumgrp, ntgroup, ntm !-------------- ! interface ! - character(idtype), intent(in) :: dtype integer, intent(in) :: idtype, insubtype + character(idtype), intent(in) :: dtype integer(4), intent(out) :: ituse, ntumgrp, ntgroup, ntmiter, isubtype real(4), intent(out) :: ttwind2, gtross2, etrmax2, etrmin2, vtar_b2, vtar_pg2 diff --git a/util/Conventional_Monitor/image_gen/sorc/conmon_read_q_IG.fd/CMakeLists.txt b/util/Conventional_Monitor/image_gen/sorc/conmon_read_q_IG.fd/CMakeLists.txt index c5c45259bb..4d5496df06 100644 --- a/util/Conventional_Monitor/image_gen/sorc/conmon_read_q_IG.fd/CMakeLists.txt +++ b/util/Conventional_Monitor/image_gen/sorc/conmon_read_q_IG.fd/CMakeLists.txt @@ -1,12 +1,29 @@ -cmake_minimum_required(VERSION 2.6) - file(GLOB CONMON_READ_Q_IG_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(CONMON_READ_Q_IG_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set_source_files_properties( ${CONMON_READ_Q_IG_SRC} PROPERTIES COMPILE_FLAGS ${CONMON_READ_Q_IG_Fortran_FLAGS} ) - add_executable(conmon_read_q_IG.x ${CONMON_READ_Q_IG_SRC} ) - set_target_properties( conmon_read_q_IG.x PROPERTIES COMPILE_FLAGS ${CONMON_READ_Q_IG_Fortran_FLAGS} ) - include_directories( ${CORE_INCS} ${NCDIAG_INCS} ) - target_link_libraries( conmon_read_q_IG.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ) - if(BUILD_W3NCO) - add_dependencies( conmon_read_q_IG.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + convinfo.f90 + histgram.f90 + mainread_q.f90 + read_q.f90 + read_q_mor.f90 + rm_dups.f90 +) + +add_executable(conmon_read_q_IG.x ${SRCS}) +if(TARGET ncdiag) + add_dependencies(conmon_read_q_IG.x ncdiag) +endif() + +target_compile_definitions(conmon_read_q_IG.x PRIVATE "_REAL8_") +target_link_libraries(conmon_read_q_IG.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(conmon_read_q_IG.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(conmon_read_q_IG.x PRIVATE ncdiag::ncdiag) +target_link_libraries(conmon_read_q_IG.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS conmon_read_q_IG.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Conventional_Monitor/image_gen/sorc/conmon_read_q_IG.fd/convinfo.f90 b/util/Conventional_Monitor/image_gen/sorc/conmon_read_q_IG.fd/convinfo.f90 index 63a749f7a0..a16a81a856 100644 --- a/util/Conventional_Monitor/image_gen/sorc/conmon_read_q_IG.fd/convinfo.f90 +++ b/util/Conventional_Monitor/image_gen/sorc/conmon_read_q_IG.fd/convinfo.f90 @@ -12,8 +12,8 @@ subroutine convinfo_read( dtype, idtype, insubtype, ituse, ntumgrp, ntgroup, ntm !-------------- ! interface ! - character(idtype), intent(in) :: dtype integer, intent(in) :: idtype, insubtype + character(idtype), intent(in) :: dtype integer(4), intent(out) :: ituse, ntumgrp, ntgroup, ntmiter, isubtype real(4), intent(out) :: ttwind2, gtross2, etrmax2, etrmin2, vtar_b2, vtar_pg2 diff --git a/util/Conventional_Monitor/image_gen/sorc/conmon_read_t_IG.fd/CMakeLists.txt b/util/Conventional_Monitor/image_gen/sorc/conmon_read_t_IG.fd/CMakeLists.txt index 9ae4052a0a..0e57ee9f63 100644 --- a/util/Conventional_Monitor/image_gen/sorc/conmon_read_t_IG.fd/CMakeLists.txt +++ b/util/Conventional_Monitor/image_gen/sorc/conmon_read_t_IG.fd/CMakeLists.txt @@ -1,12 +1,29 @@ -cmake_minimum_required(VERSION 2.6) - file(GLOB CONMON_READ_T_IG_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(CONMON_READ_T_IG_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set_source_files_properties( ${CONMON_READ_T_IG_SRC} PROPERTIES COMPILE_FLAGS ${CONMON_READ_T_IG_Fortran_FLAGS} ) - add_executable(conmon_read_t_IG.x ${CONMON_READ_T_IG_SRC} ) - set_target_properties( conmon_read_t_IG.x PROPERTIES COMPILE_FLAGS ${CONMON_READ_T_IG_Fortran_FLAGS} ) - include_directories( ${CORE_INCS} ${NCDIAG_INCS} ) - target_link_libraries( conmon_read_t_IG.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ) - if(BUILD_W3NCO) - add_dependencies( conmon_read_t_IG.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + convinfo.f90 + histgram.f90 + mainread_t.f90 + read_t.f90 + read_t_mor.f90 + rm_dups.f90 +) + +add_executable(conmon_read_t_IG.x ${SRCS}) +if(TARGET ncdiag) + add_dependencies(conmon_read_t_IG.x ncdiag) +endif() + +target_compile_definitions(conmon_read_t_IG.x PRIVATE "_REAL8_") +target_link_libraries(conmon_read_t_IG.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(conmon_read_t_IG.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(conmon_read_t_IG.x PRIVATE ncdiag::ncdiag) +target_link_libraries(conmon_read_t_IG.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS conmon_read_t_IG.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Conventional_Monitor/image_gen/sorc/conmon_read_t_IG.fd/convinfo.f90 b/util/Conventional_Monitor/image_gen/sorc/conmon_read_t_IG.fd/convinfo.f90 index 63a749f7a0..a16a81a856 100644 --- a/util/Conventional_Monitor/image_gen/sorc/conmon_read_t_IG.fd/convinfo.f90 +++ b/util/Conventional_Monitor/image_gen/sorc/conmon_read_t_IG.fd/convinfo.f90 @@ -12,8 +12,8 @@ subroutine convinfo_read( dtype, idtype, insubtype, ituse, ntumgrp, ntgroup, ntm !-------------- ! interface ! - character(idtype), intent(in) :: dtype integer, intent(in) :: idtype, insubtype + character(idtype), intent(in) :: dtype integer(4), intent(out) :: ituse, ntumgrp, ntgroup, ntmiter, isubtype real(4), intent(out) :: ttwind2, gtross2, etrmax2, etrmin2, vtar_b2, vtar_pg2 diff --git a/util/Conventional_Monitor/image_gen/sorc/conmon_read_uv_IG.fd/CMakeLists.txt b/util/Conventional_Monitor/image_gen/sorc/conmon_read_uv_IG.fd/CMakeLists.txt index e74138958c..5120d849ca 100644 --- a/util/Conventional_Monitor/image_gen/sorc/conmon_read_uv_IG.fd/CMakeLists.txt +++ b/util/Conventional_Monitor/image_gen/sorc/conmon_read_uv_IG.fd/CMakeLists.txt @@ -1,12 +1,30 @@ -cmake_minimum_required(VERSION 2.6) - file(GLOB CONMON_READ_UV_IG_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(CONMON_READ_UV_IG_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set_source_files_properties( ${CONMON_READ_UV_IG_SRC} PROPERTIES COMPILE_FLAGS ${CONMON_READ_UV_IG_Fortran_FLAGS} ) - add_executable(conmon_read_uv_IG.x ${CONMON_READ_UV_IG_SRC} ) - set_target_properties( conmon_read_uv_IG.x PROPERTIES COMPILE_FLAGS ${CONMON_READ_UV_IG_Fortran_FLAGS} ) - include_directories( ${CORE_INCS} ${NCDIAG_INCS} ) - target_link_libraries( conmon_read_uv_IG.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ) - if(BUILD_W3NCO) - add_dependencies( conmon_read_uv_IG.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + convinfo.f90 + histgram.f90 + histgramuv.f90 + mainread_uv.f90 + read_uv.f90 + read_uv_mor.f90 + rm_dups.f90 +) + +add_executable(conmon_read_uv_IG.x ${SRCS}) +if(TARGET ncdiag) + add_dependencies(conmon_read_uv_IG.x ncdiag) +endif() + +target_compile_definitions(conmon_read_uv_IG.x PRIVATE "_REAL8_") +target_link_libraries(conmon_read_uv_IG.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(conmon_read_uv_IG.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(conmon_read_uv_IG.x PRIVATE ncdiag::ncdiag) +target_link_libraries(conmon_read_uv_IG.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS conmon_read_uv_IG.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Conventional_Monitor/image_gen/sorc/conmon_read_uv_IG.fd/convinfo.f90 b/util/Conventional_Monitor/image_gen/sorc/conmon_read_uv_IG.fd/convinfo.f90 index 63a749f7a0..a16a81a856 100644 --- a/util/Conventional_Monitor/image_gen/sorc/conmon_read_uv_IG.fd/convinfo.f90 +++ b/util/Conventional_Monitor/image_gen/sorc/conmon_read_uv_IG.fd/convinfo.f90 @@ -12,8 +12,8 @@ subroutine convinfo_read( dtype, idtype, insubtype, ituse, ntumgrp, ntgroup, ntm !-------------- ! interface ! - character(idtype), intent(in) :: dtype integer, intent(in) :: idtype, insubtype + character(idtype), intent(in) :: dtype integer(4), intent(out) :: ituse, ntumgrp, ntgroup, ntmiter, isubtype real(4), intent(out) :: ttwind2, gtross2, etrmax2, etrmin2, vtar_b2, vtar_pg2 diff --git a/util/Conventional_Monitor/nwprod/CMakeLists.txt b/util/Conventional_Monitor/nwprod/CMakeLists.txt new file mode 100644 index 0000000000..11bdb4b87c --- /dev/null +++ b/util/Conventional_Monitor/nwprod/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(conmon_shared) diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/CMakeLists.txt b/util/Conventional_Monitor/nwprod/conmon_shared/CMakeLists.txt new file mode 100644 index 0000000000..ddf939af1e --- /dev/null +++ b/util/Conventional_Monitor/nwprod/conmon_shared/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(sorc) diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/exec/.gitignore b/util/Conventional_Monitor/nwprod/conmon_shared/exec/.gitignore deleted file mode 100644 index d6b7ef32c8..0000000000 --- a/util/Conventional_Monitor/nwprod/conmon_shared/exec/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/modulefiles/cray/CMonBuild b/util/Conventional_Monitor/nwprod/conmon_shared/modulefiles/cray/CMonBuild deleted file mode 100644 index 0dfad2c3b1..0000000000 --- a/util/Conventional_Monitor/nwprod/conmon_shared/modulefiles/cray/CMonBuild +++ /dev/null @@ -1,21 +0,0 @@ -#%Module################################################################# -proc ModulesHelp { } { - puts stderr "Set environment variables for WCOSS cmon build" -} - -module-whatis "Set environment variables for WCOSS cmon build" - - -module load intel -module load w3nco-intel - -set ver 2.0.4 -set FCOMP ifort - -setenv CF $FCOMP -setenv FC $FCOMP -setenv FFLAGS "-O3 -fp-model strict -D_REAL8_ -traceback -convert big_endian -assume byterecl" -setenv D_FFLAGS "-O3 -fp-model strict -D_REAL8_ -traceback -convert big_endian -assume byterecl -debug" -setenv CHECK_LIBS "/gpfs/hps/nco/ops/nwprod/spa_util/check_libs.bash" - - diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/modulefiles/theia/CMonBuild b/util/Conventional_Monitor/nwprod/conmon_shared/modulefiles/theia/CMonBuild deleted file mode 100644 index 29b99fa3c7..0000000000 --- a/util/Conventional_Monitor/nwprod/conmon_shared/modulefiles/theia/CMonBuild +++ /dev/null @@ -1,17 +0,0 @@ -#%Module################################################################# -proc ModulesHelp { } { - puts stderr "Set environment variables for THEIA cmon build" -} - -module-whatis "Set environment variables for THEIA cmon build" - -module load intel - -set FCOMP ifort - -setenv CF $FCOMP -setenv FC $FCOMP -setenv FFLAGS "-O3 -fp-model strict -D_REAL8_ -traceback -convert big_endian -assume byterecl" -setenv D_FFLAGS "-O3 -fp-model strict -D_REAL8_ -traceback -convert big_endian -assume byterecl -debug" - -setenv W3NCO_LIB4 "-L/scratch3/NCEPDEV/nwprod/lib -lw3nco_4" diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/modulefiles/wcoss/CMonBuild b/util/Conventional_Monitor/nwprod/conmon_shared/modulefiles/wcoss/CMonBuild deleted file mode 100644 index ff2d51fb86..0000000000 --- a/util/Conventional_Monitor/nwprod/conmon_shared/modulefiles/wcoss/CMonBuild +++ /dev/null @@ -1,18 +0,0 @@ -#%Module################################################################# -proc ModulesHelp { } { - puts stderr "Set environment variables for WCOSS cmon build" -} - -module-whatis "Set environment variables for WCOSS cmon build" - -set ver 2.0.4 -set FCOMP ifort - -setenv CF $FCOMP -setenv FC $FCOMP -setenv FFLAGS "-O3 -fp-model strict -D_REAL8_ -traceback -convert big_endian -assume byterecl" -setenv D_FFLAGS "-O3 -fp-model strict -D_REAL8_ -traceback -convert big_endian -assume byterecl -debug" -setenv CHECK_LIBS "/nwprod/spa_util/check_libs.bash" -module load ics -module load w3nco - diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/CMakeLists.txt b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/CMakeLists.txt new file mode 100644 index 0000000000..33eafda0c8 --- /dev/null +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/CMakeLists.txt @@ -0,0 +1,6 @@ +add_subdirectory(conmon_grads_lev.fd) +add_subdirectory(conmon_grads_mandlev.fd) +add_subdirectory(conmon_grads_sfc.fd) +add_subdirectory(conmon_grads_sfctime.fd) +add_subdirectory(conmon_grads_sig.fd) +add_subdirectory(conmon_time.fd) diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_lev.fd/CMakeLists.txt b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_lev.fd/CMakeLists.txt index 34741860e8..d53b99c4a8 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_lev.fd/CMakeLists.txt +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_lev.fd/CMakeLists.txt @@ -1,19 +1,30 @@ -cmake_minimum_required(VERSION 3.16.1) - file(GLOB CONMON_GRADS_LEV_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(CONMON_GRADS_LEV_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/conmon_grads_lev ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() - set_source_files_properties( ${CONMON_GRADS_LEV_SRC} PROPERTIES COMPILE_FLAGS ${CONMON_GRADS_LEV_Fortran_FLAGS} ) - add_executable(conmon_grads_lev.x ${CONMON_GRADS_LEV_SRC} ) - set_target_properties( conmon_grads_lev.x PROPERTIES COMPILE_FLAGS ${CONMON_GRADS_LEV_Fortran_FLAGS} ) - set_target_properties( conmon_grads_lev.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) +list(APPEND SRCS + conmon_read_diag.F90 + data_mod.f90 + generic_list.f90 + grads_lev.f90 + kinds.F90 + maingrads_lev.f90 + rm_dups.f90 +) - include_directories( ${CORE_INCS} ${NCDIAG_INCS} ) +add_executable(conmon_grads_lev.x ${SRCS}) +if(TARGET ncdiag) + add_dependencies(conmon_grads_lev.x ncdiag) +endif() - target_link_libraries( conmon_grads_lev.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} - ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES} ) +target_compile_definitions(conmon_grads_lev.x PRIVATE "_REAL8_") +target_link_libraries(conmon_grads_lev.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(conmon_grads_lev.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(conmon_grads_lev.x PRIVATE ncdiag::ncdiag) +target_link_libraries(conmon_grads_lev.x PRIVATE w3emc::w3emc_4) - if(BUILD_W3NCO) - add_dependencies( conmon_grads_lev.x ${W3NCO_4_LIBRARY} ) - endif() +# Install executable targets +install(TARGETS conmon_grads_lev.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_lev.fd/conmon_read_diag.F90 b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_lev.fd/conmon_read_diag.F90 index 0b7afcf067..add99d171f 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_lev.fd/conmon_read_diag.F90 +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_lev.fd/conmon_read_diag.F90 @@ -424,12 +424,12 @@ subroutine read_diag_file_ps_nc( input_file, return_all, ftin, ctype, intype,exp ! if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -438,7 +438,7 @@ subroutine read_diag_file_ps_nc( input_file, return_all, ftin, ctype, intype,exp end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -628,12 +628,12 @@ subroutine read_diag_file_q_nc( input_file, return_all, ftin, ctype, intype,expe ! if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -643,7 +643,7 @@ subroutine read_diag_file_q_nc( input_file, return_all, ftin, ctype, intype,expe end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -850,12 +850,12 @@ subroutine read_diag_file_sst_nc( input_file, return_all, ftin, ctype, intype,ex ! if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -865,7 +865,7 @@ subroutine read_diag_file_sst_nc( input_file, return_all, ftin, ctype, intype,ex end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1100,12 +1100,12 @@ subroutine read_diag_file_t_nc( input_file, return_all, ftin, ctype, intype, exp if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -1114,7 +1114,7 @@ subroutine read_diag_file_t_nc( input_file, return_all, ftin, ctype, intype, exp end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1319,12 +1319,12 @@ subroutine read_diag_file_uv_nc( input_file, return_all, ftin, ctype, intype, ex if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -1333,7 +1333,7 @@ subroutine read_diag_file_uv_nc( input_file, return_all, ftin, ctype, intype, ex end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1554,12 +1554,12 @@ subroutine read_diag_file_gps_nc( input_file, return_all, ftin, ctype, intype,ex if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -1568,7 +1568,7 @@ subroutine read_diag_file_gps_nc( input_file, return_all, ftin, ctype, intype,ex end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1733,7 +1733,7 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr ! exit loop if the number of reals (nreal) from file ! doesn't match the target number ! - if(( return_all == .true. ) .OR. ( trim(dtype) == trim(ctype) .and. file_nreal /= expected_nreal )) then + if(( return_all .eqv. .true. ) .OR. ( trim(dtype) == trim(ctype) .and. file_nreal /= expected_nreal )) then print *, 'matched observation type:',dtype,' file_nreal=', file_nreal exit endif @@ -1741,7 +1741,7 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr !--------------------------------------------- ! skip to next iteration if types don't match ! - if(( return_all == .false. ) .AND. ( trim( dtype ) /= trim( ctype ))) then + if(( return_all .eqv. .false. ) .AND. ( trim( dtype ) /= trim( ctype ))) then cycle endif @@ -1764,7 +1764,7 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr ! if both types and subtypes match ! then add a new data element ! - if(( return_all == .true. ) .OR. ( file_itype == intype .AND. file_subtype == in_subtype )) then + if(( return_all .eqv. .true. ) .OR. ( file_itype == intype .AND. file_subtype == in_subtype )) then nobs=nobs+1 diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_lev.fd/grads_lev.f90 b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_lev.fd/grads_lev.f90 index c537af29aa..04ae4668bd 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_lev.fd/grads_lev.f90 +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_lev.fd/grads_lev.f90 @@ -73,7 +73,7 @@ subroutine grads_lev(fileo,ifileo,nobs,nreal,nlev,plev,iscater,igrads,& obs_ctr = 0 next => list - do while ( associated( next ) == .TRUE. ) + do while ( associated( next ) .eqv. .TRUE. ) ptr = transfer(list_get( next ), ptr) next => list_next( next ) diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_mandlev.fd/CMakeLists.txt b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_mandlev.fd/CMakeLists.txt index 86d8bbe097..916b99ce6e 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_mandlev.fd/CMakeLists.txt +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_mandlev.fd/CMakeLists.txt @@ -1,19 +1,30 @@ -cmake_minimum_required(VERSION 3.16.1) - file(GLOB CONMON_GRADS_MANDLEV_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(CONMON_GRADS_MANDLEV_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/conmon_grads_mandlev ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() - set_source_files_properties( ${CONMON_GRADS_MANDLEV_SRC} PROPERTIES COMPILE_FLAGS ${CONMON_GRADS_MANDLEV_Fortran_FLAGS} ) - add_executable(conmon_grads_mandlev.x ${CONMON_GRADS_MANDLEV_SRC} ) - set_target_properties( conmon_grads_mandlev.x PROPERTIES COMPILE_FLAGS ${CONMON_GRADS_MANDLEV_Fortran_FLAGS} ) - set_target_properties( conmon_grads_mandlev.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) +list(APPEND SRCS + conmon_read_diag.F90 + data_mod.f90 + generic_list.f90 + grads_mandlev.f90 + kinds.F90 + maingrads_mandlev.f90 + rm_dups.f90 +) - include_directories( ${CORE_INCS} ${NCDIAG_INCS} ) - - target_link_libraries( conmon_grads_mandlev.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} - ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES} ) +add_executable(conmon_grads_mandlev.x ${SRCS}) +if(TARGET ncdiag) + add_dependencies(conmon_grads_mandlev.x ncdiag) +endif() - if(BUILD_W3NCO) - add_dependencies( conmon_grads_mandlev.x ${W3NCO_4_LIBRARY} ) - endif() +target_compile_definitions(conmon_grads_mandlev.x PRIVATE "_REAL8_") +target_link_libraries(conmon_grads_mandlev.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(conmon_grads_mandlev.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(conmon_grads_mandlev.x PRIVATE ncdiag::ncdiag) +target_link_libraries(conmon_grads_mandlev.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS conmon_grads_mandlev.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_mandlev.fd/conmon_read_diag.F90 b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_mandlev.fd/conmon_read_diag.F90 index 0b7afcf067..add99d171f 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_mandlev.fd/conmon_read_diag.F90 +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_mandlev.fd/conmon_read_diag.F90 @@ -424,12 +424,12 @@ subroutine read_diag_file_ps_nc( input_file, return_all, ftin, ctype, intype,exp ! if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -438,7 +438,7 @@ subroutine read_diag_file_ps_nc( input_file, return_all, ftin, ctype, intype,exp end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -628,12 +628,12 @@ subroutine read_diag_file_q_nc( input_file, return_all, ftin, ctype, intype,expe ! if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -643,7 +643,7 @@ subroutine read_diag_file_q_nc( input_file, return_all, ftin, ctype, intype,expe end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -850,12 +850,12 @@ subroutine read_diag_file_sst_nc( input_file, return_all, ftin, ctype, intype,ex ! if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -865,7 +865,7 @@ subroutine read_diag_file_sst_nc( input_file, return_all, ftin, ctype, intype,ex end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1100,12 +1100,12 @@ subroutine read_diag_file_t_nc( input_file, return_all, ftin, ctype, intype, exp if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -1114,7 +1114,7 @@ subroutine read_diag_file_t_nc( input_file, return_all, ftin, ctype, intype, exp end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1319,12 +1319,12 @@ subroutine read_diag_file_uv_nc( input_file, return_all, ftin, ctype, intype, ex if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -1333,7 +1333,7 @@ subroutine read_diag_file_uv_nc( input_file, return_all, ftin, ctype, intype, ex end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1554,12 +1554,12 @@ subroutine read_diag_file_gps_nc( input_file, return_all, ftin, ctype, intype,ex if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -1568,7 +1568,7 @@ subroutine read_diag_file_gps_nc( input_file, return_all, ftin, ctype, intype,ex end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1733,7 +1733,7 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr ! exit loop if the number of reals (nreal) from file ! doesn't match the target number ! - if(( return_all == .true. ) .OR. ( trim(dtype) == trim(ctype) .and. file_nreal /= expected_nreal )) then + if(( return_all .eqv. .true. ) .OR. ( trim(dtype) == trim(ctype) .and. file_nreal /= expected_nreal )) then print *, 'matched observation type:',dtype,' file_nreal=', file_nreal exit endif @@ -1741,7 +1741,7 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr !--------------------------------------------- ! skip to next iteration if types don't match ! - if(( return_all == .false. ) .AND. ( trim( dtype ) /= trim( ctype ))) then + if(( return_all .eqv. .false. ) .AND. ( trim( dtype ) /= trim( ctype ))) then cycle endif @@ -1764,7 +1764,7 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr ! if both types and subtypes match ! then add a new data element ! - if(( return_all == .true. ) .OR. ( file_itype == intype .AND. file_subtype == in_subtype )) then + if(( return_all .eqv. .true. ) .OR. ( file_itype == intype .AND. file_subtype == in_subtype )) then nobs=nobs+1 diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_mandlev.fd/grads_mandlev.f90 b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_mandlev.fd/grads_mandlev.f90 index 00542bd878..68a63ea3a1 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_mandlev.fd/grads_mandlev.f90 +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_mandlev.fd/grads_mandlev.f90 @@ -28,6 +28,7 @@ subroutine grads_mandlev(fileo,ifileo,nobs,nreal,nlev,plev,iscater,igrads,& real(4) rlat,rlon,rp character(3) subtype,run character(8) stid + integer ifileo character(ifileo) :: fileo character(30) :: files,filegrads character(8) :: stidend @@ -35,7 +36,7 @@ subroutine grads_mandlev(fileo,ifileo,nobs,nreal,nlev,plev,iscater,igrads,& real*4 :: rtim,xlat0,xlon0 character(30) :: filein, file_nobs - integer :: ifileo,i,j,ii,k,nreal_m2,ctr,obs_ctr + integer :: i,j,ii,k,nreal_m2,ctr,obs_ctr integer :: ilat,ilon,ipres,itime,iweight,ndup integer(4) :: isubtype @@ -66,7 +67,7 @@ subroutine grads_mandlev(fileo,ifileo,nobs,nreal,nlev,plev,iscater,igrads,& obs_ctr = 0 next => list - do while ( associated( next ) == .TRUE. ) + do while ( associated( next ) .eqv. .TRUE. ) ptr = transfer(list_get( next ), ptr) next => list_next( next ) diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfc.fd/CMakeLists.txt b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfc.fd/CMakeLists.txt index e1e38afaf3..1535bd6813 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfc.fd/CMakeLists.txt +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfc.fd/CMakeLists.txt @@ -1,17 +1,30 @@ -cmake_minimum_required(VERSION 3.16.1) - file(GLOB CONMON_GRADS_SFC_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(CONMON_GRADS_SFC_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/conmon_grads_sfc ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() - set_source_files_properties( ${CONMON_GRADS_SFC_SRC} PROPERTIES COMPILE_FLAGS ${CONMON_GRADS_SFC_Fortran_FLAGS} ) - add_executable(conmon_grads_sfc.x ${CONMON_GRADS_SFC_SRC} ) - set_target_properties( conmon_grads_sfc.x PROPERTIES COMPILE_FLAGS ${CONMON_GRADS_SFC_Fortran_FLAGS} ) - set_target_properties( conmon_grads_sfc.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) +list(APPEND SRCS + conmon_read_diag.F90 + data_mod.f90 + generic_list.f90 + grads_sfc.f90 + kinds.F90 + maingrads_sfc.f90 + rm_dups.f90 +) - include_directories( ${CORE_INCS} ${NCDIAG_INCS} ) - target_link_libraries( conmon_grads_sfc.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} - ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES} ) - if(BUILD_W3NCO) - add_dependencies( conmon_grads_sfc.x ${W3NCO_4_LIBRARY} ) - endif() +add_executable(conmon_grads_sfc.x ${SRCS}) +if(TARGET ncdiag) + add_dependencies(conmon_grads_sfc.x ncdiag) +endif() + +target_compile_definitions(conmon_grads_sfc.x PRIVATE "_REAL8_") +target_link_libraries(conmon_grads_sfc.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(conmon_grads_sfc.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(conmon_grads_sfc.x PRIVATE ncdiag::ncdiag) +target_link_libraries(conmon_grads_sfc.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS conmon_grads_sfc.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfc.fd/conmon_read_diag.F90 b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfc.fd/conmon_read_diag.F90 index 0b7afcf067..add99d171f 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfc.fd/conmon_read_diag.F90 +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfc.fd/conmon_read_diag.F90 @@ -424,12 +424,12 @@ subroutine read_diag_file_ps_nc( input_file, return_all, ftin, ctype, intype,exp ! if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -438,7 +438,7 @@ subroutine read_diag_file_ps_nc( input_file, return_all, ftin, ctype, intype,exp end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -628,12 +628,12 @@ subroutine read_diag_file_q_nc( input_file, return_all, ftin, ctype, intype,expe ! if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -643,7 +643,7 @@ subroutine read_diag_file_q_nc( input_file, return_all, ftin, ctype, intype,expe end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -850,12 +850,12 @@ subroutine read_diag_file_sst_nc( input_file, return_all, ftin, ctype, intype,ex ! if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -865,7 +865,7 @@ subroutine read_diag_file_sst_nc( input_file, return_all, ftin, ctype, intype,ex end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1100,12 +1100,12 @@ subroutine read_diag_file_t_nc( input_file, return_all, ftin, ctype, intype, exp if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -1114,7 +1114,7 @@ subroutine read_diag_file_t_nc( input_file, return_all, ftin, ctype, intype, exp end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1319,12 +1319,12 @@ subroutine read_diag_file_uv_nc( input_file, return_all, ftin, ctype, intype, ex if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -1333,7 +1333,7 @@ subroutine read_diag_file_uv_nc( input_file, return_all, ftin, ctype, intype, ex end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1554,12 +1554,12 @@ subroutine read_diag_file_gps_nc( input_file, return_all, ftin, ctype, intype,ex if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -1568,7 +1568,7 @@ subroutine read_diag_file_gps_nc( input_file, return_all, ftin, ctype, intype,ex end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1733,7 +1733,7 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr ! exit loop if the number of reals (nreal) from file ! doesn't match the target number ! - if(( return_all == .true. ) .OR. ( trim(dtype) == trim(ctype) .and. file_nreal /= expected_nreal )) then + if(( return_all .eqv. .true. ) .OR. ( trim(dtype) == trim(ctype) .and. file_nreal /= expected_nreal )) then print *, 'matched observation type:',dtype,' file_nreal=', file_nreal exit endif @@ -1741,7 +1741,7 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr !--------------------------------------------- ! skip to next iteration if types don't match ! - if(( return_all == .false. ) .AND. ( trim( dtype ) /= trim( ctype ))) then + if(( return_all .eqv. .false. ) .AND. ( trim( dtype ) /= trim( ctype ))) then cycle endif @@ -1764,7 +1764,7 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr ! if both types and subtypes match ! then add a new data element ! - if(( return_all == .true. ) .OR. ( file_itype == intype .AND. file_subtype == in_subtype )) then + if(( return_all .eqv. .true. ) .OR. ( file_itype == intype .AND. file_subtype == in_subtype )) then nobs=nobs+1 diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfc.fd/grads_sfc.f90 b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfc.fd/grads_sfc.f90 index a6a005cf25..acec4a60d9 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfc.fd/grads_sfc.f90 +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfc.fd/grads_sfc.f90 @@ -56,7 +56,7 @@ subroutine grads_sfc(fileo,ifileo,nobs,nreal,iscater,igrads,isubtype,subtype,lis obs_ctr = 0 next => list - do while ( associated( next ) == .TRUE. ) + do while ( associated( next ) .eqv. .TRUE. ) ptr = transfer(list_get( next ), ptr) next => list_next( next ) diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfctime.fd/CMakeLists.txt b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfctime.fd/CMakeLists.txt index 74b10dc307..c01c38b0f7 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfctime.fd/CMakeLists.txt +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfctime.fd/CMakeLists.txt @@ -1,24 +1,30 @@ -cmake_minimum_required(VERSION 3.16.1) - - file(GLOB CONMON_GRADS_SFCTIME_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - - set(CONMON_GRADS_SFCTIME_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/conmon_grads_sfctime ) - - set_source_files_properties( ${CONMON_GRADS_SFCTIME_SRC} PROPERTIES COMPILE_FLAGS ${CONMON_GRADS_SFCTIME_Fortran_FLAGS} ) - - add_executable(conmon_grads_sfctime.x ${CONMON_GRADS_SFCTIME_SRC} ) - - set_target_properties( conmon_grads_sfctime.x PROPERTIES COMPILE_FLAGS ${CONMON_GRADS_SFCTIME_Fortran_FLAGS} ) - set_target_properties( conmon_grads_sfctime.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) - - include_directories( ${CORE_INCS} ${NCDIAG_INCS} ) - - target_link_libraries( conmon_grads_sfctime.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} - ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES} ) - - if(BUILD_W3NCO) - add_dependencies( conmon_grads_sfctime.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + conmon_read_diag.F90 + data_mod.f90 + generic_list.f90 + grads_sfctime.f90 + kinds.F90 + maingrads_sfctime.f90 + rm_dups.f90 +) + +add_executable(conmon_grads_sfctime.x ${SRCS}) +if(TARGET ncdiag) + add_dependencies(conmon_grads_sfctime.x ncdiag) +endif() + +target_compile_definitions(conmon_grads_sfctime.x PRIVATE "_REAL8_") +target_link_libraries(conmon_grads_sfctime.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(conmon_grads_sfctime.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(conmon_grads_sfctime.x PRIVATE ncdiag::ncdiag) +target_link_libraries(conmon_grads_sfctime.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS conmon_grads_sfctime.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfctime.fd/conmon_read_diag.F90 b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfctime.fd/conmon_read_diag.F90 index 0b7afcf067..add99d171f 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfctime.fd/conmon_read_diag.F90 +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfctime.fd/conmon_read_diag.F90 @@ -424,12 +424,12 @@ subroutine read_diag_file_ps_nc( input_file, return_all, ftin, ctype, intype,exp ! if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -438,7 +438,7 @@ subroutine read_diag_file_ps_nc( input_file, return_all, ftin, ctype, intype,exp end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -628,12 +628,12 @@ subroutine read_diag_file_q_nc( input_file, return_all, ftin, ctype, intype,expe ! if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -643,7 +643,7 @@ subroutine read_diag_file_q_nc( input_file, return_all, ftin, ctype, intype,expe end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -850,12 +850,12 @@ subroutine read_diag_file_sst_nc( input_file, return_all, ftin, ctype, intype,ex ! if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -865,7 +865,7 @@ subroutine read_diag_file_sst_nc( input_file, return_all, ftin, ctype, intype,ex end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1100,12 +1100,12 @@ subroutine read_diag_file_t_nc( input_file, return_all, ftin, ctype, intype, exp if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -1114,7 +1114,7 @@ subroutine read_diag_file_t_nc( input_file, return_all, ftin, ctype, intype, exp end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1319,12 +1319,12 @@ subroutine read_diag_file_uv_nc( input_file, return_all, ftin, ctype, intype, ex if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -1333,7 +1333,7 @@ subroutine read_diag_file_uv_nc( input_file, return_all, ftin, ctype, intype, ex end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1554,12 +1554,12 @@ subroutine read_diag_file_gps_nc( input_file, return_all, ftin, ctype, intype,ex if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -1568,7 +1568,7 @@ subroutine read_diag_file_gps_nc( input_file, return_all, ftin, ctype, intype,ex end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1733,7 +1733,7 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr ! exit loop if the number of reals (nreal) from file ! doesn't match the target number ! - if(( return_all == .true. ) .OR. ( trim(dtype) == trim(ctype) .and. file_nreal /= expected_nreal )) then + if(( return_all .eqv. .true. ) .OR. ( trim(dtype) == trim(ctype) .and. file_nreal /= expected_nreal )) then print *, 'matched observation type:',dtype,' file_nreal=', file_nreal exit endif @@ -1741,7 +1741,7 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr !--------------------------------------------- ! skip to next iteration if types don't match ! - if(( return_all == .false. ) .AND. ( trim( dtype ) /= trim( ctype ))) then + if(( return_all .eqv. .false. ) .AND. ( trim( dtype ) /= trim( ctype ))) then cycle endif @@ -1764,7 +1764,7 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr ! if both types and subtypes match ! then add a new data element ! - if(( return_all == .true. ) .OR. ( file_itype == intype .AND. file_subtype == in_subtype )) then + if(( return_all .eqv. .true. ) .OR. ( file_itype == intype .AND. file_subtype == in_subtype )) then nobs=nobs+1 diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfctime.fd/grads_sfctime.f90 b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfctime.fd/grads_sfctime.f90 index 4f52806b66..bbcde658ea 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfctime.fd/grads_sfctime.f90 +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfctime.fd/grads_sfctime.f90 @@ -91,7 +91,7 @@ subroutine grads_sfctime(fileo,ifileo,nobs,nreal,nlev,plev,iscater,& obs_ctr = 0 next => list - do while ( associated( next ) == .TRUE. ) + do while ( associated( next ) .eqv. .TRUE. ) ptr = transfer(list_get( next ), ptr) next => list_next( next ) diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sig.fd/CMakeLists.txt b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sig.fd/CMakeLists.txt index b13e9f35b6..42f1367e65 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sig.fd/CMakeLists.txt +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sig.fd/CMakeLists.txt @@ -1,19 +1,32 @@ -cmake_minimum_required(VERSION 3.16.1) - file(GLOB CONMON_GRADS_SIG_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(CONMON_GRADS_SIG_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/conmon_grads_sig ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() - set_source_files_properties( ${CONMON_GRADS_SIG_SRC} PROPERTIES COMPILE_FLAGS ${CONMON_GRADS_SIG_Fortran_FLAGS} ) - add_executable(conmon_grads_sig.x ${CONMON_GRADS_SIG_SRC} ) - set_target_properties( conmon_grads_sig.x PROPERTIES COMPILE_FLAGS ${CONMON_GRADS_SIG_Fortran_FLAGS} ) - set_target_properties( conmon_grads_sig.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) +list(APPEND SRCS + conmon_read_diag.F90 + data_mod.f90 + generic_list.f90 + grads_sig.f90 + kinds.F90 + maingrads_sig.f90 + read_conv2grads.f90 + rm_dups.f90 +) - include_directories( ${CORE_INCS} ${NCDIAG_INCS} ) - - target_link_libraries( conmon_grads_sig.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} - ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES} ) +add_executable(conmon_grads_sig.x ${SRCS}) +if(TARGET ncdiag) + add_dependencies(conmon_grads_sig.x ncdiag) +endif() + +target_compile_definitions(conmon_grads_sig.x PRIVATE "_REAL8_") +target_link_libraries(conmon_grads_sig.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(conmon_grads_sig.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(conmon_grads_sig.x PRIVATE ncdiag::ncdiag) +target_link_libraries(conmon_grads_sig.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS conmon_grads_sig.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) - if(BUILD_W3NCO) - add_dependencies( conmon_grads_sig.x ${W3NCO_4_LIBRARY} ) - endif() diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sig.fd/conmon_read_diag.F90 b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sig.fd/conmon_read_diag.F90 index 0b7afcf067..add99d171f 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sig.fd/conmon_read_diag.F90 +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sig.fd/conmon_read_diag.F90 @@ -424,12 +424,12 @@ subroutine read_diag_file_ps_nc( input_file, return_all, ftin, ctype, intype,exp ! if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -438,7 +438,7 @@ subroutine read_diag_file_ps_nc( input_file, return_all, ftin, ctype, intype,exp end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -628,12 +628,12 @@ subroutine read_diag_file_q_nc( input_file, return_all, ftin, ctype, intype,expe ! if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -643,7 +643,7 @@ subroutine read_diag_file_q_nc( input_file, return_all, ftin, ctype, intype,expe end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -850,12 +850,12 @@ subroutine read_diag_file_sst_nc( input_file, return_all, ftin, ctype, intype,ex ! if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -865,7 +865,7 @@ subroutine read_diag_file_sst_nc( input_file, return_all, ftin, ctype, intype,ex end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1100,12 +1100,12 @@ subroutine read_diag_file_t_nc( input_file, return_all, ftin, ctype, intype, exp if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -1114,7 +1114,7 @@ subroutine read_diag_file_t_nc( input_file, return_all, ftin, ctype, intype, exp end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1319,12 +1319,12 @@ subroutine read_diag_file_uv_nc( input_file, return_all, ftin, ctype, intype, ex if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -1333,7 +1333,7 @@ subroutine read_diag_file_uv_nc( input_file, return_all, ftin, ctype, intype, ex end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1554,12 +1554,12 @@ subroutine read_diag_file_gps_nc( input_file, return_all, ftin, ctype, intype,ex if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -1568,7 +1568,7 @@ subroutine read_diag_file_gps_nc( input_file, return_all, ftin, ctype, intype,ex end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1733,7 +1733,7 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr ! exit loop if the number of reals (nreal) from file ! doesn't match the target number ! - if(( return_all == .true. ) .OR. ( trim(dtype) == trim(ctype) .and. file_nreal /= expected_nreal )) then + if(( return_all .eqv. .true. ) .OR. ( trim(dtype) == trim(ctype) .and. file_nreal /= expected_nreal )) then print *, 'matched observation type:',dtype,' file_nreal=', file_nreal exit endif @@ -1741,7 +1741,7 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr !--------------------------------------------- ! skip to next iteration if types don't match ! - if(( return_all == .false. ) .AND. ( trim( dtype ) /= trim( ctype ))) then + if(( return_all .eqv. .false. ) .AND. ( trim( dtype ) /= trim( ctype ))) then cycle endif @@ -1764,7 +1764,7 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr ! if both types and subtypes match ! then add a new data element ! - if(( return_all == .true. ) .OR. ( file_itype == intype .AND. file_subtype == in_subtype )) then + if(( return_all .eqv. .true. ) .OR. ( file_itype == intype .AND. file_subtype == in_subtype )) then nobs=nobs+1 diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sig.fd/grads_sig.f90 b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sig.fd/grads_sig.f90 index b07dc632a3..66ee7da3d3 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sig.fd/grads_sig.f90 +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sig.fd/grads_sig.f90 @@ -70,7 +70,7 @@ subroutine grads_sig(fileo,ifileo,nobs,nreal,nlev,plev,iscater,igrads,isubtype,s obs_ctr = 0 next => list - do while ( associated( next ) == .TRUE. ) + do while ( associated( next ) .eqv. .TRUE. ) ptr = transfer(list_get( next ), ptr) next => list_next( next ) diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_time.fd/CMakeLists.txt b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_time.fd/CMakeLists.txt index 767fdad0eb..41d0d74928 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_time.fd/CMakeLists.txt +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_time.fd/CMakeLists.txt @@ -1,19 +1,33 @@ -cmake_minimum_required(VERSION 3.16.1) - file(GLOB CONMON_TIME_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(CONMON_TIME_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/conmon_time ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() - set_source_files_properties( ${CONMON_TIME_SRC} PROPERTIES COMPILE_FLAGS ${CONMON_TIME_Fortran_FLAGS} ) - add_executable(conmon_time.x ${CONMON_TIME_SRC} ) - set_target_properties( conmon_time.x PROPERTIES COMPILE_FLAGS ${CONMON_TIME_Fortran_FLAGS} ) - set_target_properties( conmon_time.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) +list(APPEND SRCS + conmon_read_diag.F90 + convinfo2.f90 + data_mod.f90 + generic_list.f90 + kinds.F90 + mainconv_time.f90 + process_time_data.f90 + stas2ctl.f90 + stas_time.f90 + stas_time_gps.f90 +) - include_directories( ${CORE_INCS} ${NCDIAG_INCS} ) - - target_link_libraries( conmon_time.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} - ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES} ) +add_executable(conmon_time.x ${SRCS}) +if(TARGET ncdiag) + add_dependencies(conmon_time.x ncdiag) +endif() - if(BUILD_W3NCO) - add_dependencies( conmon_time.x ${W3NCO_4_LIBRARY} ) - endif() +target_compile_definitions(conmon_time.x PRIVATE "_REAL8_") +target_link_libraries(conmon_time.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(conmon_time.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(conmon_time.x PRIVATE ncdiag::ncdiag) +target_link_libraries(conmon_time.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS conmon_time.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_time.fd/conmon_read_diag.F90 b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_time.fd/conmon_read_diag.F90 index 0b7afcf067..add99d171f 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_time.fd/conmon_read_diag.F90 +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_time.fd/conmon_read_diag.F90 @@ -424,12 +424,12 @@ subroutine read_diag_file_ps_nc( input_file, return_all, ftin, ctype, intype,exp ! if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -438,7 +438,7 @@ subroutine read_diag_file_ps_nc( input_file, return_all, ftin, ctype, intype,exp end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -628,12 +628,12 @@ subroutine read_diag_file_q_nc( input_file, return_all, ftin, ctype, intype,expe ! if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -643,7 +643,7 @@ subroutine read_diag_file_q_nc( input_file, return_all, ftin, ctype, intype,expe end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -850,12 +850,12 @@ subroutine read_diag_file_sst_nc( input_file, return_all, ftin, ctype, intype,ex ! if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -865,7 +865,7 @@ subroutine read_diag_file_sst_nc( input_file, return_all, ftin, ctype, intype,ex end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1100,12 +1100,12 @@ subroutine read_diag_file_t_nc( input_file, return_all, ftin, ctype, intype, exp if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -1114,7 +1114,7 @@ subroutine read_diag_file_t_nc( input_file, return_all, ftin, ctype, intype, exp end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1319,12 +1319,12 @@ subroutine read_diag_file_uv_nc( input_file, return_all, ftin, ctype, intype, ex if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -1333,7 +1333,7 @@ subroutine read_diag_file_uv_nc( input_file, return_all, ftin, ctype, intype, ex end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1554,12 +1554,12 @@ subroutine read_diag_file_gps_nc( input_file, return_all, ftin, ctype, intype,ex if( adjustl( trim( Observation_Class(ii) )) == adjustl( trim( ctype ))) then - if( return_all == .true. ) then + if( return_all .eqv. .true. ) then add_obs = .true. else if( Observation_Type(ii) == intype ) then - if( have_subtype == .false. ) then + if( have_subtype .eqv. .false. ) then add_obs = .true. else if( Observation_Subtype(ii) == in_subtype ) then add_obs = .true. @@ -1568,7 +1568,7 @@ subroutine read_diag_file_gps_nc( input_file, return_all, ftin, ctype, intype,ex end if end if - if( add_obs == .true. ) then + if( add_obs .eqv. .true. ) then nobs=nobs+1 @@ -1733,7 +1733,7 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr ! exit loop if the number of reals (nreal) from file ! doesn't match the target number ! - if(( return_all == .true. ) .OR. ( trim(dtype) == trim(ctype) .and. file_nreal /= expected_nreal )) then + if(( return_all .eqv. .true. ) .OR. ( trim(dtype) == trim(ctype) .and. file_nreal /= expected_nreal )) then print *, 'matched observation type:',dtype,' file_nreal=', file_nreal exit endif @@ -1741,7 +1741,7 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr !--------------------------------------------- ! skip to next iteration if types don't match ! - if(( return_all == .false. ) .AND. ( trim( dtype ) /= trim( ctype ))) then + if(( return_all .eqv. .false. ) .AND. ( trim( dtype ) /= trim( ctype ))) then cycle endif @@ -1764,7 +1764,7 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr ! if both types and subtypes match ! then add a new data element ! - if(( return_all == .true. ) .OR. ( file_itype == intype .AND. file_subtype == in_subtype )) then + if(( return_all .eqv. .true. ) .OR. ( file_itype == intype .AND. file_subtype == in_subtype )) then nobs=nobs+1 diff --git a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_time.fd/process_time_data.f90 b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_time.fd/process_time_data.f90 index bc7c6ae5ec..68a4701b99 100644 --- a/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_time.fd/process_time_data.f90 +++ b/util/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_time.fd/process_time_data.f90 @@ -315,7 +315,7 @@ subroutine process_conv_nc( input_file, ctype, mregion, nregion, np, & print *, ' select, case ps' obs_ctr = 0 - do while ( associated( next ) == .TRUE. ) + do while ( associated( next ) .eqv. .TRUE. ) obs_ctr = obs_ctr + 1 ptr = transfer(list_get( next ), ptr) next => list_next( next ) @@ -340,7 +340,7 @@ subroutine process_conv_nc( input_file, ctype, mregion, nregion, np, & print *, ' select, case q' obs_ctr = 0 - do while ( associated( next ) == .TRUE. ) + do while ( associated( next ) .eqv. .TRUE. ) obs_ctr = obs_ctr + 1 ptr = transfer(list_get( next ), ptr) next => list_next( next ) @@ -365,7 +365,7 @@ subroutine process_conv_nc( input_file, ctype, mregion, nregion, np, & print *, ' select, case t' obs_ctr = 0 - do while ( associated( next ) == .TRUE. ) + do while ( associated( next ) .eqv. .TRUE. ) obs_ctr = obs_ctr + 1 ptr = transfer(list_get( next ), ptr) next => list_next( next ) @@ -389,7 +389,7 @@ subroutine process_conv_nc( input_file, ctype, mregion, nregion, np, & print *, ' select, case uv' obs_ctr = 0 - do while ( associated( next ) == .TRUE. ) + do while ( associated( next ) .eqv. .TRUE. ) obs_ctr = obs_ctr + 1 ptr = transfer(list_get( next ), ptr) next => list_next( next ) @@ -412,7 +412,7 @@ subroutine process_conv_nc( input_file, ctype, mregion, nregion, np, & case ( 'gps' ) print *, ' select, case gps' obs_ctr = 0 - do while ( associated( next ) == .TRUE. ) + do while ( associated( next ) .eqv. .TRUE. ) obs_ctr = obs_ctr + 1 ptr = transfer(list_get( next ), ptr) next => list_next( next ) diff --git a/util/Correlated_Obs/CMakeLists.txt b/util/Correlated_Obs/CMakeLists.txt index 310683be11..1c9b23ac9a 100644 --- a/util/Correlated_Obs/CMakeLists.txt +++ b/util/Correlated_Obs/CMakeLists.txt @@ -1,92 +1,38 @@ -cmake_minimum_required(VERSION 2.6) -if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) - # I am top-level project. - if( NOT DEFINED ENV{CC} ) - find_path( crayComp "ftn" ) - find_path( wcossIntel "mpfort" ) - find_path( intelComp "ifort" ) - find_path( pgiComp "pgf90" ) - if( crayComp ) - message("Setting CrayLinuxEnvironment") - set(CMAKE_SYSTEM_NAME "CrayLinuxEnvironment") - set(CMAKE_C_COMPILER "${crayComp}/cc") - set(CMAKE_CXX_COMPILER "${crayComp}/CC") - set(CMAKE_Fortran_COMPILER "${crayComp}/ftn") - endif() - if( intelComp ) - set(ENV{CC} "icc") - set(ENV{CXX} "icpc") - set(ENV{FC} "ifort") - endif() - if( wcossIntel ) - message("Setting env for wcoss intel") - set(ENV{CC} "mpcc") - set(ENV{CXX} "mpCC") - set(ENV{FC} "mpfort") - endif() - if( pgiComp ) - set(ENV{CC} "pgcc") - set(ENV{CXX} "pgCC") - set(ENV{FC} "pgf90") - endif() - endif() - project(COV_Calc) - enable_language (Fortran) - find_package(OpenMP) - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/../../cmake/Modules/") - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setPlatformVariables.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setIntelFlags.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setGNUFlags.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setPGIFlags.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setHOST.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Cheyenne.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Discover.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Generic.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Gaea.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Jet.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/S4.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Theia.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/WCOSS-C.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/WCOSS-D.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/WCOSS.cmake) - if (NOT CMAKE_BUILD_TYPE) - set (CMAKE_BUILD_TYPE RELEASE CACHE STRING - "Choose the type of build, options are: PRODUCTION Debug Release." - FORCE) - endif (NOT CMAKE_BUILD_TYPE) - if (CMAKE_CXX_COMPILER_ID MATCHES "GNU*") - message("Setting GNU flags") - setGNU() - elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - message("Setting Intel flags") - setIntel() - elseif(CMAKE_C_COMPILER MATCHES "pgc*") - message("Setting PGI flags") - setPGI() - endif() - find_package(MPI REQUIRED) - add_definitions(${MPI_Fortran_COMPILE_FLAGS}) - include_directories(${MPI_Fortran_INCLUDE_DIRS} ${MPI_INCLUDE_PATH} "./" ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) - link_directories(${MPI_Fortran_LIBRARIES} ${ARCHIVE_OUTPUT_PATH} ) - find_package( NetCDF REQUIRED) - set(BUILD_NCDIAG ON) - set(NCDIAG_INCS "${PROJECT_BINARY_DIR}/src/ncdiag/include") - add_subdirectory(src/ncdiag) - set(NCDIAG_LIBRARIES ncdiag ) -endif() - set(COV_CALC_SRC ${CMAKE_CURRENT_SOURCE_DIR}/cov_calc.f90 ${CMAKE_CURRENT_SOURCE_DIR}/cconstants.f90 ${CMAKE_CURRENT_SOURCE_DIR}/ckinds.f90 ${CMAKE_CURRENT_SOURCE_DIR}/matrix_tools.f90 ${CMAKE_CURRENT_SOURCE_DIR}/obs_tools.f90 ${CMAKE_CURRENT_SOURCE_DIR}/pairs.f90 ${CMAKE_CURRENT_SOURCE_DIR}/readsatobs.f90 ${CMAKE_CURRENT_SOURCE_DIR}/read_diag.f90 ) -message("HEY!! openmp flag is ${OpenMP_Fortran_FLAGS} and libraries are ${OpenMP_Fortran_LIBRARIES}") -#message("HEY!! coreincs is ${CORE_INCS}") -message("ncdiag is ${NCDIAG_LIBRARIES}") - set_source_files_properties( ${COV_CALC_SRC} PROPERTIES COMPILE_FLAGS ${COV_CALC_FLAGS} ) - add_executable(cov_calc ${COV_CALC_SRC} ) - add_dependencies(cov_calc ${NCDIAG_LIBRARIES}) - set_target_properties( cov_calc PROPERTIES COMPILE_FLAGS ${COV_CALC_FLAGS} ) - include_directories( ${CORE_INCS} ${NETCDF_INCLUDE_DIRS} ${NCDIAG_INCS}) -# target_link_libraries( cov_calc ${W3NCO_LIBRARY} ) - target_link_libraries( cov_calc ${OpenMP_Fortran_LIBRARIES} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES}) - if(BUILD_COV_CALC) -# add_dependencies( cov_calc ${W3NCO_LIBRARY} ) -# add_dependencies( cov_calc ${OpenMP_Fortran_LIBRARIES} ) +if(NOT TARGET ncdiag) + if(NOT ncdiag_FOUND) + message(STATUS "Utils: ncdiag library was not found. Disable Correlated Obs utility") + return() endif() +endif() + +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + cconstants.f90 + ckinds.f90 + cov_calc.f90 + matrix_tools.f90 + obs_tools.f90 + pairs.f90 + readsatobs.f90 + read_diag.f90) + +# Create cov_calc.x executable +add_executable(cov_calc.x ${SRCS}) +target_link_libraries(cov_calc.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(cov_calc.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(cov_calc.x PRIVATE ${LAPACK_LIBRARIES}) +if(TARGET ncdiag) + add_dependencies(cov_calc.x ncdiag) +endif() +target_link_libraries(cov_calc.x PRIVATE ncdiag::ncdiag) +if(OpenMP_Fortran_FOUND) + target_link_libraries(cov_calc.x PRIVATE OpenMP::OpenMP_Fortran) +endif() +# Install executable targets +install(TARGETS cov_calc.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/EFSOI_Utilities/CMakeLists.txt b/util/EFSOI_Utilities/CMakeLists.txt new file mode 100644 index 0000000000..1aec52ef07 --- /dev/null +++ b/util/EFSOI_Utilities/CMakeLists.txt @@ -0,0 +1,11 @@ +if(NOT TARGET enkf) + if(NOT enkf_FOUND) + message(FATAL_ERROR "Utils: EnKF library was not found for EFSOI utilities") + endif() +endif() + +if(NOT ENKF_MODE MATCHES "GFS") + message(FATAL_ERROR "Utils: Incompatible EnKF = ${ENKF_MODE} for EFSOI utilities") +endif() + +add_subdirectory(src) diff --git a/util/EFSOI_Utilities/src/CMakeLists.txt b/util/EFSOI_Utilities/src/CMakeLists.txt index 49d2a8fdee..fd16d71bed 100644 --- a/util/EFSOI_Utilities/src/CMakeLists.txt +++ b/util/EFSOI_Utilities/src/CMakeLists.txt @@ -1,21 +1,37 @@ -cmake_minimum_required(VERSION 2.6) -if(BUILD_EFSOI) - - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90) - - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${ENKF_Fortran_FLAGS} ) - - add_executable(global_efsoi.x ${LOCAL_SRC} ) - - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OMPFLAG}" ) - - include_directories(${CMAKE_CURRENT_BINARY_DIR} "${PROJECT_BINARY_DIR}/include/global" ${CMAKE_CURRENT_BINARY_DIR}/.. ${MPI_Fortran_INCLUDE_DIRS} ${MPI_Fortran_INCLUDE_PATH} ${CORE_INCS} ${NETCDF_INCLUDE_DIRS} ${NCDIAG_INCS} ${FV3GFS_NCIO_INCS}) - - target_link_libraries( global_efsoi.x enkflib enkfdeplib ${GSILIB} ${GSISHAREDLIB} ${CORE_LIBRARIES} - ${MPI_Fortran_LIBRARIES} ${LAPACK_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} - ${FV3GFS_NCIO_LIBRARIES} - ${EXTRA_LINKER_FLAGS} ${GSI_LDFLAGS} ${CORE_BUILT} ${CORE_LIBRARIES} ${CORE_BUILT} ${NCDIAG_LIBRARIES}) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") endif() +list(APPEND SRCS + efsoi.f90 + efsoi_main.f90 + gridio_efsoi.f90 + loadbal_efsoi.f90 + loc_advection.f90 + scatter_chunks_efsoi.f90 + statevec_efsoi.f90) +add_executable(efsoi.x ${SRCS}) +target_compile_definitions(efsoi.x PRIVATE "_REAL8_") +if(TARGET enkf) + add_dependencies(efsoi.x enkf) +endif() +target_link_libraries(efsoi.x PRIVATE enkf::enkf) +target_link_libraries(efsoi.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(efsoi.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(efsoi.x PRIVATE ${LAPACK_LIBRARIES}) +target_link_libraries(efsoi.x PRIVATE bacio::bacio_4) +target_link_libraries(efsoi.x PRIVATE sigio::sigio) +target_link_libraries(efsoi.x PRIVATE sfcio::sfcio) +target_link_libraries(efsoi.x PRIVATE nemsio::nemsio) +target_link_libraries(efsoi.x PRIVATE ncio::ncio) +target_link_libraries(efsoi.x PRIVATE w3emc::w3emc_d) +target_link_libraries(efsoi.x PRIVATE sp::sp_d) +if(OpenMP_Fortran_FOUND) + target_link_libraries(efsoi.x PRIVATE OpenMP::OpenMP_Fortran) +endif() +# Install executable targets +install(TARGETS efsoi.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/EFSOI_Utilities/src/efsoi.f90 b/util/EFSOI_Utilities/src/efsoi.f90 index 8dbf386ef7..4565eb8a08 100644 --- a/util/EFSOI_Utilities/src/efsoi.f90 +++ b/util/EFSOI_Utilities/src/efsoi.f90 @@ -33,9 +33,10 @@ module efsoi ! !$$$ -use mpisetup +use mpi +use mpisetup, only: nproc, numproc, mpi_realkind use covlocal, only: taper -use kinds, only: r_double, i_kind, r_kind +use kinds, only: r_single, r_double, i_kind, r_kind use kdtree2_module, only: kdtree2_r_nearest, kdtree2_result use loadbal_efsoi, only: numptsperproc, indxproc, lnp_chunk, kdtree_grid, & iprocob, indxob_chunk, anal_obchunk_prior, numobsperproc, & @@ -76,7 +77,7 @@ subroutine efsoi_update() integer(i_kind) :: nnpt, nsame, nskip, ngrd1 integer(i_kind) :: ierr logical :: kdgrid - +integer status(MPI_STATUS_SIZE) if (.not. constants_initialized) then print *,'constants not initialized (with init_constants, init_constants_derived)' @@ -304,7 +305,7 @@ subroutine efsoi_update() allocate(buffertmp(nanals,nobs_max)) do np=1,numproc-1 call mpi_recv(buffertmp,numobsperproc(np+1)*nanals,mpi_real4,np, & - 1,mpi_comm_world,mpi_status,ierr) + 1,mpi_comm_world,status,ierr) do nob1=1,numobsperproc(np+1) nob2 = indxproc_obs(np+1,nob1) anal_ob_post(:,nob2) = buffertmp(:,nob1) diff --git a/util/EFSOI_Utilities/src/efsoi_main.f90 b/util/EFSOI_Utilities/src/efsoi_main.f90 index e4e6307441..6482f4c940 100644 --- a/util/EFSOI_Utilities/src/efsoi_main.f90 +++ b/util/EFSOI_Utilities/src/efsoi_main.f90 @@ -57,8 +57,8 @@ program efsoi_main ! applying enkf namelist apparatus use params, only : read_namelist,nanals ! mpi functions and variables. - use mpisetup, only: mpi_initialize, mpi_initialize_io, mpi_cleanup, nproc, & - mpi_wtime, mpi_comm_world + use mpi + use mpisetup, only: mpi_initialize, mpi_initialize_io, mpi_cleanup, nproc ! model state vector use statevec_efsoi, only: read_state_efsoi, statevec_cleanup_efsoi, init_statevec_efsoi ! load balancing diff --git a/util/EFSOI_Utilities/src/gridio_efsoi.f90 b/util/EFSOI_Utilities/src/gridio_efsoi.f90 index 4687522c67..d7930fa09b 100644 --- a/util/EFSOI_Utilities/src/gridio_efsoi.f90 +++ b/util/EFSOI_Utilities/src/gridio_efsoi.f90 @@ -95,8 +95,8 @@ subroutine get_weight() nemsio_getfilehead,nemsio_getheadvar,nemsio_realkind,nemsio_charkind,& nemsio_readrecv,nemsio_init,nemsio_setheadvar,nemsio_writerecv - use module_fv3gfs_ncio, only: Dataset, Variable, Dimension, open_dataset,& - quantize_data, read_attribute, close_dataset, get_dim, read_vardata + use module_ncio, only: Dataset, Variable, Dimension, open_dataset,& + quantize_data, read_attribute, close_dataset, get_dim, read_vardata implicit none @@ -414,8 +414,8 @@ subroutine readgriddata_efsoi(vars3d,vars2d,n3d,n2d,levels,ndim,grdin,mode,nanal nemsio_getfilehead,nemsio_getheadvar,nemsio_realkind,nemsio_charkind,& nemsio_readrecv,nemsio_init,nemsio_setheadvar,nemsio_writerecv - use module_fv3gfs_ncio, only: Dataset, Variable, Dimension, open_dataset,& - read_attribute, close_dataset, get_dim, read_vardata + use module_ncio, only: Dataset, Variable, Dimension, open_dataset,& + read_attribute, close_dataset, get_dim, read_vardata implicit none diff --git a/util/EFSOI_Utilities/src/loadbal_efsoi.f90 b/util/EFSOI_Utilities/src/loadbal_efsoi.f90 index 4ba46a4760..e44281727f 100644 --- a/util/EFSOI_Utilities/src/loadbal_efsoi.f90 +++ b/util/EFSOI_Utilities/src/loadbal_efsoi.f90 @@ -91,7 +91,8 @@ module loadbal_efsoi ! !$$$ -use mpisetup +use mpi +use mpisetup, only: nproc, numproc use params, only: datapath, nanals, simple_partition, & corrlengthnh, corrlengthsh, corrlengthtr, lupd_obspace_serial,& efsoi_flag @@ -136,6 +137,7 @@ subroutine load_balance_efsoi() integer(i_kind) np,i,n,nn,nob1,nob2,ierr real(r_double) t1 logical test_loadbal +integer status(MPI_STATUS_SIZE) ! partition state vector for using Grahams rule.. ! ("When a new job arrives, allocate it to the server @@ -292,7 +294,7 @@ subroutine load_balance_efsoi() else ! recv one large message on each task. call mpi_recv(anal_obchunk_prior,nobs_max*nanals,mpi_real4,0, & - 1,mpi_comm_world,mpi_status,ierr) + 1,mpi_comm_world,status,ierr) end if call mpi_barrier(mpi_comm_world, ierr) if(nproc == 0) print *,'... took ',mpi_wtime()-t1,' secs' diff --git a/util/EnKF/CMakeLists.txt b/util/EnKF/CMakeLists.txt new file mode 100644 index 0000000000..69aed1b9f5 --- /dev/null +++ b/util/EnKF/CMakeLists.txt @@ -0,0 +1,18 @@ +# No utility code here depends on the GSI library +if(BUILD_UTIL_ENKF_GFS) + add_subdirectory(gfs) +endif() + +# Utility code here depends on the GSI library +# Specifically GSI_MODE=Regional +if(BUILD_UTIL_ENKF_ARW) + if(NOT TARGET gsi) + if(NOT gsi_FOUND) + message(FATAL_ERROR "Utils: GSI library was not found for EnKF ARW utilities") + endif() + endif() + if(NOT GSI_MODE MATCHES "Regional") + message(FATAL_ERROR "Utils: Incompatible GSI = ${GSI_MODE} for EnKF ARW utilities") + endif() + add_subdirectory(arw) +endif() diff --git a/util/EnKF/arw/CMakeLists.txt b/util/EnKF/arw/CMakeLists.txt new file mode 100644 index 0000000000..febd4f0ab6 --- /dev/null +++ b/util/EnKF/arw/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(src) diff --git a/util/EnKF/arw/src/CMakeLists.txt b/util/EnKF/arw/src/CMakeLists.txt index 5fbc72f9ac..cd78c072a9 100644 --- a/util/EnKF/arw/src/CMakeLists.txt +++ b/util/EnKF/arw/src/CMakeLists.txt @@ -1,8 +1,3 @@ -cmake_minimum_required(VERSION 2.6) - - set(CMAKE_Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/util/include") - set(UTIL_INC ${CMAKE_Fortran_MODULE_DIRECTORY}) - - add_subdirectory(enspreproc_regional.fd) - add_subdirectory(initialens_regional.fd) +add_subdirectory(enspreproc_regional.fd) +add_subdirectory(initialens_regional.fd) diff --git a/util/EnKF/arw/src/enspreproc_regional.fd/CMakeLists.txt b/util/EnKF/arw/src/enspreproc_regional.fd/CMakeLists.txt index e7f1eafe0a..efcb62e5f7 100644 --- a/util/EnKF/arw/src/enspreproc_regional.fd/CMakeLists.txt +++ b/util/EnKF/arw/src/enspreproc_regional.fd/CMakeLists.txt @@ -1,13 +1,31 @@ -cmake_minimum_required(VERSION 2.6) - set(GSI_Fortran_FLAGS_LOCAL "${GSI_Fortran_FLAGS} -DWRF") - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90 ${CMAKE_CURRENT_SOURCE_DIR}/*.F90) - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${GSI_Fortran_FLAGS_LOCAL} ) - include_directories( ${PROJECT_BINARY_DIR}/include ${CORE_INCS} ${NETCDF_INCLUDE_DIRS} ${MPI_Fortran_INCLUDE_PATH} ${FV3GFS_NCIO_INCS} ) - - add_executable(enspreproc.x ${LOCAL_SRC} ) - set_target_properties( enspreproc.x PROPERTIES COMPILE_FLAGS ${GSI_Fortran_FLAGS_LOCAL} ) - target_link_libraries(enspreproc.x ${GSISHAREDLIB} ${GSILIB} ${GSISHAREDLIB} ${WRF_LIBRARIES} - ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES} - ${LAPACK_LIBRARIES} -L./ ${EXTRA_LINKER_FLAGS} ${CORE_LIBRARIES} ${CORE_BUILT} - ${GSI_LDFLAGS} ${NCDIAG_LIBRARIES} ${wrflib} ${FV3GFS_NCIO_LIBRARIES} ) - add_dependencies(enspreproc.x ${GSILIB}) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + get_gefs_for_regional_enspro.f90 + gfsp2wrfg.f90 + guess_grids_enspro.f90 + read_wrf_mass_guess4ens.F90 + wrf_netcdf_interface4ens.F90) + +add_executable(enspreproc.x ${SRCS}) +target_compile_definitions(enspreproc.x PRIVATE "WRF") +if(TARGET gsi) + add_dependencies(enspreproc.x gsi) +endif() +target_link_libraries(enspreproc.x PRIVATE gsi::gsi) +target_link_libraries(enspreproc.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(enspreproc.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(enspreproc.x PRIVATE bacio::bacio_4) +target_link_libraries(enspreproc.x PRIVATE w3emc::w3emc_d) +target_link_libraries(enspreproc.x PRIVATE wrf_io::wrf_io) +if(OpenMP_Fortran_FOUND) + target_link_libraries(enspreproc.x PRIVATE OpenMP::OpenMP_Fortran) +endif() + +# Install executable targets +install(TARGETS enspreproc.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + diff --git a/util/EnKF/arw/src/initialens_regional.fd/CMakeLists.txt b/util/EnKF/arw/src/initialens_regional.fd/CMakeLists.txt index 0e2de4f991..4a4968fee7 100644 --- a/util/EnKF/arw/src/initialens_regional.fd/CMakeLists.txt +++ b/util/EnKF/arw/src/initialens_regional.fd/CMakeLists.txt @@ -1,12 +1,29 @@ -cmake_minimum_required(VERSION 2.6) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${GSI_Fortran_FLAGS} ) - include_directories( "${PROJECT_BINARY_DIR}/include" ${NETCDF_INCLUDE_DIRS} ${MPI_Fortran_INCLUDE_PATH} ) - - add_executable(initialens.x ${LOCAL_SRC} ) - set_target_properties( initialens.x PROPERTIES COMPILE_FLAGS ${GSI_Fortran_FLAGS} ) - target_link_libraries( initialens.x ${GSISHAREDLIB} ${GSILIB} ${GSISHAREDLIB} ${WRF_LIBRARIES} - ${NETCDF_Fortran_LIBRARIES} ${MPI_Fortran_LIBRARIES} - -L./ ${EXTRA_LINKER_FLAGS} ${CORE_LIBRARIES} ${CORE_BUILT} - ${GSI_LDFLAGS} ${NCDIAG_LIBRARIES} ${wrflib} ) - add_dependencies(initialens.x ${GSILIB}) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + initial_arw_ens.f90 + read_netcdf_mass.f90 + update_netcdf_mass.f90) + +add_executable(initialens.x ${SRCS}) +target_compile_definitions(initialens.x PRIVATE "WRF") +if(TARGET gsi) + add_dependencies(initialens.x gsi) +endif() +target_link_libraries(initialens.x PRIVATE gsi::gsi) +target_link_libraries(initialens.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(initialens.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(initialens.x PRIVATE bacio::bacio_4) +target_link_libraries(initialens.x PRIVATE w3emc::w3emc_d) +target_link_libraries(initialens.x PRIVATE wrf_io::wrf_io) +if(OpenMP_Fortran_FOUND) + target_link_libraries(initialens.x PRIVATE OpenMP::OpenMP_Fortran) +endif() + +# Install executable targets +install(TARGETS initialens.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + diff --git a/util/EnKF/gfs/CMakeLists.txt b/util/EnKF/gfs/CMakeLists.txt new file mode 100644 index 0000000000..febd4f0ab6 --- /dev/null +++ b/util/EnKF/gfs/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(src) diff --git a/util/EnKF/gfs/src/CMakeLists.txt b/util/EnKF/gfs/src/CMakeLists.txt index d60c0e3a68..94298fab44 100644 --- a/util/EnKF/gfs/src/CMakeLists.txt +++ b/util/EnKF/gfs/src/CMakeLists.txt @@ -1,23 +1,57 @@ -cmake_minimum_required(VERSION 3.16.1) -MACRO(SUBDIRLIST result curdir) - FILE(GLOB children RELATIVE ${curdir} ${curdir}/*.fd) - SET(dirlist "") - FOREACH(child ${children}) - IF(IS_DIRECTORY ${curdir}/${child}) - LIST(APPEND dirlist ${child}) - ENDIF() - ENDFOREACH() - SET(${result} ${dirlist}) -ENDMACRO() +# The GFS group "prunes" before building for Ops. +# These checks ensure the build does not fail when directories are missing. +# Some of these utilities are deprecated and should be removed. +if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/adderrspec.fd) + add_subdirectory(adderrspec.fd) +endif() +if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/adjustps.fd) + add_subdirectory(adjustps.fd) +endif() +if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/calc_increment_ens.fd) + add_subdirectory(calc_increment_ens.fd) +endif() +if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/calc_increment_ens_ncio.fd) + add_subdirectory(calc_increment_ens_ncio.fd) +endif() +if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/calc_increment_ncio.fd) + add_subdirectory(calc_increment_ncio.fd) +endif() +if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/calc_increment_serial.fd) + add_subdirectory(calc_increment_serial.fd) +endif() +if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/getnstensmeanp.fd) + add_subdirectory(getnstensmeanp.fd) +endif() +if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/getsfcensmeanp.fd) + add_subdirectory(getsfcensmeanp.fd) +endif() +if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/getsfcnstensupdp.fd) + add_subdirectory(getsfcnstensupdp.fd) +endif() +if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/getsigensmeanp_smooth.fd) + add_subdirectory(getsigensmeanp_smooth.fd) +endif() +if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/getsigensstatp.fd) + add_subdirectory(getsigensstatp.fd) +endif() +if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/gribmean.fd) + add_subdirectory(gribmean.fd) +endif() +if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/recenterens_ncio.fd) + add_subdirectory(recenterens_ncio.fd) +endif() +if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/recenterncio_hybgain.fd) + add_subdirectory(recenterncio_hybgain.fd) +endif() +if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/recenternemsiop_hybgain.fd) + add_subdirectory(recenternemsiop_hybgain.fd) +endif() +if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/recentersigp.fd) + add_subdirectory(recentersigp.fd) +endif() -if(BUILD_UTIL) - set(CMAKE_Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/util/include") - set(UTIL_INC ${CMAKE_Fortran_MODULE_DIRECTORY}) - - SUBDIRLIST(SUBDIRS ${CMAKE_CURRENT_SOURCE_DIR}) - foreach(dir ${SUBDIRS}) - message("Configuring utility in ${dir}") - add_subdirectory(${dir}) - endforeach() -endif(BUILD_UTIL) +# This code is outdated +#add_subdirectory(preproc) +# These do not have any CMakeLists.txt and thus are not built +#add_subdirectory(misc) diff --git a/util/EnKF/gfs/src/adderrspec.fd/CMakeLists.txt b/util/EnKF/gfs/src/adderrspec.fd/CMakeLists.txt index 8fbcf59afe..d7a39cb69c 100644 --- a/util/EnKF/gfs/src/adderrspec.fd/CMakeLists.txt +++ b/util/EnKF/gfs/src/adderrspec.fd/CMakeLists.txt @@ -1,10 +1,20 @@ -cmake_minimum_required(VERSION 3.16.1) -if(BUILD_UTIL) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - add_executable(adderrspec.x ${LOCAL_SRC} ) - set_target_properties( adderrspec.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - include_directories( adderrspec.x ${W3EMC4INC} ${SIGIOINC} ${NEMSIOINC} ) - target_link_libraries( adderrspec.x ${SP_4_LIBRARY} ${NEMSIO_LIBRARY} ${BACIO_LIBRARY} ${SIGIO_LIBRARY} ${MPI_Fortran_LIBRARIES} ${W3EMC_4_LIBRARY} ${W3NCO_4_LIBRARY} ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") endif() + +add_executable(adderrspec.x adderrspec_nmcmeth_ncep_spec.f90) +target_link_libraries(adderrspec.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(adderrspec.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(adderrspec.x PRIVATE bacio::bacio_4) +target_link_libraries(adderrspec.x PRIVATE sigio::sigio) +target_link_libraries(adderrspec.x PRIVATE nemsio::nemsio) +target_link_libraries(adderrspec.x PRIVATE w3emc::w3emc_d) +target_link_libraries(adderrspec.x PRIVATE sp::sp_d) +if(OpenMP_Fortran_FOUND) + target_link_libraries(adderrspec.x PRIVATE OpenMP::OpenMP_Fortran) +endif() + +# Install executable targets +install(TARGETS adderrspec.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/EnKF/gfs/src/adjustps.fd/CMakeLists.txt b/util/EnKF/gfs/src/adjustps.fd/CMakeLists.txt index 8df624e3c7..c4494f8ead 100644 --- a/util/EnKF/gfs/src/adjustps.fd/CMakeLists.txt +++ b/util/EnKF/gfs/src/adjustps.fd/CMakeLists.txt @@ -1,10 +1,18 @@ -cmake_minimum_required(VERSION 3.16.1) -if(BUILD_UTIL) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - add_executable(adjustps.x ${LOCAL_SRC} ) - set_target_properties( adjustps.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS}) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - include_directories( ${NEMSIOINC} ) - target_link_libraries( adjustps.x ${NEMSIO_LIBRARY} ${BACIO_LIBRARY} ${W3NCO_4_LIBRARY} ${MPI_Fortran_LIBRARIES} ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") endif() + +add_executable(adjustps.x adjustps.f90) +target_link_libraries(adjustps.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(adjustps.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(adjustps.x PRIVATE bacio::bacio_4) +target_link_libraries(adjustps.x PRIVATE nemsio::nemsio) +target_link_libraries(adjustps.x PRIVATE w3emc::w3emc_d) +if(OpenMP_Fortran_FOUND) + target_link_libraries(adjustps.x PRIVATE OpenMP::OpenMP_Fortran) +endif() + +# Install executable targets +install(TARGETS adjustps.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/EnKF/gfs/src/calc_increment_ens.fd/CMakeLists.txt b/util/EnKF/gfs/src/calc_increment_ens.fd/CMakeLists.txt index 389c4cf460..b532fc9bfc 100644 --- a/util/EnKF/gfs/src/calc_increment_ens.fd/CMakeLists.txt +++ b/util/EnKF/gfs/src/calc_increment_ens.fd/CMakeLists.txt @@ -1,14 +1,30 @@ -cmake_minimum_required(VERSION 3.16.1) -if(BUILD_UTIL) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - list( REMOVE_ITEM LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/main.f90 ) - - set(Util_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include/calc_increment_ens") - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - add_executable(calc_increment_ens.x ${LOCAL_SRC} ) - set_target_properties( calc_increment_ens.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - set_target_properties( calc_increment_ens.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIRECTORY} ) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - include_directories( ${UTIL_INC} ${NEMSIOINC} ${NETCDF_INCLUDE_DIRS} ${MPI_Fortran_INCLUDE_PATH} ) - target_link_libraries( calc_increment_ens.x ${NEMSIO_LIBRARY} ${BACIO_LIBRARY} ${W3NCO_4_LIBRARY} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES}) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") endif() + +list(APPEND SRCS + calc_increment_interface.f90 + constants.f90 + fv3_interface.f90 + gfs_nems_interface.f90 + kinds.f90 + namelist_def.f90 + pmain.f90 + variable_interface.f90) + +add_executable(calc_increment_ens.x ${SRCS}) +target_compile_definitions(calc_increment_ens.x PRIVATE "_REAL8_") +target_link_libraries(calc_increment_ens.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(calc_increment_ens.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(calc_increment_ens.x PRIVATE bacio::bacio_4) +target_link_libraries(calc_increment_ens.x PRIVATE w3emc::w3emc_d) +target_link_libraries(calc_increment_ens.x PRIVATE nemsio::nemsio) +if(OpenMP_Fortran_FOUND) + target_link_libraries(calc_increment_ens.x PRIVATE OpenMP::OpenMP_Fortran) +endif() + +# Install executable targets +install(TARGETS calc_increment_ens.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + diff --git a/util/EnKF/gfs/src/calc_increment_ens_ncio.fd/CMakeLists.txt b/util/EnKF/gfs/src/calc_increment_ens_ncio.fd/CMakeLists.txt index feadd301d6..4888660645 100644 --- a/util/EnKF/gfs/src/calc_increment_ens_ncio.fd/CMakeLists.txt +++ b/util/EnKF/gfs/src/calc_increment_ens_ncio.fd/CMakeLists.txt @@ -1,14 +1,29 @@ -cmake_minimum_required(VERSION 3.16.1) -if(BUILD_UTIL) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - list( REMOVE_ITEM LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/main.f90 ) - - set(Util_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include/calc_increment_ens_ncio") - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - add_executable(calc_increment_ens_ncio.x ${LOCAL_SRC} ) - set_target_properties( calc_increment_ens_ncio.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - set_target_properties( calc_increment_ens_ncio.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIRECTORY} ) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - include_directories( ${UTIL_INC} ${NEMSIOINC} ${NETCDF_INCLUDE_DIRS} ${MPI_Fortran_INCLUDE_PATH} ${FV3GFS_NCIO_INCS}) - target_link_libraries( calc_increment_ens_ncio.x ${NEMSIO_LIBRARY} ${BACIO_LIBRARY} ${W3NCO_4_LIBRARY} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES} ${FV3GFS_NCIO_LIBRARIES}) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") endif() + +list(APPEND SRCS + calc_increment_interface.f90 + constants.f90 + fv3_interface.f90 + gfs_ncio_interface.f90 + kinds.f90 + namelist_def.f90 + pmain.f90) + +add_executable(calc_increment_ens_ncio.x ${SRCS}) +target_compile_definitions(calc_increment_ens_ncio.x PRIVATE "_REAL8_") +target_link_libraries(calc_increment_ens_ncio.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(calc_increment_ens_ncio.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(calc_increment_ens_ncio.x PRIVATE ncio::ncio) +target_link_libraries(calc_increment_ens_ncio.x PRIVATE bacio::bacio_4) +target_link_libraries(calc_increment_ens_ncio.x PRIVATE w3emc::w3emc_d) +if(OpenMP_Fortran_FOUND) + target_link_libraries(calc_increment_ens_ncio.x PRIVATE OpenMP::OpenMP_Fortran) +endif() + +# Install executable targets +install(TARGETS calc_increment_ens_ncio.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + diff --git a/util/EnKF/gfs/src/calc_increment_ens_ncio.fd/gfs_ncio_interface.f90 b/util/EnKF/gfs/src/calc_increment_ens_ncio.fd/gfs_ncio_interface.f90 index ddabc66a40..7ea5fc8989 100644 --- a/util/EnKF/gfs/src/calc_increment_ens_ncio.fd/gfs_ncio_interface.f90 +++ b/util/EnKF/gfs/src/calc_increment_ens_ncio.fd/gfs_ncio_interface.f90 @@ -39,7 +39,7 @@ module gfs_ncio_interface !----------------------------------------------------------------------- use namelist_def - use module_fv3gfs_ncio + use module_ncio !----------------------------------------------------------------------- diff --git a/util/EnKF/gfs/src/calc_increment_ncio.fd/CMakeLists.txt b/util/EnKF/gfs/src/calc_increment_ncio.fd/CMakeLists.txt index 416943dc6b..f0bdc763fe 100644 --- a/util/EnKF/gfs/src/calc_increment_ncio.fd/CMakeLists.txt +++ b/util/EnKF/gfs/src/calc_increment_ncio.fd/CMakeLists.txt @@ -1,11 +1,12 @@ -cmake_minimum_required(VERSION 3.16.1) -if(BUILD_UTIL) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - list( REMOVE_ITEM LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/main.f90 ) - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${GSI_Fortran_FLAGS} ) - add_executable(calc_increment_ncio.x ${LOCAL_SRC} ) - set_target_properties( calc_increment_ncio.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - include_directories( ${UTIL_INC} ${NEMSIOINC} ${NETCDF_INCLUDE_DIRS} ${MPI_Fortran_INCLUDE_PATH} ${FV3GFS_NCIO_INCS}) - target_link_libraries( calc_increment_ncio.x ${CORE_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES} ${FV3GFS_NCIO_LIBRARIES} ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") endif() + +add_executable(calc_increment_ncio.x calc_increment_ncio.f90) +target_link_libraries(calc_increment_ncio.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(calc_increment_ncio.x PRIVATE ncio::ncio) + +# Install executable targets +install(TARGETS calc_increment_ncio.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/EnKF/gfs/src/calc_increment_ncio.fd/calc_increment_ncio.f90 b/util/EnKF/gfs/src/calc_increment_ncio.fd/calc_increment_ncio.f90 index 4928a62e6c..1bbdfb1b99 100755 --- a/util/EnKF/gfs/src/calc_increment_ncio.fd/calc_increment_ncio.f90 +++ b/util/EnKF/gfs/src/calc_increment_ncio.fd/calc_increment_ncio.f90 @@ -38,10 +38,10 @@ PROGRAM calc_increment_ncio ! !$$$ - use module_fv3gfs_ncio, only: open_dataset, create_dataset, read_attribute, & - Dataset, Dimension, close_dataset, & - read_vardata, write_attribute, write_vardata, & - has_var, has_attr, get_dim + use module_ncio, only: open_dataset, create_dataset, read_attribute, & + Dataset, Dimension, close_dataset, & + read_vardata, write_attribute, write_vardata, & + has_var, has_attr, get_dim use netcdf implicit none diff --git a/util/EnKF/gfs/src/calc_increment_serial.fd/CMakeLists.txt b/util/EnKF/gfs/src/calc_increment_serial.fd/CMakeLists.txt index 207015c324..77dcc79a7f 100644 --- a/util/EnKF/gfs/src/calc_increment_serial.fd/CMakeLists.txt +++ b/util/EnKF/gfs/src/calc_increment_serial.fd/CMakeLists.txt @@ -1,13 +1,27 @@ -cmake_minimum_required(VERSION 3.16.1) -if(BUILD_UTIL) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - list( REMOVE_ITEM LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/main.f90 ) - - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${GSI_Fortran_FLAGS} ) - add_executable(calc_increment_serial.x ${LOCAL_SRC} ) - set_target_properties( calc_increment_serial.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - include_directories( ${UTIL_INC} ${CORE_INCS} ${NETCDF_INCLUDE_DIRS} ) - target_link_libraries( calc_increment_serial.x ${CORE_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES}) - add_dependencies( calc_increment_serial.x enkfdeplib enkflib ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") endif() + +list(APPEND SRCS + calc_increment.f90 + calc_increment_interface.f90 + constants.f90 + fv3_interface.f90 + gfs_nems_interface.f90 + kinds.f90 + namelist_def.f90 + variable_interface.f90) + +add_executable(calc_increment_serial.x ${SRCS}) +target_compile_definitions(calc_increment_serial.x PRIVATE "_REAL8_") +target_link_libraries(calc_increment_serial.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(calc_increment_serial.x PRIVATE bacio::bacio_4) +target_link_libraries(calc_increment_serial.x PRIVATE w3emc::w3emc_d) +target_link_libraries(calc_increment_serial.x PRIVATE nemsio::nemsio) + +# Install executable targets +install(TARGETS calc_increment_serial.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + diff --git a/util/EnKF/gfs/src/getnstensmeanp.fd/CMakeLists.txt b/util/EnKF/gfs/src/getnstensmeanp.fd/CMakeLists.txt index 3f62c20236..29d7f18cdb 100644 --- a/util/EnKF/gfs/src/getnstensmeanp.fd/CMakeLists.txt +++ b/util/EnKF/gfs/src/getnstensmeanp.fd/CMakeLists.txt @@ -1,12 +1,15 @@ -cmake_minimum_required(VERSION 3.16.1) -if(BUILD_UTIL) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - add_executable(getnstensmeanp.x ${LOCAL_SRC} ) - set(Util_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include/getnstensmeanp") - set_target_properties( getnstensmeanp.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - set_target_properties( getnstensmeanp.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIRECTORY} ) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - include_directories( ${NEMSIOINC} ) - target_link_libraries( getnstensmeanp.x ${NEMSIO_LIBRARY} ${BACIO_LIBRARY} ${W3NCO_4_LIBRARY} ${MPI_Fortran_LIBRARIES} ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") endif() + +add_executable(getnstensmeanp.x getnstensmeanp.f90 nstio_module.f90) +target_link_libraries(getnstensmeanp.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(getnstensmeanp.x PRIVATE bacio::bacio_4) +target_link_libraries(getnstensmeanp.x PRIVATE w3emc::w3emc_d) +target_link_libraries(getnstensmeanp.x PRIVATE nemsio::nemsio) + +# Install executable targets +install(TARGETS getnstensmeanp.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + diff --git a/util/EnKF/gfs/src/getsfcensmeanp.fd/CMakeLists.txt b/util/EnKF/gfs/src/getsfcensmeanp.fd/CMakeLists.txt index 9912682da7..544d395bd3 100644 --- a/util/EnKF/gfs/src/getsfcensmeanp.fd/CMakeLists.txt +++ b/util/EnKF/gfs/src/getsfcensmeanp.fd/CMakeLists.txt @@ -1,10 +1,18 @@ -cmake_minimum_required(VERSION 3.16.1) -if(BUILD_UTIL) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - add_executable( getsfcensmeanp.x ${LOCAL_SRC} ) - set_target_properties( getsfcensmeanp.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - include_directories( ${NEMSIOINC} ${SFCIOINC} ${NETCDF_INCLUDE_DIRS} ${FV3GFS_NCIO_INCS}) - target_link_libraries( getsfcensmeanp.x ${FV3GFS_NCIO_LIBRARIES} ${BACIO_LIBRARY} ${NEMSIO_LIBRARY} ${BACIO_LIBRARY} ${SFCIO_LIBRARY} ${W3NCO_4_LIBRARY} ${MPI_Fortran_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES}) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") endif() + +add_executable(getsfcensmeanp.x getsfcensmeanp.f90) +target_link_libraries(getsfcensmeanp.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(getsfcensmeanp.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(getsfcensmeanp.x PRIVATE bacio::bacio_4) +target_link_libraries(getsfcensmeanp.x PRIVATE w3emc::w3emc_d) +target_link_libraries(getsfcensmeanp.x PRIVATE nemsio::nemsio) +target_link_libraries(getsfcensmeanp.x PRIVATE sfcio::sfcio) +target_link_libraries(getsfcensmeanp.x PRIVATE ncio::ncio) + +# Install executable targets +install(TARGETS getsfcensmeanp.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + diff --git a/util/EnKF/gfs/src/getsfcensmeanp.fd/getsfcensmeanp.f90 b/util/EnKF/gfs/src/getsfcensmeanp.fd/getsfcensmeanp.f90 index d73f74b75a..2589a08603 100644 --- a/util/EnKF/gfs/src/getsfcensmeanp.fd/getsfcensmeanp.f90 +++ b/util/EnKF/gfs/src/getsfcensmeanp.fd/getsfcensmeanp.f90 @@ -25,10 +25,10 @@ program getsfcensmeanp use nemsio_module, only: nemsio_init,nemsio_open,nemsio_close use nemsio_module, only: nemsio_gfile,nemsio_getfilehead,nemsio_readrec,& nemsio_writerec,nemsio_readrecv,nemsio_writerecv - use module_fv3gfs_ncio, only: open_dataset, create_dataset, read_attribute, & - Dataset, Dimension, close_dataset, & - read_vardata, write_attribute, write_vardata, & - get_dim + use module_ncio, only: open_dataset, create_dataset, read_attribute, & + Dataset, Dimension, close_dataset, & + read_vardata, write_attribute, write_vardata, & + get_dim implicit none diff --git a/util/EnKF/gfs/src/getsfcnstensupdp.fd/CMakeLists.txt b/util/EnKF/gfs/src/getsfcnstensupdp.fd/CMakeLists.txt index 51ff265023..0080d12a28 100644 --- a/util/EnKF/gfs/src/getsfcnstensupdp.fd/CMakeLists.txt +++ b/util/EnKF/gfs/src/getsfcnstensupdp.fd/CMakeLists.txt @@ -1,13 +1,27 @@ -cmake_minimum_required(VERSION 3.16.1) -if(BUILD_UTIL) - - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.F90 ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - set(Util_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include/getsfcnstensupdp") - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - add_executable(getsfcnstensupdp.x ${LOCAL_SRC} ) - set_target_properties( getsfcnstensupdp.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - set_target_properties( getsfcnstensupdp.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIRECTORY} ) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - include_directories( ${UTIL_INC}/getsfcnstensupdp ${SFCIOINC} ${NEMSIOINC} ${MPI_Fortran_INCLUDE_PATH} ) - target_link_libraries( getsfcnstensupdp.x ${SFCIO_LIBRARY} ${NEMSIO_LIBRARY} ${BACIO_LIBRARY} ${W3NCO_4_LIBRARY} ${SP_4_LIBRARY} ${MPI_Fortran_LIBRARIES} ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") endif() + +list(APPEND SRCS + constants.f90 + getsfcnstensupdp.f90 + grdcrd.f90 + intrp_msk.f90 + kinds.F90 + nstio_module.f90) + +add_executable(getsfcnstensupdp.x ${SRCS}) +target_compile_definitions(getsfcnstensupdp.x PRIVATE "_REAL8_") +target_link_libraries(getsfcnstensupdp.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(getsfcnstensupdp.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(getsfcnstensupdp.x PRIVATE bacio::bacio_4) +target_link_libraries(getsfcnstensupdp.x PRIVATE w3emc::w3emc_d) +target_link_libraries(getsfcnstensupdp.x PRIVATE nemsio::nemsio) +target_link_libraries(getsfcnstensupdp.x PRIVATE sfcio::sfcio) +target_link_libraries(getsfcnstensupdp.x PRIVATE sp::sp_4) + +# Install executable targets +install(TARGETS getsfcnstensupdp.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + diff --git a/util/EnKF/gfs/src/getsigensmeanp_smooth.fd/CMakeLists.txt b/util/EnKF/gfs/src/getsigensmeanp_smooth.fd/CMakeLists.txt index 2c75ccdd09..d0d240653b 100644 --- a/util/EnKF/gfs/src/getsigensmeanp_smooth.fd/CMakeLists.txt +++ b/util/EnKF/gfs/src/getsigensmeanp_smooth.fd/CMakeLists.txt @@ -1,13 +1,19 @@ -cmake_minimum_required(VERSION 3.16.1) -if(BUILD_UTIL) - - set(LOCAL_Fortran_FLAGS "-O3 -fp-model source -convert big_endian -assume byterecl -implicitnone -g -traceback ${OpenMP_Fortran_FLAGS}" ) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${LOCAL_Fortran_FLAGS} ) - add_executable(getsigensmeanp_smooth.x ${LOCAL_SRC} ) - set_target_properties( getsigensmeanp_smooth.x PROPERTIES COMPILE_FLAGS ${LOCAL_Fortran_FLAGS} ) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - include_directories( ${NEMSIOINC} ${SIGIOINC} ${NETCDF_INCLUDE_DIRS} ${FV3GFS_NCIO_INCS}) - target_link_libraries( getsigensmeanp_smooth.x ${FV3GFS_NCIO_LIBRARIES} ${BACIO_LIBRARY} ${NEMSIO_LIBRARY} ${BACIO_LIBRARY} ${SIGIO_LIBRARY} ${W3NCO_4_LIBRARY} ${SP_4_LIBRARY} ${MPI_Fortran_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES}) - +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian -assume byterecl") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0") endif() + +add_executable(getsigensmeanp_smooth.x getsigensmeanp_smooth_ncep.f90) +target_link_libraries(getsigensmeanp_smooth.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(getsigensmeanp_smooth.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(getsigensmeanp_smooth.x PRIVATE bacio::bacio_4) +target_link_libraries(getsigensmeanp_smooth.x PRIVATE w3emc::w3emc_d) +target_link_libraries(getsigensmeanp_smooth.x PRIVATE nemsio::nemsio) +target_link_libraries(getsigensmeanp_smooth.x PRIVATE sp::sp_4) +target_link_libraries(getsigensmeanp_smooth.x PRIVATE sigio::sigio) +target_link_libraries(getsigensmeanp_smooth.x PRIVATE ncio::ncio) + +# Install executable targets +install(TARGETS getsigensmeanp_smooth.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + diff --git a/util/EnKF/gfs/src/getsigensmeanp_smooth.fd/getsigensmeanp_smooth_ncep.f90 b/util/EnKF/gfs/src/getsigensmeanp_smooth.fd/getsigensmeanp_smooth_ncep.f90 index cb622350b1..74038e464b 100644 --- a/util/EnKF/gfs/src/getsigensmeanp_smooth.fd/getsigensmeanp_smooth_ncep.f90 +++ b/util/EnKF/gfs/src/getsigensmeanp_smooth.fd/getsigensmeanp_smooth_ncep.f90 @@ -27,10 +27,10 @@ program getsigensmeanp_smooth use nemsio_module, only: nemsio_gfile,nemsio_getfilehead,nemsio_charkind8, & nemsio_readrec,nemsio_writerec, & nemsio_readrecv,nemsio_writerecv - use module_fv3gfs_ncio, only: open_dataset, create_dataset, read_attribute, & - Dataset, Dimension, close_dataset, has_attr, & - read_vardata, write_attribute, write_vardata, & - get_dim, quantize_data, has_var + use module_ncio, only: open_dataset, create_dataset, read_attribute, & + Dataset, Dimension, close_dataset, has_attr, & + read_vardata, write_attribute, write_vardata, & + get_dim, quantize_data, has_var implicit none @@ -99,7 +99,7 @@ program getsigensmeanp_smooth filenameout = trim(adjustl(datapath)) // trim(adjustl(filenameout)) ! if a 5th arg present, it's a filename to write out ensemble spread ! (only used for ncio) - if (nargs() > 5) then + if (iargc() > 5) then call getarg(5,filenameoutsprd) write_spread_ncio = .true. if (mype == 0) print *,'computing ensemble spread' diff --git a/util/EnKF/gfs/src/getsigensstatp.fd/CMakeLists.txt b/util/EnKF/gfs/src/getsigensstatp.fd/CMakeLists.txt index 180a8896c3..8dd1b97674 100644 --- a/util/EnKF/gfs/src/getsigensstatp.fd/CMakeLists.txt +++ b/util/EnKF/gfs/src/getsigensstatp.fd/CMakeLists.txt @@ -1,11 +1,20 @@ -cmake_minimum_required(VERSION 3.16.1) -if(BUILD_UTIL) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - add_executable(getsigensstatp.x ${LOCAL_SRC} ) - set_target_properties( getsigensstatp.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - message(" hey, incl dirs are ${MPI_Fortran_INCLUDE_PATH} ") - include_directories( ${NETCDF_INCLUDE_DIRS} ${SIGIOINC} ${NEMSIOINC} ${MPI_Fortran_INCLUDE_PATH} ${FV3GFS_NCIO_INCS}) - target_link_libraries( getsigensstatp.x ${SIGIO_LIBRARY} ${NEMSIO_LIBRARY} ${BACIO_LIBRARY} ${SP_4_LIBRARY} ${W3NCO_4_LIBRARY} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES} ${FV3GFS_NCIO_LIBRARIES}) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian -assume byterecl") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0") endif() + +add_executable(getsigensstatp.x getsigensstatp.f90) +target_link_libraries(getsigensstatp.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(getsigensstatp.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(getsigensstatp.x PRIVATE bacio::bacio_4) +target_link_libraries(getsigensstatp.x PRIVATE w3emc::w3emc_d) +target_link_libraries(getsigensstatp.x PRIVATE nemsio::nemsio) +target_link_libraries(getsigensstatp.x PRIVATE sp::sp_4) +target_link_libraries(getsigensstatp.x PRIVATE sigio::sigio) +target_link_libraries(getsigensstatp.x PRIVATE ncio::ncio) + +# Install executable targets +install(TARGETS getsigensstatp.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + diff --git a/util/EnKF/gfs/src/getsigensstatp.fd/getsigensstatp.f90 b/util/EnKF/gfs/src/getsigensstatp.fd/getsigensstatp.f90 index 197740ef7b..efe496f547 100644 --- a/util/EnKF/gfs/src/getsigensstatp.fd/getsigensstatp.f90 +++ b/util/EnKF/gfs/src/getsigensstatp.fd/getsigensstatp.f90 @@ -34,10 +34,10 @@ program getsigensstatp use nemsio_module, only: nemsio_init,nemsio_open,nemsio_close, & nemsio_gfile,nemsio_getfilehead,nemsio_charkind8, & nemsio_readrec,nemsio_readrecv - use module_fv3gfs_ncio, only: open_dataset, create_dataset, read_attribute, & - Dataset, Dimension, close_dataset, & - read_vardata, write_attribute, write_vardata, & - get_dim, quantize_data + use module_ncio, only: open_dataset, create_dataset, read_attribute, & + Dataset, Dimension, close_dataset, & + read_vardata, write_attribute, write_vardata, & + get_dim, quantize_data implicit none @@ -46,7 +46,7 @@ program getsigensstatp integer,parameter :: iunit=21 integer,parameter :: idrt=4 ! Declare externals - external :: w3tagb, splat, sptez, sptezv, mpi_allreduce, w3tage + external :: w3tagb, splat, sptez, sptezv, w3tage character(nemsio_charkind8) :: dtype character(len=3) :: charnanal character(len=500) :: filenamein,datapath,filepref diff --git a/util/EnKF/gfs/src/gribmean.fd/CMakeLists.txt b/util/EnKF/gfs/src/gribmean.fd/CMakeLists.txt index ee609630b4..dd89073517 100644 --- a/util/EnKF/gfs/src/gribmean.fd/CMakeLists.txt +++ b/util/EnKF/gfs/src/gribmean.fd/CMakeLists.txt @@ -1,9 +1,13 @@ -cmake_minimum_required(VERSION 3.16.1) -if(BUILD_UTIL) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - add_executable(gribmean.x ${LOCAL_SRC} ) - set_target_properties( gribmean.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - target_link_libraries( gribmean.x ${BACIO_LIBRARY} ${W3NCO_4_LIBRARY} ${MPI_Fortran_LIBRARIES} ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") endif() + +add_executable(gribmean.x gribmean.f90) +target_link_libraries(gribmean.x PRIVATE bacio::bacio_4) +target_link_libraries(gribmean.x PRIVATE w3emc::w3emc_d) + +# Install executable targets +install(TARGETS gribmean.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + diff --git a/util/EnKF/gfs/src/preproc/CMakeLists.txt b/util/EnKF/gfs/src/preproc/CMakeLists.txt index 6ae2f24f93..65955d93dd 100644 --- a/util/EnKF/gfs/src/preproc/CMakeLists.txt +++ b/util/EnKF/gfs/src/preproc/CMakeLists.txt @@ -1,11 +1,29 @@ -cmake_minimum_required(VERSION 2.6) -if(BUILD_UTIL) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - set(Util_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include/preproc") - add_executable(preproc.x ${LOCAL_SRC} ) - set_target_properties( preproc.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - set_target_properties( preproc.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIRECTORY} ) - include_directories( ${SIGIOINC} ) - target_link_libraries( preproc.x ${SIGIO_LIBRARY} ) - +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian -assume byterecl") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0") endif() + +add_executable(controlpreproc.x controlpreproc.f90) +add_executable(ensincpreproc.x ensincpreproc.f90) +add_executable(enspreproc.x enspreproc.f90) + +list(APPEND _targets + controlpreproc.x + ensincpreproc.x + enspreproc.x) + +foreach(_tgt ${_targets}) + target_link_libraries(${_tgt} PRIVATE sp::sp_4) + target_link_libraries(${_tgt} PRIVATE sigio::sigio) + if(OpenMP_Fortran_FOUND) + target_link_libraries(${_tgt} PRIVATE OpenMP::OpenMP_Fortran) + endif() +endforeach() + +target_link_libraries(ensincpreproc.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(enspreproc.x PRIVATE MPI::MPI_Fortran) + +# Install executable targets +install(TARGETS ${_targets} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + diff --git a/util/EnKF/gfs/src/recenterens_ncio.fd/CMakeLists.txt b/util/EnKF/gfs/src/recenterens_ncio.fd/CMakeLists.txt index 19035c6863..0457c131da 100644 --- a/util/EnKF/gfs/src/recenterens_ncio.fd/CMakeLists.txt +++ b/util/EnKF/gfs/src/recenterens_ncio.fd/CMakeLists.txt @@ -1,10 +1,19 @@ -cmake_minimum_required(VERSION 3.16.1) -if(BUILD_UTIL) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - add_executable(recenterens_ncio.x ${LOCAL_SRC} ) - set_target_properties( recenterens_ncio.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - include_directories( ${NETCDF_INCLUDES} ${FV3GFS_NCIO_INCS}) - target_link_libraries( recenterens_ncio.x ${FV3GFS_NCIO_LIBRARIES} ${W3NCO_4_LIBRARY} ${MPI_Fortran_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_LIBRARIES} ${HDF5_HL_LIBRARIES} ${HDF5_LIBRARIES}) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian -assume byterecl") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0") endif() + +add_executable(recenterens_ncio.x recenterens_ncio.f90) +target_link_libraries(recenterens_ncio.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(recenterens_ncio.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(recenterens_ncio.x PRIVATE bacio::bacio_4) +target_link_libraries(recenterens_ncio.x PRIVATE w3emc::w3emc_d) +target_link_libraries(recenterens_ncio.x PRIVATE ncio::ncio) +if(OpenMP_Fortran_FOUND) + target_link_libraries(recenterens_ncio.x PRIVATE OpenMP::OpenMP_Fortran) +endif() + +# Install executable targets +install(TARGETS recenterens_ncio.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + diff --git a/util/EnKF/gfs/src/recenterens_ncio.fd/recenterens_ncio.f90 b/util/EnKF/gfs/src/recenterens_ncio.fd/recenterens_ncio.f90 index 6afbb572eb..2e194ed76c 100644 --- a/util/EnKF/gfs/src/recenterens_ncio.fd/recenterens_ncio.f90 +++ b/util/EnKF/gfs/src/recenterens_ncio.fd/recenterens_ncio.f90 @@ -25,10 +25,10 @@ program recenterens_ncio ! !$$$ - use module_fv3gfs_ncio, only: open_dataset, create_dataset, read_attribute, & - Dataset, Dimension, close_dataset, has_attr, has_var, & - read_vardata, write_attribute, write_vardata, & - get_dim, quantize_data + use module_ncio, only: open_dataset, create_dataset, read_attribute, & + Dataset, Dimension, close_dataset, has_attr, has_var, & + read_vardata, write_attribute, write_vardata, & + get_dim, quantize_data implicit none diff --git a/util/EnKF/gfs/src/recenterncio_hybgain.fd/CMakeLists.txt b/util/EnKF/gfs/src/recenterncio_hybgain.fd/CMakeLists.txt index ee17e9d40c..5c69d9171e 100644 --- a/util/EnKF/gfs/src/recenterncio_hybgain.fd/CMakeLists.txt +++ b/util/EnKF/gfs/src/recenterncio_hybgain.fd/CMakeLists.txt @@ -1,10 +1,19 @@ -cmake_minimum_required(VERSION 3.16.1) -if(BUILD_UTIL) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - add_executable(recenterncio_hybgain.x ${LOCAL_SRC} ) - set_target_properties( recenterncio_hybgain.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - include_directories( ${NETCDF_INCLUDE_DIRS} ${FV3GFS_NCIO_INCS}) - target_link_libraries( recenterncio_hybgain.x ${FV3GFS_NCIO_LIBRARIES} ${W3NCO_4_LIBRARY} ${MPI_Fortran_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES}) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian -assume byterecl") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0") endif() + +add_executable(recenterncio_hybgain.x recenterncio_hybgain.f90) +target_link_libraries(recenterncio_hybgain.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(recenterncio_hybgain.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(recenterncio_hybgain.x PRIVATE bacio::bacio_4) +target_link_libraries(recenterncio_hybgain.x PRIVATE w3emc::w3emc_d) +target_link_libraries(recenterncio_hybgain.x PRIVATE ncio::ncio) +if(OpenMP_Fortran_FOUND) + target_link_libraries(recenterncio_hybgain.x PRIVATE OpenMP::OpenMP_Fortran) +endif() + +# Install executable targets +install(TARGETS recenterncio_hybgain.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + diff --git a/util/EnKF/gfs/src/recenterncio_hybgain.fd/recenterncio_hybgain.f90 b/util/EnKF/gfs/src/recenterncio_hybgain.fd/recenterncio_hybgain.f90 index 5ab94f071c..1384e3ccfb 100644 --- a/util/EnKF/gfs/src/recenterncio_hybgain.fd/recenterncio_hybgain.f90 +++ b/util/EnKF/gfs/src/recenterncio_hybgain.fd/recenterncio_hybgain.f90 @@ -23,10 +23,10 @@ program recenterncio_hybgain ! !$$$ - use module_fv3gfs_ncio, only: open_dataset, create_dataset, read_attribute, & - Dataset, Dimension, close_dataset, has_attr, & - read_vardata, write_attribute, write_vardata, & - get_dim, quantize_data + use module_ncio, only: open_dataset, create_dataset, read_attribute, & + Dataset, Dimension, close_dataset, has_attr, & + read_vardata, write_attribute, write_vardata, & + get_dim, quantize_data implicit none diff --git a/util/EnKF/gfs/src/recenternemsiop_hybgain.fd/CMakeLists.txt b/util/EnKF/gfs/src/recenternemsiop_hybgain.fd/CMakeLists.txt index 2b097ca949..a8062246f6 100644 --- a/util/EnKF/gfs/src/recenternemsiop_hybgain.fd/CMakeLists.txt +++ b/util/EnKF/gfs/src/recenternemsiop_hybgain.fd/CMakeLists.txt @@ -1,10 +1,15 @@ -cmake_minimum_required(VERSION 3.16.1) -if(BUILD_UTIL) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - add_executable(recenternemsiop_hybgain.x ${LOCAL_SRC} ) - set_target_properties( recenternemsiop_hybgain.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - include_directories( ${SIGIOINC} ${NEMSIOINC} ) - target_link_libraries( recenternemsiop_hybgain.x ${SIGIO_LIBRARY} ${NEMSIO_LIBRARY} ${BACIO_LIBRARY} ${W3NCO_4_LIBRARY} ${MPI_Fortran_LIBRARIES} ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian -assume byterecl") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0") endif() + +add_executable(recenternemsiop_hybgain.x recenternemsiop_hybgain.f90) +target_link_libraries(recenternemsiop_hybgain.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(recenternemsiop_hybgain.x PRIVATE bacio::bacio_4) +target_link_libraries(recenternemsiop_hybgain.x PRIVATE w3emc::w3emc_d) +target_link_libraries(recenternemsiop_hybgain.x PRIVATE nemsio::nemsio) + +# Install executable targets +install(TARGETS recenternemsiop_hybgain.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + diff --git a/util/EnKF/gfs/src/recentersigp.fd/CMakeLists.txt b/util/EnKF/gfs/src/recentersigp.fd/CMakeLists.txt index b720e170d0..333c95b1d4 100644 --- a/util/EnKF/gfs/src/recentersigp.fd/CMakeLists.txt +++ b/util/EnKF/gfs/src/recentersigp.fd/CMakeLists.txt @@ -1,10 +1,18 @@ -cmake_minimum_required(VERSION 3.16.1) -if(BUILD_UTIL) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - add_executable(recentersigp.x ${LOCAL_SRC} ) - set_target_properties( recentersigp.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - include_directories( ${NEMSIOINC} ${SIGIOINC} ${NETCDF_INCLUDE_DIRS} ${FV3GFS_NCIO_INCS}) - target_link_libraries( recentersigp.x ${FV3GFS_NCIO_LIBRARIES} ${SIGIO_LIBRARY} ${NEMSIO_LIBRARY} ${BACIO_LIBRARY} ${W3NCO_4_LIBRARY} ${MPI_Fortran_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES}) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian -assume byterecl") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0") endif() + +add_executable(recentersigp.x recentersigp.f90) +target_link_libraries(recentersigp.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(recentersigp.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(recentersigp.x PRIVATE bacio::bacio_4) +target_link_libraries(recentersigp.x PRIVATE w3emc::w3emc_d) +target_link_libraries(recentersigp.x PRIVATE nemsio::nemsio) +target_link_libraries(recentersigp.x PRIVATE sigio::sigio) +target_link_libraries(recentersigp.x PRIVATE ncio::ncio) + +# Install executable targets +install(TARGETS recentersigp.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + diff --git a/util/EnKF/gfs/src/recentersigp.fd/recentersigp.f90 b/util/EnKF/gfs/src/recentersigp.fd/recentersigp.f90 index 321845bf35..5a94f2f26b 100644 --- a/util/EnKF/gfs/src/recentersigp.fd/recentersigp.f90 +++ b/util/EnKF/gfs/src/recentersigp.fd/recentersigp.f90 @@ -28,10 +28,10 @@ program recentersigp use nemsio_module, only: nemsio_init,nemsio_open,nemsio_close use nemsio_module, only: nemsio_gfile,nemsio_getfilehead,nemsio_readrec,& nemsio_writerec,nemsio_readrecv,nemsio_writerecv,nemsio_getrechead - use module_fv3gfs_ncio, only: open_dataset, create_dataset, read_attribute, & - Dataset, Dimension, close_dataset, has_attr, has_var, & - read_vardata, write_attribute, write_vardata, & - get_dim, quantize_data + use module_ncio, only: open_dataset, create_dataset, read_attribute, & + Dataset, Dimension, close_dataset, has_attr, has_var, & + read_vardata, write_attribute, write_vardata, & + get_dim, quantize_data implicit none diff --git a/util/FOV_utilities/CMakeLists.txt b/util/FOV_utilities/CMakeLists.txt new file mode 100644 index 0000000000..ddf939af1e --- /dev/null +++ b/util/FOV_utilities/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(sorc) diff --git a/util/FOV_utilities/sorc/CMakeLists.txt b/util/FOV_utilities/sorc/CMakeLists.txt new file mode 100644 index 0000000000..d30f361882 --- /dev/null +++ b/util/FOV_utilities/sorc/CMakeLists.txt @@ -0,0 +1,13 @@ +list(APPEND SRCS +calc_fov_conical.f90 +calc_fov_crosstrk.f90 +constants.f90 +driver.f90 +kinds.F90) + +add_executable(fov_util.x ${SRCS}) +target_compile_definitions(fov_util.x PRIVATE "_REAL8_") + +# Install executable targets +install(TARGETS fov_util.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + diff --git a/util/NMC_Bkerror/CMakeLists.txt b/util/NMC_Bkerror/CMakeLists.txt new file mode 100644 index 0000000000..3e87e78e65 --- /dev/null +++ b/util/NMC_Bkerror/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory(sorc) +add_subdirectory(sorc_aero) diff --git a/util/NMC_Bkerror/sorc/CMakeLists.txt b/util/NMC_Bkerror/sorc/CMakeLists.txt new file mode 100644 index 0000000000..6060ae1edc --- /dev/null +++ b/util/NMC_Bkerror/sorc/CMakeLists.txt @@ -0,0 +1,44 @@ +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0") +endif() + +list(APPEND SRCS +balprojs.F90 +biascor.f90 +comm_mod.f90 +delvars.f90 +deter_subdomain.f90 +genqsat.f90 +getcases.f90 +grdsphdp.f90 +horizsc.f90 +init_commvars.f90 +initvars.f90 +isrchfge.f90 +kinds.f90 +mat.f90 +postmod.f90 +readpairs.f90 +smooth2d.f90 +smoothz.f90 +specgrid.f90 +sstmod.f90 +statsmain.f90 +variables.f90 +variances.f90 +variances3d.f90 +vertsc.f90) + +add_executable(calcstats.x ${SRCS}) +target_compile_definitions(calcstats.x PRIVATE "_LAPACK_") +target_link_libraries(calcstats.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(calcstats.x PRIVATE ${LAPACK_LIBRARIES}) +target_link_libraries(calcstats.x PRIVATE bacio::bacio_4) +target_link_libraries(calcstats.x PRIVATE w3emc::w3emc_d) +target_link_libraries(calcstats.x PRIVATE sp::sp_4) +target_link_libraries(calcstats.x PRIVATE sigio::sigio) +target_link_libraries(calcstats.x PRIVATE nemsio::nemsio) + +install(TARGETS calcstats.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/NMC_Bkerror/sorc/initvars.f90 b/util/NMC_Bkerror/sorc/initvars.f90 index 8797baf65a..bc0fca444e 100644 --- a/util/NMC_Bkerror/sorc/initvars.f90 +++ b/util/NMC_Bkerror/sorc/initvars.f90 @@ -69,7 +69,7 @@ subroutine initvars(mype,npe) endif if (mype==0) write(6,*) 'INITVARS: DB_PREC = ',db_prec - if (scaling == .true.) then + if (scaling .eqv. .true.) then allocate (varscale(nsig)) open(12,file='scaling.txt',form='formatted') do k=1,nsig diff --git a/util/NMC_Bkerror/sorc/mat.f90 b/util/NMC_Bkerror/sorc/mat.f90 index 2a1f098508..0544aa2704 100644 --- a/util/NMC_Bkerror/sorc/mat.f90 +++ b/util/NMC_Bkerror/sorc/mat.f90 @@ -820,7 +820,7 @@ SUBROUTINE MULPP(A,B,C,M) ! multiply polynomials, possibly in place END SUBROUTINE PRGV(D,M) - PARAMETER(CRIT=1.E-60) + PARAMETER(CRIT=1.E-37) DIMENSION D(*) DO I=1,M IF(ABS(D(I)).LE.CRIT)D(I)=0. @@ -2960,7 +2960,7 @@ SUBROUTINE DMULPP(A,B,C,M) ! multiply polynomials, possibly in place END SUBROUTINE DPRGV(D,M) - PARAMETER(CRIT=1.D-60) + PARAMETER(CRIT=1.D-37) DIMENSION D(*) DO I=1,M IF(ABS(D(I)).LE.CRIT)D(I)=0. @@ -3195,7 +3195,7 @@ SUBROUTINE DTSINI TS(0,1)=T KSIG=-1 DO I=1,NI - IF(ABS(T).LE.1.E-60)THEN + IF(ABS(T).LE.1.E-37)THEN TS(I,1)=0 ELSE I2=I*2 @@ -3664,7 +3664,7 @@ SUBROUTINE DWRTM(A,MI,MJ,JCOLS,NA) J2=MIN(MJ,J1+JCOLS-1) PRINT'(8X,10(I3,9X))',(J,J=J1,J2) DO I=1,MI - PRINT'(1X,I3,10(1X,E11.5))',I,(A(I,J),J=J1,J2) + PRINT'(1X,I3,10(1X,E12.5))',I,(A(I,J),J=J1,J2) ENDDO PRINT'()' ENDDO diff --git a/util/NMC_Bkerror/sorc_aero/CMakeLists.txt b/util/NMC_Bkerror/sorc_aero/CMakeLists.txt new file mode 100644 index 0000000000..ae48aa40a4 --- /dev/null +++ b/util/NMC_Bkerror/sorc_aero/CMakeLists.txt @@ -0,0 +1,35 @@ +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0") +endif() + +list(APPEND SRCS +comm_mod.f90 +delvars_aerosol.f90 +deter_subdomain.f90 +getcases_nems.f90 +grdsphdp.f90 +horizsc_aerosol.f90 +init_commvars.f90 +initvars.f90 +kinds.F90 +mat.f90 +postmod.f90 +readpairs_aerosol.f90 +smoothz.f90 +specgrid.f90 +statsmain_aerosol.f90 +variables.f90 +variances_aerosol.f90 +vertsc_aerosol.f90) + +add_executable(calcstats_aero.x ${SRCS}) +target_link_libraries(calcstats_aero.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(calcstats_aero.x PRIVATE ${LAPACK_LIBRARIES}) +target_link_libraries(calcstats_aero.x PRIVATE bacio::bacio_4) +target_link_libraries(calcstats_aero.x PRIVATE w3emc::w3emc_d) +target_link_libraries(calcstats_aero.x PRIVATE sp::sp_4) +target_link_libraries(calcstats_aero.x PRIVATE nemsio::nemsio) + +install(TARGETS calcstats_aero.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/NMC_Bkerror/sorc_aero/mat.f90 b/util/NMC_Bkerror/sorc_aero/mat.f90 index 2a1f098508..0544aa2704 100644 --- a/util/NMC_Bkerror/sorc_aero/mat.f90 +++ b/util/NMC_Bkerror/sorc_aero/mat.f90 @@ -820,7 +820,7 @@ SUBROUTINE MULPP(A,B,C,M) ! multiply polynomials, possibly in place END SUBROUTINE PRGV(D,M) - PARAMETER(CRIT=1.E-60) + PARAMETER(CRIT=1.E-37) DIMENSION D(*) DO I=1,M IF(ABS(D(I)).LE.CRIT)D(I)=0. @@ -2960,7 +2960,7 @@ SUBROUTINE DMULPP(A,B,C,M) ! multiply polynomials, possibly in place END SUBROUTINE DPRGV(D,M) - PARAMETER(CRIT=1.D-60) + PARAMETER(CRIT=1.D-37) DIMENSION D(*) DO I=1,M IF(ABS(D(I)).LE.CRIT)D(I)=0. @@ -3195,7 +3195,7 @@ SUBROUTINE DTSINI TS(0,1)=T KSIG=-1 DO I=1,NI - IF(ABS(T).LE.1.E-60)THEN + IF(ABS(T).LE.1.E-37)THEN TS(I,1)=0 ELSE I2=I*2 @@ -3664,7 +3664,7 @@ SUBROUTINE DWRTM(A,MI,MJ,JCOLS,NA) J2=MIN(MJ,J1+JCOLS-1) PRINT'(8X,10(I3,9X))',(J,J=J1,J2) DO I=1,MI - PRINT'(1X,I3,10(1X,E11.5))',I,(A(I,J),J=J1,J2) + PRINT'(1X,I3,10(1X,E12.5))',I,(A(I,J),J=J1,J2) ENDDO PRINT'()' ENDDO diff --git a/util/Ozone_Monitor/CMakeLists.txt b/util/Ozone_Monitor/CMakeLists.txt index 97e24d7e1a..9e3df48cc5 100644 --- a/util/Ozone_Monitor/CMakeLists.txt +++ b/util/Ozone_Monitor/CMakeLists.txt @@ -1,96 +1,2 @@ -cmake_minimum_required(VERSION 2.8) -if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) - # I am top-level project. - if( NOT DEFINED ENV{CC} ) - find_path( crayComp "ftn" ) - find_path( wcossIntel "mpfort" ) - find_path( intelComp "ifort" ) - find_path( pgiComp "pgf90" ) - if( crayComp ) - message("Setting CrayLinuxEnvironment") - set(CMAKE_SYSTEM_NAME "CrayLinuxEnvironment") - set(CMAKE_C_COMPILER "${crayComp}/cc") - set(CMAKE_CXX_COMPILER "${crayComp}/CC") - set(CMAKE_Fortran_COMPILER "${crayComp}/ftn") - endif() - if( intelComp ) - set(ENV{CC} "icc") - set(ENV{CXX} "icpc") - set(ENV{FC} "ifort") - endif() - if( wcossIntel ) - message("Setting env for wcoss intel") - set(ENV{CC} "mpcc") - set(ENV{CXX} "mpCC") - set(ENV{FC} "mpfort") - endif() - if( pgiComp ) - set(ENV{CC} "pgcc") - set(ENV{CXX} "pgCC") - set(ENV{FC} "pgf90") - endif() - endif() - project(COV_Calc) - enable_language (Fortran) - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/../../cmake/Modules/") - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setPlatformVariables.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setIntelFlags.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setGNUFlags.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setPGIFlags.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setHOST.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Cheyenne.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Discover.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Generic.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Gaea.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Jet.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/S4.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Hera.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/WCOSS-C.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/WCOSS-D.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/WCOSS.cmake) - if (NOT CMAKE_BUILD_TYPE) - set (CMAKE_BUILD_TYPE RELEASE CACHE STRING - "Choose the type of build, options are: PRODUCTION Debug Release." - FORCE) - endif (NOT CMAKE_BUILD_TYPE) - if (CMAKE_CXX_COMPILER_ID MATCHES "GNU*") - message("Setting GNU flags") - setGNU() - elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - message("Setting Intel flags") - setIntel() - elseif(CMAKE_C_COMPILER MATCHES "pgc*") - message("Setting PGI flags") - setPGI() - endif() - - cmake_policy(SET CMP0009 NEW) - cmake_policy(SET CMP0074 NEW) - find_package(OpenMP) - message("found openmp with flag ${OPENMP_Fortran_FLAGS}") - -# Set Host specific flags and options - setHOST() - - find_package(MPI REQUIRED) - message("MPI version is ${MPI_Fortran_VERSION}") - message("MPI f90 version is ${MPI_Fortran_HAVE_F90_MODULE}") - message("MPI f08 version is ${MPI_Fortran_HAVE_F08_MODULE}") - - add_definitions(${MPI_Fortran_COMPILE_FLAGS}) - include_directories(${MPI_Fortran_INCLUDE_DIRS} ${MPI_INCLUDE_PATH} "./" ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) - link_directories(${MPI_Fortran_LIBRARIES} ${ARCHIVE_OUTPUT_PATH} ) - find_package( NetCDF COMPONENTS C Fortran REQUIRED) - find_package( W3NCO ) - - set(BUILD_NCDIAG ON) - set(NCDIAG_INCS "${PROJECT_BINARY_DIR}/src/ncdiag/include") - add_subdirectory(src/ncdiag) - set(NCDIAG_LIBRARIES ncdiag ) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) -endif() - -add_subdirectory(nwprod/oznmon_shared/sorc/oznmon_horiz.fd) -add_subdirectory(nwprod/oznmon_shared/sorc/oznmon_time.fd) -add_subdirectory(data_xtrct/sorc/make_base.fd) +add_subdirectory(data_xtrct) +add_subdirectory(nwprod) diff --git a/util/Ozone_Monitor/data_xtrct/CMakeLists.txt b/util/Ozone_Monitor/data_xtrct/CMakeLists.txt new file mode 100644 index 0000000000..ddf939af1e --- /dev/null +++ b/util/Ozone_Monitor/data_xtrct/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(sorc) diff --git a/util/Ozone_Monitor/data_xtrct/exec/.gitignore b/util/Ozone_Monitor/data_xtrct/exec/.gitignore deleted file mode 100644 index d6b7ef32c8..0000000000 --- a/util/Ozone_Monitor/data_xtrct/exec/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/util/Ozone_Monitor/data_xtrct/sorc/CMakeLists.txt b/util/Ozone_Monitor/data_xtrct/sorc/CMakeLists.txt new file mode 100644 index 0000000000..efe47a7d32 --- /dev/null +++ b/util/Ozone_Monitor/data_xtrct/sorc/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(make_base.fd) diff --git a/util/Ozone_Monitor/data_xtrct/sorc/make_base.fd/CMakeLists.txt b/util/Ozone_Monitor/data_xtrct/sorc/make_base.fd/CMakeLists.txt index 68e1da7c6c..ec8490a912 100644 --- a/util/Ozone_Monitor/data_xtrct/sorc/make_base.fd/CMakeLists.txt +++ b/util/Ozone_Monitor/data_xtrct/sorc/make_base.fd/CMakeLists.txt @@ -1,14 +1,16 @@ -cmake_minimum_required(VERSION 2.6) - file(GLOB OZNMON_MAKE_BASE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(OZNMON_MAKE_BASE_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 ") - set_source_files_properties( ${OZNMON_MAKE_BASE_SRC} PROPERTIES COMPILE_FLAGS ${OZNMON_MAKE_BASE_Fortran_FLAGS} ) - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/oznmon_make_base ) - add_executable(oznmon_make_base.x ${OZNMON_MAKE_BASE_SRC} ) - set_target_properties( oznmon_make_base.x PROPERTIES COMPILE_FLAGS ${OZNMON_MAKE_BASE_Fortran_FLAGS} ) - set_target_properties( oznmon_make_base.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) - include_directories( ${CORE_INCS} ) - target_link_libraries( oznmon_make_base.x ${W3NCO_4_LIBRARY} ) - if(BUILD_W3NCO) - add_dependencies( oznmon_make_base.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + make_base.f90 +) + +add_executable(oznmon_make_base.x ${SRCS}) +target_link_libraries(oznmon_make_base.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS oznmon_make_base.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Ozone_Monitor/data_xtrct/sorc/make_base.fd/makefile b/util/Ozone_Monitor/data_xtrct/sorc/make_base.fd/makefile deleted file mode 100755 index 292875a047..0000000000 --- a/util/Ozone_Monitor/data_xtrct/sorc/make_base.fd/makefile +++ /dev/null @@ -1,44 +0,0 @@ -# ***************************************************************** -# makefile -# -# Make the make_base executable. The executable will construct -# base history files for each entry in the SATYPE list from the -# time data files (*.ieee_d) for the specified source (suffix). -# -# This is not normally necessary for RadMon users unless you want -# to use the automated validation mechanism. -# ***************************************************************** - -BINDIR = $(dir_root)/exec - -LIBS = $(W3NCO_LIB4) - -OBJS = make_base.o - -# -# ***************************************************************** -# - -CMD = oznmon_make_base.x - -all: $(CMD) - -clean: - rm -f *.o - rm -f *.mod - rm -f oznmon_make_base.x - -check_prereqs: - /nwprod/spa_util/check_libs.bash $(LIBS) - -install: - cp -f $(CMD) $(BINDIR)/. - -debug: FFLAGS = $(D_FFLAGS) -debug: $(CMD) - -$(CMD): $(OBJS) - $(CF) $(FFLAGS) $(LDFLAGS) -o $(@) $(OBJS) $(LIBS) - -make_base.o : make_base.f90 - $(CF) $(FFLAGS) -c $(*).f90 diff --git a/util/Ozone_Monitor/nwprod/CMakeLists.txt b/util/Ozone_Monitor/nwprod/CMakeLists.txt new file mode 100644 index 0000000000..0fd3ef9eac --- /dev/null +++ b/util/Ozone_Monitor/nwprod/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(oznmon_shared) diff --git a/util/Ozone_Monitor/nwprod/oznmon_shared/CMakeLists.txt b/util/Ozone_Monitor/nwprod/oznmon_shared/CMakeLists.txt new file mode 100644 index 0000000000..ddf939af1e --- /dev/null +++ b/util/Ozone_Monitor/nwprod/oznmon_shared/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(sorc) diff --git a/util/Ozone_Monitor/nwprod/oznmon_shared/exec/.gitignore b/util/Ozone_Monitor/nwprod/oznmon_shared/exec/.gitignore deleted file mode 100644 index d6b7ef32c8..0000000000 --- a/util/Ozone_Monitor/nwprod/oznmon_shared/exec/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/util/Ozone_Monitor/nwprod/oznmon_shared/modulefiles/cray/OznMonBuild b/util/Ozone_Monitor/nwprod/oznmon_shared/modulefiles/cray/OznMonBuild deleted file mode 100644 index 94ac5cfdbc..0000000000 --- a/util/Ozone_Monitor/nwprod/oznmon_shared/modulefiles/cray/OznMonBuild +++ /dev/null @@ -1,18 +0,0 @@ -#%Module################################################################# -proc ModulesHelp { } { - puts stderr "Set environment variables for WCOSS(cray) ozmon build" -} - -module-whatis "Set environment variables for WCOSS(cray) ozmon build" - -set ver 2.0.2 -set FCOMP ifort - -setenv CF $FCOMP -setenv FC $FCOMP -setenv FFLAGS "-O3 -fp-model strict -convert big_endian -assume byterecl" - -setenv D_FFLAGS "-O3 -fp-model strict -convert big_endian -assume byterecl -debug" -module load intel -module load w3nco-intel/2.0.6 - diff --git a/util/Ozone_Monitor/nwprod/oznmon_shared/modulefiles/dell/OznMonBuild b/util/Ozone_Monitor/nwprod/oznmon_shared/modulefiles/dell/OznMonBuild deleted file mode 100644 index ea48fbadd6..0000000000 --- a/util/Ozone_Monitor/nwprod/oznmon_shared/modulefiles/dell/OznMonBuild +++ /dev/null @@ -1,18 +0,0 @@ -#%Module################################################################# -proc ModulesHelp { } { - puts stderr "Set environment variables for WCOSS(dell) ozmon build" -} - -module-whatis "Set environment variables for WCOSS(dell) ozmon build" - -set ver 2.0.2 -set FCOMP ifort - -setenv CF $FCOMP -setenv FC $FCOMP -setenv FFLAGS "-O3 -fp-model strict -convert big_endian -assume byterecl" - -setenv D_FFLAGS "-O3 -fp-model strict -convert big_endian -assume byterecl -debug" -module load ips/18.0.1.163 -module load w3nco/2.0.6 - diff --git a/util/Ozone_Monitor/nwprod/oznmon_shared/modulefiles/theia/OznMonBuild b/util/Ozone_Monitor/nwprod/oznmon_shared/modulefiles/theia/OznMonBuild deleted file mode 100644 index 2b619e9a88..0000000000 --- a/util/Ozone_Monitor/nwprod/oznmon_shared/modulefiles/theia/OznMonBuild +++ /dev/null @@ -1,20 +0,0 @@ -#%Module################################################################# -proc ModulesHelp { } { - puts stderr "Set environment variables for THEIA OzoMon build" -} - -module-whatis "Set environment variables for THEIA OzoMon build" - -set ver 2.0.2 - -module load intel - -set FCOMP ifort - -setenv CF $FCOMP -setenv FC $FCOMP -setenv FFLAGS "-O3 -fp-model strict -D_REAL8_ -traceback -convert big_endian -assume byterecl" -setenv D_FFLAGS "-O3 -fp-model strict -D_REAL8_ -traceback -convert big_endian -assume byterecl -debug" - -setenv W3NCO_LIB4 "-L/scratch3/NCEPDEV/nwprod/lib -lw3nco_4" - diff --git a/util/Ozone_Monitor/nwprod/oznmon_shared/modulefiles/wcoss/OznMonBuild b/util/Ozone_Monitor/nwprod/oznmon_shared/modulefiles/wcoss/OznMonBuild deleted file mode 100644 index 2c251a0cd9..0000000000 --- a/util/Ozone_Monitor/nwprod/oznmon_shared/modulefiles/wcoss/OznMonBuild +++ /dev/null @@ -1,18 +0,0 @@ -#%Module################################################################# -proc ModulesHelp { } { - puts stderr "Set environment variables for WCOSS(ibm) ozmon build" -} - -module-whatis "Set environment variables for WCOSS(ibm) ozmon build" - -set ver 2.0.0 -set FCOMP ifort - -setenv CF $FCOMP -setenv FC $FCOMP -setenv FFLAGS "-O3 -fp-model strict -convert big_endian -assume byterecl" - -setenv D_FFLAGS "-O3 -fp-model strict -convert big_endian -assume byterecl -debug" -module load ics -module load w3nco - diff --git a/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/CMakeLists.txt b/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/CMakeLists.txt new file mode 100644 index 0000000000..c341723f17 --- /dev/null +++ b/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory(oznmon_horiz.fd) +add_subdirectory(oznmon_time.fd) diff --git a/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_horiz.fd/CMakeLists.txt b/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_horiz.fd/CMakeLists.txt index e53b9fe053..3d7e5fb7a1 100644 --- a/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_horiz.fd/CMakeLists.txt +++ b/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_horiz.fd/CMakeLists.txt @@ -1,14 +1,27 @@ -cmake_minimum_required(VERSION 3.16.1) - file(GLOB OZNMON_HORIZ_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(OZNMON_HORIZ_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -g -traceback ") - set_source_files_properties( ${OZNMON_HORIZ_SRC} PROPERTIES COMPILE_FLAGS ${OZNMON_HORIZ_Fortran_FLAGS} ) - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/oznmon_horiz ) - add_executable(oznmon_horiz.x ${OZNMON_HORIZ_SRC} ) - set_target_properties( oznmon_horiz.x PROPERTIES COMPILE_FLAGS ${OZNMON_HORIZ_Fortran_FLAGS} ) - set_target_properties( oznmon_horiz.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) - include_directories( ${CORE_INCS} ${NCDIAG_INCS} ) - target_link_libraries( oznmon_horiz.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES} ) - if(BUILD_W3NCO) - add_dependencies( oznmon_horiz.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + create_ctl_horiz.f90 + horiz.f90 + kinds.f90 + oznmon_read_diag.f90 +) + +add_executable(oznmon_horiz.x ${SRCS}) +if(TARGET ncdiag) + add_dependencies(oznmon_horiz.x ncdiag) +endif() + +target_compile_definitions(oznmon_horiz.x PRIVATE "_REAL8_") +target_link_libraries(oznmon_horiz.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(oznmon_horiz.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(oznmon_horiz.x PRIVATE ncdiag::ncdiag) +target_link_libraries(oznmon_horiz.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS oznmon_horiz.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_horiz.fd/oznmon_read_diag.f90 b/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_horiz.fd/oznmon_read_diag.f90 index 8feb261ca4..7dadde2e87 100644 --- a/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_horiz.fd/oznmon_read_diag.f90 +++ b/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_horiz.fd/oznmon_read_diag.f90 @@ -642,7 +642,7 @@ subroutine read_ozndiag_data_nc( ftin, header_fix, data_fix, data_nlev, data_ext nlevs = header_fix%nlevs - if( ncdiag_open_status(cur_idx)%nc_read == .true. ) then + if( ncdiag_open_status(cur_idx)%nc_read .eqv. .true. ) then iflag = -1 else iflag = 0 @@ -965,7 +965,7 @@ logical function verify_var_name_nc( test_name ) end if end do - if( verify_var_name_nc == .false. ) then + if( verify_var_name_nc .eqv. .false. ) then do k=1,num_vars if( test_name == var_names(k) ) then verify_var_name_nc = .true. diff --git a/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_time.fd/CMakeLists.txt b/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_time.fd/CMakeLists.txt index ea8b907af0..dd5d973bad 100644 --- a/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_time.fd/CMakeLists.txt +++ b/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_time.fd/CMakeLists.txt @@ -1,14 +1,29 @@ -cmake_minimum_required(VERSION 3.16.1) - file(GLOB OZNMON_TIME_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(OZNMON_TIME_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -g -traceback ") - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/oznmon_time ) - set_source_files_properties( ${OZNMON_TIME_SRC} PROPERTIES COMPILE_FLAGS ${OZNMON_TIME_Fortran_FLAGS} ) - add_executable(oznmon_time.x ${OZNMON_TIME_SRC} ) - set_target_properties( oznmon_time.x PROPERTIES COMPILE_FLAGS ${OZNMON_TIME_Fortran_FLAGS} ) - set_target_properties( oznmon_time.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) - include_directories( ${CORE_INCS} ${NCDIAG_INCS} ) - target_link_libraries( oznmon_time.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES} ) - if(BUILD_W3NCO) - add_dependencies( oznmon_time.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + avgsdv.f90 + create_ctl_time.f90 + kinds.f90 + oznmon_read_diag.f90 + time.f90 + valid.f90 +) + +add_executable(oznmon_time.x ${SRCS}) +if(TARGET ncdiag) + add_dependencies(oznmon_time.x ncdiag) +endif() + +target_compile_definitions(oznmon_time.x PRIVATE "_REAL8_") +target_link_libraries(oznmon_time.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(oznmon_time.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(oznmon_time.x PRIVATE ncdiag::ncdiag) +target_link_libraries(oznmon_time.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS oznmon_time.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_time.fd/oznmon_read_diag.f90 b/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_time.fd/oznmon_read_diag.f90 index 8feb261ca4..7dadde2e87 100644 --- a/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_time.fd/oznmon_read_diag.f90 +++ b/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_time.fd/oznmon_read_diag.f90 @@ -642,7 +642,7 @@ subroutine read_ozndiag_data_nc( ftin, header_fix, data_fix, data_nlev, data_ext nlevs = header_fix%nlevs - if( ncdiag_open_status(cur_idx)%nc_read == .true. ) then + if( ncdiag_open_status(cur_idx)%nc_read .eqv. .true. ) then iflag = -1 else iflag = 0 @@ -965,7 +965,7 @@ logical function verify_var_name_nc( test_name ) end if end do - if( verify_var_name_nc == .false. ) then + if( verify_var_name_nc .eqv. .false. ) then do k=1,num_vars if( test_name == var_names(k) ) then verify_var_name_nc = .true. diff --git a/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_time.fd/time.f90 b/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_time.fd/time.f90 index 15d70cbaa2..66d08dba37 100755 --- a/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_time.fd/time.f90 +++ b/util/Ozone_Monitor/nwprod/oznmon_shared/sorc/oznmon_time.fd/time.f90 @@ -329,7 +329,7 @@ program main end do ! Do validation - if( validate == .TRUE. ) then + if( validate .eqv. .TRUE. ) then call load_base( satname, ier ) write(6,*) 'ier from load_base = ', ier @@ -344,7 +344,7 @@ program main do j=1,n_levs if ( use(j,k) > 0.0 ) then - if( validate == .TRUE. .AND. ier >= 0 ) then + if( validate .eqv. .TRUE. .AND. ier >= 0 ) then pbound = 0.00 call validate_penalty( j, k, penalty(j,k), valid_penalty, pbound, iret ) @@ -369,7 +369,7 @@ program main endif end do - if( validate == .TRUE. ) then + if( validate .eqv. .TRUE. ) then close( lupen ) close( lucnt ) endif diff --git a/util/Radiance_Monitor/CMakeLists.txt b/util/Radiance_Monitor/CMakeLists.txt index e11f186d0a..9c0124048d 100644 --- a/util/Radiance_Monitor/CMakeLists.txt +++ b/util/Radiance_Monitor/CMakeLists.txt @@ -1,104 +1,3 @@ -cmake_minimum_required(VERSION 2.8.12) -if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) - # I am top-level project. - if( NOT DEFINED ENV{CC} ) - find_path( crayComp "ftn" ) - find_path( wcossIntel "mpfort" ) - find_path( intelComp "ifort" ) - find_path( pgiComp "pgf90" ) - if( crayComp ) - message("Setting CrayLinuxEnvironment") - set(CMAKE_SYSTEM_NAME "CrayLinuxEnvironment") - set(CMAKE_C_COMPILER "${crayComp}/cc") - set(CMAKE_CXX_COMPILER "${crayComp}/CC") - set(CMAKE_Fortran_COMPILER "${crayComp}/ftn") - endif() - if( intelComp ) - set(ENV{CC} "icc") - set(ENV{CXX} "icpc") - set(ENV{FC} "ifort") - endif() - if( wcossIntel ) - message("Setting env for wcoss intel") - set(ENV{CC} "mpcc") - set(ENV{CXX} "mpCC") - set(ENV{FC} "mpfort") - endif() - if( pgiComp ) - set(ENV{CC} "pgcc") - set(ENV{CXX} "pgCC") - set(ENV{FC} "pgf90") - endif() - endif() - project(COV_Calc) - enable_language (Fortran) - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/../../cmake/Modules/") - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setPlatformVariables.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setIntelFlags.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setGNUFlags.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setPGIFlags.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setHOST.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Cheyenne.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Discover.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Generic.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Gaea.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Jet.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/S4.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Hera.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/WCOSS-C.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/WCOSS-D.cmake) - include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/WCOSS.cmake) - if (NOT CMAKE_BUILD_TYPE) - set (CMAKE_BUILD_TYPE RELEASE CACHE STRING - "Choose the type of build, options are: PRODUCTION Debug Release." - FORCE) - endif (NOT CMAKE_BUILD_TYPE) - if (CMAKE_CXX_COMPILER_ID MATCHES "GNU*") - message("Setting GNU flags") - setGNU() - elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - message("Setting Intel flags") - setIntel() - elseif(CMAKE_C_COMPILER MATCHES "pgc*") - message("Setting PGI flags") - setPGI() - endif() - - cmake_policy(SET CMP0009 NEW) - cmake_policy(SET CMP0074 NEW) - find_package(OpenMP) - message("found openmp with flag ${OPENMP_Fortran_FLAGS}") - -# Set Host specific flags and options - setHOST() - - find_package(MPI REQUIRED) - message("MPI version is ${MPI_Fortran_VERSION}") - message("MPI f90 version is ${MPI_Fortran_HAVE_F90_MODULE}") - message("MPI f08 version is ${MPI_Fortran_HAVE_F08_MODULE}") - - add_definitions(${MPI_Fortran_COMPILE_FLAGS}) - include_directories(${MPI_Fortran_INCLUDE_DIRS} ${MPI_INCLUDE_PATH} "./" ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) - link_directories(${MPI_Fortran_LIBRARIES} ${ARCHIVE_OUTPUT_PATH} ) - find_package( NetCDF COMPONENTS C Fortran REQUIRED) - find_package( W3NCO ) - - set(BUILD_NCDIAG ON) - set(NCDIAG_INCS "${PROJECT_BINARY_DIR}/src/ncdiag") - add_subdirectory(${PROJECT_SOURCE_DIR}/../../src/ncdiag ${PROJECT_BINARY_DIR}/src/ncdiag) - set(NCDIAG_LIBRARIES ncdiag ) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) -endif() - -add_subdirectory(nwprod/radmon_shared/sorc/verf_radang.fd) -add_subdirectory(nwprod/radmon_shared/sorc/verf_radbcoef.fd) -add_subdirectory(nwprod/radmon_shared/sorc/verf_radbcor.fd) -add_subdirectory(nwprod/radmon_shared/sorc/verf_radtime.fd) -add_subdirectory(data_extract/sorc/radmon_mk_base.fd) -add_subdirectory(data_extract/sorc/radmon_validate_tm.fd) -add_subdirectory(image_gen/src/radmon_ig_angle.fd) -add_subdirectory(image_gen/src/radmon_ig_bcoef.fd) -add_subdirectory(image_gen/src/radmon_ig_horiz.fd) -add_subdirectory(image_gen/src/radmon_ig_summary.fd) -add_subdirectory(image_gen/src/radmon_ig_time.fd) +add_subdirectory(data_extract) +add_subdirectory(image_gen) +add_subdirectory(nwprod) diff --git a/util/Radiance_Monitor/data_extract/CMakeLists.txt b/util/Radiance_Monitor/data_extract/CMakeLists.txt new file mode 100644 index 0000000000..ddf939af1e --- /dev/null +++ b/util/Radiance_Monitor/data_extract/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(sorc) diff --git a/util/Radiance_Monitor/data_extract/exec/.gitignore b/util/Radiance_Monitor/data_extract/exec/.gitignore deleted file mode 100644 index d6b7ef32c8..0000000000 --- a/util/Radiance_Monitor/data_extract/exec/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/util/Radiance_Monitor/data_extract/sorc/CMakeLists.txt b/util/Radiance_Monitor/data_extract/sorc/CMakeLists.txt new file mode 100644 index 0000000000..f1f7ac2f14 --- /dev/null +++ b/util/Radiance_Monitor/data_extract/sorc/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory(radmon_mk_base.fd) +add_subdirectory(radmon_validate_tm.fd) diff --git a/util/Radiance_Monitor/data_extract/sorc/radmon_mk_base.fd/CMakeLists.txt b/util/Radiance_Monitor/data_extract/sorc/radmon_mk_base.fd/CMakeLists.txt index 603d4acfbc..d60ba7d539 100644 --- a/util/Radiance_Monitor/data_extract/sorc/radmon_mk_base.fd/CMakeLists.txt +++ b/util/Radiance_Monitor/data_extract/sorc/radmon_mk_base.fd/CMakeLists.txt @@ -1,14 +1,16 @@ -cmake_minimum_required(VERSION 2.8.12) - file(GLOB RADMON_MK_BASE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(RADMON_MK_BASE_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/radmon_mk_base ) - set_source_files_properties( ${RADMON_MK_BASE_SRC} PROPERTIES COMPILE_FLAGS ${RADMON_MK_BASE_Fortran_FLAGS} ) - add_executable(radmon_mk_base.x ${RADMON_MK_BASE_SRC} ) - set_target_properties( radmon_mk_base.x PROPERTIES COMPILE_FLAGS ${RADMON_MK_BASE_Fortran_FLAGS} ) - set_target_properties( radmon_mk_base.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) - include_directories( ${CORE_INCS} ) - target_link_libraries( radmon_mk_base.x ${W3NCO_4_LIBRARY} ) - if(BUILD_W3NCO) - add_dependencies( radmon_mk_base.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + make_base.f90 +) + +add_executable(radmon_make_base.x ${SRCS}) +target_link_libraries(radmon_make_base.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS radmon_make_base.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Radiance_Monitor/data_extract/sorc/radmon_mk_base.fd/makefile b/util/Radiance_Monitor/data_extract/sorc/radmon_mk_base.fd/makefile deleted file mode 100755 index 05519c047f..0000000000 --- a/util/Radiance_Monitor/data_extract/sorc/radmon_mk_base.fd/makefile +++ /dev/null @@ -1,44 +0,0 @@ -# ***************************************************************** -# makefile -# -# Make the make_base executable. The executable will construct -# base history files for each entry in the SATYPE list from the -# time data files (*.ieee_d) for the specified source (suffix). -# -# This is not normally necessary for RadMon users unless you want -# to use the automated validation mechanism. -# ***************************************************************** - -BINDIR = ../../exec - -LIBS = $(W3NCO_LIB4) - -OBJS = make_base.o - -# -# ***************************************************************** -# - -CMD = make_base - -all: $(CMD) - -clean: - rm -f *.o - rm -f *.mod - rm -f make_base - -check_prereqs: - /nwprod/spa_util/check_libs.bash $(LIBS) - -install: - cp -f $(CMD) $(BINDIR)/. - -debug: FFLAGS = $(D_FFLAGS) -debug: $(CMD) - -$(CMD): $(OBJS) - $(CF) $(FFLAGS) $(LDFLAGS) -o $(@) $(OBJS) $(LIBS) - -make_base.o : make_base.f90 - $(CF) $(FFLAGS) -c $(*).f90 diff --git a/util/Radiance_Monitor/data_extract/sorc/radmon_validate_tm.fd/CMakeLists.txt b/util/Radiance_Monitor/data_extract/sorc/radmon_validate_tm.fd/CMakeLists.txt index 071e872e8f..d1f9128c2e 100644 --- a/util/Radiance_Monitor/data_extract/sorc/radmon_validate_tm.fd/CMakeLists.txt +++ b/util/Radiance_Monitor/data_extract/sorc/radmon_validate_tm.fd/CMakeLists.txt @@ -1,14 +1,22 @@ -cmake_minimum_required(VERSION 2.8.12) - file(GLOB RADMON_VALIDATE_TM_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(RADMON_VALIDATE_TM_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/radmon_validate_tm.x ) - set_source_files_properties( ${RADMON_VALIDATE_TM_SRC} PROPERTIES COMPILE_FLAGS ${RADMON_VALIDATE_TM_Fortran_FLAGS} ) - add_executable(radmon_validate_tm.x ${RADMON_VALIDATE_TM_SRC} ) - set_target_properties( radmon_validate_tm.x PROPERTIES COMPILE_FLAGS ${RADMON_VALIDATE_TM_Fortran_FLAGS} ) - set_target_properties( radmon_validate_tm.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) - include_directories( ${CORE_INCS} ) - target_link_libraries( radmon_validate_tm.x ${W3NCO_4_LIBRARY} ) - if(BUILD_W3NCO) - add_dependencies( radmon_validate_tm.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + bad_chan.f90 + bad_penalty.f90 + kinds.F90 + low_count.f90 + valid.f90 + validate_time.f90 +) + +add_executable(radmon_validate_tm.x ${SRCS}) +target_compile_definitions(radmon_validate_tm.x PRIVATE "_REAL8_") +target_link_libraries(radmon_validate_tm.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS radmon_validate_tm.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Radiance_Monitor/data_extract/sorc/radmon_validate_tm.fd/makefile b/util/Radiance_Monitor/data_extract/sorc/radmon_validate_tm.fd/makefile deleted file mode 100755 index afd5e05958..0000000000 --- a/util/Radiance_Monitor/data_extract/sorc/radmon_validate_tm.fd/makefile +++ /dev/null @@ -1,62 +0,0 @@ -# ***************************************************************** -# makefile -# -# Make the validate_time.x executable. This is not normally needed -# for normal use. It re-validates data in an extracted *.ieee_d -# file, applying a different set of historic base files in the -# validation. -# -# If needed, run make on this directory and move the executable -# over to the data_extract/exec directory. -# -# ***************************************************************** - -BINDIR = ../../exec - -LIBS = $(W3NCO_LIB4) - -OBJS = kinds.o bad_obs.o bad_penalty.o bad_chan.o valid.o \ - validate_time.o - -# -# ***************************************************************** -# - -CMD = validate_time.x - -all: $(CMD) - -clean: - rm -f *.o - rm -f *.mod - rm -f validate_time.x - -check_prereqs: - /nwprod/spa_util/check_libs.bash $(LIBS) - -install: - cp -f $(CMD) $(BINDIR)/ - -debug: FFLAGS = $(D_FFLAGS) -debug: $(CMD) - -$(CMD): $(OBJS) - $(CF) $(FFLAGS) $(LDFLAGS) -o $(@) $(OBJS) $(LIBS) - -bad_obs.o : bad_obs.f90 - $(CF) $(FFLAGS) -c $(*).f90 - -bad_penalty.o : bad_penalty.f90 - $(CF) $(FFLAGS) -c $(*).f90 - -bad_chan.o : bad_chan.f90 - $(CF) $(FFLAGS) -c $(*).f90 - -valid.o : valid.f90 - $(CF) $(FFLAGS) -c $(*).f90 - -validate_time.o : validate_time.f90 - $(CF) $(FFLAGS) -c $(*).f90 - -kinds.o : kinds.F90 - $(CF) $(FFLAGS) -c $(*).F90 diff --git a/util/Radiance_Monitor/image_gen/CMakeLists.txt b/util/Radiance_Monitor/image_gen/CMakeLists.txt new file mode 100644 index 0000000000..febd4f0ab6 --- /dev/null +++ b/util/Radiance_Monitor/image_gen/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(src) diff --git a/util/Radiance_Monitor/image_gen/exec/.gitignore b/util/Radiance_Monitor/image_gen/exec/.gitignore deleted file mode 100644 index d6b7ef32c8..0000000000 --- a/util/Radiance_Monitor/image_gen/exec/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/util/Radiance_Monitor/image_gen/src/CMakeLists.txt b/util/Radiance_Monitor/image_gen/src/CMakeLists.txt new file mode 100644 index 0000000000..a54d0f787b --- /dev/null +++ b/util/Radiance_Monitor/image_gen/src/CMakeLists.txt @@ -0,0 +1,5 @@ +add_subdirectory(radmon_ig_angle.fd) +add_subdirectory(radmon_ig_bcoef.fd) +add_subdirectory(radmon_ig_horiz.fd) +add_subdirectory(radmon_ig_summary.fd) +add_subdirectory(radmon_ig_time.fd) diff --git a/util/Radiance_Monitor/image_gen/src/radmon_ig_angle.fd/CMakeLists.txt b/util/Radiance_Monitor/image_gen/src/radmon_ig_angle.fd/CMakeLists.txt index e585be7a32..ede288d254 100644 --- a/util/Radiance_Monitor/image_gen/src/radmon_ig_angle.fd/CMakeLists.txt +++ b/util/Radiance_Monitor/image_gen/src/radmon_ig_angle.fd/CMakeLists.txt @@ -1,14 +1,19 @@ -cmake_minimum_required(VERSION 2.8.12) - file(GLOB RADMON_IG_ANGLE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(RADMON_IG_ANGLE_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/radmon_ig_angle ) - set_source_files_properties( ${RADMON_IG_ANGLE_SRC} PROPERTIES COMPILE_FLAGS ${RADMON_IG_ANGLE_Fortran_FLAGS} ) - add_executable(radmon_ig_angle.x ${RADMON_IG_ANGLE_SRC} ) - set_target_properties( radmon_ig_angle.x PROPERTIES COMPILE_FLAGS ${RADMON_IG_ANGLE_Fortran_FLAGS} ) - set_target_properties( radmon_ig_angle.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) - include_directories( ${CORE_INCS} ) - target_link_libraries( radmon_ig_angle.x ${W3NCO_4_LIBRARY} ) - if(BUILD_W3NCO) - add_dependencies( radmon_ig_angle.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + angle.f90 + avgsdv.f90 +) + +add_executable(radmon_ig_angle.x ${SRCS}) + +target_compile_definitions(radmon_ig_angle.x PRIVATE "_REAL8_") +target_link_libraries(radmon_ig_angle.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS radmon_ig_angle.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Radiance_Monitor/image_gen/src/radmon_ig_angle.fd/angle.f90 b/util/Radiance_Monitor/image_gen/src/radmon_ig_angle.fd/angle.f90 index 78ea2f26fc..e7f35f510e 100755 --- a/util/Radiance_Monitor/image_gen/src/radmon_ig_angle.fd/angle.f90 +++ b/util/Radiance_Monitor/image_gen/src/radmon_ig_angle.fd/angle.f90 @@ -338,7 +338,7 @@ program angle inquire(file=data_file, exist=exist) write( 6,* ) 'data_file : ', data_file, 'exist = ', exist - if ( exist == .TRUE. ) then + if ( exist .eqv. .TRUE. ) then open(ldname,file=data_file,form='unformatted') diff --git a/util/Radiance_Monitor/image_gen/src/radmon_ig_bcoef.fd/CMakeLists.txt b/util/Radiance_Monitor/image_gen/src/radmon_ig_bcoef.fd/CMakeLists.txt index 06e447e3d5..f16f518a6f 100644 --- a/util/Radiance_Monitor/image_gen/src/radmon_ig_bcoef.fd/CMakeLists.txt +++ b/util/Radiance_Monitor/image_gen/src/radmon_ig_bcoef.fd/CMakeLists.txt @@ -1,14 +1,19 @@ -cmake_minimum_required(VERSION 2.8.12) - file(GLOB RADMON_IG_BCOEF_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(RADMON_IG_BCOEF_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/radmon_ig_bcoef ) - set_source_files_properties( ${RADMON_IG_BCOEF_SRC} PROPERTIES COMPILE_FLAGS ${RADMON_IG_BCOEF_Fortran_FLAGS} ) - add_executable(radmon_ig_bcoef.x ${RADMON_IG_BCOEF_SRC} ) - set_target_properties( radmon_ig_bcoef.x PROPERTIES COMPILE_FLAGS ${RADMON_IG_BCOEF_Fortran_FLAGS} ) - set_target_properties( radmon_ig_bcoef.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) - include_directories( ${CORE_INCS} ) - target_link_libraries( radmon_ig_bcoef.x ${W3NCO_4_LIBRARY} ) - if(BUILD_W3NCO) - add_dependencies( radmon_ig_bcoef.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + avgsdv.f90 + bcoef.f90 +) + +add_executable(radmon_ig_bcoef.x ${SRCS}) + +target_compile_definitions(radmon_ig_bcoef.x PRIVATE "_REAL8_") +target_link_libraries(radmon_ig_bcoef.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS radmon_ig_bcoef.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Radiance_Monitor/image_gen/src/radmon_ig_bcoef.fd/bcoef.f90 b/util/Radiance_Monitor/image_gen/src/radmon_ig_bcoef.fd/bcoef.f90 index c70fac7c13..24fb4b60bc 100755 --- a/util/Radiance_Monitor/image_gen/src/radmon_ig_bcoef.fd/bcoef.f90 +++ b/util/Radiance_Monitor/image_gen/src/radmon_ig_bcoef.fd/bcoef.f90 @@ -18,7 +18,9 @@ program bcoef ! but not bcoef. !************************************************************************ - use IFPORT +! use IFPORT +! Intel® Fortran includes functions and subroutines that ease porting of code to or from a PC, or allow you to write code on a PC that is compatible with other platforms. The portability library is called LIBIFPORT.LIB (Windows*) or libifport.a (Linux* and macOS*). Frequently used functions are included in a portability module called IFPORT. +! What functionality from IFPORT library is being used here and why? implicit none @@ -174,7 +176,7 @@ program bcoef inquire(file=data_file, exist=exist) ! write(6,*) 'data_file,exist = ', data_file, ' ', exist - if ( exist == .TRUE. ) then + if ( exist .eqv. .TRUE. ) then open(ldname,file=data_file,form='unformatted') read(ldname) (penalty(jj),jj=1,nchanl) ! write(6,*) 'penalty(1) = ', penalty(1) diff --git a/util/Radiance_Monitor/image_gen/src/radmon_ig_horiz.fd/CMakeLists.txt b/util/Radiance_Monitor/image_gen/src/radmon_ig_horiz.fd/CMakeLists.txt index 07e20110d9..b50bf7fe47 100644 --- a/util/Radiance_Monitor/image_gen/src/radmon_ig_horiz.fd/CMakeLists.txt +++ b/util/Radiance_Monitor/image_gen/src/radmon_ig_horiz.fd/CMakeLists.txt @@ -1,14 +1,29 @@ -cmake_minimum_required(VERSION 2.8.12) - file(GLOB RADMON_HORIZ_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(RADMON_HORIZ_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/radmon_horiz ) - set_source_files_properties( ${RADMON_HORIZ_SRC} PROPERTIES COMPILE_FLAGS ${RADMON_HORIZ_Fortran_FLAGS} ) - add_executable(radmon_ig_horiz.x ${RADMON_HORIZ_SRC} ) - set_target_properties( radmon_ig_horiz.x PROPERTIES COMPILE_FLAGS ${RADMON_HORIZ_Fortran_FLAGS} ) - set_target_properties( radmon_ig_horiz.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) - include_directories( ${CORE_INCS} ${NCDIAG_INCS} ) - target_link_libraries( radmon_ig_horiz.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES}) - if(BUILD_W3NCO) - add_dependencies( radmon_ig_horiz.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + create_ctl_horiz.f90 + horiz.f90 + kinds.F90 + read_diag.f90 + sparsearr.f90 + update_ctl_horiz.f90 +) + +add_executable(radmon_ig_horiz.x ${SRCS}) +if(TARGET ncdiag) + add_dependencies(radmon_ig_horiz.x ncdiag) +endif() + +target_compile_definitions(radmon_ig_horiz.x PRIVATE "_REAL8_") +target_link_libraries(radmon_ig_horiz.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(radmon_ig_horiz.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(radmon_ig_horiz.x PRIVATE ncdiag::ncdiag) +target_link_libraries(radmon_ig_horiz.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS radmon_ig_horiz.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Radiance_Monitor/image_gen/src/radmon_ig_summary.fd/CMakeLists.txt b/util/Radiance_Monitor/image_gen/src/radmon_ig_summary.fd/CMakeLists.txt index 98dd52d74d..aa69a48b99 100644 --- a/util/Radiance_Monitor/image_gen/src/radmon_ig_summary.fd/CMakeLists.txt +++ b/util/Radiance_Monitor/image_gen/src/radmon_ig_summary.fd/CMakeLists.txt @@ -1,14 +1,19 @@ -cmake_minimum_required(VERSION 2.8.12) - file(GLOB RADMON_IG_SUMMARY_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(RADMON_IG_SUMMARY_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/radmon_ig_summary ) - set_source_files_properties( ${RADMON_IG_SUMMARY_SRC} PROPERTIES COMPILE_FLAGS ${RADMON_IG_SUMMARY_Fortran_FLAGS} ) - add_executable(radmon_ig_summary.x ${RADMON_IG_SUMMARY_SRC} ) - set_target_properties( radmon_ig_summary.x PROPERTIES COMPILE_FLAGS ${RADMON_IG_SUMMARY_Fortran_FLAGS} ) - set_target_properties( radmon_ig_summary.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) - include_directories( ${CORE_INCS} ) - target_link_libraries( radmon_ig_summary.x ${W3NCO_4_LIBRARY} ) - if(BUILD_W3NCO) - add_dependencies( radmon_ig_summary.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + avgsdv.f90 + summary.f90 +) + +add_executable(radmon_ig_summary.x ${SRCS}) + +target_compile_definitions(radmon_ig_summary.x PRIVATE "_REAL8_") +target_link_libraries(radmon_ig_summary.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS radmon_ig_summary.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Radiance_Monitor/image_gen/src/radmon_ig_summary.fd/summary.f90 b/util/Radiance_Monitor/image_gen/src/radmon_ig_summary.fd/summary.f90 index f857c4d149..531f4bd4ec 100755 --- a/util/Radiance_Monitor/image_gen/src/radmon_ig_summary.fd/summary.f90 +++ b/util/Radiance_Monitor/image_gen/src/radmon_ig_summary.fd/summary.f90 @@ -15,7 +15,9 @@ program summary ! !************************************************************************ - use IFPORT +! use IFPORT +! Intel® Fortran includes functions and subroutines that ease porting of code to or from a PC, or allow you to write code on a PC that is compatible with other platforms. The portability library is called LIBIFPORT.LIB (Windows*) or libifport.a (Linux* and macOS*). Frequently used functions are included in a portability module called IFPORT. +! What functionality from IFPORT library is being used here and why? implicit none @@ -142,7 +144,7 @@ program summary inquire(file=data_file, exist=exist) - if ( exist == .TRUE. ) then + if ( exist .eqv. .TRUE. ) then open(ldname,file=data_file,form='unformatted') read(ldname) ((cnt(ftyp,cyc,j,k),j=1,nchanl),k=1,nregion) read(ldname) ((pen(ftyp,cyc,j,k),j=1,nchanl),k=1,nregion) diff --git a/util/Radiance_Monitor/image_gen/src/radmon_ig_time.fd/CMakeLists.txt b/util/Radiance_Monitor/image_gen/src/radmon_ig_time.fd/CMakeLists.txt index 3f4bfa4cc8..390308fd26 100644 --- a/util/Radiance_Monitor/image_gen/src/radmon_ig_time.fd/CMakeLists.txt +++ b/util/Radiance_Monitor/image_gen/src/radmon_ig_time.fd/CMakeLists.txt @@ -1,14 +1,19 @@ -cmake_minimum_required(VERSION 2.8.12) - file(GLOB RADMON_IG_TIME_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(RADMON_IG_TIME_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ") - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/radmon_ig_time ) - set_source_files_properties( ${RADMON_IG_TIME_SRC} PROPERTIES COMPILE_FLAGS ${RADMON_IG_TIME_Fortran_FLAGS} ) - add_executable(radmon_ig_time.x ${RADMON_IG_TIME_SRC} ) - set_target_properties( radmon_ig_time.x PROPERTIES COMPILE_FLAGS ${RADMON_IG_TIME_Fortran_FLAGS} ) - set_target_properties( radmon_ig_time.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) - include_directories( ${CORE_INCS} ) - target_link_libraries( radmon_ig_time.x ${W3NCO_4_LIBRARY} ) - if(BUILD_W3NCO) - add_dependencies( radmon_ig_time.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + avgsdv.f90 + time.f90 +) + +add_executable(radmon_ig_time.x ${SRCS}) + +target_compile_definitions(radmon_ig_time.x PRIVATE "_REAL8_") +target_link_libraries(radmon_ig_time.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS radmon_ig_time.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Radiance_Monitor/image_gen/src/radmon_ig_time.fd/time.f90 b/util/Radiance_Monitor/image_gen/src/radmon_ig_time.fd/time.f90 index 9b964de02c..4e7df16eb5 100755 --- a/util/Radiance_Monitor/image_gen/src/radmon_ig_time.fd/time.f90 +++ b/util/Radiance_Monitor/image_gen/src/radmon_ig_time.fd/time.f90 @@ -15,7 +15,9 @@ program gatime ! one entry for a given channel per line. !************************************************************************ - use IFPORT +! use IFPORT +! Intel® Fortran includes functions and subroutines that ease porting of code to or from a PC, or allow you to write code on a PC that is compatible with other platforms. The portability library is called LIBIFPORT.LIB (Windows*) or libifport.a (Linux* and macOS*). Frequently used functions are included in a portability module called IFPORT. +! What functionality from IFPORT library is being used here and why? implicit none @@ -147,7 +149,7 @@ program gatime inquire(file=data_file, exist=exist) - if ( exist == .TRUE. ) then + if ( exist .eqv. .TRUE. ) then open(ldname,file=data_file,form='unformatted') read(ldname) ((cnt(ftyp,cyc,j,k),j=1,nchanl),k=1,nregion) read(ldname) ((pen(ftyp,cyc,j,k),j=1,nchanl),k=1,nregion) diff --git a/util/Radiance_Monitor/nwprod/CMakeLists.txt b/util/Radiance_Monitor/nwprod/CMakeLists.txt new file mode 100644 index 0000000000..067d9346e4 --- /dev/null +++ b/util/Radiance_Monitor/nwprod/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(radmon_shared) diff --git a/util/Radiance_Monitor/nwprod/radmon_shared/CMakeLists.txt b/util/Radiance_Monitor/nwprod/radmon_shared/CMakeLists.txt new file mode 100644 index 0000000000..ddf939af1e --- /dev/null +++ b/util/Radiance_Monitor/nwprod/radmon_shared/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(sorc) diff --git a/util/Radiance_Monitor/nwprod/radmon_shared/sorc/CMakeLists.txt b/util/Radiance_Monitor/nwprod/radmon_shared/sorc/CMakeLists.txt new file mode 100644 index 0000000000..b08f886e6b --- /dev/null +++ b/util/Radiance_Monitor/nwprod/radmon_shared/sorc/CMakeLists.txt @@ -0,0 +1,4 @@ +add_subdirectory(verf_radang.fd) +add_subdirectory(verf_radbcoef.fd) +add_subdirectory(verf_radbcor.fd) +add_subdirectory(verf_radtime.fd) diff --git a/util/Radiance_Monitor/nwprod/radmon_shared/sorc/verf_radang.fd/CMakeLists.txt b/util/Radiance_Monitor/nwprod/radmon_shared/sorc/verf_radang.fd/CMakeLists.txt index aba90e6d9f..7cf902a8e1 100644 --- a/util/Radiance_Monitor/nwprod/radmon_shared/sorc/verf_radang.fd/CMakeLists.txt +++ b/util/Radiance_Monitor/nwprod/radmon_shared/sorc/verf_radang.fd/CMakeLists.txt @@ -1,14 +1,28 @@ -cmake_minimum_required(VERSION 3.16.1) - file(GLOB RADMON_ANGLE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(RADMON_ANGLE_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -g -traceback -D_REAL8_ ") - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/radmon_angle ) - set_source_files_properties( ${RADMON_ANGLE_SRC} PROPERTIES COMPILE_FLAGS ${RADMON_ANGLE_Fortran_FLAGS} ) - add_executable(radmon_angle.x ${RADMON_ANGLE_SRC} ) - set_target_properties( radmon_angle.x PROPERTIES COMPILE_FLAGS ${RADMON_ANGLE_Fortran_FLAGS} ) - set_target_properties( radmon_angle.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) - include_directories( ${CORE_INCS} ${NCDIAG_INCS} ) - target_link_libraries( radmon_angle.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES} ) - if(BUILD_W3NCO) - add_dependencies( radmon_angle.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + angle_bias.f90 + create_ctl_angle.f90 + kinds.F90 + read_diag.f90 + sparsearr.f90 +) + +add_executable(radmon_angle.x ${SRCS}) +if(TARGET ncdiag) + add_dependencies(radmon_angle.x ncdiag) +endif() + +target_compile_definitions(radmon_angle.x PRIVATE "_REAL8_") +target_link_libraries(radmon_angle.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(radmon_angle.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(radmon_angle.x PRIVATE ncdiag::ncdiag) +target_link_libraries(radmon_angle.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS radmon_angle.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Radiance_Monitor/nwprod/radmon_shared/sorc/verf_radbcoef.fd/CMakeLists.txt b/util/Radiance_Monitor/nwprod/radmon_shared/sorc/verf_radbcoef.fd/CMakeLists.txt index f6c13cde49..6fc89645dd 100644 --- a/util/Radiance_Monitor/nwprod/radmon_shared/sorc/verf_radbcoef.fd/CMakeLists.txt +++ b/util/Radiance_Monitor/nwprod/radmon_shared/sorc/verf_radbcoef.fd/CMakeLists.txt @@ -1,14 +1,28 @@ -cmake_minimum_required(VERSION 3.16.1) - file(GLOB RADMON_BCOEF_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(RADMON_BCOEF_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -g -traceback -D_REAL8_ ") - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/radmon_bcoef ) - set_source_files_properties( ${RADMON_BCOEF_SRC} PROPERTIES COMPILE_FLAGS ${RADMON_BCOEF_Fortran_FLAGS} ) - add_executable(radmon_bcoef.x ${RADMON_BCOEF_SRC} ) - set_target_properties( radmon_bcoef.x PROPERTIES COMPILE_FLAGS ${RADMON_BCOEF_Fortran_FLAGS} ) - set_target_properties( radmon_bcoef.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) - include_directories( ${CORE_INCS} ${NCDIAG_INCS} ) - target_link_libraries( radmon_bcoef.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES} ) - if(BUILD_W3NCO) - add_dependencies( radmon_bcoef.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + bcoef.f90 + create_ctl_bcoef.f90 + kinds.F90 + read_diag.f90 + sparsearr.f90 +) + +add_executable(radmon_bcoef.x ${SRCS}) +if(TARGET ncdiag) + add_dependencies(radmon_bcoef.x ncdiag) +endif() + +target_compile_definitions(radmon_bcoef.x PRIVATE "_REAL8_") +target_link_libraries(radmon_bcoef.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(radmon_bcoef.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(radmon_bcoef.x PRIVATE ncdiag::ncdiag) +target_link_libraries(radmon_bcoef.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS radmon_bcoef.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Radiance_Monitor/nwprod/radmon_shared/sorc/verf_radbcor.fd/CMakeLists.txt b/util/Radiance_Monitor/nwprod/radmon_shared/sorc/verf_radbcor.fd/CMakeLists.txt index 96f5a5839b..4872ecbd35 100644 --- a/util/Radiance_Monitor/nwprod/radmon_shared/sorc/verf_radbcor.fd/CMakeLists.txt +++ b/util/Radiance_Monitor/nwprod/radmon_shared/sorc/verf_radbcor.fd/CMakeLists.txt @@ -1,14 +1,29 @@ -cmake_minimum_required(VERSION 3.16.1) - file(GLOB RADMON_BCOR_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(RADMON_BCOR_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -g -traceback -D_REAL8_ ") - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/radmon_bcor ) - set_source_files_properties( ${RADMON_BCOR_SRC} PROPERTIES COMPILE_FLAGS ${RADMON_BCOR_Fortran_FLAGS} ) - add_executable(radmon_bcor.x ${RADMON_BCOR_SRC} ) - set_target_properties( radmon_bcor.x PROPERTIES COMPILE_FLAGS ${RADMON_BCOR_Fortran_FLAGS} ) - set_target_properties( radmon_bcor.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) - include_directories( ${CORE_INCS} ${NCDIAG_INCS} ) - target_link_libraries( radmon_bcor.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES} ) - if(BUILD_W3NCO) - add_dependencies( radmon_bcor.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + avgsdv.f90 + bcor.f90 + create_ctl_bcor.f90 + kinds.F90 + read_diag.f90 + sparsearr.f90 +) + +add_executable(radmon_bcor.x ${SRCS}) +if(TARGET ncdiag) + add_dependencies(radmon_bcor.x ncdiag) +endif() + +target_compile_definitions(radmon_bcor.x PRIVATE "_REAL8_") +target_link_libraries(radmon_bcor.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(radmon_bcor.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(radmon_bcor.x PRIVATE ncdiag::ncdiag) +target_link_libraries(radmon_bcor.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS radmon_bcor.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Radiance_Monitor/nwprod/radmon_shared/sorc/verf_radtime.fd/CMakeLists.txt b/util/Radiance_Monitor/nwprod/radmon_shared/sorc/verf_radtime.fd/CMakeLists.txt index 9b24fd46b7..93c9518563 100644 --- a/util/Radiance_Monitor/nwprod/radmon_shared/sorc/verf_radtime.fd/CMakeLists.txt +++ b/util/Radiance_Monitor/nwprod/radmon_shared/sorc/verf_radtime.fd/CMakeLists.txt @@ -1,14 +1,32 @@ -cmake_minimum_required(VERSION 3.16.1) - file(GLOB RADMON_TIME_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 ) - set(RADMON_TIME_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -g -traceback -D_REAL8_ ") - set(Util_MODULE_DIR ${PROJECT_BINARY_DIR}/include/radmon_time ) - set_source_files_properties( ${RADMON_TIME_SRC} PROPERTIES COMPILE_FLAGS ${RADMON_TIME_Fortran_FLAGS} ) - add_executable(radmon_time.x ${RADMON_TIME_SRC} ) - set_target_properties( radmon_time.x PROPERTIES COMPILE_FLAGS ${RADMON_TIME_Fortran_FLAGS} ) - set_target_properties( radmon_time.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIR} ) - include_directories( ${CORE_INCS} ${NCDIAG_INCS} ) - target_link_libraries( radmon_time.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES} ) - if(BUILD_W3NCO) - add_dependencies( radmon_time.x ${W3NCO_4_LIBRARY} ) - endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +list(APPEND SRCS + bad_chan.f90 + bad_penalty.f90 + create_ctl_time.f90 + kinds.F90 + low_count.f90 + read_diag.f90 + sparsearr.f90 + time.f90 + valid.f90 +) + +add_executable(radmon_time.x ${SRCS}) +if(TARGET ncdiag) + add_dependencies(radmon_time.x ncdiag) +endif() + +target_compile_definitions(radmon_time.x PRIVATE "_REAL8_") +target_link_libraries(radmon_time.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(radmon_time.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(radmon_time.x PRIVATE ncdiag::ncdiag) +target_link_libraries(radmon_time.x PRIVATE w3emc::w3emc_4) + +# Install executable targets +install(TARGETS radmon_time.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/Single_Observation/CMakeLists.txt b/util/Single_Observation/CMakeLists.txt new file mode 100644 index 0000000000..eb54b0f86f --- /dev/null +++ b/util/Single_Observation/CMakeLists.txt @@ -0,0 +1,12 @@ +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -i4 -r8") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fdefault-real-8") +endif() + +add_executable(makeoneobbufr.x makeoneobbufr.f90) +target_link_libraries(makeoneobbufr.x PRIVATE bufr::bufr_d) + +# Install executable targets +install(TARGETS makeoneobbufr.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + diff --git a/util/bufr_tools/CMakeLists.txt b/util/bufr_tools/CMakeLists.txt index 093c19ea4f..41ed4d4f8e 100644 --- a/util/bufr_tools/CMakeLists.txt +++ b/util/bufr_tools/CMakeLists.txt @@ -1,50 +1,36 @@ -cmake_minimum_required(VERSION 2.6) -# set(CMAKE_Fortran_LIB_DIRECTORY "${PROJECT_BINARY_DIR}/lib") -# - - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - - add_executable(bufr_append_sample.x bufr_append_sample.f90 ) - set_target_properties( bufr_append_sample.x PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - target_link_libraries( bufr_append_sample.x ${BUFR_LIBRARY} ) - - add_executable(bufr_decode_sample.x bufr_decode_sample.f90 ) - set_target_properties( bufr_decode_sample.x PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - target_link_libraries( bufr_decode_sample.x ${BUFR_LIBRARY} ) - - add_executable(bufr_encode_sample.x bufr_encode_sample.f90 ) - set_target_properties( bufr_encode_sample.x PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - target_link_libraries( bufr_encode_sample.x ${BUFR_LIBRARY} ) - - add_executable(bufr_decode_radiance.x bufr_decode_radiance.f90 ) - set_target_properties( bufr_decode_radiance.x PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - target_link_libraries( bufr_decode_radiance.x ${BUFR_LIBRARY} ) - - add_executable(prepbufr_decode_all.x prepbufr_decode_all.f90 ) - set_target_properties( prepbufr_decode_all.x PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - target_link_libraries( prepbufr_decode_all.x ${BUFR_LIBRARY} ) - - add_executable(prepbufr_encode_surface.x prepbufr_encode_surface.f90 ) - set_target_properties( prepbufr_encode_surface.x PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - target_link_libraries( prepbufr_encode_surface.x ${BUFR_LIBRARY} ) - - add_executable(prepbufr_encode_upperair.x prepbufr_encode_upperair.f90 ) - set_target_properties( prepbufr_encode_upperair.x PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - target_link_libraries( prepbufr_encode_upperair.x ${BUFR_LIBRARY} ) - - add_executable(prepbufr_inventory.x prepbufr_inventory.f90 ) - set_target_properties( prepbufr_inventory.x PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - target_link_libraries( prepbufr_inventory.x ${BUFR_LIBRARY} ) - - add_executable(prepbufr_append_retrieve.x prepbufr_append_retrieve.f90 ) - set_target_properties( prepbufr_append_retrieve.x PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - target_link_libraries( prepbufr_append_retrieve.x ${BUFR_LIBRARY} ) - - add_executable(prepbufr_append_surface.x prepbufr_append_surface.f90 ) - set_target_properties( prepbufr_append_surface.x PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - target_link_libraries( prepbufr_append_surface.x ${BUFR_LIBRARY} ) - - add_executable(prepbufr_append_upperair.x prepbufr_append_upperair.f90 ) - set_target_properties( prepbufr_append_upperair.x PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - target_link_libraries( prepbufr_append_upperair.x ${BUFR_LIBRARY} ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() + +add_executable(bufr_append_sample.x bufr_append_sample.f90) +add_executable(bufr_decode_sample.x bufr_decode_sample.f90) +add_executable(bufr_encode_sample.x bufr_encode_sample.f90) +add_executable(bufr_decode_radiance.x bufr_decode_radiance.f90) +add_executable(prepbufr_decode_all.x prepbufr_decode_all.f90) +add_executable(prepbufr_encode_surface.x prepbufr_encode_surface.f90) +add_executable(prepbufr_encode_upperair.x prepbufr_encode_upperair.f90) +add_executable(prepbufr_inventory.x prepbufr_inventory.f90) +add_executable(prepbufr_append_retrieve.x prepbufr_append_retrieve.f90) +add_executable(prepbufr_append_surface.x prepbufr_append_surface.f90) +add_executable(prepbufr_append_upperair.x prepbufr_append_upperair.f90) + +list(APPEND _targets + bufr_append_sample.x + bufr_decode_sample.x + bufr_encode_sample.x + bufr_decode_radiance.x + prepbufr_decode_all.x + prepbufr_encode_surface.x + prepbufr_encode_upperair.x + prepbufr_inventory.x + prepbufr_append_retrieve.x + prepbufr_append_surface.x + prepbufr_append_upperair.x) + +foreach(_tgt ${_targets}) + target_link_libraries(${_tgt} PRIVATE bufr::bufr_d) +endforeach() + +install(TARGETS ${_targets} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/cmake/FindMKL.cmake b/util/cmake/FindMKL.cmake new file mode 100644 index 0000000000..09a1feb7d2 --- /dev/null +++ b/util/cmake/FindMKL.cmake @@ -0,0 +1,91 @@ +# (C) Copyright 2011- ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# 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. + +# - Try to find MKL +# Once done this will define +# +# MKL_FOUND - system has Intel MKL +# MKL_INCLUDE_DIRS - the MKL include directories +# MKL_LIBRARIES - link these to use MKL +# +# The following paths will be searched with priority if set in CMake or env +# +# MKLROOT - root directory of the MKL installation +# MKL_PATH - root directory of the MKL installation +# MKL_ROOT - root directory of the MKL installation + +option( MKL_PARALLEL "if mkl shoudl be parallel" OFF ) + +if( MKL_PARALLEL ) + + set( __mkl_lib_par MKL_LIB_INTEL_THREAD ) + set( __mkl_lib_name mkl_intel_thread ) + + find_package(Threads) + +else() + + set( __mkl_lib_par MKL_LIB_SEQUENTIAL ) + set( __mkl_lib_name mkl_sequential ) + +endif() + +# Search with priority for MKLROOT, MKL_PATH and MKL_ROOT if set in CMake or env +find_path(MKL_INCLUDE_DIR mkl.h + PATHS ${MKLROOT} ${MKL_PATH} ${MKL_ROOT} $ENV{MKLROOT} $ENV{MKL_PATH} $ENV{MKL_ROOT} + PATH_SUFFIXES include NO_DEFAULT_PATH) + +find_path(MKL_INCLUDE_DIR mkl.h + PATH_SUFFIXES include) + +if( MKL_INCLUDE_DIR ) # use include dir to find libs + + set( MKL_INCLUDE_DIRS ${MKL_INCLUDE_DIR} ) + + if( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" ) + set( __pathsuffix "lib/intel64") + set( __libsfx _lp64 ) + else() + set( __pathsuffix "lib/ia32") + set( __libsfx "" ) + endif() + + find_library( MKL_LIB_INTEL + PATHS ${MKLROOT} ${MKL_PATH} ${MKL_ROOT} $ENV{MKLROOT} $ENV{MKL_PATH} $ENV{MKL_ROOT} + PATH_SUFFIXES lib ${__pathsuffix} + NAMES mkl_intel${__libsfx} ) + + find_library( ${__mkl_lib_par} + PATHS ${MKLROOT} ${MKL_PATH} ${MKL_ROOT} $ENV{MKLROOT} $ENV{MKL_PATH} $ENV{MKL_ROOT} + PATH_SUFFIXES lib ${__pathsuffix} + NAMES ${__mkl_lib_name} ) + + find_library( MKL_LIB_CORE + PATHS ${MKLROOT} ${MKL_PATH} ${MKL_ROOT} $ENV{MKLROOT} $ENV{MKL_PATH} $ENV{MKL_ROOT} + PATH_SUFFIXES lib ${__pathsuffix} + NAMES mkl_core ) + + if( MKL_PARALLEL ) + find_library( MKL_LIB_IOMP5 + PATHS ${MKLROOT} ${MKL_PATH} ${MKL_ROOT} $ENV{MKLROOT} $ENV{MKL_PATH} $ENV{MKL_ROOT} + PATH_SUFFIXES lib ${__pathsuffix} + NAMES iomp5 ) + endif() + + if( MKL_LIB_INTEL AND ${__mkl_lib_par} AND MKL_LIB_CORE ) + set( MKL_LIBRARIES ${MKL_LIB_INTEL} ${${__mkl_lib_par}} ${MKL_LIB_CORE} ${MKL_LIB_IOMP5} ${CMAKE_THREAD_LIBS_INIT} ) + endif() + +endif() + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args( MKL DEFAULT_MSG + MKL_LIBRARIES MKL_INCLUDE_DIRS ) + +mark_as_advanced( MKL_INCLUDE_DIR MKL_LIB_LAPACK MKL_LIB_INTEL MKL_LIB_SEQUENTIAL MKL_LIB_CORE ) diff --git a/util/cmake/FindNetCDF.cmake b/util/cmake/FindNetCDF.cmake new file mode 100644 index 0000000000..9e32378ff5 --- /dev/null +++ b/util/cmake/FindNetCDF.cmake @@ -0,0 +1,347 @@ +# (C) Copyright 2011- ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# 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. + +# Try to find NetCDF includes and library. +# Supports static and shared libaries and allows each component to be found in sepearte prefixes. +# +# This module defines +# +# - NetCDF_FOUND - System has NetCDF +# - NetCDF_INCLUDE_DIRS - the NetCDF include directories +# - NetCDF_VERSION - the version of NetCDF +# - NetCDF_CONFIG_EXECUTABLE - the netcdf-config executable if found +# - NetCDF_PARALLEL - Boolean True if NetCDF4 has parallel IO support via hdf5 and/or pnetcdf +# - NetCDF_HAS_PNETCDF - Boolean True if NetCDF4 has pnetcdf support +# +# Deprecated Defines +# - NetCDF_LIBRARIES - [Deprecated] Use NetCDF::NetCDF_ targets instead. +# +# +# Following components are available: +# +# - C - C interface to NetCDF (netcdf) +# - CXX - CXX4 interface to NetCDF (netcdf_c++4) +# - Fortran - Fortran interface to NetCDF (netcdff) +# +# For each component the following are defined: +# +# - NetCDF__FOUND - whether the component is found +# - NetCDF__LIBRARIES - the libraries for the component +# - NetCDF__LIBRARY_SHARED - Boolean is true if libraries for component are shared +# - NetCDF__INCLUDE_DIRS - the include directories for specified component +# - NetCDF::NetCDF_ - target of component to be used with target_link_libraries() +# +# The following paths will be searched in order if set in CMake (first priority) or environment (second priority) +# +# - NetCDF_ROOT - root of NetCDF installation +# - NetCDF_PATH - root of NetCDF installation +# +# The search process begins with locating NetCDF Include headers. If these are in a non-standard location, +# set one of the following CMake or environment variables to point to the location: +# +# - NetCDF_INCLUDE_DIR or NetCDF_${comp}_INCLUDE_DIR +# - NetCDF_INCLUDE_DIRS or NetCDF_${comp}_INCLUDE_DIR +# +# Notes: +# +# - Use "NetCDF::NetCDF_" targets only. NetCDF_LIBRARIES exists for backwards compatibility and should not be used. +# - These targets have all the knowledge of include directories and library search directories, and a single +# call to target_link_libraries will provide all these transitive properties to your target. Normally all that is +# needed to build and link against NetCDF is, e.g.: +# target_link_libraries(my_c_tgt PUBLIC NetCDF::NetCDF_C) +# - "NetCDF" is always the preferred naming for this package, its targets, variables, and environment variables +# - For compatibility, some variables are also set/checked using alternate names NetCDF4, NETCDF, or NETCDF4 +# - Environments relying on these older environment variable names should move to using a "NetCDF_ROOT" environment variable +# - Preferred component capitalization follows the CMake LANGUAGES variables: i.e., C, Fortran, CXX +# - For compatibility, alternate capitalizations are supported but should not be used. +# - If no components are defined, all components will be searched +# + +list( APPEND _possible_components C CXX Fortran ) + +## Include names for each component +set( NetCDF_C_INCLUDE_NAME netcdf.h ) +set( NetCDF_CXX_INCLUDE_NAME netcdf ) +set( NetCDF_Fortran_INCLUDE_NAME netcdf.mod ) + +## Library names for each component +set( NetCDF_C_LIBRARY_NAME netcdf ) +set( NetCDF_CXX_LIBRARY_NAME netcdf_c++4 ) +set( NetCDF_Fortran_LIBRARY_NAME netcdff ) + +## Enumerate search components +foreach( _comp ${_possible_components} ) + string( TOUPPER "${_comp}" _COMP ) + set( _arg_${_COMP} ${_comp} ) + set( _name_${_COMP} ${_comp} ) +endforeach() + +set( _search_components C) +foreach( _comp ${${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS} ) + string( TOUPPER "${_comp}" _COMP ) + set( _arg_${_COMP} ${_comp} ) + list( APPEND _search_components ${_name_${_COMP}} ) + if( NOT _name_${_COMP} ) + message(SEND_ERROR "Find${CMAKE_FIND_PACKAGE_NAME}: COMPONENT ${_comp} is not a valid component. Valid components: ${_possible_components}" ) + endif() +endforeach() +list( REMOVE_DUPLICATES _search_components ) + +## Search hints for finding include directories and libraries +foreach( _comp IN ITEMS "_" "_C_" "_Fortran_" "_CXX_" ) + foreach( _name IN ITEMS NetCDF4 NetCDF NETCDF4 NETCDF ) + foreach( _var IN ITEMS ROOT PATH ) + list(APPEND _search_hints ${${_name}${_comp}${_var}} $ENV{${_name}${_comp}${_var}} ) + list(APPEND _include_search_hints + ${${_name}${_comp}INCLUDE_DIR} $ENV{${_name}${_comp}INCLUDE_DIR} + ${${_name}${_comp}INCLUDE_DIRS} $ENV{${_name}${_comp}INCLUDE_DIRS} ) + endforeach() + endforeach() +endforeach() +#Old-school HPC module env variable names +foreach( _name IN ITEMS NetCDF4 NetCDF NETCDF4 NETCDF ) + foreach( _comp IN ITEMS "_C" "_Fortran" "_CXX" ) + list(APPEND _search_hints ${${_name}} $ENV{${_name}}) + list(APPEND _search_hints ${${_name}${_comp}} $ENV{${_name}${_comp}}) + endforeach() +endforeach() + +## Find headers for each component +set(NetCDF_INCLUDE_DIRS) +set(_new_search_components) +foreach( _comp IN LISTS _search_components ) + if(NOT ${PROJECT_NAME}_NetCDF_${_comp}_FOUND) + list(APPEND _new_search_components ${_comp}) + endif() + find_file(NetCDF_${_comp}_INCLUDE_FILE + NAMES ${NetCDF_${_comp}_INCLUDE_NAME} + DOC "NetCDF ${_comp} include directory" + HINTS ${_include_search_hints} ${_search_hints} + PATH_SUFFIXES include include/netcdf + ) + mark_as_advanced(NetCDF_${_comp}_INCLUDE_FILE) + message(DEBUG "NetCDF_${_comp}_INCLUDE_FILE: ${NetCDF_${_comp}_INCLUDE_FILE}") + if( NetCDF_${_comp}_INCLUDE_FILE ) + get_filename_component(NetCDF_${_comp}_INCLUDE_FILE ${NetCDF_${_comp}_INCLUDE_FILE} ABSOLUTE) + get_filename_component(NetCDF_${_comp}_INCLUDE_DIR ${NetCDF_${_comp}_INCLUDE_FILE} DIRECTORY) + list(APPEND NetCDF_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIR}) + endif() +endforeach() +if(NetCDF_INCLUDE_DIRS) + list(REMOVE_DUPLICATES NetCDF_INCLUDE_DIRS) +endif() +set(NetCDF_INCLUDE_DIRS "${NetCDF_INCLUDE_DIRS}" CACHE STRING "NetCDF Include directory paths" FORCE) + +## Find n*-config executables for search components +foreach( _comp IN LISTS _search_components ) + if( _comp MATCHES "^(C)$" ) + set(_conf "c") + elseif( _comp MATCHES "^(Fortran)$" ) + set(_conf "f") + elseif( _comp MATCHES "^(CXX)$" ) + set(_conf "cxx4") + endif() + find_program( NetCDF_${_comp}_CONFIG_EXECUTABLE + NAMES n${_conf}-config + HINTS ${NetCDF_INCLUDE_DIRS} ${_include_search_hints} ${_search_hints} + PATH_SUFFIXES bin Bin ../bin ../../bin + DOC "NetCDF n${_conf}-config helper" ) + message(DEBUG "NetCDF_${_comp}_CONFIG_EXECUTABLE: ${NetCDF_${_comp}_CONFIG_EXECUTABLE}") +endforeach() + +set(_C_libs_flag --libs) +set(_Fortran_libs_flag --flibs) +set(_CXX_libs_flag --libs) +set(_C_includes_flag --includedir) +set(_Fortran_includes_flag --includedir) +set(_CXX_includes_flag --includedir) +function(netcdf_config exec flag output_var) + set(${output_var} False PARENT_SCOPE) + if( exec ) + execute_process( COMMAND ${exec} ${flag} RESULT_VARIABLE _ret OUTPUT_VARIABLE _val) + if( _ret EQUAL 0 ) + string( STRIP ${_val} _val ) + set( ${output_var} ${_val} PARENT_SCOPE ) + endif() + endif() +endfunction() + +## Detect additional package properties +netcdf_config(${NetCDF_C_CONFIG_EXECUTABLE} --has-parallel4 _val) +if( NOT _val MATCHES "^(yes|no)$" ) + netcdf_config(${NetCDF_C_CONFIG_EXECUTABLE} --has-parallel _val) +endif() +if( _val MATCHES "^(yes)$" ) + set(NetCDF_PARALLEL TRUE CACHE STRING "NetCDF has parallel IO capability via pnetcdf or hdf5." FORCE) +else() + set(NetCDF_PARALLEL FALSE CACHE STRING "NetCDF has no parallel IO capability." FORCE) +endif() + +if(NetCDF_PARALLEL) + find_package(MPI REQUIRED) +endif() + +## Find libraries for each component +set( NetCDF_LIBRARIES ) +foreach( _comp IN LISTS _search_components ) + string( TOUPPER "${_comp}" _COMP ) + + find_library( NetCDF_${_comp}_LIBRARY + NAMES ${NetCDF_${_comp}_LIBRARY_NAME} + DOC "NetCDF ${_comp} library" + HINTS ${NetCDF_${_comp}_INCLUDE_DIRS} ${_search_hints} + PATH_SUFFIXES lib64 lib ../lib64 ../lib ../../lib64 ../../lib ) + mark_as_advanced( NetCDF_${_comp}_LIBRARY ) + get_filename_component(NetCDF_${_comp}_LIBRARY ${NetCDF_${_comp}_LIBRARY} ABSOLUTE) + set(NetCDF_${_comp}_LIBRARY ${NetCDF_${_comp}_LIBRARY} CACHE STRING "NetCDF ${_comp} library" FORCE) + message(DEBUG "NetCDF_${_comp}_LIBRARY: ${NetCDF_${_comp}_LIBRARY}") + + if( NetCDF_${_comp}_LIBRARY ) + if( NetCDF_${_comp}_LIBRARY MATCHES ".a$" ) + set( NetCDF_${_comp}_LIBRARY_SHARED FALSE ) + set( _library_type STATIC) + else() + list( APPEND NetCDF_LIBRARIES ${NetCDF_${_comp}_LIBRARY} ) + set( NetCDF_${_comp}_LIBRARY_SHARED TRUE ) + set( _library_type SHARED) + endif() + endif() + + #Use nc-config to set per-component LIBRARIES variable if possible + netcdf_config( ${NetCDF_${_comp}_CONFIG_EXECUTABLE} ${_${_comp}_libs_flag} _val ) + if( _val ) + set( NetCDF_${_comp}_LIBRARIES ${_val} ) + if(NOT NetCDF_${_comp}_LIBRARY_SHARED AND NOT NetCDF_${_comp}_FOUND) #Static targets should use nc_config to get a proper link line with all necessary static targets. + list( APPEND NetCDF_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) + endif() + else() + set( NetCDF_${_comp}_LIBRARIES ${NetCDF_${_comp}_LIBRARY} ) + if(NOT NetCDF_${_comp}_LIBRARY_SHARED) + message(SEND_ERROR "Unable to properly find NetCDF. Found static libraries at: ${NetCDF_${_comp}_LIBRARY} but could not run nc-config: ${NetCDF_CONFIG_EXECUTABLE}") + endif() + endif() + + #Use nc-config to set per-component INCLUDE_DIRS variable if possible + netcdf_config( ${NetCDF_${_comp}_CONFIG_EXECUTABLE} ${_${_comp}_includes_flag} _val ) + if( _val ) + string( REPLACE " " ";" _val ${_val} ) + set( NetCDF_${_comp}_INCLUDE_DIRS ${_val} ) + else() + set( NetCDF_${_comp}_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIR} ) + endif() + + if( NetCDF_${_comp}_LIBRARIES AND NetCDF_${_comp}_INCLUDE_DIRS ) + set( ${CMAKE_FIND_PACKAGE_NAME}_${_arg_${_COMP}}_FOUND TRUE ) + if (NOT TARGET NetCDF::NetCDF_${_comp}) + add_library(NetCDF::NetCDF_${_comp} ${_library_type} IMPORTED) + set_target_properties(NetCDF::NetCDF_${_comp} PROPERTIES + IMPORTED_LOCATION ${NetCDF_${_comp}_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES "${NetCDF_${_comp}_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) + if( NOT _comp MATCHES "^(C)$" ) + target_link_libraries(NetCDF::NetCDF_${_comp} INTERFACE NetCDF::NetCDF_C) + endif() + if(MPI_${_comp}_FOUND) + target_link_libraries(NetCDF::NetCDF_${_comp} INTERFACE MPI::MPI_${_comp}) + endif() + endif() + endif() +endforeach() +if(NetCDF_LIBRARIES AND NetCDF_${_comp}_LIBRARY_SHARED) + list(REMOVE_DUPLICATES NetCDF_LIBRARIES) +endif() +set(NetCDF_LIBRARIES "${NetCDF_LIBRARIES}" CACHE STRING "NetCDF library targets" FORCE) + +## Find version via netcdf-config if possible +if (NetCDF_INCLUDE_DIRS) + if( NetCDF_C_CONFIG_EXECUTABLE ) + netcdf_config( ${NetCDF_C_CONFIG_EXECUTABLE} --version _vers ) + if( _vers ) + string(REGEX REPLACE ".* ((([0-9]+)\\.)+([0-9]+)).*" "\\1" NetCDF_VERSION "${_vers}" ) + endif() + else() + foreach( _dir IN LISTS NetCDF_INCLUDE_DIRS) + if( EXISTS "${_dir}/netcdf_meta.h" ) + file(STRINGS "${_dir}/netcdf_meta.h" _netcdf_version_lines + REGEX "#define[ \t]+NC_VERSION_(MAJOR|MINOR|PATCH|NOTE)") + string(REGEX REPLACE ".*NC_VERSION_MAJOR *\([0-9]*\).*" "\\1" _netcdf_version_major "${_netcdf_version_lines}") + string(REGEX REPLACE ".*NC_VERSION_MINOR *\([0-9]*\).*" "\\1" _netcdf_version_minor "${_netcdf_version_lines}") + string(REGEX REPLACE ".*NC_VERSION_PATCH *\([0-9]*\).*" "\\1" _netcdf_version_patch "${_netcdf_version_lines}") + string(REGEX REPLACE ".*NC_VERSION_NOTE *\"\([^\"]*\)\".*" "\\1" _netcdf_version_note "${_netcdf_version_lines}") + set(NetCDF_VERSION "${_netcdf_version_major}.${_netcdf_version_minor}.${_netcdf_version_patch}${_netcdf_version_note}") + unset(_netcdf_version_major) + unset(_netcdf_version_minor) + unset(_netcdf_version_patch) + unset(_netcdf_version_note) + unset(_netcdf_version_lines) + endif() + endforeach() + endif() +endif () + +## Finalize find_package +include(FindPackageHandleStandardArgs) + +if(NOT NetCDF_FOUND OR _new_search_components) + find_package_handle_standard_args( ${CMAKE_FIND_PACKAGE_NAME} + REQUIRED_VARS NetCDF_INCLUDE_DIRS NetCDF_LIBRARIES + VERSION_VAR NetCDF_VERSION + HANDLE_COMPONENTS ) +endif() + +foreach( _comp IN LISTS _search_components ) + if( NetCDF_${_comp}_FOUND ) + #Record found components to avoid duplication in NetCDF_LIBRARIES for static libraries + set(NetCDF_${_comp}_FOUND ${NetCDF_${_comp}_FOUND} CACHE BOOL "NetCDF ${_comp} Found" FORCE) + #Set a per-package, per-component found variable to communicate between multiple calls to find_package() + set(${PROJECT_NAME}_NetCDF_${_comp}_FOUND True) + endif() +endforeach() + +if( ${CMAKE_FIND_PACKAGE_NAME}_FOUND AND NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY AND _new_search_components) + message( STATUS "Find${CMAKE_FIND_PACKAGE_NAME} defines targets:" ) + message( STATUS " - NetCDF_VERSION [${NetCDF_VERSION}]") + message( STATUS " - NetCDF_PARALLEL [${NetCDF_PARALLEL}]") + foreach( _comp IN LISTS _new_search_components ) + string( TOUPPER "${_comp}" _COMP ) + message( STATUS " - NetCDF_${_comp}_CONFIG_EXECUTABLE [${NetCDF_${_comp}_CONFIG_EXECUTABLE}]") + if( ${CMAKE_FIND_PACKAGE_NAME}_${_arg_${_COMP}}_FOUND ) + get_filename_component(_root ${NetCDF_${_comp}_INCLUDE_DIR}/.. ABSOLUTE) + if( NetCDF_${_comp}_LIBRARY_SHARED ) + message( STATUS " - NetCDF::NetCDF_${_comp} [SHARED] [Root: ${_root}] Lib: ${NetCDF_${_comp}_LIBRARY} ") + else() + message( STATUS " - NetCDF::NetCDF_${_comp} [STATIC] [Root: ${_root}] Lib: ${NetCDF_${_comp}_LIBRARY} ") + endif() + endif() + endforeach() +endif() + +foreach( _prefix NetCDF NetCDF4 NETCDF NETCDF4 ${CMAKE_FIND_PACKAGE_NAME} ) + set( ${_prefix}_INCLUDE_DIRS ${NetCDF_INCLUDE_DIRS} ) + set( ${_prefix}_LIBRARIES ${NetCDF_LIBRARIES}) + set( ${_prefix}_VERSION ${NetCDF_VERSION} ) + set( ${_prefix}_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_FOUND} ) + set( ${_prefix}_CONFIG_EXECUTABLE ${NetCDF_CONFIG_EXECUTABLE} ) + set( ${_prefix}_PARALLEL ${NetCDF_PARALLEL} ) + + foreach( _comp ${_search_components} ) + string( TOUPPER "${_comp}" _COMP ) + set( _arg_comp ${_arg_${_COMP}} ) + set( ${_prefix}_${_comp}_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_${_arg_comp}_FOUND} ) + set( ${_prefix}_${_COMP}_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_${_arg_comp}_FOUND} ) + set( ${_prefix}_${_arg_comp}_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_${_arg_comp}_FOUND} ) + + set( ${_prefix}_${_comp}_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) + set( ${_prefix}_${_COMP}_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) + set( ${_prefix}_${_arg_comp}_LIBRARIES ${NetCDF_${_comp}_LIBRARIES} ) + + set( ${_prefix}_${_comp}_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIRS} ) + set( ${_prefix}_${_COMP}_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIRS} ) + set( ${_prefix}_${_arg_comp}_INCLUDE_DIRS ${NetCDF_${_comp}_INCLUDE_DIRS} ) + endforeach() +endforeach() diff --git a/util/cmake/gsiutils_compiler_flags.cmake b/util/cmake/gsiutils_compiler_flags.cmake new file mode 100644 index 0000000000..1fe8e99370 --- /dev/null +++ b/util/cmake/gsiutils_compiler_flags.cmake @@ -0,0 +1,27 @@ +if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") + add_definitions(-DNDEBUG) +endif() + +####################################################################################### +# Fortran +####################################################################################### + +if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") + include(gsiutils_compiler_flags_GNU_Fortran) +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") + include(gsiutils_compiler_flags_Intel_Fortran) +else() + message(STATUS "Fortran compiler with ID ${CMAKE_Fortran_COMPILER_ID} will be used with CMake default options") +endif() + +####################################################################################### +# C +####################################################################################### + +if(CMAKE_C_COMPILER_ID MATCHES "GNU") + include(gsiutils_compiler_flags_GNU_C) +elseif(CMAKE_C_COMPILER_ID MATCHES "Intel") + include(gsiutils_compiler_flags_Intel_C) +else() + message(STATUS "C compiler with ID ${CMAKE_C_COMPILER_ID} will be used with CMake default options") +endif() diff --git a/util/cmake/gsiutils_compiler_flags_GNU_C.cmake b/util/cmake/gsiutils_compiler_flags_GNU_C.cmake new file mode 100644 index 0000000000..ed5d63d1de --- /dev/null +++ b/util/cmake/gsiutils_compiler_flags_GNU_C.cmake @@ -0,0 +1,34 @@ +#################################################################### +# FLAGS COMMON TO ALL BUILD TYPES +#################################################################### + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") + +#################################################################### +# RELEASE FLAGS +#################################################################### + +set(CMAKE_C_FLAGS_RELEASE "") + +#################################################################### +# DEBUG FLAGS +#################################################################### + +set(CMAKE_C_FLAGS_DEBUG "-Wall") + +#################################################################### +# LINK FLAGS +#################################################################### + +set(CMAKE_C_LINK_FLAGS "") + +#################################################################### +# FLAGS FOR AUTOPROFILING +#################################################################### + +set(C_AUTOPROFILING_FLAGS "") + +#################################################################### + +# Meaning of flags +# ---------------- diff --git a/util/cmake/gsiutils_compiler_flags_GNU_Fortran.cmake b/util/cmake/gsiutils_compiler_flags_GNU_Fortran.cmake new file mode 100644 index 0000000000..85c24004c9 --- /dev/null +++ b/util/cmake/gsiutils_compiler_flags_GNU_Fortran.cmake @@ -0,0 +1,41 @@ +#################################################################### +# FLAGS COMMON TO ALL BUILD TYPES +#################################################################### + +set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -fbacktrace") + +if(${CMAKE_Fortran_COMPILER_VERSION} VERSION_GREATER_EQUAL 10) + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-argument-mismatch -fallow-invalid-boz") +endif() + +#################################################################### +# RELEASE FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -funroll-all-loops -finline-functions") + +#################################################################### +# DEBUG FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -ggdb -Wall -fcheck=bounds -ffpe-trap=invalid,zero,overflow") + +#################################################################### +# LINK FLAGS +#################################################################### + +set(CMAKE_Fortran_LINK_FLAGS "") + +#################################################################### +# FLAGS FOR AUTOPROFILING +#################################################################### + +set(Fortran_AUTOPROFILING_FLAGS "-finstrument-functions") + +#################################################################### + +# Meaning of flags +# ---------------- +# -fstack-arrays : Allocate automatic arrays on the stack (needs large stacksize!!!) +# -funroll-all-loops : Unroll all loops +# -fcheck=bounds : Bounds checking diff --git a/util/cmake/gsiutils_compiler_flags_Intel_C.cmake b/util/cmake/gsiutils_compiler_flags_Intel_C.cmake new file mode 100644 index 0000000000..ed5d63d1de --- /dev/null +++ b/util/cmake/gsiutils_compiler_flags_Intel_C.cmake @@ -0,0 +1,34 @@ +#################################################################### +# FLAGS COMMON TO ALL BUILD TYPES +#################################################################### + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") + +#################################################################### +# RELEASE FLAGS +#################################################################### + +set(CMAKE_C_FLAGS_RELEASE "") + +#################################################################### +# DEBUG FLAGS +#################################################################### + +set(CMAKE_C_FLAGS_DEBUG "-Wall") + +#################################################################### +# LINK FLAGS +#################################################################### + +set(CMAKE_C_LINK_FLAGS "") + +#################################################################### +# FLAGS FOR AUTOPROFILING +#################################################################### + +set(C_AUTOPROFILING_FLAGS "") + +#################################################################### + +# Meaning of flags +# ---------------- diff --git a/util/cmake/gsiutils_compiler_flags_Intel_Fortran.cmake b/util/cmake/gsiutils_compiler_flags_Intel_Fortran.cmake new file mode 100644 index 0000000000..5325a6ac2c --- /dev/null +++ b/util/cmake/gsiutils_compiler_flags_Intel_Fortran.cmake @@ -0,0 +1,35 @@ +#################################################################### +# FLAGS COMMON TO ALL BUILD TYPES +#################################################################### + +set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS} -g -traceback -implicitnone") + +#################################################################### +# RELEASE FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_RELEASE "-O3") + +#################################################################### +# DEBUG FLAGS +#################################################################### + +set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -fp-model source -debug -ftrapuv -warn all,nointerfaces -check all,noarg_temp_created -fp-stack-check -fstack-protector") + +#################################################################### +# LINK FLAGS +#################################################################### + +set(CMAKE_Fortran_LINK_FLAGS "") + +#################################################################### +# FLAGS FOR AUTOPROFILING +#################################################################### + +set(Fortran_AUTOPROFILING_FLAGS "-finstrument-functions") + +#################################################################### + +# Meaning of flags +# ---------------- +# todo diff --git a/util/ndate/CMakeLists.txt b/util/ndate/CMakeLists.txt deleted file mode 100644 index 70b3d1ad3c..0000000000 --- a/util/ndate/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -cmake_minimum_required(VERSION 2.6) - - set( NDATE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/ndate.f ) - set_source_files_properties( ${NDATE_SRC} PROPERTIES COMPILE_FLAGS ${NDATE_Fortran_FLAGS} ) - - add_executable( ndate.x ${NDATE_SRC} ) - target_link_libraries( ndate.x ${W3NCO_4_LIBRARY} ) - diff --git a/util/ndate/ndate.f b/util/ndate/ndate.f deleted file mode 100644 index 8f02a738b3..0000000000 --- a/util/ndate/ndate.f +++ /dev/null @@ -1,147 +0,0 @@ - PROGRAM NDATE -C$$$ MAIN PROGRAM DOCUMENTATION BLOCK -C -C MAIN PROGRAM: NDATE COMPUTE VERIFYING DATE -C PRGMMR: IREDELL ORG: NP23 DATE: 1998-08-18 -C -C ABSTRACT: PROGRAM TO COMPUTE VERIFYING DATE -C GIVEN THE FORECAST HOUR AND THE INITIAL DATE. -C -C PROGRAM HISTORY LOG: -C 95-02-28 IREDELL -C 97-09-22 IREDELL 4-DIGIT YEAR ALLOWED; 2-DIGIT YEAR STANDARDIZED -C 98-03-25 IREDELL 4-DIGIT YEAR FOR ALL DATES. A 2-DIGIT YEAR WILL -C BE INTERPRETED AS A YEAR IN THE FIRST CENTURY -C WHICH SHOULD BE ALL RIGHT BEFORE THE YEAR 2000. -C STANDARD ERROR WARNINGS WILL BE GIVEN FOR SUCH -C DATES UNTIL 1 SEPT 1998 AFTER WHICH NDATE ABORTS. -C NDATE WILL ALSO ABORT AFTER 1 SEPT 1998 IF THE -C NOW IRRELEVANT -Y OPTION IS INVOKED. -C THE NEW Y2K-COMPLIANT W3LIB PACKAGE IS USED. -C 1998-08-17 IREDELL DROP-DEAD DATE RESET TO 1 SEPT 1999 -C 1999-01-26 VUONG CHANGED TO USE 4-DIGIT YEAR AS STANDARDIZED FOR -C ALL DATES AND CONVERTED TO IBM RS/6000 SP AND -C MODIFIED PROGRAM TO CALL ROUTINE GETARG INSTEAD OF -C USING SUBROUTINE GETARG AS A FUNCTION. -C 1999-09-02 IREDELL UNDID RESTRICTION ON FORECAST HOUR -C -C USAGE: ndate [fhour [idate]] -C INPUT ARGUMENT LIST -C FHOUR - FORECAST HOUR (MAY BE NEGATIVE) -C FHOUR DEFAULTS TO ZERO. -C IDATE - INITIAL DATE IN YYYYMMDDHH FORMAT. -C IDATE DEFAULTS TO THE CURRENT UTC DATE AND HOUR. -C FIRST CENTURY DATES WILL CAUSE ABORT AFTER 1 SEPT 1999. -C OUTPUT ARGUMENT LIST: -C NDATE - VERIFYING DATE IN YYYYMMDDHH FORMAT. -C EXIT STATES: -C 0 - SUCCESS -C 1 - FAILURE; INVALID ARGUMENT -C 2 - FAILURE; INCORRECT NUMBER OF ARGUMENTS -C -C SUBPROGRAMS CALLED: -C IARGC GET NUMBER OF ARGUMENTS -C GETARG GET ARGUMENT -C W3DIFDAT RETURN A TIME INTERVAL BETWEEN TWO DATES -C W3MOVDAT RETURN A DATE FROM A TIME INTERVAL AND DATE -C W3PRADAT FORMAT A DATE AND TIME INTO CHARACTERS -C W3UTCDAT RETURN THE UTC DATE AND TIME -C ERRMSG WRITE A MESSAGE TO STDERR -C EXIT EXIT PROGRAM -C -C ATTRIBUTES: -C LANGUAGE: FORTRAN 90 -C -C$$$ - CHARACTER*256 CARG,CFMT - INTEGER*4 IARG,LARG,NCARG,NARG,IARGC - INTEGER IDAT(8),JDAT(8) - REAL RINC(5) - LOGICAL W3VALDAT -C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -C GET AND CHECK OPTIONAL ARGUMENTS - NARG=IARGC() - IARG=1 - LSTOPT=0 - DOWHILE(IARG.LE.NARG.AND.LSTOPT.EQ.0) - CALL GETARG(IARG,CARG) - LARG=LEN_TRIM(CARG) - IARG=IARG+1 - IF(CARG(1:1).NE.'-'.OR. - & (CARG(2:2).GE.'0'.AND.CARG(2:2).LE.'9')) THEN - LSTOPT=1 - IARG=IARG-1 - ELSEIF(LARG.EQ.1) THEN - CALL ERRMSG('ndate: Invalid option -') - CALL EUSAGE - CALL ERREXIT(1) - ELSE - L=2 - DOWHILE(L.LE.LARG) - IF(CARG(L:L).EQ.'-') THEN - LSTOPT=1 - ELSE - CALL ERRMSG('ndate: Invalid option '//CARG(L:L)) - CALL EUSAGE - CALL ERREXIT(1) - ENDIF - L=L+1 - ENDDO - ENDIF - ENDDO -C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -C CHECK NUMBER OF ARGUMENTS - MARG=NARG-IARG+1 - IF(MARG.GT.2) THEN - CALL ERRMSG('ndate: Incorrect number of arguments') - CALL EUSAGE - CALL ERREXIT(2) - ENDIF -C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -C GET AND CHECK FIRST ARGUMENT (HOUR INCREMENT) - IF(MARG.GE.1) THEN - CALL GETARG(IARG,CARG) - NCARG=LEN_TRIM(CARG) - WRITE(CFMT,'("(I",I2,")")') NCARG - READ(CARG,CFMT,IOSTAT=IRET) IHOUR - IF(IRET.NE.0) THEN - CALL ERRMSG('ndate: Noninteger forecast hour '//CARG(1:NCARG)) - CALL EUSAGE - CALL ERREXIT(1) - ENDIF - ELSE - IHOUR=0 - ENDIF - RINC=0 - RINC(2)=IHOUR -C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -C GET AND CHECK SECOND ARGUMENT (INITIAL DATE) - IF(MARG.GE.2) THEN - CALL GETARG(IARG+1,CARG) - NCARG=LEN_TRIM(CARG) - WRITE(CFMT,'("(I",I2,",3I2)")') NCARG-6 - IDAT=0 - READ(CARG,CFMT,IOSTAT=IRET) IDAT(1),IDAT(2),IDAT(3),IDAT(5) - IF(IRET.NE.0.OR..NOT.W3VALDAT(IDAT)) THEN - CALL ERRMSG('ndate: Invalid date '//CARG(1:NCARG)) - CALL EUSAGE - CALL ERREXIT(1) - ENDIF - ELSE - CALL W3UTCDAT(IDAT) - ENDIF -C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -C COMPUTE AND PRINT NEW DATE - CALL W3MOVDAT(RINC,IDAT,JDAT) - ND=LOG10(JDAT(1)+0.5)+1 - WRITE(CFMT,'("(I",I2,",3I2.2)")') ND - PRINT CFMT,JDAT(1),JDAT(2),JDAT(3),JDAT(5) -C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CONTAINS -C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -C WRITE USAGE - SUBROUTINE EUSAGE - CALL ERRMSG('Usage: ndate [fhour [idate]]') - ENDSUBROUTINE -C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ENDPROGRAM diff --git a/util/netcdf_io/CMakeLists.txt b/util/netcdf_io/CMakeLists.txt index d6c1baa5c7..1a35d90a46 100644 --- a/util/netcdf_io/CMakeLists.txt +++ b/util/netcdf_io/CMakeLists.txt @@ -1,23 +1,2 @@ -cmake_minimum_required(VERSION 3.16.1) -MACRO(SUBDIRLIST result curdir) - FILE(GLOB children RELATIVE ${curdir} ${curdir}/*.fd) - SET(dirlist "") - FOREACH(child ${children}) - IF(IS_DIRECTORY ${curdir}/${child}) - LIST(APPEND dirlist ${child}) - ENDIF() - ENDFOREACH() - SET(${result} ${dirlist}) -ENDMACRO() - -if(BUILD_NCIO_UTIL) - set(CMAKE_Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/util/include") - set(UTIL_INC ${CMAKE_Fortran_MODULE_DIRECTORY}) - - SUBDIRLIST(SUBDIRS ${CMAKE_CURRENT_SOURCE_DIR}) - foreach(dir ${SUBDIRS}) - message("Configuring utility in ${dir}") - add_subdirectory(${dir}) - endforeach() -endif(BUILD_NCIO_UTIL) - +add_subdirectory(calc_analysis.fd) +add_subdirectory(interp_inc.fd) diff --git a/util/netcdf_io/calc_analysis.fd/CMakeLists.txt b/util/netcdf_io/calc_analysis.fd/CMakeLists.txt index d324a1b360..7ebe050985 100644 --- a/util/netcdf_io/calc_analysis.fd/CMakeLists.txt +++ b/util/netcdf_io/calc_analysis.fd/CMakeLists.txt @@ -1,13 +1,23 @@ -cmake_minimum_required(VERSION 3.16.1) -if(BUILD_NCIO_UTIL) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - - set(Util_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include/calc_analysis") - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - add_executable(calc_analysis.x ${LOCAL_SRC} ) - set_target_properties( calc_analysis.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - set_target_properties( calc_analysis.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIRECTORY} ) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - include_directories( ${UTIL_INC} ${NEMSIOINC} ${NETCDF_INCLUDE_DIRS} ${MPI_Fortran_INCLUDE_PATH} ${FV3GFS_NCIO_INCS}) - target_link_libraries( calc_analysis.x ${FV3GFS_NCIO_LIBRARIES} ${NEMSIO_LIBRARY} ${BACIO_LIBRARY} ${W3NCO_4_LIBRARY} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES} ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") endif() + +list(APPEND SRCS + inc2anl.f90 + init_calc_analysis.f90 + init_io.f90 + main.f90 + vars_calc_analysis.f90) + +add_executable(calc_analysis.x ${SRCS}) +target_link_libraries(calc_analysis.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(calc_analysis.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(calc_analysis.x PRIVATE bacio::bacio_4) +target_link_libraries(calc_analysis.x PRIVATE nemsio::nemsio) +target_link_libraries(calc_analysis.x PRIVATE ncio::ncio) +target_link_libraries(calc_analysis.x PRIVATE w3emc::w3emc_d) + +# Install executable targets +install(TARGETS calc_analysis.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/netcdf_io/calc_analysis.fd/inc2anl.f90 b/util/netcdf_io/calc_analysis.fd/inc2anl.f90 index f18aace835..0ec6fa7bed 100644 --- a/util/netcdf_io/calc_analysis.fd/inc2anl.f90 +++ b/util/netcdf_io/calc_analysis.fd/inc2anl.f90 @@ -81,7 +81,7 @@ subroutine close_files ! close netCDF files before ending program !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! use vars_calc_analysis, only: fcstncfile, anlncfile - use module_fv3gfs_ncio, only: close_dataset + use module_ncio, only: close_dataset implicit none call close_dataset(fcstncfile) @@ -99,7 +99,7 @@ subroutine copy_ges_to_anl(varname) use vars_calc_analysis, only: fcstncfile, anlncfile, & nlat, nlon, nlev, anlfile, use_nemsio_anl, & mype, levpe - use module_fv3gfs_ncio, only: Dataset, read_vardata, write_vardata, & + use module_ncio, only: Dataset, read_vardata, write_vardata, & open_dataset, close_dataset, has_var use nemsio_module implicit none @@ -176,7 +176,7 @@ subroutine add_increment(fcstvar, incvar) use vars_calc_analysis, only: fcstncfile, anlncfile, incr_file,& nlat, nlon, nlev, anlfile, use_nemsio_anl, & levpe, mype - use module_fv3gfs_ncio, only: Dataset, read_vardata, write_vardata, & + use module_ncio, only: Dataset, read_vardata, write_vardata, & open_dataset, close_dataset, has_var use nemsio_module implicit none @@ -232,7 +232,7 @@ subroutine add_psfc_increment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! use vars_calc_analysis, only: fcstncfile, anlncfile, nlat, nlon, incr_file,& use_nemsio_anl, anlfile, nlev - use module_fv3gfs_ncio, only: Dataset, open_dataset, close_dataset,& + use module_ncio, only: Dataset, open_dataset, close_dataset,& read_vardata, write_vardata, read_attribute use nemsio_module implicit none diff --git a/util/netcdf_io/calc_analysis.fd/init_io.f90 b/util/netcdf_io/calc_analysis.fd/init_io.f90 index aa7e0f10c7..dbc6885f3c 100644 --- a/util/netcdf_io/calc_analysis.fd/init_io.f90 +++ b/util/netcdf_io/calc_analysis.fd/init_io.f90 @@ -26,7 +26,7 @@ subroutine init_read_bg idate6, nlon, nlat, nlev, & use_nemsio_anl, lats, lons, vcoord, & mype, npes, levpe - use module_fv3gfs_ncio, only: Dimension, open_dataset, get_dim,& + use module_ncio, only: Dimension, open_dataset, get_dim,& get_idate_from_time_units, & read_vardata, read_attribute implicit none @@ -84,7 +84,7 @@ subroutine init_write_anl fhr, nfhour, nfminute, nfsecondn, nfsecondd,& use_nemsio_anl, anlncfile, fcstncfile,& nlon, nlat, nlev, lats, lons, vcoord, mype - use module_fv3gfs_ncio, only: create_dataset, get_time_units_from_idate,& + use module_ncio, only: create_dataset, get_time_units_from_idate,& write_vardata, write_attribute use netcdf, only: nf90_max_name use nemsio_module diff --git a/util/netcdf_io/calc_analysis.fd/vars_calc_analysis.f90 b/util/netcdf_io/calc_analysis.fd/vars_calc_analysis.f90 index 770783ebb0..c02ffd5aee 100644 --- a/util/netcdf_io/calc_analysis.fd/vars_calc_analysis.f90 +++ b/util/netcdf_io/calc_analysis.fd/vars_calc_analysis.f90 @@ -9,7 +9,7 @@ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! module vars_calc_analysis use nemsio_module, only: nemsio_gfile - use module_fv3gfs_ncio, only: Dataset + use module_ncio, only: Dataset implicit none private diff --git a/util/netcdf_io/interp_inc.fd/CMakeLists.txt b/util/netcdf_io/interp_inc.fd/CMakeLists.txt index d46315454a..1c2d5af1d9 100644 --- a/util/netcdf_io/interp_inc.fd/CMakeLists.txt +++ b/util/netcdf_io/interp_inc.fd/CMakeLists.txt @@ -1,13 +1,16 @@ -cmake_minimum_required(VERSION 3.16.1) -if(BUILD_NCIO_UTIL) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - - set(Util_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include/interp_inc") - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - add_executable(interp_inc.x ${LOCAL_SRC} ) - set_target_properties( interp_inc.x PROPERTIES COMPILE_FLAGS ${UTIL_Fortran_FLAGS} ) - set_target_properties( interp_inc.x PROPERTIES Fortran_MODULE_DIRECTORY ${Util_MODULE_DIRECTORY} ) - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_Fortran_FLAGS}" ) - include_directories( ${UTIL_INC} ${NETCDF_INCLUDE_DIRS} ${MPI_Fortran_INCLUDE_PATH}) - target_link_libraries( interp_inc.x ${W3NCO_4_LIBRARY} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES} ${IP_LIBRARY} ${SP_LIBRARY}) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") endif() + +add_executable(interp_inc.x driver.f90) +target_link_libraries(interp_inc.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(interp_inc.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(interp_inc.x PRIVATE w3emc::w3emc_d) +target_link_libraries(interp_inc.x PRIVATE ip::ip_d) +target_link_libraries(interp_inc.x PRIVATE sp::sp_d) + +# Install executable targets +install(TARGETS interp_inc.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + diff --git a/util/netcdf_io/interp_inc.fd/driver.f90 b/util/netcdf_io/interp_inc.fd/driver.f90 index 52c140408c..d211153f30 100644 --- a/util/netcdf_io/interp_inc.fd/driver.f90 +++ b/util/netcdf_io/interp_inc.fd/driver.f90 @@ -31,7 +31,7 @@ program interp_inc ! Declare externals external :: w3tagb, netcdf_err, splat, ipolatev, & - mpi_send, ipolates, mpi_recv, w3tage + ipolates, w3tage character(len=128) :: outfile, infile character(len=11) :: records(num_recs) diff --git a/util/radar_process/CMakeLists.txt b/util/radar_process/CMakeLists.txt new file mode 100644 index 0000000000..27b86b61ba --- /dev/null +++ b/util/radar_process/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory(radialwind) +add_subdirectory(reflectivity) diff --git a/util/radar_process/radialwind/CMakeLists.txt b/util/radar_process/radialwind/CMakeLists.txt index cf5069b6bd..e32fb89025 100644 --- a/util/radar_process/radialwind/CMakeLists.txt +++ b/util/radar_process/radialwind/CMakeLists.txt @@ -1,17 +1,20 @@ -cmake_minimum_required(VERSION 2.6) -# set(CMAKE_Fortran_LIB_DIRECTORY "${PROJECT_BINARY_DIR}/lib") -# - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() - add_executable(bufr_decode_l2rwbufr.x bufr_decode_l2rwbufr.f90 ) - set_target_properties( bufr_decode_l2rwbufr.x PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - target_link_libraries( bufr_decode_l2rwbufr.x ${BUFR_LIBRARY} ) +add_executable(bufr_decode_l2rwbufr.x bufr_decode_l2rwbufr.f90) +add_executable(bufr_encode_l2rwbufr.x bufr_encode_l2rwbufr.f90) +add_executable(bufr_encode_radarbufr.x bufr_encode_radarbufr.f90) - add_executable(bufr_encode_l2rwbufr.x bufr_encode_l2rwbufr.f90 ) - set_target_properties( bufr_encode_l2rwbufr.x PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - target_link_libraries( bufr_encode_l2rwbufr.x ${BUFR_LIBRARY} ) +list(APPEND _targets + bufr_decode_l2rwbufr.x + bufr_encode_l2rwbufr.x + bufr_encode_radarbufr.x) - add_executable(bufr_encode_radarbufr.x bufr_encode_radarbufr.f90 ) - set_target_properties( bufr_encode_radarbufr.x PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - target_link_libraries( bufr_encode_radarbufr.x ${BUFR_LIBRARY} ) +foreach(_tgt ${_targets}) + target_link_libraries(${_tgt} PRIVATE bufr::bufr_d) +endforeach() + +install(TARGETS ${_targets} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/radar_process/reflectivity/CMakeLists.txt b/util/radar_process/reflectivity/CMakeLists.txt index 85922a290e..7ede68d2a0 100644 --- a/util/radar_process/reflectivity/CMakeLists.txt +++ b/util/radar_process/reflectivity/CMakeLists.txt @@ -1,9 +1,21 @@ -cmake_minimum_required(VERSION 2.6) - file(GLOB LOCAL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.f90) - set_source_files_properties( ${LOCAL_SRC} PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - include_directories( ${NETCDF_INCLUDE_DIRS} ${MPI_Fortran_INCLUDE_PATH} ) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() - add_executable(process_NSSL_mosaic.x ${LOCAL_SRC} ) - add_dependencies(process_NSSL_mosaic.x ${GSILIB} ${GSISHAREDLIB} ) - set_target_properties( process_NSSL_mosaic.x PROPERTIES COMPILE_FLAGS ${UTIL_COM_Fortran_FLAGS} ) - target_link_libraries( process_NSSL_mosaic.x ${GSISHAREDLIB} ${BUFR_LIBRARY} ${NETCDF_Fortran_LIBRARIES} ${NETCDF_C_LIBRARIES} ${MPI_Fortran_LIBRARIES} ) +list(APPEND SRCS + kinds.F90 + nc_subs.f90 + process_NSSL_mosaic.f90 + read_nssl_binary.f90 + write_bufr_ref.f90) + +# Create process_NSSL_mosaic.x executable +add_executable(process_NSSL_mosaic.x ${SRCS}) +target_link_libraries(process_NSSL_mosaic.x PRIVATE NetCDF::NetCDF_Fortran) +target_link_libraries(process_NSSL_mosaic.x PRIVATE MPI::MPI_Fortran) +target_link_libraries(process_NSSL_mosaic.x PRIVATE bufr::bufr_d) + +# Install executable targets +install(TARGETS process_NSSL_mosaic.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/util/radar_process/reflectivity/kinds.F90 b/util/radar_process/reflectivity/kinds.F90 new file mode 100644 index 0000000000..ac3a0903bf --- /dev/null +++ b/util/radar_process/reflectivity/kinds.F90 @@ -0,0 +1,39 @@ +module kinds +! Stripped down version of gsi/kinds.F90 for this utility +! This is to avoid building and depending on the entire GSI compiled library + implicit none + + public i_kind, i_byte, i_short, i_long, i_llong + public r_kind, r_single, r_double, r_quad + + private + integer, parameter :: default_integer = 3 ! 1=byte, + ! 2=short, + ! 3=long, + ! 4=llong + integer, parameter :: i_byte = selected_int_kind(1) ! byte integer + integer, parameter :: i_short = selected_int_kind(4) ! short integer + integer, parameter :: i_long = selected_int_kind(8) ! long integer + integer, parameter :: llong_t = selected_int_kind(16) ! llong integer + integer, parameter :: i_llong = max( llong_t, i_long ) + integer, parameter, dimension(4) :: integer_types = (/ & + i_byte, i_short, i_long, i_llong /) + integer, parameter :: i_kind = integer_types( default_integer ) + +#ifdef _REAL4_ + integer, parameter :: default_real = 1 ! 1=single +#elseif _REAL8_ + integer, parameter :: default_real = 2 ! 2=double +#elseif _REAL16_ + integer, parameter :: default_real = 3 ! 3=quad +#else + integer, parameter :: default_real = 1 ! 1=single +#endif + integer, parameter :: r_single = selected_real_kind(6) ! single precision + integer, parameter :: r_double = selected_real_kind(15) ! double precision + integer, parameter :: quad_t = selected_real_kind(20) ! quad precision + integer, parameter :: r_quad = max( quad_t, r_double ) + integer, parameter, dimension(3) :: & + real_kinds = (/ r_single, r_double, r_quad /) + integer, parameter :: r_kind = real_kinds( default_real ) +end module kinds diff --git a/util/radar_process/reflectivity/write_bufr_ref.f90 b/util/radar_process/reflectivity/write_bufr_ref.f90 index 08a3c1784a..d9874729e8 100644 --- a/util/radar_process/reflectivity/write_bufr_ref.f90 +++ b/util/radar_process/reflectivity/write_bufr_ref.f90 @@ -18,10 +18,11 @@ subroutine write_bufr_nsslref(maxlvl,nlon,nlat,numref,ref3d_column,idate) ! machine: linux ! !$$$ - use constants, only: zero, one use kinds, only: r_kind,i_kind implicit none + real(r_kind), parameter :: zero = 0.0_r_kind + real(r_kind), parameter :: one = 1.0_r_kind REAL(r_kind) :: ref3d_column(maxlvl+2,nlon*nlat) ! 3D reflectivity in column real(r_kind) :: hdr(5),obs(1,35) character(80):: hdrstr='SID XOB YOB DHR TYP' diff --git a/util/zero_biascoeff/CMakeLists.txt b/util/zero_biascoeff/CMakeLists.txt index 066397f6ea..deeba6732b 100644 --- a/util/zero_biascoeff/CMakeLists.txt +++ b/util/zero_biascoeff/CMakeLists.txt @@ -1,30 +1,10 @@ -# Setup the minimum version required of CMake to generate the Makefile -# Raises a FATAL_ERROR if version < 2.8 -cmake_minimum_required (VERSION 2.8 FATAL_ERROR) +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -convert big_endian") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4") +endif() -# Project name and LANGUAGE -project (zero_biascoeff Fortran) +add_executable(zero_biascoeff.x zero_biascoeff.f90) -# Where are the additional libraries installed? Note: provide includes -# path here, subsequent checks will resolve everything else -set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMake/modules/" ) - -# Fortran compiler flags -if (CMAKE_Fortran_COMPILER_ID STREQUAL Intel) - set(CMAKE_Fortran_FLAGS "-g -C -traceback -warn all") -elseif (CMAKE_Fortran_COMPILER_ID STREQUAL GNU) - set(CMAKE_Fortran_FLAGS "-g -W -fbounds-check -fbacktrace") -elseif (CMAKE_Fortran_COMPILER_ID STREQUAL Cray) - set(CMAKE_Fortran_FLAGS "-g -check all -traceback -warn") -else (CMAKE_Fortran_COMPILER_ID STREQUAL Intel) - message(FATAL_ERROR "Unsupported compiler ${CMAKE_Fortran_COMPILER_ID}, Abort!") -endif (CMAKE_Fortran_COMPILER_ID STREQUAL Intel) - -# Lists -# Setup the list of source files -set( ZERO_BIASCOEFF_SOURCES - zero_biascoeff.f90 -) - -# ${PROJECT_NAME} refers to Learn_CMake -add_executable( ${PROJECT_NAME}.x ${ZERO_BIASCOEFF_SOURCES} ) +# Install executable targets +install(TARGETS zero_biascoeff.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})