diff --git a/generic3g/specs/FieldSpec.F90 b/generic3g/specs/FieldSpec.F90 index d388480a8cf6..b31f2d29f1dc 100644 --- a/generic3g/specs/FieldSpec.F90 +++ b/generic3g/specs/FieldSpec.F90 @@ -870,7 +870,8 @@ subroutine adapt_vertical_grid(this, spec, action, rc) v_out_coord, v_out_coupler, & ! output 'ignore', this%geom, this%typekind, this%units, this%vertical_dim_spec, _RC) action = VerticalRegridAction(v_in_coord, v_out_coupler, v_out_coord, v_out_coupler, this%regrid_method) - spec%vertical_grid = this%vertical_grid + if (allocated(spec%vertical_grid)) deallocate(spec%vertical_grid) + allocate(spec%vertical_grid, source=this%vertical_grid) spec%vertical_dim_spec = this%vertical_dim_spec end select diff --git a/generic3g/tests/CMakeLists.txt b/generic3g/tests/CMakeLists.txt index 73b5e2727b43..2072d35263ac 100644 --- a/generic3g/tests/CMakeLists.txt +++ b/generic3g/tests/CMakeLists.txt @@ -1,16 +1,11 @@ set(MODULE_DIRECTORY "${esma_include}/MAPL.generic3g/tests") -add_library(scratchpad SHARED scratchpad.F90) - add_subdirectory(gridcomps) set (test_srcs - Test_VirtualConnectionPt.pf - Test_SimpleLeafGridComp.pf - Test_SimpleParentGridComp.pf - Test_RunChild.pf + Test_ConfigurableGridComp.pf Test_AddFieldSpec.pf Test_ComponentSpecParser.pf @@ -40,18 +35,18 @@ set (test_srcs Test_MeanAction.pf Test_MaxAction.pf Test_MinAction.pf - ) - - -add_pfunit_ctest(MAPL.generic3g.tests - TEST_SOURCES ${test_srcs} - LINK_LIBRARIES MAPL.generic3g MAPL.shared MAPL.pfunit scratchpad - EXTRA_INITIALIZE Initialize - EXTRA_USE MAPL_pFUnit_Initialize - OTHER_SOURCES MockUserGridComp.F90 MockItemSpec.F90 accumulator_action_test_common.F90 - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - MAX_PES 4 - ) +) + +add_pfunit_ctest( + MAPL.generic3g.tests + TEST_SOURCES ${test_srcs} + LINK_LIBRARIES MAPL.generic3g MAPL.shared MAPL.pfunit configurable_gridcomp + EXTRA_INITIALIZE Initialize + EXTRA_USE MAPL_pFUnit_Initialize + OTHER_SOURCES MockUserGridComp.F90 MockItemSpec.F90 accumulator_action_test_common.F90 + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + MAX_PES 4 +) set_target_properties(MAPL.generic3g.tests PROPERTIES Fortran_MODULE_DIRECTORY ${MODULE_DIRECTORY}) set_tests_properties(MAPL.generic3g.tests PROPERTIES LABELS "ESSENTIAL") @@ -64,9 +59,10 @@ endif () # This test also requires UDUNITS2_XML_PATH to be set to the location of the udunits2.xml file # This is found by Findudunits.cmake and stored in the variable udunits_XML_PATH -set_tests_properties(MAPL.generic3g.tests - PROPERTIES ENVIRONMENT "${LD_PATH}=${CMAKE_CURRENT_BINARY_DIR}/gridcomps:$ENV{${LD_PATH}};UDUNITS2_XML_PATH=${udunits_XML_PATH}" - ) +set_tests_properties( + MAPL.generic3g.tests + PROPERTIES ENVIRONMENT "${LD_PATH}=${CMAKE_CURRENT_BINARY_DIR}/gridcomps:${CMAKE_BINARY_DIR}/lib:$ENV{${LD_PATH}};UDUNITS2_XML_PATH=${udunits_XML_PATH}" +) add_dependencies(build-tests MAPL.generic3g.tests) diff --git a/generic3g/tests/Test_SimpleParentGridComp.pf b/generic3g/tests/Test_ConfigurableGridComp.pf similarity index 96% rename from generic3g/tests/Test_SimpleParentGridComp.pf rename to generic3g/tests/Test_ConfigurableGridComp.pf index b39703da47d6..1b94038c8db8 100644 --- a/generic3g/tests/Test_SimpleParentGridComp.pf +++ b/generic3g/tests/Test_ConfigurableGridComp.pf @@ -1,5 +1,7 @@ #include "MAPL_TestErr.h" -module Test_SimpleParentGridComp + +module Test_ConfigurableGridComp + use mapl3g_GenericPhases use mapl3g_Generic use mapl3g_UserSetServices @@ -25,7 +27,7 @@ contains type(ESMF_GridComp), intent(inout) :: outer_gc type(MultiState), intent(out) :: states integer, intent(out) :: rc - + integer :: status, userRC type(ESMF_Grid) :: grid type(ESMF_HConfig) :: config @@ -44,7 +46,7 @@ contains call ESMF_TimeIntervalSet(dt, h=1) clock = ESMF_ClockCreate(dt, t) - outer_gc = create_grid_comp('P', user_setservices('libsimple_parent_gridcomp'), config, clock, _RC) + outer_gc = create_grid_comp('P', user_setservices('libconfigurable_gridcomp'), config, clock, _RC) call ESMF_GridCompSetServices(outer_gc, setServices, userRC=userRC, _RC) _VERIFY(userRC) grid = ESMF_GridCreateNoPeriDim(maxIndex=[4,4], name='I_AM_GROOT', _RC) @@ -55,7 +57,6 @@ contains associate (import => states%importState, export => states%exportState) import = ESMF_StateCreate(_RC) export = ESMF_StateCreate(_RC) - do i = 1, size(GENERIC_INIT_PHASE_SEQUENCE) associate (phase => GENERIC_INIT_PHASE_SEQUENCE(i)) call ESMF_GridCompInitialize(outer_gc, & @@ -64,21 +65,18 @@ contains _VERIFY(userRC) end associate end do - end associate - rc = 0 end subroutine setup - subroutine tearDown(outer_gc) type(ESMF_GridComp), intent(inout) :: outer_gc end subroutine tearDown - @test(npes=[0]) subroutine test_child_user_items_created(this) + class(MpiTestMethod), intent(inout) :: this integer :: status @@ -120,13 +118,13 @@ contains status = 1 - child_comp = outer_meta%get_child(child_name, rc=status) + child_comp = outer_meta%get_child(child_name, rc=status) if (status /= 0) then status = 2 return end if - - child_gc = child_comp%get_gridcomp() + + child_gc = child_comp%get_gridcomp() child_meta => get_outer_meta(child_gc) user_component => child_meta%get_user_gc_driver() states = user_component%get_states() @@ -145,14 +143,13 @@ contains end do status = 0 - end function check end subroutine test_child_user_items_created - @test(npes=[0]) subroutine test_child_outer_items_created(this) + class(MpiTestMethod), intent(inout) :: this integer :: status @@ -176,8 +173,8 @@ contains call get_field(f, states, state_intent='export', field_name='E_A1', rc=status) @assert_that(status, is(0)) call get_field(f, states, state_intent='internal', field_name='Z_A1', rc=status) - @assert_that(status, is(0)) - + @assert_that(status, is(0)) + call get_child_user_states(states, outer_meta, 'child_B', rc=status) @assert_that(status, is(0)) @@ -188,11 +185,6 @@ contains call get_field(f, states, state_intent='internal', field_name='Z_B1', rc=status) @assert_that(status, is(0)) -!!$ @assert_that('import', check('child_B', 'import', ['I_B1']), is(0)) -!!$ @assert_that('export', check('child_B', 'export', ['E_B1']), is(0)) -!!$ @assert_that('internal', check('child_B', 'internal', ['Z_B1']), is(0)) - - contains integer function check(child_name, state_intent, expected_items) result(status) @@ -215,7 +207,7 @@ contains status = 2 return end if - + child_gc = child_comp%get_gridcomp() child_meta => get_outer_meta(child_gc) user_component => child_meta%get_user_gc_driver() @@ -226,7 +218,7 @@ contains status = 3 return end if - + do i = 1, size(expected_items) call ESMF_StateGet(state, trim(expected_items(i)), f, rc=status) if (status /= 0) then @@ -236,13 +228,13 @@ contains end do status = 0 - end function check end subroutine test_child_outer_items_created @test(npes=[0]) subroutine test_parent_user_items_created(this) + class(MpiTestMethod), intent(inout) :: this integer :: status @@ -296,10 +288,12 @@ contains end if status = 0 end function check + end subroutine test_parent_user_items_created @test(npes=[0]) subroutine test_parent_outer_items_created(this) + class(MpiTestMethod), intent(inout) :: this integer :: status @@ -317,7 +311,6 @@ contains @assert_that(check(states, 'export', field_name='child_B/E_B1'), is(0)) @assert_that(check(states, 'export', field_name='child_B/Z_B1'), is(5)) - contains integer function check(states, state_intent, field_name) result(status) @@ -369,7 +362,6 @@ contains end if status = 0 - end function check end subroutine test_parent_outer_items_created @@ -393,14 +385,13 @@ contains rc = +2 return end if - + child_gc = child_comp%get_gridcomp() child_meta => get_outer_meta(child_gc, rc=status) user_component => child_meta%get_user_gc_driver() states = user_component%get_states() rc = 0 - end subroutine get_child_user_states subroutine get_field(field, states, state_intent, unusable, field_name, substate_name, rc) @@ -439,11 +430,11 @@ contains end if rc = 0 - end subroutine get_field @test(npes=[0]) subroutine test_state_items_complete(this) + class(MpiTestMethod), intent(inout) :: this integer :: status @@ -470,6 +461,7 @@ contains @assert_that(status, is(0)) if(.false.) print*,shape(this) + contains subroutine check(child_name, state_intent, item, expected_status, rc) @@ -492,7 +484,7 @@ contains call states%get_state(state, state_intent, rc=status) @assert_that(status, is(0)) - + call ESMF_StateGet(state, item, f, rc=status) @assert_that('Item <'//item//'> not found in child <'//child_name//'>.', status, is(0)) @@ -503,9 +495,8 @@ contains rc = 0 end subroutine check - - end subroutine test_state_items_complete + end subroutine test_state_items_complete @test(npes=[0]) subroutine test_propagate_imports(this) @@ -524,7 +515,6 @@ contains ! Child A import is unsatisfied, so it should propagate up call ESMF_StateGet(states%importState, 'I_A1(1)', f, rc=status) @assert_that('Expected unsatisfied import in parent.', status, is(0)) - end subroutine test_propagate_imports -end module Test_SimpleParentGridComp +end module Test_ConfigurableGridComp diff --git a/generic3g/tests/Test_RunChild.pf b/generic3g/tests/Test_RunChild.pf deleted file mode 100644 index 4b810e685980..000000000000 --- a/generic3g/tests/Test_RunChild.pf +++ /dev/null @@ -1,204 +0,0 @@ -#include "MAPL_TestErr.h" - -module Test_RunChild - use mapl3g_GenericGridComp - use mapl3g_Generic - use mapl3g_GriddedComponentDriver - use mapl3g_OuterMetaComponent - use mapl3g_UserSetServices - use mapl_ErrorHandling - use esmf - use pfunit - use scratchpad, only: log, clear_log - implicit none - - type(ESMF_GridComp) :: parent_gc - type(ESMF_GridComp) :: user_gc - type(OuterMetaComponent), pointer :: parent_meta - -contains - - ! Build a parent gc with 2 children. - subroutine setup(this, rc) - class(MpiTestMethod), intent(inout) :: this - integer, intent(out) :: rc - - type(ESMF_HConfig) :: config - type(GriddedComponentDriver) :: user_comp - integer :: status - type(ESMF_Time) :: t - type(ESMF_TimeInterval) :: dt - type(ESMF_Clock) :: clock - - call ESMF_TimeSet(t, h=0) - call ESMF_TimeIntervalSet(dt, h=1) - clock = ESMF_ClockCreate(dt, t) - - config = ESMF_HConfigCreate(content='{}', rc=status) - @assert_that(status, is(0)) - - associate (ss_parent => user_setservices('libsimple_parent_gridcomp')) - parent_gc = create_grid_comp('parent', ss_parent, config, clock, rc=status) - end associate - - @assert_that(status, is(0)) - parent_meta => get_outer_meta(parent_gc, rc=status) - @assert_that(status, is(0)) - - associate (ss_leaf => user_setservices('libsimple_leaf_gridcomp')) - call parent_meta%add_child('child_1', ss_leaf, config, rc=status) - @assert_that(status, is(0)) - call parent_meta%add_child('child_2', ss_leaf, config, rc=status) - @assert_that(status, is(0)) - end associate - - call ESMF_GridCompSetServices(parent_gc, setServices, rc=status) - @assert_that(status, is(0)) - - user_comp = parent_meta%get_user_gc_driver() - user_gc = user_comp%get_gridcomp() - - call ESMF_HConfigDestroy(config, rc=status) - @assert_that(status, is(0)) - - call clear_log() - rc = ESMF_SUCCESS - end subroutine setup - - subroutine teardown(this) - class(MpiTestMethod), intent(inout) :: this - integer :: status - call ESMF_GridCompDestroy(parent_gc, rc=status) - @assert_that(status, is(0)) - end subroutine teardown - - - @test(npes=[0]) - ! MAPL_RunChild() is called from withis _user_ gridcomps. - subroutine test_MAPL_RunChild(this) - class(MpiTestMethod), intent(inout) :: this - integer :: status - - call setup(this, rc=status) - @assert_that(status, is(0)) - call MAPL_RunChild(user_gc, child_name='child_1', rc=status) - @assert_that(status, is(0)) - @assertEqual("wasRun_child_1", log) - - call teardown(this) - - end subroutine test_MAPL_RunChild - - @test(npes=[0]) - subroutine test_MAPL_RunChild_other_phase(this) - class(MpiTestMethod), intent(inout) :: this - integer :: status - - call setup(this, rc=status) - @assert_that(status, is(0)) - - call MAPL_RunChild(user_gc, child_name='child_1', phase_name='extra', rc=status) - @assert_that(status, is(0)) - @assertEqual("wasRun_extra_child_1", log) - - call teardown(this) - - end subroutine test_MAPL_RunChild_other_phase - - @test(npes=[0]) - subroutine test_init_children(this) - class(MpiTestMethod), intent(inout) :: this - type(ESMF_State) :: importState, exportState - type(ESMF_Time) :: t - type(ESMF_TimeInterval) :: dt - type(ESMF_Clock) :: clock - - integer :: status - - call ESMF_TimeSet(t, h=0) - call ESMF_TimeIntervalSet(dt, h=1) - clock = ESMF_ClockCreate(dt, t) - - call setup(this, rc=status) - @assert_that(status, is(0)) - - call parent_meta%initialize_user(rc=status) - @assert_that(status, is(0)) - @assertEqual("wasInit :: wasInit_child_1 :: wasInit_child_2", log) - - call teardown(this) - - end subroutine test_init_children - - - @test(npes=[0]) - subroutine test_finalize_children(this) - class(MpiTestMethod), intent(inout) :: this - type(ESMF_State) :: importState, exportState - - integer :: status - type(ESMF_Time) :: t - type(ESMF_TimeInterval) :: dt - type(ESMF_Clock) :: clock - - call ESMF_TimeSet(t, h=0) - call ESMF_TimeIntervalSet(dt, h=1) - clock = ESMF_ClockCreate(dt, t) - - call setup(this, rc=status) - @assert_that(status, is(0)) - - call parent_meta%finalize(importState, exportState, clock, rc=status) - @assert_that(status, is(0)) - @assertEqual("wasFinal :: wasFinal_child_1 :: wasFinal_child_2", log) - - call teardown(this) - - end subroutine test_finalize_children - - @test(npes=[0]) - subroutine test_MAPL_invalid_name(this) - class(MpiTestMethod), intent(inout) :: this - - type(ESMF_HConfig) :: config - integer :: status - type(ESMF_Time) :: t - type(ESMF_TimeInterval) :: dt - type(ESMF_Clock) :: clock - - call ESMF_TimeSet(t, h=0) - call ESMF_TimeIntervalSet(dt, h=1) - clock = ESMF_ClockCreate(dt, t) - - config = ESMF_HConfigCreate(content='{}', rc=status) - @assert_that(status, is(0)) - - associate (ss_parent => user_setservices('libsimple_parent_gridcomp')) - parent_gc = create_grid_comp('parent', ss_parent, config, clock, rc=status) - end associate - @assert_that(status, is(0)) - parent_meta => get_outer_meta(parent_gc, rc=status) - @assert_that(status, is(0)) - user_gc = parent_meta%get_gridcomp() - - associate (ss_leaf => user_setservices('libsimple_leaf_gridcomp')) - ! Empty name - call parent_meta%add_child('', ss_leaf, config, rc=status) - @assertExceptionRaised('Child name <> does not conform to GEOS standards.') - - ! Illegal starting character - call parent_meta%add_child('1A', ss_leaf, config, rc=status) - @assertExceptionRaised('Child name <1A> does not conform to GEOS standards.') - - ! Illegal character: hyphen - call parent_meta%add_child('A-1', ss_leaf, config, rc=status) - @assertExceptionRaised('Child name does not conform to GEOS standards.') - - end associate - - call ESMF_HConfigDestroy(config, rc=status) - @assert_that(status, is(0)) - - end subroutine test_MAPL_invalid_name - -end module Test_RunChild diff --git a/generic3g/tests/Test_Scenarios.pf b/generic3g/tests/Test_Scenarios.pf index 9eede24bae4f..efb19aeff945 100644 --- a/generic3g/tests/Test_Scenarios.pf +++ b/generic3g/tests/Test_Scenarios.pf @@ -160,7 +160,7 @@ contains call ESMF_TimeIntervalSet(dt, h=1) clock = ESMF_ClockCreate(dt, t) - outer_gc = create_grid_comp('ROOT', user_setservices('libsimple_parent_gridcomp'), config, clock, _RC) + outer_gc = create_grid_comp('ROOT', user_setservices('libconfigurable_gridcomp'), config, clock, _RC) call ESMF_GridCompSetServices(outer_gc, generic_setServices, userRC=user_status, _RC) _VERIFY(user_status) diff --git a/generic3g/tests/Test_SimpleLeafGridComp.pf b/generic3g/tests/Test_SimpleLeafGridComp.pf deleted file mode 100644 index afb2d6b1c64c..000000000000 --- a/generic3g/tests/Test_SimpleLeafGridComp.pf +++ /dev/null @@ -1,216 +0,0 @@ -#include "MAPL_TestErr.h" -module Test_SimpleLeafGridComp - - use mapl3g_Generic - use mapl3g_GenericPhases - use mapl3g_UserSetServices - use mapl3g_GenericGridComp, only: create_grid_comp - use mapl3g_GenericGridComp, only: setServices - use mapl3g_OuterMetaComponent, only: OuterMetaComponent - use mapl3g_OuterMetaComponent, only: get_outer_meta - use mapl3g_BasicVerticalGrid - use esmf - use nuopc - use pFunit - use scratchpad - - implicit none - -contains - - subroutine setup(outer_gc, config, rc) - type(ESMF_GridComp), intent(inout) :: outer_gc - type(ESMF_HConfig), intent(in) :: config - integer, intent(out) :: rc - - integer :: status, userRC - type(ESMF_Time) :: t - type(ESMF_TimeInterval) :: dt - type(ESMF_Clock) :: clock - - call ESMF_TimeSet(t, h=0) - call ESMF_TimeIntervalSet(dt, h=1) - clock = ESMF_ClockCreate(dt, t) - outer_gc = create_grid_comp('A', user_setservices('libsimple_leaf_gridcomp'), config, clock, rc=status) - @assert_that(status, is(0)) - - call ESMF_GridCompSetServices(outer_gc, setServices, userRC=userRC, rc=status) - if (status /= 0) then - rc = status - return - end if - if (userRC /= 0) then - rc = userRC - return - end if - call clear_log() - rc = 0 - end subroutine setup - - subroutine tearDown(outer_gc, hconfig) - type(ESMF_GridComp), intent(inout) :: outer_gc - type(ESMF_HConfig), intent(inout) :: hconfig - - call clear_log() - call ESMF_HConfigDestroy(hconfig) - end subroutine tearDown - - @test(npes=[0]) - subroutine test_wasrun_1(this) - class(MpiTestMethod), intent(inout) :: this - - type(ESMF_HConfig) :: config - integer :: status, userRC - type(ESMF_GridComp) :: outer_gc - - config = ESMF_HConfigCreate(content='{}', rc=status) - call setup(outer_gc, config, status) - @assert_that('DSO problem', status, is(0)) - - call ESMF_GridCompRun(outer_gc, userRC=userRC, phase=GENERIC_RUN_USER, rc=status) - @assert_that(status, is(0)) - @assert_that(userRC, is(0)) - @assertEqual("wasRun_A", log) - - call teardown(outer_gc, config) - - if(.false.) print*,shape(this) - end subroutine test_wasrun_1 - - - ! Verify that an optional run phase in the user comp can be - ! exercised. Note at this level, we cannot use the phase_name to - ! specify the phase, so the unit test assumes the extra phase has - ! index=2. In real use cases, `run_child()` will be applied in - ! which case the phase_name is available. - - @test(npes=[0]) - subroutine test_wasrun_extra(this) - use scratchpad - class(MpiTestMethod), intent(inout) :: this - - integer :: status - type(ESMF_GridComp) :: outer_gc - type(ESMF_HConfig) :: config - - config = ESMF_HConfigCreate(content='{}', rc=status) - call setup(outer_gc, config, status) - @assert_that(status, is(0)) - - call ESMF_GridCompRun(outer_gc, phase=2, rc=status) - @assert_that(status, is(0)) - @assertEqual("wasRun_extra_A", log) - - call teardown(outer_gc, config) - if(.false.) print*,shape(this) - end subroutine test_wasrun_extra - - @test(npes=[0]) - subroutine test_wasinit(this) - use scratchpad - class(MpiTestMethod), intent(inout) :: this - - integer :: status - type(ESMF_GridComp) :: outer_gc - type(ESMF_HConfig) :: config - - config = ESMF_HConfigCreate(content='{}', rc=status) - call setup(outer_gc, config, status) - @assert_that(status, is(0)) - - call ESMF_GridCompInitialize(outer_gc, phase=GENERIC_INIT_USER, rc=status) - @assert_that(status, is(0)) - @assertEqual("wasInit_A", log) - - call teardown(outer_gc, config) - - if(.false.) print*,shape(this) - end subroutine test_wasinit - - @test(npes=[0]) - subroutine test_wasfinal(this) - use scratchpad - class(MpiTestMethod), intent(inout) :: this - - integer :: status - type(ESMF_GridComp) :: outer_gc - type(ESMF_HConfig) :: config - - config = ESMF_HConfigCreate(content='{}', rc=status) - call setup(outer_gc, config, status) - @assert_that(status, is(0)) - - call ESMF_GridCompFinalize(outer_gc, phase=GENERIC_FINALIZE_USER, rc=status) - @assert_that(status, is(0)) - @assertEqual("wasFinal_A", log) - - - ! Note - do not need to call teardown, as we are - ! finalizing ourselves. But .. we do need to check that the - ! user_gc has been finalized, and that the various internal states - ! have been freed. - - if(.false.) print*,shape(this) - end subroutine test_wasfinal - - @test(npes=[0]) - subroutine test_full_run_sequence(this) - use scratchpad - use iso_fortran_env - class(MpiTestMethod), intent(inout) :: this - type(ESMF_HConfig) :: config - - integer :: status, userrc - type(ESMF_GridComp) :: outer_gc - - type(ESMF_Clock) :: clock - type(ESMF_State) :: importState, exportState - integer :: i - type(ESMF_Field) :: f - type(ESMF_Grid) :: grid - type(BasicVerticalGrid) :: vertical_grid - - call NUOPC_FieldDictionarySetup('./scenarios/FieldDictionary.yml', rc=status) - @assert_that(status, is(0)) - - config = ESMF_HConfigCreate(filename='./scenarios/leaf_A.yaml') - @assert_that(status, is(0)) - - call setup(outer_gc, config, status) - @assert_that(status, is(0)) - - grid = ESMF_GridCreateNoPeriDim(maxIndex=[4,4], name='I_AM_GROOT', rc=status) - @assert_that(status, is(0)) - vertical_grid = BasicVerticalGrid(4) - call MAPL_GridCompSetGeom(outer_gc, grid, rc=status) - @assert_that(status, is(0)) - call MAPL_GridCompSetVerticalGrid(outer_gc, vertical_grid, rc=status) - @assert_that(status, is(0)) - - importState = ESMF_StateCreate(stateIntent=ESMF_STATEINTENT_IMPORT, rc=status) - @assert_that(status, is(0)) - exportState = ESMF_StateCreate(stateIntent=ESMF_STATEINTENT_EXPORT, rc=status) - @assert_that(status, is(0)) - - do i = 1, size(GENERIC_INIT_PHASE_SEQUENCE) - associate (phase => GENERIC_INIT_PHASE_SEQUENCE(i)) - call ESMF_GridCompInitialize(outer_gc, & - importState=importState, exportState=exportState, clock=clock, & - phase=phase, userRC=userRC, rc=status) - end associate - @assert_that(userRC, is(0)) - @assert_that(status, is(0)) - end do - - call ESMF_StateGet(importState, 'I_1', f, rc=status) - @assert_that(status, is(0)) - - call ESMF_StateGet(exportState, 'E_1', f, rc=status) - @assert_that(status, is(0)) - - if(.false.) print*,shape(this) - end subroutine test_full_run_sequence - - - -end module Test_SimpleLeafGridComp diff --git a/generic3g/tests/gridcomps/CMakeLists.txt b/generic3g/tests/gridcomps/CMakeLists.txt index 3f46666cc563..f37b10f16d19 100644 --- a/generic3g/tests/gridcomps/CMakeLists.txt +++ b/generic3g/tests/gridcomps/CMakeLists.txt @@ -1,16 +1,10 @@ esma_set_this () -add_library(simple_leaf_gridcomp SHARED SimpleLeafGridComp.F90) -target_link_libraries(simple_leaf_gridcomp scratchpad) - -add_library(simple_parent_gridcomp SHARED SimpleParentGridComp.F90) -target_link_libraries(simple_parent_gridcomp scratchpad) - add_library(proto_extdata_gc SHARED ProtoExtDataGC.F90) add_library(fakedyn_gridcomp SHARED FakeDynGridComp.F90) -set (comps simple_parent_gridcomp simple_leaf_gridcomp proto_extdata_gc fakedyn_gridcomp) +set (comps proto_extdata_gc fakedyn_gridcomp) foreach (comp ${comps}) target_link_libraries(${comp} MAPL.generic3g) target_include_directories(${comp} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/..) diff --git a/generic3g/tests/gridcomps/SimpleLeafGridComp.F90 b/generic3g/tests/gridcomps/SimpleLeafGridComp.F90 deleted file mode 100644 index 88fb77a3eff2..000000000000 --- a/generic3g/tests/gridcomps/SimpleLeafGridComp.F90 +++ /dev/null @@ -1,106 +0,0 @@ -#include "MAPL_ErrLog.h" - -! See external setservices() procedure at end of file - - -module SimpleLeafGridComp - use mapl_ErrorHandling - use esmf - implicit none - private - - public :: setservices - - -contains - - subroutine setservices(gc, rc) - use mapl3g_Generic, only: MAPL_GridCompSetEntryPoint - type(ESMF_GridComp) :: gc - integer, intent(out) :: rc - - integer :: status - - call MAPL_GridCompSetEntryPoint(gc, ESMF_METHOD_RUN, run, _RC) - call MAPL_GridCompSetEntryPoint(gc, ESMF_METHOD_RUN, run_extra, phase_name='extra', _RC) - call MAPL_GridCompSetEntryPoint(gc, ESMF_METHOD_INITIALIZE, init, _RC) - call MAPL_GridCompSetEntryPoint(gc, ESMF_METHOD_FINALIZE, finalize, _RC) - - _RETURN(ESMF_SUCCESS) - end subroutine setservices - - subroutine run(gc, importState, exportState, clock, rc) - type(ESMF_GridComp) :: gc - type(ESMF_State) :: importState - type(ESMF_State) :: exportState - type(ESMF_Clock) :: clock - integer, intent(out) :: rc - - call append_message(gc, 'wasRun') - - _RETURN(ESMF_SUCCESS) - end subroutine run - - subroutine run_extra(gc, importState, exportState, clock, rc) - type(ESMF_GridComp) :: gc - type(ESMF_State) :: importState - type(ESMF_State) :: exportState - type(ESMF_Clock) :: clock - integer, intent(out) :: rc - - call append_message(gc, 'wasRun_extra') - - _RETURN(ESMF_SUCCESS) - end subroutine run_extra - - subroutine init(gc, importState, exportState, clock, rc) - type(ESMF_GridComp) :: gc - type(ESMF_State) :: importState - type(ESMF_State) :: exportState - type(ESMF_Clock) :: clock - integer, intent(out) :: rc - - call append_message(gc, 'wasInit') - - _RETURN(ESMF_SUCCESS) - end subroutine init - - subroutine finalize(gc, importState, exportState, clock, rc) - type(ESMF_GridComp) :: gc - type(ESMF_State) :: importState - type(ESMF_State) :: exportState - type(ESMF_Clock) :: clock - integer, intent(out) :: rc - - call append_message(gc, 'wasFinal') - - _RETURN(ESMF_SUCCESS) - end subroutine finalize - - subroutine append_message(gc, message) - use scratchpad, only: append_scratchpad_message => append_message - type(ESMF_GridComp), intent(in) :: gc - character(*), intent(in) :: message - - character(ESMF_MAXSTR) :: name - call ESMF_GridCompGet(gc, name=name) - - call append_scratchpad_message(message // '_' // trim(name)) - end subroutine append_message - -end module SimpleLeafGridComp - -subroutine setServices(gc, rc) - use esmf, only: ESMF_GridComp - use esmf, only: ESMF_SUCCESS - use mapl_ErrorHandling - use SimpleLeafGridComp, only: inner_setservices => setservices - type(ESMF_GridComp) :: gc - integer, intent(out) :: rc - - integer :: status - - call inner_setservices(gc, _RC) - - _RETURN(ESMF_SUCCESS) -end subroutine setServices diff --git a/generic3g/tests/gridcomps/SimpleParentGridComp.F90 b/generic3g/tests/gridcomps/SimpleParentGridComp.F90 deleted file mode 100644 index fe04f962c28f..000000000000 --- a/generic3g/tests/gridcomps/SimpleParentGridComp.F90 +++ /dev/null @@ -1,112 +0,0 @@ -#include "MAPL_ErrLog.h" - -! See external setservices() procedure at end of file - - -module SimpleParentGridComp - use mapl_ErrorHandling - use mapl3g_OuterMetaComponent - use mapl3g_Generic - use mapl3g_UserSetServices - use scratchpad - use esmf - implicit none - private - - public :: setservices - -contains - - subroutine setservices(gc, rc) - use mapl3g_Generic, only: MAPL_GridCompSetEntryPoint - type(ESMF_GridComp) :: gc - integer, intent(out) :: rc - - integer :: status - type(ESMF_HConfig) :: config_A, config_B - - call MAPL_GridCompSetEntryPoint(gc, ESMF_METHOD_RUN, run, _RC) - call MAPL_GridCompSetEntryPoint(gc, ESMF_METHOD_RUN, run_extra, phase_name='extra', _RC) - call MAPL_GridCompSetEntryPoint(gc, ESMF_METHOD_INITIALIZE, init, _RC) - call MAPL_GridCompSetEntryPoint(gc, ESMF_METHOD_FINALIZE, finalize, _RC) - - config_A = ESMF_HConfigCreate(filename='./scenarios/leaf_A.yaml',rc=status) - _ASSERT(status == 0, 'bad config') - config_B = ESMF_HConfigCreate(filename='./scenarios/leaf_B.yaml',rc=status) - _ASSERT(status == 0, 'bad config') - - - _RETURN(ESMF_SUCCESS) - end subroutine setservices - - recursive subroutine run(gc, importState, exportState, clock, rc) - type(ESMF_GridComp) :: gc - type(ESMF_State) :: importState - type(ESMF_State) :: exportState - type(ESMF_Clock) :: clock - integer, intent(out) :: rc - - type(OuterMetaComponent), pointer :: outer_meta - integer :: status - - call append_message('wasRun') -!!$ outer_meta => get_outer_meta(gc, _RC) - outer_meta => get_outer_meta_from_inner_gc(gc, _RC) - call outer_meta%run_children(_RC) - - _RETURN(ESMF_SUCCESS) - end subroutine run - - recursive subroutine run_extra(gc, importState, exportState, clock, rc) - type(ESMF_GridComp) :: gc - type(ESMF_State) :: importState - type(ESMF_State) :: exportState - type(ESMF_Clock) :: clock - integer, intent(out) :: rc - - call append_message('wasRun_extra') - - - _RETURN(ESMF_SUCCESS) - end subroutine run_extra - - recursive subroutine init(gc, importState, exportState, clock, rc) - type(ESMF_GridComp) :: gc - type(ESMF_State) :: importState - type(ESMF_State) :: exportState - type(ESMF_Clock) :: clock - integer, intent(out) :: rc - - call append_message('wasInit') - - _RETURN(ESMF_SUCCESS) - end subroutine init - - recursive subroutine finalize(gc, importState, exportState, clock, rc) - type(ESMF_GridComp) :: gc - type(ESMF_State) :: importState - type(ESMF_State) :: exportState - type(ESMF_Clock) :: clock - integer, intent(out) :: rc - - call append_message('wasFinal') - - _RETURN(ESMF_SUCCESS) - end subroutine finalize - -end module SimpleParentGridComp - -subroutine setServices(gc, rc) - use esmf, only: ESMF_GridComp - use esmf, only: ESMF_SUCCESS - use mapl_ErrorHandling - use SimpleParentGridComp, only: inner_setservices => setservices - type(ESMF_GridComp) :: gc - integer, intent(out) :: rc - - integer :: status - - call inner_setservices(gc, _RC) - - _RETURN(ESMF_SUCCESS) -end subroutine setServices diff --git a/generic3g/tests/scenarios/3d_specs/parent.yaml b/generic3g/tests/scenarios/3d_specs/parent.yaml index 383128cb4e32..0ec8cd175396 100644 --- a/generic3g/tests/scenarios/3d_specs/parent.yaml +++ b/generic3g/tests/scenarios/3d_specs/parent.yaml @@ -13,10 +13,10 @@ mapl: children: A: - dso: libsimple_leaf_gridcomp + dso: libconfigurable_gridcomp config_file: scenarios/3d_specs/A.yaml B: - dso: libsimple_leaf_gridcomp + dso: libconfigurable_gridcomp config_file: scenarios/3d_specs/B.yaml states: {} diff --git a/generic3g/tests/scenarios/export_dependency/parent.yaml b/generic3g/tests/scenarios/export_dependency/parent.yaml index 12d3d4249b34..62f19faab42b 100644 --- a/generic3g/tests/scenarios/export_dependency/parent.yaml +++ b/generic3g/tests/scenarios/export_dependency/parent.yaml @@ -13,11 +13,11 @@ mapl: children: child_A: - sharedObj: libsimple_leaf_gridcomp + sharedObj: libconfigurable_gridcomp setServices: setservices_ config_file: scenarios/export_dependency/child_A.yaml child_B: - dso: libsimple_leaf_gridcomp + dso: libconfigurable_gridcomp config_file: scenarios/export_dependency/child_B.yaml states: {} diff --git a/generic3g/tests/scenarios/extdata_1/cap.yaml b/generic3g/tests/scenarios/extdata_1/cap.yaml index 49805b66ee49..2b4b82099df8 100644 --- a/generic3g/tests/scenarios/extdata_1/cap.yaml +++ b/generic3g/tests/scenarios/extdata_1/cap.yaml @@ -5,7 +5,7 @@ mapl: dso: libproto_extdata_gc config_file: scenarios/extdata_1/extdata.yaml root: - dso: libsimple_parent_gridcomp + dso: libconfigurable_gridcomp config_file: scenarios/extdata_1/root.yaml states: {} diff --git a/generic3g/tests/scenarios/extdata_1/extdata.yaml b/generic3g/tests/scenarios/extdata_1/extdata.yaml index 7631ba9f8abc..fbb3202560ab 100644 --- a/generic3g/tests/scenarios/extdata_1/extdata.yaml +++ b/generic3g/tests/scenarios/extdata_1/extdata.yaml @@ -28,5 +28,5 @@ mapl: children: collection_1: - dso: libsimple_leaf_gridcomp + dso: libconfigurable_gridcomp config_file: scenarios/extdata_1/collection_1.yaml diff --git a/generic3g/tests/scenarios/history_1/cap.yaml b/generic3g/tests/scenarios/history_1/cap.yaml index 58ed081ae3a9..34ea1f04e85e 100644 --- a/generic3g/tests/scenarios/history_1/cap.yaml +++ b/generic3g/tests/scenarios/history_1/cap.yaml @@ -2,10 +2,10 @@ mapl: children: root: - dso: libsimple_parent_gridcomp + dso: libconfigurable_gridcomp config_file: scenarios/history_1/root.yaml history: - dso: libsimple_parent_gridcomp + dso: libconfigurable_gridcomp config_file: scenarios/history_1/history.yaml states: {} diff --git a/generic3g/tests/scenarios/history_1/history.yaml b/generic3g/tests/scenarios/history_1/history.yaml index 351304628570..12bb1e71bc2e 100644 --- a/generic3g/tests/scenarios/history_1/history.yaml +++ b/generic3g/tests/scenarios/history_1/history.yaml @@ -1,10 +1,10 @@ mapl: children: collection_1: - dso: libsimple_leaf_gridcomp + dso: libconfigurable_gridcomp config_file: scenarios/history_1/collection_1.yaml mirror_geom_collection: - dso: libsimple_leaf_gridcomp + dso: libconfigurable_gridcomp config_file: scenarios/history_1/mirror_geom_collection.yaml states: {} diff --git a/generic3g/tests/scenarios/history_1/root.yaml b/generic3g/tests/scenarios/history_1/root.yaml index d912bfb5e425..3bff619de988 100644 --- a/generic3g/tests/scenarios/history_1/root.yaml +++ b/generic3g/tests/scenarios/history_1/root.yaml @@ -14,10 +14,10 @@ mapl: children: A: - dso: libsimple_leaf_gridcomp + dso: libconfigurable_gridcomp config_file: scenarios/history_1/A.yaml B: - dso: libsimple_leaf_gridcomp + dso: libconfigurable_gridcomp config_file: scenarios/history_1/B.yaml states: diff --git a/generic3g/tests/scenarios/history_wildcard/cap.yaml b/generic3g/tests/scenarios/history_wildcard/cap.yaml index 37a55a1610cb..dc2fc8ef48ea 100644 --- a/generic3g/tests/scenarios/history_wildcard/cap.yaml +++ b/generic3g/tests/scenarios/history_wildcard/cap.yaml @@ -13,10 +13,10 @@ mapl: children: root: - dso: libsimple_parent_gridcomp + dso: libconfigurable_gridcomp config_file: scenarios/history_wildcard/root.yaml history: - dso: libsimple_parent_gridcomp + dso: libconfigurable_gridcomp config_file: scenarios/history_wildcard/history.yaml states: {} diff --git a/generic3g/tests/scenarios/history_wildcard/history.yaml b/generic3g/tests/scenarios/history_wildcard/history.yaml index de3a3d9c6a76..252ae8e0cd1e 100644 --- a/generic3g/tests/scenarios/history_wildcard/history.yaml +++ b/generic3g/tests/scenarios/history_wildcard/history.yaml @@ -1,7 +1,7 @@ mapl: children: collection_1: - dso: libsimple_leaf_gridcomp + dso: libconfigurable_gridcomp config_file: scenarios/history_wildcard/collection_1.yaml states: {} diff --git a/generic3g/tests/scenarios/history_wildcard/root.yaml b/generic3g/tests/scenarios/history_wildcard/root.yaml index 9ad00b8c766c..1238c185289e 100644 --- a/generic3g/tests/scenarios/history_wildcard/root.yaml +++ b/generic3g/tests/scenarios/history_wildcard/root.yaml @@ -2,10 +2,10 @@ mapl: children: A: - dso: libsimple_leaf_gridcomp + dso: libconfigurable_gridcomp config_file: scenarios/history_wildcard/A.yaml B: - dso: libsimple_leaf_gridcomp + dso: libconfigurable_gridcomp config_file: scenarios/history_wildcard/B.yaml states: diff --git a/generic3g/tests/scenarios/leaf_A.yaml b/generic3g/tests/scenarios/leaf_A.yaml deleted file mode 100644 index 2b7a60392ef6..000000000000 --- a/generic3g/tests/scenarios/leaf_A.yaml +++ /dev/null @@ -1,19 +0,0 @@ -mapl: - states: - import: - I_1: - standard_name: 'I_1 standard name' - units: 'meter' - vertical_dim_spec: NONE - - export: - E_1: - standard_name: 'E_1 standard name' - units: 'barn' - vertical_dim_spec: NONE - -# internal: -# Internal_1: -# standard_name: 'Internal_1 standard name' -# units: '1' -# vertical_dim_spec: NONE diff --git a/generic3g/tests/scenarios/leaf_B.yaml b/generic3g/tests/scenarios/leaf_B.yaml deleted file mode 100644 index 738baf7cba5a..000000000000 --- a/generic3g/tests/scenarios/leaf_B.yaml +++ /dev/null @@ -1,16 +0,0 @@ -mapl: - states: - import: - E_1: - standard_name: 'E_1 standard name' - units: 'barn' - - export: - I_1: - standard_name: 'I_1 standard name' - units: 'meter' - -# internal: -# Internal_1: -# standard_name: 'Internal_1 standard name' -# units: '1' diff --git a/generic3g/tests/scenarios/parent.yaml b/generic3g/tests/scenarios/parent.yaml index 7e1dcd433f23..455cf67e6ace 100644 --- a/generic3g/tests/scenarios/parent.yaml +++ b/generic3g/tests/scenarios/parent.yaml @@ -7,10 +7,10 @@ grid: children: A: - dso: libsimple_leaf_gridcomp + dso: libconfigurable_gridcomp config_file: scenarios/precision_extension/A.yaml B: - dso: libsimple_leaf_gridcomp + dso: libconfigurable_gridcomp config_file: scenarios/precision_extension/B.yaml states: {} diff --git a/generic3g/tests/scenarios/precision_extension/parent.yaml b/generic3g/tests/scenarios/precision_extension/parent.yaml index 4b14a2b1d4a3..66c8b6848924 100644 --- a/generic3g/tests/scenarios/precision_extension/parent.yaml +++ b/generic3g/tests/scenarios/precision_extension/parent.yaml @@ -13,10 +13,10 @@ mapl: children: A: - dso: libsimple_leaf_gridcomp + dso: libconfigurable_gridcomp config_file: scenarios/precision_extension/A.yaml B: - dso: libsimple_leaf_gridcomp + dso: libconfigurable_gridcomp config_file: scenarios/precision_extension/B.yaml states: {} diff --git a/generic3g/tests/scenarios/precision_extension_3d/parent.yaml b/generic3g/tests/scenarios/precision_extension_3d/parent.yaml index 7c09d05baacb..df839e98309c 100644 --- a/generic3g/tests/scenarios/precision_extension_3d/parent.yaml +++ b/generic3g/tests/scenarios/precision_extension_3d/parent.yaml @@ -13,10 +13,10 @@ mapl: children: A: - dso: libsimple_leaf_gridcomp + dso: libconfigurable_gridcomp config_file: scenarios/precision_extension_3d/A.yaml B: - dso: libsimple_leaf_gridcomp + dso: libconfigurable_gridcomp config_file: scenarios/precision_extension_3d/B.yaml states: {} diff --git a/generic3g/tests/scenarios/propagate_geom/parent.yaml b/generic3g/tests/scenarios/propagate_geom/parent.yaml index d10fe0536fa2..35f5790511db 100644 --- a/generic3g/tests/scenarios/propagate_geom/parent.yaml +++ b/generic3g/tests/scenarios/propagate_geom/parent.yaml @@ -5,11 +5,11 @@ mapl: children: child_A: - sharedObj: libsimple_leaf_gridcomp + sharedObj: libconfigurable_gridcomp setServices: setservices_ config_file: scenarios/propagate_geom/child_A.yaml child_B: - dso: libsimple_leaf_gridcomp + dso: libconfigurable_gridcomp config_file: scenarios/propagate_geom/child_B.yaml states: {} diff --git a/generic3g/tests/scenarios/regrid/cap.yaml b/generic3g/tests/scenarios/regrid/cap.yaml index 8480541beb79..1db3c34431bb 100644 --- a/generic3g/tests/scenarios/regrid/cap.yaml +++ b/generic3g/tests/scenarios/regrid/cap.yaml @@ -2,10 +2,10 @@ mapl: children: A: - dso: libsimple_leaf_gridcomp + dso: libconfigurable_gridcomp config_file: scenarios/regrid/A.yaml B: - dso: libsimple_leaf_gridcomp + dso: libconfigurable_gridcomp config_file: scenarios/regrid/B.yaml states: {} diff --git a/generic3g/tests/scenarios/scenario_1/parent.yaml b/generic3g/tests/scenarios/scenario_1/parent.yaml index c8c79bf9b24b..704dd72b3285 100644 --- a/generic3g/tests/scenarios/scenario_1/parent.yaml +++ b/generic3g/tests/scenarios/scenario_1/parent.yaml @@ -13,11 +13,11 @@ mapl: children: child_A: - sharedObj: libsimple_leaf_gridcomp + sharedObj: libconfigurable_gridcomp setServices: setservices_ config_file: scenarios/scenario_1/child_A.yaml child_B: - dso: libsimple_leaf_gridcomp + dso: libconfigurable_gridcomp config_file: scenarios/scenario_1/child_B.yaml states: {} diff --git a/generic3g/tests/scenarios/scenario_2/parent.yaml b/generic3g/tests/scenarios/scenario_2/parent.yaml index da3451368298..6e3ed8eef408 100644 --- a/generic3g/tests/scenarios/scenario_2/parent.yaml +++ b/generic3g/tests/scenarios/scenario_2/parent.yaml @@ -13,11 +13,11 @@ mapl: children: child_A: - sharedObj: libsimple_leaf_gridcomp + sharedObj: libconfigurable_gridcomp setServices: setservices_ config_file: scenarios/scenario_2/child_A.yaml child_B: - dso: libsimple_leaf_gridcomp + dso: libconfigurable_gridcomp config_file: scenarios/scenario_2/child_B.yaml states: {} diff --git a/generic3g/tests/scenarios/scenario_reexport_twice/grandparent.yaml b/generic3g/tests/scenarios/scenario_reexport_twice/grandparent.yaml index b8a5e96ea144..ec5f2af60f1d 100644 --- a/generic3g/tests/scenarios/scenario_reexport_twice/grandparent.yaml +++ b/generic3g/tests/scenarios/scenario_reexport_twice/grandparent.yaml @@ -2,7 +2,7 @@ mapl: children: parent: - sharedObj: libsimple_parent_gridcomp + sharedObj: libconfigurable_gridcomp setServices: setservices_ config_file: scenarios/scenario_reexport_twice/parent.yaml diff --git a/generic3g/tests/scenarios/scenario_reexport_twice/parent.yaml b/generic3g/tests/scenarios/scenario_reexport_twice/parent.yaml index 21e6502e5070..d5f7a1e799d2 100644 --- a/generic3g/tests/scenarios/scenario_reexport_twice/parent.yaml +++ b/generic3g/tests/scenarios/scenario_reexport_twice/parent.yaml @@ -1,11 +1,11 @@ mapl: children: child_A: - sharedObj: libsimple_leaf_gridcomp + sharedObj: libconfigurable_gridcomp setServices: setservices_ config_file: scenarios/scenario_reexport_twice/child_A.yaml child_B: - dso: libsimple_leaf_gridcomp + dso: libconfigurable_gridcomp config_file: scenarios/scenario_reexport_twice/child_B.yaml states: {} diff --git a/generic3g/tests/scenarios/service_service/parent.yaml b/generic3g/tests/scenarios/service_service/parent.yaml index 19acf46f0d2c..f5e6c3f256ce 100644 --- a/generic3g/tests/scenarios/service_service/parent.yaml +++ b/generic3g/tests/scenarios/service_service/parent.yaml @@ -13,15 +13,15 @@ mapl: children: child_A: - sharedObj: libsimple_leaf_gridcomp + sharedObj: libconfigurable_gridcomp setServices: setservices_ config_file: scenarios/service_service/child_A.yaml child_C: - sharedObj: libsimple_leaf_gridcomp + sharedObj: libconfigurable_gridcomp setServices: setservices_ config_file: scenarios/service_service/child_C.yaml child_B: - dso: libsimple_leaf_gridcomp + dso: libconfigurable_gridcomp config_file: scenarios/service_service/child_B.yaml states: {} diff --git a/generic3g/tests/scenarios/ungridded_dims/parent.yaml b/generic3g/tests/scenarios/ungridded_dims/parent.yaml index 67493a152abe..26d23dca29ba 100644 --- a/generic3g/tests/scenarios/ungridded_dims/parent.yaml +++ b/generic3g/tests/scenarios/ungridded_dims/parent.yaml @@ -14,10 +14,10 @@ mapl: children: A: - dso: libsimple_leaf_gridcomp + dso: libconfigurable_gridcomp config_file: scenarios/ungridded_dims/A.yaml B: - dso: libsimple_leaf_gridcomp + dso: libconfigurable_gridcomp config_file: scenarios/ungridded_dims/B.yaml states: {} diff --git a/generic3g/tests/scenarios/vertical_regridding/parent.yaml b/generic3g/tests/scenarios/vertical_regridding/parent.yaml index 3785013e8f43..068dfecbd062 100644 --- a/generic3g/tests/scenarios/vertical_regridding/parent.yaml +++ b/generic3g/tests/scenarios/vertical_regridding/parent.yaml @@ -2,11 +2,11 @@ mapl: children: A: - sharedObj: libsimple_leaf_gridcomp + sharedObj: libconfigurable_gridcomp setServices: setservices_ config_file: scenarios/vertical_regridding/A.yaml B: - sharedObj: libsimple_leaf_gridcomp + sharedObj: libconfigurable_gridcomp setServices: setservices_ config_file: scenarios/vertical_regridding/B.yaml diff --git a/generic3g/tests/scenarios/vertical_regridding_2/parent.yaml b/generic3g/tests/scenarios/vertical_regridding_2/parent.yaml index a665448f95f3..797a7a823068 100644 --- a/generic3g/tests/scenarios/vertical_regridding_2/parent.yaml +++ b/generic3g/tests/scenarios/vertical_regridding_2/parent.yaml @@ -2,19 +2,19 @@ mapl: children: A: - sharedObj: libsimple_leaf_gridcomp + sharedObj: libconfigurable_gridcomp setServices: setservices_ config_file: scenarios/vertical_regridding_2/A.yaml B: - sharedObj: libsimple_leaf_gridcomp + sharedObj: libconfigurable_gridcomp setServices: setservices_ config_file: scenarios/vertical_regridding_2/B.yaml C: - sharedObj: libsimple_leaf_gridcomp + sharedObj: libconfigurable_gridcomp setServices: setservices_ config_file: scenarios/vertical_regridding_2/C.yaml D: - sharedObj: libsimple_leaf_gridcomp + sharedObj: libconfigurable_gridcomp setServices: setservices_ config_file: scenarios/vertical_regridding_2/D.yaml diff --git a/generic3g/tests/scenarios/vertical_regridding_3/AGCM.yaml b/generic3g/tests/scenarios/vertical_regridding_3/AGCM.yaml index f64e41c02f24..17b62a5bac39 100644 --- a/generic3g/tests/scenarios/vertical_regridding_3/AGCM.yaml +++ b/generic3g/tests/scenarios/vertical_regridding_3/AGCM.yaml @@ -6,11 +6,11 @@ mapl: setServices: setservices_ config_file: scenarios/vertical_regridding_3/DYN.yaml PHYS: - sharedObj: libsimple_leaf_gridcomp + sharedObj: libconfigurable_gridcomp setServices: setservices_ config_file: scenarios/vertical_regridding_3/PHYS.yaml C: - sharedObj: libsimple_leaf_gridcomp + sharedObj: libconfigurable_gridcomp setServices: setservices_ config_file: scenarios/vertical_regridding_3/C.yaml diff --git a/generic3g/tests/scratchpad.F90 b/generic3g/tests/scratchpad.F90 deleted file mode 100644 index c19d4c52a780..000000000000 --- a/generic3g/tests/scratchpad.F90 +++ /dev/null @@ -1,28 +0,0 @@ -module scratchpad - implicit none - private - - public :: log - public :: append_message - public :: clear_log - - character(:), allocatable :: log - -contains - - subroutine clear_log() - if (allocated(log)) deallocate(log) - end subroutine clear_log - - subroutine append_message(msg) - character(len=*), intent(in) :: msg - - if (.not. allocated(log)) then - log = msg - else - log = log // ' :: ' // msg - end if - - end subroutine append_message - -end module scratchpad diff --git a/generic3g/vertical/BasicVerticalGrid.F90 b/generic3g/vertical/BasicVerticalGrid.F90 index 520e581fc53b..7a7838908b5c 100644 --- a/generic3g/vertical/BasicVerticalGrid.F90 +++ b/generic3g/vertical/BasicVerticalGrid.F90 @@ -82,7 +82,12 @@ logical function can_connect_to(this, dst, rc) class(VerticalGrid), intent(in) :: dst integer, optional, intent(out) :: rc - _FAIL("BasicVerticalGrid::can_connect_to - NOT implemented yet") + if (this%same_id(dst)) then + can_connect_to = .true. + _RETURN(_SUCCESS) + end if + + _RETURN(_SUCCESS) end function can_connect_to logical function is_identical_to(this, that, rc) diff --git a/gridcomps/cap3g/tests/basic_captest/GCM.yaml b/gridcomps/cap3g/tests/basic_captest/GCM.yaml index e849abeab249..d8dd5e70cd19 100644 --- a/gridcomps/cap3g/tests/basic_captest/GCM.yaml +++ b/gridcomps/cap3g/tests/basic_captest/GCM.yaml @@ -1,4 +1,5 @@ mapl: + states: export: E_1: @@ -14,7 +15,6 @@ mapl: default_value: 18. vertical_dim_spec: NONE - geometry: esmf_geom: class: latlon @@ -22,3 +22,6 @@ mapl: jm_world: 13 pole: PC dateline: DC + vertical_grid: + class: basic + num_levels: 4 diff --git a/gridcomps/cap3g/tests/basic_captest/cap.yaml b/gridcomps/cap3g/tests/basic_captest/cap.yaml index 2ee5c811e04a..6800e96a4bf8 100644 --- a/gridcomps/cap3g/tests/basic_captest/cap.yaml +++ b/gridcomps/cap3g/tests/basic_captest/cap.yaml @@ -37,7 +37,7 @@ cap: mapl: children: GCM: - dso: libconfigurable_leaf_gridcomp.dylib + dso: libconfigurable_gridcomp.dylib setServices: setservices_ config_file: GCM.yaml #EXTDATA: diff --git a/gridcomps/cap3g/tests/parent_child_captest/AGCM.yaml b/gridcomps/cap3g/tests/parent_child_captest/AGCM.yaml index a46add626bf4..d8dd5e70cd19 100644 --- a/gridcomps/cap3g/tests/parent_child_captest/AGCM.yaml +++ b/gridcomps/cap3g/tests/parent_child_captest/AGCM.yaml @@ -1,4 +1,5 @@ mapl: + states: export: E_1: @@ -21,3 +22,6 @@ mapl: jm_world: 13 pole: PC dateline: DC + vertical_grid: + class: basic + num_levels: 4 diff --git a/gridcomps/cap3g/tests/parent_child_captest/GCM.yaml b/gridcomps/cap3g/tests/parent_child_captest/GCM.yaml index 9e8e10253464..63e1da9a226e 100644 --- a/gridcomps/cap3g/tests/parent_child_captest/GCM.yaml +++ b/gridcomps/cap3g/tests/parent_child_captest/GCM.yaml @@ -1,4 +1,5 @@ mapl: + states: export: EE_1: @@ -13,6 +14,7 @@ mapl: typekind: R4 default_value: 18. vertical_dim_spec: NONE + geometry: esmf_geom: class: latlon @@ -20,8 +22,12 @@ mapl: jm_world: 13 pole: PC dateline: DC + vertical_grid: + class: basic + num_levels: 4 + children: AGCM: - dso: libconfigurable_leaf_gridcomp.dylib + dso: libconfigurable_gridcomp.dylib setServices: setservices_ config_file: AGCM.yaml diff --git a/gridcomps/cap3g/tests/parent_child_captest/cap.yaml b/gridcomps/cap3g/tests/parent_child_captest/cap.yaml index 0e01364eb339..aca4121e4a77 100644 --- a/gridcomps/cap3g/tests/parent_child_captest/cap.yaml +++ b/gridcomps/cap3g/tests/parent_child_captest/cap.yaml @@ -31,8 +31,8 @@ cap: mapl: children: GCM: - #dso: libconfigurable_leaf_gridcomp.dylib - dso: libconfigurable_parent_gridcomp.dylib + #dso: libconfigurable_gridcomp.dylib + dso: libconfigurable_gridcomp.dylib setServices: setservices_ config_file: GCM.yaml #EXTDATA: diff --git a/gridcomps/cap3g/tests/write_restart/AGCM.yaml b/gridcomps/cap3g/tests/write_restart/AGCM.yaml index 07327e4634d6..22a1e741066e 100644 --- a/gridcomps/cap3g/tests/write_restart/AGCM.yaml +++ b/gridcomps/cap3g/tests/write_restart/AGCM.yaml @@ -1,4 +1,5 @@ mapl: + states: export: EXP_1: @@ -40,3 +41,6 @@ mapl: jm_world: 13 pole: PC dateline: DC + vertical_grid: + class: basic + num_levels: 4 diff --git a/gridcomps/cap3g/tests/write_restart/GCM.yaml b/gridcomps/cap3g/tests/write_restart/GCM.yaml index 3cb56eecf56e..17a4943af475 100644 --- a/gridcomps/cap3g/tests/write_restart/GCM.yaml +++ b/gridcomps/cap3g/tests/write_restart/GCM.yaml @@ -1,4 +1,5 @@ mapl: + states: export: EE_1: @@ -13,6 +14,7 @@ mapl: typekind: R4 default_value: 18. vertical_dim_spec: NONE + geometry: esmf_geom: class: latlon @@ -20,13 +22,17 @@ mapl: jm_world: 13 pole: PC dateline: DC + vertical_grid: + class: basic + num_levels: 4 + children: AGCM: - dso: libconfigurable_leaf_gridcomp.dylib + dso: libconfigurable_gridcomp.dylib setServices: setservices_ config_file: AGCM.yaml + connections: - # import to export - src_name: EE_1 dst_name: IMP_1 src_comp: diff --git a/gridcomps/cap3g/tests/write_restart/cap.yaml b/gridcomps/cap3g/tests/write_restart/cap.yaml index 0c40bde71770..8aab0387553c 100644 --- a/gridcomps/cap3g/tests/write_restart/cap.yaml +++ b/gridcomps/cap3g/tests/write_restart/cap.yaml @@ -25,8 +25,8 @@ cap: mapl: children: GCM: - #dso: libconfigurable_leaf_gridcomp.dylib - dso: libconfigurable_parent_gridcomp.dylib + #dso: libconfigurable_gridcomp.dylib + dso: libconfigurable_gridcomp.dylib setServices: setservices_ config_file: GCM.yaml #EXTDATA: diff --git a/gridcomps/configurable/CMakeLists.txt b/gridcomps/configurable/CMakeLists.txt index 4ee25d977d30..833c5b521392 100644 --- a/gridcomps/configurable/CMakeLists.txt +++ b/gridcomps/configurable/CMakeLists.txt @@ -1,10 +1,6 @@ -esma_set_this () - -esma_add_library(configurable_leaf_gridcomp SRCS ConfigurableLeafGridComp.F90 DEPENDENCIES MAPL.generic3g TYPE SHARED) -esma_add_library(configurable_parent_gridcomp SRCS ConfigurableParentGridComp.F90 DEPENDENCIES MAPL.generic3g TYPE SHARED) - -set (comps configurable_leaf_gridcomp configurable_parent_gridcomp ) -foreach (comp ${comps}) - target_include_directories(${comp} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/..) -endforeach() +esma_set_this (OVERRIDE configurable_gridcomp) +esma_add_library(${this} + SRCS ConfigurableGridComp.F90 + DEPENDENCIES MAPL.generic3g + TYPE SHARED) diff --git a/gridcomps/configurable/ConfigurableGridComp.F90 b/gridcomps/configurable/ConfigurableGridComp.F90 new file mode 100644 index 000000000000..8a919292b367 --- /dev/null +++ b/gridcomps/configurable/ConfigurableGridComp.F90 @@ -0,0 +1,69 @@ +#include "MAPL_Generic.h" + +module ConfigurableGridComp + + use mapl_ErrorHandling + use mapl3g_Generic, only: MAPL_GridCompSetEntryPoint, MAPL_RunChildren + use esmf + + implicit none + private + + public :: setServices + +contains + + subroutine setServices(gridcomp, rc) + type(ESMF_GridComp) :: gridcomp + integer, intent(out) :: rc + + integer :: status + + call MAPL_GridCompSetEntryPoint(gridcomp, ESMF_METHOD_INITIALIZE, init, _RC) + call MAPL_GridCompSetEntryPoint(gridcomp, ESMF_METHOD_RUN, run, phase_name="run", _RC) + + _RETURN(_SUCCESS) + end subroutine setServices + + subroutine init(gridcomp, importState, exportState, clock, rc) + type(ESMF_GridComp) :: gridcomp + type(ESMF_State) :: importState + type(ESMF_State) :: exportState + type(ESMF_Clock) :: clock + integer, intent(out) :: rc + + integer :: status + + _RETURN(_SUCCESS) + end subroutine init + + recursive subroutine run(gridcomp, importState, exportState, clock, rc) + type(ESMF_GridComp) :: gridcomp + type(ESMF_State) :: importState + type(ESMF_State) :: exportState + type(ESMF_Clock) :: clock + integer, intent(out) :: rc + + integer :: status + character(len=ESMF_MAXSTR) :: gc_name + + call ESMF_GridCompGet(gridcomp, name=gc_name, _RC) + call MAPL_RunChildren(gridcomp, phase_name="run", _RC) + + _RETURN(_SUCCESS) + end subroutine run + +end module ConfigurableGridComp + +subroutine setServices(gridcomp, rc) + use ESMF + use MAPL_ErrorHandlingMod + use ConfigurableGridComp, only: Configurable_setServices => SetServices + type(ESMF_GridComp) :: gridcomp + integer, intent(out) :: rc + + integer :: status + + call Configurable_setServices(gridcomp,_RC) + _RETURN(_SUCCESS) +end subroutine setServices diff --git a/gridcomps/configurable/ConfigurableLeafGridComp.F90 b/gridcomps/configurable/ConfigurableLeafGridComp.F90 deleted file mode 100644 index 009d0db50eb8..000000000000 --- a/gridcomps/configurable/ConfigurableLeafGridComp.F90 +++ /dev/null @@ -1,84 +0,0 @@ -#include "MAPL_Generic.h" - -module ConfigurableLeafGridComp - use generic3g - use mapl_ErrorHandling - use pFlogger, only: logger - use esmf - implicit none - private - - public :: setServices - -contains - - subroutine setServices(gridcomp, rc) - use mapl3g_BasicVerticalGrid - type(ESMF_GridComp) :: gridcomp - integer, intent(out) :: rc - - type(ESMF_HConfig) :: hconfig, collections_config, child_hconfig - character(len=:), allocatable :: child_name, collection_name - type(ESMF_HConfigIter) :: iter, iter_begin, iter_end - logical :: has_active_collections - class(logger), pointer :: lgr - integer :: num_collections, status - type(BasicVerticalGrid) :: vertical_grid - type(ESMF_GridComp) outer_gridcomp - type(OuterMetaComponent), pointer :: outer_meta - - call MAPL_GridCompSetEntryPoint(gridcomp, ESMF_METHOD_INITIALIZE, init, _RC) - call MAPL_GridCompSetEntryPoint(gridcomp, ESMF_METHOD_RUN, run, phase_name='run', _RC) - - outer_meta => get_outer_meta_from_inner_gc(gridcomp,_RC) - vertical_grid = BasicVerticalGrid(4) - call outer_meta%set_vertical_grid(vertical_grid) - - - _RETURN(_SUCCESS) - end subroutine setServices - - subroutine init(gridcomp, importState, exportState, clock, rc) - type(ESMF_GridComp) :: gridcomp - type(ESMF_State) :: importState - type(ESMF_State) :: exportState - type(ESMF_Clock) :: clock - integer, intent(out) :: rc - - integer :: status - - _RETURN(_SUCCESS) - end subroutine init - - subroutine run(gridcomp, importState, exportState, clock, rc) - !use mapl3g_MultiState - type(ESMF_GridComp) :: gridcomp - type(ESMF_State) :: importState - type(ESMF_State) :: exportState - type(ESMF_Clock) :: clock - integer, intent(out) :: rc - - integer :: status - character(len=ESMF_MAXSTR) :: gc_name - call ESMF_GridCompGet(gridcomp, name=gc_name, _RC) - print*,'running ',trim(gc_name) - - _RETURN(_SUCCESS) - end subroutine run - -end module ConfigurableLeafGridComp - -subroutine setServices(gridcomp,rc) - use ESMF - use MAPL_ErrorHandlingMod - use ConfigurableLeafGridComp, only: ConfigurableLeaf_setServices => SetServices - type(ESMF_GridComp) :: gridcomp - integer, intent(out) :: rc - - integer :: status - - call ConfigurableLeaf_setServices(gridcomp,_RC) - _RETURN(_SUCCESS) - -end subroutine - diff --git a/gridcomps/configurable/ConfigurableParentGridComp.F90 b/gridcomps/configurable/ConfigurableParentGridComp.F90 deleted file mode 100644 index bf951b08c6c5..000000000000 --- a/gridcomps/configurable/ConfigurableParentGridComp.F90 +++ /dev/null @@ -1,84 +0,0 @@ -#include "MAPL_Generic.h" - -module ConfigurableParentGridComp - use generic3g - use mapl_ErrorHandling - use pFlogger, only: logger - use esmf - implicit none - private - - public :: setServices - -contains - - subroutine setServices(gridcomp, rc) - use mapl3g_BasicVerticalGrid - type(ESMF_GridComp) :: gridcomp - integer, intent(out) :: rc - - type(ESMF_HConfig) :: hconfig, collections_config, child_hconfig - character(len=:), allocatable :: child_name, collection_name - type(ESMF_HConfigIter) :: iter, iter_begin, iter_end - logical :: has_active_collections - class(logger), pointer :: lgr - integer :: num_collections, status - type(BasicVerticalGrid) :: vertical_grid - type(ESMF_GridComp) outer_gridcomp - type(OuterMetaComponent), pointer :: outer_meta - - call MAPL_GridCompSetEntryPoint(gridcomp, ESMF_METHOD_INITIALIZE, init, _RC) - call MAPL_GridCompSetEntryPoint(gridcomp, ESMF_METHOD_RUN, run, phase_name='run', _RC) - - outer_meta => get_outer_meta_from_inner_gc(gridcomp,_RC) - vertical_grid = BasicVerticalGrid(4) - call outer_meta%set_vertical_grid(vertical_grid) - - - _RETURN(_SUCCESS) - end subroutine setServices - - subroutine init(gridcomp, importState, exportState, clock, rc) - type(ESMF_GridComp) :: gridcomp - type(ESMF_State) :: importState - type(ESMF_State) :: exportState - type(ESMF_Clock) :: clock - integer, intent(out) :: rc - - integer :: status - - _RETURN(_SUCCESS) - end subroutine init - - subroutine run(gridcomp, importState, exportState, clock, rc) - !use mapl3g_MultiState - type(ESMF_GridComp) :: gridcomp - type(ESMF_State) :: importState - type(ESMF_State) :: exportState - type(ESMF_Clock) :: clock - integer, intent(out) :: rc - - integer :: status - character(len=ESMF_MAXSTR) :: gc_name - call ESMF_GridCompGet(gridcomp, name=gc_name, _RC) - print*,'running ',trim(gc_name) - call MAPL_RunChildren(gridcomp, phase_name='run', _RC) - _RETURN(_SUCCESS) - end subroutine run - -end module ConfigurableParentGridComp - -subroutine setServices(gridcomp,rc) - use ESMF - use MAPL_ErrorHandlingMod - use ConfigurableParentGridComp, only: ConfigurableParent_setServices => SetServices - type(ESMF_GridComp) :: gridcomp - integer, intent(out) :: rc - - integer :: status - - call ConfigurableParent_setServices(gridcomp,_RC) - _RETURN(_SUCCESS) - -end subroutine -