1 | SUBROUTINE driver |
---|
2 | C**** |
---|
3 | C ***************************** |
---|
4 | C * OASIS ROUTINE - LEVEL C * |
---|
5 | C * ------------- ------- * |
---|
6 | C ***************************** |
---|
7 | C |
---|
8 | C**** *driver* - Main OASIS routine |
---|
9 | C |
---|
10 | C |
---|
11 | C Purpose: |
---|
12 | C ------- |
---|
13 | C Drive and control the simulation between GCMs and coupler. |
---|
14 | C Contain the time loop. A coupled simulation with OASIS 2.0 |
---|
15 | C starts with the interpolation of the boundary conditions |
---|
16 | C from their original grid to the target grid in contrast with |
---|
17 | C the previous versions. Consequently, the GCMs pause initially |
---|
18 | C until the coupling variables have been interpolated. |
---|
19 | C |
---|
20 | C N.B: Note that the time loop goes from 0 to niter-1 in contrast |
---|
21 | C with previous versions. The iteration 0 of oasis DOES NOT |
---|
22 | C increment the simulation time. |
---|
23 | C |
---|
24 | C** Interface: |
---|
25 | C --------- |
---|
26 | C *CALL* *driver* |
---|
27 | C |
---|
28 | C Input: |
---|
29 | C ----- |
---|
30 | C None |
---|
31 | C |
---|
32 | C Output: |
---|
33 | C ------ |
---|
34 | C None |
---|
35 | C |
---|
36 | C Workspace: |
---|
37 | C --------- |
---|
38 | C iindex : index array for field identificators |
---|
39 | C |
---|
40 | C Externals: |
---|
41 | C --------- |
---|
42 | C Initialization |
---|
43 | C ************** |
---|
44 | C inipar, inilun, iniiof, inidya, initim, inicmc, chkpar, inigrd, |
---|
45 | C |
---|
46 | C Temporal loop |
---|
47 | C ************* |
---|
48 | C getfld, preproc, interp, cookart, postpro, givfld, reset, updtim |
---|
49 | C |
---|
50 | C Synchronization |
---|
51 | C *************** |
---|
52 | C modsgc, waitpc |
---|
53 | C |
---|
54 | C Reference: |
---|
55 | C --------- |
---|
56 | C See OASIS manual (1995) |
---|
57 | C |
---|
58 | C History: |
---|
59 | C ------- |
---|
60 | C Version Programmer Date Description |
---|
61 | C ------- ---------- ---- ----------- |
---|
62 | C 1.0 L. Terray 94/01/01 created |
---|
63 | C 2.0beta L. Terray 95/07/24 modified: new structure |
---|
64 | C 2.0 L. Terray 96/02/01 modified: change in time loop |
---|
65 | C 2.1 O. Marti, L.T 96/09/25 added: extra time step |
---|
66 | C 2.2 S. Valcke, L.T 97/11/13 added: SIPC call to modsgc |
---|
67 | C mode no message passing |
---|
68 | C 2.3 L. Terray 99/09/15 added: GMEM branch |
---|
69 | C |
---|
70 | C %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
71 | C |
---|
72 | C* -----------------Include files and USE of modules--------------------------- |
---|
73 | C |
---|
74 | USE mod_kinds_oasis |
---|
75 | USE mod_string |
---|
76 | USE mod_analysis |
---|
77 | USE mod_memory |
---|
78 | USE mod_parameter |
---|
79 | USE mod_experiment |
---|
80 | USE mod_timestep |
---|
81 | USE mod_unit |
---|
82 | USE mod_hardware |
---|
83 | C |
---|
84 | C* ---------------------------- Local declarations ---------------------- |
---|
85 | C |
---|
86 | INTEGER (kind=ip_intwp_p), DIMENSION(:), ALLOCATABLE :: iindex |
---|
87 | LOGICAL lltime, llseqn, llend |
---|
88 | INTEGER (kind=ip_intwp_p) :: il_flag |
---|
89 | C |
---|
90 | C* ---------------------------- Poema verses ---------------------------- |
---|
91 | C |
---|
92 | C %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
93 | C |
---|
94 | C* 1. Initialization |
---|
95 | C -------------- |
---|
96 | C |
---|
97 | C* - Initialize main run parameters |
---|
98 | C |
---|
99 | CALL inipar_alloc |
---|
100 | C |
---|
101 | C* - "iindex" allocation |
---|
102 | C |
---|
103 | IF (lg_oasis_field) THEN |
---|
104 | ALLOCATE(iindex(ig_nfield)) |
---|
105 | iindex(:)=0 |
---|
106 | ENDIF |
---|
107 | C |
---|
108 | C* - Allocate arrays (first round) |
---|
109 | C |
---|
110 | il_flag=1 |
---|
111 | CALL alloc(il_flag) |
---|
112 | C |
---|
113 | C* - Initialize other run parameters |
---|
114 | C |
---|
115 | CALL inipar |
---|
116 | C |
---|
117 | C* - Initialize logical unit numbers |
---|
118 | C |
---|
119 | CALL inilun |
---|
120 | cvg C |
---|
121 | cvg C* - Open necessary files |
---|
122 | cvg C |
---|
123 | cvg CALL iniiof |
---|
124 | |
---|
125 | C |
---|
126 | C* - Initialize time information |
---|
127 | C |
---|
128 | CALL initim |
---|
129 | C |
---|
130 | C* - Initialize communication between processes |
---|
131 | C |
---|
132 | CALL inicmc |
---|
133 | C |
---|
134 | C* - Allocate arrays (second round) |
---|
135 | C |
---|
136 | il_flag=2 |
---|
137 | CALL alloc(il_flag) |
---|
138 | C |
---|
139 | cvg>>> |
---|
140 | C |
---|
141 | C* - Set up dynamic allocation for all grid-related fields |
---|
142 | C |
---|
143 | CALL inidya |
---|
144 | C |
---|
145 | C* - Open necessary files |
---|
146 | C |
---|
147 | CALL iniiof |
---|
148 | cvg<<< |
---|
149 | |
---|
150 | C |
---|
151 | C* - Check run parameters compatibility between GCM's and coupler |
---|
152 | C |
---|
153 | CALL chkpar |
---|
154 | C |
---|
155 | C* - Initialize GCM's grids |
---|
156 | C |
---|
157 | CALL inigrd |
---|
158 | C |
---|
159 | C* - We will go through the next time loop only if one field (at least) goes |
---|
160 | C through Oasis |
---|
161 | |
---|
162 | IF (lg_oasis_field) THEN |
---|
163 | C |
---|
164 | C* 2. Time loop |
---|
165 | C --------- |
---|
166 | C |
---|
167 | C* Loop on number of iterations |
---|
168 | C* First iteration takes place at ndate (INIDATE in namcouple) and |
---|
169 | C* last iteration at one timestep before the end of the simulation |
---|
170 | C* (INIDATE + RUNTIME in namcouple), |
---|
171 | C |
---|
172 | DO 210 jt = 0, nitfn |
---|
173 | C |
---|
174 | C* Assign local variable for iteration number |
---|
175 | C |
---|
176 | iter = jt |
---|
177 | C |
---|
178 | C* Get time counter. |
---|
179 | C |
---|
180 | icount = iter * nstep |
---|
181 | C |
---|
182 | C* Update calendar date |
---|
183 | C |
---|
184 | CALL updtim (iter) |
---|
185 | C |
---|
186 | C* Loop on number of sequential models |
---|
187 | C |
---|
188 | DO 220 jm = 1, nmseq |
---|
189 | C |
---|
190 | C* Loop on number of fields to find active fields for current iteration |
---|
191 | C |
---|
192 | ifield = 0 |
---|
193 | DO 230 jf = 1, ig_total_nfield |
---|
194 | C |
---|
195 | C* Treat the field only IF it has to go through Oasis |
---|
196 | C |
---|
197 | IF (lg_state(jf)) THEN |
---|
198 | C |
---|
199 | C* Get conditional logical flags for doing analysis set |
---|
200 | C |
---|
201 | C |
---|
202 | C* Treat the field only if time smaller than end of simulation |
---|
203 | llend = icount .LT. ntime |
---|
204 | C |
---|
205 | C* Treat the field only if iteration corresponds to one |
---|
206 | C* of its coupling timesteps |
---|
207 | ifnow = nfexch(ig_number_field(jf)) |
---|
208 | lltime = mod(icount,ifnow) .EQ. 0 |
---|
209 | C |
---|
210 | C* If sequential order, treat the field only if it is consumed |
---|
211 | C* in present loop |
---|
212 | llseqn = nseqn(ig_number_field(jf)) .EQ. jm |
---|
213 | C |
---|
214 | C* Conditional test to fill up iindex array |
---|
215 | C |
---|
216 | IF (llseqn .AND. lltime .AND. llend) |
---|
217 | $ THEN |
---|
218 | ifield = ifield + 1 |
---|
219 | C |
---|
220 | C* Fill up iindex array with active fields at iteration jt |
---|
221 | C |
---|
222 | iindex(ifield) = ig_number_field(jf) |
---|
223 | ENDIF |
---|
224 | ENDIF |
---|
225 | 230 CONTINUE |
---|
226 | C |
---|
227 | C* There are ifield fields to be exchanged for iteration jt |
---|
228 | C |
---|
229 | IF (ifield .GT. 0) THEN |
---|
230 | C |
---|
231 | C* Get fields |
---|
232 | C |
---|
233 | CALL getfld (iindex, ifield, iter) |
---|
234 | C |
---|
235 | C* Do preprocessing |
---|
236 | C |
---|
237 | CALL preproc (iindex, ifield) |
---|
238 | C |
---|
239 | C* Do the interpolation |
---|
240 | C |
---|
241 | CALL interp (iindex, ifield) |
---|
242 | C |
---|
243 | C* Do the nitty gritty stuff |
---|
244 | |
---|
245 | C |
---|
246 | CALL cookart (iindex, ifield) |
---|
247 | C |
---|
248 | C* Do postprocessing |
---|
249 | C |
---|
250 | CALL postpro (iindex, ifield) |
---|
251 | C |
---|
252 | C* If last iteration in PIPE or SIPC case, switch sigcld handler |
---|
253 | IF (iter .EQ. nitfn) THEN |
---|
254 | IF (cchan .EQ. 'PIPE' .OR. cchan .EQ. 'SIPC') |
---|
255 | $ CALL modsgc |
---|
256 | ENDIF |
---|
257 | C |
---|
258 | C* Give back fields |
---|
259 | C |
---|
260 | CALL givfld (iindex, ifield, iter) |
---|
261 | ENDIF |
---|
262 | C |
---|
263 | C* End of loop over the sequential models |
---|
264 | C |
---|
265 | 220 CONTINUE |
---|
266 | C |
---|
267 | C* Reset macro arrays |
---|
268 | C |
---|
269 | CALL reset |
---|
270 | C |
---|
271 | C* End of iterative loop |
---|
272 | C |
---|
273 | 210 CONTINUE |
---|
274 | ENDIF |
---|
275 | C |
---|
276 | C* 3. Wait until end of child processes |
---|
277 | C --------------------------------- |
---|
278 | C |
---|
279 | CALL waitpc |
---|
280 | C |
---|
281 | C |
---|
282 | C* 4. End of routine |
---|
283 | C -------------- |
---|
284 | C |
---|
285 | C* "iindex" deallocation |
---|
286 | C |
---|
287 | IF (lg_oasis_field) DEALLOCATE(iindex) |
---|
288 | C |
---|
289 | C* Deallocation of arrays allocated in "inialloc" routine |
---|
290 | C |
---|
291 | CALL dealloc |
---|
292 | C |
---|
293 | RETURN |
---|
294 | END |
---|