1 | MODULE dianam |
---|
2 | !!====================================================================== |
---|
3 | !! *** MODULE dianam *** |
---|
4 | !! Ocean diagnostics: Builds output file name |
---|
5 | !!===================================================================== |
---|
6 | |
---|
7 | !!---------------------------------------------------------------------- |
---|
8 | !! dia_nam : Builds output file name |
---|
9 | !!---------------------------------------------------------------------- |
---|
10 | !! * Modules used |
---|
11 | USE dom_oce ! ocean space and time domain |
---|
12 | USE phycst ! physical constants |
---|
13 | USE in_out_manager ! I/O manager |
---|
14 | USE daymod ! calendar |
---|
15 | |
---|
16 | IMPLICIT NONE |
---|
17 | PRIVATE |
---|
18 | |
---|
19 | !! * Routine accessibility |
---|
20 | PUBLIC dia_nam ! routine called by step.F90 |
---|
21 | !!---------------------------------------------------------------------- |
---|
22 | !! OPA 9.0 , LODYC-IPSL (2003) |
---|
23 | !!---------------------------------------------------------------------- |
---|
24 | |
---|
25 | CONTAINS |
---|
26 | |
---|
27 | SUBROUTINE dia_nam( cdfnam, kfreq, cdsuff ) |
---|
28 | !!--------------------------------------------------------------------- |
---|
29 | !! *** ROUTINE dia_nam *** |
---|
30 | !! |
---|
31 | !! ** Purpose : Builds output file name |
---|
32 | !! |
---|
33 | !! ** Method : File name is a function of date and output frequency |
---|
34 | !! cdfnam=<cexper>_<clave>_<idtbeg>_<idtend>_grid_<cdsuff> |
---|
35 | !! <clave> = averaging frequency (DA, MO, etc...) |
---|
36 | !! <idtbeg>,<idtend> date of beginning and end of run |
---|
37 | !! |
---|
38 | !! History : |
---|
39 | !! ! 99-02 (E. Guilyardi) Creation for 30 days/month |
---|
40 | !! 8.5 ! 02-06 (G. Madec) F90: Free form and module |
---|
41 | !!---------------------------------------------------------------------- |
---|
42 | !! * Arguments |
---|
43 | CHARACTER (len=*), INTENT( out ) :: cdfnam ! file name |
---|
44 | CHARACTER (len=*), INTENT( in ) :: cdsuff ! ??? |
---|
45 | INTEGER, INTENT( in ) :: kfreq ! ??? |
---|
46 | |
---|
47 | !! * Local declarations |
---|
48 | CHARACTER (len=8) :: clexper |
---|
49 | CHARACTER (len=2) :: clave |
---|
50 | CHARACTER (len=5) :: clout |
---|
51 | CHARACTER (len=6) :: clsuff |
---|
52 | INTEGER :: jt, jc, jd, je ! dummy loop indices |
---|
53 | INTEGER :: & |
---|
54 | ic, id, ie, ig, ijjmm, iout, & ! temporary integers |
---|
55 | iyear1, imonth1, iday1, & ! " " |
---|
56 | iyear2, imonth2, iday2 ! " " |
---|
57 | REAL(wp) :: & |
---|
58 | z5j, znbsec, zdate1, zdate2, zdrun, zdt ! temporary scalars |
---|
59 | !!---------------------------------------------------------------------- |
---|
60 | |
---|
61 | IF(lwp) WRITE(numout,*) |
---|
62 | IF(lwp) WRITE(numout,*) ' dia_nam: building output file name' |
---|
63 | IF(lwp) WRITE(numout,*) ' ~~~~~~~' |
---|
64 | IF(lwp) WRITE(numout,*) |
---|
65 | |
---|
66 | ! 0. Initialisation |
---|
67 | ! ----------------- |
---|
68 | |
---|
69 | cdfnam = '' |
---|
70 | |
---|
71 | ! number of seconds of the run |
---|
72 | |
---|
73 | z5j = 5*rjjss |
---|
74 | zdt = rdt |
---|
75 | IF( nacc == 1 ) zdt = rdtmin |
---|
76 | zdrun = FLOAT( nitend - nit000 ) * zdt |
---|
77 | |
---|
78 | ! date of beginning of run |
---|
79 | |
---|
80 | iyear1 = ndastp/10000 |
---|
81 | imonth1 = ndastp/100 - iyear1*100 |
---|
82 | iday1 = ndastp - imonth1*100 - iyear1*10000 |
---|
83 | IF( nleapy == 1) THEN |
---|
84 | ijjmm=0 |
---|
85 | IF( MOD( iyear1, 4 ) == 0 ) THEN |
---|
86 | DO jt = 1, imonth1-1 |
---|
87 | ijjmm = ijjmm + nbiss(jt) |
---|
88 | END DO |
---|
89 | ELSE |
---|
90 | DO jt = 1, imonth1-1 |
---|
91 | ijjmm = ijjmm + nobis(jt) |
---|
92 | END DO |
---|
93 | ENDIF |
---|
94 | ijjmm = ijjmm + (iyear1-1)/4 |
---|
95 | zdate1 = ( (iyear1-1)*365 + ijjmm +iday1-1 ) * rjjss |
---|
96 | ELSE IF( nleapy == 0 ) THEN |
---|
97 | ijjmm = 0 |
---|
98 | DO jt = 1, imonth1-1 |
---|
99 | ijjmm = ijjmm + nobis(jt) |
---|
100 | END DO |
---|
101 | zdate1 = ( (iyear1-1)*raajj + ijjmm + iday1-1)* rjjss |
---|
102 | ELSE |
---|
103 | zdate1 = ( (iyear1-1)*nleapy*raamo + (imonth1-1)*nleapy + iday1-1)* rjjss |
---|
104 | ENDIF |
---|
105 | |
---|
106 | ! date of end of run (= date of beginning of next run) |
---|
107 | |
---|
108 | zdate2 = zdate1 + zdrun |
---|
109 | IF( nleapy == 1 ) THEN |
---|
110 | iyear2 = zdate2/(365.25*rjjss)+1 |
---|
111 | ijjmm = INT(zdate2/rjjss)-365*(iyear2-1)-(iyear2-1)/4 |
---|
112 | IF( ijjmm < 0 ) THEN |
---|
113 | iyear2 = iyear2-1 |
---|
114 | ijjmm = zdate2/rjjss-365.*(iyear2-1)-(iyear2-1)/4 |
---|
115 | ENDIF |
---|
116 | IF( MOD( iyear2, 4 ) == 0 ) THEN |
---|
117 | DO jt = 1, 12 |
---|
118 | ijjmm = ijjmm - nbiss(jt) |
---|
119 | IF( ijjmm <= 0 ) go to 10 |
---|
120 | END DO |
---|
121 | jt = 12 |
---|
122 | 10 CONTINUE |
---|
123 | imonth2 = jt |
---|
124 | ijjmm = 0 |
---|
125 | DO jt = 1, jt-1 |
---|
126 | ijjmm = ijjmm + nbiss(jt) |
---|
127 | END DO |
---|
128 | ELSE |
---|
129 | DO jt = 1, 12 |
---|
130 | ijjmm = ijjmm - nobis(jt) |
---|
131 | IF( ijjmm <= 0 ) go to 15 |
---|
132 | END DO |
---|
133 | jt = 12 |
---|
134 | 15 CONTINUE |
---|
135 | imonth2 = jt |
---|
136 | ijjmm = 0 |
---|
137 | DO jt = 1, jt-1 |
---|
138 | ijjmm = ijjmm + nobis(jt) |
---|
139 | END DO |
---|
140 | ENDIF |
---|
141 | iday2 = zdate2/rjjss-365.*(iyear2-1)-ijjmm+1-(iyear2-1)/4 |
---|
142 | ELSE IF( nleapy == 0 ) THEN |
---|
143 | iyear2 = zdate2/raass+1 |
---|
144 | ijjmm = zdate2/rjjss-raajj*(iyear2-1) |
---|
145 | DO jt = 1, 12 |
---|
146 | ijjmm = ijjmm - nobis(jt) |
---|
147 | IF(ijjmm <= 0) go to 20 |
---|
148 | END DO |
---|
149 | jt = 12 |
---|
150 | 20 CONTINUE |
---|
151 | imonth2 = jt |
---|
152 | ijjmm = 0 |
---|
153 | DO jt = 1, jt-1 |
---|
154 | ijjmm = ijjmm + nobis(jt) |
---|
155 | END DO |
---|
156 | iday2 = zdate2/rjjss-raajj*(iyear2-1)-ijjmm+1 |
---|
157 | ELSE |
---|
158 | zdate2 = zdate2 / rjjss |
---|
159 | imonth2 = zdate2/FLOAT(nleapy) |
---|
160 | iday2 = zdate2 - imonth2*FLOAT(nleapy) + 1. |
---|
161 | iyear2 = imonth2/12 |
---|
162 | imonth2 = imonth2 - iyear2*12 |
---|
163 | imonth2 = imonth2 + 1 |
---|
164 | iyear2 = iyear2 + 1 |
---|
165 | IF( iday2 == 0 ) THEN |
---|
166 | iday2 = nleapy |
---|
167 | imonth2 = imonth2 - 1 |
---|
168 | IF( imonth2 == 0 ) THEN |
---|
169 | imonth2 = 12 |
---|
170 | iyear2 = iyear2 - 1 |
---|
171 | ENDIF |
---|
172 | ENDIF |
---|
173 | ENDIF |
---|
174 | |
---|
175 | |
---|
176 | ! 1. Define time averaging period <nn><type> |
---|
177 | ! --------------------------------------- |
---|
178 | |
---|
179 | iout = 0 |
---|
180 | #if defined key_diainstant |
---|
181 | clave = 'IN' |
---|
182 | IF( iyear2 <= 99 ) THEN |
---|
183 | WRITE(cdfnam,9001) iyear1,imonth1,iday1,iyear2,imonth2,iday2 |
---|
184 | ELSE IF( iyear2 <= 999 ) THEN |
---|
185 | WRITE(cdfnam,9002) iyear1,imonth1,iday1,iyear2,imonth2,iday2 |
---|
186 | ELSE IF( iyear2 <= 9999 ) THEN |
---|
187 | WRITE(cdfnam,9003) iyear1,imonth1,iday1,iyear2,imonth2,iday2 |
---|
188 | ELSE |
---|
189 | WRITE(cdfnam,9004) iyear1,imonth1,iday1,iyear2,imonth2,iday2 |
---|
190 | ENDIF |
---|
191 | #else |
---|
192 | |
---|
193 | znbsec=kfreq*zdt |
---|
194 | ! daily output |
---|
195 | IF( znbsec == rjjss ) THEN |
---|
196 | clave = '1d' |
---|
197 | IF( iyear2 <= 99 ) THEN |
---|
198 | WRITE(cdfnam,9001) iyear1,imonth1,iday1,iyear2,imonth2,iday2 |
---|
199 | ELSE IF( iyear2 <= 999 ) THEN |
---|
200 | WRITE(cdfnam,9002) iyear1,imonth1,iday1,iyear2,imonth2,iday2 |
---|
201 | ELSE IF( iyear2 <= 9999 ) THEN |
---|
202 | WRITE(cdfnam,9003) iyear1,imonth1,iday1,iyear2,imonth2,iday2 |
---|
203 | ELSE |
---|
204 | WRITE(cdfnam,9004) iyear1,imonth1,iday1,iyear2,imonth2,iday2 |
---|
205 | ENDIF |
---|
206 | ! 5 day output |
---|
207 | ELSE IF( znbsec == z5j ) THEN |
---|
208 | clave='5d' |
---|
209 | IF( iyear2 <= 99 ) THEN |
---|
210 | WRITE(cdfnam,9001) iyear1,imonth1,iday1,iyear2,imonth2,iday2 |
---|
211 | ELSE IF( iyear2 <= 999 ) THEN |
---|
212 | WRITE(cdfnam,9002) iyear1,imonth1,iday1,iyear2,imonth2,iday2 |
---|
213 | ELSE IF( iyear2 <= 9999 ) THEN |
---|
214 | WRITE(cdfnam,9003) iyear1,imonth1,iday1,iyear2,imonth2,iday2 |
---|
215 | ELSE |
---|
216 | WRITE(cdfnam,9004) iyear1,imonth1,iday1,iyear2,imonth2,iday2 |
---|
217 | ENDIF |
---|
218 | ! monthly ouput |
---|
219 | ELSE IF( (znbsec == rmoss .AND. nleapy > 1) .OR. & |
---|
220 | (znbsec >= 29*rjjss .AND. znbsec <= 31*rjjss .AND. nleapy <= 1) ) THEN |
---|
221 | clave = '1m' |
---|
222 | IF( iyear2 <= 99 ) THEN |
---|
223 | WRITE(cdfnam,9011) iyear1,imonth1,iyear2,imonth2 |
---|
224 | ELSE IF( iyear2 <= 999 ) THEN |
---|
225 | WRITE(cdfnam,9012) iyear1,imonth1,iyear2,imonth2 |
---|
226 | ELSE IF( iyear2 <= 9999 ) THEN |
---|
227 | WRITE(cdfnam,9013) iyear1,imonth1,iyear2,imonth2 |
---|
228 | ELSE |
---|
229 | WRITE(cdfnam,9014) iyear1,imonth1,iyear2,imonth2 |
---|
230 | ENDIF |
---|
231 | ! annual output |
---|
232 | ELSE IF( (znbsec == raass .AND. nleapy > 1) .OR. & |
---|
233 | (znbsec >= 365*rjjss .AND. znbsec <= 366*rjjss .AND. nleapy <= 1) ) THEN |
---|
234 | clave = '1y' |
---|
235 | IF( iyear2 <= 99 ) THEN |
---|
236 | WRITE(cdfnam,9021) iyear1,iyear2 |
---|
237 | ELSE IF( iyear2 <= 999 ) THEN |
---|
238 | WRITE(cdfnam,9022) iyear1,iyear2 |
---|
239 | ELSE IF( iyear2 <= 9999 ) THEN |
---|
240 | WRITE(cdfnam,9023) iyear1,iyear2 |
---|
241 | ELSE |
---|
242 | WRITE(cdfnam,9024) iyear1,iyear2 |
---|
243 | ENDIF |
---|
244 | ELSE |
---|
245 | ! others |
---|
246 | iout = kfreq |
---|
247 | ig = 0 |
---|
248 | clout = '' |
---|
249 | IF( iout <= 9 ) THEN |
---|
250 | ig = 1 |
---|
251 | WRITE(clout,'(i1.1)') iout |
---|
252 | ELSE IF( iout <= 99 ) THEN |
---|
253 | ig = 2 |
---|
254 | WRITE(clout,'(i2.2)') iout |
---|
255 | ELSE IF( iout <= 999 ) THEN |
---|
256 | ig = 3 |
---|
257 | WRITE(clout,'(i3.3)') iout |
---|
258 | ELSE IF( iout <= 9999 ) THEN |
---|
259 | ig = 4 |
---|
260 | WRITE(clout,'(i4.4)') iout |
---|
261 | ELSE |
---|
262 | ig = 5 |
---|
263 | WRITE(clout,'(i5.5)') iout |
---|
264 | ENDIF |
---|
265 | clave = 'CU' |
---|
266 | IF( iyear2 <= 99 ) THEN |
---|
267 | WRITE(cdfnam,9001) iyear1,imonth1,iday1,iyear2,imonth2,iday2 |
---|
268 | ELSE IF( iyear2 <= 999 ) THEN |
---|
269 | WRITE(cdfnam,9002) iyear1,imonth1,iday1,iyear2,imonth2,iday2 |
---|
270 | ELSE IF( iyear2 <= 9999 ) THEN |
---|
271 | WRITE(cdfnam,9003) iyear1,imonth1,iday1,iyear2,imonth2,iday2 |
---|
272 | ELSE |
---|
273 | WRITE(cdfnam,9004) iyear1,imonth1,iday1,iyear2,imonth2,iday2 |
---|
274 | ENDIF |
---|
275 | ENDIF |
---|
276 | #endif |
---|
277 | DO jc = 1, 8 |
---|
278 | IF( cexper(jc:jc)==' ' ) go to 120 |
---|
279 | END DO |
---|
280 | 120 CONTINUE |
---|
281 | ic = jc |
---|
282 | clexper = cexper |
---|
283 | IF( jc-1 == 0 ) THEN |
---|
284 | clexper = 'orcafile' |
---|
285 | ic = 9 |
---|
286 | ENDIF |
---|
287 | DO jd = 1, 6 |
---|
288 | IF( cdsuff(jd:jd) == ' ' ) go to 130 |
---|
289 | END DO |
---|
290 | 130 CONTINUE |
---|
291 | id = jd |
---|
292 | clsuff = cdsuff |
---|
293 | IF( jd-1 == 0 ) THEN |
---|
294 | clsuff = 'output' |
---|
295 | id = 7 |
---|
296 | ENDIF |
---|
297 | DO je = 1, 45 |
---|
298 | IF( cdfnam(je:je) == ' ' ) go to 140 |
---|
299 | END DO |
---|
300 | 140 CONTINUE |
---|
301 | ie = je |
---|
302 | IF( iout == 0 ) THEN |
---|
303 | cdfnam=clexper(1:ic-1)//"_"//clave//cdfnam(1:ie-1)//clsuff(1:id-1) |
---|
304 | ELSE |
---|
305 | cdfnam=clexper(1:ic-1)//"_"//clave//clout(1:ig)//cdfnam(1:ie-1)//clsuff(1:id-1) |
---|
306 | ENDIF |
---|
307 | IF(lwp) WRITE(numout,*) cdfnam |
---|
308 | IF(lwp) WRITE(numout,*) |
---|
309 | |
---|
310 | ! FORMATS |
---|
311 | |
---|
312 | 9001 FORMAT("_",I2.2,2I2.2,"_",I2.2,2I2.2,"_") |
---|
313 | 9002 FORMAT("_",I3.3,2I2.2,"_",I3.3,2I2.2,"_") |
---|
314 | 9003 FORMAT("_",I4.4,2I2.2,"_",I4.4,2I2.2,"_") |
---|
315 | 9004 FORMAT("_",I6.6,2I2.2,"_",I6.6,2I2.2,"_") |
---|
316 | 9011 FORMAT("_",I2.2,I2.2,"_",I2.2,I2.2,"_") |
---|
317 | 9012 FORMAT("_",I3.3,I2.2,"_",I3.3,I2.2,"_") |
---|
318 | 9013 FORMAT("_",I4.4,I2.2,"_",I4.4,I2.2,"_") |
---|
319 | 9014 FORMAT("_",I6.6,I2.2,"_",I6.6,I2.2,"_") |
---|
320 | 9021 FORMAT("_",I2.2,"_",I2.2,"_") |
---|
321 | 9022 FORMAT("_",I3.3,"_",I3.3,"_") |
---|
322 | 9023 FORMAT("_",I4.4,"_",I4.4,"_") |
---|
323 | 9024 FORMAT("_",I6.6,"_",I6.6,"_") |
---|
324 | |
---|
325 | END SUBROUTINE dia_nam |
---|
326 | |
---|
327 | !!====================================================================== |
---|
328 | END MODULE dianam |
---|