1 |
heimbach |
1.2 |
|
2 |
|
|
#include "CTRL_CPPOPTIONS.h" |
3 |
|
|
|
4 |
|
|
|
5 |
|
|
subroutine ctrl_set_pack_yz( |
6 |
|
|
& cunit, ivartype, fname, masktype, |
7 |
|
|
& weightfld, lxxadxx, mythid) |
8 |
|
|
|
9 |
|
|
c ================================================================== |
10 |
|
|
c SUBROUTINE ctrl_set_pack_yz |
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 ================================================================== |
17 |
|
|
|
18 |
|
|
implicit none |
19 |
|
|
|
20 |
|
|
c == global variables == |
21 |
|
|
|
22 |
|
|
#include "EEPARAMS.h" |
23 |
|
|
#include "SIZE.h" |
24 |
|
|
#include "PARAMS.h" |
25 |
|
|
#include "GRID.h" |
26 |
|
|
|
27 |
|
|
#include "ctrl.h" |
28 |
|
|
#include "cost.h" |
29 |
|
|
|
30 |
|
|
#ifdef ALLOW_ECCO_OPTIMIZATION |
31 |
|
|
#include "optim.h" |
32 |
|
|
#endif |
33 |
|
|
|
34 |
|
|
c == routine arguments == |
35 |
|
|
|
36 |
|
|
integer cunit |
37 |
|
|
integer ivartype |
38 |
|
|
character*( 80) fname |
39 |
|
|
character*( 9) masktype |
40 |
|
|
_RL weightfld( nr,nobcs ) |
41 |
|
|
logical lxxadxx |
42 |
|
|
integer mythid |
43 |
|
|
|
44 |
|
|
c == local variables == |
45 |
|
|
|
46 |
|
|
#ifndef ALLOW_ECCO_OPTIMIZATION |
47 |
|
|
integer optimcycle |
48 |
|
|
#endif |
49 |
|
|
|
50 |
|
|
integer bi,bj |
51 |
|
|
integer ip,jp |
52 |
|
|
integer i,j,k |
53 |
|
|
integer ii |
54 |
|
|
integer il |
55 |
|
|
integer irec,iobcs |
56 |
|
|
integer itlo,ithi |
57 |
|
|
integer jtlo,jthi |
58 |
|
|
integer jmin,jmax |
59 |
|
|
integer imin,imax |
60 |
|
|
|
61 |
|
|
integer cbuffindex |
62 |
|
|
cgg( |
63 |
|
|
integer igg |
64 |
|
|
_RL gg |
65 |
|
|
cgg) |
66 |
|
|
_RL cbuff ( nsx*npx*sny*nsy*npy ) |
67 |
|
|
_RL globmskyz ( nsx,npx,sny,nsy,npy,nr ) |
68 |
|
|
_RL globfldyz ( nsx,npx,sny,nsy,npy,nr ) |
69 |
|
|
|
70 |
|
|
c == external == |
71 |
|
|
|
72 |
|
|
integer ilnblnk |
73 |
|
|
external ilnblnk |
74 |
|
|
|
75 |
|
|
c == end of interface == |
76 |
|
|
|
77 |
|
|
#ifndef ALLOW_ECCO_OPTIMIZATION |
78 |
|
|
optimcycle = 0 |
79 |
|
|
#endif |
80 |
|
|
|
81 |
|
|
jtlo = 1 |
82 |
|
|
jthi = nsy |
83 |
|
|
itlo = 1 |
84 |
|
|
ithi = nsx |
85 |
|
|
jmin = 1 |
86 |
|
|
jmax = sny |
87 |
|
|
imin = 1 |
88 |
|
|
imax = snx |
89 |
|
|
|
90 |
|
|
c Initialise temporary file |
91 |
|
|
do k = 1,nr |
92 |
|
|
do jp = 1,nPy |
93 |
|
|
do bj = jtlo,jthi |
94 |
|
|
do j = jmin,jmax |
95 |
|
|
do ip = 1,nPx |
96 |
|
|
do bi = itlo,ithi |
97 |
|
|
globfldyz(bi,ip,j,bj,jp,k) = 0. _d 0 |
98 |
|
|
globmskyz(bi,ip,j,bj,jp,k) = 0. _d 0 |
99 |
|
|
enddo |
100 |
|
|
enddo |
101 |
|
|
enddo |
102 |
|
|
enddo |
103 |
|
|
enddo |
104 |
|
|
enddo |
105 |
|
|
|
106 |
|
|
c-- Only the master thread will do I/O. |
107 |
|
|
_BEGIN_MASTER( mythid ) |
108 |
|
|
|
109 |
|
|
do irec = 1, ncvarrecs(ivartype) |
110 |
|
|
|
111 |
|
|
cgg do iobcs = 1, nobcs |
112 |
|
|
cgg Need to solve for what iobcs would have been. |
113 |
|
|
gg = (irec-1)/nobcs |
114 |
|
|
igg = int(gg) |
115 |
|
|
iobcs= irec - igg*nobcs |
116 |
|
|
|
117 |
|
|
call MDSREADFIELD_YZ_GL( |
118 |
|
|
& masktype, ctrlprec, 'RL', |
119 |
|
|
& Nr, globmskyz, iobcs, mythid) |
120 |
|
|
|
121 |
|
|
call MDSREADFIELD_YZ_GL( fname, ctrlprec, 'RL', |
122 |
|
|
& nr, globfldyz, irec, mythid) |
123 |
|
|
|
124 |
|
|
write(cunit) ncvarindex(ivartype) |
125 |
|
|
write(cunit) 1 |
126 |
|
|
write(cunit) 1 |
127 |
|
|
do k = 1,nr |
128 |
|
|
cbuffindex = 0 |
129 |
|
|
do jp = 1,nPy |
130 |
|
|
do bj = jtlo,jthi |
131 |
|
|
do ip = 1,nPx |
132 |
|
|
do bi = itlo,ithi |
133 |
|
|
do j = jmin,jmax |
134 |
|
|
if (globmskyz(bi,ip,j,bj,jp,k) .ne. 0. ) then |
135 |
|
|
cbuffindex = cbuffindex + 1 |
136 |
|
|
#ifdef ALLOW_NONDIMENSIONAL_CONTROL_IO |
137 |
|
|
if (lxxadxx) then |
138 |
|
|
cbuff(cbuffindex) = |
139 |
|
|
& globfldyz(bi,ip,j,bj,jp,k) * |
140 |
|
|
& sqrt(weightfld(k,iobcs)) |
141 |
|
|
else |
142 |
|
|
cbuff(cbuffindex) = |
143 |
|
|
& globfldyz(bi,ip,j,bj,jp,k) / |
144 |
|
|
& sqrt(weightfld(k,iobcs)) |
145 |
|
|
endif |
146 |
|
|
#else |
147 |
|
|
cbuff(cbuffindex) = globfldyz(bi,ip,j,bj,jp,k) |
148 |
|
|
#endif |
149 |
|
|
endif |
150 |
|
|
enddo |
151 |
|
|
enddo |
152 |
|
|
enddo |
153 |
|
|
enddo |
154 |
|
|
enddo |
155 |
|
|
c --> check cbuffindex. |
156 |
|
|
if ( cbuffindex .gt. 0) then |
157 |
|
|
write(cunit) cbuffindex |
158 |
|
|
write(cunit) k |
159 |
|
|
write(cunit) (cbuff(ii), ii=1,cbuffindex) |
160 |
|
|
endif |
161 |
|
|
enddo |
162 |
|
|
c |
163 |
|
|
c -- end of iobcs loop -- |
164 |
|
|
cgg enddo |
165 |
|
|
c -- end of irec loop -- |
166 |
|
|
enddo |
167 |
|
|
|
168 |
|
|
_END_MASTER( mythid ) |
169 |
|
|
|
170 |
|
|
return |
171 |
|
|
end |
172 |
|
|
|