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