Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop merge #4

Merged
merged 8 commits into from
Apr 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,10 @@ endif()
#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 @@ -71,6 +66,8 @@ enable_testing()
add_subdirectory(src)
# Documentation
add_subdirectory(doc)
# All schemes
add_subdirectory(schemes)

#------------------------------------------------------------------------------
# Configure and enable packaging
Expand Down
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,15 @@ src/tests/test_init_fini my_suite.xml
```

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

To add a new scheme one needs to

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()`.
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 IPD will call your
cap routine.
a. The cap routine must be labelled "schemename_cap".
Expand All @@ -82,7 +80,7 @@ To add a new scheme one needs to
fields from the fields array with the `ccpp_fields_get()`
subroutine.

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

## Documentation
The code is documented with [doxygen](www.doxygen.org/).
Expand Down
13 changes: 11 additions & 2 deletions tests/suite.xsd → examples/suite.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,24 @@
xmlns:xs="http://www.w3.org/2001/XMLSchema">

<!-- definition of simple elements -->
<xs:element name="scheme" type="xs:string"/>
<xs:element name="scheme">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="lib" type="xs:string" use="optional"/>
<xs:attribute name="ver" type="xs:string" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>

<!-- definition of complex elements -->
<xs:element name="subcycle">
<xs:complexType>
<xs:sequence>
<xs:element ref="scheme" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="loop" type="xs:positiveInteger" use="optional"/>
<xs:attribute name="loop" type="xs:positiveInteger" use="optional"/>
</xs:complexType>
</xs:element>

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions examples/suite_EXAMPLE.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>

<suite name="EXAMPLE">
<ipd part="1">
<subcycle loop="1">
<scheme lib="exmaple" ver="0.2">test</scheme>
</subcycle>
</ipd>
</suite>

File renamed without changes.
33 changes: 33 additions & 0 deletions schemes/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#------------------------------------------------------------------------------
# Add all the physics schemes in their own sub-directory (a.k.a repos)
#------------------------------------------------------------------------------

include(ExternalProject)

#------------------------------------------------------------------------------
# The checker scheme
ExternalProject_Add(
check
DEPENDS ccpp
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/check"
PREFIX "check"
DOWNLOAD_COMMAND ""
UPDATE_COMMAND ""
INSTALL_COMMAND ""
CMAKE_ARGS -DCCPP_INCLUDE_DIRS=${CCPP_INCLUDE_DIRS}
-DCCPP_LIB_DIRS=${CCPP_LIB_DIRS}
)

#------------------------------------------------------------------------------
# The dummy SCM scheme
ExternalProject_Add(
scm
DEPENDS ccpp
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/scm"
PREFIX "scm"
DOWNLOAD_COMMAND ""
UPDATE_COMMAND ""
INSTALL_COMMAND ""
CMAKE_ARGS -DCCPP_INCLUDE_DIRS=${CCPP_INCLUDE_DIRS}
-DCCPP_LIB_DIRS=${CCPP_LIB_DIRS}
)
61 changes: 61 additions & 0 deletions schemes/check/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#------------------------------------------------------------------------------
cmake_minimum_required(VERSION 2.8.11)

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

#------------------------------------------------------------------------------
set(PACKAGE "check")
set(AUTHORS "Timothy Brown")
string(TIMESTAMP YEAR "%Y")

#------------------------------------------------------------------------------
# Enable Fortran
enable_language(Fortran)

#------------------------------------------------------------------------------
# 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 'Debug' as none was specified.")
set(CMAKE_BUILD_TYPE Debug 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()

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

#------------------------------------------------------------------------------
# Add the CCPP include/module directory
set(CCPP_INCLUDE_DIRS "" CACHE FILEPATH "Path to ccpp includes")
set_property(DIRECTORY PROPERTY INCLUDE_DIRECTORIES ${CCPP_INCLUDE_DIRS})

#------------------------------------------------------------------------------
# Add the CCPP library
set(CCPP_LIB_DIRS "" CACHE FILEPATH "Path to ccpp library")
link_directories(${CCPP_LIB_DIRS})
list(APPEND LIBS "ccpp")

#------------------------------------------------------------------------------
# Set the sources
set(SOURCES
test.f90
noop.f90
)

add_library(check ${SOURCES})
target_link_libraries(check LINK_PUBLIC ${LIBS})
set_target_properties(check PROPERTIES VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR})

File renamed without changes.
33 changes: 33 additions & 0 deletions schemes/check/noop.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
!>
!! @brief A NO-OP physics modules.
!!
!
module check_noop

use, intrinsic :: iso_c_binding, &
only: c_f_pointer, c_ptr
use :: ccpp_types, &
only: ccpp_t, STR_LEN
use :: ccpp_fields, &
only: ccpp_fields_get
implicit none

private
public :: noop_cap

contains

subroutine noop_cap(ptr) bind(c)
implicit none
type(c_ptr), intent(inout) :: ptr

type(ccpp_t), pointer :: cdata

call c_f_pointer(ptr, cdata)

print *, 'In noop_cap'
print *, cdata%suite%ipds(1)%subcycles(1)%schemes(1)%name

