1 |
C $Header$ |
C $Header$ |
2 |
C $Name$ |
C $Name$ |
3 |
|
|
4 |
|
#include "PACKAGES_CONFIG.h" |
5 |
#include "CPP_OPTIONS.h" |
#include "CPP_OPTIONS.h" |
6 |
|
|
7 |
|
#ifdef ALLOW_GCHEM |
8 |
|
# include "GCHEM_OPTIONS.h" |
9 |
|
#endif |
10 |
|
#ifdef ALLOW_OFFLINE |
11 |
|
# include "OFFLINE_OPTIONS.h" |
12 |
|
#endif |
13 |
|
#ifdef ALLOW_GMREDI |
14 |
|
# include "GMREDI_OPTIONS.h" |
15 |
|
#endif |
16 |
|
|
17 |
|
CBOP |
18 |
|
C !ROUTINE: FORWARD_STEP |
19 |
|
C !INTERFACE: |
20 |
SUBROUTINE FORWARD_STEP( iloop, myTime, myIter, myThid ) |
SUBROUTINE FORWARD_STEP( iloop, myTime, myIter, myThid ) |
|
IMPLICIT NONE |
|
21 |
|
|
22 |
c ================================================================== |
C !DESCRIPTION: \bv |
23 |
c SUBROUTINE forward_step |
C *================================================================== |
24 |
c ================================================================== |
C | SUBROUTINE forward_step |
25 |
c |
C | o Run the ocean model and, optionally, evaluate a cost function. |
26 |
c o Run the ocean model and evaluate the specified cost function. |
C *================================================================== |
27 |
c |
C | |
28 |
c *the_main_loop* is the toplevel routine for the Tangent Linear and |
C | THE_MAIN_LOOP is the toplevel routine for the Tangent Linear and |
29 |
c Adjoint Model Compiler (TAMC). For this purpose the initialization |
C | Adjoint Model Compiler (TAMC). For this purpose the initialization |
30 |
c of the model was split into two parts. Those parameters that do |
C | of the model was split into two parts. Those parameters that do |
31 |
c not depend on a specific model run are set in *initialise_fixed*, |
C | not depend on a specific model run are set in INITIALISE_FIXED, |
32 |
c whereas those that do depend on the specific realization are |
C | whereas those that do depend on the specific realization are |
33 |
c initialized in *initialise_varia*. |
C | initialized in INITIALISE_VARIA. |
34 |
|
C | |
35 |
|
C *================================================================== |
36 |
|
C \ev |
37 |
|
|
38 |
C == global variables == |
C !USES: |
39 |
|
IMPLICIT NONE |
40 |
|
C == Global variables == |
41 |
#include "SIZE.h" |
#include "SIZE.h" |
42 |
#include "EEPARAMS.h" |
#include "EEPARAMS.h" |
43 |
#include "PARAMS.h" |
#include "PARAMS.h" |
44 |
#include "DYNVARS.h" |
#include "DYNVARS.h" |
|
#include "FFIELDS.h" |
|
45 |
|
|
46 |
#ifdef ALLOW_NONHYDROSTATIC |
#ifdef ALLOW_SHAP_FILT |
47 |
#include "CG3D.h" |
# include "SHAP_FILT.h" |
48 |
|
#endif |
49 |
|
#ifdef ALLOW_ZONAL_FILT |
50 |
|
# include "ZONAL_FILT.h" |
51 |
|
#endif |
52 |
|
#ifdef COMPONENT_MODULE |
53 |
|
# include "CPL_PARAMS.h" |
54 |
#endif |
#endif |
55 |
|
|
56 |
#ifdef ALLOW_AUTODIFF_TAMC |
#ifdef ALLOW_AUTODIFF_TAMC |
57 |
#include "tamc.h" |
# include "FFIELDS.h" |
|
#include "ctrl.h" |
|
|
#include "ctrl_dummy.h" |
|
|
#include "cost.h" |
|
|
#endif |
|
58 |
|
|
59 |
C == routine arguments == |
# ifdef ALLOW_NONHYDROSTATIC |
60 |
|
# include "CG3D.h" |
61 |
|
# endif |
62 |
|
|
63 |
|
# include "tamc.h" |
64 |
|
# include "ctrl.h" |
65 |
|
# include "ctrl_dummy.h" |
66 |
|
# include "cost.h" |
67 |
|
# include "EOS.h" |
68 |
|
# ifdef ALLOW_EXF |
69 |
|
# include "exf_fields.h" |
70 |
|
# include "exf_clim_fields.h" |
71 |
|
# ifdef ALLOW_BULKFORMULAE |
72 |
|
# include "exf_constants.h" |
73 |
|
# endif |
74 |
|
# endif |
75 |
|
# ifdef ALLOW_OBCS |
76 |
|
# include "OBCS.h" |
77 |
|
# endif |
78 |
|
# ifdef ALLOW_PTRACERS |
79 |
|
# include "PTRACERS_SIZE.h" |
80 |
|
# include "PTRACERS.h" |
81 |
|
# endif |
82 |
|
# ifdef ALLOW_CD_CODE |
83 |
|
# include "CD_CODE_VARS.h" |
84 |
|
# endif |
85 |
|
# ifdef ALLOW_EBM |
86 |
|
# include "EBM.h" |
87 |
|
# endif |
88 |
|
# ifdef EXACT_CONSERV |
89 |
|
# include "SURFACE.h" |
90 |
|
# endif |
91 |
|
# ifdef ALLOW_KPP |
92 |
|
# include "KPP.h" |
93 |
|
# endif |
94 |
|
# ifdef ALLOW_GMREDI |
95 |
|
# include "GMREDI.h" |
96 |
|
# endif |
97 |
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
98 |
|
|
99 |
|
C !LOCAL VARIABLES: |
100 |
|
C == Routine arguments == |
101 |
C note: under the multi-threaded model myiter and |
C note: under the multi-threaded model myiter and |
102 |
C mytime are local variables passed around as routine |
C mytime are local variables passed around as routine |
103 |
C arguments. Although this is fiddly it saves the need to |
C arguments. Although this is fiddly it saves the need to |
104 |
C impose additional synchronisation points when they are |
C impose additional synchronisation points when they are |
105 |
C updated. |
C updated. |
106 |
C myiter - iteration counter for this thread |
C myIter - iteration counter for this thread |
107 |
C mytime - time counter for this thread |
C myTime - time counter for this thread |
108 |
C mythid - thread number for this instance of the routine. |
C myThid - thread number for this instance of the routine. |
109 |
integer iloop |
INTEGER iloop |
110 |
integer mythid |
INTEGER myThid |
111 |
integer myiter |
INTEGER myIter |
112 |
_RL mytime |
_RL myTime |
113 |
INTEGER bi,bj |
|
114 |
|
C == Local variables == |
115 |
|
INTEGER myItP1 |
116 |
|
CEOP |
117 |
|
|
118 |
|
#ifdef ALLOW_DEBUG |
119 |
|
IF ( debugLevel .GE. debLevB ) |
120 |
|
& CALL DEBUG_ENTER('FORWARD_STEP',myThid) |
121 |
|
#endif |
122 |
|
|
123 |
C == local variables == |
#ifdef ALLOW_AUTODIFF_TAMC |
124 |
|
C-- Reset the model iteration counter and the model time. |
125 |
|
myiter = nIter0 + (iloop-1) |
126 |
|
mytime = startTime + float(iloop-1)*deltaTclock |
127 |
|
#endif |
128 |
|
|
129 |
|
#if (defined (ALLOW_AUTODIFF_TAMC) && defined (ALLOW_AUTODIFF_MONITOR)) |
130 |
|
C Include call to a dummy routine. Its adjoint will be |
131 |
|
C called at the proper place in the adjoint code. |
132 |
|
C The adjoint routine will print out adjoint values |
133 |
|
C if requested. The location of the call is important, |
134 |
|
C it has to be after the adjoint of the exchanges |
135 |
|
C (DO_GTERM_BLOCKING_EXCHANGES). |
136 |
|
CALL DUMMY_IN_STEPPING( myTime, myIter, myThid ) |
137 |
|
cph I've commented this line since it may conflict with MITgcm's adjoint |
138 |
|
cph However, need to check whether that's still consistent |
139 |
|
cph with the ecco-branch (it should). |
140 |
|
cph CALL DO_FIELDS_BLOCKING_EXCHANGES( myThid ) |
141 |
|
#endif |
142 |
|
|
143 |
#ifdef ALLOW_AUTODIFF_TAMC |
#ifdef ALLOW_AUTODIFF_TAMC |
144 |
C-- Reset the model iteration counter and the model time. |
c************************************** |
145 |
myiter = nIter0 + (iloop-1) |
#include "checkpoint_lev1_directives.h" |
146 |
mytime = startTime + float(iloop-1)*deltaTclock |
c************************************** |
147 |
#endif |
#endif |
148 |
|
|
149 |
#ifdef ALLOW_AUTODIFF_TAMC |
C-- Call external forcing package |
150 |
C Include call to a dummy routine. Its adjoint will be |
#ifdef ALLOW_BULK_FORCE |
151 |
C called at the proper place in the adjoint code. |
IF ( useBulkForce ) THEN |
152 |
C The adjoint routine will print out adjoint values |
#ifdef ALLOW_DEBUG |
153 |
C if requested. The location of the call is important, |
IF ( debugLevel .GE. debLevB ) |
154 |
C it has to be after the adjoint of the exchanges |
& CALL DEBUG_CALL('BULKF_FIELDS_LOAD',myThid) |
|
C (DO_GTERM_BLOCKING_EXCHANGES). |
|
|
CALL DUMMY_IN_STEPPING( myTime, myIter, myThid ) |
|
155 |
#endif |
#endif |
156 |
|
CALL TIMER_START('BULKF_FORCING [FORWARD_STEP]',mythid) |
157 |
|
C- load all forcing fields at current time |
158 |
|
CALL BULKF_FIELDS_LOAD( myTime, myIter, myThid ) |
159 |
|
C- calculate qnet and empmr (and wind stress) |
160 |
|
CALL BULKF_FORCING( myTime, myIter, myThid ) |
161 |
|
CALL TIMER_STOP ('BULKF_FORCING [FORWARD_STEP]',mythid) |
162 |
|
ELSE |
163 |
|
#endif /* ALLOW_BULK_FORCE */ |
164 |
|
|
165 |
|
# ifdef ALLOW_EXF |
166 |
|
# ifdef ALLOW_DEBUG |
167 |
|
IF ( debugLevel .GE. debLevB ) |
168 |
|
& CALL DEBUG_CALL('EXF_GETFORCING',myThid) |
169 |
|
# endif |
170 |
|
CALL TIMER_START('EXF_GETFORCING [FORWARD_STEP]',mythid) |
171 |
|
CALL EXF_GETFORCING( mytime, myiter, mythid ) |
172 |
|
CALL TIMER_STOP ('EXF_GETFORCING [FORWARD_STEP]',mythid) |
173 |
|
# else /* ALLOW_EXF undef */ |
174 |
|
cph The following IF-statement creates an additional dependency |
175 |
|
cph for the forcing fields requiring additional storing. |
176 |
|
cph Therefore, the IF-statement will be put between CPP-OPTIONS, |
177 |
|
cph assuming that ALLOW_SEAICE has not yet been differentiated. |
178 |
|
# if (defined (ALLOW_SEAICE) || defined (ALLOW_EBM)) |
179 |
|
IF ( .NOT. useSEAICE .AND. .NOT. useEBM ) THEN |
180 |
|
# endif |
181 |
|
#ifdef ALLOW_DEBUG |
182 |
|
IF ( debugLevel .GE. debLevB ) |
183 |
|
& CALL DEBUG_CALL('EXTERNAL_FIELDS_LOAD',myThid) |
184 |
|
#endif |
185 |
|
CALL TIMER_START('EXTERNAL_FIELDS_LOAD[FORWARD_STEP]',mythid) |
186 |
|
CALL EXTERNAL_FIELDS_LOAD( mytime, myiter, mythid ) |
187 |
|
CALL TIMER_STOP ('EXTERNAL_FIELDS_LOAD[FORWARD_STEP]',mythid) |
188 |
|
# if (defined (ALLOW_SEAICE) || defined (ALLOW_EBM)) |
189 |
|
ENDIF |
190 |
|
# endif |
191 |
|
# endif /* ALLOW_EXF */ |
192 |
|
#ifdef ALLOW_BULK_FORCE |
193 |
|
C-- end of if/else block useBulfforce -- |
194 |
|
ENDIF |
195 |
|
#endif /* ALLOW_BULK_FORCE */ |
196 |
|
|
197 |
#ifdef EXACT_CONSERV |
#ifdef ALLOW_AUTODIFF |
198 |
IF (exactConserv) THEN |
c-- Add control vector for forcing and parameter fields |
199 |
C-- Update etaH(n+1) : |
if ( myiter .EQ. nIter0 ) |
200 |
DO bj=myByLo(myThid),myByHi(myThid) |
& CALL CTRL_MAP_FORCING (mythid) |
201 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
#endif |
202 |
CALL CALC_EXACT_ETA( .FALSE., bi,bj, uVel,vVel, |
|
203 |
I startTime, nIter0, myThid ) |
# ifdef ALLOW_SEAICE |
204 |
ENDDO |
C-- Call sea ice model to compute forcing/external data fields. In |
205 |
ENDDO |
C addition to computing prognostic sea-ice variables and diagnosing the |
206 |
IF (implicDiv2Dflow .NE. 1. _d 0 ) |
C forcing/external data fields that drive the ocean model, SEAICE_MODEL |
207 |
& _EXCH_XY_R8(etaH, myThid ) |
C also sets theta to the freezing point under sea-ice. The implied |
208 |
|
C surface heat flux is then stored in variable surfaceTendencyTice, |
209 |
|
C which is needed by KPP package (kpp_calc.F and kpp_transport_t.F) |
210 |
|
C to diagnose surface buoyancy fluxes and for the non-local transport |
211 |
|
C term. Because this call precedes model thermodynamics, temperature |
212 |
|
C under sea-ice may not be "exactly" at the freezing point by the time |
213 |
|
C theta is dumped or time-averaged. |
214 |
|
IF ( useSEAICE ) THEN |
215 |
|
#ifdef ALLOW_DEBUG |
216 |
|
IF ( debugLevel .GE. debLevB ) |
217 |
|
& CALL DEBUG_CALL('SEAICE_MODEL',myThid) |
218 |
|
#endif |
219 |
|
CALL TIMER_START('SEAICE_MODEL [FORWARD_STEP]',myThid) |
220 |
|
CALL SEAICE_MODEL( myTime, myIter, myThid ) |
221 |
|
CALL TIMER_STOP ('SEAICE_MODEL [FORWARD_STEP]',myThid) |
222 |
ENDIF |
ENDIF |
223 |
#endif /* EXACT_CONSERV */ |
# endif /* ALLOW_SEAICE */ |
224 |
|
|
225 |
#ifdef NONLIN_FRSURF |
#ifdef ALLOW_AUTODIFF_TAMC |
226 |
C-- compute the future surface level thickness |
# ifdef ALLOW_PTRACERS |
227 |
C according to etaH(n+1) |
cph this replaces _bibj storing of ptracer within thermodynamics |
228 |
IF ( nonlinFreeSurf.GT.0) THEN |
CADJ STORE ptracer = comlev1, key = ikey_dynamics |
229 |
CALL CALC_SURF_DR(etaH, myTime, myIter, myThid ) |
# endif |
230 |
ENDIF |
#endif |
|
#endif /* NONLIN_FRSURF */ |
|
231 |
|
|
232 |
C-- Load forcing/external data fields. |
#ifdef ALLOW_OFFLINE |
233 |
#ifdef INCLUDE_EXTERNAL_FORCING_PACKAGE |
call OFFLINE_FIELDS_LOAD( myTime, myIter, myThid ) |
234 |
C NOTE, that although the exf package is part of the |
#endif |
235 |
C distribution, it is not currently maintained, i.e. |
|
236 |
C exf is disabled by default in genmake. |
#ifdef ALLOW_PTRACERS |
237 |
CALL EXF_GETFORCING( mytime, myiter, mythid ) |
# ifdef ALLOW_GCHEM |
238 |
#else |
CALL GCHEM_FIELDS_LOAD( mytime, myiter, mythid ) |
239 |
CALL TIMER_START('EXTERNAL_FIELDS_LOAD[THE_MAIN_LOOP]',mythid) |
# endif |
240 |
CALL EXTERNAL_FIELDS_LOAD( mytime, myiter, mythid ) |
#endif |
241 |
CALL TIMER_STOP ('EXTERNAL_FIELDS_LOAD[THE_MAIN_LOOP]',mythid) |
|
242 |
|
#ifdef COMPONENT_MODULE |
243 |
|
IF ( useCoupler .AND. cpl_earlyExpImpCall ) THEN |
244 |
|
C Post coupling data that I export. |
245 |
|
C Read in coupling data that I import. |
246 |
|
CALL TIMER_START('CPL_EXPORT-IMPORT [FORWARD_STEP]',myThid) |
247 |
|
CALL CPL_EXPORT_MY_DATA( myIter, myTime, myThid ) |
248 |
|
CALL CPL_IMPORT_EXTERNAL_DATA( myIter, myTime, myThid ) |
249 |
|
CALL TIMER_STOP ('CPL_EXPORT-IMPORT [FORWARD_STEP]',myThid) |
250 |
|
ENDIF |
251 |
|
#endif /* COMPONENT_MODULE */ |
252 |
|
|
253 |
|
#ifdef ALLOW_EBM |
254 |
|
IF ( useEBM ) THEN |
255 |
|
# ifdef ALLOW_DEBUG |
256 |
|
IF ( debugLevel .GE. debLevB ) |
257 |
|
& CALL DEBUG_CALL('EBM',myThid) |
258 |
|
# endif |
259 |
|
CALL TIMER_START('EBM [FORWARD_STEP]',mythid) |
260 |
|
CALL EBM_DRIVER ( myTime, myIter, myThid ) |
261 |
|
CALL TIMER_STOP ('EBM [FORWARD_STEP]',mythid) |
262 |
|
ENDIF |
263 |
#endif |
#endif |
264 |
|
|
265 |
C-- Step forward fields and calculate time tendency terms. |
C-- Step forward fields and calculate time tendency terms. |
266 |
CALL TIMER_START('THERMODYNAMICS [THE_MAIN_LOOP]',mythid) |
|
267 |
|
#ifdef ALLOW_DEBUG |
268 |
|
IF ( debugLevel .GE. debLevB ) |
269 |
|
& CALL DEBUG_CALL('DO_ATMOSPHERIC_PHYS',myThid) |
270 |
|
#endif |
271 |
|
CALL TIMER_START('DO_ATMOSPHERIC_PHYS [FORWARD_STEP]',mythid) |
272 |
|
CALL DO_ATMOSPHERIC_PHYS( myTime, myIter, myThid ) |
273 |
|
CALL TIMER_STOP ('DO_ATMOSPHERIC_PHYS [FORWARD_STEP]',mythid) |
274 |
|
|
275 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
276 |
|
CADJ STORE theta = comlev1, key = ikey_dynamics |
277 |
|
CADJ STORE salt = comlev1, key = ikey_dynamics |
278 |
|
CADJ STORE totphihyd = comlev1, key = ikey_dynamics |
279 |
|
CADJ STORE surfaceforcingtice = comlev1, key = ikey_dynamics |
280 |
|
# ifdef ALLOW_KPP |
281 |
|
CADJ STORE uvel = comlev1, key = ikey_dynamics |
282 |
|
CADJ STORE vvel = comlev1, key = ikey_dynamics |
283 |
|
# endif |
284 |
|
# ifdef EXACT_CONSERV |
285 |
|
CADJ STORE empmr = comlev1, key = ikey_dynamics |
286 |
|
CADJ STORE pmepr = comlev1, key = ikey_dynamics |
287 |
|
# endif |
288 |
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
289 |
|
|
290 |
|
#ifndef ALLOW_OFFLINE |
291 |
|
#ifdef ALLOW_DEBUG |
292 |
|
IF ( debugLevel .GE. debLevB ) |
293 |
|
& CALL DEBUG_CALL('DO_OCEANIC_PHYS',myThid) |
294 |
|
#endif |
295 |
|
CALL TIMER_START('DO_OCEANIC_PHYS [FORWARD_STEP]',mythid) |
296 |
|
CALL DO_OCEANIC_PHYS( myTime, myIter, myThid ) |
297 |
|
CALL TIMER_STOP ('DO_OCEANIC_PHYS [FORWARD_STEP]',mythid) |
298 |
|
#endif |
299 |
|
|
300 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
301 |
|
cph needed to be moved here from do_oceanic_physics |
302 |
|
cph to be visible down the road |
303 |
|
c |
304 |
|
CADJ STORE surfaceForcingS = comlev1, key = ikey_dynamics |
305 |
|
CADJ STORE surfaceForcingT = comlev1, key = ikey_dynamics |
306 |
|
CADJ STORE surfaceForcingTice = comlev1, key = ikey_dynamics |
307 |
|
ctest( |
308 |
|
CADJ STORE IVDConvCount = comlev1, key = ikey_dynamics |
309 |
|
ctest) |
310 |
|
# ifdef ALLOW_PTRACERS |
311 |
|
CADJ STORE surfaceForcingPtr = comlev1, key = ikey_dynamics |
312 |
|
# endif |
313 |
|
c |
314 |
|
# ifdef ALLOW_GMREDI |
315 |
|
CADJ STORE Kwx = comlev1, key = ikey_dynamics |
316 |
|
CADJ STORE Kwy = comlev1, key = ikey_dynamics |
317 |
|
CADJ STORE Kwz = comlev1, key = ikey_dynamics |
318 |
|
# ifdef GM_BOLUS_ADVEC |
319 |
|
CADJ STORE GM_PsiX = comlev1, key = ikey_dynamics |
320 |
|
CADJ STORE GM_PsiY = comlev1, key = ikey_dynamics |
321 |
|
# endif |
322 |
|
# endif |
323 |
|
c |
324 |
|
# ifdef ALLOW_KPP |
325 |
|
CADJ STORE KPPghat = comlev1, key = ikey_dynamics |
326 |
|
CADJ STORE KPPfrac = comlev1, key = ikey_dynamics |
327 |
|
CADJ STORE KPPdiffKzS = comlev1, key = ikey_dynamics |
328 |
|
CADJ STORE KPPdiffKzT = comlev1, key = ikey_dynamics |
329 |
|
# endif |
330 |
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
331 |
|
|
332 |
|
IF ( .NOT.staggerTimeStep ) THEN |
333 |
|
#ifdef ALLOW_DEBUG |
334 |
|
IF ( debugLevel .GE. debLevB ) |
335 |
|
& CALL DEBUG_CALL('THERMODYNAMICS',myThid) |
336 |
|
#endif |
337 |
|
CALL TIMER_START('THERMODYNAMICS [FORWARD_STEP]',mythid) |
338 |
CALL THERMODYNAMICS( myTime, myIter, myThid ) |
CALL THERMODYNAMICS( myTime, myIter, myThid ) |
339 |
CALL TIMER_STOP ('THERMODYNAMICS [THE_MAIN_LOOP]',mythid) |
CALL TIMER_STOP ('THERMODYNAMICS [FORWARD_STEP]',mythid) |
340 |
|
C-- if not staggerTimeStep: end |
341 |
|
ENDIF |
342 |
|
|
343 |
C-- Step forward fields and calculate time tendency terms. |
#ifdef COMPONENT_MODULE |
344 |
IF ( momStepping ) THEN |
IF ( useCoupler .AND. .NOT.cpl_earlyExpImpCall ) THEN |
345 |
CALL TIMER_START('DYNAMICS [THE_MAIN_LOOP]',mythid) |
C Post coupling data that I export. |
346 |
CALL DYNAMICS( myTime, myIter, myThid ) |
C Read in coupling data that I import. |
347 |
CALL TIMER_STOP ('DYNAMICS [THE_MAIN_LOOP]',mythid) |
myItP1 = myIter + 1 |
348 |
|
CALL TIMER_START('CPL_EXPORT-IMPORT [FORWARD_STEP]',myThid) |
349 |
|
CALL CPL_EXPORT_MY_DATA( myItP1, myTime, myThid ) |
350 |
|
CALL CPL_IMPORT_EXTERNAL_DATA( myItP1, myTime, myThid ) |
351 |
|
CALL TIMER_STOP ('CPL_EXPORT-IMPORT [FORWARD_STEP]',myThid) |
352 |
|
# ifndef ALLOW_AIM |
353 |
|
IF ( useRealFreshWaterFlux ) THEN |
354 |
|
CALL OCN_APPLY_IMPORT( .FALSE., myTime, myIter, myThid ) |
355 |
ENDIF |
ENDIF |
356 |
|
# endif |
357 |
|
ENDIF |
358 |
|
#endif /* COMPONENT_MODULE */ |
359 |
|
|
360 |
|
C-- Step forward fields and calculate time tendency terms. |
361 |
|
#ifndef ALLOW_OFFLINE |
362 |
#ifndef ALLOW_AUTODIFF_TAMC |
#ifndef ALLOW_AUTODIFF_TAMC |
363 |
|
IF ( momStepping ) THEN |
364 |
|
#endif |
365 |
|
#ifdef ALLOW_DEBUG |
366 |
|
IF ( debugLevel .GE. debLevB ) |
367 |
|
& CALL DEBUG_CALL('DYNAMICS',myThid) |
368 |
|
#endif |
369 |
|
CALL TIMER_START('DYNAMICS [FORWARD_STEP]',mythid) |
370 |
|
CALL DYNAMICS( myTime, myIter, myThid ) |
371 |
|
CALL TIMER_STOP ('DYNAMICS [FORWARD_STEP]',mythid) |
372 |
|
#ifndef ALLOW_AUTODIFF_TAMC |
373 |
|
ENDIF |
374 |
|
#endif |
375 |
|
#endif |
376 |
|
|
377 |
#ifdef ALLOW_NONHYDROSTATIC |
#ifdef ALLOW_NONHYDROSTATIC |
378 |
C-- Step forward W field in N-H algorithm |
C-- Step forward W field in N-H algorithm |
379 |
IF ( momStepping .AND. nonHydrostatic ) THEN |
IF ( momStepping .AND. nonHydrostatic ) THEN |
380 |
CALL TIMER_START('CALC_GW [THE_MAIN_LOOP]',myThid) |
#ifdef ALLOW_DEBUG |
381 |
CALL CALC_GW(myThid) |
IF ( debugLevel .GE. debLevB ) |
382 |
CALL TIMER_STOP ('CALC_GW [THE_MAIN_LOOP]',myThid) |
& CALL DEBUG_CALL('CALC_GW',myThid) |
|
ENDIF |
|
383 |
#endif |
#endif |
384 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
CALL TIMER_START('CALC_GW [FORWARD_STEP]',myThid) |
385 |
|
CALL CALC_GW(myThid) |
386 |
|
CALL TIMER_STOP ('CALC_GW [FORWARD_STEP]',myThid) |
387 |
|
ENDIF |
388 |
|
#endif |
389 |
|
|
390 |
|
C-- Update time-counter |
391 |
|
myIter = nIter0 + iLoop |
392 |
|
myTime = startTime + deltaTClock * float(iLoop) |
393 |
|
|
394 |
|
C-- Update geometric factors: |
395 |
#ifdef NONLIN_FRSURF |
#ifdef NONLIN_FRSURF |
396 |
C-- update hfacC,W,S and recip_hFac according to etaH(n+1) : |
C- update hfacC,W,S and recip_hFac according to etaH(n+1) : |
|
IF ( momStepping ) THEN |
|
397 |
IF ( nonlinFreeSurf.GT.0) THEN |
IF ( nonlinFreeSurf.GT.0) THEN |
398 |
|
IF ( select_rStar.GT.0 ) THEN |
399 |
|
CALL TIMER_START('UPDATE_R_STAR [FORWARD_STEP]',myThid) |
400 |
|
CALL UPDATE_R_STAR( myTime, myIter, myThid ) |
401 |
|
CALL TIMER_STOP ('UPDATE_R_STAR [FORWARD_STEP]',myThid) |
402 |
|
ELSE |
403 |
|
CALL TIMER_START('UPDATE_SURF_DR [FORWARD_STEP]',myThid) |
404 |
CALL UPDATE_SURF_DR( myTime, myIter, myThid ) |
CALL UPDATE_SURF_DR( myTime, myIter, myThid ) |
405 |
|
CALL TIMER_STOP ('UPDATE_SURF_DR [FORWARD_STEP]',myThid) |
406 |
|
ENDIF |
407 |
ENDIF |
ENDIF |
408 |
C- update also CG2D matrix (and preconditioner) |
C- update also CG2D matrix (and preconditioner) |
409 |
IF ( nonlinFreeSurf.GT.2) THEN |
IF ( momStepping .AND. nonlinFreeSurf.GT.2 ) THEN |
410 |
|
CALL TIMER_START('UPDATE_CG2D [FORWARD_STEP]',myThid) |
411 |
CALL UPDATE_CG2D( myTime, myIter, myThid ) |
CALL UPDATE_CG2D( myTime, myIter, myThid ) |
412 |
ENDIF |
CALL TIMER_STOP ('UPDATE_CG2D [FORWARD_STEP]',myThid) |
413 |
ENDIF |
ENDIF |
414 |
#endif |
#endif |
415 |
|
|
416 |
C-- This block has been moved to the_correction_step(). We have |
C-- Apply Filters to u*,v* before SOLVE_FOR_PRESSURE |
417 |
C left this code here to indicate where the filters used to be |
#ifdef ALLOW_SHAP_FILT |
418 |
C in the algorithm before JMC moved them to after the pressure |
IF (useSHAP_FILT .AND. shap_filt_uvStar) THEN |
419 |
C solver. |
CALL TIMER_START('SHAP_FILT [FORWARD_STEP]',myThid) |
420 |
C |
IF (implicDiv2Dflow.LT.1.) THEN |
421 |
C#ifdef ALLOW_SHAP_FILT |
C-- Explicit+Implicit part of the Barotropic Flow Divergence |
422 |
CC-- Step forward all tiles, filter and exchange. |
C => Filtering of uVel,vVel is necessary |
423 |
C CALL TIMER_START('SHAP_FILT [THE_MAIN_LOOP]',myThid) |
CALL SHAP_FILT_APPLY_UV( uVel,vVel, |
424 |
C CALL SHAP_FILT_APPLY( |
& myTime, myIter, myThid ) |
425 |
C I gUnm1, gVnm1, gTnm1, gSnm1, |
ENDIF |
426 |
C I myTime, myIter, myThid ) |
CALL SHAP_FILT_APPLY_UV( gU,gV,myTime,myIter,myThid) |
427 |
C IF (implicDiv2Dflow.LT.1.) THEN |
CALL TIMER_STOP ('SHAP_FILT [FORWARD_STEP]',myThid) |
428 |
CC-- Explicit+Implicit part of the Barotropic Flow Divergence |
ENDIF |
429 |
CC => Filtering of uVel,vVel is necessary |
#endif |
430 |
C CALL SHAP_FILT_UV( uVel, vVel, myTime, myThid ) |
#ifdef ALLOW_ZONAL_FILT |
431 |
C ENDIF |
IF (useZONAL_FILT .AND. zonal_filt_uvStar) THEN |
432 |
C CALL TIMER_STOP ('SHAP_FILT [THE_MAIN_LOOP]',myThid) |
CALL TIMER_START('ZONAL_FILT_APPLY [FORWARD_STEP]',myThid) |
433 |
C#endif |
IF (implicDiv2Dflow.LT.1.) THEN |
434 |
C |
C-- Explicit+Implicit part of the Barotropic Flow Divergence |
435 |
C#ifdef ALLOW_ZONAL_FILT |
C => Filtering of uVel,vVel is necessary |
436 |
C IF (zonal_filt_lat.LT.90.) THEN |
CALL ZONAL_FILT_APPLY_UV( uVel, vVel, myThid ) |
437 |
C CALL TIMER_START('ZONAL_FILT_APPLY [THE_MAIN_LOOP]',myThid) |
ENDIF |
438 |
C CALL ZONAL_FILT_APPLY( |
CALL ZONAL_FILT_APPLY_UV( gU, gV, myThid ) |
439 |
C U gUnm1, gVnm1, gTnm1, gSnm1, |
CALL TIMER_STOP ('ZONAL_FILT_APPLY [FORWARD_STEP]',myThid) |
440 |
C I myThid ) |
ENDIF |
441 |
C CALL TIMER_STOP ('ZONAL_FILT_APPLY [THE_MAIN_LOOP]',myThid) |
#endif |
|
C ENDIF |
|
|
C#endif |
|
442 |
|
|
443 |
C-- Solve elliptic equation(s). |
C-- Solve elliptic equation(s). |
444 |
C Two-dimensional only for conventional hydrostatic or |
C Two-dimensional only for conventional hydrostatic or |
445 |
C three-dimensional for non-hydrostatic and/or IGW scheme. |
C three-dimensional for non-hydrostatic and/or IGW scheme. |
446 |
|
#ifndef ALLOW_OFFLINE |
447 |
IF ( momStepping ) THEN |
IF ( momStepping ) THEN |
448 |
CALL TIMER_START('SOLVE_FOR_PRESSURE [THE_MAIN_LOOP]',myThid) |
CALL TIMER_START('SOLVE_FOR_PRESSURE [FORWARD_STEP]',myThid) |
449 |
CALL SOLVE_FOR_PRESSURE( myThid ) |
CALL SOLVE_FOR_PRESSURE(myTime, myIter, myThid) |
450 |
CALL TIMER_STOP ('SOLVE_FOR_PRESSURE [THE_MAIN_LOOP]',myThid) |
CALL TIMER_STOP ('SOLVE_FOR_PRESSURE [FORWARD_STEP]',myThid) |
451 |
ENDIF |
ENDIF |
452 |
|
#endif |
453 |
|
|
454 |
C-- Correct divergence in flow field and cycle time-stepping |
C-- Correct divergence in flow field and cycle time-stepping momentum |
455 |
C arrays (for all fields) ; update time-counter |
c IF ( momStepping ) THEN |
456 |
myIter = nIter0 + iLoop |
#ifndef ALLOW_OFFLINE |
457 |
myTime = startTime + deltaTClock * float(iLoop) |
CALL TIMER_START('UV_CORRECTION_STEP [FORWARD_STEP]',myThid) |
458 |
CALL TIMER_START('THE_CORRECTION_STEP [THE_MAIN_LOOP]',myThid) |
CALL MOMENTUM_CORRECTION_STEP(myTime, myIter, myThid) |
459 |
CALL THE_CORRECTION_STEP(myTime, myIter, myThid) |
CALL TIMER_STOP ('UV_CORRECTION_STEP [FORWARD_STEP]',myThid) |
460 |
CALL TIMER_STOP ('THE_CORRECTION_STEP [THE_MAIN_LOOP]',myThid) |
#endif |
461 |
|
c ENDIF |
462 |
|
|
463 |
|
#ifdef EXACT_CONSERV |
464 |
|
IF (exactConserv) THEN |
465 |
|
C-- Update etaH(n+1) : |
466 |
|
CALL TIMER_START('UPDATE_ETAH [FORWARD_STEP]',mythid) |
467 |
|
CALL UPDATE_ETAH( myTime, myIter, myThid ) |
468 |
|
CALL TIMER_STOP ('UPDATE_ETAH [FORWARD_STEP]',mythid) |
469 |
|
ENDIF |
470 |
|
#endif /* EXACT_CONSERV */ |
471 |
|
|
472 |
|
#ifdef NONLIN_FRSURF |
473 |
|
IF ( select_rStar.NE.0 ) THEN |
474 |
|
C-- r* : compute the future level thickness according to etaH(n+1) |
475 |
|
CALL TIMER_START('CALC_R_STAR [FORWARD_STEP]',mythid) |
476 |
|
CALL CALC_R_STAR(etaH, myTime, myIter, myThid ) |
477 |
|
CALL TIMER_STOP ('CALC_R_STAR [FORWARD_STEP]',mythid) |
478 |
|
ELSEIF ( nonlinFreeSurf.GT.0) THEN |
479 |
|
C-- compute the future surface level thickness according to etaH(n+1) |
480 |
|
CALL TIMER_START('CALC_SURF_DR [FORWARD_STEP]',mythid) |
481 |
|
CALL CALC_SURF_DR(etaH, myTime, myIter, myThid ) |
482 |
|
CALL TIMER_STOP ('CALC_SURF_DR [FORWARD_STEP]',mythid) |
483 |
|
ENDIF |
484 |
|
#endif /* NONLIN_FRSURF */ |
485 |
|
|
486 |
|
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
487 |
|
IF ( staggerTimeStep ) THEN |
488 |
|
C-- do exchanges of U,V (needed for multiDim) when using stagger time-step : |
489 |
|
#ifdef ALLOW_DEBUG |
490 |
|
IF ( debugLevel .GE. debLevB ) |
491 |
|
& CALL DEBUG_CALL('DO_STAGGER_FIELDS_EXCH.',myThid) |
492 |
|
#endif |
493 |
|
CALL TIMER_START('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
494 |
|
CALL DO_STAGGER_FIELDS_EXCHANGES( myTime, myIter, myThid ) |
495 |
|
CALL TIMER_STOP ('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
496 |
|
|
497 |
|
#ifdef ALLOW_DEBUG |
498 |
|
IF ( debugLevel .GE. debLevB ) |
499 |
|
& CALL DEBUG_CALL('THERMODYNAMICS',myThid) |
500 |
|
#endif |
501 |
|
CALL TIMER_START('THERMODYNAMICS [FORWARD_STEP]',mythid) |
502 |
|
CALL THERMODYNAMICS( myTime, myIter, myThid ) |
503 |
|
CALL TIMER_STOP ('THERMODYNAMICS [FORWARD_STEP]',mythid) |
504 |
|
|
505 |
|
C-- if staggerTimeStep: end |
506 |
|
ENDIF |
507 |
|
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
508 |
|
|
509 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
510 |
|
cph This is needed because convective_adjustment calls |
511 |
|
cph find_rho which may use pressure() |
512 |
|
CADJ STORE totphihyd = comlev1, key = ikey_dynamics |
513 |
|
#endif |
514 |
|
C-- Cycle time-stepping Tracers arrays (T,S,+pTracers) |
515 |
|
CALL TIMER_START('TS_CORRECTION_STEP [FORWARD_STEP]',myThid) |
516 |
|
CALL TRACERS_CORRECTION_STEP(myTime, myIter, myThid) |
517 |
|
CALL TIMER_STOP ('TS_CORRECTION_STEP [FORWARD_STEP]',myThid) |
518 |
|
|
519 |
C-- Do "blocking" sends and receives for tendency "overlap" terms |
C-- Do "blocking" sends and receives for tendency "overlap" terms |
520 |
c CALL TIMER_START('BLOCKING_EXCHANGES [THE_MAIN_LOOP]',myThid) |
c CALL TIMER_START('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
521 |
c CALL DO_GTERM_BLOCKING_EXCHANGES( myThid ) |
c CALL DO_GTERM_BLOCKING_EXCHANGES( myThid ) |
522 |
c CALL TIMER_STOP ('BLOCKING_EXCHANGES [THE_MAIN_LOOP]',myThid) |
c CALL TIMER_STOP ('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
523 |
|
|
524 |
C-- Do "blocking" sends and receives for field "overlap" terms |
C-- Do "blocking" sends and receives for field "overlap" terms |
525 |
CALL TIMER_START('BLOCKING_EXCHANGES [THE_MAIN_LOOP]',myThid) |
CALL TIMER_START('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
526 |
CALL DO_FIELDS_BLOCKING_EXCHANGES( myThid ) |
CALL DO_FIELDS_BLOCKING_EXCHANGES( myThid ) |
527 |
CALL TIMER_STOP ('BLOCKING_EXCHANGES [THE_MAIN_LOOP]',myThid) |
CALL TIMER_STOP ('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
528 |
|
|
529 |
|
cswdptr -- add for seperate timestepping of chemical/biological/forcing |
530 |
|
cswdptr of ptracers --- |
531 |
|
#ifdef ALLOW_GCHEM |
532 |
|
ceh3 This is broken -- this ifdef should not be visible! |
533 |
|
#ifdef PTRACERS_SEPARATE_FORCING |
534 |
|
ceh3 needs an IF ( use GCHEM ) THEN |
535 |
|
call GCHEM_FORCING_SEP( myTime,myIter,myThid ) |
536 |
|
#endif /* PTRACERS_SEPARATE_FORCING */ |
537 |
|
#endif /* ALLOW_GCHEM */ |
538 |
|
cswdptr -- end add --- |
539 |
|
|
540 |
|
C AMM |
541 |
|
#ifdef ALLOW_GRIDALT |
542 |
|
if (useGRIDALT) then |
543 |
|
CALL GRIDALT_UPDATE(myThid) |
544 |
|
endif |
545 |
|
#endif |
546 |
|
C AMM |
547 |
|
|
548 |
|
C AMM |
549 |
|
#ifdef ALLOW_FIZHI |
550 |
|
if( useFIZHI) then |
551 |
|
CALL TIMER_START('FIZHI [FORWARD_STEP]',mythid) |
552 |
|
CALL STEP_FIZHI_CORR ( myTime, myIter, myThid ) |
553 |
|
CALL TIMER_STOP('FIZHI [FORWARD_STEP]',mythid) |
554 |
|
endif |
555 |
|
#endif |
556 |
|
C AMM |
557 |
|
|
558 |
#ifdef ALLOW_FLT |
#ifdef ALLOW_FLT |
559 |
C-- Calculate float trajectories |
C-- Calculate float trajectories |
560 |
IF (useFLT) THEN |
IF (useFLT) THEN |
561 |
CALL TIMER_START('FLOATS [THE_MAIN_LOOP]',myThid) |
CALL TIMER_START('FLOATS [FORWARD_STEP]',myThid) |
562 |
CALL FLT_MAIN(myIter,myTime, myThid) |
CALL FLT_MAIN(myIter,myTime, myThid) |
563 |
CALL TIMER_STOP ('FLOATS [THE_MAIN_LOOP]',myThid) |
CALL TIMER_STOP ('FLOATS [FORWARD_STEP]',myThid) |
564 |
ENDIF |
ENDIF |
565 |
#endif |
#endif |
566 |
|
|
567 |
#ifndef EXCLUDE_MONITOR |
C-- State-variables statistics (time-aver, diagnostics ...) |
568 |
|
CALL TIMER_START('DO_STATEVARS_DIAGS [FORWARD_STEP]',myThid) |
569 |
|
CALL DO_STATEVARS_DIAGS( myTime, myIter, myThid ) |
570 |
|
CALL TIMER_STOP ('DO_STATEVARS_DIAGS [FORWARD_STEP]',myThid) |
571 |
|
|
572 |
|
#ifndef ALLOW_OFFLINE |
573 |
|
#ifdef ALLOW_MONITOR |
574 |
C-- Check status of solution (statistics, cfl, etc...) |
C-- Check status of solution (statistics, cfl, etc...) |
575 |
|
CALL TIMER_START('MONITOR [FORWARD_STEP]',myThid) |
576 |
CALL MONITOR( myIter, myTime, myThid ) |
CALL MONITOR( myIter, myTime, myThid ) |
577 |
#endif /* EXCLUDE_MONITOR */ |
CALL TIMER_STOP ('MONITOR [FORWARD_STEP]',myThid) |
578 |
|
#endif /* ALLOW_MONITOR */ |
579 |
|
#endif |
580 |
|
|
581 |
|
#ifdef ALLOW_COST |
582 |
|
C-- compare model with data and compute cost function |
583 |
|
C-- this is done after exchanges to allow interpolation |
584 |
|
CALL TIMER_START('COST_TILE [FORWARD_STEP]',myThid) |
585 |
|
CALL COST_TILE ( mytime, myiter, myThid ) |
586 |
|
CALL TIMER_STOP ('COST_TILE [FORWARD_STEP]',myThid) |
587 |
|
#endif |
588 |
|
|
|
#ifndef ALLOW_AUTODIFF_TAMC |
|
589 |
C-- Do IO if needed. |
C-- Do IO if needed. |
590 |
CALL TIMER_START('DO_THE_MODEL_IO [THE_MAIN_LOOP]',myThid) |
#ifdef ALLOW_OFFLINE |
591 |
|
CALL TIMER_START('OFFLINE_MODEL_IO [FORWARD_STEP]',myThid) |
592 |
|
CALL OFFLINE_MODEL_IO( myTime, myIter, myThid ) |
593 |
|
CALL TIMER_STOP ('OFFLINE_MODEL_IO [FORWARD_STEP]',myThid) |
594 |
|
#else |
595 |
|
CALL TIMER_START('DO_THE_MODEL_IO [FORWARD_STEP]',myThid) |
596 |
CALL DO_THE_MODEL_IO( myTime, myIter, myThid ) |
CALL DO_THE_MODEL_IO( myTime, myIter, myThid ) |
597 |
CALL TIMER_STOP ('DO_THE_MODEL_IO [THE_MAIN_LOOP]',myThid) |
CALL TIMER_STOP ('DO_THE_MODEL_IO [FORWARD_STEP]',myThid) |
598 |
|
#endif |
599 |
|
|
600 |
C-- Save state for restarts |
C-- Save state for restarts |
601 |
C Note: (jmc: is it still the case after ckp35 ?) |
CALL TIMER_START('WRITE_CHECKPOINT [FORWARD_STEP]',myThid) |
602 |
C ===== |
CALL PACKAGES_WRITE_PICKUP( |
603 |
C Because of the ordering of the timestepping code and |
I .FALSE., myTime, myIter, myThid ) |
604 |
C tendency term code at end of loop model arrays hold |
#ifndef ALLOW_OFFLINE |
|
C U,V,T,S at "time-level" N but gu, gv, gs, gt, guNM1,... |
|
|
C at "time-level" N+1/2 (guNM1 at "time-level" N+1/2 is |
|
|
C gu at "time-level" N-1/2) and etaN at "time-level" N+1/2. |
|
|
C where N = I+timeLevBase-1 |
|
|
C Thus a checkpoint contains U.0000000000, GU.0000000001 and |
|
|
C etaN.0000000001 in the indexing scheme used for the model |
|
|
C "state" files. This example is referred to as a checkpoint |
|
|
C at time level 1 |
|
|
CALL TIMER_START('WRITE_CHECKPOINT [THE_MAIN_LOOP]',myThid) |
|
605 |
CALL WRITE_CHECKPOINT( |
CALL WRITE_CHECKPOINT( |
606 |
& .FALSE., myTime, myIter, myThid ) |
I .FALSE., myTime, myIter, myThid ) |
607 |
CALL TIMER_STOP ('WRITE_CHECKPOINT [THE_MAIN_LOOP]',myThid) |
#endif |
608 |
|
CALL TIMER_STOP ('WRITE_CHECKPOINT [FORWARD_STEP]',myThid) |
609 |
|
|
610 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
#ifdef ALLOW_DEBUG |
611 |
|
IF ( debugLevel .GE. debLevB ) |
612 |
|
& CALL DEBUG_LEAVE('FORWARD_STEP',myThid) |
613 |
|
#endif |
614 |
|
|
615 |
|
RETURN |
616 |
END |
END |