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

Diff of /MITgcm/pkg/autodiff/active_file_control_slice.F

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

revision 1.4 by heimbach, Mon Sep 16 18:11:58 2002 UTC revision 1.9 by jmc, Mon Oct 8 23:50:53 2007 UTC
# Line 1  Line 1 
1    C $Header$
2    C $Name$
3    
4  #include "CPP_OPTIONS.h"  #include "AUTODIFF_OPTIONS.h"
5    
6  c     ==================================================================  c     ==================================================================
7  c  c
# Line 56  c     == global variables == Line 58  c     == global variables ==
58  #include "EEPARAMS.h"  #include "EEPARAMS.h"
59  #include "SIZE.h"  #include "SIZE.h"
60  #include "PARAMS.h"  #include "PARAMS.h"
61    #include "ctrl.h"
62    
63  c     == routine arguments ==  c     == routine arguments ==
64    
# Line 84  c     == local variables == Line 87  c     == local variables ==
87    
88        logical writeglobalfile        logical writeglobalfile
89    
90        _RL  active_data_t(1-olx:snx+olx,nsx,nsy)        _RL  active_data_t(1-olx:snx+olx,mynr,nsx,nsy)
91    
92  c     == functions ==  c     == functions ==
93    
# Line 94  c     == end of interface == Line 97  c     == end of interface ==
97    
98  c     force 64-bit io  c     force 64-bit io
99        oldPrec        = readBinaryPrec        oldPrec        = readBinaryPrec
100        readBinaryPrec = precFloat64        readBinaryPrec = ctrlprec
101        prec           = precFloat64        prec           = ctrlprec
102    
103        write(adfname(1:80),'(80a)') ' '        write(adfname(1:80),'(80a)') ' '
104        adpref = 'ad'        adpref = 'ad'
# Line 114  c     >>>>>>>>>>>>>>>>>>>             << Line 117  c     >>>>>>>>>>>>>>>>>>>             <<
117    
118  c       Read the active variable from file.  c       Read the active variable from file.
119    
120          call mdsreadfieldxz(          call mdsreadfieldxz(
121       &                     active_var_file,       &                     active_var_file,
122       &                     prec,       &                     prec,
123       &                     'RL',       &                     'RL',
124       &                     mynr,             &                     mynr,
125       &                     active_var,       &                     active_var,
126       &                     irec,       &                     irec,
127       &                     mythid )       &                     mythid )
128    
129          if (lAdInit) then          if (lAdInit) then
# Line 130  c         adjoint variable's file. These Line 133  c         adjoint variable's file. These
133            writeglobalfile = .false.            writeglobalfile = .false.
134            do bj = 1,nsy            do bj = 1,nsy
135               do bi = 1,nsx               do bi = 1,nsx
136                  do i = 1,snx                  do k = 1,mynr
137                     active_data_t(i,bi,bj)= 0. _d 0                     do i = 1,snx
138                          active_data_t(i,k,bi,bj)= 0. _d 0
139                       enddo
140                  enddo                  enddo
141               enddo               enddo
142            enddo            enddo
143    
144            do k = 1,mynr            call mdswritefieldxz(
145               call mdswritefieldxz(       &                           adfname,
146       &                           adfname,       &                           prec,
      &                           prec,  
147       &                           globalfile,       &                           globalfile,
148       &                           'RL',       &                           'RL',
149       &                           1,       &                           mynr,
150       &                           active_data_t,       &                           active_data_t,
151       &                           (irec-1)*mynr+k,       &                           irec,
152       &                           myOptimIter,       &                           myOptimIter,
153       &                           mythid )       &                           mythid )
           enddo  
