Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(out) | :: | unit | |||
type(ESMF_KeywordEnforcer), | optional | :: | keywordEnforcer | |||
integer, | intent(out), | optional | :: | rc |
subroutine ESMF_UtilIOUnitGet(unit, keywordEnforcer, rc) ! ! !ARGUMENTS: integer, intent(out) :: unit type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below integer, intent(out), optional :: rc ! ! !STATUS: ! \begin{itemize} ! \item\apiStatusCompatibleVersion{5.2.0r} ! \end{itemize} ! ! !DESCRIPTION: ! Scan for, and return, a free Fortran I/O unit number. ! By default, the range of unit numbers returned is between 50 and 99 ! (parameters {\tt ESMF\_LOG\_FORTRAN\_UNIT\_NUMBER} and {\tt ESMF\_LOG\_UPPER} ! respectively.) When integrating ESMF into an application where these values ! conflict with other usages, the range of values may be moved by setting the ! optional {\tt IOUnitLower} and {\tt IOUnitUpper} arguments in the initial ! {\tt ESMF\_Initialize()} call with values in a safe, alternate, range. ! ! The Fortran unit number which is returned is not reserved in any way. ! Successive calls without intervening {\tt OPEN} or {\tt CLOSE} statements ! (or other means of connecting to units), might not return a unique unit ! number. It is recommended that an {\tt OPEN} statement immediately follow ! the call to {\tt ESMF\_IOUnitGet()} to activate the unit. ! ! The arguments are: ! \begin{description} ! \item[unit] ! A Fortran I/O unit number. ! \item[{[rc]}] ! Return code; equals {\tt ESMF\_SUCCESS} if there are no errors. ! \end{description} !EOP integer :: i integer :: localstat logical :: inuse if (present(rc)) rc = ESMF_FAILURE do, i=ESMF_UtilIOUnitLower, ESMF_UtilIOUnitUpper inquire (unit=i, opened=inuse, iostat=localstat) if (.not. inuse .and. localstat == 0) exit end do if (i <= ESMF_UtilIOUnitUpper) then unit = i if (present (rc)) rc = ESMF_SUCCESS else unit = -1 end if end subroutine ESMF_UtilIOUnitGet