/[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.6 by cnh, Fri Apr 24 03:45:12 1998 UTC revision 1.37 by heimbach, Sun Mar 25 22:33:53 2001 UTC
# Line 1  Line 1 
1  C $Header$  C $Header$
2    C $Name$
3    
4  #include "CPP_EEOPTIONS.h"  #include "CPP_OPTIONS.h"
5    
6        SUBROUTINE THE_MODEL_MAIN(myThid)        SUBROUTINE THE_MODEL_MAIN(myThid)
7  C     /==========================================================\  C     /==========================================================\
# Line 22  C     | ===== Line 23  C     | =====
23  C     | C*P* comments indicating place holders for which code is |  C     | C*P* comments indicating place holders for which code is |
24  C     |      presently being developed.                          |  C     |      presently being developed.                          |
25  C     \==========================================================/  C     \==========================================================/
26          IMPLICIT NONE
27    C
28    C     Call Tree
29    C     =========
30    C    
31    C      main ( eesupp )
32    C       |
33    C       .
34    C       .
35    C       . Generic environment initialisation ( see eesupp/src and
36    C       .                                      eesupp/inc )      
37    C       . multiple threads and/or processes are created in here
38    C       .
39    C       .
40    C       .
41    C       |
42    C       |-THE_MODEL_MAIN - Begin specific model. One instance
43    C       |  |               of this codes exists for each thread
44    C       |  |               and/or instance. Each instance manages
45    C       |  |               a specifc set of tiles.              
46    C       |  |
47    C       |  |--INITIALISE_FIXED
48    C       |  |   o Set model configuration (fixed arrays)
49    C       |  |     Topography, hydrography, timestep, grid, etc..
50    C       |  |
51    C       |  |--THE_MAIN_LOOP
52    C       |  |  |
53    C       |  |  |--INITIALISE_VARIA
54    C       |  |  |   o Set initial conditions (variable arrays)
55    C       |  |  |
56    C  ==>  |  |  | ** Time stepping loop starts here **
57    C  |    |  |  |
58    C /|\   |  |  |
59    C  |    |  |  |--FORWARD_STEP
60    C /|\   |  |  |  |  o Does a single forward step of the model
61    C  |    |  |  |  |
62    C /|\   |  |  |  |
63    C  |    |  |  |  |--LOAD_EXTERNAL_DATA
64    C /|\   |  |  |  |   o Load and/or set time dependent forcing fields
65    C  |    |  |  |  |
66    C /|\   |  |  |  |--DYNAMICS
67    C  |    |  |  |  |   o Evaluate "forward" terms
68    C /|\   |  |  |  |
69    C  |    |  |  |  |--SOLVE_FOR_PRESSURE
70    C /|\   |  |  |  |   o Find pressure field to keep flow non-divergent
71    C  |    |  |  |  |
72    C /|\   |  |  |  |--THE_CORRECTION_STEP
73    C  |    |  |  |  |   o Correct flow field with and cycle time-stepping arrays
74    C /|\   |  |  |  |
75    C  |    |  |  |  |--DO_GTERM_BLOCKING_EXCHANGES
76    C /|\   |  |  |  |   o Update overlap regions
77    C  |    |  |  |  |
78    C /|\   |  |  |  |--DO_THE_MODEL_IO
79    C  |    |  |  |  |   o Write model state
80    C /|\   |  |  |  |
81    C  |    |  |  |  |--WRITE_CHECKPOINT
82    C /|\   |  |  |  |   o Write restart file(s)
83    C  |    |  |  |
84    C /|\   |  |  |
85    C  |<== |  |  | ** Time stepping loop finishes here **
86    C       |  |  |
87    C       |  |  |--
88    C       |  |
89    C       |  |--WRITE_STATE
90    C       |  |--WRITE_CHECKPOINT
91    C       |
92    C       .
93    C       .
94    C       . Generic environment termination ( see eesupp/src and
95    C       .                                      eesupp/inc )      
96    C       .
97    C       .
98    
99  C     == Global variables ===  C     == Global variables ===
100  #include "SIZE.h"  #include "SIZE.h"
101  #include "EEPARAMS.h"  #include "EEPARAMS.h"
102  #include "PARAMS.h"  #include "PARAMS.h"
 #include "CG2D.h"  
103  #include "DYNVARS.h"  #include "DYNVARS.h"
104    #ifdef ALLOW_NONHYDROSTATIC
105    #include "CG3D.h"
106    #endif
107    
108    #ifdef ALLOW_AUTODIFF_TAMC
109    #include "tamc.h"
110    #include "cost.h"
111    #include "adcost.h"
112    #endif
113    
114  C     == Routine arguments ==  C     == Routine arguments ==
115  C     myThid - Thread number for this instance of the routine.  C     myThid - Thread number for this instance of the routine.
116        INTEGER myThid          INTEGER myThid  
117    
118  C     == Local variables ==  C     == Local variables ==
119  C     Note: Under the multi-threaded model myCurrentIter and myCurrentTime  C     Note: Under the multi-threaded model myCurrentIter and
120  C           are local variables passed around as routine arguments. Although  C           myCurrentTime are local variables passed around as routine
121  C           this is fiddly it saves the need to impose additional synchronisation  C           arguments. Although this is fiddly it saves the need to
122  C           points when they are updated.  C           impose additional synchronisation points when they are
123  C     myCurrentIter - Iteration counter for this thread  C           updated.
124  C     myCurrentTime - Time counter for this thread  C     myCurrentTime - Time counter for this thread
125  C     I             - Loop counter  C     myCurrentIter - Iteration counter for this thread
126        INTEGER I, myCurrentIter        INTEGER myCurrentIter
127        REAL    myCurrentTime        _RL     myCurrentTime
   
 C--   Set model initial conditions  
       CALL INITIALISE( myThid )  
       myCurrentTime = startTime  
       myCurrentIter = nIter0  
128    
129  C--   Begin time stepping loop  C--   This timer encompasses the whole code
130        DO I=1, nTimeSteps        CALL TIMER_START('ALL                [THE_MODEL_MAIN]',myThid)
131    
 C--    Do IO if needed.  
        CALL DO_THE_MODEL_IO( myCurrentIter, myThid )  
132    
133  C--    Load offline tracer fields  C--   Set model configuration (fixed arrays)
134         IF ( MOD(myCurrentIter,numStepsPerPickup) .EQ. 1 ) THEN        CALL TIMER_START('INITIALISE_FIXED   [THE_MODEL_MAIN]',myThid)
135  C       I/O        CALL INITIALISE_FIXED( myThid )
136  C       o Writes to arrays are performed by their own thread (to ensure        CALL TIMER_STOP ('INITIALISE_FIXED   [THE_MODEL_MAIN]',myThid)
 C         physical memory allocation will pair with thread).  
 C       o Thread 1 reads into a buffer.  
 C       CALL LOAD_OFFLINE_FIELDS( myCurrentTime, myCurrentIter, myThid )  
        ENDIF  
   
 C--    Step forward fields and calculate time tendency terms  
        CALL DYNAMICS( myThid )  
   
 C--    Solve elliptic equation(s).  
 C      Two-dimensional only for conventional hydrostatic or three-dimensional  
 C      for non-hydrostatic and/or IGW scheme.  
        CALL SOLVE_FOR_PRESSURE( myThid )  
   
 C--    Do "blocking" sends and receives for tendency "overlap" terms  
        CALL DO_GTERM_BLOCKING_EXCHANGES( myThid )  
137    
138         myCurrentIter = myCurrentIter + 1        myCurrentTime = startTime
139         myCurrentTime = myCurrentTime  + deltaTtracer        myCurrentIter = nIter0
140    
141  C--    Save state for restarts  #ifdef ALLOW_MIT_ADJOINT_RUN
 C*P*   CALL CHECKPOINT( myThid )  
142    
143        ENDDO        _BEGIN_MASTER( mythid )
144          IF (myProcId .eq. 0) THEN
145             CALL CTRL_UNPACK( mycurrentiter, mycurrenttime, mythid )
146          ENDIF
147          _END_MASTER( mythid )
148          _BARRIER
149    
150          fc   = 0.0
151          adfc = 1.0
152          CALL TIMER_START('ADTHE_MAIN_SENS          [ADJOINT RUN]', mythid)
153          call ADTHE_MAIN_SENS ( mythid )
154          call TIMER_STOP ('ADTHE_MAIN_SENS          [ADJOINT RUN]', mythid)
155          _BARRIER
156    
157          _BEGIN_MASTER( mythid )
158          IF (myProcId .eq. 0) THEN
159             call CTRL_PACK( mycurrentiter, mycurrenttime, mythid )
160          ENDIF
161          _END_MASTER( mythid )
162          _BARRIER
163    
164    #else /* ALLOW_MIT_ADJOINT_RUN undef */
165    
166    C--   Call time stepping loop of full model
167          CALL TIMER_START('THE_MAIN_LOOP      [THE_MODEL_MAIN]',myThid)
168          CALL THE_MAIN_SENS(myCurrentTime, myCurrentIter, myThid )
169          CALL TIMER_STOP ('THE_MAIN_LOOP      [THE_MODEL_MAIN]',myThid)
170    
171    #endif /* ALLOW_MIT_ADJOINT_RUN */
172    
173          CALL TIMER_STOP ('ALL                [THE_MODEL_MAIN]',myThid)
174    
175    C--   Write timer statistics
176          IF ( myThid .EQ. 1 ) THEN
177           CALL TIMER_PRINTALL( myThid )
178           CALL COMM_STATS
179          ENDIF
180    
181        RETURN        RETURN
182        END        END

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.37

  ViewVC Help
Powered by ViewVC 1.1.22