From c08871c4fdb8474a53ef00c64f262ba11c542581 Mon Sep 17 00:00:00 2001 From: "denise.worthen" Date: Wed, 2 Sep 2020 16:51:15 -0400 Subject: [PATCH 1/9] add tripoletools folder with 3 submodules 1) CICE5_ICgen: grid generation for cice5/cice6 2) CICE5_gridgen: initial condition generation for cice5/cice6 3) WeightGen: weight generation for: a) gen_fixgrid and associated fortran code: a fortran routine to read the MOM6 supergrid and create a netcdf file which is the basis for the remaining transformations b) generate_icocn_weights.ncl: esmf weight generation for tripole:tripole or tripole:rectilinear or other grid:grid transformations c) generate_icemesh.ncl: generation of the ice_mesh for use by the CMEPS mediator d) generate_frac_land_weights.sh: generation of the frac_land weights (the ocean mask on the fv3 grid) using ESMF_RegridWeightGen d) cmake_frac_land.ncl: creation of the 6-tiled land_frac files --- .gitmodules | 9 +++++++++ tripoletools/CICE5_ICgen | 1 + tripoletools/CICE5_gridgen | 1 + tripoletools/WeightGen | 1 + 4 files changed, 12 insertions(+) create mode 160000 tripoletools/CICE5_ICgen create mode 160000 tripoletools/CICE5_gridgen create mode 160000 tripoletools/WeightGen diff --git a/.gitmodules b/.gitmodules index 5efb05cac..0312e81d4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,3 +2,12 @@ path = cmake url = https://github.com/NOAA-EMC/CMakeModules branch = develop +[submodule "tripoletools/CICE5_gridgen"] + path = tripoletools/CICE5_gridgen + url = https://github.com/DeniseWorthen/CICE5_gridgen +[submodule "tripoletools/CICE5_ICgen"] + path = tripoletools/CICE5_ICgen + url = https://github.com/DeniseWorthen/CICE5_ICgen.git +[submodule "tripoletools/WeightGen"] + path = tripoletools/WeightGen + url = https://github.com/DeniseWorthen/WeightGen.git diff --git a/tripoletools/CICE5_ICgen b/tripoletools/CICE5_ICgen new file mode 160000 index 000000000..a4902299b --- /dev/null +++ b/tripoletools/CICE5_ICgen @@ -0,0 +1 @@ +Subproject commit a4902299be94c9b1121e4bdab9a0378127829f5a diff --git a/tripoletools/CICE5_gridgen b/tripoletools/CICE5_gridgen new file mode 160000 index 000000000..dc8e54f0e --- /dev/null +++ b/tripoletools/CICE5_gridgen @@ -0,0 +1 @@ +Subproject commit dc8e54f0e0f7046f86f0ab24631b967a3d4e2f64 diff --git a/tripoletools/WeightGen b/tripoletools/WeightGen new file mode 160000 index 000000000..e67cba325 --- /dev/null +++ b/tripoletools/WeightGen @@ -0,0 +1 @@ +Subproject commit e67cba3251c6730b97beef33e45fb758d41ce8ed From 393b5e4aac762575dbeee9292959ea2cf2baaee9 Mon Sep 17 00:00:00 2001 From: "denise.worthen" Date: Wed, 5 Jan 2022 15:43:34 -0500 Subject: [PATCH 2/9] remove tripoletools subdirectory --- tripoletools/CICE5_ICgen | 1 - tripoletools/CICE5_gridgen | 1 - tripoletools/WeightGen | 1 - 3 files changed, 3 deletions(-) delete mode 160000 tripoletools/CICE5_ICgen delete mode 160000 tripoletools/CICE5_gridgen delete mode 160000 tripoletools/WeightGen diff --git a/tripoletools/CICE5_ICgen b/tripoletools/CICE5_ICgen deleted file mode 160000 index a4902299b..000000000 --- a/tripoletools/CICE5_ICgen +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a4902299be94c9b1121e4bdab9a0378127829f5a diff --git a/tripoletools/CICE5_gridgen b/tripoletools/CICE5_gridgen deleted file mode 160000 index dc8e54f0e..000000000 --- a/tripoletools/CICE5_gridgen +++ /dev/null @@ -1 +0,0 @@ -Subproject commit dc8e54f0e0f7046f86f0ab24631b967a3d4e2f64 diff --git a/tripoletools/WeightGen b/tripoletools/WeightGen deleted file mode 160000 index e67cba325..000000000 --- a/tripoletools/WeightGen +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e67cba3251c6730b97beef33e45fb758d41ce8ed From 1033db65d90dbf58c99dbf9940d7ad716ffa0a8b Mon Sep 17 00:00:00 2001 From: "denise.worthen" Date: Fri, 20 Jan 2023 14:07:35 -0500 Subject: [PATCH 3/9] remove Modules subdir --- cmake/LICENSE.md | 157 -- cmake/Modules/FindESMF.cmake | 105 -- cmake/Modules/FindG2C.cmake | 6 - cmake/Modules/FindGEMPAK.cmake | 7 - cmake/Modules/FindGSICONTROL.cmake | 53 - cmake/Modules/FindNDATE.cmake | 14 - cmake/Modules/FindNetCDF.cmake | 337 ---- cmake/Modules/FindWGRIB2.cmake | 26 - cmake/Modules/Findbacio.cmake | 32 - cmake/Modules/Findbufr.cmake | 34 - cmake/Modules/Findcrtm.cmake | 27 - cmake/Modules/Findg2.cmake | 34 - cmake/Modules/Findg2tmpl.cmake | 29 - cmake/Modules/Findgfsio.cmake | 32 - cmake/Modules/Findip.cmake | 37 - cmake/Modules/Findlandsfcutil.cmake | 36 - cmake/Modules/Findnemsio.cmake | 28 - cmake/Modules/Findnemsiogfs.cmake | 28 - cmake/Modules/Findpost.cmake | 20 - cmake/Modules/Findsfcio.cmake | 32 - cmake/Modules/Findsigio.cmake | 32 - cmake/Modules/Findsp.cmake | 33 - cmake/Modules/Findw3emc.cmake | 38 - cmake/Modules/Findw3nco.cmake | 32 - .../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/comp_src.pl | 15 - cmake/Modules/findHelpers.cmake | 65 - cmake/Modules/platforms/Cheyenne.cmake | 24 - cmake/Modules/platforms/Discover.cmake | 55 - cmake/Modules/platforms/Gaea.cmake | 14 - cmake/Modules/platforms/Generic.cmake | 14 - cmake/Modules/platforms/Generic.cmake.orig | 25 - cmake/Modules/platforms/Hera.cmake | 42 - cmake/Modules/platforms/Jet.cmake | 10 - cmake/Modules/platforms/S4.cmake | 10 - cmake/Modules/platforms/WCOSS-C.cmake | 60 - cmake/Modules/platforms/WCOSS-D.cmake | 51 - cmake/Modules/platforms/WCOSS.cmake | 61 - cmake/Modules/setGNUFlags.cmake | 62 - cmake/Modules/setHOST.cmake | 85 - cmake/Modules/setIntelFlags.cmake | 87 - cmake/Modules/setPGIFlags.cmake | 78 - cmake/Modules/setPlatformVariables.cmake | 10 - 54 files changed, 5022 deletions(-) delete mode 100644 cmake/LICENSE.md delete mode 100644 cmake/Modules/FindESMF.cmake delete mode 100644 cmake/Modules/FindG2C.cmake delete mode 100644 cmake/Modules/FindGEMPAK.cmake delete mode 100644 cmake/Modules/FindGSICONTROL.cmake delete mode 100644 cmake/Modules/FindNDATE.cmake delete mode 100644 cmake/Modules/FindNetCDF.cmake delete mode 100644 cmake/Modules/FindWGRIB2.cmake delete mode 100644 cmake/Modules/Findbacio.cmake delete mode 100644 cmake/Modules/Findbufr.cmake delete mode 100644 cmake/Modules/Findcrtm.cmake delete mode 100644 cmake/Modules/Findg2.cmake delete mode 100644 cmake/Modules/Findg2tmpl.cmake delete mode 100644 cmake/Modules/Findgfsio.cmake delete mode 100644 cmake/Modules/Findip.cmake delete mode 100644 cmake/Modules/Findlandsfcutil.cmake delete mode 100644 cmake/Modules/Findnemsio.cmake delete mode 100644 cmake/Modules/Findnemsiogfs.cmake delete mode 100644 cmake/Modules/Findpost.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/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 100755 cmake/Modules/comp_src.pl delete mode 100644 cmake/Modules/findHelpers.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/Generic.cmake.orig delete mode 100644 cmake/Modules/platforms/Hera.cmake delete mode 100644 cmake/Modules/platforms/Jet.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/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 diff --git a/cmake/LICENSE.md b/cmake/LICENSE.md deleted file mode 100644 index 0927556b5..000000000 --- a/cmake/LICENSE.md +++ /dev/null @@ -1,157 +0,0 @@ -### GNU LESSER GENERAL PUBLIC LICENSE - -Version 3, 29 June 2007 - -Copyright (C) 2007 Free Software Foundation, Inc. - - -Everyone is permitted to copy and distribute verbatim copies of this -license document, but changing it is not allowed. - -This version of the GNU Lesser General Public License incorporates the -terms and conditions of version 3 of the GNU General Public License, -supplemented by the additional permissions listed below. - -#### 0. Additional Definitions. - -As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the -GNU General Public License. - -"The Library" refers to a covered work governed by this License, other -than an Application or a Combined Work as defined below. - -An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - -A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - -The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - -The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - -#### 1. Exception to Section 3 of the GNU GPL. - -You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - -#### 2. Conveying Modified Versions. - -If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - -- a) under this License, provided that you make a good faith effort - to ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or -- b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - -#### 3. Object Code Incorporating Material from Library Header Files. - -The object code form of an Application may incorporate material from a -header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - -- a) Give prominent notice with each copy of the object code that - the Library is used in it and that the Library and its use are - covered by this License. -- b) Accompany the object code with a copy of the GNU GPL and this - license document. - -#### 4. Combined Works. - -You may convey a Combined Work under terms of your choice that, taken -together, effectively do not restrict modification of the portions of -the Library contained in the Combined Work and reverse engineering for -debugging such modifications, if you also do each of the following: - -- a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. -- b) Accompany the Combined Work with a copy of the GNU GPL and this - license document. -- c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. -- d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of - this License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with - the Library. A suitable mechanism is one that (a) uses at run - time a copy of the Library already present on the user's - computer system, and (b) will operate properly with a modified - version of the Library that is interface-compatible with the - Linked Version. -- e) Provide Installation Information, but only if you would - otherwise be required to provide such information under section 6 - of the GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the Application - with a modified version of the Linked Version. (If you use option - 4d0, the Installation Information must accompany the Minimal - Corresponding Source and Corresponding Application Code. If you - use option 4d1, you must provide the Installation Information in - the manner specified by section 6 of the GNU GPL for conveying - Corresponding Source.) - -#### 5. Combined Libraries. - -You may place library facilities that are a work based on the Library -side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - -- a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities, conveyed under the terms of this License. -- b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - -#### 6. Revised Versions of the GNU Lesser General Public License. - -The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -as you received it specifies that a certain numbered version of the -GNU Lesser General Public License "or any later version" applies to -it, you have the option of following the terms and conditions either -of that published version or of any later version published by the -Free Software Foundation. If the Library as you received it does not -specify a version number of the GNU Lesser General Public License, you -may choose any version of the GNU Lesser General Public License ever -published by the Free Software Foundation. - -If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/cmake/Modules/FindESMF.cmake b/cmake/Modules/FindESMF.cmake deleted file mode 100644 index de6e88909..000000000 --- a/cmake/Modules/FindESMF.cmake +++ /dev/null @@ -1,105 +0,0 @@ -# - Try to find ESMF -# -# Requires setting ESMFMKFILE to the filepath of esmf.mk. If this is NOT set, -# then ESMF_FOUND will always be FALSE. If ESMFMKFILE exists, then ESMF_FOUND=TRUE -# and all ESMF makefile variables will be set in the global scope. Optionally, -# set ESMF_MKGLOBALS to a string list to filter makefile variables. For example, -# to globally scope only ESMF_LIBSDIR and ESMF_APPSDIR variables, use this CMake -# command in CMakeLists.txt: -# -# set(ESMF_MKGLOBALS "LIBSDIR" "APPSDIR") - - -# Add the ESMFMKFILE path to the cache if defined as system env variable -if (DEFINED ENV{ESMFMKFILE} AND NOT DEFINED ESMFMKFILE) - set(ESMFMKFILE $ENV{ESMFMKFILE} CACHE FILEPATH "Path to ESMF mk file") -endif () - -# Found the mk file and ESMF exists on the system -if (EXISTS ${ESMFMKFILE}) - set(ESMF_FOUND TRUE CACHE BOOL "ESMF mk file found" FORCE) - # Did not find the ESMF mk file -else() - set(ESMF_FOUND FALSE CACHE BOOL "ESMF mk file NOT found" FORCE) - # Best to warn users that without the mk file there is no way to find ESMF - if (NOT DEFINED ESMFMKFILE) - message(WARNING "ESMFMKFILE not defined. This is the path to esmf.mk file. \ -Without this filepath, ESMF_FOUND will always be FALSE.") - endif () -endif() - -# Only parse the mk file if it is found -if (ESMF_FOUND) - # Read the mk file - file(STRINGS "${ESMFMKFILE}" esmfmkfile_contents) - # Parse each line in the mk file - foreach(str ${esmfmkfile_contents}) - # Only consider uncommented lines - string(REGEX MATCH "^[^#]" def ${str}) - # Line is not commented - if (def) - # Extract the variable name - string(REGEX MATCH "^[^=]+" esmf_varname ${str}) - # Extract the variable's value - string(REGEX MATCH "=.+$" esmf_vardef ${str}) - # Only for variables with a defined value - if (esmf_vardef) - # Get rid of the assignment string - string(SUBSTRING ${esmf_vardef} 1 -1 esmf_vardef) - # Remove whitespace - string(STRIP ${esmf_vardef} esmf_vardef) - # A string or single-valued list - if(NOT DEFINED ESMF_MKGLOBALS) - # Set in global scope - set(${esmf_varname} ${esmf_vardef}) - # Don't display by default in GUI - mark_as_advanced(esmf_varname) - else() # Need to filter global promotion - foreach(m ${ESMF_MKGLOBALS}) - string(FIND ${esmf_varname} ${m} match) - # Found the string - if(NOT ${match} EQUAL -1) - # Promote to global scope - set(${esmf_varname} ${esmf_vardef}) - # Don't display by default in the GUI - mark_as_advanced (esmf_varname) - # No need to search for the current string filter - break() - endif() - endforeach() - endif() - endif() - endif() - endforeach() - - separate_arguments(ESMF_F90COMPILEPATHS NATIVE_COMMAND ${ESMF_F90COMPILEPATHS}) - foreach (ITEM ${ESMF_F90COMPILEPATHS}) - string(REGEX REPLACE "^-I" "" ITEM "${ITEM}") - list(APPEND tmp ${ITEM}) - endforeach() - set(ESMF_F90COMPILEPATHS ${tmp}) - - add_library(esmf UNKNOWN IMPORTED) - # Look for static library, if not found try dynamic library - find_library(esmf_lib NAMES libesmf.a PATHS ${ESMF_LIBSDIR}) - if(esmf_lib MATCHES "esmf_lib-NOTFOUND") - message(STATUS "Static ESMF library not found, searching for dynamic library instead") - find_library(esmf_lib NAMES esmf_fullylinked PATHS ${ESMF_LIBSDIR}) - if(esmf_lib MATCHES "esmf_lib-NOTFOUND") - message(WARNING "Neither the dynamic nor the static ESMF library was found") - else() - message(STATUS "Found ESMF library: ${esmf_lib}") - endif() - set(ESMF_INTERFACE_LINK_LIBRARIES "") - else() - # When linking the static library, also need the ESMF linker flags; strip any leading/trailing whitespaces - string(STRIP "${ESMF_F90ESMFLINKRPATHS} ${ESMF_F90ESMFLINKPATHS} ${ESMF_F90LINKLIBS} ${ESMF_F90LINKOPTS}" ESMF_INTERFACE_LINK_LIBRARIES) - message(STATUS "Found ESMF library: ${esmf_lib}") - endif() - - set_target_properties(esmf PROPERTIES - IMPORTED_LOCATION ${esmf_lib} - INTERFACE_INCLUDE_DIRECTORIES "${ESMF_F90COMPILEPATHS}" - INTERFACE_LINK_LIBRARIES "${ESMF_INTERFACE_LINK_LIBRARIES}") - -endif() diff --git a/cmake/Modules/FindG2C.cmake b/cmake/Modules/FindG2C.cmake deleted file mode 100644 index bce9d163e..000000000 --- a/cmake/Modules/FindG2C.cmake +++ /dev/null @@ -1,6 +0,0 @@ -# This module looks for environment variables detailing where G2 lib is -# If variables are not set, G2 will be built from external source -if(DEFINED ENV{G2C_LIB}) - set(G2C_LIB $ENV{G2C_LIB} CACHE STRING "G2C Library Location") - set(G2C_VER $ENV{G2C_VER} CACHE STRING "G2C Version") -endif() diff --git a/cmake/Modules/FindGEMPAK.cmake b/cmake/Modules/FindGEMPAK.cmake deleted file mode 100644 index a5359e0be..000000000 --- a/cmake/Modules/FindGEMPAK.cmake +++ /dev/null @@ -1,7 +0,0 @@ -# - Find GEMPAK -if(DEFINED ENV{GEMPAK}) - set(GEM_INC $ENV{GEMPAK}/include CACHE STRING "GEMPAK Include Path" ) - set(OS_INC $ENV{OS_INC} CACHE STRING "GEMPAK OS Include Path" ) -else () - message(FATAL_ERROR "Could not find GEMPAK module") -endif() diff --git a/cmake/Modules/FindGSICONTROL.cmake b/cmake/Modules/FindGSICONTROL.cmake deleted file mode 100644 index 2b8acaa66..000000000 --- a/cmake/Modules/FindGSICONTROL.cmake +++ /dev/null @@ -1,53 +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 - /scratch4/NCEPDEV/da/save/Michael.Lueken/svn1_old/build/bin - /scratch4/NCEPDEV/da/save/Michael.Lueken/svn1/src - - ${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 - /scratch4/NCEPDEV/da/save/Michael.Lueken/svn1_old/build/bin - /scratch4/NCEPDEV/da/save/Michael.Lueken/svn1/src/enkf - - ${NO_DEFAULT_PATH}) - -set( ENKFCONTROL ${ENKF_CONTROL_EXE} CACHE STRING "ENKF control executable for regression testing" FORCE ) diff --git a/cmake/Modules/FindNDATE.cmake b/cmake/Modules/FindNDATE.cmake deleted file mode 100644 index d9bc8bb4e..000000000 --- a/cmake/Modules/FindNDATE.cmake +++ /dev/null @@ -1,14 +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 - ${NCEPLIBS_INSTALL_DIR}/bin - ${NO_DEFAULT_PATH}) -endif() diff --git a/cmake/Modules/FindNetCDF.cmake b/cmake/Modules/FindNetCDF.cmake deleted file mode 100644 index 1439ae848..000000000 --- a/cmake/Modules/FindNetCDF.cmake +++ /dev/null @@ -1,337 +0,0 @@ -# (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() - -## 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} ) - 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 () - -## 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) - -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/cmake/Modules/FindWGRIB2.cmake b/cmake/Modules/FindWGRIB2.cmake deleted file mode 100644 index 5f3376b11..000000000 --- a/cmake/Modules/FindWGRIB2.cmake +++ /dev/null @@ -1,26 +0,0 @@ -# This module looks for the wgrib2 library and Fortran modules in WGRIB2_ROOT -if(DEFINED ENV{WGRIB2_ROOT}) - set(WGRIB2_ROOT $ENV{WGRIB2_ROOT}) -endif() - -find_path (WGRIB2_INCLUDES - wgrib2api.mod - HINTS ${WGRIB2_ROOT}/include) - -find_library (WGRIB2_LIBRARIES - names libwgrib2.a - HINTS ${WGRIB2_ROOT}/lib ${WGRIB2_ROOT}/lib64) - -if(EXISTS ${WGRIB2_INCLUDES} AND EXISTS ${WGRIB2_LIBRARIES}) - message(STATUS "Found WGRIB2: include directory ${WGRIB2_INCLUDES}, library ${WGRIB2_LIBRARIES}") -else() - message(STATUS "Unable to locate WGRIB2 library and/or Fortran modules") -endif() - -mark_as_advanced (WGRIB2_INCLUDES WGRIB2_LIBRARIES) - -add_library(wgrib2 UNKNOWN IMPORTED) -set_target_properties(wgrib2 PROPERTIES - IMPORTED_LOCATION "${WGRIB2_LIBRARIES}" - INTERFACE_INCLUDE_DIRECTORIES "${WGRIB2_INCLUDES}" - INTERFACE_LINK_LIBRARIES "${WGRIB2_LIBRARIES}") diff --git a/cmake/Modules/Findbacio.cmake b/cmake/Modules/Findbacio.cmake deleted file mode 100644 index 9652d2db7..000000000 --- a/cmake/Modules/Findbacio.cmake +++ /dev/null @@ -1,32 +0,0 @@ -# This module looks for environment variables detailing where BACIO lib is -# If variables are not set, BACIO will be built from external source -if(DEFINED ENV{BACIO_LIB4}) - set(BACIO_LIB4 $ENV{BACIO_LIB4} CACHE STRING "BACIO_4 Library Location") - set(BACIO_LIB8 $ENV{BACIO_LIB8} CACHE STRING "BACIO_8 Library Location") - set(BACIO_LIBd $ENV{BACIO_LIBd} CACHE STRING "BACIO_d Library Location") - - set(name "bacio") - string(TOUPPER ${name} uppercase_name) - - string(REGEX MATCH "(v[0-9]+\\.[0-9]+\\.[0-9]+)" _ ${${uppercase_name}_LIB4}) - set(version ${CMAKE_MATCH_1}) - - set(kinds "4" "8" "d") - foreach(kind ${kinds}) - set(lib_name ${name}_${kind}) - set(versioned_lib_name ${name}_${version}_${kind}) - - if(EXISTS ${${uppercase_name}_LIB${kind}} ) - get_filename_component(lib_dir ${${uppercase_name}_LIB${kind}} DIRECTORY) - find_library(bacio_path_${kind} NAMES ${versioned_lib_name} PATHS ${lib_dir} NO_DEFAULT_PATH) - add_library(${lib_name} STATIC IMPORTED) - set_target_properties(${lib_name} PROPERTIES - IMPORTED_LOCATION ${bacio_path_${kind}}) - endif() - endforeach() -endif() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(bacio - REQUIRED_VARS bacio_path_4) - diff --git a/cmake/Modules/Findbufr.cmake b/cmake/Modules/Findbufr.cmake deleted file mode 100644 index c82933ccd..000000000 --- a/cmake/Modules/Findbufr.cmake +++ /dev/null @@ -1,34 +0,0 @@ -# This module looks for environment variables detailing where BUFR lib is -# If variables are not set, BUFR will be built from external source -if(DEFINED ENV{BUFR_LIB4} ) - set(BUFR_VER $ENV{BUFR_VER} CACHE STRING "BUFR Version") - set(BUFR_LIB4 $ENV{BUFR_LIB4} CACHE STRING "BUFR_4 Library Location") - set(BUFR_LIB8 $ENV{BUFR_LIB8} CACHE STRING "BUFR_8 Library Location") - set(BUFR_LIBd $ENV{BUFR_LIBd} CACHE STRING "BUFR_d Library Location") - - set(name "bufr") - string(TOUPPER ${name} uppercase_name) - - string(REGEX MATCH "(v[0-9]+\\.[0-9]+\\.[0-9]+)" _ ${${uppercase_name}_LIB4}) - set(version ${CMAKE_MATCH_1}) - - set(kinds "4" "8" "d") - foreach(kind ${kinds}) - set(lib_name ${name}_${kind}) - set(versioned_lib_name ${name}_${version}_${kind}) - - if(EXISTS ${${uppercase_name}_LIB${kind}} ) - get_filename_component(lib_dir ${${uppercase_name}_LIB${kind}} DIRECTORY) - find_library(bufr_path_${kind} NAMES ${versioned_lib_name} PATHS ${lib_dir} NO_DEFAULT_PATH) - - add_library(${lib_name} STATIC IMPORTED) - set_target_properties(${lib_name} PROPERTIES - IMPORTED_LOCATION ${bufr_path_${kind}}) - endif() - endforeach() - -endif() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(bufr - REQUIRED_VARS bufr_path_4) diff --git a/cmake/Modules/Findcrtm.cmake b/cmake/Modules/Findcrtm.cmake deleted file mode 100644 index dc09941fc..000000000 --- a/cmake/Modules/Findcrtm.cmake +++ /dev/null @@ -1,27 +0,0 @@ -# This module attempts to find the CRTM library and will set it up to build if it cannot be found -# -if(DEFINED ENV{CRTM_LIB}) - set(CRTM_VER $ENV{CRTM_VER} CACHE STRING "CRTM Version") - set(CRTM_LIB $ENV{CRTM_LIB} CACHE STRING "CRTM Library Location") - set(CRTM_INC $ENV{CRTM_INC} CACHE STRING "CRTM Library Location") - - set(name "crtm") - string(TOUPPER ${name} uppercase_name) - - string(REGEX MATCH "(v[0-9]+\\.[0-9]+\\.[0-9]+)" _ ${${uppercase_name}_LIB}) - set(version ${CMAKE_MATCH_1}) - - set(versioned_lib_name ${name}_${version}) - - get_filename_component(lib_dir ${${uppercase_name}_LIB} DIRECTORY) - find_library(crtm_path NAMES ${versioned_lib_name} PATHS ${lib_dir} NO_DEFAULT_PATH) - - add_library(${name} STATIC IMPORTED) - set_target_properties(${name} PROPERTIES - IMPORTED_LOCATION ${crtm_path} - INTERFACE_INCLUDE_DIRECTORIES ${${uppercase_name}_INC}) -endif() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(crtm - REQUIRED_VARS crtm_path) diff --git a/cmake/Modules/Findg2.cmake b/cmake/Modules/Findg2.cmake deleted file mode 100644 index a3acd376e..000000000 --- a/cmake/Modules/Findg2.cmake +++ /dev/null @@ -1,34 +0,0 @@ -# This module looks for environment variables detailing where G2 lib is -# If variables are not set, G2 will be built from external source -if(DEFINED ENV{G2_LIBd}) - set(G2_LIBd $ENV{G2_LIBd} CACHE STRING "G2_d Library Location" ) - set(G2_LIB4 $ENV{G2_LIB4} CACHE STRING "G2_4 Library Location" ) - set(G2_INC4 $ENV{G2_INC4} CACHE STRING "G2_4 Include Location" ) - set(G2_INCd $ENV{G2_INCd} CACHE STRING "G2_d Include Location" ) - - set(name "g2") - string(TOUPPER ${name} uppercase_name) - - string(REGEX MATCH "(v[0-9]+\\.[0-9]+\\.[0-9]+)" _ ${${uppercase_name}_LIBd}) - set(version ${CMAKE_MATCH_1}) - - set(kinds "4" "d") - foreach(kind ${kinds}) - set(lib_name ${name}_${kind}) - set(versioned_lib_name ${name}_${version}_${kind}) - - if(EXISTS ${${uppercase_name}_LIB${kind}} ) - get_filename_component(lib_dir ${${uppercase_name}_LIB${kind}} DIRECTORY) - find_library(g2_path_${kind} NAMES ${versioned_lib_name} PATHS ${lib_dir} NO_DEFAULT_PATH) - - add_library(${lib_name} STATIC IMPORTED) - set_target_properties(${lib_name} PROPERTIES - IMPORTED_LOCATION ${g2_path_${kind}} - INTERFACE_INCLUDE_DIRECTORIES ${${uppercase_name}_INC${kind}}) - endif() - endforeach() -endif() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(g2 - REQUIRED_VARS g2_path_d) diff --git a/cmake/Modules/Findg2tmpl.cmake b/cmake/Modules/Findg2tmpl.cmake deleted file mode 100644 index eae6f1992..000000000 --- a/cmake/Modules/Findg2tmpl.cmake +++ /dev/null @@ -1,29 +0,0 @@ -# This module looks for environment variables detailing where G2TMPL lib is -# If variables are not set, G2TMPL will be built from external source -if(DEFINED ENV{G2TMPL_LIB} ) - set(G2TMPL_LIB $ENV{G2TMPL_LIB} CACHE STRING "G2TMPL Library Location" ) - set(G2TMPL_INC $ENV{G2TMPL_INC} CACHE STRING "G2TMPL Include Location" ) - - set(name "g2tmpl") - string(TOUPPER ${name} uppercase_name) - - string(REGEX MATCH "(v[0-9]+\\.[0-9]+\\.[0-9]+)" _ ${${uppercase_name}_LIB}) - set(version ${CMAKE_MATCH_1}) - - set(lib_name ${name}) - set(versioned_lib_name ${name}_${version}) - - if(EXISTS ${${uppercase_name}_LIB} ) - get_filename_component(lib_dir ${${uppercase_name}_LIB} DIRECTORY) - find_library(g2tmpl_path NAMES ${versioned_lib_name} PATHS ${lib_dir} NO_DEFAULT_PATH) - - add_library(${lib_name} STATIC IMPORTED) - set_target_properties(${lib_name} PROPERTIES - IMPORTED_LOCATION ${g2tmpl_path} - INTERFACE_INCLUDE_DIRECTORIES ${${uppercase_name}_INC}) - endif() -endif() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(g2tmpl - REQUIRED_VARS g2tmpl_path) diff --git a/cmake/Modules/Findgfsio.cmake b/cmake/Modules/Findgfsio.cmake deleted file mode 100644 index f2f330146..000000000 --- a/cmake/Modules/Findgfsio.cmake +++ /dev/null @@ -1,32 +0,0 @@ -# This module looks for environment variables detailing where GFSIO lib is -# If variables are not set, GFSIO will be built from external source -if(DEFINED ENV{GFSIO_LIB4} ) - set(GFSIO_LIB4 $ENV{GFSIO_LIB4} CACHE STRING "GFSIO_4 Library Location" ) - set(GFSIO_INC4 $ENV{GFSIO_INC4} CACHE STRING "GFSIO_4 Include Location" ) - - set(name "gfsio") - string(TOUPPER ${name} uppercase_name) - - string(REGEX MATCH "(v[0-9]+\\.[0-9]+\\.[0-9]+)" _ ${${uppercase_name}_LIB4}) - set(version ${CMAKE_MATCH_1}) - - set(kinds "4") - foreach(kind ${kinds}) - set(lib_name ${name}_${kind}) - set(versioned_lib_name ${name}_${version}_${kind}) - - if(EXISTS ${${uppercase_name}_LIB${kind}} ) - get_filename_component(lib_dir ${${uppercase_name}_LIB${kind}} DIRECTORY) - find_library(gfsio_path_${kind} NAMES ${versioned_lib_name} PATHS ${lib_dir} NO_DEFAULT_PATH) - - add_library(${lib_name} STATIC IMPORTED) - set_target_properties(${lib_name} PROPERTIES - IMPORTED_LOCATION ${gfsio_path_${kind}} - INTERFACE_INCLUDE_DIRECTORIES ${${uppercase_name}_INC${kind}}) - endif() - endforeach() -endif() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(gfsio - REQUIRED_VARS gfsio_path_4) diff --git a/cmake/Modules/Findip.cmake b/cmake/Modules/Findip.cmake deleted file mode 100644 index 569a8a937..000000000 --- a/cmake/Modules/Findip.cmake +++ /dev/null @@ -1,37 +0,0 @@ -# This module looks for environment variables detailing where IP lib is -# If variables are not set, IP will be built from external source - -if(DEFINED ENV{IP_LIBd} ) - set(IP_LIBd $ENV{IP_LIBd} CACHE STRING "IP_d Library Location" ) - set(IP_LIB4 $ENV{IP_LIB4} CACHE STRING "IP_4 Library Location" ) - set(IP_LIB8 $ENV{IP_LIB8} CACHE STRING "IP_8 Library Location" ) - set(IP_INC4 $ENV{IP_INC4} CACHE STRING "IP_4 Include Location" ) - set(IP_INC8 $ENV{IP_INC8} CACHE STRING "IP_8 Include Location" ) - set(IP_INCd $ENV{IP_INCd} CACHE STRING "IP_d Include Location" ) - - set(name "ip") - string(TOUPPER ${name} uppercase_name) - - string(REGEX MATCH "(v[0-9]+\\.[0-9]+\\.[0-9]+)" _ ${${uppercase_name}_LIBd}) - set(version ${CMAKE_MATCH_1}) - - set(kinds "4" "d" "8") - foreach(kind ${kinds}) - set(lib_name ${name}_${kind}) - set(versioned_lib_name ${name}_${version}_${kind}) - - if(EXISTS ${${uppercase_name}_LIB${kind}} ) - get_filename_component(lib_dir ${${uppercase_name}_LIB${kind}} DIRECTORY) - find_library(ip_path_${kind} NAMES ${versioned_lib_name} PATHS ${lib_dir} NO_DEFAULT_PATH) - - add_library(${lib_name} STATIC IMPORTED) - set_target_properties(${lib_name} PROPERTIES - IMPORTED_LOCATION ${ip_path_${kind}} - INTERFACE_INCLUDE_DIRECTORIES ${${uppercase_name}_INC${kind}}) - endif() - endforeach() -endif() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(ip - REQUIRED_VARS ip_path_d) diff --git a/cmake/Modules/Findlandsfcutil.cmake b/cmake/Modules/Findlandsfcutil.cmake deleted file mode 100644 index 28c60a245..000000000 --- a/cmake/Modules/Findlandsfcutil.cmake +++ /dev/null @@ -1,36 +0,0 @@ -# This module looks for environment variables detailing where LANDSFCUTIL lib is -# If variables are not set, LANDSFCUTIL will be built from external source - -if(DEFINED ENV{LANDSFCUTIL_LIB4} ) - set(LANDSFCUTIL_VER $ENV{LANDSFCUTIL_VER} CACHE STRING "LANDSFCUTIL Version") - set(LANDSFCUTIL_LIB4 $ENV{LANDSFCUTIL_LIB4} CACHE STRING "LANDSFCUTIL_4 Library Location") - set(LANDSFCUTIL_LIBd $ENV{LANDSFCUTIL_LIBd} CACHE STRING "LANDSFCUTIL_d Library Location") - set(LANDSFCUTIL_INC4 $ENV{LANDSFCUTIL_INC4} CACHE STRING "LANDSFCUTIL_4 Include Location") - set(LANDSFCUTIL_INCd $ENV{LANDSFCUTIL_INCd} CACHE STRING "LANDSFCUTIL_d Include Location") - - set(name "landsfcutil") - string(TOUPPER ${name} uppercase_name) - - string(REGEX MATCH "(v[0-9]+\\.[0-9]+\\.[0-9]+)" _ ${${uppercase_name}_LIB4}) - set(version ${CMAKE_MATCH_1}) - - set(kinds "4" "d") - foreach(kind ${kinds}) - set(lib_name ${name}_${kind}) - set(versioned_lib_name ${name}_${version}_${kind}) - - if(EXISTS ${${uppercase_name}_LIB${kind}} ) - get_filename_component(lib_dir ${${uppercase_name}_LIB${kind}} DIRECTORY) - find_library(landsfcutil_path_${kind} NAMES ${versioned_lib_name} PATHS ${lib_dir} NO_DEFAULT_PATH) - - add_library(${lib_name} STATIC IMPORTED) - set_target_properties(${lib_name} PROPERTIES - IMPORTED_LOCATION ${landsfcutil_path_${kind}} - INTERFACE_INCLUDE_DIRECTORIES ${${uppercase_name}_INC${kind}}) - endif() - endforeach() -endif() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(landsfcutil - REQUIRED_VARS landsfcutil_path_4) diff --git a/cmake/Modules/Findnemsio.cmake b/cmake/Modules/Findnemsio.cmake deleted file mode 100644 index f2c8839d3..000000000 --- a/cmake/Modules/Findnemsio.cmake +++ /dev/null @@ -1,28 +0,0 @@ -# This module looks for environment variables detailing where NEMSIO lib is -# If variables are not set, NEMSIO will be built from external source -if(DEFINED ENV{NEMSIO_LIB} ) - set(NEMSIO_LIB $ENV{NEMSIO_LIB} CACHE STRING "NEMSIO Library Location" ) - set(NEMSIO_INC $ENV{NEMSIO_INC} CACHE STRING "NEMSIO Include Location" ) - - set(name "nemsio") - string(TOUPPER ${name} uppercase_name) - - string(REGEX MATCH "(v[0-9]+\\.[0-9]+\\.[0-9]+)" _ ${${uppercase_name}_LIB}) - set(version ${CMAKE_MATCH_1}) - - set(versioned_lib_name ${name}_${version}) - - if(EXISTS ${${uppercase_name}_LIB} ) - get_filename_component(lib_dir ${${uppercase_name}_LIB} DIRECTORY) - find_library(nemsio_path NAMES ${versioned_lib_name} PATHS ${lib_dir} NO_DEFAULT_PATH) - - add_library(${name} STATIC IMPORTED) - set_target_properties(${name} PROPERTIES - IMPORTED_LOCATION ${nemsio_path} - INTERFACE_INCLUDE_DIRECTORIES ${${uppercase_name}_INC}) - endif() -endif() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(nemsio - REQUIRED_VARS nemsio_path) diff --git a/cmake/Modules/Findnemsiogfs.cmake b/cmake/Modules/Findnemsiogfs.cmake deleted file mode 100644 index 8cc5467c6..000000000 --- a/cmake/Modules/Findnemsiogfs.cmake +++ /dev/null @@ -1,28 +0,0 @@ -# This module looks for environment variables detailing where NEMSIOGFS lib is -# If variables are not set, NEMSIOGFS will be built from external source -if(DEFINED ENV{NEMSIOGFS_LIB} ) - set(NEMSIOGFS_LIB $ENV{NEMSIOGFS_LIB} CACHE STRING "NEMSIOGFS Library Location" ) - set(NEMSIOGFS_INC $ENV{NEMSIOGFS_INC} CACHE STRING "NEMSIOGFS Include Location" ) - - set(name "nemsiogfs") - string(TOUPPER ${name} uppercase_name) - - string(REGEX MATCH "(v[0-9]+\\.[0-9]+\\.[0-9]+)" _ ${${uppercase_name}_LIB}) - set(version ${CMAKE_MATCH_1}) - - set(versioned_lib_name ${name}_${version}) - - if(EXISTS ${${uppercase_name}_LIB${kind}} ) - get_filename_component(lib_dir ${${uppercase_name}_LIB} DIRECTORY) - find_library(nemsiogfs_path NAMES ${versioned_lib_name} PATHS ${lib_dir} NO_DEFAULT_PATH) - - add_library(${name} STATIC IMPORTED) - set_target_properties(${name} PROPERTIES - IMPORTED_LOCATION ${nemsiogfs_path} - INTERFACE_INCLUDE_DIRECTORIES ${${uppercase_name}_INC}) - endif() -endif() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(nemsiogfs - REQUIRED_VARS nemsiogfs_path) diff --git a/cmake/Modules/Findpost.cmake b/cmake/Modules/Findpost.cmake deleted file mode 100644 index 167a74aec..000000000 --- a/cmake/Modules/Findpost.cmake +++ /dev/null @@ -1,20 +0,0 @@ -# This module looks for environment variables detailing where IP lib is -# If variables are not set, IP will be built from external source - -if(DEFINED ENV{POST_LIB} ) - set(POST_LIB $ENV{POST_LIB} CACHE STRING "POST Library Location" ) - set(POST_INC $ENV{POST_INC} CACHE STRING "POST Include Location" ) - set(POST_SRC $ENV{POST_SRC} CACHE STRING "POST Include Location" ) -else() - set(POST_VER 8.0.0) - find_library( POST_LIB - NAMES libip_v${POST_VER}.a - HINTS - ${NCEPLIBS_INSTALL_DIR}/lib - ) - if(${NCEPLIBS_INSTALL_DIR}) - set(POST_INC ${NCEPLIBS_INSTALL_DIR}/include CACHE STRING "POST Include Location" ) - else() - set(POST_INC ${CMAKE_INSTALL_PREFIX}/include CACHE STRING "POST Include Location" ) - endif() -endif() diff --git a/cmake/Modules/Findsfcio.cmake b/cmake/Modules/Findsfcio.cmake deleted file mode 100644 index 3995c5844..000000000 --- a/cmake/Modules/Findsfcio.cmake +++ /dev/null @@ -1,32 +0,0 @@ -# This module looks for environment variables detailing where SFCIO lib is -# If variables are not set, SFCIO will be built from external source -if(DEFINED ENV{SFCIO_LIB4} ) - set(SFCIO_LIB4 $ENV{SFCIO_LIB4} CACHE STRING "SFCIO_4 Library Location" ) - set(SFCIO_INC4 $ENV{SFCIO_INC4} CACHE STRING "SFCIO_4 Include Location" ) - - set(name "sfcio") - string(TOUPPER ${name} uppercase_name) - - string(REGEX MATCH "(v[0-9]+\\.[0-9]+\\.[0-9]+)" _ ${${uppercase_name}_LIB4}) - set(version ${CMAKE_MATCH_1}) - - set(kinds "4") - foreach(kind ${kinds}) - set(lib_name ${name}_${kind}) - set(versioned_lib_name ${name}_${version}_${kind}) - - if(EXISTS ${${uppercase_name}_LIB${kind}} ) - get_filename_component(lib_dir ${${uppercase_name}_LIB${kind}} DIRECTORY) - find_library(sfcio_path NAMES ${versioned_lib_name} PATHS ${lib_dir} NO_DEFAULT_PATH) - - add_library(${lib_name} STATIC IMPORTED) - set_target_properties(${lib_name} PROPERTIES - IMPORTED_LOCATION ${sfcio_path} - INTERFACE_INCLUDE_DIRECTORIES ${${uppercase_name}_INC${kind}}) - endif() - endforeach() -endif() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(sfcio - REQUIRED_VARS sfcio_path) diff --git a/cmake/Modules/Findsigio.cmake b/cmake/Modules/Findsigio.cmake deleted file mode 100644 index 9bcab151c..000000000 --- a/cmake/Modules/Findsigio.cmake +++ /dev/null @@ -1,32 +0,0 @@ -# This module looks for environment variables detailing where SIGIO lib is -# If variables are not set, SIGIO will be built from external source -if(DEFINED ENV{SIGIO_LIB4} ) - set(SIGIO_LIB4 $ENV{SIGIO_LIB4} CACHE STRING "SIGIO_4 Library Location" ) - set(SIGIO_INC4 $ENV{SIGIO_INC4} CACHE STRING "SIGIO_4 Include Location" ) - - set(name "sigio") - string(TOUPPER ${name} uppercase_name) - - string(REGEX MATCH "(v[0-9]+\\.[0-9]+\\.[0-9]+)" _ ${${uppercase_name}_LIB4}) - set(version ${CMAKE_MATCH_1}) - - set(kinds "4") - foreach(kind ${kinds}) - set(lib_name ${name}_${kind}) - set(versioned_lib_name ${name}_${version}_${kind}) - - if(EXISTS ${${uppercase_name}_LIB${kind}} ) - get_filename_component(lib_dir ${${uppercase_name}_LIB${kind}} DIRECTORY) - find_library(sigio_path NAMES ${versioned_lib_name} PATHS ${lib_dir} NO_DEFAULT_PATH) - - add_library(${lib_name} STATIC IMPORTED) - set_target_properties(${lib_name} PROPERTIES - IMPORTED_LOCATION ${sigio_path} - INTERFACE_INCLUDE_DIRECTORIES ${${uppercase_name}_INC${kind}}) - endif() - endforeach() -endif() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(sigio - REQUIRED_VARS sigio_path) diff --git a/cmake/Modules/Findsp.cmake b/cmake/Modules/Findsp.cmake deleted file mode 100644 index 59454dc88..000000000 --- a/cmake/Modules/Findsp.cmake +++ /dev/null @@ -1,33 +0,0 @@ -# This module looks for environment variables detailing where SP lib is -# If variables are not set, SP will be built from external source - -if(DEFINED ENV{SP_LIBd}) - set(SP_LIBd $ENV{SP_LIBd} CACHE STRING "SP_d Library Location" ) - set(SP_LIB4 $ENV{SP_LIB4} CACHE STRING "SP_4 Library Location" ) - set(SP_LIB8 $ENV{SP_LIB8} CACHE STRING "SP_8 Library Location" ) - - set(name "sp") - string(TOUPPER ${name} uppercase_name) - - string(REGEX MATCH "(v[0-9]+\\.[0-9]+\\.[0-9]+)" _ ${${uppercase_name}_LIBd}) - set(version ${CMAKE_MATCH_1}) - - set(kinds "4" "d" "8") - foreach(kind ${kinds}) - set(lib_name ${name}_${kind}) - set(versioned_lib_name ${name}_${version}_${kind}) - - if(EXISTS ${${uppercase_name}_LIB${kind}} ) - get_filename_component(lib_dir ${${uppercase_name}_LIB${kind}} DIRECTORY) - find_library(sp_path_${kind} NAMES ${versioned_lib_name} PATHS ${lib_dir} NO_DEFAULT_PATH) - - add_library(${lib_name} STATIC IMPORTED) - set_target_properties(${lib_name} PROPERTIES - IMPORTED_LOCATION ${sp_path_${kind}}) - endif() - endforeach() -endif() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(sp - REQUIRED_VARS sp_path_d) diff --git a/cmake/Modules/Findw3emc.cmake b/cmake/Modules/Findw3emc.cmake deleted file mode 100644 index 42f2ce1c4..000000000 --- a/cmake/Modules/Findw3emc.cmake +++ /dev/null @@ -1,38 +0,0 @@ -# This module looks for environment variables detailing where W3EMC lib is -# If variables are not set, W3EMC will be built from external source - -if(DEFINED ENV{W3EMC_LIBd} ) - set(W3EMC_VER $ENV{W3EMC_VER} CACHE STRING "W3EMC Version") - set(W3EMC_LIB4 $ENV{W3EMC_LIB4} CACHE STRING "W3EMC_4 Library Location") - set(W3EMC_LIB8 $ENV{W3EMC_LIB8} CACHE STRING "W3EMC_8 Library Location") - set(W3EMC_LIBd $ENV{W3EMC_LIBd} CACHE STRING "W3EMC_d Library Location") - set(W3EMC_INC4 $ENV{W3EMC_INC4} CACHE STRING "W3EMC_4 Include Location") - set(W3EMC_INC8 $ENV{W3EMC_INC8} CACHE STRING "W3EMC_8 Include Location") - set(W3EMC_INCd $ENV{W3EMC_INCd} CACHE STRING "W3EMC_d Include Location") - - set(name "w3emc") - string(TOUPPER ${name} uppercase_name) - - string(REGEX MATCH "(v[0-9]+\\.[0-9]+\\.[0-9]+)" _ ${${uppercase_name}_LIBd}) - set(version ${CMAKE_MATCH_1}) - - set(kinds "4" "d" "8") - foreach(kind ${kinds}) - set(lib_name ${name}_${kind}) - set(versioned_lib_name ${name}_${version}_${kind}) - - if((EXISTS ${${uppercase_name}_LIB${kind}}) AND (EXISTS ${${uppercase_name}_INC${kind}})) - get_filename_component(lib_dir ${${uppercase_name}_LIB${kind}} DIRECTORY) - find_library(w3emc_path_${kind} NAMES ${versioned_lib_name} PATHS ${lib_dir} NO_DEFAULT_PATH) - - add_library(${lib_name} STATIC IMPORTED) - set_target_properties(${lib_name} PROPERTIES - IMPORTED_LOCATION ${w3emc_path_${kind}} - INTERFACE_INCLUDE_DIRECTORIES ${${uppercase_name}_INC${kind}}) - endif() - endforeach() -endif() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(w3emc - REQUIRED_VARS w3emc_path_d) diff --git a/cmake/Modules/Findw3nco.cmake b/cmake/Modules/Findw3nco.cmake deleted file mode 100644 index e2d8c846a..000000000 --- a/cmake/Modules/Findw3nco.cmake +++ /dev/null @@ -1,32 +0,0 @@ -# This module looks for environment variables detailing where W3NCO lib is -# If variables are not set, W3NCO will be built from external source -if(DEFINED ENV{W3NCO_LIBd} ) - set(W3NCO_LIBd $ENV{W3NCO_LIBd} CACHE STRING "W3NCO_d Library Location" ) - set(W3NCO_LIB4 $ENV{W3NCO_LIB4} CACHE STRING "W3NCO_4 Library Location" ) - set(W3NCO_LIB8 $ENV{W3NCO_LIB8} CACHE STRING "W3NCO_4 Library Location" ) - - set(name "w3nco") - string(TOUPPER ${name} uppercase_name) - - string(REGEX MATCH "(v[0-9]+\\.[0-9]+\\.[0-9]+)" _ ${${uppercase_name}_LIBd}) - set(version ${CMAKE_MATCH_1}) - - set(kinds "4" "d" "8") - foreach(kind ${kinds}) - set(lib_name ${name}_${kind}) - set(versioned_lib_name ${name}_${version}_${kind}) - - if(EXISTS ${${uppercase_name}_LIB${kind}} ) - get_filename_component(lib_dir ${${uppercase_name}_LIB${kind}} DIRECTORY) - find_library(w3nco_path_${kind} NAMES ${versioned_lib_name} PATHS ${lib_dir} NO_DEFAULT_PATH) - - add_library(${lib_name} STATIC IMPORTED) - set_target_properties(${lib_name} PROPERTIES - IMPORTED_LOCATION ${w3nco_path_${kind}}) - endif() - endforeach() -endif() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(w3nco - REQUIRED_VARS w3nco_path_d) diff --git a/cmake/Modules/NewCMake/CMakeParseArguments.cmake b/cmake/Modules/NewCMake/CMakeParseArguments.cmake deleted file mode 100644 index 7ee2bbace..000000000 --- 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 fd8891cf2..000000000 --- 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 5cd2a2afe..000000000 --- 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 30f912c62..000000000 --- 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 be9d19d43..000000000 --- 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 793858716..000000000 --- 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 a25452385..000000000 --- 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 b8a308a4b..000000000 --- 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 4d43a04d6..000000000 --- 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 67f6bd6f2..000000000 --- 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 6821cee4f..000000000 --- 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 dce6f9926..000000000 --- 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/comp_src.pl b/cmake/Modules/comp_src.pl deleted file mode 100755 index 510be2504..000000000 --- a/cmake/Modules/comp_src.pl +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/perl - - @list = @ARGV; - foreach(@list) { - $file = $_; - $compfile = "../../../P2/cmake/Modules/".$file; - $diffs = `diff $file $compfile`; - if($diffs != '') { - print "------------------------------------\n"; - print "$file\n"; - print "$diffs\n"; - print "------------------------------------\n"; - } - } - diff --git a/cmake/Modules/findHelpers.cmake b/cmake/Modules/findHelpers.cmake deleted file mode 100644 index 6b9d2ce28..000000000 --- a/cmake/Modules/findHelpers.cmake +++ /dev/null @@ -1,65 +0,0 @@ - -function (findSrc varName version varDir ) - if(EXISTS ${CMAKE_SOURCE_DIR}/libsrc/${varName}) - message("setting source for ${varName} to be in libsrc") - set( ${varDir} "${CMAKE_SOURCE_DIR}/libsrc/${varName}" PARENT_SCOPE) - set( ${varCacheName} "${CMAKE_SOURCE_DIR}/libsrc/${varName}" CACHE STRING "" FORCE ) - else() - message("ProdGSI/libsrc directory not pulled from repo. Either clone with recursive or specify location of library sources") - endif() -endfunction() - -function (findInc incName version incFile ) - cmake_policy(SET CMP0011 NEW) - cmake_policy(SET CMP0009 NEW) - STRING(COMPARE EQUAL ${incFile} "CRTM_INC" USECRTMBASE ) - if(( USECRTMBASE ) AND ( CRTM_BASE )) - execute_process(COMMAND find ${CRTM_BASE} -iname ${incName}_module.mod RESULT_VARIABLE res OUTPUT_VARIABLE INCFILES) - else() - if(crayComp) - if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - execute_process(COMMAND find ${COREPATH}/${incName}/v${${version}}/intel -iname ${incName}_module.mod RESULT_VARIABLE res OUTPUT_VARIABLE INCFILES) - else() - execute_process(COMMAND find ${COREPATH}/${incName}/v${${version}}/cray -iname ${incName}_module.mod RESULT_VARIABLE res OUTPUT_VARIABLE INCFILES) - endif() - else() - execute_process(COMMAND find ${COREPATH}/${incName} -iname ${incName}_module.mod RESULT_VARIABLE res OUTPUT_VARIABLE INCFILES) - endif() - if( NOT (INCFILES) ) - execute_process(COMMAND find ${COREPATH}/sorc -iname ${incName}_module.mod RESULT_VARIABLE res OUTPUT_VARIABLE INCFILES) - endif() - endif() - if( INCFILES ) - string(REGEX REPLACE "\n" ";" INCFILES ${INCFILES} ) - endif() - foreach( INC_FILE in ${INCFILES} ) - message("found ${INC_FILE}") - string(REGEX REPLACE "${incName}_module.mod" "" INCPATH ${INC_FILE} ) - set( ${incFile} ${INCPATH} PARENT_SCOPE ) - return() - endforeach() - file(GLOB_RECURSE INCFILES ${COREPATH}/${incName}_module.mod ) - list(LENGTH INCFILES numFiles) - if(numFiles EQUAL 1) - get_filename_component( INCPATH ${INCFILES} DIRECTORY ) - else() - foreach( INC_FILE in ${INCFILES} ) - get_filename_component( INCPATH ${INC_FILE} DIRECTORY ) - endforeach() - endif() - set( ${incFile} ${INCPATH} PARENT_SCOPE ) -endfunction() - -function (findOtherVersion rootPath srcName srcPath newVer ) - file(GLOB SRCDIRS ${${rootPath}}/${srcName}* ) - foreach( SRC_DIR in ${SRCDIRS} ) - string(REGEX MATCH ${srcName} MATCHFOUND ${SRC_DIR} ) - if( MATCHFOUND ) - set( ${srcPath} ${SRC_DIR} PARENT_SCOPE ) - string(REGEX MATCH "[0-9].[0-9].[0-9]" ALTVER ${SRC_DIR} ) - message("Found ${ALTVER} of ${srcName}. Proceeding with Alternative") - set( ${newVer} ${ALTVER} PARENT_SCOPE ) - return() - endif() - endforeach() -endfunction() diff --git a/cmake/Modules/platforms/Cheyenne.cmake b/cmake/Modules/platforms/Cheyenne.cmake deleted file mode 100644 index 764a2bffa..000000000 --- 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_ ${MPI3FLAG} ${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 54429b1a6..000000000 --- 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_ ${MPI3FLAG} ${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 d897400e6..000000000 --- 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} ${MPI3FLAG} ${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 9945c4bfd..000000000 --- a/cmake/Modules/platforms/Generic.cmake +++ /dev/null @@ -1,14 +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_ ${MPI3FLAG} ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "ENKF Fortran Flags") - -endmacro() diff --git a/cmake/Modules/platforms/Generic.cmake.orig b/cmake/Modules/platforms/Generic.cmake.orig deleted file mode 100644 index 1adc85d4f..000000000 --- a/cmake/Modules/platforms/Generic.cmake.orig +++ /dev/null @@ -1,25 +0,0 @@ -macro (setGeneric) - message("Setting paths for Generic System") -<<<<<<< HEAD -# option(FIND_HDF5 "Try to Find HDF5 libraries" OFF) -# option(FIND_HDF5_HL "Try to Find HDF5 libraries" OFF) - option(BUILD_CORELIBS "Build core libs from source" ON) - set(HOST_FLAG "-xHOST" CACHE INTERNAL "Host Flag") -======= - 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 "-axSSE4.2,AVX,CORE-AVX2" CACHE INTERNAL "Host Flag") - else() - set(HOST_FLAG "-xHOST" CACHE INTERNAL "Host Flag") - endif() ->>>>>>> origin/master - set(MKL_FLAG "-mkl" CACHE INTERNAL "MKL Flag") - set(GSI_Intel_Platform_FLAGS "${HOST_FLAG} -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_ ${MPI3FLAG} ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "ENKF Fortran Flags") -<<<<<<< HEAD - option(HDF5_USE_STATIC_LIBRARIES "Use only static libraries for HDF5" OFF) -======= ->>>>>>> origin/master - -endmacro() diff --git a/cmake/Modules/platforms/Hera.cmake b/cmake/Modules/platforms/Hera.cmake deleted file mode 100644 index 9fce9a3a4..000000000 --- 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" 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_ ${MPI3FLAG} ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "ENKF Fortran Flags") - set(HDF5_USE_STATIC_LIBRARIES "OFF") - - 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 8c19dd06f..000000000 --- a/cmake/Modules/platforms/Jet.cmake +++ /dev/null @@ -1,10 +0,0 @@ -macro (setJet) - message("Setting paths for Jet") - option(FIND_HDF5 "Try to Find HDF5 libraries" OFF) - 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 "${HOST_FLAG} -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_ ${MPI3FLAG} ${OpenMP_Fortran_FLAGS}" CACHE INTERNAL "ENKF Fortran Flags") -endmacro() - diff --git a/cmake/Modules/platforms/S4.cmake b/cmake/Modules/platforms/S4.cmake deleted file mode 100644 index 1a5fe7ec7..000000000 --- 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 "-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_ ${MPI3FLAG} ${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 1c9cf712c..000000000 --- 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 ccc2a4f9c..000000000 --- a/cmake/Modules/platforms/WCOSS-D.cmake +++ /dev/null @@ -1,51 +0,0 @@ -macro (setWCOSS_D) - message("Setting paths for Dell") - 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 -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_ ${MPI3FLAG} ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "ENKF Fortran Flags") - - set(HDF5_USE_STATIC_LIBRARIES "ON" CACHE INTERNAL "" ) - 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.2.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 81b129739..000000000 --- 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/setGNUFlags.cmake b/cmake/Modules/setGNUFlags.cmake deleted file mode 100644 index c47f56eee..000000000 --- a/cmake/Modules/setGNUFlags.cmake +++ /dev/null @@ -1,62 +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 " -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(NDATE_Fortran_FLAGS "-fconvert=big-endian -DCOMMCODE -DLINUX -DUPPLITTLEENDIAN -O3 -Wl,-noinhibit-exec" 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 " -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(NDATE_Fortran_FLAGS "-fconvert=big-endian -DCOMMCODE -DLINUX -DUPPLITTLEENDIAN -g -fbacktrace -Wl,-noinhibit-exec" 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 a4f3628b3..000000000 --- a/cmake/Modules/setHOST.cmake +++ /dev/null @@ -1,85 +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} ) - 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 - string(REGEX MATCH "m[0-9][0-9]a" HOST-WCOSS_D ${HOSTNAME} ) - 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 "discover" HOST-Discover ${HOSTNAME} ) - string(REGEX MATCH "cheyenne" HOST-Cheyenne ${HOSTNAME} ) - message("done figuring out host--${HOSTNAME}") - if ( BUILD_CORELIBS ) - MESSAGE(STATUS "BUILD_CORELIBS manually-specified as ON") - set( host "GENERIC" ) - set( HOST-Generic "TRUE" ) - setGeneric() - elseif(HOST-Jet) - option(BUILD_CORELIBS "Build the Core libraries " ON) - set( host "Jet" ) - set( HOST-Jet "TRUE" ) - setJet() - elseif( HOST-S4 ) - option(BUILD_CORELIBS "Build the Core libraries " ON) - 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-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" ) - 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 bd968fc76..000000000 --- a/cmake/Modules/setIntelFlags.cmake +++ /dev/null @@ -1,87 +0,0 @@ -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 -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 -convert big_endian -assume byterecl -fp-model strict ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set (W3NCO_Fortran_FLAGS " -O3 -auto -assume nocc_omp -i -r8 -convert big_endian -assume byterecl -fp-model strict ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set (W3NCO_4_Fortran_FLAGS " -O3 -auto -assume nocc_omp -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" CACHE INTERNAL "" ) - set(UTIL_Fortran_FLAGS "-O3 ${HOST_FLAG} -warn all -implicitnone -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" CACHE INTERNAL "") -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 -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 -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 -r8 -convert big_endian -assume byterecl -fp-model strict ${OpenMP_Fortran_FLAGS} " CACHE INTERNAL "" ) - set(W3NCO_4_Fortran_FLAGS " -g -auto -assume nocc_omp -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(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 "") -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 -mcmodel medium -shared-intel -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_ ${MPI3FLAG} ${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 3e63ba4ce..000000000 --- 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 " -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(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 " -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(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 728e1a3e7..000000000 --- a/cmake/Modules/setPlatformVariables.cmake +++ /dev/null @@ -1,10 +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/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/Generic.cmake) From 722dd03cddfae7a0d9cc5a26a3e5114e1eb457c5 Mon Sep 17 00:00:00 2001 From: Denise Worthen Date: Sun, 5 Feb 2023 10:48:17 -0500 Subject: [PATCH 4/9] updates for additional configurations * allow additional ATM-OCN resolutions * remove references to mastertask, since code runs on single PE * apply emacs indenting --- reg_tests/cpld_gridgen/rt.conf | 9 + reg_tests/cpld_gridgen/rt.sh | 422 +++++++++--------- sorc/cpld_gridgen.fd/angles.F90 | 224 +++++----- sorc/cpld_gridgen.fd/charstrings.F90 | 4 +- sorc/cpld_gridgen.fd/cicegrid.F90 | 128 +++--- sorc/cpld_gridgen.fd/debugprint.F90 | 74 ++-- sorc/cpld_gridgen.fd/gen_fixgrid.F90 | 623 +++++++++++++-------------- sorc/cpld_gridgen.fd/grdvars.F90 | 354 +++++++-------- sorc/cpld_gridgen.fd/inputnml.F90 | 66 +-- sorc/cpld_gridgen.fd/mapped_mask.F90 | 146 ++++--- sorc/cpld_gridgen.fd/postwgts.F90 | 186 ++++---- sorc/cpld_gridgen.fd/scripgrid.F90 | 302 +++++++------ sorc/cpld_gridgen.fd/topoedits.F90 | 390 ++++++++--------- sorc/cpld_gridgen.fd/tripolegrid.F90 | 252 ++++++----- sorc/cpld_gridgen.fd/vartypedefs.F90 | 364 ++++++++-------- sorc/cpld_gridgen.fd/vertices.F90 | 238 +++++----- ush/cpld_gridgen.sh | 141 +++--- 17 files changed, 1949 insertions(+), 1974 deletions(-) diff --git a/reg_tests/cpld_gridgen/rt.conf b/reg_tests/cpld_gridgen/rt.conf index 7c263f631..fcb42bb1c 100644 --- a/reg_tests/cpld_gridgen/rt.conf +++ b/reg_tests/cpld_gridgen/rt.conf @@ -4,3 +4,12 @@ C384_025 | C192_050 | C384_025 C096_100 | C384_025 + +# Non-baseline configurations + #C3072_025 | + #C1152_025 | + #C768_025 | + + #C192_025 | + #C048_500 | C384_025 + #C096_500 | C384_025 \ No newline at end of file diff --git a/reg_tests/cpld_gridgen/rt.sh b/reg_tests/cpld_gridgen/rt.sh index 9a947391a..0d2700ddc 100755 --- a/reg_tests/cpld_gridgen/rt.sh +++ b/reg_tests/cpld_gridgen/rt.sh @@ -1,98 +1,100 @@ #!/bin/bash set -eu +SECONDS=0 + error() { - echo - echo "$@" 1>&2 - exit 1 + echo + echo "$@" 1>&2 + exit 1 } usage() { - echo - echo "Usage: $program [-c] [-m] [-h] [-b]" - echo - echo " -b build the executable" - echo - echo " -c create a new baseline" - echo - echo " -m compare against the new baseline" - echo - echo " -h display this help and exit" - echo - echo " Examples" - echo - echo " './rt.sh -b' build exe file. compare against the existing baseline" - echo " './rt.sh -bc' build exe file. create a new baseline" - echo " './rt.sh -m' do not build exe file. compare against the new baseline" - echo + echo + echo "Usage: $program [-c] [-m] [-h] [-b]" + echo + echo " -b build the executable" + echo + echo " -c create a new baseline" + echo + echo " -m compare against the new baseline" + echo + echo " -h display this help and exit" + echo + echo " Examples" + echo + echo " './rt.sh -b' build exe file. compare against the existing baseline" + echo " './rt.sh -bc' build exe file. create a new baseline" + echo " './rt.sh -m' do not build exe file. compare against the new baseline" + echo } usage_and_exit() { - usage - exit $1 + usage + exit $1 } check_results() { - [ -o xtrace ] && set_x='set -x' || set_x='set +x' - set +x - - local test_status=PASS - # verification run - if [[ $CREATE_BASELINE = false ]]; then - - echo | tee -a $PATHRT/$REGRESSIONTEST_LOG - echo "Working dir = $RUNDIR" | tee -a $PATHRT/$REGRESSIONTEST_LOG - echo "Baseline dir = $BASELINE" | tee -a $PATHRT/$REGRESSIONTEST_LOG - echo | tee -a $PATHRT/$REGRESSIONTEST_LOG - echo "Checking test $TEST_NAME results ...." | tee -a $PATHRT/$REGRESSIONTEST_LOG - - for file in $BASELINE/*.nc; do - printf %s "Comparing " $(basename ${file}) "...." | tee -a $PATHRT/$REGRESSIONTEST_LOG - - if [[ ! -f $RUNDIR/$(basename ${file}) ]]; then - echo "....MISSING file" | tee -a $PATHRT/$REGRESSIONTEST_LOG - test_status=FAIL - else - $NCCMP -dmfqS $(basename ${file}) $file >>${PATHRT}/nccmp_${TEST_NAME}.log 2>&1 && d=$? || d=$? - if [[ $d -ne 0 ]]; then - echo "....NOT OK" | tee -a $PATHRT/$REGRESSIONTEST_LOG - test_status=FAIL - else - echo "....OK" | tee -a $PATHRT/$REGRESSIONTEST_LOG - fi - fi - done - echo | tee -a $PATHRT/$REGRESSIONTEST_LOG - - # baseline creation run - else - - echo | tee -a $PATHRT/$REGRESSIONTEST_LOG - echo "Working dir = $RUNDIR" | tee -a $PATHRT/$REGRESSIONTEST_LOG - echo "Moving baseline files to $NEW_BASELINE ...." | tee -a $PATHRT/$REGRESSIONTEST_LOG - echo | tee -a $PATHRT/$REGRESSIONTEST_LOG - - mkdir -p $NEW_BASELINE + [ -o xtrace ] && set_x='set -x' || set_x='set +x' + set +x + + local test_status=PASS + # verification run + if [[ $CREATE_BASELINE = false ]]; then + + echo | tee -a $PATHRT/$REGRESSIONTEST_LOG + echo "Working dir = $RUNDIR" | tee -a $PATHRT/$REGRESSIONTEST_LOG + echo "Baseline dir = $BASELINE" | tee -a $PATHRT/$REGRESSIONTEST_LOG + echo | tee -a $PATHRT/$REGRESSIONTEST_LOG + echo "Checking test $TEST_NAME results ...." | tee -a $PATHRT/$REGRESSIONTEST_LOG + + for file in $BASELINE/*.nc; do + printf %s "Comparing " $(basename ${file}) "...." | tee -a $PATHRT/$REGRESSIONTEST_LOG + + if [[ ! -f $RUNDIR/$(basename ${file}) ]]; then + echo "....MISSING file" | tee -a $PATHRT/$REGRESSIONTEST_LOG + test_status=FAIL + else + $NCCMP -dmfqS $(basename ${file}) $file >>${PATHRT}/nccmp_${TEST_NAME}.log 2>&1 && d=$? || d=$? + if [[ $d -ne 0 ]]; then + echo "....NOT OK" | tee -a $PATHRT/$REGRESSIONTEST_LOG + test_status=FAIL + else + echo "....OK" | tee -a $PATHRT/$REGRESSIONTEST_LOG + fi + fi + done + echo | tee -a $PATHRT/$REGRESSIONTEST_LOG + + # baseline creation run + else + + echo | tee -a $PATHRT/$REGRESSIONTEST_LOG + echo "Working dir = $RUNDIR" | tee -a $PATHRT/$REGRESSIONTEST_LOG + echo "Moving baseline files to $NEW_BASELINE ...." | tee -a $PATHRT/$REGRESSIONTEST_LOG + echo | tee -a $PATHRT/$REGRESSIONTEST_LOG + + mkdir -p $NEW_BASELINE + + for file in *.nc; do + printf %s "Moving " $file "...." | tee -a $PATHRT/$REGRESSIONTEST_LOG + + cp $file $NEW_BASELINE/$file && d=$? || d=$? + if [[ $d -ne 0 ]]; then + echo "....NOT OK" | tee -a $PATHRT/$REGRESSIONTEST_LOG + test_status=FAIL + else + echo "....OK" | tee -a $PATHRT/$REGRESSIONTEST_LOG + fi + done + echo | tee -a $PATHRT/$REGRESSIONTEST_LOG - for file in *.nc; do - printf %s "Moving " $file "...." | tee -a $PATHRT/$REGRESSIONTEST_LOG - - cp $file $NEW_BASELINE/$file && d=$? || d=$? - if [[ $d -ne 0 ]]; then - echo "....NOT OK" | tee -a $PATHRT/$REGRESSIONTEST_LOG - test_status=FAIL - else - echo "....OK" | tee -a $PATHRT/$REGRESSIONTEST_LOG - fi - done - echo | tee -a $PATHRT/$REGRESSIONTEST_LOG - - fi + fi - if [[ $test_status == FAIL ]]; then - echo "$TEST_NAME failed" >> $PATHRT/fail_test_$TEST_NAME - fi + if [[ $test_status == FAIL ]]; then + echo "$TEST_NAME failed" >> $PATHRT/fail_test_$TEST_NAME + fi } readonly program=$(basename $0) @@ -116,43 +118,43 @@ REGRESSIONTEST_LOG=RegressionTests_$target.$compiler.log rm -f fail_test* $COMPILE_LOG run_*.log nccmp_*.log summary.log if [[ $target = wcoss2 ]]; then - STMP=${STMP:-/lfs/h2/emc/stmp/$USER} - export MOM6_FIXDIR=/lfs/h2/emc/nems/noscrub/emc.nems/UFS_UTILS/reg_tests/cpld_gridgen/fix_mom6 - BASELINE_ROOT=/lfs/h2/emc/nems/noscrub/emc.nems/UFS_UTILS/reg_tests/cpld_gridgen/baseline_data - ACCOUNT=${ACCOUNT:-GFS-DEV} - export APRUN="mpiexec -n 1 -ppn 1 --cpu-bind core" - QUEUE=${QUEUE:-dev} - SBATCH_COMMAND="./cpld_gridgen.sh" - NCCMP=/lfs/h2/emc/global/noscrub/George.Gayno/util/nccmp/nccmp-1.8.5.0/src/nccmp + STMP=${STMP:-/lfs/h2/emc/stmp/$USER} + export MOM6_FIXDIR=/lfs/h2/emc/nems/noscrub/emc.nems/UFS_UTILS/reg_tests/cpld_gridgen/fix_mom6 + BASELINE_ROOT=/lfs/h2/emc/nems/noscrub/emc.nems/UFS_UTILS/reg_tests/cpld_gridgen/baseline_data + ACCOUNT=${ACCOUNT:-GFS-DEV} + export APRUN="mpiexec -n 1 -ppn 1 --cpu-bind core" + QUEUE=${QUEUE:-dev} + SBATCH_COMMAND="./cpld_gridgen.sh" + NCCMP=/lfs/h2/emc/global/noscrub/George.Gayno/util/nccmp/nccmp-1.8.5.0/src/nccmp elif [[ $target = hera ]]; then - STMP=${STMP:-/scratch1/NCEPDEV/stmp4/$USER} - export MOM6_FIXDIR=/scratch1/NCEPDEV/nems/role.ufsutils/ufs_utils/reg_tests/cpld_gridgen/fix_mom6 - BASELINE_ROOT=/scratch1/NCEPDEV/nems/role.ufsutils/ufs_utils/reg_tests/cpld_gridgen/baseline_data - ACCOUNT=${ACCOUNT:-nems} - QUEUE=${QUEUE:-batch} - NCCMP=nccmp - PARTITION=hera - SBATCH_COMMAND="./cpld_gridgen.sh" + STMP=${STMP:-/scratch1/NCEPDEV/stmp4/$USER} + export MOM6_FIXDIR=/scratch1/NCEPDEV/nems/role.ufsutils/ufs_utils/reg_tests/cpld_gridgen/fix_mom6 + BASELINE_ROOT=/scratch1/NCEPDEV/nems/role.ufsutils/ufs_utils/reg_tests/cpld_gridgen/baseline_data + ACCOUNT=${ACCOUNT:-nems} + QUEUE=${QUEUE:-batch} + NCCMP=nccmp + PARTITION=hera + SBATCH_COMMAND="./cpld_gridgen.sh" elif [[ $target = orion ]]; then - STMP=${STMP:-/work/noaa/stmp/$USER} - export MOM6_FIXDIR=/work/noaa/nems/role-nems/ufs_utils/reg_tests/cpld_gridgen/fix_mom6 - BASELINE_ROOT=/work/noaa/nems/role-nems/ufs_utils/reg_tests/cpld_gridgen/baseline_data - ACCOUNT=${ACCOUNT:-nems} - QUEUE=${QUEUE:-batch} - NCCMP=nccmp - PARTITION=orion - ulimit -s unlimited - SBATCH_COMMAND="./cpld_gridgen.sh" + STMP=${STMP:-/work/noaa/stmp/$USER} + export MOM6_FIXDIR=/work/noaa/nems/role-nems/ufs_utils/reg_tests/cpld_gridgen/fix_mom6 + BASELINE_ROOT=/work/noaa/nems/role-nems/ufs_utils/reg_tests/cpld_gridgen/baseline_data + ACCOUNT=${ACCOUNT:-nems} + QUEUE=${QUEUE:-batch} + NCCMP=nccmp + PARTITION=orion + ulimit -s unlimited + SBATCH_COMMAND="./cpld_gridgen.sh" elif [[ $target = jet ]]; then - STMP=${STMP:-/lfs4/HFIP/h-nems/$USER} - export MOM6_FIXDIR=/lfs4/HFIP/hfv3gfs/emc.nemspara/role.ufsutils/ufs_utils/reg_tests/cpld_gridgen/fix_mom6 - BASELINE_ROOT=/lfs4/HFIP/hfv3gfs/emc.nemspara/role.ufsutils/ufs_utils/reg_tests/cpld_gridgen/baseline_data - ACCOUNT=${ACCOUNT:-h-nems} - QUEUE=${QUEUE:-batch} - NCCMP=nccmp - PARTITION=xjet - ulimit -s unlimited - SBATCH_COMMAND="./cpld_gridgen.sh" + STMP=${STMP:-/lfs4/HFIP/h-nems/$USER} + export MOM6_FIXDIR=/lfs4/HFIP/hfv3gfs/emc.nemspara/role.ufsutils/ufs_utils/reg_tests/cpld_gridgen/fix_mom6 + BASELINE_ROOT=/lfs4/HFIP/hfv3gfs/emc.nemspara/role.ufsutils/ufs_utils/reg_tests/cpld_gridgen/baseline_data + ACCOUNT=${ACCOUNT:-h-nems} + QUEUE=${QUEUE:-batch} + NCCMP=nccmp + PARTITION=xjet + ulimit -s unlimited + SBATCH_COMMAND="./cpld_gridgen.sh" fi NEW_BASELINE_ROOT=$STMP/CPLD_GRIDGEN/BASELINE RUNDIR_ROOT=$STMP/CPLD_GRIDGEN/rt_$$ @@ -160,41 +162,41 @@ RUNDIR_ROOT=$STMP/CPLD_GRIDGEN/rt_$$ BUILD_EXE=false CREATE_BASELINE=false while getopts :bcmh opt; do - case $opt in - b) - BUILD_EXE=true - ;; - c) - CREATE_BASELINE=true - ;; - m) - BASELINE_ROOT=$NEW_BASELINE_ROOT - ;; - h) - usage_and_exit 0 - ;; - '?') - error "$program: invalid option" - ;; - esac + case $opt in + b) + BUILD_EXE=true + ;; + c) + CREATE_BASELINE=true + ;; + m) + BASELINE_ROOT=$NEW_BASELINE_ROOT + ;; + h) + usage_and_exit 0 + ;; + '?') + error "$program: invalid option" + ;; + esac done # Build the executable file if [[ $BUILD_EXE = true ]]; then - cd $PATHTR - rm -rf $PATHTR/build $PATHTR/exec $PATHTR/lib - ./build_all.sh >$PATHRT/$COMPILE_LOG 2>&1 && d=$? || d=$? - if [[ d -ne 0 ]]; then - error "Build did not finish successfully. Check $COMPILE_LOG" - else - echo "Build was successful" - fi + cd $PATHTR + rm -rf $PATHTR/build $PATHTR/exec $PATHTR/lib + ./build_all.sh >$PATHRT/$COMPILE_LOG 2>&1 && d=$? || d=$? + if [[ d -ne 0 ]]; then + error "Build did not finish successfully. Check $COMPILE_LOG" + else + echo "Build was successful" + fi fi if [[ ! -f $PATHTR/exec/cpld_gridgen ]]; then - error "cpld_gridgen exe file is not found in $PATHTR/exe/. Try -b to build or -h for help." + error "cpld_gridgen exe file is not found in $PATHTR/exe/. Try -b to build or -h for help." else - echo "cpld_gridgen exe file is found in $PATHTR/exec/" + echo "cpld_gridgen exe file is found in $PATHTR/exec/" fi module use $PATHTR/modulefiles @@ -202,8 +204,8 @@ module load build.$target.$compiler module list if [[ $CREATE_BASELINE = true ]]; then - rm -rf $NEW_BASELINE_ROOT - mkdir -p $NEW_BASELINE_ROOT + rm -rf $NEW_BASELINE_ROOT + mkdir -p $NEW_BASELINE_ROOT fi date > $PATHRT/$REGRESSIONTEST_LOG @@ -212,92 +214,98 @@ echo "Start Regression test" | tee -a $PATHRT/$REGRESSIONTEST_LOG # Run tests specified in $TESTS_FILE while read -r line || [ "$line" ]; do - line="${line#"${line%%[![:space:]]*}"}" - [[ ${#line} == 0 ]] && continue - [[ $line =~ \# ]] && continue - - TEST_NAME=$(echo $line | cut -d'|' -f1 | sed -e 's/^ *//' -e 's/ *$//') - DEP_NAME=$(echo $line | cut -d'|' -f2 | sed -e 's/^ *//' -e 's/ *$//') - TEST_NAME=${TEST_NAME##*_} - DEP_NAME=${DEP_NAME##*_} - - cd $PATHRT - RUNDIR=$RUNDIR_ROOT/$TEST_NAME - BASELINE=$BASELINE_ROOT/$TEST_NAME - NEW_BASELINE=$NEW_BASELINE_ROOT/$TEST_NAME - DEPDIR=$RUNDIR_ROOT/$DEP_NAME - mkdir -p $RUNDIR - - # OUTDIR_PATH is passed down to $PATHTR/ush/cpld_gridgen.sh - # It MUST be set - export OUTDIR_PATH=$RUNDIR - - if [[ -n $DEP_NAME ]]; then - cp $DEPDIR/Ct.mx025_SCRIP.nc $RUNDIR >/dev/null 2>&1 && d=$? || d=$? - if [[ $d -eq 1 ]]; then - error "DEPDIR $DEPDIR does not exist. Dependency not met" + line="${line#"${line%%[![:space:]]*}"}" + [[ ${#line} == 0 ]] && continue + [[ $line =~ \# ]] && continue + + TEST_NAME=$(echo $line | cut -d'|' -f1 | sed -e 's/^ *//' -e 's/ *$//') + DEP_NAME=$(echo $line | cut -d'|' -f2 | sed -e 's/^ *//' -e 's/ *$//') + MOSAICRES=${TEST_NAME%_*} + TEST_NAME=${TEST_NAME##*_} + DEP_NAME=${DEP_NAME##*_} + + cd $PATHRT + RUNDIR=$RUNDIR_ROOT/$TEST_NAME + BASELINE=$BASELINE_ROOT/$TEST_NAME + NEW_BASELINE=$NEW_BASELINE_ROOT/$TEST_NAME + DEPDIR=$RUNDIR_ROOT/$DEP_NAME + mkdir -p $RUNDIR + + # OUTDIR_PATH is passed down to $PATHTR/ush/cpld_gridgen.sh + # It MUST be set + export OUTDIR_PATH=$RUNDIR + export MOSAICRES=$MOSAICRES + + if [[ -n $DEP_NAME ]]; then + cp $DEPDIR/Ct.mx025_SCRIP.nc $RUNDIR >/dev/null 2>&1 && d=$? || d=$? + if [[ $d -eq 1 ]]; then + error "DEPDIR $DEPDIR does not exist. Dependency not met" + fi fi - fi - cp $PATHTR/exec/cpld_gridgen $RUNDIR - cp $PATHTR/ush/cpld_gridgen.sh $RUNDIR - cp $PATHRT/parm/grid.nml.IN $RUNDIR - cd $RUNDIR + cp $PATHTR/exec/cpld_gridgen $RUNDIR + cp $PATHTR/ush/cpld_gridgen.sh $RUNDIR + cp $PATHRT/parm/grid.nml.IN $RUNDIR + cd $RUNDIR - if [[ $target = wcoss2 ]]; then + if [[ $target = wcoss2 ]]; then -# rm -f $RUNDIR/bad.${TEST_NAME} + # rm -f $RUNDIR/bad.${TEST_NAME} - TEST=$(qsub -V -o $PATHRT/run_${TEST_NAME}.log -e $PATHRT/run_${TEST_NAME}.log -q $QUEUE -A $ACCOUNT \ - -Wblock=true -l walltime=00:05:00 -N $TEST_NAME -l select=1:ncpus=1:mem=8GB -v RESNAME=$TEST_NAME $SBATCH_COMMAND) + TEST=$(qsub -V -o $PATHRT/run_${TEST_NAME}.log -e $PATHRT/run_${TEST_NAME}.log -q $QUEUE -A $ACCOUNT \ + -Wblock=true -l walltime=00:05:00 -N $TEST_NAME -l select=1:ncpus=1:mem=8GB -v RESNAME=$TEST_NAME $SBATCH_COMMAND) -# qsub -o $PATHRT/run_${TEST_NAME}.log -e $PATHRT/run_${TEST_NAME}.log -q $QUEUE -A $ACCOUNT \ -# -Wblock=true -l walltime=00:01:00 -N chgres_summary -l select=1:ncpus=1:mem=100MB -W depend=afternotok:$TEST << EOF -#!/bin/bash -# touch $RUNDIR/bad.${TEST_NAME} -#EOF -# if [[ -f $RUNDIR/bad.${TEST_NAME} ]]; then -# error "Batch job for test $TEST_NAME did not finish successfully. Refer to run_${TEST_NAME}.log" -# fi + # qsub -o $PATHRT/run_${TEST_NAME}.log -e $PATHRT/run_${TEST_NAME}.log -q $QUEUE -A $ACCOUNT \ + # -Wblock=true -l walltime=00:01:00 -N chgres_summary -l select=1:ncpus=1:mem=100MB -W depend=afternotok:$TEST << EOF + #!/bin/bash + # touch $RUNDIR/bad.${TEST_NAME} + #EOF + # if [[ -f $RUNDIR/bad.${TEST_NAME} ]]; then + # error "Batch job for test $TEST_NAME did not finish successfully. Refer to run_${TEST_NAME}.log" + # fi - else - sbatch --wait --ntasks-per-node=1 --nodes=1 --mem=4G -t 0:05:00 -A $ACCOUNT -q $QUEUE -J $TEST_NAME \ - --partition=$PARTITION -o $PATHRT/run_${TEST_NAME}.log -e $PATHRT/run_${TEST_NAME}.log \ - --wrap "$SBATCH_COMMAND $TEST_NAME" && d=$? || d=$? + else + sbatch --wait --ntasks-per-node=1 --nodes=1 --exclusive -t 1:00:00 -A $ACCOUNT -q $QUEUE -J $TEST_NAME \ + --partition=$PARTITION -o $PATHRT/run_${TEST_NAME}.log -e $PATHRT/run_${TEST_NAME}.log \ + --wrap "$SBATCH_COMMAND $TEST_NAME" && d=$? || d=$? - if [[ d -ne 0 ]]; then - error "Batch job for test $TEST_NAME did not finish successfully. Refer to run_${TEST_NAME}.log" - fi + if [[ d -ne 0 ]]; then + error "Batch job for test $TEST_NAME did not finish successfully. Refer to run_${TEST_NAME}.log" + fi - fi + fi - check_results + check_results done <$TESTS_FILE if [[ $? -ne 0 ]]; then - error "Run test while loop did not finish properly" + error "Run test while loop did not finish properly" fi cd $PATHRT FAIL_FILES="fail_test_*" for file in $FAIL_FILES; do - if [[ -f "$file" ]]; then - cat "$file" >> fail_test - fi + if [[ -f "$file" ]]; then + cat "$file" >> fail_test + fi done if [[ -e fail_test ]]; then - echo | tee -a $REGRESSIONTEST_LOG - for file in fail_test_*; do - cat $file >>$REGRESSIONTEST_LOG - cat $file >>summary.log - done - - echo | tee -a $REGRESSIONTEST_LOG - echo "REGRESSION TEST FAILED" | tee -a $REGRESSIONTEST_LOG + echo | tee -a $REGRESSIONTEST_LOG + for file in fail_test_*; do + cat $file >>$REGRESSIONTEST_LOG + cat $file >>summary.log + done + + echo | tee -a $REGRESSIONTEST_LOG + echo "REGRESSION TEST FAILED" | tee -a $REGRESSIONTEST_LOG else - echo | tee -a $REGRESSIONTEST_LOG - echo "REGRESSION TEST WAS SUCCESSFUL" | tee -a $REGRESSIONTEST_LOG - echo "All tests passed" >>summary.log + echo | tee -a $REGRESSIONTEST_LOG + echo "REGRESSION TEST WAS SUCCESSFUL" | tee -a $REGRESSIONTEST_LOG + echo "All tests passed" >>summary.log fi date >> $REGRESSIONTEST_LOG + +elapsed_time=$( printf '%02dh:%02dm:%02ds\n' $((SECONDS%86400/3600)) $((SECONDS%3600/60)) $((SECONDS%60)) ) +echo "Elapsed time: ${elapsed_time}. Have a nice day!" >> ${REGRESSIONTEST_LOG} +echo "Elapsed time: ${elapsed_time}. Have a nice day!" diff --git a/sorc/cpld_gridgen.fd/angles.F90 b/sorc/cpld_gridgen.fd/angles.F90 index 99d323f3d..31ac0bbcb 100644 --- a/sorc/cpld_gridgen.fd/angles.F90 +++ b/sorc/cpld_gridgen.fd/angles.F90 @@ -14,179 +14,177 @@ module angles use grdvars, only : x,y,xsgp1,ysgp1,sg_maxlat use grdvars, only : latBu,lonBu,lonCt use grdvars, only : angq,anglet - use grdvars, only : mastertask, debug + use grdvars, only : debug implicit none - contains -!> Find the rotation angle on corner grid (Bu) points using the full MOM6 supergrid -!! -!! @author Denise.Worthen@noaa.gov +contains + !> Find the rotation angle on corner grid (Bu) points using the full MOM6 supergrid + !! + !! @author Denise.Worthen@noaa.gov subroutine find_angq ! local variables integer :: i,j,i1,i2,m,n - + ! pole locations on SG integer(int_kind) :: ipolesg(2) - + ! from geolonB fix in MOM6 real(dbl_kind) :: len_lon ! The periodic range of longitudes, usually 360 degrees. real(dbl_kind) :: pi_720deg ! One quarter the conversion factor from degrees to radians. real(dbl_kind) :: lonB(2,2) ! The longitude of a point, shifted to have about the same value. real(dbl_kind) :: lon_scale = 0.0 -!--------------------------------------------------------------------- -! to find angleq on seam, replicate supergrid values across seam -!--------------------------------------------------------------------- + !--------------------------------------------------------------------- + ! to find angleq on seam, replicate supergrid values across seam + !--------------------------------------------------------------------- - angq = 0.0 + angq = 0.0 xsgp1 = 0.0; ysgp1 = 0.0 !pole on supergrid ipolesg = -1 - j = ny + j = ny do i = 1,nx/2 - if(y(i,j) .eq. sg_maxlat)ipolesg(1) = i + if(y(i,j) .eq. sg_maxlat)ipolesg(1) = i enddo do i = nx/2+1,nx - if(y(i,j) .eq. sg_maxlat)ipolesg(2) = i + if(y(i,j) .eq. sg_maxlat)ipolesg(2) = i enddo - if(mastertask .and. debug)print *,'poles found at ',ipolesg + if(debug)print *,'poles found at ',ipolesg xsgp1(:,0:ny) = x(:,0:ny) ysgp1(:,0:ny) = y(:,0:ny) !check do i = ipolesg(1)-5,ipolesg(1)+5 - i2 = ipolesg(2)+(ipolesg(1)-i)+1 - if(mastertask .and. debug)print *,i,i2 + i2 = ipolesg(2)+(ipolesg(1)-i)+1 + if(debug)print *,i,i2 enddo - print * + print * do i = ipolesg(2)-5,ipolesg(2)+5 - i2 = ipolesg(2)+(ipolesg(1)-i)+1 - if(mastertask .and. debug)print *,i,i2 + i2 = ipolesg(2)+(ipolesg(1)-i)+1 + if(debug)print *,i,i2 enddo - + !replicate supergrid across pole do i = 1,nx - i2 = ipolesg(2)+(ipolesg(1)-i) - xsgp1(i,ny+1) = xsgp1(i2,ny) - ysgp1(i,ny+1) = ysgp1(i2,ny) + i2 = ipolesg(2)+(ipolesg(1)-i) + xsgp1(i,ny+1) = xsgp1(i2,ny) + ysgp1(i,ny+1) = ysgp1(i2,ny) enddo - + !check - if(mastertask .and. debug)then - j = ny+1 + j = ny+1 i1 = ipolesg(1); i2 = ipolesg(2)-(ipolesg(1)-i1) - print *,'replicate X across seam on SG' - print *,xsgp1(i1-2,j),xsgp1(i2+2,j) - print *,xsgp1(i1-1,j),xsgp1(i2+1,j) - print *,xsgp1(i1, j),xsgp1(i2, j) - print *,xsgp1(i1+1,j),xsgp1(i2-1,j) - print *,xsgp1(i1+2,j),xsgp1(i2-2,j) - - print *,'replicate Y across seam on SG' - print *,ysgp1(i1-2,j),ysgp1(i2+2,j) - print *,ysgp1(i1-1,j),ysgp1(i2+1,j) - print *,ysgp1(i1, j),ysgp1(i2, j) - print *,ysgp1(i1+1,j),ysgp1(i2-1,j) - print *,ysgp1(i1+2,j),ysgp1(i2-2,j) - end if - -!--------------------------------------------------------------------- -! rotation angle on supergrid vertices -! lonB: x(i-1,j-1) has same relationship to x(i,j) on SG as -! geolonT(i,j) has to geolonBu(i,j) on the reduced grid -!--------------------------------------------------------------------- - - ! constants as defined in MOM - pi_720deg = atan(1.0) / 180.0 - len_lon = 360.0 + print *,'replicate X across seam on SG' + print *,xsgp1(i1-2,j),xsgp1(i2+2,j) + print *,xsgp1(i1-1,j),xsgp1(i2+1,j) + print *,xsgp1(i1, j),xsgp1(i2, j) + print *,xsgp1(i1+1,j),xsgp1(i2-1,j) + print *,xsgp1(i1+2,j),xsgp1(i2-2,j) + + print *,'replicate Y across seam on SG' + print *,ysgp1(i1-2,j),ysgp1(i2+2,j) + print *,ysgp1(i1-1,j),ysgp1(i2+1,j) + print *,ysgp1(i1, j),ysgp1(i2, j) + print *,ysgp1(i1+1,j),ysgp1(i2-1,j) + print *,ysgp1(i1+2,j),ysgp1(i2-2,j) + + !--------------------------------------------------------------------- + ! rotation angle on supergrid vertices + ! lonB: x(i-1,j-1) has same relationship to x(i,j) on SG as + ! geolonT(i,j) has to geolonBu(i,j) on the reduced grid + !--------------------------------------------------------------------- + + ! constants as defined in MOM + pi_720deg = atan(1.0) / 180.0 + len_lon = 360.0 do j=1,ny ; do i=1,nx-1 - do n=1,2 ; do m=1,2 - lonB(m,n) = modulo_around_point(xsgp1(I+m-2,J+n-2), xsgp1(i-1,j-1), len_lon) - enddo ; enddo - lon_scale = cos(pi_720deg*(ysgp1(i-1,j-1) + ysgp1(i+1,j-1) + & - ysgp1(i-1,j+1) + ysgp1(i+1,j+1)) ) - angq(i,j) = atan2(lon_scale*((lonB(1,2) - lonB(2,1)) + (lonB(2,2) - lonB(1,1))), & - ysgp1(i-1,j+1) + ysgp1(i+1,j+1) - & - ysgp1(i-1,j-1) - ysgp1(i+1,j-1) ) - enddo ; enddo + do n=1,2 ; do m=1,2 + lonB(m,n) = modulo_around_point(xsgp1(I+m-2,J+n-2), xsgp1(i-1,j-1), len_lon) + enddo; enddo + lon_scale = cos(pi_720deg*(ysgp1(i-1,j-1) + ysgp1(i+1,j-1) + & + ysgp1(i-1,j+1) + ysgp1(i+1,j+1)) ) + angq(i,j) = atan2(lon_scale*((lonB(1,2) - lonB(2,1)) + (lonB(2,2) - lonB(1,1))), & + ysgp1(i-1,j+1) + ysgp1(i+1,j+1) - & + ysgp1(i-1,j-1) - ysgp1(i+1,j-1) ) + enddo; enddo !check - if(mastertask .and. debug) then + if(debug) then j = ny - i1 = ipolesg(1); i2 = ipolesg(2)-(ipolesg(1)-i1) - print *,'angq along seam on SG' - print *,angq(i1-2,j),angq(i2+2,j) - print *,angq(i1-1,j),angq(i2+1,j) - print *,angq(i1, j),angq(i2, j) - print *,angq(i1+1,j),angq(i2-1,j) - print *,angq(i1+2,j),angq(i2-2,j) + i1 = ipolesg(1); i2 = ipolesg(2)-(ipolesg(1)-i1) + print *,'angq along seam on SG' + print *,angq(i1-2,j),angq(i2+2,j) + print *,angq(i1-1,j),angq(i2+1,j) + print *,angq(i1, j),angq(i2, j) + print *,angq(i1+1,j),angq(i2-1,j) + print *,angq(i1+2,j),angq(i2-2,j) end if end subroutine find_angq -!> Find the rotation angle on center (Ct) grid points -!! -!! @author Denise.Worthen@noaa.gov + !> Find the rotation angle on center (Ct) grid points + !! + !! @author Denise.Worthen@noaa.gov subroutine find_ang ! local variables integer :: i,j,m,n integer :: ii,jj - + ! from geolonB fix in MOM6 real(dbl_kind) :: len_lon ! The periodic range of longitudes, usually 360 degrees. real(dbl_kind) :: pi_720deg ! One quarter the conversion factor from degrees to radians. real(dbl_kind) :: lonB(2,2) ! The longitude of a point, shifted to have about the same value. real(dbl_kind) :: lon_scale = 0.0 - -!--------------------------------------------------------------------- -! rotation angle for "use_bugs" = false case from MOM6 -! src/initialization/MOM_shared_initialization.F90 but allow for not -! having halo values -! note this does not reproduce sin_rot,cos_rot found in MOM6 output -! differences are ~O 10-6 -!--------------------------------------------------------------------- - - anglet = 0.0 - pi_720deg = atan(1.0) / 180.0 - len_lon = 360.0 - do j=1,nj; do i = 1,ni - do n=1,2 ; do m=1,2 - jj = J+n-2; ii = I+m-2 - if(jj .eq. 0)jj = 1 - if(ii .eq. 0)ii = ni + + !--------------------------------------------------------------------- + ! rotation angle for "use_bugs" = false case from MOM6 + ! src/initialization/MOM_shared_initialization.F90 but allow for not + ! having halo values + ! note this does not reproduce sin_rot,cos_rot found in MOM6 output + ! differences are ~O 10-6 + !--------------------------------------------------------------------- + + anglet = 0.0 + pi_720deg = atan(1.0) / 180.0 + len_lon = 360.0 + do j=1,nj; do i = 1,ni + do n=1,2 ; do m=1,2 + jj = J+n-2; ii = I+m-2 + if(jj .eq. 0)jj = 1 + if(ii .eq. 0)ii = ni lonB(m,n) = modulo_around_point(LonBu(ii,jj), LonCt(i,j), len_lon) - ! lonB(m,n) = modulo_around_point(LonBu(I+m-2,J+n-2), LonCt(i,j), len_lon) - enddo ; enddo - jj = j-1; ii = i-1 - if(jj .eq. 0)jj = 1 - if(ii .eq. 0)ii = ni - lon_scale = cos(pi_720deg*((LatBu(ii,jj) + LatBu(I,J)) + & - (LatBu(I,jj) + LatBu(ii,J)) ) ) + ! lonB(m,n) = modulo_around_point(LonBu(I+m-2,J+n-2), LonCt(i,j), len_lon) + enddo; enddo + jj = j-1; ii = i-1 + if(jj .eq. 0)jj = 1 + if(ii .eq. 0)ii = ni + lon_scale = cos(pi_720deg*((LatBu(ii,jj) + LatBu(I,J)) + & + (LatBu(I,jj) + LatBu(ii,J)) ) ) anglet(i,j) = atan2(lon_scale*((lonB(1,2) - lonB(2,1)) + (lonB(2,2) - lonB(1,1))), & - (LatBu(ii,J) - LatBu(I,jj)) + & - (LatBu(I,J) - LatBu(ii,jj)) ) - - !lon_scale = cos(pi_720deg*((LatBu(I-1,J-1) + LatBu(I,J)) + & - ! (LatBu(I,J-1) + LatBu(I-1,J)) ) ) + (LatBu(ii,J) - LatBu(I,jj)) + & + (LatBu(I,J) - LatBu(ii,jj)) ) + + !lon_scale = cos(pi_720deg*((LatBu(I-1,J-1) + LatBu(I,J)) + & + ! (LatBu(I,J-1) + LatBu(I-1,J)) ) ) !anglet(i,j) = atan2(lon_scale*((lonB(1,2) - lonB(2,1)) + (lonB(2,2) - lonB(1,1))), & ! (LatBu(I-1,J) - LatBu(I,J-1)) + & ! (LatBu(I,J) - LatBu(I-1,J-1)) ) - enddo ; enddo + enddo; enddo end subroutine find_ang -! ----------------------------------------------------------------------------- -!> Return the modulo value of x in an interval [xc-(Lx/2) xc+(Lx/2)] -!! If Lx<=0, then it returns x without applying modulo arithmetic. -!! -!! From src/initialization/MOM_shared_initialization.F90: -!! @param[in] x Value to which to apply modulo arithmetic -!! @param[in] xc Center of modulo range -!! @param[in] Lx Modulo range width -!! @return x_mod Value x shifted by an integer multiple of Lx to be close to xc + ! ----------------------------------------------------------------------------- + !> Return the modulo value of x in an interval [xc-(Lx/2) xc+(Lx/2)] + !! If Lx<=0, then it returns x without applying modulo arithmetic. + !! + !! From src/initialization/MOM_shared_initialization.F90: + !! @param[in] x Value to which to apply modulo arithmetic + !! @param[in] xc Center of modulo range + !! @param[in] Lx Modulo range width + !! @return x_mod Value x shifted by an integer multiple of Lx to be close to xc function modulo_around_point(x, xc, Lx) result(x_mod) use gengrid_kinds, only : dbl_kind @@ -196,9 +194,9 @@ function modulo_around_point(x, xc, Lx) result(x_mod) real(dbl_kind) :: x_mod if (Lx > 0.0) then - x_mod = modulo(x - (xc - 0.5*Lx), Lx) + (xc - 0.5*Lx) + x_mod = modulo(x - (xc - 0.5*Lx), Lx) + (xc - 0.5*Lx) else - x_mod = x + x_mod = x endif end function modulo_around_point end module angles diff --git a/sorc/cpld_gridgen.fd/charstrings.F90 b/sorc/cpld_gridgen.fd/charstrings.F90 index 93c6b304c..00deab1b4 100644 --- a/sorc/cpld_gridgen.fd/charstrings.F90 +++ b/sorc/cpld_gridgen.fd/charstrings.F90 @@ -14,8 +14,8 @@ module charstrings character(len=CL) :: dirsrc !< The source directory containing the fix files for MOM6 character(len=CL) :: dirout !< The directory where output files will be written character(len=CL) :: fv3dir !< The directory containing the FV3 mosaic files - character(len=CS) :: res !< The Ocean/Ice resolution, e.g. 100 (1deg), 050 (1/2deg), - !! 025 (1/4deg) + character(len=CS) :: res !< The Ocean/Ice resolution, e.g. 500 (5deg), 100 (1deg) + !! 050 (1/2deg), 025 (1/4deg) character(len=CS) :: atmres !< The ATM resolution, e.g. C96, C192, C384 character(len=CL) :: logmsg !< An informational message diff --git a/sorc/cpld_gridgen.fd/cicegrid.F90 b/sorc/cpld_gridgen.fd/cicegrid.F90 index aaca257da..bd7c366f2 100644 --- a/sorc/cpld_gridgen.fd/cicegrid.F90 +++ b/sorc/cpld_gridgen.fd/cicegrid.F90 @@ -7,7 +7,7 @@ module cicegrid - use grdvars, only: ni,nj,ulat,ulon,htn,hte,angle,wet4,mastertask + use grdvars, only: ni,nj,ulat,ulon,htn,hte,angle,wet4 use charstrings, only: history, logmsg use vartypedefs, only: maxvars, cicevars, cicevars_typedefine use gengrid_kinds, only: CM @@ -18,80 +18,78 @@ module cicegrid public write_cicegrid - contains -!> Write the CICE6 grid file -!! -!! @param[in] fname the name of the CICE6 grid file to write -!! -!! @author Denise.Worthen@noaa.gov - +contains + !> Write the CICE6 grid file + !! + !! @param[in] fname the name of the CICE6 grid file to write + !! + !! @author Denise.Worthen@noaa.gov + subroutine write_cicegrid(fname) - character(len=*), intent(in) :: fname + character(len=*), intent(in) :: fname - ! local variables - integer :: ii,id,rc, ncid, dim2(2) - integer :: idimid,jdimid + ! local variables + integer :: ii,id,rc, ncid, dim2(2) + integer :: idimid,jdimid - character(len=2) :: vtype - character(len=CM) :: vname - character(len=CM) :: vlong - character(len=CM) :: vunit + character(len=2) :: vtype + character(len=CM) :: vname + character(len=CM) :: vlong + character(len=CM) :: vunit -!--------------------------------------------------------------------- -! create the netcdf file -!--------------------------------------------------------------------- + !--------------------------------------------------------------------- + ! create the netcdf file + !--------------------------------------------------------------------- - ! define the output variables and file name - call cicevars_typedefine + ! define the output variables and file name + call cicevars_typedefine - rc = nf90_create(fname, nf90_write, ncid) - if(mastertask) then + rc = nf90_create(fname, nf90_write, ncid) logmsg = '==> writing CICE grid to '//trim(fname) print '(a)', trim(logmsg) if(rc .ne. 0)print '(a)', 'nf90_create = '//trim(nf90_strerror(rc)) - end if - - rc = nf90_def_dim(ncid, 'ni', ni, idimid) - rc = nf90_def_dim(ncid, 'nj', nj, jdimid) - - do ii = 1,maxvars - if(len_trim(cicevars(ii)%var_name) .gt. 0)then - vname = trim(cicevars(ii)%var_name) - vlong = trim(cicevars(ii)%long_name) - vunit = trim(cicevars(ii)%unit_name) - vtype = trim(cicevars(ii)%var_type) - - dim2(:) = (/idimid, jdimid/) - if(vtype .eq. 'r8')rc = nf90_def_var(ncid, vname, nf90_double, dim2, id) - if(vtype .eq. 'r4')rc = nf90_def_var(ncid, vname, nf90_float, dim2, id) - if(vtype .eq. 'i4')rc = nf90_def_var(ncid, vname, nf90_int, dim2, id) - rc = nf90_put_att(ncid, id, 'units', vunit) - rc = nf90_put_att(ncid, id, 'long_name', vlong) - end if - enddo - rc = nf90_put_att(ncid, nf90_global, 'history', trim(history)) - rc = nf90_enddef(ncid) - - rc = nf90_inq_varid(ncid, 'ulon', id) - rc = nf90_put_var(ncid, id, ulon) - - rc = nf90_inq_varid(ncid, 'ulat', id) - rc = nf90_put_var(ncid, id, ulat) - - rc = nf90_inq_varid(ncid, 'htn', id) - rc = nf90_put_var(ncid, id, htn) - - rc = nf90_inq_varid(ncid, 'hte', id) - rc = nf90_put_var(ncid, id, hte) - - rc = nf90_inq_varid(ncid, 'angle', id) - rc = nf90_put_var(ncid, id, angle) - - rc = nf90_inq_varid(ncid, 'kmt', id) - rc = nf90_put_var(ncid, id, int(wet4)) - - rc = nf90_close(ncid) + + rc = nf90_def_dim(ncid, 'ni', ni, idimid) + rc = nf90_def_dim(ncid, 'nj', nj, jdimid) + + do ii = 1,maxvars + if(len_trim(cicevars(ii)%var_name) .gt. 0)then + vname = trim(cicevars(ii)%var_name) + vlong = trim(cicevars(ii)%long_name) + vunit = trim(cicevars(ii)%unit_name) + vtype = trim(cicevars(ii)%var_type) + + dim2(:) = (/idimid, jdimid/) + if(vtype .eq. 'r8')rc = nf90_def_var(ncid, vname, nf90_double, dim2, id) + if(vtype .eq. 'r4')rc = nf90_def_var(ncid, vname, nf90_float, dim2, id) + if(vtype .eq. 'i4')rc = nf90_def_var(ncid, vname, nf90_int, dim2, id) + rc = nf90_put_att(ncid, id, 'units', vunit) + rc = nf90_put_att(ncid, id, 'long_name', vlong) + end if + enddo + rc = nf90_put_att(ncid, nf90_global, 'history', trim(history)) + rc = nf90_enddef(ncid) + + rc = nf90_inq_varid(ncid, 'ulon', id) + rc = nf90_put_var(ncid, id, ulon) + + rc = nf90_inq_varid(ncid, 'ulat', id) + rc = nf90_put_var(ncid, id, ulat) + + rc = nf90_inq_varid(ncid, 'htn', id) + rc = nf90_put_var(ncid, id, htn) + + rc = nf90_inq_varid(ncid, 'hte', id) + rc = nf90_put_var(ncid, id, hte) + + rc = nf90_inq_varid(ncid, 'angle', id) + rc = nf90_put_var(ncid, id, angle) + + rc = nf90_inq_varid(ncid, 'kmt', id) + rc = nf90_put_var(ncid, id, int(wet4)) + + rc = nf90_close(ncid) end subroutine write_cicegrid end module cicegrid diff --git a/sorc/cpld_gridgen.fd/debugprint.F90 b/sorc/cpld_gridgen.fd/debugprint.F90 index 93f0d98b9..71b9c289a 100644 --- a/sorc/cpld_gridgen.fd/debugprint.F90 +++ b/sorc/cpld_gridgen.fd/debugprint.F90 @@ -18,22 +18,22 @@ module debugprint private public :: checkseam, checkxlatlon, checkpoint - - contains -!> Print values across the tripole seam -!! -!! @author Denise.Worthen@noaa.gov - + +contains + !> Print values across the tripole seam + !! + !! @author Denise.Worthen@noaa.gov + subroutine checkseam - ! local variables - integer :: j,i1,i2 + ! local variables + integer :: j,i1,i2 j = nj i1 = ipole(1); i2 = ipole(2)+1 !htn must be the same along seam - j = nj + j = nj i1 = ipole(1); i2 = ipole(2)+1 print *,'HTN across seam ' print *,htn(i1-2,j),htn(i2+2,j) @@ -41,21 +41,21 @@ subroutine checkseam print *,htn(i1, j),htn(i2, j) print *,htn(i1+1,j),htn(i2-1,j) print *,htn(i1+2,j),htn(i2-2,j) - + print *,'latCv across seam ' print *,latCv(i1-2,j),latCv(i2+2,j) print *,latCv(i1-1,j),latCv(i2+1,j) print *,latCv(i1, j),latCv(i2, j) print *,latCv(i1+1,j),latCv(i2-1,j) print *,latCv(i1+2,j),latCv(i2-2,j) - + print *,'lonCv across seam ' print *,lonCv(i1-2,j),lonCv(i2+2,j) print *,lonCv(i1-1,j),lonCv(i2+1,j) print *,lonCv(i1, j),lonCv(i2, j) print *,lonCv(i1+1,j),lonCv(i2-1,j) print *,lonCv(i1+2,j),lonCv(i2-2,j) - + print *,'angleT across seam ' print *,angleT(i1-2,j),angleT(i2+2,j) print *,angleT(i1-1,j),angleT(i2+1,j) @@ -100,38 +100,38 @@ subroutine checkseam print *,lonCt(i1+3,j),lonCt(i2-3,j) print * end subroutine checkseam - + !> Print values near the poles and along the domain edges !! !! @author Denise.Worthen@noaa.gov - + subroutine checkxlatlon - - ! local variables - integer :: i + + ! local variables + integer :: i print *,'============== Ct grid ===============' print *,'============== Left pole ============' do i = ipole(1)-3,ipole(1)+3 - print '(i5,6f12.5)',i,lonCt(i,nj),xlonCt(i),lonCt(i,nj)+xlonCt(i),latCt(i,nj),xlatCt(i),latCt(i,nj)-xlatCt(i) + print '(i5,6f12.5)',i,lonCt(i,nj),xlonCt(i),lonCt(i,nj)+xlonCt(i),latCt(i,nj),xlatCt(i),latCt(i,nj)-xlatCt(i) enddo print * print *,'============ Right pole ============' do i = ipole(2)-3,ipole(2)+3 - print '(i5,6f12.5)',i,lonCt(i,nj),xlonCt(i),lonCt(i,nj)+xlonCt(i),latCt(i,nj),xlatCt(i),latCt(i,nj)-xlatCt(i) + print '(i5,6f12.5)',i,lonCt(i,nj),xlonCt(i),lonCt(i,nj)+xlonCt(i),latCt(i,nj),xlatCt(i),latCt(i,nj)-xlatCt(i) enddo print * print *,'============== Ct grid ===============' print *,'============== Left edge ============' do i = 1,5 - print '(i5,6f12.5)',i,lonCt(i,nj),xlonCt(i),lonCt(i,nj)+xlonCt(i),latCt(i,nj),xlatCt(i),latCt(i,nj)-xlatCt(i) + print '(i5,6f12.5)',i,lonCt(i,nj),xlonCt(i),lonCt(i,nj)+xlonCt(i),latCt(i,nj),xlatCt(i),latCt(i,nj)-xlatCt(i) enddo print * print *,'============== Right edge ===========' do i = ni-4,ni - print '(i5,6f12.5)',i,lonCt(i,nj),xlonCt(i),lonCt(i,nj)+xlonCt(i),latCt(i,nj),xlatCt(i),latCt(i,nj)-xlatCt(i) + print '(i5,6f12.5)',i,lonCt(i,nj),xlonCt(i),lonCt(i,nj)+xlonCt(i),latCt(i,nj),xlatCt(i),latCt(i,nj)-xlatCt(i) enddo print * @@ -139,38 +139,38 @@ subroutine checkxlatlon print *,'============== Cu grid ===============' print *,'============== Left pole =============' do i = ipole(1)-3,ipole(1)+3 - print '(i5,6f12.5)',i,lonCu(i,nj),xlonCu(i),lonCu(i,nj)+xlonCu(i),latCu(i,nj),xlatCu(i),latCu(i,nj)-xlatCu(i) + print '(i5,6f12.5)',i,lonCu(i,nj),xlonCu(i),lonCu(i,nj)+xlonCu(i),latCu(i,nj),xlatCu(i),latCu(i,nj)-xlatCu(i) enddo print * print *,'============ Right pole ============' do i = ipole(2)-3,ipole(2)+3 - print '(i5,6f12.5)',i,lonCu(i,nj),xlonCu(i),lonCu(i,nj)+xlonCu(i),latCu(i,nj),xlatCu(i),latCu(i,nj)-xlatCu(i) + print '(i5,6f12.5)',i,lonCu(i,nj),xlonCu(i),lonCu(i,nj)+xlonCu(i),latCu(i,nj),xlatCu(i),latCu(i,nj)-xlatCu(i) enddo print * print *,'============== Cu grid ===============' print *,'============== Left edge ============' do i = 1,5 - print '(i5,6f12.5)',i,lonCu(i,nj),xlonCu(i),lonCu(i,nj)+xlonCu(i),latCu(i,nj),xlatCu(i),latCu(i,nj)-xlatCu(i) + print '(i5,6f12.5)',i,lonCu(i,nj),xlonCu(i),lonCu(i,nj)+xlonCu(i),latCu(i,nj),xlatCu(i),latCu(i,nj)-xlatCu(i) enddo print * print *,'============== Right edge ===========' do i = ni-4,ni - print '(i5,6f12.5)',i,lonCu(i,nj),xlonCu(i),lonCu(i,nj)+xlonCu(i),latCu(i,nj),xlatCu(i),latCu(i,nj)-xlatCu(i) + print '(i5,6f12.5)',i,lonCu(i,nj),xlonCu(i),lonCu(i,nj)+xlonCu(i),latCu(i,nj),xlatCu(i),latCu(i,nj)-xlatCu(i) enddo print * end subroutine checkxlatlon - -!> Print values at specified point -!! -!! @author Denise.Worthen@noaa.gov - + + !> Print values at specified point + !! + !! @author Denise.Worthen@noaa.gov + subroutine checkpoint - ! local variables - integer :: i,j + ! local variables + integer :: i,j ! check i = 1; j = nj @@ -183,7 +183,7 @@ subroutine checkpoint print '(f12.5,a,f12.5)',lonBu_vert(i,j,3),' ',lonBu_vert(i,j,4) print * print * - ! check + ! check print '(f12.5,a,f12.5)',latCv_vert(i,j,2),' ',latCv_vert(i,j,1) print '(a12,f12.5)',' ',latCv(i,j) print '(f12.5,a,f12.5)',latCv_vert(i,j,3),' ',latCv_vert(i,j,4) @@ -239,9 +239,9 @@ subroutine checkpoint print *,"latCv minmax ",minval(latCv),maxval(latCv) print *,"latBu minmax ",minval(latBu),maxval(latBu) - ! print *,minval(latCt_vert),maxval(latCt_vert) - ! print *,minval(lonCt_vert),maxval(lonCt_vert) - ! print *,minval(latBu_vert),maxval(latBu_vert) - ! print *,minval(lonBu_vert),maxval(lonBu_vert) + ! print *,minval(latCt_vert),maxval(latCt_vert) + ! print *,minval(lonCt_vert),maxval(lonCt_vert) + ! print *,minval(latBu_vert),maxval(latBu_vert) + ! print *,minval(lonBu_vert),maxval(lonBu_vert) end subroutine checkpoint end module debugprint diff --git a/sorc/cpld_gridgen.fd/gen_fixgrid.F90 b/sorc/cpld_gridgen.fd/gen_fixgrid.F90 index 5d1b2d72b..344f459bc 100644 --- a/sorc/cpld_gridgen.fd/gen_fixgrid.F90 +++ b/sorc/cpld_gridgen.fd/gen_fixgrid.F90 @@ -4,7 +4,7 @@ !! @author Denise.Worthen@noaa.gov !> Generate fixed grid files required for coupled model using the MOM6 super grid file and ocean mask file. It creates -!! a master grid file which is then used to create subsequent files which are required to create the fix and IC +!! a main grid file which is then used to create subsequent files which are required to create the fix and IC !! files required for the S2S or S2SW application. !! !! This executable created with this source code runs within the shell scrip cpld_gridgen.sh in ../../ush, which @@ -41,7 +41,7 @@ program gen_fixgrid real(kind=dbl_kind), parameter :: pi = 3.14159265358979323846_dbl_kind real(kind=dbl_kind), parameter :: deg2rad = pi/180.0_dbl_kind - real(real_kind), allocatable, dimension(:,:) :: ww3dpth + real(real_kind), allocatable, dimension(:,:) :: ww3dpth integer(int_kind), allocatable, dimension(:,:) :: ww3mask character(len=CL) :: fsrc, fdst, fwgt @@ -61,88 +61,82 @@ program gen_fixgrid character(len=CS) :: form1 character(len=CS) :: form2 character(len= 6) :: cnx - -!------------------------------------------------------------------------- -! Initialize esmf environment. -!------------------------------------------------------------------------- - - call ESMF_VMGetGlobal(vm, rc=rc) - call ESMF_Initialize(VM=vm, logkindflag=ESMF_LOGKIND_MULTI, rc=rc) - call ESMF_VMGet(vm, localPet=localPet, peCount=nPet, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) call ESMF_Finalize(endflag=ESMF_END_ABORT) - mastertask = .false. - if (localPet == 0) mastertask=.true. - if (nPet /= 1) then - print *,npet,' More than one task specified; Aborting ' - call ESMF_Finalize(endflag=ESMF_END_ABORT) - end if - -!--------------------------------------------------------------------- -! -!--------------------------------------------------------------------- + + !------------------------------------------------------------------------- + ! Initialize esmf environment. + !------------------------------------------------------------------------- + + call ESMF_VMGetGlobal(vm, rc=rc) + call ESMF_Initialize(VM=vm, logkindflag=ESMF_LOGKIND_MULTI, rc=rc) + call ESMF_VMGet(vm, localPet=localPet, peCount=nPet, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & + line=__LINE__, file=__FILE__)) call ESMF_Finalize(endflag=ESMF_END_ABORT) + roottask = .false. + if (localPet == 0) roottask =.true. + if (nPet /= 1) then + print *,npet,' More than one task specified; Aborting ' + call ESMF_Finalize(endflag=ESMF_END_ABORT) + end if + + !--------------------------------------------------------------------- + ! + !--------------------------------------------------------------------- call read_inputnml('grid.nml') - if(mastertask) then - print '(a,2i6)',' output grid requested ',ni,nj - print '(a,2i6)',' supergrid size used ', nx,ny - print '(a)',' output grid tag '//trim(res) - print '(a)',' supergrid source directory '//trim(dirsrc) - print '(a)',' output grid directory '//trim(dirout) - print '(a)',' atm resolution '//trim(atmres) - print '(a,i6)',' fv3 tile grid size ',npx - print '(a)',' atm mosaic directory '//trim(fv3dir) - print '(a)',' MOM6 topography file '//trim(topofile) - print '(a)',' MOM6 edits file '//trim(editsfile) - print *,'editmask flag ',editmask - print *,'debug flag ',debug - print *,'do_postwgts flag ',do_postwgts - print * - end if + print '(a,2i6)',' output grid requested ',ni,nj + print '(a,2i6)',' supergrid size used ', nx,ny + print '(a)',' output grid tag '//trim(res) + print '(a)',' supergrid source directory '//trim(dirsrc) + print '(a)',' output grid directory '//trim(dirout) + print '(a)',' atm resolution '//trim(atmres) + print '(a,i6)',' fv3 tile grid size ',npx + print '(a)',' atm mosaic directory '//trim(fv3dir) + print '(a)',' MOM6 topography file '//trim(topofile) + print '(a)',' MOM6 edits file '//trim(editsfile) + print *,'editmask flag ',editmask + print *,'debug flag ',debug + print *,'do_postwgts flag ',do_postwgts + print * call allocate_all - + call ESMF_LogWrite("Starting gen_fixgrid", ESMF_LOGMSG_INFO) -!--------------------------------------------------------------------- -! set up the arrays to retrieve the vertices -!--------------------------------------------------------------------- + !--------------------------------------------------------------------- + ! set up the arrays to retrieve the vertices + !--------------------------------------------------------------------- iVertCu = iVertCt + 1; jVertCu = jVertCt + 0 iVertCv = iVertCt + 0; jVertCv = jVertCt + 1 iVertBu = iVertCt + 1; jVertBu = jVertCt + 1 - if(mastertask) then - print '(a8,4i6)','iVertCt ',(iVertCt(i),i=1,4) - print '(a8,4i6)','jVertCt ',(jVertCt(i),i=1,4) - print * - print '(a8,4i6)','iVertCu ',(iVertCu(i),i=1,4) - print '(a8,4i6)','jVertCu ',(jVertCu(i),i=1,4) - print * - print '(a8,4i6)','iVertCv ',(iVertCv(i),i=1,4) - print '(a8,4i6)','jVertCv ',(jVertCv(i),i=1,4) - print * - print '(a8,4i6)','iVertBu ',(iVertBu(i),i=1,4) - print '(a8,4i6)','jVertBu ',(jVertBu(i),i=1,4) - print * - end if + print '(a8,4i6)','iVertCt ',(iVertCt(i),i=1,4) + print '(a8,4i6)','jVertCt ',(jVertCt(i),i=1,4) + print * + print '(a8,4i6)','iVertCu ',(iVertCu(i),i=1,4) + print '(a8,4i6)','jVertCu ',(jVertCu(i),i=1,4) + print * + print '(a8,4i6)','iVertCv ',(iVertCv(i),i=1,4) + print '(a8,4i6)','jVertCv ',(jVertCv(i),i=1,4) + print * + print '(a8,4i6)','iVertBu ',(iVertBu(i),i=1,4) + print '(a8,4i6)','jVertBu ',(jVertBu(i),i=1,4) + print * latCt_vert = -9999.0 ; lonCt_vert = -9999.0 latCu_vert = -9999.0 ; lonCu_vert = -9999.0 latCv_vert = -9999.0 ; lonCv_vert = -9999.0 latBu_vert = -9999.0 ; lonBu_vert = -9999.0 -!--------------------------------------------------------------------- -! read the MOM6 land mask -!--------------------------------------------------------------------- + !--------------------------------------------------------------------- + ! read the MOM6 land mask + !--------------------------------------------------------------------- fsrc = trim(dirsrc)//'/'//trim(maskfile) rc = nf90_open(fsrc, nf90_nowrite, ncid) - if(mastertask) then - print '(a)', 'reading ocean mask from '//trim(fsrc) - if(rc .ne. 0)print '(a)', 'nf90_open = '//trim(nf90_strerror(rc)) - end if + print '(a)', 'reading ocean mask from '//trim(fsrc) + if(rc .ne. 0)print '(a)', 'nf90_open = '//trim(nf90_strerror(rc)) wet4 = 0.0; wet8 = 0.0 rc = nf90_inq_varid(ncid, trim(maskname), id) @@ -156,17 +150,15 @@ program gen_fixgrid !print *,minval(wet8),maxval(wet8) !print *,minval(wet4),maxval(wet4) -!--------------------------------------------------------------------- -! read the MOM6 depth file -!--------------------------------------------------------------------- + !--------------------------------------------------------------------- + ! read the MOM6 depth file + !--------------------------------------------------------------------- fsrc = trim(dirsrc)//'/'//trim(topofile) rc = nf90_open(fsrc, nf90_nowrite, ncid) - if(mastertask) then - print '(a)', 'reading ocean topography from '//trim(fsrc) - if(rc .ne. 0)print '(a)', 'nf90_open = '//trim(nf90_strerror(rc)) - end if + print '(a)', 'reading ocean topography from '//trim(fsrc) + if(rc .ne. 0)print '(a)', 'nf90_open = '//trim(nf90_strerror(rc)) dp4 = 0.0; dp8 = 0.0 rc = nf90_inq_varid(ncid, trim(toponame), id) @@ -181,45 +173,43 @@ program gen_fixgrid !print *,minval(dp4),maxval(dp4) if(editmask)then -!--------------------------------------------------------------------- -! apply topoedits run time mask changes if required for this config -!--------------------------------------------------------------------- - - if(trim(editsfile) == 'none')then - print '(a)', 'Need a valid editsfile to make mask edits ' - stop - end if - - fsrc = trim(dirsrc)//'/'//trim(editsfile) - fdst = trim(dirout)//'/'//'ufs.'//trim(editsfile) - call add_topoedits(fsrc,fdst) + !--------------------------------------------------------------------- + ! apply topoedits run time mask changes if required for this config + !--------------------------------------------------------------------- + + if(trim(editsfile) == 'none')then + print '(a)', 'Need a valid editsfile to make mask edits ' + stop + end if + + fsrc = trim(dirsrc)//'/'//trim(editsfile) + fdst = trim(dirout)//'/'//'ufs.'//trim(editsfile) + call add_topoedits(fsrc,fdst) endif -!--------------------------------------------------------------------- -! MOM6 reads the depth file, applies the topo edits and then adjusts -! depth using masking_depth and min/max depth. This call mimics -! MOM6 routines apply_topography_edits_from_file and limit_topography -!--------------------------------------------------------------------- + !--------------------------------------------------------------------- + ! MOM6 reads the depth file, applies the topo edits and then adjusts + ! depth using masking_depth and min/max depth. This call mimics + ! MOM6 routines apply_topography_edits_from_file and limit_topography + !--------------------------------------------------------------------- - fsrc = trim(dirsrc)//'/'//trim(editsfile) - if(editmask)fsrc = trim(dirout)//'/'//'ufs.'//trim(editsfile) - call apply_topoedits(fsrc) + fsrc = trim(dirsrc)//'/'//trim(editsfile) + if(editmask)fsrc = trim(dirout)//'/'//'ufs.'//trim(editsfile) + call apply_topoedits(fsrc) -!--------------------------------------------------------------------- -! read MOM6 supergrid file -!--------------------------------------------------------------------- + !--------------------------------------------------------------------- + ! read MOM6 supergrid file + !--------------------------------------------------------------------- fsrc = trim(dirsrc)//'/'//'ocean_hgrid.nc' rc = nf90_open(fsrc, nf90_nowrite, ncid) - if(mastertask) then - print '(a)', 'reading supergrid from '//trim(fsrc) - if(rc .ne. 0)print '(a)', 'nf90_open = '//trim(nf90_strerror(rc)) - end if - + print '(a)', 'reading supergrid from '//trim(fsrc) + if(rc .ne. 0)print '(a)', 'nf90_open = '//trim(nf90_strerror(rc)) + rc = nf90_inq_varid(ncid, 'x', id) !lon rc = nf90_get_var(ncid, id, x) - + rc = nf90_inq_varid(ncid, 'y', id) !lat rc = nf90_get_var(ncid, id, y) @@ -234,136 +224,127 @@ program gen_fixgrid !print *,'max lat in super grid ',maxval(y) sg_maxlat = maxval(y) -!--------------------------------------------------------------------- -! find the angle on corners---this requires the supergrid -!--------------------------------------------------------------------- + !--------------------------------------------------------------------- + ! find the angle on corners---this requires the supergrid + !--------------------------------------------------------------------- - call find_angq + call find_angq -!--------------------------------------------------------------------- -! fill grid variables -!--------------------------------------------------------------------- + !--------------------------------------------------------------------- + ! fill grid variables + !--------------------------------------------------------------------- do j = 1,nj - do i = 1,ni - i2 = 2*i ; j2 = 2*j - !deg->rad - ulon(i,j) = x(i2,j2)*deg2rad - ulat(i,j) = y(i2,j2)*deg2rad - !in rad already - angle(i,j) = -angq(i2,j2) - !m->cm - htn(i,j) = (dx(i2-1,j2) + dx(i2,j2))*100._dbl_kind - hte(i,j) = (dy(i2,j2-1) + dy(i2,j2))*100._dbl_kind - !deg - lonBu(i,j) = x(i2,j2) - latBu(i,j) = y(i2,j2) - !deg - lonCt(i,j) = x(i2-1,j2-1) - lonCu(i,j) = x(i2, j2-1) - lonCv(i,j) = x(i2-1,j2 ) - !deg - latCt(i,j) = y(i2-1,j2-1) - latCu(i,j) = y(i2, j2-1) - latCv(i,j) = y(i2-1,j2 ) - !m2 - dxT = dx(i2-1,j2-1) + dx(i2,j2-1) - dyT = dy(i2-1,j2-1) + dy(i2-1,j2) - areaCt(i,j) = dxT*dyT - enddo + do i = 1,ni + i2 = 2*i ; j2 = 2*j + !deg->rad + ulon(i,j) = x(i2,j2)*deg2rad + ulat(i,j) = y(i2,j2)*deg2rad + !in rad already + angle(i,j) = -angq(i2,j2) + !m->cm + htn(i,j) = (dx(i2-1,j2) + dx(i2,j2))*100._dbl_kind + hte(i,j) = (dy(i2,j2-1) + dy(i2,j2))*100._dbl_kind + !deg + lonBu(i,j) = x(i2,j2) + latBu(i,j) = y(i2,j2) + !deg + lonCt(i,j) = x(i2-1,j2-1) + lonCu(i,j) = x(i2, j2-1) + lonCv(i,j) = x(i2-1,j2 ) + !deg + latCt(i,j) = y(i2-1,j2-1) + latCu(i,j) = y(i2, j2-1) + latCv(i,j) = y(i2-1,j2 ) + !m2 + dxT = dx(i2-1,j2-1) + dx(i2,j2-1) + dyT = dy(i2-1,j2-1) + dy(i2-1,j2) + areaCt(i,j) = dxT*dyT + enddo enddo -!--------------------------------------------------------------------- -! find the angle on centers---this does not requires the supergrid -!--------------------------------------------------------------------- - - call find_ang - - if(mastertask) then - print *,'ANGLET ',minval(anglet),maxval(anglet) - print *,'ANGLE ',minval(angle),maxval(angle) - end if - -!--------------------------------------------------------------------- -! For the 1/4deg grid, hte at j=720 and j = 1440 is identically=0.0 for -! j > 840 (64.0N). These are land points, but since CICE uses hte to -! generate remaining variables, setting them to zero will cause problems -! For 1deg grid, hte at ni/2 and ni are very small O~10-12, so test for -! hte < 1.0 -!--------------------------------------------------------------------- - - if(mastertask) then - write(logmsg,'(a,2e12.5)')'min vals of hte at folds ', & - minval(hte(ni/2,:)),minval(hte(ni,:)) - print '(a)',trim(logmsg) - end if - do j = 1,nj - ii = ni/2 - if(hte(ii,j) .le. 1.0)hte(ii,j) = 0.5*(hte(ii-1,j) + hte(ii+1,j)) - ii = ni - if(hte(ii,j) .le. 1.0)hte(ii,j) = 0.5*(hte(ii-1,j) + hte( 1,j)) - enddo - if(mastertask) then - write(logmsg,'(a,2e12.5)')'min vals of hte at folds ', & - minval(hte(ni/2,:)),minval(hte(ni,:)) - print '(a)',trim(logmsg) - end if + !--------------------------------------------------------------------- + ! find the angle on centers---this does not requires the supergrid + !--------------------------------------------------------------------- + + call find_ang + print *,'ANGLET ',minval(anglet),maxval(anglet) + print *,'ANGLE ',minval(angle),maxval(angle) + + !--------------------------------------------------------------------- + ! For the 1/4deg grid, hte at j=720 and j = 1440 is identically=0.0 for + ! j > 840 (64.0N). These are land points, but since CICE uses hte to + ! generate remaining variables, setting them to zero will cause problems + ! For 1deg grid, hte at ni/2 and ni are very small O~10-12, so test for + ! hte < 1.0 + !--------------------------------------------------------------------- + + write(logmsg,'(a,2e12.5)')'min vals of hte at folds ', & + minval(hte(ni/2,:)),minval(hte(ni,:)) + print '(a)',trim(logmsg) + do j = 1,nj + ii = ni/2 + if(hte(ii,j) .le. 1.0)hte(ii,j) = 0.5*(hte(ii-1,j) + hte(ii+1,j)) + ii = ni + if(hte(ii,j) .le. 1.0)hte(ii,j) = 0.5*(hte(ii-1,j) + hte( 1,j)) + enddo + write(logmsg,'(a,2e12.5)')'min vals of hte at folds ', & + minval(hte(ni/2,:)),minval(hte(ni,:)) + print '(a)',trim(logmsg) -!--------------------------------------------------------------------- -! -!--------------------------------------------------------------------- + !--------------------------------------------------------------------- + ! + !--------------------------------------------------------------------- where(lonCt .lt. 0.0)lonCt = lonCt + 360._dbl_kind where(lonCu .lt. 0.0)lonCu = lonCu + 360._dbl_kind where(lonCv .lt. 0.0)lonCv = lonCv + 360._dbl_kind where(lonBu .lt. 0.0)lonBu = lonBu + 360._dbl_kind -!--------------------------------------------------------------------- -! some basic error checking -! find the i-th index of the poles at j= nj -! the corner points must lie on the pole -!--------------------------------------------------------------------- + !--------------------------------------------------------------------- + ! some basic error checking + ! find the i-th index of the poles at j= nj + ! the corner points must lie on the pole + !--------------------------------------------------------------------- - ipole = -1 - j = nj - do i = 1,ni/2 + ipole = -1 + j = nj + do i = 1,ni/2 if(latBu(i,j) .eq. sg_maxlat)ipole(1) = i - enddo - do i = ni/2+1,ni + enddo + do i = ni/2+1,ni if(latBu(i,j) .eq. sg_maxlat)ipole(2) = i - enddo - if(mastertask) then - write(logmsg,'(a,2i6,2f12.2)')'poles found at i = ',ipole,latBu(ipole(1),nj), & - latBu(ipole(2),nj) - print '(a)',trim(logmsg) - end if - - if(mastertask .and. debug)call checkseam - - do i = 1,ni - i2 = ipole(2)+(ipole(1)-i)+1 - xlonCt(i) = lonCt(i2,nj) - xlatCt(i) = latCt(i2,nj) - enddo - - do i = 1,ni - i2 = ipole(2)+(ipole(1)-i) - if(i2 .lt. 1)i2 = ni + enddo + write(logmsg,'(a,2i6,2f12.2)')'poles found at i = ',ipole,latBu(ipole(1),nj), & + latBu(ipole(2),nj) + print '(a)',trim(logmsg) + + if(debug)call checkseam + + do i = 1,ni + i2 = ipole(2)+(ipole(1)-i)+1 + xlonCt(i) = lonCt(i2,nj) + xlatCt(i) = latCt(i2,nj) + enddo + + do i = 1,ni + i2 = ipole(2)+(ipole(1)-i) + if(i2 .lt. 1)i2 = ni xlonCu(i) = lonCu(i2,nj) xlatCu(i) = latCu(i2,nj) - enddo - - if(mastertask .and. debug)call checkxlatlon + enddo + + if(debug)call checkxlatlon - !approx lat at grid bottom - do i = 1,ni + !approx lat at grid bottom + do i = 1,ni dlatBu(i) = latBu(i,1) + 2.0*(latCu(i,1) - latBu(i,1)) dlatCv(i) = latCt(i,1) + 2.0*(latCt(i,1) - latCv(i,1)) - enddo + enddo -!--------------------------------------------------------------------- -! fill grid vertices variables -!--------------------------------------------------------------------- + !--------------------------------------------------------------------- + ! fill grid vertices variables + !--------------------------------------------------------------------- !Ct and Cu grids align in j call fill_vertices(2,nj , iVertCt,jVertCt, latBu,lonBu, latCt_vert,lonCt_vert) @@ -378,8 +359,8 @@ program gen_fixgrid call fill_vertices(1,nj-1, iVertBu,jVertBu, latCt,lonCt, latBu_vert,lonBu_vert) call fill_top(iVertBu,jVertBu, latCt,lonCt, latBu_vert,lonBu_vert, xlatCt, xlonCt) - - if(mastertask .and. debug)call checkpoint + + if(debug)call checkpoint if(minval(latCt_vert) .lt. -1.e3)stop if(minval(lonCt_vert) .lt. -1.e3)stop @@ -391,52 +372,48 @@ program gen_fixgrid if(minval(lonBu_vert) .lt. -1.e3)stop deallocate(xlonCt, xlatCt, xlonCu, xlatCu, dlatBu, dlatCv) -!--------------------------------------------------------------------- -! write out grid file files -!--------------------------------------------------------------------- + !--------------------------------------------------------------------- + ! write out grid file files + !--------------------------------------------------------------------- ! create a history attribute - call date_and_time(date=cdate) - history = 'created on '//trim(cdate)//' from '//trim(fsrc) - - ! write fix grid - fdst = trim(dirout)//'/'//'tripole.mx'//trim(res)//'.nc' - call write_tripolegrid(trim(fdst)) - - ! write cice grid - fdst = trim(dirout)//'/'//'grid_cice_NEMS_mx'//trim(res)//'.nc' - call write_cicegrid(trim(fdst)) - deallocate(ulon, ulat, htn, hte) - ! write scrip grids; only the Ct is required, the remaining - ! staggers are used only in the postweights generation - do k = 1,nv - cstagger = trim(staggerlocs(k)) - fdst = trim(dirout)//'/'//trim(cstagger)//'.mx'//trim(res)//'_SCRIP.nc' - if(mastertask) then - logmsg = 'creating SCRIP file '//trim(fdst) - print '(a)',trim(logmsg) - end if - call write_scripgrid(trim(fdst),trim(cstagger)) - end do - deallocate(latCv_vert, lonCv_vert) - deallocate(latCu_vert, lonCu_vert) - deallocate(latBu_vert, lonBu_vert) - - ! write SCRIP file with land mask, used for mapped ocean mask - ! and mesh creation - cstagger = trim(staggerlocs(1)) - fdst= trim(dirout)//'/'//trim(cstagger)//'.mx'//trim(res)//'_SCRIP_land.nc' - if(mastertask) then + call date_and_time(date=cdate) + history = 'created on '//trim(cdate)//' from '//trim(fsrc) + + ! write fix grid + fdst = trim(dirout)//'/'//'tripole.mx'//trim(res)//'.nc' + call write_tripolegrid(trim(fdst)) + + ! write cice grid + fdst = trim(dirout)//'/'//'grid_cice_NEMS_mx'//trim(res)//'.nc' + call write_cicegrid(trim(fdst)) + deallocate(ulon, ulat, htn, hte) + ! write scrip grids; only the Ct is required, the remaining + ! staggers are used only in the postweights generation + do k = 1,nv + cstagger = trim(staggerlocs(k)) + fdst = trim(dirout)//'/'//trim(cstagger)//'.mx'//trim(res)//'_SCRIP.nc' logmsg = 'creating SCRIP file '//trim(fdst) print '(a)',trim(logmsg) - end if - call write_scripgrid(trim(fdst),trim(cstagger),imask=int(wet4)) - deallocate(latCt_vert, lonCt_vert) - -!--------------------------------------------------------------------- -! write lat,lon,depth and mask arrays required by ww3 in creating -! mod_def file -!--------------------------------------------------------------------- + call write_scripgrid(trim(fdst),trim(cstagger)) + end do + deallocate(latCv_vert, lonCv_vert) + deallocate(latCu_vert, lonCu_vert) + deallocate(latBu_vert, lonBu_vert) + + ! write SCRIP file with land mask, used for mapped ocean mask + ! and mesh creation + cstagger = trim(staggerlocs(1)) + fdst= trim(dirout)//'/'//trim(cstagger)//'.mx'//trim(res)//'_SCRIP_land.nc' + logmsg = 'creating SCRIP file '//trim(fdst) + print '(a)',trim(logmsg) + call write_scripgrid(trim(fdst),trim(cstagger),imask=int(wet4)) + deallocate(latCt_vert, lonCt_vert) + + !--------------------------------------------------------------------- + ! write lat,lon,depth and mask arrays required by ww3 in creating + ! mod_def file + !--------------------------------------------------------------------- write(cnx,i4fmt)nx write(form1,'(a)')'('//trim(cnx)//'f14.8)' @@ -457,98 +434,90 @@ program gen_fixgrid open(unit=25,file=trim(dirout)//'/'//'ww3.mx'//trim(res)//'_obstr.inp',form='formatted') do j = 1,nj - write( 21,trim(form1))lonCt(:,j) - write( 22,trim(form1))latCt(:,j) + write( 21,trim(form1))lonCt(:,j) + write( 22,trim(form1))latCt(:,j) end do do j = 1,nj - write( 23,trim(form1))ww3dpth(:,j) - write( 24,trim(form2))ww3mask(:,j) - !'obsx' and 'obsy' arrays ??? - write( 25,trim(form2))ww3mask(:,j)*0 - write( 25,trim(form2))ww3mask(:,j)*0 + write( 23,trim(form1))ww3dpth(:,j) + write( 24,trim(form2))ww3mask(:,j) + !'obsx' and 'obsy' arrays ??? + write( 25,trim(form2))ww3mask(:,j)*0 + write( 25,trim(form2))ww3mask(:,j)*0 end do close(21); close(22); close(23); close(24); close(25) deallocate(ww3mask); deallocate(ww3dpth) deallocate(wet4, wet8) -!--------------------------------------------------------------------- -! use ESMF regridding to produce mapped ocean mask; first generate -! conservative regrid weights from ocean to tiles; then generate the -! tiled files containing the mapped ocean mask -!--------------------------------------------------------------------- - - method=ESMF_REGRIDMETHOD_CONSERVE - fsrc = trim(dirout)//'/'//'Ct.mx'//trim(res)//'_SCRIP_land.nc' - fdst = trim(fv3dir)//'/'//trim(atmres)//'/'//trim(atmres)//'_mosaic.nc' - fwgt = trim(dirout)//'/'//'Ct.mx'//trim(res)//'.to.'//trim(atmres)//'.nc' - if(mastertask) then - logmsg = 'creating weight file '//trim(fwgt) - print '(a)',trim(logmsg) - end if - - call ESMF_RegridWeightGen(srcFile=trim(fsrc),dstFile=trim(fdst), & - weightFile=trim(fwgt), regridmethod=method, & - unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, & - ignoreDegenerate=.true., & - tileFilePath=trim(fv3dir)//'/'//trim(atmres)//'/', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) call ESMF_Finalize(endflag=ESMF_END_ABORT) - - if(mastertask) then - logmsg = 'creating mapped ocean mask for '//trim(atmres) - print '(a)',trim(logmsg) - end if - call make_frac_land(trim(fsrc), trim(fwgt)) - -!--------------------------------------------------------------------- -! use ESMF to find the tripole:tripole weights for creation -! of CICE ICs; the source grid is always mx025; don't create this -! file if destination is also mx025 -!--------------------------------------------------------------------- - - if(trim(res) .ne. '025') then + !--------------------------------------------------------------------- + ! use ESMF regridding to produce mapped ocean mask; first generate + ! conservative regrid weights from ocean to tiles; then generate the + ! tiled files containing the mapped ocean mask + !--------------------------------------------------------------------- + + method=ESMF_REGRIDMETHOD_CONSERVE + fsrc = trim(dirout)//'/'//'Ct.mx'//trim(res)//'_SCRIP_land.nc' + fdst = trim(fv3dir)//'/'//trim(atmres)//'/'//trim(atmres)//'_mosaic.nc' + fwgt = trim(dirout)//'/'//'Ct.mx'//trim(res)//'.to.'//trim(atmres)//'.nc' + logmsg = 'creating weight file '//trim(fwgt) + print '(a)',trim(logmsg) + + call ESMF_RegridWeightGen(srcFile=trim(fsrc),dstFile=trim(fdst), & + weightFile=trim(fwgt), regridmethod=method, & + unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, & + ignoreDegenerate=.true., & + tileFilePath=trim(fv3dir)//'/'//trim(atmres)//'/', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & + line=__LINE__, file=__FILE__)) call ESMF_Finalize(endflag=ESMF_END_ABORT) + + logmsg = 'creating mapped ocean mask for '//trim(atmres) + print '(a)',trim(logmsg) + call make_frac_land(trim(fsrc), trim(fwgt)) + + !--------------------------------------------------------------------- + ! use ESMF to find the tripole:tripole weights for creation + ! of CICE ICs; the source grid is always mx025; don't create this + ! file if destination is also mx025 + !--------------------------------------------------------------------- + + if(trim(res) .ne. '025') then fsrc = trim(dirout)//'/'//'Ct.mx025_SCRIP.nc' inquire(FILE=trim(fsrc), EXIST=fexist) if (fexist ) then - method=ESMF_REGRIDMETHOD_NEAREST_STOD - fdst = trim(dirout)//'/'//'Ct.mx'//trim(res)//'_SCRIP.nc' - fwgt = trim(dirout)//'/'//'tripole.mx025.Ct.to.mx'//trim(res)//'.Ct.neareststod.nc' - if(mastertask) then - logmsg = 'creating weight file '//trim(fwgt) - print '(a)',trim(logmsg) - end if - - call ESMF_RegridWeightGen(srcFile=trim(fsrc),dstFile=trim(fdst), & - weightFile=trim(fwgt), regridmethod=method, & - ignoreDegenerate=.true., & - unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) call ESMF_Finalize(endflag=ESMF_END_ABORT) + method=ESMF_REGRIDMETHOD_NEAREST_STOD + fdst = trim(dirout)//'/'//'Ct.mx'//trim(res)//'_SCRIP.nc' + fwgt = trim(dirout)//'/'//'tripole.mx025.Ct.to.mx'//trim(res)//'.Ct.neareststod.nc' + logmsg = 'creating weight file '//trim(fwgt) + print '(a)',trim(logmsg) + + call ESMF_RegridWeightGen(srcFile=trim(fsrc),dstFile=trim(fdst), & + weightFile=trim(fwgt), regridmethod=method, & + ignoreDegenerate=.true., & + unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & + line=__LINE__, file=__FILE__)) call ESMF_Finalize(endflag=ESMF_END_ABORT) else - if(mastertask) then - logmsg = 'ERROR: '//trim(fsrc)//' is required to generate tripole:triple weights' - print '(a)',trim(logmsg) - end if - stop + logmsg = 'ERROR: '//trim(fsrc)//' is required to generate tripole:triple weights' + print '(a)',trim(logmsg) + stop end if - end if + end if -!--------------------------------------------------------------------- -! -!--------------------------------------------------------------------- + !--------------------------------------------------------------------- + ! + !--------------------------------------------------------------------- - if(do_postwgts)call make_postwgts + if(do_postwgts)call make_postwgts -!--------------------------------------------------------------------- -! clean up -!--------------------------------------------------------------------- + !--------------------------------------------------------------------- + ! clean up + !--------------------------------------------------------------------- - deallocate(x,y, angq, dx, dy, xsgp1, ysgp1) - deallocate(areaCt, anglet, angle) - deallocate(latCt, lonCt) - deallocate(latCv, lonCv) - deallocate(latCu, lonCu) - deallocate(latBu, lonBu) + deallocate(x,y, angq, dx, dy, xsgp1, ysgp1) + deallocate(areaCt, anglet, angle) + deallocate(latCt, lonCt) + deallocate(latCv, lonCv) + deallocate(latCu, lonCu) + deallocate(latBu, lonBu) end program gen_fixgrid diff --git a/sorc/cpld_gridgen.fd/grdvars.F90 b/sorc/cpld_gridgen.fd/grdvars.F90 index 7946b07c2..578ac269a 100644 --- a/sorc/cpld_gridgen.fd/grdvars.F90 +++ b/sorc/cpld_gridgen.fd/grdvars.F90 @@ -6,202 +6,202 @@ !! @author Denise.Worthen@noaa.gov module grdvars - + use gengrid_kinds, only : dbl_kind, real_kind, int_kind - + implicit none - integer :: ni !< i-dimension of output grid - integer :: nj !< j-dimension of output grid - integer :: npx !< i or j-dimension of fv3 tile - - integer :: nx !< i-dimension of MOM6 supergrid - integer :: ny !< j-dimension of MOM6 supergrid - - logical :: editmask !< flag indicating whether the MOM6 land mask - !! should be edited. Default is false - logical :: debug !< flag indicating whether grid information - !! should be printed for debugging purposes - !! Default is false - logical :: do_postwgts !< flag indicating whether then ESMF weights to - !! regrid from the tripole grid to a rectilinear - !! grid should be generated. Default is false. - logical :: mastertask !< flag indicating whether this is the mastertask - - integer, parameter :: nv = 4. !< the number of vertices for each stagger location - integer, parameter :: ncoord = 2*4. !< the number of coord pairs (lat,lon) for each of - !! 4 stagger locations - integer, parameter :: nverts = 2*4. !< the number of coord pairs (lat,lon) for the - !! vertices of each stagger location - integer, parameter :: nvars = ncoord + nverts !< the total number of cooridinate variables - - - real(dbl_kind) :: sg_maxlat !< the maximum latitute present in the supergrid - !! file - integer(int_kind) :: ipole(2) !< the i-index for both pole locations - !! along the top-most row - - integer, parameter, dimension(nv) :: iVertCt = (/0, -1, -1, 0/) !< The i-offsets of the Bu grid at each Ct(i,j) - !! which determine the 4 vertices of each Ct grid - !! grid point in i - integer, parameter, dimension(nv) :: jVertCt = (/0, 0, -1, -1/) !< The j-offsets of the Bu grid at each Ct(i,j) - !! which determine the 4 vertices of each Ct - !! grid point in j - integer, dimension(nv) :: iVertCv !< The i-offsets of the Cu grid at each Cv(i,j) - !! which determine the 4 vertices of each Cv - !! grid point in i - integer, dimension(nv) :: jVertCv !< The j-offsets of the Cu grid at each Cv(i,j) - !! which determine the 4 vertices of each Cv - !! grid point in j - integer, dimension(nv) :: iVertCu !< The i-offsets of the Cv grid at each Cu(i,j) - !! which determine the 4 vertices of each Cu - !! grid point in i - integer, dimension(nv) :: jVertCu !< The j-offsets of the Cv grid at each Cu(i,j) - !! which determine the 4 vertices of each Cu - !! grid point in j - integer, dimension(nv) :: iVertBu !< The i-offsets of the Ct grid at each Bu(i,j) - !! which determine the 4 vertices of each Bu - !! grid point in i - integer, dimension(nv) :: jVertBu !< The j-offsets of the Ct grid at each Bu(i,j) - !! which determine the 4 vertices of each Bu - !! grid point in j + integer :: ni !< i-dimension of output grid + integer :: nj !< j-dimension of output grid + integer :: npx !< i or j-dimension of fv3 tile + + integer :: nx !< i-dimension of MOM6 supergrid + integer :: ny !< j-dimension of MOM6 supergrid + + logical :: editmask !< flag indicating whether the MOM6 land mask + !! should be edited. Default is false + logical :: debug !< flag indicating whether grid information + !! should be printed for debugging purposes + !! Default is false + logical :: do_postwgts !< flag indicating whether then ESMF weights to + !! regrid from the tripole grid to a rectilinear + !! grid should be generated. Default is false. + logical :: roottask !< flag indicating whether this is the roottask + + integer, parameter :: nv = 4. !< the number of vertices for each stagger location + integer, parameter :: ncoord = 2*4. !< the number of coord pairs (lat,lon) for each of + !! 4 stagger locations + integer, parameter :: nverts = 2*4. !< the number of coord pairs (lat,lon) for the + !! vertices of each stagger location + integer, parameter :: nvars = ncoord + nverts !< the total number of cooridinate variables + + + real(dbl_kind) :: sg_maxlat !< the maximum latitute present in the supergrid + !! file + integer(int_kind) :: ipole(2) !< the i-index for both pole locations + !! along the top-most row + + integer, parameter, dimension(nv) :: iVertCt = (/0, -1, -1, 0/) !< The i-offsets of the Bu grid at each Ct(i,j) + !! which determine the 4 vertices of each Ct grid + !! grid point in i + integer, parameter, dimension(nv) :: jVertCt = (/0, 0, -1, -1/) !< The j-offsets of the Bu grid at each Ct(i,j) + !! which determine the 4 vertices of each Ct + !! grid point in j + integer, dimension(nv) :: iVertCv !< The i-offsets of the Cu grid at each Cv(i,j) + !! which determine the 4 vertices of each Cv + !! grid point in i + integer, dimension(nv) :: jVertCv !< The j-offsets of the Cu grid at each Cv(i,j) + !! which determine the 4 vertices of each Cv + !! grid point in j + integer, dimension(nv) :: iVertCu !< The i-offsets of the Cv grid at each Cu(i,j) + !! which determine the 4 vertices of each Cu + !! grid point in i + integer, dimension(nv) :: jVertCu !< The j-offsets of the Cv grid at each Cu(i,j) + !! which determine the 4 vertices of each Cu + !! grid point in j + integer, dimension(nv) :: iVertBu !< The i-offsets of the Ct grid at each Bu(i,j) + !! which determine the 4 vertices of each Bu + !! grid point in i + integer, dimension(nv) :: jVertBu !< The j-offsets of the Ct grid at each Bu(i,j) + !! which determine the 4 vertices of each Bu + !! grid point in j ! Super-grid source grid variables - real(dbl_kind), allocatable, dimension(:,:) :: x !< The longitudes of the MOM6 supergrid - real(dbl_kind), allocatable, dimension(:,:) :: y !< The latitudes of the MOM6 supergrid - real(dbl_kind), allocatable, dimension(:,:) :: angq !< The grid rotation angle at the Bu (or corner) - !! grid points of the super grid - - real(dbl_kind), allocatable, dimension(:,:) :: dx !< The grid cell width in meters of the supergrid - !! in the x-direction (i-dimension) - real(dbl_kind), allocatable, dimension(:,:) :: dy !< The grid cell width in meters of the supergrid - !! in the y-direction (j-dimension) - real(dbl_kind), allocatable, dimension(:,:) :: xsgp1 !< The longitudes of the super-grid replicated - !! across the tripole seam - real(dbl_kind), allocatable, dimension(:,:) :: ysgp1 !< The latitudes of the super-grid replicated - !! across the tripole seam - + real(dbl_kind), allocatable, dimension(:,:) :: x !< The longitudes of the MOM6 supergrid + real(dbl_kind), allocatable, dimension(:,:) :: y !< The latitudes of the MOM6 supergrid + real(dbl_kind), allocatable, dimension(:,:) :: angq !< The grid rotation angle at the Bu (or corner) + !! grid points of the super grid + + real(dbl_kind), allocatable, dimension(:,:) :: dx !< The grid cell width in meters of the supergrid + !! in the x-direction (i-dimension) + real(dbl_kind), allocatable, dimension(:,:) :: dy !< The grid cell width in meters of the supergrid + !! in the y-direction (j-dimension) + real(dbl_kind), allocatable, dimension(:,:) :: xsgp1 !< The longitudes of the super-grid replicated + !! across the tripole seam + real(dbl_kind), allocatable, dimension(:,:) :: ysgp1 !< The latitudes of the super-grid replicated + !! across the tripole seam + ! Output grid variables - real(dbl_kind), allocatable, dimension(:,:) :: latCt !< The latitude of the center (tracer) grid points - !! on the C-grid - real(dbl_kind), allocatable, dimension(:,:) :: lonCt !< The longitude of the center (tracer) grid - !! points on the C-grid - real(dbl_kind), allocatable, dimension(:,:) :: latCv !< The latitude of the v-velocity grid points on - !! the C-grid - real(dbl_kind), allocatable, dimension(:,:) :: lonCv !< The longitude of the v-velocity grid points on - !! the C-grid - real(dbl_kind), allocatable, dimension(:,:) :: latCu !< The latitude of the u-velocity grid points on - !! the C-grid - real(dbl_kind), allocatable, dimension(:,:) :: lonCu !< The longitude of the u-velocity grid points on - !! the C-grid - real(dbl_kind), allocatable, dimension(:,:) :: latBu !< The latitude of the corner points on the C-grid. - !! These are equivalent to u,v velocity grid - !! points on the B-grid - real(dbl_kind), allocatable, dimension(:,:) :: lonBu !< The longitude of the corner points on the - !! C-grid. These are equivalent to u,v velocity - !! grid points on the B-grid - real(dbl_kind), allocatable, dimension(:,:) :: areaCt !< The grid areas of the Ct grid cell in m2 - real(dbl_kind), allocatable, dimension(:,:) :: anglet !< The rotation angle on Ct points (opposite sense - !! from angle) - real(dbl_kind), allocatable, dimension(:,:) :: angle !< The rotation angle on Bu points - - real(dbl_kind), allocatable, dimension(:,:,:) :: latCt_vert !< The latitudes of the 4 vertices of each Ct grid - !! point - real(dbl_kind), allocatable, dimension(:,:,:) :: lonCt_vert !< The longitudes of the 4 vertices of each Ct - !! grid point - - real(dbl_kind), allocatable, dimension(:,:,:) :: latCv_vert !< The latitudes of the 4 vertices of each Cv grid - !! point - real(dbl_kind), allocatable, dimension(:,:,:) :: lonCv_vert !< The longitudes of the 4 vertices of each Cv - !! grid point - - real(dbl_kind), allocatable, dimension(:,:,:) :: latCu_vert !< The latitudes of the 4 vertices of each Cu grid - !! point - real(dbl_kind), allocatable, dimension(:,:,:) :: lonCu_vert !< The longitudes of the 4 vertices of each Cu - !! grid point - - real(dbl_kind), allocatable, dimension(:,:,:) :: latBu_vert !< The latitudes of the 4 vertices of each Bu grid - !! point - real(dbl_kind), allocatable, dimension(:,:,:) :: lonBu_vert !< The longitudes of the 4 vertices of each Bu - !! grid point - - - real(dbl_kind), allocatable, dimension(:) :: xlonCt !< The longitude of the Ct grid points on the - !! opposite side of the tripole seam - real(dbl_kind), allocatable, dimension(:) :: xlatCt !< The latitude of the Ct grid points on the - !! opposite side of the tripole seam - real(dbl_kind), allocatable, dimension(:) :: xlonCu !< The longitude of the Cu grid points on the - !! opposite side of the tripole seam - real(dbl_kind), allocatable, dimension(:) :: xlatCu !< The latitude of the Cu grid points on the - !! opposite side of the tripole seam - real(dbl_kind), allocatable, dimension(:) :: dlatBu !< The latitude spacing between Bu points at the - !! grid bottom - real(dbl_kind), allocatable, dimension(:) :: dlatCv !< The latitude spacing between Cv points at the - !! grid bottom + real(dbl_kind), allocatable, dimension(:,:) :: latCt !< The latitude of the center (tracer) grid points + !! on the C-grid + real(dbl_kind), allocatable, dimension(:,:) :: lonCt !< The longitude of the center (tracer) grid + !! points on the C-grid + real(dbl_kind), allocatable, dimension(:,:) :: latCv !< The latitude of the v-velocity grid points on + !! the C-grid + real(dbl_kind), allocatable, dimension(:,:) :: lonCv !< The longitude of the v-velocity grid points on + !! the C-grid + real(dbl_kind), allocatable, dimension(:,:) :: latCu !< The latitude of the u-velocity grid points on + !! the C-grid + real(dbl_kind), allocatable, dimension(:,:) :: lonCu !< The longitude of the u-velocity grid points on + !! the C-grid + real(dbl_kind), allocatable, dimension(:,:) :: latBu !< The latitude of the corner points on the C-grid. + !! These are equivalent to u,v velocity grid + !! points on the B-grid + real(dbl_kind), allocatable, dimension(:,:) :: lonBu !< The longitude of the corner points on the + !! C-grid. These are equivalent to u,v velocity + !! grid points on the B-grid + real(dbl_kind), allocatable, dimension(:,:) :: areaCt !< The grid areas of the Ct grid cell in m2 + real(dbl_kind), allocatable, dimension(:,:) :: anglet !< The rotation angle on Ct points (opposite sense + !! from angle) + real(dbl_kind), allocatable, dimension(:,:) :: angle !< The rotation angle on Bu points + + real(dbl_kind), allocatable, dimension(:,:,:) :: latCt_vert !< The latitudes of the 4 vertices of each Ct grid + !! point + real(dbl_kind), allocatable, dimension(:,:,:) :: lonCt_vert !< The longitudes of the 4 vertices of each Ct + !! grid point + + real(dbl_kind), allocatable, dimension(:,:,:) :: latCv_vert !< The latitudes of the 4 vertices of each Cv grid + !! point + real(dbl_kind), allocatable, dimension(:,:,:) :: lonCv_vert !< The longitudes of the 4 vertices of each Cv + !! grid point + + real(dbl_kind), allocatable, dimension(:,:,:) :: latCu_vert !< The latitudes of the 4 vertices of each Cu grid + !! point + real(dbl_kind), allocatable, dimension(:,:,:) :: lonCu_vert !< The longitudes of the 4 vertices of each Cu + !! grid point + + real(dbl_kind), allocatable, dimension(:,:,:) :: latBu_vert !< The latitudes of the 4 vertices of each Bu grid + !! point + real(dbl_kind), allocatable, dimension(:,:,:) :: lonBu_vert !< The longitudes of the 4 vertices of each Bu + !! grid point + + + real(dbl_kind), allocatable, dimension(:) :: xlonCt !< The longitude of the Ct grid points on the + !! opposite side of the tripole seam + real(dbl_kind), allocatable, dimension(:) :: xlatCt !< The latitude of the Ct grid points on the + !! opposite side of the tripole seam + real(dbl_kind), allocatable, dimension(:) :: xlonCu !< The longitude of the Cu grid points on the + !! opposite side of the tripole seam + real(dbl_kind), allocatable, dimension(:) :: xlatCu !< The latitude of the Cu grid points on the + !! opposite side of the tripole seam + real(dbl_kind), allocatable, dimension(:) :: dlatBu !< The latitude spacing between Bu points at the + !! grid bottom + real(dbl_kind), allocatable, dimension(:) :: dlatCv !< The latitude spacing between Cv points at the + !! grid bottom ! MOM6 fix fields - real(real_kind), allocatable, dimension(:,:) :: wet4 !< The ocean mask from a MOM6 mask file, stored as - !! real*4 (nd) - real(dbl_kind), allocatable, dimension(:,:) :: wet8 !< The ocean mask from a MOM6 mask file, stored as - !! real*8 (nd) + real(real_kind), allocatable, dimension(:,:) :: wet4 !< The ocean mask from a MOM6 mask file, stored as + !! real*4 (nd) + real(dbl_kind), allocatable, dimension(:,:) :: wet8 !< The ocean mask from a MOM6 mask file, stored as + !! real*8 (nd) - real(real_kind), allocatable, dimension(:,:) :: dp4 !< The ocean depth from a MOM6 topog file, stored - !! as real*4 (m) - real(dbl_kind), allocatable, dimension(:,:) :: dp8 !< The ocean depth from a MOM6 topog file, stored - !! as real*8 (m) + real(real_kind), allocatable, dimension(:,:) :: dp4 !< The ocean depth from a MOM6 topog file, stored + !! as real*4 (m) + real(dbl_kind), allocatable, dimension(:,:) :: dp8 !< The ocean depth from a MOM6 topog file, stored + !! as real*8 (m) ! CICE6 fields - real(dbl_kind), allocatable, dimension(:,:) :: ulon !< The longitude points (on the Bu grid) for CICE6 - !! (radians) - real(dbl_kind), allocatable, dimension(:,:) :: ulat !< The latitude points (on the Bu grid) for CICE6 - !! (radians) - real(dbl_kind), allocatable, dimension(:,:) :: htn !< The grid cell width in centimeters of the CICE6 - !! grid in the x-direction (i-dimension) - real(dbl_kind), allocatable, dimension(:,:) :: hte !< The grid cell width in centimeters of the CICE6 - !! grid in the y-direction (j-dimension) - - real(kind=real_kind), parameter :: minimum_depth = 9.5 !< The minimum depth for MOM6 - real(kind=real_kind), parameter :: maximum_depth = 6500.0 !< The maximum depth for MOM6 - real(kind=real_kind), parameter :: masking_depth = 0.0 !< The masking depth for MOM6. Depths shallower than - !! minimum_depth but deeper than masking_depth are - !! rounded to minimum_depth - real(kind=real_kind), parameter :: maximum_lat = 88.0 !< The maximum latitude for water points for WW3 - - contains -!> Allocate grid variables -!! -!! @author Denise Worthen - + real(dbl_kind), allocatable, dimension(:,:) :: ulon !< The longitude points (on the Bu grid) for CICE6 + !! (radians) + real(dbl_kind), allocatable, dimension(:,:) :: ulat !< The latitude points (on the Bu grid) for CICE6 + !! (radians) + real(dbl_kind), allocatable, dimension(:,:) :: htn !< The grid cell width in centimeters of the CICE6 + !! grid in the x-direction (i-dimension) + real(dbl_kind), allocatable, dimension(:,:) :: hte !< The grid cell width in centimeters of the CICE6 + !! grid in the y-direction (j-dimension) + + real(kind=real_kind), parameter :: minimum_depth = 9.5 !< The minimum depth for MOM6 + real(kind=real_kind), parameter :: maximum_depth = 6500.0 !< The maximum depth for MOM6 + real(kind=real_kind), parameter :: masking_depth = 0.0 !< The masking depth for MOM6. Depths shallower than + !! minimum_depth but deeper than masking_depth are + !! rounded to minimum_depth + real(kind=real_kind), parameter :: maximum_lat = 88.0 !< The maximum latitude for water points for WW3 + +contains + !> Allocate grid variables + !! + !! @author Denise Worthen + subroutine allocate_all - allocate( x(0:nx,0:ny), y(0:nx,0:ny), angq(0:nx,0:ny) ) - allocate( dx(nx,0:ny), dy(0:nx,ny) ) + allocate( x(0:nx,0:ny), y(0:nx,0:ny), angq(0:nx,0:ny) ) + allocate( dx(nx,0:ny), dy(0:nx,ny) ) - allocate( xsgp1(0:nx,0:ny+1), ysgp1(0:nx,0:ny+1) ) + allocate( xsgp1(0:nx,0:ny+1), ysgp1(0:nx,0:ny+1) ) - allocate( latCt(ni,nj), lonCt(ni,nj) ) - allocate( latCv(ni,nj), lonCv(ni,nj) ) - allocate( latCu(ni,nj), lonCu(ni,nj) ) - allocate( latBu(ni,nj), lonBu(ni,nj) ) + allocate( latCt(ni,nj), lonCt(ni,nj) ) + allocate( latCv(ni,nj), lonCv(ni,nj) ) + allocate( latCu(ni,nj), lonCu(ni,nj) ) + allocate( latBu(ni,nj), lonBu(ni,nj) ) - allocate( areaCt(ni,nj), anglet(ni,nj), angle(ni,nj) ) + allocate( areaCt(ni,nj), anglet(ni,nj), angle(ni,nj) ) - allocate( latCt_vert(ni,nj,nv), lonCt_vert(ni,nj,nv) ) - allocate( latCv_vert(ni,nj,nv), lonCv_vert(ni,nj,nv) ) - allocate( latCu_vert(ni,nj,nv), lonCu_vert(ni,nj,nv) ) - allocate( latBu_vert(ni,nj,nv), lonBu_vert(ni,nj,nv) ) + allocate( latCt_vert(ni,nj,nv), lonCt_vert(ni,nj,nv) ) + allocate( latCv_vert(ni,nj,nv), lonCv_vert(ni,nj,nv) ) + allocate( latCu_vert(ni,nj,nv), lonCu_vert(ni,nj,nv) ) + allocate( latBu_vert(ni,nj,nv), lonBu_vert(ni,nj,nv) ) - allocate( xlonCt(ni), xlatCt(ni) ) - allocate( xlonCu(ni), xlatCu(ni) ) - allocate( dlatBu(ni), dlatCv(ni) ) + allocate( xlonCt(ni), xlatCt(ni) ) + allocate( xlonCu(ni), xlatCu(ni) ) + allocate( dlatBu(ni), dlatCv(ni) ) - allocate( wet4(ni,nj) ) - allocate( wet8(ni,nj) ) + allocate( wet4(ni,nj) ) + allocate( wet8(ni,nj) ) - allocate( dp4(ni,nj) ) - allocate( dp8(ni,nj) ) + allocate( dp4(ni,nj) ) + allocate( dp8(ni,nj) ) - allocate( ulon(ni,nj), ulat(ni,nj) ) - allocate( htn(ni,nj), hte(ni,nj) ) + allocate( ulon(ni,nj), ulat(ni,nj) ) + allocate( htn(ni,nj), hte(ni,nj) ) end subroutine allocate_all - + end module grdvars diff --git a/sorc/cpld_gridgen.fd/inputnml.F90 b/sorc/cpld_gridgen.fd/inputnml.F90 index 60bc6c2e4..6e363657b 100644 --- a/sorc/cpld_gridgen.fd/inputnml.F90 +++ b/sorc/cpld_gridgen.fd/inputnml.F90 @@ -7,51 +7,51 @@ module inputnml - use grdvars, only : nx,ny,ni,nj,npx - use grdvars, only : editmask, debug, do_postwgts - use charstrings, only : dirsrc, dirout, fv3dir, res, atmres, topofile, editsfile + use grdvars, only : nx,ny,ni,nj,npx + use grdvars, only : editmask, debug, do_postwgts + use charstrings, only : dirsrc, dirout, fv3dir, res, atmres, topofile, editsfile - implicit none + implicit none - contains +contains -!> Read input namelist file -!! -!! @param[in] fname the file name to read -!! -!! @author Denise.Worthen@noaa.gov + !> Read input namelist file + !! + !! @param[in] fname the file name to read + !! + !! @author Denise.Worthen@noaa.gov - subroutine read_inputnml(fname) + subroutine read_inputnml(fname) - character(len=*), intent(in) :: fname + character(len=*), intent(in) :: fname - ! local variables - integer :: stderr, iounit, rc + ! local variables + integer :: stderr, iounit, rc - namelist /grid_nml/ ni, nj, dirsrc, dirout, fv3dir, topofile, editsfile, & - res, atmres, npx, editmask, debug, & - do_postwgts + namelist /grid_nml/ ni, nj, dirsrc, dirout, fv3dir, topofile, editsfile, & + res, atmres, npx, editmask, debug, & + do_postwgts - ! Check whether file exists. - inquire (file=trim(fname), iostat=rc) + ! Check whether file exists. + inquire (file=trim(fname), iostat=rc) - if (rc /= 0) then - write (stderr, '(3a)') 'Error: input file "', trim(fname), '" does not exist.' - return - end if + if (rc /= 0) then + write (stderr, '(3a)') 'Error: input file "', trim(fname), '" does not exist.' + return + end if - ! Open and read Namelist file. - open (action='read', file=trim(fname), iostat=rc, newunit=iounit) - read (nml=grid_nml, iostat=rc, unit=iounit) + ! Open and read Namelist file. + open (action='read', file=trim(fname), iostat=rc, newunit=iounit) + read (nml=grid_nml, iostat=rc, unit=iounit) - ! set supergrid dimensions - nx = ni*2 - ny = nj*2 + ! set supergrid dimensions + nx = ni*2 + ny = nj*2 - if (rc /= 0) then - write (stderr, '(a)') 'Error: invalid Namelist format.' - end if + if (rc /= 0) then + write (stderr, '(a)') 'Error: invalid Namelist format.' + end if - close (iounit) + close (iounit) end subroutine read_inputnml end module inputnml diff --git a/sorc/cpld_gridgen.fd/mapped_mask.F90 b/sorc/cpld_gridgen.fd/mapped_mask.F90 index 514c45ca3..02e3b85d2 100644 --- a/sorc/cpld_gridgen.fd/mapped_mask.F90 +++ b/sorc/cpld_gridgen.fd/mapped_mask.F90 @@ -8,49 +8,49 @@ module mapped_mask use gengrid_kinds, only : dbl_kind,int_kind,CL,CM,CS - use grdvars, only : ni,nj,npx,mastertask + use grdvars, only : ni,nj,npx use charstrings, only : dirout,res,atmres,logmsg use netcdf implicit none - contains +contains -!> Use ESMF weights to map the ocean land mask to the FV3 tiles and write the mapped mask to 6 tile files -!! -!! @param[in] src a SCRIP file containing the land mask for the ocean domain -!! @param[in] wgt a file containing the ESMF weights to regrid from the ocean domain to the FV3 tile domain -!! -!! @author Denise.Worthen@noaa.gov + !> Use ESMF weights to map the ocean land mask to the FV3 tiles and write the mapped mask to 6 tile files + !! + !! @param[in] src a SCRIP file containing the land mask for the ocean domain + !! @param[in] wgt a file containing the ESMF weights to regrid from the ocean domain to the FV3 tile domain + !! + !! @author Denise.Worthen@noaa.gov subroutine make_frac_land(src, wgt) - character(len=*), intent(in) :: src, wgt + character(len=*), intent(in) :: src, wgt - ! local variables - integer, parameter :: ntile = 6 - integer(int_kind) :: n_a, n_b, n_s + ! local variables + integer, parameter :: ntile = 6 + integer(int_kind) :: n_a, n_b, n_s - integer(int_kind), allocatable, dimension(:) :: col, row - real(dbl_kind), allocatable, dimension(:) :: S - real(dbl_kind), allocatable, dimension(:) :: lat1d, lon1d + integer(int_kind), allocatable, dimension(:) :: col, row + real(dbl_kind), allocatable, dimension(:) :: S + real(dbl_kind), allocatable, dimension(:) :: lat1d, lon1d - integer(int_kind), allocatable, dimension(:) :: src_field - real(dbl_kind), allocatable, dimension(:) :: dst_field + integer(int_kind), allocatable, dimension(:) :: src_field + real(dbl_kind), allocatable, dimension(:) :: dst_field - real(dbl_kind), allocatable, dimension(:,:) :: dst2d - real(dbl_kind), allocatable, dimension(:,:) :: lat2d,lon2d + real(dbl_kind), allocatable, dimension(:,:) :: dst2d + real(dbl_kind), allocatable, dimension(:,:) :: lat2d,lon2d - character(len=CS) :: ctile - character(len=CL) :: fdst - integer :: i,ii,jj,id,rc,ncid, dim2(2) - integer :: istr,iend - integer :: idimid,jdimid + character(len=CS) :: ctile + character(len=CL) :: fdst + integer :: i,ii,jj,id,rc,ncid, dim2(2) + integer :: istr,iend + integer :: idimid,jdimid - character(len=CM) :: vname -!--------------------------------------------------------------------- -! retrieve the weights -!--------------------------------------------------------------------- + character(len=CM) :: vname + !--------------------------------------------------------------------- + ! retrieve the weights + !--------------------------------------------------------------------- rc = nf90_open(trim(wgt), nf90_nowrite, ncid) rc = nf90_inq_dimid(ncid, 'n_s', id) @@ -59,7 +59,7 @@ subroutine make_frac_land(src, wgt) rc = nf90_inquire_dimension(ncid, id, len=n_a) rc = nf90_inq_dimid(ncid, 'n_b', id) rc = nf90_inquire_dimension(ncid, id, len=n_b) - + allocate(col(1:n_s)) allocate(row(1:n_s)) allocate( S(1:n_s)) @@ -81,9 +81,9 @@ subroutine make_frac_land(src, wgt) rc = nf90_get_var(ncid, id, lon1d) rc = nf90_close(ncid) -!--------------------------------------------------------------------- -! retrieve 1-d land mask from the SCRIP file and map it -!--------------------------------------------------------------------- + !--------------------------------------------------------------------- + ! retrieve 1-d land mask from the SCRIP file and map it + !--------------------------------------------------------------------- allocate(src_field(1:n_a)) allocate(dst_field(1:n_b)) @@ -97,61 +97,59 @@ subroutine make_frac_land(src, wgt) dst_field = 0.0 do i = 1,n_s - ii = row(i); jj = col(i) - dst_field(ii) = dst_field(ii) + S(i)*real(src_field(jj),dbl_kind) + ii = row(i); jj = col(i) + dst_field(ii) = dst_field(ii) + S(i)*real(src_field(jj),dbl_kind) enddo -!--------------------------------------------------------------------- -! -!--------------------------------------------------------------------- + !--------------------------------------------------------------------- + ! + !--------------------------------------------------------------------- allocate(dst2d(npx,npx)) allocate(lon2d(npx,npx)); allocate(lat2d(npx,npx)) do i = 0,ntile-1 - istr = i*npx*npx+1 - iend = istr+npx*npx-1 - !print *,i,istr,iend + istr = i*npx*npx+1 + iend = istr+npx*npx-1 + !print *,i,istr,iend - write(ctile,'(a5,i1)')'.tile',i+1 - fdst = trim(dirout)//'/'//trim(atmres)//'.mx'//trim(res)//trim(ctile)//'.nc' - if(mastertask) then + write(ctile,'(a5,i1)')'.tile',i+1 + fdst = trim(dirout)//'/'//trim(atmres)//'.mx'//trim(res)//trim(ctile)//'.nc' logmsg = 'creating mapped ocean mask file '//trim(fdst) print '(a)',trim(logmsg) - end if - - dst2d(:,:) = reshape(dst_field(istr:iend), (/npx,npx/)) - lat2d(:,:) = reshape( lat1d(istr:iend), (/npx,npx/)) - lon2d(:,:) = reshape( lon1d(istr:iend), (/npx,npx/)) - - rc = nf90_create(trim(fdst), nf90_64bit_offset, ncid) - rc = nf90_def_dim(ncid, 'grid_xt', npx, idimid) - rc = nf90_def_dim(ncid, 'grid_yt', npx, jdimid) - - dim2(:) = (/idimid, jdimid/) - vname = 'grid_xt' - rc = nf90_def_var(ncid, vname, nf90_double, dim2, id) - vname = 'grid_yt' - rc = nf90_def_var(ncid, vname, nf90_double, dim2, id) - vname = 'land_frac' - rc = nf90_def_var(ncid, vname, nf90_double, dim2, id) - rc = nf90_enddef(ncid) - - rc = nf90_inq_varid(ncid, 'grid_xt', id) - rc = nf90_put_var(ncid, id, lon2d) - rc = nf90_inq_varid(ncid, 'grid_yt', id) - rc = nf90_put_var(ncid, id, lat2d) - rc = nf90_inq_varid(ncid, 'land_frac', id) - rc = nf90_put_var(ncid, id, dst2d) - rc = nf90_close(ncid) + + dst2d(:,:) = reshape(dst_field(istr:iend), (/npx,npx/)) + lat2d(:,:) = reshape( lat1d(istr:iend), (/npx,npx/)) + lon2d(:,:) = reshape( lon1d(istr:iend), (/npx,npx/)) + + rc = nf90_create(trim(fdst), nf90_64bit_offset, ncid) + rc = nf90_def_dim(ncid, 'grid_xt', npx, idimid) + rc = nf90_def_dim(ncid, 'grid_yt', npx, jdimid) + + dim2(:) = (/idimid, jdimid/) + vname = 'grid_xt' + rc = nf90_def_var(ncid, vname, nf90_double, dim2, id) + vname = 'grid_yt' + rc = nf90_def_var(ncid, vname, nf90_double, dim2, id) + vname = 'land_frac' + rc = nf90_def_var(ncid, vname, nf90_double, dim2, id) + rc = nf90_enddef(ncid) + + rc = nf90_inq_varid(ncid, 'grid_xt', id) + rc = nf90_put_var(ncid, id, lon2d) + rc = nf90_inq_varid(ncid, 'grid_yt', id) + rc = nf90_put_var(ncid, id, lat2d) + rc = nf90_inq_varid(ncid, 'land_frac', id) + rc = nf90_put_var(ncid, id, dst2d) + rc = nf90_close(ncid) end do -!--------------------------------------------------------------------- -! clean up -!--------------------------------------------------------------------- + !--------------------------------------------------------------------- + ! clean up + !--------------------------------------------------------------------- - deallocate(col, row, S, lat1d, lon1d, src_field, dst_field) - deallocate(dst2d,lon2d,lat2d) + deallocate(col, row, S, lat1d, lon1d, src_field, dst_field) + deallocate(dst2d,lon2d,lat2d) end subroutine make_frac_land end module mapped_mask diff --git a/sorc/cpld_gridgen.fd/postwgts.F90 b/sorc/cpld_gridgen.fd/postwgts.F90 index 76d17b779..4ff0bc0fa 100644 --- a/sorc/cpld_gridgen.fd/postwgts.F90 +++ b/sorc/cpld_gridgen.fd/postwgts.F90 @@ -9,108 +9,104 @@ module postwgts use ESMF use gengrid_kinds, only : CL,CM,CS - use grdvars, only : nv, mastertask + use grdvars, only : nv use charstrings, only : dirout, res, staggerlocs, logmsg use netcdf implicit none - contains -!> Create the ESMF weights files to remap velocity points from their native stagger location to the center -!! (Ct) location. Create the ESMF weights file to remap from the Ct location to a rectilinear grid -!! -!! @author Denise.Worthen@noaa.gov - +contains + !> Create the ESMF weights files to remap velocity points from their native stagger location to the center + !! (Ct) location. Create the ESMF weights file to remap from the Ct location to a rectilinear grid + !! + !! @author Denise.Worthen@noaa.gov + subroutine make_postwgts - ! local variables - character(len=CL) :: fsrc, fdst, fwgt - character(len= 2) :: cstagger - - character(len=CM), dimension(2) :: methodname = (/'conserve', 'bilinear'/) - - type(ESMF_RegridMethod_Flag) :: method - ! the number of possible destination grids depends on the source grid resolution - integer :: k,rc,nd,ndest - character(len=CS), allocatable, dimension(:) :: destgrds - -!--------------------------------------------------------------------- -! set the destination grids -!--------------------------------------------------------------------- - - if(trim(res) .eq. '400')return - - if(trim(res) .eq. '100')then - ndest = 1 - allocate(destgrds(ndest)) - destgrds = (/'1p0 '/) - end if - if(trim(res) .eq. '050')then - ndest = 2 - allocate(destgrds(ndest)) - destgrds = (/'1p0 ', '0p5 '/) - end if - if(trim(res) .eq. '025')then - ndest = 3 - allocate(destgrds(ndest)) - destgrds = (/'1p0 ', '0p5 ', '0p25'/) - end if - -!--------------------------------------------------------------------- -! use ESMF to create the weights for unstaggering the points onto -! the Ct staggers for post; the destination is always Ct -!--------------------------------------------------------------------- - - method=ESMF_REGRIDMETHOD_BILINEAR - fdst = trim(dirout)//'/'//'Ct.mx'//trim(res)//'_SCRIP.nc' - do k = 2,nv - cstagger = trim(staggerlocs(k)) - fsrc = trim(dirout)//'/'//trim(cstagger)//'.mx'//trim(res)//'_SCRIP.nc' - fwgt = trim(dirout)//'/'//'tripole.mx'//trim(res)//'.'//trim(cstagger)//'.to.Ct.bilinear.nc' - if(mastertask) then - logmsg = 'creating weight file '//trim(fwgt) - print '(a)',trim(logmsg) - end if - - call ESMF_RegridWeightGen(srcFile=trim(fsrc),dstFile=trim(fdst), & - weightFile=trim(fwgt), regridmethod=method, & - ignoreDegenerate=.true., & - unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) call ESMF_Finalize(endflag=ESMF_END_ABORT) - end do - -!--------------------------------------------------------------------- -! use ESMF to create the weights from the Ct tripole to the rectilinear -! grids with conservative and bilinear methods for post; the source -! file is always Ct -!--------------------------------------------------------------------- - - do nd = 1,ndest - fsrc = trim(dirout)//'/'//'Ct.mx'//trim(res)//'_SCRIP.nc' - fdst = trim(dirout)//'/rect.'//trim(destgrds(nd))//'_SCRIP.nc' - - do k = 1,size(methodname) - if(trim(methodname(k)) .eq. 'bilinear')method=ESMF_REGRIDMETHOD_BILINEAR - if(trim(methodname(k)) .eq. 'conserve')method=ESMF_REGRIDMETHOD_CONSERVE - - fwgt = trim(dirout)//'/'//'tripole.mx'//trim(res)//'.Ct.to.rect.'//trim(destgrds(nd)) & - //'.'//trim(methodname(k))//'.nc' - if(mastertask) then - logmsg = 'creating weight file '//trim(fwgt) - print '(a)',trim(logmsg) - end if - - call ESMF_RegridWeightGen(srcFile=trim(fsrc),dstFile=trim(fdst), & - weightFile=trim(fwgt), regridmethod=method, & - ignoreDegenerate=.true., & - unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) call ESMF_Finalize(endflag=ESMF_END_ABORT) - end do - end do - - deallocate(destgrds) + ! local variables + character(len=CL) :: fsrc, fdst, fwgt + character(len= 2) :: cstagger + + character(len=CM), dimension(2) :: methodname = (/'conserve', 'bilinear'/) + + type(ESMF_RegridMethod_Flag) :: method + ! the number of possible destination grids depends on the source grid resolution + integer :: k,rc,nd,ndest + character(len=CS), allocatable, dimension(:) :: destgrds + + !--------------------------------------------------------------------- + ! set the destination grids + !--------------------------------------------------------------------- + + if(trim(res) .eq. '400')return + + if(trim(res) .eq. '100')then + ndest = 1 + allocate(destgrds(ndest)) + destgrds = (/'1p0 '/) + end if + if(trim(res) .eq. '050')then + ndest = 2 + allocate(destgrds(ndest)) + destgrds = (/'1p0 ', '0p5 '/) + end if + if(trim(res) .eq. '025')then + ndest = 3 + allocate(destgrds(ndest)) + destgrds = (/'1p0 ', '0p5 ', '0p25'/) + end if + + !--------------------------------------------------------------------- + ! use ESMF to create the weights for unstaggering the points onto + ! the Ct staggers for post; the destination is always Ct + !--------------------------------------------------------------------- + + method=ESMF_REGRIDMETHOD_BILINEAR + fdst = trim(dirout)//'/'//'Ct.mx'//trim(res)//'_SCRIP.nc' + do k = 2,nv + cstagger = trim(staggerlocs(k)) + fsrc = trim(dirout)//'/'//trim(cstagger)//'.mx'//trim(res)//'_SCRIP.nc' + fwgt = trim(dirout)//'/'//'tripole.mx'//trim(res)//'.'//trim(cstagger)//'.to.Ct.bilinear.nc' + logmsg = 'creating weight file '//trim(fwgt) + print '(a)',trim(logmsg) + + call ESMF_RegridWeightGen(srcFile=trim(fsrc),dstFile=trim(fdst), & + weightFile=trim(fwgt), regridmethod=method, & + ignoreDegenerate=.true., & + unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & + line=__LINE__, file=__FILE__)) call ESMF_Finalize(endflag=ESMF_END_ABORT) + end do + + !--------------------------------------------------------------------- + ! use ESMF to create the weights from the Ct tripole to the rectilinear + ! grids with conservative and bilinear methods for post; the source + ! file is always Ct + !--------------------------------------------------------------------- + + do nd = 1,ndest + fsrc = trim(dirout)//'/'//'Ct.mx'//trim(res)//'_SCRIP.nc' + fdst = trim(dirout)//'/rect.'//trim(destgrds(nd))//'_SCRIP.nc' + + do k = 1,size(methodname) + if(trim(methodname(k)) .eq. 'bilinear')method=ESMF_REGRIDMETHOD_BILINEAR + if(trim(methodname(k)) .eq. 'conserve')method=ESMF_REGRIDMETHOD_CONSERVE + + fwgt = trim(dirout)//'/'//'tripole.mx'//trim(res)//'.Ct.to.rect.'//trim(destgrds(nd)) & + //'.'//trim(methodname(k))//'.nc' + logmsg = 'creating weight file '//trim(fwgt) + print '(a)',trim(logmsg) + + call ESMF_RegridWeightGen(srcFile=trim(fsrc),dstFile=trim(fdst), & + weightFile=trim(fwgt), regridmethod=method, & + ignoreDegenerate=.true., & + unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & + line=__LINE__, file=__FILE__)) call ESMF_Finalize(endflag=ESMF_END_ABORT) + end do + end do + + deallocate(destgrds) end subroutine make_postwgts end module postwgts diff --git a/sorc/cpld_gridgen.fd/scripgrid.F90 b/sorc/cpld_gridgen.fd/scripgrid.F90 index e08b77e44..d501939a5 100644 --- a/sorc/cpld_gridgen.fd/scripgrid.F90 +++ b/sorc/cpld_gridgen.fd/scripgrid.F90 @@ -8,7 +8,7 @@ module scripgrid use gengrid_kinds, only: dbl_kind,int_kind,CM - use grdvars, only: ni,nj,nv,mastertask + use grdvars, only: ni,nj,nv use grdvars, only: lonCt,latCt,lonCt_vert,latCt_vert use grdvars, only: lonCu,latCu,lonCu_vert,latCu_vert use grdvars, only: lonCv,latCv,lonCv_vert,latCv_vert @@ -22,162 +22,160 @@ module scripgrid public write_scripgrid - contains -!> Write a SCRIP grid file -!! -!! @param[in] fname the file name to write -!! @param[in] cstagger the name of the stagger location -!! @param[in] imask (optional) the land mask values -!! -!! @author Denise.Worthen@noaa.gov - +contains + !> Write a SCRIP grid file + !! + !! @param[in] fname the file name to write + !! @param[in] cstagger the name of the stagger location + !! @param[in] imask (optional) the land mask values + !! + !! @author Denise.Worthen@noaa.gov + subroutine write_scripgrid(fname,cstagger, imask) - character(len=*) , intent(in) :: fname - character(len=*) , intent(in) :: cstagger - integer(int_kind), optional, intent(in) :: imask(:,:) - - ! local variables - integer, parameter :: grid_rank = 2 - - integer :: ii,n,id,rc, ncid, dim2(2),dim1(1) - integer :: idimid,jdimid,kdimid - - integer, dimension(grid_rank) :: gdims - integer(int_kind), dimension(ni*nj) :: cnmask !1-d mask - real(dbl_kind), dimension(ni*nj) :: cnlons, cnlats !1-d center lats,lons - real(dbl_kind), dimension(nv,ni*nj) :: crlons, crlats !2-d corner lats,lons - - real(dbl_kind), dimension(ni,nj) :: tmp - - character(len=2) :: vtype - character(len=CM) :: vname - character(len=CM) :: vunit - -!--------------------------------------------------------------------- -! -!--------------------------------------------------------------------- - - gdims(:) = (/ni,nj/) - if(trim(cstagger) .eq. 'Ct')then - cnlons = reshape(lonCt, (/ni*nj/)) - cnlats = reshape(latCt, (/ni*nj/)) - do n = 1,nv - tmp(:,:) = lonCt_vert(:,:,n) - crlons(n,:) = reshape(tmp, (/ni*nj/)) - tmp(:,:) = latCt_vert(:,:,n) - crlats(n,:) = reshape(tmp, (/ni*nj/)) - end do - end if - - if(trim(cstagger) .eq. 'Cu')then - cnlons = reshape(lonCu, (/ni*nj/)) - cnlats = reshape(latCu, (/ni*nj/)) - do n = 1,nv - tmp(:,:) = lonCu_vert(:,:,n) - crlons(n,:) = reshape(tmp, (/ni*nj/)) - tmp(:,:) = latCu_vert(:,:,n) - crlats(n,:) = reshape(tmp, (/ni*nj/)) - end do - end if - - if(trim(cstagger) .eq. 'Cv')then - cnlons = reshape(lonCv, (/ni*nj/)) - cnlats = reshape(latCv, (/ni*nj/)) - do n = 1,nv - tmp(:,:) = lonCv_vert(:,:,n) - crlons(n,:) = reshape(tmp, (/ni*nj/)) - tmp(:,:) = latCv_vert(:,:,n) - crlats(n,:) = reshape(tmp, (/ni*nj/)) - end do - end if - - if(trim(cstagger) .eq. 'Bu')then - cnlons = reshape(lonBu, (/ni*nj/)) - cnlats = reshape(latBu, (/ni*nj/)) - do n = 1,nv - tmp(:,:) = lonBu_vert(:,:,n) - crlons(n,:) = reshape(tmp, (/ni*nj/)) - tmp(:,:) = latBu_vert(:,:,n) - crlats(n,:) = reshape(tmp, (/ni*nj/)) - end do - end if - - if(present(imask))then - cnmask = reshape(imask, (/ni*nj/)) - else - cnmask = 1 - end if - -!--------------------------------------------------------------------- -! create the netcdf file -!--------------------------------------------------------------------- - - ! define the output variables and file name - call scripvars_typedefine - ! create the file - ! 64_bit offset reqd for 008 grid - ! produces b4b results for smaller grids - rc = nf90_create(trim(fname), nf90_64bit_offset, ncid) - if(mastertask) then + character(len=*) , intent(in) :: fname + character(len=*) , intent(in) :: cstagger + integer(int_kind), optional, intent(in) :: imask(:,:) + + ! local variables + integer, parameter :: grid_rank = 2 + + integer :: ii,n,id,rc, ncid, dim2(2),dim1(1) + integer :: idimid,jdimid,kdimid + + integer, dimension(grid_rank) :: gdims + integer(int_kind), dimension(ni*nj) :: cnmask !1-d mask + real(dbl_kind), dimension(ni*nj) :: cnlons, cnlats !1-d center lats,lons + real(dbl_kind), dimension(nv,ni*nj) :: crlons, crlats !2-d corner lats,lons + + real(dbl_kind), dimension(ni,nj) :: tmp + + character(len=2) :: vtype + character(len=CM) :: vname + character(len=CM) :: vunit + + !--------------------------------------------------------------------- + ! + !--------------------------------------------------------------------- + + gdims(:) = (/ni,nj/) + if(trim(cstagger) .eq. 'Ct')then + cnlons = reshape(lonCt, (/ni*nj/)) + cnlats = reshape(latCt, (/ni*nj/)) + do n = 1,nv + tmp(:,:) = lonCt_vert(:,:,n) + crlons(n,:) = reshape(tmp, (/ni*nj/)) + tmp(:,:) = latCt_vert(:,:,n) + crlats(n,:) = reshape(tmp, (/ni*nj/)) + end do + end if + + if(trim(cstagger) .eq. 'Cu')then + cnlons = reshape(lonCu, (/ni*nj/)) + cnlats = reshape(latCu, (/ni*nj/)) + do n = 1,nv + tmp(:,:) = lonCu_vert(:,:,n) + crlons(n,:) = reshape(tmp, (/ni*nj/)) + tmp(:,:) = latCu_vert(:,:,n) + crlats(n,:) = reshape(tmp, (/ni*nj/)) + end do + end if + + if(trim(cstagger) .eq. 'Cv')then + cnlons = reshape(lonCv, (/ni*nj/)) + cnlats = reshape(latCv, (/ni*nj/)) + do n = 1,nv + tmp(:,:) = lonCv_vert(:,:,n) + crlons(n,:) = reshape(tmp, (/ni*nj/)) + tmp(:,:) = latCv_vert(:,:,n) + crlats(n,:) = reshape(tmp, (/ni*nj/)) + end do + end if + + if(trim(cstagger) .eq. 'Bu')then + cnlons = reshape(lonBu, (/ni*nj/)) + cnlats = reshape(latBu, (/ni*nj/)) + do n = 1,nv + tmp(:,:) = lonBu_vert(:,:,n) + crlons(n,:) = reshape(tmp, (/ni*nj/)) + tmp(:,:) = latBu_vert(:,:,n) + crlats(n,:) = reshape(tmp, (/ni*nj/)) + end do + end if + + if(present(imask))then + cnmask = reshape(imask, (/ni*nj/)) + else + cnmask = 1 + end if + + !--------------------------------------------------------------------- + ! create the netcdf file + !--------------------------------------------------------------------- + + ! define the output variables and file name + call scripvars_typedefine + ! create the file + ! 64_bit offset reqd for 008 grid + ! produces b4b results for smaller grids + rc = nf90_create(trim(fname), nf90_64bit_offset, ncid) logmsg = '==> writing SCRIP grid to '//trim(fname) print '(a)',trim(logmsg) if(rc .ne. 0)print '(a)', 'nf90_create = '//trim(nf90_strerror(rc)) - end if - - rc = nf90_def_dim(ncid, 'grid_size', ni*nj, idimid) - rc = nf90_def_dim(ncid, 'grid_corners', nv, jdimid) - rc = nf90_def_dim(ncid, 'grid_rank', grid_rank, kdimid) - - !grid_dims - dim1(:) = (/kdimid/) - rc = nf90_def_var(ncid, 'grid_dims', nf90_int, dim1, id) - ! mask - dim1(:) = (/idimid/) - rc = nf90_def_var(ncid, 'grid_imask', nf90_int, dim1, id) - rc = nf90_put_att(ncid, id, 'units', 'unitless') - - ! centers - do ii = 1,2 - vname = trim(scripvars(ii)%var_name) - vunit = trim(scripvars(ii)%unit_name) - vtype = trim(scripvars(ii)%var_type) - dim1(:) = (/idimid/) - if(vtype .eq. 'r8')rc = nf90_def_var(ncid, vname, nf90_double, dim1, id) - if(vtype .eq. 'r4')rc = nf90_def_var(ncid, vname, nf90_float, dim1, id) - if(vtype .eq. 'i4')rc = nf90_def_var(ncid, vname, nf90_int, dim1, id) - rc = nf90_put_att(ncid, id, 'units', vunit) - enddo - - ! corners - do ii = 3,4 - vname = trim(scripvars(ii)%var_name) - vunit = trim(scripvars(ii)%unit_name) - vtype = trim(scripvars(ii)%var_type) - dim2(:) = (/jdimid,idimid/) - if(vtype .eq. 'r8')rc = nf90_def_var(ncid, vname, nf90_double, dim2, id) - if(vtype .eq. 'r4')rc = nf90_def_var(ncid, vname, nf90_float, dim2, id) - if(vtype .eq. 'i4')rc = nf90_def_var(ncid, vname, nf90_int, dim2, id) - rc = nf90_put_att(ncid, id, 'units', vunit) - enddo - rc = nf90_enddef(ncid) - - rc = nf90_inq_varid(ncid, 'grid_dims', id) - rc = nf90_put_var(ncid, id, gdims) - rc = nf90_inq_varid(ncid, 'grid_imask', id) - rc = nf90_put_var(ncid, id, cnmask) - - rc = nf90_inq_varid(ncid, 'grid_center_lon', id) - rc = nf90_put_var(ncid, id, cnlons) - rc = nf90_inq_varid(ncid, 'grid_center_lat', id) - rc = nf90_put_var(ncid, id, cnlats) - - rc = nf90_inq_varid(ncid, 'grid_corner_lon', id) - rc = nf90_put_var(ncid, id, crlons) - rc = nf90_inq_varid(ncid, 'grid_corner_lat', id) - rc = nf90_put_var(ncid, id, crlats) - - rc = nf90_close(ncid) + + rc = nf90_def_dim(ncid, 'grid_size', ni*nj, idimid) + rc = nf90_def_dim(ncid, 'grid_corners', nv, jdimid) + rc = nf90_def_dim(ncid, 'grid_rank', grid_rank, kdimid) + + !grid_dims + dim1(:) = (/kdimid/) + rc = nf90_def_var(ncid, 'grid_dims', nf90_int, dim1, id) + ! mask + dim1(:) = (/idimid/) + rc = nf90_def_var(ncid, 'grid_imask', nf90_int, dim1, id) + rc = nf90_put_att(ncid, id, 'units', 'unitless') + + ! centers + do ii = 1,2 + vname = trim(scripvars(ii)%var_name) + vunit = trim(scripvars(ii)%unit_name) + vtype = trim(scripvars(ii)%var_type) + dim1(:) = (/idimid/) + if(vtype .eq. 'r8')rc = nf90_def_var(ncid, vname, nf90_double, dim1, id) + if(vtype .eq. 'r4')rc = nf90_def_var(ncid, vname, nf90_float, dim1, id) + if(vtype .eq. 'i4')rc = nf90_def_var(ncid, vname, nf90_int, dim1, id) + rc = nf90_put_att(ncid, id, 'units', vunit) + enddo + + ! corners + do ii = 3,4 + vname = trim(scripvars(ii)%var_name) + vunit = trim(scripvars(ii)%unit_name) + vtype = trim(scripvars(ii)%var_type) + dim2(:) = (/jdimid,idimid/) + if(vtype .eq. 'r8')rc = nf90_def_var(ncid, vname, nf90_double, dim2, id) + if(vtype .eq. 'r4')rc = nf90_def_var(ncid, vname, nf90_float, dim2, id) + if(vtype .eq. 'i4')rc = nf90_def_var(ncid, vname, nf90_int, dim2, id) + rc = nf90_put_att(ncid, id, 'units', vunit) + enddo + rc = nf90_enddef(ncid) + + rc = nf90_inq_varid(ncid, 'grid_dims', id) + rc = nf90_put_var(ncid, id, gdims) + rc = nf90_inq_varid(ncid, 'grid_imask', id) + rc = nf90_put_var(ncid, id, cnmask) + + rc = nf90_inq_varid(ncid, 'grid_center_lon', id) + rc = nf90_put_var(ncid, id, cnlons) + rc = nf90_inq_varid(ncid, 'grid_center_lat', id) + rc = nf90_put_var(ncid, id, cnlats) + + rc = nf90_inq_varid(ncid, 'grid_corner_lon', id) + rc = nf90_put_var(ncid, id, crlons) + rc = nf90_inq_varid(ncid, 'grid_corner_lat', id) + rc = nf90_put_var(ncid, id, crlats) + + rc = nf90_close(ncid) end subroutine write_scripgrid end module scripgrid diff --git a/sorc/cpld_gridgen.fd/topoedits.F90 b/sorc/cpld_gridgen.fd/topoedits.F90 index 927c3fba2..6e1889474 100644 --- a/sorc/cpld_gridgen.fd/topoedits.F90 +++ b/sorc/cpld_gridgen.fd/topoedits.F90 @@ -9,7 +9,7 @@ module topoedits use gengrid_kinds, only: real_kind,int_kind - use grdvars, only: ni,nj,mastertask + use grdvars, only: ni,nj use grdvars, only: wet4,dp4,minimum_depth,maximum_depth,masking_depth use charstrings, only: logmsg,history use netcdf @@ -20,208 +20,208 @@ module topoedits public add_topoedits public apply_topoedits - contains -!> Read the existing topoedits file, append required topoedits and write a new topoedits file. Use the new topoedits -!! to adjust the land mask used in subsequent steps to match the land mask which will be created at run time -!! -!! @param[in] fsrc the existing topoedits file name -!! @param[out] fdst the modified topoedits file name -!! -!! @author Denise.Worthen@noaa.gov - +contains + !> Read the existing topoedits file, append required topoedits and write a new topoedits file. Use the new topoedits + !! to adjust the land mask used in subsequent steps to match the land mask which will be created at run time + !! + !! @param[in] fsrc the existing topoedits file name + !! @param[out] fdst the modified topoedits file name + !! + !! @author Denise.Worthen@noaa.gov + subroutine add_topoedits(fsrc,fdst) - character(len=*), intent(in) :: fsrc, fdst - - ! local variables - integer :: rc,id,i,j,ii,jj,ncid,dimid,idimid,dim1(1) - integer :: cnt1=0, cnt2=0, icnt - integer(int_kind), allocatable, dimension(:) :: ieds1, jeds1, ieds2, jeds2 - real(real_kind), allocatable, dimension(:) :: zeds1, zeds2 - -!--------------------------------------------------------------------- -! read existing topo edits -!--------------------------------------------------------------------- - - rc = nf90_open(trim(fsrc), nf90_nowrite, ncid) - print '(a)','using topo edits file '//trim(fsrc)//' to edit land mask ' - - rc = nf90_inq_dimid(ncid, 'nEdits', dimid) - rc = nf90_inquire_dimension(ncid, dimid, len=cnt1) - rc = nf90_close(ncid) - - ! return the existing values - allocate(ieds1(cnt1)); ieds1 = 0 - allocate(jeds1(cnt1)); jeds2 = 0 - allocate(zeds1(cnt1)); zeds2 = 0.0 - - rc = nf90_open(fsrc, nf90_nowrite, ncid) - rc = nf90_inq_varid(ncid, 'iEdit', id) - rc = nf90_get_var(ncid, id, ieds1) - rc = nf90_inq_varid(ncid, 'jEdit', id) - rc = nf90_get_var(ncid, id, jeds1) - rc = nf90_inq_varid(ncid, 'zEdit', id) - rc = nf90_get_var(ncid, id, zeds1) - rc = nf90_close(ncid) - -!--------------------------------------------------------------------- -! determine the number of points to be added to topo-edits file -! check only j=1 now -!--------------------------------------------------------------------- - - icnt = 0 - j = 1 - do i = 1,ni - if(wet4(i,j) .eq. 1.0)icnt = icnt+1 - end do - cnt2 = cnt2+icnt - print '(a,i4,a,i4)', 'found ',icnt,' open water points at j=1 , cnt2 = ',cnt2 - - cnt2 = cnt1 + cnt2 - ! allocate space for existing+new values and copy in original values - allocate(ieds2(cnt2)); ieds2 = 0 - allocate(jeds2(cnt2)); jeds2 = 0 - allocate(zeds2(cnt2)); zeds2 = 0.0 - - ieds2(1:cnt1) = ieds1(1:cnt1) - jeds2(1:cnt1) = jeds1(1:cnt1) - zeds2(1:cnt1) = zeds1(1:cnt1) - -!--------------------------------------------------------------------- -! fill in new values and write new topoedits file -!--------------------------------------------------------------------- - - icnt = cnt1 - j = 1 - do i = 1,ni - if(wet4(i,j) .eq. 1.0)then - icnt = icnt+1 - ii = i-1; jj = j-1 - ieds2(icnt) = ii - jeds2(icnt) = jj - zeds2(icnt) = 0.0 - end if - end do - - !do i = 1,cnt2 - ! print '(3i5,f12.4)',i,ieds2(i),jeds2(i),zeds2(i) - !end do - - rc = nf90_create(fdst, nf90_write, ncid) - print '(a)', 'writing new topo edits to '//trim(fdst) - - rc = nf90_def_dim(ncid, 'nEdits', cnt2, idimid) - - rc = nf90_def_var(ncid, 'ni', nf90_int, id) - rc = nf90_def_var(ncid, 'nj', nf90_int, id) - - dim1(:) = (/idimid/) - rc = nf90_def_var(ncid, 'iEdit', nf90_int, dim1, id) - rc = nf90_def_var(ncid, 'jEdit', nf90_int, dim1, id) - rc = nf90_def_var(ncid, 'zEdit', nf90_float, dim1, id) - rc = nf90_put_att(ncid, nf90_global, 'history', trim(history)) - rc = nf90_enddef(ncid) - - rc = nf90_inq_varid(ncid, 'ni', id) - rc = nf90_put_var(ncid, id, ni) - rc = nf90_inq_varid(ncid, 'nj', id) - rc = nf90_put_var(ncid, id, nj) - - rc = nf90_inq_varid(ncid, 'iEdit', id) - rc = nf90_put_var(ncid, id, ieds2) - rc = nf90_inq_varid(ncid, 'jEdit', id) - rc = nf90_put_var(ncid, id, jeds2) - rc = nf90_inq_varid(ncid, 'zEdit', id) - rc = nf90_put_var(ncid, id, zeds2) - - rc = nf90_close(ncid) - -!--------------------------------------------------------------------- -! adjust land mask by same edits used at run time -!--------------------------------------------------------------------- - - do i = 1,cnt2 - ii = ieds2(i); jj = jeds2(i) - if(wet4(ii+1,jj+1) .eq. 0.0 .and. zeds2(i) .gt. 0.0) then - wet4(ii+1,jj+1) = 1.0 - print '(a,2i4,a)', 'switch point ',ii+1,jj+1,' from land->ocean at runtime' - end if - if(wet4(ii+1,jj+1) .eq. 1.0 .and. zeds2(i) .eq. 0.0) then - wet4(ii+1,jj+1) = 0.0 - print '(a,2i4,a)', 'switch point ',ii+1,jj+1,' from ocean->land at runtime' - end if - end do - deallocate(ieds1, jeds1, zeds1) - deallocate(ieds2, jeds2, zeds2) + character(len=*), intent(in) :: fsrc, fdst + + ! local variables + integer :: rc,id,i,j,ii,jj,ncid,dimid,idimid,dim1(1) + integer :: cnt1=0, cnt2=0, icnt + integer(int_kind), allocatable, dimension(:) :: ieds1, jeds1, ieds2, jeds2 + real(real_kind), allocatable, dimension(:) :: zeds1, zeds2 + + !--------------------------------------------------------------------- + ! read existing topo edits + !--------------------------------------------------------------------- + + rc = nf90_open(trim(fsrc), nf90_nowrite, ncid) + print '(a)','using topo edits file '//trim(fsrc)//' to edit land mask ' + + rc = nf90_inq_dimid(ncid, 'nEdits', dimid) + rc = nf90_inquire_dimension(ncid, dimid, len=cnt1) + rc = nf90_close(ncid) + + ! return the existing values + allocate(ieds1(cnt1)); ieds1 = 0 + allocate(jeds1(cnt1)); jeds2 = 0 + allocate(zeds1(cnt1)); zeds2 = 0.0 + + rc = nf90_open(fsrc, nf90_nowrite, ncid) + rc = nf90_inq_varid(ncid, 'iEdit', id) + rc = nf90_get_var(ncid, id, ieds1) + rc = nf90_inq_varid(ncid, 'jEdit', id) + rc = nf90_get_var(ncid, id, jeds1) + rc = nf90_inq_varid(ncid, 'zEdit', id) + rc = nf90_get_var(ncid, id, zeds1) + rc = nf90_close(ncid) + + !--------------------------------------------------------------------- + ! determine the number of points to be added to topo-edits file + ! check only j=1 now + !--------------------------------------------------------------------- + + icnt = 0 + j = 1 + do i = 1,ni + if(wet4(i,j) .eq. 1.0)icnt = icnt+1 + end do + cnt2 = cnt2+icnt + print '(a,i4,a,i4)', 'found ',icnt,' open water points at j=1 , cnt2 = ',cnt2 + + cnt2 = cnt1 + cnt2 + ! allocate space for existing+new values and copy in original values + allocate(ieds2(cnt2)); ieds2 = 0 + allocate(jeds2(cnt2)); jeds2 = 0 + allocate(zeds2(cnt2)); zeds2 = 0.0 + + ieds2(1:cnt1) = ieds1(1:cnt1) + jeds2(1:cnt1) = jeds1(1:cnt1) + zeds2(1:cnt1) = zeds1(1:cnt1) + + !--------------------------------------------------------------------- + ! fill in new values and write new topoedits file + !--------------------------------------------------------------------- + + icnt = cnt1 + j = 1 + do i = 1,ni + if(wet4(i,j) .eq. 1.0)then + icnt = icnt+1 + ii = i-1; jj = j-1 + ieds2(icnt) = ii + jeds2(icnt) = jj + zeds2(icnt) = 0.0 + end if + end do + + !do i = 1,cnt2 + ! print '(3i5,f12.4)',i,ieds2(i),jeds2(i),zeds2(i) + !end do + + rc = nf90_create(fdst, nf90_write, ncid) + print '(a)', 'writing new topo edits to '//trim(fdst) + + rc = nf90_def_dim(ncid, 'nEdits', cnt2, idimid) + + rc = nf90_def_var(ncid, 'ni', nf90_int, id) + rc = nf90_def_var(ncid, 'nj', nf90_int, id) + + dim1(:) = (/idimid/) + rc = nf90_def_var(ncid, 'iEdit', nf90_int, dim1, id) + rc = nf90_def_var(ncid, 'jEdit', nf90_int, dim1, id) + rc = nf90_def_var(ncid, 'zEdit', nf90_float, dim1, id) + rc = nf90_put_att(ncid, nf90_global, 'history', trim(history)) + rc = nf90_enddef(ncid) + + rc = nf90_inq_varid(ncid, 'ni', id) + rc = nf90_put_var(ncid, id, ni) + rc = nf90_inq_varid(ncid, 'nj', id) + rc = nf90_put_var(ncid, id, nj) + + rc = nf90_inq_varid(ncid, 'iEdit', id) + rc = nf90_put_var(ncid, id, ieds2) + rc = nf90_inq_varid(ncid, 'jEdit', id) + rc = nf90_put_var(ncid, id, jeds2) + rc = nf90_inq_varid(ncid, 'zEdit', id) + rc = nf90_put_var(ncid, id, zeds2) + + rc = nf90_close(ncid) + + !--------------------------------------------------------------------- + ! adjust land mask by same edits used at run time + !--------------------------------------------------------------------- + + do i = 1,cnt2 + ii = ieds2(i); jj = jeds2(i) + if(wet4(ii+1,jj+1) .eq. 0.0 .and. zeds2(i) .gt. 0.0) then + wet4(ii+1,jj+1) = 1.0 + print '(a,2i4,a)', 'switch point ',ii+1,jj+1,' from land->ocean at runtime' + end if + if(wet4(ii+1,jj+1) .eq. 1.0 .and. zeds2(i) .eq. 0.0) then + wet4(ii+1,jj+1) = 0.0 + print '(a,2i4,a)', 'switch point ',ii+1,jj+1,' from ocean->land at runtime' + end if + end do + deallocate(ieds1, jeds1, zeds1) + deallocate(ieds2, jeds2, zeds2) end subroutine add_topoedits -!> Read the topoedits file and adjust the bathymetry. Apply limits to bathymetry. -!! -!! @param[in] fsrc the topoedits file name -!! -!! @author Denise.Worthen@noaa.gov + !> Read the topoedits file and adjust the bathymetry. Apply limits to bathymetry. + !! + !! @param[in] fsrc the topoedits file name + !! + !! @author Denise.Worthen@noaa.gov subroutine apply_topoedits(fsrc) - character(len=*), intent(in) :: fsrc - - ! local variables - integer :: rc,ncid,id,dimid,i,j,ii,jj,cnt1 - integer(int_kind), allocatable, dimension(:) :: ieds1, jeds1 - real(real_kind), allocatable, dimension(:) :: zeds1 - - logical :: file_exists -!--------------------------------------------------------------------- -! read and apply topo edits file, if any -!--------------------------------------------------------------------- - - inquire(file=trim(fsrc),exist=file_exists) - if (file_exists) then - rc = nf90_open(trim(fsrc), nf90_nowrite, ncid) - print '(a)','using topo edits file '//trim(fsrc)//' to adjust bathymetry ' - - rc = nf90_inq_dimid(ncid, 'nEdits', dimid) - rc = nf90_inquire_dimension(ncid, dimid, len=cnt1) - rc = nf90_close(ncid) - - ! return the existing values - allocate(ieds1(cnt1)) - allocate(jeds1(cnt1)) - allocate(zeds1(cnt1)) - - rc = nf90_open(fsrc, nf90_nowrite, ncid) - rc = nf90_inq_varid(ncid, 'iEdit', id) - rc = nf90_get_var(ncid, id, ieds1) - rc = nf90_inq_varid(ncid, 'jEdit', id) - rc = nf90_get_var(ncid, id, jeds1) - rc = nf90_inq_varid(ncid, 'zEdit', id) - rc = nf90_get_var(ncid, id, zeds1) - rc = nf90_close(ncid) - - ! apply topo edits from file - do i = 1,cnt1 - ii = ieds1(i); jj = jeds1(i) - print '(a,3i5,f8.2,a,f8.2)', 'Ocean topography edit: ', i, ii+1, jj+1 , dp4(ii+1,jj+1), '->', abs(zeds1(i)) - dp4(ii+1,jj+1) = abs(zeds1(i)) - end do - deallocate(ieds1, jeds1, zeds1) - end if - -!--------------------------------------------------------------------- -! limit topography -!--------------------------------------------------------------------- - - print '(a)', 'Applying topo limits to ensure that min_depth < D(x,y) < max_depth ' - print '(a, f8.2)', 'Using min_depth = ',minimum_depth - print '(a, f8.2)', 'Using max_depth = ',maximum_depth - do j = 1,nj - do i = 1,ni - if(dp4(i,j) > min(minimum_depth,masking_depth))then - dp4(i,j) = min( max(dp4(i,j), minimum_depth), maximum_depth) - end if - end do - end do + character(len=*), intent(in) :: fsrc + + ! local variables + integer :: rc,ncid,id,dimid,i,j,ii,jj,cnt1 + integer(int_kind), allocatable, dimension(:) :: ieds1, jeds1 + real(real_kind), allocatable, dimension(:) :: zeds1 + + logical :: file_exists + !--------------------------------------------------------------------- + ! read and apply topo edits file, if any + !--------------------------------------------------------------------- + + inquire(file=trim(fsrc),exist=file_exists) + if (file_exists) then + rc = nf90_open(trim(fsrc), nf90_nowrite, ncid) + print '(a)','using topo edits file '//trim(fsrc)//' to adjust bathymetry ' + + rc = nf90_inq_dimid(ncid, 'nEdits', dimid) + rc = nf90_inquire_dimension(ncid, dimid, len=cnt1) + rc = nf90_close(ncid) + + ! return the existing values + allocate(ieds1(cnt1)) + allocate(jeds1(cnt1)) + allocate(zeds1(cnt1)) + + rc = nf90_open(fsrc, nf90_nowrite, ncid) + rc = nf90_inq_varid(ncid, 'iEdit', id) + rc = nf90_get_var(ncid, id, ieds1) + rc = nf90_inq_varid(ncid, 'jEdit', id) + rc = nf90_get_var(ncid, id, jeds1) + rc = nf90_inq_varid(ncid, 'zEdit', id) + rc = nf90_get_var(ncid, id, zeds1) + rc = nf90_close(ncid) + + ! apply topo edits from file + do i = 1,cnt1 + ii = ieds1(i); jj = jeds1(i) + print '(a,3i5,f8.2,a,f8.2)', 'Ocean topography edit: ', i, ii+1, jj+1 , dp4(ii+1,jj+1), '->', abs(zeds1(i)) + dp4(ii+1,jj+1) = abs(zeds1(i)) + end do + deallocate(ieds1, jeds1, zeds1) + end if + + !--------------------------------------------------------------------- + ! limit topography + !--------------------------------------------------------------------- + + print '(a)', 'Applying topo limits to ensure that min_depth < D(x,y) < max_depth ' + print '(a, f8.2)', 'Using min_depth = ',minimum_depth + print '(a, f8.2)', 'Using max_depth = ',maximum_depth + do j = 1,nj + do i = 1,ni + if(dp4(i,j) > min(minimum_depth,masking_depth))then + dp4(i,j) = min( max(dp4(i,j), minimum_depth), maximum_depth) + end if + end do + end do end subroutine apply_topoedits end module topoedits diff --git a/sorc/cpld_gridgen.fd/tripolegrid.F90 b/sorc/cpld_gridgen.fd/tripolegrid.F90 index 7161ee0d5..feb287101 100644 --- a/sorc/cpld_gridgen.fd/tripolegrid.F90 +++ b/sorc/cpld_gridgen.fd/tripolegrid.F90 @@ -2,13 +2,13 @@ !! @brief Write the tripole grid file !! @author Denise.Worthen@noaa.gov !! -!> This module writes the master tripole grid file +!> This module writes the main tripole grid file !! @author Denise.Worthen@noaa.gov module tripolegrid use gengrid_kinds, only: dbl_kind,int_kind,CM - use grdvars, only: ni,nj,nv,mastertask,nverts,ncoord + use grdvars, only: ni,nj,nv,nverts,ncoord use grdvars, only: lonCt,latCt,lonCt_vert,latCt_vert use grdvars, only: lonCu,latCu,lonCu_vert,latCu_vert use grdvars, only: lonCv,latCv,lonCv_vert,latCv_vert @@ -23,140 +23,138 @@ module tripolegrid public write_tripolegrid - contains -!> Write the tripole grid file -!! -!! @param[in] fname the name of the tripole grid file to write -!! -!! @author Denise.Worthen@noaa.gov - +contains + !> Write the tripole grid file + !! + !! @param[in] fname the name of the tripole grid file to write + !! + !! @author Denise.Worthen@noaa.gov + subroutine write_tripolegrid(fname) - character(len=*), intent(in) :: fname + character(len=*), intent(in) :: fname - ! local variables - integer :: ii,id,rc, ncid, dim2(2),dim3(3) - integer :: idimid,jdimid,kdimid + ! local variables + integer :: ii,id,rc, ncid, dim2(2),dim3(3) + integer :: idimid,jdimid,kdimid -!--------------------------------------------------------------------- -! create the netcdf file -!--------------------------------------------------------------------- + !--------------------------------------------------------------------- + ! create the netcdf file + !--------------------------------------------------------------------- - ! define the output variables and file name - call fixvars_typedefine + ! define the output variables and file name + call fixvars_typedefine - ! create the file - ! 64_bit offset reqd for 008 grid - ! produces b4b results for smaller grids - rc = nf90_create(trim(fname), nf90_64bit_offset, ncid) - if(mastertask) then + ! create the file + ! 64_bit offset reqd for 008 grid + ! produces b4b results for smaller grids + rc = nf90_create(trim(fname), nf90_64bit_offset, ncid) logmsg = '==> writing tripole grid to '//trim(fname) print '(a)', trim(logmsg) if(rc .ne. 0)print '(a)', 'nf90_create = '//trim(nf90_strerror(rc)) - end if - - rc = nf90_def_dim(ncid, 'ni', ni, idimid) - rc = nf90_def_dim(ncid, 'nj', nj, jdimid) - rc = nf90_def_dim(ncid, 'nv', nv, kdimid) - - !mask - dim2(:) = (/idimid, jdimid/) - rc = nf90_def_var(ncid, 'wet', nf90_int, dim2, id) - rc = nf90_put_att(ncid, id, 'units', 'nd') - !area - rc = nf90_def_var(ncid, 'area', nf90_double, dim2, id) - rc = nf90_put_att(ncid, id, 'units', 'm2') - !angleT - rc = nf90_def_var(ncid, 'anglet', nf90_double, dim2, id) - rc = nf90_put_att(ncid, id, 'units', 'radians') - !bathymetry - rc = nf90_def_var(ncid, 'depth', nf90_float, dim2, id) - rc = nf90_put_att(ncid, id, 'units', 'm') - - dim2(:) = (/idimid, jdimid/) - do ii = 1,ncoord - rc = nf90_def_var(ncid, trim(fixvars(ii)%var_name), nf90_double, dim2, id) - rc = nf90_put_att(ncid, id, 'units', trim(fixvars(ii)%unit_name)) - rc = nf90_put_att(ncid, id, 'long_name', trim(fixvars(ii)%long_name)) - if(trim(fixvars(ii)%var_name(1:3)) .eq. "lon")then - rc = nf90_put_att(ncid, id, 'lon_bounds', trim(fixvars(ii)%vertices)) - else - rc = nf90_put_att(ncid, id, 'lat_bounds', trim(fixvars(ii)%vertices)) - endif - enddo - - dim3(:) = (/idimid, jdimid, kdimid/) - do ii = ncoord+1,ncoord+nverts - rc = nf90_def_var(ncid, trim(fixvars(ii)%var_name), nf90_double, dim3, id) - rc = nf90_put_att(ncid, id, 'units', trim(fixvars(ii)%unit_name)) - rc = nf90_put_att(ncid, id, 'long_name', trim(fixvars(ii)%long_name)) - enddo - - rc = nf90_put_att(ncid, nf90_global, 'history', trim(history)) - rc = nf90_enddef(ncid) - - rc = nf90_inq_varid(ncid, 'wet', id) - rc = nf90_put_var(ncid, id, int(wet4)) - - rc = nf90_inq_varid(ncid, 'area', id) - rc = nf90_put_var(ncid, id, areaCt) - - rc = nf90_inq_varid(ncid,'anglet', id) - rc = nf90_put_var(ncid, id, anglet) - - rc = nf90_inq_varid(ncid, 'depth', id) - rc = nf90_put_var(ncid, id, dp4) - - rc = nf90_inq_varid(ncid, 'lonCt', id) - rc = nf90_put_var(ncid, id, lonCt) - - rc = nf90_inq_varid(ncid, 'latCt', id) - rc = nf90_put_var(ncid, id, latCt) - - rc = nf90_inq_varid(ncid, 'lonCv', id) - rc = nf90_put_var(ncid, id, lonCv) - - rc = nf90_inq_varid(ncid, 'latCv', id) - rc = nf90_put_var(ncid, id, latCv) - - rc = nf90_inq_varid(ncid, 'lonCu', id) - rc = nf90_put_var(ncid, id, lonCu) - - rc = nf90_inq_varid(ncid, 'latCu', id) - rc = nf90_put_var(ncid, id, latCu) - - rc = nf90_inq_varid(ncid, 'lonBu', id) - rc = nf90_put_var(ncid, id, lonBu) - - rc = nf90_inq_varid(ncid, 'latBu', id) - rc = nf90_put_var(ncid, id, latBu) - - ! vertices - rc = nf90_inq_varid(ncid, 'lonCt_vert', id) - rc = nf90_put_var(ncid, id, lonCt_vert) - - rc = nf90_inq_varid(ncid, 'latCt_vert', id) - rc = nf90_put_var(ncid, id, latCt_vert) - - rc = nf90_inq_varid(ncid, 'lonCv_vert', id) - rc = nf90_put_var(ncid, id, lonCv_vert) - - rc = nf90_inq_varid(ncid, 'latCv_vert', id) - rc = nf90_put_var(ncid, id, latCv_vert) - - rc = nf90_inq_varid(ncid, 'lonCu_vert', id) - rc = nf90_put_var(ncid, id, lonCu_vert) - - rc = nf90_inq_varid(ncid, 'latCu_vert', id) - rc = nf90_put_var(ncid, id, latCu_vert) - - rc = nf90_inq_varid(ncid, 'lonBu_vert', id) - rc = nf90_put_var(ncid, id, lonBu_vert) - - rc = nf90_inq_varid(ncid, 'latBu_vert', id) - rc = nf90_put_var(ncid, id, latBu_vert) - - rc = nf90_close(ncid) + + rc = nf90_def_dim(ncid, 'ni', ni, idimid) + rc = nf90_def_dim(ncid, 'nj', nj, jdimid) + rc = nf90_def_dim(ncid, 'nv', nv, kdimid) + + !mask + dim2(:) = (/idimid, jdimid/) + rc = nf90_def_var(ncid, 'wet', nf90_int, dim2, id) + rc = nf90_put_att(ncid, id, 'units', 'nd') + !area + rc = nf90_def_var(ncid, 'area', nf90_double, dim2, id) + rc = nf90_put_att(ncid, id, 'units', 'm2') + !angleT + rc = nf90_def_var(ncid, 'anglet', nf90_double, dim2, id) + rc = nf90_put_att(ncid, id, 'units', 'radians') + !bathymetry + rc = nf90_def_var(ncid, 'depth', nf90_float, dim2, id) + rc = nf90_put_att(ncid, id, 'units', 'm') + + dim2(:) = (/idimid, jdimid/) + do ii = 1,ncoord + rc = nf90_def_var(ncid, trim(fixvars(ii)%var_name), nf90_double, dim2, id) + rc = nf90_put_att(ncid, id, 'units', trim(fixvars(ii)%unit_name)) + rc = nf90_put_att(ncid, id, 'long_name', trim(fixvars(ii)%long_name)) + if(trim(fixvars(ii)%var_name(1:3)) .eq. "lon")then + rc = nf90_put_att(ncid, id, 'lon_bounds', trim(fixvars(ii)%vertices)) + else + rc = nf90_put_att(ncid, id, 'lat_bounds', trim(fixvars(ii)%vertices)) + endif + enddo + + dim3(:) = (/idimid, jdimid, kdimid/) + do ii = ncoord+1,ncoord+nverts + rc = nf90_def_var(ncid, trim(fixvars(ii)%var_name), nf90_double, dim3, id) + rc = nf90_put_att(ncid, id, 'units', trim(fixvars(ii)%unit_name)) + rc = nf90_put_att(ncid, id, 'long_name', trim(fixvars(ii)%long_name)) + enddo + + rc = nf90_put_att(ncid, nf90_global, 'history', trim(history)) + rc = nf90_enddef(ncid) + + rc = nf90_inq_varid(ncid, 'wet', id) + rc = nf90_put_var(ncid, id, int(wet4)) + + rc = nf90_inq_varid(ncid, 'area', id) + rc = nf90_put_var(ncid, id, areaCt) + + rc = nf90_inq_varid(ncid,'anglet', id) + rc = nf90_put_var(ncid, id, anglet) + + rc = nf90_inq_varid(ncid, 'depth', id) + rc = nf90_put_var(ncid, id, dp4) + + rc = nf90_inq_varid(ncid, 'lonCt', id) + rc = nf90_put_var(ncid, id, lonCt) + + rc = nf90_inq_varid(ncid, 'latCt', id) + rc = nf90_put_var(ncid, id, latCt) + + rc = nf90_inq_varid(ncid, 'lonCv', id) + rc = nf90_put_var(ncid, id, lonCv) + + rc = nf90_inq_varid(ncid, 'latCv', id) + rc = nf90_put_var(ncid, id, latCv) + + rc = nf90_inq_varid(ncid, 'lonCu', id) + rc = nf90_put_var(ncid, id, lonCu) + + rc = nf90_inq_varid(ncid, 'latCu', id) + rc = nf90_put_var(ncid, id, latCu) + + rc = nf90_inq_varid(ncid, 'lonBu', id) + rc = nf90_put_var(ncid, id, lonBu) + + rc = nf90_inq_varid(ncid, 'latBu', id) + rc = nf90_put_var(ncid, id, latBu) + + ! vertices + rc = nf90_inq_varid(ncid, 'lonCt_vert', id) + rc = nf90_put_var(ncid, id, lonCt_vert) + + rc = nf90_inq_varid(ncid, 'latCt_vert', id) + rc = nf90_put_var(ncid, id, latCt_vert) + + rc = nf90_inq_varid(ncid, 'lonCv_vert', id) + rc = nf90_put_var(ncid, id, lonCv_vert) + + rc = nf90_inq_varid(ncid, 'latCv_vert', id) + rc = nf90_put_var(ncid, id, latCv_vert) + + rc = nf90_inq_varid(ncid, 'lonCu_vert', id) + rc = nf90_put_var(ncid, id, lonCu_vert) + + rc = nf90_inq_varid(ncid, 'latCu_vert', id) + rc = nf90_put_var(ncid, id, latCu_vert) + + rc = nf90_inq_varid(ncid, 'lonBu_vert', id) + rc = nf90_put_var(ncid, id, lonBu_vert) + + rc = nf90_inq_varid(ncid, 'latBu_vert', id) + rc = nf90_put_var(ncid, id, latBu_vert) + + rc = nf90_close(ncid) end subroutine write_tripolegrid end module tripolegrid diff --git a/sorc/cpld_gridgen.fd/vartypedefs.F90 b/sorc/cpld_gridgen.fd/vartypedefs.F90 index 8e4b09985..388b6aef2 100644 --- a/sorc/cpld_gridgen.fd/vartypedefs.F90 +++ b/sorc/cpld_gridgen.fd/vartypedefs.F90 @@ -14,195 +14,195 @@ module vartypedefs integer, parameter :: maxvars = 20 !< The maximum number of variables written to a file type :: vardefs - character(len=CM) :: var_name !< A variable name - character(len=CM) :: long_name !< A variable's long name - character(len=CM) :: unit_name !< A variable's unit - character(len= 2) :: var_type !< A variable's type - character(len=CM) :: vertices !< A variable's vertices + character(len=CM) :: var_name !< A variable name + character(len=CM) :: long_name !< A variable's long name + character(len=CM) :: unit_name !< A variable's unit + character(len= 2) :: var_type !< A variable's type + character(len=CM) :: vertices !< A variable's vertices end type vardefs - type(vardefs) :: fixvars(maxvars) !< Attribute definitions for the variables written to the master tripole file + type(vardefs) :: fixvars(maxvars) !< Attribute definitions for the variables written to the main tripole file type(vardefs) :: cicevars(maxvars) !< Attribute definitions for the variables written to the CICE grid file type(vardefs) :: scripvars(maxvars) !< Attribute definitions for the variables written to any SCRIP file - contains +contains -!> Define the variables written to the tripole grid file -!! -!! @author Denise.Worthen@noaa.gov + !> Define the variables written to the tripole grid file + !! + !! @author Denise.Worthen@noaa.gov subroutine fixvars_typedefine - ! local variables - integer :: ii = 0 - - !default - fixvars(:)%var_type = 'r8' - fixvars(:)%vertices = '' - - ii = ii + 1 - fixvars(ii)%var_name = 'lonCt' - fixvars(ii)%long_name = 'Longitude of center (Ct) points' - fixvars(ii)%unit_name = 'degrees_east' - fixvars(ii)%vertices = 'lonCt_vert' - - ii = ii + 1 - fixvars(ii)%var_name = 'latCt' - fixvars(ii)%long_name = 'Latitude of center (Ct) points' - fixvars(ii)%unit_name = 'degrees_north' - fixvars(ii)%vertices = 'latCt_vert' - - ii = ii + 1 - fixvars(ii)%var_name = 'lonCv' - fixvars(ii)%long_name = 'Longitude of meridional velocity (Cv) points' - fixvars(ii)%unit_name = 'degrees_east' - fixvars(ii)%vertices = 'lonCv_vert' - - ii = ii + 1 - fixvars(ii)%var_name = 'latCv' - fixvars(ii)%long_name = 'Latitude of meridional velocity (Cv) points' - fixvars(ii)%unit_name = 'degrees_north' - fixvars(ii)%vertices = 'latCv_vert' - - ii = ii + 1 - fixvars(ii)%var_name = 'lonCu' - fixvars(ii)%long_name = 'Longitude of zonal velocity (Cu) points' - fixvars(ii)%unit_name = 'degrees_east' - fixvars(ii)%vertices = 'lonCu_vert' - - ii = ii + 1 - fixvars(ii)%var_name = 'latCu' - fixvars(ii)%long_name = 'Latitude of zonal velocity (Cu) points' - fixvars(ii)%unit_name = 'degrees_north' - fixvars(ii)%vertices = 'latCu_vert' - - ii = ii + 1 - fixvars(ii)%var_name = 'lonBu' - fixvars(ii)%long_name = 'Longitude of corner (Bu) points' - fixvars(ii)%unit_name = 'degrees_east' - fixvars(ii)%vertices = 'lonBu_vert' - - ii = ii + 1 - fixvars(ii)%var_name = 'latBu' - fixvars(ii)%long_name = 'Latitude of corner (Bu) points' - fixvars(ii)%unit_name = 'degrees_north' - fixvars(ii)%vertices = 'latBu_vert' - - ii = ii + 1 - fixvars(ii)%var_name = 'lonCt_vert' - fixvars(ii)%long_name = 'Longitude Vertices of Ct points' - fixvars(ii)%unit_name = 'degrees_east' - - ii = ii + 1 - fixvars(ii)%var_name = 'latCt_vert' - fixvars(ii)%long_name = 'Latitude Vertices of Ct points' - fixvars(ii)%unit_name = 'degrees_north' - - ii = ii + 1 - fixvars(ii)%var_name = 'lonCu_vert' - fixvars(ii)%long_name = 'Longitude Vertices of Cu points' - fixvars(ii)%unit_name = 'degrees_east' - - ii = ii + 1 - fixvars(ii)%var_name = 'latCu_vert' - fixvars(ii)%long_name = 'Latitude Vertices of Cu points' - fixvars(ii)%unit_name = 'degrees_north' - - ii = ii + 1 - fixvars(ii)%var_name = 'lonCv_vert' - fixvars(ii)%long_name = 'Longitude Vertices of Cv points' - fixvars(ii)%unit_name = 'degrees_east' - - ii = ii + 1 - fixvars(ii)%var_name = 'latCv_vert' - fixvars(ii)%long_name = 'Latitude Vertices of Cv points' - fixvars(ii)%unit_name = 'degrees_north' - - ii = ii + 1 - fixvars(ii)%var_name = 'lonBu_vert' - fixvars(ii)%long_name = 'Longitude Vertices of Bu points' - fixvars(ii)%unit_name = 'degrees_east' - - ii = ii + 1 - fixvars(ii)%var_name = 'latBu_vert' - fixvars(ii)%long_name = 'Latitude Vertices of Bu points' - fixvars(ii)%unit_name = 'degrees_north' - - end subroutine fixvars_typedefine -!> Define the variables written to the CICE grid file -!! -!! @author Denise.Worthen@noaa.gov - - subroutine cicevars_typedefine - - ! local variables - integer :: ii = 0 - - !default - cicevars(:)%var_type = 'r8' - cicevars(:)%vertices = '' - - ii = ii + 1 - cicevars(ii)%var_name = 'ulon' - cicevars(ii)%long_name = 'Longitude of corner (Bu) points' - cicevars(ii)%unit_name = 'radians' - - ii = ii + 1 - cicevars(ii)%var_name = 'ulat' - cicevars(ii)%long_name = 'Latitude of corner (Bu) points' - cicevars(ii)%unit_name = 'radians' - - ii = ii + 1 - cicevars(ii)%var_name = 'hte' - cicevars(ii)%long_name = 'Distance between corner (Bu) points, east face' - cicevars(ii)%unit_name = 'cm' - - ii = ii + 1 - cicevars(ii)%var_name = 'htn' - cicevars(ii)%long_name = 'Distance between corner (Bu) points, north face' - cicevars(ii)%unit_name = 'cm' - - ii = ii + 1 - cicevars(ii)%var_name = 'angle' - cicevars(ii)%long_name = 'Angle at corner (Bu) points' - cicevars(ii)%unit_name = 'radians' - - ii = ii + 1 - cicevars(ii)%var_name = 'kmt' - cicevars(ii)%long_name = 'ocean fraction at T-cell centers' - cicevars(ii)%unit_name = 'none' - cicevars(ii)%var_type = 'i4' - - end subroutine cicevars_typedefine -!> Define the variables written to any SCRIP grid file -!! -!! @author Denise.Worthen@noaa.gov - - subroutine scripvars_typedefine - - ! local variables - integer :: ii = 0 - - !default - scripvars(:)%long_name = '' - scripvars(:)%var_type = 'r8' - scripvars(:)%vertices = '' - - ii = ii + 1 - scripvars(ii)%var_name = 'grid_center_lat' - scripvars(ii)%unit_name = 'degrees' - - ii = ii + 1 - scripvars(ii)%var_name = 'grid_center_lon' - scripvars(ii)%unit_name = 'degrees' - - ii = ii + 1 - scripvars(ii)%var_name = 'grid_corner_lat' - scripvars(ii)%unit_name = 'degrees' - - ii = ii + 1 - scripvars(ii)%var_name = 'grid_corner_lon' - scripvars(ii)%unit_name = 'degrees' - - end subroutine scripvars_typedefine + ! local variables + integer :: ii = 0 + + !default + fixvars(:)%var_type = 'r8' + fixvars(:)%vertices = '' + + ii = ii + 1 + fixvars(ii)%var_name = 'lonCt' + fixvars(ii)%long_name = 'Longitude of center (Ct) points' + fixvars(ii)%unit_name = 'degrees_east' + fixvars(ii)%vertices = 'lonCt_vert' + + ii = ii + 1 + fixvars(ii)%var_name = 'latCt' + fixvars(ii)%long_name = 'Latitude of center (Ct) points' + fixvars(ii)%unit_name = 'degrees_north' + fixvars(ii)%vertices = 'latCt_vert' + + ii = ii + 1 + fixvars(ii)%var_name = 'lonCv' + fixvars(ii)%long_name = 'Longitude of meridional velocity (Cv) points' + fixvars(ii)%unit_name = 'degrees_east' + fixvars(ii)%vertices = 'lonCv_vert' + + ii = ii + 1 + fixvars(ii)%var_name = 'latCv' + fixvars(ii)%long_name = 'Latitude of meridional velocity (Cv) points' + fixvars(ii)%unit_name = 'degrees_north' + fixvars(ii)%vertices = 'latCv_vert' + + ii = ii + 1 + fixvars(ii)%var_name = 'lonCu' + fixvars(ii)%long_name = 'Longitude of zonal velocity (Cu) points' + fixvars(ii)%unit_name = 'degrees_east' + fixvars(ii)%vertices = 'lonCu_vert' + + ii = ii + 1 + fixvars(ii)%var_name = 'latCu' + fixvars(ii)%long_name = 'Latitude of zonal velocity (Cu) points' + fixvars(ii)%unit_name = 'degrees_north' + fixvars(ii)%vertices = 'latCu_vert' + + ii = ii + 1 + fixvars(ii)%var_name = 'lonBu' + fixvars(ii)%long_name = 'Longitude of corner (Bu) points' + fixvars(ii)%unit_name = 'degrees_east' + fixvars(ii)%vertices = 'lonBu_vert' + + ii = ii + 1 + fixvars(ii)%var_name = 'latBu' + fixvars(ii)%long_name = 'Latitude of corner (Bu) points' + fixvars(ii)%unit_name = 'degrees_north' + fixvars(ii)%vertices = 'latBu_vert' + + ii = ii + 1 + fixvars(ii)%var_name = 'lonCt_vert' + fixvars(ii)%long_name = 'Longitude Vertices of Ct points' + fixvars(ii)%unit_name = 'degrees_east' + + ii = ii + 1 + fixvars(ii)%var_name = 'latCt_vert' + fixvars(ii)%long_name = 'Latitude Vertices of Ct points' + fixvars(ii)%unit_name = 'degrees_north' + + ii = ii + 1 + fixvars(ii)%var_name = 'lonCu_vert' + fixvars(ii)%long_name = 'Longitude Vertices of Cu points' + fixvars(ii)%unit_name = 'degrees_east' + + ii = ii + 1 + fixvars(ii)%var_name = 'latCu_vert' + fixvars(ii)%long_name = 'Latitude Vertices of Cu points' + fixvars(ii)%unit_name = 'degrees_north' + + ii = ii + 1 + fixvars(ii)%var_name = 'lonCv_vert' + fixvars(ii)%long_name = 'Longitude Vertices of Cv points' + fixvars(ii)%unit_name = 'degrees_east' + + ii = ii + 1 + fixvars(ii)%var_name = 'latCv_vert' + fixvars(ii)%long_name = 'Latitude Vertices of Cv points' + fixvars(ii)%unit_name = 'degrees_north' + + ii = ii + 1 + fixvars(ii)%var_name = 'lonBu_vert' + fixvars(ii)%long_name = 'Longitude Vertices of Bu points' + fixvars(ii)%unit_name = 'degrees_east' + + ii = ii + 1 + fixvars(ii)%var_name = 'latBu_vert' + fixvars(ii)%long_name = 'Latitude Vertices of Bu points' + fixvars(ii)%unit_name = 'degrees_north' + + end subroutine fixvars_typedefine + !> Define the variables written to the CICE grid file + !! + !! @author Denise.Worthen@noaa.gov + + subroutine cicevars_typedefine + + ! local variables + integer :: ii = 0 + + !default + cicevars(:)%var_type = 'r8' + cicevars(:)%vertices = '' + + ii = ii + 1 + cicevars(ii)%var_name = 'ulon' + cicevars(ii)%long_name = 'Longitude of corner (Bu) points' + cicevars(ii)%unit_name = 'radians' + + ii = ii + 1 + cicevars(ii)%var_name = 'ulat' + cicevars(ii)%long_name = 'Latitude of corner (Bu) points' + cicevars(ii)%unit_name = 'radians' + + ii = ii + 1 + cicevars(ii)%var_name = 'hte' + cicevars(ii)%long_name = 'Distance between corner (Bu) points, east face' + cicevars(ii)%unit_name = 'cm' + + ii = ii + 1 + cicevars(ii)%var_name = 'htn' + cicevars(ii)%long_name = 'Distance between corner (Bu) points, north face' + cicevars(ii)%unit_name = 'cm' + + ii = ii + 1 + cicevars(ii)%var_name = 'angle' + cicevars(ii)%long_name = 'Angle at corner (Bu) points' + cicevars(ii)%unit_name = 'radians' + + ii = ii + 1 + cicevars(ii)%var_name = 'kmt' + cicevars(ii)%long_name = 'ocean fraction at T-cell centers' + cicevars(ii)%unit_name = 'none' + cicevars(ii)%var_type = 'i4' + + end subroutine cicevars_typedefine + !> Define the variables written to any SCRIP grid file + !! + !! @author Denise.Worthen@noaa.gov + + subroutine scripvars_typedefine + + ! local variables + integer :: ii = 0 + + !default + scripvars(:)%long_name = '' + scripvars(:)%var_type = 'r8' + scripvars(:)%vertices = '' + + ii = ii + 1 + scripvars(ii)%var_name = 'grid_center_lat' + scripvars(ii)%unit_name = 'degrees' + + ii = ii + 1 + scripvars(ii)%var_name = 'grid_center_lon' + scripvars(ii)%unit_name = 'degrees' + + ii = ii + 1 + scripvars(ii)%var_name = 'grid_corner_lat' + scripvars(ii)%unit_name = 'degrees' + + ii = ii + 1 + scripvars(ii)%var_name = 'grid_corner_lon' + scripvars(ii)%unit_name = 'degrees' + + end subroutine scripvars_typedefine end module vartypedefs diff --git a/sorc/cpld_gridgen.fd/vertices.F90 b/sorc/cpld_gridgen.fd/vertices.F90 index e45df6568..17158abaf 100644 --- a/sorc/cpld_gridgen.fd/vertices.F90 +++ b/sorc/cpld_gridgen.fd/vertices.F90 @@ -17,134 +17,134 @@ module vertices implicit none - contains -!> Fill the vertices for any stagger location between bounding j-rows -!! -!! @param[in] jbeg the beginning row -!! @param[in] jend the ending row -!! @param[in] iVert the i-offset applied to the i-index of a stagger grid -!! @param[in] jVert the j-offset applied to the j-index of a stagger grid -!! @param[in] lat the latitudes of the stagger grid which define each vertex -!! @param[in] lon the longitudes of the stagger grid which define each vertex -!! @param[out] latvert the latitudes of each vertex -!! @param[out] lonvert the longitudes of each vertex -!! @author Denise.Worthen@noaa.gov - - subroutine fill_vertices(jbeg,jend,iVert,jVert,lat,lon,latvert,lonvert) - - integer, intent( in) :: jbeg,jend - integer, intent( in) :: iVert(nv), jVert(nv) - real(dbl_kind), dimension(ni,nj), intent( in) :: lat, lon +contains + !> Fill the vertices for any stagger location between bounding j-rows + !! + !! @param[in] jbeg the beginning row + !! @param[in] jend the ending row + !! @param[in] iVert the i-offset applied to the i-index of a stagger grid + !! @param[in] jVert the j-offset applied to the j-index of a stagger grid + !! @param[in] lat the latitudes of the stagger grid which define each vertex + !! @param[in] lon the longitudes of the stagger grid which define each vertex + !! @param[out] latvert the latitudes of each vertex + !! @param[out] lonvert the longitudes of each vertex + !! @author Denise.Worthen@noaa.gov - real(dbl_kind), dimension(ni,nj,nv), intent(out) :: latvert,lonvert - - ! local variables - integer :: i,j,n,ii,jj + subroutine fill_vertices(jbeg,jend,iVert,jVert,lat,lon,latvert,lonvert) - do j = jbeg,jend - do i = 1,ni - do n = 1,nv - ii = i + iVert(n); jj = j + jVert(n) - if(ii .eq. 0)ii = ni - if(ii .eq. ni+1)ii = 1 - latvert(i,j,n) = lat(ii,jj) - lonvert(i,j,n) = lon(ii,jj) + integer, intent( in) :: jbeg,jend + integer, intent( in) :: iVert(nv), jVert(nv) + real(dbl_kind), dimension(ni,nj), intent( in) :: lat, lon + + real(dbl_kind), dimension(ni,nj,nv), intent(out) :: latvert,lonvert + + ! local variables + integer :: i,j,n,ii,jj + + do j = jbeg,jend + do i = 1,ni + do n = 1,nv + ii = i + iVert(n); jj = j + jVert(n) + if(ii .eq. 0)ii = ni + if(ii .eq. ni+1)ii = 1 + latvert(i,j,n) = lat(ii,jj) + lonvert(i,j,n) = lon(ii,jj) + enddo + enddo enddo - enddo - enddo end subroutine fill_vertices -!> Fill the vertices for a stagger location along the bottom j-row -!! -!! @param[in] iVert the i-offset applied to the i-index of a stagger grid -!! @param[in] jVert the j-offset applied to the j-index of a stagger grid -!! @param[in] lat the latitudes of the stagger grid which define each vertex -!! @param[in] lon the longitudes of the stagger grid which define each vertex -!! @param[in] dlat the approximate latitude along the bottom-most row -!! @param[out] latvert the latitudes of each vertex -!! @param[out] lonvert the longitudes of each vertex -!! @author Denise.Worthen@noaa.gov + !> Fill the vertices for a stagger location along the bottom j-row + !! + !! @param[in] iVert the i-offset applied to the i-index of a stagger grid + !! @param[in] jVert the j-offset applied to the j-index of a stagger grid + !! @param[in] lat the latitudes of the stagger grid which define each vertex + !! @param[in] lon the longitudes of the stagger grid which define each vertex + !! @param[in] dlat the approximate latitude along the bottom-most row + !! @param[out] latvert the latitudes of each vertex + !! @param[out] lonvert the longitudes of each vertex + !! @author Denise.Worthen@noaa.gov subroutine fill_bottom(iVert,jVert,lat,lon,latvert,lonvert,dlat) - integer, intent( in) :: iVert(nv), jVert(nv) - real(dbl_kind), dimension(ni,nj), intent( in) :: lat, lon - real(dbl_kind), dimension(ni), intent( in) :: dlat - - real(dbl_kind), dimension(ni,nj,nv), intent(out) :: latvert,lonvert - - ! local variables - integer :: i,j,n,ii,jj - - ! fill in grid bottom (j=1) - ! vertices 1,2 are available - ! vertices 3,4 must be set manually - j = 1 - do i = 1,ni - do n = 1,2 - ii = i + iVert(n); jj = j + jVert(n) - if(ii .eq. 0)ii = ni - if(ii .eq. ni+1)ii = 1 - latvert(i,j,n) = lat(ii,jj) - lonvert(i,j,n) = lon(ii,jj) - enddo - do n = 3,4 - ii = i + iVert(n) - if(ii .eq. 0)ii = ni - if(ii .eq. ni+1)ii = 1 - latvert(i,j, n) = dlat(ii) + integer, intent( in) :: iVert(nv), jVert(nv) + real(dbl_kind), dimension(ni,nj), intent( in) :: lat, lon + real(dbl_kind), dimension(ni), intent( in) :: dlat + + real(dbl_kind), dimension(ni,nj,nv), intent(out) :: latvert,lonvert + + ! local variables + integer :: i,j,n,ii,jj + + ! fill in grid bottom (j=1) + ! vertices 1,2 are available + ! vertices 3,4 must be set manually + j = 1 + do i = 1,ni + do n = 1,2 + ii = i + iVert(n); jj = j + jVert(n) + if(ii .eq. 0)ii = ni + if(ii .eq. ni+1)ii = 1 + latvert(i,j,n) = lat(ii,jj) + lonvert(i,j,n) = lon(ii,jj) + enddo + do n = 3,4 + ii = i + iVert(n) + if(ii .eq. 0)ii = ni + if(ii .eq. ni+1)ii = 1 + latvert(i,j, n) = dlat(ii) + enddo + lonvert(i,j, 3) = lonvert(i,j,2) + lonvert(i,j, 4) = lonvert(i,j,1) enddo - lonvert(i,j, 3) = lonvert(i,j,2) - lonvert(i,j, 4) = lonvert(i,j,1) - enddo - end subroutine fill_bottom - -!> Fill the vertices for a stagger location along the top j-row -!! -!! @param[in] iVert the i-offset applied to the i-index of a stagger grid -!! @param[in] jVert the j-offset applied to the j-index of a stagger grid -!! @param[in] lat the latitudes of the stagger grid which define each vertex -!! @param[in] lon the longitudes of the stagger grid which define each vertex -!! @param[in] xlat the latitude across the tripole seam -!! @param[in] xlon the longitude across the tripole seam -!! @param[out] latvert the latitudes of each vertex -!! @param[out] lonvert the longitudes of each vertex -!! @author Denise.Worthen@noaa.gov - - subroutine fill_top(iVert,jVert,lat,lon,latvert,lonvert,xlat,xlon) - - integer, intent( in) :: iVert(nv), jVert(nv) - real(dbl_kind), dimension(ni,nj), intent( in) :: lat, lon - real(dbl_kind), dimension(ni), intent( in) :: xlat, xlon - - real(dbl_kind), dimension(ni,nj,nv), intent(out) :: latvert,lonvert - - ! local variables - integer :: i,j,n,ii,jj - - ! fill in grid top (j=nj) - ! vertices 3,4 are available - ! vertices 1,2 must be set manually using 'across seam' values - j = nj - do i = 1,ni - do n = 3,4 - ii = i + iVert(n); jj = j + jVert(n) - if(ii .eq. 0)ii = ni - if(ii .eq. ni+1)ii = 1 - latvert(i,j,n) = lat(ii,jj) - lonvert(i,j,n) = lon(ii,jj) + end subroutine fill_bottom + + !> Fill the vertices for a stagger location along the top j-row + !! + !! @param[in] iVert the i-offset applied to the i-index of a stagger grid + !! @param[in] jVert the j-offset applied to the j-index of a stagger grid + !! @param[in] lat the latitudes of the stagger grid which define each vertex + !! @param[in] lon the longitudes of the stagger grid which define each vertex + !! @param[in] xlat the latitude across the tripole seam + !! @param[in] xlon the longitude across the tripole seam + !! @param[out] latvert the latitudes of each vertex + !! @param[out] lonvert the longitudes of each vertex + !! @author Denise.Worthen@noaa.gov + + subroutine fill_top(iVert,jVert,lat,lon,latvert,lonvert,xlat,xlon) + + integer, intent( in) :: iVert(nv), jVert(nv) + real(dbl_kind), dimension(ni,nj), intent( in) :: lat, lon + real(dbl_kind), dimension(ni), intent( in) :: xlat, xlon + + real(dbl_kind), dimension(ni,nj,nv), intent(out) :: latvert,lonvert + + ! local variables + integer :: i,j,n,ii,jj + + ! fill in grid top (j=nj) + ! vertices 3,4 are available + ! vertices 1,2 must be set manually using 'across seam' values + j = nj + do i = 1,ni + do n = 3,4 + ii = i + iVert(n); jj = j + jVert(n) + if(ii .eq. 0)ii = ni + if(ii .eq. ni+1)ii = 1 + latvert(i,j,n) = lat(ii,jj) + lonvert(i,j,n) = lon(ii,jj) + enddo + do n = 1,2 + ii = i + iVert(n) + if(ii .eq. 0)ii = ni + if(ii .eq. ni+1)ii = 1 + latvert(i,j,n) = xlat(ii) + lonvert(i,j,n) = xlon(ii) + enddo enddo - do n = 1,2 - ii = i + iVert(n) - if(ii .eq. 0)ii = ni - if(ii .eq. ni+1)ii = 1 - latvert(i,j,n) = xlat(ii) - lonvert(i,j,n) = xlon(ii) - enddo - enddo - !latCv_vert(i,j, 1) = latCv_vert(i,j,4) - !latCv_vert(i,j, 2) = latCv_vert(i,j,3) - !lonCv_vert(i,j, 1) = lonCv_vert(i,j,4)+240.d0 - !lonCv_vert(i,j, 2) = lonCv_vert(i,j,3)+240.d0 + !latCv_vert(i,j, 1) = latCv_vert(i,j,4) + !latCv_vert(i,j, 2) = latCv_vert(i,j,3) + !lonCv_vert(i,j, 1) = lonCv_vert(i,j,4)+240.d0 + !lonCv_vert(i,j, 2) = lonCv_vert(i,j,3)+240.d0 end subroutine fill_top end module vertices diff --git a/ush/cpld_gridgen.sh b/ush/cpld_gridgen.sh index f9c61ccea..3e4d25e90 100755 --- a/ush/cpld_gridgen.sh +++ b/ush/cpld_gridgen.sh @@ -3,96 +3,99 @@ set -eux function edit_namelist { - sed -e "s/NI_GLB/$NI/g" \ - -e "s/NJ_GLB/$NJ/g" \ - -e "s|FIXDIR|$FIXDIR_PATH|g" \ - -e "s|OUTDIR|$OUTDIR_PATH|g" \ - -e "s|MOSAICDIR|$MOSAICDIR_PATH|g" \ - -e "s/TOPOGFILE/$TOPOGFILE/g" \ - -e "s/EDITSFILE/$EDITSFILE/g" \ - -e "s/RESNAME/$RESNAME/g" \ - -e "s/MOSAICRES/$MOSAICRES/g" \ - -e "s/NPX/$NPX/g" \ - -e "s/DO_MASKEDIT/$MASKEDIT/g" \ - -e "s/DO_DEBUG/$DEBUG/g" \ - -e "s/DO_POSTWGTS/$DO_POSTWGTS/g" + sed -e "s/NI_GLB/$NI/g" \ + -e "s/NJ_GLB/$NJ/g" \ + -e "s|FIXDIR|$FIXDIR_PATH|g" \ + -e "s|OUTDIR|$OUTDIR_PATH|g" \ + -e "s|MOSAICDIR|$MOSAICDIR_PATH|g" \ + -e "s/TOPOGFILE/$TOPOGFILE/g" \ + -e "s/EDITSFILE/$EDITSFILE/g" \ + -e "s/RESNAME/$RESNAME/g" \ + -e "s/MOSAICRES/$MOSAICRES/g" \ + -e "s/NPX/$NPX/g" \ + -e "s/DO_MASKEDIT/$MASKEDIT/g" \ + -e "s/DO_DEBUG/$DEBUG/g" \ + -e "s/DO_POSTWGTS/$DO_POSTWGTS/g" } export RESNAME=${RESNAME:-$1} export DEBUG=.false. export MASKEDIT=.false. export DO_POSTWGTS=.false. -export OUTDIR_PATH=${OUTDIR_PATH:-/scratch2/NCEPDEV/climate/Denise.Worthen/grids-20220116} +export OUTDIR_PATH=${OUTDIR_PATH:-/scratch1/NCEPDEV/climate/Denise.Worthen/grids-20220116} export MOSAICDIR_PATH=${MOSAICDIR_PATH:-$PATHTR/fix/orog} -APRUN=${APRUN:-"srun"} - -if [ $RESNAME = 400 ]; then - echo "The 4 degree resolution is not implemented yet" - exit 1 -else - export FIXDIR_PATH=${MOM6_FIXDIR}/${RESNAME} +if [[ $MOSAICRES == C3072 ]]; then + export NPX=3072 +elif [[ $MOSAICRES == C1152 ]]; then + export NPX=1152 +elif [[ $MOSAICRES == C768 ]]; then + export NPX=768 +elif [[ $MOSAICRES == C384 ]]; then + export NPX=384 +elif [[ $MOSAICRES == C192 ]]; then + export NPX=192 +elif [[ $MOSAICRES == C096 ]]; then + export MOSAICRES=C96 + export NPX=96 +elif [[ $MOSAICRES == C048 ]]; then + export MOSAICRES=C48 + export NPX=48 fi +export FIXDIR_PATH=${MOM6_FIXDIR}/${RESNAME} +APRUN=${APRUN:-"srun"} if [ $RESNAME = 400 ]; then - export NI=72 - export NJ=35 - export MOSAICRES=C48 - export NPX=48 - export TOPOGFILE=ocean_topog.nc - export EDITSFILE='none' + export NI=72 + export NJ=35 + export TOPOGFILE=ocean_topog.nc + export EDITSFILE='none' fi if [ $RESNAME = 100 ]; then - export NI=360 - export NJ=320 - export MASKEDIT=.T. - export MOSAICRES=C96 - export NPX=96 - export TOPOGFILE=topog.nc - export EDITSFILE=topo_edits_011818.nc - if [ $DO_POSTWGTS == .true. ]; then - #pre-generate SCRIP files for dst rectilinear grids using NCO - # TODO: is the stagger really correct? The first pt is at 0.0E? - # should lat_type be cap? #lon_typ=grn_ctr#lat_typ=cap - ncremap -g ${OUTDIR_PATH}/rect.1p0_SCRIP.nc -G latlon=181,360#lon_typ=grn_ctr - fi + export NI=360 + export NJ=320 + export MASKEDIT=.T. + export TOPOGFILE=topog.nc + export EDITSFILE=topo_edits_011818.nc + if [ $DO_POSTWGTS == .true. ]; then + #pre-generate SCRIP files for dst rectilinear grids using NCO + # TODO: is the stagger really correct? The first pt is at 0.0E? + # should lat_type be cap? #lon_typ=grn_ctr#lat_typ=cap + ncremap -g ${OUTDIR_PATH}/rect.1p0_SCRIP.nc -G latlon=181,360#lon_typ=grn_ctr + fi fi if [ $RESNAME = 050 ]; then - export NI=720 - export NJ=576 - export MOSAICRES=C192 - export NPX=192 - export TOPOGFILE=ocean_topog.nc - export EDITSFILE='none' - if [ $DO_POSTWGTS == .true. ]; then - #pre-generate SCRIP files for dst rectilinear grids using NCO - # TODO: is the stagger really correct? The first pt is at 0.0E? - # should lat_type be cap? #lon_typ=grn_ctr#lat_typ=cap - ncremap -g ${OUTDIR_PATH}/rect.1p0_SCRIP.nc -G latlon=181,360#lon_typ=grn_ctr - ncremap -g ${OUTDIR_PATH}/rect.0p5_SCRIP.nc -G latlon=361,720#lon_typ=grn_ctr - fi + export NI=720 + export NJ=576 + export TOPOGFILE=ocean_topog.nc + export EDITSFILE='none' + if [ $DO_POSTWGTS == .true. ]; then + #pre-generate SCRIP files for dst rectilinear grids using NCO + # TODO: is the stagger really correct? The first pt is at 0.0E? + # should lat_type be cap? #lon_typ=grn_ctr#lat_typ=cap + ncremap -g ${OUTDIR_PATH}/rect.1p0_SCRIP.nc -G latlon=181,360#lon_typ=grn_ctr + ncremap -g ${OUTDIR_PATH}/rect.0p5_SCRIP.nc -G latlon=361,720#lon_typ=grn_ctr + fi fi if [ $RESNAME = 025 ]; then - export NI=1440 - export NJ=1080 - export MOSAICRES=C384 - export NPX=384 - export TOPOGFILE=ocean_topog.nc - export EDITSFILE=All_edits.nc - if [ $DO_POSTWGTS == .true. ]; then - #pre-generate SCRIP files for dst rectilinear grids using NCO - # TODO: is the stagger really correct? The first pt is at 0.0E? - # should lat_type be cap? #lon_typ=grn_ctr#lat_typ=cap - ncremap -g ${OUTDIR_PATH}/rect.1p0_SCRIP.nc -G latlon=181,360#lon_typ=grn_ctr - ncremap -g ${OUTDIR_PATH}/rect.0p5_SCRIP.nc -G latlon=361,720#lon_typ=grn_ctr - ncremap -g ${OUTDIR_PATH}/rect.0p25_SCRIP.nc -G latlon=721,1440#lon_typ=grn_ctr - fi + export NI=1440 + export NJ=1080 + export TOPOGFILE=ocean_topog.nc + export EDITSFILE=All_edits.nc + if [ $DO_POSTWGTS == .true. ]; then + #pre-generate SCRIP files for dst rectilinear grids using NCO + # TODO: is the stagger really correct? The first pt is at 0.0E? + # should lat_type be cap? #lon_typ=grn_ctr#lat_typ=cap + ncremap -g ${OUTDIR_PATH}/rect.1p0_SCRIP.nc -G latlon=181,360#lon_typ=grn_ctr + ncremap -g ${OUTDIR_PATH}/rect.0p5_SCRIP.nc -G latlon=361,720#lon_typ=grn_ctr + ncremap -g ${OUTDIR_PATH}/rect.0p25_SCRIP.nc -G latlon=721,1440#lon_typ=grn_ctr + fi fi if [ ! -d ${OUTDIR_PATH} ]; then - mkdir -p ${OUTDIR_PATH} + mkdir -p ${OUTDIR_PATH} fi cd ${OUTDIR_PATH} @@ -103,7 +106,7 @@ $APRUN ./cpld_gridgen # generate ice mesh export FSRC=${OUTDIR_PATH}/Ct.mx${RESNAME}_SCRIP_land.nc export FDST=${OUTDIR_PATH}/mesh.mx${RESNAME}.nc -$APRUN ESMF_Scrip2Unstruct ${FSRC} ${FDST} 0 +$APRUN -n 1 ESMF_Scrip2Unstruct ${FSRC} ${FDST} 0 # generate kmt file for CICE export FSRC=${OUTDIR_PATH}/grid_cice_NEMS_mx${RESNAME}.nc From aae43283ad22dc12fe2d6eec2efd9878c0f30794 Mon Sep 17 00:00:00 2001 From: "denise.worthen" Date: Sun, 5 Feb 2023 17:57:46 +0000 Subject: [PATCH 5/9] baselines b4b on hera.intel From a302ac9d0af8b7c1f34067951d25eb2072840d5d Mon Sep 17 00:00:00 2001 From: "denise.worthen" Date: Mon, 6 Feb 2023 16:36:20 +0000 Subject: [PATCH 6/9] tests on hera for all resolutions, serially * c3072mx025 takes 42m and about 6GB of memory. requires setting netcdf4 file type in regridweightgen (file size~3gb), otherwise fails w/ "violate size constraint". Setting the file type to netcdf4 changes the baseline. The file data compares as identical though using cprnc. * c1152mx025 takes 6min * c768mx025 takes 3m * c192mx025 takes 1m From 16f2a825fbb82c968d27e9f29515822d3d733313 Mon Sep 17 00:00:00 2001 From: "denise.worthen" Date: Wed, 8 Feb 2023 17:20:05 +0000 Subject: [PATCH 7/9] add alt resolution updates *correction to previous commit message. C3072mx025 takes approx 60GB of memory (~60% of total node), not 6GB. * update rt.conf w/ details of alt resolutions * update rt.sh w/ variables to allow quick setting of C3072 values * add netcdf4 file type in generation of weights for mapped mask. This is required for the higher resolutions. It breaks comparison for the baseline weights files, even though the identical nccmp command outside of the rt script shows no differences. --- reg_tests/cpld_gridgen/rt.conf | 20 +++++++++++++++++--- reg_tests/cpld_gridgen/rt.sh | 14 ++++++++++---- sorc/cpld_gridgen.fd/gen_fixgrid.F90 | 10 +++++----- ush/cpld_gridgen.sh | 9 +++++++-- 4 files changed, 39 insertions(+), 14 deletions(-) diff --git a/reg_tests/cpld_gridgen/rt.conf b/reg_tests/cpld_gridgen/rt.conf index fcb42bb1c..525ecbbb8 100644 --- a/reg_tests/cpld_gridgen/rt.conf +++ b/reg_tests/cpld_gridgen/rt.conf @@ -1,15 +1,29 @@ -# C384_025 needs to be the first test due to dependency +################################################################# +# Baseline configurations +# C384_025 needs to be the first test due to dependency of +# the weight-generation from 1/4deg ocean to lower resolution +################################################################# + # TEST_NAME | DEP_NAME # C384_025 | C192_050 | C384_025 C096_100 | C384_025 -# Non-baseline configurations +################################################################# +# Non-baseline configurations. +# These configurations have been tested on hera. For hera, the +# memory use for the C3072 config is approx 60% of the full node, +# C1152 is 12% of the full node and C768 is 8% of the full node. +# The default is set as 12g on RDHPCS platforms and should be +# sufficient for all but C3072. On hera C3072 requires approx 50min +# of wall clock and using --exclusive. See C3072 settings in rt.sh +################################################################# + #C3072_025 | #C1152_025 | #C768_025 | #C192_025 | #C048_500 | C384_025 - #C096_500 | C384_025 \ No newline at end of file + #C096_500 | C384_025 diff --git a/reg_tests/cpld_gridgen/rt.sh b/reg_tests/cpld_gridgen/rt.sh index 0d2700ddc..a470a48be 100755 --- a/reg_tests/cpld_gridgen/rt.sh +++ b/reg_tests/cpld_gridgen/rt.sh @@ -107,6 +107,12 @@ export PATHTR TESTS_FILE="$PATHRT/rt.conf" export TEST_NAME= +# for C3072 on hera, use WLCLK=60 and MEM="--exclusive" +WLCLK_dflt=10 +export WLCLK=$WLCLK_dflt +MEM_dflt="--mem=12g" +export MEM=$MEM_dflt + cd $PATHRT export compiler=${compiler:-intel} source $PATHTR/sorc/machine-setup.sh >/dev/null 2>&1 @@ -253,7 +259,7 @@ while read -r line || [ "$line" ]; do # rm -f $RUNDIR/bad.${TEST_NAME} TEST=$(qsub -V -o $PATHRT/run_${TEST_NAME}.log -e $PATHRT/run_${TEST_NAME}.log -q $QUEUE -A $ACCOUNT \ - -Wblock=true -l walltime=00:05:00 -N $TEST_NAME -l select=1:ncpus=1:mem=8GB -v RESNAME=$TEST_NAME $SBATCH_COMMAND) + -Wblock=true -l walltime=00:${WLCLK}:00 -N $TEST_NAME -l select=1:ncpus=1:mem=12GB -v RESNAME=$TEST_NAME $SBATCH_COMMAND) # qsub -o $PATHRT/run_${TEST_NAME}.log -e $PATHRT/run_${TEST_NAME}.log -q $QUEUE -A $ACCOUNT \ # -Wblock=true -l walltime=00:01:00 -N chgres_summary -l select=1:ncpus=1:mem=100MB -W depend=afternotok:$TEST << EOF @@ -265,9 +271,9 @@ while read -r line || [ "$line" ]; do # fi else - sbatch --wait --ntasks-per-node=1 --nodes=1 --exclusive -t 1:00:00 -A $ACCOUNT -q $QUEUE -J $TEST_NAME \ - --partition=$PARTITION -o $PATHRT/run_${TEST_NAME}.log -e $PATHRT/run_${TEST_NAME}.log \ - --wrap "$SBATCH_COMMAND $TEST_NAME" && d=$? || d=$? + sbatch --wait --ntasks-per-node=1 --nodes=1 ${MEM} -t 00:${WLCLK}:00 -A $ACCOUNT -q $QUEUE -J $TEST_NAME \ + --partition=$PARTITION -o $PATHRT/run_${TEST_NAME}.log -e $PATHRT/run_${TEST_NAME}.log \ + --wrap "time $SBATCH_COMMAND $TEST_NAME" && d=$? || d=$? if [[ d -ne 0 ]]; then error "Batch job for test $TEST_NAME did not finish successfully. Refer to run_${TEST_NAME}.log" diff --git a/sorc/cpld_gridgen.fd/gen_fixgrid.F90 b/sorc/cpld_gridgen.fd/gen_fixgrid.F90 index 344f459bc..2e1dbbdb8 100644 --- a/sorc/cpld_gridgen.fd/gen_fixgrid.F90 +++ b/sorc/cpld_gridgen.fd/gen_fixgrid.F90 @@ -463,9 +463,9 @@ program gen_fixgrid print '(a)',trim(logmsg) call ESMF_RegridWeightGen(srcFile=trim(fsrc),dstFile=trim(fdst), & - weightFile=trim(fwgt), regridmethod=method, & - unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, & - ignoreDegenerate=.true., & + weightFile=trim(fwgt), regridmethod=method, & + unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, & + ignoreDegenerate=.true., netcdf4fileFlag=.true., & tileFilePath=trim(fv3dir)//'/'//trim(atmres)//'/', rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, file=__FILE__)) call ESMF_Finalize(endflag=ESMF_END_ABORT) @@ -491,8 +491,8 @@ program gen_fixgrid print '(a)',trim(logmsg) call ESMF_RegridWeightGen(srcFile=trim(fsrc),dstFile=trim(fdst), & - weightFile=trim(fwgt), regridmethod=method, & - ignoreDegenerate=.true., & + weightFile=trim(fwgt), regridmethod=method, & + ignoreDegenerate=.true., & unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, file=__FILE__)) call ESMF_Finalize(endflag=ESMF_END_ABORT) diff --git a/ush/cpld_gridgen.sh b/ush/cpld_gridgen.sh index 3e4d25e90..2573baf6e 100755 --- a/ush/cpld_gridgen.sh +++ b/ush/cpld_gridgen.sh @@ -41,10 +41,15 @@ elif [[ $MOSAICRES == C048 ]]; then export MOSAICRES=C48 export NPX=48 fi -export FIXDIR_PATH=${MOM6_FIXDIR}/${RESNAME} +if [ $RESNAME = 500 ]; then + export FIXDIR_PATH=/scratch1/NCEPDEV/global/glopara/fix/mom6/20220805/500/ +else + export FIXDIR_PATH=${MOM6_FIXDIR}/${RESNAME} +fi + APRUN=${APRUN:-"srun"} -if [ $RESNAME = 400 ]; then +if [ $RESNAME = 500 ]; then export NI=72 export NJ=35 export TOPOGFILE=ocean_topog.nc From 34ba07e6bd6c4048721eda1285f4def384b7c02c Mon Sep 17 00:00:00 2001 From: Denise Worthen Date: Fri, 10 Feb 2023 09:57:17 -0500 Subject: [PATCH 8/9] add -w format to nccmp command * allows comparison between netcdf4 and netcdf classic as identical --- reg_tests/cpld_gridgen/rt.sh | 2 +- sorc/cpld_gridgen.fd/gen_fixgrid.F90 | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/reg_tests/cpld_gridgen/rt.sh b/reg_tests/cpld_gridgen/rt.sh index a470a48be..b08cbac7c 100755 --- a/reg_tests/cpld_gridgen/rt.sh +++ b/reg_tests/cpld_gridgen/rt.sh @@ -56,7 +56,7 @@ check_results() { echo "....MISSING file" | tee -a $PATHRT/$REGRESSIONTEST_LOG test_status=FAIL else - $NCCMP -dmfqS $(basename ${file}) $file >>${PATHRT}/nccmp_${TEST_NAME}.log 2>&1 && d=$? || d=$? + $NCCMP -dmfqS -w format $(basename ${file}) $file >>${PATHRT}/nccmp_${TEST_NAME}.log 2>&1 && d=$? || d=$? if [[ $d -ne 0 ]]; then echo "....NOT OK" | tee -a $PATHRT/$REGRESSIONTEST_LOG test_status=FAIL diff --git a/sorc/cpld_gridgen.fd/gen_fixgrid.F90 b/sorc/cpld_gridgen.fd/gen_fixgrid.F90 index 2e1dbbdb8..2fcffb126 100644 --- a/sorc/cpld_gridgen.fd/gen_fixgrid.F90 +++ b/sorc/cpld_gridgen.fd/gen_fixgrid.F90 @@ -462,11 +462,10 @@ program gen_fixgrid logmsg = 'creating weight file '//trim(fwgt) print '(a)',trim(logmsg) - call ESMF_RegridWeightGen(srcFile=trim(fsrc),dstFile=trim(fdst), & - weightFile=trim(fwgt), regridmethod=method, & - unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, & - ignoreDegenerate=.true., netcdf4fileFlag=.true., & - tileFilePath=trim(fv3dir)//'/'//trim(atmres)//'/', rc=rc) + call ESMF_RegridWeightGen(srcFile=trim(fsrc),dstFile=trim(fdst), & + weightFile=trim(fwgt), regridmethod=method, & + unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, ignoreDegenerate=.true., & + netcdf4fileFlag=.true., tileFilePath=trim(fv3dir)//'/'//trim(atmres)//'/', rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, file=__FILE__)) call ESMF_Finalize(endflag=ESMF_END_ABORT) @@ -492,8 +491,7 @@ program gen_fixgrid call ESMF_RegridWeightGen(srcFile=trim(fsrc),dstFile=trim(fdst), & weightFile=trim(fwgt), regridmethod=method, & - ignoreDegenerate=.true., & - unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, rc=rc) + ignoreDegenerate=.true., unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, file=__FILE__)) call ESMF_Finalize(endflag=ESMF_END_ABORT) else From ee4b73bb49dc1def8039f01a74522f2a5a93feb9 Mon Sep 17 00:00:00 2001 From: "denise.worthen" Date: Wed, 15 Feb 2023 13:08:47 -0500 Subject: [PATCH 9/9] add note in rt.conf for 5deg case only on hera --- reg_tests/cpld_gridgen/rt.conf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/reg_tests/cpld_gridgen/rt.conf b/reg_tests/cpld_gridgen/rt.conf index 525ecbbb8..64b2a617f 100644 --- a/reg_tests/cpld_gridgen/rt.conf +++ b/reg_tests/cpld_gridgen/rt.conf @@ -18,6 +18,9 @@ # The default is set as 12g on RDHPCS platforms and should be # sufficient for all but C3072. On hera C3072 requires approx 50min # of wall clock and using --exclusive. See C3072 settings in rt.sh +# +# Note that the 5deg ocean cases are currently only supported on +# hera ################################################################# #C3072_025 |