I am trying to run a program wrote in fortran where the subroutine has been compiled with gfortran and the main program has been compiled with ifort:
Here the source code:
subroutine testsub
implicit none
integer icarte
read(10,*) icarte
write(*,*)icarte
return
end`
program test
implicit none
integer i
open (unit=10, file="file_test")
do i=1,6
read(10,*)
enddo
call testsub
close(10)
end
1
2
3
4
5
6
7 5 6 8
23
And then I compile like that:
gfortran -c testsub.f
ar rcs libtest.a testsub.o
ifort -o testexe test.f -L./ -ltest -L/.../gcc/4.7.1/lib64 -lgfortran
and I obtained:
At line 4 of file testsub.f (unit = 10, file = 'fort.10')
Fortran runtime error: End of file
It looks like the logical unit was not given to the subroutine. I should add a compilation option somewhere... but I don't really know what and where... And to respond to the question "what happens if I compile both files with the same compiler ?" : the program runs perfectly :)
So if anyone as any idea...
This won't work. When you open the file in the main program, somewhere in the bowels of the ifort library the file will be opened and some state associated with it stored. GFortran knows nothing about the internal state of the ifort runtime library, and tries to look up the unit in its own runtime library state, which obviously fails.