/[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.11 - (show annotations) (download)
Thu Oct 30 19:09:05 2003 UTC (20 years, 7 months ago) by heimbach
Branch: MAIN
CVS Tags: checkpoint51t_post, checkpoint51s_post, checkpoint51q_post, checkpoint51r_post
Branch point for: branch-nonh
Changes since 1.10: +99 -164 lines
ctrl package totally restructured
o pack/unpack now optional and decoupled from
  xx_/adxx_ I/O
o ctrl_pack/unpack cleaned
  (new routines ctrl_init_ctrlvar.F, pkg/ctrl/ctrl_init_wet.F)
o confined inclusion of AD_CONFIG.h to where necessary.

1 C
2 C $Header: /u/gcmpack/MITgcm/pkg/ctrl/ctrl_pack.F,v 1.10 2003/10/23 04:41:40 edhill Exp $
3 C $Name: $
4
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 restrucured 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 "ecco.h"
45 #include "ctrl.h"
46 #include "cost.h"
47
48 #ifdef ALLOW_ECCO_OPTIMIZATION
49 #include "optim.h"
50 #endif
51
52 c == routine arguments ==
53
54 logical first
55 integer mythid
56
57 #ifndef EXCLUDE_CTRL_PACK
58 c == local variables ==
59
60 #ifndef ALLOW_ECCO_OPTIMIZATION
61 integer optimcycle
62 _RL fmin
63 #endif
64
65 _RL fcloc
66
67 integer i, j, k
68 integer ii
69 integer il
70 integer irec
71 integer ig,jg
72 integer ivartype
73 integer iobcs
74
75 logical doglobalread
76 logical ladinit
77 integer cbuffindex
78 logical lxxadxx
79
80 integer cunit
81 integer ictrlgrad
82
83 character*(128) cfile
84 character*( 80) weighttype
85
86 c == external ==
87
88 integer ilnblnk
89 external ilnblnk
90
91 c == end of interface ==
92
93 #ifndef ALLOW_ECCO_OPTIMIZATION
94 optimcycle = 0
95 fmin = 0. _d 0
96 #endif
97
98 c-- Tiled files are used.
99 doglobalread = .false.
100
101 c-- Initialise adjoint variables on active files.
102 ladinit = .false.
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 print *, 'ph-pack in pack '
135 if ( first .AND. optimcycle .EQ. 0 ) then
136 c >>> Initialise control vector for optimcycle=0 <<<
137 print *, 'ph-pack in ctrl '
138 lxxadxx = .TRUE.
139 ictrlgrad = 1
140 fcloc = fmin
141 write(cfile(1:128),'(4a,i4.4)')
142 & ctrlname(1:9),'_',yctrlid(1:10),'.opt', optimcycle
143 else
144 c >>> Write gradient vector <<<
145 print *, 'ph-pack in cost '
146 lxxadxx = .FALSE.
147 ictrlgrad = 2
148 fcloc = fc
149 write(cfile(1:128),'(4a,i4.4)')
150 & costname(1:9),'_',yctrlid(1:10),'.opt', optimcycle
151 endif
152
153 print *, 'ph-pack vor open ', optimcycle, cfile
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) fcloc
166 write(cunit) 1
167 write(cunit) 1
168 write(cunit) 1
169 write(cunit) 1
170 write(cunit) (nWetcGlobal(k), k=1,nr)
171 write(cunit) (nWetsGlobal(k), k=1,nr)
172 write(cunit) (nWetwGlobal(k), k=1,nr)
173 #ifdef ALLOW_CTRL_WETV
174 write(cunit) (nWetvGlobal(k), k=1,nr)
175 #endif
176
177 #ifdef ALLOW_OBCSN_CONTROL
178 write(cunit) ((nWetobcsnGlo(k,iobcs), k=1,nr),iobcs= 1,nobcs)
179 #endif
180 #ifdef ALLOW_OBCSS_CONTROL
181 write(cunit) ((nWetobcssGlo(k,iobcs), k=1,nr),iobcs= 1,nobcs)
182 #endif
183 #ifdef ALLOW_OBCSW_CONTROL
184 write(cunit) ((nWetobcswGlo(k,iobcs), k=1,nr),iobcs= 1,nobcs)
185 #endif
186 #ifdef ALLOW_OBCSE_CONTROL
187 write(cunit) ((nWetobcseGlo(k,iobcs), k=1,nr),iobcs= 1,nobcs)
188 #endif
189 write(cunit) (ncvarindex(i), i=1,maxcvars)
190 write(cunit) (ncvarrecs(i), i=1,maxcvars)
191 write(cunit) (nx, i=1,maxcvars)
192 write(cunit) (ny, i=1,maxcvars)
193 write(cunit) (ncvarnrmax(i), i=1,maxcvars)
194 write(cunit) (ncvargrd(i), i=1,maxcvars)
195 write(cunit)
196
197 #ifdef ALLOW_THETA0_CONTROL
198 ivartype = 1
199 write(weighttype(1:80),'(80a)') ' '
200 write(weighttype(1:80),'(a)') "wtheta"
201 call ctrl_set_pack_xyz(
202 & cunit, ivartype, fname_theta(ictrlgrad), "hFacC",
203 & weighttype, wtheta, lxxadxx, mythid)
204 #endif
205
206 #ifdef ALLOW_SALT0_CONTROL
207 ivartype = 2
208 write(weighttype(1:80),'(80a)') ' '
209 write(weighttype(1:80),'(a)') "wsalt"
210 call ctrl_set_pack_xyz(
211 & cunit, ivartype, fname_salt(ictrlgrad), "hFacC",
212 & weighttype, wsalt, lxxadxx, mythid)
213 #endif
214
215 #if (defined (ALLOW_HFLUX_CONTROL) || \
216 defined (ALLOW_HFLUX0_CONTROL))
217 ivartype = 3
218 write(weighttype(1:80),'(80a)') ' '
219 write(weighttype(1:80),'(a)') "whflux"
220 call ctrl_set_pack_xy(
221 & cunit, ivartype, fname_hflux(ictrlgrad), "hFacC",
222 & weighttype, lxxadxx, mythid)
223 #endif
224
225 #if (defined (ALLOW_SFLUX_CONTROL) || \
226 defined (ALLOW_SFLUX0_CONTROL))
227 ivartype = 4
228 write(weighttype(1:80),'(80a)') ' '
229 write(weighttype(1:80),'(a)') "wsflux"
230 call ctrl_set_pack_xy(
231 & cunit, ivartype, fname_sflux(ictrlgrad), "hFacC",
232 & weighttype, lxxadxx, mythid)
233 #endif
234
235 #if (defined (ALLOW_USTRESS_CONTROL) || \
236 defined (ALLOW_TAUU0_CONTROL))
237 ivartype = 5
238 write(weighttype(1:80),'(80a)') ' '
239 write(weighttype(1:80),'(a)') "wtauu"
240 call ctrl_set_pack_xy(
241 & cunit, ivartype, fname_tauu(ictrlgrad), "maskW",
242 & weighttype, lxxadxx, mythid)
243 #endif
244
245 #if (defined (ALLOW_VSTRESS_CONTROL) || \
246 defined (ALLOW_TAUV0_CONTROL))
247 ivartype = 6
248 write(weighttype(1:80),'(80a)') ' '
249 write(weighttype(1:80),'(a)') "wtauv"
250 call ctrl_set_pack_xy(
251 & cunit, ivartype, fname_tauv(ictrlgrad), "maskS",
252 & weighttype, lxxadxx, mythid)
253 #endif
254
255 #ifdef ALLOW_ATEMP_CONTROL
256 ivartype = 7
257 write(weighttype(1:80),'(80a)') ' '
258 write(weighttype(1:80),'(a)') "watemp"
259 call ctrl_set_pack_xy(
260 & cunit, ivartype, fname_atemp(ictrlgrad), "hFacC",
261 & weighttype, lxxadxx, mythid)
262 #endif
263
264 #ifdef ALLOW_AQH_CONTROL
265 ivartype = 8
266 write(weighttype(1:80),'(80a)') ' '
267 write(weighttype(1:80),'(a)') "waqh"
268 call ctrl_set_pack_xy(
269 & cunit, ivartype, fname_aqh(ictrlgrad), "hFacC",
270 & weighttype, lxxadxx, mythid)
271 #endif
272
273 #ifdef ALLOW_UWIND_CONTROL
274 ivartype = 9
275 write(weighttype(1:80),'(80a)') ' '
276 write(weighttype(1:80),'(a)') "wuwind"
277 call ctrl_set_pack_xy(
278 & cunit, ivartype, fname_uwind(ictrlgrad), "maskW",
279 & weighttype, lxxadxx, mythid)
280 #endif
281
282 #ifdef ALLOW_VWIND_CONTROL
283 ivartype = 10
284 write(weighttype(1:80),'(80a)') ' '
285 write(weighttype(1:80),'(a)') "wvwind"
286 call ctrl_set_pack_xy(
287 & cunit, ivartype, fname_vwind(ictrlgrad), "maskS",
288 & weighttype, lxxadxx, mythid)
289 #endif
290
291 #ifdef ALLOW_OBCSN_CONTROL
292 ivartype = 11
293 write(weighttype(1:80),'(80a)') ' '
294 write(weighttype(1:80),'(a)') "wobcsn"
295 call ctrl_set_pack_xz(
296 & cunit, ivartype, fname_obcsn(ictrlgrad), "maskobcsn",
297 & weighttype, wobcsn, lxxadxx, mythid)
298 #endif
299
300 #ifdef ALLOW_OBCSS_CONTROL
301 ivartype = 12
302 write(weighttype(1:80),'(80a)') ' '
303 write(weighttype(1:80),'(a)') "wobcss"
304 call ctrl_set_pack_xz(
305 & cunit, ivartype, fname_obcss(ictrlgrad), "maskobcss",
306 & weighttype, wobcss, lxxadxx, mythid)
307 #endif
308
309 #ifdef ALLOW_OBCSW_CONTROL
310 ivartype = 13
311 write(weighttype(1:80),'(80a)') ' '
312 write(weighttype(1:80),'(a)') "wobcsw"
313 call ctrl_set_pack_yz(
314 & cunit, ivartype, fname_obcsw(ictrlgrad), "maskobcsw",
315 & weighttype, wobcsw, lxxadxx, mythid)
316 #endif
317
318 #ifdef ALLOW_OBCSE_CONTROL
319 ivartype = 14
320 write(weighttype(1:80),'(80a)') ' '
321 write(weighttype(1:80),'(a)') "wobcse"
322 call ctrl_set_pack_yz(
323 & cunit, ivartype, fname_obcse(ictrlgrad), "maskobcse",
324 & weighttype, wobcse, lxxadxx, mythid)
325 #endif
326
327 #ifdef ALLOW_DIFFKR_CONTROL
328 ivartype = 15
329 write(weighttype(1:80),'(80a)') ' '
330 write(weighttype(1:80),'(a)') "wdiffkr"
331 call ctrl_set_pack_xyz(
332 & cunit, ivartype, fname_diffkr(ictrlgrad), "hFacC",
333 & weighttype, wunit, lxxadxx, mythid)
334 #endif
335
336 #ifdef ALLOW_KAPGM_CONTROL
337 ivartype = 16
338 write(weighttype(1:80),'(80a)') ' '
339 write(weighttype(1:80),'(a)') "wkapgm"
340 call ctrl_set_pack_xyz(
341 & cunit, ivartype, fname_kapgm(ictrlgrad), "hFacC",
342 & weighttype, wunit, lxxadxx, mythid)
343 #endif
344
345 #ifdef ALLOW_TR10_CONTROL
346 ivartype = 17
347 write(weighttype(1:80),'(80a)') ' '
348 write(weighttype(1:80),'(a)') "wtr1"
349 call ctrl_set_pack_xyz(
350 & cunit, ivartype, fname_tr1(ictrlgrad), "hFacC",
351 & weighttype, wunit, lxxadxx, mythid)
352 #endif
353
354 #ifdef ALLOW_SST0_CONTROL
355 ivartype = 18
356 write(weighttype(1:80),'(80a)') ' '
357 write(weighttype(1:80),'(a)') "wsst0"
358 call ctrl_set_pack_xy(
359 & cunit, ivartype, fname_sst(ictrlgrad), "hFacC",
360 & weighttype, lxxadxx, mythid)
361 #endif
362
363 #ifdef ALLOW_SSS0_CONTROL
364 ivartype = 19
365 write(weighttype(1:80),'(80a)') ' '
366 write(weighttype(1:80),'(a)') "wsss0"
367 call ctrl_set_pack_xy(
368 & cunit, ivartype, fname_sss(ictrlgrad), "hFacC",
369 & weighttype, lxxadxx, mythid)
370 #endif
371
372 #ifdef ALLOW_HFACC_CONTROL
373 ivartype = 20
374 write(weighttype(1:80),'(80a)') ' '
375 write(weighttype(1:80),'(a)') "whfacc"
376 # ifdef ALLOW_HFACC3D_CONTROL
377 call ctrl_set_pack_xyz(
378 & cunit, ivartype, fname_hfacc(ictrlgrad), "hFacC",
379 & weighttype, wunit, lxxadxx, mythid)
380 # else
381 call ctrl_set_pack_xy(
382 & cunit, ivartype, fname_hfacc(ictrlgrad), "hFacC",
383 & weighttype, lxxadxx, mythid)
384 # endif
385 #endif
386
387 #ifdef ALLOW_EFLUXY0_CONTROL
388 ivartype = 21
389 write(weighttype(1:80),'(80a)') ' '
390 write(weighttype(1:80),'(a)') "wefluxy0"
391 call ctrl_set_pack_xyz(
392 & cunit, ivartype, fname_efluxy(ictrlgrad), "hFacS",
393 & weighttype, wunit, lxxadxx, mythid)
394 #endif
395
396 #ifdef ALLOW_EFLUXP0_CONTROL
397 ivartype = 22
398 write(weighttype(1:80),'(80a)') ' '
399 write(weighttype(1:80),'(a)') "wefluxp0"
400 call ctrl_set_pack_xyz(
401 & cunit, ivartype, fname_efluxp(ictrlgrad), "hFacV",
402 & weighttype, wunit, lxxadxx, mythid)
403 #endif
404
405 #ifdef ALLOW_BOTTOMDRAG_CONTROL
406 ivartype = 23
407 write(weighttype(1:80),'(80a)') ' '
408 write(weighttype(1:80),'(a)') "wbottomdrag"
409 call ctrl_set_pack_xy(
410 & cunit, ivartype, fname_bottomdrag(ictrlgrad), "hFacC",
411 & weighttype, lxxadxx, mythid)
412 #endif
413
414 close ( cunit )
415
416 _END_MASTER( mythid )
417
418 #endif /* EXCLUDE_CTRL_PACK */
419
420 return
421 end
422

  ViewVC Help
Powered by ViewVC 1.1.22