1 |
C $Header: /u/gcmpack/MITgcm/pkg/ecco/cost_ies.F,v 1.2 2012/08/06 20:41:55 heimbach Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "ECCO_OPTIONS.h" |
5 |
|
6 |
|
7 |
subroutine cost_ies( |
8 |
I myiter, |
9 |
I mytime, |
10 |
I mythid |
11 |
& ) |
12 |
|
13 |
c ================================================================== |
14 |
c SUBROUTINE cost_ies |
15 |
c ================================================================== |
16 |
c |
17 |
c o Evaluate cost function contribution of invertted echo sounders |
18 |
c => uses travel time (daily average) |
19 |
c |
20 |
c started: Matt Mazloff May-2010 |
21 |
c |
22 |
c ================================================================== |
23 |
c SUBROUTINE cost_ies |
24 |
c ================================================================== |
25 |
|
26 |
implicit none |
27 |
|
28 |
c == global variables == |
29 |
|
30 |
#include "EEPARAMS.h" |
31 |
#include "SIZE.h" |
32 |
#include "PARAMS.h" |
33 |
#include "GRID.h" |
34 |
|
35 |
#include "ecco_cost.h" |
36 |
#include "CTRL_SIZE.h" |
37 |
#include "ctrl.h" |
38 |
#include "ctrl_dummy.h" |
39 |
#include "optim.h" |
40 |
#include "DYNVARS.h" |
41 |
#ifdef ALLOW_PROFILES |
42 |
#include "profiles.h" |
43 |
#endif |
44 |
|
45 |
c == routine arguments == |
46 |
|
47 |
integer myiter |
48 |
_RL mytime |
49 |
integer mythid |
50 |
|
51 |
#ifdef ALLOW_IESTAU_COST_CONTRIBUTION |
52 |
|
53 |
c == local variables == |
54 |
|
55 |
integer bi,bj |
56 |
integer i,j |
57 |
integer itlo,ithi |
58 |
integer jtlo,jthi |
59 |
integer jmin,jmax |
60 |
integer imin,imax |
61 |
integer irec |
62 |
integer ilps |
63 |
|
64 |
logical doglobalread |
65 |
logical ladinit |
66 |
|
67 |
_RL iesmean ( 1-olx:snx+olx, 1-oly:sny+oly, nsx, nsy ) |
68 |
_RL datmean ( 1-olx:snx+olx, 1-oly:sny+oly, nsx, nsy ) |
69 |
_RL iescount ( 1-olx:snx+olx, 1-oly:sny+oly, nsx, nsy ) |
70 |
_RL junk,junkweight |
71 |
|
72 |
character*(80) fname |
73 |
character*(80) fname4test |
74 |
character*(MAX_LEN_MBUF) msgbuf |
75 |
|
76 |
c == external functions == |
77 |
|
78 |
integer ilnblnk |
79 |
external ilnblnk |
80 |
|
81 |
c == end of interface == |
82 |
|
83 |
jtlo = mybylo(mythid) |
84 |
jthi = mybyhi(mythid) |
85 |
itlo = mybxlo(mythid) |
86 |
ithi = mybxhi(mythid) |
87 |
jmin = 1 |
88 |
jmax = sny |
89 |
imin = 1 |
90 |
imax = snx |
91 |
|
92 |
c-- Initialise local variables. |
93 |
|
94 |
do bj = jtlo,jthi |
95 |
do bi = itlo,ithi |
96 |
do j = jmin,jmax |
97 |
do i = imin,imax |
98 |
iesmean(i,j,bi,bj) = 0. _d 0 |
99 |
datmean(i,j,bi,bj) = 0. _d 0 |
100 |
iescount(i,j,bi,bj) = 0. _d 0 |
101 |
enddo |
102 |
enddo |
103 |
enddo |
104 |
enddo |
105 |
|
106 |
doglobalread = .false. |
107 |
ladinit = .false. |
108 |
|
109 |
write(fname(1:80),'(80a)') ' ' |
110 |
ilps=ilnblnk( iestaubarfile ) |
111 |
write(fname(1:80),'(2a,i10.10)') |
112 |
& iestaubarfile(1:ilps),'.',optimcycle |
113 |
|
114 |
c-- ============ |
115 |
c-- Mean values. |
116 |
c-- ============ |
117 |
|
118 |
do irec = 1,ndaysrec |
119 |
|
120 |
c-- Compute the mean over all iesdat records. |
121 |
call active_read_xy( fname, iestaubar, irec, doglobalread, |
122 |
& ladinit, optimcycle, mythid, |
123 |
& xx_iestaubar_mean_dummy ) |
124 |
|
125 |
call cost_ies_read( irec, mythid ) |
126 |
|
127 |
do bj = jtlo,jthi |
128 |
do bi = itlo,ithi |
129 |
do j = jmin,jmax |
130 |
do i = imin,imax |
131 |
if (iesmask(i,j,bi,bj).NE.0.) then |
132 |
iesmean(i,j,bi,bj) = iesmean(i,j,bi,bj) + |
133 |
& iestaubar(i,j,bi,bj) |
134 |
datmean(i,j,bi,bj) = datmean(i,j,bi,bj) + |
135 |
& iesdat(i,j,bi,bj) |
136 |
iescount(i,j,bi,bj) = iescount(i,j,bi,bj) +1. |
137 |
endif |
138 |
enddo |
139 |
enddo |
140 |
enddo |
141 |
enddo |
142 |
enddo |
143 |
|
144 |
CMM done accumulating -- now average |
145 |
do bj = jtlo,jthi |
146 |
do bi = itlo,ithi |
147 |
do j = jmin,jmax |
148 |
do i = imin,imax |
149 |
if (iescount(i,j,bi,bj).GT.0.) then |
150 |
iesmean(i,j,bi,bj) = iesmean(i,j,bi,bj)/iescount(i,j,bi,bj) |
151 |
datmean(i,j,bi,bj) = datmean(i,j,bi,bj)/iescount(i,j,bi,bj) |
152 |
CMM( |
153 |
c print*,'CMM:IES DEBUG: i,j,iescount = ',i,j,iescount(i,j,bi,bj) |
154 |
CMM) |
155 |
endif |
156 |
enddo |
157 |
enddo |
158 |
enddo |
159 |
enddo |
160 |
|
161 |
CMM( output means |
162 |
c CALL WRITE_FLD_XY_RL( 'DiagnosIESmean', ' ', iesmean, |
163 |
c & optimcycle, mythid ) |
164 |
c CALL WRITE_FLD_XY_RL( 'DiagIESobsMean', ' ', datmean, |
165 |
c & optimcycle, mythid ) |
166 |
CMM( DEBUG STUFF |
167 |
c CALL WRITE_FLD_XY_RL( 'DiagnosIEScount', ' ', iescount, |
168 |
c & optimcycle, mythid ) |
169 |
c |
170 |
c CALL WRITE_FLD_XY_RL( 'DiaIESwght', ' ', wies, |
171 |
c & optimcycle, mythid ) |
172 |
|
173 |
CMM) |
174 |
|
175 |
c-- ========== |
176 |
c-- Cost |
177 |
c-- ========== |
178 |
|
179 |
c-- Loop over records for the second time. |
180 |
do irec = 1, ndaysrec |
181 |
|
182 |
call active_read_xy( fname, iestaubar, irec, doglobalread, |
183 |
& ladinit, optimcycle, mythid, |
184 |
& xx_iestaubar_mean_dummy ) |
185 |
|
186 |
call cost_ies_read( irec, mythid ) |
187 |
|
188 |
c-- Compute cost function |
189 |
do bj = jtlo,jthi |
190 |
do bi = itlo,ithi |
191 |
do j = jmin,jmax |
192 |
do i = imin,imax |
193 |
junkweight = wies(i,j,bi,bj)*iesmask(i,j,bi,bj) |
194 |
junk = (iestaubar(i,j,bi,bj) - iesmean(i,j,bi,bj)) |
195 |
& -(iesdat(i,j,bi,bj) - datmean(i,j,bi,bj)) |
196 |
objf_ies(bi,bj) = objf_ies(bi,bj) |
197 |
& + junk*junk*junkweight |
198 |
if ( junkweight .ne. 0. ) |
199 |
& num_ies(bi,bj) = num_ies(bi,bj) + 1. _d 0 |
200 |
C for now dont penalize mean misfit.....depths likely different |
201 |
C and would need offset |
202 |
CMM( |
203 |
c if ( iescount(i,j,bi,bj) .ne. 0. ) then |
204 |
c print*,'CMM:IESdbg1: i,j,irec,junkweight= ',i,j,irec,junkweight |
205 |
c print*,'CMM:IESdbg2: wies,iesmask= ' |
206 |
c & ,wies(i,j,bi,bj),iesmask(i,j,bi,bj) |
207 |
c endif |
208 |
CMM) |
209 |
enddo |
210 |
enddo |
211 |
enddo |
212 |
enddo |
213 |
|
214 |
enddo |
215 |
|
216 |
#endif |
217 |
|
218 |
end |