/[MITgcm]/MITgcm/pkg/seaice/seaice_cost_sss.F
ViewVC logotype

Contents of /MITgcm/pkg/seaice/seaice_cost_sss.F

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


Revision 1.5 - (show annotations) (download)
Tue Mar 23 18:50:02 2010 UTC (14 years, 3 months ago) by heimbach
Branch: MAIN
CVS Tags: checkpoint63p, checkpoint63q, checkpoint63l, checkpoint63m, checkpoint63n, checkpoint63o, checkpoint63h, checkpoint63i, checkpoint63j, checkpoint63k, checkpoint63d, checkpoint63e, checkpoint63f, checkpoint63g, checkpoint63a, checkpoint63b, checkpoint63c, checkpoint63, checkpoint62g, checkpoint62f, checkpoint62e, checkpoint62k, checkpoint62j, checkpoint62i, checkpoint62h, checkpoint62o, checkpoint62n, checkpoint62m, checkpoint62l, checkpoint62s, checkpoint62r, checkpoint62q, checkpoint62p, checkpoint62w, checkpoint62v, checkpoint62u, checkpoint62t, checkpoint62z, checkpoint62y, checkpoint62x
Changes since 1.4: +2 -2 lines
More ifdef oops.

1 C $Header: /u/gcmpack/MITgcm/pkg/seaice/seaice_cost_sss.F,v 1.4 2010/03/23 15:05:46 heimbach Exp $
2 C $Name: $
3
4 #include "SEAICE_OPTIONS.h"
5
6 c read the area dat file and compare against the averaged salinity file
7
8 subroutine seaice_cost_sss(
9 & nnzbar, localbarfile, localbar, xx_localbar_mean_dummy,
10 & areabarfile, areabar, xx_areabar_mean_dummy,
11 & nnzobs, localobsfile, localobs, mult_local,
12 & nrecloc, localstartdate, localperiod,
13 & localmask, localweight,
14 & spminloc, spmaxloc, spzeroloc,
15 & objf_local, num_local,
16 & myiter, mytime, mythid )
17
18 implicit none
19
20 c ian fenty
21 c == global variables ==
22
23 #include "EEPARAMS.h"
24 #include "SIZE.h"
25 #include "PARAMS.h"
26 #ifdef ALLOW_CAL
27 # include "cal.h"
28 #endif
29 #ifdef ALLOW_COST
30 # include "optim.h"
31 # ifdef ALLOW_ECCO
32 # include "ecco_cost.h"
33 # endif
34 # ifdef ALLOW_SEAICE
35 # include "SEAICE_COST.h"
36 # include "SEAICE_PARAMS.h"
37 # endif
38 #endif
39
40 c == routine arguments ==
41
42 integer nnzbar
43 integer nnzobs
44 integer nrecloc
45 integer myiter
46 integer mythid
47 integer localstartdate(4)
48
49 _RL localbar (1-olx:snx+olx,1-oly:sny+oly,nnzbar,nsx,nsy)
50 _RL areabar (1-olx:snx+olx,1-oly:sny+oly,nnzbar,nsx,nsy)
51
52 _RL localobs (1-olx:snx+olx,1-oly:sny+oly,nnzobs,nsx,nsy)
53 _RL localweight(1-olx:snx+olx,1-oly:sny+oly,nsx,nsy)
54 _RL localmask (1-olx:snx+olx,1-oly:sny+oly,nr,nsx,nsy)
55 _RL xx_localbar_mean_dummy
56 _RL xx_areabar_mean_dummy
57 _RL mult_local
58 _RL mytime
59 _RL localperiod
60 _RL spminloc
61 _RL spmaxloc
62 _RL spzeroloc
63 _RL objf_local(nsx,nsy)
64 _RL num_local(nsx,nsy)
65
66 character*(MAX_LEN_FNAM) areabarfile
67 character*(MAX_LEN_FNAM) localbarfile
68 character*(MAX_LEN_FNAM) localobsfile
69
70 #if (defined (ALLOW_ECCO) && defined (ALLOW_COST))
71 c == local variables ==
72
73 integer bi,bj
74 integer i,j,k
75 integer itlo,ithi
76 integer jtlo,jthi
77 integer jmin,jmax
78 integer imin,imax
79 integer irec
80 integer il
81 integer localrec
82 integer obsrec
83
84 logical doglobalread
85 logical ladinit
86
87 _RL spval
88 parameter (spval = -9999. )
89 _RL localwww
90 _RL localcost
91 _RL junk
92
93 _RL cmask (1-olx:snx+olx,1-oly:sny+oly,nnzobs)
94
95 character*(128) fname1, fname2,fname3
96 character*(MAX_LEN_MBUF) msgbuf
97
98 cnew(
99 _RL daytime
100 _RL diffsecs
101 integer dayiter
102 integer daydate(4)
103 integer difftime(4)
104 integer middate(4)
105 integer yday, ymod
106 integer md, dd, sd, ld, wd
107 integer mody, modm
108 integer beginmodel, beginlocal
109 logical exst
110 cnew)
111
112 c == external functions ==
113
114 integer ilnblnk
115 external ilnblnk
116
117 c == end of interface ==
118
119 jtlo = mybylo(mythid)
120 jthi = mybyhi(mythid)
121 itlo = mybxlo(mythid)
122 ithi = mybxhi(mythid)
123 jmin = 1
124 jmax = sny
125 imin = 1
126 imax = snx
127
128 c-- Initialise local variables.
129
130 localwww = 0. _d 0
131
132 do bj = jtlo,jthi
133 do bi = itlo,ithi
134 objf_local(bi,bj) = 0. _d 0
135 num_local(bi,bj) = 0. _d 0
136 enddo
137 enddo
138
139 c-- First, read tiled data.
140 doglobalread = .false.
141 ladinit = .false.
142
143
144 write(fname1(1:128),'(80a)') ' '
145 csss
146 write(fname3(1:128),'(80a)') ' '
147
148 il=ilnblnk( localbarfile )
149 write(fname1(1:128),'(2a,i10.10)')
150 & localbarfile(1:il),'.',optimcycle
151
152 csss
153 il=ilnblnk( areabarfile )
154 write(fname3(1:128),'(2a,i10.10)')
155 & areabarfile(1:il),'.',optimcycle
156
157 if ( .NOT. ( localobsfile.EQ.' ' ) ) then
158
159 c-- Loop over records for the second time.
160 do irec = 1, nrecloc
161
162 if ( nnzbar .EQ. 1 ) then
163 call active_read_xy( fname1, localbar, irec, doglobalread,
164 & ladinit, optimcycle, mythid,
165 & xx_localbar_mean_dummy )
166 else
167 call active_read_xyz( fname1, localbar, irec, doglobalread,
168 & ladinit, optimcycle, mythid,
169 & xx_localbar_mean_dummy )
170 endif
171
172 csss
173 if ( nnzbar .EQ. 1 ) then
174 call active_read_xy( fname3, areabar, irec, doglobalread,
175 & ladinit, optimcycle, mythid,
176 & xx_areabar_mean_dummy )
177 else
178 call active_read_xyz( fname3, areabar, irec, doglobalread,
179 & ladinit, optimcycle, mythid,
180 & xx_areabar_mean_dummy )
181 endif
182
183 cnew(
184 obsrec = irec
185
186 daytime = FLOAT(secondsperday*(irec-1)) + modelstart
187 dayiter = hoursperday*(irec-1)+modeliter0
188
189 call cal_getdate( dayiter, daytime, daydate, mythid )
190 call cal_convdate( daydate,yday,md,dd,sd,ld,wd,mythid )
191 ymod = smrareastartdate(1)/10000
192
193 #ifdef SEAICE_DEBUG
194 print *,'cost_seaice_sss'
195 print *,'daydate ', daydate
196 print *,'areaobsfile: ', localobsfile
197 print *,'nrecloc ', nrecloc
198 print *,'obsrec,daytime ', obsrec,daytime
199 print *,'dayiter ', dayiter
200 print *,'yday : ', yday
201 print *,'md,dd,sd ', md,dd,sd
202 print *,'ld,wd ', ld,wd
203 print *,'loclstrtdte(1) ', localstartdate(1)
204 print *,'ymod, yday ', ymod,yday
205 print *,'smrarstrtdt(1) ', smrareastartdate(1)
206 print *,'smrarstartdate ', smrareastartdate
207 #endif /* SEAICE_DEBUG */
208
209 if ( ymod .EQ. yday ) then
210 middate(1) = smrareastartdate(1)
211 else
212 middate(1) = yday*10000+100+1
213 endif
214 middate(2) = 0
215 middate(3) = modelstartdate(3)
216 middate(4) = modelstartdate(4)
217
218
219 call cal_TimePassed( middate, daydate, difftime, mythid )
220 call cal_ToSeconds( difftime, diffsecs, mythid )
221
222 localrec = int(diffsecs/localperiod) + 1
223
224 #ifdef SEAICE_DEBUG
225 print *,'middate(1,2) ',middate(1),middate(2)
226 print *,'middate(3,4) ', middate(3),middate(4)
227 print *,'difftime,diffsecs',difftime,diffsecs
228 print *,'localrec ',localrec
229 #endif
230
231 il=ilnblnk(localobsfile)
232 write(fname2(1:128),'(2a,i4)')
233 & localobsfile(1:il), '_', yday
234 inquire( file=fname2, exist=exst )
235
236 #ifdef SEAICE_DEBUG
237 print *,'fname2',fname2
238 #endif
239 if (.NOT. exst) then
240 write(fname2(1:128),'(a)') localobsfile(1:il)
241 localrec = obsrec
242 #ifdef SEAICE_DEBUG
243 print *,'localrec ', localrec
244 print *,'not exist'
245 #endif
246 endif
247
248 if ( localrec .GT. 0 ) then
249
250 #ifdef SEAICE_DEBUG
251 print *,'calling mdsreadfile',fname2,localrec
252 #endif
253
254 call mdsreadfield( fname2, cost_iprec, cost_yftype, nnzobs,
255 & localobs, localrec, mythid )
256 else
257 do bj = jtlo,jthi
258 do bi = itlo,ithi
259 do k = 1,nnzobs
260 do j = jmin,jmax
261 do i = imin,imax
262 localobs(i,j,k,bi,bj) = spval
263 enddo
264 enddo
265 enddo
266 enddo
267 enddo
268 endif
269 cnew)
270
271 #ifdef SEAICE_DEBUG
272 do bj = jtlo,jthi
273 do bi = itlo,ithi
274 do k = 1,nnzobs
275 do i = imin,imax
276 do j = jmin,jmax
277 if (localobs(i,j,k,bi,bj) .LT. -1) THEN
278 print *,'obs rec date: ', -localobs(i,j,1,bi,bj)
279 endif
280 enddo
281 enddo
282 enddo
283 enddo
284 enddo
285 #endif
286
287 do bj = jtlo,jthi
288 do bi = itlo,ithi
289
290 localcost = 0. _d 0
291
292 c-- Determine the mask on weights
293 do k = 1,nnzobs
294 do j = jmin,jmax
295 do i = imin,imax
296 cmask(i,j,k) = cosphi(i,j,bi,bj)*localmask(i,j,k,bi,bj)
297 if ( localobs(i,j,k,bi,bj) .lt. spminloc .or.
298 & localobs(i,j,k,bi,bj) .gt. spmaxloc .or.
299 & localobs(i,j,k,bi,bj) .eq. spzeroloc ) then
300 cmask(i,j,k) = 0. _d 0
301 endif
302 enddo
303 enddo
304 enddo
305 c--
306 do k = 1,nnzobs
307 do j = jmin,jmax
308 do i = imin,imax
309 localwww = localweight(i,j,bi,bj)*cmask(i,j,k)
310
311 c only accumulate cost if there is ice observed but not simulated..
312 if ( localobs(i,j,k,bi,bj) .GT. 0.0 .AND.
313 & areabar(i,j,1,bi,bj) .LE. 0.0) then
314
315 c if ( localobs(i,j,k,bi,bj) .GT.
316 c & areabar(i,j,1,bi,bj)) then
317
318 junk = ( localbar(i,j,k,bi,bj) - SEAICE_clamp_salt )
319
320 c junk = localbar(i,j,k,bi,bj) -
321 c & ( localbar(i,j,k,bi,bj) - 1.0)
322 else
323 junk = 0.0
324 endif
325
326 localcost = localcost + junk*junk*localwww
327
328 #ifdef SEAICE_DEBUG
329 if ((i == SEAICE_debugPointX) .and.
330 & (j == SEAICE_debugPointY)) then
331
332 print '(A,2i4,3(1x,1P2E15.3))',
333 & 'costg i j sbar, abar,obs ',i,j,
334 & localbar(i,j,k,bi,bj),
335 & areabar(i,j,k,bi,bj),
336 & localobs(i,j,k,bi,bj)
337
338 print '(A,2i4,2(1x,1P2E15.3))',
339 & 'costg i j bar-obs,wgt,loCost ',i,j,
340 & junk,
341 & localwww,
342 & localcost
343 endif
344 #endif
345
346 if ( localwww .ne. 0. )
347 & num_local(bi,bj) = num_local(bi,bj) + 1. _d 0
348 enddo
349 enddo
350 enddo
351
352 objf_local(bi,bj) = objf_local(bi,bj) + localcost
353
354 enddo !/bj
355 enddo !/ bi
356
357 enddo
358 c-- End of second loop over records.
359
360 c-- End of mult_local or localobsfile
361 endif
362 #endif /* ifdef ALLOW_COST */
363
364 end

  ViewVC Help
Powered by ViewVC 1.1.22