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

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

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


Revision 1.36 - (hide annotations) (download)
Tue Nov 12 20:39:46 2002 UTC (21 years, 6 months ago) by heimbach
Branch: MAIN
CVS Tags: checkpoint46n_post
Changes since 1.35: +74 -40 lines
Merging from release1_p8 branch:
o external_fields_load:
  - added this routine to TAF list
  - needed to make some common blocks global and additional storing
    along the same lines as exf package (checkpoint_lev?_directives.h)

1 heimbach 1.36 C $Header: /u/gcmpack/MITgcm/model/src/forward_step.F,v 1.35 2002/10/07 16:24:45 jmc Exp $
2 adcroft 1.15 C $Name: $
3 adcroft 1.1
4     #include "CPP_OPTIONS.h"
5    
6 cnh 1.22 CBOP
7     C !ROUTINE: FORWARD_STEP
8     C !INTERFACE:
9 adcroft 1.13 SUBROUTINE FORWARD_STEP( iloop, myTime, myIter, myThid )
10 heimbach 1.12
11 cnh 1.22 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 adcroft 1.1
27 cnh 1.22 C !USES:
28     IMPLICIT NONE
29     C == Global variables ==
30 adcroft 1.1 #include "SIZE.h"
31     #include "EEPARAMS.h"
32     #include "PARAMS.h"
33     #include "DYNVARS.h"
34 heimbach 1.12 #include "FFIELDS.h"
35    
36 adcroft 1.1 #ifdef ALLOW_NONHYDROSTATIC
37     #include "CG3D.h"
38     #endif
39    
40 jmc 1.27 #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 heimbach 1.12 #ifdef ALLOW_AUTODIFF_TAMC
48 heimbach 1.30 # include "tamc.h"
49     # include "ctrl.h"
50     # include "ctrl_dummy.h"
51     # include "cost.h"
52     # ifdef INCLUDE_EXTERNAL_FORCING_PACKAGE
53     # include "exf_fields.h"
54     # ifdef ALLOW_BULKFORMULAE
55     # include "exf_constants.h"
56     # endif
57     # endif
58     # ifdef ALLOW_OBCS
59     # include "OBCS.h"
60     # endif
61 heimbach 1.12 #endif
62    
63 cnh 1.22 C !LOCAL VARIABLES:
64     C == Routine arguments ==
65 adcroft 1.13 C note: under the multi-threaded model myiter and
66     C mytime are local variables passed around as routine
67     C arguments. Although this is fiddly it saves the need to
68     C impose additional synchronisation points when they are
69     C updated.
70     C myiter - iteration counter for this thread
71     C mytime - time counter for this thread
72     C mythid - thread number for this instance of the routine.
73 heimbach 1.12 integer iloop
74     integer mythid
75     integer myiter
76     _RL mytime
77 jmc 1.21 INTEGER bi,bj
78 heimbach 1.12
79 cnh 1.22 CEOP
80 heimbach 1.12
81    
82     #ifdef ALLOW_AUTODIFF_TAMC
83 heimbach 1.14 C-- Reset the model iteration counter and the model time.
84 heimbach 1.12 myiter = nIter0 + (iloop-1)
85     mytime = startTime + float(iloop-1)*deltaTclock
86     #endif
87    
88 heimbach 1.32 #if (defined (ALLOW_AUTODIFF_TAMC) && defined (ALLOW_AUTODIFF_MONITOR))
89 heimbach 1.16 C Include call to a dummy routine. Its adjoint will be
90     C called at the proper place in the adjoint code.
91     C The adjoint routine will print out adjoint values
92     C if requested. The location of the call is important,
93     C it has to be after the adjoint of the exchanges
94     C (DO_GTERM_BLOCKING_EXCHANGES).
95     CALL DUMMY_IN_STEPPING( myTime, myIter, myThid )
96 heimbach 1.26 CALL DO_FIELDS_BLOCKING_EXCHANGES( myThid )
97 heimbach 1.16 #endif
98    
99 jmc 1.21 #ifdef EXACT_CONSERV
100     IF (exactConserv) THEN
101     C-- Update etaH(n+1) :
102 heimbach 1.36 CALL TIMER_START('UPDATE_ETAH [FORWARD_STEP]',mythid)
103 jmc 1.35 CALL UPDATE_ETAH( myTime, myIter, myThid )
104 heimbach 1.36 CALL TIMER_STOP ('UPDATE_ETAH [FORWARD_STEP]',mythid)
105 jmc 1.21 ENDIF
106     #endif /* EXACT_CONSERV */
107    
108 jmc 1.18 #ifdef NONLIN_FRSURF
109     C-- compute the future surface level thickness
110 jmc 1.21 C according to etaH(n+1)
111 jmc 1.18 IF ( nonlinFreeSurf.GT.0) THEN
112 heimbach 1.36 CALL TIMER_START('CALC_SURF_DR [FORWARD_STEP]',mythid)
113 jmc 1.21 CALL CALC_SURF_DR(etaH, myTime, myIter, myThid )
114 heimbach 1.36 CALL TIMER_STOP ('CALC_SURF_DR [FORWARD_STEP]',mythid)
115 jmc 1.18 ENDIF
116 jmc 1.21 #endif /* NONLIN_FRSURF */
117 jmc 1.18
118 adcroft 1.13 C-- Load forcing/external data fields.
119 heimbach 1.28 #ifdef ALLOW_AUTODIFF_TAMC
120     c**************************************
121     #include "checkpoint_lev1_directives.h"
122     c**************************************
123 heimbach 1.23 #endif
124 heimbach 1.36 #ifdef INCLUDE_EXTERNAL_FORCING_PACKAGE
125     C NOTE, that although the exf package is part of the
126     C distribution, it is not currently maintained, i.e.
127     C exf is disabled by default in genmake.
128     IF ( .not. useSEAICE ) THEN
129     CALL TIMER_START('EXF_GETFORCING [FORWARD_STEP]',mythid)
130     CALL EXF_GETFORCING( mytime, myiter, mythid )
131     CALL TIMER_STOP ('EXF_GETFORCING [FORWARD_STEP]',mythid)
132     ENDIF
133 heimbach 1.12 #else
134 heimbach 1.36 IF ( .not. useSEAICE ) THEN
135     CALL TIMER_START('EXTERNAL_FIELDS_LOAD[FORWARD_STEP]',mythid)
136     CALL EXTERNAL_FIELDS_LOAD( mytime, myiter, mythid )
137     CALL TIMER_STOP ('EXTERNAL_FIELDS_LOAD[FORWARD_STEP]',mythid)
138     ENDIF
139     #endif /* INCLUDE_EXTERNAL_FORCING_PACKAGE */
140    
141     #ifdef ALLOW_SEAICE
142     C-- Call sea ice model to compute forcing/external data fields. In
143     C addition to computing prognostic sea-ice variables and diagnosing the
144     C forcing/external data fields that drive the ocean model, SEAICE_MODEL
145     C also sets theta to the freezing point under sea-ice. The implied
146     C surface heat flux is then stored in variable surfaceTendencyTice,
147     C which is needed by KPP package (kpp_calc.F and kpp_transport_t.F)
148     C to diagnose surface buoyancy fluxes and for the non-local transport
149     C term. Because this call precedes model thermodynamics, temperature
150     C under sea-ice may not be "exactly" at the freezing point by the time
151     C theta is dumped or time-averaged.
152     IF ( useSEAICE ) THEN
153     CALL TIMER_START('SEAICE_MODEL [FORWARD_STEP]',myThid)
154     CALL SEAICE_MODEL( myTime, myIter, myThid )
155     CALL TIMER_STOP ('SEAICE_MODEL [FORWARD_STEP]',myThid)
156     ENDIF
157     #endif ALLOW_SEAICE
158 adcroft 1.15
159     C-- Step forward fields and calculate time tendency terms.
160 heimbach 1.36 CALL TIMER_START('THERMODYNAMICS [FORWARD_STEP]',mythid)
161 adcroft 1.15 CALL THERMODYNAMICS( myTime, myIter, myThid )
162 heimbach 1.36 CALL TIMER_STOP ('THERMODYNAMICS [FORWARD_STEP]',mythid)
163 jmc 1.35
164     C-- do exchanges (needed for DYNAMICS) when using stagger time-step :
165 heimbach 1.36 CALL TIMER_START('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid)
166 jmc 1.35 CALL DO_STAGGER_FIELDS_EXCHANGES( myTime, myIter, myThid )
167 heimbach 1.36 CALL TIMER_STOP ('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid)
168 jmc 1.24
169     #ifdef ALLOW_SHAP_FILT
170 jmc 1.27 IF (useSHAP_FILT .AND.
171     & staggerTimeStep .AND. shap_filt_TrStagg ) THEN
172 heimbach 1.36 CALL TIMER_START('SHAP_FILT [FORWARD_STEP]',myThid)
173 jmc 1.24 CALL SHAP_FILT_APPLY_TS( gT, gS, myTime, myIter, myThid )
174 heimbach 1.36 CALL TIMER_STOP ('SHAP_FILT [FORWARD_STEP]',myThid)
175 jmc 1.24 ENDIF
176     #endif
177 jmc 1.27 #ifdef ALLOW_ZONAL_FILT
178     IF (useZONAL_FILT .AND.
179     & staggerTimeStep .AND. zonal_filt_TrStagg ) THEN
180 heimbach 1.36 CALL TIMER_START('ZONAL_FILT_APPLY [FORWARD_STEP]',myThid)
181 jmc 1.27 CALL ZONAL_FILT_APPLY_TS( gT, gS, myThid )
182 heimbach 1.36 CALL TIMER_STOP ('ZONAL_FILT_APPLY [FORWARD_STEP]',myThid)
183 jmc 1.27 ENDIF
184     #endif
185 heimbach 1.12
186 adcroft 1.13 C-- Step forward fields and calculate time tendency terms.
187 adcroft 1.19 IF ( momStepping ) THEN
188 heimbach 1.36 CALL TIMER_START('DYNAMICS [FORWARD_STEP]',mythid)
189 heimbach 1.12 CALL DYNAMICS( myTime, myIter, myThid )
190 heimbach 1.36 CALL TIMER_STOP ('DYNAMICS [FORWARD_STEP]',mythid)
191 adcroft 1.19 ENDIF
192 heimbach 1.12
193 adcroft 1.1 #ifdef ALLOW_NONHYDROSTATIC
194     C-- Step forward W field in N-H algorithm
195 adcroft 1.19 IF ( momStepping .AND. nonHydrostatic ) THEN
196 heimbach 1.36 CALL TIMER_START('CALC_GW [FORWARD_STEP]',myThid)
197 heimbach 1.12 CALL CALC_GW(myThid)
198 heimbach 1.36 CALL TIMER_STOP ('CALC_GW [FORWARD_STEP]',myThid)
199 heimbach 1.12 ENDIF
200 adcroft 1.1 #endif
201 jmc 1.18
202     #ifdef NONLIN_FRSURF
203 jmc 1.21 C-- update hfacC,W,S and recip_hFac according to etaH(n+1) :
204 jmc 1.18 IF ( nonlinFreeSurf.GT.0) THEN
205 heimbach 1.36 CALL TIMER_START('UPDATE_SURF_DR [FORWARD_STEP]',mythid)
206 jmc 1.18 CALL UPDATE_SURF_DR( myTime, myIter, myThid )
207 heimbach 1.36 CALL TIMER_STOP ('UPDATE_SURF_DR [FORWARD_STEP]',myThid)
208 jmc 1.18 ENDIF
209     C- update also CG2D matrix (and preconditioner)
210 jmc 1.33 IF ( momStepping .AND. nonlinFreeSurf.GT.2 ) THEN
211 heimbach 1.36 CALL TIMER_START('UPDATE_CG2D [FORWARD_STEP]',mythid)
212 jmc 1.18 CALL UPDATE_CG2D( myTime, myIter, myThid )
213 heimbach 1.36 CALL TIMER_START('UPDATE_CG2D [FORWARD_STEP]',mythid)
214 adcroft 1.19 ENDIF
215 jmc 1.18 #endif
216 adcroft 1.1
217 jmc 1.27 C-- Apply Filters to u*,v* before SOLVE_FOR_PRESSURE
218     #ifdef ALLOW_SHAP_FILT
219     IF (useSHAP_FILT .AND. shap_filt_uvStar) THEN
220 heimbach 1.36 CALL TIMER_START('SHAP_FILT [FORWARD_STEP]',myThid)
221 jmc 1.27 CALL SHAP_FILT_APPLY_UV( gUnm1,gVnm1, myTime,myIter,myThid )
222     IF (implicDiv2Dflow.LT.1.) THEN
223     C-- Explicit+Implicit part of the Barotropic Flow Divergence
224     C => Filtering of uVel,vVel is necessary
225     CALL SHAP_FILT_APPLY_UV( uVel,vVel, myTime,myIter,myThid )
226     ENDIF
227 heimbach 1.36 CALL TIMER_STOP ('SHAP_FILT [FORWARD_STEP]',myThid)
228 jmc 1.27 ENDIF
229     #endif
230     #ifdef ALLOW_ZONAL_FILT
231     IF (useZONAL_FILT .AND. zonal_filt_uvStar) THEN
232 heimbach 1.36 CALL TIMER_START('ZONAL_FILT_APPLY [FORWARD_STEP]',myThid)
233 jmc 1.27 CALL ZONAL_FILT_APPLY_UV( gUnm1, gVnm1, myThid )
234     IF (implicDiv2Dflow.LT.1.) THEN
235     C-- Explicit+Implicit part of the Barotropic Flow Divergence
236     C => Filtering of uVel,vVel is necessary
237     CALL ZONAL_FILT_APPLY_UV( uVel, vVel, myThid )
238     ENDIF
239 heimbach 1.36 CALL TIMER_STOP ('ZONAL_FILT_APPLY [FORWARD_STEP]',myThid)
240 jmc 1.27 ENDIF
241     #endif
242 heimbach 1.12
243 adcroft 1.1 C-- Solve elliptic equation(s).
244     C Two-dimensional only for conventional hydrostatic or
245     C three-dimensional for non-hydrostatic and/or IGW scheme.
246 adcroft 1.19 IF ( momStepping ) THEN
247 heimbach 1.36 CALL TIMER_START('SOLVE_FOR_PRESSURE [FORWARD_STEP]',myThid)
248 jmc 1.31 CALL SOLVE_FOR_PRESSURE(myTime, myIter, myThid)
249 heimbach 1.36 CALL TIMER_STOP ('SOLVE_FOR_PRESSURE [FORWARD_STEP]',myThid)
250 adcroft 1.19 ENDIF
251 adcroft 1.1
252 adcroft 1.5 C-- Correct divergence in flow field and cycle time-stepping
253 jmc 1.7 C arrays (for all fields) ; update time-counter
254 heimbach 1.12 myIter = nIter0 + iLoop
255     myTime = startTime + deltaTClock * float(iLoop)
256 heimbach 1.36 CALL TIMER_START('THE_CORRECTION_STEP [FORWARD_STEP]',myThid)
257 heimbach 1.12 CALL THE_CORRECTION_STEP(myTime, myIter, myThid)
258 heimbach 1.36 CALL TIMER_STOP ('THE_CORRECTION_STEP [FORWARD_STEP]',myThid)
259 adcroft 1.5
260 adcroft 1.1 C-- Do "blocking" sends and receives for tendency "overlap" terms
261 heimbach 1.36 c CALL TIMER_START('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid)
262 jmc 1.7 c CALL DO_GTERM_BLOCKING_EXCHANGES( myThid )
263 heimbach 1.36 c CALL TIMER_STOP ('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid)
264 adcroft 1.5
265     C-- Do "blocking" sends and receives for field "overlap" terms
266 heimbach 1.36 CALL TIMER_START('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid)
267 adcroft 1.5 CALL DO_FIELDS_BLOCKING_EXCHANGES( myThid )
268 heimbach 1.36 CALL TIMER_STOP ('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid)
269 adcroft 1.20
270     #ifdef ALLOW_FLT
271     C-- Calculate float trajectories
272     IF (useFLT) THEN
273 heimbach 1.36 CALL TIMER_START('FLOATS [FORWARD_STEP]',myThid)
274 adcroft 1.20 CALL FLT_MAIN(myIter,myTime, myThid)
275 heimbach 1.36 CALL TIMER_STOP ('FLOATS [FORWARD_STEP]',myThid)
276 adcroft 1.20 ENDIF
277     #endif
278 heimbach 1.12
279     #ifndef EXCLUDE_MONITOR
280     C-- Check status of solution (statistics, cfl, etc...)
281 heimbach 1.36 CALL TIMER_START('MONITOR [FORWARD_STEP]',mythid)
282 heimbach 1.12 CALL MONITOR( myIter, myTime, myThid )
283 heimbach 1.36 CALL TIMER_STOP ('MONITOR [FORWARD_STEP]',myThid)
284 heimbach 1.12 #endif /* EXCLUDE_MONITOR */
285 adcroft 1.1
286 jmc 1.7 C-- Do IO if needed.
287 heimbach 1.36 CALL TIMER_START('DO_THE_MODEL_IO [FORWARD_STEP]',myThid)
288 heimbach 1.12 CALL DO_THE_MODEL_IO( myTime, myIter, myThid )
289 heimbach 1.36 CALL TIMER_STOP ('DO_THE_MODEL_IO [FORWARD_STEP]',myThid)
290 adcroft 1.1
291     C-- Save state for restarts
292 jmc 1.7 C Note: (jmc: is it still the case after ckp35 ?)
293 adcroft 1.1 C =====
294     C Because of the ordering of the timestepping code and
295     C tendency term code at end of loop model arrays hold
296     C U,V,T,S at "time-level" N but gu, gv, gs, gt, guNM1,...
297     C at "time-level" N+1/2 (guNM1 at "time-level" N+1/2 is
298 jmc 1.10 C gu at "time-level" N-1/2) and etaN at "time-level" N+1/2.
299 adcroft 1.1 C where N = I+timeLevBase-1
300     C Thus a checkpoint contains U.0000000000, GU.0000000001 and
301 jmc 1.10 C etaN.0000000001 in the indexing scheme used for the model
302 adcroft 1.1 C "state" files. This example is referred to as a checkpoint
303     C at time level 1
304 heimbach 1.36 CALL TIMER_START('WRITE_CHECKPOINT [FORWARD_STEP]',myThid)
305 adcroft 1.1 CALL WRITE_CHECKPOINT(
306 heimbach 1.12 & .FALSE., myTime, myIter, myThid )
307 heimbach 1.36 CALL TIMER_STOP ('WRITE_CHECKPOINT [FORWARD_STEP]',myThid)
308 adcroft 1.1
309     END

  ViewVC Help
Powered by ViewVC 1.1.22