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

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

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

revision 1.9 by adcroft, Mon Jun 1 20:36:13 1998 UTC revision 1.24 by adcroft, Wed Dec 9 16:11:54 1998 UTC
# Line 1  Line 1 
1  C $Header$  C $Header$
2    
3  #include "CPP_EEOPTIONS.h"  #include "CPP_OPTIONS.h"
4    
5        SUBROUTINE THE_MODEL_MAIN(myThid)        SUBROUTINE THE_MODEL_MAIN(myThid)
6  C     /==========================================================\  C     /==========================================================\
# Line 22  C     | ===== Line 22  C     | =====
22  C     | C*P* comments indicating place holders for which code is |  C     | C*P* comments indicating place holders for which code is |
23  C     |      presently being developed.                          |  C     |      presently being developed.                          |
24  C     \==========================================================/  C     \==========================================================/
25          IMPLICIT NONE
26    C
27    C     Call Tree
28    C     =========
29    C    
30    C      main ( eesupp )
31    C       |
32    C       .
33    C       .
34    C       . Generic environment initialisation ( see eesupp/src and
35    C       .                                      eesupp/inc )      
36    C       . multiple threads and/or processes are created in here
37    C       .
38    C       .
39    C       .
40    C       |
41    C       |-THE_MODEL_MAIN - Begin specific model. One instance
42    C       |  |               of this codes exists for each thread
43    C       |  |               and/or instance. Each instance manages
44    C       |  |               a specifc set of tiles.              
45    C       |  |
46    C       |  |--INITIALISE
47    C       |  |   o Set initial conditions and model configuration
48    C       |  |     Topography, hydrography, timestep, grid, etc..
49    C       |  |
50    C  ==>  |  | ** Time stepping loop starts here **
51    C  |    |  |
52    C /|\   |  |
53    C  |    |  |--LOAD_EXTERNAL_DATA
54    C /|\   |  |   o Load and/or set time dependent forcing fields
55    C  |    |  |
56    C /|\   |  |--DYNAMICS
57    C  |    |  |   o Evaluate "forward" terms
58    C /|\   |  |
59    C  |    |  |--DO_THE_MODEL_IO
60    C /|\   |  |   o Write model state
61    C  |    |  |
62    C /|\   |  |--SOLVE_FOR_PRESSURE
63    C  |    |  |   o Find pressure field to keep flow non-divergent
64    C /|\   |  |
65    C  |    |  |--DO_GTERM_BLOCKING_EXCHANGES
66    C /|\   |  |   o Update overlap regions
67    C  |    |  |
68    C /|\   |  |--WRITE_CHECKPOINT
69    C  |    |  |   o Write restart file(s)
70    C /|\   |  |
71    C  |    |  |
72    C  |<== |  | ** Time stepping loop finishes here **
73    C       |  |
74    C       |  |--WRITE_STATE
75    C       |  |--WRITE_CHECKPOINT
76    C       |
77    C       .
78    C       .
79    C       . Generic environment termination ( see eesupp/src and
80    C       .                                      eesupp/inc )      
81    C       .
82    C       .
83    
84  C     == Global variables ===  C     == Global variables ===
85  #include "SIZE.h"  #include "SIZE.h"
# Line 29  C     == Global variables === Line 87  C     == Global variables ===
87  #include "PARAMS.h"  #include "PARAMS.h"
88  #include "CG2D.h"  #include "CG2D.h"
89  #include "DYNVARS.h"  #include "DYNVARS.h"
90    #include "AVER.h"
91    
92  C     == Routine arguments ==  C     == Routine arguments ==
93  C     myThid - Thread number for this instance of the routine.  C     myThid - Thread number for this instance of the routine.
# Line 46  C     I             - Loop counter Line 105  C     I             - Loop counter
105        INTEGER I, myCurrentIter        INTEGER I, myCurrentIter
106        REAL    myCurrentTime        REAL    myCurrentTime
107    
108    C--   This timer encompasses the whole code
109          CALL TIMER_START('ALL',myThid)
110    
111          CALL TIMER_START('SPIN-UP',myThid)
112    
113  C--   Set model initial conditions  C--   Set model initial conditions
114          CALL TIMER_START('INITIALISE          [SPIN-UP]',myThid)
115        CALL INITIALISE( myThid )        CALL INITIALISE( myThid )
116        myCurrentTime = startTime        myCurrentTime = startTime
117        myCurrentIter = nIter0        myCurrentIter = nIter0
118          CALL TIMER_STOP ('INITIALISE          [SPIN-UP]',myThid)
119    
120    C--   Dump for start state
121          CALL TIMER_START('I/O (WRITE)         [SPIN-UP]',myThid)
122          CALL WRITE_STATE( .TRUE., myCurrentTime, myCurrentIter, myThid )
123          CALL TIMER_STOP ('I/O (WRITE)         [SPIN-UP]',myThid)
124    
125  C--   Initialise time-stepping (predictor variables are carried in G)        CALL TIMER_STOP ('SPIN-UP',myThid)
       CALL INIT_PREDICTOR( myThid )  
