1 |
heimbach |
1.1.2.1 |
|
2 |
|
|
#include "CTRL_CPPOPTIONS.h" |
3 |
|
|
|
4 |
|
|
|
5 |
|
|
subroutine ctrl_set_unpack_yz( |
6 |
|
|
& cunit, ivartype, fname, masktype, |
7 |
|
|
& weightfld, nwettile, mythid) |
8 |
|
|
|
9 |
|
|
c ================================================================== |
10 |
|
|
c SUBROUTINE ctrl_set_unpack_yz |
11 |
|
|
c ================================================================== |
12 |
|
|
c |
13 |
|
|
c o Unpack the control vector such that the land points are filled |
14 |
|
|
c in. |
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 "cal.h" |
28 |
|
|
#include "ecco.h" |
29 |
|
|
#include "ctrl.h" |
30 |
|
|
#include "cost.h" |
31 |
|
|
|
32 |
|
|
#ifdef ALLOW_ECCO_OPTIMIZATION |
33 |
|
|
#include "optim.h" |
34 |
|
|
#endif |
35 |
|
|
|
36 |
|
|
c == routine arguments == |
37 |
|
|
|
38 |
|
|
integer cunit |
39 |
|
|
integer ivartype |
40 |
|
|
character*( 80) fname |
41 |
|
|
character* (9) masktype |
42 |
heimbach |
1.1.2.2 |
_RL weightfld( nr,nobcs ) |
43 |
heimbach |
1.1.2.1 |
integer nwettile(nsx,nsy,nr,nobcs) |
44 |
|
|
integer mythid |
45 |
|
|
|
46 |
|
|
c == local variables == |
47 |
|
|
|
48 |
|
|
#ifndef ALLOW_ECCO_OPTIMIZATION |
49 |
|
|
integer optimcycle |
50 |
|
|
#endif |
51 |
|
|
|
52 |
|
|
integer bi,bj |
53 |
|
|
integer ip,jp |
54 |
|
|
integer i,j,k |
55 |
|
|
integer ii |
56 |
|
|
integer il |
57 |
|
|
integer irec,iobcs |
58 |
|
|
integer itlo,ithi |
59 |
|
|
integer jtlo,jthi |
60 |
|
|
integer jmin,jmax |
61 |
|
|
integer imin,imax |
62 |
|
|
|
63 |
|
|
integer cbuffindex |
64 |
|
|
|
65 |
|
|
_RL cbuff ( nsx*npx*sny*nsy*npy ) |
66 |
|
|
_RL globmskyz( nsx,npx,sny,nsy,npy,nr ) |
67 |
|
|
_RL globfldyz( nsx,npx,sny,nsy,npy,nr ) |
68 |
|
|
|
69 |
|
|
integer filenvartype |
70 |
|
|
integer filenvarlength |
71 |
|
|
character*(10) fileExpId |
72 |
|
|
integer fileOptimCycle |
73 |
|
|
integer filencbuffindex |
74 |
|
|
_RL fileDummy |
75 |
|
|
integer fileIg |
76 |
|
|
integer fileJg |
77 |
|
|
integer fileI |
78 |
|
|
integer fileJ |
79 |
|
|
integer filensx |
80 |
|
|
integer filensy |
81 |
|
|
integer filek |
82 |
|
|
integer filencvarindex(maxcvars) |
83 |
|
|
integer filencvarrecs(maxcvars) |
84 |
|
|
integer filencvarxmax(maxcvars) |
85 |
|
|
integer filencvarymax(maxcvars) |
86 |
|
|
integer filencvarnrmax(maxcvars) |
87 |
|
|
character*( 1) filencvargrd(maxcvars) |
88 |
|
|
|
89 |
|
|
c == external == |
90 |
|
|
|
91 |
|
|
integer ilnblnk |
92 |
|
|
external ilnblnk |
93 |
|
|
|
94 |
|
|
cc == end of interface == |
95 |
|
|
|
96 |
|
|
jtlo = 1 |
97 |
|
|
jthi = nsy |
98 |
|
|
itlo = 1 |
99 |
|
|
ithi = nsx |
100 |
|
|
jmin = 1 |
101 |
|
|
jmax = sny |
102 |
|
|
imin = 1 |
103 |
|
|
imax = snx |
104 |
|
|
|
105 |
|
|
c Initialise temporary file |
106 |
|
|
do k = 1,nr |
107 |
|
|
do jp = 1,nPy |
108 |
|
|
do bj = jtlo,jthi |
109 |
|
|
do j = jmin,jmax |
110 |
|
|
do ip = 1,nPx |
111 |
|
|
do bi = itlo,ithi |
112 |
|
|
globfldyz(bi,ip,j,bj,jp,k) = 0. _d 0 |
113 |
|
|
globmskyz(bi,ip,j,bj,jp,k) = 0. _d 0 |
114 |
|
|
enddo |
115 |
|
|
enddo |
116 |
|
|
enddo |
117 |
|
|
enddo |
118 |
|
|
enddo |
119 |
|
|
enddo |
120 |
|
|
|
121 |
|
|
#ifndef ALLOW_ECCO_OPTIMIZATION |
122 |
|
|
optimcycle = 0 |
123 |
|
|
#endif |
124 |
|
|
|
125 |
|
|
c-- Only the master thread will do I/O. |
126 |
|
|
_BEGIN_MASTER( mythid ) |
127 |
|
|
|
128 |
|
|
do irec = 1, ncvarrecs(ivartype) |
129 |
|
|
do iobcs = 1, nobcs |
130 |
|
|
|
131 |
|
|
call MDSREADFIELD_YZ_GL( |
132 |
|
|
& masktype, ctrlprec, 'RL', |
133 |
|
|
& Nr, globmskyz, iobcs, mythid) |
134 |
|
|
|
135 |
|
|
read(cunit) filencvarindex(ivartype) |
136 |
|
|
if (filencvarindex(ivartype) .NE. ncvarindex(ivartype)) |
137 |
|
|
& then |
138 |
|
|
print *, 'WARNING: wrong ncvarindex ', |
139 |
|
|
& filencvarindex(ivartype), ncvarindex(ivartype) |
140 |
|
|
STOP 'in S/R ctrl_unpack' |
141 |
|
|
endif |
142 |
|
|
read(cunit) filej |
143 |
|
|
read(cunit) filei |
144 |
|
|
do k = 1, Nr |
145 |
|
|
cbuffindex = nwettile(1,1,k,iobcs) |
146 |
|
|
if ( cbuffindex .gt. 0 ) then |
147 |
|
|
read(cunit) filencbuffindex |
148 |
|
|
if (filencbuffindex .NE. cbuffindex) then |
149 |
|
|
print *, 'WARNING: wrong cbuffindex ', |
150 |
|
|
& filencbuffindex, cbuffindex |
151 |
|
|
STOP 'in S/R ctrl_unpack' |
152 |
|
|
endif |
153 |
|
|
read(cunit) filek |
154 |
|
|
if (filek .NE. k) then |
155 |
|
|
print *, 'WARNING: wrong k ', |
156 |
|
|
& filek, k |
157 |
|
|
STOP 'in S/R ctrl_unpack' |
158 |
|
|
endif |
159 |
|
|
read(cunit) (cbuff(ii), ii=1,cbuffindex) |
160 |
|
|
endif |
161 |
|
|
cbuffindex = 0 |
162 |
|
|
do jp = 1,nPy |
163 |
|
|
do bj = jtlo,jthi |
164 |
|
|
do j = jmin,jmax |
165 |
|
|
do ip = 1,nPx |
166 |
|
|
do bi = itlo,ithi |
167 |
|
|
if ( globmskyz(bi,ip,j,bj,jp,k) .ne. 0. ) then |
168 |
|
|
cbuffindex = cbuffindex + 1 |
169 |
|
|
globfldyz(bi,ip,j,bj,jp,k) = cbuff(cbuffindex) |
170 |
|
|
#ifdef ALLOW_NONDIMENSIONAL_CONTROL_IO |
171 |
|
|
globfldyz(bi,ip,j,bj,jp,k) = |
172 |
|
|
& globfldyz(bi,ip,j,bj,jp,k)/ |
173 |
heimbach |
1.1.2.2 |
& sqrt(weightfld(k,iobcs)) |
174 |
heimbach |
1.1.2.1 |
#endif |
175 |
|
|
else |
176 |
|
|
globfldyz(bi,ip,j,bj,jp,k) = 0. _d 0 |
177 |
|
|
endif |
178 |
|
|
enddo |
179 |
|
|
enddo |
180 |
|
|
enddo |
181 |
|
|
enddo |
182 |
|
|
enddo |
183 |
|
|
c |
184 |
|
|
enddo |
185 |
|
|
|
186 |
|
|
call MDSWRITEFIELD_YZ_GL( fname, ctrlprec, 'RL', |
187 |
|
|
& Nr, globfldyz, (irec-1)*nobcs+iobcs, |
188 |
|
|
& optimcycle, mythid) |
189 |
|
|
|
190 |
|
|
c -- end of iobcs loop -- |
191 |
|
|
enddo |
192 |
|
|
c -- end of irec loop -- |
193 |
|
|
enddo |
194 |
|
|
|
195 |
|
|
_END_MASTER( mythid ) |
196 |
|
|
|
197 |
|
|
return |
198 |
|
|
end |
199 |
|
|
|