From be9b30f29efe87e7d6f9adefa94dcb010e834300 Mon Sep 17 00:00:00 2001 From: Timothy Brown Date: Tue, 18 Apr 2017 22:37:07 -0600 Subject: [PATCH 1/6] Extending the fields. Extending the fields out to 7D. Also the start of the great re-org and re-name. - The XML validation suites are now called no-op. - The test dummy program is now a test check program. The removal of the need for the cmake "add_sources()" since we are going to move the schemes to the toplevel and have them as external projects. --- {tests => examples}/suite.xsd | 0 {tests => examples}/suite_DUMMY.xml | 0 {tests => examples}/suite_DUMMY_scm.xml | 0 {tests => examples}/suite_DUMMY_scm2.xml | 0 {tests => examples}/suite_RAP.xml | 0 {src/schemes => schemes}/CMakeLists.txt | 0 {src/schemes => schemes}/check/CMakeLists.txt | 0 {src/schemes => schemes}/check/nan.f90 | 0 {src/schemes => schemes}/check/test.f90 | 0 {src/schemes => schemes}/noop/CMakeLists.txt | 0 {src/schemes => schemes}/scm/CMakeLists.txt | 0 {src/schemes => schemes}/scm/dummy_scm.f90 | 0 {src/schemes => schemes}/scm/dummy_scm2.f90 | 0 src/ccpp_fields.f90 | 896 +++++++++++++++++- .../{suite_test_1.xml => suite_noop_1.xml} | 0 .../{suite_test_2.xml => suite_noop_2.xml} | 0 .../{suite_test_3.xml => suite_noop_3.xml} | 0 .../{suite_test_4.xml => suite_noop_4.xml} | 0 .../{suite_test_5.xml => suite_noop_5.xml} | 0 .../{suite_test_6.xml => suite_noop_6.xml} | 0 src/tests/{test_dummy.f90 => test_check.f90} | 0 21 files changed, 848 insertions(+), 48 deletions(-) rename {tests => examples}/suite.xsd (100%) rename {tests => examples}/suite_DUMMY.xml (100%) rename {tests => examples}/suite_DUMMY_scm.xml (100%) rename {tests => examples}/suite_DUMMY_scm2.xml (100%) rename {tests => examples}/suite_RAP.xml (100%) rename {src/schemes => schemes}/CMakeLists.txt (100%) rename {src/schemes => schemes}/check/CMakeLists.txt (100%) rename {src/schemes => schemes}/check/nan.f90 (100%) rename {src/schemes => schemes}/check/test.f90 (100%) rename {src/schemes => schemes}/noop/CMakeLists.txt (100%) rename {src/schemes => schemes}/scm/CMakeLists.txt (100%) rename {src/schemes => schemes}/scm/dummy_scm.f90 (100%) rename {src/schemes => schemes}/scm/dummy_scm2.f90 (100%) rename src/tests/{suite_test_1.xml => suite_noop_1.xml} (100%) rename src/tests/{suite_test_2.xml => suite_noop_2.xml} (100%) rename src/tests/{suite_test_3.xml => suite_noop_3.xml} (100%) rename src/tests/{suite_test_4.xml => suite_noop_4.xml} (100%) rename src/tests/{suite_test_5.xml => suite_noop_5.xml} (100%) rename src/tests/{suite_test_6.xml => suite_noop_6.xml} (100%) rename src/tests/{test_dummy.f90 => test_check.f90} (100%) diff --git a/tests/suite.xsd b/examples/suite.xsd similarity index 100% rename from tests/suite.xsd rename to examples/suite.xsd diff --git a/tests/suite_DUMMY.xml b/examples/suite_DUMMY.xml similarity index 100% rename from tests/suite_DUMMY.xml rename to examples/suite_DUMMY.xml diff --git a/tests/suite_DUMMY_scm.xml b/examples/suite_DUMMY_scm.xml similarity index 100% rename from tests/suite_DUMMY_scm.xml rename to examples/suite_DUMMY_scm.xml diff --git a/tests/suite_DUMMY_scm2.xml b/examples/suite_DUMMY_scm2.xml similarity index 100% rename from tests/suite_DUMMY_scm2.xml rename to examples/suite_DUMMY_scm2.xml diff --git a/tests/suite_RAP.xml b/examples/suite_RAP.xml similarity index 100% rename from tests/suite_RAP.xml rename to examples/suite_RAP.xml diff --git a/src/schemes/CMakeLists.txt b/schemes/CMakeLists.txt similarity index 100% rename from src/schemes/CMakeLists.txt rename to schemes/CMakeLists.txt diff --git a/src/schemes/check/CMakeLists.txt b/schemes/check/CMakeLists.txt similarity index 100% rename from src/schemes/check/CMakeLists.txt rename to schemes/check/CMakeLists.txt diff --git a/src/schemes/check/nan.f90 b/schemes/check/nan.f90 similarity index 100% rename from src/schemes/check/nan.f90 rename to schemes/check/nan.f90 diff --git a/src/schemes/check/test.f90 b/schemes/check/test.f90 similarity index 100% rename from src/schemes/check/test.f90 rename to schemes/check/test.f90 diff --git a/src/schemes/noop/CMakeLists.txt b/schemes/noop/CMakeLists.txt similarity index 100% rename from src/schemes/noop/CMakeLists.txt rename to schemes/noop/CMakeLists.txt diff --git a/src/schemes/scm/CMakeLists.txt b/schemes/scm/CMakeLists.txt similarity index 100% rename from src/schemes/scm/CMakeLists.txt rename to schemes/scm/CMakeLists.txt diff --git a/src/schemes/scm/dummy_scm.f90 b/schemes/scm/dummy_scm.f90 similarity index 100% rename from src/schemes/scm/dummy_scm.f90 rename to schemes/scm/dummy_scm.f90 diff --git a/src/schemes/scm/dummy_scm2.f90 b/schemes/scm/dummy_scm2.f90 similarity index 100% rename from src/schemes/scm/dummy_scm2.f90 rename to schemes/scm/dummy_scm2.f90 diff --git a/src/ccpp_fields.f90 b/src/ccpp_fields.f90 index 69161ab1..c9fab044 100644 --- a/src/ccpp_fields.f90 +++ b/src/ccpp_fields.f90 @@ -61,26 +61,46 @@ module ccpp_fields ccpp_fields_add_i32_1, & ccpp_fields_add_i32_2, & ccpp_fields_add_i32_3, & + ccpp_fields_add_i32_4, & + ccpp_fields_add_i32_5, & + ccpp_fields_add_i32_6, & + ccpp_fields_add_i32_7, & ccpp_fields_add_i64_0, & ccpp_fields_add_i64_1, & ccpp_fields_add_i64_2, & ccpp_fields_add_i64_3, & + ccpp_fields_add_i64_4, & + ccpp_fields_add_i64_5, & + ccpp_fields_add_i64_6, & + ccpp_fields_add_i64_7, & ccpp_fields_add_r32_0, & ccpp_fields_add_r32_1, & ccpp_fields_add_r32_2, & ccpp_fields_add_r32_3, & + ccpp_fields_add_r32_4, & + ccpp_fields_add_r32_5, & + ccpp_fields_add_r32_6, & + ccpp_fields_add_r32_7, & ccpp_fields_add_r64_0, & ccpp_fields_add_r64_1, & ccpp_fields_add_r64_2, & ccpp_fields_add_r64_3, & + ccpp_fields_add_r64_4, & + ccpp_fields_add_r64_5, & + ccpp_fields_add_r64_6, & + ccpp_fields_add_r64_7, & ccpp_fields_add_l_0, & ccpp_fields_add_l_1, & ccpp_fields_add_l_2, & - ccpp_fields_add_l_3 + ccpp_fields_add_l_3, & + ccpp_fields_add_l_4, & + ccpp_fields_add_l_5, & + ccpp_fields_add_l_6, & + ccpp_fields_add_l_7 end interface ccpp_fields_add !> @@ -91,26 +111,46 @@ module ccpp_fields ccpp_fields_get_i32_1, & ccpp_fields_get_i32_2, & ccpp_fields_get_i32_3, & + ccpp_fields_get_i32_4, & + ccpp_fields_get_i32_5, & + ccpp_fields_get_i32_6, & + ccpp_fields_get_i32_7, & ccpp_fields_get_i64_0, & ccpp_fields_get_i64_1, & ccpp_fields_get_i64_2, & ccpp_fields_get_i64_3, & + ccpp_fields_get_i64_4, & + ccpp_fields_get_i64_5, & + ccpp_fields_get_i64_6, & + ccpp_fields_get_i64_7, & ccpp_fields_get_r32_0, & ccpp_fields_get_r32_1, & ccpp_fields_get_r32_2, & ccpp_fields_get_r32_3, & + ccpp_fields_get_r32_4, & + ccpp_fields_get_r32_5, & + ccpp_fields_get_r32_6, & + ccpp_fields_get_r32_7, & ccpp_fields_get_r64_0, & ccpp_fields_get_r64_1, & ccpp_fields_get_r64_2, & ccpp_fields_get_r64_3, & + ccpp_fields_get_r64_4, & + ccpp_fields_get_r64_5, & + ccpp_fields_get_r64_6, & + ccpp_fields_get_r64_7, & ccpp_fields_get_l_0, & ccpp_fields_get_l_1, & ccpp_fields_get_l_2, & - ccpp_fields_get_l_3 + ccpp_fields_get_l_3, & + ccpp_fields_get_l_4, & + ccpp_fields_get_l_5, & + ccpp_fields_get_l_6, & + ccpp_fields_get_l_7 end interface ccpp_fields_get !> @@ -225,13 +265,13 @@ end subroutine ccpp_fields_fini !! @param[ out] ierr Integer error flag. ! subroutine ccpp_field_add_ptr(cdata, standard_name, units, ptr, & - p_rank, p_dims, ierr) + rank, dims, ierr) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name character(len=*), intent(in) :: units type(c_ptr), intent(in) :: ptr - integer, optional, intent(in) :: p_rank - integer, dimension(:), optional, intent(in) :: p_dims + integer, optional, intent(in) :: rank + integer, dimension(:), optional, intent(in) :: dims integer, intent( out) :: ierr integer :: i @@ -268,19 +308,19 @@ subroutine ccpp_field_add_ptr(cdata, standard_name, units, ptr, & cdata%fields(i)%units = units cdata%fields(i)%ptr = ptr - if (present(p_rank)) then - cdata%fields(i)%rank = p_rank + if (present(rank)) then + cdata%fields(i)%rank = rank else cdata%fields(i)%rank = 0 end if - if (present(p_dims)) then - allocate(cdata%fields(i)%dims(p_rank), stat=ierr) + if (present(dims)) then + allocate(cdata%fields(i)%dims(rank), stat=ierr) if (ierr /= 0) then call ccpp_warn('Unable to allocate cdata fields dims') return end if - cdata%fields(i)%dims = p_dims + cdata%fields(i)%dims = dims end if end subroutine ccpp_field_add_ptr @@ -367,6 +407,58 @@ subroutine ccpp_fields_add_i32_3(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_i32_3 + subroutine ccpp_fields_add_i32_4(cdata, standard_name, units, ptr, ierr) + type(ccpp_t), intent(inout) :: cdata + character(len=*), intent(in) :: standard_name + character(len=*), intent(in) :: units + integer(kind=INT32), target, intent(in) :: ptr(:,:,:,:) + integer, intent( out) :: ierr + + ierr = 0 + call ccpp_field_add_ptr(cdata, standard_name, units, & + c_loc(ptr), size(ptr), shape(ptr), ierr=ierr) + + end subroutine ccpp_fields_add_i32_4 + + subroutine ccpp_fields_add_i32_5(cdata, standard_name, units, ptr, ierr) + type(ccpp_t), intent(inout) :: cdata + character(len=*), intent(in) :: standard_name + character(len=*), intent(in) :: units + integer(kind=INT32), target, intent(in) :: ptr(:,:,:,:,:) + integer, intent( out) :: ierr + + ierr = 0 + call ccpp_field_add_ptr(cdata, standard_name, units, & + c_loc(ptr), size(ptr), shape(ptr), ierr=ierr) + + end subroutine ccpp_fields_add_i32_5 + + subroutine ccpp_fields_add_i32_6(cdata, standard_name, units, ptr, ierr) + type(ccpp_t), intent(inout) :: cdata + character(len=*), intent(in) :: standard_name + character(len=*), intent(in) :: units + integer(kind=INT32), target, intent(in) :: ptr(:,:,:,:,:,:) + integer, intent( out) :: ierr + + ierr = 0 + call ccpp_field_add_ptr(cdata, standard_name, units, & + c_loc(ptr), size(ptr), shape(ptr), ierr=ierr) + + end subroutine ccpp_fields_add_i32_6 + + subroutine ccpp_fields_add_i32_7(cdata, standard_name, units, ptr, ierr) + type(ccpp_t), intent(inout) :: cdata + character(len=*), intent(in) :: standard_name + character(len=*), intent(in) :: units + integer(kind=INT32), target, intent(in) :: ptr(:,:,:,:,:,:,:) + integer, intent( out) :: ierr + + ierr = 0 + call ccpp_field_add_ptr(cdata, standard_name, units, & + c_loc(ptr), size(ptr), shape(ptr), ierr=ierr) + + end subroutine ccpp_fields_add_i32_7 + !------------------------------------------------------------------! !> !! Double precision (64-bit) integer field addition subroutines. @@ -424,6 +516,58 @@ subroutine ccpp_fields_add_i64_3(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_i64_3 + subroutine ccpp_fields_add_i64_4(cdata, standard_name, units, ptr, ierr) + type(ccpp_t), intent(inout) :: cdata + character(len=*), intent(in) :: standard_name + character(len=*), intent(in) :: units + integer(kind=INT64), target, intent(in) :: ptr(:,:,:,:) + integer, intent( out) :: ierr + + ierr = 0 + call ccpp_field_add_ptr(cdata, standard_name, units, & + c_loc(ptr), size(ptr), shape(ptr), ierr=ierr) + + end subroutine ccpp_fields_add_i64_4 + + subroutine ccpp_fields_add_i64_5(cdata, standard_name, units, ptr, ierr) + type(ccpp_t), intent(inout) :: cdata + character(len=*), intent(in) :: standard_name + character(len=*), intent(in) :: units + integer(kind=INT64), target, intent(in) :: ptr(:,:,:,:,:) + integer, intent( out) :: ierr + + ierr = 0 + call ccpp_field_add_ptr(cdata, standard_name, units, & + c_loc(ptr), size(ptr), shape(ptr), ierr=ierr) + + end subroutine ccpp_fields_add_i64_5 + + subroutine ccpp_fields_add_i64_6(cdata, standard_name, units, ptr, ierr) + type(ccpp_t), intent(inout) :: cdata + character(len=*), intent(in) :: standard_name + character(len=*), intent(in) :: units + integer(kind=INT64), target, intent(in) :: ptr(:,:,:,:,:,:) + integer, intent( out) :: ierr + + ierr = 0 + call ccpp_field_add_ptr(cdata, standard_name, units, & + c_loc(ptr), size(ptr), shape(ptr), ierr=ierr) + + end subroutine ccpp_fields_add_i64_6 + + subroutine ccpp_fields_add_i64_7(cdata, standard_name, units, ptr, ierr) + type(ccpp_t), intent(inout) :: cdata + character(len=*), intent(in) :: standard_name + character(len=*), intent(in) :: units + integer(kind=INT64), target, intent(in) :: ptr(:,:,:,:,:,:,:) + integer, intent( out) :: ierr + + ierr = 0 + call ccpp_field_add_ptr(cdata, standard_name, units, & + c_loc(ptr), size(ptr), shape(ptr), ierr=ierr) + + end subroutine ccpp_fields_add_i64_7 + !------------------------------------------------------------------! !> !! Single precision (32-bit) real field addition subroutines. @@ -481,6 +625,58 @@ subroutine ccpp_fields_add_r32_3(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_r32_3 + subroutine ccpp_fields_add_r32_4(cdata, standard_name, units, ptr, ierr) + type(ccpp_t), intent(inout) :: cdata + character(len=*), intent(in) :: standard_name + character(len=*), intent(in) :: units + real(kind=REAL32), target, intent(in) :: ptr(:,:,:,:) + integer, intent( out) :: ierr + + ierr = 0 + call ccpp_field_add_ptr(cdata, standard_name, units, & + c_loc(ptr), size(ptr), shape(ptr), ierr=ierr) + + end subroutine ccpp_fields_add_r32_4 + + subroutine ccpp_fields_add_r32_5(cdata, standard_name, units, ptr, ierr) + type(ccpp_t), intent(inout) :: cdata + character(len=*), intent(in) :: standard_name + character(len=*), intent(in) :: units + real(kind=REAL32), target, intent(in) :: ptr(:,:,:,:,:) + integer, intent( out) :: ierr + + ierr = 0 + call ccpp_field_add_ptr(cdata, standard_name, units, & + c_loc(ptr), size(ptr), shape(ptr), ierr=ierr) + + end subroutine ccpp_fields_add_r32_5 + + subroutine ccpp_fields_add_r32_6(cdata, standard_name, units, ptr, ierr) + type(ccpp_t), intent(inout) :: cdata + character(len=*), intent(in) :: standard_name + character(len=*), intent(in) :: units + real(kind=REAL32), target, intent(in) :: ptr(:,:,:,:,:,:) + integer, intent( out) :: ierr + + ierr = 0 + call ccpp_field_add_ptr(cdata, standard_name, units, & + c_loc(ptr), size(ptr), shape(ptr), ierr=ierr) + + end subroutine ccpp_fields_add_r32_6 + + subroutine ccpp_fields_add_r32_7(cdata, standard_name, units, ptr, ierr) + type(ccpp_t), intent(inout) :: cdata + character(len=*), intent(in) :: standard_name + character(len=*), intent(in) :: units + real(kind=REAL32), target, intent(in) :: ptr(:,:,:,:,:,:,:) + integer, intent( out) :: ierr + + ierr = 0 + call ccpp_field_add_ptr(cdata, standard_name, units, & + c_loc(ptr), size(ptr), shape(ptr), ierr=ierr) + + end subroutine ccpp_fields_add_r32_7 + !------------------------------------------------------------------! !> !! Double precision (64-bit) real field addition subroutines. @@ -538,6 +734,58 @@ subroutine ccpp_fields_add_r64_3(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_r64_3 + subroutine ccpp_fields_add_r64_4(cdata, standard_name, units, ptr, ierr) + type(ccpp_t), intent(inout) :: cdata + character(len=*), intent(in) :: standard_name + character(len=*), intent(in) :: units + real(kind=REAL64), target, intent(in) :: ptr(:,:,:,:) + integer, intent( out) :: ierr + + ierr = 0 + call ccpp_field_add_ptr(cdata, standard_name, units, & + c_loc(ptr), size(ptr), shape(ptr), ierr=ierr) + + end subroutine ccpp_fields_add_r64_4 + + subroutine ccpp_fields_add_r64_5(cdata, standard_name, units, ptr, ierr) + type(ccpp_t), intent(inout) :: cdata + character(len=*), intent(in) :: standard_name + character(len=*), intent(in) :: units + real(kind=REAL64), target, intent(in) :: ptr(:,:,:,:,:) + integer, intent( out) :: ierr + + ierr = 0 + call ccpp_field_add_ptr(cdata, standard_name, units, & + c_loc(ptr), size(ptr), shape(ptr), ierr=ierr) + + end subroutine ccpp_fields_add_r64_5 + + subroutine ccpp_fields_add_r64_6(cdata, standard_name, units, ptr, ierr) + type(ccpp_t), intent(inout) :: cdata + character(len=*), intent(in) :: standard_name + character(len=*), intent(in) :: units + real(kind=REAL64), target, intent(in) :: ptr(:,:,:,:,:,:) + integer, intent( out) :: ierr + + ierr = 0 + call ccpp_field_add_ptr(cdata, standard_name, units, & + c_loc(ptr), size(ptr), shape(ptr), ierr=ierr) + + end subroutine ccpp_fields_add_r64_6 + + subroutine ccpp_fields_add_r64_7(cdata, standard_name, units, ptr, ierr) + type(ccpp_t), intent(inout) :: cdata + character(len=*), intent(in) :: standard_name + character(len=*), intent(in) :: units + real(kind=REAL64), target, intent(in) :: ptr(:,:,:,:,:,:,:) + integer, intent( out) :: ierr + + ierr = 0 + call ccpp_field_add_ptr(cdata, standard_name, units, & + c_loc(ptr), size(ptr), shape(ptr), ierr=ierr) + + end subroutine ccpp_fields_add_r64_7 + !------------------------------------------------------------------! !> !! Logical field addition subroutines. @@ -595,6 +843,58 @@ subroutine ccpp_fields_add_l_3(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_l_3 + subroutine ccpp_fields_add_l_4(cdata, standard_name, units, ptr, ierr) + type(ccpp_t), intent(inout) :: cdata + character(len=*), intent(in) :: standard_name + character(len=*), intent(in) :: units + logical, target, intent(in) :: ptr(:,:,:,:) + integer, intent( out) :: ierr + + ierr = 0 + call ccpp_field_add_ptr(cdata, standard_name, units, & + c_loc(ptr), size(ptr), shape(ptr), ierr=ierr) + + end subroutine ccpp_fields_add_l_4 + + subroutine ccpp_fields_add_l_5(cdata, standard_name, units, ptr, ierr) + type(ccpp_t), intent(inout) :: cdata + character(len=*), intent(in) :: standard_name + character(len=*), intent(in) :: units + logical, target, intent(in) :: ptr(:,:,:,:,:) + integer, intent( out) :: ierr + + ierr = 0 + call ccpp_field_add_ptr(cdata, standard_name, units, & + c_loc(ptr), size(ptr), shape(ptr), ierr=ierr) + + end subroutine ccpp_fields_add_l_5 + + subroutine ccpp_fields_add_l_6(cdata, standard_name, units, ptr, ierr) + type(ccpp_t), intent(inout) :: cdata + character(len=*), intent(in) :: standard_name + character(len=*), intent(in) :: units + logical, target, intent(in) :: ptr(:,:,:,:,:,:) + integer, intent( out) :: ierr + + ierr = 0 + call ccpp_field_add_ptr(cdata, standard_name, units, & + c_loc(ptr), size(ptr), shape(ptr), ierr=ierr) + + end subroutine ccpp_fields_add_l_6 + + subroutine ccpp_fields_add_l_7(cdata, standard_name, units, ptr, ierr) + type(ccpp_t), intent(inout) :: cdata + character(len=*), intent(in) :: standard_name + character(len=*), intent(in) :: units + logical, target, intent(in) :: ptr(:,:,:,:,:,:,:) + integer, intent( out) :: ierr + + ierr = 0 + call ccpp_field_add_ptr(cdata, standard_name, units, & + c_loc(ptr), size(ptr), shape(ptr), ierr=ierr) + + end subroutine ccpp_fields_add_l_7 + !------------------------------------------------------------------! !> !! Single precision (32-bit) integer field retrieval subroutines. @@ -700,15 +1000,10 @@ subroutine ccpp_fields_get_i32_3(cdata, standard_name, ptr, ierr, units) end subroutine ccpp_fields_get_i32_3 - !------------------------------------------------------------------! - !> - !! Double precision (64-bit) integer field retrieval subroutines. - ! - !------------------------------------------------------------------! - subroutine ccpp_fields_get_i64_0(cdata, standard_name, ptr, ierr, units) + subroutine ccpp_fields_get_i32_4(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(in) :: cdata character(len=*), intent(in) :: standard_name - integer(kind=INT64), pointer, intent( out) :: ptr + integer(kind=INT32), pointer, intent( out) :: ptr(:,:,:,:) integer, intent( out) :: ierr character(len=*), optional, intent( out) :: units @@ -722,18 +1017,18 @@ subroutine ccpp_fields_get_i64_0(cdata, standard_name, ptr, ierr, units) return end if - call c_f_pointer(cdata%fields(idx)%ptr, ptr) + call c_f_pointer(cdata%fields(idx)%ptr, ptr, cdata%fields(idx)%dims) if (present(units)) then units = cdata%fields(idx)%units end if - end subroutine ccpp_fields_get_i64_0 + end subroutine ccpp_fields_get_i32_4 - subroutine ccpp_fields_get_i64_1(cdata, standard_name, ptr, ierr, units) + subroutine ccpp_fields_get_i32_5(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(in) :: cdata character(len=*), intent(in) :: standard_name - integer(kind=INT64), pointer, intent( out) :: ptr(:) + integer(kind=INT32), pointer, intent( out) :: ptr(:,:,:,:,:) integer, intent( out) :: ierr character(len=*), optional, intent( out) :: units @@ -753,12 +1048,12 @@ subroutine ccpp_fields_get_i64_1(cdata, standard_name, ptr, ierr, units) units = cdata%fields(idx)%units end if - end subroutine ccpp_fields_get_i64_1 + end subroutine ccpp_fields_get_i32_5 - subroutine ccpp_fields_get_i64_2(cdata, standard_name, ptr, ierr, units) + subroutine ccpp_fields_get_i32_6(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(in) :: cdata character(len=*), intent(in) :: standard_name - integer(kind=INT64), pointer, intent( out) :: ptr(:,:) + integer(kind=INT32), pointer, intent( out) :: ptr(:,:,:,:,:,:) integer, intent( out) :: ierr character(len=*), optional, intent( out) :: units @@ -778,12 +1073,12 @@ subroutine ccpp_fields_get_i64_2(cdata, standard_name, ptr, ierr, units) units = cdata%fields(idx)%units end if - end subroutine ccpp_fields_get_i64_2 + end subroutine ccpp_fields_get_i32_6 - subroutine ccpp_fields_get_i64_3(cdata, standard_name, ptr, ierr, units) + subroutine ccpp_fields_get_i32_7(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(in) :: cdata character(len=*), intent(in) :: standard_name - integer(kind=INT64), pointer, intent( out) :: ptr(:,:,:) + integer(kind=INT32), pointer, intent( out) :: ptr(:,:,:,:,:,:,:) integer, intent( out) :: ierr character(len=*), optional, intent( out) :: units @@ -803,21 +1098,21 @@ subroutine ccpp_fields_get_i64_3(cdata, standard_name, ptr, ierr, units) units = cdata%fields(idx)%units end if - end subroutine ccpp_fields_get_i64_3 + end subroutine ccpp_fields_get_i32_7 !------------------------------------------------------------------! !> - !! Single precision (32-bit) real field retrieval subroutines. + !! Double precision (64-bit) integer field retrieval subroutines. ! !------------------------------------------------------------------! - subroutine ccpp_fields_get_r32_0(cdata, standard_name, ptr, ierr, units) - type(ccpp_t), intent(in) :: cdata - character(len=*), intent(in) :: standard_name - real(kind=REAL32), pointer, intent( out) :: ptr - integer, intent( out) :: ierr - character(len=*), optional, intent( out) :: units + subroutine ccpp_fields_get_i64_0(cdata, standard_name, ptr, ierr, units) + type(ccpp_t), intent(in) :: cdata + character(len=*), intent(in) :: standard_name + integer(kind=INT64), pointer, intent( out) :: ptr + integer, intent( out) :: ierr + character(len=*), optional, intent( out) :: units - integer :: idx + integer :: idx ierr = 0 ! Lookup the standard name in the index @@ -833,16 +1128,16 @@ subroutine ccpp_fields_get_r32_0(cdata, standard_name, ptr, ierr, units) units = cdata%fields(idx)%units end if - end subroutine ccpp_fields_get_r32_0 + end subroutine ccpp_fields_get_i64_0 - subroutine ccpp_fields_get_r32_1(cdata, standard_name, ptr, ierr, units) - type(ccpp_t), intent(in) :: cdata - character(len=*), intent(in) :: standard_name - real(kind=REAL32), pointer, intent( out) :: ptr(:) - integer, intent( out) :: ierr - character(len=*), optional, intent( out) :: units + subroutine ccpp_fields_get_i64_1(cdata, standard_name, ptr, ierr, units) + type(ccpp_t), intent(in) :: cdata + character(len=*), intent(in) :: standard_name + integer(kind=INT64), pointer, intent( out) :: ptr(:) + integer, intent( out) :: ierr + character(len=*), optional, intent( out) :: units - integer :: idx + integer :: idx ierr = 0 ! Lookup the standard name in the index @@ -858,11 +1153,216 @@ subroutine ccpp_fields_get_r32_1(cdata, standard_name, ptr, ierr, units) units = cdata%fields(idx)%units end if - end subroutine ccpp_fields_get_r32_1 + end subroutine ccpp_fields_get_i64_1 - subroutine ccpp_fields_get_r32_2(cdata, standard_name, ptr, ierr, units) - type(ccpp_t), intent(in) :: cdata - character(len=*), intent(in) :: standard_name + subroutine ccpp_fields_get_i64_2(cdata, standard_name, ptr, ierr, units) + type(ccpp_t), intent(in) :: cdata + character(len=*), intent(in) :: standard_name + integer(kind=INT64), pointer, intent( out) :: ptr(:,:) + integer, intent( out) :: ierr + character(len=*), optional, intent( out) :: units + + integer :: idx + + ierr = 0 + ! Lookup the standard name in the index + idx = ccpp_fields_find(cdata, standard_name, ierr) + if (ierr /= 0) then + call ccpp_warn('Unable to find the requested field') + return + end if + + call c_f_pointer(cdata%fields(idx)%ptr, ptr, cdata%fields(idx)%dims) + + if (present(units)) then + units = cdata%fields(idx)%units + end if + + end subroutine ccpp_fields_get_i64_2 + + subroutine ccpp_fields_get_i64_3(cdata, standard_name, ptr, ierr, units) + type(ccpp_t), intent(in) :: cdata + character(len=*), intent(in) :: standard_name + integer(kind=INT64), pointer, intent( out) :: ptr(:,:,:) + integer, intent( out) :: ierr + character(len=*), optional, intent( out) :: units + + integer :: idx + + ierr = 0 + ! Lookup the standard name in the index + idx = ccpp_fields_find(cdata, standard_name, ierr) + if (ierr /= 0) then + call ccpp_warn('Unable to find the requested field') + return + end if + + call c_f_pointer(cdata%fields(idx)%ptr, ptr, cdata%fields(idx)%dims) + + if (present(units)) then + units = cdata%fields(idx)%units + end if + + end subroutine ccpp_fields_get_i64_3 + + subroutine ccpp_fields_get_i64_4(cdata, standard_name, ptr, ierr, units) + type(ccpp_t), intent(in) :: cdata + character(len=*), intent(in) :: standard_name + integer(kind=INT64), pointer, intent( out) :: ptr(:,:,:,:) + integer, intent( out) :: ierr + character(len=*), optional, intent( out) :: units + + integer :: idx + + ierr = 0 + ! Lookup the standard name in the index + idx = ccpp_fields_find(cdata, standard_name, ierr) + if (ierr /= 0) then + call ccpp_warn('Unable to find the requested field') + return + end if + + call c_f_pointer(cdata%fields(idx)%ptr, ptr, cdata%fields(idx)%dims) + + if (present(units)) then + units = cdata%fields(idx)%units + end if + + end subroutine ccpp_fields_get_i64_4 + + subroutine ccpp_fields_get_i64_5(cdata, standard_name, ptr, ierr, units) + type(ccpp_t), intent(in) :: cdata + character(len=*), intent(in) :: standard_name + integer(kind=INT64), pointer, intent( out) :: ptr(:,:,:,:,:) + integer, intent( out) :: ierr + character(len=*), optional, intent( out) :: units + + integer :: idx + + ierr = 0 + ! Lookup the standard name in the index + idx = ccpp_fields_find(cdata, standard_name, ierr) + if (ierr /= 0) then + call ccpp_warn('Unable to find the requested field') + return + end if + + call c_f_pointer(cdata%fields(idx)%ptr, ptr, cdata%fields(idx)%dims) + + if (present(units)) then + units = cdata%fields(idx)%units + end if + + end subroutine ccpp_fields_get_i64_5 + + subroutine ccpp_fields_get_i64_6(cdata, standard_name, ptr, ierr, units) + type(ccpp_t), intent(in) :: cdata + character(len=*), intent(in) :: standard_name + integer(kind=INT64), pointer, intent( out) :: ptr(:,:,:,:,:,:) + integer, intent( out) :: ierr + character(len=*), optional, intent( out) :: units + + integer :: idx + + ierr = 0 + ! Lookup the standard name in the index + idx = ccpp_fields_find(cdata, standard_name, ierr) + if (ierr /= 0) then + call ccpp_warn('Unable to find the requested field') + return + end if + + call c_f_pointer(cdata%fields(idx)%ptr, ptr, cdata%fields(idx)%dims) + + if (present(units)) then + units = cdata%fields(idx)%units + end if + + end subroutine ccpp_fields_get_i64_6 + + subroutine ccpp_fields_get_i64_7(cdata, standard_name, ptr, ierr, units) + type(ccpp_t), intent(in) :: cdata + character(len=*), intent(in) :: standard_name + integer(kind=INT64), pointer, intent( out) :: ptr(:,:,:,:,:,:,:) + integer, intent( out) :: ierr + character(len=*), optional, intent( out) :: units + + integer :: idx + + ierr = 0 + ! Lookup the standard name in the index + idx = ccpp_fields_find(cdata, standard_name, ierr) + if (ierr /= 0) then + call ccpp_warn('Unable to find the requested field') + return + end if + + call c_f_pointer(cdata%fields(idx)%ptr, ptr, cdata%fields(idx)%dims) + + if (present(units)) then + units = cdata%fields(idx)%units + end if + + end subroutine ccpp_fields_get_i64_7 + + !------------------------------------------------------------------! + !> + !! Single precision (32-bit) real field retrieval subroutines. + ! + !------------------------------------------------------------------! + subroutine ccpp_fields_get_r32_0(cdata, standard_name, ptr, ierr, units) + type(ccpp_t), intent(in) :: cdata + character(len=*), intent(in) :: standard_name + real(kind=REAL32), pointer, intent( out) :: ptr + integer, intent( out) :: ierr + character(len=*), optional, intent( out) :: units + + integer :: idx + + ierr = 0 + ! Lookup the standard name in the index + idx = ccpp_fields_find(cdata, standard_name, ierr) + if (ierr /= 0) then + call ccpp_warn('Unable to find the requested field') + return + end if + + call c_f_pointer(cdata%fields(idx)%ptr, ptr) + + if (present(units)) then + units = cdata%fields(idx)%units + end if + + end subroutine ccpp_fields_get_r32_0 + + subroutine ccpp_fields_get_r32_1(cdata, standard_name, ptr, ierr, units) + type(ccpp_t), intent(in) :: cdata + character(len=*), intent(in) :: standard_name + real(kind=REAL32), pointer, intent( out) :: ptr(:) + integer, intent( out) :: ierr + character(len=*), optional, intent( out) :: units + + integer :: idx + + ierr = 0 + ! Lookup the standard name in the index + idx = ccpp_fields_find(cdata, standard_name, ierr) + if (ierr /= 0) then + call ccpp_warn('Unable to find the requested field') + return + end if + + call c_f_pointer(cdata%fields(idx)%ptr, ptr, cdata%fields(idx)%dims) + + if (present(units)) then + units = cdata%fields(idx)%units + end if + + end subroutine ccpp_fields_get_r32_1 + + subroutine ccpp_fields_get_r32_2(cdata, standard_name, ptr, ierr, units) + type(ccpp_t), intent(in) :: cdata + character(len=*), intent(in) :: standard_name real(kind=REAL32), pointer, intent( out) :: ptr(:,:) integer, intent( out) :: ierr character(len=*), optional, intent( out) :: units @@ -910,6 +1410,106 @@ subroutine ccpp_fields_get_r32_3(cdata, standard_name, ptr, ierr, units) end subroutine ccpp_fields_get_r32_3 + subroutine ccpp_fields_get_r32_4(cdata, standard_name, ptr, ierr, units) + type(ccpp_t), intent(in) :: cdata + character(len=*), intent(in) :: standard_name + real(kind=REAL32), pointer, intent( out) :: ptr(:,:,:,:) + integer, intent( out) :: ierr + character(len=*), optional, intent( out) :: units + + integer :: idx + + ierr = 0 + ! Lookup the standard name in the index + idx = ccpp_fields_find(cdata, standard_name, ierr) + if (ierr /= 0) then + call ccpp_warn('Unable to find the requested field') + return + end if + + call c_f_pointer(cdata%fields(idx)%ptr, ptr, cdata%fields(idx)%dims) + + if (present(units)) then + units = cdata%fields(idx)%units + end if + + end subroutine ccpp_fields_get_r32_4 + + subroutine ccpp_fields_get_r32_5(cdata, standard_name, ptr, ierr, units) + type(ccpp_t), intent(in) :: cdata + character(len=*), intent(in) :: standard_name + real(kind=REAL32), pointer, intent( out) :: ptr(:,:,:,:,:) + integer, intent( out) :: ierr + character(len=*), optional, intent( out) :: units + + integer :: idx + + ierr = 0 + ! Lookup the standard name in the index + idx = ccpp_fields_find(cdata, standard_name, ierr) + if (ierr /= 0) then + call ccpp_warn('Unable to find the requested field') + return + end if + + call c_f_pointer(cdata%fields(idx)%ptr, ptr, cdata%fields(idx)%dims) + + if (present(units)) then + units = cdata%fields(idx)%units + end if + + end subroutine ccpp_fields_get_r32_5 + + subroutine ccpp_fields_get_r32_6(cdata, standard_name, ptr, ierr, units) + type(ccpp_t), intent(in) :: cdata + character(len=*), intent(in) :: standard_name + real(kind=REAL32), pointer, intent( out) :: ptr(:,:,:,:,:,:) + integer, intent( out) :: ierr + character(len=*), optional, intent( out) :: units + + integer :: idx + + ierr = 0 + ! Lookup the standard name in the index + idx = ccpp_fields_find(cdata, standard_name, ierr) + if (ierr /= 0) then + call ccpp_warn('Unable to find the requested field') + return + end if + + call c_f_pointer(cdata%fields(idx)%ptr, ptr, cdata%fields(idx)%dims) + + if (present(units)) then + units = cdata%fields(idx)%units + end if + + end subroutine ccpp_fields_get_r32_6 + + subroutine ccpp_fields_get_r32_7(cdata, standard_name, ptr, ierr, units) + type(ccpp_t), intent(in) :: cdata + character(len=*), intent(in) :: standard_name + real(kind=REAL32), pointer, intent( out) :: ptr(:,:,:,:,:,:,:) + integer, intent( out) :: ierr + character(len=*), optional, intent( out) :: units + + integer :: idx + + ierr = 0 + ! Lookup the standard name in the index + idx = ccpp_fields_find(cdata, standard_name, ierr) + if (ierr /= 0) then + call ccpp_warn('Unable to find the requested field') + return + end if + + call c_f_pointer(cdata%fields(idx)%ptr, ptr, cdata%fields(idx)%dims) + + if (present(units)) then + units = cdata%fields(idx)%units + end if + + end subroutine ccpp_fields_get_r32_7 + !------------------------------------------------------------------! !> !! Double precision (64-bit) real field retrieval subroutines. @@ -1015,6 +1615,106 @@ subroutine ccpp_fields_get_r64_3(cdata, standard_name, ptr, ierr, units) end subroutine ccpp_fields_get_r64_3 + subroutine ccpp_fields_get_r64_4(cdata, standard_name, ptr, ierr, units) + type(ccpp_t), intent(in) :: cdata + character(len=*), intent(in) :: standard_name + real(kind=REAL64), pointer, intent( out) :: ptr(:,:,:,:) + integer, intent( out) :: ierr + character(len=*), optional, intent( out) :: units + + integer :: idx + + ierr = 0 + ! Lookup the standard name in the index + idx = ccpp_fields_find(cdata, standard_name, ierr) + if (ierr /= 0) then + call ccpp_warn('Unable to find the requested field') + return + end if + + call c_f_pointer(cdata%fields(idx)%ptr, ptr, cdata%fields(idx)%dims) + + if (present(units)) then + units = cdata%fields(idx)%units + end if + + end subroutine ccpp_fields_get_r64_4 + + subroutine ccpp_fields_get_r64_5(cdata, standard_name, ptr, ierr, units) + type(ccpp_t), intent(in) :: cdata + character(len=*), intent(in) :: standard_name + real(kind=REAL64), pointer, intent( out) :: ptr(:,:,:,:,:) + integer, intent( out) :: ierr + character(len=*), optional, intent( out) :: units + + integer :: idx + + ierr = 0 + ! Lookup the standard name in the index + idx = ccpp_fields_find(cdata, standard_name, ierr) + if (ierr /= 0) then + call ccpp_warn('Unable to find the requested field') + return + end if + + call c_f_pointer(cdata%fields(idx)%ptr, ptr, cdata%fields(idx)%dims) + + if (present(units)) then + units = cdata%fields(idx)%units + end if + + end subroutine ccpp_fields_get_r64_5 + + subroutine ccpp_fields_get_r64_6(cdata, standard_name, ptr, ierr, units) + type(ccpp_t), intent(in) :: cdata + character(len=*), intent(in) :: standard_name + real(kind=REAL64), pointer, intent( out) :: ptr(:,:,:,:,:,:) + integer, intent( out) :: ierr + character(len=*), optional, intent( out) :: units + + integer :: idx + + ierr = 0 + ! Lookup the standard name in the index + idx = ccpp_fields_find(cdata, standard_name, ierr) + if (ierr /= 0) then + call ccpp_warn('Unable to find the requested field') + return + end if + + call c_f_pointer(cdata%fields(idx)%ptr, ptr, cdata%fields(idx)%dims) + + if (present(units)) then + units = cdata%fields(idx)%units + end if + + end subroutine ccpp_fields_get_r64_6 + + subroutine ccpp_fields_get_r64_7(cdata, standard_name, ptr, ierr, units) + type(ccpp_t), intent(in) :: cdata + character(len=*), intent(in) :: standard_name + real(kind=REAL64), pointer, intent( out) :: ptr(:,:,:,:,:,:,:) + integer, intent( out) :: ierr + character(len=*), optional, intent( out) :: units + + integer :: idx + + ierr = 0 + ! Lookup the standard name in the index + idx = ccpp_fields_find(cdata, standard_name, ierr) + if (ierr /= 0) then + call ccpp_warn('Unable to find the requested field') + return + end if + + call c_f_pointer(cdata%fields(idx)%ptr, ptr, cdata%fields(idx)%dims) + + if (present(units)) then + units = cdata%fields(idx)%units + end if + + end subroutine ccpp_fields_get_r64_7 + !------------------------------------------------------------------! !> !! Logical field retrieval subroutines. @@ -1119,6 +1819,106 @@ subroutine ccpp_fields_get_l_3(cdata, standard_name, ptr, ierr, units) end if end subroutine ccpp_fields_get_l_3 + + subroutine ccpp_fields_get_l_4(cdata, standard_name, ptr, ierr, units) + type(ccpp_t), intent(in) :: cdata + character(len=*), intent(in) :: standard_name + logical, pointer, intent( out) :: ptr(:,:,:,:) + integer, intent( out) :: ierr + character(len=*), optional, intent( out) :: units + + integer :: idx + + ierr = 0 + ! Lookup the standard name in the index + idx = ccpp_fields_find(cdata, standard_name, ierr) + if (ierr /= 0) then + call ccpp_warn('Unable to find the requested field') + return + end if + + call c_f_pointer(cdata%fields(idx)%ptr, ptr, cdata%fields(idx)%dims) + + if (present(units)) then + units = cdata%fields(idx)%units + end if + + end subroutine ccpp_fields_get_l_4 + + subroutine ccpp_fields_get_l_5(cdata, standard_name, ptr, ierr, units) + type(ccpp_t), intent(in) :: cdata + character(len=*), intent(in) :: standard_name + logical, pointer, intent( out) :: ptr(:,:,:,:,:) + integer, intent( out) :: ierr + character(len=*), optional, intent( out) :: units + + integer :: idx + + ierr = 0 + ! Lookup the standard name in the index + idx = ccpp_fields_find(cdata, standard_name, ierr) + if (ierr /= 0) then + call ccpp_warn('Unable to find the requested field') + return + end if + + call c_f_pointer(cdata%fields(idx)%ptr, ptr, cdata%fields(idx)%dims) + + if (present(units)) then + units = cdata%fields(idx)%units + end if + + end subroutine ccpp_fields_get_l_5 + + subroutine ccpp_fields_get_l_6(cdata, standard_name, ptr, ierr, units) + type(ccpp_t), intent(in) :: cdata + character(len=*), intent(in) :: standard_name + logical, pointer, intent( out) :: ptr(:,:,:,:,:,:) + integer, intent( out) :: ierr + character(len=*), optional, intent( out) :: units + + integer :: idx + + ierr = 0 + ! Lookup the standard name in the index + idx = ccpp_fields_find(cdata, standard_name, ierr) + if (ierr /= 0) then + call ccpp_warn('Unable to find the requested field') + return + end if + + call c_f_pointer(cdata%fields(idx)%ptr, ptr, cdata%fields(idx)%dims) + + if (present(units)) then + units = cdata%fields(idx)%units + end if + + end subroutine ccpp_fields_get_l_6 + + subroutine ccpp_fields_get_l_7(cdata, standard_name, ptr, ierr, units) + type(ccpp_t), intent(in) :: cdata + character(len=*), intent(in) :: standard_name + logical, pointer, intent( out) :: ptr(:,:,:,:,:,:,:) + integer, intent( out) :: ierr + character(len=*), optional, intent( out) :: units + + integer :: idx + + ierr = 0 + ! Lookup the standard name in the index + idx = ccpp_fields_find(cdata, standard_name, ierr) + if (ierr /= 0) then + call ccpp_warn('Unable to find the requested field') + return + end if + + call c_f_pointer(cdata%fields(idx)%ptr, ptr, cdata%fields(idx)%dims) + + if (present(units)) then + units = cdata%fields(idx)%units + end if + + end subroutine ccpp_fields_get_l_7 !------------------------------------------------------------------! end module ccpp_fields diff --git a/src/tests/suite_test_1.xml b/src/tests/suite_noop_1.xml similarity index 100% rename from src/tests/suite_test_1.xml rename to src/tests/suite_noop_1.xml diff --git a/src/tests/suite_test_2.xml b/src/tests/suite_noop_2.xml similarity index 100% rename from src/tests/suite_test_2.xml rename to src/tests/suite_noop_2.xml diff --git a/src/tests/suite_test_3.xml b/src/tests/suite_noop_3.xml similarity index 100% rename from src/tests/suite_test_3.xml rename to src/tests/suite_noop_3.xml diff --git a/src/tests/suite_test_4.xml b/src/tests/suite_noop_4.xml similarity index 100% rename from src/tests/suite_test_4.xml rename to src/tests/suite_noop_4.xml diff --git a/src/tests/suite_test_5.xml b/src/tests/suite_noop_5.xml similarity index 100% rename from src/tests/suite_test_5.xml rename to src/tests/suite_noop_5.xml diff --git a/src/tests/suite_test_6.xml b/src/tests/suite_noop_6.xml similarity index 100% rename from src/tests/suite_test_6.xml rename to src/tests/suite_noop_6.xml diff --git a/src/tests/test_dummy.f90 b/src/tests/test_check.f90 similarity index 100% rename from src/tests/test_dummy.f90 rename to src/tests/test_check.f90 From 906aaa6a8631d8231a85943bdb730bfb1db681ca Mon Sep 17 00:00:00 2001 From: Timothy Brown Date: Tue, 18 Apr 2017 22:43:36 -0600 Subject: [PATCH 2/6] Clean-up in prep for v0.0.1 release. A pretty big clean-up, hopefully getting ready for v0.0.1 release. Since we re-jigged the source tree (moving the schemes out), we don't need to use the cmake "add_sources()" function to push source files up to their parent scope. I'll leave the macro/function in for now. Renaming the toplevel tests to be examples. In moving the schemes up to the toplevel, I've renamed the check one and made it into it's own library. Going forward, each scheme should be it's own library. This means the application has to know where the library is so as to open it (i.e. LD_LIBRARY_PATH or RPATH). Since scheme should be it's own library, we don't dlopen() ourself and so there is no need to add the "-Wl,--export-dynamic" flag to the linker on Linux. A simple todo would be to make the library (dlopen() call), use the absolute path if provided. Adding the optional "lib" and "ver" attributes to the scheme element in the XSD (and a few XML files). Added a ccpp_ipd_init() and ccpp_ipd_fini() subroutines. - The init will dlopen() the library and dlsym() to find the function. - The fini closes the library. This is make sure we are able to call the scheme cap function when needed. Revamped the ccpp_ipd_run() subroutine to ONLY call the ONE scheme it was asked to call instead of looping over ALL schemes. We are putting the scheme calling logic into the hands of the caller. TODO: Possible to use c_funptr's instead of generic c_ptr and therefore expose the cap routines to Fortran... --- CMakeLists.txt | 9 +- README.md | 14 ++- examples/suite.xsd | 13 ++- examples/suite_EXAMPLE.xml | 10 +++ schemes/CMakeLists.txt | 18 ++-- schemes/check/CMakeLists.txt | 58 ++++++++++++- schemes/check/noop.f90 | 33 +++++++ schemes/check/test.f90 | 1 + src/CMakeLists.txt | 14 +-- src/ccpp.f90 | 18 +++- src/ccpp_ipd.c | 109 ++++++++++++++++++----- src/ccpp_ipd.f90 | 163 +++++++++++++++++++++++++++-------- src/ccpp_ipd.h | 8 +- src/ccpp_suite.f90 | 37 ++++++-- src/ccpp_types.f90 | 18 +++- src/tests/CMakeLists.txt | 26 +++--- src/tests/suite_check.xml | 2 +- src/tests/suite_noop_1.xml | 2 +- src/tests/suite_noop_2.xml | 2 +- src/tests/suite_noop_3.xml | 2 +- src/tests/suite_noop_4.xml | 10 +-- src/tests/suite_noop_5.xml | 4 +- src/tests/suite_noop_6.xml | 2 +- src/tests/test_check.f90 | 21 +++-- 24 files changed, 463 insertions(+), 131 deletions(-) create mode 100644 examples/suite_EXAMPLE.xml create mode 100644 schemes/check/noop.f90 diff --git a/CMakeLists.txt b/CMakeLists.txt index 756ec768..d6b58742 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,8 +11,6 @@ else(POLICY CMP0048) set(PROJECT_VERSION_PATCH 1) endif(POLICY CMP0048) -#string(TOLOWER ${CMAKE_PROJECT_NAME} PROJECT_NAME_LC) - #------------------------------------------------------------------------------ # Enable Fortran enable_language(Fortran) @@ -40,15 +38,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")) @@ -69,6 +62,8 @@ enable_testing() add_subdirectory(src) # Documentation add_subdirectory(doc) +# All schemes +add_subdirectory(schemes) #------------------------------------------------------------------------------ # Configure and enable packaging diff --git a/README.md b/README.md index b0a77c6b..23fea87e 100644 --- a/README.md +++ b/README.md @@ -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". @@ -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/). diff --git a/examples/suite.xsd b/examples/suite.xsd index ac5dcb85..b5e2ebc6 100644 --- a/examples/suite.xsd +++ b/examples/suite.xsd @@ -3,7 +3,16 @@ xmlns:xs="http://www.w3.org/2001/XMLSchema"> - + + + + + + + + + + @@ -11,7 +20,7 @@ - + diff --git a/examples/suite_EXAMPLE.xml b/examples/suite_EXAMPLE.xml new file mode 100644 index 00000000..2b808209 --- /dev/null +++ b/examples/suite_EXAMPLE.xml @@ -0,0 +1,10 @@ + + + + + + test + + + + diff --git a/schemes/CMakeLists.txt b/schemes/CMakeLists.txt index 74b67013..376db58e 100644 --- a/schemes/CMakeLists.txt +++ b/schemes/CMakeLists.txt @@ -1,9 +1,17 @@ #------------------------------------------------------------------------------ # Add all the physics schemes in their own sub-directory (a.k.a repos) -add_subdirectory(noop) -add_subdirectory(check) -add_subdirectory(scm) +#------------------------------------------------------------------------------ + +include(ExternalProject) #------------------------------------------------------------------------------ -# Push all the sources upwards -add_sources() +# The checker scheme +ExternalProject_Add( + check + SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/check" + PREFIX "check" + DOWNLOAD_COMMAND "" + UPDATE_COMMAND "" + INSTALL_COMMAND "" + CMAKE_ARGS -DCCPP_INCLUDE_DIRS=${CCPP_INCLUDE_DIRS} +) diff --git a/schemes/check/CMakeLists.txt b/schemes/check/CMakeLists.txt index 8f729fe2..a4166ef3 100644 --- a/schemes/check/CMakeLists.txt +++ b/schemes/check/CMakeLists.txt @@ -1,5 +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") +set_property(DIRECTORY PROPERTY INCLUDE_DIRECTORIES ${CCPP_INCLUDE_DIRS}) + + #------------------------------------------------------------------------------ # Set the sources -add_sources( +set(SOURCES test.f90 + noop.f90 ) + +add_library(check ${SOURCES}) +target_link_libraries(check LINK_PUBLIC ${LIBS} ${CMAKE_DL_LIBS}) +set_target_properties(check PROPERTIES VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR}) + diff --git a/schemes/check/noop.f90 b/schemes/check/noop.f90 new file mode 100644 index 00000000..b2312895 --- /dev/null +++ b/schemes/check/noop.f90 @@ -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 diff --git a/schemes/check/test.f90 b/schemes/check/test.f90 index f2985e54..84d226ef 100644 --- a/schemes/check/test.f90 +++ b/schemes/check/test.f90 @@ -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 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1de3ca4e..4c14979d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ # Set the sources -add_sources( +set(SOURCES ccpp.f90 ccpp_errors.f90 ccpp_fields.f90 @@ -29,13 +29,15 @@ 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}$${CMAKE_CURRENT_BINARY_DIR}" + CACHE FILEPATH "${PACKAGE} include directories") #------------------------------------------------------------------------------ # Add the tests diff --git a/src/ccpp.f90 b/src/ccpp.f90 index 47517765..6b91b199 100644 --- a/src/ccpp.f90 +++ b/src/ccpp.f90 @@ -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 @@ -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 @@ -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') diff --git a/src/ccpp_ipd.c b/src/ccpp_ipd.c index 990d1d4c..91ff7b0d 100644 --- a/src/ccpp_ipd.c +++ b/src/ccpp_ipd.c @@ -17,53 +17,79 @@ #include "ccpp_ipd.h" -#if 0 -static const char libname[] = "libccpp.so"; /* Library name */ -static const char version[] = "1"; /* Linux needs the ver num */ +/** Shared library prefix and suffix for different platforms **/ +static const char prefix[] = "lib"; +#if __APPLE__ +static const char suffix[] = ".dylib"; +#elif __unix__ +static const char suffix[] = ".so"; #endif /** - * IPD physics cap calling rouinte. + * IPD cap initialization routine. * - * @param[in] scheme The physics scheme name to call. - * @param[in] aip The aip_t fortran type. + * @param[in] scheme The scheme name to call. + * @param[in] lib The library continaing the physics scheme. + * @param[out] shdl The scheme function pointer handle. + * @param[out] lhdl The library handle. * @retval 0 If it was sucessful * @retval 1 If there was an error **/ int -ccpp_ipd_phy_cap(const char *scheme, void *aip) +ccpp_ipd_open(const char *scheme, const char *lib, const char *ver, + void **shdl, void **lhdl) { - void *hdl = NULL; - void (*f_ptr)(void *) = NULL; int i = 0; int n = 0; + const char cap[] = "_cap"; + char *library = NULL; char *scheme_cap = NULL; char *error = NULL; + /* Generate the library name with the platform suffix */ + n = (strlen(prefix) + strlen(lib) + strlen(suffix) + strlen(ver) +2) + *sizeof(char); + library = malloc(n); + memset(library, 0, n); + if (strcmp(ver, "") != 0) { + snprintf(library, n, "%s%s.%s%s", prefix, lib, ver, suffix); + } else { + snprintf(library, n, "%s%s%s", prefix, lib, suffix); + } + /* Generate the scheme cap function name */ - n = strlen(scheme); - scheme_cap = malloc(n+5); - memset(scheme_cap, 0, (n+5)*sizeof(char)); + n = (strlen(scheme) +strlen(cap) +1)*sizeof(char); + scheme_cap = malloc(n); + memset(scheme_cap, 0, n); for (i=0; i < n; ++i) { scheme_cap[i] = tolower(scheme[i]); } - strncat(scheme_cap, "_cap", n+5); + strncat(scheme_cap, cap, n); - /* Open a handle to ourself */ - hdl = dlopen(NULL, RTLD_NOW); - if (!hdl) { - errx(EX_SOFTWARE, "%s", dlerror()); + /* Open a handle to the library */ + *lhdl = dlopen(library, RTLD_NOW); + if (!*lhdl) { + warnx("%s", dlerror()); + return(EXIT_FAILURE); } - *(void **) (&f_ptr) = dlsym(hdl, scheme_cap); + dlerror(); + /* + *(void **)(&(*shdl)) = dlsym(*lhdl, scheme_cap); + */ + *(void **)shdl = dlsym(*lhdl, scheme_cap); if ((error = dlerror()) != NULL) { - errx(EX_SOFTWARE, "%s", error); + warnx("%s", error); + return(EXIT_FAILURE); } - /* Call the schemes cap subroutine */ - f_ptr(aip); + /* Free the library filename */ + if (library) { + free(library); + library = NULL; + } /* Free the scheme cap function name */ if (scheme_cap) { @@ -71,7 +97,46 @@ ccpp_ipd_phy_cap(const char *scheme, void *aip) scheme_cap = NULL; } - dlclose(hdl); + return(EXIT_SUCCESS); +} + +/** + * IPD library finialization routine. + * + * @param[in] lhdl The library handle. + * @retval 0 If it was sucessful + * @retval 1 If there was an error + **/ +int +ccpp_ipd_close(void **lhdl) +{ + char *error = NULL; + + dlerror(); + dlclose(lhdl); + if ((error = dlerror()) != NULL) { + warnx("%s", error); + return(EXIT_FAILURE); + } + + return(EXIT_SUCCESS); +} + +/** + * IPD cap calling routine. + * + * @param[in] s_ptr The scheme function pointer to call. + * @param[in] data The opaque ccpp_t data type to pass. + * @retval 0 If it was sucessful + * @retval 1 If there was an error + **/ +int +ccpp_ipd_cap(void **f_ptr, void **data) +{ + void (*fun)(void **) = *f_ptr; + + /* Call the schemes cap subroutine */ + fun(data); return(EXIT_SUCCESS); } diff --git a/src/ccpp_ipd.f90 b/src/ccpp_ipd.f90 index 7efcea43..76fb5de2 100644 --- a/src/ccpp_ipd.f90 +++ b/src/ccpp_ipd.f90 @@ -7,9 +7,9 @@ module ccpp_ipd use, intrinsic :: iso_c_binding, & - only: c_int32_t, c_char, c_ptr, c_loc + only: c_int32_t, c_char, c_ptr, c_loc, c_funptr use :: ccpp_types, & - only: ccpp_t + only: ccpp_t, ccpp_scheme_t use :: ccpp_errors, & only: ccpp_error use :: ccpp_strings, & @@ -18,21 +18,123 @@ module ccpp_ipd implicit none private - public :: ccpp_ipd_run + public :: ccpp_ipd_init, & + ccpp_ipd_fini, & + ccpp_ipd_run interface - integer(c_int32_t) & - function ccpp_ipd_phy_cap & - (scheme, cdata) & - bind(c, name='ccpp_ipd_phy_cap') - import :: c_char, c_int32_t, c_ptr - character(kind=c_char), dimension(*) :: scheme + integer(c_int32_t) & + function ccpp_ipd_open & + (name, library, version, shdl, lhdl) & + bind(c, name='ccpp_ipd_open') + import :: c_char, c_int32_t, c_ptr, c_funptr + character(kind=c_char), dimension(*) :: name + character(kind=c_char), dimension(*) :: library + character(kind=c_char), dimension(*) :: version + type(c_ptr) :: shdl + type(c_ptr) :: lhdl + end function ccpp_ipd_open + + integer(c_int32_t) & + function ccpp_ipd_close & + (lhdl) & + bind(c, name='ccpp_ipd_close') + import :: c_int32_t, c_ptr, c_funptr + type(c_ptr) :: lhdl + end function ccpp_ipd_close + + integer(c_int32_t) & + function ccpp_ipd_cap & + (shdl, cdata) & + bind(c, name='ccpp_ipd_cap') + import :: c_int32_t, c_ptr, c_funptr + type(c_ptr) :: shdl type(c_ptr) :: cdata - end function ccpp_ipd_phy_cap + end function ccpp_ipd_cap end interface contains + !> + !! IPD initialization subroutine. + !! + !! This loops over all defined schemes to obtain + !! a function pointer to them. + !! + !! @param[inout] cdata The CCPP data of type ccpp_t + !! @param[ out] ierr Integer error flag + ! + subroutine ccpp_ipd_init(cdata, ierr) + + type(ccpp_t), target, intent(inout) :: cdata + + integer :: ierr + integer :: i + integer :: j + integer :: k + + ierr = 0 + + do i=1, cdata%suite%ipds_max + do j=1, cdata%suite%ipds(i)%subcycles_max + do k=1, cdata%suite%ipds(i)%subcycles(j)%schemes_max + + associate (s => cdata%suite%ipds(i)%subcycles(j)%schemes(k)) + ierr = ccpp_ipd_open(ccpp_cstr(s%name), & + ccpp_cstr(s%library), & + ccpp_cstr(s%version), & + s%scheme_hdl, & + s%library_hdl) + if (ierr /= 0) then + call ccpp_error('A problem occured loading ' & + // trim(s%name) // ' from ' & + // trim(s%library)) + end if + end associate + + end do + end do + end do + + end subroutine ccpp_ipd_init + + !> + !! IPD finalization subroutine. + !! + !! This loops over all defined schemes to close + !! the handle to the scheme library + !! + !! @param[inout] cdata The CCPP data of type ccpp_t + !! @param[ out] ierr Integer error flag + ! + subroutine ccpp_ipd_fini(cdata, ierr) + + type(ccpp_t), target, intent(inout) :: cdata + + integer :: ierr + integer :: i + integer :: j + integer :: k + + ierr = 0 + + do i=1, cdata%suite%ipds_max + do j=1, cdata%suite%ipds(i)%subcycles_max + do k=1, cdata%suite%ipds(i)%subcycles(j)%schemes_max + + associate (s => cdata%suite%ipds(i)%subcycles(j)%schemes(k)) + ierr = ccpp_ipd_close(s%library_hdl) + if (ierr /= 0) then + call ccpp_error('A problem occured close ' & + // trim(s%library)) + end if + end associate + end do + end do + end do + + end subroutine ccpp_ipd_fini + !> !! The run subroutine for the IPD. This will call !! the various physics schemes as specified in the @@ -40,34 +142,19 @@ end function ccpp_ipd_phy_cap !! !! @param[inout] cdata The CCPP data of type ccpp_t ! - subroutine ccpp_ipd_run(cdata) - - type(ccpp_t), target, intent(inout) :: cdata - - integer :: ierr - integer :: i - integer :: j - integer :: k - character(len=:), pointer :: scheme - type(c_ptr) :: ptr - - ierr = 0 - - i = cdata%suite%ipd_n - - do j=1, cdata%suite%ipds(i)%subcycles_max - cdata%suite%ipds(i)%subcycles_n = j - do k=1, cdata%suite%ipds(i)%subcycles(j)%schemes_max - cdata%suite%ipds(i)%subcycles(j)%schemes_n = k - scheme => cdata%suite%ipds(i)%subcycles(j)%schemes(k) - ptr = c_loc(cdata) - ierr = ccpp_ipd_phy_cap(ccpp_cstr(scheme), ptr) - if (ierr /= 0) then - call ccpp_error('A problem occured calling ' & - // trim(scheme) // ' physics scheme') - end if - end do - end do + subroutine ccpp_ipd_run(scheme, cdata, ierr) + + type(ccpp_scheme_t), intent(in ) :: scheme + type(ccpp_t), target, intent(inout) :: cdata + integer, intent( out) :: ierr + + ierr = 0 + + ierr = ccpp_ipd_cap(scheme%scheme_hdl, c_loc(cdata)) + if (ierr /= 0) then + call ccpp_error('A problem occured calling '// & + trim(scheme%name) //' scheme') + end if end subroutine ccpp_ipd_run diff --git a/src/ccpp_ipd.h b/src/ccpp_ipd.h index 3e9b02dc..1f505bfb 100644 --- a/src/ccpp_ipd.h +++ b/src/ccpp_ipd.h @@ -14,8 +14,14 @@ extern "C" { #endif +/** IPD libaray and cap function initialization routine. **/ +int ccpp_ipd_open(const char *, const char *, const char *, void **, void **); + +/** IPD library finalization routine. **/ +int ccpp_ipd_close(void **); + /** IPD physics cap function call. **/ -int ccpp_ipd_phy_cap(const char *, void *); +int ccpp_ipd_cap(void **, void **); #ifdef __cplusplus } /* extern "C" */ diff --git a/src/ccpp_suite.f90 b/src/ccpp_suite.f90 index c20bb16e..a1ff47bd 100644 --- a/src/ccpp_suite.f90 +++ b/src/ccpp_suite.f90 @@ -16,8 +16,7 @@ module ccpp_suite private public :: ccpp_suite_init, & - ccpp_suite_fini, & - ccpp_suite_t + ccpp_suite_fini !> !! @brief Suite XML tags. @@ -32,6 +31,8 @@ module ccpp_suite character(len=*), parameter :: XML_ATT_NAME = "name" character(len=*), parameter :: XML_ATT_PART = "part" character(len=*), parameter :: XML_ATT_LOOP = "loop" + character(len=*), parameter :: XML_ATT_LIB = "lib" + character(len=*), parameter :: XML_ATT_VER = "ver" contains @@ -44,7 +45,6 @@ module ccpp_suite !! @param[ out] ierr Integer error flag. ! subroutine ccpp_suite_init(filename, suite, ierr) - implicit none character(len=*), intent(in) :: filename type(ccpp_suite_t), intent(inout) :: suite @@ -204,8 +204,14 @@ subroutine ccpp_suite_init(filename, suite, ierr) suite%ipds(i)%subcycles(j)%schemes_max = n allocate(suite%ipds(i)%subcycles(j)%schemes(n), stat=ierr) + if (ierr /= 0) then + call ccpp_error('Unable to allocate schemes') + return + end if + num_schemes_this_ipd_call = n - max_num_schemes_per_ipd_call = MAX ( max_num_schemes_per_ipd_call , num_schemes_this_ipd_call ) + max_num_schemes_per_ipd_call = max(max_num_schemes_per_ipd_call, & + num_schemes_this_ipd_call) ! Find the first scheme ierr = ccpp_xml_ele_find(subcycle, ccpp_cstr(XML_ELE_SCHEME), & @@ -214,7 +220,26 @@ subroutine ccpp_suite_init(filename, suite, ierr) ! Loop over all scheme do k=1, suite%ipds(i)%subcycles(j)%schemes_max ierr = ccpp_xml_ele_contents(scheme, tmp) - suite%ipds(i)%subcycles(j)%schemes(k) = ccpp_fstr(tmp) + suite%ipds(i)%subcycles(j)%schemes(k)%name = ccpp_fstr(tmp) + + ! See if we have a different library name + ierr = ccpp_xml_ele_att(scheme, ccpp_cstr(XML_ATT_LIB), tmp) + if (ierr /= 0) then + suite%ipds(i)%subcycles(j)%schemes(k)%library = & + suite%ipds(i)%subcycles(j)%schemes(k)%name + else + suite%ipds(i)%subcycles(j)%schemes(k)%library = ccpp_fstr(tmp) + end if + + ! See if we have a library version + ierr = ccpp_xml_ele_att(scheme, ccpp_cstr(XML_ATT_VER), tmp) + if (ierr == 0) then + suite%ipds(i)%subcycles(j)%schemes(k)%version = & + ccpp_fstr(tmp) + else + suite%ipds(i)%subcycles(j)%schemes(k)%version = '' + end if + ! Find the next scheme ierr = ccpp_xml_ele_next(scheme, ccpp_cstr(XML_ELE_SCHEME), & scheme) @@ -241,7 +266,7 @@ subroutine ccpp_suite_init(filename, suite, ierr) write(*, '(A, I4, A, I4)') 'subcycle: ', j, ' loop: ', suite%ipds(i)%subcycles(j)%loop write(*, '(A, I4)') 'schemes: ', suite%ipds(i)%subcycles(j)%schemes_max do k=1, suite%ipds(i)%subcycles(j)%schemes_max - write(*, '(A, A)') 'scheme: ', trim(suite%ipds(i)%subcycles(j)%schemes(k)) + write(*, '(A, A)') 'scheme: ', trim(suite%ipds(i)%subcycles(j)%schemes(k)%name) end do end do end do diff --git a/src/ccpp_types.f90 b/src/ccpp_types.f90 index cda5ea1f..18f08e8e 100644 --- a/src/ccpp_types.f90 +++ b/src/ccpp_types.f90 @@ -8,7 +8,7 @@ module ccpp_types use, intrinsic :: iso_c_binding, & - only: c_ptr + only: c_ptr, c_funptr implicit none @@ -16,6 +16,7 @@ module ccpp_types public :: STR_LEN, & ccpp_t, & ccpp_field_t, & + ccpp_scheme_t, & ccpp_suite_t, & ccpp_ipd_t, & ccpp_subcycle_t @@ -38,6 +39,19 @@ module ccpp_types type(c_ptr) :: ptr end type ccpp_field_t + !> + !! @breif CCPP scheme type + !! + !! The scheme type contains all the scheme information. + ! + type :: ccpp_scheme_t + character(len=STR_LEN) :: name + character(len=STR_LEN) :: library + character(len=STR_LEN) :: version + type(c_ptr) :: scheme_hdl + type(c_ptr) :: library_hdl + end type ccpp_scheme_t + !> !! @breif CCPP subcycle type !! @@ -49,7 +63,7 @@ module ccpp_types integer :: loop integer :: schemes_max integer :: schemes_n - character(len=STR_LEN), allocatable, dimension(:) :: schemes + type(ccpp_scheme_t), allocatable, dimension(:) :: schemes end type ccpp_subcycle_t !> diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index cb83c505..41c938d4 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -4,25 +4,27 @@ add_executable(test_init_fini test_init_fini.f90) target_link_libraries(test_init_fini ccpp) -add_executable(test_dummy test_dummy.f90) -target_link_libraries(test_dummy ccpp) - add_executable(test_fields test_fields.c) target_link_libraries(test_fields ccpp) +add_executable(test_check test_check.f90) +target_link_libraries(test_check ccpp) + + #------------------------------------------------------------------------------ # Run all the tests # Make sure we can accept valid xml suites -add_test(XML_1 test_init_fini ${CMAKE_CURRENT_SOURCE_DIR}/suite_test_1.xml) -add_test(XML_2 test_init_fini ${CMAKE_CURRENT_SOURCE_DIR}/suite_test_2.xml) -add_test(XML_3 test_init_fini ${CMAKE_CURRENT_SOURCE_DIR}/suite_test_3.xml) -add_test(XML_4 test_init_fini ${CMAKE_CURRENT_SOURCE_DIR}/suite_test_4.xml) -add_test(XML_5 test_init_fini ${CMAKE_CURRENT_SOURCE_DIR}/suite_test_5.xml) -add_test(XML_6 test_init_fini ${CMAKE_CURRENT_SOURCE_DIR}/suite_test_6.xml) - -# Make sure we can do the physics cap call -add_test(DUMMY test_dummy ${CMAKE_CURRENT_SOURCE_DIR}/suite_check.xml) +add_test(XML_1 test_init_fini ${CMAKE_CURRENT_SOURCE_DIR}/suite_noop_1.xml) +add_test(XML_2 test_init_fini ${CMAKE_CURRENT_SOURCE_DIR}/suite_noop_2.xml) +add_test(XML_3 test_init_fini ${CMAKE_CURRENT_SOURCE_DIR}/suite_noop_3.xml) +add_test(XML_4 test_init_fini ${CMAKE_CURRENT_SOURCE_DIR}/suite_noop_4.xml) +add_test(XML_5 test_init_fini ${CMAKE_CURRENT_SOURCE_DIR}/suite_noop_5.xml) +add_test(XML_6 test_init_fini ${CMAKE_CURRENT_SOURCE_DIR}/suite_noop_6.xml) # Make sure we can grow the fields index add_test(FIELDS test_fields) + +# Make sure we can do the cap call +add_test(CHECK test_check ${CMAKE_CURRENT_SOURCE_DIR}/suite_check.xml) + diff --git a/src/tests/suite_check.xml b/src/tests/suite_check.xml index 07c579b2..a3b250a3 100644 --- a/src/tests/suite_check.xml +++ b/src/tests/suite_check.xml @@ -3,7 +3,7 @@ - test + test diff --git a/src/tests/suite_noop_1.xml b/src/tests/suite_noop_1.xml index 6566de39..e290f5af 100644 --- a/src/tests/suite_noop_1.xml +++ b/src/tests/suite_noop_1.xml @@ -3,7 +3,7 @@ - noop + noop diff --git a/src/tests/suite_noop_2.xml b/src/tests/suite_noop_2.xml index 028b84d6..0947f6f7 100644 --- a/src/tests/suite_noop_2.xml +++ b/src/tests/suite_noop_2.xml @@ -3,7 +3,7 @@ - noop + noop diff --git a/src/tests/suite_noop_3.xml b/src/tests/suite_noop_3.xml index 69e56dbe..0e94ed40 100644 --- a/src/tests/suite_noop_3.xml +++ b/src/tests/suite_noop_3.xml @@ -3,7 +3,7 @@ - noop + noop diff --git a/src/tests/suite_noop_4.xml b/src/tests/suite_noop_4.xml index 08884788..fbe44e9a 100644 --- a/src/tests/suite_noop_4.xml +++ b/src/tests/suite_noop_4.xml @@ -3,19 +3,19 @@ - noop + noop - noop + noop - noop - noop - noop + noop + noop + noop diff --git a/src/tests/suite_noop_5.xml b/src/tests/suite_noop_5.xml index 761ddc5e..f7ad6346 100644 --- a/src/tests/suite_noop_5.xml +++ b/src/tests/suite_noop_5.xml @@ -3,10 +3,10 @@ - noop + noop - noop + noop diff --git a/src/tests/suite_noop_6.xml b/src/tests/suite_noop_6.xml index ede1f06e..8ce3cf65 100644 --- a/src/tests/suite_noop_6.xml +++ b/src/tests/suite_noop_6.xml @@ -2,7 +2,7 @@ - noop + noop diff --git a/src/tests/test_check.f90 b/src/tests/test_check.f90 index 5aa30278..3f6feded 100644 --- a/src/tests/test_check.f90 +++ b/src/tests/test_check.f90 @@ -1,7 +1,7 @@ !> !! @brief A Test Atmospheric Driver Program. !! -program test_dummy +program test_check use, intrinsic :: iso_c_binding, & only: c_loc, c_f_pointer @@ -32,8 +32,7 @@ program test_dummy call get_command_argument(1, filename, len, ierr) if (ierr /= 0) then - print *, 'Error: no suite XML file specified.' - stop + call exit(1) end if ! Allocate the data @@ -41,16 +40,19 @@ program test_dummy allocate(surf_t(asize), stat=ierr) if (ierr /= 0) then print *, 'Unable to allocate surface temperature array' + call exit(1) end if allocate(u(asize,asize,asize), stat=ierr) if (ierr /= 0) then print *, 'Unable to allocate U array' + call exit(1) end if allocate(v(asize,asize,asize), stat=ierr) if (ierr /= 0) then print *, 'Unable to allocate U array' + call exit(1) end if ! Generate data to pass into a physics driver @@ -61,9 +63,15 @@ program test_dummy ! Initalize the CCPP (with the filename of the suite to load). call ccpp_init(filename, cdata, ierr) + if (ierr /= 0) then + call exit(1) + end if ! Add all the fields we want to expose to the physics driver. call ccpp_fields_add(cdata, 'gravity', 'm s-2', gravity, ierr) + if (ierr /= 0) then + call exit(1) + end if call ccpp_fields_add(cdata, 'surface_temperature', 'K', surf_t, ierr) @@ -71,10 +79,7 @@ program test_dummy call ccpp_fields_add(cdata, 'northward_wind', 'm s-1', v, ierr) - do ipd_loop = 1, cdata%suite%ipds_max - cdata%suite%ipd_n = ipd_loop - call ccpp_ipd_run(cdata) - end do + call ccpp_ipd_run(cdata%suite%ipds(1)%subcycles(1)%schemes(1), cdata, ierr) print *, 'In test dummy main' print *, 'gravity: ', gravity @@ -82,4 +87,4 @@ program test_dummy print *, 'u: ', u(1,1,1) print *, 'v: ', v(1,1,1) -end program test_dummy +end program test_check From e596e2328cf0ec26b2df78c0f9d59047763ecc63 Mon Sep 17 00:00:00 2001 From: "Timothy P. Brown" Date: Wed, 19 Apr 2017 11:17:40 -0600 Subject: [PATCH 3/6] Cleaning up the CMakeLists.txt files. Cleaned up the cmake files so the program builds on OS X. Also changed the return variable from pathconf() to long, as it's meant to be, to keep gcc happy. --- schemes/CMakeLists.txt | 2 ++ schemes/check/CMakeLists.txt | 6 +++--- src/CMakeLists.txt | 3 +++ src/ccpp_utils.c | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/schemes/CMakeLists.txt b/schemes/CMakeLists.txt index 376db58e..9e31b982 100644 --- a/schemes/CMakeLists.txt +++ b/schemes/CMakeLists.txt @@ -8,10 +8,12 @@ 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} ) diff --git a/schemes/check/CMakeLists.txt b/schemes/check/CMakeLists.txt index a4166ef3..7d4853e3 100644 --- a/schemes/check/CMakeLists.txt +++ b/schemes/check/CMakeLists.txt @@ -44,8 +44,8 @@ set_property(DIRECTORY PROPERTY INCLUDE_DIRECTORIES ${CCPP_INCLUDE_DIRS}) #------------------------------------------------------------------------------ # Add the CCPP library set(CCPP_LIB_DIRS "" CACHE FILEPATH "Path to ccpp library") -set_property(DIRECTORY PROPERTY INCLUDE_DIRECTORIES ${CCPP_INCLUDE_DIRS}) - +link_directories(${CCPP_LIB_DIRS}) +list(APPEND LIBS "ccpp") #------------------------------------------------------------------------------ # Set the sources @@ -55,7 +55,7 @@ set(SOURCES ) add_library(check ${SOURCES}) -target_link_libraries(check LINK_PUBLIC ${LIBS} ${CMAKE_DL_LIBS}) +target_link_libraries(check LINK_PUBLIC ${LIBS}) set_target_properties(check PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4c14979d..9083b8f8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -38,6 +38,9 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}) set(${PACKAGE}_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}$${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 diff --git a/src/ccpp_utils.c b/src/ccpp_utils.c index 32258439..84c1ecef 100644 --- a/src/ccpp_utils.c +++ b/src/ccpp_utils.c @@ -26,7 +26,7 @@ int ccpp_abs_path(const char *rel, char **abs) { - size_t bsize = 0; + long bsize = 0; char *buf = NULL; struct stat sbuf = {0}; From 99a58dbbbcd51aa2d4b06910c2804474e07272e1 Mon Sep 17 00:00:00 2001 From: Timothy Brown Date: Wed, 19 Apr 2017 11:42:16 -0600 Subject: [PATCH 4/6] Removig the noop scheme cmake file. The NO-OP scheme has been rolled into the check scheme. --- schemes/noop/CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 schemes/noop/CMakeLists.txt diff --git a/schemes/noop/CMakeLists.txt b/schemes/noop/CMakeLists.txt deleted file mode 100644 index 61c83cf9..00000000 --- a/schemes/noop/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -#------------------------------------------------------------------------------ -# Set the sources -add_sources( -) From 279608dd90ce6b512c37a4a1019d03db390c648f Mon Sep 17 00:00:00 2001 From: Timothy Brown Date: Thu, 20 Apr 2017 08:45:32 -0600 Subject: [PATCH 5/6] Changes to SCM scheme and CCPP documentation. Changed the SCM physics package/scheme to and external project. Fixed errors in the doxygen documentation of CCPP routines. --- schemes/CMakeLists.txt | 14 ++++++++++ schemes/scm/CMakeLists.txt | 56 +++++++++++++++++++++++++++++++++++++- src/ccpp.f90 | 10 +++---- src/ccpp_fields.f90 | 28 +++++++++---------- src/ccpp_fields_idx.c | 40 +++++++++++++-------------- src/ccpp_ipd.c | 7 +++-- src/ccpp_ipd.f90 | 12 ++++---- src/ccpp_strings.f90 | 8 +++--- src/ccpp_suite.f90 | 12 ++++---- 9 files changed, 128 insertions(+), 59 deletions(-) diff --git a/schemes/CMakeLists.txt b/schemes/CMakeLists.txt index 9e31b982..011b3452 100644 --- a/schemes/CMakeLists.txt +++ b/schemes/CMakeLists.txt @@ -17,3 +17,17 @@ ExternalProject_Add( 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} +) diff --git a/schemes/scm/CMakeLists.txt b/schemes/scm/CMakeLists.txt index fa06585e..fe9a7d2a 100644 --- a/schemes/scm/CMakeLists.txt +++ b/schemes/scm/CMakeLists.txt @@ -1,6 +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 -add_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}) + diff --git a/src/ccpp.f90 b/src/ccpp.f90 index 6b91b199..22b2d03f 100644 --- a/src/ccpp.f90 +++ b/src/ccpp.f90 @@ -28,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 @@ -65,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 diff --git a/src/ccpp_fields.f90 b/src/ccpp_fields.f90 index c9fab044..c66a6300 100644 --- a/src/ccpp_fields.f90 +++ b/src/ccpp_fields.f90 @@ -206,8 +206,8 @@ end function ccpp_field_idx_max !> !! CCPP fields initialization 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_fields_init(cdata, ierr) type(ccpp_t), intent(inout) :: cdata @@ -236,8 +236,8 @@ end subroutine ccpp_fields_init !> !! CCPP fields 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_fields_fini(cdata, ierr) type(ccpp_t), intent(inout) :: cdata @@ -256,13 +256,13 @@ end subroutine ccpp_fields_fini !> !! CCPP fields addition subroutine. !! - !! @param[inout] cdata The ccpp_t type data. - !! @param[in ] standard_name The standard name for the data. - !! @param[in ] units The SI units for the data. - !! @param[in ] ptr A C pointer to the data. - !! @param[in ] p_rank Optional rank of the data. - !! @param[in ] p_dims Optional dimensions of the data. - !! @param[ out] ierr Integer error flag. + !! @param[in,out] cdata The ccpp_t type data. + !! @param[in ] standard_name The standard name for the data. + !! @param[in ] units The SI units for the data. + !! @param[in ] ptr A C pointer to the data. + !! @param[in ] p_rank Optional rank of the data. + !! @param[in ] p_dims Optional dimensions of the data. + !! @param[ out] ierr Integer error flag. ! subroutine ccpp_field_add_ptr(cdata, standard_name, units, ptr, & rank, dims, ierr) @@ -328,9 +328,9 @@ end subroutine ccpp_field_add_ptr !> !! CCPP find a fields location/array index by standard name. !! - !! @param[inout] cdata The ccpp_t type data. - !! @param[in ] standard_name The standard name for the data. - !! @param[ out] ierr Integer error flag. + !! @param[in,out] cdata The ccpp_t type data. + !! @param[in ] standard_name The standard name for the data. + !! @param[ out] ierr Integer error flag. ! function ccpp_fields_find(cdata, standard_name, ierr) result(location) type(ccpp_t), intent(in) :: cdata diff --git a/src/ccpp_fields_idx.c b/src/ccpp_fields_idx.c index 7a52360c..6da0aa15 100644 --- a/src/ccpp_fields_idx.c +++ b/src/ccpp_fields_idx.c @@ -52,9 +52,9 @@ cmp(const void *f1, const void *f2) * * Allocates an array for the field indices. * - * @param[inout] index The index array. - * @retval 0 If it was sucessful. - * @retval 1 If there was an error. + * @param[in,out] index The index array. + * @retval 0 If it was sucessful. + * @retval 1 If there was an error. **/ int ccpp_field_idx_init(void **index) @@ -85,8 +85,8 @@ ccpp_field_idx_init(void **index) * * Deallocates the field indices array. * - * @param[inout] index The index array. - * @retval 0 If it was sucessful. + * @param[in] index The index array. + * @retval 0 If it was sucessful. **/ int ccpp_field_idx_fini(void **index) @@ -115,10 +115,10 @@ ccpp_field_idx_fini(void **index) /** * Add/Insert a field into the index. * - * @param[in] name The name to add to the index array. - * @param[inout] index The index array. - * @retval > 0 The index location. - * @retval -1 If there was an error. + * @param[in] name The name to add to the index array. + * @param[in,out] index The index array. + * @retval > 0 The index location. + * @retval -1 If there was an error. **/ int ccpp_field_idx_add(const char *name, void **index) @@ -154,11 +154,10 @@ ccpp_field_idx_add(const char *name, void **index) /** * Find the index number of a field. * - * @param[in] name The field name to find the index array. - * @param[inout] index The index array. - * @retval > 0 The position in the index array of the - * requested field. - * @retval -1 If there was an error. + * @param[in] name The field name to find the index array. + * @param[in,out] index The index array. + * @retval > 0 The position in the index array of the requested field. + * @retval -1 If there was an error. **/ int ccpp_field_idx_find(const char *name, void **index) @@ -197,9 +196,8 @@ ccpp_field_idx_find(const char *name, void **index) * Sort the index by calling qsort() and using cmp() as the * comparison function. * - * @param[inout] index The index array. - - * @retval 0 If there was no error. + * @param[in,out] index The index array. + * @retval 0 If there was no error. **/ int ccpp_field_idx_sort(void **index) @@ -215,8 +213,8 @@ ccpp_field_idx_sort(void **index) /** * Grow the index field array. * - * @param[inout] index The index array. - * @retval 0 If there was no error. + * @param[in,out] index The index array. + * @retval 0 If there was no error. **/ int ccpp_field_idx_grow(void **index) @@ -241,8 +239,8 @@ ccpp_field_idx_grow(void **index) /** * Get the maximum number of fields the index array can hold. * - * @param[inout] index The index array. - * @retval >= 0 The maximum number of fields. + * @param[in,out] index The index array. + * @retval >= 0 The maximum number of fields. **/ int ccpp_field_idx_max(void **index) diff --git a/src/ccpp_ipd.c b/src/ccpp_ipd.c index 91ff7b0d..3a5cc766 100644 --- a/src/ccpp_ipd.c +++ b/src/ccpp_ipd.c @@ -30,10 +30,11 @@ static const char suffix[] = ".so"; * * @param[in] scheme The scheme name to call. * @param[in] lib The library continaing the physics scheme. + * @param[in] ver The library version number. * @param[out] shdl The scheme function pointer handle. * @param[out] lhdl The library handle. - * @retval 0 If it was sucessful - * @retval 1 If there was an error + * @retval 0 If it was sucessful + * @retval 1 If there was an error **/ int ccpp_ipd_open(const char *scheme, const char *lib, const char *ver, @@ -125,7 +126,7 @@ ccpp_ipd_close(void **lhdl) /** * IPD cap calling routine. * - * @param[in] s_ptr The scheme function pointer to call. + * @param[in] f_ptr The scheme function pointer to call. * @param[in] data The opaque ccpp_t data type to pass. * @retval 0 If it was sucessful * @retval 1 If there was an error diff --git a/src/ccpp_ipd.f90 b/src/ccpp_ipd.f90 index 76fb5de2..45c4d8da 100644 --- a/src/ccpp_ipd.f90 +++ b/src/ccpp_ipd.f90 @@ -61,8 +61,8 @@ end function ccpp_ipd_cap !! This loops over all defined schemes to obtain !! a function pointer to them. !! - !! @param[inout] cdata The CCPP data of type ccpp_t - !! @param[ out] ierr Integer error flag + !! @param[in,out] cdata The CCPP data of type ccpp_t + !! @param[ out] ierr Integer error flag ! subroutine ccpp_ipd_init(cdata, ierr) @@ -104,8 +104,8 @@ end subroutine ccpp_ipd_init !! This loops over all defined schemes to close !! the handle to the scheme library !! - !! @param[inout] cdata The CCPP data of type ccpp_t - !! @param[ out] ierr Integer error flag + !! @param[in,out] cdata The CCPP data of type ccpp_t + !! @param[ out] ierr Integer error flag ! subroutine ccpp_ipd_fini(cdata, ierr) @@ -140,7 +140,9 @@ end subroutine ccpp_ipd_fini !! the various physics schemes as specified in the !! suite data. !! - !! @param[inout] cdata The CCPP data of type ccpp_t + !! @param[in ] scheme The scheme to run + !! @param[in,out] cdata The CCPP data of type ccpp_t + !! @param[ out] ierr Integer error flag ! subroutine ccpp_ipd_run(scheme, cdata, ierr) diff --git a/src/ccpp_strings.f90 b/src/ccpp_strings.f90 index 19ffee9c..4b8cb7ac 100644 --- a/src/ccpp_strings.f90 +++ b/src/ccpp_strings.f90 @@ -34,8 +34,8 @@ end function strlen !! !! This function is needed to pass C char arrays to Fortran. !! - !! \param[in] str1 The character array. - !! \returns str2 The fortran string. + !! @param[in] str1 The character array. + !! @returns str2 The fortran string. ! function ccpp_fstr(str1) result(str2) type(c_ptr), intent(in) :: str1 @@ -68,8 +68,8 @@ end function ccpp_fstr !! !! This function is needed to pass Fortran strings to C. !! - !! \param[in] str1 The fortran string. - !! \returns str2 The trimmed, null terminated string. + !! @param[in] str1 The fortran string. + !! @returns str2 The trimmed, null terminated string. ! function ccpp_cstr(str1) result(str2) character(len=*) :: str1 diff --git a/src/ccpp_suite.f90 b/src/ccpp_suite.f90 index a1ff47bd..b39395d2 100644 --- a/src/ccpp_suite.f90 +++ b/src/ccpp_suite.f90 @@ -39,10 +39,10 @@ module ccpp_suite !> !! Suite initialization subroutine. !! - !! @param[in] filename The file name of the XML scheme file to load. - !! @param[inout] suite The suite_t type to initalize from the scheme + !! @param[in] filename The file name of the XML scheme file to load. + !! @param[in,out] suite The suite_t type to initalize from the scheme !! XML file. - !! @param[ out] ierr Integer error flag. + !! @param[ out] ierr Integer error flag. ! subroutine ccpp_suite_init(filename, suite, ierr) @@ -278,9 +278,9 @@ end subroutine ccpp_suite_init !> !! Suite finalization subroutine. !! - !! @param[inout] suite The suite_t type to initalize from the scheme - !! XML file. - !! @param[ out] ierr Integer error flag. + !! @param[in,out] suite The suite_t type to initalize from the scheme + !! XML file. + !! @param[ out] ierr Integer error flag. ! subroutine ccpp_suite_fini(suite, ierr) type(ccpp_suite_t), intent(inout) :: suite From 9b66dac35dea801bd8d8fc0c1e41161fe98d9864 Mon Sep 17 00:00:00 2001 From: Timothy Brown Date: Thu, 20 Apr 2017 09:22:06 -0600 Subject: [PATCH 6/6] Making units optional for fields. Since the retrieval of a field the units is an optional parameter. I've changed the adding a field to make the units an optional parameter too. --- src/ccpp_fields.f90 | 164 +++++++++++++++++++-------------------- src/tests/test_check.f90 | 8 +- 2 files changed, 86 insertions(+), 86 deletions(-) diff --git a/src/ccpp_fields.f90 b/src/ccpp_fields.f90 index c66a6300..15a49672 100644 --- a/src/ccpp_fields.f90 +++ b/src/ccpp_fields.f90 @@ -11,8 +11,8 @@ !! @code{.f90} !! !! ! Add a field, for example the eastward_wind. -!! call ccpp_fields_add(ipd_data, 'eastward_wind', 'm s-1', & -!! u, ierr) +!! call ccpp_fields_add(ipd_data, 'eastward_wind', & +!! u, ierr, 'm s-1') !! if (ierr /= 0) then !! call exit(ierr) !! end if @@ -355,12 +355,12 @@ end function ccpp_fields_find !! Single precision (32-bit) integer field addition subroutines. ! !------------------------------------------------------------------! - subroutine ccpp_fields_add_i32_0(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_i32_0(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units integer(kind=INT32), target, intent(in) :: ptr integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -368,12 +368,12 @@ subroutine ccpp_fields_add_i32_0(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_i32_0 - subroutine ccpp_fields_add_i32_1(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_i32_1(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units integer(kind=INT32), target, intent(in) :: ptr(:) integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -381,12 +381,12 @@ subroutine ccpp_fields_add_i32_1(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_i32_1 - subroutine ccpp_fields_add_i32_2(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_i32_2(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units integer(kind=INT32), target, intent(in) :: ptr(:,:) integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -394,12 +394,12 @@ subroutine ccpp_fields_add_i32_2(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_i32_2 - subroutine ccpp_fields_add_i32_3(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_i32_3(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units integer(kind=INT32), target, intent(in) :: ptr(:,:,:) integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -407,12 +407,12 @@ subroutine ccpp_fields_add_i32_3(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_i32_3 - subroutine ccpp_fields_add_i32_4(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_i32_4(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units integer(kind=INT32), target, intent(in) :: ptr(:,:,:,:) integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -420,12 +420,12 @@ subroutine ccpp_fields_add_i32_4(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_i32_4 - subroutine ccpp_fields_add_i32_5(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_i32_5(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units integer(kind=INT32), target, intent(in) :: ptr(:,:,:,:,:) integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -433,12 +433,12 @@ subroutine ccpp_fields_add_i32_5(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_i32_5 - subroutine ccpp_fields_add_i32_6(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_i32_6(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units integer(kind=INT32), target, intent(in) :: ptr(:,:,:,:,:,:) integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -446,12 +446,12 @@ subroutine ccpp_fields_add_i32_6(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_i32_6 - subroutine ccpp_fields_add_i32_7(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_i32_7(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units integer(kind=INT32), target, intent(in) :: ptr(:,:,:,:,:,:,:) integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -464,12 +464,12 @@ end subroutine ccpp_fields_add_i32_7 !! Double precision (64-bit) integer field addition subroutines. ! !------------------------------------------------------------------! - subroutine ccpp_fields_add_i64_0(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_i64_0(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units integer(kind=INT64), target, intent(in) :: ptr integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -477,12 +477,12 @@ subroutine ccpp_fields_add_i64_0(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_i64_0 - subroutine ccpp_fields_add_i64_1(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_i64_1(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units integer(kind=INT64), target, intent(in) :: ptr(:) integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -490,12 +490,12 @@ subroutine ccpp_fields_add_i64_1(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_i64_1 - subroutine ccpp_fields_add_i64_2(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_i64_2(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units integer(kind=INT64), target, intent(in) :: ptr(:,:) integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -503,12 +503,12 @@ subroutine ccpp_fields_add_i64_2(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_i64_2 - subroutine ccpp_fields_add_i64_3(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_i64_3(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units integer(kind=INT64), target, intent(in) :: ptr(:,:,:) integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -516,12 +516,12 @@ subroutine ccpp_fields_add_i64_3(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_i64_3 - subroutine ccpp_fields_add_i64_4(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_i64_4(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units integer(kind=INT64), target, intent(in) :: ptr(:,:,:,:) integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -529,12 +529,12 @@ subroutine ccpp_fields_add_i64_4(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_i64_4 - subroutine ccpp_fields_add_i64_5(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_i64_5(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units integer(kind=INT64), target, intent(in) :: ptr(:,:,:,:,:) integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -542,12 +542,12 @@ subroutine ccpp_fields_add_i64_5(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_i64_5 - subroutine ccpp_fields_add_i64_6(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_i64_6(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units integer(kind=INT64), target, intent(in) :: ptr(:,:,:,:,:,:) integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -555,12 +555,12 @@ subroutine ccpp_fields_add_i64_6(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_i64_6 - subroutine ccpp_fields_add_i64_7(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_i64_7(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units integer(kind=INT64), target, intent(in) :: ptr(:,:,:,:,:,:,:) integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -573,12 +573,12 @@ end subroutine ccpp_fields_add_i64_7 !! Single precision (32-bit) real field addition subroutines. ! !------------------------------------------------------------------! - subroutine ccpp_fields_add_r32_0(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_r32_0(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units real(kind=REAL32), target, intent(in) :: ptr integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -586,12 +586,12 @@ subroutine ccpp_fields_add_r32_0(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_r32_0 - subroutine ccpp_fields_add_r32_1(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_r32_1(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units real(kind=REAL32), target, intent(in) :: ptr(:) integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -599,12 +599,12 @@ subroutine ccpp_fields_add_r32_1(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_r32_1 - subroutine ccpp_fields_add_r32_2(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_r32_2(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units real(kind=REAL32), target, intent(in) :: ptr(:,:) integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -612,12 +612,12 @@ subroutine ccpp_fields_add_r32_2(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_r32_2 - subroutine ccpp_fields_add_r32_3(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_r32_3(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units real(kind=REAL32), target, intent(in) :: ptr(:,:,:) integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -625,12 +625,12 @@ subroutine ccpp_fields_add_r32_3(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_r32_3 - subroutine ccpp_fields_add_r32_4(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_r32_4(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units real(kind=REAL32), target, intent(in) :: ptr(:,:,:,:) integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -638,12 +638,12 @@ subroutine ccpp_fields_add_r32_4(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_r32_4 - subroutine ccpp_fields_add_r32_5(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_r32_5(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units real(kind=REAL32), target, intent(in) :: ptr(:,:,:,:,:) integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -651,12 +651,12 @@ subroutine ccpp_fields_add_r32_5(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_r32_5 - subroutine ccpp_fields_add_r32_6(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_r32_6(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units real(kind=REAL32), target, intent(in) :: ptr(:,:,:,:,:,:) integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -664,12 +664,12 @@ subroutine ccpp_fields_add_r32_6(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_r32_6 - subroutine ccpp_fields_add_r32_7(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_r32_7(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units real(kind=REAL32), target, intent(in) :: ptr(:,:,:,:,:,:,:) integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -682,12 +682,12 @@ end subroutine ccpp_fields_add_r32_7 !! Double precision (64-bit) real field addition subroutines. ! !------------------------------------------------------------------! - subroutine ccpp_fields_add_r64_0(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_r64_0(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units real(kind=REAL64), target, intent(in) :: ptr integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -695,12 +695,12 @@ subroutine ccpp_fields_add_r64_0(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_r64_0 - subroutine ccpp_fields_add_r64_1(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_r64_1(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units real(kind=REAL64), target, intent(in) :: ptr(:) integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -708,12 +708,12 @@ subroutine ccpp_fields_add_r64_1(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_r64_1 - subroutine ccpp_fields_add_r64_2(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_r64_2(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units real(kind=REAL64), target, intent(in) :: ptr(:,:) integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -721,12 +721,12 @@ subroutine ccpp_fields_add_r64_2(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_r64_2 - subroutine ccpp_fields_add_r64_3(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_r64_3(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units real(kind=REAL64), target, intent(in) :: ptr(:,:,:) integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -734,12 +734,12 @@ subroutine ccpp_fields_add_r64_3(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_r64_3 - subroutine ccpp_fields_add_r64_4(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_r64_4(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units real(kind=REAL64), target, intent(in) :: ptr(:,:,:,:) integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -747,12 +747,12 @@ subroutine ccpp_fields_add_r64_4(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_r64_4 - subroutine ccpp_fields_add_r64_5(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_r64_5(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units real(kind=REAL64), target, intent(in) :: ptr(:,:,:,:,:) integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -760,12 +760,12 @@ subroutine ccpp_fields_add_r64_5(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_r64_5 - subroutine ccpp_fields_add_r64_6(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_r64_6(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units real(kind=REAL64), target, intent(in) :: ptr(:,:,:,:,:,:) integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -773,12 +773,12 @@ subroutine ccpp_fields_add_r64_6(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_r64_6 - subroutine ccpp_fields_add_r64_7(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_r64_7(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units real(kind=REAL64), target, intent(in) :: ptr(:,:,:,:,:,:,:) integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -791,12 +791,12 @@ end subroutine ccpp_fields_add_r64_7 !! Logical field addition subroutines. ! !------------------------------------------------------------------! - subroutine ccpp_fields_add_l_0(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_l_0(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units logical, target, intent(in) :: ptr integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -804,12 +804,12 @@ subroutine ccpp_fields_add_l_0(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_l_0 - subroutine ccpp_fields_add_l_1(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_l_1(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units logical, target, intent(in) :: ptr(:) integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -817,12 +817,12 @@ subroutine ccpp_fields_add_l_1(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_l_1 - subroutine ccpp_fields_add_l_2(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_l_2(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units logical, target, intent(in) :: ptr(:,:) integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -830,12 +830,12 @@ subroutine ccpp_fields_add_l_2(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_l_2 - subroutine ccpp_fields_add_l_3(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_l_3(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units logical, target, intent(in) :: ptr(:,:,:) integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -843,12 +843,12 @@ subroutine ccpp_fields_add_l_3(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_l_3 - subroutine ccpp_fields_add_l_4(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_l_4(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units logical, target, intent(in) :: ptr(:,:,:,:) integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -856,12 +856,12 @@ subroutine ccpp_fields_add_l_4(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_l_4 - subroutine ccpp_fields_add_l_5(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_l_5(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units logical, target, intent(in) :: ptr(:,:,:,:,:) integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -869,12 +869,12 @@ subroutine ccpp_fields_add_l_5(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_l_5 - subroutine ccpp_fields_add_l_6(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_l_6(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units logical, target, intent(in) :: ptr(:,:,:,:,:,:) integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & @@ -882,12 +882,12 @@ subroutine ccpp_fields_add_l_6(cdata, standard_name, units, ptr, ierr) end subroutine ccpp_fields_add_l_6 - subroutine ccpp_fields_add_l_7(cdata, standard_name, units, ptr, ierr) + subroutine ccpp_fields_add_l_7(cdata, standard_name, ptr, ierr, units) type(ccpp_t), intent(inout) :: cdata character(len=*), intent(in) :: standard_name - character(len=*), intent(in) :: units logical, target, intent(in) :: ptr(:,:,:,:,:,:,:) integer, intent( out) :: ierr + character(len=*), optional, intent(in) :: units ierr = 0 call ccpp_field_add_ptr(cdata, standard_name, units, & diff --git a/src/tests/test_check.f90 b/src/tests/test_check.f90 index 3f6feded..b0d5600e 100644 --- a/src/tests/test_check.f90 +++ b/src/tests/test_check.f90 @@ -68,16 +68,16 @@ program test_check end if ! Add all the fields we want to expose to the physics driver. - call ccpp_fields_add(cdata, 'gravity', 'm s-2', gravity, ierr) + call ccpp_fields_add(cdata, 'gravity', gravity, ierr, 'm s-2') if (ierr /= 0) then call exit(1) end if - call ccpp_fields_add(cdata, 'surface_temperature', 'K', surf_t, ierr) + call ccpp_fields_add(cdata, 'surface_temperature', surf_t, ierr, 'K') - call ccpp_fields_add(cdata, 'eastward_wind', 'm s-1', u, ierr) + call ccpp_fields_add(cdata, 'eastward_wind', u, ierr, 'm s-1') - call ccpp_fields_add(cdata, 'northward_wind', 'm s-1', v, ierr) + call ccpp_fields_add(cdata, 'northward_wind', v, ierr, 'm s-1') call ccpp_ipd_run(cdata%suite%ipds(1)%subcycles(1)%schemes(1), cdata, ierr)