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

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

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


Revision 1.7 - (show annotations) (download)
Fri Nov 29 13:38:37 2002 UTC (21 years, 6 months ago) by heimbach
Branch: MAIN
CVS Tags: checkpoint47e_post, checkpoint47c_post, checkpoint48e_post, checkpoint48i_post, checkpoint48b_post, checkpoint48c_pre, checkpoint47d_pre, checkpoint48d_pre, checkpoint47i_post, checkpoint47d_post, checkpoint48d_post, checkpoint48f_post, checkpoint48h_post, checkpoint47g_post, checkpoint48a_post, checkpoint47j_post, branch-exfmods-tag, checkpoint48c_post, checkpoint47b_post, checkpoint47f_post, checkpoint48, checkpoint49, checkpoint48g_post, checkpoint47h_post
Branch point for: branch-exfmods-curt
Changes since 1.6: +159 -4 lines
Controls of sst, sss, hfacc, bottomdrag.
(no ice climbing).

1
2 #include "CTRL_CPPOPTIONS.h"
3
4 CBOI
5 C
6 C !TITLE: CONTROL VECTOR
7 C !AUTHORS: mitgcm developers ( support@mitgcm.org )
8 C !AFFILIATION: Massachussetts Institute of Technology
9 C !DATE:
10 C !INTRODUCTION: control vector handling
11 C \bv
12 c The control vector package is connected to the differntiability
13 c of the code. Differentiability refers to computing the derivative
14 c of a cost function with respect to a set of control variables
15 c (initial state, boundary values, model parameters).
16 c To reduce memory, the control variables are kept on file and
17 c are only read/written, when needed.
18 c To achieve this, adjoint support routines are available which
19 c handle I/O of active variables.
20 c In addition, a single control vector is created, which contains
21 c all wet points of all control variables.
22 c
23 C !CALLING SEQUENCE:
24 c ...
25 c |-- the_model_main
26 c |
27 c |-- initialise_fixed
28 c | |
29 c | |-- packages_readparms
30 c | |
31 c | |-- ctrl_init - initialise control
32 c | package
33 c |-- ctrl_unpack - unpack control vector
34 c |
35 c |-- adthe_main_loop - forward/adjoint run
36 c | |
37 c | |-- initialise_variables
38 c | | |
39 c | | |-- packages_init_variables
40 c | | |
41 c | | |-- ctrl_map_ini - link init. state to
42 c | | control variables
43 c | |-- ctrl_map_forcing - link forcing fields to
44 c | ... control variables
45 c |
46 c |-- ctrl_pack - pack control vector
47 C \ev
48 CEOI
49
50 CBOP
51 C !ROUTINE: ctrl_unpack
52 C !INTERFACE:
53 subroutine ctrl_unpack( myiter, mytime, mythid )
54
55 C !DESCRIPTION: \bv
56 c *=================================================================
57 c | SUBROUTINE ctrl_unpack
58 c | Unpack the control vector
59 c | * If in sensitivity study mode,
60 c | control variable and adjoint variable arrays and files
61 c | are initialised.
62 c | * If in optimization mode,
63 c | wet points of updated control variables (i.e. anomalies
64 c | to corresponding fields) from previous optimization
65 c | iteration are extracted from single control vector,
66 c | mapped onto full (2D or 3D) fields and distributed
67 c | to control variable files.
68 c *=================================================================
69 C \ev
70
71 C !USES:
72 implicit none
73
74 c == global variables ==
75
76 #include "EEPARAMS.h"
77 #include "SIZE.h"
78 #include "PARAMS.h"
79 #include "GRID.h"
80
81 #include "ecco.h"
82 #include "ctrl.h"
83 #include "cost.h"
84
85 #ifdef ALLOW_ECCO_OPTIMIZATION
86 #include "optim.h"
87 #endif
88
89 c == routine arguments ==
90
91 integer myiter
92 _RL mytime
93 integer mythid
94
95 c == local variables ==
96
97 #ifndef ALLOW_ECCO_OPTIMIZATION
98 integer optimcycle
99 #endif
100
101 integer i, j, k
102 integer ii
103 integer il
104 integer irec
105 integer ig,jg
106 integer ivartype
107
108 integer cbuffindex
109 integer cunit
110
111 character*(128) cfile
112 character*( 80) weighttype
113
114 logical first
115
116 integer filenvartype
117 integer filenvarlength
118 character*(10) fileYctrlid
119 integer fileOptimCycle
120 integer filencbuffindex
121 _RL fileDummy
122 integer fileIg
123 integer fileJg
124 integer fileI
125 integer fileJ
126 integer filensx
127 integer filensy
128 integer filek
129 integer filenWetcGlobal(nr)
130 integer filenWetsGlobal(nr)
131 integer filenWetwGlobal(nr)
132 integer filenWetvGlobal(nr)
133 integer filencvarindex(maxcvars)
134 integer filencvarrecs(maxcvars)
135 integer filencvarxmax(maxcvars)
136 integer filencvarymax(maxcvars)
137 integer filencvarnrmax(maxcvars)
138 cgg( Add OBCS mask names.
139 #ifdef ALLOW_OBCSN_CONTROL
140 integer filenWetobcsnGlo(nr,nobcs)
141 #endif
142 #ifdef ALLOW_OBCSS_CONTROL
143 integer filenWetobcssGlo(nr,nobcs)
144 #endif
145 #ifdef ALLOW_OBCSW_CONTROL
146 integer filenWetobcswGlo(nr,nobcs)
147 #endif
148 #ifdef ALLOW_OBCSE_CONTROL
149 integer filenWetobcseGlo(nr,nobcs)
150 #endif
151 integer iobcs
152 cgg)
153 character*( 1) filencvargrd(maxcvars)
154 character*( 80) fname_theta
155 character*( 80) adfname_theta
156 character*( 80) fname_salt
157 character*( 80) adfname_salt
158 character*( 80) fname_hflux
159 character*( 80) adfname_hflux
160 character*( 80) fname_sflux
161 character*( 80) adfname_sflux
162 character*( 80) fname_tauu
163 character*( 80) adfname_tauu
164 character*( 80) fname_tauv
165 character*( 80) adfname_tauv
166 character*( 80) fname_atemp
167 character*( 80) adfname_atemp
168 character*( 80) fname_aqh
169 character*( 80) adfname_aqh
170 character*( 80) fname_uwind
171 character*( 80) adfname_uwind
172 character*( 80) fname_vwind
173 character*( 80) adfname_vwind
174 character*( 80) fname_obcsn
175 character*( 80) adfname_obcsn
176 character*( 80) fname_obcss
177 character*( 80) adfname_obcss
178 character*( 80) fname_obcsw
179 character*( 80) adfname_obcsw
180 character*( 80) fname_obcse
181 character*( 80) adfname_obcse
182 character*( 80) fname_diffkr
183 character*( 80) adfname_diffkr
184 character*( 80) fname_kapgm
185 character*( 80) adfname_kapgm
186 character*( 80) fname_tr1
187 character*( 80) adfname_tr1
188 character*( 80) fname_sst
189 character*( 80) adfname_sst
190 character*( 80) fname_sss
191 character*( 80) adfname_sss
192 character*( 80) fname_hfacc
193 character*( 80) adfname_hfacc
194 character*( 80) fname_efluxy
195 character*( 80) adfname_efluxy
196 character*( 80) fname_efluxp
197 character*( 80) adfname_efluxp
198 character*( 80) fname_bottomdrag
199 character*( 80) adfname_bottomdrag
200
201 cgg( Initialization of ecco_ctrl requires two new local var.
202 _RL tmpvar
203 logical lxxadxx
204 cgg)
205
206 c == external ==
207
208 integer ilnblnk
209 external ilnblnk
210
211 c == end of interface ==
212
213 #ifndef ALLOW_ECCO_OPTIMIZATION
214 optimcycle = 0
215 #endif
216
217 tmpvar = 0. _d 0
218
219 c-- Check if this is the first model time step.
220 if ( mytime .lt. startTime + 0.5*deltaTClock ) then
221 first = .true.
222 else
223 first = .false.
224 endif
225
226 if ( first ) then
227
228 c-- Only the master thread will do I/O.
229 _BEGIN_MASTER( mythid )
230
231 jG = 1 + (myygloballo - 1)/sny
232 iG = 1 + (myxgloballo - 1)/snx
233
234 #ifdef ALLOW_THETA0_CONTROL
235 ivartype = 1
236 call ctrl_set_fname(
237 & xx_theta_file, fname_theta, adfname_theta, mythid )
238 call ctrl_set_globfld_xyz(
239 & adfname_theta, ivartype, mythid)
240 #endif /* ALLOW_THETA0_CONTROL */
241
242 #ifdef ALLOW_SALT0_CONTROL
243 ivartype = 2
244 call ctrl_set_fname(
245 I xx_salt_file, fname_salt, adfname_salt, mythid )
246 call ctrl_set_globfld_xyz(
247 & adfname_salt, ivartype, mythid)
248 #endif
249
250 #if (defined (ALLOW_HFLUX_CONTROL) || \
251 defined (ALLOW_HFLUX0_CONTROL))
252 ivartype = 3
253 call ctrl_set_fname(
254 I xx_hflux_file, fname_hflux, adfname_hflux, mythid )
255 call ctrl_set_globfld_xy(
256 & adfname_hflux, ivartype, mythid)
257 #endif
258
259 #if (defined (ALLOW_SFLUX_CONTROL) || \
260 defined (ALLOW_SFLUX0_CONTROL))
261 ivartype = 4
262 call ctrl_set_fname(
263 I xx_sflux_file, fname_sflux, adfname_sflux, mythid )
264 call ctrl_set_globfld_xy(
265 & adfname_sflux, ivartype, mythid)
266 #endif
267
268 #if (defined (ALLOW_USTRESS_CONTROL) || \
269 defined (ALLOW_TAUU0_CONTROL))
270 ivartype = 5
271 call ctrl_set_fname(
272 I xx_tauu_file, fname_tauu, adfname_tauu, mythid )
273 call ctrl_set_globfld_xy(
274 & adfname_tauu, ivartype, mythid)
275 #endif
276
277 #if (defined (ALLOW_VSTRESS_CONTROL) || \
278 defined (ALLOW_TAUV0_CONTROL))
279 ivartype = 6
280 call ctrl_set_fname(
281 I xx_tauv_file, fname_tauv, adfname_tauv, mythid )
282 call ctrl_set_globfld_xy(
283 & adfname_tauv, ivartype, mythid)
284 #endif
285
286 #ifdef ALLOW_ATEMP_CONTROL
287 ivartype = 7
288 call ctrl_set_fname(
289 I xx_atemp_file, fname_atemp, adfname_atemp, mythid )
290 call ctrl_set_globfld_xy(
291 & adfname_atemp, ivartype, mythid)
292 #endif
293
294 #ifdef ALLOW_AQH_CONTROL
295 ivartype = 8
296 call ctrl_set_fname(
297 I xx_aqh_file, fname_aqh, adfname_aqh, mythid )
298 call ctrl_set_globfld_xy(
299 & adfname_aqh, ivartype, mythid)
300 #endif
301
302 #ifdef ALLOW_UWIND_CONTROL
303 ivartype = 9
304 call ctrl_set_fname(
305 I xx_uwind_file, fname_uwind, adfname_uwind, mythid )
306 call ctrl_set_globfld_xy(
307 & adfname_uwind, ivartype, mythid)
308 #endif
309
310 #ifdef ALLOW_VWIND_CONTROL
311 ivartype = 10
312 call ctrl_set_fname(
313 I xx_vwind_file, fname_vwind, adfname_vwind, mythid )
314 call ctrl_set_globfld_xy(
315 & adfname_vwind, ivartype, mythid)
316 #endif
317
318 #ifdef ALLOW_OBCSN_CONTROL
319 ivartype = 11
320 call ctrl_set_fname(
321 I xx_obcsn_file, fname_obcsn, adfname_obcsn, mythid )
322 call ctrl_set_globfld_xz(
323 & adfname_obcsn, ivartype, mythid)
324 #endif
325
326 #ifdef ALLOW_OBCSS_CONTROL
327 ivartype = 12
328 call ctrl_set_fname(
329 I xx_obcss_file, fname_obcss, adfname_obcss, mythid )
330 call ctrl_set_globfld_xz(
331 & adfname_obcss, ivartype, mythid)
332 #endif
333
334 #ifdef ALLOW_OBCSW_CONTROL
335 ivartype = 13
336 call ctrl_set_fname(
337 I xx_obcsw_file, fname_obcsw, adfname_obcsw, mythid )
338 call ctrl_set_globfld_yz(
339 & adfname_obcsw, ivartype, mythid)
340 #endif
341
342 #ifdef ALLOW_OBCSE_CONTROL
343 ivartype = 14
344 call ctrl_set_fname(
345 I xx_obcse_file, fname_obcse, adfname_obcse, mythid )
346 call ctrl_set_globfld_yz(
347 & adfname_obcse, ivartype, mythid)
348 #endif
349
350 #ifdef ALLOW_DIFFKR_CONTROL
351 ivartype = 15
352 call ctrl_set_fname(
353 I xx_diffkr_file, fname_diffkr, adfname_diffkr, mythid )
354 call ctrl_set_globfld_xyz(
355 & adfname_diffkr, ivartype, mythid)
356 #endif
357
358 #ifdef ALLOW_KAPGM_CONTROL
359 ivartype = 16
360 call ctrl_set_fname(
361 I xx_kapgm_file, fname_kapgm, adfname_kapgm, mythid )
362 call ctrl_set_globfld_xyz(
363 & adfname_kapgm, ivartype, mythid)
364 #endif
365
366 #ifdef ALLOW_TR10_CONTROL
367 ivartype = 17
368 call ctrl_set_fname(
369 I xx_tr1_file, fname_tr1, adfname_tr1, mythid )
370 call ctrl_set_globfld_xyz(
371 & adfname_tr1, ivartype, mythid)
372 #endif
373
374 #ifdef ALLOW_SST0_CONTROL
375 ivartype = 18
376 call ctrl_set_fname(
377 I xx_sst_file, fname_sst, adfname_sst, mythid )
378 call ctrl_set_globfld_xy(
379 & adfname_sst, ivartype, mythid)
380 #endif
381
382 #ifdef ALLOW_SSS0_CONTROL
383 ivartype = 19
384 call ctrl_set_fname(
385 I xx_sss_file, fname_sss, adfname_sss, mythid )
386 call ctrl_set_globfld_xy(
387 & adfname_sss, ivartype, mythid)
388 #endif
389
390 #ifdef ALLOW_HFACC_CONTROL
391 ivartype = 20
392 call ctrl_set_fname(
393 I xx_hfacc_file, fname_hfacc, adfname_hfacc, mythid )
394 #ifdef ALLOW_HFACC3D_CONTROL
395 call ctrl_set_globfld_xyz(
396 & adfname_hfacc, ivartype, mythid)
397 #else
398 call ctrl_set_globfld_xy(
399 & adfname_hfacc, ivartype, mythid)
400 #endif
401 #endif
402
403 #ifdef ALLOW_EFLUXY0_CONTROL
404 ivartype = 21
405 call ctrl_set_fname(
406 I xx_efluxy_file, fname_efluxy, adfname_efluxy, mythid )
407 call ctrl_set_globfld_xyz(
408 & adfname_efluxy, ivartype, mythid)
409 #endif
410
411 #ifdef ALLOW_EFLUXP0_CONTROL
412 ivartype = 22
413 call ctrl_set_fname(
414 I xx_efluxp_file, fname_efluxp, adfname_efluxp, mythid )
415 call ctrl_set_globfld_xyz(
416 & adfname_efluxp, ivartype, mythid)
417 #endif
418
419 #ifdef ALLOW_BOTTOMDRAG_CONTROL
420 ivartype = 23
421 call ctrl_set_fname(
422 I xx_bottomdrag_file, fname_bottomdrag, adfname_bottomdrag
423 I , mythid )
424 call ctrl_set_globfld_xy(
425 & adfname_bottomdrag, ivartype, mythid)
426 #endif
427
428
429 c *********************************************************************
430 c if NOT very first iteration of optimization
431 if ( optimcycle .ne. 0 ) then
432 c *********************************************************************
433
434 call mdsfindunit( cunit, mythid )
435
436 write(cfile(1:128),'(4a,i4.4)')
437 & ctrlname(1:9),'_',yctrlid(1:10),'.opt',
438 & optimcycle
439
440 open( cunit, file = cfile,
441 & status = 'old',
442 & form = 'unformatted',
443 & access = 'sequential' )
444
445 c-- Header information.
446 read(cunit) filenvartype
447 read(cunit) filenvarlength
448 read(cunit) fileYctrlid
449 read(cunit) fileOptimCycle
450 read(cunit) fileDummy
451 read(cunit) fileIg
452 read(cunit) fileJg
453 read(cunit) filensx
454 read(cunit) filensy
455 read(cunit) (filenWetcGlobal(k), k=1,nr)
456 read(cunit) (filenWetsGlobal(k), k=1,nr)
457 read(cunit) (filenWetwGlobal(k), k=1,nr)
458 read(cunit) (filenWetvGlobal(k), k=1,nr)
459
460 cgg( Add OBCS mask information to the header.
461 #ifdef ALLOW_OBCSN_CONTROL
462 read(cunit) ((filenWetobcsnGlo(k,iobcs),
463 & k=1,nr), iobcs= 1,nobcs)
464 #endif
465 #ifdef ALLOW_OBCSS_CONTROL
466 read(cunit) ((filenWetobcssGlo(k,iobcs),
467 & k=1,nr), iobcs= 1,nobcs)
468 #endif
469 #ifdef ALLOW_OBCSW_CONTROL
470 read(cunit) ((filenWetobcswGlo(k,iobcs),
471 & k=1,nr), iobcs= 1,nobcs)
472 #endif
473 #ifdef ALLOW_OBCSE_CONTROL
474 read(cunit) ((filenWetobcseGlo(k,iobcs),
475 & k=1,nr), iobcs= 1,nobcs)
476 #endif
477 cgg)
478 read(cunit) (filencvarindex(i), i=1,maxcvars)
479 read(cunit) (filencvarrecs(i), i=1,maxcvars)
480 read(cunit) (filencvarxmax(i), i=1,maxcvars)
481 read(cunit) (filencvarymax(i), i=1,maxcvars)
482 read(cunit) (filencvarnrmax(i), i=1,maxcvars)
483 read(cunit) (filencvargrd(i), i=1,maxcvars)
484 read(cunit)
485
486 c Check file header info.
487 c
488 if ( filenvarlength .NE. nvarlength ) then
489 print *, 'WARNING: wrong nvarlength ',
490 & filenvarlength, nvarlength
491 STOP 'in S/R ctrl_unpack'
492 else if ( filensx .NE. nsx .OR. filensy .NE. nsy ) then
493 print *, 'WARNING: wrong nsx or nsy ',
494 & filensx, nsx, filensy, nsy
495 STOP 'in S/R ctrl_unpack'
496 endif
497 do k = 1, nr
498 if ( filenWetcGlobal(k) .NE. nWetcGlobal(k) .OR.
499 & filenWetsGlobal(k) .NE. nWetsGlobal(k) .OR.
500 & filenWetwGlobal(k) .NE. nWetwGlobal(k) .OR.
501 & filenWetvGlobal(k) .NE. nWetvGlobal(k) ) then
502 print *, 'WARNING: wrong nWet?Global for k = ', k
503 STOP
504 endif
505 end do
506
507 cgg( Lets also check the OBCS mask info in the header.
508
509 #ifdef ALLOW_OBCSN_CONTROL
510 do iobcs = 1, nobcs
511 do k = 1, nr
512 if (filenWetobcsnGlo(k,iobcs) .NE.
513 & nWetobcsnGlo(k,iobcs)) then
514 print *, 'WARNING: OBCSN wrong nWet?Global for k = ', k
515 STOP
516 endif
517 end do
518 end do
519 #endif
520
521 #ifdef ALLOW_OBCSS_CONTROL
522 do iobcs = 1, nobcs
523 do k = 1, nr
524 if (filenWetobcssGlo(k,iobcs) .NE.
525 & nWetobcssGlo(k,iobcs)) then
526 print *, 'WARNING: OBCSS wrong nWet?Global for k = ', k
527 STOP
528 endif
529 end do
530 end do
531 #endif
532
533 #ifdef ALLOW_OBCSW_CONTROL
534 do iobcs = 1, nobcs
535 do k = 1, nr
536 if (filenWetobcswGlo(k,iobcs) .NE.
537 & nWetobcswGlo(k,iobcs)) then
538 print *, 'WARNING: OBCSW wrong nWet?Global for k = ', k
539 STOP
540 endif
541 end do
542 end do
543 #endif
544
545 #ifdef ALLOW_OBCSE_CONTROL
546 do iobcs = 1, nobcs
547 do k = 1, nr
548 if (filenWetobcseGlo(k,iobcs) .NE.
549 & nWetobcseGlo(k,iobcs)) then
550 print *, 'WARNING: OBCSE wrong nWet?Global for k = ', k
551 STOP
552 endif
553 end do
554 end do
555 #endif
556 cgg) End OBCS mask check.
557
558 c----------------------------------------------------------------------
559
560 #ifdef ALLOW_THETA0_CONTROL
561 ivartype = 1
562 call ctrl_set_unpack_xyz(
563 & cunit, ivartype, fname_theta, "hFacC",
564 & wtheta, nwetcglobal, mythid)
565 #endif
566
567 #ifdef ALLOW_SALT0_CONTROL
568 ivartype = 2
569 call ctrl_set_unpack_xyz(
570 & cunit, ivartype, fname_salt, "hFacC",
571 & wsalt, nwetcglobal, mythid)
572 #endif
573
574 #if (defined (ALLOW_HFLUX_CONTROL) || \
575 defined (ALLOW_HFLUX0_CONTROL))
576 ivartype = 3
577 write(weighttype(1:80),'(80a)') ' '
578 write(weighttype(1:80),'(a)') "whflux"
579 call ctrl_set_unpack_xy(
580 & cunit, ivartype, fname_hflux, "hFacC", weighttype,
581 & nwetcglobal, mythid)
582 #endif
583
584 #if (defined (ALLOW_SFLUX_CONTROL) || \
585 defined (ALLOW_SFLUX0_CONTROL))
586 ivartype = 4
587 write(weighttype(1:80),'(80a)') ' '
588 write(weighttype(1:80),'(a)') "wsflux"
589 call ctrl_set_unpack_xy(
590 & cunit, ivartype, fname_sflux, "hFacC", weighttype,
591 & nwetcglobal, mythid)
592 #endif
593
594 #if (defined (ALLOW_USTRESS_CONTROL) || \
595 defined (ALLOW_TAUU0_CONTROL))
596 ivartype = 5
597 write(weighttype(1:80),'(80a)') ' '
598 write(weighttype(1:80),'(a)') "wtauu"
599 call ctrl_set_unpack_xy(
600 & cunit, ivartype, fname_tauu, "maskW", weighttype,
601 & nwetwglobal, mythid)
602 #endif
603
604 #if (defined (ALLOW_VSTRESS_CONTROL) || \
605 defined (ALLOW_TAUV0_CONTROL))
606 ivartype = 6
607 write(weighttype(1:80),'(80a)') ' '
608 write(weighttype(1:80),'(a)') "wtauv"
609 call ctrl_set_unpack_xy(
610 & cunit, ivartype, fname_tauv, "maskS", weighttype,
611 & nwetsglobal, mythid)
612 #endif
613
614 #ifdef ALLOW_ATEMP_CONTROL
615 ivartype = 7
616 write(weighttype(1:80),'(80a)') ' '
617 write(weighttype(1:80),'(a)') "watemp"
618 call ctrl_set_unpack_xy(
619 & cunit, ivartype, fname_atemp, "hFacC", weighttype,
620 & nwetcglobal, mythid)
621 #endif
622
623 #ifdef ALLOW_AQH_CONTROL
624 ivartype = 8
625 write(weighttype(1:80),'(80a)') ' '
626 write(weighttype(1:80),'(a)') "waqh"
627 call ctrl_set_unpack_xy(
628 & cunit, ivartype, fname_aqh, "hFacC", weighttype,
629 & nwetcglobal, mythid)
630 #endif
631
632 #ifdef ALLOW_UWIND_CONTROL
633 ivartype = 9
634 write(weighttype(1:80),'(80a)') ' '
635 write(weighttype(1:80),'(a)') "wuwind"
636 call ctrl_set_unpack_xy(
637 & cunit, ivartype, fname_uwind, "maskW", weighttype,
638 & nwetcglobal, mythid)
639 #endif
640
641 #ifdef ALLOW_VWIND_CONTROL
642 ivartype = 10
643 write(weighttype(1:80),'(80a)') ' '
644 write(weighttype(1:80),'(a)') "wvwind"
645 call ctrl_set_unpack_xy(
646 & cunit, ivartype, fname_vwind, "maskS", weighttype,
647 & nwetcglobal, mythid)
648 #endif
649
650 #ifdef ALLOW_OBCSN_CONTROL
651 ivartype = 11
652 write(weighttype(1:80),'(80a)') ' '
653 write(weighttype(1:80),'(a)') "wobcsn"
654 call ctrl_set_unpack_xz(
655 & cunit, ivartype, fname_obcsn, "maskobcsn",
656 & wobcsn, nWetobcsnGlo, mythid)
657 #endif
658
659 #ifdef ALLOW_OBCSS_CONTROL
660 ivartype = 12
661 write(weighttype(1:80),'(80a)') ' '
662 write(weighttype(1:80),'(a)') "wobcss"
663 call ctrl_set_unpack_xz(
664 & cunit, ivartype, fname_obcss, "maskobcss",
665 & wobcss, nWetobcssGlo, mythid)
666 #endif
667
668 #ifdef ALLOW_OBCSW_CONTROL
669 ivartype = 13
670 write(weighttype(1:80),'(80a)') ' '
671 write(weighttype(1:80),'(a)') "wobcsw"
672 call ctrl_set_unpack_yz(
673 & cunit, ivartype, fname_obcsw, "maskobcsw",
674 & wobcsw, nWetobcswGlo, mythid)
675 #endif
676
677 #ifdef ALLOW_OBCSE_CONTROL
678 ivartype = 14
679 write(weighttype(1:80),'(80a)') ' '
680 write(weighttype(1:80),'(a)') "wobcse"
681 call ctrl_set_unpack_yz(
682 & cunit, ivartype, fname_obcse, "maskobcse",
683 & wobcse, nWetobcseGlo, mythid)
684 #endif
685
686 #ifdef ALLOW_DIFFKR_CONTROL
687 ivartype = 15
688 call ctrl_set_unpack_xyz(
689 & cunit, ivartype, fname_diffkr, "hFacC",
690 & wunit, nwetcglobal, mythid)
691 #endif
692
693 #ifdef ALLOW_KAPGM_CONTROL
694 ivartype = 16
695 call ctrl_set_unpack_xyz(
696 & cunit, ivartype, fname_kapgm, "hFacC",
697 & wunit, nwetcglobal, mythid)
698 #endif
699
700 #ifdef ALLOW_TR10_CONTROL
701 ivartype = 17
702 call ctrl_set_unpack_xyz(
703 & cunit, ivartype, fname_tr1, "hFacC",
704 & wunit, nwetcglobal, mythid)
705 #endif
706
707 #ifdef ALLOW_SST0_CONTROL
708 ivartype = 18
709 write(weighttype(1:80),'(80a)') ' '
710 write(weighttype(1:80),'(a)') "wsst"
711 call ctrl_set_unpack_xy(
712 & cunit, ivartype, fname_sst, "hFacC", weighttype,
713 & nwetcglobal, mythid)
714 #endif
715
716 #ifdef ALLOW_SSS0_CONTROL
717 ivartype = 19
718 write(weighttype(1:80),'(80a)') ' '
719 write(weighttype(1:80),'(a)') "wsss"
720 call ctrl_set_unpack_xy(
721 & cunit, ivartype, fname_sss, "hFacC", weighttype,
722 & nwetcglobal, mythid)
723 #endif
724
725 #ifdef ALLOW_HFACC_CONTROL
726 ivartype = 20
727 #ifdef ALLOW_HFACC3D_CONTROL
728 call ctrl_set_unpack_xyz(
729 & cunit, ivartype, fname_hfacc, "hFacC",
730 & wunit, nwetcglobal, mythid)
731 #else
732 write(weighttype(1:80),'(80a)') ' '
733 write(weighttype(1:80),'(a)') "whfacc"
734 call ctrl_set_unpack_xy(
735 & cunit, ivartype, fname_hfacc, "hFacC", weighttype,
736 & nwetcglobal, mythid)
737 #endif
738 #endif
739
740 #ifdef ALLOW_EFLUXY0_CONTROL
741 ivartype = 21
742 call ctrl_set_unpack_xyz(
743 & cunit, ivartype, fname_efluxy, "hFacS",
744 & wefluxy, nwetsglobal, mythid)
745 #endif
746
747 #ifdef ALLOW_EFLUXP0_CONTROL
748 ivartype = 22
749 call ctrl_set_unpack_xyz(
750 & cunit, ivartype, fname_efluxp, "hFacV",
751 & wefluxp, nwetvglobal, mythid)
752 #endif
753
754 #ifdef ALLOW_BOTTOMDRAG_CONTROL
755 ivartype = 23
756 write(weighttype(1:80),'(80a)') ' '
757 write(weighttype(1:80),'(a)') "wbottomdrag"
758 call ctrl_set_unpack_xy(
759 & cunit, ivartype, fname_bottomdrag, "hFacC", weighttype,
760 & nwetcglobal, mythid)
761 #endif
762
763 close ( cunit )
764
765 c *********************************************************************
766 c if very first iteration of optimization
767 else
768 c *********************************************************************
769
770 c-- Write zeroes to file.
771
772 #ifdef ALLOW_THETA0_CONTROL
773 ivartype = 1
774 call ctrl_set_globfld_xyz(
775 I fname_theta, ivartype, mythid )
776 #endif
777
778 #ifdef ALLOW_SALT0_CONTROL
779 ivartype = 2
780 call ctrl_set_globfld_xyz(
781 I fname_salt, ivartype, mythid )
782 #endif
783
784 #if (defined (ALLOW_HFLUX_CONTROL) || \
785 defined (ALLOW_HFLUX0_CONTROL))
786 ivartype = 3
787 call ctrl_set_globfld_xy(
788 I fname_hflux, ivartype, mythid )
789 #endif
790
791 #if (defined (ALLOW_SFLUX_CONTROL) || \
792 defined (ALLOW_SFLUX0_CONTROL))
793 ivartype = 4
794 call ctrl_set_globfld_xy(
795 I fname_sflux, ivartype, mythid )
796 #endif
797
798 #if (defined (ALLOW_USTRESS_CONTROL) || \
799 defined (ALLOW_TAUU0_CONTROL))
800 ivartype = 5
801 call ctrl_set_globfld_xy(
802 I fname_tauu, ivartype, mythid )
803 #endif
804
805 #if (defined (ALLOW_VSTRESS_CONTROL) || \
806 defined (ALLOW_TAUV0_CONTROL))
807 ivartype = 6
808 call ctrl_set_globfld_xy(
809 I fname_tauv, ivartype, mythid )
810 #endif
811
812 #ifdef ALLOW_ATEMP_CONTROL
813 ivartype = 7
814 call ctrl_set_globfld_xy(
815 I fname_atemp, ivartype, mythid )
816 #endif
817
818 #ifdef ALLOW_AQH_CONTROL
819 ivartype = 8
820 call ctrl_set_globfld_xy(
821 I fname_aqh, ivartype, mythid )
822 #endif
823
824 #ifdef ALLOW_UWIND_CONTROL
825 ivartype = 9
826 call ctrl_set_globfld_xy(
827 I fname_uwind, ivartype, mythid )
828 #endif
829
830 #ifdef ALLOW_VWIND_CONTROL
831 ivartype = 10
832 call ctrl_set_globfld_xy(
833 I fname_vwind, ivartype, mythid )
834 #endif
835
836 #ifdef ALLOW_OBCSN_CONTROL
837 ivartype = 11
838 call ctrl_set_globfld_xz(
839 I fname_obcsn, ivartype, mythid )
840 #endif
841
842 #ifdef ALLOW_OBCSS_CONTROL
843 ivartype = 12
844 call ctrl_set_globfld_xz(
845 I fname_obcss, ivartype, mythid )
846 #endif
847
848 #ifdef ALLOW_OBCSW_CONTROL
849 ivartype = 13
850 call ctrl_set_globfld_yz(
851 I fname_obcsw, ivartype, mythid )
852 #endif
853
854 #ifdef ALLOW_OBCSE_CONTROL
855 ivartype = 14
856 call ctrl_set_globfld_yz(
857 I fname_obcse, ivartype, mythid )
858 #endif
859
860 #ifdef ALLOW_DIFFKR_CONTROL
861 ivartype = 15
862 call ctrl_set_globfld_xyz(
863 I fname_diffkr, ivartype, mythid )
864 #endif
865
866 #ifdef ALLOW_KAPGM_CONTROL
867 ivartype = 16
868 call ctrl_set_globfld_xyz(
869 I fname_kapgm, ivartype, mythid )
870 #endif
871
872 #ifdef ALLOW_TR10_CONTROL
873 ivartype = 17
874 call ctrl_set_globfld_xyz(
875 I fname_tr1, ivartype, mythid )
876 #endif
877
878 #ifdef ALLOW_SST0_CONTROL
879 ivartype = 18
880 call ctrl_set_globfld_xy(
881 I fname_sst, ivartype, mythid )
882 #endif
883
884 #ifdef ALLOW_SSS0_CONTROL
885 ivartype = 19
886 call ctrl_set_globfld_xy(
887 I fname_sss, ivartype, mythid )
888 #endif
889
890 #ifdef ALLOW_HFACC_CONTROL
891 ivartype = 20
892 #ifdef ALLOW_HFACC3D_CONTROL
893 call ctrl_set_globfld_xyz(
894 I fname_hfacc, ivartype, mythid )
895 #else
896 call ctrl_set_globfld_xy(
897 I fname_hfacc, ivartype, mythid )
898 #endif
899 #endif
900
901 #ifdef ALLOW_EFLUXY0_CONTROL
902 ivartype = 21
903 call ctrl_set_globfld_xyz(
904 I fname_efluxy, ivartype, mythid )
905 #endif
906
907 #ifdef ALLOW_EFLUXP0_CONTROL
908 ivartype = 22
909 call ctrl_set_globfld_xyz(
910 I fname_efluxp, ivartype, mythid )
911 #endif
912
913 #ifdef ALLOW_BOTTOMDRAG_CONTROL
914 ivartype = 23
915 call ctrl_set_globfld_xy(
916 I fname_bottomdrag, ivartype, mythid )
917 #endif
918
919 cgg( For optimcycle = 0, we need to output ecco_ctrl file to disk with the
920 cgg header information and everything else 0.
921 c >>> Write control vector <<<
922 lxxadxx = .TRUE.
923
924 call mdsfindunit( cunit, mythid )
925 write(cfile(1:128),'(4a,i4.4)')
926 & ctrlname(1:9),'_',yctrlid(1:10),'.opt',
927 & optimcycle
928
929 open( cunit, file = cfile,
930 & status = 'unknown',
931 & form = 'unformatted',
932 & access = 'sequential' )
933
934 c-- Header information.
935
936 write(cunit) nvartype
937 write(cunit) nvarlength
938 write(cunit) yctrlid
939 write(cunit) optimCycle
940 write(cunit) tmpvar
941 write(cunit) 1
942 write(cunit) 1
943 write(cunit) 1
944 write(cunit) 1
945 write(cunit) (nWetcGlobal(k), k=1,nr)
946 write(cunit) (nWetsGlobal(k), k=1,nr)
947 write(cunit) (nWetwGlobal(k), k=1,nr)
948 write(cunit) (nWetvGlobal(k), k=1,nr)
949
950 cgg( Add OBCS Mask information into the header section for optimization.
951 #ifdef ALLOW_OBCSN_CONTROL
952 write(cunit) ((nWetobcsnGlo(k,iobcs), k=1,nr),iobcs= 1,nobcs)
953 #endif
954 #ifdef ALLOW_OBCSS_CONTROL
955 write(cunit) ((nWetobcssGlo(k,iobcs), k=1,nr),iobcs= 1,nobcs)
956 #endif
957 #ifdef ALLOW_OBCSW_CONTROL
958 write(cunit) ((nWetobcswGlo(k,iobcs), k=1,nr),iobcs= 1,nobcs)
959 #endif
960 #ifdef ALLOW_OBCSE_CONTROL
961 write(cunit) ((nWetobcseGlo(k,iobcs), k=1,nr),iobcs= 1,nobcs)
962 #endif
963 cgg)
964 write(cunit) (ncvarindex(i), i=1,maxcvars)
965 write(cunit) (ncvarrecs(i), i=1,maxcvars)
966 write(cunit) (nx, i=1,maxcvars)
967 write(cunit) (ny, i=1,maxcvars)
968 write(cunit) (ncvarnrmax(i), i=1,maxcvars)
969 write(cunit) (ncvargrd(i), i=1,maxcvars)
970 write(cunit)
971
972 #ifdef ALLOW_THETA0_CONTROL
973 ivartype = 1
974 call ctrl_set_pack_xyz(
975 & cunit, ivartype, fname_theta, "hFacC",
976 & wtheta, lxxadxx, mythid)
977 #endif
978
979 #ifdef ALLOW_SALT0_CONTROL
980 ivartype = 2
981 call ctrl_set_pack_xyz(
982 & cunit, ivartype, fname_salt, "hFacC",
983 & wsalt, lxxadxx, mythid)
984 #endif
985
986 #if (defined (ALLOW_HFLUX_CONTROL) || \
987 defined (ALLOW_HFLUX0_CONTROL))
988 ivartype = 3
989 write(weighttype(1:80),'(80a)') ' '
990 write(weighttype(1:80),'(a)') "whflux"
991 call ctrl_set_pack_xy(
992 & cunit, ivartype, fname_hflux, "hFacC", weighttype,
993 & lxxadxx, mythid)
994 #endif
995
996 #if (defined (ALLOW_SFLUX_CONTROL) || \
997 defined (ALLOW_SFLUX0_CONTROL))
998 ivartype = 4
999 write(weighttype(1:80),'(80a)') ' '
1000 write(weighttype(1:80),'(a)') "wsflux"
1001 call ctrl_set_pack_xy(
1002 & cunit, ivartype, fname_sflux, "hFacC", weighttype,
1003 & lxxadxx, mythid)
1004 #endif
1005
1006 #if (defined (ALLOW_USTRESS_CONTROL) || \
1007 defined (ALLOW_TAUU0_CONTROL))
1008 ivartype = 5
1009 write(weighttype(1:80),'(80a)') ' '
1010 write(weighttype(1:80),'(a)') "wtauu"
1011 call ctrl_set_pack_xy(
1012 & cunit, ivartype, fname_tauu, "maskW", weighttype,
1013 & lxxadxx, mythid)
1014 #endif
1015
1016 #if (defined (ALLOW_VSTRESS_CONTROL) || \
1017 defined (ALLOW_TAUV0_CONTROL))
1018 ivartype = 6
1019 write(weighttype(1:80),'(80a)') ' '
1020 write(weighttype(1:80),'(a)') "wtauv"
1021 call ctrl_set_pack_xy(
1022 & cunit, ivartype, fname_tauv, "maskS", weighttype,
1023 & lxxadxx, mythid)
1024 #endif
1025
1026 #ifdef ALLOW_ATEMP_CONTROL
1027 ivartype = 7
1028 write(weighttype(1:80),'(80a)') ' '
1029 write(weighttype(1:80),'(a)') "watemp"
1030 call ctrl_set_pack_xy(
1031 & cunit, ivartype, fname_atemp, "hFacC", weighttype,
1032 & lxxadxx, mythid)
1033 #endif
1034
1035 #ifdef ALLOW_AQH_CONTROL
1036 ivartype = 8
1037 write(weighttype(1:80),'(80a)') ' '
1038 write(weighttype(1:80),'(a)') "waqh"
1039 call ctrl_set_pack_xy(
1040 & cunit, ivartype, fname_aqh, "hFacC", weighttype,
1041 & lxxadxx, mythid)
1042 #endif
1043
1044 #ifdef ALLOW_UWIND_CONTROL
1045 ivartype = 9
1046 write(weighttype(1:80),'(80a)') ' '
1047 write(weighttype(1:80),'(a)') "wuwind"
1048 call ctrl_set_pack_xy(
1049 & cunit, ivartype, fname_uwind, "maskW", weighttype,
1050 & lxxadxx, mythid)
1051 #endif
1052
1053 #ifdef ALLOW_VWIND_CONTROL
1054 ivartype = 10
1055 write(weighttype(1:80),'(80a)') ' '
1056 write(weighttype(1:80),'(a)') "wvwind"
1057 call ctrl_set_pack_xy(
1058 & cunit, ivartype, fname_vwind, "maskS", weighttype,
1059 & lxxadxx, mythid)
1060 #endif
1061
1062 #ifdef ALLOW_OBCSN_CONTROL
1063 ivartype = 11
1064 call ctrl_set_pack_xz(
1065 & cunit, ivartype, fname_obcsn, "maskobcsn",
1066 & wobcsn, lxxadxx, mythid)
1067 #endif
1068
1069 #ifdef ALLOW_OBCSS_CONTROL
1070 ivartype = 12
1071 call ctrl_set_pack_xz(
1072 & cunit, ivartype, fname_obcsn, "maskobcss",
1073 & wobcss, lxxadxx, mythid)
1074 #endif
1075
1076 #ifdef ALLOW_OBCSW_CONTROL
1077 ivartype = 13
1078 call ctrl_set_pack_yz(
1079 & cunit, ivartype, fname_obcsw, "maskobcsw",
1080 & wobcsw, lxxadxx, mythid)
1081 #endif
1082
1083 #ifdef ALLOW_OBCSE_CONTROL
1084 ivartype = 14
1085 call ctrl_set_pack_yz(
1086 & cunit, ivartype, fname_obcse, "maskobcse",
1087 & wobcse, lxxadxx, mythid)
1088 #endif
1089
1090 #ifdef ALLOW_DIFFKR_CONTROL
1091 ivartype = 15
1092 call ctrl_set_pack_xyz(
1093 & cunit, ivartype, fname_diffkr, "hFacC",
1094 & wunit, lxxadxx, mythid)
1095 #endif
1096
1097 #ifdef ALLOW_KAPGM_CONTROL
1098 ivartype = 16
1099 call ctrl_set_pack_xyz(
1100 & cunit, ivartype, fname_kapgm, "hFacC",
1101 & wunit, lxxadxx, mythid)
1102 #endif
1103
1104 #ifdef ALLOW_TR10_CONTROL
1105 ivartype = 17
1106 call ctrl_set_pack_xyz(
1107 & cunit, ivartype, fname_tr1, "hFacC",
1108 & wunit, lxxadxx, mythid)
1109 #endif
1110
1111 #ifdef ALLOW_SST0_CONTROL
1112 ivartype = 18
1113 write(weighttype(1:80),'(80a)') ' '
1114 write(weighttype(1:80),'(a)') "wsst"
1115 call ctrl_set_pack_xy(
1116 & cunit, ivartype, fname_sst, "hFacC", weighttype,
1117 & lxxadxx, mythid)
1118 #endif
1119
1120 #ifdef ALLOW_SSS0_CONTROL
1121 ivartype = 19
1122 write(weighttype(1:80),'(80a)') ' '
1123 write(weighttype(1:80),'(a)') "wsss"
1124 call ctrl_set_pack_xy(
1125 & cunit, ivartype, fname_sss, "hFacC", weighttype,
1126 & lxxadxx, mythid)
1127 #endif
1128
1129 #ifdef ALLOW_HFACC_CONTROL
1130 ivartype = 20
1131 #ifdef ALLOW_HFACC3D_CONTROL
1132 call ctrl_set_pack_xyz(
1133 & cunit, ivartype, fname_hfacc, "hFacC",
1134 #else
1135 write(weighttype(1:80),'(80a)') ' '
1136 write(weighttype(1:80),'(a)') "whfacc"
1137 call ctrl_set_pack_xy(
1138 & cunit, ivartype, fname_hfacc, "hFacC", weighttype,
1139 & lxxadxx, mythid)
1140 #endif
1141 #endif
1142
1143 #ifdef ALLOW_EFLUXY0_CONTROL
1144 ivartype = 21
1145 call ctrl_set_pack_xyz(
1146 & cunit, ivartype, fname_efluxy, "hFacS",
1147 & wunit, lxxadxx, mythid)
1148 #endif
1149
1150 #ifdef ALLOW_EFLUXP0_CONTROL
1151 ivartype = 22
1152 call ctrl_set_pack_xyz(
1153 & cunit, ivartype, fname_efluxp, "hFacV",
1154 & wunit, lxxadxx, mythid)
1155 #endif
1156
1157 #ifdef ALLOW_BOTTOMDRAG_CONTROL
1158 ivartype = 23
1159 write(weighttype(1:80),'(80a)') ' '
1160 write(weighttype(1:80),'(a)') "wbottomdrag"
1161 call ctrl_set_pack_xy(
1162 & cunit, ivartype, fname_bottomdrag, "hFacC", weighttype,
1163 & lxxadxx, mythid)
1164 #endif
1165
1166 close ( cunit )
1167 cgg) End of the initialization of the ecco_ctrl file for optimcycle=0.
1168
1169 endif
1170 cgg End of optimcycle if.
1171
1172 _END_MASTER( mythid )
1173
1174 endif
1175 cgg End of "first" if.
1176
1177 return
1178 end
1179

  ViewVC Help
Powered by ViewVC 1.1.22