154          endif          endif
155    
156          _END_MASTER( mythid )          _END_MASTER( mythid )
# Line 163  c     >>>>>>>>>>>>>>>>>>>             << Line 166  c     >>>>>>>>>>>>>>>>>>>             <<
166          _BEGIN_MASTER( mythid )          _BEGIN_MASTER( mythid )
167    
168          writeglobalfile = .false.          writeglobalfile = .false.
169          do k=1,mynr          call mdsreadfieldxz(
170  c             Read data from file layer by layer.       &                        active_var_file,
171             call mdsreadfieldxz(       &                        prec,
      &                        active_var_file,  
      &                        prec,  
172       &                        'RL',       &                        'RL',
173       &                        1,       &                        mynr,
174       &                        active_data_t,       &                        active_data_t,
175       &                        (irec-1)*mynr+k,       &                        irec,
176       &                        mythid )       &                        mythid )
177    
178  c             Add active_var from appropriate location to data.  c             Add active_var from appropriate location to data.
179             do bj = 1,nsy          do bj = 1,nsy
180                do bi = 1,nsx             do bi = 1,nsx
181                  do k = 1,mynr
182                   do i = 1,snx                   do i = 1,snx
183                      active_data_t(i,bi,bj) = active_data_t(i,bi,bj) +                      active_data_t(i,k,bi,bj) =
184         &                   active_data_t(i,k,bi,bj) +
185       &                   active_var(i,k,bi,bj)       &                   active_var(i,k,bi,bj)
186                   enddo                   enddo
187                enddo                enddo
188             enddo             enddo
189            enddo
190    
191  c             Store the result on disk.  c             Store the result on disk.
192             call mdswritefieldxz(          call mdswritefieldxz(
193       &                         active_var_file,       &                         active_var_file,
194       &                         prec,       &                         prec,
195       &                         writeglobalfile,       &                         writeglobalfile,
196       &                         'RL',       &                         'RL',
197       &                         1,       &                         mynr,
198       &                         active_data_t,       &                         active_data_t,
199       &                         (irec-1)*mynr+k,       &                         irec,
200       &                         myOptimIter,       &                         myOptimIter,
201       &                         mythid )       &                         mythid )
         enddo  
   
