/[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.6 - (hide annotations) (download)
Fri Nov 10 15:34:14 2006 UTC (20 years ago) by utke
Branch: MAIN
Changes since 1.5: +23 -3 lines
cleanup checkpoints

1 utke 1.6 ! $Header: /u/gcmpack/MITgcm_contrib/heimbach/OpenAD/code_shallow_openad2/OpenAD_checkpoints.f90,v 1.5 2006/11/09 21:45:19 utke Exp $
2 utke 1.1 module OpenAD_checkpoints
3    
4     implicit none
5    
6 utke 1.6 private :: cp_file_number, cp_open
7 utke 1.1
8 utke 1.6 public :: cp_io_unit, cp_init, cp_write_open, cp_read_open, cp_close
9 utke 1.1
10 utke 1.5 integer :: cp_file_number, cp_io_unit
11 utke 1.1
12     interface cp_init
13 utke 1.5 module procedure init_i
14     end interface
15 utke 1.1
16 utke 1.2 interface cp_open
17 utke 1.5 module procedure open_i
18     end interface
19 utke 1.2
20 utke 1.6 interface cp_write_open
21     module procedure write_open_i
22     end interface
23    
24     interface cp_read_open
25     module procedure read_open_i
26     end interface
27    
28 utke 1.2 interface cp_close
29 utke 1.5 module procedure close_i
30     end interface
31 utke 1.2
32     interface cp_findunit
33 utke 1.5 module procedure findunit_i
34 utke 1.2 end interface
35    
36 utke 1.1 contains
37    
38 utke 1.5 subroutine init_i
39     implicit none
40 utke 1.2 cp_file_number=1
41 utke 1.5 end subroutine
42 utke 1.2
43 utke 1.6 subroutine write_open_i()
44     implicit none
45     call cp_open()
46     cp_file_number=cp_file_number+1
47     end subroutine
48    
49     subroutine read_open_i()
50     implicit none
51     cp_file_number=cp_file_number-1
52     call cp_open()
53     end subroutine
54    
55 utke 1.5 subroutine open_i()
56     implicit none
57     character*128 fname ! file name
58     ! get unit
59     call cp_findunit()
60     ! print *, 'JU: opening CP file ', cp_file_number
61     ! construct the file name
62     write(fname,'(A,I20.20)') 'openad_checkpoint_',cp_file_number
63     open( UNIT=cp_io_unit,FILE=TRIM(fname),FORM='binary',STATUS='UNKNOWN' )
64     end subroutine
65    
66     subroutine close_i()
67     implicit none
68     close( UNIT=cp_io_unit)
69     end subroutine
70    
71     subroutine findunit_i()
72     ! returns a valid, unused unit number for Fortran I/O
73     ! the routine stops the program if an error occurs in the process
74     ! of searching the I/O channels.
75     implicit none
76     ! Local
77     integer ii
78     logical op
79     integer ios
80     character*(1024) msgbuf
81     ! Sweep through a valid range of unit numbers
82     cp_io_unit=-1
83     do ii=9,999
84     if (cp_io_unit.eq.-1) then
85 utke 1.2 inquire(unit=ii,iostat=ios,opened=op)
86     if (ios.ne.0) then
87 utke 1.5 write(msgbuf,'(a,i2.2)') 'OpenAD_checkpoints:findunit_i: inquiring unit number = ',ii
88     print *, msgBuf
89     write(msgbuf,'(a)') 'OpenAD_checkpoints:findunit_i: inquire statement failed!'
90     print *, msgBuf
91     stop 'ABNORMAL END: S/R OpenAD_checkpoints:findunit_i'
92 utke 1.2 endif
93     if (.NOT. op) then
94 utke 1.5 cp_io_unit=ii
95     end if
96     end if
97     end do
98     ! Was there an available unit number
99     if (cp_io_unit.eq.-1) then
100     write(msgbuf,'(a)') 'OpenAD_checkpoints:findunit_i: could not find an available unit number!'
101     print *, msgBuf
102     stop 'ABNORMAL END: S/R OpenAD_checkpoints:findunit_i'
103     endif
104     end subroutine
105 utke 1.2
106 utke 1.1 end module OpenAD_checkpoints

  ViewVC Help
Powered by ViewVC 1.1.22