/[MITgcm]/MITgcm/pkg/ecco/cost_mean_saltflux.F
ViewVC logotype

Diff of /MITgcm/pkg/ecco/cost_mean_saltflux.F

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

revision 1.1 by heimbach, Thu Nov 6 22:10:07 2003 UTC revision 1.8 by heimbach, Fri Oct 5 18:53:21 2007 UTC
# Line 45  c     == routine arguments == Line 45  c     == routine arguments ==
45  c     == local variables ==  c     == local variables ==
46    
47        integer bi,bj        integer bi,bj
48        integer i,j,k,kk        integer i,j,kk
49        integer itlo,ithi        integer itlo,ithi
50        integer jtlo,jthi        integer jtlo,jthi
51        integer jmin,jmax        integer jmin,jmax
# Line 55  c     == local variables == Line 55  c     == local variables ==
55        integer levoff        integer levoff
56        integer ilsalt        integer ilsalt
57    
       _RL fctilemm  
       _RL fcthreadmm  
58        _RL tmpx        _RL tmpx
59        _RL sumcos        _RL sumtot
60          _RL fctiletot
61    
62    
63        character*(80) fnamesflux        character*(80) fnamesflux
# Line 90  c--   Read tiled data. Line 89  c--   Read tiled data.
89    
90  #ifdef ALLOW_MEAN_SFLUX_COST_CONTRIBUTION  #ifdef ALLOW_MEAN_SFLUX_COST_CONTRIBUTION
91    
 #ifdef ECCO_VERBOSE  
       _BEGIN_MASTER( mythid )  
         write(msgbuf,'(a)') ' '  
         call print_message( msgbuf, standardmessageunit,  
      &                      SQUEEZE_RIGHT , mythid)  
         write(msgbuf,'(a,i8.8)')  
      &    ' cost_mean_saltflux: no. of records to process = ',nmonsrec  
         call print_message( msgbuf, standardmessageunit,  
      &                      SQUEEZE_RIGHT , mythid)  
         write(msgbuf,'(a)') ' '  
         call print_message( msgbuf, standardmessageunit,  
      &                      SQUEEZE_RIGHT , mythid)  
       _END_MASTER( mythid )  
 #endif  
   
92        if (optimcycle .ge. 0) then        if (optimcycle .ge. 0) then
93          ilsalt = ilnblnk( sfluxbarfile )          ilsalt = ilnblnk( sfluxbarfile )
94          write(fnamesflux(1:80),'(2a,i10.10)')          write(fnamesflux(1:80),'(2a,i10.10)')
95       &    sfluxbarfile(1:ilsalt),'.',optimcycle       &    sfluxbarfile(1:ilsalt),'.',optimcycle
96        endif        endif
97    
98        fcthreadmm       = 0. _d 0        do irec = 1, MAX(1,nyearsrec)
   
       irec = 1  
99    
100  c--     Read time averages and the monthly mean data.  c--     Read time averages and the monthly mean data.
101          call active_read_xy( fnamesflux, tmpfld2d, irec,          call active_read_xy( fnamesflux, tmpfld2d, irec,
# Line 121  c--     Read time averages and the month Line 103  c--     Read time averages and the month
103       &                        optimcycle, mythid,       &                        optimcycle, mythid,
104       &                        xx_sflux_mean_dummy )       &                        xx_sflux_mean_dummy )
105    
106            sumtot    = 0.
107            fctiletot = 0.
108          do bj = jtlo,jthi          do bj = jtlo,jthi
109            do bi = itlo,ithi            do bi = itlo,ithi
110              kk = 1              kk = 1
             fctilemm = 0. _d 0  
             sumcos   = 0. _d 0  