202    
203  c       Set active_var to zero.  c       Set active_var to zero.
204          do k=1,mynr          do bj = 1,nsy
205             do bj = 1,nsy             do bi = 1,nsx
206                do bi = 1,nsx                do k=1,mynr
207                   do i = 1,snx                   do i = 1,snx
208                      active_var(i,k,bi,bj) = 0. _d 0                      active_var(i,k,bi,bj) = 0. _d 0
209                   enddo                   enddo
# Line 222  c     >>>>>>>>>>>>>>>>>>>             << Line 224  c     >>>>>>>>>>>>>>>>>>>             <<
224    
225  c       Read the active variable from file.  c       Read the active variable from file.
226    
227          call mdsreadfieldxz(          call mdsreadfieldxz(
228       &                     active_var_file,       &                     active_var_file,
229       &                     prec,       &                     prec,
230       &                     'RL',       &                     'RL',
231       &                     mynr,             &                     mynr,
232       &                     active_var,       &                     active_var,
233       &                     irec,       &                     irec,
234       &                     mythid )       &                     mythid )
235    
236          _END_MASTER( mythid )          _END_MASTER( mythid )
# Line 275  c     == global variables == Line 277  c     == global variables ==
277  #include "EEPARAMS.h"  #include "EEPARAMS.h"
278  #include "SIZE.h"  #include "SIZE.h"
279  #include "PARAMS.h"  #include "PARAMS.h"
280    #include "ctrl.h"
281    
282  c     == routine arguments ==  c     == routine arguments ==
283    
# Line 292  c     == local variables == Line 295  c     == local variables ==
295    
296        integer  i,j,k        integer  i,j,k
297        integer  bi,bj        integer  bi,bj
298        _RL  active_data_t(1-olx:snx+olx,nsx,nsy)        _RL  active_data_t(1-olx:snx+olx,mynr,nsx,nsy)
299        integer  oldprec        integer  oldprec
300        integer  prec        integer  prec
301    
# Line 300  c     == end of interface == Line 303  c     == end of interface ==
303    
304  c     force 64-bit io  c     force 64-bit io
305        oldPrec        = readBinaryPrec        oldPrec        = readBinaryPrec
306        readBinaryPrec = precFloat64        readBinaryPrec = ctrlprec
307        prec           = precFloat64        prec           = ctrlprec
308    
309  c     >>>>>>>>>>>>>>>>>>>             <<<<<<<<<<<<<<<<<<<  c     >>>>>>>>>>>>>>>>>>>             <<<<<<<<<<<<<<<<<<<
310  c     >>>>>>>>>>>>>>>>>>> FORWARD RUN <<<<<<<<<<<<<<<<<<<  c     >>>>>>>>>>>>>>>>>>> FORWARD RUN <<<<<<<<<<<<<<<<<<<
# Line 311  c     >>>>>>>>>>>>>>>>>>>             << Line 314  c     >>>>>>>>>>>>>>>>>>>             <<
314    
315          _BEGIN_MASTER( mythid )          _BEGIN_MASTER( mythid )
316    
317            call mdswritefieldxz(            call mdswritefieldxz(
318       &                        active_var_file,       &                        active_var_file,
319       &                        prec,       &                        prec,
320       &                        globalfile,       &                        globalfile,
321       &                        'RL',       &                        'RL',
322       &                        mynr,       &                        mynr,
323       &                        active_var,       &                        active_var,
324       &                        irec,       &                        irec,
325       &                        myOptimIter,       &                        myOptimIter,
326       &                        mythid )       &                        mythid )
327    
# Line 334  c     >>>>>>>>>>>>>>>>>>>             << Line 337  c     >>>>>>>>>>>>>>>>>>>             <<
337    
338          _BEGIN_MASTER( mythid )          _BEGIN_MASTER( mythid )
339    
340              do k=1,mynr          call mdsreadfieldxz(
341  c             Read data from file layer by layer.       &                           active_var_file,
342                call mdsreadfieldxz(       &                           prec,
      &                           active_var_file,  
      &                           prec,  
343       &                           'RL',       &                           'RL',
344       &                            1,       &                            mynr,
345       &                            active_data_t,       &                            active_data_t,
346       &                            (irec-1)*mynr+k,       &                            irec,
347       &                            mythid )       &                            mythid )
348    
349  c             Add active_var from appropriate location to data.  c             Add active_var from appropriate location to data.
350                do bj = 1,nsy          do bj = 1,nsy
351                   do bi = 1,nsx             do bi = 1,nsx
352                      do i = 1,snx                do k = 1,nr
353                         active_var(i,k,bi,bj) =                   do i = 1,snx
354       &                      active_var(i,k,bi,bj) +                      active_var(i,k,bi,bj) =
355       &                      active_data_t(i,bi,bj)       &                   active_var(i,k,bi,bj) +
356                         active_data_t(i,bi,bj) = 0. _d 0       &                   active_data_t(i,k,bi,bj)
357                      enddo                      active_data_t(i,k,bi,bj) = 0. _d 0
358                   enddo                   enddo
359                enddo                enddo
360                call mdswritefieldxz(             enddo
361       &                            active_var_file,          enddo
362       &                            prec,          call mdswritefieldxz(
363         &                            active_var_file,
364         &                            prec,
365       &                            globalfile,       &                            globalfile,
366       &                            'RL',       &                            'RL',
367       &                            1,       &                            mynr,
368       &                            active_data_t,       &                            active_data_t,
369       &                            (irec-1)*mynr+k,       &                            irec,
370       &                            myOptimIter,       &                            myOptimIter,
371       &                            mythid )       &                            mythid )
         enddo  
