program ESMF_VMUTest
!------------------------------------------------------------------------------
!==============================================================================
!BOP
! !PROGRAM: ESMF_VMTest - This unit test file verifies VM methods.
!
! !DESCRIPTION:
!
! The code in this file drives F90 VM unit tests.
! The companion file ESMF\_VM.F90 contains the definitions for the
! VM methods.
!
!-----------------------------------------------------------------------------
! !USES:
use ESMF_TestMod ! test methods
use ESMF
use ESMF_VMSubrs_UMI ! VM specific subroutines
implicit none
#ifndef ESMF_MPIUNI
integer:: ierr
#endif
!------------------------------------------------------------------------------
! The following line turns the CVS identifier string into a printable variable.
character(*), parameter :: version = &
'$Id$'
!------------------------------------------------------------------------------
!-------------------------------------------------------------------------------
! The unit tests are divided into Sanity and Exhaustive. The Sanity tests are
! always run. When the environment variable, EXHAUSTIVE, is set to ON then
! the EXHAUSTIVE and sanity tests both run. If the EXHAUSTIVE variable is set
! to OFF, then only the sanity unit tests.
! Special strings (Non-exhaustive and exhaustive) have been
! added to allow a script to count the number and types of unit tests.
!-------------------------------------------------------------------------------
! testing that VM is o.k. with user initializing MPI
#ifndef ESMF_MPIUNI
call MPI_Init(ierr)
print *, "The user code called MPI_Init() and does IO before ESMF_Initialize() is called"
#else
print *, "This test is meaningless in MPIUNI mode!"
#endif
call ESMF_TestStart(ESMF_SRCLINE, rc=rc)
if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)
!------------------------------------------------------------------------
!NEX_UTest
write(failMsg, *) "Did not return ESMF_SUCCESS"
write(name, *) "VM Get Global Test"
call ESMF_VMGetGlobal(vm, rc=rc)
call ESMF_Test((rc.eq.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
!------------------------------------------------------------------------
!NEX_UTest
write(failMsg, *) "Did not return ESMF_SUCCESS"
write(name, *) "VM Get Test"
call ESMF_VMGet(vm, petCount=npets, rc=rc)
call ESMF_Test((rc.eq.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
!------------------------------------------------------------------------
!NEX_UTest
write(failMsg, *) "Did not return ESMF_SUCCESS"
write(name, *) "VM print Test"
call ESMF_VMPrint(vm, rc=rc)
call ESMF_Test((rc.eq.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
#ifdef ESMF_TESTEXHAUSTIVE
!------------------------------------------------------------------------
!EX_UTest
write(failMsg, *) "Did not return ESMF_SUCCESS"
write(name, *) "VM Get Test"
call ESMF_VMGet(vm, localPet=localPet, petCount=npets, rc=rc)
call ESMF_Test((rc.eq.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
!------------------------------------------------------------------------
! allocate data arrays
nsize = 2
allocate(array1(nsize))
allocate(farray1(nsize))
allocate(f4array1(nsize))
allocate(array3(nsize))
allocate(farray3(nsize))
allocate(f4array3(nsize))
allocate(array3_soln(nsize))
allocate(farray3_soln(nsize))
allocate(f4array3_soln(nsize))
! prepare data array1, farray1, f4array1
do i=1, nsize
array1(i) = localPet * 100 + i
farray1(i)= real(array1(i), ESMF_KIND_R8)
f4array1(i)=real(farray1(i), ESMF_KIND_R4)
enddo
! Populate array2
allocate(array2(nsize,npets))
allocate(farray2(nsize,npets))
allocate(f4array2(nsize,npets))
do j=1, npets
do i=1, nsize
array2(i,j) = (j-1) * 100 + i
farray2(i,j) = real(array2(i,j), ESMF_KIND_R8)
f4array2(i,j) = real(farray2(i,j), ESMF_KIND_R4)
enddo
enddo
call test_AllFullReduce_sum
call test_allReduce_sum
call test_AllFullReduce_min
call test_AllReduce_min
call test_AllFullReduce_max
call test_AllReduce_max
!------------------------------------------------------------------------
! deallocate data arrays
deallocate(array1)
deallocate(farray1)
deallocate(f4array1)
deallocate(array3)
deallocate(farray3)
deallocate(f4array3)
deallocate(array3_soln)
deallocate(farray3_soln)
deallocate(f4array3_soln)
deallocate(array2)
deallocate(farray2)
deallocate(f4array2)
#endif
call ESMF_TestEnd(ESMF_SRCLINE)
end program ESMF_VMUTest