1 |
C $Header: /u/gcmpack/MITgcm_contrib/snarayan/divided_adjoint/model/src/inner_do_loop.F,v 1.3 2015/07/03 04:10:13 snarayan Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "PACKAGES_CONFIG.h" |
5 |
#include "CPP_OPTIONS.h" |
6 |
#include "OPENAD_OPTIONS.h" |
7 |
c#ifdef ALLOW_AUTODIFF |
8 |
c# include "AUTODIFF_OPTIONS.h" |
9 |
c#endif |
10 |
#ifdef ALLOW_OBCS |
11 |
# include "OBCS_OPTIONS.h" |
12 |
#endif |
13 |
#ifdef ALLOW_SEAICE |
14 |
# include "SEAICE_OPTIONS.h" |
15 |
#endif |
16 |
#ifdef ALLOW_GENERIC_ADVDIFF |
17 |
# include "GAD_OPTIONS.h" |
18 |
#endif |
19 |
#ifdef ALLOW_GMREDI |
20 |
# include "GMREDI_OPTIONS.h" |
21 |
#endif |
22 |
#ifdef ALLOW_STREAMICE |
23 |
# include "STREAMICE_OPTIONS.h" |
24 |
#endif |
25 |
#ifdef ALLOW_GGL90 |
26 |
# include "GGL90_OPTIONS.h" |
27 |
#endif |
28 |
#ifdef ALLOW_EXF |
29 |
# include "EXF_OPTIONS.h" |
30 |
#endif |
31 |
#ifdef ALLOW_COST |
32 |
# include "COST_OPTIONS.h" |
33 |
#endif |
34 |
#ifdef ALLOW_CTRL |
35 |
# include "CTRL_OPTIONS.h" |
36 |
#endif |
37 |
c#ifdef ALLOW_ECCO |
38 |
c# include "ECCO_OPTIONS.h" |
39 |
c#endif |
40 |
|
41 |
CBOP |
42 |
C !ROUTINE: INNER_DO_LOOP |
43 |
C !INTERFACE: |
44 |
SUBROUTINE INNER_DO_LOOP( iloop, myTime, myIter, myThid ) |
45 |
|
46 |
C !DESCRIPTION: \bv |
47 |
C *================================================================* |
48 |
C | SUBROUTINE the_loop_body |
49 |
C | o Run the ocean model and evaluate the specified cost function. |
50 |
C *================================================================* |
51 |
C | |
52 |
C | INNER_DO_LOOP is the toplevel routine for the Tangent Linear and |
53 |
C | Adjoint Model Compiler (TAMC). |
54 |
C | For this purpose the initialization |
55 |
C | of the model was split into two parts. Those parameters that do |
56 |
C | not depend on a specific model run are set in INITIALISE_FIXED, |
57 |
C | whereas those that do depend on the specific realization are |
58 |
C | initialized in INITIALISE_VARIA. |
59 |
C | This routine is to be used in conjuction with the MITgcmuv |
60 |
C | checkpoint 37. |
61 |
C *================================================================* |
62 |
C \ev |
63 |
|
64 |
C !USES: |
65 |
IMPLICIT NONE |
66 |
C == Global variables == |
67 |
#include "SIZE.h" |
68 |
#include "EEPARAMS.h" |
69 |
#include "PARAMS.h" |
70 |
|
71 |
c************************************** |
72 |
#ifdef ALLOW_OPENAD |
73 |
|
74 |
C-- The folowing header files are included in the_main_loop.F for TAF |
75 |
C and might be needed here (where the iloop is done) for OpenAD |
76 |
c# include "AUTODIFF_MYFIELDS.h" |
77 |
c# include "GRID.h" |
78 |
c# include "DYNVARS.h" |
79 |
c# include "SURFACE.h" |
80 |
c# include "FFIELDS.h" |
81 |
c# include "EOS.h" |
82 |
c# include "AUTODIFF.h" |
83 |
c# ifdef ALLOW_GENERIC_ADVDIFF |
84 |
c# include "GAD.h" |
85 |
c# include "GAD_SOM_VARS.h" |
86 |
c# endif |
87 |
c# ifdef ALLOW_MOM_FLUXFORM |
88 |
c# include "MOM_FLUXFORM.h" |
89 |
c# endif |
90 |
c# ifdef ALLOW_CD_CODE |
91 |
c# include "CD_CODE_VARS.h" |
92 |
c# endif |
93 |
c# ifdef ALLOW_EXF |
94 |
c# include "EXF_FIELDS.h" |
95 |
c# ifdef ALLOW_BULKFORMULAE |
96 |
c# include "EXF_CONSTANTS.h" |
97 |
c# endif |
98 |
c# endif /* ALLOW_EXF */ |
99 |
c# ifdef ALLOW_SEAICE |
100 |
c# include "SEAICE_SIZE.h" |
101 |
c# include "SEAICE.h" |
102 |
c# include "SEAICE_PARAMS.h" |
103 |
c# include "SEAICE_COST.h" |
104 |
c# include "SEAICE_TRACER.h" |
105 |
c# endif |
106 |
c# ifdef ALLOW_SALT_PLUME |
107 |
c# include "SALT_PLUME.h" |
108 |
c# endif |
109 |
c# ifdef ALLOW_THSICE |
110 |
c# include "THSICE_SIZE.h" |
111 |
c# include "THSICE_VARS.h" |
112 |
c# include "THSICE_COST.h" |
113 |
c# endif |
114 |
c# ifdef ALLOW_EBM |
115 |
c# include "EBM.h" |
116 |
c# endif |
117 |
c# ifdef ALLOW_RBCS |
118 |
c# include "RBCS_SIZE.h" |
119 |
c# include "RBCS_FIELDS.h" |
120 |
c# endif |
121 |
c# ifdef ALLOW_OFFLINE |
122 |
c# include "OFFLINE.h" |
123 |
c# endif |
124 |
c# ifdef ALLOW_CG2D_NSA |
125 |
c# include "CG2D.h" |
126 |
c# endif |
127 |
c# ifdef ALLOW_GGL90 |
128 |
c# include "GGL90.h" |
129 |
c# endif |
130 |
c# ifdef ALLOW_PROFILES |
131 |
c# include "profiles.h" |
132 |
c# endif |
133 |
c# ifdef ALLOW_ECCO_EVOLUTION |
134 |
c# ifdef ALLOW_ECCO |
135 |
c# include "ecco_cost.h" |
136 |
c# endif |
137 |
c# endif |
138 |
|
139 |
# ifdef ALLOW_CTRL |
140 |
# include "CTRL_SIZE.h" |
141 |
# include "ctrl.h" |
142 |
# include "ctrl_dummy.h" |
143 |
# include "CTRL_GENARR.h" |
144 |
# include "CTRL_OBCS.h" |
145 |
# endif |
146 |
# ifdef ALLOW_COST |
147 |
# include "cost.h" |
148 |
# endif |
149 |
|
150 |
# ifdef ALLOW_PTRACERS |
151 |
# include "PTRACERS_SIZE.h" |
152 |
# include "PTRACERS_FIELDS.h" |
153 |
# include "PTRACERS_START.h" |
154 |
# endif |
155 |
# ifdef ALLOW_GCHEM |
156 |
# include "GCHEM_FIELDS.h" |
157 |
# endif |
158 |
# ifdef ALLOW_CFC |
159 |
# include "CFC.h" |
160 |
# endif |
161 |
# ifdef ALLOW_DIC |
162 |
# include "DIC_VARS.h" |
163 |
# include "DIC_LOAD.h" |
164 |
# include "DIC_ATMOS.h" |
165 |
# include "DIC_CTRL.h" |
166 |
# include "DIC_COST.h" |
167 |
# endif |
168 |
# ifdef ALLOW_OBCS |
169 |
# include "OBCS_PARAMS.h" |
170 |
# include "OBCS_FIELDS.h" |
171 |
# include "OBCS_SEAICE.h" |
172 |
# ifdef ALLOW_PTRACERS |
173 |
# include "OBCS_PTRACERS.h" |
174 |
# endif |
175 |
# endif |
176 |
# ifdef ALLOW_SHELFICE |
177 |
# include "SHELFICE.h" |
178 |
# include "SHELFICE_COST.h" |
179 |
# endif |
180 |
# ifdef ALLOW_STREAMICE |
181 |
# include "STREAMICE.h" |
182 |
# include "STREAMICE_ADV.h" |
183 |
# include "STREAMICE_BDRY.h" |
184 |
# include "STREAMICE_CG.h" |
185 |
# endif |
186 |
|
187 |
#endif /* ALLOW_OPENAD */ |
188 |
c************************************** |
189 |
|
190 |
C !INPUT/OUTPUT PARAMETERS: |
191 |
C == Routine arguments == |
192 |
C note: under the multi-threaded model myIter and |
193 |
C myTime are local variables passed around as routine |
194 |
C arguments. Although this is fiddly it saves the need to |
195 |
C impose additional synchronisation points when they are |
196 |
C updated. |
197 |
C myTime :: time counter for this thread |
198 |
C myIter :: iteration counter for this thread |
199 |
C myThid :: thread number for this instance of the routine. |
200 |
INTEGER iloop |
201 |
_RL myTime |
202 |
INTEGER myIter |
203 |
INTEGER myThid |
204 |
#if (defined ALLOW_OPENAD) && (defined ALLOW_OPENAD_DIVA) |
205 |
C !FUNCTIONS: |
206 |
C == Functions == |
207 |
|
208 |
C !LOCAL VARIABLES: |
209 |
C == Local variables == |
210 |
INTEGER iloop1 |
211 |
INTEGER prod |
212 |
CEOP |
213 |
|
214 |
#ifdef ALLOW_DEBUG |
215 |
IF (debugMode) CALL DEBUG_ENTER('INNER_DO_LOOP',myThid) |
216 |
#endif |
217 |
|
218 |
#ifdef ALLOW_OPENAD |
219 |
C >>>>>>>>>>>>>>>>>>>>>>>>>>> LOOP <<<<<<<<<<<<<<<<<<<<<<<<<<<< |
220 |
C >>>>>>>>>>>>>>>>>>>>>>>>>>> STARTS <<<<<<<<<<<<<<<<<<<<<<<<<<<< |
221 |
DO iloop1 = 1, nTimeSteps |
222 |
prod = (iloop-1)*nTimeSteps_l2+iloop1 |
223 |
#endif |
224 |
|
225 |
#ifdef ALLOW_DEBUG |
226 |
IF (debugMode) CALL DEBUG_CALL('FORWARD_STEP',myThid) |
227 |
#endif |
228 |
|
229 |
#ifdef ALLOW_ATM2D |
230 |
CALL TIMER_START('FORWARD_STEP_ATM2D [INNER_DO_LOOP]',myThid) |
231 |
#ifdef ALLOW_OPENAD |
232 |
CALL FORWARD_STEP_ATM2D( prod, myTime, myIter, myThid ) |
233 |
#else |
234 |
CALL FORWARD_STEP_ATM2D( iloop, myTime, myIter, myThid ) |
235 |
#endif |
236 |
CALL TIMER_STOP ('FORWARD_STEP_ATM2D [INNER_DO_LOOP]',myThid) |
237 |
#else |
238 |
CALL TIMER_START('FORWARD_STEP [INNER_DO_LOOP]',myThid) |
239 |
#ifdef ALLOW_OPENAD |
240 |
CALL FORWARD_STEP( prod, myTime, myIter, myThid ) |
241 |
#else |
242 |
CALL FORWARD_STEP( iloop, myTime, myIter, myThid ) |
243 |
#endif |
244 |
CALL TIMER_STOP ('FORWARD_STEP [INNER_DO_LOOP]',myThid) |
245 |
#endif |
246 |
|
247 |
#ifdef ALLOW_OPENAD |
248 |
ENDDO |
249 |
C >>>>>>>>>>>>>>>>>>>>>>>>>>> LOOP <<<<<<<<<<<<<<<<<<<<<<<<<<<< |
250 |
C >>>>>>>>>>>>>>>>>>>>>>>>>>> STOPS <<<<<<<<<<<<<<<<<<<<<<<<<<<< |
251 |
#endif |
252 |
|
253 |
#ifdef ALLOW_DEBUG |
254 |
IF (debugMode) CALL DEBUG_LEAVE('INNER_DO_LOOP',myThid) |
255 |
#endif |
256 |
|
257 |
RETURN |
258 |
#endif |
259 |
END |