372    
373          _END_MASTER( mythid )          _END_MASTER( mythid )
374    
# Line 380  c     >>>>>>>>>>>>>>>>>>>             << Line 382  c     >>>>>>>>>>>>>>>>>>>             <<
382    
383          _BEGIN_MASTER( mythid )          _BEGIN_MASTER( mythid )
384    
385            call mdswritefieldxz(            call mdswritefieldxz(
386       &                        active_var_file,       &                        active_var_file,
387       &                        prec,       &                        prec,
388       &                        globalfile,       &                        globalfile,
389       &                        'RL',       &                        'RL',
390       &                        mynr,       &                        mynr,
391       &                        active_var,       &                        active_var,
392       &                        irec,       &                        irec,
393       &                        myOptimIter,       &                        myOptimIter,
394       &                        mythid )       &                        mythid )
395    
# Line 440  c     == global variables == Line 442  c     == global variables ==
442  #include "EEPARAMS.h"  #include "EEPARAMS.h"
443  #include "SIZE.h"  #include "SIZE.h"
444  #include "PARAMS.h"  #include "PARAMS.h"
445    #include "ctrl.h"
446    
447  c     == routine arguments ==  c     == routine arguments ==
448    
# Line 468  c     == local variables == Line 471  c     == local variables ==
471    
472        logical writeglobalfile        logical writeglobalfile
473    
474        _RL  active_data_t(1-oly:sny+oly,nsx,nsy)        _RL  active_data_t(1-oly:sny+oly,mynr,nsx,nsy)
475    
476  c     == functions ==  c     == functions ==
477    
# Line 478  c     == end of interface == Line 481  c     == end of interface ==
481    
482  c     force 64-bit io  c     force 64-bit io
483        oldPrec        = readBinaryPrec        oldPrec        = readBinaryPrec
484        readBinaryPrec = precFloat64        readBinaryPrec = ctrlprec
485        prec           = precFloat64        prec           = ctrlprec
486    
487        write(adfname(1:80),'(80a)') ' '        write(adfname(1:80),'(80a)') ' '
488        adpref = 'ad'        adpref = 'ad'
# Line 498  c     >>>>>>>>>>>>>>>>>>>             << Line 501  c     >>>>>>>>>>>>>>>>>>>             <<
501    
502  c       Read the active variable from file.  c       Read the active variable from file.
503    
504          call mdsreadfieldyz(          call mdsreadfieldyz(
505       &                     active_var_file,       &                     active_var_file,
506       &                     prec,       &                     prec,
507       &                     'RL',       &                     'RL',
508       &                     mynr,             &                     mynr,
509       &                     active_var,       &                     active_var,
510       &                     irec,       &                     irec,
511       &                     mythid )       &                     mythid )
512    
513          if (lAdInit) then          if (lAdInit) then
# Line 514  c         adjoint variable's file. These Line 517  c         adjoint variable's file. These
517            writeglobalfile = .false.            writeglobalfile = .false.
518            do bj = 1,nsy            do bj = 1,nsy
519               do bi = 1,nsx               do bi = 1,nsx
520                  do j = 1,sny                  do k = 1, mynr
521                     active_data_t(j,bi,bj)= 0. _d 0                     do j = 1,sny
522                          active_data_t(j,k,bi,bj)= 0. _d 0
523                       enddo
524                  enddo                  enddo
525               enddo               enddo
526            enddo            enddo
527    
528            do k = 1,mynr            call mdswritefieldyz(
529               call mdswritefieldyz(       &                           adfname,
530       &                           adfname,       &                           prec,
      &                           prec,  
531       &                           globalfile,       &                           globalfile,
532       &                           'RL',       &                           'RL',
533       &                           1,       &                           mynr,
534       &                           active_data_t,       &                           active_data_t,
535       &                           (irec-1)*mynr+k,       &                           irec,
536       &                           myOptimIter,       &                           myOptimIter,
537       &                           mythid )       &                           mythid )
           enddo  
