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