/[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.28 - (show annotations) (download)
Fri Jan 11 19:00:43 2002 UTC (22 years, 4 months ago) by heimbach
Branch: MAIN
CVS Tags: checkpoint44
Changes since 1.27: +5 -3 lines
Transfering major checkpoint store directive blocks to
separate header files.
Files are included in the_main_loop (lev3, lev2)
and forward_step (lev1).

1 C $Header: /u/gcmpack/MITgcm/model/src/forward_step.F,v 1.27 2001/12/11 14:58:46 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 #endif
53
54 C !LOCAL VARIABLES:
55 C == Routine arguments ==
56 C note: under the multi-threaded model myiter and
57 C mytime are local variables passed around as routine
58 C arguments. Although this is fiddly it saves the need to
59 C impose additional synchronisation points when they are
60 C updated.
61 C myiter - iteration counter for this thread
62 C mytime - time counter for this thread
63 C mythid - thread number for this instance of the routine.
64 integer iloop
65 integer mythid
66 integer myiter
67 _RL mytime
68 INTEGER bi,bj
69
70 CEOP
71
72
73 #ifdef ALLOW_AUTODIFF_TAMC
74 C-- Reset the model iteration counter and the model time.
75 myiter = nIter0 + (iloop-1)
76 mytime = startTime + float(iloop-1)*deltaTclock
77 #endif
78
79 #ifdef ALLOW_AUTODIFF_TAMC
80 C Include call to a dummy routine. Its adjoint will be
81 C called at the proper place in the adjoint code.
82 C The adjoint routine will print out adjoint values
83 C if requested. The location of the call is important,
84 C it has to be after the adjoint of the exchanges
85 C (DO_GTERM_BLOCKING_EXCHANGES).
86 CALL DUMMY_IN_STEPPING( myTime, myIter, myThid )
87 CALL DO_FIELDS_BLOCKING_EXCHANGES( myThid )
88 #endif
89
90 #ifdef EXACT_CONSERV
91 IF (exactConserv) THEN
92 C-- Update etaH(n+1) :
93 DO bj=myByLo(myThid),myByHi(myThid)
94 DO bi=myBxLo(myThid),myBxHi(myThid)
95 CALL CALC_EXACT_ETA( .FALSE., bi,bj, uVel,vVel,
96 I startTime, nIter0, myThid )
97 ENDDO
98 ENDDO
99 IF (implicDiv2Dflow .NE. 1. _d 0 )
100 & _EXCH_XY_R8(etaH, myThid )
101 ENDIF
102 #endif /* EXACT_CONSERV */
103
104 #ifdef NONLIN_FRSURF
105 C-- compute the future surface level thickness
106 C according to etaH(n+1)
107 IF ( nonlinFreeSurf.GT.0) THEN
108 CALL CALC_SURF_DR(etaH, myTime, myIter, myThid )
109 ENDIF
110 #endif /* NONLIN_FRSURF */
111
112 C-- Load forcing/external data fields.
113 #ifdef INCLUDE_EXTERNAL_FORCING_PACKAGE
114 C NOTE, that although the exf package is part of the
115 C distribution, it is not currently maintained, i.e.
116 C exf is disabled by default in genmake.
117 #ifdef ALLOW_AUTODIFF_TAMC
118 c**************************************
119 #include "checkpoint_lev1_directives.h"
120 c**************************************
121 #endif
122 CALL EXF_GETFORCING( mytime, myiter, mythid )
123 #else
124 CALL TIMER_START('EXTERNAL_FIELDS_LOAD[THE_MAIN_LOOP]',mythid)
125 CALL EXTERNAL_FIELDS_LOAD( mytime, myiter, mythid )
126 CALL TIMER_STOP ('EXTERNAL_FIELDS_LOAD[THE_MAIN_LOOP]',mythid)
127 #endif
128
129 C-- Step forward fields and calculate time tendency terms.
130 CALL TIMER_START('THERMODYNAMICS [THE_MAIN_LOOP]',mythid)
131 CALL THERMODYNAMICS( myTime, myIter, myThid )
132 CALL TIMER_STOP ('THERMODYNAMICS [THE_MAIN_LOOP]',mythid)
133
134 #ifdef ALLOW_SHAP_FILT
135 IF (useSHAP_FILT .AND.
136 & staggerTimeStep .AND. shap_filt_TrStagg ) THEN
137 CALL TIMER_START('SHAP_FILT [THE_MAIN_LOOP]',myThid)
138 CALL SHAP_FILT_APPLY_TS( gT, gS, myTime, myIter, myThid )
139 CALL TIMER_STOP ('SHAP_FILT [THE_MAIN_LOOP]',myThid)
140 ENDIF
141 #endif
142 #ifdef ALLOW_ZONAL_FILT
143 IF (useZONAL_FILT .AND.
144 & staggerTimeStep .AND. zonal_filt_TrStagg ) THEN
145 CALL TIMER_START('ZONAL_FILT_APPLY [THE_MAIN_LOOP]',myThid)
146 CALL ZONAL_FILT_APPLY_TS( gT, gS, myThid )
147 CALL TIMER_STOP ('ZONAL_FILT_APPLY [THE_MAIN_LOOP]',myThid)
148 ENDIF
149 #endif
150
151 C-- Step forward fields and calculate time tendency terms.
152 IF ( momStepping ) THEN
153 CALL TIMER_START('DYNAMICS [THE_MAIN_LOOP]',mythid)
154 CALL DYNAMICS( myTime, myIter, myThid )
155 CALL TIMER_STOP ('DYNAMICS [THE_MAIN_LOOP]',mythid)
156 ENDIF
157
158 #ifdef ALLOW_NONHYDROSTATIC
159 C-- Step forward W field in N-H algorithm
160 IF ( momStepping .AND. nonHydrostatic ) THEN
161 CALL TIMER_START('CALC_GW [THE_MAIN_LOOP]',myThid)
162 CALL CALC_GW(myThid)
163 CALL TIMER_STOP ('CALC_GW [THE_MAIN_LOOP]',myThid)
164 ENDIF
165 #endif
166
167 #ifdef NONLIN_FRSURF
168 C-- update hfacC,W,S and recip_hFac according to etaH(n+1) :
169 IF ( momStepping ) THEN
170 IF ( nonlinFreeSurf.GT.0) THEN
171 CALL UPDATE_SURF_DR( myTime, myIter, myThid )
172 ENDIF
173 C- update also CG2D matrix (and preconditioner)
174 IF ( nonlinFreeSurf.GT.2) THEN
175 CALL UPDATE_CG2D( myTime, myIter, myThid )
176 ENDIF
177 ENDIF
178 #endif
179
180 C-- Apply Filters to u*,v* before SOLVE_FOR_PRESSURE
181 #ifdef ALLOW_SHAP_FILT
182 IF (useSHAP_FILT .AND. shap_filt_uvStar) THEN
183 CALL TIMER_START('SHAP_FILT [THE_MAIN_LOOP]',myThid)
184 CALL SHAP_FILT_APPLY_UV( gUnm1,gVnm1, myTime,myIter,myThid )
185 IF (implicDiv2Dflow.LT.1.) THEN
186 C-- Explicit+Implicit part of the Barotropic Flow Divergence
187 C => Filtering of uVel,vVel is necessary
188 CALL SHAP_FILT_APPLY_UV( uVel,vVel, myTime,myIter,myThid )
189 ENDIF
190 CALL TIMER_STOP ('SHAP_FILT [THE_MAIN_LOOP]',myThid)
191 ENDIF
192 #endif
193 #ifdef ALLOW_ZONAL_FILT
194 IF (useZONAL_FILT .AND. zonal_filt_uvStar) THEN
195 CALL TIMER_START('ZONAL_FILT_APPLY [THE_MAIN_LOOP]',myThid)
196 CALL ZONAL_FILT_APPLY_UV( gUnm1, gVnm1, myThid )
197 IF (implicDiv2Dflow.LT.1.) THEN
198 C-- Explicit+Implicit part of the Barotropic Flow Divergence
199 C => Filtering of uVel,vVel is necessary
200 CALL ZONAL_FILT_APPLY_UV( uVel, vVel, myThid )
201 ENDIF
202 CALL TIMER_STOP ('ZONAL_FILT_APPLY [THE_MAIN_LOOP]',myThid)
203 ENDIF
204 #endif
205
206 C-- Solve elliptic equation(s).
207 C Two-dimensional only for conventional hydrostatic or
208 C three-dimensional for non-hydrostatic and/or IGW scheme.
209 IF ( momStepping ) THEN
210 CALL TIMER_START('SOLVE_FOR_PRESSURE [THE_MAIN_LOOP]',myThid)
211 CALL SOLVE_FOR_PRESSURE( myThid )
212 CALL TIMER_STOP ('SOLVE_FOR_PRESSURE [THE_MAIN_LOOP]',myThid)
213 ENDIF
214
215 C-- Correct divergence in flow field and cycle time-stepping
216 C arrays (for all fields) ; update time-counter
217 myIter = nIter0 + iLoop
218 myTime = startTime + deltaTClock * float(iLoop)
219 CALL TIMER_START('THE_CORRECTION_STEP [THE_MAIN_LOOP]',myThid)
220 CALL THE_CORRECTION_STEP(myTime, myIter, myThid)
221 CALL TIMER_STOP ('THE_CORRECTION_STEP [THE_MAIN_LOOP]',myThid)
222
223 C-- Do "blocking" sends and receives for tendency "overlap" terms
224 c CALL TIMER_START('BLOCKING_EXCHANGES [THE_MAIN_LOOP]',myThid)
225 c CALL DO_GTERM_BLOCKING_EXCHANGES( myThid )
226 c CALL TIMER_STOP ('BLOCKING_EXCHANGES [THE_MAIN_LOOP]',myThid)
227
228 C-- Do "blocking" sends and receives for field "overlap" terms
229 CALL TIMER_START('BLOCKING_EXCHANGES [THE_MAIN_LOOP]',myThid)
230 CALL DO_FIELDS_BLOCKING_EXCHANGES( myThid )
231 CALL TIMER_STOP ('BLOCKING_EXCHANGES [THE_MAIN_LOOP]',myThid)
232
233 #ifdef ALLOW_FLT
234 C-- Calculate float trajectories
235 IF (useFLT) THEN
236 CALL TIMER_START('FLOATS [THE_MAIN_LOOP]',myThid)
237 CALL FLT_MAIN(myIter,myTime, myThid)
238 CALL TIMER_STOP ('FLOATS [THE_MAIN_LOOP]',myThid)
239 ENDIF
240 #endif
241
242 #ifndef EXCLUDE_MONITOR
243 C-- Check status of solution (statistics, cfl, etc...)
244 CALL MONITOR( myIter, myTime, myThid )
245 #endif /* EXCLUDE_MONITOR */
246
247 #ifndef ALLOW_AUTODIFF_TAMC
248 C-- Do IO if needed.
249 CALL TIMER_START('DO_THE_MODEL_IO [THE_MAIN_LOOP]',myThid)
250 CALL DO_THE_MODEL_IO( myTime, myIter, myThid )
251 CALL TIMER_STOP ('DO_THE_MODEL_IO [THE_MAIN_LOOP]',myThid)
252
253 C-- Save state for restarts
254 C Note: (jmc: is it still the case after ckp35 ?)
255 C =====
256 C Because of the ordering of the timestepping code and
257 C tendency term code at end of loop model arrays hold
258 C U,V,T,S at "time-level" N but gu, gv, gs, gt, guNM1,...
259 C at "time-level" N+1/2 (guNM1 at "time-level" N+1/2 is
260 C gu at "time-level" N-1/2) and etaN at "time-level" N+1/2.
261 C where N = I+timeLevBase-1
262 C Thus a checkpoint contains U.0000000000, GU.0000000001 and
263 C etaN.0000000001 in the indexing scheme used for the model
264 C "state" files. This example is referred to as a checkpoint
265 C at time level 1
266 CALL TIMER_START('WRITE_CHECKPOINT [THE_MAIN_LOOP]',myThid)
267 CALL WRITE_CHECKPOINT(
268 & .FALSE., myTime, myIter, myThid )
269 CALL TIMER_STOP ('WRITE_CHECKPOINT [THE_MAIN_LOOP]',myThid)
270
271 #endif /* ALLOW_AUTODIFF_TAMC */
272
273 END

  ViewVC Help
Powered by ViewVC 1.1.22