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

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

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


Revision 1.8 - (hide annotations) (download)
Fri Nov 9 22:15:18 2012 UTC (11 years, 6 months ago) by heimbach
Branch: MAIN
CVS Tags: checkpoint64y, checkpoint64x, checkpoint64z, checkpoint64q, checkpoint64p, checkpoint64s, checkpoint64r, checkpoint64u, checkpoint64t, checkpoint64w, checkpoint64v, checkpoint64i, checkpoint64h, checkpoint64k, checkpoint64j, checkpoint64m, checkpoint64l, checkpoint64o, checkpoint64n, checkpoint64a, checkpoint64c, checkpoint64b, checkpoint64e, checkpoint64d, checkpoint64g, checkpoint64f, checkpoint65, checkpoint65b, checkpoint65c, checkpoint65a, checkpoint65d, checkpoint65e
Changes since 1.7: +2 -1 lines
Merge SEAICE_SIZE.h inclusion from MITgcm_contrib/torge/itd/code/
into main branch

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

  ViewVC Help
Powered by ViewVC 1.1.22