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

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

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


Revision 1.1 - (show annotations) (download)
Fri Jul 3 21:33:55 2015 UTC (4 years, 3 months ago) by heimbach
Branch: MAIN
CVS Tags: checkpoint66g, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, checkpoint66n, checkpoint66m, checkpoint66l, checkpoint66k, checkpoint66j, checkpoint66i, checkpoint66h, checkpoint65z, checkpoint65x, checkpoint65y, checkpoint65r, checkpoint65s, checkpoint65p, checkpoint65q, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint65n, checkpoint65o, HEAD
Merge and update from Krishna Narayanan's contrib area:
o genmake2 flag -diva (but only for OpenAD)
o required modifs for OAD_support

1 #include "PACKAGES_CONFIG.h"
2 #include "OPENAD_OPTIONS.h"
3
4 subroutine template()
5 #ifdef ALLOW_OPENAD_DIVA
6 use OAD_regular_cp
7 use OAD_tape
8 use OAD_rev
9
10 c we may need these for the checkpointing
11 use SIZE_mod
12 use EEPARAMS_mod
13 use PARAMS_mod
14 use BAR2_mod
15 use BARRIER_mod
16 #ifdef ALLOW_CD_CODE
17 use CD_CODE_VARS_mod
18 #endif
19 use CG2D_mod
20 use CG3D_mod
21 use DYNVARS_mod
22 use EESUPPORT_mod
23 use EOS_mod
24 use EXCH_mod
25 use FC_NAMEMANGLE_mod
26 use FFIELDS_mod
27 #ifdef ALLOW_GENERIC_ADVDIFF
28 use GAD_mod
29 #endif
30 use GLOBAL_MAX_mod
31 use GLOBAL_SUM_mod
32 #ifdef ALLOW_GMREDI
33 use GMREDI_mod
34 use GMREDI_TAVE_mod
35 #endif
36 use GRID_mod
37 #ifdef ALLOW_MOM_COMMON
38 use MOM_VISC_mod
39 #endif
40 use MPI_INFO_mod
41 #ifdef ALLOW_SHAP_FILT
42 use SHAP_FILT_mod
43 #endif
44 #ifdef ALLOW_STREAMICE
45 use STREAMICE_mod
46 use STREAMICE_ADV_mod
47 use STREAMICE_BDRY_mod
48 use STREAMICE_CG_mod
49 #endif
50 use SOLVE_FOR_PRESSURE3D_mod
51 use SOLVE_FOR_PRESSURE_mod
52 use SURFACE_mod
53 use tamc_mod
54 use tamc_keys_mod
55 use cost_mod
56 use g_cost_mod
57 use ctrl_mod
58 use ctrl_dummy_mod
59 use ctrl_weights_mod
60 use optim_mod
61 use grdchk_mod
62
63 !$TEMPLATE_PRAGMA_DECLARATIONS
64 integer, save :: currcp, curradjointcp
65 integer :: cp_loop_variable_1,cp_loop_variable_2,
66 + cp_loop_variable_3,cp_loop_variable_4,cp_loop_variable_5
67
68 double precision, dimension(:), allocatable, save :: theArgFStack
69 integer, save :: theArgFStackoffset=0, theArgFStackSize=0
70 integer, dimension(:), allocatable, save :: theArgIStack
71 integer, save :: theArgIStackoffset=0, theArgIStackSize=0
72 type(modeType) :: our_orig_mode
73 integer nt
74
75 integer iaddr
76 external iaddr
77 if (our_rev_mode%arg_store) then
78 call cp_write_open()
79 !$PLACEHOLDER_PRAGMA$ id=8
80 call cp_close()
81 end if
82 if (our_rev_mode%arg_restore) then
83 call cp_read_open()
84 !$PLACEHOLDER_PRAGMA$ id=9
85 call cp_close()
86 end if
87 if (our_rev_mode%plain) then
88 do nt=1,nTimeSteps_l2
89 CALL OpenAD_inner_do_loop(nt, MYTIME, MYITER, MYTHID)
90 enddo
91 end if
92 if (our_rev_mode%tape) then
93 print *, 'DIVA Running Regular Plain nTimeSteps_l2 ', nTimeSteps
94 +_l2
95 currcp = 0
96 do nt=1,nTimeSteps_l2
97 print *, 'DIVA Checkpointing currcp and running plain', currc
98 +p
99 call cp_write_open(currcp)
100 !$PLACEHOLDER_PRAGMA$ id=8
101 call cp_close
102 currcp=currcp+1
103 call OAD_revPlain
104 CALL OpenAD_inner_do_loop(nt, MYTIME, MYITER, MYTHID)
105 call OAD_revTape
106 end do
107 currcp = currcp -1
108 end if
109 if (our_rev_mode%adjoint) then
110 curradjointcp = currcp
111 print *, 'DIVA Reading plain checkpoint currcp ', currcp
112 call cp_read_open(currcp)
113 !$PLACEHOLDER_PRAGMA$ id=9
114 call cp_close
115 call OAD_revTape
116 print *, 'DIVA Running First Tape'
117 CALL OpenAD_inner_do_loop(nTimeSteps_l2, MYTIME, MYITER, MYTHID)
118 print *, 'DIVA Running First Adjoint '
119 call OAD_revAdjoint
120 CALL OpenAD_inner_do_loop(nTimeSteps_l2, MYTIME, MYITER, MYTHID)
121 print *, 'DIVA Writing adjoint checkpoint curradjointcp ', curra
122 +djointcp
123 call cp_write_open(curradjointcp)
124 !$PLACEHOLDER_PRAGMA$ id=12
125 call cp_close
126 do nt=nTimeSteps_l2-1,1,-1
127 currcp = currcp -1
128 print *, 'DIVA Running TA pairs'
129 print *, 'DIVA Reading plain checkpoint currcp ', currcp
130 call cp_read_open(currcp)
131 !$PLACEHOLDER_PRAGMA$ id=9
132 call cp_close
133 call OAD_revTape
134 print *, 'DIVA Running Tape'
135 CALL OpenAD_inner_do_loop(nt, MYTIME, MYITER, MYTHID)
136 print *, 'DIVA Reading adjoint checkpoint curradjointcp ', cur
137 +radjointcp
138 call cp_read_open(curradjointcp)
139 !$PLACEHOLDER_PRAGMA$ id=13
140 call cp_close
141 print *, 'DIVA Running adjoint '
142 call OAD_revAdjoint
143 CALL OpenAD_inner_do_loop(nt, MYTIME, MYITER, MYTHID)
144 print *, 'DIVA Writing adjoint checkpoint curradjointcp ', cur
145 +radjointcp-1
146 call cp_write_open(curradjointcp-1)
147 !$PLACEHOLDER_PRAGMA$ id=12
148 curradjointcp = curradjointcp-1
149 call cp_close
150 end do
151 end if
152 #endif
153 end subroutine template

  ViewVC Help
Powered by ViewVC 1.1.22