Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions MAPL_cfio/ESMF_CFIOMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,6 @@ end subroutine ESMF_CFIOVarWrite1D_

! !INTERFACE:
subroutine ESMF_CFIOFileOpen (cfio, fmode, rc, expid, cyclic)

!
! !ARGUMENTS:
!
Expand Down Expand Up @@ -839,7 +838,11 @@ subroutine ESMF_CFIOFileOpen (cfio, fmode, rc, expid, cyclic)
character(len=16) :: format
logical :: ex
character(len=MLEN) :: fileName
logical :: myCyclic
logical :: myCyclic
logical :: exists, found, open
integer :: LUN, i

INTEGER, PARAMETER :: iTop = 199 ! Maximum LUN limit


if (present(expid)) call ESMF_CFIOSet(cfio, expid = expid)
Expand All @@ -855,9 +858,24 @@ subroutine ESMF_CFIOFileOpen (cfio, fmode, rc, expid, cyclic)
print *, trim(fileName), "doesn't exist"
return
end if
open(11, file=fileName)
read(11, '(a)') dset
close(11)
!======================================================================
! Find an available logical unit
!======================================================================
found = .FALSE.
i = 11

DO WHILE ( .NOT. found .AND. i <= iTop )
INQUIRE( UNIT=i, EXIST=exists, OPENED=open )
IF ( exists .AND. .NOT. open ) THEN
found = .TRUE.
lun = i
ENDIF
i = i + 1
ENDDO

open(LUN, file=fileName)
read(LUN, '(a)') dset
close(LUN)
format = 'SDF'
if (index(dset,'DSET') .ge. 1 .or. index(dset,'dset') .ge. 1 &
.or. index(dset,'Dset') .ge. 1 ) then
Expand Down
Loading