/[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.17 by adcroft, Wed Jul 1 19:49:36 1998 UTC revision 1.34 by jmc, Thu Feb 8 18:13:37 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  C
28  C     Call Tree  C     Call Tree
29  C     =========  C     =========
# Line 42  C       |  |               of this codes Line 44  C       |  |               of this codes
44  C       |  |               and/or instance. Each instance manages  C       |  |               and/or instance. Each instance manages
45  C       |  |               a specifc set of tiles.                C       |  |               a specifc set of tiles.              
46  C       |  |  C       |  |
47  C       |  |--INITIALISE  C       |  |--INITIALISE_FIXED
48  C       |  |   o Set initial conditions and model configuration  C       |  |   o Set model configuration (fixed arrays)
49  C       |  |     Topography, hydrography, timestep, grid, etc..  C       |  |     Topography, hydrography, timestep, grid, etc..
50  C       |  |  C       |  |
51  C  ==>  |  | ** Time stepping loop starts here **  C       |  |--THE_MAIN_LOOP
52  C  |    |  |  C       |  |  |
53  C /|\   |  |  C       |  |  |--INITIALISE_VARIA
54  C  |    |  |--LOAD_EXTERNAL_DATA  C       |  |  |   o Set initial conditions (variable arrays)
55  C /|\   |  |   o Load and/or set time dependent forcing fields  C       |  |  |
56  C  |    |  |  C  ==>  |  |  | ** Time stepping loop starts here **
57  C /|\   |  |--DYNAMICS  C  |    |  |  |
58  C  |    |  |   o Evaluate "forward" terms  C /|\   |  |  |
59  C /|\   |  |  C  |    |  |  |--FORWARD_STEP
60  C  |    |  |--DO_THE_MODEL_IO  C /|\   |  |  |  |  o Does a single forward step of the model
61  C /|\   |  |   o Write model state  C  |    |  |  |  |
62  C  |    |  |  C /|\   |  |  |  |
63  C /|\   |  |--SOLVE_FOR_PRESSURE  C  |    |  |  |  |--LOAD_EXTERNAL_DATA
64  C  |    |  |   o Find pressure field to keep flow non-divergent  C /|\   |  |  |  |   o Load and/or set time dependent forcing fields
65  C /|\   |  |  C  |    |  |  |  |
66  C  |    |  |--DO_GTERM_BLOCKING_EXCHANGES  C /|\   |  |  |  |--DYNAMICS
67  C /|\   |  |   o Update overlap regions  C  |    |  |  |  |   o Evaluate "forward" terms
68  C  |    |  |  C /|\   |  |  |  |
69  C /|\   |  |--WRITE_CHECKPOINT  C  |    |  |  |  |--DO_THE_MODEL_IO
70  C  |    |  |   o Write restart file(s)  C /|\   |  |  |  |   o Write model state
71  C /|\   |  |  C  |    |  |  |  |
72  C  |    |  |  C /|\   |  |  |  |--SOLVE_FOR_PRESSURE
73  C  |<== |  | ** Time stepping loop finishes here **  C  |    |  |  |  |   o Find pressure field to keep flow non-divergent
74    C /|\   |  |  |  |
75    C  |    |  |  |  |--DO_GTERM_BLOCKING_EXCHANGES
76    C /|\   |  |  |  |   o Update overlap regions
77    C  |    |  |  |  |
78    C /|\   |  |  |  |--WRITE_CHECKPOINT
79    C  |    |  |  |  |   o Write restart file(s)
80    C /|\   |  |  |
81    C  |    |  |  |
82    C  |<== |  |  | ** Time stepping loop finishes here **
83    C       |  |  |
84    C       |  |  |--
85  C       |  |  C       |  |
86  C       |  |--WRITE_STATE  C       |  |--WRITE_STATE
87  C       |  |--WRITE_CHECKPOINT  C       |  |--WRITE_CHECKPOINT
# Line 84  C     == Global variables === Line 97  C     == Global variables ===
97  #include "SIZE.h"  #include "SIZE.h"
98  #include "EEPARAMS.h"  #include "EEPARAMS.h"
99  #include "PARAMS.h"  #include "PARAMS.h"
 #include "CG2D.h"  
100  #include "DYNVARS.h"  #include "DYNVARS.h"
101  #include "AVER.h"  #include "CG2D.h"
102    #ifdef ALLOW_NONHYDROSTATIC
103    #include "CG3D.h"
104    #endif
105    
106  C     == Routine arguments ==  C     == Routine arguments ==
107  C     myThid - Thread number for this instance of the routine.  C     myThid - Thread number for this instance of the routine.
# Line 98  C           myCurrentTime are local vari Line 113  C           myCurrentTime are local vari
113  C           arguments. Although this is fiddly it saves the need to  C           arguments. Although this is fiddly it saves the need to
114  C           impose additional synchronisation points when they are  C           impose additional synchronisation points when they are
115  C           updated.  C           updated.
 C     myCurrentIter - Iteration counter for this thread  
116  C     myCurrentTime - Time counter for this thread  C     myCurrentTime - Time counter for this thread
117  C     I             - Loop counter  C     myCurrentIter - Iteration counter for this thread
118        INTEGER I, myCurrentIter        INTEGER myCurrentIter
119        REAL    myCurrentTime        _RL     myCurrentTime
120    
121  C--   Set model initial conditions  C--   This timer encompasses the whole code
122        CALL INITIALISE( myThid )        CALL TIMER_START('ALL                [THE_MODEL_MAIN]',myThid)
       myCurrentTime = startTime  
       myCurrentIter = nIter0  
123    
 C--   Dump for start state  
       CALL WRITE_STATE( .TRUE., myCurrentTime, myCurrentIter, myThid )  
124    
125  C--   Begin time stepping loop  C--   Set model configuration (fixed arrays)
126        DO I=1, nTimeSteps        CALL TIMER_START('INITIALISE_FIXED   [THE_MODEL_MAIN]',myThid)
127          CALL INITIALISE_FIXED( myThid )
128          CALL TIMER_STOP ('INITIALISE_FIXED   [THE_MODEL_MAIN]',myThid)
129    
 C--    Load forcing/external data fields  
        CALL LOAD_EXTERNAL_FIELDS( myCurrentTime, myCurrentIter, myThid )  
130    
131  C--    Step forward fields and calculate time tendency terms        myCurrentTime = startTime
132         CALL DYNAMICS( myCurrentTime, myCurrentIter, myThid )        myCurrentIter = nIter0
   
 C--    Do time averages  
 #ifdef ALLOW_DIAGNOSTICS  
        IF (taveFreq.GT.0.) THEN  
         CALL WRITE_TIME_AVERAGES( myCurrentTime, myCurrentIter, myThid )  
        ENDIF  
 #endif  
133    
134  C--    Do IO if needed.  C--   Call time stepping loop of full model
135  C      Note:        CALL TIMER_START('THE_MAIN_LOOP      [THE_MODEL_MAIN]',myThid)
136  C      =====        CALL THE_MAIN_LOOP(myCurrentTime, myCurrentIter, myThid )
137  C      At this point model arrays hold U,V,T,S  at "time-level" N        CALL TIMER_STOP ('THE_MAIN_LOOP      [THE_MODEL_MAIN]',myThid)
 C      and cg2d_x at "time-level" N-1/2 where N = I+timeLevBase-1.  
 C      By convention this is taken to be the model "state".  
        CALL DO_THE_MODEL_IO( myCurrentTime, myCurrentIter, myThid )  
   
 C--    Solve elliptic equation(s).  
 C      Two-dimensional only for conventional hydrostatic or  
 C      three-dimensional 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 )  
   
        myCurrentIter = myCurrentIter + 1  
        myCurrentTime = myCurrentTime + deltaTClock  
   
 C--    Save state for restarts  
 C      Note:  
 C      =====  
 C      Because of the ordering of the timestepping code and  
 C      tendency term code at end of loop model arrays hold  
 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 WRITE_CHECKPOINT( .FALSE., myCurrentTime, myCurrentIter, myThid )  
   
       ENDDO  
   
 C--   Final checkpoint (incase the in-loop checkpoint was missed)  
       CALL WRITE_CHECKPOINT( .TRUE., myCurrentTime, myCurrentIter, myThid )  
   
 C--   Step-forward U/V/Theta/Salt for purposes of final I/O dump  
       CALL DYNAMICS( myCurrentTime, myCurrentIter, myThid )  
   
 C--   Do time averages  
 #ifdef ALLOW_DIAGNOSTICS  
       IF (taveFreq.GT.0.) THEN  
         CALL WRITE_TIME_AVERAGES( myCurrentTime, myCurrentIter, myThid )  
       ENDIF  
 #endif  
138    
 C--   Dump for end state  
       CALL WRITE_STATE( .FALSE., myCurrentTime, myCurrentIter, myThid )  
139    
140          CALL TIMER_STOP ('ALL                [THE_MODEL_MAIN]',myThid)
141    
142    C--   Write timer statistics
143          IF ( myThid .EQ. 1 ) THEN
144           CALL TIMER_PRINTALL( myThid )
145           CALL COMM_STATS
146          ENDIF
147    
148        RETURN        RETURN
149        END        END

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.34

  ViewVC Help
Powered by ViewVC 1.1.22