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

Annotation 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.2 - (hide annotations) (download)
Sat Feb 14 23:56:59 2015 UTC (9 years, 2 months ago) by heimbach
Branch: MAIN
CVS Tags: checkpoint65j, checkpoint65k
Changes since 1.1: +2 -1 lines
Initialize globalFile (Dan Goldberg)

1 heimbach 1.2 ! $Header: /u/gcmpack/MITgcm/tools/OAD_support/ad_template.active_write_xy.F,v 1.1 2015/02/11 00:09:55 heimbach Exp $
2 heimbach 1.1 ! $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 heimbach 1.2 globalFile = .FALSE.
40 heimbach 1.1 useCurrentDir = .FALSE.
41    
42     if (our_rev_mode%plain) then
43     our_orig_mode = our_rev_mode
44     ! original function
45     active_var_p = active_var%v
46     ! set up for plain execution
47     our_rev_mode%arg_store=.FALSE.
48     our_rev_mode%arg_restore=.FALSE.
49     our_rev_mode%plain=.TRUE.
50     our_rev_mode%tape=.FALSE.
51     our_rev_mode%adjoint=.FALSE.
52     call ACTIVE_WRITE_3D_RL(
53     & active_var_file, active_var_p, globalFile,
54     & useCurrentDir, iRec, myNr,
55     & FORWARD_SIMULATION, myOptimIter, myThid )
56     ! reset the mode
57     our_rev_mode=our_orig_mode
58     ! copy back
59     active_var%v = active_var_p
60     end if
61    
62     if (our_rev_mode%tape) then
63     ! taping
64     our_orig_mode=our_rev_mode
65     our_rev_mode%arg_store=.FALSE.
66     our_rev_mode%arg_restore=.FALSE.
67     our_rev_mode%plain=.TRUE.
68     our_rev_mode%tape=.FALSE.
69     our_rev_mode%adjoint=.FALSE.
70     if (oad_st_sz.lt.oad_st_ptr) call oad_st_grow()
71     oad_st(oad_st_ptr) = active_var_file
72     oad_st_ptr = oad_st_ptr+1
73     if (oad_it_sz.lt.oad_it_ptr) call oad_it_grow()
74     oad_it(oad_it_ptr) = iRec
75     oad_it_ptr = oad_it_ptr+1
76     call ACTIVE_WRITE_3D_RL(
77     & active_var_file, active_var, globalFile,
78     & useCurrentDir, iRec, myNr,
79     & FORWARD_SIMULATION, myOptimIter, myThid )
80     our_rev_mode=our_orig_mode
81     end if
82    
83     if (our_rev_mode%adjoint) then
84     ! adjoint
85     oad_st_ptr = oad_st_ptr-1
86     active_var_file = oad_st(oad_st_ptr)
87     oad_it_ptr = oad_it_ptr-1
88     iRec = oad_it(oad_it_ptr)
89     adpref = 'ad'
90     il = ILNBLNK( active_var_file )
91     WRITE(fname(1:80),'(A)') ' '
92     WRITE(fname(1:2+il),'(2A)') adpref, active_var_file(1:il)
93     ! WRITE(fname(1:2+il),'(2A)') adpref, active_var_file
94     active_var_p = active_var%d
95     ! set up for plain execution
96     our_orig_mode=our_rev_mode
97     our_rev_mode%arg_store=.FALSE.
98     our_rev_mode%arg_restore=.FALSE.
99     our_rev_mode%plain=.TRUE.
100     our_rev_mode%tape=.FALSE.
101     our_rev_mode%adjoint=.FALSE.
102     call ACTIVE_WRITE_3D_RL(
103     & fname, active_var_p, globalFile,
104     & useCurrentDir, iRec, myNr,
105     & REVERSE_SIMULATION, myOptimIter, myThid )
106     ! reset the mode
107     our_rev_mode=our_orig_mode
108     ! copy back
109     active_var%d = active_var_p
110     end if
111    
112     #endif /* ALLOW_OPENAD_ACTIVE_WRITE */
113    
114     end

  ViewVC Help
Powered by ViewVC 1.1.22