comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Why this loop does not work?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Why this loop does not work? [message #63837] Thu, 20 November 2008 12:29
xiao zhang is currently offline  xiao zhang
Messages: 81
Registered: June 2008
Member
Hi~ everyone, I have a short program like this. But there are some
bugs in it that I cannot open all the files in the loop. Anyone got an
idea why is that? Thank you very much :)

pro read_rams,fulnam,vname,nvars,data,kx,ky,kz

vname =['UP','VP','WP','THETA']
hh=
['00','01','02','03','04','05','06','07','08','09','10','11' ,'12','13','14','15','16','17','18','19','20','21','22','23' ]
mm=['00','15','30','45']
ss='00'

; timestep

nvars=4 ; number of varible

dirnm='test8/anal/' ;/* print to string 'dirnm' */
filehd='a-A-A-2005-12-'
filend='-g4.h5'

for j=0,23 do begin ; ---------------This loop this loop works
here, all the file names are correct :(
for k=0,3 do begin ; ---------------This loop this loop works
here, all the file names are correct :(

fulnam=dirnm+filehd+'17-'+hh(j)+mm(k)+ss+filend

openw,3,'data.txt'

file_id = H5F_open(fulnam)

if file_id ge 0 then begin
for iv=0, nvars-1 do begin


dataset_id = H5D_open(file_id, vname(iv)) ;/* Open existing
dataset. but only opend one file*/
print,file_id
rdata = H5D_read(dataset_id)
dataspace_id = H5D_GET_SPACE(dataset_id)
dimensions = H5S_GET_SIMPLE_EXTENT_DIMS(dataspace_id)
simspc = H5S_IS_SIMPLE(Dataspace_id)

if iv eq 0 then begin
kz=dimensions(0)
ky=dimensions(1)
kx=dimensions(2)
data=fltarr(kx,ky,kz,nvars)

endif

ntot=long(kx)*ky*kz
a=fltarr(ntot) ;introduce "a" to redistribute the data
a(*)=rdata

ii=-1L
for k=0,kz-1 do begin
for j=0,ky-1 do begin
for i=0,kx-1 do begin
ii=ii+1
data(i,j,k,iv)=a(ii)
endfor
endfor
endfor
print,'pocessing varible is ',vname(iv)
printf,3,data

H5S_CLOSE, dataspace_id
H5D_close,dataset_id ;/* Close the dataset. */
endfor
H5F_close,file_id ;/* Close the file. */
endif
print,'finishing process file ',fulnam

endfor ; ---------------This loop does not work, only processed
the first file :(
endfor ; ---------------This loop does not work, only processed
the first file :(

close,3
a=0.
end
[Message index]
 
Read Message
Previous Topic: Can I use array elements of a pointer like a regular array?
Next Topic: Re: Why this loop does not work?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 20:02:01 PDT 2025

Total time taken to generate the page: 0.45072 seconds