1 |
jmc |
1.98 |
C $Header: /u/gcmpack/MITgcm/model/src/forward_step.F,v 1.97 2004/07/06 21:12:51 jmc Exp $ |
2 |
adcroft |
1.15 |
C $Name: $ |
3 |
adcroft |
1.1 |
|
4 |
edhill |
1.64 |
#include "PACKAGES_CONFIG.h" |
5 |
adcroft |
1.1 |
#include "CPP_OPTIONS.h" |
6 |
edhill |
1.64 |
|
7 |
stephd |
1.55 |
cswdptr -- add -- |
8 |
heimbach |
1.56 |
#ifdef ALLOW_GCHEM |
9 |
|
|
# include "GCHEM_OPTIONS.h" |
10 |
stephd |
1.55 |
#endif |
11 |
|
|
cswdptr -- end add --- |
12 |
adcroft |
1.1 |
|
13 |
cnh |
1.22 |
CBOP |
14 |
|
|
C !ROUTINE: FORWARD_STEP |
15 |
|
|
C !INTERFACE: |
16 |
adcroft |
1.13 |
SUBROUTINE FORWARD_STEP( iloop, myTime, myIter, myThid ) |
17 |
heimbach |
1.12 |
|
18 |
cnh |
1.22 |
C !DESCRIPTION: \bv |
19 |
|
|
C *================================================================== |
20 |
|
|
C | SUBROUTINE forward_step |
21 |
|
|
C | o Run the ocean model and, optionally, evaluate a cost function. |
22 |
|
|
C *================================================================== |
23 |
|
|
C | |
24 |
|
|
C | THE_MAIN_LOOP is the toplevel routine for the Tangent Linear and |
25 |
|
|
C | Adjoint Model Compiler (TAMC). For this purpose the initialization |
26 |
|
|
C | of the model was split into two parts. Those parameters that do |
27 |
|
|
C | not depend on a specific model run are set in INITIALISE_FIXED, |
28 |
|
|
C | whereas those that do depend on the specific realization are |
29 |
|
|
C | initialized in INITIALISE_VARIA. |
30 |
|
|
C | |
31 |
|
|
C *================================================================== |
32 |
|
|
C \ev |
33 |
adcroft |
1.1 |
|
34 |
cnh |
1.22 |
C !USES: |
35 |
|
|
IMPLICIT NONE |
36 |
|
|
C == Global variables == |
37 |
adcroft |
1.1 |
#include "SIZE.h" |
38 |
|
|
#include "EEPARAMS.h" |
39 |
|
|
#include "PARAMS.h" |
40 |
|
|
#include "DYNVARS.h" |
41 |
|
|
|
42 |
jmc |
1.27 |
#ifdef ALLOW_SHAP_FILT |
43 |
jmc |
1.91 |
# include "SHAP_FILT.h" |
44 |
jmc |
1.27 |
#endif |
45 |
|
|
#ifdef ALLOW_ZONAL_FILT |
46 |
jmc |
1.91 |
# include "ZONAL_FILT.h" |
47 |
jmc |
1.27 |
#endif |
48 |
jmc |
1.93 |
#ifdef COMPONENT_MODULE |
49 |
|
|
# include "CPL_PARAMS.h" |
50 |
|
|
#endif |
51 |
jmc |
1.27 |
|
52 |
heimbach |
1.12 |
#ifdef ALLOW_AUTODIFF_TAMC |
53 |
jmc |
1.91 |
# include "FFIELDS.h" |
54 |
|
|
|
55 |
|
|
# ifdef ALLOW_NONHYDROSTATIC |
56 |
|
|
# include "CG3D.h" |
57 |
|
|
# endif |
58 |
|
|
|
59 |
heimbach |
1.30 |
# include "tamc.h" |
60 |
|
|
# include "ctrl.h" |
61 |
|
|
# include "ctrl_dummy.h" |
62 |
|
|
# include "cost.h" |
63 |
heimbach |
1.37 |
# include "EOS.h" |
64 |
edhill |
1.69 |
# ifdef ALLOW_EXF |
65 |
heimbach |
1.30 |
# include "exf_fields.h" |
66 |
heimbach |
1.85 |
# include "exf_clim_fields.h" |
67 |
jmc |
1.63 |
# ifdef ALLOW_BULKFORMULAE |
68 |
heimbach |
1.30 |
# include "exf_constants.h" |
69 |
|
|
# endif |
70 |
|
|
# endif |
71 |
|
|
# ifdef ALLOW_OBCS |
72 |
|
|
# include "OBCS.h" |
73 |
|
|
# endif |
74 |
heimbach |
1.56 |
# ifdef ALLOW_PTRACERS |
75 |
|
|
# include "PTRACERS.h" |
76 |
heimbach |
1.82 |
# endif |
77 |
|
|
# ifdef ALLOW_CD_CODE |
78 |
|
|
# include "CD_CODE_VARS.h" |
79 |
heimbach |
1.56 |
# endif |
80 |
heimbach |
1.92 |
# ifdef ALLOW_EBM |
81 |
|
|
# include "EBM.h" |
82 |
|
|
# endif |
83 |
heimbach |
1.56 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
84 |
heimbach |
1.12 |
|
85 |
cnh |
1.22 |
C !LOCAL VARIABLES: |
86 |
|
|
C == Routine arguments == |
87 |
adcroft |
1.13 |
C note: under the multi-threaded model myiter and |
88 |
|
|
C mytime are local variables passed around as routine |
89 |
|
|
C arguments. Although this is fiddly it saves the need to |
90 |
|
|
C impose additional synchronisation points when they are |
91 |
|
|
C updated. |
92 |
jmc |
1.93 |
C myIter - iteration counter for this thread |
93 |
|
|
C myTime - time counter for this thread |
94 |
|
|
C myThid - thread number for this instance of the routine. |
95 |
|
|
INTEGER iloop |
96 |
|
|
INTEGER myThid |
97 |
|
|
INTEGER myIter |
98 |
|
|
_RL myTime |
99 |
molod |
1.83 |
|
100 |
jmc |
1.93 |
C == Local variables == |
101 |
|
|
INTEGER myItP1 |
102 |
cnh |
1.22 |
CEOP |
103 |
heimbach |
1.12 |
|
104 |
edhill |
1.71 |
#ifdef ALLOW_DEBUG |
105 |
heimbach |
1.57 |
IF ( debugLevel .GE. debLevB ) |
106 |
|
|
& CALL DEBUG_ENTER('FORWARD_STEP',myThid) |
107 |
adcroft |
1.53 |
#endif |
108 |
|
|
|
109 |
heimbach |
1.12 |
#ifdef ALLOW_AUTODIFF_TAMC |
110 |
dimitri |
1.45 |
C-- Reset the model iteration counter and the model time. |
111 |
|
|
myiter = nIter0 + (iloop-1) |
112 |
|
|
mytime = startTime + float(iloop-1)*deltaTclock |
113 |
heimbach |
1.12 |
#endif |
114 |
|
|
|
115 |
heimbach |
1.32 |
#if (defined (ALLOW_AUTODIFF_TAMC) && defined (ALLOW_AUTODIFF_MONITOR)) |
116 |
dimitri |
1.45 |
C Include call to a dummy routine. Its adjoint will be |
117 |
|
|
C called at the proper place in the adjoint code. |
118 |
|
|
C The adjoint routine will print out adjoint values |
119 |
|
|
C if requested. The location of the call is important, |
120 |
|
|
C it has to be after the adjoint of the exchanges |
121 |
|
|
C (DO_GTERM_BLOCKING_EXCHANGES). |
122 |
|
|
CALL DUMMY_IN_STEPPING( myTime, myIter, myThid ) |
123 |
heimbach |
1.46 |
cph I've commented this line since it may conflict with MITgcm's adjoint |
124 |
|
|
cph However, need to check whether that's still consistent |
125 |
|
|
cph with the ecco-branch (it should). |
126 |
|
|
cph CALL DO_FIELDS_BLOCKING_EXCHANGES( myThid ) |
127 |
heimbach |
1.16 |
#endif |
128 |
|
|
|
129 |
heimbach |
1.28 |
#ifdef ALLOW_AUTODIFF_TAMC |
130 |
|
|
c************************************** |
131 |
|
|
#include "checkpoint_lev1_directives.h" |
132 |
|
|
c************************************** |
133 |
heimbach |
1.23 |
#endif |
134 |
cheisey |
1.38 |
|
135 |
heimbach |
1.37 |
C-- Call external forcing package |
136 |
cheisey |
1.40 |
#ifdef ALLOW_BULK_FORCE |
137 |
jmc |
1.76 |
IF ( useBulkForce ) THEN |
138 |
edhill |
1.71 |
#ifdef ALLOW_DEBUG |
139 |
jmc |
1.58 |
IF ( debugLevel .GE. debLevB ) |
140 |
heimbach |
1.57 |
& CALL DEBUG_CALL('BULKF_FIELDS_LOAD',myThid) |
141 |
adcroft |
1.53 |
#endif |
142 |
jmc |
1.76 |
CALL TIMER_START('BULKF_FORCING [FORWARD_STEP]',mythid) |
143 |
|
|
C- load all forcing fields at current time |
144 |
|
|
CALL BULKF_FIELDS_LOAD( myTime, myIter, myThid ) |
145 |
|
|
C- calculate qnet and empmr (and wind stress) |
146 |
|
|
CALL BULKF_FORCING( myTime, myIter, myThid ) |
147 |
|
|
CALL TIMER_STOP ('BULKF_FORCING [FORWARD_STEP]',mythid) |
148 |
jmc |
1.63 |
ELSE |
149 |
jmc |
1.58 |
#endif /* ALLOW_BULK_FORCE */ |
150 |
jmc |
1.63 |
|
151 |
edhill |
1.64 |
# ifdef ALLOW_EXF |
152 |
heimbach |
1.72 |
# ifdef ALLOW_DEBUG |
153 |
heimbach |
1.57 |
IF ( debugLevel .GE. debLevB ) |
154 |
|
|
& CALL DEBUG_CALL('EXF_GETFORCING',myThid) |
155 |
heimbach |
1.72 |
# endif |
156 |
dimitri |
1.45 |
CALL TIMER_START('EXF_GETFORCING [FORWARD_STEP]',mythid) |
157 |
|
|
CALL EXF_GETFORCING( mytime, myiter, mythid ) |
158 |
|
|
CALL TIMER_STOP ('EXF_GETFORCING [FORWARD_STEP]',mythid) |
159 |
edhill |
1.64 |
# else /* ALLOW_EXF undef */ |
160 |
heimbach |
1.49 |
cph The following IF-statement creates an additional dependency |
161 |
|
|
cph for the forcing fields requiring additional storing. |
162 |
|
|
cph Therefore, the IF-statement will be put between CPP-OPTIONS, |
163 |
|
|
cph assuming that ALLOW_SEAICE has not yet been differentiated. |
164 |
heimbach |
1.92 |
# if (defined (ALLOW_SEAICE) || defined (ALLOW_EBM)) |
165 |
|
|
IF ( .NOT. useSEAICE .AND. .NOT. useEBM ) THEN |
166 |
heimbach |
1.49 |
# endif |
167 |
edhill |
1.71 |
#ifdef ALLOW_DEBUG |
168 |
heimbach |
1.57 |
IF ( debugLevel .GE. debLevB ) |
169 |
|
|
& CALL DEBUG_CALL('EXTERNAL_FIELDS_LOAD',myThid) |
170 |
adcroft |
1.53 |
#endif |
171 |
dimitri |
1.45 |
CALL TIMER_START('EXTERNAL_FIELDS_LOAD[FORWARD_STEP]',mythid) |
172 |
|
|
CALL EXTERNAL_FIELDS_LOAD( mytime, myiter, mythid ) |
173 |
|
|
CALL TIMER_STOP ('EXTERNAL_FIELDS_LOAD[FORWARD_STEP]',mythid) |
174 |
heimbach |
1.92 |
# if (defined (ALLOW_SEAICE) || defined (ALLOW_EBM)) |
175 |
dimitri |
1.45 |
ENDIF |
176 |
heimbach |
1.49 |
# endif |
177 |
edhill |
1.64 |
# endif /* ALLOW_EXF */ |
178 |
jmc |
1.63 |
#ifdef ALLOW_BULK_FORCE |
179 |
|
|
C-- end of if/else block useBulfforce -- |
180 |
|
|
ENDIF |
181 |
|
|
#endif /* ALLOW_BULK_FORCE */ |
182 |
heimbach |
1.49 |
|
183 |
heimbach |
1.68 |
#ifdef ALLOW_AUTODIFF |
184 |
heimbach |
1.49 |
c-- Add control vector for forcing and parameter fields |
185 |
|
|
if ( myiter .EQ. nIter0 ) |
186 |
|
|
& CALL CTRL_MAP_FORCING (mythid) |
187 |
|
|
#endif |
188 |
cheisey |
1.38 |
|
189 |
jmc |
1.76 |
#ifdef ALLOW_THSICE |
190 |
jmc |
1.91 |
IF ( useThSIce .AND. buoyancyRelation(1:7) .EQ. 'OCEANIC' ) THEN |
191 |
jmc |
1.76 |
#ifdef ALLOW_DEBUG |
192 |
|
|
IF ( debugLevel .GE. debLevB ) |
193 |
|
|
& CALL DEBUG_CALL('THSICE_MAIN',myThid) |
194 |
|
|
#endif |
195 |
|
|
C-- Step forward Therm.Sea-Ice variables |
196 |
|
|
C and modify forcing terms including effects from ice |
197 |
|
|
CALL TIMER_START('THSICE_MAIN [FORWARD_STEP]', myThid) |
198 |
|
|
CALL THSICE_MAIN( myTime, myIter, myThid ) |
199 |
|
|
CALL TIMER_STOP( 'THSICE_MAIN [FORWARD_STEP]', myThid) |
200 |
|
|
ENDIF |
201 |
|
|
#endif /* ALLOW_THSICE */ |
202 |
|
|
|
203 |
heimbach |
1.49 |
# ifdef ALLOW_SEAICE |
204 |
dimitri |
1.45 |
C-- Call sea ice model to compute forcing/external data fields. In |
205 |
|
|
C addition to computing prognostic sea-ice variables and diagnosing the |
206 |
|
|
C forcing/external data fields that drive the ocean model, SEAICE_MODEL |
207 |
|
|
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 |
edhill |
1.71 |
#ifdef ALLOW_DEBUG |
216 |
heimbach |
1.57 |
IF ( debugLevel .GE. debLevB ) |
217 |
|
|
& CALL DEBUG_CALL('SEAICE_MODEL',myThid) |
218 |
adcroft |
1.53 |
#endif |
219 |
heimbach |
1.36 |
CALL TIMER_START('SEAICE_MODEL [FORWARD_STEP]',myThid) |
220 |
jmc |
1.41 |
CALL SEAICE_MODEL( myTime, myIter, myThid ) |
221 |
heimbach |
1.36 |
CALL TIMER_STOP ('SEAICE_MODEL [FORWARD_STEP]',myThid) |
222 |
dimitri |
1.45 |
ENDIF |
223 |
dimitri |
1.50 |
# endif /* ALLOW_SEAICE */ |
224 |
dimitri |
1.73 |
|
225 |
|
|
C-- Freeze water at the surface |
226 |
heimbach |
1.75 |
#ifdef ALLOW_AUTODIFF_TAMC |
227 |
|
|
CADJ STORE theta = comlev1, key = ikey_dynamics |
228 |
|
|
#endif |
229 |
dimitri |
1.73 |
IF ( allowFreezing .AND. .NOT. useSEAICE |
230 |
jmc |
1.76 |
& .AND. .NOT. useThSIce ) THEN |
231 |
heimbach |
1.75 |
CALL FREEZE_SURFACE( myTime, myIter, myThid ) |
232 |
|
|
ENDIF |
233 |
adcroft |
1.15 |
|
234 |
heimbach |
1.56 |
#ifdef ALLOW_AUTODIFF_TAMC |
235 |
|
|
# ifdef ALLOW_PTRACERS |
236 |
|
|
cph this replaces _bibj storing of ptracer within thermodynamics |
237 |
|
|
CADJ STORE ptracer = comlev1, key = ikey_dynamics |
238 |
|
|
# endif |
239 |
|
|
#endif |
240 |
stephd |
1.62 |
|
241 |
|
|
#ifdef ALLOW_PTRACERS |
242 |
|
|
# ifdef ALLOW_GCHEM |
243 |
|
|
CALL GCHEM_FIELDS_LOAD( mytime, myiter, mythid ) |
244 |
|
|
# endif |
245 |
|
|
#endif |
246 |
jmc |
1.78 |
|
247 |
|
|
#ifdef COMPONENT_MODULE |
248 |
jmc |
1.93 |
IF ( useCoupler .AND. cpl_earlyExpImpCall ) THEN |
249 |
jmc |
1.78 |
C Post coupling data that I export. |
250 |
|
|
C Read in coupling data that I import. |
251 |
|
|
CALL TIMER_START('CPL_EXPORT-IMPORT [FORWARD_STEP]',myThid) |
252 |
|
|
CALL CPL_EXPORT_MY_DATA( myIter, myTime, myThid ) |
253 |
|
|
CALL CPL_IMPORT_EXTERNAL_DATA( myIter, myTime, myThid ) |
254 |
|
|
CALL TIMER_STOP ('CPL_EXPORT-IMPORT [FORWARD_STEP]',myThid) |
255 |
|
|
ENDIF |
256 |
|
|
# ifndef ALLOW_AIM |
257 |
|
|
C jmc: don't know precisely where to put this call. leave it here for now. |
258 |
|
|
IF ( useCoupler ) THEN |
259 |
jmc |
1.93 |
CALL OCN_APPLY_IMPORT( .TRUE., myTime, myIter, myThid ) |
260 |
jmc |
1.78 |
ENDIF |
261 |
|
|
# endif |
262 |
|
|
#endif /* COMPONENT_MODULE */ |
263 |
stephd |
1.62 |
|
264 |
heimbach |
1.92 |
#ifdef ALLOW_EBM |
265 |
|
|
IF ( useEBM ) THEN |
266 |
|
|
# ifdef ALLOW_DEBUG |
267 |
|
|
IF ( debugLevel .GE. debLevB ) |
268 |
|
|
& CALL DEBUG_CALL('EBM',myThid) |
269 |
|
|
# endif |
270 |
|
|
CALL TIMER_START('EBM [FORWARD_STEP]',mythid) |
271 |
|
|
CALL EBM_DRIVER ( myTime, myIter, myThid ) |
272 |
|
|
CALL TIMER_STOP ('EBM [FORWARD_STEP]',mythid) |
273 |
|
|
ENDIF |
274 |
|
|
#endif |
275 |
molod |
1.79 |
|
276 |
jmc |
1.97 |
C-- Step forward fields and calculate time tendency terms. |
277 |
|
|
|
278 |
|
|
#ifdef ALLOW_DEBUG |
279 |
|
|
IF ( debugLevel .GE. debLevB ) |
280 |
|
|
& CALL DEBUG_CALL('DO_ATMOSPHERIC_PHYS',myThid) |
281 |
|
|
#endif |
282 |
|
|
CALL TIMER_START('DO_ATMOSPHERIC_PHYS [FORWARD_STEP]',mythid) |
283 |
|
|
CALL DO_ATMOSPHERIC_PHYS( myTime, myIter, myThid ) |
284 |
|
|
CALL TIMER_STOP ('DO_ATMOSPHERIC_PHYS [FORWARD_STEP]',mythid) |
285 |
|
|
|
286 |
edhill |
1.71 |
#ifdef ALLOW_DEBUG |
287 |
jmc |
1.96 |
IF ( debugLevel .GE. debLevB ) |
288 |
|
|
& CALL DEBUG_CALL('DO_OCEANIC_PHYS',myThid) |
289 |
|
|
#endif |
290 |
|
|
CALL TIMER_START('DO_OCEANIC_PHYS [FORWARD_STEP]',mythid) |
291 |
|
|
CALL DO_OCEANIC_PHYS( myTime, myIter, myThid ) |
292 |
|
|
CALL TIMER_STOP ('DO_OCEANIC_PHYS [FORWARD_STEP]',mythid) |
293 |
|
|
|
294 |
|
|
IF ( .NOT.staggerTimeStep ) THEN |
295 |
|
|
#ifdef ALLOW_DEBUG |
296 |
|
|
IF ( debugLevel .GE. debLevB ) |
297 |
heimbach |
1.57 |
& CALL DEBUG_CALL('THERMODYNAMICS',myThid) |
298 |
adcroft |
1.53 |
#endif |
299 |
heimbach |
1.36 |
CALL TIMER_START('THERMODYNAMICS [FORWARD_STEP]',mythid) |
300 |
adcroft |
1.15 |
CALL THERMODYNAMICS( myTime, myIter, myThid ) |
301 |
heimbach |
1.36 |
CALL TIMER_STOP ('THERMODYNAMICS [FORWARD_STEP]',mythid) |
302 |
jmc |
1.96 |
C-- if not staggerTimeStep: end |
303 |
dimitri |
1.45 |
ENDIF |
304 |
jmc |
1.93 |
|
305 |
|
|
#ifdef COMPONENT_MODULE |
306 |
|
|
IF ( useCoupler .AND. .NOT.cpl_earlyExpImpCall ) THEN |
307 |
|
|
C Post coupling data that I export. |
308 |
|
|
C Read in coupling data that I import. |
309 |
|
|
myItP1 = myIter + 1 |
310 |
|
|
CALL TIMER_START('CPL_EXPORT-IMPORT [FORWARD_STEP]',myThid) |
311 |
|
|
CALL CPL_EXPORT_MY_DATA( myItP1, myTime, myThid ) |
312 |
|
|
CALL CPL_IMPORT_EXTERNAL_DATA( myItP1, myTime, myThid ) |
313 |
|
|
CALL TIMER_STOP ('CPL_EXPORT-IMPORT [FORWARD_STEP]',myThid) |
314 |
|
|
# ifndef ALLOW_AIM |
315 |
|
|
IF ( useRealFreshWaterFlux ) THEN |
316 |
|
|
CALL OCN_APPLY_IMPORT( .FALSE., myTime, myIter, myThid ) |
317 |
|
|
ENDIF |
318 |
|
|
# endif |
319 |
|
|
ENDIF |
320 |
|
|
#endif /* COMPONENT_MODULE */ |
321 |
heimbach |
1.12 |
|
322 |
dimitri |
1.45 |
C-- Step forward fields and calculate time tendency terms. |
323 |
heimbach |
1.61 |
#ifndef ALLOW_AUTODIFF_TAMC |
324 |
dimitri |
1.45 |
IF ( momStepping ) THEN |
325 |
heimbach |
1.61 |
#endif |
326 |
edhill |
1.71 |
#ifdef ALLOW_DEBUG |
327 |
heimbach |
1.57 |
IF ( debugLevel .GE. debLevB ) |
328 |
|
|
& CALL DEBUG_CALL('DYNAMICS',myThid) |
329 |
adcroft |
1.53 |
#endif |
330 |
heimbach |
1.36 |
CALL TIMER_START('DYNAMICS [FORWARD_STEP]',mythid) |
331 |
heimbach |
1.12 |
CALL DYNAMICS( myTime, myIter, myThid ) |
332 |
heimbach |
1.36 |
CALL TIMER_STOP ('DYNAMICS [FORWARD_STEP]',mythid) |
333 |
heimbach |
1.61 |
#ifndef ALLOW_AUTODIFF_TAMC |
334 |
dimitri |
1.45 |
ENDIF |
335 |
heimbach |
1.61 |
#endif |
336 |
heimbach |
1.12 |
|
337 |
adcroft |
1.1 |
#ifdef ALLOW_NONHYDROSTATIC |
338 |
|
|
C-- Step forward W field in N-H algorithm |
339 |
dimitri |
1.45 |
IF ( momStepping .AND. nonHydrostatic ) THEN |
340 |
edhill |
1.71 |
#ifdef ALLOW_DEBUG |
341 |
heimbach |
1.57 |
IF ( debugLevel .GE. debLevB ) |
342 |
|
|
& CALL DEBUG_CALL('CALC_GW',myThid) |
343 |
adcroft |
1.53 |
#endif |
344 |
dimitri |
1.45 |
CALL TIMER_START('CALC_GW [FORWARD_STEP]',myThid) |
345 |
|
|
CALL CALC_GW(myThid) |
346 |
|
|
CALL TIMER_STOP ('CALC_GW [FORWARD_STEP]',myThid) |
347 |
|
|
ENDIF |
348 |
adcroft |
1.1 |
#endif |
349 |
jmc |
1.18 |
|
350 |
jmc |
1.96 |
C-- Update time-counter |
351 |
|
|
myIter = nIter0 + iLoop |
352 |
|
|
myTime = startTime + deltaTClock * float(iLoop) |
353 |
|
|
|
354 |
|
|
C-- Update geometric factors: |
355 |
jmc |
1.18 |
#ifdef NONLIN_FRSURF |
356 |
jmc |
1.96 |
C- update hfacC,W,S and recip_hFac according to etaH(n+1) : |
357 |
jmc |
1.18 |
IF ( nonlinFreeSurf.GT.0) THEN |
358 |
jmc |
1.48 |
IF ( select_rStar.GT.0 ) THEN |
359 |
|
|
CALL TIMER_START('UPDATE_R_STAR [FORWARD_STEP]',myThid) |
360 |
|
|
CALL UPDATE_R_STAR( myTime, myIter, myThid ) |
361 |
|
|
CALL TIMER_STOP ('UPDATE_R_STAR [FORWARD_STEP]',myThid) |
362 |
|
|
ELSE |
363 |
dimitri |
1.45 |
CALL TIMER_START('UPDATE_SURF_DR [FORWARD_STEP]',myThid) |
364 |
jmc |
1.18 |
CALL UPDATE_SURF_DR( myTime, myIter, myThid ) |
365 |
heimbach |
1.36 |
CALL TIMER_STOP ('UPDATE_SURF_DR [FORWARD_STEP]',myThid) |
366 |
jmc |
1.48 |
ENDIF |
367 |
jmc |
1.18 |
ENDIF |
368 |
|
|
C- update also CG2D matrix (and preconditioner) |
369 |
jmc |
1.33 |
IF ( momStepping .AND. nonlinFreeSurf.GT.2 ) THEN |
370 |
dimitri |
1.45 |
CALL TIMER_START('UPDATE_CG2D [FORWARD_STEP]',myThid) |
371 |
jmc |
1.18 |
CALL UPDATE_CG2D( myTime, myIter, myThid ) |
372 |
jmc |
1.47 |
CALL TIMER_STOP ('UPDATE_CG2D [FORWARD_STEP]',myThid) |
373 |
adcroft |
1.19 |
ENDIF |
374 |
jmc |
1.18 |
#endif |
375 |
adcroft |
1.1 |
|
376 |
jmc |
1.27 |
C-- Apply Filters to u*,v* before SOLVE_FOR_PRESSURE |
377 |
|
|
#ifdef ALLOW_SHAP_FILT |
378 |
|
|
IF (useSHAP_FILT .AND. shap_filt_uvStar) THEN |
379 |
heimbach |
1.36 |
CALL TIMER_START('SHAP_FILT [FORWARD_STEP]',myThid) |
380 |
jmc |
1.27 |
IF (implicDiv2Dflow.LT.1.) THEN |
381 |
|
|
C-- Explicit+Implicit part of the Barotropic Flow Divergence |
382 |
|
|
C => Filtering of uVel,vVel is necessary |
383 |
jmc |
1.59 |
CALL SHAP_FILT_APPLY_UV( uVel,vVel, |
384 |
jmc |
1.96 |
& myTime, myIter, myThid ) |
385 |
jmc |
1.27 |
ENDIF |
386 |
jmc |
1.96 |
CALL SHAP_FILT_APPLY_UV( gU,gV,myTime,myIter,myThid) |
387 |
heimbach |
1.36 |
CALL TIMER_STOP ('SHAP_FILT [FORWARD_STEP]',myThid) |
388 |
jmc |
1.27 |
ENDIF |
389 |
|
|
#endif |
390 |
|
|
#ifdef ALLOW_ZONAL_FILT |
391 |
|
|
IF (useZONAL_FILT .AND. zonal_filt_uvStar) THEN |
392 |
heimbach |
1.36 |
CALL TIMER_START('ZONAL_FILT_APPLY [FORWARD_STEP]',myThid) |
393 |
jmc |
1.27 |
IF (implicDiv2Dflow.LT.1.) THEN |
394 |
|
|
C-- Explicit+Implicit part of the Barotropic Flow Divergence |
395 |
|
|
C => Filtering of uVel,vVel is necessary |
396 |
|
|
CALL ZONAL_FILT_APPLY_UV( uVel, vVel, myThid ) |
397 |
|
|
ENDIF |
398 |
jmc |
1.59 |
CALL ZONAL_FILT_APPLY_UV( gU, gV, myThid ) |
399 |
heimbach |
1.36 |
CALL TIMER_STOP ('ZONAL_FILT_APPLY [FORWARD_STEP]',myThid) |
400 |
jmc |
1.27 |
ENDIF |
401 |
|
|
#endif |
402 |
heimbach |
1.12 |
|
403 |
adcroft |
1.1 |
C-- Solve elliptic equation(s). |
404 |
|
|
C Two-dimensional only for conventional hydrostatic or |
405 |
|
|
C three-dimensional for non-hydrostatic and/or IGW scheme. |
406 |
adcroft |
1.19 |
IF ( momStepping ) THEN |
407 |
jmc |
1.96 |
CALL TIMER_START('SOLVE_FOR_PRESSURE [FORWARD_STEP]',myThid) |
408 |
|
|
CALL SOLVE_FOR_PRESSURE(myTime, myIter, myThid) |
409 |
|
|
CALL TIMER_STOP ('SOLVE_FOR_PRESSURE [FORWARD_STEP]',myThid) |
410 |
|
|
ENDIF |
411 |
|
|
|
412 |
|
|
C-- Correct divergence in flow field and cycle time-stepping momentum |
413 |
|
|
c IF ( momStepping ) THEN |
414 |
|
|
CALL TIMER_START('UV_CORRECTION_STEP [FORWARD_STEP]',myThid) |
415 |
|
|
CALL MOMENTUM_CORRECTION_STEP(myTime, myIter, myThid) |
416 |
|
|
CALL TIMER_STOP ('UV_CORRECTION_STEP [FORWARD_STEP]',myThid) |
417 |
|
|
c ENDIF |
418 |
|
|
|
419 |
|
|
#ifdef EXACT_CONSERV |
420 |
|
|
IF (exactConserv) THEN |
421 |
|
|
C-- Update etaH(n+1) : |
422 |
|
|
CALL TIMER_START('UPDATE_ETAH [FORWARD_STEP]',mythid) |
423 |
|
|
CALL UPDATE_ETAH( myTime, myIter, myThid ) |
424 |
|
|
CALL TIMER_STOP ('UPDATE_ETAH [FORWARD_STEP]',mythid) |
425 |
adcroft |
1.19 |
ENDIF |
426 |
jmc |
1.96 |
#endif /* EXACT_CONSERV */ |
427 |
|
|
|
428 |
|
|
#ifdef NONLIN_FRSURF |
429 |
|
|
IF ( select_rStar.NE.0 ) THEN |
430 |
|
|
C-- r* : compute the future level thickness according to etaH(n+1) |
431 |
|
|
CALL TIMER_START('CALC_R_STAR [FORWARD_STEP]',mythid) |
432 |
|
|
CALL CALC_R_STAR(etaH, myTime, myIter, myThid ) |
433 |
|
|
CALL TIMER_STOP ('CALC_R_STAR [FORWARD_STEP]',mythid) |
434 |
|
|
ELSEIF ( nonlinFreeSurf.GT.0) THEN |
435 |
|
|
C-- compute the future surface level thickness according to etaH(n+1) |
436 |
|
|
CALL TIMER_START('CALC_SURF_DR [FORWARD_STEP]',mythid) |
437 |
|
|
CALL CALC_SURF_DR(etaH, myTime, myIter, myThid ) |
438 |
|
|
CALL TIMER_STOP ('CALC_SURF_DR [FORWARD_STEP]',mythid) |
439 |
|
|
ENDIF |
440 |
|
|
#endif /* NONLIN_FRSURF */ |
441 |
|
|
|
442 |
|
|
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
443 |
|
|
IF ( staggerTimeStep ) THEN |
444 |
jmc |
1.98 |
C-- do exchanges of U,V (needed for multiDim) when using stagger time-step : |
445 |
|
|
#ifdef ALLOW_DEBUG |
446 |
|
|
IF ( debugLevel .GE. debLevB ) |
447 |
|
|
& CALL DEBUG_CALL('DO_STAGGER_FIELDS_EXCH.',myThid) |
448 |
|
|
#endif |
449 |
|
|
CALL TIMER_START('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
450 |
|
|
CALL DO_STAGGER_FIELDS_EXCHANGES( myTime, myIter, myThid ) |
451 |
|
|
CALL TIMER_STOP ('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
452 |
jmc |
1.96 |
|
453 |
|
|
#ifdef ALLOW_DEBUG |
454 |
|
|
IF ( debugLevel .GE. debLevB ) |
455 |
|
|
& CALL DEBUG_CALL('THERMODYNAMICS',myThid) |
456 |
|
|
#endif |
457 |
|
|
CALL TIMER_START('THERMODYNAMICS [FORWARD_STEP]',mythid) |
458 |
|
|
CALL THERMODYNAMICS( myTime, myIter, myThid ) |
459 |
|
|
CALL TIMER_STOP ('THERMODYNAMICS [FORWARD_STEP]',mythid) |
460 |
|
|
|
461 |
|
|
C-- if staggerTimeStep: end |
462 |
|
|
ENDIF |
463 |
|
|
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
464 |
adcroft |
1.1 |
|
465 |
heimbach |
1.37 |
#ifdef ALLOW_AUTODIFF_TAMC |
466 |
|
|
cph This is needed because convective_adjustment calls |
467 |
|
|
cph find_rho which may use pressure() |
468 |
heimbach |
1.51 |
CADJ STORE totphihyd = comlev1, key = ikey_dynamics |
469 |
heimbach |
1.37 |
#endif |
470 |
jmc |
1.96 |
C-- Cycle time-stepping Tracers arrays (T,S,+pTracers) |
471 |
|
|
CALL TIMER_START('TS_CORRECTION_STEP [FORWARD_STEP]',myThid) |
472 |
|
|
CALL TRACERS_CORRECTION_STEP(myTime, myIter, myThid) |
473 |
|
|
CALL TIMER_STOP ('TS_CORRECTION_STEP [FORWARD_STEP]',myThid) |
474 |
adcroft |
1.5 |
|
475 |
adcroft |
1.1 |
C-- Do "blocking" sends and receives for tendency "overlap" terms |
476 |
heimbach |
1.36 |
c CALL TIMER_START('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
477 |
jmc |
1.7 |
c CALL DO_GTERM_BLOCKING_EXCHANGES( myThid ) |
478 |
heimbach |
1.36 |
c CALL TIMER_STOP ('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
479 |
adcroft |
1.5 |
|
480 |
|
|
C-- Do "blocking" sends and receives for field "overlap" terms |
481 |
heimbach |
1.36 |
CALL TIMER_START('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
482 |
adcroft |
1.5 |
CALL DO_FIELDS_BLOCKING_EXCHANGES( myThid ) |
483 |
heimbach |
1.36 |
CALL TIMER_STOP ('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
484 |
stephd |
1.54 |
|
485 |
|
|
cswdptr -- add for seperate timestepping of chemical/biological/forcing |
486 |
|
|
cswdptr of ptracers --- |
487 |
heimbach |
1.56 |
#ifdef ALLOW_GCHEM |
488 |
edhill |
1.64 |
ceh3 This is broken -- this ifdef should not be visible! |
489 |
stephd |
1.62 |
#ifdef PTRACERS_SEPARATE_FORCING |
490 |
edhill |
1.64 |
ceh3 needs an IF ( use GCHEM ) THEN |
491 |
stephd |
1.62 |
call GCHEM_FORCING_SEP( myTime,myIter,myThid ) |
492 |
edhill |
1.64 |
#endif /* PTRACERS_SEPARATE_FORCING */ |
493 |
|
|
#endif /* ALLOW_GCHEM */ |
494 |
stephd |
1.54 |
cswdptr -- end add --- |
495 |
molod |
1.83 |
|
496 |
|
|
C AMM |
497 |
|
|
#ifdef ALLOW_GRIDALT |
498 |
molod |
1.88 |
if (useGRIDALT) then |
499 |
|
|
CALL GRIDALT_UPDATE(myThid) |
500 |
molod |
1.89 |
endif |
501 |
molod |
1.83 |
#endif |
502 |
|
|
C AMM |
503 |
stephd |
1.54 |
|
504 |
molod |
1.79 |
C AMM |
505 |
|
|
#ifdef ALLOW_FIZHI |
506 |
molod |
1.88 |
if( useFIZHI) then |
507 |
molod |
1.90 |
CALL TIMER_START('FIZHI [FORWARD_STEP]',mythid) |
508 |
molod |
1.88 |
CALL STEP_FIZHI_CORR ( myTime, myIter, myThid ) |
509 |
molod |
1.90 |
CALL TIMER_STOP('FIZHI [FORWARD_STEP]',mythid) |
510 |
molod |
1.88 |
endif |
511 |
molod |
1.79 |
#endif |
512 |
|
|
C AMM |
513 |
adcroft |
1.20 |
|
514 |
|
|
#ifdef ALLOW_FLT |
515 |
|
|
C-- Calculate float trajectories |
516 |
|
|
IF (useFLT) THEN |
517 |
heimbach |
1.36 |
CALL TIMER_START('FLOATS [FORWARD_STEP]',myThid) |
518 |
adcroft |
1.20 |
CALL FLT_MAIN(myIter,myTime, myThid) |
519 |
heimbach |
1.36 |
CALL TIMER_STOP ('FLOATS [FORWARD_STEP]',myThid) |
520 |
adcroft |
1.20 |
ENDIF |
521 |
|
|
#endif |
522 |
heimbach |
1.12 |
|
523 |
jmc |
1.97 |
C-- State-variables statistics (time-aver, diagnostics ...) |
524 |
|
|
CALL TIMER_START('DO_STATEVARS_DIAGS [FORWARD_STEP]',myThid) |
525 |
|
|
CALL DO_STATEVARS_DIAGS( myTime, myIter, myThid ) |
526 |
|
|
CALL TIMER_STOP ('DO_STATEVARS_DIAGS [FORWARD_STEP]',myThid) |
527 |
|
|
|
528 |
edhill |
1.70 |
#ifdef ALLOW_MONITOR |
529 |
heimbach |
1.12 |
C-- Check status of solution (statistics, cfl, etc...) |
530 |
dimitri |
1.45 |
CALL TIMER_START('MONITOR [FORWARD_STEP]',myThid) |
531 |
heimbach |
1.12 |
CALL MONITOR( myIter, myTime, myThid ) |
532 |
heimbach |
1.36 |
CALL TIMER_STOP ('MONITOR [FORWARD_STEP]',myThid) |
533 |
edhill |
1.70 |
#endif /* ALLOW_MONITOR */ |
534 |
molod |
1.86 |
|
535 |
jmc |
1.7 |
C-- Do IO if needed. |
536 |
heimbach |
1.36 |
CALL TIMER_START('DO_THE_MODEL_IO [FORWARD_STEP]',myThid) |
537 |
heimbach |
1.12 |
CALL DO_THE_MODEL_IO( myTime, myIter, myThid ) |
538 |
heimbach |
1.36 |
CALL TIMER_STOP ('DO_THE_MODEL_IO [FORWARD_STEP]',myThid) |
539 |
adcroft |
1.1 |
|
540 |
|
|
C-- Save state for restarts |
541 |
heimbach |
1.36 |
CALL TIMER_START('WRITE_CHECKPOINT [FORWARD_STEP]',myThid) |
542 |
jmc |
1.77 |
CALL PACKAGES_WRITE_PICKUP( |
543 |
|
|
I .FALSE., myTime, myIter, myThid ) |
544 |
adcroft |
1.1 |
CALL WRITE_CHECKPOINT( |
545 |
jmc |
1.77 |
I .FALSE., myTime, myIter, myThid ) |
546 |
heimbach |
1.36 |
CALL TIMER_STOP ('WRITE_CHECKPOINT [FORWARD_STEP]',myThid) |
547 |
adcroft |
1.53 |
|
548 |
edhill |
1.71 |
#ifdef ALLOW_DEBUG |
549 |
heimbach |
1.57 |
IF ( debugLevel .GE. debLevB ) |
550 |
|
|
& CALL DEBUG_LEAVE('FORWARD_STEP',myThid) |
551 |
adcroft |
1.53 |
#endif |
552 |
adcroft |
1.1 |
|
553 |
jmc |
1.77 |
RETURN |
554 |
adcroft |
1.1 |
END |