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

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

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


Revision 1.3 - (show annotations) (download)
Tue Jun 24 16:07:07 2003 UTC (20 years, 10 months ago) by heimbach
Branch: MAIN
CVS Tags: checkpoint51k_post, checkpoint51l_post, checkpoint51, checkpoint51f_post, checkpoint51d_post, checkpoint51j_post, checkpoint51l_pre, checkpoint51b_pre, checkpoint51h_pre, branchpoint-genmake2, checkpoint51i_post, checkpoint51b_post, checkpoint51c_post, checkpoint51i_pre, checkpoint51e_post, checkpoint51f_pre, checkpoint51g_post, checkpoint51m_post, checkpoint51a_post
Branch point for: branch-genmake2, tg2-branch
Changes since 1.2: +27 -4 lines
Merging for c51 vs. e34

1
2 #include "CTRL_CPPOPTIONS.h"
3
4
5 subroutine ctrl_set_unpack_xyz(
6 & cunit, ivartype, fname, masktype, weighttype,
7 & weightfld, nwetglobal, mythid)
8
9 c ==================================================================
10 c SUBROUTINE ctrl_set_unpack_xyz
11 c ==================================================================
12 c
13 c o Unpack the control vector such that land points are filled in.
14 c
15 c o Use a more precise nondimensionalization that depends on (x,y)
16 c Added weighttype to the argument list so that I can geographically
17 c vary the nondimensionalization.
18 c gebbie@mit.edu, 18-Mar-2003
19 c
20 c ==================================================================
21
22 implicit none
23
24 c == global variables ==
25
26 #include "EEPARAMS.h"
27 #include "SIZE.h"
28 #include "PARAMS.h"
29 #include "GRID.h"
30
31 #include "ctrl.h"
32 #include "cost.h"
33
34 #ifdef ALLOW_ECCO_OPTIMIZATION
35 #include "optim.h"
36 #endif
37
38 c == routine arguments ==
39
40 integer cunit
41 integer ivartype
42 character*( 80) fname
43 character* (5) masktype
44 character*( 80) weighttype
45 _RL weightfld( nr,nsx,nsy )
46 integer nwetglobal(nr)
47 integer mythid
48
49 c == local variables ==
50
51 #ifndef ALLOW_ECCO_OPTIMIZATION
52 integer optimcycle
53 #endif
54
55 integer bi,bj
56 integer ip,jp
57 integer i,j,k
58 integer ii
59 integer il
60 integer irec
61 integer itlo,ithi
62 integer jtlo,jthi
63 integer jmin,jmax
64 integer imin,imax
65
66 integer cbuffindex
67
68 _RL cbuff ( snx*nsx*npx*sny*nsy*npy )
69 _RL globmsk ( snx,nsx,npx,sny,nsy,npy,nr )
70 _RL globfld3d( snx,nsx,npx,sny,nsy,npy,nr )
71 #ifdef CTRL_UNPACK_PRECISE
72 _RL weightfld3d( snx,nsx,npx,sny,nsy,npy,nr )
73 #endif
74
75 character*(128) cfile
76 character*(80) weightname
77
78 integer filenvartype
79 integer filenvarlength
80 character*(10) fileExpId
81 integer fileOptimCycle
82 integer filencbuffindex
83 _RL fileDummy
84 integer fileIg
85 integer fileJg
86 integer fileI
87 integer fileJ
88 integer filensx
89 integer filensy
90 integer filek
91 integer filencvarindex(maxcvars)
92 integer filencvarrecs(maxcvars)
93 integer filencvarxmax(maxcvars)
94 integer filencvarymax(maxcvars)
95 integer filencvarnrmax(maxcvars)
96 character*( 1) filencvargrd(maxcvars)
97
98 c == external ==
99
100 integer ilnblnk
101 external ilnblnk
102
103 cc == end of interface ==
104
105 jtlo = 1
106 jthi = nsy
107 itlo = 1
108 ithi = nsx
109 jmin = 1
110 jmax = sny
111 imin = 1
112 imax = snx
113
114 c Initialise temporary file
115 do k = 1,nr
116 do jp = 1,nPy
117 do bj = jtlo,jthi
118 do j = jmin,jmax
119 do ip = 1,nPx
120 do bi = itlo,ithi
121 do i = imin,imax
122 globfld3d(i,bi,ip,j,bj,jp,k) = 0. _d 0
123 globmsk (i,bi,ip,j,bj,jp,k) = 0. _d 0
124 enddo
125 enddo
126 enddo
127 enddo
128 enddo
129 enddo
130 enddo
131
132 #ifndef ALLOW_ECCO_OPTIMIZATION
133 optimcycle = 0
134 #endif
135
136 c-- Only the master thread will do I/O.
137 _BEGIN_MASTER( mythid )
138
139 #ifdef CTRL_UNPACK_PRECISE
140 il=ilnblnk( weighttype)
141 write(weightname(1:80),'(80a)') ' '
142 write(weightname(1:80),'(a)') weighttype(1:il)
143
144 call MDSREADFIELD_3D_GL(
145 & weightname, ctrlprec, 'RL',
146 & Nr, weightfld3d, 1, mythid)
147 #endif
148
149 call MDSREADFIELD_3D_GL(
150 & masktype, ctrlprec, 'RL',
151 & Nr, globmsk, 1, mythid)
152
153 do irec = 1, ncvarrecs(ivartype)
154 read(cunit) filencvarindex(ivartype)
155 if (filencvarindex(ivartype) .NE. ncvarindex(ivartype))
156 & then
157 print *, 'ctrl_set_unpack_xyz:WARNING: wrong ncvarindex ',
158 & filencvarindex(ivartype), ncvarindex(ivartype)
159 STOP 'in S/R ctrl_unpack'
160 endif
161 read(cunit) filej
162 read(cunit) filei
163 do k = 1, Nr
164 cbuffindex = nwetglobal(k)
165 if ( cbuffindex .gt. 0 ) then
166 read(cunit) filencbuffindex
167 if (filencbuffindex .NE. cbuffindex) then
168 print *, 'WARNING: wrong cbuffindex ',
169 & filencbuffindex, cbuffindex
170 STOP 'in S/R ctrl_unpack'
171 endif
172 read(cunit) filek
173 if (filek .NE. k) then
174 print *, 'WARNING: wrong k ',
175 & filek, k
176 STOP 'in S/R ctrl_unpack'
177 endif
178 read(cunit) (cbuff(ii), ii=1,cbuffindex)
179 endif
180 cbuffindex = 0
181 do jp = 1,nPy
182 do bj = jtlo,jthi
183 do j = jmin,jmax
184 do ip = 1,nPx
185 do bi = itlo,ithi
186 do i = imin,imax
187 if ( globmsk(i,bi,ip,j,bj,jp,k) .ne. 0. ) then
188 cbuffindex = cbuffindex + 1
189 globfld3d(i,bi,ip,j,bj,jp,k) = cbuff(cbuffindex)
190 #ifdef ALLOW_NONDIMENSIONAL_CONTROL_IO
191 globfld3d(i,bi,ip,j,bj,jp,k) =
192 & globfld3d(i,bi,ip,j,bj,jp,k)/
193 # ifdef CTRL_UNPACK_PRECISE
194 & sqrt(weightfld3d(i,bi,ip,j,bj,jp,k))
195 # else
196 & sqrt(weightfld(k,bi,bj))
197 # endif
198 #endif /* ALLOW_NONDIMENSIONAL_CONTROL_IO */
199 else
200 globfld3d(i,bi,ip,j,bj,jp,k) = 0. _d 0
201 endif
202 enddo
203 enddo
204 enddo
205 enddo
206 enddo
207 enddo
208 c
209 enddo
210
211 call MDSWRITEFIELD_3D_GL( fname, ctrlprec, 'RL',
212 & Nr, globfld3d,
213 & irec, optimcycle, mythid)
214
215 enddo
216
217 _END_MASTER( mythid )
218
219 return
220 end
221

  ViewVC Help
Powered by ViewVC 1.1.22