/[MITgcm]/MITgcm/pkg/profiles/active_file_control_profiles.F
ViewVC logotype

Contents of /MITgcm/pkg/profiles/active_file_control_profiles.F

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


Revision 1.5 - (show annotations) (download)
Tue Oct 9 00:07:59 2007 UTC (16 years, 8 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint60, checkpoint61, checkpoint62, checkpoint59q, checkpoint59p, checkpoint59r, checkpoint59m, checkpoint59l, checkpoint59o, checkpoint59n, checkpoint59i, checkpoint59k, checkpoint59j, checkpoint62c, checkpoint62b, checkpoint62a, checkpoint62g, checkpoint62f, checkpoint62e, checkpoint62d, checkpoint62i, checkpoint62h, checkpoint61f, checkpoint61g, checkpoint61d, checkpoint61e, checkpoint61b, checkpoint61c, checkpoint61a, checkpoint61n, checkpoint61o, checkpoint61l, checkpoint61m, checkpoint61j, checkpoint61k, checkpoint61h, checkpoint61i, checkpoint61v, checkpoint61w, checkpoint61t, checkpoint61u, checkpoint61r, checkpoint61s, checkpoint61p, checkpoint61q, checkpoint61z, checkpoint61x, checkpoint61y
Changes since 1.4: +8 -6 lines
add missing cvs $Header:$ or $Name:$

1 C $Header: $
2 C $Name: $
3
4 #include "PROFILES_OPTIONS.h"
5
6 C o==========================================================o
7 C | subroutine active_file_control_profile |
8 C | o handles the i/o of active variables for the adjoint |
9 C | calculations, related to netcdf profiles data files |
10 C | o active_read_profile_rl, active_write_profile_rl |
11 C | started: Gael Forget 15-March-2006 |
12 C o==========================================================o
13
14 subroutine active_read_profile_rl(
15 I fid,
16 I active_num_file,
17 I nactive_var,
18 O active_var,
19 I active_varnum,
20 I lAdInit,
21 I irec,
22 I irecglob,
23 I theSimulationMode,
24 I myOptimIter,
25 I bi,
26 I bj,
27 I mythid
28 & )
29
30 c ==================================================================
31 c
32 c o Read an active 1D record.
33 c
34 c ==================================================================
35
36 implicit none
37
38 c == global variables ==
39
40 #include "EEPARAMS.h"
41 #include "SIZE.h"
42 #include "PARAMS.h"
43 #ifdef ALLOW_PROFILES
44 #include "netcdf.inc"
45 #include "profiles.h"
46 #endif
47
48 c == routine arguments ==
49
50 integer err, fid, varid1 , vec_start(2), vec_count(2)
51
52 logical lAdInit
53 integer irec, irecglob,active_varnum
54 integer theSimulationMode
55 integer myOptimIter
56 integer bi,bj,mythid
57 integer nactive_var,active_num_file
58 _RL active_var(nactive_var)
59 _RL active_data_t(nactive_var)
60 integer i,ivar
61 real*8 vec_tmp(nactive_var+1)
62
63 #ifdef ALLOW_PROFILES
64
65 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
66 c >>>>>>>>>>>>>>>>>>> FORWARD RUN <<<<<<<<<<<<<<<<<<<
67 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
68
69 if (theSimulationMode .eq. FORWARD_SIMULATION) then
70
71 _BEGIN_MASTER( mythid )
72
73 if (profilesfile_equi_type.EQ.1) then
74 vec_start(1)=1
75 vec_start(2)=irec
76 vec_count(1)=nactive_var
77 vec_count(2)=1
78
79 err = NF_INQ_VARID(fid,prof_names(active_varnum), varid1 )
80 err = NF_GET_VARA_DOUBLE(fid, varid1 , vec_start, vec_count,
81 & active_var)
82
83 err = NF_INQ_VARID(fid,prof_namesmask(active_varnum)
84 & ,varid1)
85 err = NF_GET_VARA_DOUBLE(fid, varid1 , vec_start, vec_count,
86 & prof_mask1D_cur(1,bi,bj))
87
88 else
89
90 read(fid,rec=( (irec-1)*prof_num_var_tot(active_num_file,bi,bj)
91 & +prof_num_var_cur(active_num_file,active_varnum,bi,bj)-1)*2+1 )
92 & vec_tmp
93 #ifdef _BYTESWAPIO
94 call MDS_BYTESWAPR8(nactive_var+1,vec_tmp)
95 #endif
96 do ivar=1,nactive_var
97 active_var(ivar)=vec_tmp(ivar)
98 enddo
99 read(fid,rec=( (irec-1)*prof_num_var_tot(active_num_file,bi,bj)
100 & +prof_num_var_cur(active_num_file,active_varnum,bi,bj)-1)*2+2 )
101 & vec_tmp
102 #ifdef _BYTESWAPIO
103 call MDS_BYTESWAPR8(nactive_var+1,vec_tmp)
104 #endif
105 do ivar=1,nactive_var
106 prof_mask1D_cur(ivar,bi,bj)=vec_tmp(ivar)
107 enddo
108
109 endif
110
111 _END_MASTER( mythid )
112
113 endif
114
115 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
116 c >>>>>>>>>>>>>>>>>>> ADJOINT RUN <<<<<<<<<<<<<<<<<<<
117 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
118
119 if (theSimulationMode .eq. REVERSE_SIMULATION) then
120
121 _BEGIN_MASTER( mythid )
122
123 if (profilesfile_equi_type.EQ.1) then
124
125 vec_start(1)=1
126 vec_start(2)=irec
127 vec_count(1)=nactive_var
128 vec_count(2)=1
129
130 err = NF_INQ_VARID(fid,prof_names(active_varnum), varid1 )
131 err = NF_GET_VARA_DOUBLE(fid, varid1 , vec_start, vec_count,
132 & active_data_t)
133
134 c Add active_var from appropriate location to data.
135 do i = 1,nactive_var
136 active_data_t(i) = active_data_t(i) + active_var(i)
137 enddo
138 c Store the result on disk.
139 vec_start(1)=1
140 vec_start(2)=irec
141 vec_count(1)=nactive_var
142 vec_count(2)=1
143
144 err = NF_INQ_VARID(fid,prof_names(active_varnum), varid1 )
145 err = NF_PUT_VARA_DOUBLE(fid, varid1 , vec_start, vec_count,
146 & active_data_t)
147
148 c Set active_var to zero.
149 do i = 1,nactive_var
150 active_var(i) = 0. _d 0
151 enddo
152
153 else
154
155
156 read(fid,rec=( (irec-1)*prof_num_var_tot(active_num_file,bi,bj)
157 & +prof_num_var_cur(active_num_file,active_varnum,bi,bj)-1)*2+1 )
158 & vec_tmp
159 #ifdef _BYTESWAPIO
160 call MDS_BYTESWAPR8(nactive_var+1,vec_tmp)
161 #endif
162 do ivar=1,nactive_var
163 active_data_t(ivar)=vec_tmp(ivar)
164 enddo
165
166 c Add active_var from appropriate location to data.
167 do i = 1,nactive_var
168 active_data_t(i) = active_data_t(i) + active_var(i)
169 enddo
170
171 c Store the result on disk.
172 do ivar=1,nactive_var
173 vec_tmp(ivar)=active_data_t(ivar)
174 enddo
175 #ifdef _BYTESWAPIO
176 call MDS_BYTESWAPR8(nactive_var+1,vec_tmp)
177 #endif
178 write(fid,rec=( (irec-1)*prof_num_var_tot(active_num_file,bi,bj)
179 & +prof_num_var_cur(active_num_file,active_varnum,bi,bj)-1)*2+1 )
180 & vec_tmp
181
182 c Set active_var to zero.
183 do i = 1,nactive_var
184 active_var(i) = 0. _d 0
185 enddo
186
187 endif
188
189 _END_MASTER( mythid )
190
191 endif
192
193 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
194 c >>>>>>>>>>>>>>>>>>> TANGENT RUN <<<<<<<<<<<<<<<<<<<
195 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
196
197 if (theSimulationMode .eq. TANGENT_SIMULATION) then
198
199 _BEGIN_MASTER( mythid )
200
201 if (profilesfile_equi_type.EQ.1) then
202
203 vec_start(1)=1
204 vec_start(2)=irec
205 vec_count(1)=nactive_var
206 vec_count(2)=1
207
208 err = NF_INQ_VARID(fid,prof_names(active_varnum), varid1 )
209 err = NF_GET_VARA_DOUBLE(fid, varid1 , vec_start, vec_count,
210 & active_var)
211
212 else
213
214 read(fid,rec=( (irec-1)*prof_num_var_tot(active_num_file,bi,bj)
215 & +prof_num_var_cur(active_num_file,active_varnum,bi,bj)-1)*2+1 )
216 & vec_tmp
217 #ifdef _BYTESWAPIO
218 call MDS_BYTESWAPR8(nactive_var+1,vec_tmp)
219 #endif
220 do ivar=1,nactive_var
221 active_var(ivar)=vec_tmp(ivar)
222 enddo
223
224 endif
225
226 _END_MASTER( mythid )
227
228 endif
229
230
231 #endif /* ALLOW_PROFILES */
232
233 return
234 end
235
236 c ==================================================================
237
238
239 subroutine active_write_profile_rl(
240 I fid,
241 I active_num_file,
242 I nactive_var,
243 I active_var,
244 I active_varnum,
245 I irec,
246 I irecglob,
247 I theSimulationMode,
248 I myOptimIter,
249 I bi,
250 I bj,
251 I mythid
252 & )
253
254 c ==================================================================
255 c
256 c o Write an active 1D record to a file.
257 c
258 c ==================================================================
259
260 implicit none
261
262 c == global variables ==
263
264 #include "EEPARAMS.h"
265 #include "SIZE.h"
266 #include "PARAMS.h"
267 #ifdef ALLOW_PROFILES
268 #include "netcdf.inc"
269 #include "profiles.h"
270 #endif
271
272 c == routine arguments ==
273
274 integer err, fid, varid1 , vec_start(2), vec_count(2)
275 integer ivar, irec, irecglob,active_varnum
276 integer theSimulationMode
277 integer myOptimIter
278 integer bi,bj,mythid
279 integer nactive_var,active_num_file
280 _RL active_var(nactive_var)
281 real*8 vec_tmp(nactive_var+1)
282
283 #ifdef ALLOW_PROFILES
284 c == local variables ==
285
286 integer i
287 _RL active_data_t(nactive_var)
288
289 c == end of interface ==
290
291 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
292 c >>>>>>>>>>>>>>>>>>> FORWARD RUN <<<<<<<<<<<<<<<<<<<
293 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
294
295
296 if (theSimulationMode .eq. FORWARD_SIMULATION) then
297
298 _BEGIN_MASTER( mythid )
299
300 if (profilesfile_equi_type.EQ.1) then
301
302 vec_start(1)=1
303 vec_start(2)=irec
304 vec_count(1)=nactive_var
305 vec_count(2)=1
306
307 err = NF_INQ_VARID(fid,prof_names(active_varnum), varid1 )
308 err = NF_PUT_VARA_DOUBLE(fid, varid1 , vec_start, vec_count,
309 & active_var)
310
311 err = NF_INQ_VARID(fid,prof_namesmask(active_varnum),
312 & varid1 )
313 err = NF_PUT_VARA_DOUBLE(fid, varid1 , vec_start, vec_count,
314 & prof_mask1D_cur(1,bi,bj))
315
316 err = NF_INQ_VARID(fid,'prof_ind_glob', varid1 )
317 err = NF_PUT_VAR1_INT(fid, varid1 , vec_start(2),
318 & irecglob)
319
320 else
321
322
323 do ivar=1,nactive_var
324 vec_tmp(ivar)=active_var(ivar)
325 enddo
326 vec_tmp(nactive_var+1)=irecglob
327 #ifdef _BYTESWAPIO
328 call MDS_BYTESWAPR8(nactive_var+1,vec_tmp)
329 #endif
330 write(fid,rec=( (irec-1)*prof_num_var_tot(active_num_file,bi,bj)
331 & +prof_num_var_cur(active_num_file,active_varnum,bi,bj)-1)*2+1 )
332 & vec_tmp
333 do ivar=1,nactive_var
334 vec_tmp(ivar)=prof_mask1D_cur(ivar,bi,bj)
335 enddo
336 vec_tmp(nactive_var+1)=irecglob
337 #ifdef _BYTESWAPIO
338 call MDS_BYTESWAPR8(nactive_var+1,vec_tmp)
339 #endif
340 write(fid,rec=( (irec-1)*prof_num_var_tot(active_num_file,bi,bj)
341 & +prof_num_var_cur(active_num_file,active_varnum,bi,bj)-1)*2+2 )
342 & vec_tmp
343
344 endif
345
346
347 _END_MASTER( mythid )
348
349 endif
350
351 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
352 c >>>>>>>>>>>>>>>>>>> ADJOINT RUN <<<<<<<<<<<<<<<<<<<
353 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
354
355 if (theSimulationMode .eq. REVERSE_SIMULATION) then
356
357 _BEGIN_MASTER( mythid )
358
359 if (profilesfile_equi_type.EQ.1) then
360
361 vec_start(1)=1
362 vec_start(2)=irec
363 vec_count(1)=nactive_var
364 vec_count(2)=1
365 err = NF_INQ_VARID(fid,prof_names(active_varnum) , varid1 )
366 err = NF_GET_VARA_DOUBLE(fid, varid1 , vec_start, vec_count,
367 & active_data_t)
368
369 c Add active_var to data.
370 do i = 1,nactive_var
371 active_var(i) = active_var(i) + active_data_t(i)
372 active_data_t(i) = 0. _d 0
373 enddo
374
375 vec_start(1)=1
376 vec_start(2)=irec
377 vec_count(1)=nactive_var
378 vec_count(2)=1
379
380 err = NF_INQ_VARID(fid,prof_names(active_varnum), varid1 )
381 err = NF_PUT_VARA_DOUBLE(fid, varid1 , vec_start, vec_count,
382 & active_data_t)
383
384 else
385
386
387 read(fid,rec=( (irec-1)*prof_num_var_tot(active_num_file,bi,bj)
388 & +prof_num_var_cur(active_num_file,active_varnum,bi,bj)-1)*2+1 )
389 & vec_tmp
390 #ifdef _BYTESWAPIO
391 call MDS_BYTESWAPR8(nactive_var+1,vec_tmp)
392 #endif
393 do ivar=1,nactive_var
394 active_data_t(ivar)=vec_tmp(ivar)
395 enddo
396
397 c Add active_var from appropriate location to data.
398 do i = 1,nactive_var
399 active_var(i) = active_var(i) + active_data_t(i)
400 active_data_t(i) = 0. _d 0
401 enddo
402
403 c Store the result on disk.
404 do ivar=1,nactive_var
405 vec_tmp(ivar)=active_data_t(ivar)
406 enddo
407 #ifdef _BYTESWAPIO
408 call MDS_BYTESWAPR8(nactive_var+1,vec_tmp)
409 #endif
410 write(fid,rec=( (irec-1)*prof_num_var_tot(active_num_file,bi,bj)
411 & +prof_num_var_cur(active_num_file,active_varnum,bi,bj)-1)*2+1 )
412 & vec_tmp
413
414 endif
415
416
417 _END_MASTER( mythid )
418
419 endif
420
421 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
422 c >>>>>>>>>>>>>>>>>>> TANGENT RUN <<<<<<<<<<<<<<<<<<<
423 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
424
425 if (theSimulationMode .eq. TANGENT_SIMULATION) then
426
427 _BEGIN_MASTER( mythid )
428
429 if (profilesfile_equi_type.EQ.1) then
430
431 vec_start(1)=1
432 vec_start(2)=irec
433 vec_count(1)=nactive_var
434 vec_count(2)=1
435
436 err = NF_INQ_VARID(fid, prof_names(active_varnum), varid1 )
437 err = NF_PUT_VARA_DOUBLE(fid, varid1 , vec_start, vec_count,
438 & active_var)
439
440 else
441
442
443 do ivar=1,nactive_var
444 vec_tmp(ivar)=active_var(ivar)
445 enddo
446 vec_tmp(nactive_var+1)=irecglob
447 #ifdef _BYTESWAPIO
448 call MDS_BYTESWAPR8(nactive_var+1,vec_tmp)
449 #endif
450 write(fid,rec=( (irec-1)*prof_num_var_tot(active_num_file,bi,bj)
451 & +prof_num_var_cur(active_num_file,active_varnum,bi,bj)-1)*2+1 )
452 & vec_tmp
453
454 endif
455
456
457 _END_MASTER( mythid )
458
459 endif
460
461
462 #endif /* ALLOW_PROFILES */
463
464 return
465 end
466

  ViewVC Help
Powered by ViewVC 1.1.22