126    
127  C--   Begin time stepping loop  C--   Begin time stepping loop
128          CALL TIMER_START('MAIN LOOP',myThid)
129        DO I=1, nTimeSteps        DO I=1, nTimeSteps
130    
131  C--    Load offline tracer fields  C--    Load forcing/external data fields
132         IF ( MOD(myCurrentIter,numStepsPerPickup) .EQ. 1 ) THEN         CALL TIMER_START('I/O (READ)         [MAIN LOOP]',myThid)
133  C       I/O         CALL LOAD_EXTERNAL_FIELDS( myCurrentTime, myCurrentIter, myThid )
134  C       o Writes to arrays are performed by their own thread (to ensure         CALL TIMER_STOP ('I/O (READ)         [MAIN LOOP]',myThid)
135  C         physical memory allocation will pair with thread).  
136  C       o Thread 1 reads into a buffer.  #ifdef INCLUDE_SHAPIRO_FILTER_CODE
137  C       CALL LOAD_OFFLINE_FIELDS( myCurrentTime, myCurrentIter, myThid )  C--    Step forward all tiles, filter and exchange.
138           CALL TIMER_START('SHAP_FILT          [MAIN LOOP]',myThid)
139           CALL SHAP_FILT( myCurrentTime, myCurrentIter, myThid )
140           CALL TIMER_STOP ('SHAP_FILT          [MAIN LOOP]',myThid)
141    #endif
142    
143    C--    Set Open Boundaries Values
144           IF (openBoundaries) THEN
145            CALL TIMER_START('OBCS               [MAIN LOOP]',myThid)
146            CALL SET_OBCS( myCurrentTime, myThid )
147            CALL TIMER_STOP ('OBCS               [MAIN LOOP]',myThid)
148         ENDIF         ENDIF
149    
150  C--    Step forward fields and calculate time tendency terms  C--    Step forward fields and calculate time tendency terms
151           CALL TIMER_START('DYNAMICS           [MAIN LOOP]',myThid)
152         CALL DYNAMICS( myCurrentTime, myCurrentIter, myThid )         CALL DYNAMICS( myCurrentTime, myCurrentIter, myThid )
153           CALL TIMER_STOP ('DYNAMICS           [MAIN LOOP]',myThid)
154    
155    C--    Do time averages
156    #ifdef INCLUDE_DIAGNOSTICS_INTERFACE_CODE
157           CALL TIMER_START('I/O (WRITE)        [MAIN LOOP]',myThid)
158           IF (taveFreq.GT.0.) THEN
159            CALL WRITE_TIME_AVERAGES( myCurrentTime, myCurrentIter, myThid )
160           ENDIF
161           CALL TIMER_STOP ('I/O (WRITE)        [MAIN LOOP]',myThid)
162    #endif
163    
164  C--    Do IO if needed.  C--    Do IO if needed.
165  C      Note:  C      Note:
# Line 75  C      ===== Line 167  C      =====
167  C      At this point model arrays hold U,V,T,S  at "time-level" N  C      At this point model arrays hold U,V,T,S  at "time-level" N
168  C      and cg2d_x at "time-level" N-1/2 where N = I+timeLevBase-1.  C      and cg2d_x at "time-level" N-1/2 where N = I+timeLevBase-1.
169  C      By convention this is taken to be the model "state".  C      By convention this is taken to be the model "state".
170           CALL TIMER_START('I/O (WRITE)        [MAIN LOOP]',myThid)
171         CALL DO_THE_MODEL_IO( myCurrentTime, myCurrentIter, myThid )         CALL DO_THE_MODEL_IO( myCurrentTime, myCurrentIter, myThid )
172           CALL TIMER_STOP ('I/O (WRITE)        [MAIN LOOP]',myThid)
173    
174  C--    Solve elliptic equation(s).  C--    Solve elliptic equation(s).
175  C      Two-dimensional only for conventional hydrostatic or  C      Two-dimensional only for conventional hydrostatic or
176  C      three-dimensional for non-hydrostatic and/or IGW scheme.  C      three-dimensional for non-hydrostatic and/or IGW scheme.
177           CALL TIMER_START('SOLVE_FOR_PRESSURE [MAIN LOOP]',myThid)
178         CALL SOLVE_FOR_PRESSURE( myThid )         CALL SOLVE_FOR_PRESSURE( myThid )
179           CALL TIMER_STOP ('SOLVE_FOR_PRESSURE [MAIN LOOP]',myThid)
180    
181  C--    Do "blocking" sends and receives for tendency "overlap" terms  C--    Do "blocking" sends and receives for tendency "overlap" terms
182           CALL TIMER_START('BLOCKING_EXCHANGES [MAIN LOOP]',myThid)
183         CALL DO_GTERM_BLOCKING_EXCHANGES( myThid )         CALL DO_GTERM_BLOCKING_EXCHANGES( myThid )
184           CALL TIMER_STOP ('BLOCKING_EXCHANGES [MAIN LOOP]',myThid)
185    
186         myCurrentIter = myCurrentIter + 1         myCurrentIter = myCurrentIter + 1
187         myCurrentTime = myCurrentTime + deltaTClock         myCurrentTime = myCurrentTime + deltaTClock
# Line 91  C--    Do "blocking" sends and receives Line 189  C--    Do "blocking" sends and receives
189  C--    Save state for restarts  C--    Save state for restarts
190  C      Note:  C      Note:
191  C      =====  C      =====
192  C      Because of the ordereing of the timestepping code and  C      Because of the ordering of the timestepping code and
193  C      tendency term code at end of loop model arrays hold  C      tendency term code at end of loop model arrays hold
194  C      U,V,T,S  at "time-level" N but gu, gv, gs, gt, guNM1,...  C      U,V,T,S  at "time-level" N but gu, gv, gs, gt, guNM1,...
195  C      at "time-level" N+1/2 (guNM1 at "time-level" N+1/2 is  C      at "time-level" N+1/2 (guNM1 at "time-level" N+1/2 is
# Line 101  C      Thus a checkpoint contains U.0000 Line 199  C      Thus a checkpoint contains U.0000
199  C      cg2d_x.0000000001 in the indexing scheme used for the model  C      cg2d_x.0000000001 in the indexing scheme used for the model
200  C      "state" files. This example is referred to as a checkpoint  C      "state" files. This example is referred to as a checkpoint
201  C      at time level 1  C      at time level 1
202         CALL WRITE_CHECKPOINT( .FALSE., myCurrentTime, myCurrentIter, myThid )         CALL TIMER_START('I/O (WRITE)        [MAIN LOOP]',myThid)
203           CALL
204         & WRITE_CHECKPOINT( .FALSE., myCurrentTime, myCurrentIter, myThid )
205           CALL TIMER_STOP ('I/O (WRITE)        [MAIN LOOP]',myThid)
206    
207        ENDDO        ENDDO
208          CALL TIMER_STOP ('MAIN LOOP',myThid)
209          CALL TIMER_START('SPIN-DOWN',myThid)
210    
211  C--   Dump for end state and final checkpoint  C--   Final checkpoint (incase the in-loop checkpoint was missed)
212        CALL WRITE_STATE( myCurrentTime, myCurrentIter, myThid )        CALL TIMER_START('I/O (WRITE)         [SPIN-DOWN]',myThid)
213        CALL WRITE_CHECKPOINT( .TRUE., myCurrentTime, myCurrentIter, myThid )        CALL
214         & WRITE_CHECKPOINT( .TRUE., myCurrentTime, myCurrentIter, myThid )
215          CALL TIMER_STOP ('I/O (WRITE)         [SPIN-DOWN]',myThid)
216    
217    C--   Set Open Boundaries Values
218          IF (openBoundaries) THEN
219           CALL TIMER_START('OBCS               [SPIN_DOWN]',myThid)
220           CALL SET_OBCS( myCurrentTime, myThid )
221           CALL TIMER_STOP ('OBCS               [SPIN_DOWN]',myThid)
222          ENDIF
223    
224    C--   Step-forward U/V/Theta/Salt for purposes of final I/O dump
225          CALL TIMER_START('DYNAMICS            [SPIN-DOWN]',myThid)
226          CALL DYNAMICS( myCurrentTime, myCurrentIter, myThid )
227          CALL TIMER_STOP ('DYNAMICS            [SPIN-DOWN]',myThid)
228    
229    C--   Do time averages
230    #ifdef ALLOW_DIAGNOSTICS
231          IF (taveFreq.GT.0.) THEN
232           CALL TIMER_START('I/O (WRITE)        [SPIN-DOWN]',myThid)
233           CALL WRITE_TIME_AVERAGES( myCurrentTime, myCurrentIter, myThid )
234           CALL TIMER_STOP ('I/O (WRITE)        [SPIN-DOWN]',myThid)
235          ENDIF
236    #endif
237    
238    C--   Dump for end state
239          CALL TIMER_START('I/O (WRITE)         [SPIN-DOWN]',myThid)
240          CALL WRITE_STATE( .FALSE., myCurrentTime, myCurrentIter, myThid )
241          CALL TIMER_STOP ('I/O (WRITE)         [SPIN-DOWN]',myThid)
242    
243          CALL TIMER_STOP ('SPIN-DOWN',myThid)
244          CALL TIMER_STOP ('ALL',myThid)
245    
246    C--   Write timer statistics
247          IF ( myThid .EQ. 1 ) THEN
248           CALL TIMER_PRINTALL( myThid )
249           CALL COMM_STATS
250          ENDIF
251    
252        RETURN        RETURN
253        END        END

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.24

  ViewVC Help
Powered by ViewVC 1.1.22