Back to home page

MITgcm

 
 

    


File indexing completed on 2018-03-02 18:37:55 UTC

view on githubraw file Latest commit add29e06 on 2018-01-31 20:35:05 UTC
ddd663a9a8 Gael*0001 #include "CPP_EEOPTIONS.h"
                0002 
                0003       SUBROUTINE AUTODIFF_FINDUNIT( ioUnit, myThid )
                0004 C OUT:
                0005 C     ioUnit  (integer) :: unit number
                0006 C
                0007 C AUTODIFF_FINDUNIT returns a valid, unused unit number for f77 I/O
                0008 C The routine stops the program is an error occurs in the process
                0009 C of searching the I/O channels.
                0010 C
                0011 C Created: 03/20/99 adcroft@mit.edu
                0012 
                0013       IMPLICIT NONE
                0014 
                0015 #include "EEPARAMS.h"
                0016 
                0017 C Arguments
                0018       INTEGER ioUnit
                0019       INTEGER myThid
                0020 C Local
                0021       INTEGER ii
                0022       LOGICAL op
                0023       INTEGER ios
                0024       CHARACTER*(MAX_LEN_MBUF) msgBuf
                0025 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
                0026 
                0027 C Sweep through a valid range of unit numbers
                0028       ioUnit=-1
                0029       DO ii=1000,1999
                0030        IF ( ioUnit.EQ.-1 ) THEN
                0031 C- skip reserved unit numbers
                0032         IF (       ii.NE.errorMessageUnit
                0033      &       .AND. ii.NE.standardMessageUnit
                0034      &       .AND. ii.NE.scrUnit1   .AND. ii.NE.scrUnit2
                0035      &       .AND. ii.NE.eeDataUnit .AND. ii.NE.modelDataUnit
                0036      &     ) THEN
                0037           INQUIRE(unit=ii,iostat=ios,opened=op)
                0038           IF ( ios.NE.0 ) THEN
                0039             WRITE(msgBuf,'(A,I4)')
                0040      &        ' AUTODIFF_FINDUNIT: inquiring unit number =', ii
                0041             CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
                0042      &                          SQUEEZE_RIGHT, myThid )
                0043             WRITE(msgBuf,'(A)')
                0044      &        ' AUTODIFF_FINDUNIT: inquire statement failed!'
                0045             CALL PRINT_ERROR( msgBuf, myThid )
                0046             STOP 'ABNORMAL END: S/R AUTODIFF_FINDUNIT'
                0047           ENDIF
                0048           IF ( .NOT.op ) THEN
                0049             ioUnit=ii
                0050           ENDIF
                0051         ENDIF
                0052        ENDIF
                0053       ENDDO
                0054 
                0055 C Was there an available unit number
                0056       IF ( ioUnit.EQ.-1 ) THEN
                0057         WRITE(msgBuf,'(A)')
                0058      &    ' AUTODIFF_FINDUNIT: could not find an available unit number!'
                0059         CALL PRINT_ERROR( msgBuf, myThid )
                0060         STOP 'ABNORMAL END: S/R AUTODIFF_FINDUNIT'
                0061       ENDIF
                0062 
                0063       RETURN
                0064       END