/[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.11 by heimbach, Tue Apr 10 22:35:25 2001 UTC revision 1.12 by heimbach, Fri Jul 13 20:14:08 2001 UTC
# Line 1  Line 1 
 C $Header$  
 C $Name$  
1    
2  #include "CPP_OPTIONS.h"  #include "CPP_OPTIONS.h"
3    
4        SUBROUTINE FORWARD_STEP(        subroutine forward_step( iloop, mytime, myiter, mythid )
5       I                    iLoop,  
6       U                    myCurrentTime, myCurrentIter,  c     ==================================================================
7       &                    myThid)  c     SUBROUTINE forward_step
8  C     /==========================================================\  c     ==================================================================
9  C     | SUBROUTINE FORWARD_STEP                                  |  c
10  C     | o Does one instance of the model time stepping           |  c     o Run the ocean model and evaluate the specified cost function.
11  C     |   The time stepping loop in THE_MAIN_LOOP() calls        |  c
12  C     |   this routine                                           |  c     *the_main_loop* is the toplevel routine for the Tangent Linear and
13  C     |==========================================================|  c     Adjoint Model Compiler (TAMC). For this purpose the initialization
14  C     \==========================================================/  c     of the model was split into two parts. Those parameters that do
15        IMPLICIT NONE  c     not depend on a specific model run are set in *initialise_fixed*,
16  C  c     whereas those that do depend on the specific realization are
17  C     Call Tree  c     initialized in *initialise_varia*.
18  C     =========  c     This routine is to be used in conjuction with the MITgcmuv
19  C      c     checkpoint 37.
20  C      THE_MAIN_LOOP()  c
21  C       |  c     ==================================================================
22  C  ==>  | ** Time stepping loop starts here **  c     SUBROUTINE forward_step
23  C  |    |  c     ==================================================================
24  C /|\   |-FORWARD_STEP  
25  C  |    |  |        implicit none
26  C /|\   |  |--LOAD_EXTERNAL_DATA  
27  C  |    |  |   o Load and/or set time dependent forcing fields  c     == global variables ==
 C /|\   |  |  
 C  |    |  |--DYNAMICS  
 C /|\   |  |   o Evaluate "forward" terms  
 C  |    |  |  
 C /|\   |  |  
 C  |    |  |--SOLVE_FOR_PRESSURE  
 C /|\   |  |   o Find pressure field to keep flow non-divergent  
 C  |    |  |  
 C /|\   |  |  
 C  |    |  |--THE_CORRECTION_STEP  
 C /|\   |  |   o Correct flow field with pressure gradient  
 C  |    |  |     and cycle time-stepping arrays (for all fields)  
 C /|\   |  |  
 C  |    |  |--DO_GTERM_BLOCKING_EXCHANGES  
 C /|\   |  |   o Update overlap regions  
 C  |    |  |  
 C /|\   |  |  
 C  |    |  |--DO_THE_MODEL_IO  
 C /|\   |  |   o Write model state  
 C  |    |  |  
 C /|\   |  |  
 C  |    |  |--WRITE_CHECKPOINT  
 C /|\   |  |   o Write restart file(s)  
 C  |    |  
 C /|\   |  
 C  |<== | ** Time stepping loop finishes here **  
 C  
28    
 C     == Global variables ===  
29  #include "SIZE.h"  #include "SIZE.h"
30  #include "EEPARAMS.h"  #include "EEPARAMS.h"
31  #include "PARAMS.h"  #include "PARAMS.h"
32  #include "DYNVARS.h"  #include "DYNVARS.h"
33    #include "FFIELDS.h"
34    #include "TR1.h"
35    
36  #ifdef ALLOW_NONHYDROSTATIC  #ifdef ALLOW_NONHYDROSTATIC
37  #include "CG3D.h"  #include "CG3D.h"
38  #endif  #endif
39    
40  C     == Routine arguments ==  #ifdef ALLOW_AUTODIFF_TAMC
41  C     iLoop         - Invocation count (counter in THE_MAIN_LOOP)  #include "tamc.h"
42  C     myCurrentIter - Iteration counter for this thread  #include "ctrl.h"
43  C     myCurrentTime - Time counter for this thread  #include "ctrl_dummy.h"
44  C     myThid - Thread number for this instance of the routine.  #include "cost.h"
45        INTEGER iLoop  #endif
46        INTEGER myCurrentIter  
47        _RL     myCurrentTime  c     == routine arguments ==
48        INTEGER myThid    c     note: under the multi-threaded model myiter and
49    c           mytime are local variables passed around as routine
50  C     == Local variables ==  c           arguments. Although this is fiddly it saves the need to
51    c           impose additional synchronisation points when they are
52  C--   Load forcing/external data fields  c           updated.
53        CALL TIMER_START('I/O (READ)         [FORWARD_STEP]',myThid)  c     myiter - iteration counter for this thread
54        CALL EXTERNAL_FIELDS_LOAD( myCurrentTime, myCurrentIter, myThid )  c     mytime - time counter for this thread
55        CALL TIMER_STOP ('I/O (READ)         [FORWARD_STEP]',myThid)  c     mythid - thread number for this instance of the routine.
56          integer iloop
57  C--   Step forward fields and calculate time tendency terms        integer mythid
58        CALL TIMER_START('DYNAMICS           [FORWARD_STEP]',myThid)        integer myiter
59        CALL DYNAMICS( myCurrentTime, myCurrentIter, myThid )        _RL     mytime
60        CALL TIMER_STOP ('DYNAMICS           [FORWARD_STEP]',myThid)  
61    c     == local variables ==
62    
63    c--   == end of interface ==
64    
65    c--     >>> Loop body start <<<
66    
67    #ifdef ALLOW_AUTODIFF_TAMC
68    c--     Set the model iteration counter and the model time.
69            myiter = nIter0 + (iloop-1)
70            mytime = startTime + float(iloop-1)*deltaTclock
71    
72    c       Include call to a dummy routine. Its adjoint will be
73    c       called at the proper place in the adjoint code.
74    c       The adjoint routine will print out adjoint values
75    c       if requested. The location of the call is important,
76    c       it has to be after the adjoint of the exchanges
77    c       (DO_GTERM_BLOCKING_EXCHANGES).
78            call dummy_in_stepping( myTime, myIter, myThid )
79    #endif
80    
81    c--     Load forcing/external data fields.
82    #ifdef INCLUDE_EXTERNAL_FORCING_PACKAGE
83    c       NOTE, that although the exf package is part of the
84    c       distribution, it is not currently maintained, i.e.
85    c       exf is disabled by default in genmake.
86            CALL EXF_GETFORCING( mytime, myiter, mythid )
87    #else
88            CALL TIMER_START('EXTERNAL_FIELDS_LOAD[THE_MAIN_LOOP]',mythid)
89            CALL EXTERNAL_FIELDS_LOAD( mytime, myiter, mythid )
90            CALL TIMER_STOP ('EXTERNAL_FIELDS_LOAD[THE_MAIN_LOOP]',mythid)
91    #endif
92    
93    c--     Step forward fields and calculate time tendency terms.
94            CALL TIMER_START('DYNAMICS            [THE_MAIN_LOOP]',mythid)
95            CALL DYNAMICS( myTime, myIter, myThid )
96            CALL TIMER_STOP ('DYNAMICS            [THE_MAIN_LOOP]',mythid)
97    
98    #ifndef ALLOW_AUTODIFF_TAMC
99    
100  #ifdef ALLOW_NONHYDROSTATIC  #ifdef ALLOW_NONHYDROSTATIC
101  C--   Step forward W field in N-H algorithm  C--   Step forward W field in N-H algorithm
102        IF ( nonHydrostatic ) THEN          IF ( nonHydrostatic ) THEN
103         CALL TIMER_START('CALC_GW            [FORWARD_STEP]',myThid)            CALL TIMER_START('CALC_GW          [THE_MAIN_LOOP]',myThid)
104         CALL CALC_GW( myThid)            CALL CALC_GW(myThid)
105         CALL TIMER_STOP ('CALC_GW            [FORWARD_STEP]',myThid)            CALL TIMER_STOP ('CALC_GW          [THE_MAIN_LOOP]',myThid)
106        ENDIF          ENDIF
107  #endif  #endif
108    
109  #ifdef ALLOW_SHAP_FILT  #ifdef ALLOW_SHAP_FILT
110  C--   Step forward all tiles, filter and exchange.  C--   Step forward all tiles, filter and exchange.
111        CALL TIMER_START('SHAP_FILT          [FORWARD_STEP]',myThid)        CALL TIMER_START('SHAP_FILT           [THE_MAIN_LOOP]',myThid)
112        CALL SHAP_FILT_APPLY(        CALL SHAP_FILT_APPLY(
113       I                     gUnm1, gVnm1, gTnm1, gSnm1,       I                     gUnm1, gVnm1, gTnm1, gSnm1,
114       I                     myCurrentTime, myCurrentIter, myThid )       I                     myTime, myIter, myThid )
115        IF (implicDiv2Dflow.LT.1.) THEN        IF (implicDiv2Dflow.LT.1.) THEN
116  C--   Explicit+Implicit part of the Barotropic Flow Divergence  C--   Explicit+Implicit part of the Barotropic Flow Divergence
117  C      => Filtering of uVel,vVel is necessary  C      => Filtering of uVel,vVel is necessary
118           CALL SHAP_FILT_UV( uVel, vVel, myCurrentTime, myThid )           CALL SHAP_FILT_UV( uVel, vVel, myTime, myThid )
119        ENDIF        ENDIF
120        CALL TIMER_STOP ('SHAP_FILT          [FORWARD_STEP]',myThid)        CALL TIMER_STOP ('SHAP_FILT           [THE_MAIN_LOOP]',myThid)
121  #endif  #endif
122    
123  #ifdef ALLOW_ZONAL_FILT  #ifdef ALLOW_ZONAL_FILT
124        IF (zonal_filt_lat.LT.90.) THEN        IF (zonal_filt_lat.LT.90.) THEN
125        CALL ZONAL_FILT_APPLY(          CALL TIMER_START('ZONAL_FILT_APPLY    [THE_MAIN_LOOP]',myThid)
126            CALL ZONAL_FILT_APPLY(
127       U           gUnm1, gVnm1, gTnm1, gSnm1,       U           gUnm1, gVnm1, gTnm1, gSnm1,
128       I           myThid )       I           myThid )
129            CALL TIMER_STOP ('ZONAL_FILT_APPLY    [THE_MAIN_LOOP]',myThid)
130        ENDIF        ENDIF
131  #endif  #endif
132    
133    #endif /* ALLOW_AUTODIFF_TAMC */
134    
135  C--   Solve elliptic equation(s).  C--   Solve elliptic equation(s).
136  C     Two-dimensional only for conventional hydrostatic or  C     Two-dimensional only for conventional hydrostatic or
137  C     three-dimensional for non-hydrostatic and/or IGW scheme.  C     three-dimensional for non-hydrostatic and/or IGW scheme.
138        CALL TIMER_START('SOLVE_FOR_PRESSURE [FORWARD_STEP]',myThid)        CALL TIMER_START('SOLVE_FOR_PRESSURE  [THE_MAIN_LOOP]',myThid)
139        CALL SOLVE_FOR_PRESSURE( myThid )        CALL SOLVE_FOR_PRESSURE( myThid )
140        CALL TIMER_STOP ('SOLVE_FOR_PRESSURE [FORWARD_STEP]',myThid)        CALL TIMER_STOP ('SOLVE_FOR_PRESSURE  [THE_MAIN_LOOP]',myThid)
141    
142  C--   Correct divergence in flow field and cycle time-stepping  C--   Correct divergence in flow field and cycle time-stepping
143  C     arrays (for all fields) ; update time-counter  C     arrays (for all fields) ; update time-counter
144        myCurrentIter = nIter0 + iLoop        myIter = nIter0 + iLoop
145        myCurrentTime = startTime + deltaTClock * float(iLoop)        myTime = startTime + deltaTClock * float(iLoop)
146        CALL THE_CORRECTION_STEP(myCurrentTime, myCurrentIter, myThid)        CALL TIMER_START('THE_CORRECTION_STEP [THE_MAIN_LOOP]',myThid)
147          CALL THE_CORRECTION_STEP(myTime, myIter, myThid)
148          CALL TIMER_STOP ('THE_CORRECTION_STEP [THE_MAIN_LOOP]',myThid)
149    
150  C--   Do "blocking" sends and receives for tendency "overlap" terms  C--   Do "blocking" sends and receives for tendency "overlap" terms
151  c     CALL TIMER_START('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid)  c     CALL TIMER_START('BLOCKING_EXCHANGES  [THE_MAIN_LOOP]',myThid)
152  c     CALL DO_GTERM_BLOCKING_EXCHANGES( myThid )  c     CALL DO_GTERM_BLOCKING_EXCHANGES( myThid )
153  c     CALL TIMER_STOP ('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid)  c     CALL TIMER_STOP ('BLOCKING_EXCHANGES  [THE_MAIN_LOOP]',myThid)
154    
155  C--   Do "blocking" sends and receives for field "overlap" terms  C--   Do "blocking" sends and receives for field "overlap" terms
156        CALL TIMER_START('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid)        CALL TIMER_START('BLOCKING_EXCHANGES  [THE_MAIN_LOOP]',myThid)
157        CALL DO_FIELDS_BLOCKING_EXCHANGES( myThid )        CALL DO_FIELDS_BLOCKING_EXCHANGES( myThid )
158        CALL TIMER_STOP ('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid)        CALL TIMER_STOP ('BLOCKING_EXCHANGES  [THE_MAIN_LOOP]',myThid)
159    
160    #ifndef EXCLUDE_MONITOR
161    C--   Check status of solution (statistics, cfl, etc...)
162          CALL MONITOR( myIter, myTime, myThid )
163    #endif /* EXCLUDE_MONITOR */
164    
165    #ifndef ALLOW_AUTODIFF_TAMC
166  C--   Do IO if needed.  C--   Do IO if needed.
167        CALL TIMER_START('I/O (WRITE)        [FORWARD_STEP]',myThid)        CALL TIMER_START('DO_THE_MODEL_IO     [THE_MAIN_LOOP]',myThid)
168        CALL DO_THE_MODEL_IO(.FALSE.,        CALL DO_THE_MODEL_IO( myTime, myIter, myThid )
169       &                     myCurrentTime, myCurrentIter, myThid )        CALL TIMER_STOP ('DO_THE_MODEL_IO     [THE_MAIN_LOOP]',myThid)
       CALL TIMER_STOP ('I/O (WRITE)        [FORWARD_STEP]',myThid)  
170    
171  C--   Save state for restarts  C--   Save state for restarts
172  C     Note:    (jmc: is it still the case after ckp35 ?)  C     Note:    (jmc: is it still the case after ckp35 ?)
# Line 159  C     Thus a checkpoint contains U.00000 Line 181  C     Thus a checkpoint contains U.00000
181  C     etaN.0000000001 in the indexing scheme used for the model  C     etaN.0000000001 in the indexing scheme used for the model
182  C     "state" files. This example is referred to as a checkpoint  C     "state" files. This example is referred to as a checkpoint
183  C     at time level 1  C     at time level 1
184        CALL TIMER_START('I/O (WRITE)        [FORWARD_STEP]',myThid)        CALL TIMER_START('WRITE_CHECKPOINT    [THE_MAIN_LOOP]',myThid)
185        CALL WRITE_CHECKPOINT(        CALL WRITE_CHECKPOINT(
186       &        .FALSE., myCurrentTime, myCurrentIter, myThid )       &        .FALSE., myTime, myIter, myThid )
187        CALL TIMER_STOP ('I/O (WRITE)        [FORWARD_STEP]',myThid)        CALL TIMER_STOP ('WRITE_CHECKPOINT    [THE_MAIN_LOOP]',myThid)
188    
189    #endif /* ALLOW_AUTODIFF_TAMC */
190    
191    c--           >>> Loop body end <<<
192    
       RETURN  
193        END        END

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

  ViewVC Help
Powered by ViewVC 1.1.22