ESMF_GeomUTest Program

Uses

  • program~~esmf_geomutest~~UsesGraph program~esmf_geomutest ESMF_GeomUTest module~esmf ESMF program~esmf_geomutest->module~esmf module~esmf_testmod ESMF_TestMod program~esmf_geomutest->module~esmf_testmod

Calls

program~~esmf_geomutest~~CallsGraph program~esmf_geomutest ESMF_GeomUTest interface~esmf_geomcreate ESMF_GeomCreate program~esmf_geomutest->interface~esmf_geomcreate interface~esmf_gridcreatenoperidim ESMF_GridCreateNoPeriDim program~esmf_geomutest->interface~esmf_gridcreatenoperidim interface~esmf_vmget ESMF_VMGet program~esmf_geomutest->interface~esmf_vmget proc~esmf_finalize ESMF_Finalize program~esmf_geomutest->proc~esmf_finalize proc~esmf_geomdestroy ESMF_GeomDestroy program~esmf_geomutest->proc~esmf_geomdestroy proc~esmf_geommatch ESMF_GeomMatch program~esmf_geomutest->proc~esmf_geommatch proc~esmf_griddestroy ESMF_GridDestroy program~esmf_geomutest->proc~esmf_griddestroy proc~esmf_test ESMF_Test program~esmf_geomutest->proc~esmf_test proc~esmf_testend ESMF_TestEnd program~esmf_geomutest->proc~esmf_testend proc~esmf_teststart ESMF_TestStart program~esmf_geomutest->proc~esmf_teststart proc~esmf_vmgetglobal ESMF_VMGetGlobal program~esmf_geomutest->proc~esmf_vmgetglobal

Variables

Type Attributes Name Initial
character(len=*), parameter :: version = '$Id$'
character(len=ESMF_MAXSTR) :: failMsg
character(len=ESMF_MAXSTR) :: grid_name
character(len=ESMF_MAXSTR) :: name
integer :: localPet
integer :: localrc
integer :: petCount
integer :: rc
integer :: result = 0
logical :: shouldBeFalse
logical :: shouldBeTrue
type(ESMF_Geom) :: geom1
type(ESMF_Geom) :: geom2
type(ESMF_Geom) :: geomAlias
type(ESMF_GeomMatch_Flag) :: geomMatchFlag
type(ESMF_Grid) :: grid1
type(ESMF_Grid) :: grid2
type(ESMF_Grid) :: gridAlias
type(ESMF_VM) :: vm

Source Code

program ESMF_GeomUTest

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

#include "ESMF.h"
#include "ESMF_Macros.inc"

