3 |
|
|
4 |
#include "CPP_EEOPTIONS.h" |
#include "CPP_EEOPTIONS.h" |
5 |
|
|
6 |
subroutine MDSFINDUNIT( iounit, mythid ) |
SUBROUTINE MDSFINDUNIT( ioUnit, myThid ) |
7 |
C OUT: |
C OUT: |
8 |
C iounit integer - unit number |
C ioUnit (integer) :: unit number |
9 |
C |
C |
10 |
C MDSFINDUNIT returns a valid, unused unit number for f77 I/O |
C MDSFINDUNIT returns a valid, unused unit number for f77 I/O |
11 |
C The routine stops the program is an error occurs in the process |
C The routine stops the program is an error occurs in the process |
13 |
C |
C |
14 |
C Created: 03/20/99 adcroft@mit.edu |
C Created: 03/20/99 adcroft@mit.edu |
15 |
|
|
16 |
implicit none |
IMPLICIT NONE |
17 |
|
|
18 |
#include "EEPARAMS.h" |
#include "EEPARAMS.h" |
19 |
|
|
20 |
C Arguments |
C Arguments |
21 |
integer iounit |
INTEGER ioUnit |
22 |
integer mythid |
INTEGER myThid |
23 |
C Local |
C Local |
24 |
integer ii |
INTEGER ii |
25 |
logical op |
LOGICAL op |
26 |
integer ios |
INTEGER ios |
27 |
character*(max_len_mbuf) msgbuf |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
28 |
C ------------------------------------------------------------------ |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
29 |
|
|
30 |
C Sweep through a valid range of unit numbers |
C Sweep through a valid range of unit numbers |
31 |
iounit=-1 |
ioUnit=-1 |
32 |
do ii=9,999 |
DO ii=9,999 |
33 |
if (iounit.eq.-1) then |
IF ( ioUnit.EQ.-1 ) THEN |
34 |
inquire(unit=ii,iostat=ios,opened=op) |
C- skip reserved unit numbers |
35 |
if (ios.ne.0) then |
IF ( ii.NE.errorMessageUnit |
36 |
write(msgbuf,'(a,i2.2)') |
& .AND. ii.NE.standardMessageUnit |
37 |
& ' MDSFINDUNIT: inquiring unit number = ',ii |
& .AND. ii.NE.scrUnit1 .AND. ii.NE.scrUnit2 |
38 |
call print_message( msgbuf, standardmessageunit, |
& .AND. ii.NE.eeDataUnit .AND. ii.NE.modelDataUnit |
39 |
& SQUEEZE_RIGHT , mythid) |
& ) THEN |
40 |
write(msgbuf,'(a)') |
INQUIRE(unit=ii,iostat=ios,opened=op) |
41 |
|
IF ( ios.NE.0 ) THEN |
42 |
|
WRITE(msgBuf,'(A,I4)') |
43 |
|
& ' MDSFINDUNIT: inquiring unit number =', ii |
44 |
|
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
45 |
|
& SQUEEZE_RIGHT, myThid ) |
46 |
|
WRITE(msgBuf,'(A)') |
47 |
& ' MDSFINDUNIT: inquire statement failed!' |
& ' MDSFINDUNIT: inquire statement failed!' |
48 |
call print_error( msgbuf, mythid ) |
CALL PRINT_ERROR( msgBuf, myThid ) |
49 |
stop 'ABNORMAL END: S/R MDSFINDUNIT' |
STOP 'ABNORMAL END: S/R MDSFINDUNIT' |
50 |
endif |
ENDIF |
51 |
if (.NOT. op) then |
IF ( .NOT.op ) THEN |
52 |
iounit=ii |
ioUnit=ii |
53 |
endif |
ENDIF |
54 |
endif |
ENDIF |
55 |
enddo |
ENDIF |
56 |
|
ENDDO |
57 |
|
|
58 |
C Was there an available unit number |
C Was there an available unit number |
59 |
if (iounit.eq.-1) then |
IF ( ioUnit.EQ.-1 ) THEN |
60 |
write(msgbuf,'(a)') |
WRITE(msgBuf,'(A)') |
61 |
& ' MDSFINDUNIT: could not find an available unit number!' |
& ' MDSFINDUNIT: could not find an available unit number!' |
62 |
call print_error( msgbuf, mythid ) |
CALL PRINT_ERROR( msgBuf, myThid ) |
63 |
stop 'ABNORMAL END: S/R MDSFINDUNIT' |
STOP 'ABNORMAL END: S/R MDSFINDUNIT' |
64 |
endif |
ENDIF |
65 |
|
|
66 |
C ------------------------------------------------------------------ |
RETURN |
67 |
return |
END |
|
end |
|