/[MITgcm]/MITgcm/pkg/autodiff/active_file_loc_control.F
ViewVC logotype

Contents of /MITgcm/pkg/autodiff/active_file_loc_control.F

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


Revision 1.3 - (show annotations) (download)
Thu Oct 9 04:19:18 2003 UTC (20 years, 7 months ago) by edhill
Branch: MAIN
CVS Tags: checkpoint51k_post, checkpoint51l_post, checkpoint52d_pre, checkpoint52e_pre, checkpoint51o_pre, checkpoint52e_post, checkpoint51n_pre, checkpoint51q_post, branch-netcdf, checkpoint51r_post, checkpoint52b_pre, checkpoint51i_post, checkpoint51l_pre, checkpoint51o_post, checkpoint51p_post, checkpoint52, checkpoint52d_post, checkpoint52a_post, checkpoint52b_post, checkpoint52f_post, checkpoint52c_post, ecco_c52_e35, checkpoint52a_pre, checkpoint52i_post, checkpoint51t_post, checkpoint51n_post, checkpoint52i_pre, checkpoint51u_post, checkpoint52h_pre, checkpoint52f_pre, hrcube_1, hrcube_2, hrcube_3, checkpoint51m_post, checkpoint51s_post
Branch point for: netcdf-sm0, branch-nonh, tg2-branch, checkpoint51n_branch
Changes since 1.2: +1 -1 lines
 o first check-in for the "branch-genmake2" merge
 o verification suite as run on shelley (gcc 3.2.2):

Wed Oct  8 23:42:29 EDT 2003
                T           S           U           V
G D M    c        m  s        m  s        m  s        m  s
E p a R  g  m  m  e  .  m  m  e  .  m  m  e  .  m  m  e  .
N n k u  2  i  a  a  d  i  a  a  d  i  a  a  d  i  a  a  d
2 d e n  d  n  x  n  .  n  x  n  .  n  x  n  .  n  x  n  .

OPTFILE=NONE

Y Y Y Y 13 16 16 16  0 16 16 16 16 16 16 16 16 13 12  0  0 pass  adjustment.128x64x1
Y Y Y Y 16 16 16 16  0 16 16 16 16 16 16  0  0 16 16  0  0 pass  adjustment.cs-32x32x1
Y Y Y Y 16 16 16 16  0 16 16 16 16 16 16 22  0 16 16 22  0 pass  adjust_nlfs.cs-32x32x1
Y Y Y Y -- 13 13 16 16 13 13 13 13 16 16 16 16 16 16 16 16 N/O   advect_cs
Y Y Y Y -- 22 16 16 16 16 16 16 13 16 16 16 16 16 16 16 16 N/O   advect_xy
Y Y Y Y -- 13 16 13 16 16 16 16 16 16 16 22 16 16 16 16 16 N/O   advect_xz
Y Y Y Y 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 pass  aim.5l_cs
Y Y Y Y 14 16 16 16 16 16 16 16 16 13 16 16 16 16 16 13 16 pass  aim.5l_Equatorial_Channel
Y Y Y Y 16 16 16 16 16 16 16 16 16 16 16 13 16 16 13 13 16 pass  aim.5l_LatLon
Y Y Y Y 13 16 16 16 16 16 16 16 16 16 13 12 13 13 16 13 16 pass  exp0
Y Y Y Y 14 16 16 16 16 16 16 16 22 16 16 16 13 16 16 22 16 pass  exp1
Y Y Y Y 13 13 16 13 16 16 16 16 16 13 13 16 16 13 13 13 13 pass  exp2
Y Y Y Y 16 16 16 16 16 16 16 16 22 16 16 16 16 16 16 16 16 pass  exp4
Y Y Y Y 16 16 16 16 16 16 16 16 16 16 16 22 16 16 16 22 16 pass  exp5
Y Y Y Y 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 pass  front_relax
Y Y Y Y 14 16 16 13 13 16 16 13 13 16 13 13 16 12 13 13 16 pass  global_ocean.90x40x15
Y Y Y Y 10 16 16 13 13 16 13 16 16 13 13 13 13 16 16 13 16 FAIL  global_ocean.cs32x15
Y Y Y Y  6 11 12 13 13 12 13 16 13  9  9  9  9 10  9  9 11 FAIL  global_ocean_pressure
Y Y Y Y 14 16 16 13 16 16 16 13 13 13 13 13 16 12 16 13 16 pass  global_with_exf
Y Y Y Y 14 16 16 16 16 16 16 16 16 11 13 22 13 16 16  9 16 pass  hs94.128x64x5
Y Y Y Y 13 16 16 16 16 16 16 16 16 11 16 16 16 13 16 22 13 pass  hs94.1x64x5
Y Y Y Y 14 16 16 16 16 16 16 16 16 13 16 13 13 16 16 22 13 pass  hs94.cs-32x32x5
Y Y Y Y 10 10 16 13 13 16 16 16 22 16 13 13 13 13 13 22 13 FAIL  ideal_2D_oce
Y Y Y Y  8 16 16 16 16 16 16 16 16 13 13  8 16 16 16 16 16 FAIL  internal_wave
Y Y Y Y 14 16 16 16 16 16 16 16 16 13 13 22 13 13 13 22 16 pass  inverted_barometer
Y Y Y Y 12 16 16 16 16 16 16 16 16 16 13 12 13 13 13 13 13 FAIL  lab_sea
Y Y Y Y 11 16 16 16 16 16 16 16 13 13 13 12 13 16 13 12 13 FAIL  natl_box
Y Y Y Y 16 16 16 16 16 16 16 16 22 16 16 16 16 16 16 16 16 pass  plume_on_slope
Y Y Y Y 13 16 16 16 16 13 16 16 16 16 16 16 16 13 16 16 16 pass  solid-body.cs-32x32x1

