| 5 | 
  | 
  | 
| 6 | 
 c read the area dat file and compare against the averaged salinity file | 
 c read the area dat file and compare against the averaged salinity file | 
| 7 | 
  | 
  | 
| 8 | 
       subroutine seaice_cost_sss(  | 
       subroutine seaice_cost_sss( | 
| 9 | 
      &     nnzbar, localbarfile, localbar, xx_localbar_mean_dummy, | 
      &     nnzbar, localbarfile, localbar, xx_localbar_mean_dummy, | 
| 10 | 
      &             areabarfile,   areabar, xx_areabar_mean_dummy, | 
      &             areabarfile,   areabar, xx_areabar_mean_dummy, | 
| 11 | 
      &     nnzobs, localobsfile, localobs, mult_local, | 
      &     nnzobs, localobsfile, localobs, mult_local, | 
| 88 | 
       _RL localcost | 
       _RL localcost | 
| 89 | 
       _RL junk | 
       _RL junk | 
| 90 | 
  | 
  | 
| 91 | 
       _RL cmask (1-olx:snx+olx,1-oly:sny+oly,nnzobs)   | 
       _RL cmask (1-olx:snx+olx,1-oly:sny+oly,nnzobs) | 
| 92 | 
  | 
  | 
| 93 | 
       character*(128) fname1, fname2,fname3 | 
       character*(128) fname1, fname2,fname3 | 
| 94 | 
       character*(MAX_LEN_MBUF) msgbuf | 
       character*(MAX_LEN_MBUF) msgbuf | 
| 144 | 
       write(fname3(1:128),'(80a)') ' ' | 
       write(fname3(1:128),'(80a)') ' ' | 
| 145 | 
  | 
  | 
| 146 | 
       il=ilnblnk( localbarfile ) | 
       il=ilnblnk( localbarfile ) | 
| 147 | 
       write(fname1(1:128),'(2a,i10.10)')  | 
       write(fname1(1:128),'(2a,i10.10)') | 
| 148 | 
      &     localbarfile(1:il),'.',optimcycle | 
      &     localbarfile(1:il),'.',optimcycle | 
| 149 | 
  | 
  | 
| 150 | 
 csss | 
 csss | 
| 151 | 
       il=ilnblnk( areabarfile ) | 
       il=ilnblnk( areabarfile ) | 
| 152 | 
       write(fname3(1:128),'(2a,i10.10)')  | 
       write(fname3(1:128),'(2a,i10.10)') | 
| 153 | 
      &     areabarfile(1:il),'.',optimcycle | 
      &     areabarfile(1:il),'.',optimcycle | 
| 154 | 
  | 
  | 
| 155 | 
       if ( .NOT. ( localobsfile.EQ.' ' ) ) then | 
       if ( .NOT. ( localobsfile.EQ.' ' ) ) then | 
| 159 | 
  | 
  | 
| 160 | 
         if ( nnzbar .EQ. 1 ) then | 
         if ( nnzbar .EQ. 1 ) then | 
| 161 | 
            call active_read_xy( fname1, localbar, irec, doglobalread, | 
            call active_read_xy( fname1, localbar, irec, doglobalread, | 
| 162 | 
      &                      ladinit, optimcycle, mythid,  | 
      &                      ladinit, optimcycle, mythid, | 
| 163 | 
      &                      xx_localbar_mean_dummy ) | 
      &                      xx_localbar_mean_dummy ) | 
| 164 | 
         else | 
         else | 
| 165 | 
            call active_read_xyz( fname1, localbar, irec, doglobalread, | 
            call active_read_xyz( fname1, localbar, irec, doglobalread, | 
| 166 | 
      &                       ladinit, optimcycle, mythid,  | 
      &                       ladinit, optimcycle, mythid, | 
| 167 | 
      &                       xx_localbar_mean_dummy ) | 
      &                       xx_localbar_mean_dummy ) | 
| 168 | 
         endif | 
         endif | 
| 169 | 
  | 
  | 
| 170 | 
 csss | 
 csss | 
| 171 | 
         if ( nnzbar .EQ. 1 ) then | 
         if ( nnzbar .EQ. 1 ) then | 
| 172 | 
            call active_read_xy( fname3, areabar, irec, doglobalread, | 
            call active_read_xy( fname3, areabar, irec, doglobalread, | 
| 173 | 
      &                      ladinit, optimcycle, mythid,  | 
      &                      ladinit, optimcycle, mythid, | 
| 174 | 
      &                      xx_areabar_mean_dummy ) | 
      &                      xx_areabar_mean_dummy ) | 
| 175 | 
         else | 
         else | 
| 176 | 
            call active_read_xyz( fname3, areabar, irec, doglobalread, | 
            call active_read_xyz( fname3, areabar, irec, doglobalread, | 
| 177 | 
      &                       ladinit, optimcycle, mythid,  | 
      &                       ladinit, optimcycle, mythid, | 
| 178 | 
      &                       xx_areabar_mean_dummy ) | 
      &                       xx_areabar_mean_dummy ) | 
| 179 | 
         endif | 
         endif | 
| 180 | 
  | 
  | 
| 202 | 
       print *,'ymod, yday     ', ymod,yday | 
       print *,'ymod, yday     ', ymod,yday | 
| 203 | 
       print *,'smrarstrtdt(1) ', smrareastartdate(1) | 
       print *,'smrarstrtdt(1) ', smrareastartdate(1) | 
| 204 | 
       print *,'smrarstartdate ', smrareastartdate | 
       print *,'smrarstartdate ', smrareastartdate | 
| 205 | 
 #endif SEAICE_DEBUG | 
 #endif /* SEAICE_DEBUG */ | 
| 206 | 
  | 
  | 
| 207 | 
       if ( ymod .EQ. yday ) then | 
       if ( ymod .EQ. yday ) then | 
| 208 | 
          middate(1) = smrareastartdate(1)  | 
          middate(1) = smrareastartdate(1) | 
| 209 | 
       else | 
       else | 
| 210 | 
          middate(1) = yday*10000+100+1 | 
          middate(1) = yday*10000+100+1 | 
| 211 | 
       endif | 
       endif | 
| 224 | 
       print *,'middate(3,4)     ', middate(3),middate(4) | 
       print *,'middate(3,4)     ', middate(3),middate(4) | 
| 225 | 
       print *,'difftime,diffsecs',difftime,diffsecs | 
       print *,'difftime,diffsecs',difftime,diffsecs | 
| 226 | 
       print *,'localrec         ',localrec | 
       print *,'localrec         ',localrec | 
| 227 | 
 #endif  | 
 #endif | 
| 228 | 
  | 
  | 
| 229 | 
       il=ilnblnk(localobsfile) | 
       il=ilnblnk(localobsfile) | 
| 230 | 
       write(fname2(1:128),'(2a,i4)') | 
       write(fname2(1:128),'(2a,i4)') | 
| 243 | 
 #endif | 
 #endif | 
| 244 | 
         endif | 
         endif | 
| 245 | 
  | 
  | 
| 246 | 
         if ( localrec .GT. 0 ) then  | 
         if ( localrec .GT. 0 ) then | 
| 247 | 
  | 
  | 
| 248 | 
 #ifdef SEAICE_DEBUG | 
 #ifdef SEAICE_DEBUG | 
| 249 | 
           print *,'calling mdsreadfile',fname2,localrec | 
           print *,'calling mdsreadfile',fname2,localrec | 
| 250 | 
 #endif | 
 #endif | 
| 251 | 
  | 
  | 
| 252 | 
           call mdsreadfield( fname2, cost_iprec, cost_yftype, nnzobs,  | 
           call mdsreadfield( fname2, cost_iprec, cost_yftype, nnzobs, | 
| 253 | 
      &         localobs, localrec, mythid ) | 
      &         localobs, localrec, mythid ) | 
| 254 | 
         else | 
         else | 
| 255 | 
           do bj = jtlo,jthi | 
           do bj = jtlo,jthi | 
| 307 | 
                 localwww  = localweight(i,j,bi,bj)*cmask(i,j,k) | 
                 localwww  = localweight(i,j,bi,bj)*cmask(i,j,k) | 
| 308 | 
  | 
  | 
| 309 | 
 c only accumulate cost if there is ice observed but not simulated.. | 
 c only accumulate cost if there is ice observed but not simulated.. | 
| 310 | 
                 if ( localobs(i,j,k,bi,bj) .GT. 0.0 .AND.  | 
                 if ( localobs(i,j,k,bi,bj) .GT. 0.0 .AND. | 
| 311 | 
      &                areabar(i,j,1,bi,bj) .LE. 0.0) then | 
      &                areabar(i,j,1,bi,bj) .LE. 0.0) then | 
| 312 | 
  | 
  | 
| 313 | 
 c                if ( localobs(i,j,k,bi,bj) .GT.   | 
 c                if ( localobs(i,j,k,bi,bj) .GT. | 
| 314 | 
 c     &               areabar(i,j,1,bi,bj)) then | 
 c     &               areabar(i,j,1,bi,bj)) then | 
| 315 | 
  | 
  | 
| 316 | 
                    junk = ( localbar(i,j,k,bi,bj) - SEAICE_clamp_salt ) | 
                    junk = ( localbar(i,j,k,bi,bj) - SEAICE_clamp_salt ) | 
| 335 | 
  | 
  | 
| 336 | 
                    print '(A,2i4,2(1x,1P2E15.3))', | 
                    print '(A,2i4,2(1x,1P2E15.3))', | 
| 337 | 
      &                 'costg i j bar-obs,wgt,loCost ',i,j, | 
      &                 'costg i j bar-obs,wgt,loCost ',i,j, | 
| 338 | 
      &                 junk,  | 
      &                 junk, | 
| 339 | 
      &                 localwww,  | 
      &                 localwww, | 
| 340 | 
      &                 localcost | 
      &                 localcost | 
| 341 | 
                 endif | 
                 endif | 
| 342 | 
 #endif | 
 #endif |