1 |
C $Header: /u/gcmpack/MITgcm/pkg/ecco/cost_obcse.F,v 1.7 2011/06/24 19:39:32 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "COST_CPPOPTIONS.h" |
5 |
|
6 |
CBOP |
7 |
C !ROUTINE: COST_OBCSE |
8 |
C !INTERFACE: |
9 |
subroutine cost_obcse( |
10 |
I myiter, |
11 |
I mytime, |
12 |
I startrec, |
13 |
I endrec, |
14 |
I mythid |
15 |
& ) |
16 |
|
17 |
C !DESCRIPTION: \bv |
18 |
c ================================================================== |
19 |
c SUBROUTINE cost_obcse |
20 |
c ================================================================== |
21 |
c |
22 |
c o cost function contribution obc |
23 |
c |
24 |
c ================================================================== |
25 |
c SUBROUTINE cost_obcse |
26 |
c ================================================================== |
27 |
C \ev |
28 |
|
29 |
C !USES: |
30 |
|
31 |
implicit none |
32 |
|
33 |
c == global variables == |
34 |
|
35 |
#include "EEPARAMS.h" |
36 |
#include "SIZE.h" |
37 |
#include "PARAMS.h" |
38 |
#include "GRID.h" |
39 |
c#include "DYNVARS.h" |
40 |
#ifdef ALLOW_OBCS |
41 |
c# include "OBCS_PARAMS.h" |
42 |
# include "OBCS_GRID.h" |
43 |
#endif |
44 |
|
45 |
#include "cal.h" |
46 |
#include "ecco_cost.h" |
47 |
#include "CTRL_SIZE.h" |
48 |
#include "ctrl.h" |
49 |
#include "ctrl_dummy.h" |
50 |
#include "optim.h" |
51 |
|
52 |
C !INPUT/OUTPUT PARAMETERS: |
53 |
c == routine arguments == |
54 |
|
55 |
integer myiter |
56 |
_RL mytime |
57 |
integer mythid |
58 |
integer startrec |
59 |
integer endrec |
60 |
|
61 |
C !LOCAL VARIABLES: |
62 |
c == local variables == |
63 |
|
64 |
integer bi,bj |
65 |
integer i,j,k |
66 |
integer itlo,ithi |
67 |
integer jtlo,jthi |
68 |
integer jmin,jmax |
69 |
integer imin,imax |
70 |
integer irec |
71 |
integer il |
72 |
integer iobcs |
73 |
integer ip1 |
74 |
integer nrec |
75 |
integer ilfld |
76 |
integer igg |
77 |
|
78 |
_RL fctile |
79 |
_RL fcthread |
80 |
_RL dummy |
81 |
_RL gg |
82 |
_RL tmpx |
83 |
cgg( |
84 |
_RL tmpfield (1-oly:sny+oly,nr,nsx,nsy) |
85 |
_RL maskyz (1-oly:sny+oly,nr,nsx,nsy) |
86 |
|
87 |
character*(80) fnamefld |
88 |
|
89 |
logical doglobalread |
90 |
logical ladinit |
91 |
|
92 |
#ifdef ECCO_VERBOSE |
93 |
character*(MAX_LEN_MBUF) msgbuf |
94 |
#endif |
95 |
|
96 |
c == external functions == |
97 |
|
98 |
integer ilnblnk |
99 |
external ilnblnk |
100 |
|
101 |
c == end of interface == |
102 |
CEOP |
103 |
|
104 |
jtlo = mybylo(mythid) |
105 |
jthi = mybyhi(mythid) |
106 |
itlo = mybxlo(mythid) |
107 |
ithi = mybxhi(mythid) |
108 |
jmin = 1 |
109 |
jmax = sny |
110 |
imin = 1 |
111 |
imax = snx |
112 |
|
113 |
c-- Read tiled data. |
114 |
doglobalread = .false. |
115 |
ladinit = .false. |
116 |
|
117 |
c Number of records to be used. |
118 |
nrec = endrec-startrec+1 |
119 |
|
120 |
#ifdef ALLOW_OBCSE_COST_CONTRIBUTION |
121 |
|
122 |
ip1 = 1 |
123 |
fcthread = 0. _d 0 |
124 |
|
125 |
#ifdef ECCO_VERBOSE |
126 |
_BEGIN_MASTER( mythid ) |
127 |
write(msgbuf,'(a)') ' ' |
128 |
call print_message( msgbuf, standardmessageunit, |
129 |
& SQUEEZE_RIGHT , mythid) |
130 |
write(msgbuf,'(a)') ' ' |
131 |
call print_message( msgbuf, standardmessageunit, |
132 |
& SQUEEZE_RIGHT , mythid) |
133 |
write(msgbuf,'(a,i9.8)') |
134 |
& ' cost_obcse: number of records to process: ',nrec |
135 |
call print_message( msgbuf, standardmessageunit, |
136 |
& SQUEEZE_RIGHT , mythid) |
137 |
write(msgbuf,'(a)') ' ' |
138 |
call print_message( msgbuf, standardmessageunit, |
139 |
& SQUEEZE_RIGHT , mythid) |
140 |
_END_MASTER( mythid ) |
141 |
#endif |
142 |
|
143 |
if (optimcycle .ge. 0) then |
144 |
ilfld=ilnblnk( xx_obcse_file ) |
145 |
write(fnamefld(1:80),'(2a,i10.10)') |
146 |
& xx_obcse_file(1:ilfld), '.', optimcycle |
147 |
endif |
148 |
|
149 |
c-- Loop over records. |
150 |
do irec = 1,nrec |
151 |
|
152 |
call active_read_yz( fnamefld, tmpfield, irec, doglobalread, |
153 |
& ladinit, optimcycle, mythid |
154 |
& , xx_obcse_dummy ) |
155 |
|
156 |
cgg Need to solve for iobcs would have been. |
157 |
gg = (irec-1)/nobcs |
158 |
igg = int(gg) |
159 |
iobcs = irec - igg*nobcs |
160 |
|
161 |
call active_read_yz( 'maskobcse', maskyz, |
162 |
& iobcs, |
163 |
& doglobalread, ladinit, 0, |
164 |
& mythid, dummy ) |
165 |
|
166 |
c-- Loop over this thread s tiles. |
167 |
do bj = jtlo,jthi |
168 |
do bi = itlo,ithi |
169 |
|
170 |
c-- Determine the weights to be used. |
171 |
fctile = 0. _d 0 |
172 |
|
173 |
do k = 1, Nr |
174 |
do j = jmin,jmax |
175 |
i = OB_Iw(j,bi,bj) |
176 |
cgg if (maskW(i+ip1,j,k,bi,bj) .ne. 0.) then |
177 |
tmpx = tmpfield(j,k,bi,bj) |
178 |
CMM fctile = fctile + wobcse2(j,k,bi,bj,iobcs) |
179 |
fctile = fctile + wobcse(k,iobcs) |
180 |
& *tmpx*tmpx*maskyz(j,k,bi,bj) |
181 |
cgg endif |
182 |
CMM if (wobcsw2(j,k,bi,bj,iobcs)*maskyz(j,k,bi,bj).ne.0.) |
183 |
if (wobcse(k,iobcs)*maskyz(j,k,bi,bj).ne.0.) |
184 |
& num_obcse(bi,bj) = num_obcse(bi,bj) + 1. _d 0 |
185 |
enddo |
186 |
enddo |
187 |
|
188 |
objf_obcse(bi,bj) = objf_obcse(bi,bj) + fctile |
189 |
fcthread = fcthread + fctile |
190 |
enddo |
191 |
enddo |
192 |
|
193 |
#ifdef ECCO_VERBOSE |
194 |
c-- Print cost function for all tiles. |
195 |
_GLOBAL_SUM_RL( fcthread , myThid ) |
196 |
write(msgbuf,'(a)') ' ' |
197 |
call print_message( msgbuf, standardmessageunit, |
198 |
& SQUEEZE_RIGHT , mythid) |
199 |
write(msgbuf,'(a,i8.8)') |
200 |
& ' cost_obcse: irec = ',irec |
201 |
call print_message( msgbuf, standardmessageunit, |
202 |
& SQUEEZE_RIGHT , mythid) |
203 |
write(msgbuf,'(a,a,d22.15)') |
204 |
& ' global cost function value', |
205 |
& ' (obcse) = ',fcthread |
206 |
call print_message( msgbuf, standardmessageunit, |
207 |
& SQUEEZE_RIGHT , mythid) |
208 |
write(msgbuf,'(a)') ' ' |
209 |
call print_message( msgbuf, standardmessageunit, |
210 |
& SQUEEZE_RIGHT , mythid) |
211 |
#endif |
212 |
|
213 |
enddo |
214 |
c-- End of loop over records. |
215 |
|
216 |
#endif |
217 |
|
218 |
return |
219 |
end |