1 |
c ian fenty |
C $Header$ |
2 |
#include "COST_CPPOPTIONS.h" |
C $Name$ |
3 |
|
|
4 |
|
#include "SEAICE_OPTIONS.h" |
5 |
|
#ifdef ALLOW_ECCO |
6 |
|
# include "ECCO_OPTIONS.h" |
7 |
|
#endif |
8 |
|
#ifdef ALLOW_CTRL |
9 |
|
# include "CTRL_OPTIONS.h" |
10 |
|
#endif |
11 |
|
#ifdef ALLOW_COST |
12 |
|
# include "COST_OPTIONS.h" |
13 |
|
#endif |
14 |
|
|
15 |
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 |
16 |
|
|
17 |
subroutine seaice_cost_sss( |
subroutine seaice_cost_sss( |
18 |
& nnzbar, localbarfile, localbar, xx_localbar_mean_dummy, |
& nnzbar, localbarfile, localbar, xx_localbar_mean_dummy, |
19 |
& areabarfile, areabar, xx_areabar_mean_dummy, |
& areabarfile, areabar, xx_areabar_mean_dummy, |
20 |
& nnzobs, localobsfile, localobs, mult_local, |
& nnzobs, localobsfile, localobs, mult_local, |
26 |
|
|
27 |
implicit none |
implicit none |
28 |
|
|
29 |
|
c ian fenty |
30 |
c == global variables == |
c == global variables == |
31 |
|
|
32 |
#include "EEPARAMS.h" |
#include "EEPARAMS.h" |
36 |
# include "cal.h" |
# include "cal.h" |
37 |
#endif |
#endif |
38 |
#ifdef ALLOW_COST |
#ifdef ALLOW_COST |
39 |
# include "ecco_cost.h" |
# ifdef ALLOW_CTRL |
40 |
# include "optim.h" |
# include "optim.h" |
41 |
|
# endif |
42 |
|
# ifdef ALLOW_ECCO |
43 |
|
# include "ecco.h" |
44 |
|
# endif |
45 |
# ifdef ALLOW_SEAICE |
# ifdef ALLOW_SEAICE |
46 |
# include "SEAICE_COST.h" |
# include "SEAICE_COST.h" |
47 |
|
# include "SEAICE_SIZE.h" |
48 |
# include "SEAICE_PARAMS.h" |
# include "SEAICE_PARAMS.h" |
49 |
# endif |
# endif |
50 |
#endif |
#endif |
63 |
|
|
64 |
_RL localobs (1-olx:snx+olx,1-oly:sny+oly,nnzobs,nsx,nsy) |
_RL localobs (1-olx:snx+olx,1-oly:sny+oly,nnzobs,nsx,nsy) |
65 |
_RL localweight(1-olx:snx+olx,1-oly:sny+oly,nsx,nsy) |
_RL localweight(1-olx:snx+olx,1-oly:sny+oly,nsx,nsy) |
66 |
_RL localmask (1-olx:snx+olx,1-oly:sny+oly,nr,nsx,nsy) |
_RS localmask (1-olx:snx+olx,1-oly:sny+oly,nr,nsx,nsy) |
67 |
_RL xx_localbar_mean_dummy |
_RL xx_localbar_mean_dummy |
68 |
_RL xx_areabar_mean_dummy |
_RL xx_areabar_mean_dummy |
69 |
_RL mult_local |
_RL mult_local |
79 |
character*(MAX_LEN_FNAM) localbarfile |
character*(MAX_LEN_FNAM) localbarfile |
80 |
character*(MAX_LEN_FNAM) localobsfile |
character*(MAX_LEN_FNAM) localobsfile |
81 |
|
|
82 |
#ifdef ALLOW_COST |
#if (defined (ALLOW_ECCO) && defined (ALLOW_COST)) |
83 |
|
#ifdef ALLOW_SEAICE_COST_SMR_AREA |
84 |
|
|
85 |
c == local variables == |
c == local variables == |
86 |
|
|
87 |
integer bi,bj |
integer bi,bj |
104 |
_RL localcost |
_RL localcost |
105 |
_RL junk |
_RL junk |
106 |
|
|
107 |
_RL cmask (1-olx:snx+olx,1-oly:sny+oly,nnzobs) |
_RL cmask (1-olx:snx+olx,1-oly:sny+oly,nnzobs) |
108 |
|
|
109 |
character*(128) fname1, fname2,fname3 |
character*(128) fname1, fname2,fname3 |
|
character*(MAX_LEN_MBUF) msgbuf |
|
110 |
|
|
111 |
cnew( |
cnew( |
112 |
_RL daytime |
_RL daytime |
117 |
integer middate(4) |
integer middate(4) |
118 |
integer yday, ymod |
integer yday, ymod |
119 |
integer md, dd, sd, ld, wd |
integer md, dd, sd, ld, wd |
|
integer mody, modm |
|
|
integer beginmodel, beginlocal |
|
120 |
logical exst |
logical exst |
121 |
cnew) |
cnew) |
122 |
|
|
157 |
write(fname3(1:128),'(80a)') ' ' |
write(fname3(1:128),'(80a)') ' ' |
158 |
|
|
159 |
il=ilnblnk( localbarfile ) |
il=ilnblnk( localbarfile ) |
160 |
write(fname1(1:128),'(2a,i10.10)') |
write(fname1(1:128),'(2a,i10.10)') |
161 |
& localbarfile(1:il),'.',optimcycle |
& localbarfile(1:il),'.',optimcycle |
162 |
|
|
163 |
csss |
csss |
164 |
il=ilnblnk( areabarfile ) |
il=ilnblnk( areabarfile ) |
165 |
write(fname3(1:128),'(2a,i10.10)') |
write(fname3(1:128),'(2a,i10.10)') |
166 |
& areabarfile(1:il),'.',optimcycle |
& areabarfile(1:il),'.',optimcycle |
167 |
|
|
168 |
if ( .NOT. ( localobsfile.EQ.' ' ) ) then |
if ( .NOT. ( localobsfile.EQ.' ' ) ) then |
172 |
|
|
173 |
if ( nnzbar .EQ. 1 ) then |
if ( nnzbar .EQ. 1 ) then |
174 |
call active_read_xy( fname1, localbar, irec, doglobalread, |
call active_read_xy( fname1, localbar, irec, doglobalread, |
175 |
& ladinit, optimcycle, mythid, |
& ladinit, optimcycle, mythid, |
176 |
& xx_localbar_mean_dummy ) |
& xx_localbar_mean_dummy ) |
177 |
else |
else |
178 |
call active_read_xyz( fname1, localbar, irec, doglobalread, |
call active_read_xyz( fname1, localbar, irec, doglobalread, |
179 |
& ladinit, optimcycle, mythid, |
& ladinit, optimcycle, mythid, |
180 |
& xx_localbar_mean_dummy ) |
& xx_localbar_mean_dummy ) |
181 |
endif |
endif |
182 |
|
|
183 |
csss |
csss |
184 |
if ( nnzbar .EQ. 1 ) then |
if ( nnzbar .EQ. 1 ) then |
185 |
call active_read_xy( fname3, areabar, irec, doglobalread, |
call active_read_xy( fname3, areabar, irec, doglobalread, |
186 |
& ladinit, optimcycle, mythid, |
& ladinit, optimcycle, mythid, |
187 |
& xx_areabar_mean_dummy ) |
& xx_areabar_mean_dummy ) |
188 |
else |
else |
189 |
call active_read_xyz( fname3, areabar, irec, doglobalread, |
call active_read_xyz( fname3, areabar, irec, doglobalread, |
190 |
& ladinit, optimcycle, mythid, |
& ladinit, optimcycle, mythid, |
191 |
& xx_areabar_mean_dummy ) |
& xx_areabar_mean_dummy ) |
192 |
endif |
endif |
193 |
|
|
215 |
print *,'ymod, yday ', ymod,yday |
print *,'ymod, yday ', ymod,yday |
216 |
print *,'smrarstrtdt(1) ', smrareastartdate(1) |
print *,'smrarstrtdt(1) ', smrareastartdate(1) |
217 |
print *,'smrarstartdate ', smrareastartdate |
print *,'smrarstartdate ', smrareastartdate |
218 |
#endif SEAICE_DEBUG |
#endif /* SEAICE_DEBUG */ |
219 |
|
|
220 |
if ( ymod .EQ. yday ) then |
if ( ymod .EQ. yday ) then |
221 |
middate(1) = smrareastartdate(1) |
middate(1) = smrareastartdate(1) |
222 |
else |
else |
223 |
middate(1) = yday*10000+100+1 |
middate(1) = yday*10000+100+1 |
224 |
endif |
endif |
237 |
print *,'middate(3,4) ', middate(3),middate(4) |
print *,'middate(3,4) ', middate(3),middate(4) |
238 |
print *,'difftime,diffsecs',difftime,diffsecs |
print *,'difftime,diffsecs',difftime,diffsecs |
239 |
print *,'localrec ',localrec |
print *,'localrec ',localrec |
240 |
#endif |
#endif |
241 |
|
|
242 |
il=ilnblnk(localobsfile) |
il=ilnblnk(localobsfile) |
243 |
write(fname2(1:128),'(2a,i4)') |
write(fname2(1:128),'(2a,i4)') |
256 |
#endif |
#endif |
257 |
endif |
endif |
258 |
|
|
259 |
if ( localrec .GT. 0 ) then |
if ( localrec .GT. 0 ) then |
260 |
|
|
261 |
#ifdef SEAICE_DEBUG |
#ifdef SEAICE_DEBUG |
262 |
print *,'calling mdsreadfile',fname2,localrec |
print *,'calling mdsreadfile',fname2,localrec |
263 |
#endif |
#endif |
264 |
|
|
265 |
call mdsreadfield( fname2, cost_iprec, cost_yftype, nnzobs, |
call mdsreadfield( fname2, cost_iprec, cost_yftype, nnzobs, |
266 |
& localobs, localrec, mythid ) |
& localobs, localrec, mythid ) |
267 |
else |
else |
268 |
do bj = jtlo,jthi |
do bj = jtlo,jthi |
320 |
localwww = localweight(i,j,bi,bj)*cmask(i,j,k) |
localwww = localweight(i,j,bi,bj)*cmask(i,j,k) |
321 |
|
|
322 |
c only accumulate cost if there is ice observed but not simulated.. |
c only accumulate cost if there is ice observed but not simulated.. |
323 |
if ( localobs(i,j,k,bi,bj) .GT. 0.0 .AND. |
if ( localobs(i,j,k,bi,bj) .GT. 0.0 .AND. |
324 |
& areabar(i,j,1,bi,bj) .LE. 0.0) then |
& areabar(i,j,1,bi,bj) .LE. 0.0) then |
325 |
|
|
326 |
c if ( localobs(i,j,k,bi,bj) .GT. |
c if ( localobs(i,j,k,bi,bj) .GT. |
327 |
c & areabar(i,j,1,bi,bj)) then |
c & areabar(i,j,1,bi,bj)) then |
328 |
|
|
329 |
junk = ( localbar(i,j,k,bi,bj) - SEAICE_clamp_salt ) |
junk = ( localbar(i,j,k,bi,bj) - SEAICE_clamp_salt ) |
348 |
|
|
349 |
print '(A,2i4,2(1x,1P2E15.3))', |
print '(A,2i4,2(1x,1P2E15.3))', |
350 |
& 'costg i j bar-obs,wgt,loCost ',i,j, |
& 'costg i j bar-obs,wgt,loCost ',i,j, |
351 |
& junk, |
& junk, |
352 |
& localwww, |
& localwww, |
353 |
& localcost |
& localcost |
354 |
endif |
endif |
355 |
#endif |
#endif |
370 |
|
|
371 |
c-- End of mult_local or localobsfile |
c-- End of mult_local or localobsfile |
372 |
endif |
endif |
373 |
|
|
374 |
|
#endif /* ALLOW_SEAICE_COST_SMR_AREA */ |
375 |
#endif /* ifdef ALLOW_COST */ |
#endif /* ifdef ALLOW_COST */ |
376 |
|
|
377 |
end |
end |