subroutine ESMFIO_Read(IOComp, fileName, fieldList, keywordEnforcer, &
filePath, iofmt, rc)
type(ESMF_GridComp), intent(inout) :: IOComp
character(len=*), intent(in) :: fileName
type(ESMF_Field), intent(in) :: fieldList(:)
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
character(len=*), intent(in), optional :: filePath
type(ESMF_IOFmt_flag), intent(in), optional :: iofmt
integer, intent(out), optional :: rc
! -- local variables
integer :: localrc
integer :: item, localDe, localDeCount
type(ioWrapper) :: is
type(ESMF_IOFmt_flag) :: liofmt
! -- begin
if (present(rc)) rc = ESMF_SUCCESS
if (.not.ESMF_GridCompIsPetLocal(IOComp)) return
call ESMF_GridCompGetInternalState(IOComp, is, localrc)
if (ESMF_LogFoundError(rcToCheck=localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return ! bail out
if (.not.associated(is % IO)) return
if (.not.associated(is % IO % IOLayout)) return
localDeCount = size(is % IO % IOLayout)
liofmt = ESMF_IOFMT_NETCDF
if (present(iofmt)) liofmt = iofmt
if (liofmt == ESMF_IOFMT_NETCDF) then
do localDe = 0, localDeCount - 1
call IONCOpen(IOComp, fileName, filePath=filePath, localDe=localDe, rc=localrc)
if (ESMF_LogFoundError(rcToCheck=localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return ! bail out
end do
do item = 1, size(fieldList)
call ESMFIO_FieldAccess(IOComp, fieldList(item), 'read', iofmt=liofmt, &
rc=localrc)
if (ESMF_LogFoundError(rcToCheck=localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return ! bail out
end do
do localDe = 0, localDeCount - 1
call IONCClose(IOComp, localDe=localDe, rc=localrc)
if (ESMF_LogFoundError(rcToCheck=localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return ! bail out
call IONCClose(IOComp, localDe=localDe, rc=localrc)
end do
else
call ESMF_LogSetError(ESMF_RC_NOT_IMPL, &
msg="I/O format not implemented", &
ESMF_CONTEXT, rcToReturn=rc)
return ! bail out
end if
end subroutine ESMFIO_Read