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

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

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


Revision 1.8 - (show annotations) (download)
Fri Aug 3 18:50:01 2012 UTC (11 years, 10 months ago) by jmc
Branch: MAIN
CVS Tags: HEAD
Changes since 1.7: +1 -1 lines
FILE REMOVED
remove (no longer used with added argument "useCurrentDir" to high level
 active I/O S/R ACTIVE_READ/WRITE_3D/XZ/YZ_RL)

1 C $Header: /u/gcmpack/MITgcm/pkg/autodiff/active_file_loc_control_slice.F,v 1.7 2010/03/22 02:15:02 jmc Exp $
2 C $Name: $
3
4 #include "AUTODIFF_OPTIONS.h"
5
6 c ==================================================================
7 c
8 c active_file_control.F: Routines to handle the i/o of active vari-
9 c ables for the adjoint calculations. All
10 c files are direct access files.
11 c
12 c Routines:
13 c
14 c o active_read_xz_rl_loc - Basic routine to handle active read
15 c operations.
16 c o active_write_xz_rl_loc - Basic routine to handle active write
17 c operations.
18 c o active_read_yz_rl_loc - Basic routine to handle active read
19 c operations.
20 c o active_write_yz_rl_loc - Basic routine to handle active write
21 c operations.
22 c
23 c ==================================================================
24
25
26 subroutine active_read_xz_rl_loc(
27 I active_var_file,
28 O active_var,
29 I globalfile,
30 I lAdInit,
31 I irec,
32 I mynr,
33 I theSimulationMode,
34 I myOptimIter,
35 I mythid
36 & )
37
38 c ==================================================================
39 c
40 c o Read an active variable from file.
41 c
42 c The variable *globalfile* can be used as a switch, which allows
43 c to read from a global file. The adjoint files are, however, always
44 c treated as tiled files.
45 c
46 c started: heimbach@mit.edu 05-Mar-2001
47 c
48 c ==================================================================
49
50 implicit none
51
52 c == global variables ==
53
54 #include "EEPARAMS.h"
55 #include "SIZE.h"
56 #include "PARAMS.h"
57 #include "ctrl.h"
58
59 c == routine arguments ==
60
61 character*(*) active_var_file
62
63 logical globalfile
64 logical lAdInit
65 integer irec
66 integer mynr
67 integer theSimulationMode
68 integer myOptimIter
69 integer mythid
70 _RL active_var(1-olx:snx+olx,mynr,nsx,nsy)
71
72 c == local variables ==
73
74 character*(2) adpref
75 character*(80) adfname
76
77 integer bi,bj
78 integer i,j,k
79 integer oldprec
80 integer prec
81 integer il
82 integer ilnblnk
83
84 logical writeglobalfile
85
86 _RL active_data_t(1-olx:snx+olx,mynr,nsx,nsy)
87
88 c == functions ==
89
90 external ilnblnk
91
92 c == end of interface ==
93
94 c force 64-bit io
95 oldPrec = readBinaryPrec
96 readBinaryPrec = ctrlprec
97 prec = ctrlprec
98
99 write(adfname(1:80),'(80a)') ' '
100 adpref = 'ad'
101 il = ilnblnk( active_var_file )
102
103 write(adfname(1:2),'(a)') adpref
104 write(adfname(3:il+2),'(a)') active_var_file(1:il)
105
106 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
107 c >>>>>>>>>>>>>>>>>>> FORWARD RUN <<<<<<<<<<<<<<<<<<<
108 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
109
110 if (theSimulationMode .eq. FORWARD_SIMULATION) then
111
112 _BEGIN_MASTER( mythid )
113
114 c Read the active variable from file.
115
116 call mdsreadfieldxz_loc(
117 & active_var_file,
118 & prec,
119 & 'RL',
120 & mynr,
121 & active_var,
122 & irec,
123 & mythid )
124
125 if (lAdInit) then
126 c Initialise the corresponding adjoint variable on the
127 c adjoint variable file. These files are tiled.
128
129 writeglobalfile = .false.
130 do bj = 1,nsy
131 do bi = 1,nsx
132 do k = 1,mynr
133 do i = 1,snx
134 active_data_t(i,k,bi,bj)= 0. _d 0
135 enddo
136 enddo
137 enddo
138 enddo
139
140 call mdswritefieldxz_loc(
141 & adfname,
142 & prec,
143 & globalfile,
144 & 'RL',
145 & mynr,
146 & active_data_t,
147 & irec,
148 & myOptimIter,
149 & mythid )
150 endif
151
152 _END_MASTER( mythid )
153
154 endif
155
156 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
157 c >>>>>>>>>>>>>>>>>>> ADJOINT RUN <<<<<<<<<<<<<<<<<<<
158 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
159
160 if (theSimulationMode .eq. REVERSE_SIMULATION) then
161
162 _BEGIN_MASTER( mythid )
163
164 writeglobalfile = .false.
165 call mdsreadfieldxz_loc(
166 & active_var_file,
167 & prec,
168 & 'RL',
169 & mynr,
170 & active_data_t,
171 & irec,
172 & mythid )
173
174 c Add active_var from appropriate location to data.
175 do bj = 1,nsy
176 do bi = 1,nsx
177 do k = 1,mynr
178 do i = 1,snx
179 active_data_t(i,k,bi,bj) =
180 & active_data_t(i,k,bi,bj) +
181 & active_var(i,k,bi,bj)
182 enddo
183 enddo
184 enddo
185 enddo
186
187 c Store the result on disk.
188 call mdswritefieldxz_loc(
189 & active_var_file,
190 & prec,
191 & writeglobalfile,
192 & 'RL',
193 & mynr,
194 & active_data_t,
195 & irec,
196 & myOptimIter,
197 & mythid )
198
199 c Set active_var to zero.
200 do bj = 1,nsy
201 do bi = 1,nsx
202 do k=1,mynr
203 do i = 1,snx
204 active_var(i,k,bi,bj) = 0. _d 0
205 enddo
206 enddo
207 enddo
208 enddo
209
210 _END_MASTER( mythid )
211 endif
212
213 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
214 c >>>>>>>>>>>>>>>>>>> TANGENT RUN <<<<<<<<<<<<<<<<<<<
215 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
216
217 if (theSimulationMode .eq. TANGENT_SIMULATION) then
218
219 _BEGIN_MASTER( mythid )
220
221 c Read the active variable from file.
222
223 call mdsreadfieldxz_loc(
224 & active_var_file,
225 & prec,
226 & 'RL',
227 & mynr,
228 & active_var,
229 & irec,
230 & mythid )
231
232 _END_MASTER( mythid )
233
234 endif
235
236 c Reset default io precision.
237 readBinaryPrec = oldPrec
238
239 _BARRIER
240
241 return
242 end
243
244 c ==================================================================
245
246 subroutine active_write_xz_rl_loc(
247 I active_var_file,
248 I active_var,
249 I globalfile,
250 I irec,
251 I mynr,
252 I theSimulationMode,
253 I myOptimIter,
254 I mythid
255 & )
256
257 c ==================================================================
258 c
259 c o Write an active variable to a file.
260 c
261 c started: heimbach@mit.edu 05-Mar-2001
262 c
263 c ==================================================================
264
265 implicit none
266
267 c == global variables ==
268
269 #include "EEPARAMS.h"
270 #include "SIZE.h"
271 #include "PARAMS.h"
272 #include "ctrl.h"
273
274 c == routine arguments ==
275
276 character*(*) active_var_file
277
278 integer mynr
279 logical globalfile
280 integer irec
281 integer theSimulationMode
282 integer myOptimIter
283 integer mythid
284 _RL active_var(1-olx:snx+olx,mynr,nsx,nsy)
285
286 c == local variables ==
287
288 integer i,j,k
289 integer bi,bj
290 _RL active_data_t(1-olx:snx+olx,mynr,nsx,nsy)
291 integer oldprec
292 integer prec
293
294 c == end of interface ==
295
296 c force 64-bit io
297 oldPrec = readBinaryPrec
298 readBinaryPrec = ctrlprec
299 prec = ctrlprec
300
301 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
302 c >>>>>>>>>>>>>>>>>>> FORWARD RUN <<<<<<<<<<<<<<<<<<<
303 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
304
305 if (theSimulationMode .eq. FORWARD_SIMULATION) then
306
307 _BEGIN_MASTER( mythid )
308
309 call mdswritefieldxz_loc(
310 & active_var_file,
311 & prec,
312 & globalfile,
313 & 'RL',
314 & mynr,
315 & active_var,
316 & irec,
317 & myOptimIter,
318 & mythid )
319
320 _END_MASTER( mythid )
321
322 endif
323
324 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
325 c >>>>>>>>>>>>>>>>>>> ADJOINT RUN <<<<<<<<<<<<<<<<<<<
326 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
327
328 if (theSimulationMode .eq. REVERSE_SIMULATION) then
329
330 _BEGIN_MASTER( mythid )
331
332 call mdsreadfieldxz_loc(
333 & active_var_file,
334 & prec,
335 & 'RL',
336 & mynr,
337 & active_data_t,
338 & irec,
339 & mythid )
340
341 c Add active_var from appropriate location to data.
342 do bj = 1,nsy
343 do bi = 1,nsx
344 do k = 1,mynr
345 do i = 1,snx
346 active_var(i,k,bi,bj) =
347 & active_var(i,k,bi,bj) +
348 & active_data_t(i,k,bi,bj)
349 active_data_t(i,k,bi,bj) = 0. _d 0
350 enddo
351 enddo
352 enddo
353 enddo
354 call mdswritefieldxz_loc(
355 & active_var_file,
356 & prec,
357 & globalfile,
358 & 'RL',
359 & mynr,
360 & active_data_t,
361 & irec,
362 & myOptimIter,
363 & mythid )
364
365 _END_MASTER( mythid )
366
367 endif
368
369 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
370 c >>>>>>>>>>>>>>>>>>> TANGENT RUN <<<<<<<<<<<<<<<<<<<
371 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
372
373 if (theSimulationMode .eq. TANGENT_SIMULATION) then
374
375 _BEGIN_MASTER( mythid )
376
377 call mdswritefieldxz_loc(
378 & active_var_file,
379 & prec,
380 & globalfile,
381 & 'RL',
382 & mynr,
383 & active_var,
384 & irec,
385 & myOptimIter,
386 & mythid )
387
388 _END_MASTER( mythid )
389
390 endif
391
392 c Reset default io precision.
393 readBinaryPrec = oldPrec
394
395 _BARRIER
396
397 return
398 end
399
400 c ==================================================================
401
402 subroutine active_read_yz_rl_loc(
403 I active_var_file,
404 O active_var,
405 I globalfile,
406 I lAdInit,
407 I irec,
408 I mynr,
409 I theSimulationMode,
410 I myOptimIter,
411 I mythid
412 & )
413
414 c ==================================================================
415 c
416 c o Read an active variable from file.
417 c
418 c The variable *globalfile* can be used as a switch, which allows
419 c to read from a global file. The adjoint files are, however, always
420 c treated as tiled files.
421 c
422 c started: heimbach@mit.edu 05-Mar-2001
423 c
424 c ==================================================================
425
426 implicit none
427
428 c == global variables ==
429
430 #include "EEPARAMS.h"
431 #include "SIZE.h"
432 #include "PARAMS.h"
433 #include "ctrl.h"
434
435 c == routine arguments ==
436
437 character*(*) active_var_file
438
439 logical globalfile
440 logical lAdInit
441 integer irec
442 integer mynr
443 integer theSimulationMode
444 integer myOptimIter
445 integer mythid
446 _RL active_var(1-oly:sny+oly,mynr,nsx,nsy)
447
448 c == local variables ==
449
450 character*(2) adpref
451 character*(80) adfname
452
453 integer bi,bj
454 integer i,j,k
455 integer oldprec
456 integer prec
457 integer il
458 integer ilnblnk
459
460 logical writeglobalfile
461
462 _RL active_data_t(1-oly:sny+oly,mynr,nsx,nsy)
463
464 c == functions ==
465
466 external ilnblnk
467
468 c == end of interface ==
469
470 c force 64-bit io
471 oldPrec = readBinaryPrec
472 readBinaryPrec = ctrlprec
473 prec = ctrlprec
474
475 write(adfname(1:80),'(80a)') ' '
476 adpref = 'ad'
477 il = ilnblnk( active_var_file )
478
479 write(adfname(1:2),'(a)') adpref
480 write(adfname(3:il+2),'(a)') active_var_file(1:il)
481
482 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
483 c >>>>>>>>>>>>>>>>>>> FORWARD RUN <<<<<<<<<<<<<<<<<<<
484 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
485
486 if (theSimulationMode .eq. FORWARD_SIMULATION) then
487
488 _BEGIN_MASTER( mythid )
489
490 c Read the active variable from file.
491
492 call mdsreadfieldyz_loc(
493 & active_var_file,
494 & prec,
495 & 'RL',
496 & mynr,
497 & active_var,
498 & irec,
499 & mythid )
500
501 if (lAdInit) then
502 c Initialise the corresponding adjoint variable on the
503 c adjoint variable file. These files are tiled.
504
505 writeglobalfile = .false.
506 do bj = 1,nsy
507 do bi = 1,nsx
508 do k = 1,mynr
509 do j = 1,sny
510 active_data_t(j,k,bi,bj)= 0. _d 0
511 enddo
512 enddo
513 enddo
514 enddo
515
516 call mdswritefieldyz_loc(
517 & adfname,
518 & prec,
519 & globalfile,
520 & 'RL',
521 & mynr,
522 & active_data_t,
523 & irec,
524 & myOptimIter,
525 & mythid )
526 endif
527
528 _END_MASTER( mythid )
529
530 endif
531
532 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
533 c >>>>>>>>>>>>>>>>>>> ADJOINT RUN <<<<<<<<<<<<<<<<<<<
534 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
535
536 if (theSimulationMode .eq. REVERSE_SIMULATION) then
537
538 _BEGIN_MASTER( mythid )
539
540 writeglobalfile = .false.
541 call mdsreadfieldyz_loc(
542 & active_var_file,
543 & prec,
544 & 'RL',
545 & mynr,
546 & active_data_t,
547 & irec,
548 & mythid )
549
550 c Add active_var from appropriate location to data.
551 do bj = 1,nsy
552 do bi = 1,nsx
553 do k = 1,mynr
554 do j = 1,sny
555 active_data_t(j,k,bi,bj) =
556 & active_data_t(j,k,bi,bj) +
557 & active_var(j,k,bi,bj)
558 enddo
559 enddo
560 enddo
561 enddo
562
563 c Store the result on disk.
564 call mdswritefieldyz_loc(
565 & active_var_file,
566 & prec,
567 & writeglobalfile,
568 & 'RL',
569 & mynr,
570 & active_data_t,
571 & irec,
572 & myOptimIter,
573 & mythid )
574
575 c Set active_var to zero.
576 do bj = 1,nsy
577 do bi = 1,nsx
578 do k = 1,mynr
579 do j = 1,sny
580 active_var(j,k,bi,bj) = 0. _d 0
581 enddo
582 enddo
583 enddo
584 enddo
585
586 _END_MASTER( mythid )
587 endif
588
589 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
590 c >>>>>>>>>>>>>>>>>>> TANGENT RUN <<<<<<<<<<<<<<<<<<<
591 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
592
593 if (theSimulationMode .eq. TANGENT_SIMULATION) then
594
595 _BEGIN_MASTER( mythid )
596
597 c Read the active variable from file.
598
599 call mdsreadfieldyz_loc(
600 & active_var_file,
601 & prec,
602 & 'RL',
603 & mynr,
604 & active_var,
605 & irec,
606 & mythid )
607
608 _END_MASTER( mythid )
609
610 endif
611
612 c Reset default io precision.
613 readBinaryPrec = oldPrec
614
615 _BARRIER
616
617 return
618 end
619
620 c ==================================================================
621
622 subroutine active_write_yz_rl_loc(
623 I active_var_file,
624 I active_var,
625 I globalfile,
626 I irec,
627 I mynr,
628 I theSimulationMode,
629 I myOptimIter,
630 I mythid
631 & )
632
633 c ==================================================================
634 c
635 c o Write an active variable to a file.
636 c
637 c started: heimbach@mit.edu 05-Mar-2001
638 c
639 c ==================================================================
640
641 implicit none
642
643 c == global variables ==
644
645 #include "EEPARAMS.h"
646 #include "SIZE.h"
647 #include "PARAMS.h"
648 #include "ctrl.h"
649
650 c == routine arguments ==
651
652 character*(*) active_var_file
653
654 integer mynr
655 logical globalfile
656 integer irec
657 integer theSimulationMode
658 integer myOptimIter
659 integer mythid
660 _RL active_var(1-oly:sny+oly,mynr,nsx,nsy)
661
662 c == local variables ==
663
664 integer i,j,k
665 integer bi,bj
666 _RL active_data_t(1-oly:sny+oly,mynr,nsx,nsy)
667 integer oldprec
668 integer prec
669
670 c == end of interface ==
671
672 c force 64-bit io
673 oldPrec = readBinaryPrec
674 readBinaryPrec = ctrlprec
675 prec = ctrlprec
676
677 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
678 c >>>>>>>>>>>>>>>>>>> FORWARD RUN <<<<<<<<<<<<<<<<<<<
679 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
680
681 if (theSimulationMode .eq. FORWARD_SIMULATION) then
682
683 _BEGIN_MASTER( mythid )
684
685 call mdswritefieldyz_loc(
686 & active_var_file,
687 & prec,
688 & globalfile,
689 & 'RL',
690 & mynr,
691 & active_var,
692 & irec,
693 & myOptimIter,
694 & mythid )
695
696 _END_MASTER( mythid )
697
698 endif
699
700 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
701 c >>>>>>>>>>>>>>>>>>> ADJOINT RUN <<<<<<<<<<<<<<<<<<<
702 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
703
704 if (theSimulationMode .eq. REVERSE_SIMULATION) then
705
706 _BEGIN_MASTER( mythid )
707
708 call mdsreadfieldyz_loc(
709 & active_var_file,
710 & prec,
711 & 'RL',
712 & mynr,
713 & active_data_t,
714 & irec,
715 & mythid )
716
717 c Add active_var from appropriate location to data.
718 do bj = 1,nsy
719 do bi = 1,nsx
720 do k = 1,mynr
721 do j = 1,sny
722 active_var(j,k,bi,bj) =
723 & active_var(j,k,bi,bj) +
724 & active_data_t(j,k,bi,bj)
725 active_data_t(j,k,bi,bj) = 0. _d 0
726 enddo
727 enddo
728 enddo
729 enddo
730 call mdswritefieldyz_loc(
731 & active_var_file,
732 & prec,
733 & globalfile,
734 & 'RL',
735 & mynr,
736 & active_data_t,
737 & irec,
738 & myOptimIter,
739 & mythid )
740
741 _END_MASTER( mythid )
742
743 endif
744
745 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
746 c >>>>>>>>>>>>>>>>>>> TANGENTY RUN <<<<<<<<<<<<<<<<<<<
747 c >>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<
748
749 if (theSimulationMode .eq. TANGENT_SIMULATION) then
750
751 _BEGIN_MASTER( mythid )
752
753 call mdswritefieldyz_loc(
754 & active_var_file,
755 & prec,
756 & globalfile,
757 & 'RL',
758 & mynr,
759 & active_var,
760 & irec,
761 & myOptimIter,
762 & mythid )
763
764 _END_MASTER( mythid )
765
766 endif
767
768 c Reset default io precision.
769 readBinaryPrec = oldPrec
770
771 _BARRIER
772
773 return
774 end
775

  ViewVC Help
Powered by ViewVC 1.1.22