/[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.14 by heimbach, Sat Feb 6 02:43:03 2010 UTC
# Line 1  Line 1 
1    C $Header$
2    C $Name$
3    
4  #include "COST_CPPOPTIONS.h"  #include "COST_CPPOPTIONS.h"
5    
# Line 45  c     == routine arguments == Line 47  c     == routine arguments ==
47  c     == local variables ==  c     == local variables ==
48    
49        integer bi,bj        integer bi,bj
50        integer i,j,k,kk        integer i,j,kk
51        integer itlo,ithi        integer itlo,ithi
52        integer jtlo,jthi        integer jtlo,jthi
53        integer jmin,jmax        integer jmin,jmax
# Line 55  c     == local variables == Line 57  c     == local variables ==
57        integer levoff        integer levoff
58        integer ilsalt        integer ilsalt
59    
       _RL fctilemm  
       _RL fcthreadmm  
60        _RL tmpx        _RL tmpx
61        _RL sumcos        _RL sumtot
62          _RL fctiletot
63    
64    
65        character*(80) fnamesflux        character*(80) fnamesflux
# Line 90  c--   Read tiled data. Line 91  c--   Read tiled data.
91    
92  #ifdef ALLOW_MEAN_SFLUX_COST_CONTRIBUTION  #ifdef ALLOW_MEAN_SFLUX_COST_CONTRIBUTION
93    
 #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  
   
94        if (optimcycle .ge. 0) then        if (optimcycle .ge. 0) then
95          ilsalt = ilnblnk( sfluxbarfile )          ilsalt = ilnblnk( sfluxmeanbarfile )
96          write(fnamesflux(1:80),'(2a,i10.10)')          write(fnamesflux(1:80),'(2a,i10.10)')
97       &    sfluxbarfile(1:ilsalt),'.',optimcycle       &    sfluxmeanbarfile(1:ilsalt),'.',optimcycle
98        endif        endif
99    
100        fcthreadmm       = 0. _d 0        do irec = 1, MAX(1,nyearsrec)
   
       irec = 1  
101    
102  c--     Read time averages and the monthly mean data.  c--     Read time averages and the monthly mean data.
103          call active_read_xy( fnamesflux, tmpfld2d, irec,          call active_read_xy( fnamesflux, tmpfld2d, irec,
# Line 121  c--     Read time averages and the month Line 105  c--     Read time averages and the month
105       &                        optimcycle, mythid,       &                        optimcycle, mythid,
106       &                        xx_sflux_mean_dummy )       &                        xx_sflux_mean_dummy )
107    
108            sumtot    = 0.
109            fctiletot = 0.
110          do bj = jtlo,jthi          do bj = jtlo,jthi
111            do bi = itlo,ithi            do bi = itlo,ithi
112              kk = 1              kk = 1
             fctilemm = 0. _d 0  
             sumcos   = 0. _d 0  
113              do j = jmin,jmax              do j = jmin,jmax
114                do i = imin,imax                do i = imin,imax
115                  tmpx=tmpfld2d(i,j,bi,bj)                  tmpx=tmpfld2d(i,j,bi,bj)
116                  if (maskw(i,j,kk,bi,bj) .ne. 0.) then                  if (maskC(i,j,kk,bi,bj) .ne. 0.) then
117                    fctilemm = fctilemm + tmpx*cos(yc(i,j,bi,bj)*deg2rad)                     fctiletot = fctiletot
118                    sumcos = sumcos + cos(yc(i,j,bi,bj)*deg2rad)       &                + tmpx* _rA(i,j,bi,bj)/rhoConstFresh
119                       sumtot = sumtot
120         &                + _rA(i,j,bi,bj)
121                       num_sfluxmm(bi,bj) = num_sfluxmm(bi,bj) + 1
122                  endif                  endif
123                enddo                enddo
124              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  
   
125            enddo            enddo
126          enddo          enddo
127    
128           _GLOBAL_SUM_RL( sumtot , myThid )
129           _GLOBAL_SUM_RL( fctiletot , myThid )
130    
131  #ifdef ECCO_VERBOSE         if (sumtot.eq.0.) sumtot = 1.
132  c--     Print cost function for all tiles.  
133          _GLOBAL_SUM_R8( fcthreadmm       , myThid )         if ( wmean_sflux .NE. 0. ) then
134          write(msgbuf,'(a)') ' '            objf_sfluxmm = objf_sfluxmm
135          call print_message( msgbuf, standardmessageunit,       &        + ( (fctiletot/sumtot)/wmean_sflux )**2
136       &                      SQUEEZE_RIGHT , mythid)         else
137          write(msgbuf,'(a,i8.8)')            objf_sfluxmm = 0. _d 0
138       &    ' cost_: irec = ',irec         endif
139          call print_message( msgbuf, standardmessageunit,  
140       &                      SQUEEZE_RIGHT , mythid)  c-- diagnostic: imbalance per year:
141          write(msgbuf,'(a,a,d22.15)')         write(standardmessageunit,'(A,I5,2(X,D22.14))')
142       &    ' global cost function value',       &      ' --> bal_sfluxmm    =', irec,
143       &    ' (        ) = ',fcthreadmm           &      fctiletot/sumtot,
144          call print_message( msgbuf, standardmessageunit,       &      objf_sfluxmm
145       &                      SQUEEZE_RIGHT , mythid)  
146          write(msgbuf,'(a)') ' '        enddo
         call print_message( msgbuf, standardmessageunit,  
      &                      SQUEEZE_RIGHT , mythid)  
 #endif  
147    
 #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 )  
148  #endif  #endif
149    
150        return        return

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

  ViewVC Help
Powered by ViewVC 1.1.22