111              do j = jmin,jmax              do j = jmin,jmax
112                do i = imin,imax                do i = imin,imax
113                  tmpx=tmpfld2d(i,j,bi,bj)                  tmpx=tmpfld2d(i,j,bi,bj)
114                  if (maskw(i,j,kk,bi,bj) .ne. 0.) then                  if (maskC(i,j,kk,bi,bj) .ne. 0.) then
115                    fctilemm = fctilemm + tmpx*cos(yc(i,j,bi,bj)*deg2rad)                     fctiletot = fctiletot
116                    sumcos = sumcos + cos(yc(i,j,bi,bj)*deg2rad)       &                + tmpx*cos(yc(i,j,bi,bj)*deg2rad)
117                       sumtot = sumtot
118         &                + cos(yc(i,j,bi,bj)*deg2rad)
119                       num_sfluxmm(bi,bj) = num_sfluxmm(bi,bj) + 1
120                  endif                  endif
121                enddo                enddo
122              enddo              enddo
   
             if(sumcos .eq. 0.) sumcos = 1.  
             fctilemm = (fctilemm / sumcos)  
             fctilemm = wsfluxmm(bi,bj)*fctilemm  
   
             objf_sfluxmm(bi,bj) = fctilemm  
             fcthreadmm          = fcthreadmm + fctilemm  
   
 #ifdef ECCO_VERBOSE  
 c--     Print cost function for all tiles.  
         _GLOBAL_SUM_R8( fcthreadmm , myThid )  
         write(msgbuf,'(a)') ' '  
         call print_message( msgbuf, standardmessageunit,  
      &                      SQUEEZE_RIGHT , mythid)  
         write(msgbuf,'(a,i8.8)')  
      &    ' cost_saltflux:                       irec =  ',irec  
         call print_message( msgbuf, standardmessageunit,  
      &                      SQUEEZE_RIGHT , mythid)  
         write(msgbuf,'(a,d22.15)')  
      &    '                 global cost function value = ',  
      &    fcthreadmm  
         call print_message( msgbuf, standardmessageunit,  
      &                      SQUEEZE_RIGHT , mythid)  
         write(msgbuf,'(a)') ' '  
         call print_message( msgbuf, standardmessageunit,  
      &                      SQUEEZE_RIGHT , mythid)  
 #endif  
   
123            enddo            enddo
124          enddo          enddo
125    
126           _GLOBAL_SUM_R8( sumtot , myThid )
127           _GLOBAL_SUM_R8( fctiletot , myThid )
128          
129           if (sumtot.eq.0.) sumtot = 1.
130    
131           if ( wmean_sflux .NE. 0. ) then
132              objf_sfluxmm = objf_sfluxmm
133         &        + ( (fctiletot/sumtot-1.D0)/wmean_sflux )**2
134           else
135              objf_sfluxmm = 0. _d 0
136           endif
137    
138    c-- diagnostic: imbalance per year:
139           write(standardmessageunit,'(A,I5,2(X,D22.14))')
140         &      ' --> bal_sfluxmm    =', irec,
141         &      fctiletot/sumtot,
142         &      (fctiletot/sumtot/wmean_sflux)**2
143    
144  #ifdef ECCO_VERBOSE        enddo
 c--     Print cost function for all tiles.  
         _GLOBAL_SUM_R8( fcthreadmm       , myThid )  
         write(msgbuf,'(a)') ' '  
         call print_message( msgbuf, standardmessageunit,  
      &                      SQUEEZE_RIGHT , mythid)  
         write(msgbuf,'(a,i8.8)')  
      &    ' cost_: irec = ',irec  
         call print_message( msgbuf, standardmessageunit,  
      &                      SQUEEZE_RIGHT , mythid)  
         write(msgbuf,'(a,a,d22.15)')  
      &    ' global cost function value',  
      &    ' (        ) = ',fcthreadmm      
         call print_message( msgbuf, standardmessageunit,  
      &                      SQUEEZE_RIGHT , mythid)  
         write(msgbuf,'(a)') ' '  
         call print_message( msgbuf, standardmessageunit,  
      &                      SQUEEZE_RIGHT , mythid)  
 #endif  
145    
 #else  
 c--   Do not enter the calculation of the temperature contribution to  
 c--   the final cost function.  
   
       fctilemm         = 0. _d 0  
       fcthreadmm       = 0. _d 0  
   
       _BEGIN_MASTER( mythid )  
         write(msgbuf,'(a)') ' '  
         call print_message( msgbuf, standardmessageunit,  
      &                      SQUEEZE_RIGHT , mythid)  
         write(msgbuf,'(a,a)')  
      &    ' cost_: no contribution of temperature field ',  
      &                 'to cost function.'  
         call print_message( msgbuf, standardmessageunit,  
      &                      SQUEEZE_RIGHT , mythid)  
         write(msgbuf,'(a,a,i9.8)')  
      &    ' cost_: number of records that would have',  
      &                ' been processed: ',nmonsrec  
         call print_message( msgbuf, standardmessageunit,  
      &                      SQUEEZE_RIGHT , mythid)  
         write(msgbuf,'(a)') ' '  
         call print_message( msgbuf, standardmessageunit,  
      &                      SQUEEZE_RIGHT , mythid)  
       _END_MASTER( mythid )  
146  #endif  #endif
147    
148        return        return

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.8

  ViewVC Help
Powered by ViewVC 1.1.22