1 |
heimbach |
1.38 |
C $Header: /u/gcmpack/models/MITgcmUV/model/src/the_model_main.F,v 1.37 2001/03/25 22:33:53 heimbach Exp $ |
2 |
|
|
C $Name: $ |
3 |
cnh |
1.1 |
|
4 |
adcroft |
1.18 |
#include "CPP_OPTIONS.h" |
5 |
cnh |
1.1 |
|
6 |
|
|
SUBROUTINE THE_MODEL_MAIN(myThid) |
7 |
|
|
C /==========================================================\ |
8 |
|
|
C | SUBROUTINE THE_MODEL_MAIN | |
9 |
|
|
C | o Master controlling routine for model using the MITgcm | |
10 |
|
|
C | UV parallel wrapper. | |
11 |
|
|
C |==========================================================| |
12 |
|
|
C | THE_MODEL_MAIN is invoked by the MITgcm UV parallel | |
13 |
|
|
C | wrapper with a single integer argument "myThid". This | |
14 |
|
|
C | variable identifies the thread number of an instance of | |
15 |
|
|
C | THE_MODEL_MAIN. Each instance of THE_MODEL_MAIN works | |
16 |
|
|
C | on a particular region of the models domain and | |
17 |
|
|
C | synchronises with other instances as necessary. The | |
18 |
|
|
C | routine has to "understand" the MITgcm parallel | |
19 |
|
|
C | environment and the numerical algorithm. Editing this | |
20 |
|
|
C | routine is best done with some knowledge of both aspects.| |
21 |
|
|
C | Notes | |
22 |
|
|
C | ===== | |
23 |
|
|
C | C*P* comments indicating place holders for which code is | |
24 |
|
|
C | presently being developed. | |
25 |
|
|
C \==========================================================/ |
26 |
adcroft |
1.24 |
IMPLICIT NONE |
27 |
cnh |
1.10 |
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 |
adcroft |
1.32 |
C | |--INITIALISE_FIXED |
48 |
|
|
C | | o Set model configuration (fixed arrays) |
49 |
cnh |
1.10 |
C | | Topography, hydrography, timestep, grid, etc.. |
50 |
|
|
C | | |
51 |
adcroft |
1.32 |
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 |
jmc |
1.35 |
C | | | | |--SOLVE_FOR_PRESSURE |
70 |
|
|
C /|\ | | | | o Find pressure field to keep flow non-divergent |
71 |
adcroft |
1.32 |
C | | | | | |
72 |
jmc |
1.35 |
C /|\ | | | |--THE_CORRECTION_STEP |
73 |
|
|
C | | | | | o Correct flow field with and cycle time-stepping arrays |
74 |
adcroft |
1.32 |
C /|\ | | | | |
75 |
|
|
C | | | | |--DO_GTERM_BLOCKING_EXCHANGES |
76 |
|
|
C /|\ | | | | o Update overlap regions |
77 |
|
|
C | | | | | |
78 |
jmc |
1.35 |
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 |
adcroft |
1.32 |
C /|\ | | | |
85 |
|
|
C |<== | | | ** Time stepping loop finishes here ** |
86 |
|
|
C | | | |
87 |
|
|
C | | |-- |
88 |
cnh |
1.10 |
C | | |
89 |
|
|
C | |--WRITE_STATE |
90 |
adcroft |
1.17 |
C | |--WRITE_CHECKPOINT |
91 |
cnh |
1.10 |
C | |
92 |
|
|
C . |
93 |
|
|
C . |
94 |
|
|
C . Generic environment termination ( see eesupp/src and |
95 |
|
|
C . eesupp/inc ) |
96 |
|
|
C . |
97 |
|
|
C . |
98 |
cnh |
1.1 |
|
99 |
|
|
C == Global variables === |
100 |
|
|
#include "SIZE.h" |
101 |
|
|
#include "EEPARAMS.h" |
102 |
|
|
#include "PARAMS.h" |
103 |
adcroft |
1.26 |
#include "DYNVARS.h" |
104 |
adcroft |
1.27 |
#ifdef ALLOW_NONHYDROSTATIC |
105 |
adcroft |
1.26 |
#include "CG3D.h" |
106 |
adcroft |
1.27 |
#endif |
107 |
cnh |
1.1 |
|
108 |
heimbach |
1.37 |
#ifdef ALLOW_AUTODIFF_TAMC |
109 |
|
|
#include "tamc.h" |
110 |
|
|
#include "cost.h" |
111 |
|
|
#include "adcost.h" |
112 |
|
|
#endif |
113 |
|
|
|
114 |
cnh |
1.1 |
C == Routine arguments == |
115 |
|
|
C myThid - Thread number for this instance of the routine. |
116 |
cnh |
1.6 |
INTEGER myThid |
117 |
cnh |
1.1 |
|
118 |
|
|
C == Local variables == |
119 |
cnh |
1.7 |
C Note: Under the multi-threaded model myCurrentIter and |
120 |
|
|
C myCurrentTime are local variables passed around as routine |
121 |
|
|
C arguments. Although this is fiddly it saves the need to |
122 |
|
|
C impose additional synchronisation points when they are |
123 |
|
|
C updated. |
124 |
jmc |
1.34 |
C myCurrentTime - Time counter for this thread |
125 |
|
|
C myCurrentIter - Iteration counter for this thread |
126 |
|
|
INTEGER myCurrentIter |
127 |
|
|
_RL myCurrentTime |
128 |
cnh |
1.1 |
|
129 |
adcroft |
1.19 |
C-- This timer encompasses the whole code |
130 |
adcroft |
1.32 |
CALL TIMER_START('ALL [THE_MODEL_MAIN]',myThid) |
131 |
adcroft |
1.19 |
|
132 |
|
|
|
133 |
adcroft |
1.32 |
C-- Set model configuration (fixed arrays) |
134 |
|
|
CALL TIMER_START('INITIALISE_FIXED [THE_MODEL_MAIN]',myThid) |
135 |
|
|
CALL INITIALISE_FIXED( myThid ) |
136 |
|
|
CALL TIMER_STOP ('INITIALISE_FIXED [THE_MODEL_MAIN]',myThid) |
137 |
adcroft |
1.26 |
|
138 |
jmc |
1.34 |
myCurrentTime = startTime |
139 |
|
|
myCurrentIter = nIter0 |
140 |
|
|
|
141 |
heimbach |
1.37 |
#ifdef ALLOW_MIT_ADJOINT_RUN |
142 |
|
|
|
143 |
|
|
_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 |
heimbach |
1.38 |
CALL TIMER_START('ADTHE_MAIN_LOOP [ADJOINT RUN]', mythid) |
153 |
|
|
call ADTHE_MAIN_LOOP ( mythid ) |
154 |
|
|
call TIMER_STOP ('ADTHE_MAIN_LOOP [ADJOINT RUN]', mythid) |
155 |
heimbach |
1.37 |
_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 |
adcroft |
1.32 |
C-- Call time stepping loop of full model |
167 |
|
|
CALL TIMER_START('THE_MAIN_LOOP [THE_MODEL_MAIN]',myThid) |
168 |
heimbach |
1.38 |
CALL THE_MAIN_LOOP(myCurrentTime, myCurrentIter, myThid ) |
169 |
adcroft |
1.32 |
CALL TIMER_STOP ('THE_MAIN_LOOP [THE_MODEL_MAIN]',myThid) |
170 |
adcroft |
1.12 |
|
171 |
heimbach |
1.37 |
#endif /* ALLOW_MIT_ADJOINT_RUN */ |
172 |
heimbach |
1.38 |
|
173 |
|
|
C-- Final checkpoint (incase the in-loop checkpoint was missed) |
174 |
|
|
CALL TIMER_START('WRITE_CHECKPOINT [THE_MODEL_MAIN]',myThid) |
175 |
|
|
CALL WRITE_CHECKPOINT( |
176 |
|
|
& .TRUE., myCurrentTime, myCurrentIter, myThid ) |
177 |
|
|
CALL TIMER_STOP ('WRITE_CHECKPOINT [THE_MODEL_MAIN]',myThid) |
178 |
adcroft |
1.19 |
|
179 |
adcroft |
1.32 |
CALL TIMER_STOP ('ALL [THE_MODEL_MAIN]',myThid) |
180 |
cnh |
1.7 |
|
181 |
adcroft |
1.19 |
C-- Write timer statistics |
182 |
cnh |
1.20 |
IF ( myThid .EQ. 1 ) THEN |
183 |
|
|
CALL TIMER_PRINTALL( myThid ) |
184 |
|
|
CALL COMM_STATS |
185 |
|
|
ENDIF |
186 |
cnh |
1.1 |
|
187 |
|
|
RETURN |
188 |
|
|
END |