ESMF_StateReconcileProxyUTest Program

Uses

  • program~~esmf_statereconcileproxyutest~~UsesGraph program~esmf_statereconcileproxyutest ESMF_StateReconcileProxyUTest module~esmf ESMF program~esmf_statereconcileproxyutest->module~esmf module~esmf_testmod ESMF_TestMod program~esmf_statereconcileproxyutest->module~esmf_testmod module~subcomp_mod subcomp_mod program~esmf_statereconcileproxyutest->module~subcomp_mod

Calls

program~~esmf_statereconcileproxyutest~~CallsGraph program~esmf_statereconcileproxyutest ESMF_StateReconcileProxyUTest esmf_arrayget esmf_arrayget program~esmf_statereconcileproxyutest->esmf_arrayget esmf_fieldget esmf_fieldget program~esmf_statereconcileproxyutest->esmf_fieldget esmf_gridcompsetservices esmf_gridcompsetservices program~esmf_statereconcileproxyutest->esmf_gridcompsetservices esmf_statecreate esmf_statecreate program~esmf_statereconcileproxyutest->esmf_statecreate esmf_statedestroy esmf_statedestroy program~esmf_statereconcileproxyutest->esmf_statedestroy esmf_stateget esmf_stateget program~esmf_statereconcileproxyutest->esmf_stateget interface~esmf_vmget ESMF_VMGet program~esmf_statereconcileproxyutest->interface~esmf_vmget proc~esmf_finalize ESMF_Finalize program~esmf_statereconcileproxyutest->proc~esmf_finalize proc~esmf_gridcompcreate ESMF_GridCompCreate program~esmf_statereconcileproxyutest->proc~esmf_gridcompcreate proc~esmf_gridcompdestroy ESMF_GridCompDestroy program~esmf_statereconcileproxyutest->proc~esmf_gridcompdestroy proc~esmf_gridcompfinalize ESMF_GridCompFinalize program~esmf_statereconcileproxyutest->proc~esmf_gridcompfinalize proc~esmf_gridcompinitialize ESMF_GridCompInitialize program~esmf_statereconcileproxyutest->proc~esmf_gridcompinitialize proc~esmf_statereconcile ESMF_StateReconcile program~esmf_statereconcileproxyutest->proc~esmf_statereconcile proc~esmf_test ESMF_Test program~esmf_statereconcileproxyutest->proc~esmf_test proc~esmf_testend ESMF_TestEnd program~esmf_statereconcileproxyutest->proc~esmf_testend proc~esmf_teststart ESMF_TestStart program~esmf_statereconcileproxyutest->proc~esmf_teststart proc~esmf_vmgetglobal ESMF_VMGetGlobal program~esmf_statereconcileproxyutest->proc~esmf_vmgetglobal

Variables

Type Attributes Name Initial
character(len=*), parameter :: version = '$Id$'
character(len=ESMF_MAXSTR) :: failMsg
character(len=ESMF_MAXSTR) :: name
integer :: i
integer :: j
integer :: petCount
integer, allocatable :: petList(:)
integer :: rc
integer :: result = 0
type(ESMF_Array) :: array
type(ESMF_DistGrid) :: dg1
type(ESMF_DistGrid) :: dg2
type(ESMF_Field) :: field
type(ESMF_Field) :: fieldRe
type(ESMF_FieldBundle) :: fb
type(ESMF_FieldBundle) :: fbRe
type(ESMF_Grid) :: g1
type(ESMF_Grid) :: g2
type(ESMF_GridComp) :: subcomp
type(ESMF_LocStream) :: l1
type(ESMF_LocStream) :: l2
type(ESMF_Mesh) :: m1
type(ESMF_Mesh) :: m2
type(ESMF_State) :: exportState
type(ESMF_VM) :: vm

Source Code

program ESMF_StateReconcileProxyUTest

!------------------------------------------------------------------------------
 
#include "ESMF_Macros.inc"

