/[MITgcm]/MITgcm/pkg/autodiff/active_file_ad.F
ViewVC logotype

Contents of /MITgcm/pkg/autodiff/active_file_ad.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.8 - (show annotations) (download)
Fri Jun 20 21:43:18 2008 UTC (16 years, 3 months ago) by heimbach
Branch: MAIN
CVS Tags: checkpoint61, checkpoint61a
Changes since 1.7: +93 -414 lines
o autodiff
  Change default for TAF usage by removing argument '-nonew_arg'
  This changes TAF subroutine argument list (ordering of active var.)
  Omission of this flag leads to incompatibility w.r.t. TAMC
  To restore TAMC-compatibility, need following modifs:
  * use adoptfile tools/adjoint_options/adjoint_tamc_compatibility
  * use CPP option #define AUTODIFF_TAMC_COMPATIBILITY
  Tested TAF version is 1.9.22
  N.B.: exch2 hand-written adjoint code currently not TAMC compatible

1
2 #include "AUTODIFF_OPTIONS.h"
3
4 c ==================================================================
5 c
6 c active_files_ad.F: Routines to handle the I/O of the active file
7 c for the adjoint calculations. All files are
8 c direct access files.
9 c
10 c Routines
11 c
12 c o adactive_read_xy - Adjoint of active_read_xy
13 c o adactive_read_xyz - Adjoint of active_read_xyz
14 c o adactive_write_xy - Adjoint of active_write_xy
15 c o adactive_write_xyz - Adjoint of active_write_xyz
16 c
17 c o adactive_read_xz - Adjoint of active_read_xz
18 c o adactive_read_yz - Adjoint of active_read_yz
19 c o adactive_write_xz - Adjoint of active_write_xz
20 c o adactive_write_yz - Adjoint of active_write_yz
21 c
22 c changed: Christian Eckert eckert@mit.edu 24-Apr-2000
23 c - Added routines that do active writes on tiles
24 c instead of a whole thread.
25 c changed: Patrick Heimbach heimbach@mit.edu 27-May-2000
26 c - changed suboutine argument list:
27 c dropped mycurrentiter, mycurrenttime
28 c changed: heimbach@mit.edu 25-Mar-2002
29 c - added active file handling of xz-/yz-arrays
30 c
31 c ==================================================================
32
33 CBOP
34 C !ROUTINE: adactive_read_xy
35 C !INTERFACE:
36 #ifdef AUTODIFF_TAMC_COMPATIBILITY
37 subroutine adactive_read_xy(
38 I active_var_file,
39 I irec,
40 I doglobalread,
41 I lAdInit,
42 I myiter,
43 I mythid,
44 I adactive_var
45 & )
46 #else
47 subroutine adactive_read_xy(
48 I active_var_file,
49 I adactive_var,
50 I irec,
51 I doglobalread,
52 I lAdInit,
53 I myiter,
54 I mythid
55 & )
56 #endif
57
58 C !DESCRIPTION: \bv
59 c ==================================================================
60 c SUBROUTINE adactive_read_xy
61 c ==================================================================
62 c o Adjoint of active_read_xy.
63 c started: Christian Eckert eckert@mit.edu 24-May-1999
64 c ==================================================================
65 C \ev
66
67 C !USES:
68 implicit none
69
70 c == global variables ==
71 #include "EEPARAMS.h"
72 #include "SIZE.h"
73
74 C !INPUT/OUTPUT PARAMETERS:
75 c == routine arguments ==
76 c active_var_file: filename
77 c adactive_var: array
78 c irec: record number
79 c myIter: number of optimization iteration (default: 0)
80 c mythid: thread number for this instance
81 c doglobalread: flag for global or local read/write
82 c (default: .false.)
83 c lAdInit: initialisation of corresponding adjoint
84 c variable and write to active file
85 character*(*) active_var_file
86 _RL adactive_var(1-olx:snx+olx,1-oly:sny+oly,nsx,nsy)
87 integer irec
88 integer myiter,mythid
89 logical doglobalread
90 logical lAdInit
91
92 C !LOCAL VARIABLES:
93 c == local variables ==
94 integer mynr
95 integer il
96 integer ilnblnk
97 character*(2) adpref
98 character*(80) fname
99
100 c == functions ==
101 external ilnblnk
102
103 c == end of interface ==
104 CEOP
105
106 mynr = 1
107 adpref = 'ad'
108 write(fname(1:80),'(a)') ' '
109
110 il = ilnblnk(active_var_file)
111
112 write(fname(1:2),'(a)') adpref
113 write(fname(3:2+il),'(a)') active_var_file(1:il)
114
115 call active_read_rl( fname, adactive_var,
116 & doglobalread, lAdInit, irec, mynr,
117 & REVERSE_SIMULATION, myiter, mythid )
118
119 end
120
121 CBOP
122 C !ROUTINE: adactive_read_xyz
123 C !INTERFACE:
124 #ifdef AUTODIFF_TAMC_COMPATIBILITY
125 subroutine adactive_read_xyz(
126 I active_var_file,
127 I irec,
128 I doglobalread,
129 I lAdInit,
130 I myiter,
131 I mythid,
132 I adactive_var
133 & )
134 #else
135 subroutine adactive_read_xyz(
136 I active_var_file,
137 I adactive_var,
138 I irec,
139 I doglobalread,
140 I lAdInit,
141 I myiter,
142 I mythid
143 & )
144 #endif
145
146 C !DESCRIPTION: \bv
147 c ==================================================================
148 c SUBROUTINE adactive_read_xyz
149 c ==================================================================
150 c o Adjoint of active_read_xyz.
151 c started: Christian Eckert eckert@mit.edu 24-May-1999
152 c ==================================================================
153 C \ev
154
155 C !USES:
156 implicit none
157
158 c == global variables ==
159 #include "EEPARAMS.h"
160 #include "SIZE.h"
161
162 c == routine arguments ==
163 c active_var_file: filename
164 c adactive_var: array
165 c irec: record number
166 c myIter: number of optimization iteration (default: 0)
167 c mythid: thread number for this instance
168 c doglobalread: flag for global or local read/write
169 c (default: .false.)
170 c lAdInit: initialisation of corresponding adjoint
171 c variable and write to active file
172 character*(*) active_var_file
173 _RL adactive_var(1-olx:snx+olx,1-oly:sny+oly,nr,nsx,nsy)
174 integer irec
175 integer myiter,mythid
176 logical doglobalread
177 logical lAdInit
178
179 C !LOCAL VARIABLES:
180 c == local variables ==
181 integer mynr
182 integer il
183 integer ilnblnk
184 character*(2) adpref
185 character*(80) fname
186
187 c == functions ==
188 external ilnblnk
189
190 c == end of interface ==
191 CEOP
192
193 mynr = nr
194 adpref = 'ad'
195 write(fname(1:80),'(a)') ' '
196
197 il = ilnblnk(active_var_file)
198
199 write(fname(1:2),'(a)') adpref
200 write(fname(3:2+il),'(a)') active_var_file(1:il)
201
202 call active_read_rl( fname, adactive_var,
203 & doglobalread, lAdInit, irec, mynr,
204 & REVERSE_SIMULATION, myiter, mythid )
205
206 end
207
208 CBOP
209 C !ROUTINE: adactive_read_xz
210 C !INTERFACE:
211 #ifdef AUTODIFF_TAMC_COMPATIBILITY
212 subroutine adactive_read_xz(
213 I active_var_file,
214 I irec,
215 I doglobalread,
216 I lAdInit,
217 I myiter,
218 I mythid,
219 I adactive_var
220 & )
221 #else
222 subroutine adactive_read_xz(
223 I active_var_file,
224 I adactive_var,
225 I irec,
226 I doglobalread,
227 I lAdInit,
228 I myiter,
229 I mythid
230 & )
231 #endif
232
233 C !DESCRIPTION: \bv
234 c ==================================================================
235 c SUBROUTINE adactive_read_xz
236 c ==================================================================
237 c o Adjoint of active_read_xz.
238 c started: heimbach@mit.edu 05-Mar-2001
239 c ==================================================================
240 C \ev
241
242 C !USES:
243 implicit none
244
245 c == global variables ==
246 #include "EEPARAMS.h"
247 #include "SIZE.h"
248
249 c == routine arguments ==
250 c active_var_file: filename
251 c adactive_var: array
252 c irec: record number
253 c myIter: number of optimization iteration (default: 0)
254 c mythid: thread number for this instance
255 c doglobalread: flag for global or local read/write
256 c (default: .false.)
257 c lAdInit: initialisation of corresponding adjoint
258 c variable and write to active file
259 character*(*) active_var_file
260 _RL adactive_var(1-olx:snx+olx,nr,nsx,nsy)
261 integer irec
262 integer myiter,mythid
263 logical doglobalread
264 logical lAdInit
265
266 C !LOCAL VARIABLES:
267 c == local variables ==
268 integer mynr
269 integer il
270 integer ilnblnk
271 character*(2) adpref
272 character*(80) fname
273
274 c == functions ==
275 external ilnblnk
276
277 c == end of interface ==
278 CEOP
279
280 mynr = nr
281 adpref = 'ad'
282 write(fname(1:80),'(a)') ' '
283
284 il = ilnblnk(active_var_file)
285
286 write(fname(1:2),'(a)') adpref
287 write(fname(3:2+il),'(a)') active_var_file(1:il)
288
289 call active_read_xz_rl( fname, adactive_var,
290 & doglobalread, lAdInit, irec, mynr,
291 & REVERSE_SIMULATION, myiter, mythid )
292
293 end
294
295 CBOP
296 C !ROUTINE: adactive_read_yz
297 C !INTERFACE:
298 #ifdef AUTODIFF_TAMC_COMPATIBILITY
299 subroutine adactive_read_yz(
300 I active_var_file,
301 I irec,
302 I doglobalread,
303 I lAdInit,
304 I myiter,
305 I mythid,
306 I adactive_var
307 & )
308 #else
309 subroutine adactive_read_yz(
310 I active_var_file,
311 I adactive_var,
312 I irec,
313 I doglobalread,
314 I lAdInit,
315 I myiter,
316 I mythid
317 & )
318 #endif
319
320 C !DESCRIPTION: \bv
321 c ==================================================================
322 c SUBROUTINE adactive_read_yz
323 c ==================================================================
324 c o Adjoint of active_read_yz.
325 c started: heimbach@mit.edu 05-Mar-2001
326 c ==================================================================
327 C \ev
328
329 C !USES:
330 implicit none
331
332 c == global variables ==
333 #include "EEPARAMS.h"
334 #include "SIZE.h"
335
336 c == routine arguments ==
337 c active_var_file: filename
338 c adactive_var: array
339 c irec: record number
340 c myIter: number of optimization iteration (default: 0)
341 c mythid: thread number for this instance
342 c doglobalread: flag for global or local read/write
343 c (default: .false.)
344 c lAdInit: initialisation of corresponding adjoint
345 c variable and write to active file
346 character*(*) active_var_file
347 _RL adactive_var(1-oly:sny+oly,nr,nsx,nsy)
348 integer irec
349 integer myiter,mythid
350 logical doglobalread
351 logical lAdInit
352
353 C !LOCAL VARIABLES:
354 c == local variables ==
355 integer mynr
356 integer il
357 integer ilnblnk
358 character*(2) adpref
359 character*(80) fname
360
361 c == functions ==
362 external ilnblnk
363
364 c == end of interface ==
365 CEOP
366
367 mynr = nr
368 adpref = 'ad'
369 write(fname(1:80),'(a)') ' '
370
371 il = ilnblnk(active_var_file)
372
373 write(fname(1:2),'(a)') adpref
374 write(fname(3:2+il),'(a)') active_var_file(1:il)
375
376 call active_read_yz_rl( fname, adactive_var,
377 & doglobalread, lAdInit, irec, mynr,
378 & REVERSE_SIMULATION, myiter, mythid )
379
380 end
381
382 CBOP
383 C !ROUTINE: adactive_read_xy
384 C !INTERFACE:
385 #ifdef AUTODIFF_TAMC_COMPATIBILITY
386 subroutine adactive_write_xy(
387 I active_var_file,
388 I irec,
389 I myiter,
390 I mythid,
391 U adactive_var,
392 I dummy
393 & )
394 #else
395 subroutine adactive_write_xy(
396 I active_var_file,
397 U adactive_var,
398 I irec,
399 I myiter,
400 I mythid,
401 I dummy
402 & )
403 #endif
404
405
406 C !DESCRIPTION: \bv
407 c ==================================================================
408 c SUBROUTINE adactive_write_xy
409 c ==================================================================
410 c o Adjoint of active_write_xy.
411 c started: Christian Eckert eckert@mit.edu 24-May-1999
412 c ==================================================================
413 C \ev
414
415 C !USES:
416 implicit none
417
418 c == global variables ==
419 #include "EEPARAMS.h"
420 #include "SIZE.h"
421
422 c == routine arguments ==
423 c active_var_file: filename
424 c adactive_var: array
425 c irec: record number
426 c myIter: number of optimization iteration (default: 0)
427 c mythid: thread number for this instance
428 character*(*) active_var_file
429 _RL adactive_var(1-olx:snx+olx,1-oly:sny+oly,nsx,nsy)
430 integer irec
431 integer myiter,mythid
432 _RL dummy
433
434 C !LOCAL VARIABLES:
435 c == local variables ==
436 integer mynr
437 integer il
438 integer ilnblnk
439 character*(2) adpref
440 character*(80) fname
441 logical globalfile
442
443 c == functions ==
444 external ilnblnk
445
446 c == end of interface ==
447 CEOP
448
449 mynr = 1
450 adpref = 'ad'
451 write(fname(1:80),'(a)') ' '
452
453 il = ilnblnk(active_var_file)
454
455 write(fname(1:2),'(a)') adpref
456 write(fname(3:2+il),'(a)') active_var_file(1:il)
457
458 globalfile = .false.
459
460 call active_write_rl( fname, adactive_var,
461 & globalfile, irec, mynr,
462 & REVERSE_SIMULATION, myiter, mythid )
463
464 end
465
466 CBOP
467 C !ROUTINE: adactive_read_xyz
468 C !INTERFACE:
469 #ifdef AUTODIFF_TAMC_COMPATIBILITY
470 subroutine adactive_write_xyz(
471 I active_var_file,
472 I irec,
473 I myiter,
474 I mythid,
475 U adactive_var,
476 I dummy
477 & )
478 #else
479 subroutine adactive_write_xyz(
480 I active_var_file,
481 U adactive_var,
482 I irec,
483 I myiter,
484 I mythid,
485 I dummy
486 & )
487 #endif
488
489
490 C !DESCRIPTION: \bv
491 c ==================================================================
492 c SUBROUTINE adactive_write_xyz
493 c ==================================================================
494 c o Adjoint of active_write_xyz.
495 c started: Christian Eckert eckert@mit.edu 24-May-1999
496 c ==================================================================
497 C \ev
498
499 C !USES:
500 implicit none
501
502 c == global variables ==
503 #include "EEPARAMS.h"
504 #include "SIZE.h"
505
506 c == routine arguments ==
507 c active_var_file: filename
508 c adactive_var: array
509 c irec: record number
510 c myIter: number of optimization iteration (default: 0)
511 c mythid: thread number for this instance
512 character*(*) active_var_file
513 _RL adactive_var(1-olx:snx+olx,1-oly:sny+oly,nr,nsx,nsy)
514 integer irec
515 integer myiter,mythid
516 _RL dummy
517
518 C !LOCAL VARIABLES:
519 c == local variables ==
520 integer mynr
521 integer il
522 integer ilnblnk
523 character*(2) adpref
524 character*(80) fname
525 logical globalfile
526
527 c == functions ==
528 external ilnblnk
529
530 c == end of interface ==
531 CEOP
532
533 mynr = nr
534 adpref = 'ad'
535 write(fname(1:80),'(a)') ' '
536
537 il = ilnblnk(active_var_file)
538
539 write(fname(1:2),'(a)') adpref
540 write(fname(3:2+il),'(a)') active_var_file(1:il)
541
542 globalfile = .false.
543
544 call active_write_rl( fname, adactive_var,
545 & globalfile, irec, mynr,
546 & REVERSE_SIMULATION, myiter, mythid )
547
548 end
549
550 CBOP
551 C !ROUTINE: adactive_read_xz
552 C !INTERFACE:
553 #ifdef AUTODIFF_TAMC_COMPATIBILITY
554 subroutine adactive_write_xz(
555 I active_var_file,
556 I irec,
557 I myiter,
558 I mythid,
559 U adactive_var,
560 I dummy
561 & )
562 #else
563 subroutine adactive_write_xz(
564 I active_var_file,
565 U adactive_var,
566 I irec,
567 I myiter,
568 I mythid,
569 I dummy
570 & )
571 #endif
572
573 C !DESCRIPTION: \bv
574 c ==================================================================
575 c SUBROUTINE adactive_write_xz
576 c ==================================================================
577 c o Adjoint of active_write_xz.
578 c started: heimbach@mit.edu 05-Mar-2001
579 c ==================================================================
580 C \ev
581
582 C !USES:
583 implicit none
584
585 c == global variables ==
586 #include "EEPARAMS.h"
587 #include "SIZE.h"
588
589 c == routine arguments ==
590 c active_var_file: filename
591 c adactive_var: array
592 c irec: record number
593 c myIter: number of optimization iteration (default: 0)
594 c mythid: thread number for this instance
595 character*(*) active_var_file
596 _RL adactive_var(1-olx:snx+olx,nr,nsx,nsy)
597 integer irec
598 integer myiter,mythid
599 _RL dummy
600
601 C !LOCAL VARIABLES:
602 c == local variables ==
603 integer mynr
604 integer il
605 integer ilnblnk
606 character*(2) adpref
607 character*(80) fname
608 logical globalfile
609
610 c == functions ==
611 external ilnblnk
612
613 c == end of interface ==
614 CEOP
615
616 mynr = nr
617 adpref = 'ad'
618 write(fname(1:80),'(a)') ' '
619
620 il = ilnblnk(active_var_file)
621
622 write(fname(1:2),'(a)') adpref
623 write(fname(3:2+il),'(a)') active_var_file(1:il)
624
625 globalfile = .false.
626
627 call active_write_xz_rl( fname, adactive_var,
628 & globalfile, irec, mynr,
629 & REVERSE_SIMULATION, myiter, mythid )
630
631 end
632
633 CBOP
634 C !ROUTINE: adactive_read_yz
635 C !INTERFACE:
636 #ifdef AUTODIFF_TAMC_COMPATIBILITY
637 subroutine adactive_write_yz(
638 I active_var_file,
639 I irec,
640 I myiter,
641 I mythid,
642 U adactive_var,
643 I dummy
644 & )
645 #else
646 subroutine adactive_write_yz(
647 I active_var_file,
648 U adactive_var,
649 I irec,
650 I myiter,
651 I mythid,
652 I dummy
653 & )
654 #endif
655
656
657 C !DESCRIPTION: \bv
658 c ==================================================================
659 c SUBROUTINE adactive_write_yz
660 c ==================================================================
661 c o Adjoint of active_write_yz.
662 c started: heimbach@mit.edu 05-Mar-2001
663 c ==================================================================
664 C \ev
665
666 C !USES:
667 implicit none
668
669 c == global variables ==
670 #include "EEPARAMS.h"
671 #include "SIZE.h"
672
673 c == routine arguments ==
674 c active_var_file: filename
675 c adactive_var: array
676 c irec: record number
677 c myIter: number of optimization iteration (default: 0)
678 c mythid: thread number for this instance
679 character*(*) active_var_file
680 _RL adactive_var(1-oly:sny+oly,nr,nsx,nsy)
681 integer irec
682 integer myiter,mythid
683 _RL dummy
684
685 C !LOCAL VARIABLES:
686 c == local variables ==
687 integer mynr
688 integer il
689 integer ilnblnk
690 character*(2) adpref
691 character*(80) fname
692 logical globalfile
693
694 c == functions ==
695 external ilnblnk
696
697 c == end of interface ==
698 CEOP
699
700 mynr = nr
701 adpref = 'ad'
702 write(fname(1:80),'(a)') ' '
703
704 il = ilnblnk(active_var_file)
705
706 write(fname(1:2),'(a)') adpref
707 write(fname(3:2+il),'(a)') active_var_file(1:il)
708
709 globalfile = .false.
710
711 call active_write_yz_rl( fname, adactive_var,
712 & globalfile, irec, mynr,
713 & REVERSE_SIMULATION, myiter, mythid )
714
715 end
716
717

  ViewVC Help
Powered by ViewVC 1.1.22