/[MITgcm]/MITgcm/tools/OAD_support/ad_template.active_write_xy.F
ViewVC logotype

Contents of /MITgcm/tools/OAD_support/ad_template.active_write_xy.F

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


Revision 1.1 - (show annotations) (download)
Wed Feb 11 00:09:55 2015 UTC (9 years, 2 months ago) by heimbach
Branch: MAIN
Begin active write for OpenAD

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 globalFile
31 LOGICAL useCurrentDir
32 Real*8 active_var_p(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
33 INTEGER ILNBLNK
34 EXTERNAL ILNBLNK
35
36 #ifdef ALLOW_OPENAD_ACTIVE_WRITE
37
38 myNr = 1
39 useCurrentDir = .FALSE.
40
41 if (our_rev_mode%plain) then
42 our_orig_mode = our_rev_mode
43 ! original function
44 active_var_p = active_var%v
45 ! set up for plain execution
46 our_rev_mode%arg_store=.FALSE.
47 our_rev_mode%arg_restore=.FALSE.
48 our_rev_mode%plain=.TRUE.
49 our_rev_mode%tape=.FALSE.
50 our_rev_mode%adjoint=.FALSE.
51 call ACTIVE_WRITE_3D_RL(
52 & active_var_file, active_var_p, globalFile,
53 & useCurrentDir, iRec, myNr,
54 & FORWARD_SIMULATION, myOptimIter, myThid )
55 ! reset the mode
56 our_rev_mode=our_orig_mode
57 ! copy back
58 active_var%v = active_var_p
59 end if
60
61 if (our_rev_mode%tape) then
62 ! taping
63 our_orig_mode=our_rev_mode
64 our_rev_mode%arg_store=.FALSE.
65 our_rev_mode%arg_restore=.FALSE.
66 our_rev_mode%plain=.TRUE.
67 our_rev_mode%tape=.FALSE.
68 our_rev_mode%adjoint=.FALSE.
69 if (oad_st_sz.lt.oad_st_ptr) call oad_st_grow()
70 oad_st(oad_st_ptr) = active_var_file
71 oad_st_ptr = oad_st_ptr+1
72 if (oad_it_sz.lt.oad_it_ptr) call oad_it_grow()
73 oad_it(oad_it_ptr) = iRec
74 oad_it_ptr = oad_it_ptr+1
75 call ACTIVE_WRITE_3D_RL(
76 & active_var_file, active_var, globalFile,
77 & useCurrentDir, iRec, myNr,
78 & FORWARD_SIMULATION, myOptimIter, myThid )
79 our_rev_mode=our_orig_mode
80 end if
81
82 if (our_rev_mode%adjoint) then
83 ! adjoint
84 oad_st_ptr = oad_st_ptr-1
85 active_var_file = oad_st(oad_st_ptr)
86 oad_it_ptr = oad_it_ptr-1
87 iRec = oad_it(oad_it_ptr)
88 adpref = 'ad'
89 il = ILNBLNK( active_var_file )
90 WRITE(fname(1:80),'(A)') ' '
91 WRITE(fname(1:2+il),'(2A)') adpref, active_var_file(1:il)
92 ! WRITE(fname(1:2+il),'(2A)') adpref, active_var_file
93 active_var_p = active_var%d
94 ! set up for plain execution
95 our_orig_mode=our_rev_mode
96 our_rev_mode%arg_store=.FALSE.
97 our_rev_mode%arg_restore=.FALSE.
98 our_rev_mode%plain=.TRUE.
99 our_rev_mode%tape=.FALSE.
100 our_rev_mode%adjoint=.FALSE.
101 call ACTIVE_WRITE_3D_RL(
102 & fname, active_var_p, globalFile,
103 & useCurrentDir, iRec, myNr,
104 & REVERSE_SIMULATION, myOptimIter, myThid )
105 ! reset the mode
106 our_rev_mode=our_orig_mode
107 ! copy back
108 active_var%d = active_var_p
109 end if
110
111 #endif /* ALLOW_OPENAD_ACTIVE_WRITE */
112
113 end

  ViewVC Help
Powered by ViewVC 1.1.22