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

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

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


Revision 1.3 - (show annotations) (download)
Sat Dec 20 20:11:14 2003 UTC (20 years, 6 months ago) by heimbach
Branch: MAIN
CVS Tags: checkpoint52l_pre, checkpoint52e_pre, hrcube4, checkpoint52n_post, checkpoint52j_post, checkpoint53d_post, checkpoint54a_pre, checkpoint55c_post, checkpoint54e_post, checkpoint52e_post, checkpoint53c_post, checkpoint55d_pre, checkpoint52j_pre, checkpoint54a_post, checkpoint52l_post, checkpoint52k_post, checkpoint54b_post, checkpoint53b_pre, checkpoint55b_post, checkpoint54d_post, checkpoint53f_post, hrcube_1, checkpoint52m_post, checkpoint55, checkpoint53a_post, checkpoint54, checkpoint54f_post, checkpoint53b_post, checkpoint53, checkpoint53g_post, checkpoint52f_post, hrcube5, checkpoint52i_post, checkpoint55a_post, checkpoint53d_pre, checkpoint54c_post, checkpoint52i_pre, checkpoint52h_pre, checkpoint52f_pre, hrcube_2, hrcube_3
Changes since 1.2: +7 -2 lines
oh mann, die lieben verwandten...

1 C $Header: /u/gcmpack/MITgcm/pkg/ecco/cost_ctdsclim.F,v 1.2 2003/12/03 23:08:40 heimbach Exp $
2
3 #include "COST_CPPOPTIONS.h"
4
5
6 subroutine cost_ctdsclim(
7 I myiter,
8 I mytime,
9 I mythid
10 & )
11
12 c ==================================================================
13 c SUBROUTINE cost_Ctdsclim
14 c ==================================================================
15 c
16 c o Evaluate cost function contribution of salinity.
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 adsbar file
28 c
29 c ==================================================================
30 c SUBROUTINE cost_Ctdsclim
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 ilctdsclim
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) fnamesalt
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 c == external functions ==
87
88 integer ilnblnk
89 external ilnblnk
90
91 c == end of interface ==
92
93 jtlo = mybylo(mythid)
94 jthi = mybyhi(mythid)
95 itlo = mybxlo(mythid)
96 ithi = mybxhi(mythid)
97 jmin = 1
98 jmax = sny
99 imin = 1
100 imax = snx
101
102 spval = -9990.
103
104 c-- Read tiled data.
105 doglobalread = .false.
106 ladinit = .false.
107
108 #ifdef ALLOW_CTDSCLIM_COST_CONTRIBUTION
109
110 #ifdef ECCO_VERBOSE
111 _BEGIN_MASTER( mythid )
112 write(msgbuf,'(a)') ' '
113 call print_message( msgbuf, standardmessageunit,
114 & SQUEEZE_RIGHT , mythid)
115 write(msgbuf,'(a,i8.8)')
116 & ' cost_Ctdsclim: number of records to process = ',nmonsrec
117 call print_message( msgbuf, standardmessageunit,
118 & SQUEEZE_RIGHT , mythid)
119 write(msgbuf,'(a)') ' '
120 call print_message( msgbuf, standardmessageunit,
121 & SQUEEZE_RIGHT , mythid)
122 _END_MASTER( mythid )
123 #endif
124
125 if (optimcycle .ge. 0) then
126 ilctdsclim = ilnblnk( sbarfile )
127 write(fnamesalt(1:80),'(2a,i10.10)')
128 & sbarfile(1:ilctdsclim),'.',optimcycle
129 endif
130
131 fcthread = 0. _d 0
132
133 #ifdef GENERIC_BAR_MONTH
134 c-- Loop over month
135 if (nmonsrec.GT.12) then
136 tmpmon = 12
137 else
138 tmpmon = nmonsrec
139 endif
140 do irec = 1,12
141 nyears=int((nmonsrec-irec)/12)+1
142 if(nyears.gt.0) then
143 do iyear=1,nyears
144 mrec=irec+(iyear-1)*12
145 c-- Read time averages and the monthly mean data.
146 call active_read_xyz( fnamesalt, sbar, mrec,
147 & doglobalread, ladinit,
148 & optimcycle, mythid,
149 & xx_sbar_mean_dummy )
150 do bj = jtlo,jthi
151 do bi = itlo,ithi
152 do k = 1,nr
153 do j = jmin,jmax
154 do i = imin,imax
155 if(iyear.eq.1) then
156 sbar_gen(i,j,k,bi,bj) =sbar(i,j,k,bi,bj)
157 elseif(iyear.eq.nyears) then
158 sbar(i,j,k,bi,bj) =(sbar_gen(i,j,k,bi,bj)
159 $ +sbar(i,j,k,bi,bj))/float(nyears)
160 else
161 sbar_gen(i,j,k,bi,bj) =sbar_gen(i,j,k,bi,bj)
162 $ +sbar(i,j,k,bi,bj)
163 endif
164 enddo
165 enddo
166 enddo
167 enddo
168 enddo
169 enddo
170 #else
171 c-- Loop over records.
172 do irec = 1,nmonsrec
173
174 c-- Read time averages and the monthly mean data.
175 call active_read_xyz( fnamesalt, sbar, irec,
176 & doglobalread, ladinit,
177 & optimcycle, mythid,
178 & xx_sbar_mean_dummy )
179 #endif
180 c-- Determine the month to be read.
181 levoff = mod(modelstartdate(1)/100,100)
182 levmon = (irec-1) + levoff
183 levmon = mod(levmon-1,12)+1
184
185 call mdsreadfield( ctdsclimfile, cost_iprec, cost_yftype,
186 & nr, sdat, levmon, mythid)
187
188 do bj = jtlo,jthi
189 do bi = itlo,ithi
190
191 c-- Loop over the model layers
192 fctile = 0. _d 0
193 do k = 1,nr
194
195 c-- Determine the mask or weights
196 do j = jmin,jmax
197 do i = imin,imax
198 cmask(i,j) = 1. _d 0
199 if (sdat(i,j,k,bi,bj) .eq. 0.) then
200 cmask(i,j) = 0. _d 0
201 endif
202 if (sdat(i,j,k,bi,bj) .lt. spval) then
203 cmask(i,j) = 0. _d 0
204 endif
205
206 cph(
207 cph print *, 'WARNING: SPECIFIC SETUP FOR ECCO'
208 cph below statement could be replaced by following
209 cph to make it independnet of Nr:
210 cph
211 cph if ( rC(K) .GT. -1000. ) then
212 cph)
213 c set cmask=0 in areas shallower than 1000m
214 if (_hFacC(i,j,13,bi,bj) .eq. 0.) then
215 cmask(i,j) = 0. _d 0
216 endif
217
218 enddo
219 enddo
220
221 c-- Compute model data misfit and cost function term for
222 c the salinity field.
223 do j = jmin,jmax
224 do i = imin,imax
225 if (_hFacC(i,j,k,bi,bj) .ne. 0.) then
226 fctile = fctile +
227 & (wsalt2(i,j,k,bi,bj)*cosphi(i,j,bi,bj)*
228 & cmask(i,j)*
229 & (sbar(i,j,k,bi,bj) - sdat(i,j,k,bi,bj))*
230 & (sbar(i,j,k,bi,bj) - sdat(i,j,k,bi,bj)) )
231 endif
232 enddo
233 enddo
234
235 enddo
236 c-- End of loop over layers.
237
238 fcthread = fcthread + fctile
239 objf_ctdsclim(bi,bj) = objf_ctdsclim(bi,bj) + fctile
240
241 #ifdef ECCO_VERBOSE
242 c-- Print cost function for each tile in each thread.
243 write(msgbuf,'(a)') ' '
244 call print_message( msgbuf, standardmessageunit,
245 & SQUEEZE_RIGHT , mythid)
246 write(msgbuf,'(a,i8.8,1x,i3.3,1x,i3.3)')
247 & ' cost_Ctdsclim: irec,bi,bj = ',irec,bi,bj
248 call print_message( msgbuf, standardmessageunit,
249 & SQUEEZE_RIGHT , mythid)
250 write(msgbuf,'(a,d22.15)')
251 & ' cost function (salinity) = ',
252 & fctile
253 call print_message( msgbuf, standardmessageunit,
254 & SQUEEZE_RIGHT , mythid)
255 write(msgbuf,'(a)') ' '
256 call print_message( msgbuf, standardmessageunit,
257 & SQUEEZE_RIGHT , mythid)
258 #endif
259
260 enddo
261 enddo
262
263 #ifdef ECCO_VERBOSE
264 c-- Print cost function for all tiles.
265 _GLOBAL_SUM_R8( fcthread , myThid )
266 write(msgbuf,'(a)') ' '
267 call print_message( msgbuf, standardmessageunit,
268 & SQUEEZE_RIGHT , mythid)
269 write(msgbuf,'(a,i8.8)')
270 & ' cost_Ctdsclim: irec = ',irec
271 call print_message( msgbuf, standardmessageunit,
272 & SQUEEZE_RIGHT , mythid)
273 write(msgbuf,'(a,a,d22.15)')
274 & ' global cost function value',
275 & ' (salinity) = ',fcthread
276 call print_message( msgbuf, standardmessageunit,
277 & SQUEEZE_RIGHT , mythid)
278 write(msgbuf,'(a)') ' '
279 call print_message( msgbuf, standardmessageunit,
280 & SQUEEZE_RIGHT , mythid)
281 #endif
282
283 #ifdef GENERIC_BAR_MONTH
284 endif
285 #endif
286 enddo
287 c-- End of loop over records.
288
289 #else
290 c-- Do not enter the calculation of the salinity contribution to
291 c-- the final cost function.
292
293 _BEGIN_MASTER( mythid )
294 write(msgbuf,'(a)') ' '
295 call print_message( msgbuf, standardmessageunit,
296 & SQUEEZE_RIGHT , mythid)
297 write(msgbuf,'(a,a)')
298 & ' cost_Ctdsclim: no contribution of salinity field ',
299 & 'to cost function.'
300 call print_message( msgbuf, standardmessageunit,
301 & SQUEEZE_RIGHT , mythid)
302 write(msgbuf,'(a,a,i9.8)')
303 & ' cost_Ctdsclim: number of records that would have',
304 & ' been processed: ',nmonsrec
305 call print_message( msgbuf, standardmessageunit,
306 & SQUEEZE_RIGHT , mythid)
307 write(msgbuf,'(a)') ' '
308 call print_message( msgbuf, standardmessageunit,
309 & SQUEEZE_RIGHT , mythid)
310 _END_MASTER( mythid )
311 #endif
312
313 return
314 end
315

  ViewVC Help
Powered by ViewVC 1.1.22