program ESMF_WebServicesSTest
#define ESMF_METHOD "program ESMF_WebServicesSTest"
#include "ESMF.h"
! ESMF Framework module
use ESMF
use ESMF_TestMod
use ESMF_WebServMod
use ESMF_WebServUserModel
implicit none
! Local variables
integer :: rc = ESMF_SUCCESS
character(len=ESMF_MAXSTR) :: cname1
type(ESMF_VM) :: vm
type(ESMF_GridComp) :: comp1
integer :: portNum
integer :: localrc
! cumulative result: count failures; no failures equals "all pass"
integer :: result = 0
! individual test name
character(ESMF_MAXSTR) :: testname
! individual test failure message, and final status msg
character(ESMF_MAXSTR) :: failMsg, finalMsg
!-------------------------------------------------------------------------
!-------------------------------------------------------------------------
write(testname, *) "System Test ESMF_WebServicesSTest"
write(failMsg, *) "System Test failure"
!-------------------------------------------------------------------------
!-------------------------------------------------------------------------
print *, "--------------------------------------- "
print *, "Start of ", trim(testname)
print *, "--------------------------------------- "
!-------------------------------------------------------------------------
!-------------------------------------------------------------------------
! Create section
!-------------------------------------------------------------------------
!-------------------------------------------------------------------------
!
! Initialize framework and get back default global VM
call ESMF_Initialize(vm=vm, defaultlogfilename="WebServicesSTest.Log", &
logkindflag=ESMF_LOGKIND_MULTI, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) &
call ESMF_Finalize(rc=rc, endflag=ESMF_END_ABORT)
call ESMF_LogSet (flush=.true.)
! Create the model component
cname1 = "user model 1"
comp1 = ESMF_GridCompCreate(name=cname1, rc=localrc)
print *, "Created component ", trim(cname1), "rc =", localrc
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) &
call ESMF_Finalize(rc=rc, endflag=ESMF_END_ABORT)
print *, "Comp Create finished"
!-------------------------------------------------------------------------
!-------------------------------------------------------------------------
! Register section
!-------------------------------------------------------------------------
!-------------------------------------------------------------------------
call ESMF_GridCompSetServices(comp1, &
userRoutine=ESMF_WebServUserModelRegister, rc=localrc)
print *, "Comp1 SetServices finished, rc= ", localrc
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) &
call ESMF_Finalize(rc=rc, endflag=ESMF_END_ABORT)
!-------------------------------------------------------------------------
!-------------------------------------------------------------------------
! Start Loop section
!-------------------------------------------------------------------------
!-------------------------------------------------------------------------
rc = ESMF_SUCCESS
portNum = 27060
call ESMF_WebServicesLoop(comp1, portNum, rc=rc)
!-------------------------------------------------------------------------
!-------------------------------------------------------------------------
! Destroy section
!-------------------------------------------------------------------------
!-------------------------------------------------------------------------
call ESMF_GridCompDestroy(comp1, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) &
call ESMF_Finalize(rc=rc, endflag=ESMF_END_ABORT)
print *, "All Destroy routines done"
!-------------------------------------------------------------------------
!-------------------------------------------------------------------------
10 continue
! Normal ESMF Test output
print *, testname, " complete."
if (rc .eq. ESMF_SUCCESS) then
! Separate message to console, for quick confirmation of success/failure
write(finalMsg, *) "SUCCESS: ",trim(testname)," finished correctly."
write(0, *) ""
write(0, *) trim(testname)
write(0, *) trim(finalMsg)
write(0, *) ""
endif
print *, "------------------------------------------------------------"
print *, "------------------------------------------------------------"
! print *, "Test finished, localPet = ", localPet
print *, "Test finished, rc = ", rc
print *, "------------------------------------------------------------"
print *, "------------------------------------------------------------"
! IMPORTANT: ESMF_STest() prints the PASS string and the # of processors in the log
! file that the scripts grep for.
call ESMF_STest((rc.eq.ESMF_SUCCESS), testname, failMsg, result, ESMF_SRCLINE)
call ESMF_Finalize()
end program ESMF_WebServicesSTest