!==============================================================================
!BOP
! !PROGRAM: ESMF_StateReconcileProxyUTest - Unit test 
!
! !DESCRIPTION:
!
! Test correct properties and behavior of proxy objects created during
! StateReconcile.
!
!-----------------------------------------------------------------------------
! !USES:
  use ESMF_TestMod     ! test methods
  use ESMF
  use subcomp_mod

  implicit none

!------------------------------------------------------------------------------
  ! The following line turns the CVS identifier string into a printable variable.
  character(*), parameter :: version = &
    '$Id$'
!------------------------------------------------------------------------------
  ! cumulative result: count failures; no failures equals "all pass"
  integer :: result = 0

  ! individual test failure message
  character(ESMF_MAXSTR) :: failMsg
  character(ESMF_MAXSTR) :: name

  ! local variables
  integer:: i, j, rc
  integer:: petCount
  integer, allocatable  :: petList(:)
  type(ESMF_VM)         :: vm
  type(ESMF_GridComp)   :: subcomp
  type(ESMF_State)      :: exportState
  type(ESMF_Array)      :: array
  type(ESMF_DistGrid)   :: dg1, dg2
  type(ESMF_Field)      :: field, fieldRe
  type(ESMF_Grid)       :: g1, g2
  type(ESMF_Mesh)       :: m1, m2
  type(ESMF_LocStream)  :: l1, l2
  type(ESMF_FieldBundle):: fb, fbRe
  
  call ESMF_TestStart(ESMF_SRCLINE, rc=rc)
  if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)
  
  ! Create State
  exportState = ESMF_StateCreate(rc=rc)
  if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)  

  ! Get global VM info
  call ESMF_VMGetGlobal(vm, rc=rc)
  if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)
  
  call ESMF_VMGet(vm, petCount=petCount, rc=rc)
  if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)
  
  ! Construct reduced petList for sub component
  allocate(petList(petCount/2))
  j = 0
  do i=1, petCount/2
    petList(i) = j
    j = j + 2
  enddo
  
  ! Create sub component on reduced petList
  subcomp = ESMF_GridCompCreate(name="sub-component", petList=petList, rc=rc)
  if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)

  ! Sub component SetServices
  call ESMF_GridCompSetServices(subcomp, userRoutine=SetServices, rc=rc)
  if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)
  
  ! Sub component Initialize
  call ESMF_GridCompInitialize(subcomp, exportState=exportState, rc=rc)
  if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)
  
  ! Reconcile the State
  !NEX_UTest_Multi_Proc_Only
  call ESMF_StateReconcile(exportState, checkflag=.true., rc=rc)
  write(name, *) "Reconciling a State"
  write(failMsg, *) "Did not return ESMF_SUCCESS"
  call ESMF_Test((rc.eq.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
  
  ! Extract the DistGrid from the two Array objects in the State
  call ESMF_StateGet(exportState, "array1", array=array, rc=rc)
  if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)
  call ESMF_ArrayGet(array, distgrid=dg1, rc=rc)
  if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)
  !-
  call ESMF_StateGet(exportState, "array2", array=array, rc=rc)
  if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)
  call ESMF_ArrayGet(array, distgrid=dg2, rc=rc)
  if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)

  ! NOTE: This test is disabled until DistGrid aliasing is implemented in
  ! StateReconcile.