538          endif          endif
539    
540          _END_MASTER( mythid )          _END_MASTER( mythid )
# Line 547  c     >>>>>>>>>>>>>>>>>>>             << Line 550  c     >>>>>>>>>>>>>>>>>>>             <<
550          _BEGIN_MASTER( mythid )          _BEGIN_MASTER( mythid )
551    
552          writeglobalfile = .false.          writeglobalfile = .false.
553          do k=1,mynr          call mdsreadfieldyz(
554  c             Read data from file layer by layer.       &                        active_var_file,
555             call mdsreadfieldyz(       &                        prec,
      &                        active_var_file,  
      &                        prec,  
556       &                        'RL',       &                        'RL',
557       &                        1,       &                        mynr,
558       &                        active_data_t,       &                        active_data_t,
559       &                        (irec-1)*mynr+k,       &                        irec,
560       &                        mythid )       &                        mythid )
561    
562  c             Add active_var from appropriate location to data.  c             Add active_var from appropriate location to data.
563             do bj = 1,nsy          do bj = 1,nsy
564                do bi = 1,nsx             do bi = 1,nsx
565                  do k = 1,mynr
566                   do j = 1,sny                   do j = 1,sny
567                      active_data_t(j,bi,bj) = active_data_t(j,bi,bj) +                      active_data_t(j,k,bi,bj) =
568         &                   active_data_t(j,k,bi,bj) +
569       &                   active_var(j,k,bi,bj)       &                   active_var(j,k,bi,bj)
570                   enddo                   enddo
571                enddo                enddo
572             enddo             enddo
573            enddo
574    
575  c             Store the result on disk.  c             Store the result on disk.
576             call mdswritefieldyz(          call mdswritefieldyz(
577       &                         active_var_file,       &                         active_var_file,
578       &                         prec,       &                         prec,
579       &                         writeglobalfile,       &                         writeglobalfile,
580       &                         'RL',       &                         'RL',
581       &                         1,       &                         mynr,
582       &                         active_data_t,       &                         active_data_t,
583       &                         (irec-1)*mynr+k,       &                         irec,
584       &                         myOptimIter,       &                         myOptimIter,
585       &                         mythid )       &                         mythid )
         enddo  
   
