subroutine bundle_test1_generic(rc, datacopyflag, do_slicing, do_slicing1)
integer :: rc
type(ESMF_DataCopy_Flag), optional, intent(in) :: datacopyflag
logical, optional, intent(in) :: do_slicing
logical, optional, intent(in) :: do_slicing1
type(ESMF_FieldBundle) :: bundle
type(ESMF_Grid) :: grid
integer :: localrc
integer :: fieldCount, i
type(ESMF_Field) :: field
real(ESMF_KIND_R4), dimension(:,:), pointer :: farray1
real(ESMF_KIND_R4), dimension(:,:), pointer :: farray2
real(ESMF_KIND_R4), dimension(:,:), pointer :: farray3
real(ESMF_KIND_R4), dimension(:,:), pointer :: farray4
rc = ESMF_SUCCESS
localrc = ESMF_SUCCESS
grid = ESMF_GridCreateNoPeriDim(minIndex=(/1,1/), maxIndex=(/10,20/), &
gridEdgeLWidth=(/0,0/), gridEdgeUWidth=(/0,0/), &
regDecomp=(/2,2/), name="landgrid", rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
bundle = ESMF_FieldBundleCreate(name='mybundle', rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call assemble_bundle(bundle, grid, datacopyflag, farray1, farray2, farray3, farray4, do_slicing, do_slicing1, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call retrieve_bundle_dataptr(bundle, datacopyflag, do_slicing, do_slicing1, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call serialize_bundle(bundle, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_FieldBundleGet(bundle, fieldCount=fieldCount, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
do i = 1, fieldCount
call ESMF_FieldBundleGet(bundle, fieldIndex=i, field=field, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_FieldDestroy(field, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
enddo
call ESMF_FieldBundleDestroy(bundle, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_GridDestroy(grid, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
deallocate(farray1, farray2, farray3, farray4)
end subroutine bundle_test1_generic