- #1
Giammy85
- 19
- 0
I'm try to read some files in subdirectories and create some other files in my present location:
program multiread
!
implicit none
!variables
integer :: n, k, i
integer :: j, m2
real(8) :: pratio, crap, rmsttv
character(len=42) :: filein(98)
character(len=10) :: fileout(14)
character (LEN=26) :: path
character(len=2) number, mass
j = 1
do i=0, 6
m2=5*i
if (m2==0) then
m2=1
end if
write(mass,998) m2
998 format(i2.2)
write(*,*) j
fileout(i)=mass//'_000.dat'
write(*,*) fileout(i),j
open(unit=i+10,file=fileout(i),status='replace',access="append")
! write(*,*) j
do n=0,6
pratio=1.5+0.25*n
! write(*,*) pratio
write(number,998) j
! write(*,*) j
! 999 format(i2.2)
write(*,*) number
path='/scratch/project3/set1/'//number//'/'
filein(j)=path//'periodrmsttv.dat'
write(*,*) filein(j)
open(unit=j+40,file=filein(j),status='old')
read (j+40,*) crap
read (j+40, '(f14.6)') rmsttv
write (i+10,'(f4.2,f14.6)') pratio, rmsttv
close (j+40)
j=j+2
end do
close (i+10)
end do
end program multiread
I receive a segmentation fault message: debugging I have found the value of j change from 1 to a random number just after having defined fileout(i)=mass//'_000.dat'
How to solve this problem?
Thanks
program multiread
!
implicit none
!variables
integer :: n, k, i
integer :: j, m2
real(8) :: pratio, crap, rmsttv
character(len=42) :: filein(98)
character(len=10) :: fileout(14)
character (LEN=26) :: path
character(len=2) number, mass
j = 1
do i=0, 6
m2=5*i
if (m2==0) then
m2=1
end if
write(mass,998) m2
998 format(i2.2)
write(*,*) j
fileout(i)=mass//'_000.dat'
write(*,*) fileout(i),j
open(unit=i+10,file=fileout(i),status='replace',access="append")
! write(*,*) j
do n=0,6
pratio=1.5+0.25*n
! write(*,*) pratio
write(number,998) j
! write(*,*) j
! 999 format(i2.2)
write(*,*) number
path='/scratch/project3/set1/'//number//'/'
filein(j)=path//'periodrmsttv.dat'
write(*,*) filein(j)
open(unit=j+40,file=filein(j),status='old')
read (j+40,*) crap
read (j+40, '(f14.6)') rmsttv
write (i+10,'(f4.2,f14.6)') pratio, rmsttv
close (j+40)
j=j+2
end do
close (i+10)
end do
end program multiread
I receive a segmentation fault message: debugging I have found the value of j change from 1 to a random number just after having defined fileout(i)=mass//'_000.dat'
How to solve this problem?
Thanks