HI guys
when i run my fortran code . the memory get less and less and finely run out . i'm not family with memory work .here is my code :
program rfcor
character*32,dimension(20,160)::synfile
character*32 syn,synname,obspath,filepath
character*64 outpath
character*32,dimension(3329):bsfile
character*32,dimension(300)::filename
* real,dimension(3500)::syndata,obsdata
real,allocatable,dimension)::syndata,obsdata
integer ni,nj,filenum,num
integer,dimension(20,160)::corr
syn='syndata/data.txt'
open(300,file=syn)
do i=1,20
do j=1,160
read(300,*,end=600)synfile(i,j)
end do
end do
600 continue
open(400,file='list.txt')
read(400,*)obsfile
*******************************************************
*up read station name
********************************************************
do ni=1,3329
obspath=trim(obsfile(ni))//'/data.txt'
* print*,obspath
open(401,file=obspath)
num=0
filename=''
do while(.true.)
num=num+1
read(401,*,end=500)filename(num)
end do
500 continue
print*,num
filenum=num-1
* print*,filenum
******************************************************
*read event name
******************************************************
do nj=1,filenum
filepath=trim(obsfile(ni))//'/'//trim(filename(nj))
print*,filepath
allocate(obsdata(3500))
obsdata=''
print*,obsdata
open(402,file=filepath)
read(402,*)(obsdata(nk),nk=1,3500)
* print*,size(obsdata)
program rfcor
character*32,dimension(20,160)::synfile
character*32 syn,synname,obspath,filepath
character*64 outpath
character*32,dimension(3329):bsfile
character*32,dimension(300)::filename
* real,dimension(3500)::syndata,obsdata
real,allocatable,dimension)::syndata,obsdata
integer ni,nj,filenum,num
integer,dimension(20,160)::corr
syn='syndata/data.txt'
open(300,file=syn)
do i=1,20
do j=1,160
read(300,*,end=600)synfile(i,j)
end do
end do
600 continue
open(400,file='list.txt')
read(400,*)obsfile
*******************************************************
*up read station name
********************************************************
do ni=1,3329
obspath=trim(obsfile(ni))//'/data.txt'
* print*,obspath
open(401,file=obspath)
num=0
filename=''
do while(.true.)
num=num+1
read(401,*,end=500)filename(num)
end do
500 continue
print*,num
filenum=num-1
* print*,filenum
******************************************************
*read event name
******************************************************
do nj=1,filenum
filepath=trim(obsfile(ni))//'/'//trim(filename(nj))
print*,filepath
allocate(obsdata(3500))
obsdata=''
print*,obsdata
open(402,file=filepath)
read(402,*)(obsdata(nk),nk=1,3500)
* print*,size(obsdata)
***********************************************************
*read syn data
************************************************************
do i =1,20
do j=1,160
synname='syndata/'//synfile(i,j)
* print*,synname
allocate(syndata(3500))
syndata=''
open(301,file=synname)
read(301,*)(syndata(k),k=1,3500)
* print*,'syndata'
* print*,size(syndata)
corr(i,j)=sum(obsdata*syndata)
deallocate(syndata)
end do
end do
deallocate(obsdata)
************************************************************
*write result in to txt file
***********************************************************
outpath=filepath//'rfcor.txt'
print*,outpath
open(700,file=outpath,action='write')
do i=1,20
write(700,*)(corr(i,j),j=1,160)
end do
end do
end do
end program rfcor
i only give one variable and overwrite in loop . but this take more and more memory . anybody know about this problem
thaks a lot
when i run my fortran code . the memory get less and less and finely run out . i'm not family with memory work .here is my code :
program rfcor
character*32,dimension(20,160)::synfile
character*32 syn,synname,obspath,filepath
character*64 outpath
character*32,dimension(3329):bsfile
character*32,dimension(300)::filename
* real,dimension(3500)::syndata,obsdata
real,allocatable,dimension)::syndata,obsdata
integer ni,nj,filenum,num
integer,dimension(20,160)::corr
syn='syndata/data.txt'
open(300,file=syn)
do i=1,20
do j=1,160
read(300,*,end=600)synfile(i,j)
end do
end do
600 continue
open(400,file='list.txt')
read(400,*)obsfile
*******************************************************
*up read station name
********************************************************
do ni=1,3329
obspath=trim(obsfile(ni))//'/data.txt'
* print*,obspath
open(401,file=obspath)
num=0
filename=''
do while(.true.)
num=num+1
read(401,*,end=500)filename(num)
end do
500 continue
print*,num
filenum=num-1
* print*,filenum
******************************************************
*read event name
******************************************************
do nj=1,filenum
filepath=trim(obsfile(ni))//'/'//trim(filename(nj))
print*,filepath
allocate(obsdata(3500))
obsdata=''
print*,obsdata
open(402,file=filepath)
read(402,*)(obsdata(nk),nk=1,3500)
* print*,size(obsdata)
program rfcor
character*32,dimension(20,160)::synfile
character*32 syn,synname,obspath,filepath
character*64 outpath
character*32,dimension(3329):bsfile
character*32,dimension(300)::filename
* real,dimension(3500)::syndata,obsdata
real,allocatable,dimension)::syndata,obsdata
integer ni,nj,filenum,num
integer,dimension(20,160)::corr
syn='syndata/data.txt'
open(300,file=syn)
do i=1,20
do j=1,160
read(300,*,end=600)synfile(i,j)
end do
end do
600 continue
open(400,file='list.txt')
read(400,*)obsfile
*******************************************************
*up read station name
********************************************************
do ni=1,3329
obspath=trim(obsfile(ni))//'/data.txt'
* print*,obspath
open(401,file=obspath)
num=0
filename=''
do while(.true.)
num=num+1
read(401,*,end=500)filename(num)
end do
500 continue
print*,num
filenum=num-1
* print*,filenum
******************************************************
*read event name
******************************************************
do nj=1,filenum
filepath=trim(obsfile(ni))//'/'//trim(filename(nj))
print*,filepath
allocate(obsdata(3500))
obsdata=''
print*,obsdata
open(402,file=filepath)
read(402,*)(obsdata(nk),nk=1,3500)
* print*,size(obsdata)
***********************************************************
*read syn data
************************************************************
do i =1,20
do j=1,160
synname='syndata/'//synfile(i,j)
* print*,synname
allocate(syndata(3500))
syndata=''
open(301,file=synname)
read(301,*)(syndata(k),k=1,3500)
* print*,'syndata'
* print*,size(syndata)
corr(i,j)=sum(obsdata*syndata)
deallocate(syndata)
end do
end do
deallocate(obsdata)
************************************************************
*write result in to txt file
***********************************************************
outpath=filepath//'rfcor.txt'
print*,outpath
open(700,file=outpath,action='write')
do i=1,20
write(700,*)(corr(i,j),j=1,160)
end do
end do
end do
end program rfcor
i only give one variable and overwrite in loop . but this take more and more memory . anybody know about this problem
thaks a lot