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

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

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

revision 1.3 by heimbach, Mon Sep 11 20:54:37 2000 UTC revision 1.105 by heimbach, Thu Nov 11 02:24:20 2004 UTC
# Line 1  Line 1 
1  C $Header$  C $Header$
2    C $Name$
3    
4    #include "PACKAGES_CONFIG.h"
5  #include "CPP_OPTIONS.h"  #include "CPP_OPTIONS.h"
6    
7        SUBROUTINE FORWARD_STEP(  #ifdef ALLOW_GCHEM
8       I                    doHalfStep, iLoop,  # include "GCHEM_OPTIONS.h"
9       U                    myCurrentTime, myCurrentIter,  #endif
10       &                    myThid)  #ifdef ALLOW_OFFLINE
11  C     /==========================================================\  # include "OFFLINE_OPTIONS.h"
12  C     | SUBROUTINE FORWARD_STEP                                  |  #endif
13  C     | o Does one instance of the model time stepping           |  #ifdef ALLOW_GMREDI
14  C     |   The time stepping loop in THE_MAIN_LOOP() calls        |  # include "GMREDI_OPTIONS.h"
15  C     |   this routine                                           |  #endif
16  C     |==========================================================|  
17  C     \==========================================================/  CBOP
18        IMPLICIT NONE  C     !ROUTINE: FORWARD_STEP
19  C  C     !INTERFACE:
20  C     Call Tree        SUBROUTINE FORWARD_STEP( iloop, myTime, myIter, myThid )
21  C     =========  
22  C      C     !DESCRIPTION: \bv
23  C      THE_MAIN_LOOP()  C     *==================================================================
24  C       |  C     | SUBROUTINE forward_step
25  C  ==>  | ** Time stepping loop starts here **  C     | o Run the ocean model and, optionally, evaluate a cost function.
26  C  |    |  C     *==================================================================
27  C /|\   |-FORWARD_STEP  C     |
28  C  |    |  |  C     | THE_MAIN_LOOP is the toplevel routine for the Tangent Linear and
29  C  |    |  |--LOAD_EXTERNAL_DATA  C     | Adjoint Model Compiler (TAMC). For this purpose the initialization
30  C /|\   |  |   o Load and/or set time dependent forcing fields  C     | of the model was split into two parts. Those parameters that do
31  C  |    |  |  C     | not depend on a specific model run are set in INITIALISE_FIXED,  
32  C /|\   |  |--DYNAMICS  C     | whereas those that do depend on the specific realization are
33  C  |    |  |   o Evaluate "forward" terms  C     | initialized in INITIALISE_VARIA.  
34  C /|\   |  |  C     |
35  C  |    |  |--DO_THE_MODEL_IO  C     *==================================================================
36  C /|\   |  |   o Write model state  C     \ev
 C  |    |  |  
 C /|\   |  |--SOLVE_FOR_PRESSURE  
 C  |    |  |   o Find pressure field to keep flow non-divergent  
 C /|\   |  |  
 C  |    |  |--DO_GTERM_BLOCKING_EXCHANGES  
 C /|\   |  |   o Update overlap regions  
 C  |    |  |  
 C /|\   |  |--WRITE_CHECKPOINT  
 C  |    |  |   o Write restart file(s)  
 C /|\   |  
 C  |    |  
 C  |<== | ** Time stepping loop finishes here **  
 C  
