program ESMF_TraceEx
!EOC
!==============================================================================
!ESMF_EXAMPLE String used by test script to count examples.
!==============================================================================
#include "ESMF.h"
! !PROGRAM: ESMF\_Trace - Examples of Trace usage.
!
! !DESCRIPTION:
!
! This program shows examples of Trace usage
!BOC
! Use ESMF framework module
use ESMF
use SimpleComp, only: SetServices
!EOC
use ESMF_TestMod
!BOC
implicit none
! Local variables
integer :: rc, finalrc, i
type(ESMF_GridComp) :: gridcomp
!EOC
integer :: petCount, localPet, &
itemCount, count, result
type(ESMF_VM) :: vm
character(ESMF_MAXSTR) :: name
character(ESMF_MAXSTR) :: testname
character(ESMF_MAXSTR) :: failMsg
!-------------------------------------------------------------------------
!-------------------------------------------------------------------------
write(failMsg, *) "Example failure"
write(testname, *) "Example ESMF_TraceEx"
! ------------------------------------------------------------------------------
! ------------------------------------------------------------------------------
!BOC
! initialize ESMF
finalrc = ESMF_SUCCESS
call ESMF_Initialize(vm=vm, defaultlogfilename="TraceEx.Log", &
logkindflag=ESMF_LOGKIND_MULTI, rc=rc)
!EOC
if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)
! get the vm
call ESMF_VMGet(vm, petCount=petCount, localPet=localPet, rc=rc)
if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)
if (localPet==0) then
print *, "--------------------------------------- "
print *, "Start of ESMF_Trace Example"
print *, "--------------------------------------- "
endif
!BOC
! create the component and then execute
! initialize, run, and finalize routines
gridcomp = ESMF_GridCompCreate(name="test", rc=rc)
!EOC
if (rc /= ESMF_SUCCESS) finalrc = ESMF_FAILURE
!BOC
call ESMF_GridCompSetServices(gridcomp, userRoutine=SetServices, rc=rc)
!EOC
if (rc /= ESMF_SUCCESS) finalrc = ESMF_FAILURE
!BOC
call ESMF_GridCompInitialize(gridcomp, rc=rc)
!EOC
if (rc /= ESMF_SUCCESS) finalrc = ESMF_FAILURE
!BOC
do i=1, 5
call ESMF_GridCompRun(gridcomp, rc=rc)
enddo
!EOC
if (rc /= ESMF_SUCCESS) finalrc = ESMF_FAILURE
!BOC
call ESMF_GridCompFinalize(gridcomp, rc=rc)
!EOC
if (rc /= ESMF_SUCCESS) finalrc = ESMF_FAILURE
!BOC
call ESMF_GridCompDestroy(gridcomp, rc=rc)
!EOC
if (rc /= ESMF_SUCCESS) finalrc = ESMF_FAILURE
! IMPORTANT: ESMF_STest() prints the PASS string and the # of processors in the log
! file that the scripts grep for.
call ESMF_STest((finalrc.eq.ESMF_SUCCESS), testname, failMsg, result, ESMF_SRCLINE)
!BOC
call ESMF_Finalize(rc=rc)
!EOC
if (localPet==0) then
print *, "--------------------------------------- "
print *, "End of ESMF_Trace Example"
print *, "--------------------------------------- "
endif
if (rc/=ESMF_SUCCESS) finalrc = ESMF_FAILURE
if (finalrc==ESMF_SUCCESS) then
print *, "PASS: ESMF_TraceEx.F90"
else
print *, "FAIL: ESMF_TraceEx.F90"
endif
!BOC
end program ESMF_TraceEx