/[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.10 - (show annotations) (download)
Sat Oct 18 18:15:44 2014 UTC (9 years, 7 months ago) by gforget
Branch: MAIN
CVS Tags: checkpoint65p, checkpoint65j, checkpoint65k, checkpoint65h, checkpoint65i, checkpoint65n, checkpoint65o, checkpoint65l, checkpoint65m, checkpoint65g
Changes since 1.9: +4 -25 lines
- add CPP brackets around includes, to omit
  them altogether when they are not used.

1 C $Header: /u/gcmpack/MITgcm/pkg/ecco/cost_ctdsclim.F,v 1.9 2012/08/10 19:45:25 jmc Exp $
2 C $Name: $
3
4 #include "ECCO_OPTIONS.h"
5
6
7 subroutine cost_ctdsclim(
8 I myiter,
9 I mytime,
10 I mythid
11 & )
12
13 c ==================================================================
14 c SUBROUTINE cost_Ctdsclim
15 c ==================================================================
16 c
17 c o Evaluate cost function contribution of salinity.
18 c
19 c started: Christian Eckert eckert@mit.edu 30-Jun-1999
20 c
21 c changed: Christian Eckert eckert@mit.edu 25-Feb-2000
22 c
23 c - Restructured the code in order to create a package
24 c for the MITgcmUV.
25 c
26 c changed: Patrick Heimbach heimbach@mit.edu 27-May-2000
27 c
28 c - set ladinit to .true. to initialise adsbar file
29 c
30 c ==================================================================
31 c SUBROUTINE cost_Ctdsclim
32 c ==================================================================
33
34 implicit none
35
36 c == global variables ==
37
38 #ifdef ALLOW_CTDSCLIM_COST_CONTRIBUTION
39 #include "EEPARAMS.h"
40 #include "SIZE.h"
41 #include "GRID.h"
42 #include "DYNVARS.h"
43
44 #include "cal.h"
45 #include "ecco_cost.h"
46 #include "CTRL_SIZE.h"
47 #include "ctrl.h"
48 #include "ctrl_dummy.h"
49 #include "optim.h"
50 #endif
51
52 c == routine arguments ==
53
54 integer myiter
55 _RL mytime
56 integer mythid
57
58 #ifdef ALLOW_CTDSCLIM_COST_CONTRIBUTION
59 c == local variables ==
60
61 _RS one_rs
62 parameter( one_rs = 1. )
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 levmon
72 integer levoff
73 integer ilctdsclim
74
75 _RL fctile
76 _RL fcthread
77
78 _RL cmask (1-olx:snx+olx,1-oly:sny+oly)
79 _RL spval
80
81 character*(80) fnamesalt
82
83 logical doglobalread
84 logical ladinit
85
86 character*(MAX_LEN_MBUF) msgbuf
87
88 #ifdef GENERIC_BAR_MONTH
89 integer mrec, nyears, iyear
90 #endif
91 c == external functions ==
92
93 integer ilnblnk
94 external ilnblnk
95
96 c == end of interface ==
97
98 jtlo = mybylo(mythid)
99 jthi = mybyhi(mythid)
100 itlo = mybxlo(mythid)
101 ithi = mybxhi(mythid)
102 jmin = 1
103 jmax = sny
104 imin = 1
105 imax = snx
106
107 spval = -9990.
108
109 c-- Read tiled data.
110 doglobalread = .false.
111 ladinit = .false.
112
113 if (optimcycle .ge. 0) then
114 ilctdsclim = ilnblnk( sbarfile )
115 write(fnamesalt(1:80),'(2a,i10.10)')
116 & sbarfile(1:ilctdsclim),'.',optimcycle
117 endif
118
119 fcthread = 0. _d 0
120
121 #ifdef GENERIC_BAR_MONTH
122 c-- Loop over month
123 do irec = 1,12
124 nyears=int((nmonsrec-irec)/12)+1
125 if(nyears.gt.0) then
126 do iyear=1,nyears
127 mrec=irec+(iyear-1)*12
128 c-- Read time averages and the monthly mean data.
129 call active_read_xyz( fnamesalt, sbar, mrec,
130 & doglobalread, ladinit,
131 & optimcycle, mythid,
132 & xx_sbar_mean_dummy )
133 do bj = jtlo,jthi
134 do bi = itlo,ithi
135 do k = 1,nr
136 do j = jmin,jmax
137 do i = imin,imax
138 if(iyear.eq.1) then
139 sbar_gen(i,j,k,bi,bj) =sbar(i,j,k,bi,bj)
140 elseif(iyear.eq.nyears) then
141 sbar(i,j,k,bi,bj) =(sbar_gen(i,j,k,bi,bj)
142 $ +sbar(i,j,k,bi,bj))/float(nyears)
143 else
144 sbar_gen(i,j,k,bi,bj) =sbar_gen(i,j,k,bi,bj)
145 $ +sbar(i,j,k,bi,bj)
146 endif
147 enddo
148 enddo
149 enddo
150 enddo
151 enddo
152 enddo
153 #else
154 c-- Loop over records.
155 do irec = 1,nmonsrec
156
157 c-- Read time averages and the monthly mean data.
158 call active_read_xyz( fnamesalt, sbar, irec,
159 & doglobalread, ladinit,
160 & optimcycle, mythid,
161 & xx_sbar_mean_dummy )
162 #endif
163 c-- Determine the month to be read.
164 levoff = mod(modelstartdate(1)/100,100)
165 levmon = (irec-1) + levoff
166 levmon = mod(levmon-1,12)+1
167
168 call mdsreadfield( ctdsclimfile, cost_iprec, cost_yftype,
169 & nr, sdat, levmon, mythid)
170
171 do bj = jtlo,jthi
172 do bi = itlo,ithi
173
174 c-- Loop over the model layers
175 fctile = 0. _d 0
176 do k = 1,nr
177
178 c-- Determine the mask or weights
179 do j = jmin,jmax
180 do i = imin,imax
181 cmask(i,j) = 1. _d 0
182 if (sdat(i,j,k,bi,bj) .eq. 0.) then
183 cmask(i,j) = 0. _d 0
184 endif
185 if (sdat(i,j,k,bi,bj) .lt. spval) then
186 cmask(i,j) = 0. _d 0
187 endif
188 enddo
189 enddo
190
191 c-- Compute model data misfit and cost function term for
192 c the salinity field.
193 do j = jmin,jmax
194 do i = imin,imax
195 if (_hFacC(i,j,k,bi,bj) .ne. 0.) then
196 fctile = fctile +
197 & (wsalt2(i,j,k,bi,bj)*cosphi(i,j,bi,bj)*
198 & cmask(i,j)*
199 & (sbar(i,j,k,bi,bj) - sdat(i,j,k,bi,bj))*
200 & (sbar(i,j,k,bi,bj) - sdat(i,j,k,bi,bj)) )
201 endif
202 enddo
203 enddo
204
205 enddo
206 c-- End of loop over layers.
207
208 fcthread = fcthread + fctile
209 objf_ctdsclim(bi,bj) = objf_ctdsclim(bi,bj) + fctile
210
211 #ifdef ECCO_VERBOSE
212 c-- Print cost function for each tile in each thread.
213 write(msgbuf,'(a)') ' '
214 call print_message( msgbuf, standardmessageunit,
215 & SQUEEZE_RIGHT , mythid)
216 write(msgbuf,'(a,i8.8,1x,i3.3,1x,i3.3)')
217 & ' cost_Ctdsclim: irec,bi,bj = ',irec,bi,bj
218 call print_message( msgbuf, standardmessageunit,
219 & SQUEEZE_RIGHT , mythid)
220 write(msgbuf,'(a,d22.15)')
221 & ' cost function (salinity) = ',
222 & fctile
223 call print_message( msgbuf, standardmessageunit,
224 & SQUEEZE_RIGHT , mythid)
225 write(msgbuf,'(a)') ' '
226 call print_message( msgbuf, standardmessageunit,
227 & SQUEEZE_RIGHT , mythid)
228 #endif
229
230 enddo
231 enddo
232
233 #ifdef ECCO_VERBOSE
234 c-- Print cost function for all tiles.
235 _GLOBAL_SUM_RL( fcthread , myThid )
236 write(msgbuf,'(a)') ' '
237 call print_message( msgbuf, standardmessageunit,
238 & SQUEEZE_RIGHT , mythid)
239 write(msgbuf,'(a,i8.8)')
240 & ' cost_Ctdsclim: irec = ',irec
241 call print_message( msgbuf, standardmessageunit,
242 & SQUEEZE_RIGHT , mythid)
243 write(msgbuf,'(a,a,d22.15)')
244 & ' global cost function value',
245 & ' (salinity) = ',fcthread
246 call print_message( msgbuf, standardmessageunit,
247 & SQUEEZE_RIGHT , mythid)
248 write(msgbuf,'(a)') ' '
249 call print_message( msgbuf, standardmessageunit,
250 & SQUEEZE_RIGHT , mythid)
251 #endif
252
253 #ifdef GENERIC_BAR_MONTH
254 endif
255 #endif
256 enddo
257 c-- End of loop over records.
258
259 #endif
260
261 return
262 end
263

  ViewVC Help
Powered by ViewVC 1.1.22