diff --git a/.travis.yml b/.travis.yml index fa22d398..100192cd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,6 @@ script: notifications: email: recipients: - - schramm@ucar.edu - dom.heinzeller@noaa.gov - goldy@ucar.edu on_success: always # default: change diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f908916..8291f668 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,90 +1,44 @@ -# Set default project to unknown -if(NOT PROJECT) - message(STATUS "Setting CCPP project to 'unknown' as none was specified.") - set(PROJECT "Unknown") -endif (NOT PROJECT) - -#------------------------------------------------------------------------------ cmake_minimum_required(VERSION 3.0) project(ccpp_framework VERSION 5.0.0 LANGUAGES Fortran) -# Use rpaths on MacOSX -set(CMAKE_MACOSX_RPATH 1) -if(POLICY CMP0042) - cmake_policy(SET CMP0042 NEW) -endif(POLICY CMP0042) - #------------------------------------------------------------------------------ # Set package definitions set(PACKAGE "ccpp-framework") set(AUTHORS "Dom Heinzeller" "Grant Firl" "Laurie Carson") string(TIMESTAMP YEAR "%Y") -#------------------------------------------------------------------------------ -# CMake Modules -# Set the CMake module path -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") - #------------------------------------------------------------------------------ # Set OpenMP flags for C/C++/Fortran if (OPENMP) - include(detect_openmp) - detect_openmp() + find_package(OpenMP REQUIRED) set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${OpenMP_Fortran_FLAGS}") - message(STATUS "Enable OpenMP support") -else (OPENMP) - message (STATUS "Disable OpenMP support") endif (OPENMP) #------------------------------------------------------------------------------ # Set a default build type if none was specified if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + # DH* TODO - TRY TO CHANGE THIS TO RELEASE AND SEE WHAT HAPPENS TO THE RESULTS message(STATUS "Setting build type to 'Debug' as none was specified.") set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE) - + # *DH # Set the possible values of build type for cmake-gui - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "Coverage") + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Bitforbit" "Release" "Coverage") endif() #------------------------------------------------------------------------------ -# Request a static build -option(BUILD_SHARED_LIBS "Build a static library" OFF) - -#------------------------------------------------------------------------------ -# Enable code coverage -if ("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "GNU" AND (CMAKE_BUILD_TYPE STREQUAL "Coverage")) - include(code_coverage) - list(APPEND LIBS "gcov") +# Pass debug/release flag to Fortran files for preprocessor +if(CMAKE_BUILD_TYPE STREQUAL "Debug") + add_definitions(-DDEBUG) endif() #------------------------------------------------------------------------------ -# Enable testing -enable_testing() +# Request a static build +option(BUILD_SHARED_LIBS "Build a static library" OFF) #------------------------------------------------------------------------------ # Add the sub-directories -# Source add_subdirectory(src) -# Documentation add_subdirectory(doc) - -#------------------------------------------------------------------------------ -# Configure and enable packaging -set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Common Community Physics Package - Framework") -set(CPACK_PACKAGE_VENDOR "DTC NOAA/NCAR") -set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md") -set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") -set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) -set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR}) -set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH}) -set(CPACK_PACKAGE_INSTALL_DIRECTORY - "CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}") -set(CPACK_SOURCE_PACKAGE_FILE_NAME - "${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") -set(CPACK_SOURCE_GENERATOR "TBZ2") -set(CPACK_GENERATOR "TBZ2") - -include(CPack) diff --git a/README.md b/README.md index 590f863a..dced2973 100644 --- a/README.md +++ b/README.md @@ -1,328 +1,11 @@ -# CCPP Framwork +# CCPP Framework -Common Community Physics Package (CCPP) Framework. - -| Branch | Linux/MacOS Build | Coverage | -|--- |--- |--- | -| Master | [![Build Status](https://travis-ci.org/NCAR/gmtb-ccpp.svg?branch=master)](https://travis-ci.org/NCAR/gmtb-ccpp) | [![Coverage Status](https://codecov.io/github/NCAR/gmtb-ccpp/coverage.svg?branch=master)](https://codecov.io/github/NCAR/gmtb-ccpp) | -| Develop | [![Build Status](https://travis-ci.org/NCAR/gmtb-ccpp.svg?branch=develop)](https://travis-ci.org/NCAR/gmtb-ccpp) | [![Coverage Status](https://codecov.io/github/NCAR/gmtb-ccpp/coverage.svg?branch=develop)](https://codecov.io/github/NCAR/gmtb-ccpp?branch=develop) | - - -## Notes to Users -This repository contains the Common Community Physics Packages (CCPP) Framework. - -The repository for the CCPP and the CCPP driver contains sufficient code for standalone -testing of the CCPP. The CCPP repository may also be used in conjunction with the -GMTB Single Column Model (SCM). Please see the [GMTB SCM+CCPP page](http://www.dtcenter.org/GMTB/gmtb_scm_ccpp_doc/) -for more information on combining the GMTB SCM and the CCPP. - -This is the release v0.1.0 of the CCPP. As this is the initial release, -the CCPP only has infrastructure to support the neccesary functioning of -the anticipated package, without having actual (i.e. physically valid) -physical parameterization schemes included. The included physical -parameterization schemes inside of the CCPP are "stub" only. While the -schemes do have arguments similar to what traditional schemes require -(wind, surface temperature, physical constants), the schemes immediately -return after a message "I am in this scheme" has been output. - -This repository for the CCPP and the CCPP driver contains tests to verify -proper running of the CCPP and driver. Detailed information on how to -include fully functioning physical parameterizations schemes will be -provided once examples of fully functioning schemes are part of the CCPP. - -## Requirements - -### Compilers -The CCPP uses both the C and Fortran compilers. Note, the -Fortran compiler must be 2008 compliant. There are a number of Fortran -2003 pieces, and a single convenience right now with Fortran 2008. - -1. [GNU Compiler Collection](https://gcc.gnu.org/) -2. [Intel 16.0.2](https://software.intel.com/en-us/intel-compilers) and beyond work. -3. [PGI](http://www.pgroup.com/) compilers do **not** easily support C functions - calling Fortran routines. The PGI compilers attach the Fortran module name as a - prefix to the Fortran symbol. This **breaks** the method that the CCPP uses to - identify which schemes to call. - -### [Cmake](https://cmake.org) - -The CCPP build system uses cmake. - -### [LibXML2](http://xmlsoft.org/) - -The suite definition is currently written in XML, LibXML2 is currently used to -parse these files. - -## Building -It is recommend to do an out of source build. This is "cmake" terminology -for creating a separate directory where all of the built code (objects, -libraries, executables) exist. - -1. Clone the repository. -``` -git clone https://github.com/NCAR/ccpp-framework ccpp -``` -2. Change into the repository clone -``` -cd ccpp -``` -3. Specify the compiler to use. For example the GNU compilers, - when it is available as a module called `gcc`. - * For sh or bash -``` -ml gcc -export CC=gcc -export FC=gfortran -export CXX=g++ -``` - * For csh or tcsh -``` -ml gcc -setenv CC gcc -setenv FC gfortran -setenv CXX g++ -``` -4. Make a build directory and change into it. -``` -mkdir build -cd build -``` -5. Create the makefiles. -``` -cmake .. -``` -6. Build the CCPP library and test programs. -``` -make -``` - -## Running Tests -There are a few test programs within the `ccpp/src/tests` directory. -These should be built when the CCPP library is compiled. - -To run the tests you have to add the CCPP check scheme library (`libcheck.so`) -to your `LD_LIBRARY_PATH` (`DYLD_LIBRARY_PATH` for OS X). - -For sh or bash: -``` -export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${PWD}/schemes/check/src/check-build/ -``` - -For csh or tcsh: -``` -setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:${cwd}/schemes/check/src/check-build/ -``` - -Note that if CCPP was built as part of a build system, you might have to load -the compiler and set environment variables that were used by the build system. - - -Then issue the following within the build directory. - * `make test` - -All tests should pass, if not, please open an issue. The output should be -similar to: -~~~~{.sh} -Running tests... -Test project /home/tbrown/Sources/ccpp-framework/build - Start 1: XML_1 -1/8 Test #1: XML_1 ............................ Passed 0.02 sec - Start 2: XML_2 -2/8 Test #2: XML_2 ............................ Passed 0.01 sec - Start 3: XML_3 -3/8 Test #3: XML_3 ............................ Passed 0.01 sec - Start 4: XML_4 -4/8 Test #4: XML_4 ............................ Passed 0.01 sec - Start 5: XML_5 -5/8 Test #5: XML_5 ............................ Passed 0.00 sec - Start 6: XML_6 -6/8 Test #6: XML_6 ............................ Passed 0.00 sec - Start 7: FIELDS -7/8 Test #7: FIELDS ........................... Passed 0.00 sec - Start 8: CHECK -8/8 Test #8: CHECK ............................ Passed 0.01 sec - -100% tests passed, 0 tests failed out of 8 - - -Total Test time (real) = 0.08 sec -~~~~ - -## Validating XML -A suite is defined in XML. There are several test suites defined within -the `ccpp/src/tests` directory (which are able to test the build and -installation of the standalone CCPP). There is also the XML Schema -Definition in that directory too. To validate a new test suite, you can -use `xmllint`. For example to validate `suite_EXAMPLE.xml`: -~~~~{.sh} -cd src/tests -xmllint --schema suite.xsd --noout suite_EXAMPLE.xml -suite_EXAMLE.xml validates -~~~~ - -Within the `src/tests` directory there is a Fortran file -`test_init_finalize.f90` which will get built into an executable program -when the CCPP library is built. This program only calls: - * `ccpp_init()` - * `ccpp_finalize()` - -It is a program to check the suite XML validation within the CCPP -library. The following is an example of using it from within the -`build` directory. -~~~~{.sh} -src/tests/test_init_finalize my_suite.xml -~~~~ - -For this to work, the library that is referenced in the xml file -must be added to the LD_LIBRARY_PATH (see above). To test the -correct functionality of CCPP itself, the suite suite_EXAMPLE.xml -in src/tests can be used. - -There are two general types of XML files for the CCPP. The first is the -definition file for a suite. These reside in the host model repositories. -Here is a fairly short example: - -~~~~{.xml} - - - - - - RRTMGLW - RRTMGSW - MYNNSFC - RUCLSM - MYNNPBL - GF - - - - - THOMPSONAERO - - - -~~~~ - -* suite - * This text string "name" attribute is compared to the user-selected - physics suite option at run-time. -* ipd part - * To allow for the design of the interface between the dynamics and -physical parameterization schemes, this attribute clearly associates particular -packages with the dynamical sections. In this XML example, there are two "part" -sections, with the second part only containing the "THOMPSONAERO" microphysics -scheme. - * Users should carefully construct the XML file to map the schemes into the -existing sections of the code that calls the physical parameterization schemes. -* subcycle - * This functionality is not fully enabled. It is expected to be utilized for -early testing, and is included in the initial release. -* scheme - * The scheme elements fully describe the calling sequence of the physical - parameterization schemes within the model. - * For each scheme, an XML file (the scheme definition file) needs to exist. - For the initial release, this XML file has not yet been designed. - -## Physics Schemes -All physics schemes are kept in the GitHub repository ccpp-physics. - -To add a new scheme one needs to - -1. Add/Create the scheme within `schemes`. You should create a - sub-directory under the `schemes` directory. You will need to - add a [`ExternalProject_Add()`](https://cmake.org/cmake/help/latest/module/ExternalProject.html). - call to the `schemes/CMakeLists.txt` file. -2. Create a `cap` subroutine. The CCPP will call your - cap routine. - - 1. The cap routine must be labelled "schemename_cap". - - For example, the dummy scheme has a cap called - "dummy_cap". The requirements are that it is - 1. The scheme name is lowercase (the symbol is called from a C - function). - 2. "_cap" is appended. - - 2. Map all the inputs for the cap from the `cdata` encapsulating - type (this is of the `ccpp_t` type). The cap will extract the - fields from the fields array with the `ccpp_field_get()` - subroutine. - -An example of a scheme is `schemes/check/test.f90`. It has the cap -routine and the run routine. The run routine prints out that the -scheme has been entered. - - -## Usage -The CCPP must first be initialized, this is done by calling `ccpp_init()`. -Once initialized, all variables that will be required in a physics scheme -have to be added to the ccpp data object (of type `ccpp_t`). These variables -can later be retrieved in a physics schemes cap. - -Example usage, in an atmosphere component: -~~~~{.f90} -type(ccpp_t), target :: cdata -character(len=128) :: scheme_xml_filename -integer :: ierr - -ierr = 0 - -! Initialize the CCPP and load the physics scheme. -call ccpp_init(scheme_xml_filename, cdata, ierr) -if (ierr /= 0) then - call exit(1) -end if - -! Add surface temperature (variable surf_t). -call ccpp_field_add(cdata, 'surface_temperature', surf_t, ierr, 'K') -if (ierr /= 0) then - call exit(1) -end if - -! Call the first physics scheme -call ccpp_ipd_run(cdata%suite%ipds(1)%subcycles(1)%schemes(1), cdata, ierr) -if (ierr /= 0) then - call exit(1) -end if -~~~~ - -Example usage, in a physics cap: -~~~~{.f90} -type(ccpp_t), pointer :: cdata -real, pointer :: surf_t(:) -integer :: ierr - -call c_f_pointer(ptr, cdata) -call ccpp_field_get(cdata, 'surface_temperature', surf_t, ierr) -if (ierr /= 0) then - call exit(1) -end if -~~~~ - -Note, the cap routine must -* Accept only one argument of type `type(c_ptr)`. -* Be marked as `bind(c)`. +This repository contains the Common Community Physics Package (CCPP) Framework: The infrastructure that connects CCPP physics schemes with a host model, as well as stand-alone tools for use with CCPP. ## Documentation -The code is documented with [doxygen](www.doxygen.org/). -To generate the documentation you must have [doxygen](www.doxygen.org/) -and [graphviz](http://www.graphviz.org/) installed. Then execute: -``` -make doc -``` +The CCPP Framework is designed to be used with the [CCPP Physics repository](https://github.com/NCAR/ccpp-physics) and a host model. Links to further information about this repository and its place in the context of the CCPP as a whole can be found on the [GitHub Wiki](https://github.com/NCAR/ccpp-framework/wiki). + +The CCPP Single Column Model (SCM) is designed as a simple host model for testing and development of the CCPP; information about building and using the CCPP in this context can be found in [the CCPP SCM Users Guide](https://dtcenter.org/sites/default/files/paragraph/scm-ccpp-guide-v5.0.0.pdf). -## Code Coverage -The code can be built and run to indicate code coverage. In order to do -this, you must have GNU [gcov](https://gcc.gnu.org/onlinedocs/gcc/Gcov.html) -and [lcov](http://ltp.sourceforge.net/coverage/lcov.php) installed. -To generate the coverage: +More information about the design and use of CCPP can be found in the [CCPP Technical Documentation](https://ccpp-techdoc.readthedocs.io/en/v5.0.0/). -1. Make sure you are using the GNU compilers. -2. Configure the build for coverage. - * `cmake -DCMAKE_BUILD_TYPE=Coverage ..` -3. Build the CCPP. - * `make` -4. Build the coverage report - * `make coverage` -The coverage report will be in the `coverage` directory within the build. diff --git a/README_TODO.txt b/README_TODO.txt deleted file mode 100644 index 09f72242..00000000 --- a/README_TODO.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Dom 2018/02/13 - -- Python scripts/modules in this directory are superseded by those in ../scripts - -- Other functionality (longnames_autocheck, parse_fortran) must be moved over/merged and updated to provide the same functionality - -- The tests run in this directory needs updating. For instance, mkcap.py in ../scripts looks slightly different - -- More tests desirable! diff --git a/cmake/add_sources.cmake b/cmake/add_sources.cmake deleted file mode 100644 index b858e361..00000000 --- a/cmake/add_sources.cmake +++ /dev/null @@ -1,16 +0,0 @@ -#------------------------------------------------------------------------------ -# Define a macro to find and add sources -macro(add_sources) - file(RELATIVE_PATH _relPath "${CMAKE_SOURCE_DIR}/ccpp/src" "${CMAKE_CURRENT_SOURCE_DIR}") - foreach(_src ${ARGN}) - if (_relPath) - list (APPEND SOURCES "${_relPath}/${_src}") - else() - list (APPEND SOURCES "${_src}") - endif() - endforeach() - if (_relPath) - # propagate SOURCES to parent directory - set(SOURCES ${SOURCES} PARENT_SCOPE) - endif() -endmacro() diff --git a/cmake/code_coverage.cmake b/cmake/code_coverage.cmake deleted file mode 100644 index 7bb7dfbe..00000000 --- a/cmake/code_coverage.cmake +++ /dev/null @@ -1,218 +0,0 @@ -# -# https://github.com/bilke/cmake-modules/blob/master/CodeCoverage.cmake -# -# Copyright (c) 2012 - 2015, Lars Bilke -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, -# are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of its contributors -# may be used to endorse or promote products derived from this software without -# specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# -# -# 2012-01-31, Lars Bilke -# - Enable Code Coverage -# -# 2013-09-17, Joakim Söderberg -# - Added support for Clang. -# - Some additional usage instructions. -# -# 2017-03-23, Timothy Brown -# - Added support for Fortran. -# -# USAGE: - -# 0. (Mac only) If you use Xcode 5.1 make sure to patch geninfo as described here: -# http://stackoverflow.com/a/22404544/80480 -# -# 1. Copy this file into your cmake modules path. -# -# 2. Add the following line to your CMakeLists.txt: -# INCLUDE(CodeCoverage) -# -# 3. Set compiler flags to turn off optimization and enable coverage: -# SET(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage") -# SET(CMAKE_C_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage") -# -# 3. Use the function SETUP_TARGET_FOR_COVERAGE to create a custom make target -# which runs your test executable and produces a lcov code coverage report: -# Example: -# SETUP_TARGET_FOR_COVERAGE( -# my_coverage_target # Name for custom target. -# test_driver # Name of the test driver -# # executable that runs the tests. -# # NOTE! This should always -# # have a ZERO as exit code -# # otherwise the coverage -# # generation will not complete. -# coverage # Name of output directory. -# ) -# -# If you need to exclude additional directories from the report, specify them -# using the LCOV_REMOVE_EXTRA variable before calling SETUP_TARGET_FOR_COVERAGE. -# For example: -# -# set(LCOV_REMOVE_EXTRA "'thirdparty/*'") -# -# 4. Build a Debug build: -# cmake -DCMAKE_BUILD_TYPE=Debug .. -# make -# make my_coverage_target -# -# - -# Check prereqs -FIND_PROGRAM( GCOV_PATH gcov ) -FIND_PROGRAM( LCOV_PATH lcov ) -FIND_PROGRAM( GENHTML_PATH genhtml ) -FIND_PROGRAM( GCOVR_PATH gcovr PATHS ${CMAKE_SOURCE_DIR}/tests) - -IF(NOT GCOV_PATH) - MESSAGE(FATAL_ERROR "gcov not found! Aborting...") -ENDIF() # NOT GCOV_PATH - -IF("${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang") - IF("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 3) - MESSAGE(FATAL_ERROR "Clang version must be 3.0.0 or greater! Aborting...") - ENDIF() -ELSEIF(NOT CMAKE_COMPILER_IS_GNUCXX) - MESSAGE(FATAL_ERROR "Compiler is not GNU gcc! Aborting...") -ENDIF() # CHECK VALID COMPILER - -SET(CMAKE_CXX_FLAGS_COVERAGE - "-g -O0 --coverage -fprofile-arcs -ftest-coverage" - CACHE STRING "Flags used by the C++ compiler during coverage builds." - FORCE ) -SET(CMAKE_Fortran_FLAGS_COVERAGE - "-g -O0 --coverage -fprofile-arcs -ftest-coverage" - CACHE STRING "Flags used by the Fortran compiler during coverage builds." - FORCE ) -SET(CMAKE_C_FLAGS_COVERAGE - "-g -O0 --coverage -fprofile-arcs -ftest-coverage" - CACHE STRING "Flags used by the C compiler during coverage builds." - FORCE ) -SET(CMAKE_EXE_LINKER_FLAGS_COVERAGE - "" - CACHE STRING "Flags used for linking binaries during coverage builds." - FORCE ) -SET(CMAKE_SHARED_LINKER_FLAGS_COVERAGE - "" - CACHE STRING "Flags used by the shared libraries linker during coverage builds." - FORCE ) -MARK_AS_ADVANCED( - CMAKE_CXX_FLAGS_COVERAGE - CMAKE_C_FLAGS_COVERAGE - CMAKE_FC_FLAGS_COVERAGE - CMAKE_EXE_LINKER_FLAGS_COVERAGE - CMAKE_SHARED_LINKER_FLAGS_COVERAGE ) - -IF ( NOT (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "Coverage")) - MESSAGE( WARNING "Code coverage results with an optimized (non-Debug) build may be misleading" ) -ENDIF() # NOT CMAKE_BUILD_TYPE STREQUAL "Debug" - - -# Param _targetname The name of new the custom make target -# Param _testrunner The name of the target which runs the tests. -# MUST return ZERO always, even on errors. -# If not, no coverage report will be created! -# Param _outputname lcov output is generated as _outputname.info -# HTML report is generated in _outputname/index.html -# Optional fourth parameter is passed as arguments to _testrunner -# Pass them in list form, e.g.: "-j;2" for -j 2 -FUNCTION(SETUP_TARGET_FOR_COVERAGE _targetname _testrunner _outputname) - - IF(NOT LCOV_PATH) - MESSAGE(FATAL_ERROR "lcov not found! Aborting...") - ENDIF() # NOT LCOV_PATH - - IF(NOT GENHTML_PATH) - MESSAGE(FATAL_ERROR "genhtml not found! Aborting...") - ENDIF() # NOT GENHTML_PATH - - SET(coverage_info "${CMAKE_BINARY_DIR}/${_outputname}.info") - SET(coverage_cleaned "${coverage_info}.cleaned") - - SEPARATE_ARGUMENTS(test_command UNIX_COMMAND "${_testrunner}") - - # Setup target - ADD_CUSTOM_TARGET(${_targetname} - - # Cleanup lcov - ${LCOV_PATH} --directory . --zerocounters - - # Run tests - COMMAND ${test_command} ${ARGV3} - - # Capturing lcov counters and generating report - COMMAND ${LCOV_PATH} --directory . --capture --output-file ${coverage_info} - COMMAND ${LCOV_PATH} --remove ${coverage_info} 'tests/*' '/usr/*' ${LCOV_REMOVE_EXTRA} --output-file ${coverage_cleaned} - COMMAND ${GENHTML_PATH} -o ${_outputname} ${coverage_cleaned} - COMMAND ${CMAKE_COMMAND} -E remove ${coverage_info} ${coverage_cleaned} - - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - COMMENT "Resetting code coverage counters to zero.\nProcessing code coverage counters and generating report." - ) - - # Show info where to find the report - ADD_CUSTOM_COMMAND(TARGET ${_targetname} POST_BUILD - COMMAND ; - COMMENT "Open ./${_outputname}/index.html in your browser to view the coverage report." - ) - -ENDFUNCTION() # SETUP_TARGET_FOR_COVERAGE - -# Param _targetname The name of new the custom make target -# Param _testrunner The name of the target which runs the tests -# Param _outputname cobertura output is generated as _outputname.xml -# Optional fourth parameter is passed as arguments to _testrunner -# Pass them in list form, e.g.: "-j;2" for -j 2 -FUNCTION(SETUP_TARGET_FOR_COVERAGE_COBERTURA _targetname _testrunner _outputname) - - IF(NOT PYTHON_EXECUTABLE) - MESSAGE(FATAL_ERROR "Python not found! Aborting...") - ENDIF() # NOT PYTHON_EXECUTABLE - - IF(NOT GCOVR_PATH) - MESSAGE(FATAL_ERROR "gcovr not found! Aborting...") - ENDIF() # NOT GCOVR_PATH - - ADD_CUSTOM_TARGET(${_targetname} - - # Run tests - ${_testrunner} ${ARGV3} - - # Running gcovr - COMMAND ${GCOVR_PATH} -x -r ${CMAKE_SOURCE_DIR} -e '${CMAKE_SOURCE_DIR}/tests/' -o ${_outputname}.xml - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - COMMENT "Running gcovr to produce Cobertura code coverage report." - ) - - # Show info where to find the report - ADD_CUSTOM_COMMAND(TARGET ${_targetname} POST_BUILD - COMMAND ; - COMMENT "Cobertura code coverage report saved in ${_outputname}.xml." - ) - -ENDFUNCTION() # SETUP_TARGET_FOR_COVERAGE_COBERTURA - diff --git a/cmake/detect_openmp.cmake b/cmake/detect_openmp.cmake deleted file mode 100644 index 2fd30d8d..00000000 --- a/cmake/detect_openmp.cmake +++ /dev/null @@ -1,48 +0,0 @@ -#----------------------------------------------------------------------------- -# find_package(OpenMP) does not support Fortran and has other problems, too - -macro(detect_openmp) - - # C - if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel") - set (OpenMP_C_FLAGS "-qopenmp") - elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "PGI") - set (OpenMP_C_FLAGS "-mp") - elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") - set (OpenMP_C_FLAGS "-fopenmp") - elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") - set (OpenMP_C_FLAGS "-fopenmp") - else ("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel") - message (FATAL_ERROR "C compiler ${CMAKE_C_COMPILER_ID} not configured") - endif ("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel") - message (STATUS "Detecting OpenMP flags for ${CMAKE_C_COMPILER_ID} C compiler: ${OpenMP_C_FLAGS}") - - # C++ not used - if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") - set (OpenMP_CXX_FLAGS "-qopenmp") - elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "PGI") - set (OpenMP_CXX_FLAGS "-mp") - elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - set (OpenMP_CXX_FLAGS "-fopenmp") - elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - set (OpenMP_CXX_FLAGS "-fopenmp") - else ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") - message (FATAL_ERROR "C compiler ${CMAKE_CXX_COMPILER_ID} not configured") - endif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") - message (STATUS "Detecting OpenMP flags for ${CMAKE_CXX_COMPILER_ID} C++ compiler: ${OpenMP_CXX_FLAGS}") - - # Fortran - if ("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "Intel") - set (OpenMP_Fortran_FLAGS "-qopenmp") - elseif ("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "PGI") - set (OpenMP_Fortran_FLAGS "-mp") - elseif ("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "GNU") - set (OpenMP_Fortran_FLAGS "-fopenmp") - elseif ("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "Clang") - set (OpenMP_Fortran_FLAGS "-fopenmp") - else ("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "Intel") - message (FATAL_ERROR "Fortran compiler ${CMAKE_Fortran_COMPILER_ID} not configured") - endif ("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "Intel") - message (STATUS "Detecting OpenMP flags for ${CMAKE_Fortran_COMPILER_ID} Fortran compiler: ${OpenMP_Fortran_FLAGS}") - -endmacro() diff --git a/cmake/export_dynamic.cmake b/cmake/export_dynamic.cmake deleted file mode 100644 index 502ed415..00000000 --- a/cmake/export_dynamic.cmake +++ /dev/null @@ -1,7 +0,0 @@ -#----------------------------------------------------------------------------- -# Darwin uses Mach-O binaries, so we don't need to export our own functions. -if (NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")) - set(LINK_EXPORT_DYNAMIC "-Wl,--export-dynamic") - set(CMAKE_EXE_LINKER_FLAGS - "${CMAKE_EXE_LINKER_FLAGS} ${LINK_EXPORT_DYNAMIC}") -endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b09f5fc7..31ac3ef6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,9 +1,3 @@ -# Set default project to unknown -if(NOT PROJECT) - message(STATUS "Setting CCPP project to 'unknown' as none was specified.") - set(PROJECT "Unknown") -endif (NOT PROJECT) - #------------------------------------------------------------------------------ # Set the sources set(SOURCES_F90 @@ -17,30 +11,6 @@ foreach(source_f90 ${SOURCES_F90}) list(APPEND MODULES_F90 ${CMAKE_CURRENT_BINARY_DIR}/${module_f90}) endforeach() -#------------------------------------------------------------------------------ -# CMake Modules -# Set the CMake module path -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake") - -#------------------------------------------------------------------------------ -# Set a default build type if none was specified -if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - message(STATUS "Setting build type to 'Release' as none was specified.") - set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE) - - # Set the possible values of build type for cmake-gui - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" - "MinSizeRel" "RelWithDebInfo") -endif() - -#------------------------------------------------------------------------------ -# Pass debug/release flag to Fortran files for preprocessor -if(CMAKE_BUILD_TYPE STREQUAL "Debug") - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -DDEBUG") -else(CMAKE_BUILD_TYPE) - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -DRELEASE") -endif() - #------------------------------------------------------------------------------ # Add the toplevel source directory to our include directoies (for .h) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) @@ -67,17 +37,10 @@ set_target_properties(ccpp_framework PROPERTIES VERSION ${PROJECT_VERSION} #------------------------------------------------------------------------------ # Installation # -if (PROJECT STREQUAL "CCPP-FV3") - target_include_directories(ccpp_framework PUBLIC - $ - $ - ) -elseif (PROJECT STREQUAL "CCPP-SCM") - target_include_directories(ccpp_framework PUBLIC - $ - $ - ) -endif (PROJECT STREQUAL "CCPP-FV3") +target_include_directories(ccpp_framework PUBLIC + $ + $ +) # Define where to install the library install(TARGETS ccpp_framework @@ -94,8 +57,4 @@ install(EXPORT ccpp_framework-targets ) # Define where to install the Fortran modules -if (PROJECT STREQUAL "CCPP-FV3") - install(FILES ${MODULES_F90} DESTINATION include) -else (PROJECT STREQUAL "CCPP-SCM") - install(FILES ${MODULES_F90} DESTINATION include/${PROJECT_NAME}) -endif (PROJECT STREQUAL "CCPP-FV3") +install(FILES ${MODULES_F90} DESTINATION include)