2 |
C $Name$ |
C $Name$ |
3 |
|
|
4 |
#include "CPP_OPTIONS.h" |
#include "CPP_OPTIONS.h" |
5 |
|
cswdptr -- add -- |
6 |
|
#ifdef ALLOW_GCHEM |
7 |
|
# include "GCHEM_OPTIONS.h" |
8 |
|
#endif |
9 |
|
cswdptr -- end add --- |
10 |
|
|
11 |
SUBROUTINE FORWARD_STEP( |
CBOP |
12 |
I doHalfStep, iLoop, |
C !ROUTINE: FORWARD_STEP |
13 |
U myCurrentTime, myCurrentIter, |
C !INTERFACE: |
14 |
& myThid) |
SUBROUTINE FORWARD_STEP( iloop, myTime, myIter, myThid ) |
15 |
C /==========================================================\ |
|
16 |
C | SUBROUTINE FORWARD_STEP | |
C !DESCRIPTION: \bv |
17 |
C | o Does one instance of the model time stepping | |
C *================================================================== |
18 |
C | The time stepping loop in THE_MAIN_LOOP() calls | |
C | SUBROUTINE forward_step |
19 |
C | this routine | |
C | o Run the ocean model and, optionally, evaluate a cost function. |
20 |
C |==========================================================| |
C *================================================================== |
21 |
C \==========================================================/ |
C | |
22 |
IMPLICIT NONE |
C | THE_MAIN_LOOP is the toplevel routine for the Tangent Linear and |
23 |
C |
C | Adjoint Model Compiler (TAMC). For this purpose the initialization |
24 |
C Call Tree |
C | of the model was split into two parts. Those parameters that do |
25 |
C ========= |
C | not depend on a specific model run are set in INITIALISE_FIXED, |
26 |
C |
C | whereas those that do depend on the specific realization are |
27 |
C THE_MAIN_LOOP() |
C | initialized in INITIALISE_VARIA. |
28 |
C | |
C | |
29 |
C ==> | ** Time stepping loop starts here ** |
C *================================================================== |
30 |
C | | |
C \ev |
|
C /|\ |-FORWARD_STEP |
|
|
C | | | |
|
|
C /|\ | |--LOAD_EXTERNAL_DATA |
|
|
C | | | o Load and/or set time dependent forcing fields |
|
|
C /|\ | | |
|
|
C | | |--DYNAMICS |
|
|
C /|\ | | o Evaluate "forward" terms |
|
|
C | | | |
|
|
C /|\ | | |
|
|
C | | |--DO_THE_MODEL_IO |
|
|
C /|\ | | o Write model state |
|
|
C | | | |
|
|
C /|\ | | |
|
|
C | | |--SOLVE_FOR_PRESSURE |
|
|
C /|\ | | o Find pressure field to keep flow non-divergent |
|
|
C | | | |
|
|
C /|\ | | |
|
|
C | | |--THE_CORRECTION_STEP |
|
|
C /|\ | | o Correct flow field with pressure gradient |
|
|
C | | | and cycle time-stepping arrays (for all fields) |
|
|
C /|\ | | |
|
|
C | | |--DO_GTERM_BLOCKING_EXCHANGES |
|
|
C /|\ | | o Update overlap regions |
|
|
C | | | |
|
|
C /|\ | | |
|
|
C | | |--WRITE_CHECKPOINT |
|
|
C /|\ | | o Write restart file(s) |
|
|
C | | |
|
|
C /|\ | |
|
|
C |<== | ** Time stepping loop finishes here ** |
|
|
C |
|
31 |
|
|
32 |
C == Global variables === |
C !USES: |
33 |
|
IMPLICIT NONE |
34 |
|
C == Global variables == |
35 |
#include "SIZE.h" |
#include "SIZE.h" |
36 |
#include "EEPARAMS.h" |
#include "EEPARAMS.h" |
37 |
#include "PARAMS.h" |
#include "PARAMS.h" |
38 |
#include "DYNVARS.h" |
#include "DYNVARS.h" |
39 |
#include "CG2D.h" |
#include "FFIELDS.h" |
40 |
|
|
41 |
#ifdef ALLOW_NONHYDROSTATIC |
#ifdef ALLOW_NONHYDROSTATIC |
42 |
#include "CG3D.h" |
#include "CG3D.h" |
43 |
#endif |
#endif |
44 |
|
|
45 |
|
#ifdef ALLOW_SHAP_FILT |
46 |
|
#include "SHAP_FILT.h" |
47 |
|
#endif |
48 |
|
#ifdef ALLOW_ZONAL_FILT |
49 |
|
#include "ZONAL_FILT.h" |
50 |
|
#endif |
51 |
|
|
52 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
53 |
|
# include "tamc.h" |
54 |
|
# include "ctrl.h" |
55 |
|
# include "ctrl_dummy.h" |
56 |
|
# include "cost.h" |
57 |
|
# include "EOS.h" |
58 |
|
# ifdef INCLUDE_EXTERNAL_FORCING_PACKAGE |
59 |
|
# include "exf_fields.h" |
60 |
|
# if (defined (ALLOW_BULKFORMULAE) || defined (ALLOW_BULK_FORCE)) |
61 |
|
# include "exf_constants.h" |
62 |
|
# endif |
63 |
|
# endif |
64 |
|
# ifdef ALLOW_OBCS |
65 |
|
# include "OBCS.h" |
66 |
|
# endif |
67 |
|
# ifdef ALLOW_PTRACERS |
68 |
|
# include "PTRACERS.h" |
69 |
|
# endif |
70 |
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
71 |
|
|
72 |
|
C !LOCAL VARIABLES: |
73 |
C == Routine arguments == |
C == Routine arguments == |
74 |
C doHalfStep - If .TRUE. then this is the last half step |
C note: under the multi-threaded model myiter and |
75 |
C iLoop - Invocation count (counter in THE_MAIN_LOOP) |
C mytime are local variables passed around as routine |
76 |
C myCurrentIter - Iteration counter for this thread |
C arguments. Although this is fiddly it saves the need to |
77 |
C myCurrentTime - Time counter for this thread |
C impose additional synchronisation points when they are |
78 |
C myThid - Thread number for this instance of the routine. |
C updated. |
79 |
LOGICAL doHalfStep |
C myiter - iteration counter for this thread |
80 |
INTEGER iLoop |
C mytime - time counter for this thread |
81 |
INTEGER myCurrentIter |
C mythid - thread number for this instance of the routine. |
82 |
_RL myCurrentTime |
integer iloop |
83 |
INTEGER myThid |
integer mythid |
84 |
|
integer myiter |
85 |
C == Local variables == |
_RL mytime |
86 |
|
#ifdef ALLOW_BULK_FORCE |
87 |
C-- Load forcing/external data fields |
INTEGER bi,bj |
88 |
CALL TIMER_START('I/O (READ) [FORWARD_STEP]',myThid) |
#endif |
|
CALL EXTERNAL_FIELDS_LOAD( myCurrentTime, myCurrentIter, myThid ) |
|
|
CALL TIMER_STOP ('I/O (READ) [FORWARD_STEP]',myThid) |
|
|
|
|
|
C-- Step forward fields and calculate time tendency terms |
|
|
CALL TIMER_START('DYNAMICS [FORWARD_STEP]',myThid) |
|
|
CALL DYNAMICS( myCurrentTime, myCurrentIter, myThid ) |
|
|
CALL TIMER_STOP ('DYNAMICS [FORWARD_STEP]',myThid) |
|
89 |
|
|
90 |
#ifdef ALLOW_NONHYDROSTATIC |
CEOP |
91 |
C-- Step forward W field in N-H algorithm |
|
92 |
IF ( nonHydrostatic ) THEN |
#ifndef DISABLE_DEBUGMODE |
93 |
CALL TIMER_START('CALC_GW [FORWARD_STEP]',myThid) |
IF ( debugLevel .GE. debLevB ) |
94 |
CALL CALC_GW( myThid) |
& CALL DEBUG_ENTER('FORWARD_STEP',myThid) |
95 |
CALL TIMER_STOP ('CALC_GW [FORWARD_STEP]',myThid) |
#endif |
96 |
|
|
97 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
98 |
|
C-- Reset the model iteration counter and the model time. |
99 |
|
myiter = nIter0 + (iloop-1) |
100 |
|
mytime = startTime + float(iloop-1)*deltaTclock |
101 |
|
#endif |
102 |
|
|
103 |
|
#if (defined (ALLOW_AUTODIFF_TAMC) && defined (ALLOW_AUTODIFF_MONITOR)) |
104 |
|
C Include call to a dummy routine. Its adjoint will be |
105 |
|
C called at the proper place in the adjoint code. |
106 |
|
C The adjoint routine will print out adjoint values |
107 |
|
C if requested. The location of the call is important, |
108 |
|
C it has to be after the adjoint of the exchanges |
109 |
|
C (DO_GTERM_BLOCKING_EXCHANGES). |
110 |
|
CALL DUMMY_IN_STEPPING( myTime, myIter, myThid ) |
111 |
|
cph I've commented this line since it may conflict with MITgcm's adjoint |
112 |
|
cph However, need to check whether that's still consistent |
113 |
|
cph with the ecco-branch (it should). |
114 |
|
cph CALL DO_FIELDS_BLOCKING_EXCHANGES( myThid ) |
115 |
|
#endif |
116 |
|
|
117 |
|
#ifdef EXACT_CONSERV |
118 |
|
IF (exactConserv) THEN |
119 |
|
C-- Update etaH(n+1) : |
120 |
|
CALL TIMER_START('UPDATE_ETAH [FORWARD_STEP]',mythid) |
121 |
|
CALL UPDATE_ETAH( myTime, myIter, myThid ) |
122 |
|
CALL TIMER_STOP ('UPDATE_ETAH [FORWARD_STEP]',mythid) |
123 |
|
ENDIF |
124 |
|
#endif /* EXACT_CONSERV */ |
125 |
|
|
126 |
|
#ifdef NONLIN_FRSURF |
127 |
|
IF ( select_rStar.NE.0 ) THEN |
128 |
|
C-- r* : compute the future level thickness according to etaH(n+1) |
129 |
|
CALL TIMER_START('CALC_R_STAR [FORWARD_STEP]',mythid) |
130 |
|
CALL CALC_R_STAR(etaH, myTime, myIter, myThid ) |
131 |
|
CALL TIMER_STOP ('CALC_R_STAR [FORWARD_STEP]',mythid) |
132 |
|
ELSEIF ( nonlinFreeSurf.GT.0) THEN |
133 |
|
C-- compute the future surface level thickness according to etaH(n+1) |
134 |
|
CALL TIMER_START('CALC_SURF_DR [FORWARD_STEP]',mythid) |
135 |
|
CALL CALC_SURF_DR(etaH, myTime, myIter, myThid ) |
136 |
|
CALL TIMER_STOP ('CALC_SURF_DR [FORWARD_STEP]',mythid) |
137 |
ENDIF |
ENDIF |
138 |
|
#endif /* NONLIN_FRSURF */ |
139 |
|
|
140 |
|
C-- Load forcing/external data fields. |
141 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
142 |
|
c************************************** |
143 |
|
#include "checkpoint_lev1_directives.h" |
144 |
|
c************************************** |
145 |
#endif |
#endif |
146 |
|
|
147 |
#ifdef ALLOW_SHAP_FILT |
|
148 |
C-- Step forward all tiles, filter and exchange. |
C-- Call external forcing package |
149 |
CALL TIMER_START('SHAP_FILT [FORWARD_STEP]',myThid) |
#ifdef ALLOW_BULK_FORCE |
150 |
CALL SHAP_FILT_APPLY( |
#ifndef DISABLE_DEBUGMODE |
151 |
I gUnm1, gVnm1, gTnm1, gSnm1, |
IF ( useBulkforce ) THEN |
152 |
I myCurrentTime, myCurrentIter, myThid ) |
IF ( debugLevel .GE. debLevB ) |
153 |
CALL TIMER_STOP ('SHAP_FILT [FORWARD_STEP]',myThid) |
& CALL DEBUG_CALL('BULKF_FIELDS_LOAD',myThid) |
154 |
|
#endif |
155 |
|
CALL TIMER_START('BULKF_FIELDS_LOAD[THE_MAIN_LOOP]',mythid) |
156 |
|
CALL BULKF_FIELDS_LOAD( mytime, myiter, mythid ) |
157 |
|
CALL TIMER_STOP ('BULKF_FIELDS_LOAD[THE_MAIN_LOOP]',mythid) |
158 |
|
c calculate qnet and empmr (and wind stress) |
159 |
|
DO bj=myByLo(myThid),myByHi(myThid) |
160 |
|
DO bi=myBxLo(myThid),myBxHi(myThid) |
161 |
|
CALL BULKF_FORCING( bi,bj, mytime, myiter, mythid ) |
162 |
|
ENDDO |
163 |
|
ENDDO |
164 |
|
c Update the tile edges. |
165 |
|
_EXCH_XY_R8(Qnet, mythid) |
166 |
|
_EXCH_XY_R8(EmPmR, mythid) |
167 |
|
CALL EXCH_UV_XY_RS(fu, fv, .TRUE., myThid) |
168 |
|
C _EXCH_XY_R8(fu , mythid) |
169 |
|
C _EXCH_XY_R8(fv , mythid) |
170 |
|
END IF |
171 |
|
#endif /* ALLOW_BULK_FORCE */ |
172 |
|
# ifdef INCLUDE_EXTERNAL_FORCING_PACKAGE |
173 |
|
C NOTE, that although the exf package is part of the |
174 |
|
C distribution, it is not currently maintained, i.e. |
175 |
|
C exf is disabled by default in genmake. |
176 |
|
#ifndef DISABLE_DEBUGMODE |
177 |
|
IF ( debugLevel .GE. debLevB ) |
178 |
|
& CALL DEBUG_CALL('EXF_GETFORCING',myThid) |
179 |
|
#endif |
180 |
|
CALL TIMER_START('EXF_GETFORCING [FORWARD_STEP]',mythid) |
181 |
|
CALL EXF_GETFORCING( mytime, myiter, mythid ) |
182 |
|
CALL TIMER_STOP ('EXF_GETFORCING [FORWARD_STEP]',mythid) |
183 |
|
# else /* INCLUDE_EXTERNAL_FORCING_PACKAGE undef */ |
184 |
|
cph The following IF-statement creates an additional dependency |
185 |
|
cph for the forcing fields requiring additional storing. |
186 |
|
cph Therefore, the IF-statement will be put between CPP-OPTIONS, |
187 |
|
cph assuming that ALLOW_SEAICE has not yet been differentiated. |
188 |
|
# ifdef ALLOW_SEAICE |
189 |
|
IF ( .NOT. useSEAICE ) THEN |
190 |
|
# endif |
191 |
|
#ifndef DISABLE_DEBUGMODE |
192 |
|
IF ( debugLevel .GE. debLevB ) |
193 |
|
& CALL DEBUG_CALL('EXTERNAL_FIELDS_LOAD',myThid) |
194 |
#endif |
#endif |
195 |
|
CALL TIMER_START('EXTERNAL_FIELDS_LOAD[FORWARD_STEP]',mythid) |
196 |
|
CALL EXTERNAL_FIELDS_LOAD( mytime, myiter, mythid ) |
197 |
|
CALL TIMER_STOP ('EXTERNAL_FIELDS_LOAD[FORWARD_STEP]',mythid) |
198 |
|
# ifdef ALLOW_SEAICE |
199 |
|
ENDIF |
200 |
|
# endif |
201 |
|
# endif /* INCLUDE_EXTERNAL_FORCING_PACKAGE */ |
202 |
|
|
203 |
|
#if (defined (ALLOW_ADJOINT_RUN) || defined (ALLOW_TANGENTLINEAR_RUN)) |
204 |
|
c-- Add control vector for forcing and parameter fields |
205 |
|
if ( myiter .EQ. nIter0 ) |
206 |
|
& CALL CTRL_MAP_FORCING (mythid) |
207 |
|
#endif |
208 |
|
|
209 |
|
# ifdef ALLOW_SEAICE |
210 |
|
C-- Call sea ice model to compute forcing/external data fields. In |
211 |
|
C addition to computing prognostic sea-ice variables and diagnosing the |
212 |
|
C forcing/external data fields that drive the ocean model, SEAICE_MODEL |
213 |
|
C also sets theta to the freezing point under sea-ice. The implied |
214 |
|
C surface heat flux is then stored in variable surfaceTendencyTice, |
215 |
|
C which is needed by KPP package (kpp_calc.F and kpp_transport_t.F) |
216 |
|
C to diagnose surface buoyancy fluxes and for the non-local transport |
217 |
|
C term. Because this call precedes model thermodynamics, temperature |
218 |
|
C under sea-ice may not be "exactly" at the freezing point by the time |
219 |
|
C theta is dumped or time-averaged. |
220 |
|
IF ( useSEAICE ) THEN |
221 |
|
#ifndef DISABLE_DEBUGMODE |
222 |
|
IF ( debugLevel .GE. debLevB ) |
223 |
|
& CALL DEBUG_CALL('SEAICE_MODEL',myThid) |
224 |
|
#endif |
225 |
|
CALL TIMER_START('SEAICE_MODEL [FORWARD_STEP]',myThid) |
226 |
|
CALL SEAICE_MODEL( myTime, myIter, myThid ) |
227 |
|
CALL TIMER_STOP ('SEAICE_MODEL [FORWARD_STEP]',myThid) |
228 |
|
ENDIF |
229 |
|
# endif /* ALLOW_SEAICE */ |
230 |
|
|
231 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
232 |
|
# ifdef ALLOW_PTRACERS |
233 |
|
cph this replaces _bibj storing of ptracer within thermodynamics |
234 |
|
CADJ STORE ptracer = comlev1, key = ikey_dynamics |
235 |
|
# endif |
236 |
|
#endif |
237 |
|
C-- Step forward fields and calculate time tendency terms. |
238 |
|
#ifndef DISABLE_DEBUGMODE |
239 |
|
IF ( debugLevel .GE. debLevB ) |
240 |
|
& CALL DEBUG_CALL('THERMODYNAMICS',myThid) |
241 |
|
#endif |
242 |
|
CALL TIMER_START('THERMODYNAMICS [FORWARD_STEP]',mythid) |
243 |
|
CALL THERMODYNAMICS( myTime, myIter, myThid ) |
244 |
|
CALL TIMER_STOP ('THERMODYNAMICS [FORWARD_STEP]',mythid) |
245 |
|
|
246 |
|
C-- do exchanges (needed for DYNAMICS) when using stagger time-step : |
247 |
|
#ifndef DISABLE_DEBUGMODE |
248 |
|
IF ( debugLevel .GE. debLevB ) |
249 |
|
& CALL DEBUG_CALL('DO_STAGGER_FIELDS_EXCH.',myThid) |
250 |
|
#endif |
251 |
|
CALL TIMER_START('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
252 |
|
CALL DO_STAGGER_FIELDS_EXCHANGES( myTime, myIter, myThid ) |
253 |
|
CALL TIMER_STOP ('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
254 |
|
|
255 |
|
#ifdef ALLOW_SHAP_FILT |
256 |
|
IF (useSHAP_FILT .AND. |
257 |
|
& staggerTimeStep .AND. shap_filt_TrStagg ) THEN |
258 |
|
#ifndef DISABLE_DEBUGMODE |
259 |
|
IF ( debugLevel .GE. debLevB ) |
260 |
|
& CALL DEBUG_CALL('SHAP_FILT_APPLY_TS',myThid) |
261 |
|
#endif |
262 |
|
CALL TIMER_START('SHAP_FILT [FORWARD_STEP]',myThid) |
263 |
|
CALL SHAP_FILT_APPLY_TS(gT,gS,myTime+deltaT,myIter+1,myThid) |
264 |
|
CALL TIMER_STOP ('SHAP_FILT [FORWARD_STEP]',myThid) |
265 |
|
ENDIF |
266 |
|
#endif |
267 |
#ifdef ALLOW_ZONAL_FILT |
#ifdef ALLOW_ZONAL_FILT |
268 |
CALL ZONAL_FILT_APPLY( |
IF (useZONAL_FILT .AND. |
269 |
U gUnm1, gVnm1, gTnm1, gSnm1, |
& staggerTimeStep .AND. zonal_filt_TrStagg ) THEN |
270 |
I myThid ) |
#ifndef DISABLE_DEBUGMODE |
271 |
|
IF ( debugLevel .GE. debLevB ) |
272 |
|
& CALL DEBUG_CALL('ZONAL_FILT_APPLY_TS',myThid) |
273 |
#endif |
#endif |
274 |
|
CALL TIMER_START('ZONAL_FILT_APPLY [FORWARD_STEP]',myThid) |
275 |
|
CALL ZONAL_FILT_APPLY_TS( gT, gS, myThid ) |
276 |
|
CALL TIMER_STOP ('ZONAL_FILT_APPLY [FORWARD_STEP]',myThid) |
277 |
|
ENDIF |
278 |
|
#endif |
279 |
|
|
280 |
C-- Do IO if needed. |
C-- Step forward fields and calculate time tendency terms. |
281 |
C Note: |
#ifndef ALLOW_AUTODIFF_TAMC |
282 |
C ===== |
IF ( momStepping ) THEN |
283 |
C At this point model arrays hold U,V,T,S at "time-level" N |
#endif |
284 |
C and cg2d_x at "time-level" N-1/2 where N = I+timeLevBase-1. |
#ifndef DISABLE_DEBUGMODE |
285 |
C By convention this is taken to be the model "state". |
IF ( debugLevel .GE. debLevB ) |
286 |
CALL TIMER_START('I/O (WRITE) [FORWARD_STEP]',myThid) |
& CALL DEBUG_CALL('DYNAMICS',myThid) |
287 |
CALL DO_THE_MODEL_IO( |
#endif |
288 |
& doHalfStep, myCurrentTime, myCurrentIter, myThid ) |
CALL TIMER_START('DYNAMICS [FORWARD_STEP]',mythid) |
289 |
CALL TIMER_STOP ('I/O (WRITE) [FORWARD_STEP]',myThid) |
CALL DYNAMICS( myTime, myIter, myThid ) |
290 |
|
CALL TIMER_STOP ('DYNAMICS [FORWARD_STEP]',mythid) |
291 |
|
#ifndef ALLOW_AUTODIFF_TAMC |
292 |
|
ENDIF |
293 |
|
#endif |
294 |
|
|
295 |
|
#ifdef ALLOW_NONHYDROSTATIC |
296 |
|
C-- Step forward W field in N-H algorithm |
297 |
|
IF ( momStepping .AND. nonHydrostatic ) THEN |
298 |
|
#ifndef DISABLE_DEBUGMODE |
299 |
|
IF ( debugLevel .GE. debLevB ) |
300 |
|
& CALL DEBUG_CALL('CALC_GW',myThid) |
301 |
|
#endif |
302 |
|
CALL TIMER_START('CALC_GW [FORWARD_STEP]',myThid) |
303 |
|
CALL CALC_GW(myThid) |
304 |
|
CALL TIMER_STOP ('CALC_GW [FORWARD_STEP]',myThid) |
305 |
|
ENDIF |
306 |
|
#endif |
307 |
|
|
308 |
IF (.NOT. doHalfStep) THEN |
#ifdef NONLIN_FRSURF |
309 |
|
C-- update hfacC,W,S and recip_hFac according to etaH(n+1) : |
310 |
|
IF ( nonlinFreeSurf.GT.0) THEN |
311 |
|
IF ( select_rStar.GT.0 ) THEN |
312 |
|
CALL TIMER_START('UPDATE_R_STAR [FORWARD_STEP]',myThid) |
313 |
|
CALL UPDATE_R_STAR( myTime, myIter, myThid ) |
314 |
|
CALL TIMER_STOP ('UPDATE_R_STAR [FORWARD_STEP]',myThid) |
315 |
|
ELSE |
316 |
|
CALL TIMER_START('UPDATE_SURF_DR [FORWARD_STEP]',myThid) |
317 |
|
CALL UPDATE_SURF_DR( myTime, myIter, myThid ) |
318 |
|
CALL TIMER_STOP ('UPDATE_SURF_DR [FORWARD_STEP]',myThid) |
319 |
|
ENDIF |
320 |
|
ENDIF |
321 |
|
C- update also CG2D matrix (and preconditioner) |
322 |
|
IF ( momStepping .AND. nonlinFreeSurf.GT.2 ) THEN |
323 |
|
CALL TIMER_START('UPDATE_CG2D [FORWARD_STEP]',myThid) |
324 |
|
CALL UPDATE_CG2D( myTime, myIter, myThid ) |
325 |
|
CALL TIMER_STOP ('UPDATE_CG2D [FORWARD_STEP]',myThid) |
326 |
|
ENDIF |
327 |
|
#endif |
328 |
|
|
329 |
|
C-- Apply Filters to u*,v* before SOLVE_FOR_PRESSURE |
330 |
|
#ifdef ALLOW_SHAP_FILT |
331 |
|
IF (useSHAP_FILT .AND. shap_filt_uvStar) THEN |
332 |
|
CALL TIMER_START('SHAP_FILT [FORWARD_STEP]',myThid) |
333 |
|
IF (implicDiv2Dflow.LT.1.) THEN |
334 |
|
C-- Explicit+Implicit part of the Barotropic Flow Divergence |
335 |
|
C => Filtering of uVel,vVel is necessary |
336 |
|
CALL SHAP_FILT_APPLY_UV( uVel,vVel, |
337 |
|
& myTime+deltaT, myIter+1, myThid ) |
338 |
|
ENDIF |
339 |
|
CALL SHAP_FILT_APPLY_UV( gU,gV,myTime+deltaT,myIter+1,myThid) |
340 |
|
CALL TIMER_STOP ('SHAP_FILT [FORWARD_STEP]',myThid) |
341 |
|
ENDIF |
342 |
|
#endif |
343 |
|
#ifdef ALLOW_ZONAL_FILT |
344 |
|
IF (useZONAL_FILT .AND. zonal_filt_uvStar) THEN |
345 |
|
CALL TIMER_START('ZONAL_FILT_APPLY [FORWARD_STEP]',myThid) |
346 |
|
IF (implicDiv2Dflow.LT.1.) THEN |
347 |
|
C-- Explicit+Implicit part of the Barotropic Flow Divergence |
348 |
|
C => Filtering of uVel,vVel is necessary |
349 |
|
CALL ZONAL_FILT_APPLY_UV( uVel, vVel, myThid ) |
350 |
|
ENDIF |
351 |
|
CALL ZONAL_FILT_APPLY_UV( gU, gV, myThid ) |
352 |
|
CALL TIMER_STOP ('ZONAL_FILT_APPLY [FORWARD_STEP]',myThid) |
353 |
|
ENDIF |
354 |
|
#endif |
355 |
|
|
356 |
C-- Solve elliptic equation(s). |
C-- Solve elliptic equation(s). |
357 |
C Two-dimensional only for conventional hydrostatic or |
C Two-dimensional only for conventional hydrostatic or |
358 |
C three-dimensional for non-hydrostatic and/or IGW scheme. |
C three-dimensional for non-hydrostatic and/or IGW scheme. |
359 |
CALL TIMER_START('SOLVE_FOR_PRESSURE [FORWARD_STEP]',myThid) |
IF ( momStepping ) THEN |
360 |
CALL SOLVE_FOR_PRESSURE( myThid ) |
CALL TIMER_START('SOLVE_FOR_PRESSURE [FORWARD_STEP]',myThid) |
361 |
CALL TIMER_STOP ('SOLVE_FOR_PRESSURE [FORWARD_STEP]',myThid) |
CALL SOLVE_FOR_PRESSURE(myTime, myIter, myThid) |
362 |
|
CALL TIMER_STOP ('SOLVE_FOR_PRESSURE [FORWARD_STEP]',myThid) |
363 |
|
ENDIF |
364 |
|
|
365 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
366 |
|
cph This is needed because convective_adjustment calls |
367 |
|
cph find_rho which may use pressure() |
368 |
|
CADJ STORE totphihyd = comlev1, key = ikey_dynamics |
369 |
|
#endif |
370 |
C-- Correct divergence in flow field and cycle time-stepping |
C-- Correct divergence in flow field and cycle time-stepping |
371 |
C arrays (for all fields) |
C arrays (for all fields) ; update time-counter |
372 |
CALL THE_CORRECTION_STEP(myCurrentTime, myCurrentIter, myThid) |
myIter = nIter0 + iLoop |
373 |
|
myTime = startTime + deltaTClock * float(iLoop) |
374 |
|
CALL TIMER_START('THE_CORRECTION_STEP [FORWARD_STEP]',myThid) |
375 |
|
CALL THE_CORRECTION_STEP(myTime, myIter, myThid) |
376 |
|
CALL TIMER_STOP ('THE_CORRECTION_STEP [FORWARD_STEP]',myThid) |
377 |
|
|
378 |
C-- Do "blocking" sends and receives for tendency "overlap" terms |
C-- Do "blocking" sends and receives for tendency "overlap" terms |
379 |
C CALL TIMER_START('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
c CALL TIMER_START('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
380 |
C CALL DO_GTERM_BLOCKING_EXCHANGES( myThid ) |
c CALL DO_GTERM_BLOCKING_EXCHANGES( myThid ) |
381 |
C CALL TIMER_STOP ('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
c CALL TIMER_STOP ('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
382 |
|
|
383 |
C-- Do "blocking" sends and receives for field "overlap" terms |
C-- Do "blocking" sends and receives for field "overlap" terms |
384 |
CALL TIMER_START('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
CALL TIMER_START('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
385 |
CALL DO_FIELDS_BLOCKING_EXCHANGES( myThid ) |
CALL DO_FIELDS_BLOCKING_EXCHANGES( myThid ) |
386 |
CALL TIMER_STOP ('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
CALL TIMER_STOP ('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
387 |
|
|
388 |
|
cswdptr -- add for seperate timestepping of chemical/biological/forcing |
389 |
|
cswdptr of ptracers --- |
390 |
|
#ifdef ALLOW_GCHEM |
391 |
|
#ifdef PTRACERS_SEPERATE_FORCING |
392 |
|
call GCHEM_FORCING( myTime,myIter,myThid ) |
393 |
|
#endif |
394 |
|
#endif |
395 |
|
cswdptr -- end add --- |
396 |
|
|
397 |
|
|
398 |
|
#ifdef ALLOW_FLT |
399 |
|
C-- Calculate float trajectories |
400 |
|
IF (useFLT) THEN |
401 |
|
CALL TIMER_START('FLOATS [FORWARD_STEP]',myThid) |
402 |
|
CALL FLT_MAIN(myIter,myTime, myThid) |
403 |
|
CALL TIMER_STOP ('FLOATS [FORWARD_STEP]',myThid) |
404 |
|
ENDIF |
405 |
|
#endif |
406 |
|
|
407 |
c myCurrentIter = myCurrentIter + 1 |
#ifndef EXCLUDE_MONITOR |
408 |
c myCurrentTime = myCurrentTime + deltaTClock |
C-- Check status of solution (statistics, cfl, etc...) |
409 |
myCurrentIter = nIter0 + iLoop |
CALL TIMER_START('MONITOR [FORWARD_STEP]',myThid) |
410 |
myCurrentTime = startTime + deltaTClock * float(iLoop) |
CALL MONITOR( myIter, myTime, myThid ) |
411 |
|
CALL TIMER_STOP ('MONITOR [FORWARD_STEP]',myThid) |
412 |
|
#endif /* EXCLUDE_MONITOR */ |
413 |
|
|
414 |
|
C-- Do IO if needed. |
415 |
|
CALL TIMER_START('DO_THE_MODEL_IO [FORWARD_STEP]',myThid) |
416 |
|
CALL DO_THE_MODEL_IO( myTime, myIter, myThid ) |
417 |
|
CALL TIMER_STOP ('DO_THE_MODEL_IO [FORWARD_STEP]',myThid) |
418 |
|
|
419 |
C-- Save state for restarts |
C-- Save state for restarts |
420 |
C Note: |
C Note: (jmc: is it still the case after ckp35 ?) |
421 |
C ===== |
C ===== |
422 |
C Because of the ordering of the timestepping code and |
C Because of the ordering of the timestepping code and |
423 |
C tendency term code at end of loop model arrays hold |
C tendency term code at end of loop model arrays hold |
424 |
C U,V,T,S at "time-level" N but gu, gv, gs, gt, guNM1,... |
C U,V,T,S at "time-level" N but gu, gv, gs, gt, guNM1,... |
425 |
C at "time-level" N+1/2 (guNM1 at "time-level" N+1/2 is |
C at "time-level" N+1/2 (guNM1 at "time-level" N+1/2 is |
426 |
C gu at "time-level" N-1/2) and cg2d_x at "time-level" N+1/2. |
C gu at "time-level" N-1/2) and etaN at "time-level" N+1/2. |
427 |
C where N = I+timeLevBase-1 |
C where N = I+timeLevBase-1 |
428 |
C Thus a checkpoint contains U.0000000000, GU.0000000001 and |
C Thus a checkpoint contains U.0000000000, GU.0000000001 and |
429 |
C cg2d_x.0000000001 in the indexing scheme used for the model |
C etaN.0000000001 in the indexing scheme used for the model |
430 |
C "state" files. This example is referred to as a checkpoint |
C "state" files. This example is referred to as a checkpoint |
431 |
C at time level 1 |
C at time level 1 |
432 |
CALL TIMER_START('I/O (WRITE) [FORWARD_STEP]',myThid) |
CALL TIMER_START('WRITE_CHECKPOINT [FORWARD_STEP]',myThid) |
433 |
CALL WRITE_CHECKPOINT( |
CALL WRITE_CHECKPOINT( |
434 |
& .FALSE., myCurrentTime, myCurrentIter, myThid ) |
& .FALSE., myTime, myIter, myThid ) |
435 |
CALL TIMER_STOP ('I/O (WRITE) [FORWARD_STEP]',myThid) |
CALL TIMER_STOP ('WRITE_CHECKPOINT [FORWARD_STEP]',myThid) |
436 |
|
|
437 |
ENDIF |
#ifndef DISABLE_DEBUGMODE |
438 |
|
IF ( debugLevel .GE. debLevB ) |
439 |
|
& CALL DEBUG_LEAVE('FORWARD_STEP',myThid) |
440 |
|
#endif |
441 |
|
|
|
RETURN |
|
442 |
END |
END |