Skip to content

Commit

Permalink
Merge pull request #2 from NCAR/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
t-brown authored Apr 17, 2017
2 parents 849d07c + a4f9315 commit 217f800
Show file tree
Hide file tree
Showing 65 changed files with 2,865 additions and 1,562 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
branches:
only:
- master
- develop

language: fortran

Expand Down
44 changes: 40 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
cmake_minimum_required(VERSION 2.8.11)
cmake_policy(SET CMP0048 NEW)

project(CCPP VERSION 0.0.1)
if(POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
project(ccpp VERSION 0.0.1)
else(POLICY CMP0048)
project(ccpp)
set(PROJECT_VERSION 0.0.1)
set(PROJECT_VERSION_MAJOR 0)
set(PROJECT_VERSION_MINOR 0)
set(PROJECT_VERSION_PATCH 1)
endif(POLICY CMP0048)

#string(TOLOWER ${CMAKE_PROJECT_NAME} PROJECT_NAME_LC)

#------------------------------------------------------------------------------
# Enable Fortran
Expand All @@ -25,13 +35,20 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
endif()

#------------------------------------------------------------------------------
# Set the CMake module path
# CMake Modules
#
#Set the CMake module path
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

# Include modules
include(add_sources)
include(export_dynamic)

#------------------------------------------------------------------------------
# By default we want a shared library
option(BUILD_SHARED_LIBS "Build a shared library" ON)


#------------------------------------------------------------------------------
# Enable code coverage
if(CMAKE_COMPILER_IS_GNUCC AND (CMAKE_BUILD_TYPE STREQUAL "Coverage"))
Expand All @@ -45,11 +62,30 @@ endif()
#------------------------------------------------------------------------------
# Enable testing
enable_testing()
add_test(DUMMY src/atm_drv ${CMAKE_SOURCE_DIR}/tests/suite_DUMMY.xml)

#------------------------------------------------------------------------------
# Add the sub-directories
# Source
add_subdirectory(src)
# Documentation
add_subdirectory(doc)

#------------------------------------------------------------------------------
# Configure and enable packaging
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Common Community Phyics Package")
set(CPACK_PACKAGE_VENDOR "DTC 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")
#set(CPACK_GENERATOR "DEB")
#set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Timothy Brown")

include(CPack)
52 changes: 29 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![Coverage Status](https://coveralls.io/repos/github/t-brown/ccpp/badge.svg?branch=master)](https://coveralls.io/github/NCAR/gmtb-ccpp?branch=master)

## Requirements
1. Compilers [GNU Compiler Collection](https://gcc.gnu.org/)
1. Compilers for example the [GNU Compiler Collection](https://gcc.gnu.org/)
* C
* Fortran (must be 2003 compliant)
2. [Cmake](https://cmake.org)
Expand All @@ -28,13 +28,14 @@ It is recommend to do an out of source build.
* `cd build`
5. Create the makefiles.
* `cmake ..`
5. Build the test program.
5. Build the CCPP library and test programs.
* `make`

## Running
The test program will be in the `ccpp/build/src` directory. While test suite
definitions are in the `ccpp/tests` directory.
* `src/atm_drv ../tests/suite_DUMMY.xml`
## 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 all
the tests issue the following within the build directory.
* `make test`

## Validating XML
A suite is defined in XML. There is a test suite definied within
Expand All @@ -46,37 +47,42 @@ xmllint --schema suite.xsd --noout suite_RAP.xml
suite_RAP.xml validates
```

Within the `src/tests` directoty there is `test_init_fini.f90` which
will get built when the CCPP library is built. This program only calls
* `ccpp_init()`
* `ccpp_fini()`
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.
```
src/tests/test_init_fini my_suite.xml
```

## Physics Schemes
All physics schemes are kept in the repository under the `src/schemes`
directory.

To add a new scheme one needs to

1. Add/Create the scheme within `src/schemes`.
a. If it is a simple single source file, you can add
it in this directory. Then also add the file to
list of source files in the `CMakeLists.txt` file
in the `src/schemes` directory.
b. If it is a more complicated scheme, you should
create a sub-directory under the `src/schemes`
directory. If you are using CMake as the build
system, you need to add an `add_subdirectory()`
directive to end of those entires (before the
`add_sources()` list). If you are using an
external build system we will need to address
the usage of `ExternalProject_Add()`.
1. Add/Create the scheme within `src/schemes`. You should create a
sub-directory under the `src/schemes` directory. If you are using
CMake as the build system, you need to add an `add_subdirectory()`
directive to end of those entires (before the `add_sources()` list).
If you are using an external build system we will need to address
the usage of `ExternalProject_Add()`.
2. Create a `cap` subroutine. The IPD will call your
cap routine.
a. 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. Lowercased
2. "_cap" is appended.
b. Map all the inputs for the cap from the `ap_data`
fields array. The `phy_field_data()` subroutine
should be used for this.
b. 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_fields_get()`
subroutine.

An example of a scheme that does nothing is `src/schemes/dummy.f90`.
An example of a scheme that does nothing is `src/schemes/check/test.f90`.

## Documentation
The code is documented with [doxygen](www.doxygen.org/).
Expand Down
7 changes: 6 additions & 1 deletion doc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#-----------------------------------------------------------------------------
# Doxygen rules
#
# Add a target to generate API documentation with Doxygen
find_package(Doxygen)
option(BUILD_DOCUMENTATION
"Create and install the HTML documentation (requires Doxygen)"
${DOXYGEN_FOUND})

#
if(BUILD_DOCUMENTATION)
if(NOT DOXYGEN_FOUND)
message(FATAL_ERROR "Doxygen is needed to build the documentation.")
Expand All @@ -21,6 +24,8 @@ if(BUILD_DOCUMENTATION)
COMMENT "Generating API documentation with Doxygen"
VERBATIM)

install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION share/doc)
# Define where to install the documentation
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html
DESTINATION share/doc/${PROJECT_NAME})
endif()

80 changes: 60 additions & 20 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
#------------------------------------------------------------------------------
# Set the sources
add_sources(
#atm_drv.f90
kinds.f90
errors.f90
strings.f90
types.f90
types.h
xml.c
xml.f90
xml.h
ipd/ipd.f90
ipd/ipd_phy.c
ipd/ipd_phy.h
phy/phy_field_idx.c
phy/phy_fields.f90
phy/phy_infra.f90
ccpp.f90
ccpp_errors.f90
ccpp_fields.f90
ccpp_fields_idx.h
ccpp_fields_idx.c
ccpp_ipd.f90
ccpp_ipd.h
ccpp_ipd.c
ccpp_strings.f90
ccpp_suite.f90
ccpp_types.f90
ccpp_utils.h
ccpp_utils.c
ccpp_xml.f90
ccpp_xml.h
ccpp_xml.c
)

#------------------------------------------------------------------------------
Expand All @@ -27,16 +28,55 @@ if (LIBXML2_FOUND)
endif(LIBXML2_FOUND)

#------------------------------------------------------------------------------
# Add the toplevel source directory to our include directoies
include_directories(".")
# Add the toplevel source directory to our include directoies (for .h)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
# Add the toplevel binary directory to our include directoies (for .mod)
include_directories("${CMAKE_CURRENT_BINARY_DIR}")

#------------------------------------------------------------------------------
# Add all the different physics schemes
add_subdirectory(schemes)

#------------------------------------------------------------------------------
# Add the tests
add_subdirectory(tests)

#------------------------------------------------------------------------------
# Define the executable and what to link
#add_executable(atm_drv ${SOURCES})
#target_link_libraries(atm_drv LINK_PUBLIC ${LIBS} ${CMAKE_DL_LIBS})
add_library(ccpp SHARED ${SOURCES})
add_library(ccpp ${SOURCES})
target_link_libraries(ccpp LINK_PUBLIC ${LIBS} ${CMAKE_DL_LIBS})
set_target_properties(ccpp PROPERTIES VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR})

#------------------------------------------------------------------------------
# Installation
#

# Find all the C headers and Fortran modules
file(GLOB headers
"${CMAKE_CURRENT_SOURCE_DIR}/ccpp*.h"
"${CMAKE_CURRENT_BINARY_DIR}/ccpp*.mod"
)

target_include_directories(ccpp PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}>
)

# Define where to install the library
install(TARGETS ccpp
EXPORT ccpp-targets
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION lib
)

# Export our configuration
install(EXPORT ccpp-targets
FILE ccpp-config.cmake
DESTINATION lib/cmake
)

# Define where to install the modules
install(FILES ${headers} DESTINATION include/${PROJECT_NAME})

92 changes: 0 additions & 92 deletions src/atm_drv.f90

This file was deleted.

Loading

0 comments on commit 217f800

Please sign in to comment.