I tried the short program attached on various Sun machines:
it runs on 4 but crashes on 3; in subroutine write_file.
Q1. Is the program conforming with the F90 standard?
Q2. Any idea why it crashes?
thanks in advance for your help.
Lambert Assamoi
program test
implicit none
integer :: nf6,l1,nelemz,error,merror,real_byte
character*256 :: scr_string,scr2
scr_string='./'
scr2=trim(scr_string)//'zz_2'
! open(8,file='bug.in',status='old')
! rewind 8
open(9,file='bug.out',status='unknown')
rewind 9
write(9,*)
write(9,*)'file string: ',trim(scr2)
write(9,*)
write(*,*)'file string: ',trim(scr2)
! initialization
nelemz=10
l1=171
real_byte=8
error=0
merror=0
write(*,*)'please provide a positive value for unit nf6
&- bigger than 9'
read(*,*) nf6
if(nf6 < 10) nf6=93
open(nf6,file=scr2(1:len_trim(scr2)),access='direct',
& recl=(l1*real_byte),iostat=error,action='readwrite')
if(error /= 0) merror=811
write(*,*)'after opening file nf6, merror = ',merror
if(merror /= 0 ) then
write(9,*)
write(9,*)'error while attempting to open a file'
write(9,*) ' file # ',nf6
write(9,*)
write(*,*)'run was stopped'
stop
endif
call write_file(nelemz,nf6)
call read_file(nelemz,nf6)
close(nf6,status='delete')
end program test
subroutine write_file(nelemz,nf6)
implicit none
integer :: nelem,i,nelemz,l1,nf6,error,merror
doubleprecision :: skn(171)
error=0
merror=0
l1=171
skn=0.0d0
! test write for confirmation
write(nf6,rec=1,iostat=error) (skn(i),i=1,l1)
if(error /= 0) then
write(9,*)
write(9,*)' error in writing to nf6'
write(9,*) ' merror =',error
write(9,*)
write(*,*)' error in writing to nf6'
write(*,*) ' merror =',error
write(*,*)'run was stopped'
stop
endif
skn=1.0d0
do nelem=1,nelemz
write(*,*)' index # ',nelem
write(nf6,rec=nelem) (skn(i),i=1,l1)
enddo
end subroutine write_file
subroutine read_file(nelemz,nf6)
implicit none
integer:: i,nelem,nelemz,nf6,l1
double precision:: elpa(300)
l1= 171
write(9,*)'elpa is next'
write(9,*)
do nelem=1,nelemz
read(nf6,rec=nelem) (elpa(i),i=1,l1)
write(9,*) nelem
enddo
end subroutine read_file
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|