subroutine ESMF_IORead(io, fileName, keywordEnforcer, timeslice, &
iofmt, schema, rc)
!
! !ARGUMENTS:
type(ESMF_IO), intent(in) :: io
character (len=*), intent(in) :: fileName
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
integer, intent(in), optional :: timeslice
type(ESMF_IOFmt_Flag), intent(in), optional :: iofmt
character (len=*), intent(in), optional :: schema
integer, intent(out), optional :: rc
! !DESCRIPTION:
! Perform a read on an {\tt ESMF\_IO} object. Any properties specified
! will override, but not reset, those previously set on the io object.
!
! The arguments are:
! \begin{description}
! \item[io]
! The object instance to read.
! \item[{[fileName]}]
! The file name to be read from.
! \item[{[timeslice]}]
! The time-slice number of the variable read from file.
! \item[{[iofmt]}]
! \begin{sloppypar}
! The I/O format. Please see Section~\ref{opt:iofmtflag} for the list
! of options. If not present, defaults to {\tt ESMF\_IOFMT\_NETCDF}.
! \end{sloppypar}
! \item[{[schema]}]
! Selects, for reading, the Attribute package of the ESMF
! objects included in <io> (e.g., with ESMF_IOAddArray)
! \item[{[rc]}]
! Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
! \end{description}
!EOPI
! !REQUIREMENTS:
integer :: localrc
integer :: len_fileName ! filename length or 0
type(ESMF_IOFmt_Flag) :: opt_iofmt ! helper variable
integer :: len_schema ! schema string length or 0
! Assume failure until success
if (present(rc)) rc = ESMF_RC_NOT_IMPL
localrc = ESMF_RC_NOT_IMPL
! Grab the filename length for the C++ level
len_fileName = len_trim(fileName)
! Set default flags
opt_iofmt = ESMF_IOFMT_NETCDF;
if ( present(iofmt)) opt_iofmt = iofmt
! Grab the schema string length for the C++ level
if (present(schema)) then
len_schema = len_trim(schema)
else
len_schema = 0
endif
! invoke C to C++ entry point TODO
call c_ESMC_IORead(io, fileName, len_fileName, opt_iofmt, &
timeslice, schema, len_schema, localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! Return success
if (present(rc)) rc = ESMF_SUCCESS
end subroutine ESMF_IORead