Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

open files

p_ackerer
Beginner
671 Views

Hi,
I had some troubles with file opening (see below).
Can you tell me why options 2 & 3 are not working ?
Thanks

Have a nice day,
Philippe

!

implicit none

INTEGER :: i,n,ind,opt

character (LEN=15) :: fichier,fich

fichier='test_o'

!

n=75000

write(*,*) ' Select option:'

read(*,*) opt

!

do i=1,N

write(*,*) ' Start',i,n

if(opt==1) open(15,file='test_o.dat',status='old') ! ok

if(opt==2) open(15,file=TRIM(fichier)//'.dat',status='old') ! program ends at i= 63913

if(opt==3) then ! program ends at i= 63913

ind=index(fichier,' ')-1

open(15, FILE=fichier(1:ind)//'.dat',status='old')

endif

if(opt==4) then ! ok

fich=TRIM(fichier)//'.dat'

open(15,file=fich,status='old')

endif

close(15)

write(*,*) ' end do'

enddo

stop

!

END PROGRAM test_o

0 Kudos
2 Replies
tropfen
New Contributor I
671 Views
Hello Philippe,

with option 2 & 3 you using the open command to construct the file name. For this the stack is used and every time a bit more. It ends with an not shown stack overflow. This bug is old. (http://redfort-software.intel.com/en-us/forums/showthread.php?t=42116&o=a&s=lr).

To solve the problem you have to construct the file name in advance:


character(len=400) :: filename

filename=''
filename=TRIM(fichier)//'.dat'
open(15,file=filename,status='old')


This problem should be solved with IVF 12 Update 2 (see http://redfort-software.intel.com/en-us/forums/showthread.php?t=77857)

Frank
0 Kudos
p_ackerer
Beginner
671 Views
Thanks Frank for your answer.
What had troubled me is that no debug option is able to detect the problem...
Philippe
0 Kudos
Reply