- #1
shitij
- 19
- 0
Hi all !
This is a weird problem. A simple program to read a file and display it works differently when compiled with different versions of the same compiler.
When I compile it as:
garbageij@garbageij:~/NMA$ mpif90 exp4.f90
and run it, it gives the correct output. But when I compile it as:
garbageij@garbageij:~/NMA$ /home/garbageij/Lib/MPI/mpich2-1.3.2/bin/mpif90 exp4.f90
and run it, the output is incorrect. Like a few lines are missing altogether, some lines are read half-way, for example:
The line
is always read as
.
Please note that in the actual program I am using some libraries (PETSc/SLEPc) which are configured to use the second version of the compiler. So I can't just use a different compiler and get it over with.
Also, it seems as if the discrepancies in output also remain the same after any compile-->run, so it probably isn't some random occurrence. Also, I re-installed MPICH2 in another directory, and if I use that version's mpif90, the problem remains the same. (even the discrepancy in the output remains the same)
I am giving the code below:
I am totally clueless. Any ideas?
EDIT: I just remembered that MPICH2 is configured to use ifort only. When I compiled it with ifort and ran it, it really was giving incorrect output ! When I compiled it with gfortran, the output was fine. Is this some sort of bug with ifort?
This is a weird problem. A simple program to read a file and display it works differently when compiled with different versions of the same compiler.
When I compile it as:
garbageij@garbageij:~/NMA$ mpif90 exp4.f90
and run it, it gives the correct output. But when I compile it as:
garbageij@garbageij:~/NMA$ /home/garbageij/Lib/MPI/mpich2-1.3.2/bin/mpif90 exp4.f90
and run it, the output is incorrect. Like a few lines are missing altogether, some lines are read half-way, for example:
The line
Code:
ATOM NE2 NR2 -0.70
Code:
ATOM NE2 -0.70
Please note that in the actual program I am using some libraries (PETSc/SLEPc) which are configured to use the second version of the compiler. So I can't just use a different compiler and get it over with.
Also, it seems as if the discrepancies in output also remain the same after any compile-->run, so it probably isn't some random occurrence. Also, I re-installed MPICH2 in another directory, and if I use that version's mpif90, the problem remains the same. (even the discrepancy in the output remains the same)
I am giving the code below:
Code:
program exp4
implicit none
character(79)::line
open(unit=1,file='top_all27_prot_na_RTF.txt',action='read',ACCESS='STREAM',FORM='FORMATTED')
do
read(1,'(a)',END=10)line ! Read line as string
write(*,*)line
enddo
10 write(*,*)'Done !'
end program exp4
I am totally clueless. Any ideas?
EDIT: I just remembered that MPICH2 is configured to use ifort only. When I compiled it with ifort and ran it, it really was giving incorrect output ! When I compiled it with gfortran, the output was fine. Is this some sort of bug with ifort?
Last edited: