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

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

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


Revision 1.11 - (hide 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 edhill 1.10 C
2 heimbach 1.11 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 heimbach 1.1
5     #include "CTRL_CPPOPTIONS.h"
6    
7 heimbach 1.11 subroutine ctrl_pack( first, mythid )
8 heimbach 1.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 heimbach 1.11 c heimbach@mit.edu totally restrucured 28-Oct-2003
30     c
31 heimbach 1.8 c ==================================================================
32     c SUBROUTINE ctrl_pack
33     c ==================================================================
34    
35 heimbach 1.1 implicit none
36    
37     c == global variables ==
38 heimbach 1.5
39 heimbach 1.1 #include "EEPARAMS.h"
40     #include "SIZE.h"
41     #include "PARAMS.h"
42     #include "GRID.h"
43 heimbach 1.5
44     #include "ecco.h"
45 heimbach 1.1 #include "ctrl.h"
46     #include "cost.h"
47 heimbach 1.5
48     #ifdef ALLOW_ECCO_OPTIMIZATION
49 heimbach 1.2 #include "optim.h"
50 heimbach 1.5 #endif
51 heimbach 1.1
52     c == routine arguments ==
53 heimbach 1.5
54 heimbach 1.11 logical first
55 heimbach 1.1 integer mythid
56    
57 heimbach 1.11 #ifndef EXCLUDE_CTRL_PACK
58 heimbach 1.1 c == local variables ==
59    
60 heimbach 1.5 #ifndef ALLOW_ECCO_OPTIMIZATION
61     integer optimcycle
62 heimbach 1.11 _RL fmin
63 heimbach 1.5 #endif
64    
65 heimbach 1.11 _RL fcloc
66    
67 heimbach 1.5 integer i, j, k
68 heimbach 1.1 integer ii
69     integer il
70     integer irec
71 heimbach 1.5 integer ig,jg
72     integer ivartype
73     integer iobcs
74 heimbach 1.1
75     logical doglobalread
76     logical ladinit
77 heimbach 1.5 integer cbuffindex
78 heimbach 1.11 logical lxxadxx
79    
80 heimbach 1.5 integer cunit
81 heimbach 1.11 integer ictrlgrad
82 heimbach 1.1
83     character*(128) cfile
84 heimbach 1.5 character*( 80) weighttype
85    
86 heimbach 1.1 c == external ==
87 heimbach 1.5
88 heimbach 1.1 integer ilnblnk
89     external ilnblnk
90    
91     c == end of interface ==
92    
93 heimbach 1.5 #ifndef ALLOW_ECCO_OPTIMIZATION
94     optimcycle = 0
95 heimbach 1.11 fmin = 0. _d 0
96 heimbach 1.5 #endif
97 heimbach 1.1
98     c-- Tiled files are used.
99     doglobalread = .false.
100    
101     c-- Initialise adjoint variables on active files.
102     ladinit = .false.
103    
104 heimbach 1.5 c-- Assign file names.
105    
106 heimbach 1.11 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 heimbach 1.5
130 heimbach 1.1 c
131 heimbach 1.5 c-- Only the master thread will do I/O.
132 heimbach 1.1 _BEGIN_MASTER( mythid )
133    
134 heimbach 1.11 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 heimbach 1.1 c >>> Write gradient vector <<<
145 heimbach 1.11 print *, 'ph-pack in cost '
146     lxxadxx = .FALSE.
147     ictrlgrad = 2
148     fcloc = fc
149 heimbach 1.5 write(cfile(1:128),'(4a,i4.4)')
150 heimbach 1.11 & costname(1:9),'_',yctrlid(1:10),'.opt', optimcycle
151     endif
152 heimbach 1.1
153 heimbach 1.11 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 heimbach 1.1
160     c-- Header information.
161     write(cunit) nvartype
162     write(cunit) nvarlength
163 heimbach 1.5 write(cunit) yctrlid
164 heimbach 1.1 write(cunit) optimCycle
165 heimbach 1.11 write(cunit) fcloc
166 heimbach 1.1 write(cunit) 1
167     write(cunit) 1
168     write(cunit) 1
169     write(cunit) 1
170 heimbach 1.5 write(cunit) (nWetcGlobal(k), k=1,nr)
171     write(cunit) (nWetsGlobal(k), k=1,nr)
172     write(cunit) (nWetwGlobal(k), k=1,nr)
173 heimbach 1.7 #ifdef ALLOW_CTRL_WETV
174 heimbach 1.5 write(cunit) (nWetvGlobal(k), k=1,nr)
175 heimbach 1.7 #endif
176 heimbach 1.11
177 heimbach 1.5 #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 heimbach 1.1 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 heimbach 1.5 ivartype = 1
199 heimbach 1.8 write(weighttype(1:80),'(80a)') ' '
200     write(weighttype(1:80),'(a)') "wtheta"
201 heimbach 1.5 call ctrl_set_pack_xyz(
202 heimbach 1.11 & cunit, ivartype, fname_theta(ictrlgrad), "hFacC",
203 heimbach 1.8 & weighttype, wtheta, lxxadxx, mythid)
204 heimbach 1.1 #endif
205    
206     #ifdef ALLOW_SALT0_CONTROL
207 heimbach 1.5 ivartype = 2
208 heimbach 1.8 write(weighttype(1:80),'(80a)') ' '
209     write(weighttype(1:80),'(a)') "wsalt"
210 heimbach 1.5 call ctrl_set_pack_xyz(
211 heimbach 1.11 & cunit, ivartype, fname_salt(ictrlgrad), "hFacC",
212 heimbach 1.8 & weighttype, wsalt, lxxadxx, mythid)
213 heimbach 1.5 #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 heimbach 1.11 & cunit, ivartype, fname_hflux(ictrlgrad), "hFacC",
222     & weighttype, lxxadxx, mythid)
223 heimbach 1.5 #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 heimbach 1.11 & cunit, ivartype, fname_sflux(ictrlgrad), "hFacC",
232     & weighttype, lxxadxx, mythid)
233 heimbach 1.5 #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 heimbach 1.11 & cunit, ivartype, fname_tauu(ictrlgrad), "maskW",
242     & weighttype, lxxadxx, mythid)
243 heimbach 1.5 #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 heimbach 1.11 & cunit, ivartype, fname_tauv(ictrlgrad), "maskS",
252     & weighttype, lxxadxx, mythid)
253 heimbach 1.5 #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 heimbach 1.11 & cunit, ivartype, fname_atemp(ictrlgrad), "hFacC",
261     & weighttype, lxxadxx, mythid)
262 heimbach 1.5 #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 heimbach 1.11 & cunit, ivartype, fname_aqh(ictrlgrad), "hFacC",
270     & weighttype, lxxadxx, mythid)
271 heimbach 1.5 #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 heimbach 1.11 & cunit, ivartype, fname_uwind(ictrlgrad), "maskW",
279     & weighttype, lxxadxx, mythid)
280 heimbach 1.5 #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 heimbach 1.11 & cunit, ivartype, fname_vwind(ictrlgrad), "maskS",
288     & weighttype, lxxadxx, mythid)
289 heimbach 1.5 #endif
290    
291     #ifdef ALLOW_OBCSN_CONTROL
292     ivartype = 11
293 heimbach 1.8 write(weighttype(1:80),'(80a)') ' '
294     write(weighttype(1:80),'(a)') "wobcsn"
295 heimbach 1.5 call ctrl_set_pack_xz(
296 heimbach 1.11 & cunit, ivartype, fname_obcsn(ictrlgrad), "maskobcsn",
297 heimbach 1.8 & weighttype, wobcsn, lxxadxx, mythid)
298 heimbach 1.5 #endif
299    
300     #ifdef ALLOW_OBCSS_CONTROL
301     ivartype = 12
302 heimbach 1.8 write(weighttype(1:80),'(80a)') ' '
303     write(weighttype(1:80),'(a)') "wobcss"
304 heimbach 1.5 call ctrl_set_pack_xz(
305 heimbach 1.11 & cunit, ivartype, fname_obcss(ictrlgrad), "maskobcss",
306 heimbach 1.8 & weighttype, wobcss, lxxadxx, mythid)
307 heimbach 1.5 #endif
308    
309     #ifdef ALLOW_OBCSW_CONTROL
310     ivartype = 13
311 heimbach 1.8 write(weighttype(1:80),'(80a)') ' '
312     write(weighttype(1:80),'(a)') "wobcsw"
313 heimbach 1.5 call ctrl_set_pack_yz(
314 heimbach 1.11 & cunit, ivartype, fname_obcsw(ictrlgrad), "maskobcsw",
315 heimbach 1.8 & weighttype, wobcsw, lxxadxx, mythid)
316 heimbach 1.5 #endif
317    
318     #ifdef ALLOW_OBCSE_CONTROL
319     ivartype = 14
320 heimbach 1.8 write(weighttype(1:80),'(80a)') ' '
321     write(weighttype(1:80),'(a)') "wobcse"
322 heimbach 1.5 call ctrl_set_pack_yz(
323 heimbach 1.11 & cunit, ivartype, fname_obcse(ictrlgrad), "maskobcse",
324 heimbach 1.8 & weighttype, wobcse, lxxadxx, mythid)
325 heimbach 1.1 #endif
326 heimbach 1.3
327     #ifdef ALLOW_DIFFKR_CONTROL
328 heimbach 1.5 ivartype = 15
329 heimbach 1.8 write(weighttype(1:80),'(80a)') ' '
330     write(weighttype(1:80),'(a)') "wdiffkr"
331 heimbach 1.5 call ctrl_set_pack_xyz(
332 heimbach 1.11 & cunit, ivartype, fname_diffkr(ictrlgrad), "hFacC",
333 heimbach 1.8 & weighttype, wunit, lxxadxx, mythid)
334 heimbach 1.3 #endif
335    
336     #ifdef ALLOW_KAPGM_CONTROL
337 heimbach 1.5 ivartype = 16
338 heimbach 1.8 write(weighttype(1:80),'(80a)') ' '
339     write(weighttype(1:80),'(a)') "wkapgm"
340 heimbach 1.5 call ctrl_set_pack_xyz(
341 heimbach 1.11 & cunit, ivartype, fname_kapgm(ictrlgrad), "hFacC",
342 heimbach 1.8 & weighttype, wunit, lxxadxx, mythid)
343 heimbach 1.3 #endif
344    
345 heimbach 1.5 #ifdef ALLOW_TR10_CONTROL
346     ivartype = 17
347 heimbach 1.8 write(weighttype(1:80),'(80a)') ' '
348     write(weighttype(1:80),'(a)') "wtr1"
349 heimbach 1.5 call ctrl_set_pack_xyz(
350 heimbach 1.11 & cunit, ivartype, fname_tr1(ictrlgrad), "hFacC",
351 heimbach 1.8 & weighttype, wunit, lxxadxx, mythid)
352 heimbach 1.5 #endif
353    
354 heimbach 1.6 #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 heimbach 1.11 & cunit, ivartype, fname_sst(ictrlgrad), "hFacC",
360     & weighttype, lxxadxx, mythid)
361 heimbach 1.6 #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 heimbach 1.11 & cunit, ivartype, fname_sss(ictrlgrad), "hFacC",
369     & weighttype, lxxadxx, mythid)
370 heimbach 1.6 #endif
371    
372     #ifdef ALLOW_HFACC_CONTROL
373     ivartype = 20
374 heimbach 1.8 write(weighttype(1:80),'(80a)') ' '
375     write(weighttype(1:80),'(a)') "whfacc"
376     # ifdef ALLOW_HFACC3D_CONTROL
377 heimbach 1.6 call ctrl_set_pack_xyz(
378 heimbach 1.11 & cunit, ivartype, fname_hfacc(ictrlgrad), "hFacC",
379 heimbach 1.8 & weighttype, wunit, lxxadxx, mythid)
380     # else
381 heimbach 1.6 call ctrl_set_pack_xy(
382 heimbach 1.11 & cunit, ivartype, fname_hfacc(ictrlgrad), "hFacC",
383     & weighttype, lxxadxx, mythid)
384 heimbach 1.8 # endif
385 heimbach 1.6 #endif
386    
387 heimbach 1.5 #ifdef ALLOW_EFLUXY0_CONTROL
388     ivartype = 21
389 heimbach 1.8 write(weighttype(1:80),'(80a)') ' '
390     write(weighttype(1:80),'(a)') "wefluxy0"
391 heimbach 1.5 call ctrl_set_pack_xyz(
392 heimbach 1.11 & cunit, ivartype, fname_efluxy(ictrlgrad), "hFacS",
393 heimbach 1.8 & weighttype, wunit, lxxadxx, mythid)
394 heimbach 1.5 #endif
395    
396     #ifdef ALLOW_EFLUXP0_CONTROL
397     ivartype = 22
398 heimbach 1.8 write(weighttype(1:80),'(80a)') ' '
399     write(weighttype(1:80),'(a)') "wefluxp0"
400 heimbach 1.5 call ctrl_set_pack_xyz(
401 heimbach 1.11 & cunit, ivartype, fname_efluxp(ictrlgrad), "hFacV",
402 heimbach 1.8 & weighttype, wunit, lxxadxx, mythid)
403 heimbach 1.6 #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 heimbach 1.11 & cunit, ivartype, fname_bottomdrag(ictrlgrad), "hFacC",
411     & weighttype, lxxadxx, mythid)
412 heimbach 1.5 #endif
413    
414     close ( cunit )
415 heimbach 1.1
416 heimbach 1.5 _END_MASTER( mythid )
417 heimbach 1.11
418     #endif /* EXCLUDE_CTRL_PACK */
419 heimbach 1.1
420     return
421     end
422    

  ViewVC Help
Powered by ViewVC 1.1.22