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

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

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


Revision 1.13 - (show annotations) (download)
Mon Oct 20 03:16:12 2014 UTC (9 years, 6 months ago) by gforget
Branch: MAIN
CVS Tags: checkpoint66g, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, checkpoint66n, checkpoint66m, checkpoint66l, checkpoint66k, checkpoint66j, checkpoint66i, checkpoint66h, checkpoint65z, checkpoint65x, checkpoint65y, checkpoint65r, checkpoint65s, checkpoint65p, checkpoint65q, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint65j, checkpoint65k, checkpoint65h, checkpoint65i, checkpoint65n, checkpoint65o, checkpoint65l, checkpoint65m, checkpoint65g, HEAD
Changes since 1.12: +4 -1 lines
- CTRL_OPTIONS.h is needed when including ctrl.h, etc

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

  ViewVC Help
Powered by ViewVC 1.1.22