!  ! Test whether dg1 and dg2 are aliases to the same DistGrid in memory
!  !NEX_disabled_UTest_Multi_Proc_Only
!  write(name, *) "Ensure dg1 and dg2 are aliases to the same DistGrid Test"
!  write(failMsg, *) "Found non-aliased DistGrid objects!"
!  call ESMF_Test((dg1==dg2), name, failMsg, result, ESMF_SRCLINE)

  ! Extract the Grid from two Field objects in the State built on same Grid
  call ESMF_StateGet(exportState, "field1G", field=field, rc=rc)
  if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)
  call ESMF_FieldGet(field, grid=g1, rc=rc)
  if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)
  !-
  call ESMF_StateGet(exportState, "field2G", field=field, rc=rc)
  if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)
  call ESMF_FieldGet(field, grid=g2, rc=rc)
  if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)
  
  ! Test whether g1 and g2 are aliases to the same Grid in memory
  !NEX_UTest_Multi_Proc_Only
  write(name, *) "Ensure g1 and g2 are aliases to the same Grid (proxy) Test"
  write(failMsg, *) "Found non-aliased Grid (proxy) objects!"
  call ESMF_Test((g1==g2), name, failMsg, result, ESMF_SRCLINE)

  ! Extract the Mesh from two Field objects in the State built on same Mesh
  call ESMF_StateGet(exportState, "field1M", field=field, rc=rc)
  if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)
  call ESMF_FieldGet(field, mesh=m1, rc=rc)
  if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)
  !-
  call ESMF_StateGet(exportState, "field2M", field=field, rc=rc)
  if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)
  call ESMF_FieldGet(field, mesh=m2, rc=rc)
  if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)
  
  ! Test whether m1 and m2 are aliases to the same Mesh in memory
  !NEX_UTest_Multi_Proc_Only
  write(name, *) "Ensure m1 and m2 are aliases to the same Mesh (proxy) Test"
  write(failMsg, *) "Found non-aliased Mesh (proxy) objects!"
  call ESMF_Test((m1==m2), name, failMsg, result, ESMF_SRCLINE)

  ! Extract the LocStream from two Field objects in the State built on same LocStream
  call ESMF_StateGet(exportState, "field1L", field=field, rc=rc)
  if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)
  call ESMF_FieldGet(field, locStream=l1, rc=rc)
  if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)
  !-
  call ESMF_StateGet(exportState, "field2L", field=field, rc=rc)
  if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)
  call ESMF_FieldGet(field, locStream=l2, rc=rc)
  if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)
  
  ! Test whether l1 and l2 are aliases to the same LocStream in memory
  !NEX_UTest_Multi_Proc_Only
  write(name, *) "Ensure l1 and l2 are aliases to the same LocStream (proxy) Test"
  write(failMsg, *) "Found non-aliased LocStream (proxy) objects!"
  call ESMF_Test((l1==l2), name, failMsg, result, ESMF_SRCLINE)

  call ESMF_StateGet(exportState, "fb", fieldbundle=fb, rc=rc)
  if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)

  ! Re-Reconcile the State
  !NEX_UTest_Multi_Proc_Only
  call ESMF_StateReconcile(exportState, checkflag=.true., rc=rc)
  write(name, *) "Re-Reconciling a State"
  write(failMsg, *) "Did not return ESMF_SUCCESS"
  call ESMF_Test((rc.eq.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)

  call ESMF_StateGet(exportState, "field2L", field=fieldRe, rc=rc)
  if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)

  ! Test whether field and fieldRe are aliases
  !NEX_UTest_Multi_Proc_Only
  write(name, *) "Ensure Re-Reconcile Field (proxy) persistence Test"
  write(failMsg, *) "Found non-persistent Field (proxy) objects!"
  call ESMF_Test((field==fieldRe), name, failMsg, result, ESMF_SRCLINE)

  call ESMF_StateGet(exportState, "fb", fieldbundle=fbRe, rc=rc)
  if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)

  ! Test whether fb and fbRe are aliases
  !NEX_UTest_Multi_Proc_Only
  write(name, *) "Ensure Re-Reconcile FieldBundle (proxy) persistence Test"
  write(failMsg, *) "Found non-persistent FieldBundle (proxy) objects!"
  call ESMF_Test((fb==fbRe), name, failMsg, result, ESMF_SRCLINE)

  ! Sub component Finalize
  call ESMF_GridCompFinalize(subcomp, exportState=exportState, rc=rc)
  if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)

  ! clean-up
  deallocate(petList)

  ! Destroy sub component
  call ESMF_GridCompDestroy(subcomp, rc=rc)
  if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)
  
  ! Destroy State
  call ESMF_StateDestroy(exportState, rc=rc)
  if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)

  !----------------------------------------------------------------

  call ESMF_TestEnd(ESMF_SRCLINE)
  
end program ESMF_StateReconcileProxyUTest