1 |
C $Header: /u/gcmpack/MITgcm/pkg/autodiff/active_file.F,v 1.9 2012/08/02 22:10:31 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "AUTODIFF_OPTIONS.h" |
5 |
|
6 |
C ================================================================== |
7 |
C active_file.F: Routines to handle the I/O of the active file for |
8 |
C the adjoint calculations. All files are direct |
9 |
C access files. |
10 |
C Routines |
11 |
C o active_read_xy_loc - Read an active 2D variable from file. |
12 |
C o active_read_xyz_loc - Read an active 3D variable from file. |
13 |
C o active_read_xz_loc - Read an active 2D xz-slice from file. |
14 |
C o active_read_yz_loc - Read an active 2D yz-slice from file. |
15 |
C |
16 |
C o active_write_xy_loc - Write an active 2D variable to a file. |
17 |
C o active_write_xyz_loc - Write an active 3D variable to a file. |
18 |
C o active_write_xz_loc - Write an active 2D xz-slice to a file. |
19 |
C o active_write_yz_loc - Write an active 2D yz-slice to a file. |
20 |
C |
21 |
C changed: Christian Eckert eckert@mit.edu 24-Apr-2000 |
22 |
C - Added routines that do active writes on tiles |
23 |
C instead of a whole thread. |
24 |
C changed: heimbach@mit.edu 05-Mar-2001 |
25 |
C - added active file handling of xz-/yz-arrays |
26 |
C ================================================================== |
27 |
|
28 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
29 |
CBOP |
30 |
C !ROUTINE: active_read_xy_loc |
31 |
C !INTERFACE: |
32 |
subroutine active_read_xy_loc( |
33 |
I active_var_file, |
34 |
O active_var, |
35 |
I iRec, |
36 |
I doglobalread, |
37 |
I lAdInit, |
38 |
I myOptimIter, |
39 |
I myThid |
40 |
I , dummy |
41 |
& ) |
42 |
|
43 |
C !DESCRIPTION: \bv |
44 |
C ================================================================== |
45 |
C SUBROUTINE active_read_xy_loc |
46 |
C ================================================================== |
47 |
C o Read an active 2D (XY) variable from file. |
48 |
C started: Christian Eckert eckert@mit.edu 30-Jun-1999 |
49 |
C ================================================================== |
50 |
C \ev |
51 |
|
52 |
C !USES: |
53 |
IMPLICIT NONE |
54 |
|
55 |
C == global variables == |
56 |
#include "EEPARAMS.h" |
57 |
#include "SIZE.h" |
58 |
|
59 |
C !INPUT/OUTPUT PARAMETERS: |
60 |
C active_var_file: filename |
61 |
C active_var: array |
62 |
C iRec: record number |
63 |
C myOptimIter: number of optimization iteration (default: 0) |
64 |
C myThid: thread number for this instance |
65 |
C doglobalread: flag for global or local read/write |
66 |
C (default: .false.) |
67 |
C lAdInit: initialisation of corresponding adjoint |
68 |
C variable and write to active file |
69 |
CHARACTER*(*) active_var_file |
70 |
_RL active_var(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
71 |
INTEGER iRec |
72 |
INTEGER myOptimIter |
73 |
INTEGER myThid |
74 |
LOGICAL doglobalread |
75 |
LOGICAL lAdInit |
76 |
_RL dummy |
77 |
|
78 |
C !LOCAL VARIABLES: |
79 |
INTEGER myNr |
80 |
LOGICAL useCurrentDir |
81 |
CEOP |
82 |
|
83 |
myNr = 1 |
84 |
useCurrentDir = .TRUE. |
85 |
CALL ACTIVE_READ_3D_RL( |
86 |
& active_var_file, active_var, doglobalread, |
87 |
& useCurrentDir, lAdInit, iRec, myNr, |
88 |
& FORWARD_SIMULATION, myOptimIter, myThid ) |
89 |
|
90 |
RETURN |
91 |
END |
92 |
|
93 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
94 |
CBOP |
95 |
C !ROUTINE: active_read_xyz_loc |
96 |
C !INTERFACE: |
97 |
subroutine active_read_xyz_loc( |
98 |
I active_var_file, |
99 |
O active_var, |
100 |
I iRec, |
101 |
I doglobalread, |
102 |
I lAdInit, |
103 |
I myOptimIter, |
104 |
I myThid |
105 |
I , dummy |
106 |
& ) |
107 |
|
108 |
C !DESCRIPTION: \bv |
109 |
C ================================================================== |
110 |
C SUBROUTINE active_read_xyz_loc |
111 |
C ================================================================== |
112 |
C o Read an active 3D variable from file. |
113 |
C started: Christian Eckert eckert@mit.edu 30-Jun-1999 |
114 |
C ================================================================== |
115 |
C \ev |
116 |
|
117 |
C !USES: |
118 |
IMPLICIT NONE |
119 |
|
120 |
C == global variables == |
121 |
#include "EEPARAMS.h" |
122 |
#include "SIZE.h" |
123 |
|
124 |
C !INPUT/OUTPUT PARAMETERS: |
125 |
C active_var_file: filename |
126 |
C active_var: array |
127 |
C iRec: record number |
128 |
C myOptimIter: number of optimization iteration (default: 0) |
129 |
C myThid: thread number for this instance |
130 |
C doglobalread: flag for global or local read/write |
131 |
C (default: .false.) |
132 |
C lAdInit: initialisation of corresponding adjoint |
133 |
C variable and write to active file |
134 |
CHARACTER*(*) active_var_file |
135 |
_RL active_var(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
136 |
INTEGER iRec |
137 |
INTEGER myOptimIter |
138 |
INTEGER myThid |
139 |
LOGICAL doglobalread |
140 |
LOGICAL lAdInit |
141 |
_RL dummy |
142 |
|
143 |
C !LOCAL VARIABLES: |
144 |
INTEGER myNr |
145 |
LOGICAL useCurrentDir |
146 |
CEOP |
147 |
|
148 |
myNr = Nr |
149 |
useCurrentDir = .TRUE. |
150 |
CALL ACTIVE_READ_3D_RL( |
151 |
& active_var_file, active_var, doglobalread, |
152 |
& useCurrentDir, lAdInit, iRec, myNr, |
153 |
& FORWARD_SIMULATION, myOptimIter, myThid ) |
154 |
|
155 |
RETURN |
156 |
END |
157 |
|
158 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
159 |
CBOP |
160 |
C !ROUTINE: active_read_xz_loc |
161 |
C !INTERFACE: |
162 |
subroutine active_read_xz_loc( |
163 |
I active_var_file, |
164 |
O active_var, |
165 |
I iRec, |
166 |
I doglobalread, |
167 |
I lAdInit, |
168 |
I myOptimIter, |
169 |
I myThid |
170 |
I , dummy |
171 |
& ) |
172 |
|
173 |
C !DESCRIPTION: \bv |
174 |
C ================================================================== |
175 |
C SUBROUTINE active_read_xz_loc |
176 |
C ================================================================== |
177 |
C o Read an active 2D xz-slice from file. |
178 |
C started: heimbach@mit.edu 05-Mar-2001 |
179 |
C ================================================================== |
180 |
C \ev |
181 |
|
182 |
C !USES: |
183 |
IMPLICIT NONE |
184 |
|
185 |
C == global variables == |
186 |
#include "EEPARAMS.h" |
187 |
#include "SIZE.h" |
188 |
|
189 |
C !INPUT/OUTPUT PARAMETERS: |
190 |
C active_var_file: filename |
191 |
C active_var: array |
192 |
C iRec: record number |
193 |
C myOptimIter: number of optimization iteration (default: 0) |
194 |
C myThid: thread number for this instance |
195 |
C doglobalread: flag for global or local read/write |
196 |
C (default: .false.) |
197 |
C lAdInit: initialisation of corresponding adjoint |
198 |
C variable and write to active file |
199 |
CHARACTER*(*) active_var_file |
200 |
_RL active_var(1-OLx:sNx+OLx,nSx,nSy) |
201 |
INTEGER iRec |
202 |
INTEGER myOptimIter |
203 |
INTEGER myThid |
204 |
LOGICAL doglobalread |
205 |
LOGICAL lAdInit |
206 |
_RL dummy |
207 |
|
208 |
C !LOCAL VARIABLES: |
209 |
INTEGER myNr |
210 |
LOGICAL useCurrentDir |
211 |
CEOP |
212 |
|
213 |
myNr = Nr |
214 |
useCurrentDir = .TRUE. |
215 |
CALL ACTIVE_READ_XZ_RL( |
216 |
& active_var_file, active_var, doglobalread, |
217 |
& useCurrentDir, lAdInit, iRec, myNr, |
218 |
& FORWARD_SIMULATION, myOptimIter, myThid ) |
219 |
|
220 |
RETURN |
221 |
END |
222 |
|
223 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
224 |
CBOP |
225 |
C !ROUTINE: active_read_yz_loc |
226 |
C !INTERFACE: |
227 |
subroutine active_read_yz_loc( |
228 |
I active_var_file, |
229 |
O active_var, |
230 |
I iRec, |
231 |
I doglobalread, |
232 |
I lAdInit, |
233 |
I myOptimIter, |
234 |
I myThid |
235 |
I , dummy |
236 |
& ) |
237 |
|
238 |
C !DESCRIPTION: \bv |
239 |
C ================================================================== |
240 |
C SUBROUTINE active_read_yz_loc |
241 |
C ================================================================== |
242 |
C o Read an active 2D yz-slice from file. |
243 |
C started: heimbach@mit.edu 05-Mar-2001 |
244 |
C ================================================================== |
245 |
C \ev |
246 |
|
247 |
IMPLICIT NONE |
248 |
|
249 |
C == global variables == |
250 |
#include "EEPARAMS.h" |
251 |
#include "SIZE.h" |
252 |
|
253 |
C !INPUT/OUTPUT PARAMETERS: |
254 |
C active_var_file: filename |
255 |
C active_var: array |
256 |
C iRec: record number |
257 |
C myOptimIter: number of optimization iteration (default: 0) |
258 |
C myThid: thread number for this instance |
259 |
C doglobalread: flag for global or local read/write |
260 |
C (default: .false.) |
261 |
C lAdInit: initialisation of corresponding adjoint |
262 |
C variable and write to active file |
263 |
CHARACTER*(*) active_var_file |
264 |
_RL active_var(1-OLy:sNy+OLy,nSx,nSy) |
265 |
INTEGER iRec |
266 |
INTEGER myOptimIter |
267 |
INTEGER myThid |
268 |
LOGICAL doglobalread |
269 |
LOGICAL lAdInit |
270 |
_RL dummy |
271 |
|
272 |
C !LOCAL VARIABLES: |
273 |
INTEGER myNr |
274 |
LOGICAL useCurrentDir |
275 |
CEOP |
276 |
|
277 |
myNr = Nr |
278 |
useCurrentDir = .TRUE. |
279 |
CALL ACTIVE_READ_YZ_RL( |
280 |
& active_var_file, active_var, doglobalread, |
281 |
& useCurrentDir, lAdInit, iRec, myNr, |
282 |
& FORWARD_SIMULATION, myOptimIter, myThid ) |
283 |
|
284 |
RETURN |
285 |
END |
286 |
|
287 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
288 |
CBOP |
289 |
C !ROUTINE: active_write_xy_loc |
290 |
C !INTERFACE: |
291 |
subroutine active_write_xy_loc( |
292 |
I active_var_file, |
293 |
I active_var, |
294 |
I iRec, |
295 |
I myOptimIter, |
296 |
I myThid |
297 |
I , dummy |
298 |
& ) |
299 |
|
300 |
C !DESCRIPTION: \bv |
301 |
C ================================================================== |
302 |
C SUBROUTINE active_write_xy_loc |
303 |
C ================================================================== |
304 |
C o Write an active 2D variable to a file. |
305 |
C started: Christian Eckert eckert@mit.edu 30-Jun-1999 |
306 |
C ================================================================== |
307 |
C \ev |
308 |
|
309 |
C !USES: |
310 |
IMPLICIT NONE |
311 |
|
312 |
C == global variables == |
313 |
#include "EEPARAMS.h" |
314 |
#include "SIZE.h" |
315 |
|
316 |
C !INPUT/OUTPUT PARAMETERS: |
317 |
C active_var_file: filename |
318 |
C active_var: array |
319 |
C iRec: record number |
320 |
C myOptimIter: number of optimization iteration (default: 0) |
321 |
C myThid: thread number for this instance |
322 |
CHARACTER*(*) active_var_file |
323 |
_RL active_var(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
324 |
INTEGER iRec |
325 |
INTEGER myOptimIter |
326 |
INTEGER myThid |
327 |
_RL dummy |
328 |
|
329 |
C !LOCAL VARIABLES: |
330 |
INTEGER myNr |
331 |
LOGICAL globalFile |
332 |
LOGICAL useCurrentDir |
333 |
CEOP |
334 |
|
335 |
myNr = 1 |
336 |
globalFile = .FALSE. |
337 |
useCurrentDir = .TRUE. |
338 |
CALL ACTIVE_WRITE_3D_RL( |
339 |
& active_var_file, active_var, globalFile, |
340 |
& useCurrentDir, iRec, myNr, |
341 |
& FORWARD_SIMULATION, myOptimIter, myThid ) |
342 |
|
343 |
RETURN |
344 |
END |
345 |
|
346 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
347 |
CBOP |
348 |
C !ROUTINE: active_write_xyz_loc |
349 |
C !INTERFACE: |
350 |
subroutine active_write_xyz_loc( |
351 |
I active_var_file, |
352 |
I active_var, |
353 |
I iRec, |
354 |
I myOptimIter, |
355 |
I myThid |
356 |
I , dummy |
357 |
& ) |
358 |
|
359 |
C !DESCRIPTION: \bv |
360 |
C ================================================================== |
361 |
C SUBROUTINE active_write_xyz_loc |
362 |
C ================================================================== |
363 |
C o Write an active 3D variable to a file. |
364 |
C started: Christian Eckert eckert@mit.edu 30-Jun-1999 |
365 |
C ================================================================== |
366 |
C \ev |
367 |
|
368 |
C !USES: |
369 |
IMPLICIT NONE |
370 |
|
371 |
C == global variables == |
372 |
#include "EEPARAMS.h" |
373 |
#include "SIZE.h" |
374 |
|
375 |
C !INPUT/OUTPUT PARAMETERS: |
376 |
C active_var_file: filename |
377 |
C active_var: array |
378 |
C iRec: record number |
379 |
C myOptimIter: number of optimization iteration (default: 0) |
380 |
C myThid: thread number for this instance |
381 |
CHARACTER*(*) active_var_file |
382 |
_RL active_var(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
383 |
INTEGER iRec |
384 |
INTEGER myOptimIter |
385 |
INTEGER myThid |
386 |
_RL dummy |
387 |
|
388 |
C !LOCAL VARIABLES: |
389 |
INTEGER myNr |
390 |
LOGICAL globalFile |
391 |
LOGICAL useCurrentDir |
392 |
CEOP |
393 |
|
394 |
myNr = Nr |
395 |
globalFile = .FALSE. |
396 |
useCurrentDir = .TRUE. |
397 |
CALL ACTIVE_WRITE_3D_RL( |
398 |
& active_var_file, active_var, globalFile, |
399 |
& useCurrentDir, iRec, myNr, |
400 |
& FORWARD_SIMULATION, myOptimIter, myThid ) |
401 |
|
402 |
RETURN |
403 |
END |
404 |
|
405 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
406 |
CBOP |
407 |
C !ROUTINE: active_write_xz_loc |
408 |
C !INTERFACE: |
409 |
subroutine active_write_xz_loc( |
410 |
I active_var_file, |
411 |
I active_var, |
412 |
I iRec, |
413 |
I myOptimIter, |
414 |
I myThid |
415 |
I , dummy |
416 |
& ) |
417 |
|
418 |
C !DESCRIPTION: \bv |
419 |
C ================================================================== |
420 |
C SUBROUTINE active_write_xz_loc |
421 |
C ================================================================== |
422 |
C o Write an active 2D xz-slice to a file. |
423 |
C started: heimbach@mit.edu 05-Mar-2001 |
424 |
C ================================================================== |
425 |
C \ev |
426 |
|
427 |
C !USES: |
428 |
IMPLICIT NONE |
429 |
|
430 |
C == global variables == |
431 |
#include "EEPARAMS.h" |
432 |
#include "SIZE.h" |
433 |
|
434 |
C !INPUT/OUTPUT PARAMETERS: |
435 |
C active_var_file: filename |
436 |
C active_var: array |
437 |
C iRec: record number |
438 |
C myOptimIter: number of optimization iteration (default: 0) |
439 |
C myThid: thread number for this instance |
440 |
CHARACTER*(*) active_var_file |
441 |
_RL active_var(1-OLx:sNx+OLx,nSx,nSy) |
442 |
INTEGER iRec |
443 |
INTEGER myOptimIter |
444 |
INTEGER myThid |
445 |
_RL dummy |
446 |
|
447 |
C !LOCAL VARIABLES: |
448 |
INTEGER myNr |
449 |
LOGICAL globalFile |
450 |
LOGICAL useCurrentDir |
451 |
CEOP |
452 |
|
453 |
myNr = Nr |
454 |
globalFile = .FALSE. |
455 |
useCurrentDir = .TRUE. |
456 |
CALL ACTIVE_WRITE_XZ_RL( |
457 |
& active_var_file, active_var, globalFile, |
458 |
& useCurrentDir, iRec, myNr, |
459 |
& FORWARD_SIMULATION, myOptimIter, myThid ) |
460 |
|
461 |
RETURN |
462 |
END |
463 |
|
464 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
465 |
CBOP |
466 |
C !ROUTINE: active_write_yz_loc |
467 |
C !INTERFACE: |
468 |
subroutine active_write_yz_loc( |
469 |
I active_var_file, |
470 |
I active_var, |
471 |
I iRec, |
472 |
I myOptimIter, |
473 |
I myThid |
474 |
I , dummy |
475 |
& ) |
476 |
|
477 |
C !DESCRIPTION: \bv |
478 |
C ================================================================== |
479 |
C SUBROUTINE active_write_yz_loc |
480 |
C ================================================================== |
481 |
C o Write an active 2D variable to a file. |
482 |
C started: heimbach@mit.edu 05-Mar-2001 |
483 |
C ================================================================== |
484 |
C \ev |
485 |
|
486 |
C !USES: |
487 |
IMPLICIT NONE |
488 |
|
489 |
C == global variables == |
490 |
#include "EEPARAMS.h" |
491 |
#include "SIZE.h" |
492 |
|
493 |
C !INPUT/OUTPUT PARAMETERS: |
494 |
C active_var_file: filename |
495 |
C active_var: array |
496 |
C iRec: record number |
497 |
C myOptimIter: number of optimization iteration (default: 0) |
498 |
C myThid: thread number for this instance |
499 |
CHARACTER*(*) active_var_file |
500 |
_RL active_var(1-OLy:sNy+OLy,nSx,nSy) |
501 |
INTEGER iRec |
502 |
INTEGER myOptimIter |
503 |
INTEGER myThid |
504 |
_RL dummy |
505 |
|
506 |
C !LOCAL VARIABLES: |
507 |
INTEGER myNr |
508 |
LOGICAL globalFile |
509 |
LOGICAL useCurrentDir |
510 |
CEOP |
511 |
|
512 |
myNr = Nr |
513 |
globalFile = .FALSE. |
514 |
useCurrentDir = .TRUE. |
515 |
CALL ACTIVE_WRITE_YZ_RL( |
516 |
& active_var_file, active_var, globalFile, |
517 |
& useCurrentDir, iRec, myNr, |
518 |
& FORWARD_SIMULATION, myOptimIter, myThid ) |
519 |
|
520 |
RETURN |
521 |
END |