37    
38  C     == Global variables ===  C     !USES:
39          IMPLICIT NONE
40    C     == Global variables ==
41  #include "SIZE.h"  #include "SIZE.h"
42  #include "EEPARAMS.h"  #include "EEPARAMS.h"
43  #include "PARAMS.h"  #include "PARAMS.h"
44  #include "DYNVARS.h"  #include "DYNVARS.h"
45  #include "CG2D.h"  
46  #ifdef ALLOW_NONHYDROSTATIC  #ifdef ALLOW_SHAP_FILT
47  #include "CG3D.h"  # include "SHAP_FILT.h"
48    #endif
49    #ifdef ALLOW_ZONAL_FILT
50    # include "ZONAL_FILT.h"
51  #endif  #endif
52    #ifdef COMPONENT_MODULE
53    # include "CPL_PARAMS.h"
54    #endif
55    
56    #ifdef ALLOW_AUTODIFF_TAMC
57    # include "FFIELDS.h"
58    
59    # ifdef ALLOW_NONHYDROSTATIC
60    #  include "CG3D.h"
61    # endif
62    
63    # include "tamc.h"
64    # include "ctrl.h"
65    # include "ctrl_dummy.h"
66    # include "cost.h"
67    # include "EOS.h"
68    # ifdef ALLOW_EXF
69    #  include "exf_fields.h"
70    #  include "exf_clim_fields.h"
71    #  ifdef ALLOW_BULKFORMULAE
72    #   include "exf_constants.h"
73    #  endif
74    # endif
75    # ifdef ALLOW_OBCS
76    #  include "OBCS.h"
77    # endif
78    # ifdef ALLOW_PTRACERS
79    #  include "PTRACERS_SIZE.h"
80    #  include "PTRACERS.h"
81    # endif
82    # ifdef ALLOW_CD_CODE
83    #  include "CD_CODE_VARS.h"
84    # endif
85    # ifdef ALLOW_EBM
86    #  include "EBM.h"
87    # endif
88    # ifdef EXACT_CONSERV
89    #  include "SURFACE.h"
90    # endif
91    # ifdef ALLOW_KPP
92    #  include "KPP.h"
93    # endif
94    # ifdef ALLOW_GMREDI
95    #  include "GMREDI.h"
96    # endif
97    #endif /* ALLOW_AUTODIFF_TAMC */
98    
99    C     !LOCAL VARIABLES:
100  C     == Routine arguments ==  C     == Routine arguments ==
101  C     doHalfStep - If .TRUE. then this is the last half step  C     note: under the multi-threaded model myiter and
102  C     iLoop         - Invocation count (counter in THE_MAIN_LOOP)  C           mytime are local variables passed around as routine
103  C     myCurrentIter - Iteration counter for this thread  C           arguments. Although this is fiddly it saves the need to
104  C     myCurrentTime - Time counter for this thread  C           impose additional synchronisation points when they are
105  C     myThid - Thread number for this instance of the routine.  C           updated.
106        LOGICAL doHalfStep  C     myIter - iteration counter for this thread
107        INTEGER iLoop  C     myTime - time counter for this thread
108        INTEGER myCurrentIter  C     myThid - thread number for this instance of the routine.
109        _RL     myCurrentTime        INTEGER iloop
110        INTEGER myThid          INTEGER myThid
111          INTEGER myIter
112          _RL     myTime
113    
114  C     == Local variables ==  C     == Local variables ==
115          INTEGER myItP1
116    CEOP
117    
118    #ifdef ALLOW_DEBUG
119          IF ( debugLevel .GE. debLevB )
120         &    CALL DEBUG_ENTER('FORWARD_STEP',myThid)
121    #endif
122    
123    #ifdef ALLOW_AUTODIFF_TAMC
124    C--   Reset the model iteration counter and the model time.
125          myiter = nIter0 + (iloop-1)
126          mytime = startTime + float(iloop-1)*deltaTclock
127    #endif
128    
129    #if (defined (ALLOW_AUTODIFF_TAMC) && defined (ALLOW_AUTODIFF_MONITOR))
130    C     Include call to a dummy routine. Its adjoint will be
131    C     called at the proper place in the adjoint code.
132    C     The adjoint routine will print out adjoint values
133    C     if requested. The location of the call is important,
134    C     it has to be after the adjoint of the exchanges
135    C     (DO_GTERM_BLOCKING_EXCHANGES).
136          CALL DUMMY_IN_STEPPING( myTime, myIter, myThid )
137    cph   I've commented this line since it may conflict with MITgcm's adjoint
138    cph   However, need to check whether that's still consistent
139    cph   with the ecco-branch (it should).
140    cph      CALL DO_FIELDS_BLOCKING_EXCHANGES( myThid )
141    #endif
142    
143    #ifdef ALLOW_AUTODIFF_TAMC
144    c**************************************
145    #include "checkpoint_lev1_directives.h"
146    c**************************************
147    #endif
148    
149    C--   Call external forcing package
150    #ifdef ALLOW_BULK_FORCE
151          IF ( useBulkForce ) THEN
152    #ifdef ALLOW_DEBUG
153           IF ( debugLevel .GE. debLevB )
154         &    CALL DEBUG_CALL('BULKF_FIELDS_LOAD',myThid)
155    #endif
156           CALL TIMER_START('BULKF_FORCING      [FORWARD_STEP]',mythid)
157    C-    load all forcing fields at current time
158           CALL BULKF_FIELDS_LOAD( myTime, myIter, myThid )
159    C-    calculate qnet and empmr (and wind stress)
160           CALL BULKF_FORCING( myTime, myIter, myThid )
161           CALL TIMER_STOP ('BULKF_FORCING      [FORWARD_STEP]',mythid)
162          ELSE
163    #endif /* ALLOW_BULK_FORCE */
164    
165    # ifdef ALLOW_EXF
166    #  ifdef ALLOW_DEBUG
167          IF ( debugLevel .GE. debLevB )
168         &    CALL DEBUG_CALL('EXF_GETFORCING',myThid)
169    #  endif
170          CALL TIMER_START('EXF_GETFORCING     [FORWARD_STEP]',mythid)
171          CALL EXF_GETFORCING( mytime, myiter, mythid )
172          CALL TIMER_STOP ('EXF_GETFORCING     [FORWARD_STEP]',mythid)
173    # else /* ALLOW_EXF undef */
174    cph The following IF-statement creates an additional dependency
175    cph for the forcing fields requiring additional storing.
176    cph Therefore, the IF-statement will be put between CPP-OPTIONS,
177    cph assuming that ALLOW_SEAICE has not yet been differentiated.
178    #  if (defined (ALLOW_SEAICE) || defined (ALLOW_EBM))
179          IF ( .NOT. useSEAICE .AND. .NOT. useEBM ) THEN
180    #  endif
181    #ifdef ALLOW_DEBUG
182           IF ( debugLevel .GE. debLevB )
183         &    CALL DEBUG_CALL('EXTERNAL_FIELDS_LOAD',myThid)
184    #endif
185           CALL TIMER_START('EXTERNAL_FIELDS_LOAD[FORWARD_STEP]',mythid)
186           CALL EXTERNAL_FIELDS_LOAD( mytime, myiter, mythid )
187           CALL TIMER_STOP ('EXTERNAL_FIELDS_LOAD[FORWARD_STEP]',mythid)
188    #  if (defined (ALLOW_SEAICE) || defined (ALLOW_EBM))
189          ENDIF
190    #  endif
191    # endif /* ALLOW_EXF */
192    #ifdef ALLOW_BULK_FORCE
193    C--   end of if/else block useBulfforce --
194          ENDIF
195    #endif /* ALLOW_BULK_FORCE */
196    
197    #ifdef ALLOW_AUTODIFF
198    c--   Add control vector for forcing and parameter fields
199          if ( myiter .EQ. nIter0 )
200         &     CALL CTRL_MAP_FORCING (mythid)
201    #endif
202    
203    # ifdef ALLOW_SEAICE
204    C--   Call sea ice model to compute forcing/external data fields.  In
205    C     addition to computing prognostic sea-ice variables and diagnosing the
206    C     forcing/external data fields that drive the ocean model, SEAICE_MODEL
207    C     also sets theta to the freezing point under sea-ice.  The implied
208    C     surface heat flux is then stored in variable surfaceTendencyTice,
209    C     which is needed by KPP package (kpp_calc.F and kpp_transport_t.F)
210    C     to diagnose surface buoyancy fluxes and for the non-local transport
211    C     term.  Because this call precedes model thermodynamics, temperature
212    C     under sea-ice may not be "exactly" at the freezing point by the time
213    C     theta is dumped or time-averaged.
214          IF ( useSEAICE ) THEN
215    #ifdef ALLOW_DEBUG
216             IF ( debugLevel .GE. debLevB )
217         &    CALL DEBUG_CALL('SEAICE_MODEL',myThid)
218    #endif
219             CALL TIMER_START('SEAICE_MODEL       [FORWARD_STEP]',myThid)
220             CALL SEAICE_MODEL( myTime, myIter, myThid )
221             CALL TIMER_STOP ('SEAICE_MODEL       [FORWARD_STEP]',myThid)
222          ENDIF
223    # endif /* ALLOW_SEAICE */
224    
225    #ifdef ALLOW_AUTODIFF_TAMC
226    # ifdef ALLOW_PTRACERS
227    cph this replaces _bibj storing of ptracer within thermodynamics
228    CADJ STORE ptracer  = comlev1, key = ikey_dynamics
229    # endif
230    #endif
231    
232    #ifdef ALLOW_OFFLINE
233            call OFFLINE_FIELDS_LOAD( myTime, myIter, myThid )
234    #endif
235    
236    #ifdef ALLOW_PTRACERS
237    # ifdef ALLOW_GCHEM
238             CALL GCHEM_FIELDS_LOAD( mytime, myiter, mythid )
239    # endif
240    #endif
241    
242    #ifdef COMPONENT_MODULE
243           IF ( useCoupler .AND. cpl_earlyExpImpCall ) THEN
244    C      Post coupling data that I export.
245    C      Read in coupling data that I import.
246             CALL TIMER_START('CPL_EXPORT-IMPORT  [FORWARD_STEP]',myThid)
247             CALL CPL_EXPORT_MY_DATA(       myIter, myTime, myThid )
248             CALL CPL_IMPORT_EXTERNAL_DATA( myIter, myTime, myThid )
249             CALL TIMER_STOP ('CPL_EXPORT-IMPORT  [FORWARD_STEP]',myThid)
250           ENDIF
251    #endif /* COMPONENT_MODULE */
252    
253    #ifdef ALLOW_EBM
254            IF ( useEBM ) THEN
255    # ifdef ALLOW_DEBUG
256             IF ( debugLevel .GE. debLevB )
257         &    CALL DEBUG_CALL('EBM',myThid)
258    # endif
259             CALL TIMER_START('EBM                [FORWARD_STEP]',mythid)
260             CALL EBM_DRIVER ( myTime, myIter, myThid )
261             CALL TIMER_STOP ('EBM                [FORWARD_STEP]',mythid)
262            ENDIF
263    #endif
264    
265    C--     Step forward fields and calculate time tendency terms.
266    
267    #ifdef ALLOW_DEBUG
268           IF ( debugLevel .GE. debLevB )
269         &    CALL DEBUG_CALL('DO_ATMOSPHERIC_PHYS',myThid)
270    #endif
271           CALL TIMER_START('DO_ATMOSPHERIC_PHYS [FORWARD_STEP]',mythid)
272           CALL DO_ATMOSPHERIC_PHYS( myTime, myIter, myThid )
273           CALL TIMER_STOP ('DO_ATMOSPHERIC_PHYS [FORWARD_STEP]',mythid)
274    
275    #ifdef ALLOW_AUTODIFF_TAMC
276    CADJ STORE theta              = comlev1, key = ikey_dynamics
277    CADJ STORE salt               = comlev1, key = ikey_dynamics
278    CADJ STORE totphihyd          = comlev1, key = ikey_dynamics
279    CADJ STORE surfaceforcingtice = comlev1, key = ikey_dynamics
280    # ifdef ALLOW_KPP
281    CADJ STORE uvel               = comlev1, key = ikey_dynamics
282    CADJ STORE vvel               = comlev1, key = ikey_dynamics
283    # endif
284    # ifdef EXACT_CONSERV
285    CADJ STORE empmr              = comlev1, key = ikey_dynamics
286    CADJ STORE pmepr              = comlev1, key = ikey_dynamics
287    # endif
288    #endif /* ALLOW_AUTODIFF_TAMC */
289    
290    #ifndef ALLOW_OFFLINE
291    #ifdef ALLOW_DEBUG
292           IF ( debugLevel .GE. debLevB )
293         &    CALL DEBUG_CALL('DO_OCEANIC_PHYS',myThid)
294    #endif
295           CALL TIMER_START('DO_OCEANIC_PHYS     [FORWARD_STEP]',mythid)
296           CALL DO_OCEANIC_PHYS( myTime, myIter, myThid )
297           CALL TIMER_STOP ('DO_OCEANIC_PHYS     [FORWARD_STEP]',mythid)
298    #endif
299    
300    #ifdef ALLOW_AUTODIFF_TAMC
301    cph needed to be moved here from do_oceanic_physics
302    cph to be visible down the road
303    c
304    CADJ STORE surfaceForcingS    = comlev1, key = ikey_dynamics
305    CADJ STORE surfaceForcingT    = comlev1, key = ikey_dynamics
306    CADJ STORE surfaceForcingTice = comlev1, key = ikey_dynamics
307    ctest(
308    CADJ STORE IVDConvCount       = comlev1, key = ikey_dynamics
309    ctest)
310    # ifdef ALLOW_PTRACERS
311    CADJ STORE surfaceForcingPtr  = comlev1, key = ikey_dynamics
312    # endif
313    c
314    # ifdef ALLOW_GMREDI
315    CADJ STORE Kwx                = comlev1, key = ikey_dynamics
316    CADJ STORE Kwy                = comlev1, key = ikey_dynamics
317    CADJ STORE Kwz                = comlev1, key = ikey_dynamics
318    #  ifdef GM_BOLUS_ADVEC
319    CADJ STORE GM_PsiX            = comlev1, key = ikey_dynamics
320    CADJ STORE GM_PsiY            = comlev1, key = ikey_dynamics
321    #  endif
322    # endif
323    c
324    # ifdef ALLOW_KPP
325    CADJ STORE KPPghat            = comlev1, key = ikey_dynamics
326    CADJ STORE KPPfrac            = comlev1, key = ikey_dynamics
327    CADJ STORE KPPdiffKzS         = comlev1, key = ikey_dynamics
328    CADJ STORE KPPdiffKzT         = comlev1, key = ikey_dynamics
329    # endif
330    #endif /* ALLOW_AUTODIFF_TAMC */
331    
332          IF ( .NOT.staggerTimeStep ) THEN
333    #ifdef ALLOW_DEBUG
334            IF ( debugLevel .GE. debLevB )
335         &    CALL DEBUG_CALL('THERMODYNAMICS',myThid)
336    #endif
337            CALL TIMER_START('THERMODYNAMICS      [FORWARD_STEP]',mythid)
338            CALL THERMODYNAMICS( myTime, myIter, myThid )
339            CALL TIMER_STOP ('THERMODYNAMICS      [FORWARD_STEP]',mythid)
340    C--    if not staggerTimeStep: end
341          ENDIF
342    
343  C--   Load forcing/external data fields  #ifdef COMPONENT_MODULE
344        CALL TIMER_START('I/O (READ)         [FORWARD_STEP]',myThid)         IF ( useCoupler .AND. .NOT.cpl_earlyExpImpCall ) THEN
345        CALL EXTERNAL_FIELDS_LOAD( myCurrentTime, myCurrentIter, myThid )  C      Post coupling data that I export.
346        CALL TIMER_STOP ('I/O (READ)         [FORWARD_STEP]',myThid)  C      Read in coupling data that I import.
347             myItP1 = myIter + 1
348  #ifdef INCLUDE_SHAPIRO_FILTER_CODE           CALL TIMER_START('CPL_EXPORT-IMPORT  [FORWARD_STEP]',myThid)
349  C--   Step forward all tiles, filter and exchange.           CALL CPL_EXPORT_MY_DATA(       myItP1, myTime, myThid )
350        CALL TIMER_START('SHAP_FILT          [FORWARD_STEP]',myThid)           CALL CPL_IMPORT_EXTERNAL_DATA( myItP1, myTime, myThid )
351        CALL SHAP_FILT( myCurrentTime, myCurrentIter, myThid )           CALL TIMER_STOP ('CPL_EXPORT-IMPORT  [FORWARD_STEP]',myThid)
352        CALL TIMER_STOP ('SHAP_FILT          [FORWARD_STEP]',myThid)  # ifndef ALLOW_AIM
353  #endif          IF ( useRealFreshWaterFlux ) THEN
354             CALL OCN_APPLY_IMPORT( .FALSE., myTime, myIter, myThid )
355  C--   Step forward fields and calculate time tendency terms          ENDIF
356        CALL TIMER_START('DYNAMICS           [FORWARD_STEP]',myThid)  # endif
357        CALL DYNAMICS( myCurrentTime, myCurrentIter, myThid )         ENDIF
358        CALL TIMER_STOP ('DYNAMICS           [FORWARD_STEP]',myThid)  #endif /* COMPONENT_MODULE */
359    
360    C--   Step forward fields and calculate time tendency terms.
361    #ifndef ALLOW_OFFLINE
362    #ifndef ALLOW_AUTODIFF_TAMC
363          IF ( momStepping ) THEN
364    #endif
365    #ifdef ALLOW_DEBUG
366            IF ( debugLevel .GE. debLevB )
367         &    CALL DEBUG_CALL('DYNAMICS',myThid)
368    #endif
369            CALL TIMER_START('DYNAMICS            [FORWARD_STEP]',mythid)
370            CALL DYNAMICS( myTime, myIter, myThid )
371            CALL TIMER_STOP ('DYNAMICS            [FORWARD_STEP]',mythid)
372    #ifndef ALLOW_AUTODIFF_TAMC
373          ENDIF
374    #endif
375    #endif
376    
377  #ifdef ALLOW_NONHYDROSTATIC  #ifdef ALLOW_NONHYDROSTATIC
378  C--   Step forward W field in N-H algorithm  C--   Step forward W field in N-H algorithm
379        IF ( nonHydrostatic ) THEN        IF ( momStepping .AND. nonHydrostatic ) THEN
380         CALL TIMER_START('CALC_GW            [FORWARD_STEP]',myThid)  #ifdef ALLOW_DEBUG
381         CALL CALC_GW( myThid)            IF ( debugLevel .GE. debLevB )
382         CALL TIMER_STOP ('CALC_GW            [FORWARD_STEP]',myThid)       &     CALL DEBUG_CALL('CALC_GW',myThid)
383    #endif
384             CALL TIMER_START('CALC_GW          [FORWARD_STEP]',myThid)
385             CALL CALC_GW(myThid)
386             CALL TIMER_STOP ('CALC_GW          [FORWARD_STEP]',myThid)
387        ENDIF        ENDIF
388  #endif  #endif
389    
390  C--   Do IO if needed.  C--   Update time-counter
391  C     Note:        myIter = nIter0 + iLoop
392  C     =====        myTime = startTime + deltaTClock * float(iLoop)
393  C     At this point model arrays hold U,V,T,S  at "time-level" N  
394  C     and cg2d_x at "time-level" N-1/2 where N = I+timeLevBase-1.  C--   Update geometric factors:
395  C     By convention this is taken to be the model "state".  #ifdef NONLIN_FRSURF
396        CALL TIMER_START('I/O (WRITE)        [FORWARD_STEP]',myThid)  C-    update hfacC,W,S and recip_hFac according to etaH(n+1) :
397        CALL DO_THE_MODEL_IO(        IF ( nonlinFreeSurf.GT.0) THEN
398       &        doHalfStep, myCurrentTime, myCurrentIter, myThid )         IF ( select_rStar.GT.0 ) THEN
399        CALL TIMER_STOP ('I/O (WRITE)        [FORWARD_STEP]',myThid)          CALL TIMER_START('UPDATE_R_STAR      [FORWARD_STEP]',myThid)
400            CALL UPDATE_R_STAR( myTime, myIter, myThid )
401            CALL TIMER_STOP ('UPDATE_R_STAR      [FORWARD_STEP]',myThid)
402           ELSE
403            CALL TIMER_START('UPDATE_SURF_DR     [FORWARD_STEP]',myThid)
404            CALL UPDATE_SURF_DR( myTime, myIter, myThid )
405            CALL TIMER_STOP ('UPDATE_SURF_DR     [FORWARD_STEP]',myThid)
406           ENDIF
407          ENDIF
408    C-    update also CG2D matrix (and preconditioner)
409          IF ( momStepping .AND. nonlinFreeSurf.GT.2 ) THEN
410            CALL TIMER_START('UPDATE_CG2D        [FORWARD_STEP]',myThid)
411            CALL UPDATE_CG2D( myTime, myIter, myThid )
412            CALL TIMER_STOP ('UPDATE_CG2D        [FORWARD_STEP]',myThid)
413          ENDIF
414    #endif
415    
416        IF (.NOT. doHalfStep) THEN  C--   Apply Filters to u*,v* before SOLVE_FOR_PRESSURE
417    #ifdef ALLOW_SHAP_FILT
418          IF (useSHAP_FILT .AND. shap_filt_uvStar) THEN
419            CALL TIMER_START('SHAP_FILT           [FORWARD_STEP]',myThid)
420            IF (implicDiv2Dflow.LT.1.) THEN
421    C--   Explicit+Implicit part of the Barotropic Flow Divergence
422    C      => Filtering of uVel,vVel is necessary
423              CALL SHAP_FILT_APPLY_UV( uVel,vVel,
424         &                             myTime, myIter, myThid )
425            ENDIF
426            CALL SHAP_FILT_APPLY_UV( gU,gV,myTime,myIter,myThid)
427            CALL TIMER_STOP ('SHAP_FILT           [FORWARD_STEP]',myThid)
428          ENDIF
429    #endif
430    #ifdef ALLOW_ZONAL_FILT
431          IF (useZONAL_FILT .AND. zonal_filt_uvStar) THEN
432            CALL TIMER_START('ZONAL_FILT_APPLY    [FORWARD_STEP]',myThid)
433            IF (implicDiv2Dflow.LT.1.) THEN
434    C--   Explicit+Implicit part of the Barotropic Flow Divergence
435    C      => Filtering of uVel,vVel is necessary
436              CALL ZONAL_FILT_APPLY_UV( uVel, vVel, myThid )
437            ENDIF
438            CALL ZONAL_FILT_APPLY_UV( gU, gV, myThid )
439            CALL TIMER_STOP ('ZONAL_FILT_APPLY    [FORWARD_STEP]',myThid)
440          ENDIF
441    #endif  
442    
443  C--   Solve elliptic equation(s).  C--   Solve elliptic equation(s).
444  C     Two-dimensional only for conventional hydrostatic or  C     Two-dimensional only for conventional hydrostatic or
445  C     three-dimensional for non-hydrostatic and/or IGW scheme.  C     three-dimensional for non-hydrostatic and/or IGW scheme.
446        CALL TIMER_START('SOLVE_FOR_PRESSURE [FORWARD_STEP]',myThid)  #ifndef ALLOW_OFFLINE
447        CALL SOLVE_FOR_PRESSURE( myThid )        IF ( momStepping ) THEN
448        CALL TIMER_STOP ('SOLVE_FOR_PRESSURE [FORWARD_STEP]',myThid)          CALL TIMER_START('SOLVE_FOR_PRESSURE  [FORWARD_STEP]',myThid)
449            CALL SOLVE_FOR_PRESSURE(myTime, myIter, myThid)
450            CALL TIMER_STOP ('SOLVE_FOR_PRESSURE  [FORWARD_STEP]',myThid)
451          ENDIF
452    #endif
453    
454    C--   Correct divergence in flow field and cycle time-stepping momentum
455    c     IF ( momStepping ) THEN
456    #ifndef ALLOW_OFFLINE
457            CALL TIMER_START('UV_CORRECTION_STEP  [FORWARD_STEP]',myThid)
458            CALL MOMENTUM_CORRECTION_STEP(myTime, myIter, myThid)
459            CALL TIMER_STOP ('UV_CORRECTION_STEP  [FORWARD_STEP]',myThid)
460    #endif
461    c     ENDIF
462    
463    #ifdef EXACT_CONSERV
464          IF (exactConserv) THEN
465    C--   Update etaH(n+1) :
466            CALL TIMER_START('UPDATE_ETAH        [FORWARD_STEP]',mythid)
467            CALL UPDATE_ETAH( myTime, myIter, myThid )
468            CALL TIMER_STOP ('UPDATE_ETAH        [FORWARD_STEP]',mythid)
469          ENDIF
470    #endif /* EXACT_CONSERV */
471    
472    #ifdef NONLIN_FRSURF
473          IF ( select_rStar.NE.0 ) THEN
474    C--   r* : compute the future level thickness according to etaH(n+1)
475            CALL TIMER_START('CALC_R_STAR       [FORWARD_STEP]',mythid)
476            CALL CALC_R_STAR(etaH, myTime, myIter, myThid )
477            CALL TIMER_STOP ('CALC_R_STAR       [FORWARD_STEP]',mythid)
478          ELSEIF ( nonlinFreeSurf.GT.0) THEN
479    C--   compute the future surface level thickness according to etaH(n+1)
480            CALL TIMER_START('CALC_SURF_DR      [FORWARD_STEP]',mythid)
481            CALL CALC_SURF_DR(etaH, myTime, myIter, myThid )
482            CALL TIMER_STOP ('CALC_SURF_DR      [FORWARD_STEP]',mythid)
483          ENDIF
484    #endif /* NONLIN_FRSURF */
485    
486    C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
487          IF ( staggerTimeStep ) THEN
488    C--   do exchanges of U,V (needed for multiDim) when using stagger time-step :
489    #ifdef ALLOW_DEBUG
490            IF ( debugLevel .GE. debLevB )
491         &    CALL DEBUG_CALL('DO_STAGGER_FIELDS_EXCH.',myThid)
492    #endif
493            CALL TIMER_START('BLOCKING_EXCHANGES  [FORWARD_STEP]',myThid)
494            CALL DO_STAGGER_FIELDS_EXCHANGES( myTime, myIter, myThid )
495            CALL TIMER_STOP ('BLOCKING_EXCHANGES  [FORWARD_STEP]',myThid)
496    
497    #ifdef ALLOW_DEBUG
498            IF ( debugLevel .GE. debLevB )
499         &    CALL DEBUG_CALL('THERMODYNAMICS',myThid)
500    #endif
501            CALL TIMER_START('THERMODYNAMICS      [FORWARD_STEP]',mythid)
502            CALL THERMODYNAMICS( myTime, myIter, myThid )
503            CALL TIMER_STOP ('THERMODYNAMICS      [FORWARD_STEP]',mythid)
504    
505    C--    if staggerTimeStep: end
506          ENDIF
507    C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
508    
509    #ifdef ALLOW_AUTODIFF_TAMC
510    cph This is needed because convective_adjustment calls
511    cph find_rho which may use pressure()
512    CADJ STORE totphihyd  = comlev1, key = ikey_dynamics
513    #endif
514    C--   Cycle time-stepping Tracers arrays (T,S,+pTracers)
515            CALL TIMER_START('TS_CORRECTION_STEP  [FORWARD_STEP]',myThid)
516            CALL TRACERS_CORRECTION_STEP(myTime, myIter, myThid)
517            CALL TIMER_STOP ('TS_CORRECTION_STEP  [FORWARD_STEP]',myThid)
518    
519  C--   Do "blocking" sends and receives for tendency "overlap" terms  C--   Do "blocking" sends and receives for tendency "overlap" terms
520        CALL TIMER_START('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid)  c     CALL TIMER_START('BLOCKING_EXCHANGES  [FORWARD_STEP]',myThid)
521        CALL DO_GTERM_BLOCKING_EXCHANGES( myThid )  c     CALL DO_GTERM_BLOCKING_EXCHANGES( myThid )
522        CALL TIMER_STOP ('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid)  c     CALL TIMER_STOP ('BLOCKING_EXCHANGES  [FORWARD_STEP]',myThid)
523    
524  c     myCurrentIter = myCurrentIter + 1  C--   Do "blocking" sends and receives for field "overlap" terms
525  c     myCurrentTime = myCurrentTime + deltaTClock        CALL TIMER_START('BLOCKING_EXCHANGES  [FORWARD_STEP]',myThid)
526        myCurrentIter = nIter0 + iLoop        CALL DO_FIELDS_BLOCKING_EXCHANGES( myThid )
527        myCurrentTime = startTime + deltaTClock * float(iLoop)        CALL TIMER_STOP ('BLOCKING_EXCHANGES  [FORWARD_STEP]',myThid)
528    
529    cswdptr -- add for seperate timestepping of chemical/biological/forcing
530    cswdptr    of ptracers ---
531    #ifdef ALLOW_GCHEM
532    ceh3 This is broken -- this ifdef should not be visible!
533    #ifdef PTRACERS_SEPARATE_FORCING
534    ceh3 needs an IF ( use GCHEM ) THEN
535            call GCHEM_FORCING_SEP( myTime,myIter,myThid )
536    #endif /* PTRACERS_SEPARATE_FORCING */
537    #endif /* ALLOW_GCHEM */
538    cswdptr -- end add ---
539    
540    C AMM
541    #ifdef ALLOW_GRIDALT
542            if (useGRIDALT) then
543             CALL GRIDALT_UPDATE(myThid)
544            endif
545    #endif
546    C AMM
547    
548    C AMM
549    #ifdef ALLOW_FIZHI
550            if( useFIZHI) then
551             CALL TIMER_START('FIZHI               [FORWARD_STEP]',mythid)
552             CALL STEP_FIZHI_CORR ( myTime, myIter, myThid )
553             CALL TIMER_STOP('FIZHI               [FORWARD_STEP]',mythid)
554            endif
555    #endif
556    C AMM
557    
558    #ifdef ALLOW_FLT
559    C--   Calculate float trajectories
560          IF (useFLT) THEN
561            CALL TIMER_START('FLOATS            [FORWARD_STEP]',myThid)
562            CALL FLT_MAIN(myIter,myTime, myThid)
563            CALL TIMER_STOP ('FLOATS            [FORWARD_STEP]',myThid)
564          ENDIF
565    #endif
566    
567    C--   State-variables statistics (time-aver, diagnostics ...)
568          CALL TIMER_START('DO_STATEVARS_DIAGS  [FORWARD_STEP]',myThid)
569          CALL DO_STATEVARS_DIAGS( myTime, myIter, myThid )
570          CALL TIMER_STOP ('DO_STATEVARS_DIAGS  [FORWARD_STEP]',myThid)
571    
572    #ifndef ALLOW_OFFLINE
573    #ifdef ALLOW_MONITOR
574    C--   Check status of solution (statistics, cfl, etc...)
575          CALL TIMER_START('MONITOR             [FORWARD_STEP]',myThid)
576          CALL MONITOR( myIter, myTime, myThid )
577          CALL TIMER_STOP ('MONITOR             [FORWARD_STEP]',myThid)
578    #endif /* ALLOW_MONITOR */
579    #endif
580    
581    #ifdef ALLOW_COST
582    C--     compare model with data and compute cost function
583    C--     this is done after exchanges to allow interpolation
584          CALL TIMER_START('COST_TILE           [FORWARD_STEP]',myThid)
585          CALL COST_TILE  ( mytime, myiter, myThid )
586          CALL TIMER_STOP ('COST_TILE           [FORWARD_STEP]',myThid)
587    #endif
588    
589    C--   Do IO if needed.
590    #ifdef ALLOW_OFFLINE
591          CALL TIMER_START('OFFLINE_MODEL_IO    [FORWARD_STEP]',myThid)
592          CALL OFFLINE_MODEL_IO( myTime, myIter, myThid )
593          CALL TIMER_STOP ('OFFLINE_MODEL_IO    [FORWARD_STEP]',myThid)
594    #else
595          CALL TIMER_START('DO_THE_MODEL_IO     [FORWARD_STEP]',myThid)
596          CALL DO_THE_MODEL_IO( myTime, myIter, myThid )
597          CALL TIMER_STOP ('DO_THE_MODEL_IO     [FORWARD_STEP]',myThid)
598    #endif
599    
600  C--   Save state for restarts  C--   Save state for restarts
601  C     Note:        CALL TIMER_START('WRITE_CHECKPOINT    [FORWARD_STEP]',myThid)
602  C     =====        CALL PACKAGES_WRITE_PICKUP(
603  C     Because of the ordering of the timestepping code and       I               .FALSE., myTime, myIter, myThid )
604  C     tendency term code at end of loop model arrays hold  #ifndef ALLOW_OFFLINE
 C     U,V,T,S  at "time-level" N but gu, gv, gs, gt, guNM1,...  
 C     at "time-level" N+1/2 (guNM1 at "time-level" N+1/2 is  
 C     gu at "time-level" N-1/2) and cg2d_x at "time-level" N+1/2.  
 C      where N = I+timeLevBase-1  
 C     Thus a checkpoint contains U.0000000000, GU.0000000001 and  
 C     cg2d_x.0000000001 in the indexing scheme used for the model  
 C     "state" files. This example is referred to as a checkpoint  
 C     at time level 1  
       CALL TIMER_START('I/O (WRITE)        [FORWARD_STEP]',myThid)  
605        CALL WRITE_CHECKPOINT(        CALL WRITE_CHECKPOINT(
606       &        .FALSE., myCurrentTime, myCurrentIter, myThid )       I               .FALSE., myTime, myIter, myThid )  
607        CALL TIMER_STOP ('I/O (WRITE)        [FORWARD_STEP]',myThid)  #endif
608          CALL TIMER_STOP ('WRITE_CHECKPOINT    [FORWARD_STEP]',myThid)
609    
610        ENDIF  #ifdef ALLOW_DEBUG
611          IF ( debugLevel .GE. debLevB )
612         &    CALL DEBUG_LEAVE('FORWARD_STEP',myThid)
613    #endif
614    
615        RETURN        RETURN
616        END        END

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.105

  ViewVC Help
Powered by ViewVC 1.1.22