/[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.11 - (show annotations) (download)
Mon Mar 23 21:04:59 2015 UTC (9 years, 2 months ago) by gforget
Branch: MAIN
CVS Tags: checkpoint66g, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, checkpoint66n, checkpoint66m, checkpoint66l, checkpoint66k, checkpoint66j, checkpoint66i, checkpoint66h, checkpoint65z, checkpoint65x, checkpoint65y, checkpoint65r, checkpoint65s, checkpoint65p, checkpoint65q, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint65k, checkpoint65n, checkpoint65o, checkpoint65l, checkpoint65m, HEAD
Changes since 1.10: +4 -1 lines
- add CPP brackets.

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

  ViewVC Help
Powered by ViewVC 1.1.22