1 |
! $Header: /u/gcmpack/MITgcm/tools/OAD_support/ad_template.active_read_xy.F,v 1.3 2015/01/17 07:13:07 heimbach Exp $ |
2 |
! $Name: $ |
3 |
|
4 |
#include "OPENAD_OPTIONS.h" |
5 |
|
6 |
subroutine template() |
7 |
C !FUNCTIONS |
8 |
use OAD_tape |
9 |
use OAD_rev |
10 |
use OAD_cp |
11 |
|
12 |
|
13 |
! original arguments get inserted before version |
14 |
! ! and declared here together with all local variables |
15 |
! ! generated by xaifBooster |
16 |
|
17 |
!use mode_variables |
18 |
|
19 |
!$TEMPLATE_PRAGMA_DECLARATIONS |
20 |
type(modeType) :: our_orig_mode |
21 |
|
22 |
integer iaddr |
23 |
external iaddr |
24 |
|
25 |
!LOCAL VARIABLES: |
26 |
CHARACTER*(2) adpref |
27 |
CHARACTER*(80) fname |
28 |
INTEGER il |
29 |
INTEGER myNr |
30 |
LOGICAL useCurrentDir |
31 |
Real*8 active_var_p(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
32 |
INTEGER ILNBLNK |
33 |
EXTERNAL ILNBLNK |
34 |
|
35 |
#ifdef ALLOW_OPENAD_ACTIVE_READ_XYZ |
36 |
|
37 |
myNr = Nr |
38 |
useCurrentDir = .FALSE. |
39 |
|
40 |
if (our_rev_mode%plain) then |
41 |
our_orig_mode = our_rev_mode |
42 |
! original function |
43 |
active_var_p = active_var%v |
44 |
! set up for plain execution |
45 |
our_rev_mode%arg_store=.FALSE. |
46 |
our_rev_mode%arg_restore=.FALSE. |
47 |
our_rev_mode%plain=.TRUE. |
48 |
our_rev_mode%tape=.FALSE. |
49 |
our_rev_mode%adjoint=.FALSE. |
50 |
call ACTIVE_READ_3D_RL( |
51 |
& active_var_file, active_var_p, doglobalread, |
52 |
& useCurrentDir, lAdInit, iRec, myNr, |
53 |
& FORWARD_SIMULATION, myOptimIter, myThid ) |
54 |
! reset the mode |
55 |
our_rev_mode=our_orig_mode |
56 |
! copy back |
57 |
active_var%v = active_var_p |
58 |
end if |
59 |
|
60 |
if (our_rev_mode%tape) then |
61 |
! taping |
62 |
our_orig_mode=our_rev_mode |
63 |
our_rev_mode%arg_store=.FALSE. |
64 |
our_rev_mode%arg_restore=.FALSE. |
65 |
our_rev_mode%plain=.TRUE. |
66 |
our_rev_mode%tape=.FALSE. |
67 |
our_rev_mode%adjoint=.FALSE. |
68 |
if (oad_st_sz.lt.oad_st_ptr) call oad_st_grow() |
69 |
oad_st(oad_st_ptr) = active_var_file |
70 |
oad_st_ptr = oad_st_ptr+1 |
71 |
if (oad_it_sz.lt.oad_it_ptr) call oad_it_grow() |
72 |
oad_it(oad_it_ptr) = iRec |
73 |
oad_it_ptr = oad_it_ptr+1 |
74 |
call ACTIVE_READ_3D_RL( |
75 |
& active_var_file, active_var, doglobalread, |
76 |
& useCurrentDir, lAdInit, iRec, myNr, |
77 |
& FORWARD_SIMULATION, myOptimIter, myThid ) |
78 |
our_rev_mode=our_orig_mode |
79 |
end if |
80 |
|
81 |
if (our_rev_mode%adjoint) then |
82 |
! adjoint |
83 |
oad_st_ptr = oad_st_ptr-1 |
84 |
active_var_file = oad_st(oad_st_ptr) |
85 |
oad_it_ptr = oad_it_ptr-1 |
86 |
iRec = oad_it(oad_it_ptr) |
87 |
adpref = 'ad' |
88 |
il = ILNBLNK( active_var_file ) |
89 |
WRITE(fname(1:80),'(A)') ' ' |
90 |
WRITE(fname(1:2+il),'(2A)') adpref, active_var_file(1:il) |
91 |
! WRITE(fname(1:2+il),'(2A)') adpref, active_var_file |
92 |
active_var_p = active_var%d |
93 |
! set up for plain execution |
94 |
our_orig_mode=our_rev_mode |
95 |
our_rev_mode%arg_store=.FALSE. |
96 |
our_rev_mode%arg_restore=.FALSE. |
97 |
our_rev_mode%plain=.TRUE. |
98 |
our_rev_mode%tape=.FALSE. |
99 |
our_rev_mode%adjoint=.FALSE. |
100 |
call ACTIVE_READ_3D_RL( |
101 |
& fname, active_var_p, doglobalread, |
102 |
& useCurrentDir, lAdInit, iRec, myNr, |
103 |
& REVERSE_SIMULATION, myOptimIter, myThid ) |
104 |
! reset the mode |
105 |
our_rev_mode=our_orig_mode |
106 |
! copy back |
107 |
active_var%d = active_var_p |
108 |
end if |
109 |
|
110 |
#endif /* ALLOW_OPENAD_ACTIVE_READ_XYZ */ |
111 |
|
112 |
end |