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 |
c == local variables == |
c == local variables == |
84 |
|
|
85 |
integer bi,bj |
integer bi,bj |
102 |
_RL localcost |
_RL localcost |
103 |
_RL junk |
_RL junk |
104 |
|
|
105 |
_RL cmask (1-olx:snx+olx,1-oly:sny+oly,nnzobs) |
_RL cmask (1-olx:snx+olx,1-oly:sny+oly,nnzobs) |
106 |
|
|
107 |
character*(128) fname1, fname2,fname3 |
character*(128) fname1, fname2,fname3 |
|
character*(MAX_LEN_MBUF) msgbuf |
|
108 |
|
|
109 |
cnew( |
cnew( |
110 |
_RL daytime |
_RL daytime |
115 |
integer middate(4) |
integer middate(4) |
116 |
integer yday, ymod |
integer yday, ymod |
117 |
integer md, dd, sd, ld, wd |
integer md, dd, sd, ld, wd |
|
integer mody, modm |
|
|
integer beginmodel, beginlocal |
|
118 |
logical exst |
logical exst |
119 |
cnew) |
cnew) |
120 |
|
|
155 |
write(fname3(1:128),'(80a)') ' ' |
write(fname3(1:128),'(80a)') ' ' |
156 |
|
|
157 |
il=ilnblnk( localbarfile ) |
il=ilnblnk( localbarfile ) |
158 |
write(fname1(1:128),'(2a,i10.10)') |
write(fname1(1:128),'(2a,i10.10)') |
159 |
& localbarfile(1:il),'.',optimcycle |
& localbarfile(1:il),'.',optimcycle |
160 |
|
|
161 |
csss |
csss |
162 |
il=ilnblnk( areabarfile ) |
il=ilnblnk( areabarfile ) |
163 |
write(fname3(1:128),'(2a,i10.10)') |
write(fname3(1:128),'(2a,i10.10)') |
164 |
& areabarfile(1:il),'.',optimcycle |
& areabarfile(1:il),'.',optimcycle |
165 |
|
|
166 |
if ( .NOT. ( localobsfile.EQ.' ' ) ) then |
if ( .NOT. ( localobsfile.EQ.' ' ) ) then |
170 |
|
|
171 |
if ( nnzbar .EQ. 1 ) then |
if ( nnzbar .EQ. 1 ) then |
172 |
call active_read_xy( fname1, localbar, irec, doglobalread, |
call active_read_xy( fname1, localbar, irec, doglobalread, |
173 |
& ladinit, optimcycle, mythid, |
& ladinit, optimcycle, mythid, |
174 |
& xx_localbar_mean_dummy ) |
& xx_localbar_mean_dummy ) |
175 |
else |
else |
176 |
call active_read_xyz( fname1, localbar, irec, doglobalread, |
call active_read_xyz( fname1, localbar, irec, doglobalread, |
177 |
& ladinit, optimcycle, mythid, |
& ladinit, optimcycle, mythid, |
178 |
& xx_localbar_mean_dummy ) |
& xx_localbar_mean_dummy ) |
179 |
endif |
endif |
180 |
|
|
181 |
csss |
csss |
182 |
if ( nnzbar .EQ. 1 ) then |
if ( nnzbar .EQ. 1 ) then |
183 |
call active_read_xy( fname3, areabar, irec, doglobalread, |
call active_read_xy( fname3, areabar, irec, doglobalread, |
184 |
& ladinit, optimcycle, mythid, |
& ladinit, optimcycle, mythid, |
185 |
& xx_areabar_mean_dummy ) |
& xx_areabar_mean_dummy ) |
186 |
else |
else |
187 |
call active_read_xyz( fname3, areabar, irec, doglobalread, |
call active_read_xyz( fname3, areabar, irec, doglobalread, |
188 |
& ladinit, optimcycle, mythid, |
& ladinit, optimcycle, mythid, |
189 |
& xx_areabar_mean_dummy ) |
& xx_areabar_mean_dummy ) |
190 |
endif |
endif |
191 |
|
|
213 |
print *,'ymod, yday ', ymod,yday |
print *,'ymod, yday ', ymod,yday |
214 |
print *,'smrarstrtdt(1) ', smrareastartdate(1) |
print *,'smrarstrtdt(1) ', smrareastartdate(1) |
215 |
print *,'smrarstartdate ', smrareastartdate |
print *,'smrarstartdate ', smrareastartdate |
216 |
#endif SEAICE_DEBUG |
#endif /* SEAICE_DEBUG */ |
217 |
|
|
218 |
if ( ymod .EQ. yday ) then |
if ( ymod .EQ. yday ) then |
219 |
middate(1) = smrareastartdate(1) |
middate(1) = smrareastartdate(1) |
220 |
else |
else |
221 |
middate(1) = yday*10000+100+1 |
middate(1) = yday*10000+100+1 |
222 |
endif |
endif |
235 |
print *,'middate(3,4) ', middate(3),middate(4) |
print *,'middate(3,4) ', middate(3),middate(4) |
236 |
print *,'difftime,diffsecs',difftime,diffsecs |
print *,'difftime,diffsecs',difftime,diffsecs |
237 |
print *,'localrec ',localrec |
print *,'localrec ',localrec |
238 |
#endif |
#endif |
239 |
|
|
240 |
il=ilnblnk(localobsfile) |
il=ilnblnk(localobsfile) |
241 |
write(fname2(1:128),'(2a,i4)') |
write(fname2(1:128),'(2a,i4)') |
254 |
#endif |
#endif |
255 |
endif |
endif |
256 |
|
|
257 |
if ( localrec .GT. 0 ) then |
if ( localrec .GT. 0 ) then |
258 |
|
|
259 |
#ifdef SEAICE_DEBUG |
#ifdef SEAICE_DEBUG |
260 |
print *,'calling mdsreadfile',fname2,localrec |
print *,'calling mdsreadfile',fname2,localrec |
261 |
#endif |
#endif |
262 |
|
|
263 |
call mdsreadfield( fname2, cost_iprec, cost_yftype, nnzobs, |
call mdsreadfield( fname2, cost_iprec, cost_yftype, nnzobs, |
264 |
& localobs, localrec, mythid ) |
& localobs, localrec, mythid ) |
265 |
else |
else |
266 |
do bj = jtlo,jthi |
do bj = jtlo,jthi |
318 |
localwww = localweight(i,j,bi,bj)*cmask(i,j,k) |
localwww = localweight(i,j,bi,bj)*cmask(i,j,k) |
319 |
|
|
320 |
c only accumulate cost if there is ice observed but not simulated.. |
c only accumulate cost if there is ice observed but not simulated.. |
321 |
if ( localobs(i,j,k,bi,bj) .GT. 0.0 .AND. |
if ( localobs(i,j,k,bi,bj) .GT. 0.0 .AND. |
322 |
& areabar(i,j,1,bi,bj) .LE. 0.0) then |
& areabar(i,j,1,bi,bj) .LE. 0.0) then |
323 |
|
|
324 |
c if ( localobs(i,j,k,bi,bj) .GT. |
c if ( localobs(i,j,k,bi,bj) .GT. |
325 |
c & areabar(i,j,1,bi,bj)) then |
c & areabar(i,j,1,bi,bj)) then |
326 |
|
|
327 |
junk = ( localbar(i,j,k,bi,bj) - SEAICE_clamp_salt ) |
junk = ( localbar(i,j,k,bi,bj) - SEAICE_clamp_salt ) |
346 |
|
|
347 |
print '(A,2i4,2(1x,1P2E15.3))', |
print '(A,2i4,2(1x,1P2E15.3))', |
348 |
& 'costg i j bar-obs,wgt,loCost ',i,j, |
& 'costg i j bar-obs,wgt,loCost ',i,j, |
349 |
& junk, |
& junk, |
350 |
& localwww, |
& localwww, |
351 |
& localcost |
& localcost |
352 |
endif |
endif |
353 |
#endif |
#endif |