/[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.45 - (hide annotations) (download)
Sat Dec 28 10:11:10 2002 UTC (21 years, 5 months ago) by dimitri
Branch: MAIN
CVS Tags: checkpoint47i_post, checkpoint47g_post, checkpoint47f_post, checkpoint47h_post
Changes since 1.44: +55 -49 lines
checkpoint47f_post
Merging from release1_p10:
o modifications for using pkg/exf with pkg/seaice
  - pkg/seaice CPP options SEAICE_EXTERNAL_FORCING
    and SEAICE_EXTERNAL_FLUXES
  - pkg/exf CPP options EXF_READ_EVAP and
    EXF_NO_BULK_COMPUTATIONS
  - usage examples are Experiments 8 and 9 in
    verification/lab_sea/README
  - verification/lab_sea default experiment now uses
    pkg/gmredi, pkg/kpp, pkg/seaice, and pkg/exf

1 dimitri 1.45 C $Header: /u/gcmpack/MITgcm/model/src/forward_step.F,v 1.44 2002/12/21 00:33:54 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 heimbach 1.37 # include "EOS.h"
53 heimbach 1.30 # ifdef INCLUDE_EXTERNAL_FORCING_PACKAGE
54     # include "exf_fields.h"
55 dimitri 1.45 # if (defined (ALLOW_BULKFORMULAE) || defined (ALLOW_BULK_FORCE))
56 heimbach 1.30 # include "exf_constants.h"
57     # endif
58     # endif
59     # ifdef ALLOW_OBCS
60     # include "OBCS.h"
61     # endif
62 heimbach 1.12 #endif
63    
64 cnh 1.22 C !LOCAL VARIABLES:
65     C == Routine arguments ==
66 adcroft 1.13 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 heimbach 1.12 integer iloop
75     integer mythid
76     integer myiter
77     _RL mytime
78 dimitri 1.45 #ifdef ALLOW_BULK_FORCE
79 jmc 1.21 INTEGER bi,bj
80 dimitri 1.45 #endif ALLOW_BULK_FORCE
81 heimbach 1.12
82 cnh 1.22 CEOP
83 heimbach 1.12
84     #ifdef ALLOW_AUTODIFF_TAMC
85 dimitri 1.45 C-- Reset the model iteration counter and the model time.
86     myiter = nIter0 + (iloop-1)
87     mytime = startTime + float(iloop-1)*deltaTclock
88 heimbach 1.12 #endif
89    
90 heimbach 1.32 #if (defined (ALLOW_AUTODIFF_TAMC) && defined (ALLOW_AUTODIFF_MONITOR))
91 dimitri 1.45 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     CALL DO_FIELDS_BLOCKING_EXCHANGES( myThid )
99 heimbach 1.16 #endif
100    
101 jmc 1.21 #ifdef EXACT_CONSERV
102     IF (exactConserv) THEN
103     C-- Update etaH(n+1) :
104 heimbach 1.36 CALL TIMER_START('UPDATE_ETAH [FORWARD_STEP]',mythid)
105 jmc 1.35 CALL UPDATE_ETAH( myTime, myIter, myThid )
106 heimbach 1.36 CALL TIMER_STOP ('UPDATE_ETAH [FORWARD_STEP]',mythid)
107 jmc 1.21 ENDIF
108     #endif /* EXACT_CONSERV */
109    
110 jmc 1.18 #ifdef NONLIN_FRSURF
111     C-- compute the future surface level thickness
112 jmc 1.21 C according to etaH(n+1)
113 jmc 1.18 IF ( nonlinFreeSurf.GT.0) THEN
114 heimbach 1.36 CALL TIMER_START('CALC_SURF_DR [FORWARD_STEP]',mythid)
115 jmc 1.21 CALL CALC_SURF_DR(etaH, myTime, myIter, myThid )
116 heimbach 1.36 CALL TIMER_STOP ('CALC_SURF_DR [FORWARD_STEP]',mythid)
117 jmc 1.18 ENDIF
118 jmc 1.21 #endif /* NONLIN_FRSURF */
119 jmc 1.18
120 dimitri 1.45 C-- Load forcing/external data fields.
121 heimbach 1.28 #ifdef ALLOW_AUTODIFF_TAMC
122     c**************************************
123     #include "checkpoint_lev1_directives.h"
124     c**************************************
125 heimbach 1.23 #endif
126 cheisey 1.38
127    
128 heimbach 1.37 C-- Call external forcing package
129 cheisey 1.38 cswdblk -- add ---
130 cheisey 1.40 #ifdef ALLOW_BULK_FORCE
131 cheisey 1.38 CALL TIMER_START('BULKF_FIELDS_LOAD[THE_MAIN_LOOP]',mythid)
132     CALL BULKF_FIELDS_LOAD( mytime, myiter, mythid )
133     CALL TIMER_STOP ('BULKF_FIELDS_LOAD[THE_MAIN_LOOP]',mythid)
134     c calculate qnet and empmr (and wind stress)
135     DO bj=myByLo(myThid),myByHi(myThid)
136     DO bi=myBxLo(myThid),myBxHi(myThid)
137     CALL BULKF_FORCING( bi,bj, mytime, myiter, mythid )
138     ENDDO
139     ENDDO
140     c Update the tile edges.
141     _EXCH_XY_R8(Qnet, mythid)
142     _EXCH_XY_R8(EmPmR, mythid)
143 cheisey 1.43 CALL EXCH_UV_XY_RS(fu, fv, .TRUE., myThid)
144     C _EXCH_XY_R8(fu , mythid)
145     C _EXCH_XY_R8(fv , mythid)
146 cheisey 1.38 cswdblk -- end add ---
147 cheisey 1.42 #else
148 cheisey 1.39 #ifdef INCLUDE_EXTERNAL_FORCING_PACKAGE
149 dimitri 1.45 C NOTE, that although the exf package is part of the
150     C distribution, it is not currently maintained, i.e.
151     C exf is disabled by default in genmake.
152     CALL TIMER_START('EXF_GETFORCING [FORWARD_STEP]',mythid)
153     CALL EXF_GETFORCING( mytime, myiter, mythid )
154     CALL TIMER_STOP ('EXF_GETFORCING [FORWARD_STEP]',mythid)
155 heimbach 1.12 #else
156 dimitri 1.45 IF ( .NOT. useSEAICE ) THEN
157     CALL TIMER_START('EXTERNAL_FIELDS_LOAD[FORWARD_STEP]',mythid)
158     CALL EXTERNAL_FIELDS_LOAD( mytime, myiter, mythid )
159     CALL TIMER_STOP ('EXTERNAL_FIELDS_LOAD[FORWARD_STEP]',mythid)
160     ENDIF
161 heimbach 1.36 #endif /* INCLUDE_EXTERNAL_FORCING_PACKAGE */
162 cheisey 1.38
163 heimbach 1.36 #ifdef ALLOW_SEAICE
164 dimitri 1.45 C-- Call sea ice model to compute forcing/external data fields. In
165     C addition to computing prognostic sea-ice variables and diagnosing the
166     C forcing/external data fields that drive the ocean model, SEAICE_MODEL
167     C also sets theta to the freezing point under sea-ice. The implied
168     C surface heat flux is then stored in variable surfaceTendencyTice,
169     C which is needed by KPP package (kpp_calc.F and kpp_transport_t.F)
170     C to diagnose surface buoyancy fluxes and for the non-local transport
171     C term. Because this call precedes model thermodynamics, temperature
172     C under sea-ice may not be "exactly" at the freezing point by the time
173     C theta is dumped or time-averaged.
174     IF ( useSEAICE ) THEN
175 heimbach 1.36 CALL TIMER_START('SEAICE_MODEL [FORWARD_STEP]',myThid)
176 jmc 1.41 CALL SEAICE_MODEL( myTime, myIter, myThid )
177 heimbach 1.36 CALL TIMER_STOP ('SEAICE_MODEL [FORWARD_STEP]',myThid)
178 dimitri 1.45 ENDIF
179 heimbach 1.36 #endif ALLOW_SEAICE
180 dimitri 1.45 #endif ALLOW_BULK_FORCE
181 adcroft 1.15
182     C-- Step forward fields and calculate time tendency terms.
183 heimbach 1.36 CALL TIMER_START('THERMODYNAMICS [FORWARD_STEP]',mythid)
184 adcroft 1.15 CALL THERMODYNAMICS( myTime, myIter, myThid )
185 heimbach 1.36 CALL TIMER_STOP ('THERMODYNAMICS [FORWARD_STEP]',mythid)
186 jmc 1.35
187     C-- do exchanges (needed for DYNAMICS) when using stagger time-step :
188 heimbach 1.36 CALL TIMER_START('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid)
189 jmc 1.35 CALL DO_STAGGER_FIELDS_EXCHANGES( myTime, myIter, myThid )
190 heimbach 1.36 CALL TIMER_STOP ('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid)
191 jmc 1.24
192     #ifdef ALLOW_SHAP_FILT
193 dimitri 1.45 IF (useSHAP_FILT .AND.
194 jmc 1.27 & staggerTimeStep .AND. shap_filt_TrStagg ) THEN
195 heimbach 1.36 CALL TIMER_START('SHAP_FILT [FORWARD_STEP]',myThid)
196 jmc 1.24 CALL SHAP_FILT_APPLY_TS( gT, gS, myTime, myIter, myThid )
197 heimbach 1.36 CALL TIMER_STOP ('SHAP_FILT [FORWARD_STEP]',myThid)
198 dimitri 1.45 ENDIF
199 jmc 1.24 #endif
200 jmc 1.27 #ifdef ALLOW_ZONAL_FILT
201 dimitri 1.45 IF (useZONAL_FILT .AND.
202 jmc 1.27 & staggerTimeStep .AND. zonal_filt_TrStagg ) THEN
203 heimbach 1.36 CALL TIMER_START('ZONAL_FILT_APPLY [FORWARD_STEP]',myThid)
204 jmc 1.27 CALL ZONAL_FILT_APPLY_TS( gT, gS, myThid )
205 heimbach 1.36 CALL TIMER_STOP ('ZONAL_FILT_APPLY [FORWARD_STEP]',myThid)
206 jmc 1.27 ENDIF
207     #endif
208 heimbach 1.12
209 dimitri 1.45 C-- Step forward fields and calculate time tendency terms.
210     IF ( momStepping ) THEN
211 heimbach 1.36 CALL TIMER_START('DYNAMICS [FORWARD_STEP]',mythid)
212 heimbach 1.12 CALL DYNAMICS( myTime, myIter, myThid )
213 heimbach 1.36 CALL TIMER_STOP ('DYNAMICS [FORWARD_STEP]',mythid)
214 dimitri 1.45 ENDIF
215 heimbach 1.12
216 adcroft 1.1 #ifdef ALLOW_NONHYDROSTATIC
217     C-- Step forward W field in N-H algorithm
218 dimitri 1.45 IF ( momStepping .AND. nonHydrostatic ) THEN
219     CALL TIMER_START('CALC_GW [FORWARD_STEP]',myThid)
220     CALL CALC_GW(myThid)
221     CALL TIMER_STOP ('CALC_GW [FORWARD_STEP]',myThid)
222     ENDIF
223 adcroft 1.1 #endif
224 jmc 1.18
225     #ifdef NONLIN_FRSURF
226 jmc 1.21 C-- update hfacC,W,S and recip_hFac according to etaH(n+1) :
227 jmc 1.18 IF ( nonlinFreeSurf.GT.0) THEN
228 dimitri 1.45 CALL TIMER_START('UPDATE_SURF_DR [FORWARD_STEP]',myThid)
229 jmc 1.18 CALL UPDATE_SURF_DR( myTime, myIter, myThid )
230 heimbach 1.36 CALL TIMER_STOP ('UPDATE_SURF_DR [FORWARD_STEP]',myThid)
231 jmc 1.18 ENDIF
232     C- update also CG2D matrix (and preconditioner)
233 jmc 1.33 IF ( momStepping .AND. nonlinFreeSurf.GT.2 ) THEN
234 dimitri 1.45 CALL TIMER_START('UPDATE_CG2D [FORWARD_STEP]',myThid)
235 jmc 1.18 CALL UPDATE_CG2D( myTime, myIter, myThid )
236 dimitri 1.45 CALL TIMER_STOP ('UPDATE_CG2D [FORWARD_STEP]',myThid)
237 adcroft 1.19 ENDIF
238 jmc 1.18 #endif
239 adcroft 1.1
240 jmc 1.27 C-- Apply Filters to u*,v* before SOLVE_FOR_PRESSURE
241     #ifdef ALLOW_SHAP_FILT
242     IF (useSHAP_FILT .AND. shap_filt_uvStar) THEN
243 heimbach 1.36 CALL TIMER_START('SHAP_FILT [FORWARD_STEP]',myThid)
244 jmc 1.27 CALL SHAP_FILT_APPLY_UV( gUnm1,gVnm1, myTime,myIter,myThid )
245     IF (implicDiv2Dflow.LT.1.) THEN
246     C-- Explicit+Implicit part of the Barotropic Flow Divergence
247     C => Filtering of uVel,vVel is necessary
248     CALL SHAP_FILT_APPLY_UV( uVel,vVel, myTime,myIter,myThid )
249     ENDIF
250 heimbach 1.36 CALL TIMER_STOP ('SHAP_FILT [FORWARD_STEP]',myThid)
251 jmc 1.27 ENDIF
252     #endif
253     #ifdef ALLOW_ZONAL_FILT
254     IF (useZONAL_FILT .AND. zonal_filt_uvStar) THEN
255 heimbach 1.36 CALL TIMER_START('ZONAL_FILT_APPLY [FORWARD_STEP]',myThid)
256 jmc 1.27 CALL ZONAL_FILT_APPLY_UV( gUnm1, gVnm1, myThid )
257     IF (implicDiv2Dflow.LT.1.) THEN
258     C-- Explicit+Implicit part of the Barotropic Flow Divergence
259     C => Filtering of uVel,vVel is necessary
260     CALL ZONAL_FILT_APPLY_UV( uVel, vVel, myThid )
261     ENDIF
262 heimbach 1.36 CALL TIMER_STOP ('ZONAL_FILT_APPLY [FORWARD_STEP]',myThid)
263 jmc 1.27 ENDIF
264     #endif
265 heimbach 1.12
266 adcroft 1.1 C-- Solve elliptic equation(s).
267     C Two-dimensional only for conventional hydrostatic or
268     C three-dimensional for non-hydrostatic and/or IGW scheme.
269 adcroft 1.19 IF ( momStepping ) THEN
270 heimbach 1.36 CALL TIMER_START('SOLVE_FOR_PRESSURE [FORWARD_STEP]',myThid)
271 jmc 1.31 CALL SOLVE_FOR_PRESSURE(myTime, myIter, myThid)
272 heimbach 1.36 CALL TIMER_STOP ('SOLVE_FOR_PRESSURE [FORWARD_STEP]',myThid)
273 adcroft 1.19 ENDIF
274 adcroft 1.1
275 heimbach 1.37 #ifdef ALLOW_AUTODIFF_TAMC
276     cph This is needed because convective_adjustment calls
277     cph find_rho which may use pressure()
278     CADJ STORE pressure = comlev1, key = ikey_dynamics
279     #endif
280 adcroft 1.5 C-- Correct divergence in flow field and cycle time-stepping
281 jmc 1.7 C arrays (for all fields) ; update time-counter
282 heimbach 1.12 myIter = nIter0 + iLoop
283     myTime = startTime + deltaTClock * float(iLoop)
284 heimbach 1.36 CALL TIMER_START('THE_CORRECTION_STEP [FORWARD_STEP]',myThid)
285 heimbach 1.12 CALL THE_CORRECTION_STEP(myTime, myIter, myThid)
286 heimbach 1.36 CALL TIMER_STOP ('THE_CORRECTION_STEP [FORWARD_STEP]',myThid)
287 adcroft 1.5
288 adcroft 1.1 C-- Do "blocking" sends and receives for tendency "overlap" terms
289 heimbach 1.36 c CALL TIMER_START('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid)
290 jmc 1.7 c CALL DO_GTERM_BLOCKING_EXCHANGES( myThid )
291 heimbach 1.36 c CALL TIMER_STOP ('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid)
292 adcroft 1.5
293     C-- Do "blocking" sends and receives for field "overlap" terms
294 heimbach 1.36 CALL TIMER_START('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid)
295 adcroft 1.5 CALL DO_FIELDS_BLOCKING_EXCHANGES( myThid )
296 heimbach 1.36 CALL TIMER_STOP ('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid)
297 adcroft 1.20
298     #ifdef ALLOW_FLT
299     C-- Calculate float trajectories
300     IF (useFLT) THEN
301 heimbach 1.36 CALL TIMER_START('FLOATS [FORWARD_STEP]',myThid)
302 adcroft 1.20 CALL FLT_MAIN(myIter,myTime, myThid)
303 heimbach 1.36 CALL TIMER_STOP ('FLOATS [FORWARD_STEP]',myThid)
304 adcroft 1.20 ENDIF
305     #endif
306 heimbach 1.12
307     #ifndef EXCLUDE_MONITOR
308     C-- Check status of solution (statistics, cfl, etc...)
309 dimitri 1.45 CALL TIMER_START('MONITOR [FORWARD_STEP]',myThid)
310 heimbach 1.12 CALL MONITOR( myIter, myTime, myThid )
311 heimbach 1.36 CALL TIMER_STOP ('MONITOR [FORWARD_STEP]',myThid)
312 heimbach 1.12 #endif /* EXCLUDE_MONITOR */
313 adcroft 1.1
314 jmc 1.7 C-- Do IO if needed.
315 heimbach 1.36 CALL TIMER_START('DO_THE_MODEL_IO [FORWARD_STEP]',myThid)
316 heimbach 1.12 CALL DO_THE_MODEL_IO( myTime, myIter, myThid )
317 heimbach 1.36 CALL TIMER_STOP ('DO_THE_MODEL_IO [FORWARD_STEP]',myThid)
318 adcroft 1.1
319     C-- Save state for restarts
320 jmc 1.7 C Note: (jmc: is it still the case after ckp35 ?)
321 adcroft 1.1 C =====
322     C Because of the ordering of the timestepping code and
323     C tendency term code at end of loop model arrays hold
324     C U,V,T,S at "time-level" N but gu, gv, gs, gt, guNM1,...
325     C at "time-level" N+1/2 (guNM1 at "time-level" N+1/2 is
326 jmc 1.10 C gu at "time-level" N-1/2) and etaN at "time-level" N+1/2.
327 adcroft 1.1 C where N = I+timeLevBase-1
328     C Thus a checkpoint contains U.0000000000, GU.0000000001 and
329 jmc 1.10 C etaN.0000000001 in the indexing scheme used for the model
330 adcroft 1.1 C "state" files. This example is referred to as a checkpoint
331     C at time level 1
332 heimbach 1.36 CALL TIMER_START('WRITE_CHECKPOINT [FORWARD_STEP]',myThid)
333 adcroft 1.1 CALL WRITE_CHECKPOINT(
334 heimbach 1.12 & .FALSE., myTime, myIter, myThid )
335 heimbach 1.36 CALL TIMER_STOP ('WRITE_CHECKPOINT [FORWARD_STEP]',myThid)
336 adcroft 1.1
337     END

  ViewVC Help
Powered by ViewVC 1.1.22