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

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

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


Revision 1.6 - (show annotations) (download)
Wed Mar 24 03:05:11 2010 UTC (14 years, 2 months ago) by jmc
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.5: +31 -31 lines
add missing "_d 0"

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

  ViewVC Help
Powered by ViewVC 1.1.22