/[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.4 by cnh, Fri Apr 24 03:24:29 1998 UTC revision 1.15 by adcroft, Mon Jun 22 15:26:26 1998 UTC
# 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    C
26    C     Call Tree
27    C     =========
28    C    
29    C      main ( eesupp )
30    C       |
31    C       .
32    C       .
33    C       . Generic environment initialisation ( see eesupp/src and
34    C       .                                      eesupp/inc )      
35    C       . multiple threads and/or processes are created in here
36    C       .
37    C       .
38    C       .
39    C       |
40    C       |-THE_MODEL_MAIN - Begin specific model. One instance
41    C       |  |               of this codes exists for each thread
42    C       |  |               and/or instance. Each instance manages
43    C       |  |               a specifc set of tiles.              
44    C       |  |
45    C       |  |--INITIALISE
46    C       |  |   o Set initial conditions and model configuration
47    C       |  |     Topography, hydrography, timestep, grid, etc..
48    C       |  |
49    C  ==>  |  | ** Time stepping loop starts here **
50    C  |    |  |
51    C /|\   |  |
52    C  |    |  |--LOAD_EXTERNAL_DATA
53    C /|\   |  |   o Load and/or set time dependent forcing fields
54    C  |    |  |
55    C /|\   |  |--DYNAMICS
56    C  |    |  |   o Evaluate "forward" terms
57    C /|\   |  |
58    C  |    |  |--DO_THE_MODEL_IO
59    C /|\   |  |   o Write model state
60    C  |    |  |
61    C /|\   |  |--SOLVE_FOR_PRESSURE
62    C  |    |  |   o Find pressure field to keep flow non-divergent
63    C /|\   |  |
64    C  |    |  |--DO_GTERM_BLOCKING_EXCHANGES
65    C /|\   |  |   o Update overlap regions
66    C  |    |  |
67    C /|\   |  |--WRITE_CHECKPOINT
68    C  |    |  |   o Write restart file(s)
69    C /|\   |  |
70    C  |    |  |
71    C  |<== |  | ** Time stepping loop finishes here **
72    C       |  |
73    C       |  |--WRITE_STATE
74    C       |  |--WRITE_CHECKPOINT
75    C       |
76    C       .
77    C       .
78    C       . Generic environment termination ( see eesupp/src and
79    C       .                                      eesupp/inc )      
80    C       .
81    C       .
82    
83  C     == Global variables ===  C     == Global variables ===
84  #include "SIZE.h"  #include "SIZE.h"
# Line 29  C     == Global variables === Line 86  C     == Global variables ===
86  #include "PARAMS.h"  #include "PARAMS.h"
87  #include "CG2D.h"  #include "CG2D.h"
88  #include "DYNVARS.h"  #include "DYNVARS.h"
89    #include "AVER.h"
90    
91  C     == Routine arguments ==  C     == Routine arguments ==
92  C     myThid - Thread number for this instance of the routine.  C     myThid - Thread number for this instance of the routine.
93        INTEGER myThid        INTEGER myThid  
94    
95  C     == Local variables ==  C     == Local variables ==
96  C     Note: Under the multi-threaded model myCurrentIter and myCurrentTime  C     Note: Under the multi-threaded model myCurrentIter and
97  C           are local variables passed around as routine arguments. Although  C           myCurrentTime are local variables passed around as routine
98  C           this is fiddly it saves the need to impose additional synchronisation  C           arguments. Although this is fiddly it saves the need to
99  C           points when they are updated.  C           impose additional synchronisation points when they are
100    C           updated.
101  C     myCurrentIter - Iteration counter for this thread  C     myCurrentIter - Iteration counter for this thread
102  C     myCurrentTime - Time counter for this thread  C     myCurrentTime - Time counter for this thread
103  C     I             - Loop counter  C     I             - Loop counter
# Line 50  C--   Set model initial conditions Line 109  C--   Set model initial conditions
109        myCurrentTime = startTime        myCurrentTime = startTime
110        myCurrentIter = nIter0        myCurrentIter = nIter0
111    
112    C--   Dump for start state
113          CALL WRITE_STATE( .TRUE., myCurrentTime, myCurrentIter, myThid )
114    
115  C--   Begin time stepping loop  C--   Begin time stepping loop
116        DO I=1, nTimeSteps        DO I=1, nTimeSteps
117    
118  C--    Do IO if needed.  C--    Load forcing/external data fields
119         CALL DO_THE_MODEL_IO( myCurrentIter, myThid )         CALL LOAD_EXTERNAL_FIELDS( myCurrentTime, myCurrentIter, myThid )
120    
121    C--    Step forward fields and calculate time tendency terms
122           CALL DYNAMICS( myCurrentTime, myCurrentIter, myThid )
123    
124  C--    Load offline tracer fields  C--    Do time averages
125         IF ( MOD(myCurrentIter,numStepsPerPickup) .EQ. 1 ) THEN         IF (taveFreq.GT.0.) THEN
126  C       I/O           CALL DO_TIME_AVERAGES( myCurrentTime, myCurrentIter, myThid )
 C       o Writes to arrays are performed by their own thread (to ensure  
 C         physical memory allocation will pair with thread).  
 C       o Thread 1 reads into a buffer.  
 C       CALL LOAD_OFFLINE_FIELDS( myCurrentTime, myCurrentIter, myThid )  
127         ENDIF         ENDIF
128    
129  C--    Step forward fields and calculate time tendency terms  C--    Do IO if needed.
130         CALL DYNAMICS( myThid )  C      Note:
131    C      =====
132    C      At this point model arrays hold U,V,T,S  at "time-level" N
133    C      and cg2d_x at "time-level" N-1/2 where N = I+timeLevBase-1.
134    C      By convention this is taken to be the model "state".
135           CALL DO_THE_MODEL_IO( myCurrentTime, myCurrentIter, myThid )
136    
137  C--    Solve elliptic equation(s).  C--    Solve elliptic equation(s).
138  C      Two-dimensional only for conventional hydrostatic or three-dimensional  C      Two-dimensional only for conventional hydrostatic or
139  C      for non-hydrostatic and/or IGW scheme.  C      three-dimensional for non-hydrostatic and/or IGW scheme.
140         CALL SOLVE_FOR_PRESSURE( myThid )         CALL SOLVE_FOR_PRESSURE( myThid )
141    
142  C--    Do "blocking" sends and receives for tendency "overlap" terms  C--    Do "blocking" sends and receives for tendency "overlap" terms
143         CALL DO_GTERM_BLOCKING_EXCHANGES( myThid )         CALL DO_GTERM_BLOCKING_EXCHANGES( myThid )
144    
145         myCurrentIter = myCurrentIter + 1         myCurrentIter = myCurrentIter + 1
146         myCurrentTime = myCurrentTime  + deltaTtracer         myCurrentTime = myCurrentTime + deltaTClock
147    
148  C--    Save state for restarts  C--    Save state for restarts
149  C*P*   CALL CHECKPOINT( myThid )  C      Note:
150    C      =====
151    C      Because of the ordering of the timestepping code and
152    C      tendency term code at end of loop model arrays hold
153    C      U,V,T,S  at "time-level" N but gu, gv, gs, gt, guNM1,...
154    C      at "time-level" N+1/2 (guNM1 at "time-level" N+1/2 is
155    C      gu at "time-level" N-1/2) and cg2d_x at "time-level" N+1/2.
156    C       where N = I+timeLevBase-1
157    C      Thus a checkpoint contains U.0000000000, GU.0000000001 and
158    C      cg2d_x.0000000001 in the indexing scheme used for the model
159    C      "state" files. This example is referred to as a checkpoint
160    C      at time level 1
161           CALL WRITE_CHECKPOINT( .FALSE., myCurrentTime, myCurrentIter, myThid )
162    
163        ENDDO        ENDDO
164    
165    C--   Final checkpoint (incase the in-loop checkpoint was missed)
166          CALL WRITE_CHECKPOINT( .TRUE., myCurrentTime, myCurrentIter, myThid )
167    
168    C--   Step-forward U/V/Theta/Salt for purposes of final I/O dump
169          CALL DYNAMICS( myCurrentTime, myCurrentIter, myThid )
170    
171    C--   Do time averages
172          IF (taveFreq.GT.0.) THEN
173            CALL DO_TIME_AVERAGES( myCurrentTime, myCurrentIter, myThid )
174          ENDIF
175    
176    C--   Dump for end state
177          CALL WRITE_STATE( .FALSE., myCurrentTime, myCurrentIter, myThid )
178    
179    
180        RETURN        RETURN
181        END        END

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.15

  ViewVC Help
Powered by ViewVC 1.1.22