program StringTest
#include "ESMF.h"
use ESMF
use ESMF_TestMod
implicit none
integer :: rc, result
character(len=ESMF_MAXSTR) :: failMsg, name
character(len=120) :: fstr
character(len=60) :: fstr2
integer :: i1, i2, i3, i4
external f90ints, f90string2, f90string3
character(len=*), parameter :: &
str1 = "1234567890"
character(len=*), parameter :: &
str2 = "12345678901234567890"
character(len=*), parameter :: &
str3 = "123456789012345678901234567890"
character(len=*), parameter :: &
str4 = "1234567890123456789012345678901234567890"
character(len=*), parameter :: &
str5 = "12345678901234567890123456789012345678901234567890"
!------------------------------------------------------------------------
! test of passing ints and strings between F90 and C++
result = 0
call ESMF_TestStart(ESMF_SRCLINE, rc=rc)
if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)
!------------------------------------------------------------------------
!------------------------------------------------------------------------
! warning: if you change these values, you also have to
! change them in the subroutines below.
i1 = 102
i2 = 204
i3 = 409
i4 = 819
fstr = "abcdefghijklmnopqrstuvwxyz0123456789"
fstr2 = "0123456789abcdefghijklmnopqrstuvwxyz"
!------------------------------------------------------------------------
!NEX_UTest
write(failMsg,*) "Failure calling f90ints() directly from F90"
write(name, *) "Calling f90ints() directly from F90"
call f90ints(i1, i2, i3, i4, rc)
call ESMF_Test((rc .eq. ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
!------------------------------------------------------------------------
!NEX_UTest
write(failMsg,*) "Failure calling f90string2() directly from F90"
write(name, *) "Calling f90string2() directly from F90"
call f90string2(i1, i2, fstr2, i3, i4, rc)
call ESMF_Test((rc .eq. ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
!------------------------------------------------------------------------
!NEX_UTest
write(failMsg,*) "Failure calling f90string3() directly from F90"
write(name, *) "Calling f90string3() directly from F90"
call f90string3(i1, fstr, i2, fstr2, i3, i4, rc)
call ESMF_Test((rc .eq. ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
!------------------------------------------------------------------------
!NEX_UTest
write(failMsg,*) "Failure calling c_strings with fstr"
write(name, *) "Calling c_strings with fstr"
call c_strings(f90ints, f90string2, f90string3, i1, i2, fstr, i3, i4, rc)
call ESMF_Test((rc .eq. ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
!------------------------------------------------------------------------
!NEX_UTest
write(failMsg,*) "Failure in c_5strings"
write(name, *) "Calling c_5strings"
call c_5strings(str1, str2, str3, str4, str5, rc)
call ESMF_Test((rc .eq. ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
!------------------------------------------------------------------------
!------------------------------------------------------------------------
#ifdef ESMF_TESTEXHAUSTIVE
!------------------------------------------------------------------------
!------------------------------------------------------------------------
!------------------------------------------------------------------------
!EX_UTest
write(failMsg,*) "Failure calling c_strings with fstr2"
write(name, *) "Calling c_strings with fstr2"
call c_strings(f90ints, f90string2, f90string3, i1, i2, fstr2, i3, i4, rc)
call ESMF_Test((rc .eq. ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
!------------------------------------------------------------------------
!------------------------------------------------------------------------
#endif
call ESMF_TestEnd(ESMF_SRCLINE)
end program StringTest