1
2 #include "AUTODIFF_OPTIONS.h"
3
4 c ==================================================================
5 c
6 c active_file_control_loc.F: Routines to handle the i/o of active vari-
7 c ables for the adjoint calculations. All
8 c files are direct access files.
9 c
10 c Routines:
11 c
12 c o active_read_rl_loc - Basic routine to handle active read
13 c operations.
14 c o active_write_rl_loc - Basic routine to handle active write
15 c operations.
16 c
17 c
18 c ==================================================================
19
20 CBOP
21 C !ROUTINE: active_read_rl_loc
22 C !INTERFACE:
23 subroutine active_read_rl_loc(
24 I active_var_file,
25 O active_var,
26 I globalfile,
27 I lAdInit,
28 I irec,
29 I mynr,
30 I theSimulationMode,
31 I myOptimIter,
32 I mythid
33 & )
34
35 C !DESCRIPTION: \bv
36 c ==================================================================
37 c o Read an active _RL variable from file.
38 c The variable *globalfile* can be used as a switch, which allows
39 c to read from a global file. The adjoint files are, however, always
40 c treated as tiled files.
41 c started: Christian Eckert eckert@mit.edu Jan-1999
42 c ==================================================================
43 C \ev
44
45 C !USES:
46 implicit none
47
48 c == global variables ==
49 #include "EEPARAMS.h"
50 #include "SIZE.h"
51 #include "PARAMS.h"
52
53 C !INPUT/OUTPUT PARAMETERS:
54 c == routine arguments ==
55 c active_var_file: filename
56 c active_var: array
57 c irec: record number
58 c myOptimIter: number of optimization iteration (default: 0)
59 c mythid: thread number for this instance
60 c doglobalread: flag for global or local read/write
61 c (default: .false.)
62 c lAdInit: initialisation of corresponding adjoint
63 c variable and write to active file
64 c mynr: vertical array dimension
65 c theSimulationMode: forward mode or reverse mode simulation
66 character*(*) active_var_file
67 logical globalfile
68 logical lAdInit
69 integer irec
70 integer mynr
71 integer theSimulationMode
72 integer myOptimIter
73 integer mythid
74 _RL active_var(1-olx:snx+olx,1-oly:sny+oly,mynr,nsx,nsy)
75
76 C !LOCAL VARIABLES:
77 c == local variables ==
78 character*(2) adpref
79 character*(80) adfname
80 integer bi,bj
81 integer i,j,k
82 integer oldprec
83 integer prec
84 integer il
85 integer ilnblnk
86 logical writeglobalfile
87 _RL active_data_t(1-olx:snx+olx,1-oly:sny+oly,nsx,nsy)
88
89 c == functions ==
90 external ilnblnk
91
92 c == end of interface ==
93 CEOP
94
95 c force 64-bit io
96 oldPrec = readBinaryPrec
97 readBinaryPrec = precFloat64
98 prec = precFloat64
99
100 write(adfname(1:80),'(80a)') ' '
101 adpref = 'ad'
102 il = ilnblnk( active_var_file )
103
104 write(adfname(1:2),'(a)') adpref
105 write(adfname(3:il+2),'(a)') active_var_file(1:il)
106
107 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
108 c >>>>>>>>>>>>>>>>>>> FORWARD RUN <<<<<<<<<<<<<<<<<<<
109 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
110
111 if (theSimulationMode .eq. FORWARD_SIMULATION) then
112
113 _BEGIN_MASTER( mythid )
114
115 c Read the active variable from file.
116
117 call mdsreadfield_loc(
118 & active_var_file,
119 & prec,
120 & 'RL',
121 & mynr,
122 & active_var,
123 & irec,
124 & mythid )
125
126 if (lAdInit) then
127 c Initialise the corresponding adjoint variable on the
128 c adjoint variable's file. These files are tiled.
129
130 writeglobalfile = .false.
131 do bj = 1,nsy
132 do bi = 1,nsx
133 do j=1,sny
134 do i=1,snx
135 active_data_t(i,j,bi,bj)= 0. _d 0
136 enddo
137 enddo
138 enddo
139 enddo
140
141 do k = 1,mynr
142 call mdswritefield_loc(
143 & adfname,
144 & prec,
145 & globalfile,
146 & 'RL',
147 & 1,
148 & active_data_t,
149 & (irec-1)*mynr+k,
150 & myOptimIter,
151 & mythid )
152 enddo
153 endif
154
155 _END_MASTER( mythid )
156
157 endif
158
159 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
160 c >>>>>>>>>>>>>>>>>>> ADJOINT RUN <<<<<<<<<<<<<<<<<<<
161 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
162
163 if (theSimulationMode .eq. REVERSE_SIMULATION) then
164
165 _BEGIN_MASTER( mythid )
166
167 writeglobalfile = .false.
168 do k=1,mynr
169 c Read data from file layer by layer.
170 call mdsreadfield_loc(
171 & active_var_file,
172 & prec,
173 & 'RL',
174 & 1,
175 & active_data_t,
176 & (irec-1)*mynr+k,
177 & mythid )
178
179 c Add active_var from appropriate location to data.
180 do bj = 1,nsy
181 do bi = 1,nsx
182 do j=1,sny
183 do i=1,snx
184 active_data_t(i,j,bi,bj) = active_data_t(i,j,bi,bj) +
185 & active_var(i,j,k,bi,bj)
186 enddo
187 enddo
188 enddo
189 enddo
190
191 c Store the result on disk.
192 call mdswritefield_loc(
193 & active_var_file,
194 & prec,
195 & writeglobalfile,
196 & 'RL',
197 & 1,
198 & active_data_t,
199 & (irec-1)*mynr+k,
200 & myOptimIter,
201 & mythid )
202 enddo
203
204
205 c Set active_var to zero.
206 do k=1,mynr
207 do bj = 1,nsy
208 do bi = 1,nsx
209 do j=1,sny
210 do i=1,snx
211 active_var(i,j,k,bi,bj) = 0. _d 0
212 enddo
213 enddo
214 enddo
215 enddo
216 enddo
217
218 _END_MASTER( mythid )
219 endif
220
221 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
222 c >>>>>>>>>>>>>>>>>>> TANGENT RUN <<<<<<<<<<<<<<<<<<<
223 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
224
225 if (theSimulationMode .eq. TANGENT_SIMULATION) then
226
227 _BEGIN_MASTER( mythid )
228
229 c Read the active variable from file.
230
231 call mdsreadfield_loc(
232 & active_var_file,
233 & prec,
234 & 'RL',
235 & mynr,
236 & active_var,
237 & irec,
238 & mythid )
239
240 _END_MASTER( mythid )
241 endif
242
243 c Reset default io precision.
244 readBinaryPrec = oldPrec
245
246 _BARRIER
247
248 return
249 end
250
251
252 CBOP
253 C !ROUTINE: active_write_rl_loc
254 C !INTERFACE:
255 subroutine active_write_rl_loc(
256 I active_var_file,
257 I active_var,
258 I globalfile,
259 I irec,
260 I mynr,
261 I theSimulationMode,
262 I myOptimIter,
263 I mythid
264 & )
265
266 C !DESCRIPTION: \bv
267 c ==================================================================
268 c o Write an active _RL variable to a file.
269 c started: Christian Eckert eckert@mit.edu Jan-1999
270 c ==================================================================
271 C \ev
272
273 C !USES:
274 implicit none
275
276 c == global variables ==
277 #include "EEPARAMS.h"
278 #include "SIZE.h"
279 #include "PARAMS.h"
280
281 C !INPUT/OUTPUT PARAMETERS:
282 c == routine arguments ==
283 c active_var_file: filename
284 c active_var: array
285 c irec: record number
286 c myOptimIter: number of optimization iteration (default: 0)
287 c mythid: thread number for this instance
288 c doglobalread: flag for global or local read/write
289 c (default: .false.)
290 c lAdInit: initialisation of corresponding adjoint
291 c variable and write to active file
292 c mynr: vertical array dimension
293 c theSimulationMode: forward mode or reverse mode simulation
294 character*(*) active_var_file
295 integer mynr
296 logical globalfile
297 integer irec
298 integer theSimulationMode
299 integer myOptimIter
300 integer mythid
301 _RL active_var(1-olx:snx+olx,1-oly:sny+oly,mynr,nsx,nsy)
302
303 C !LOCAL VARIABLES:
304 c == local variables ==
305 integer i,j,k
306 integer bi,bj
307 _RL active_data_t(1-olx:snx+olx,1-oly:sny+oly,nsx,nsy)
308 integer oldprec
309 integer prec
310
311 c == end of interface ==
312 CEOP
313
314 c force 64-bit io
315 oldPrec = readBinaryPrec
316 readBinaryPrec = precFloat64
317 prec = precFloat64
318
319 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
320 c >>>>>>>>>>>>>>>>>>> FORWARD RUN <<<<<<<<<<<<<<<<<<<
321 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
322
323 if (theSimulationMode .eq. FORWARD_SIMULATION) then
324
325 _BEGIN_MASTER( mythid )
326
327 call mdswritefield_loc(
328 & active_var_file,
329 & prec,
330 & globalfile,
331 & 'RL',
332 & mynr,
333 & active_var,
334 & irec,
335 & myOptimIter,
336 & mythid )
337
338 _END_MASTER( mythid )
339
340 endif
341
342 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
343 c >>>>>>>>>>>>>>>>>>> ADJOINT RUN <<<<<<<<<<<<<<<<<<<
344 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
345
346 if (theSimulationMode .eq. REVERSE_SIMULATION) then
347
348 _BEGIN_MASTER( mythid )
349
350 do k=1,mynr
351 c Read data from file layer by layer.
352 call mdsreadfield_loc(
353 & active_var_file,
354 & prec,
355 & 'RL',
356 & 1,
357 & active_data_t,
358 & (irec-1)*mynr+k,
359 & mythid )
360
361 c Add active_var from appropriate location to data.
362 do bj = 1,nsy
363 do bi = 1,nsx
364 do j=1,sny
365 do i=1,snx
366 active_var(i,j,k,bi,bj) =
367 & active_var(i,j,k,bi,bj) +
368 & active_data_t(i,j,bi,bj)
369 active_data_t(i,j,bi,bj) = 0. _d 0
370 enddo
371 enddo
372 enddo
373 enddo
374 call mdswritefield_loc(
375 & active_var_file,
376 & prec,
377 & globalfile,
378 & 'RL',
379 & 1,
380 & active_data_t,
381 & (irec-1)*mynr+k,
382 & myOptimIter,
383 & mythid )
384 enddo
385
386 _END_MASTER( mythid )
387
388 endif
389
390 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
391 c >>>>>>>>>>>>>>>>>>> TANGENT RUN <<<<<<<<<<<<<<<<<<<
392 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
393
394 if (theSimulationMode .eq. TANGENT_SIMULATION) then
395
396 _BEGIN_MASTER( mythid )
397
398 call mdswritefield_loc(
399 & active_var_file,
400 & prec,
401 & globalfile,
402 & 'RL',
403 & mynr,
404 & active_var,
405 & irec,
406 & myOptimIter,
407 & mythid )
408
409 _END_MASTER( mythid )
410
411 endif
412
413 c Reset default io precision.
414 readBinaryPrec = oldPrec
415
416 _BARRIER
417
418 return
419 end
420

  ViewVC Help
Powered by ViewVC 1.1.22