1 | MODULE in_out_manager |
---|
2 | !!====================================================================== |
---|
3 | !! *** MODULE in_out_manager *** |
---|
4 | !! Ocean physics: vertical mixing coefficient compute from the tke |
---|
5 | !! turbulent closure parameterization |
---|
6 | !!===================================================================== |
---|
7 | !! History : 1.0 ! 2002-06 (G. Madec) original code |
---|
8 | !! 2.0 ! 2006-07 (S. Masson) iom, add ctl_stop, ctl_warn |
---|
9 | !! 3.0 ! 2008-06 (G. Madec) add ctmp4 to ctmp10 |
---|
10 | !! 3.2 ! 2009-08 (S. MAsson) add new ctl_opn |
---|
11 | !!---------------------------------------------------------------------- |
---|
12 | |
---|
13 | !!---------------------------------------------------------------------- |
---|
14 | !! ctl_stop : update momentum and tracer Kz from a tke scheme |
---|
15 | !! ctl_warn : initialization, namelist read, and parameters control |
---|
16 | !! getunit : give the index of an unused logical unit |
---|
17 | !!---------------------------------------------------------------------- |
---|
18 | USE par_kind ! kind definition |
---|
19 | USE par_oce ! ocean parameter |
---|
20 | USE lib_print ! formated print library |
---|
21 | #if defined key_agrif |
---|
22 | USE Agrif_Util |
---|
23 | #endif |
---|
24 | |
---|
25 | IMPLICIT NONE |
---|
26 | PUBLIC |
---|
27 | |
---|
28 | !!---------------------------------------------------------------------- |
---|
29 | !! namrun namelist parameters |
---|
30 | !!---------------------------------------------------------------------- |
---|
31 | CHARACTER(len=16) :: cn_exp = "exp0" !: experiment name used for output filename |
---|
32 | CHARACTER(len=32) :: cn_ocerst_in = "restart" !: suffix of ocean restart name (input) |
---|
33 | CHARACTER(len=32) :: cn_ocerst_out = "restart" !: suffix of ocean restart name (output) |
---|
34 | LOGICAL :: ln_rstart = .FALSE. !: start from (F) rest or (T) a restart file |
---|
35 | INTEGER :: nn_no = 0 !: job number |
---|
36 | INTEGER :: nn_rstctl = 0 !: control of the time step (0, 1 or 2) |
---|
37 | INTEGER :: nn_rstssh = 0 !: hand made initilization of ssh or not (1/0) |
---|
38 | INTEGER :: nn_it000 = 1 !: index of the first time step |
---|
39 | INTEGER :: nn_itend = 10 !: index of the last time step |
---|
40 | INTEGER :: nn_date0 = 961115 !: initial calendar date aammjj |
---|
41 | INTEGER :: nn_leapy = 0 !: Leap year calendar flag (0/1 or 30) |
---|
42 | INTEGER :: nn_istate = 0 !: initial state output flag (0/1) |
---|
43 | INTEGER :: nn_write = 10 !: model standard output frequency |
---|
44 | INTEGER :: nn_stock = 10 !: restart file frequency |
---|
45 | LOGICAL :: ln_dimgnnn = .FALSE. !: type of dimgout. (F): 1 file for all proc |
---|
46 | !: (T): 1 file per proc |
---|
47 | LOGICAL :: ln_mskland = .FALSE. !: mask land points in NetCDF outputs (costly: + ~15%) |
---|
48 | LOGICAL :: ln_clobber = .FALSE. !: clobber (overwrite) an existing file |
---|
49 | INTEGER :: nn_chunksz = 0 !: chunksize (bytes) for NetCDF file (working only with iom_nf90 routines) |
---|
50 | |
---|
51 | !! conversion of DOCTOR norm namelist name into model name |
---|
52 | !! (this should disappear in a near futur) |
---|
53 | |
---|
54 | CHARACTER(len=16) :: cexper !: experiment name used for output filename |
---|
55 | INTEGER :: no !: job number |
---|
56 | INTEGER :: nrstdt !: control of the time step (0, 1 or 2) |
---|
57 | INTEGER :: nit000 !: index of the first time step |
---|
58 | INTEGER :: nitend !: index of the last time step |
---|
59 | INTEGER :: ndate0 !: initial calendar date aammjj |
---|
60 | INTEGER :: nleapy !: Leap year calendar flag (0/1 or 30) |
---|
61 | INTEGER :: ninist !: initial state output flag (0/1) |
---|
62 | INTEGER :: nwrite !: model standard output frequency |
---|
63 | INTEGER :: nstock !: restart file frequency |
---|
64 | |
---|
65 | !!---------------------------------------------------------------------- |
---|
66 | !! was in restart but moved here because of the OFF line... better solution should be found... |
---|
67 | !!---------------------------------------------------------------------- |
---|
68 | INTEGER :: nitrst !: time step at which restart file should be written |
---|
69 | |
---|
70 | !!---------------------------------------------------------------------- |
---|
71 | !! output monitoring |
---|
72 | !!---------------------------------------------------------------------- |
---|
73 | LOGICAL :: ln_ctl = .FALSE. !: run control for debugging |
---|
74 | INTEGER :: nn_print = 0 !: level of print (0 no print) |
---|
75 | INTEGER :: nn_ictls = 0 !: Start i indice for the SUM control |
---|
76 | INTEGER :: nn_ictle = 0 !: End i indice for the SUM control |
---|
77 | INTEGER :: nn_jctls = 0 !: Start j indice for the SUM control |
---|
78 | INTEGER :: nn_jctle = 0 !: End j indice for the SUM control |
---|
79 | INTEGER :: nn_isplt = 1 !: number of processors following i |
---|
80 | INTEGER :: nn_jsplt = 1 !: number of processors following j |
---|
81 | INTEGER :: nn_bench = 0 !: benchmark parameter (0/1) |
---|
82 | INTEGER :: nn_bit_cmp = 0 !: bit reproducibility (0/1) |
---|
83 | |
---|
84 | ! !: OLD namelist names |
---|
85 | INTEGER :: nprint, nictls, nictle, njctls, njctle, isplt, jsplt, nbench, nbit_cmp |
---|
86 | |
---|
87 | INTEGER :: ijsplt = 1 !: nb of local domain = nb of processors |
---|
88 | |
---|
89 | !!---------------------------------------------------------------------- |
---|
90 | !! logical units |
---|
91 | !!---------------------------------------------------------------------- |
---|
92 | INTEGER :: numstp = -1 !: logical unit for time step |
---|
93 | INTEGER :: numout = 6 !: logical unit for output print |
---|
94 | INTEGER :: numnam = -1 !: logical unit for namelist |
---|
95 | INTEGER :: numnam_ice = -1 !: logical unit for ice namelist |
---|
96 | INTEGER :: numevo_ice = -1 !: logical unit for ice variables (temp. evolution) |
---|
97 | INTEGER :: numsol = -1 !: logical unit for solver statistics |
---|
98 | |
---|
99 | !!---------------------------------------------------------------------- |
---|
100 | !! Run control |
---|
101 | !!---------------------------------------------------------------------- |
---|
102 | INTEGER :: nstop = 0 !: error flag (=number of reason for a premature stop run) |
---|
103 | INTEGER :: nwarn = 0 !: warning flag (=number of warning found during the run) |
---|
104 | CHARACTER(len=200) :: ctmp1, ctmp2, ctmp3 !: temporary characters 1 to 3 |
---|
105 | CHARACTER(len=200) :: ctmp4, ctmp5, ctmp6 !: temporary characters 4 to 6 |
---|
106 | CHARACTER(len=200) :: ctmp7, ctmp8, ctmp9 !: temporary characters 7 to 9 |
---|
107 | CHARACTER(len=200) :: ctmp10 !: temporary character 10 |
---|
108 | CHARACTER (len=64) :: cform_err = "(/,' ===>>> : E R R O R', /,' ===========',/)" !: |
---|
109 | CHARACTER (len=64) :: cform_war = "(/,' ===>>> : W A R N I N G', /,' ===============',/)" !: |
---|
110 | LOGICAL :: lwp = .FALSE. !: boolean : true on the 1st processor only |
---|
111 | LOGICAL :: lsp_area = .TRUE. !: to make a control print over a specific area |
---|
112 | !!---------------------------------------------------------------------- |
---|
113 | !! NEMO/OPA 3.0 , LOCEAN-IPSL (2008) |
---|
114 | !! $Id$ |
---|
115 | !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt) |
---|
116 | !!---------------------------------------------------------------------- |
---|
117 | |
---|
118 | CONTAINS |
---|
119 | |
---|
120 | SUBROUTINE ctl_stop( cd1, cd2, cd3, cd4, cd5, & |
---|
121 | & cd6, cd7, cd8, cd9, cd10 ) |
---|
122 | !!---------------------------------------------------------------------- |
---|
123 | !! *** ROUTINE stop_opa *** |
---|
124 | !! |
---|
125 | !! ** Purpose : print in ocean.outpput file a error message and |
---|
126 | !! increment the error number (nstop) by one. |
---|
127 | !!---------------------------------------------------------------------- |
---|
128 | CHARACTER(len=*), INTENT(in), OPTIONAL :: cd1, cd2, cd3, cd4, cd5 |
---|
129 | CHARACTER(len=*), INTENT(in), OPTIONAL :: cd6, cd7, cd8, cd9, cd10 |
---|
130 | !!---------------------------------------------------------------------- |
---|
131 | ! |
---|
132 | nstop = nstop + 1 |
---|
133 | IF(lwp) THEN |
---|
134 | WRITE(numout,"(/,' ===>>> : E R R O R', /,' ===========',/)") |
---|
135 | IF( PRESENT(cd1 ) ) WRITE(numout,*) cd1 |
---|
136 | IF( PRESENT(cd2 ) ) WRITE(numout,*) cd2 |
---|
137 | IF( PRESENT(cd3 ) ) WRITE(numout,*) cd3 |
---|
138 | IF( PRESENT(cd4 ) ) WRITE(numout,*) cd4 |
---|
139 | IF( PRESENT(cd5 ) ) WRITE(numout,*) cd5 |
---|
140 | IF( PRESENT(cd6 ) ) WRITE(numout,*) cd6 |
---|
141 | IF( PRESENT(cd7 ) ) WRITE(numout,*) cd7 |
---|
142 | IF( PRESENT(cd8 ) ) WRITE(numout,*) cd8 |
---|
143 | IF( PRESENT(cd9 ) ) WRITE(numout,*) cd9 |
---|
144 | IF( PRESENT(cd10) ) WRITE(numout,*) cd10 |
---|
145 | ENDIF |
---|
146 | CALL FLUSH(numout ) |
---|
147 | IF( numstp /= -1 ) CALL FLUSH(numstp ) |
---|
148 | IF( numsol /= -1 ) CALL FLUSH(numsol ) |
---|
149 | IF( numevo_ice /= -1 ) CALL FLUSH(numevo_ice) |
---|
150 | ! |
---|
151 | END SUBROUTINE ctl_stop |
---|
152 | |
---|
153 | |
---|
154 | SUBROUTINE ctl_warn( cd1, cd2, cd3, cd4, cd5, & |
---|
155 | & cd6, cd7, cd8, cd9, cd10 ) |
---|
156 | !!---------------------------------------------------------------------- |
---|
157 | !! *** ROUTINE stop_warn *** |
---|
158 | !! |
---|
159 | !! ** Purpose : print in ocean.outpput file a error message and |
---|
160 | !! increment the warning number (nwarn) by one. |
---|
161 | !!---------------------------------------------------------------------- |
---|
162 | CHARACTER(len=*), INTENT(in), OPTIONAL :: cd1, cd2, cd3, cd4, cd5 |
---|
163 | CHARACTER(len=*), INTENT(in), OPTIONAL :: cd6, cd7, cd8, cd9, cd10 |
---|
164 | !!---------------------------------------------------------------------- |
---|
165 | ! |
---|
166 | nwarn = nwarn + 1 |
---|
167 | IF(lwp) THEN |
---|
168 | WRITE(numout,"(/,' ===>>> : W A R N I N G', /,' ===============',/)") |
---|
169 | IF( PRESENT(cd1 ) ) WRITE(numout,*) cd1 |
---|
170 | IF( PRESENT(cd2 ) ) WRITE(numout,*) cd2 |
---|
171 | IF( PRESENT(cd3 ) ) WRITE(numout,*) cd3 |
---|
172 | IF( PRESENT(cd4 ) ) WRITE(numout,*) cd4 |
---|
173 | IF( PRESENT(cd5 ) ) WRITE(numout,*) cd5 |
---|
174 | IF( PRESENT(cd6 ) ) WRITE(numout,*) cd6 |
---|
175 | IF( PRESENT(cd7 ) ) WRITE(numout,*) cd7 |
---|
176 | IF( PRESENT(cd8 ) ) WRITE(numout,*) cd8 |
---|
177 | IF( PRESENT(cd9 ) ) WRITE(numout,*) cd9 |
---|
178 | IF( PRESENT(cd10) ) WRITE(numout,*) cd10 |
---|
179 | ENDIF |
---|
180 | CALL FLUSH(numout) |
---|
181 | ! |
---|
182 | END SUBROUTINE ctl_warn |
---|
183 | |
---|
184 | |
---|
185 | SUBROUTINE ctl_opn ( knum, cdfile, cdstat, cdform, cdacce, klengh, kout, ldwp, karea ) |
---|
186 | !!---------------------------------------------------------------------- |
---|
187 | !! *** ROUTINE ctl_opn *** |
---|
188 | !! |
---|
189 | !! ** Purpose : Open file and check if required file is available. |
---|
190 | !! |
---|
191 | !! ** Method : Fortan open |
---|
192 | !! |
---|
193 | !! History : |
---|
194 | !! ! 1995-12 (G. Madec) Original code |
---|
195 | !! 8.5 ! 2002-06 (G. Madec) F90: Free form and module |
---|
196 | !!---------------------------------------------------------------------- |
---|
197 | |
---|
198 | INTEGER , INTENT( out) :: knum ! logical unit to open |
---|
199 | CHARACTER(len=*) , INTENT(in ) :: cdfile ! file name to open |
---|
200 | CHARACTER(len=*) , INTENT(in ) :: cdstat ! disposition specifier |
---|
201 | CHARACTER(len=*) , INTENT(in ) :: cdform ! formatting specifier |
---|
202 | CHARACTER(len=*) , INTENT(in ) :: cdacce ! access specifier |
---|
203 | INTEGER , INTENT(in ) :: klengh ! record length |
---|
204 | INTEGER , INTENT(in ) :: kout ! number of logical units for write |
---|
205 | LOGICAL , INTENT(in ) :: ldwp ! boolean term for print |
---|
206 | INTEGER, OPTIONAL, INTENT(in ) :: karea ! proc number |
---|
207 | !! |
---|
208 | CHARACTER(len=80) :: clfile |
---|
209 | INTEGER :: iost |
---|
210 | |
---|
211 | ! adapt filename |
---|
212 | ! ---------------- |
---|
213 | clfile = TRIM(cdfile) |
---|
214 | IF( PRESENT( karea ) ) THEN |
---|
215 | IF( karea > 1 ) WRITE(clfile, "(a,'_',i4.4)") TRIM(clfile), karea-1 |
---|
216 | ENDIF |
---|
217 | #if defined key_agrif |
---|
218 | IF( .NOT. Agrif_Root() ) clfile = TRIM(Agrif_CFixed())//'_'//TRIM(clfile) |
---|
219 | knum=Agrif_Get_Unit() |
---|
220 | #else |
---|
221 | knum=getunit() |
---|
222 | #endif |
---|
223 | |
---|
224 | iost=0 |
---|
225 | IF( cdacce(1:6) == 'DIRECT' ) THEN |
---|
226 | OPEN( UNIT=knum, FILE=clfile, FORM=cdform, ACCESS=cdacce, STATUS=cdstat, RECL=klengh, ERR=100, IOSTAT=iost ) |
---|
227 | ELSE |
---|
228 | OPEN( UNIT=knum, FILE=clfile, FORM=cdform, ACCESS=cdacce, STATUS=cdstat , ERR=100, IOSTAT=iost ) |
---|
229 | ENDIF |
---|
230 | IF( iost == 0 ) THEN |
---|
231 | IF(ldwp) THEN |
---|
232 | WRITE(kout,*) ' file : ', clfile,' open ok' |
---|
233 | WRITE(kout,*) ' unit = ', knum |
---|
234 | WRITE(kout,*) ' status = ', cdstat |
---|
235 | WRITE(kout,*) ' form = ', cdform |
---|
236 | WRITE(kout,*) ' access = ', cdacce |
---|
237 | WRITE(kout,*) |
---|
238 | ENDIF |
---|
239 | ENDIF |
---|
240 | 100 CONTINUE |
---|
241 | IF( iost /= 0 ) THEN |
---|
242 | IF(ldwp) THEN |
---|
243 | WRITE(kout,*) |
---|
244 | WRITE(kout,*) ' ===>>>> : bad opening file: ', clfile |
---|
245 | WRITE(kout,*) ' ======= === ' |
---|
246 | WRITE(kout,*) ' unit = ', knum |
---|
247 | WRITE(kout,*) ' status = ', cdstat |
---|
248 | WRITE(kout,*) ' form = ', cdform |
---|
249 | WRITE(kout,*) ' access = ', cdacce |
---|
250 | WRITE(kout,*) ' iostat = ', iost |
---|
251 | WRITE(kout,*) ' we stop. verify the file ' |
---|
252 | WRITE(kout,*) |
---|
253 | ENDIF |
---|
254 | STOP 'ctl_opn bad opening' |
---|
255 | ENDIF |
---|
256 | |
---|
257 | END SUBROUTINE ctl_opn |
---|
258 | |
---|
259 | |
---|
260 | FUNCTION getunit() |
---|
261 | !!---------------------------------------------------------------------- |
---|
262 | !! *** FUNCTION getunit *** |
---|
263 | !! |
---|
264 | !! ** Purpose : return the index of an unused logical unit |
---|
265 | !!---------------------------------------------------------------------- |
---|
266 | INTEGER :: getunit |
---|
267 | LOGICAL :: llopn |
---|
268 | !!---------------------------------------------------------------------- |
---|
269 | ! |
---|
270 | getunit = 15 ! choose a unit that is big enough then it is not already used in NEMO |
---|
271 | llopn = .TRUE. |
---|
272 | DO WHILE( (getunit < 998) .AND. llopn ) |
---|
273 | getunit = getunit + 1 |
---|
274 | INQUIRE( unit = getunit, opened = llopn ) |
---|
275 | END DO |
---|
276 | IF( (getunit == 999) .AND. llopn ) THEN |
---|
277 | CALL ctl_stop( 'getunit: All logical units until 999 are used...' ) |
---|
278 | getunit = -1 |
---|
279 | ENDIF |
---|
280 | ! |
---|
281 | END FUNCTION getunit |
---|
282 | |
---|
283 | !!===================================================================== |
---|
284 | END MODULE in_out_manager |
---|