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

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

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


Revision 1.3 - (show annotations) (download)
Tue Jan 20 16:59:16 2004 UTC (20 years, 5 months ago) by heimbach
Branch: MAIN
CVS Tags: checkpoint52l_pre, hrcube4, checkpoint52n_post, checkpoint52j_post, checkpoint53d_post, checkpoint54a_pre, checkpoint55c_post, checkpoint54e_post, checkpoint53c_post, checkpoint55d_pre, checkpoint52j_pre, checkpoint54a_post, checkpoint52l_post, checkpoint52k_post, checkpoint54b_post, checkpoint53b_pre, checkpoint55b_post, checkpoint54d_post, checkpoint53f_post, checkpoint52m_post, checkpoint55, checkpoint53a_post, checkpoint54, checkpoint54f_post, checkpoint53b_post, checkpoint53, checkpoint53g_post, hrcube5, checkpoint52i_post, checkpoint55a_post, checkpoint53d_pre, checkpoint54c_post, checkpoint52i_pre, checkpoint52h_pre, hrcube_2, hrcube_3
Changes since 1.2: +13 -1 lines
Bug fixes and updates to ecco cost functions

1 C $Header: /u/gcmpack/MITgcm/pkg/ecco/cost_theta.F,v 1.2 2003/12/20 20:11:14 heimbach Exp $
2
3 #include "COST_CPPOPTIONS.h"
4
5
6 subroutine cost_Theta(
7 I myiter,
8 I mytime,
9 I mythid
10 & )
11
12 c ==================================================================
13 c SUBROUTINE cost_Theta
14 c ==================================================================
15 c
16 c o Evaluate cost function contribution of temperature.
17 c
18 c started: Christian Eckert eckert@mit.edu 30-Jun-1999
19 c
20 c changed: Christian Eckert eckert@mit.edu 25-Feb-2000
21 c
22 c - Restructured the code in order to create a package
23 c for the MITgcmUV.
24 c
25 c changed: Patrick Heimbach heimbach@mit.edu 27-May-2000
26 c
27 c - set ladinit to .true. to initialise adtbar file
28 c
29 c ==================================================================
30 c SUBROUTINE cost_Theta
31 c ==================================================================
32
33 implicit none
34
35 c == global variables ==
36
37 #include "EEPARAMS.h"
38 #include "SIZE.h"
39 #include "GRID.h"
40 #include "DYNVARS.h"
41
42 #include "cal.h"
43 #include "ecco_cost.h"
44 #include "ctrl.h"
45 #include "ctrl_dummy.h"
46 #include "optim.h"
47
48 c == routine arguments ==
49
50 integer myiter
51 _RL mytime
52 integer mythid
53
54 c == local variables ==
55
56 _RS one_rs
57 parameter( one_rs = 1. )
58
59 integer bi,bj
60 integer i,j,k
61 integer itlo,ithi
62 integer jtlo,jthi
63 integer jmin,jmax
64 integer imin,imax
65 integer irec
66 integer levmon
67 integer levoff
68 integer iltheta
69
70 _RL fctile
71 _RL fcthread
72
73 _RL cmask (1-olx:snx+olx,1-oly:sny+oly)
74 _RL spval
75
76 character*(80) fnametheta
77
78 logical doglobalread
79 logical ladinit
80
81 character*(MAX_LEN_MBUF) msgbuf
82
83 #ifdef GENERIC_BAR_MONTH
84 integer mrec, nyears, iyear, tmpmon
85 #endif
86
87 c == external functions ==
88
89 integer ilnblnk
90 external ilnblnk
91
92 c == end of interface ==
93
94 jtlo = mybylo(mythid)
95 jthi = mybyhi(mythid)
96 itlo = mybxlo(mythid)
97 ithi = mybxhi(mythid)
98 jmin = 1
99 jmax = sny
100 imin = 1
101 imax = snx
102
103 spval = -9990.
104
105 c-- Read tiled data.
106 doglobalread = .false.
107 ladinit = .false.
108
109 #ifdef ALLOW_THETA_COST_CONTRIBUTION
110
111 #ifdef ECCO_VERBOSE
112 _BEGIN_MASTER( mythid )
113 write(msgbuf,'(a)') ' '
114 call print_message( msgbuf, standardmessageunit,
115 & SQUEEZE_RIGHT , mythid)
116 write(msgbuf,'(a,i8.8)')
117 & ' cost_Theta: number of records to process = ',nmonsrec
118 call print_message( msgbuf, standardmessageunit,
119 & SQUEEZE_RIGHT , mythid)
120 write(msgbuf,'(a)') ' '
121 call print_message( msgbuf, standardmessageunit,
122 & SQUEEZE_RIGHT , mythid)
123 _END_MASTER( mythid )
124 #endif
125
126 if (optimcycle .ge. 0) then
127 iltheta = ilnblnk( tbarfile )
128 write(fnametheta(1:80),'(2a,i10.10)')
129 & tbarfile(1:iltheta),'.',optimcycle
130 endif
131
132 fcthread = 0. _d 0
133
134 #ifdef GENERIC_BAR_MONTH
135
136 do bj = jtlo,jthi
137 do bi = itlo,ithi
138 do k = 1,nr
139 do j = jmin,jmax
140 do i = imin,imax
141 tbar_gen(i,j,k,bi,bj) = 0.
142 enddo
143 enddo
144 enddo
145 enddo
146 enddo
147
148 c-- Loop over month
149 if (nmonsrec.GT.12) then
150 tmpmon = 12
151 else
152 tmpmon = nmonsrec
153 endif
154 do irec = 1,tmpmon
155 nyears=int((nmonsrec-irec)/12)+1
156 if(nyears.gt.0) then
157 do iyear=1,nyears
158 mrec=irec+(iyear-1)*12
159 print *, 'ph-rec irec, iyear, mrec ',
160 & irec, iyear, mrec
161 c-- Read time averages and the monthly mean data.
162 call active_read_xyz( fnametheta, tbar, mrec,
163 & doglobalread, ladinit,
164 & optimcycle, mythid,
165 & xx_tbar_mean_dummy )
166 do bj = jtlo,jthi
167 do bi = itlo,ithi
168 do k = 1,nr
169 do j = jmin,jmax
170 do i = imin,imax
171 if(iyear.eq.1) then
172 tbar_gen(i,j,k,bi,bj) =tbar(i,j,k,bi,bj)
173 elseif(iyear.eq.nyears) then
174 tbar(i,j,k,bi,bj) =(tbar_gen(i,j,k,bi,bj)
175 $ +tbar(i,j,k,bi,bj))/float(nyears)
176 else
177 tbar_gen(i,j,k,bi,bj) =tbar_gen(i,j,k,bi,bj)
178 $ +tbar(i,j,k,bi,bj)
179 endif
180 enddo
181 enddo
182 enddo
183 enddo
184 enddo
185 enddo
186
187 #else
188
189 c-- Loop over records.
190 do irec = 1,nmonsrec
191
192 c-- Read time averages and the monthly mean data.
193 call active_read_xyz( fnametheta, tbar, irec,
194 & doglobalread, ladinit,
195 & optimcycle, mythid,
196 & xx_tbar_mean_dummy )
197
198 #endif
199
200 c-- Determine the month to be read.
201 levoff = mod(modelstartdate(1)/100,100)
202 levmon = (irec-1) + levoff
203 levmon = mod(levmon-1,12)+1
204
205 print *, 'ph-rec irec, levmon ', irec, levmon
206 call mdsreadfield( tdatfile, cost_iprec, cost_yftype,
207 & nr, tdat, levmon, mythid)
208
209 do bj = jtlo,jthi
210 do bi = itlo,ithi
211
212 c-- Loop over the model layers
213 fctile = 0. _d 0
214 do k = 1,nr
215
216 c-- Determine the mask on weights
217 do j = jmin,jmax
218 do i = imin,imax
219 cmask(i,j) = 1. _d 0
220 if (tdat(i,j,k,bi,bj) .eq. 0.) then
221 cmask(i,j) = 0. _d 0
222 endif
223
224 if (tdat(i,j,k,bi,bj) .lt. spval) then
225 cmask(i,j) = 0. _d 0
226 endif
227
228 cph(
229 cph print *, 'WARNING: SPECIFIC SETUP FOR ECCO'
230 cph below statement could be replaced by following
231 cph to make it independnet of Nr:
232 cph
233 cph if ( rC(K) .GT. -1000. ) then
234 cph)
235 c set cmask=0 in areas shallower than 1000m
236 if (_hFacC(i,j,13,bi,bj) .eq. 0.) then
237 cmask(i,j) = 0. _d 0
238 endif
239 enddo
240 enddo
241
242 c-- Compute model data misfit and cost function term for
243 c the temperature field.
244 do j = jmin,jmax
245 do i = imin,imax
246 if (_hFacC(i,j,k,bi,bj) .ne. 0.) then
247 fctile = fctile +
248 & (wtheta(k,bi,bj)*cosphi(i,j,bi,bj)*cmask(i,j)*
249 & (tbar(i,j,k,bi,bj) - tdat(i,j,k,bi,bj))*
250 & (tbar(i,j,k,bi,bj) - tdat(i,j,k,bi,bj)) )
251 endif
252 enddo
253 enddo
254
255 enddo
256 c-- End of loop over layers.
257
258 fcthread = fcthread + fctile
259 objf_temp(bi,bj) = objf_temp(bi,bj) + fctile
260
261 #ifdef ECCO_VERBOSE
262 c-- Print cost function for each tile in each thread.
263 write(msgbuf,'(a)') ' '
264 call print_message( msgbuf, standardmessageunit,
265 & SQUEEZE_RIGHT , mythid)
266 write(msgbuf,'(a,i8.8,1x,i3.3,1x,i3.3)')
267 & ' cost_Theta: irec,bi,bj = ',irec,bi,bj
268 call print_message( msgbuf, standardmessageunit,
269 & SQUEEZE_RIGHT , mythid)
270 write(msgbuf,'(a,d22.15)')
271 & ' cost function (temperature) = ',
272 & fctile
273 call print_message( msgbuf, standardmessageunit,
274 & SQUEEZE_RIGHT , mythid)
275 write(msgbuf,'(a)') ' '
276 call print_message( msgbuf, standardmessageunit,
277 & SQUEEZE_RIGHT , mythid)
278 #endif
279
280 enddo
281 enddo
282
283 #ifdef ECCO_VERBOSE
284 c-- Print cost function for all tiles.
285 _GLOBAL_SUM_R8( fcthread , myThid )
286 write(msgbuf,'(a)') ' '
287 call print_message( msgbuf, standardmessageunit,
288 & SQUEEZE_RIGHT , mythid)
289 write(msgbuf,'(a,i8.8)')
290 & ' cost_Theta: irec = ',irec
291 call print_message( msgbuf, standardmessageunit,
292 & SQUEEZE_RIGHT , mythid)
293 write(msgbuf,'(a,a,d22.15)')
294 & ' global cost function value',
295 & ' (temperature) = ',fcthread
296 call print_message( msgbuf, standardmessageunit,
297 & SQUEEZE_RIGHT , mythid)
298 write(msgbuf,'(a)') ' '
299 call print_message( msgbuf, standardmessageunit,
300 & SQUEEZE_RIGHT , mythid)
301 #endif
302
303 #ifdef GENERIC_BAR_MONTH
304 endif
305 #endif
306
307 enddo
308 c-- End of loop over records.
309
310 #endif
311
312 return
313 end
314

  ViewVC Help
Powered by ViewVC 1.1.22