subroutine test_pointlist_from_locStream_nomask(rc)
integer, intent(out) :: rc
integer :: localrc
!LOCAL VARIABLES:
type(ESMF_PointList) :: pointlist
type(ESMF_VM) :: vm
integer :: maxpts, mydims, mypts, myid
type(ESMF_Mesh) :: myMesh
integer :: numNodes
integer :: numTriElems, numQuadElems, numTotElems
integer, pointer :: elemIds(:),elemTypes(:),elemConn(:)
integer, pointer :: nodeIds(:), nodeOwners(:)
real(ESMF_KIND_R8), pointer :: nodeCoords(:)
real(ESMF_KIND_R8), pointer :: elemCoords(:)
integer :: petCount,localPet
integer, pointer :: elemMask(:)
integer(ESMF_KIND_I4) :: maskValues(2)
integer :: local_pts
real(ESMF_KIND_R8), dimension(3) :: test_coords
real(ESMF_KIND_R8) my_err1,my_err2,my_err3
real(ESMF_KIND_R8), pointer :: temperature(:)
real(ESMF_KIND_R8), allocatable :: lat(:),lon(:)
integer :: i
type(ESMF_LocStream) :: myLocStream
type(ESMF_Field) :: field_temperature
! get global VM
call ESMF_VMGetGlobal(vm, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_VMGet(vm, localPet=localPet, petCount=petCount, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! If we don't have 1 or 4 PETS then exit successfully
if ((petCount .ne. 1) .and. (petCount .ne. 4)) then
print*,'ERROR: test must be run using exactly 1 or 4 PETS - detected ',petCount
rc=ESMF_FAILURE
return
endif
! setup source locStream
local_pts=6
!-------------------------------------------------------------------
! Allocate and set example Field data
!-------------------------------------------------------------------
allocate(temperature(local_pts))
allocate(lat(local_pts))
allocate(lon(local_pts))
do i=1,local_pts
temperature(i)=80.0+i
lon(i)=(i-1)*360.0/local_pts
lat(i)=0.0
enddo
!-------------------------------------------------------------------
! Create the LocStream: Allocate space for the LocStream object,
! define the number and distribution of the locations.
!-------------------------------------------------------------------
myLocStream=ESMF_LocStreamCreate(name="Equatorial Measurements", &
localCount=local_pts, &
coordSys=ESMF_COORDSYS_SPH_DEG, &
rc=localrc)
if (localrc /=ESMF_SUCCESS) then
print*,'ERROR: trouble creating locStream'
rc=ESMF_FAILURE
return
endif
!-------------------------------------------------------------------
! Add key data (internally allocating memory).
!-------------------------------------------------------------------
call ESMF_LocStreamAddKey(myLocStream, &
keyName="ESMF:Lat", &
farray=lat, &
datacopyflag=ESMF_DATACOPY_REFERENCE, &
keyUnits="Degrees", &
keyLongName="Latitude", rc=localrc)
if (localrc /=ESMF_SUCCESS) then
print*,'ERROR: trouble adding LocStream key for Lat'
rc=ESMF_FAILURE
return
endif
call ESMF_LocStreamAddKey(myLocStream, &
keyName="ESMF:Lon", &
farray=lon, &
datacopyflag=ESMF_DATACOPY_REFERENCE, &
keyUnits="Degrees", &
keyLongName="Longitude", rc=localrc)
if (localrc /=ESMF_SUCCESS) then
print*,'ERROR: trouble adding LocStream key for Lon'
rc=ESMF_FAILURE
return
endif
!-------------------------------------------------------------------
! Create a Field on the Location Stream. In this case the
! Field is created from a user array, but any of the other
! Field create methods (e.g. from ArraySpec) would also apply.
!-------------------------------------------------------------------
field_temperature=ESMF_FieldCreate(myLocStream, &
temperature, &
name="temperature", &
rc=localrc)
if (localrc /=ESMF_SUCCESS) then
print*,'ERROR: trouble creating field on locStream'
rc=ESMF_FAILURE
return
endif
pointlist=ESMF_PointListCreate(myLocStream, rc=localrc)
if (localrc /= ESMF_SUCCESS) then
print*,'ERROR: trouble creating pointlist'
rc=ESMF_FAILURE
return
endif
call ESMF_PointListGet(pointlist, dims=mydims, numpts=mypts, maxpts=maxpts, rc=localrc)
if (localrc /= ESMF_SUCCESS) then
print*,'ERROR: trouble accessing pointlist data with get routine'
rc=ESMF_FAILURE
return
endif
! call ESMF_PointListPrint(pointlist)
! if (localrc /= ESMF_SUCCESS) then
! rc=ESMF_FAILURE
! return
! endif
if (maxpts .ne. local_pts .or. mypts .ne. local_pts .or. mydims .ne. 3) then
print*,'ERROR: unexpected values for newly created pointlist:'
print*,'maxpts should be: ',local_pts,' got: ',maxpts
print*,'numpts should be: ',local_pts,' got: ',mypts
print*,'dims should be: 2 got: ',mydims
rc=ESMF_FAILURE
return
endif
if (local_pts .gt. 0) then
!locations values are zero based
call ESMF_PointListGetForLoc(pointlist,1,loc_coords=test_coords,rc=localrc)
if (localrc /= ESMF_SUCCESS) then
print*,'ERROR: trouble accessing pointlist data with get for location routine'
rc=ESMF_FAILURE
return
endif
my_err1 = abs(test_coords(1) - 0.5)
my_err2 = abs(test_coords(2) - 0.866)
my_err3 = abs(test_coords(3) - 0.0)
if (my_err1 .gt. .0001 .or. my_err2 .gt. .0001 .or. my_err3 .gt. .0001) then
print*,'ERROR: unexpected coordinates for queried pointlist location:'
print*,'expected ( 0.5 , 0.866 , 0 ) got (',test_coords(1),',',test_coords(2),',',test_coords(3),')'
rc=ESMF_FAILURE
return
endif
endif
deallocate(temperature)
deallocate(lon)
deallocate(lat)
call ESMF_PointListDestroy(pointlist,rc=localrc)
if (localrc /= ESMF_SUCCESS) then
print*,'ERROR: trouble destroying pointlist'
rc=ESMF_FAILURE
return
endif
call ESMF_LocStreamDestroy(myLocStream, rc=localrc)
if (localrc /=ESMF_SUCCESS) then
print*,'ERROR: trouble destroying LocStream'
rc=ESMF_FAILURE
return
endif
rc=ESMF_SUCCESS
end subroutine test_pointlist_from_locStream_nomask