586    
587  c       Set active_var to zero.  c       Set active_var to zero.
588          do k=1,mynr          do bj = 1,nsy
589             do bj = 1,nsy             do bi = 1,nsx
590                do bi = 1,nsx                do k=1,mynr
591                   do j = 1,sny                   do j = 1,sny
592                      active_var(j,k,bi,bj) = 0. _d 0                      active_var(j,k,bi,bj) = 0. _d 0
593                   enddo                   enddo
# Line 606  c     >>>>>>>>>>>>>>>>>>>             << Line 608  c     >>>>>>>>>>>>>>>>>>>             <<
608    
609  c       Read the active variable from file.  c       Read the active variable from file.
610    
611          call mdsreadfieldyz(          call mdsreadfieldyz(
612       &                     active_var_file,       &                     active_var_file,
613       &                     prec,       &                     prec,
614       &                     'RL',       &                     'RL',
615       &                     mynr,             &                     mynr,
616       &                     active_var,       &                     active_var,
617       &                     irec,       &                     irec,
618       &                     mythid )       &                     mythid )
619    
620          _END_MASTER( mythid )          _END_MASTER( mythid )
# Line 659  c     == global variables == Line 661  c     == global variables ==
661  #include "EEPARAMS.h"  #include "EEPARAMS.h"
662  #include "SIZE.h"  #include "SIZE.h"
663  #include "PARAMS.h"  #include "PARAMS.h"
664    #include "ctrl.h"
665    
666  c     == routine arguments ==  c     == routine arguments ==
667    
# Line 676  c     == local variables == Line 679  c     == local variables ==
679    
680        integer  i,j,k        integer  i,j,k
681        integer  bi,bj        integer  bi,bj
682        _RL  active_data_t(1-oly:sny+oly,nsx,nsy)        _RL  active_data_t(1-oly:sny+oly,mynr,nsx,nsy)
683        integer  oldprec        integer  oldprec
684        integer  prec        integer  prec
685    
# Line 684  c     == end of interface == Line 687  c     == end of interface ==
687    
688  c     force 64-bit io  c     force 64-bit io
689        oldPrec        = readBinaryPrec        oldPrec        = readBinaryPrec
690        readBinaryPrec = precFloat64        readBinaryPrec = ctrlprec
691        prec           = precFloat64        prec           = ctrlprec
692    
693  c     >>>>>>>>>>>>>>>>>>>             <<<<<<<<<<<<<<<<<<<  c     >>>>>>>>>>>>>>>>>>>             <<<<<<<<<<<<<<<<<<<
694  c     >>>>>>>>>>>>>>>>>>> FORWARD RUN <<<<<<<<<<<<<<<<<<<  c     >>>>>>>>>>>>>>>>>>> FORWARD RUN <<<<<<<<<<<<<<<<<<<
# Line 695  c     >>>>>>>>>>>>>>>>>>>             << Line 698  c     >>>>>>>>>>>>>>>>>>>             <<
698    
699          _BEGIN_MASTER( mythid )          _BEGIN_MASTER( mythid )
700    
701            call mdswritefieldyz(            call mdswritefieldyz(
702       &                        active_var_file,       &                        active_var_file,
703       &                        prec,       &                        prec,
704       &                        globalfile,       &                        globalfile,
705       &                        'RL',       &                        'RL',
706       &                        mynr,       &                        mynr,
707       &                        active_var,       &                        active_var,
708       &                        irec,       &                        irec,
709       &                        myOptimIter,       &                        myOptimIter,
710       &                        mythid )       &                        mythid )
711    
# Line 718  c     >>>>>>>>>>>>>>>>>>>             << Line 721  c     >>>>>>>>>>>>>>>>>>>             <<
721    
722          _BEGIN_MASTER( mythid )          _BEGIN_MASTER( mythid )
723    
724              do k=1,mynr          call mdsreadfieldyz(
725  c             Read data from file layer by layer.       &                           active_var_file,
726                call mdsreadfieldyz(       &                           prec,
      &                           active_var_file,  
      &                           prec,  
727       &                           'RL',       &                           'RL',
728       &                            1,       &                            mynr,
729       &                            active_data_t,       &                            active_data_t,
730       &                            (irec-1)*mynr+k,       &                            irec,
731       &                            mythid )       &                            mythid )
732    
733  c             Add active_var from appropriate location to data.  c             Add active_var from appropriate location to data.
734                do bj = 1,nsy          do bj = 1,nsy
735                   do bi = 1,nsx             do bi = 1,nsx
736                      do j = 1,sny                do k = 1, mynr
737                         active_var(j,k,bi,bj) =                   do j = 1,sny
738       &                      active_var(j,k,bi,bj) +                      active_var(j,k,bi,bj) =
739       &                      active_data_t(j,bi,bj)       &                   active_var(j,k,bi,bj) +
740                         active_data_t(j,bi,bj) = 0. _d 0       &                   active_data_t(j,k,bi,bj)
741                      enddo                      active_data_t(j,k,bi,bj) = 0. _d 0
742                   enddo                   enddo
743                enddo                enddo
744                call mdswritefieldyz(             enddo
745       &                            active_var_file,          enddo
746       &                            prec,          call mdswritefieldyz(
747         &                            active_var_file,
748         &                            prec,
749       &                            globalfile,       &                            globalfile,
750       &                            'RL',       &                            'RL',
751       &                            1,       &                            mynr,
752       &                            active_data_t,       &                            active_data_t,
753       &                            (irec-1)*mynr+k,       &                            irec,
754       &                            myOptimIter,       &                            myOptimIter,
755       &                            mythid )       &                            mythid )
         enddo  
756    
757          _END_MASTER( mythid )          _END_MASTER( mythid )
758    
# Line 764  c     >>>>>>>>>>>>>>>>>>>             << Line 766  c     >>>>>>>>>>>>>>>>>>>             <<
766    
767          _BEGIN_MASTER( mythid )          _BEGIN_MASTER( mythid )
768    
769            call mdswritefieldyz(            call mdswritefieldyz(
770       &                        active_var_file,       &                        active_var_file,
771       &                        prec,       &                        prec,
772       &                        globalfile,       &                        globalfile,
773       &                        'RL',       &                        'RL',
774       &                        mynr,       &                        mynr,
775       &                        active_var,       &                        active_var,
776       &                        irec,       &                        irec,
777       &                        myOptimIter,       &                        myOptimIter,
778       &                        mythid )       &                        mythid )
779    

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.9

  ViewVC Help
Powered by ViewVC 1.1.22