!==============================================================================
!BOP
! !PROGRAM: ESMF_GeomTest - Check Grid Create Routines
!
! !DESCRIPTION:
!
! The code in this file drives F90 Grid Create unit tests.
!
!-----------------------------------------------------------------------------
! !USES:
  use ESMF_TestMod     ! test methods
  use ESMF

  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 result code
  integer :: localrc, rc, localPet, petCount
  type(ESMF_VM) :: vm

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

  type(ESMF_Grid) :: grid1, grid2, gridAlias
  type(ESMF_Geom) :: geom1, geom2, geomAlias
  logical :: shouldBeFalse, shouldBeTrue
  type(ESMF_GeomMatch_Flag) :: geomMatchFlag  

  !-----------------------------------------------------------------------------
  call ESMF_TestStart(ESMF_SRCLINE, rc=rc)
  if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)
  !-----------------------------------------------------------------------------

  ! get global VM
  call ESMF_VMGetGlobal(vm, rc=rc)
  if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)
  call ESMF_VMGet(vm, localPet=localPet, petCount=petCount, rc=rc)
  if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)

  ! Create two different Grids to be used for testing below
  grid1=ESMF_GridCreateNoPeriDim(maxIndex=(/100,100/), rc=localrc)
  if (localrc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)

  grid2=ESMF_GridCreateNoPeriDim(maxIndex=(/200,200/), rc=localrc)
  if (localrc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)


  !------------------------------------------------------------------------
  !NEX_UTest
  ! Testing ESMF_GeomOperator(==)()    
  write(name, *) "Geom equality before assignment Test"
  write(failMsg, *) "Did not return ESMF_SUCCESS"
  shouldBeFalse = (geom1 == geom2)
  call ESMF_Test(.not. shouldBeFalse, name, failMsg, result, ESMF_SRCLINE)

  !------------------------------------------------------------------------
  !NEX_UTest
  write(name, *) "Geom non-equality before assignment Test"
  write(failMsg, *) "Did not return ESMF_SUCCESS"
  shouldBeTrue = (geom1 /= geom2)
  call ESMF_Test(shouldBeTrue, name, failMsg, result, ESMF_SRCLINE)

  !------------------------------------------------------------------------
  !NEX_UTest
  ! Testing ESMF_GeomAssignment(=)() 
  write(name, *) "Geom equality with alias test"
  write(failMsg, *) "Did not return ESMF_SUCCESS"

  ! Init
  rc=ESMF_SUCCESS
  
  ! Create geom
  geom1=ESMF_GeomCreate(grid1, rc=localrc)
  if (localrc /= ESMF_SUCCESS) rc=ESMF_FAILURE

  ! Assign alias
  geomAlias=geom1
  
  ! Test equality
  shouldBeTrue = (geom1 == geomAlias)

  ! Get rid of geom1
  call ESMF_GeomDestroy(geom1, rc=localrc)
  if (localrc /= ESMF_SUCCESS) rc=ESMF_FAILURE
  
  call ESMF_Test((shouldBeTrue .and. (rc==ESMF_SUCCESS)), name, failMsg, result, ESMF_SRCLINE)

  !------------------------------------------------------------------------
  !NEX_UTest
  ! Testing ESMF_GeomOperator(/=)()
  write(name, *) "Geom inequality with two different geoms"
  write(failMsg, *) "Did not return ESMF_SUCCESS"

  ! Init
  rc=ESMF_SUCCESS
  
  ! Create geom1
  geom1=ESMF_GeomCreate(grid1, rc=localrc)
  if (localrc /= ESMF_SUCCESS) rc=ESMF_FAILURE

  ! Create geom2
  geom2=ESMF_GeomCreate(grid2, rc=localrc)
  if (localrc /= ESMF_SUCCESS) rc=ESMF_FAILURE

  ! Test equality
  shouldBeTrue = (geom1 /= geom2)

  ! Get rid of geom1
  call ESMF_GeomDestroy(geom1, rc=localrc)
  if (localrc /= ESMF_SUCCESS) rc=ESMF_FAILURE

  ! Get rid of geom2
  call ESMF_GeomDestroy(geom2, rc=localrc)
  if (localrc /= ESMF_SUCCESS) rc=ESMF_FAILURE
  
  call ESMF_Test((shouldBeTrue .and. (rc==ESMF_SUCCESS)), name, failMsg, result, ESMF_SRCLINE)


  !------------------------------------------------------------------------
  !NEX_UTest
  write(name, *) "Geom match with the same geoms"
  write(failMsg, *) "Did not return ESMF_SUCCESS"

  ! Init
  rc=ESMF_SUCCESS
  
  ! Create geom1
  geom1=ESMF_GeomCreate(grid1, rc=localrc)
  if (localrc /= ESMF_SUCCESS) rc=ESMF_FAILURE

  ! Get Match
  geomMatchFlag=ESMF_GeomMatch(geom1, geom1, rc=localrc)
  if (localrc /= ESMF_SUCCESS) rc=ESMF_FAILURE

 
  ! Get rid of geom1
  call ESMF_GeomDestroy(geom1, rc=localrc)
  if (localrc /= ESMF_SUCCESS) rc=ESMF_FAILURE
  
  call ESMF_Test((geomMatchFlag == ESMF_GEOMMATCH_ALIAS) .and. (rc == ESMF_SUCCESS), &
       name, failMsg, result, ESMF_SRCLINE)


  !------------------------------------------------------------------------
  !NEX_UTest
  write(name, *) "Geom match with different geoms with the same grid"
  write(failMsg, *) "Did not return ESMF_SUCCESS"

  ! Init
  rc=ESMF_SUCCESS
  
  ! Create geom1
  geom1=ESMF_GeomCreate(grid1, rc=localrc)
  if (localrc /= ESMF_SUCCESS) rc=ESMF_FAILURE

  ! Create geom2
  geom2=ESMF_GeomCreate(grid1, rc=localrc)
  if (localrc /= ESMF_SUCCESS) rc=ESMF_FAILURE

  ! Get Match
  geomMatchFlag=ESMF_GeomMatch(geom1, geom2, rc=localrc)
  if (localrc /= ESMF_SUCCESS) rc=ESMF_FAILURE

  ! Get rid of geom1
  call ESMF_GeomDestroy(geom1, rc=localrc)
  if (localrc /= ESMF_SUCCESS) rc=ESMF_FAILURE

  ! Get rid of geom2
  call ESMF_GeomDestroy(geom2, rc=localrc)
  if (localrc /= ESMF_SUCCESS) rc=ESMF_FAILURE
  
  call ESMF_Test((geomMatchFlag == ESMF_GEOMMATCH_GEOMALIAS), name, failMsg, result, ESMF_SRCLINE)


  !------------------------------------------------------------------------
  !NEX_UTest
  write(name, *) "Geom match with different geoms with different grids"
  write(failMsg, *) "Did not return ESMF_SUCCESS"

  ! Init
  rc=ESMF_SUCCESS
  
  ! Create geom1
  geom1=ESMF_GeomCreate(grid1, rc=localrc)
  if (localrc /= ESMF_SUCCESS) rc=ESMF_FAILURE

  ! Create geom2
  geom2=ESMF_GeomCreate(grid2, rc=localrc)
  if (localrc /= ESMF_SUCCESS) rc=ESMF_FAILURE

  ! Get Match
  geomMatchFlag=ESMF_GeomMatch(geom1, geom2, rc=localrc)
  if (localrc /= ESMF_SUCCESS) rc=ESMF_FAILURE

  ! Get rid of geom1
  call ESMF_GeomDestroy(geom1, rc=localrc)
  if (localrc /= ESMF_SUCCESS) rc=ESMF_FAILURE

  ! Get rid of geom2
  call ESMF_GeomDestroy(geom2, rc=localrc)
  if (localrc /= ESMF_SUCCESS) rc=ESMF_FAILURE
  
  call ESMF_Test((geomMatchFlag == ESMF_GEOMMATCH_NONE), name, failMsg, result, ESMF_SRCLINE)

 !------------------------ Cleanup after testing --------------------------------------------
  
  ! Get rid of test Grids
  call ESMF_GridDestroy(grid1)
  call ESMF_GridDestroy(grid2)
 
  
  !-----------------------------------------------------------------------------
  ! Stop testing
  call ESMF_TestEnd(ESMF_SRCLINE)
  !-----------------------------------------------------------------------------

end program ESMF_GeomUTest