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