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

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

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


Revision 1.10 - (hide annotations) (download)
Wed Jun 10 02:41:11 1998 UTC (25 years, 11 months ago) by cnh
Branch: MAIN
Changes since 1.9: +58 -4 lines
Added code structure comments and rearranged code to adhere
to clean structure.

1 cnh 1.10 C $Header: /u/gcmpack/models/MITgcmUV/model/src/the_model_main.F,v 1.9 1998/06/01 20:36:13 adcroft Exp $
2 cnh 1.1
3     #include "CPP_EEOPTIONS.h"
4    
5     SUBROUTINE THE_MODEL_MAIN(myThid)
6     C /==========================================================\
7     C | SUBROUTINE THE_MODEL_MAIN |
8     C | o Master controlling routine for model using the MITgcm |
9     C | UV parallel wrapper. |
10     C |==========================================================|
11     C | THE_MODEL_MAIN is invoked by the MITgcm UV parallel |
12     C | wrapper with a single integer argument "myThid". This |
13     C | variable identifies the thread number of an instance of |
14     C | THE_MODEL_MAIN. Each instance of THE_MODEL_MAIN works |
15     C | on a particular region of the models domain and |
16     C | synchronises with other instances as necessary. The |
17     C | routine has to "understand" the MITgcm parallel |
18     C | environment and the numerical algorithm. Editing this |
19     C | routine is best done with some knowledge of both aspects.|
20     C | Notes |
21     C | ===== |
22     C | C*P* comments indicating place holders for which code is |
23     C | presently being developed. |
24     C \==========================================================/
25 cnh 1.10 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 cnh 1.1
83     C == Global variables ===
84     #include "SIZE.h"
85     #include "EEPARAMS.h"
86     #include "PARAMS.h"
87     #include "CG2D.h"
88     #include "DYNVARS.h"
89    
90     C == Routine arguments ==
91     C myThid - Thread number for this instance of the routine.
92 cnh 1.6 INTEGER myThid
93 cnh 1.1
94     C == Local variables ==
95 cnh 1.7 C Note: Under the multi-threaded model myCurrentIter and
96     C myCurrentTime are local variables passed around as routine
97     C arguments. Although this is fiddly it saves the need to
98     C impose additional synchronisation points when they are
99     C updated.
100 cnh 1.1 C myCurrentIter - Iteration counter for this thread
101     C myCurrentTime - Time counter for this thread
102     C I - Loop counter
103     INTEGER I, myCurrentIter
104     REAL myCurrentTime
105    
106     C-- Set model initial conditions
107     CALL INITIALISE( myThid )
108     myCurrentTime = startTime
109     myCurrentIter = nIter0
110    
111     C-- Begin time stepping loop
112     DO I=1, nTimeSteps
113 cnh 1.4
114 cnh 1.1 C-- Load offline tracer fields
115     IF ( MOD(myCurrentIter,numStepsPerPickup) .EQ. 1 ) THEN
116     C I/O
117     C o Writes to arrays are performed by their own thread (to ensure
118     C physical memory allocation will pair with thread).
119     C o Thread 1 reads into a buffer.
120     C CALL LOAD_OFFLINE_FIELDS( myCurrentTime, myCurrentIter, myThid )
121     ENDIF
122    
123     C-- Step forward fields and calculate time tendency terms
124 cnh 1.8 CALL DYNAMICS( myCurrentTime, myCurrentIter, myThid )
125 cnh 1.1
126 cnh 1.7 C-- Do IO if needed.
127     C Note:
128     C =====
129     C At this point model arrays hold U,V,T,S at "time-level" N
130     C and cg2d_x at "time-level" N-1/2 where N = I+timeLevBase-1.
131     C By convention this is taken to be the model "state".
132     CALL DO_THE_MODEL_IO( myCurrentTime, myCurrentIter, myThid )
133    
134 cnh 1.1 C-- Solve elliptic equation(s).
135 cnh 1.7 C Two-dimensional only for conventional hydrostatic or
136     C three-dimensional for non-hydrostatic and/or IGW scheme.
137 cnh 1.1 CALL SOLVE_FOR_PRESSURE( myThid )
138    
139     C-- Do "blocking" sends and receives for tendency "overlap" terms
140     CALL DO_GTERM_BLOCKING_EXCHANGES( myThid )
141    
142     myCurrentIter = myCurrentIter + 1
143 cnh 1.7 myCurrentTime = myCurrentTime + deltaTClock
144 cnh 1.1
145     C-- Save state for restarts
146 cnh 1.7 C Note:
147     C =====
148     C Because of the ordereing of the timestepping code and
149     C tendency term code at end of loop model arrays hold
150     C U,V,T,S at "time-level" N but gu, gv, gs, gt, guNM1,...
151     C at "time-level" N+1/2 (guNM1 at "time-level" N+1/2 is
152     C gu at "time-level" N-1/2) and cg2d_x at "time-level" N+1/2.
153     C where N = I+timeLevBase-1
154     C Thus a checkpoint contains U.0000000000, GU.0000000001 and
155     C cg2d_x.0000000001 in the indexing scheme used for the model
156     C "state" files. This example is referred to as a checkpoint
157     C at time level 1
158     CALL WRITE_CHECKPOINT( .FALSE., myCurrentTime, myCurrentIter, myThid )
159 cnh 1.1
160     ENDDO
161 cnh 1.7
162     C-- Dump for end state and final checkpoint
163     CALL WRITE_STATE( myCurrentTime, myCurrentIter, myThid )
164     CALL WRITE_CHECKPOINT( .TRUE., myCurrentTime, myCurrentIter, myThid )
165    
166 cnh 1.1
167     RETURN
168     END

  ViewVC Help
Powered by ViewVC 1.1.22