/[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.16 - (show annotations) (download)
Sat Dec 4 17:57:37 2004 UTC (19 years, 5 months ago) by heimbach
Branch: MAIN
CVS Tags: checkpoint57b_post, checkpoint57, checkpoint57a_post, checkpoint57a_pre
Changes since 1.15: +5 -4 lines
More untangling.

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

  ViewVC Help
Powered by ViewVC 1.1.22