/[MITgcm]/MITgcm_contrib/heimbach/OpenAD/code_shallow_openad2/OpenAD_checkpoints.f90
ViewVC logotype

Annotation of /MITgcm_contrib/heimbach/OpenAD/code_shallow_openad2/OpenAD_checkpoints.f90

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.4 - (hide annotations) (download)
Wed Nov 8 22:08:58 2006 UTC (20 years ago) by cnh
Branch: MAIN
Changes since 1.3: +1 -1 lines
Fix to check cp_io_unit ( not iounit )

1 utke 1.1 module OpenAD_checkpoints
2    
3     implicit none
4    
5     private
6    
7 utke 1.2 public :: cp_file_number, cp_io_unit, cp_init, cp_open, cp_close
8 utke 1.1
9    
10 utke 1.2 integer :: cp_file_number, cp_io_unit
11 utke 1.1
12     interface cp_init
13     module procedure init
14     end interface cp_init
15    
16 utke 1.2 interface cp_open
17     module procedure cp_open_i
18     end interface cp_open
19    
20     interface cp_close
21     module procedure cp_close_i
22     end interface cp_close
23    
24     interface cp_findunit
25     module procedure cp_findunit_i
26     end interface
27    
28 utke 1.1 contains
29    
30     subroutine init
31 utke 1.2 cp_file_number=1
32 utke 1.1 end subroutine init
33    
34 utke 1.2 SUBROUTINE cp_open_i()
35    
36     ! Local variables
37     ! iounit :: I/O unit number
38     ! fname :: File name
39     ! varA, varB, varC :: Test variables
40     INTEGER iounit
41     CHARACTER*128 fname
42     ! Get unit and open
43     CALL cp_findunit()
44     print *, 'JU: opening CP file ', cp_file_number
45 utke 1.3 WRITE(fname,'(A,I20.20)') 'openad_checkpoint_',cp_file_number
46 utke 1.2 OPEN( UNIT=cp_io_unit, FILE=TRIM(fname), FORM='binary', STATUS='UNKNOWN' )
47    
48     end subroutine
49    
50     subroutine cp_close_i()
51     CLOSE( UNIT=cp_io_unit)
52    
53     END subroutine
54    
55     subroutine cp_findunit_i()
56    
57     ! iounit integer - unit numberpapiunit
58     ! returns a valid, unused unit number for Fortran I/O
59     ! The routine stops the program if an error occurs in the process
60     ! of searching the I/O channels.
61     !
62     ! Created: 03/20/99 adcroft@mit.edu
63    
64     implicit none
65    
66     ! Arguments
67     integer iounit
68     ! Local
69     integer ii
70     logical op
71     integer ios
72     character*(1024) msgbuf
73     ! ------------------------------------------------------------------
74    
75     ! Sweep through a valid range of unit numbers
76     cp_io_unit=-1
77     do ii=9,999
78     if (cp_io_unit.eq.-1) then
79     inquire(unit=ii,iostat=ios,opened=op)
80     if (ios.ne.0) then
81     write(msgbuf,'(a,i2.2)') ' OPENAD_FINDUNIT: inquiring unit number = ',ii
82     PRINT *, msgBuf
83     write(msgbuf,'(a)') ' OPENAD_FINDUNIT: inquire statement failed!'
84     PRINT *, msgBuf
85     stop 'ABNORMAL END: S/R OPENAD_FINDUNIT'
86     endif
87     if (.NOT. op) then
88     cp_io_unit=ii
89     endif
90     endif
91     enddo
92    
93     ! Was there an available unit number
94 cnh 1.4 if (cp_io_unit.eq.-1) then
95 utke 1.2 write(msgbuf,'(a)') ' OPENAD_FINDUNIT: could not find an available unit number!'
96     PRINT *, msgBuf
97     stop 'ABNORMAL END: S/R OPENAD_FINDUNIT'
98     endif
99    
100     ! ------------------------------------------------------------------
101     return
102     end subroutine
103 utke 1.1 end module OpenAD_checkpoints

  ViewVC Help
Powered by ViewVC 1.1.22