/[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.7 - (hide annotations) (download)
Fri Mar 7 02:45:48 2003 UTC (21 years, 3 months ago) by heimbach
Branch: MAIN
CVS Tags: checkpoint50c_post, c49_ctrl, checkpoint50c_pre, checkpoint50, checkpoint50d_post, checkpoint50b_pre, checkpoint50f_post, checkpoint50a_post, checkpoint50f_pre, checkpoint50g_post, checkpoint50h_post, checkpoint50e_pre, checkpoint50i_post, checkpoint50e_post, checkpoint50d_pre, checkpoint50b_post
Changes since 1.6: +2 -0 lines
merging.

1 heimbach 1.1
2     #include "CTRL_CPPOPTIONS.h"
3    
4 heimbach 1.4 CBOP
5     C !ROUTINE: ctrl_pack
6     C !INTERFACE:
7     subroutine ctrl_pack( myiter, mytime, mythid )
8    
9     C !DESCRIPTION: \bv
10     c *=================================================================
11     c | SUBROUTINE ctrl_pack
12     c | Pack the control vector
13     c | * All control variable and adjoint variable fields are
14     c | read from disk.
15     c | * Wet points are extracted, and elements are
16     c | normalized (optional)
17     c | * A single control vector containing only (normalized
18     c | wet points is written to file.
19     c *=================================================================
20     C \ev
21 heimbach 1.1
22 heimbach 1.4 C !USES:
23 heimbach 1.1 implicit none
24    
25     c == global variables ==
26 heimbach 1.5
27 heimbach 1.1 #include "EEPARAMS.h"
28     #include "SIZE.h"
29     #include "PARAMS.h"
30     #include "GRID.h"
31 heimbach 1.5
32     #include "ecco.h"
33 heimbach 1.1 #include "ctrl.h"
34     #include "cost.h"
35 heimbach 1.5
36     #ifdef ALLOW_ECCO_OPTIMIZATION
37 heimbach 1.2 #include "optim.h"
38 heimbach 1.5 #endif
39 heimbach 1.1
40     c == routine arguments ==
41 heimbach 1.5
42 heimbach 1.1 integer myiter
43     _RL mytime
44     integer mythid
45    
46     c == local variables ==
47    
48 heimbach 1.5 #ifndef ALLOW_ECCO_OPTIMIZATION
49     integer optimcycle
50     #endif
51    
52     integer i, j, k
53 heimbach 1.1 integer ii
54     integer il
55     integer irec
56 heimbach 1.5 integer ig,jg
57     integer ivartype
58     integer iobcs
59 heimbach 1.1
60     logical doglobalread
61     logical ladinit
62 heimbach 1.5 integer cbuffindex
63 heimbach 1.1
64 heimbach 1.5 integer cunit
65 heimbach 1.1 _RL tmpvar
66    
67     character*(128) cfile
68 heimbach 1.5 character*( 80) weighttype
69    
70     character*( 80) fname_theta
71     character*( 80) fname_salt
72     character*( 80) fname_hflux
73     character*( 80) fname_sflux
74     character*( 80) fname_tauu
75     character*( 80) fname_tauv
76     character*( 80) adfname_theta
77     character*( 80) adfname_salt
78     character*( 80) adfname_hflux
79     character*( 80) adfname_sflux
80     character*( 80) adfname_tauu
81     character*( 80) adfname_tauv
82     character*( 80) fname_atemp
83     character*( 80) adfname_atemp
84     character*( 80) fname_aqh
85     character*( 80) adfname_aqh
86     character*( 80) fname_uwind
87     character*( 80) adfname_uwind
88     character*( 80) fname_vwind
89     character*( 80) adfname_vwind
90     character*( 80) fname_obcsn
91     character*( 80) adfname_obcsn
92     character*( 80) fname_obcss
93     character*( 80) adfname_obcss
94     character*( 80) fname_obcsw
95     character*( 80) adfname_obcsw
96     character*( 80) fname_obcse
97     character*( 80) adfname_obcse
98     character*( 80) fname_diffkr
99     character*( 80) adfname_diffkr
100     character*( 80) fname_kapgm
101     character*( 80) adfname_kapgm
102     character*( 80) fname_tr1
103     character*( 80) adfname_tr1
104 heimbach 1.6 character*( 80) fname_sst
105     character*( 80) adfname_sst
106     character*( 80) fname_sss
107     character*( 80) adfname_sss
108     character*( 80) fname_hfacc
109     character*( 80) adfname_hfacc
110 heimbach 1.5 character*( 80) fname_efluxy
111     character*( 80) adfname_efluxy
112     character*( 80) fname_efluxp
113     character*( 80) adfname_efluxp
114 heimbach 1.6 character*( 80) fname_bottomdrag
115     character*( 80) adfname_bottomdrag
116 heimbach 1.5
117     logical lxxadxx
118 heimbach 1.1
119     c == external ==
120 heimbach 1.5
121 heimbach 1.1 integer ilnblnk
122     external ilnblnk
123    
124     c == end of interface ==
125    
126 heimbach 1.5 #ifndef ALLOW_ECCO_OPTIMIZATION
127     optimcycle = 0
128     #endif
129 heimbach 1.1
130 heimbach 1.5 tmpvar = -9999. _d 0
131 heimbach 1.1
132     c-- Tiled files are used.
133     doglobalread = .false.
134    
135     c-- Initialise adjoint variables on active files.
136     ladinit = .false.
137    
138 heimbach 1.5 c-- Assign file names.
139    
140     call ctrl_set_fname(
141     I xx_theta_file, fname_theta, adfname_theta, mythid )
142     call ctrl_set_fname(
143     I xx_salt_file, fname_salt, adfname_salt, mythid )
144     call ctrl_set_fname(
145     I xx_hflux_file, fname_hflux, adfname_hflux, mythid )
146     call ctrl_set_fname(
147     I xx_sflux_file, fname_sflux, adfname_sflux, mythid )
148     call ctrl_set_fname(
149     I xx_tauu_file, fname_tauu, adfname_tauu, mythid )
150     call ctrl_set_fname(
151     I xx_tauv_file, fname_tauv, adfname_tauv, mythid )
152     call ctrl_set_fname(
153     I xx_atemp_file, fname_atemp, adfname_atemp, mythid )
154     call ctrl_set_fname(
155     I xx_aqh_file, fname_aqh, adfname_aqh, mythid )
156     call ctrl_set_fname(
157     I xx_uwind_file, fname_uwind, adfname_uwind, mythid )
158     call ctrl_set_fname(
159     I xx_vwind_file, fname_vwind, adfname_vwind, mythid )
160     call ctrl_set_fname(
161     I xx_obcsn_file, fname_obcsn, adfname_obcsn, mythid )
162     call ctrl_set_fname(
163     I xx_obcss_file, fname_obcss, adfname_obcss, mythid )
164     call ctrl_set_fname(
165     I xx_obcsw_file, fname_obcsw, adfname_obcsw, mythid )
166     call ctrl_set_fname(
167     I xx_obcse_file, fname_obcse, adfname_obcse, mythid )
168     call ctrl_set_fname(
169     I xx_diffkr_file, fname_diffkr, adfname_diffkr, mythid )
170     call ctrl_set_fname(
171     I xx_kapgm_file, fname_kapgm, adfname_kapgm, mythid )
172     call ctrl_set_fname(
173     I xx_tr1_file, fname_tr1, adfname_tr1, mythid )
174     call ctrl_set_fname(
175 heimbach 1.6 I xx_sst_file, fname_sst, adfname_sst, mythid )
176     call ctrl_set_fname(
177     I xx_sss_file, fname_sss, adfname_sss, mythid )
178     call ctrl_set_fname(
179     I xx_hfacc_file, fname_hfacc, adfname_hfacc, mythid )
180     call ctrl_set_fname(
181 heimbach 1.5 I xx_efluxy_file, fname_efluxy, adfname_efluxy, mythid )
182     call ctrl_set_fname(
183     I xx_efluxp_file, fname_efluxp, adfname_efluxp, mythid )
184 heimbach 1.6 call ctrl_set_fname(
185     I xx_bottomdrag_file, fname_bottomdrag, adfname_bottomdrag
186     I , mythid )
187 heimbach 1.5
188 heimbach 1.1 c
189 heimbach 1.5 c-- Only the master thread will do I/O.
190 heimbach 1.1 _BEGIN_MASTER( mythid )
191    
192     c >>> Write control vector <<<
193    
194 heimbach 1.5 cph this part was removed since it's not necessary
195     cph and causes huge amounts of wall clock time on parallel machines
196 heimbach 1.2
197    
198 heimbach 1.1
199     c >>> Write gradient vector <<<
200 heimbach 1.5 lxxadxx = .FALSE.
201 heimbach 1.1
202     call mdsfindunit( cunit, mythid )
203 heimbach 1.5 write(cfile(1:128),'(4a,i4.4)')
204     & costname(1:9),'_',yctrlid(1:10),'.opt',
205 heimbach 1.1 & optimcycle
206    
207     open( cunit, file = cfile,
208     & status = 'unknown',
209     & form = 'unformatted',
210     & access = 'sequential' )
211    
212     c-- Header information.
213     write(cunit) nvartype
214     write(cunit) nvarlength
215 heimbach 1.5 write(cunit) yctrlid
216 heimbach 1.1 write(cunit) optimCycle
217     write(cunit) fc
218     write(cunit) 1
219     write(cunit) 1
220     write(cunit) 1
221     write(cunit) 1
222 heimbach 1.5 write(cunit) (nWetcGlobal(k), k=1,nr)
223     write(cunit) (nWetsGlobal(k), k=1,nr)
224     write(cunit) (nWetwGlobal(k), k=1,nr)
225 heimbach 1.7 #ifdef ALLOW_CTRL_WETV
226 heimbach 1.5 write(cunit) (nWetvGlobal(k), k=1,nr)
227 heimbach 1.7 #endif
228 heimbach 1.5 #ifdef ALLOW_OBCSN_CONTROL
229     write(cunit) ((nWetobcsnGlo(k,iobcs), k=1,nr),iobcs= 1,nobcs)
230     #endif
231     #ifdef ALLOW_OBCSS_CONTROL
232     write(cunit) ((nWetobcssGlo(k,iobcs), k=1,nr),iobcs= 1,nobcs)
233     #endif
234     #ifdef ALLOW_OBCSW_CONTROL
235     write(cunit) ((nWetobcswGlo(k,iobcs), k=1,nr),iobcs= 1,nobcs)
236     #endif
237     #ifdef ALLOW_OBCSE_CONTROL
238     write(cunit) ((nWetobcseGlo(k,iobcs), k=1,nr),iobcs= 1,nobcs)
239     #endif
240 heimbach 1.1 write(cunit) (ncvarindex(i), i=1,maxcvars)
241     write(cunit) (ncvarrecs(i), i=1,maxcvars)
242     write(cunit) (nx, i=1,maxcvars)
243     write(cunit) (ny, i=1,maxcvars)
244     write(cunit) (ncvarnrmax(i), i=1,maxcvars)
245     write(cunit) (ncvargrd(i), i=1,maxcvars)
246     write(cunit)
247    
248     #ifdef ALLOW_THETA0_CONTROL
249 heimbach 1.5 ivartype = 1
250     call ctrl_set_pack_xyz(
251     & cunit, ivartype, adfname_theta, "hFacC",
252     & wtheta, lxxadxx, mythid)
253 heimbach 1.1 #endif
254    
255     #ifdef ALLOW_SALT0_CONTROL
256 heimbach 1.5 ivartype = 2
257     call ctrl_set_pack_xyz(
258     & cunit, ivartype, adfname_salt, "hFacC",
259     & wsalt, lxxadxx, mythid)
260     #endif
261    
262     #if (defined (ALLOW_HFLUX_CONTROL) || \
263     defined (ALLOW_HFLUX0_CONTROL))
264     ivartype = 3
265     write(weighttype(1:80),'(80a)') ' '
266     write(weighttype(1:80),'(a)') "whflux"
267     call ctrl_set_pack_xy(
268     & cunit, ivartype, adfname_hflux, "hFacC", weighttype,
269     & lxxadxx, mythid)
270     #endif
271    
272     #if (defined (ALLOW_SFLUX_CONTROL) || \
273     defined (ALLOW_SFLUX0_CONTROL))
274     ivartype = 4
275     write(weighttype(1:80),'(80a)') ' '
276     write(weighttype(1:80),'(a)') "wsflux"
277     call ctrl_set_pack_xy(
278     & cunit, ivartype, adfname_sflux, "hFacC", weighttype,
279     & lxxadxx, mythid)
280     #endif
281    
282     #if (defined (ALLOW_USTRESS_CONTROL) || \
283     defined (ALLOW_TAUU0_CONTROL))
284     ivartype = 5
285     write(weighttype(1:80),'(80a)') ' '
286     write(weighttype(1:80),'(a)') "wtauu"
287     call ctrl_set_pack_xy(
288     & cunit, ivartype, adfname_tauu, "maskW", weighttype,
289     & lxxadxx, mythid)
290     #endif
291    
292     #if (defined (ALLOW_VSTRESS_CONTROL) || \
293     defined (ALLOW_TAUV0_CONTROL))
294     ivartype = 6
295     write(weighttype(1:80),'(80a)') ' '
296     write(weighttype(1:80),'(a)') "wtauv"
297     call ctrl_set_pack_xy(
298     & cunit, ivartype, adfname_tauv, "maskS", weighttype,
299     & lxxadxx, mythid)
300     #endif
301    
302     #ifdef ALLOW_ATEMP_CONTROL
303     ivartype = 7
304     write(weighttype(1:80),'(80a)') ' '
305     write(weighttype(1:80),'(a)') "watemp"
306     call ctrl_set_pack_xy(
307     & cunit, ivartype, adfname_atemp, "hFacC", weighttype,
308     & lxxadxx, mythid)
309     #endif
310    
311     #ifdef ALLOW_AQH_CONTROL
312     ivartype = 8
313     write(weighttype(1:80),'(80a)') ' '
314     write(weighttype(1:80),'(a)') "waqh"
315     call ctrl_set_pack_xy(
316     & cunit, ivartype, adfname_aqh, "hFacC", weighttype,
317     & lxxadxx, mythid)
318     #endif
319    
320     #ifdef ALLOW_UWIND_CONTROL
321     ivartype = 9
322     write(weighttype(1:80),'(80a)') ' '
323     write(weighttype(1:80),'(a)') "wuwind"
324     call ctrl_set_pack_xy(
325     & cunit, ivartype, adfname_uwind, "maskW", weighttype,
326     & lxxadxx, mythid)
327     #endif
328    
329     #ifdef ALLOW_VWIND_CONTROL
330     ivartype = 10
331     write(weighttype(1:80),'(80a)') ' '
332     write(weighttype(1:80),'(a)') "wvwind"
333     call ctrl_set_pack_xy(
334     & cunit, ivartype, adfname_vwind, "maskS", weighttype,
335     & lxxadxx, mythid)
336     #endif
337    
338     #ifdef ALLOW_OBCSN_CONTROL
339     ivartype = 11
340     call ctrl_set_pack_xz(
341     & cunit, ivartype, adfname_obcsn, "maskobcsn",
342     & wobcsn, lxxadxx, mythid)
343     #endif
344    
345     #ifdef ALLOW_OBCSS_CONTROL
346     ivartype = 12
347     call ctrl_set_pack_xz(
348     & cunit, ivartype, adfname_obcss, "maskobcss",
349     & wobcss, lxxadxx, mythid)
350     #endif
351    
352     #ifdef ALLOW_OBCSW_CONTROL
353     ivartype = 13
354     call ctrl_set_pack_yz(
355     & cunit, ivartype, adfname_obcsw, "maskobcsw",
356     & wobcsw, lxxadxx, mythid)
357     #endif
358    
359     #ifdef ALLOW_OBCSE_CONTROL
360     ivartype = 14
361     call ctrl_set_pack_yz(
362     & cunit, ivartype, adfname_obcse, "maskobcse",
363     & wobcse, lxxadxx, mythid)
364 heimbach 1.1 #endif
365 heimbach 1.3
366     #ifdef ALLOW_DIFFKR_CONTROL
367 heimbach 1.5 ivartype = 15
368     call ctrl_set_pack_xyz(
369     & cunit, ivartype, adfname_diffkr, "hFacC",
370     & wunit, lxxadxx, mythid)
371 heimbach 1.3 #endif
372    
373     #ifdef ALLOW_KAPGM_CONTROL
374 heimbach 1.5 ivartype = 16
375     call ctrl_set_pack_xyz(
376     & cunit, ivartype, adfname_kapgm, "hFacC",
377     & wunit, lxxadxx, mythid)
378 heimbach 1.3 #endif
379    
380 heimbach 1.5 #ifdef ALLOW_TR10_CONTROL
381     ivartype = 17
382     call ctrl_set_pack_xyz(
383     & cunit, ivartype, adfname_tr1, "hFacC",
384     & wunit, lxxadxx, mythid)
385     #endif
386    
387 heimbach 1.6 #ifdef ALLOW_SST0_CONTROL
388     ivartype = 18
389     write(weighttype(1:80),'(80a)') ' '
390     write(weighttype(1:80),'(a)') "wsst0"
391     call ctrl_set_pack_xy(
392     & cunit, ivartype, adfname_sst0, "hFacC", weighttype,
393     & lxxadxx, mythid)
394     #endif
395    
396     #ifdef ALLOW_SSS0_CONTROL
397     ivartype = 19
398     write(weighttype(1:80),'(80a)') ' '
399     write(weighttype(1:80),'(a)') "wsss0"
400     call ctrl_set_pack_xy(
401     & cunit, ivartype, adfname_sss0, "hFacC", weighttype,
402     & lxxadxx, mythid)
403     #endif
404    
405     #ifdef ALLOW_HFACC_CONTROL
406     ivartype = 20
407     #ifdef ALLOW_HFACC3D_CONTROL
408     call ctrl_set_pack_xyz(
409     & cunit, ivartype, adfname_hfacc, "hFacC",
410     & wunit, lxxadxx, mythid)
411     #else
412     write(weighttype(1:80),'(80a)') ' '
413     write(weighttype(1:80),'(a)') "whfacc"
414     call ctrl_set_pack_xy(
415     & cunit, ivartype, adfname_hfacc, "hFacC", weighttype,
416     & lxxadxx, mythid)
417     #endif
418     #endif
419    
420 heimbach 1.5 #ifdef ALLOW_EFLUXY0_CONTROL
421     ivartype = 21
422     call ctrl_set_pack_xyz(
423     & cunit, ivartype, adfname_efluxy, "hFacS",
424 heimbach 1.6 & wunit, lxxadxx, mythid)
425 heimbach 1.5 #endif
426    
427     #ifdef ALLOW_EFLUXP0_CONTROL
428     ivartype = 22
429     call ctrl_set_pack_xyz(
430     & cunit, ivartype, adfname_efluxp, "hFacV",
431 heimbach 1.6 & wunit, lxxadxx, mythid)
432     #endif
433    
434     #ifdef ALLOW_BOTTOMDRAG_CONTROL
435     ivartype = 23
436     write(weighttype(1:80),'(80a)') ' '
437     write(weighttype(1:80),'(a)') "wbottomdrag"
438     call ctrl_set_pack_xy(
439     & cunit, ivartype, adfname_bottomdrag, "hFacC", weighttype,
440     & lxxadxx, mythid)
441 heimbach 1.5 #endif
442    
443     close ( cunit )
444 heimbach 1.1
445 heimbach 1.5 _END_MASTER( mythid )
446 heimbach 1.1
447     return
448     end
449    

  ViewVC Help
Powered by ViewVC 1.1.22