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

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

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


Revision 1.8 - (hide annotations) (download)
Fri Jun 20 21:43:18 2008 UTC (15 years, 11 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 heimbach 1.1
2 edhill 1.4 #include "AUTODIFF_OPTIONS.h"
3 heimbach 1.1
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 heimbach 1.3 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 heimbach 1.1 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 heimbach 1.8 c - changed suboutine argument list:
27 heimbach 1.1 c dropped mycurrentiter, mycurrenttime
28 heimbach 1.3 c changed: heimbach@mit.edu 25-Mar-2002
29     c - added active file handling of xz-/yz-arrays
30 heimbach 1.1 c
31     c ==================================================================
32    
33 heimbach 1.2 CBOP
34     C !ROUTINE: adactive_read_xy
35     C !INTERFACE:
36 heimbach 1.8 #ifdef AUTODIFF_TAMC_COMPATIBILITY
37 heimbach 1.1 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 heimbach 1.8 #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 heimbach 1.1
58 heimbach 1.2 C !DESCRIPTION: \bv
59 heimbach 1.1 c ==================================================================
60 heimbach 1.2 c SUBROUTINE adactive_read_xy
61 heimbach 1.1 c ==================================================================
62     c o Adjoint of active_read_xy.
63     c started: Christian Eckert eckert@mit.edu 24-May-1999
64     c ==================================================================
65 heimbach 1.2 C \ev
66 heimbach 1.1
67 heimbach 1.2 C !USES:
68 heimbach 1.1 implicit none
69    
70     c == global variables ==
71     #include "EEPARAMS.h"
72     #include "SIZE.h"
73    
74 heimbach 1.2 C !INPUT/OUTPUT PARAMETERS:
75 heimbach 1.1 c == routine arguments ==
76 heimbach 1.2 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 heimbach 1.1 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 heimbach 1.2 C !LOCAL VARIABLES:
93 heimbach 1.1 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 heimbach 1.2 CEOP
105 heimbach 1.1
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 heimbach 1.2 CBOP
122     C !ROUTINE: adactive_read_xyz
123     C !INTERFACE:
124 heimbach 1.8 #ifdef AUTODIFF_TAMC_COMPATIBILITY
125 heimbach 1.1 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 heimbach 1.8 #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 heimbach 1.1
146 heimbach 1.2 C !DESCRIPTION: \bv
147 heimbach 1.1 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 heimbach 1.2 C \ev
154 heimbach 1.1
155 heimbach 1.2 C !USES:
156 heimbach 1.1 implicit none
157    
158     c == global variables ==
159     #include "EEPARAMS.h"
160     #include "SIZE.h"
161    
162     c == routine arguments ==
163 heimbach 1.2 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 heimbach 1.1 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 heimbach 1.2 C !LOCAL VARIABLES:
180 heimbach 1.1 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 heimbach 1.2 CEOP
192 heimbach 1.1
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 heimbach 1.2 CBOP
209 heimbach 1.3 C !ROUTINE: adactive_read_xz
210     C !INTERFACE:
211 heimbach 1.8 #ifdef AUTODIFF_TAMC_COMPATIBILITY
212 heimbach 1.3 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 heimbach 1.8 #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 heimbach 1.3
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 heimbach 1.8 #ifdef AUTODIFF_TAMC_COMPATIBILITY
299 heimbach 1.3 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 heimbach 1.8 #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 heimbach 1.3
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 heimbach 1.2 C !ROUTINE: adactive_read_xy
384     C !INTERFACE:
385 heimbach 1.8 #ifdef AUTODIFF_TAMC_COMPATIBILITY
386 heimbach 1.1 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 heimbach 1.8 #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 heimbach 1.1
405    
406 heimbach 1.2 C !DESCRIPTION: \bv
407 heimbach 1.1 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 heimbach 1.2 C \ev
414 heimbach 1.1
415 heimbach 1.2 C !USES:
416 heimbach 1.1 implicit none
417    
418     c == global variables ==
419     #include "EEPARAMS.h"
420     #include "SIZE.h"
421    
422     c == routine arguments ==
423 heimbach 1.2 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 heimbach 1.1 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 heimbach 1.2 C !LOCAL VARIABLES:
435 heimbach 1.1 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 heimbach 1.2 CEOP
448 heimbach 1.1
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 heimbach 1.2 CBOP
467     C !ROUTINE: adactive_read_xyz
468     C !INTERFACE:
469 heimbach 1.8 #ifdef AUTODIFF_TAMC_COMPATIBILITY
470 heimbach 1.1 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 heimbach 1.8 #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 heimbach 1.1
489    
490 heimbach 1.2 C !DESCRIPTION: \bv
491 heimbach 1.1 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 heimbach 1.2 C \ev
498 heimbach 1.1
499 heimbach 1.2 C !USES:
500 heimbach 1.1 implicit none
501    
502     c == global variables ==
503     #include "EEPARAMS.h"
504     #include "SIZE.h"
505    
506     c == routine arguments ==
507 heimbach 1.2 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 heimbach 1.1 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 heimbach 1.2 C !LOCAL VARIABLES:
519 heimbach 1.1 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 heimbach 1.2 CEOP
532 heimbach 1.1
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 heimbach 1.3 & globalfile, irec, mynr,
546     & REVERSE_SIMULATION, myiter, mythid )
547    
548     end
549    
550     CBOP
551     C !ROUTINE: adactive_read_xz
552     C !INTERFACE:
553 heimbach 1.8 #ifdef AUTODIFF_TAMC_COMPATIBILITY
554 heimbach 1.3 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 heimbach 1.8 #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 heimbach 1.3
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 heimbach 1.8 #ifdef AUTODIFF_TAMC_COMPATIBILITY
637 heimbach 1.3 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 heimbach 1.8 #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 heimbach 1.3
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 heimbach 1.1 & globalfile, irec, mynr,
713     & REVERSE_SIMULATION, myiter, mythid )
714    
715     end
716    
717    

  ViewVC Help
Powered by ViewVC 1.1.22