/[MITgcm]/MITgcm/pkg/ctrl/ctrl_pack.F
ViewVC logotype

Contents of /MITgcm/pkg/ctrl/ctrl_pack.F

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


Revision 1.15 - (show annotations) (download)
Fri Dec 3 00:48:57 2004 UTC (19 years, 5 months ago) by mlosch
Branch: MAIN
CVS Tags: checkpoint56c_post
Changes since 1.14: +23 -21 lines
o OBCS as control variables
  - update ad_diff.list
  - remove balance of obcs controls from default
  - fix index bug nobcs in ctrl_init
  - fix dummy fields filen in ctrl_pack
  - add dummy weights for obcs

1 C
2 C $Header: /u/gcmpack/MITgcm/pkg/ctrl/ctrl_pack.F,v 1.14 2004/11/16 05:42:12 heimbach Exp $
3 C $Name: checkpoint56 $
4
5 #include "PACKAGES_CONFIG.h"
6 #include "CTRL_CPPOPTIONS.h"
7
8 subroutine ctrl_pack( first, mythid )
9
10 c ==================================================================
11 c SUBROUTINE ctrl_pack
12 c ==================================================================
13 c
14 c o Compress the control vector such that only ocean points are
15 c written to file.
16 c
17 c started: Christian Eckert eckert@mit.edu 10-Mar=2000
18 c
19 c changed: Patrick Heimbach heimbach@mit.edu 06-Jun-2000
20 c - Transferred some filename declarations
21 c from here to namelist in ctrl_init
22 c
23 c Patrick Heimbach heimbach@mit.edu 16-Jun-2000
24 c - single file name convention with or without
25 c ALLOW_ECCO_OPTIMIZATION
26 c
27 c G. Gebbie, added open boundary control packing,
28 c gebbie@mit.edu 18 -Mar- 2003
29 c
30 c heimbach@mit.edu totally restructured 28-Oct-2003
31 c
32 c ==================================================================
33 c SUBROUTINE ctrl_pack
34 c ==================================================================
35
36 implicit none
37
38 c == global variables ==
39
40 #include "EEPARAMS.h"
41 #include "SIZE.h"
42 #include "PARAMS.h"
43 #include "GRID.h"
44
45 #include "ctrl.h"
46 #include "cost.h"
47 #include "optim.h"
48
49 #ifdef ALLOW_ECCO
50 # include "ecco_cost.h"
51 #else
52 # include "ctrl_weights.h"
53 #endif
54
55 c == routine arguments ==
56
57 logical first
58 integer mythid
59
60 #ifndef EXCLUDE_CTRL_PACK
61 c == local variables ==
62
63 _RL fcloc
64
65 integer i, j, k
66 integer ii
67 integer il
68 integer irec
69 integer ig,jg
70 integer ivartype
71 integer iobcs
72
73 logical doglobalread
74 logical ladinit
75 integer cbuffindex
76 logical lxxadxx
77
78 integer cunit
79 integer ictrlgrad
80
81 character*(128) cfile
82 character*( 80) weighttype
83
84 c == external ==
85
86 integer ilnblnk
87 external ilnblnk
88
89 c == end of interface ==
90
91 #ifndef ALLOW_ECCO_OPTIMIZATION
92 fmin = 0. _d 0
93 #endif
94
95 c-- Tiled files are used.
96 doglobalread = .false.
97
98 c-- Initialise adjoint variables on active files.
99 ladinit = .false.
100
101 c-- Initialise global buffer index
102 nbuffglobal = 0
103
104 c-- Assign file names.
105
106 call ctrl_set_fname(xx_theta_file, fname_theta, mythid)
107 call ctrl_set_fname(xx_salt_file, fname_salt, mythid)
108 call ctrl_set_fname(xx_hflux_file, fname_hflux, mythid)
109 call ctrl_set_fname(xx_sflux_file, fname_sflux, mythid)
110 call ctrl_set_fname(xx_tauu_file, fname_tauu, mythid)
111 call ctrl_set_fname(xx_tauv_file, fname_tauv, mythid)
112 call ctrl_set_fname(xx_atemp_file, fname_atemp, mythid)
113 call ctrl_set_fname(xx_aqh_file, fname_aqh, mythid)
114 call ctrl_set_fname(xx_uwind_file, fname_uwind, mythid)
115 call ctrl_set_fname(xx_vwind_file, fname_vwind, mythid)
116 call ctrl_set_fname(xx_obcsn_file, fname_obcsn, mythid)
117 call ctrl_set_fname(xx_obcss_file, fname_obcss, mythid)
118 call ctrl_set_fname(xx_obcsw_file, fname_obcsw, mythid)
119 call ctrl_set_fname(xx_obcse_file, fname_obcse, mythid)
120 call ctrl_set_fname(xx_diffkr_file, fname_diffkr, mythid)
121 call ctrl_set_fname(xx_kapgm_file, fname_kapgm, mythid)
122 call ctrl_set_fname(xx_tr1_file, fname_tr1, mythid)
123 call ctrl_set_fname(xx_sst_file, fname_sst, mythid)
124 call ctrl_set_fname(xx_sss_file, fname_sss, mythid)
125 call ctrl_set_fname(xx_hfacc_file, fname_hfacc, mythid)
126 call ctrl_set_fname(xx_efluxy_file, fname_efluxy, mythid)
127 call ctrl_set_fname(xx_efluxp_file, fname_efluxp, mythid)
128 call ctrl_set_fname(xx_bottomdrag_file, fname_bottomdrag, mythid)
129
130 c
131 c-- Only the master thread will do I/O.
132 _BEGIN_MASTER( mythid )
133
134 if ( first ) then
135 c >>> Initialise control vector for optimcycle=0 <<<
136 lxxadxx = .TRUE.
137 ictrlgrad = 1
138 fcloc = fmin
139 write(cfile(1:128),'(4a,i4.4)')
140 & ctrlname(1:9),'_',yctrlid(1:10),
141 & yctrlpospack, optimcycle
142 print *, 'ph-pack: unpacking ', ctrlname(1:9)
143 else
144 c >>> Write gradient vector <<<
145 lxxadxx = .FALSE.
146 ictrlgrad = 2
147 fcloc = fc
148 write(cfile(1:128),'(4a,i4.4)')
149 & costname(1:9),'_',yctrlid(1:10),
150 & yctrlpospack, optimcycle
151 print *, 'ph-pack: unpacking ', costname(1:9)
152 endif
153
154 call mdsfindunit( cunit, mythid )
155 open( cunit, file = cfile,
156 & status = 'unknown',
157 & form = 'unformatted',
158 & access = 'sequential' )
159
160 c-- Header information.
161 write(cunit) nvartype
162 write(cunit) nvarlength
163 write(cunit) yctrlid
164 write(cunit) optimCycle
165 write(cunit) fc
166 C place holder of obsolete variable iG
167 write(cunit) 1
168 C place holder of obsolete variable jG
169 write(cunit) 1
170 write(cunit) nsx
171 write(cunit) nsy
172 write(cunit) (nWetcGlobal(k), k=1,nr)
173 write(cunit) (nWetsGlobal(k), k=1,nr)
174 write(cunit) (nWetwGlobal(k), k=1,nr)
175 #ifdef ALLOW_CTRL_WETV
176 write(cunit) (nWetvGlobal(k), k=1,nr)
177 #endif
178
179 #ifdef ALLOW_OBCSN_CONTROL
180 write(cunit) ((nWetobcsnGlo(k,iobcs), k=1,nr),iobcs= 1,nobcs)
181 #endif
182 #ifdef ALLOW_OBCSS_CONTROL
183 write(cunit) ((nWetobcssGlo(k,iobcs), k=1,nr),iobcs= 1,nobcs)
184 #endif
185 #ifdef ALLOW_OBCSW_CONTROL
186 write(cunit) ((nWetobcswGlo(k,iobcs), k=1,nr),iobcs= 1,nobcs)
187 #endif
188 #ifdef ALLOW_OBCSE_CONTROL
189 write(cunit) ((nWetobcseGlo(k,iobcs), k=1,nr),iobcs= 1,nobcs)
190 #endif
191 write(cunit) (ncvarindex(i), i=1,maxcvars)
192 write(cunit) (ncvarrecs(i), i=1,maxcvars)
193 write(cunit) (ncvarxmax(i), i=1,maxcvars)
194 write(cunit) (ncvarymax(i), i=1,maxcvars)
195 write(cunit) (ncvarnrmax(i), i=1,maxcvars)
196 write(cunit) (ncvargrd(i), i=1,maxcvars)
197 write(cunit)
198
199 #ifdef ALLOW_THETA0_CONTROL
200 ivartype = 1
201 write(weighttype(1:80),'(80a)') ' '
202 write(weighttype(1:80),'(a)') "wtheta"
203 call ctrl_set_pack_xyz(
204 & cunit, ivartype, fname_theta(ictrlgrad), "hFacC",
205 & weighttype, wtheta, lxxadxx, mythid)
206 #endif
207
208 #ifdef ALLOW_SALT0_CONTROL
209 ivartype = 2
210 write(weighttype(1:80),'(80a)') ' '
211 write(weighttype(1:80),'(a)') "wsalt"
212 call ctrl_set_pack_xyz(
213 & cunit, ivartype, fname_salt(ictrlgrad), "hFacC",
214 & weighttype, wsalt, lxxadxx, mythid)
215 #endif
216
217 #if (defined (ALLOW_HFLUX_CONTROL) || \
218 defined (ALLOW_HFLUX0_CONTROL))
219 ivartype = 3
220 write(weighttype(1:80),'(80a)') ' '
221 write(weighttype(1:80),'(a)') "whflux"
222 call ctrl_set_pack_xy(
223 & cunit, ivartype, fname_hflux(ictrlgrad), "hFacC",
224 & weighttype, lxxadxx, mythid)
225 #endif
226
227 #if (defined (ALLOW_SFLUX_CONTROL) || \
228 defined (ALLOW_SFLUX0_CONTROL))
229 ivartype = 4
230 write(weighttype(1:80),'(80a)') ' '
231 write(weighttype(1:80),'(a)') "wsflux"
232 call ctrl_set_pack_xy(
233 & cunit, ivartype, fname_sflux(ictrlgrad), "hFacC",
234 & weighttype, lxxadxx, mythid)
235 #endif
236
237 #if (defined (ALLOW_USTRESS_CONTROL) || \
238 defined (ALLOW_TAUU0_CONTROL))
239 ivartype = 5
240 write(weighttype(1:80),'(80a)') ' '
241 write(weighttype(1:80),'(a)') "wtauu"
242 call ctrl_set_pack_xy(
243 & cunit, ivartype, fname_tauu(ictrlgrad), "maskW",
244 & weighttype, lxxadxx, mythid)
245 #endif
246
247 #if (defined (ALLOW_VSTRESS_CONTROL) || \
248 defined (ALLOW_TAUV0_CONTROL))
249 ivartype = 6
250 write(weighttype(1:80),'(80a)') ' '
251 write(weighttype(1:80),'(a)') "wtauv"
252 call ctrl_set_pack_xy(
253 & cunit, ivartype, fname_tauv(ictrlgrad), "maskS",
254 & weighttype, lxxadxx, mythid)
255 #endif
256
257 #ifdef ALLOW_ATEMP_CONTROL
258 ivartype = 7
259 write(weighttype(1:80),'(80a)') ' '
260 write(weighttype(1:80),'(a)') "watemp"
261 call ctrl_set_pack_xy(
262 & cunit, ivartype, fname_atemp(ictrlgrad), "hFacC",
263 & weighttype, lxxadxx, mythid)
264 #endif
265
266 #ifdef ALLOW_AQH_CONTROL
267 ivartype = 8
268 write(weighttype(1:80),'(80a)') ' '
269 write(weighttype(1:80),'(a)') "waqh"
270 call ctrl_set_pack_xy(
271 & cunit, ivartype, fname_aqh(ictrlgrad), "hFacC",
272 & weighttype, lxxadxx, mythid)
273 #endif
274
275 #ifdef ALLOW_UWIND_CONTROL
276 ivartype = 9
277 write(weighttype(1:80),'(80a)') ' '
278 write(weighttype(1:80),'(a)') "wuwind"
279 call ctrl_set_pack_xy(
280 & cunit, ivartype, fname_uwind(ictrlgrad), "maskW",
281 & weighttype, lxxadxx, mythid)
282 #endif
283
284 #ifdef ALLOW_VWIND_CONTROL
285 ivartype = 10
286 write(weighttype(1:80),'(80a)') ' '
287 write(weighttype(1:80),'(a)') "wvwind"
288 call ctrl_set_pack_xy(
289 & cunit, ivartype, fname_vwind(ictrlgrad), "maskS",
290 & weighttype, lxxadxx, mythid)
291 #endif
292
293 #ifdef ALLOW_OBCSN_CONTROL
294 ivartype = 11
295 write(weighttype(1:80),'(80a)') ' '
296 write(weighttype(1:80),'(a)') "wobcsn"
297 call ctrl_set_pack_xz(
298 & cunit, ivartype, fname_obcsn(ictrlgrad), "maskobcsn",
299 & weighttype, wobcsn, lxxadxx, mythid)
300 #endif
301
302 #ifdef ALLOW_OBCSS_CONTROL
303 ivartype = 12
304 write(weighttype(1:80),'(80a)') ' '
305 write(weighttype(1:80),'(a)') "wobcss"
306 call ctrl_set_pack_xz(
307 & cunit, ivartype, fname_obcss(ictrlgrad), "maskobcss",
308 & weighttype, wobcss, lxxadxx, mythid)
309 #endif
310
311 #ifdef ALLOW_OBCSW_CONTROL
312 ivartype = 13
313 write(weighttype(1:80),'(80a)') ' '
314 write(weighttype(1:80),'(a)') "wobcsw"
315 call ctrl_set_pack_yz(
316 & cunit, ivartype, fname_obcsw(ictrlgrad), "maskobcsw",
317 & weighttype, wobcsw, lxxadxx, mythid)
318 #endif
319
320 #ifdef ALLOW_OBCSE_CONTROL
321 ivartype = 14
322 write(weighttype(1:80),'(80a)') ' '
323 write(weighttype(1:80),'(a)') "wobcse"
324 call ctrl_set_pack_yz(
325 & cunit, ivartype, fname_obcse(ictrlgrad), "maskobcse",
326 & weighttype, wobcse, lxxadxx, mythid)
327 #endif
328
329 #ifdef ALLOW_DIFFKR_CONTROL
330 ivartype = 15
331 write(weighttype(1:80),'(80a)') ' '
332 write(weighttype(1:80),'(a)') "wdiffkr"
333 call ctrl_set_pack_xyz(
334 & cunit, ivartype, fname_diffkr(ictrlgrad), "hFacC",
335 & weighttype, wunit, lxxadxx, mythid)
336 #endif
337
338 #ifdef ALLOW_KAPGM_CONTROL
339 ivartype = 16
340 write(weighttype(1:80),'(80a)') ' '
341 write(weighttype(1:80),'(a)') "wkapgm"
342 call ctrl_set_pack_xyz(
343 & cunit, ivartype, fname_kapgm(ictrlgrad), "hFacC",
344 & weighttype, wunit, lxxadxx, mythid)
345 #endif
346
347 #ifdef ALLOW_TR10_CONTROL
348 ivartype = 17
349 write(weighttype(1:80),'(80a)') ' '
350 write(weighttype(1:80),'(a)') "wtr1"
351 call ctrl_set_pack_xyz(
352 & cunit, ivartype, fname_tr1(ictrlgrad), "hFacC",
353 & weighttype, wunit, lxxadxx, mythid)
354 #endif
355
356 #ifdef ALLOW_SST0_CONTROL
357 ivartype = 18
358 write(weighttype(1:80),'(80a)') ' '
359 write(weighttype(1:80),'(a)') "wsst0"
360 call ctrl_set_pack_xy(
361 & cunit, ivartype, fname_sst(ictrlgrad), "hFacC",
362 & weighttype, lxxadxx, mythid)
363 #endif
364
365 #ifdef ALLOW_SSS0_CONTROL
366 ivartype = 19
367 write(weighttype(1:80),'(80a)') ' '
368 write(weighttype(1:80),'(a)') "wsss0"
369 call ctrl_set_pack_xy(
370 & cunit, ivartype, fname_sss(ictrlgrad), "hFacC",
371 & weighttype, lxxadxx, mythid)
372 #endif
373
374 #ifdef ALLOW_HFACC_CONTROL
375 ivartype = 20
376 write(weighttype(1:80),'(80a)') ' '
377 write(weighttype(1:80),'(a)') "whfacc"
378 # ifdef ALLOW_HFACC3D_CONTROL
379 call ctrl_set_pack_xyz(
380 & cunit, ivartype, fname_hfacc(ictrlgrad), "hFacC",
381 & weighttype, wunit, lxxadxx, mythid)
382 # else
383 call ctrl_set_pack_xy(
384 & cunit, ivartype, fname_hfacc(ictrlgrad), "hFacC",
385 & weighttype, lxxadxx, mythid)
386 # endif
387 #endif
388
389 #ifdef ALLOW_EFLUXY0_CONTROL
390 ivartype = 21
391 write(weighttype(1:80),'(80a)') ' '
392 write(weighttype(1:80),'(a)') "wefluxy0"
393 call ctrl_set_pack_xyz(
394 & cunit, ivartype, fname_efluxy(ictrlgrad), "hFacS",
395 & weighttype, wunit, lxxadxx, mythid)
396 #endif
397
398 #ifdef ALLOW_EFLUXP0_CONTROL
399 ivartype = 22
400 write(weighttype(1:80),'(80a)') ' '
401 write(weighttype(1:80),'(a)') "wefluxp0"
402 call ctrl_set_pack_xyz(
403 & cunit, ivartype, fname_efluxp(ictrlgrad), "hFacV",
404 & weighttype, wunit, lxxadxx, mythid)
405 #endif
406
407 #ifdef ALLOW_BOTTOMDRAG_CONTROL
408 ivartype = 23
409 write(weighttype(1:80),'(80a)') ' '
410 write(weighttype(1:80),'(a)') "wbottomdrag"
411 call ctrl_set_pack_xy(
412 & cunit, ivartype, fname_bottomdrag(ictrlgrad), "hFacC",
413 & weighttype, lxxadxx, mythid)
414 #endif
415
416 close ( cunit )
417
418 _END_MASTER( mythid )
419
420 #endif /* EXCLUDE_CTRL_PACK */
421
422 return
423 end
424

  ViewVC Help
Powered by ViewVC 1.1.22