/[MITgcm]/MITgcm/model/src/forward_step.F
ViewVC logotype

Contents of /MITgcm/model/src/forward_step.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.48 - (show annotations) (download)
Sun Jan 26 21:07:25 2003 UTC (21 years, 4 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint48b_post
Changes since 1.47: +15 -5 lines
r* coordinate added in #ifdef NONLIN_FRSURF block.
  (modification to pressure gradient not yet implemented)

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

  ViewVC Help
Powered by ViewVC 1.1.22