/[MITgcm]/MITgcm_contrib/osse/EnKF/rwObsState3.F
ViewVC logotype

Annotation of /MITgcm_contrib/osse/EnKF/rwObsState3.F

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


Revision 1.3 - (hide annotations) (download)
Wed May 19 15:43:11 2004 UTC (21 years, 2 months ago) by afe
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +0 -0 lines
FILE REMOVED
o refining osse setup

1 afe 1.2 c*** Generates observations from truth
2     subroutine GenObs(eps, mobs,iobsloc,n,ytrue,yobs)
3    
4     implicit none
5    
6     integer, intent(in) :: eps, mobs, iobsloc(mobs), n
7     real*8, intent(in) :: ytrue(n)
8     real*8, intent(out) :: yobs(mobs)
9     integer i, indxa
10     real*8 pert(mobs)
11    
12    
13     end subroutine GenObs
14    
15 afe 1.1 c*** Reads iobsloc
16 afe 1.2 subroutine ReadObsLoc(obsnum,mobs,iobsloc)
17 afe 1.1
18     implicit none
19    
20     integer, intent(in) :: obsnum,mobs
21     integer, intent(out) :: iobsloc(mobs)
22     character*(100) fn
23     real*8 r8seg(mobs)
24     write(fn,'(A,I3.3,A)') '../inits/iobsloc-',obsnum,'.txt'
25     write(*,*) fn
26    
27     open(unit=3,file=fn,status='old')
28 afe 1.2 write(*,*) 'reading...'
29 afe 1.1 read(unit=3,'(1I7)') iobsloc
30 afe 1.2
31 afe 1.1 close(unit=3)
32     call flush()
33 afe 1.2 end subroutine ReadObsLoc
34 afe 1.1
35     c*** Call Model Kludge
36     subroutine Model(mem)
37     implicit none
38     integer, intent(in) :: mem
39     character*(1000) fn
40     write(fn,'(A,I2.2,A)')
41 afe 1.2 & 'cd ../',mem,'/assimilate;../../cylrun/mitgcmuv>& LOG'
42 afe 1.1 call system(fn)
43     end subroutine Model
44    
45     c*** Reads a pickup file...
46    
47     subroutine ReadPickup(mem,n,nx,ny,nz,y)
48    
49     implicit none
50    
51     integer, intent(in) :: mem,n,nx,ny,nz
52     real*8, intent(out) :: y(n)
53     real*8 r8seg(nx)
54     integer i, irec,j,k
55     character*(1024) fn
56     write(fn,'(A,I2.2,A)') '../',mem,'/assimilate/pickup.in'
57 afe 1.2 c write(fn,'(A,I2.2,A)') '../',mem,'/pickup.in'
58 afe 1.1 open(unit=3,file=fn,status='old',
59     & access='direct',recl=nx*8)
60    
61     ccc Set counter for state
62     i =1
63    
64     ccc Reading uVel
65     do k = 1,nz
66     do j = 1,ny
67     irec = (k-1)*ny + j
68     read(3,rec=irec) r8seg
69     call DA_BYTESWAPR8(nx,r8seg)
70     y(i:i+nx-1) = r8seg(1:nx)
71     i = i+nx
72     enddo
73     enddo
74    
75    
76     ccc Skip Next Two gU and gUnm1
77     ccc Read vVel
78     do k = 1,nz
79     do j = 1,ny
80     irec = (k-1)*ny + j + nz*ny*3
81     read(3,rec=irec) r8seg
82     call DA_BYTESWAPR8(nx,r8seg)
83     y(i:i+nx-1) = r8seg(1:nx)
84     i=i+nx
85     enddo
86     enddo
87    
88    
89     ccc Skip Next two gV and gVnm1
90     ccc Read wVel
91     do k = 1,nz
92     do j = 1,ny
93     irec = (k-1)*ny + j + nz*ny*6
94     read(3,rec=irec) r8seg
95     call DA_BYTESWAPR8(nx,r8seg)
96     y(i:i+nx-1) = r8seg(1:nx)
97     i=i+nx
98     enddo
99     enddo
100    
101    
102     ccc Read theta
103     do k = 1,nz
104     do j = 1,ny
105     irec = (k-1)*ny + j + nz*ny*7
106     read(3,rec=irec) r8seg
107     call DA_BYTESWAPR8(nx,r8seg)
108     y(i:i+nx-1) = r8seg(1:nx)
109     i=i+nx
110     enddo
111     enddo
112    
113     ccc Now close the file
114     close(unit=3)
115 afe 1.2
116     #ifdef NONHYDRO
117 afe 1.1 ccc Open Non-Hydrostatic
118     c write(fn,'(A,I2.2,A)') '../',mem,'/assimilate/pickup_nh.in'
119     c open(unit=3,file=fn,
120     c & status='old',access='direct',recl=nx*8)
121    
122     ccc Read pressure Non-hydrostatic
123     c do k = 1,nz
124     c do j = 1,ny
125     c irec = (k-1)*ny + j
126     c read(3,rec=irec) r8seg
127     c call DA_BYTESWAPR8(nx,r8seg)
128     c y(i:i+nx-1) = r8seg(1:nx)
129     c i = i+nx
130     c enddo
131     c enddo
132    
133     c close(unit=3)
134 afe 1.2 #endif
135 afe 1.1 ccc Done Reading State
136     call flush()
137     end subroutine ReadPickup
138    
139     ccc Writes a pickup
140     subroutine WritePickup(mem,n,nx,ny,nz,y)
141    
142     implicit none
143    
144     integer, intent(in) :: mem,n,nx,ny,nz
145     real*8, intent(in) :: y(n)
146     real*8 r8seg(nx)
147     integer i, irec,j,k
148     character*(1000) fni, fno
149     write(fni,'(A,I2.2,A)') '../',mem,'/assimilate/pickup.in'
150     open(unit=3,file=fni,status='old',
151     & access='direct',recl=nx*8)
152     write(fni,'(A,I2.2,A)') '../',mem,'/assimilate/pickup.out'
153     open(unit=4,file=fni,status='unknown',
154     & access='direct',recl=nx*8)
155     ccc Set counter for state
156     i =1
157    
158     ccc Writing uVel
159     do k = 1,nz
160     do j = 1,ny
161     irec = (k-1)*ny + j
162     r8seg(1:nx) = y(i:i+nx-1)
163     call DA_BYTESWAPR8(nx,r8seg)
164     write(4,rec=irec) r8seg
165     i = i+nx
166     enddo
167     enddo
168    
169     ccc Copy gU and gUnm1
170     do k = 1,2*nz
171     do j = 1,ny
172     irec = (k-1)*ny + j+nz*ny
173     read(3,rec=irec) r8seg
174     write(4,rec=irec) r8seg
175     enddo
176     enddo
177     ccc Writing vVel
178     do k = 1,nz
179     do j = 1,ny
180     irec = (k-1)*ny + j + nz*ny*3
181     r8seg(1:nx) = y(i:i+nx-1)
182     call DA_BYTESWAPR8(nx,r8seg)
183     write(4,rec=irec) r8seg
184     i=i+nx
185     enddo
186     enddo
187    
188     ccc copy Next two gV and gVnm1
189     do k = 1,2*nz
190     do j = 1,ny
191     irec = (k-1)*ny + j+nz*ny*4
192     read(3,rec=irec) r8seg
193     write(4,rec=irec) r8seg
194     enddo
195     enddo
196     ccc Write wVel and Theta
197     do k = 1,2*nz
198     do j = 1,ny
199     irec = (k-1)*ny + j + nz*ny*6
200     r8seg(1:nx) = y(i:i+nx-1)
201     call DA_BYTESWAPR8(nx,r8seg)
202     write(4,rec=irec) r8seg
203     i=i+nx
204     enddo
205     enddo
206     ccc Copy Remaining fields
207     do k = 1,5*nz
208     do j = 1,ny
209     irec = (k-1)*ny + j+nz*ny*8
210     read(3,rec=irec) r8seg
211     write(4,rec=irec) r8seg
212     enddo
213     enddo
214     do j = 1,ny
215     irec = j+13*nz*ny
216     read(3,rec=irec) r8seg
217     write(4,rec=irec) r8seg
218     enddo
219    
220     ccc Now close the file
221     close(unit=3)
222     close(unit=4)
223    
224 afe 1.2 #ifdef NONHYDRO
225 afe 1.1 ccc Open Non-Hydrostatic
226     write(fni,'(A,I2.2,A)') '../',mem,'/assimilate/pickup_nh.in'
227     open(unit=3,file=fni,
228     & status='old',access='direct',recl=nx*8)
229     write(fni,'(A,I2.2,A)') '../',mem,'/assimilate/pickup_nh.out'
230     open(unit=4,file=fni,status='unknown',
231     & access='direct',recl=nx*8)
232    
233     ccc Write pressure Non-hydrostatic from State
234     c do k = 1,nz
235     c do j = 1,ny
236     c irec = (k-1)*ny + j
237     c r8seg(1:nx) = y(i:i+nx-1)
238     c call DA_BYTESWAPR8(nx,r8seg)
239     c write(4,rec=irec) r8seg
240     c i = i+nx
241     c enddo
242     c enddo
243     ccc Write out other fields
244     do k = 1,2*nz
245     do j = 1,ny
246     irec = (k-1)*ny + j
247     read(3,rec=irec) r8seg
248     write(4,rec=irec) r8seg
249     enddo
250     enddo
251    
252     c close(unit=3)
253     c close(unit=4)
254 afe 1.2 #endif
255 afe 1.1 ccc Done Reading State
256     call flush()
257     end subroutine WritePickup
258    
259    
260    
261    
262     subroutine loadMask(mask,nx,ny)
263     implicit none
264     integer, intent(in) :: nx, ny
265     real*4, intent(out) :: mask(ny,nx)
266     real*4 r4seg(nx)
267     integer i, irec,j,k
268     character*(1000) fni, fno
269    
270     write(fni,'(A)') '../inits/bathy61.bin'
271    
272     open(unit=3,file=fni,
273     & status='old',access='direct',recl=nx*4)
274    
275     do j = 1,ny
276     irec = j
277     read(3,rec=irec) r4seg
278     call DA_BYTESWAPR4(nx,r4seg)
279     mask(j,1:nx) = r4seg(1:nx)
280     enddo
281     close(unit=3)
282     call flush()
283     end subroutine loadMask
284    
285     subroutine DA_BYTESWAPR8( na, arr )
286     C IN:
287     C n integer - Number of 8-byte words in arr
288     C IN/OUT:
289     C arr real*8 - Array declared as real*4(n)
290     C
291     C Created: 05/05/99 adcroft@mit.edu (This is an unfortunate hack!!)
292    
293     implicit none
294     C Arguments
295     integer na
296     character*(*) arr
297     C Local
298     integer i
299     character*(1) cc
300     C ------------------------------------------------------------------
301     do i=1,8*na,8
302     cc=arr(i:i)
303     arr(i:i)=arr(i+7:i+7)
304     arr(i+7:i+7)=cc
305     cc=arr(i+1:i+1)
306     arr(i+1:i+1)=arr(i+6:i+6)
307     arr(i+6:i+6)=cc
308     cc=arr(i+2:i+2)
309     arr(i+2:i+2)=arr(i+5:i+5)
310     arr(i+5:i+5)=cc
311     cc=arr(i+3:i+3)
312     arr(i+3:i+3)=arr(i+4:i+4)
313     arr(i+4:i+4)=cc
314     enddo
315     C ------------------------------------------------------------------
316     return
317     end
318     C==========================
319    
320    
321     C=======================================================================
322     subroutine DA_BYTESWAPR4( n, arr )
323     C IN:
324     C n integer - Number of 4-byte words in arr
325     C IN/OUT:
326     C arr real*4 - Array declared as real*4(n)
327     C
328     C Created: 05/05/99 adcroft@mit.edu (This is an unfortunate hack!!)
329    
330     implicit none
331     C Arguments
332     integer n
333     character*(*) arr
334     C Local
335     integer i
336     character*(1) cc
337     C ------------------------------------------------------------------
338     do i=1,4*n,4
339     cc=arr(i:i)
340     arr(i:i)=arr(i+3:i+3)
341     arr(i+3:i+3)=cc
342     cc=arr(i+1:i+1)
343     arr(i+1:i+1)=arr(i+2:i+2)
344     arr(i+2:i+2)=cc
345     enddo
346     C ------------------------------------------------------------------
347     return
348     end
349     C=======================================================================
350    
351    
352    
353    
354    
355    

  ViewVC Help
Powered by ViewVC 1.1.22