/[MITgcm]/MITgcm/pkg/ecco/cost_tau_eddy.F
ViewVC logotype

Contents of /MITgcm/pkg/ecco/cost_tau_eddy.F

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


Revision 1.9 - (show annotations) (download)
Tue Apr 28 18:13:28 2009 UTC (15 years, 1 month ago) by jmc
Branch: MAIN
CVS Tags: checkpoint62, checkpoint62c, checkpoint62b, checkpoint62a, checkpoint61n, checkpoint61o, checkpoint61m, checkpoint61v, checkpoint61w, checkpoint61t, checkpoint61u, checkpoint61r, checkpoint61s, checkpoint61p, checkpoint61q, checkpoint61z, checkpoint61x, checkpoint61y
Changes since 1.8: +2 -2 lines
change macros (EXCH & GLOBAL_SUM/MAX) sufix _R4/_R8 to _RS/_RL
 when applied to _RS/_RL variable

1 C $Header: /u/gcmpack/MITgcm/pkg/ecco/cost_tau_eddy.F,v 1.8 2008/05/30 02:49:05 gforget Exp $
2 C $Name: $
3
4 #include "COST_CPPOPTIONS.h"
5
6
7 subroutine cost_tau_eddy(
8 I myiter,
9 I mytime,
10 I mythid
11 & )
12
13 C o==========================================================o
14 C | subroutine cost_tau_eddy |
15 C | o eddy stress cost term |
16 C | o now two options: |
17 C | ECCO standard or as in Ferreira and Marshall. |
18 C o==========================================================o
19
20 implicit none
21
22 c == global variables ==
23
24 #include "EEPARAMS.h"
25 #include "SIZE.h"
26 #include "GRID.h"
27 #include "DYNVARS.h"
28
29 #include "ecco_cost.h"
30 #include "ctrl.h"
31 #include "ctrl_dummy.h"
32 #include "optim.h"
33
34 c == routine arguments ==
35
36 integer myiter
37 _RL mytime
38 integer mythid
39
40 c == local variables ==
41
42 integer bi,bj
43 integer i,j,k
44 integer itlo,ithi
45 integer jtlo,jthi
46 integer jmin,jmax
47 integer imin,imax
48 integer nrec
49 integer irec
50 integer ilfld
51
52 _RL locfc
53 _RL tau2_max, tau2_temp
54
55 _RL fctile
56 _RL fcthread
57 _RL tmpx
58
59 logical doglobalread
60 logical ladinit
61
62 character*(80) fnamefld
63
64 character*(MAX_LEN_MBUF) msgbuf
65
66 c == external functions ==
67
68 integer ilnblnk
69 external ilnblnk
70
71 c == end of interface ==
72
73
74 #ifdef ALLOW_EDDYPSI_COST_CONTRIBUTION
75 C------------------------------------------------------
76 C Cost function consistent with ECCO standards
77 C------------------------------------------------------
78
79 jtlo = mybylo(mythid)
80 jthi = mybyhi(mythid)
81 itlo = mybxlo(mythid)
82 ithi = mybxhi(mythid)
83 jmin = 1
84 jmax = sny
85 imin = 1
86 imax = snx
87
88 c-- Read state record from global file.
89 doglobalread = .false.
90 ladinit = .false.
91
92 irec = 1
93
94 fcthread = 0. _d 0
95
96 if (optimcycle .ge. 0) then
97 ilfld = ilnblnk( xx_edtaux_file )
98 write(fnamefld(1:80),'(2a,i10.10)')
99 & xx_edtaux_file(1:ilfld),'.',optimcycle
100 endif
101 call active_read_xyz( fnamefld, tmpfld3d, irec, doglobalread,
102 & ladinit, optimcycle, mythid
103 & , xx_edtaux_dummy )
104 c-- Loop over this thread's tiles.
105 do bj = jtlo,jthi
106 do bi = itlo,ithi
107 c-- Determine the weights to be used.
108 fctile = 0. _d 0
109 do k = 1,nr
110 do j = jmin,jmax
111 do i = imin,imax
112 if (_hFacC(i,j,k,bi,bj) .ne. 0.) then
113 tmpx = tmpfld3d(i,j,k,bi,bj)
114 #ifndef ALLOW_SMOOTH_CORREL3D
115 fctile = fctile
116 & + wedtauxFld(i,j,k,bi,bj)*cosphi(i,j,bi,bj)
117 & *tmpx*tmpx
118 #else
119 fctile = fctile + tmpx*tmpx
120 #endif
121 endif
122 enddo
123 enddo
124 enddo
125
126 objf_eddytau(bi,bj) = objf_eddytau(bi,bj) + fctile
127 fcthread = fcthread + fctile
128 enddo
129 enddo
130
131 if (optimcycle .ge. 0) then
132 ilfld = ilnblnk( xx_edtauy_file )
133 write(fnamefld(1:80),'(2a,i10.10)')
134 & xx_edtauy_file(1:ilfld),'.',optimcycle
135 endif
136 call active_read_xyz( fnamefld, tmpfld3d, irec, doglobalread,
137 & ladinit, optimcycle, mythid
138 & , xx_edtauy_dummy )
139 c-- Loop over this thread's tiles.
140 do bj = jtlo,jthi
141 do bi = itlo,ithi
142 c-- Determine the weights to be used.
143 fctile = 0. _d 0
144 do k = 1,nr
145 do j = jmin,jmax
146 do i = imin,imax
147 if (_hFacC(i,j,k,bi,bj) .ne. 0.) then
148 tmpx = tmpfld3d(i,j,k,bi,bj)
149 #ifndef ALLOW_SMOOTH_CORREL3D
150 fctile = fctile
151 & + wedtauyFld(i,j,k,bi,bj)*cosphi(i,j,bi,bj)
152 & *tmpx*tmpx
153 #else
154 fctile = fctile + tmpx*tmpx
155 #endif
156 endif
157 enddo
158 enddo
159 enddo
160
161 objf_eddytau(bi,bj) = objf_eddytau(bi,bj) + fctile
162 fcthread = fcthread + fctile
163
164 #ifdef ECCO_VERBOSE
165 c-- Print cost function for each tile in each thread.
166 write(msgbuf,'(a)') ' '
167 call print_message( msgbuf, standardmessageunit,
168 & SQUEEZE_RIGHT , mythid)
169 write(msgbuf,'(a,i8.8,1x,i3.3,1x,i3.3)')
170 & ' cost_tau_eddy: irec,bi,bj = ',irec,bi,bj
171 call print_message( msgbuf, standardmessageunit,
172 & SQUEEZE_RIGHT , mythid)
173 write(msgbuf,'(a,d22.15)')
174 & ' cost function (dT(0)) = ',
175 & fctile
176 call print_message( msgbuf, standardmessageunit,
177 & SQUEEZE_RIGHT , mythid)
178 #endif
179 enddo
180 enddo
181
182 #ifdef ECCO_VERBOSE
183 c-- Print cost function for all tiles.
184 _GLOBAL_SUM_RL( fcthread , myThid )
185 write(msgbuf,'(a)') ' '
186 call print_message( msgbuf, standardmessageunit,
187 & SQUEEZE_RIGHT , mythid)
188 write(msgbuf,'(a,i8.8)')
189 & ' cost_: irec = ',irec
190 call print_message( msgbuf, standardmessageunit,
191 & SQUEEZE_RIGHT , mythid)
192 write(msgbuf,'(a,d22.15)')
193 & ' global cost function value = ',
194 & fcthread
195 call print_message( msgbuf, standardmessageunit,
196 & SQUEEZE_RIGHT , mythid)
197 write(msgbuf,'(a)') ' '
198 call print_message( msgbuf, standardmessageunit,
199 & SQUEEZE_RIGHT , mythid)
200 #endif
201
202
203
204
205 #elif (defined (ALLOW_COST_TAU_EDDY))
206 C------------------------------------------------------
207 C Cost function as a distance to max. value
208 C------------------------------------------------------
209 C
210 C maximum autorized value of the Eddy stress (squared)
211 C from D. Ferreira
212 C values beyond will be penalized;
213 C values below are not penalized
214 tau2_max = 0.4**2
215 locfc = 0.0
216 c
217 DO bj=myByLo(myThid),myByHi(myThid)
218 DO bi=myBxLo(myThid),myBxHi(myThid)
219 c
220 #ifdef ALLOW_AUTODIFF_TAMC
221 act1 = bi - myBxLo(myThid)
222 max1 = myBxHi(myThid) - myBxLo(myThid) + 1
223 act2 = bj - myByLo(myThid)
224 max2 = myByHi(myThid) - myByLo(myThid) + 1
225 act3 = myThid - 1
226 ikey = (act1 + 1) + act2*max1
227 & + act3*max1*max2
228 #endif /* ALLOW_AUTODIFF_TAMC */
229 c
230 do j=1,sNy
231 do i=1,sNx
232 do k=2,Nr
233 tau2_temp = ( rhonil*eddyPsiX(i,j,k,bi,bj)
234 & *0.5*(_fCori(i,j,bi,bj)+_fCori(i-1,j,bi,bj)) )**2
235 if ( tau2_temp .gt. tau2_max) then
236 locfc = locfc + maskW(i,j,k,bi,bj)*
237 & ( tau2_temp - tau2_max )
238 endif
239 tau2_temp = ( rhonil*eddyPsiY(i,j,k,bi,bj)
240 & *0.5*(_fCori(i,j,bi,bj)+_fCori(i,j-1,bi,bj)) )**2
241 if ( tau2_temp .gt. tau2_max) then
242 locfc = locfc + maskS(i,j,k,bi,bj)*
243 & ( tau2_temp - tau2_max )
244 endif
245 enddo
246 enddo
247 enddo
248 c
249 objf_eddytau(bi,bj) = locfc
250 print*,'objf_eddytau =',locfc
251 c
252 ENDDO
253 ENDDO
254
255
256 #else
257
258 fctile = 0. _d 0
259 fcthread = 0. _d 0
260
261 #ifdef ECCO_VERBOSE
262 _BEGIN_MASTER( mythid )
263 write(msgbuf,'(a)') ' '
264 call print_message( msgbuf, standardmessageunit,
265 & SQUEEZE_RIGHT , mythid)
266 write(msgbuf,'(a)')
267 & ' cost_tau_eddy : no contribution to cost function'
268 call print_message( msgbuf, standardmessageunit,
269 & SQUEEZE_RIGHT , mythid)
270 write(msgbuf,'(a)') ' '
271 call print_message( msgbuf, standardmessageunit,
272 & SQUEEZE_RIGHT , mythid)
273 _END_MASTER( mythid )
274 #endif
275
276 #endif
277
278
279
280 return
281 end
282
283

  ViewVC Help
Powered by ViewVC 1.1.22