end subroutine noop_cap

end module check_noop
1 change: 1 addition & 0 deletions src/schemes/check/test.f90 → schemes/check/test.f90
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ subroutine test_cap(ptr) bind(c)
call ccpp_fields_get(cdata, 'northward_wind', v, ierr)

call test_run(gravity, u, v, surf_t)
print *, 'In test_cap'

end subroutine test_cap

Expand Down
60 changes: 60 additions & 0 deletions schemes/scm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#------------------------------------------------------------------------------
cmake_minimum_required(VERSION 2.8.11)

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

#------------------------------------------------------------------------------
set(PACKAGE "scm")
set(AUTHORS "Grant J. Firl")

#------------------------------------------------------------------------------
# Enable Fortran
enable_language(Fortran)

#------------------------------------------------------------------------------
# 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 'Debug' as none was specified.")
set(CMAKE_BUILD_TYPE Debug 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()

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

#------------------------------------------------------------------------------
# Add the CCPP include/module directory
set(CCPP_INCLUDE_DIRS "" CACHE FILEPATH "Path to ccpp includes")
set_property(DIRECTORY PROPERTY INCLUDE_DIRECTORIES ${CCPP_INCLUDE_DIRS})

#------------------------------------------------------------------------------
# Add the CCPP library
set(CCPP_LIB_DIRS "" CACHE FILEPATH "Path to ccpp library")
link_directories(${CCPP_LIB_DIRS})
list(APPEND LIBS "ccpp")

#------------------------------------------------------------------------------
# Set the sources
set(SOURCES
dummy_scm.f90
dummy_scm2.f90
)

add_library(scm ${SOURCES})
target_link_libraries(scm LINK_PUBLIC ${LIBS})
set_target_properties(scm PROPERTIES VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR})

File renamed without changes.
File renamed without changes.
17 changes: 11 additions & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
# Set the sources
add_sources(
set(SOURCES
ccpp.f90
ccpp_errors.f90
ccpp_fields.f90
Expand Down Expand Up @@ -29,13 +29,18 @@ endif(LIBXML2_FOUND)

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

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

#------------------------------------------------------------------------------
# Add all the different physics schemes
add_subdirectory(schemes)
# Set a cached variable containing the includes, so schemes can use them
set(${PACKAGE}_INCLUDE_DIRS
"${CMAKE_CURRENT_SOURCE_DIR}$<SEMICOLON>${CMAKE_CURRENT_BINARY_DIR}"
CACHE FILEPATH "${PACKAGE} include directories")
set(${PACKAGE}_LIB_DIRS
"${CMAKE_CURRENT_BINARY_DIR}"
CACHE FILEPATH "${PACKAGE} library directories")

#------------------------------------------------------------------------------
# Add the tests
Expand Down
28 changes: 22 additions & 6 deletions src/ccpp.f90
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ module ccpp
only: ccpp_suite_init, ccpp_suite_fini
use :: ccpp_fields, &
only: ccpp_fields_init, ccpp_fields_fini
use :: ccpp_ipd, &
only: ccpp_ipd_init, ccpp_ipd_fini
use :: ccpp_errors, &
only: ccpp_error

Expand All @@ -26,9 +28,9 @@ module ccpp
!>
!! CCPP initialization subroutine.
!!
!! @param[in] filename The file name of the XML scheme file to load.
!! @param[inout] cdata The ccpp_t type data.
!! @param[ out] ierr Integer error flag.
!! @param[in] filename The file name of the XML scheme file to load.
!! @param[in,out] cdata The ccpp_t type data.
!! @param[ out] ierr Integer error flag.
!
subroutine ccpp_init(filename, cdata, ierr)
character(len=*), intent(in) :: filename
Expand All @@ -44,6 +46,13 @@ subroutine ccpp_init(filename, cdata, ierr)
return
end if

! Initialize the scheme calls
call ccpp_ipd_init(cdata, ierr)
if (ierr /= 0) then
call ccpp_error('In initializing the CCPP scheme calls')
return
end if

! Initialize the fields
call ccpp_fields_init(cdata, ierr)
if (ierr /= 0) then
Expand All @@ -56,8 +65,8 @@ end subroutine ccpp_init
!>
!! CCPP finalization subroutine.
!!
!! @param[inout] cdata The ccpp_t type data.
!! @param[ out] ierr Integer error flag.
!! @param[in,out] cdata The ccpp_t type data.
!! @param[ out] ierr Integer error flag.
!
subroutine ccpp_fini(cdata, ierr)
type(ccpp_t), intent(inout) :: cdata
Expand All @@ -72,7 +81,14 @@ subroutine ccpp_fini(cdata, ierr)
return
end if

! Initialize the fields
! Finalize the scheme calls
call ccpp_ipd_fini(cdata, ierr)
if (ierr /= 0) then
call ccpp_error('In finalizing the CCPP scheme calls')
return
end if

! Finalize the fields
call ccpp_fields_fini(cdata, ierr)
if (ierr /= 0) then
call ccpp_error('In finalizing the CCPP fields')
Expand Down
Loading