MPIF90 running error “bad value during integer read”










1















There is a problem when I use the mpif90 compiler that complains that 'bad value during integer read'. However, when I use the gfortran compiler, there is no problem.



The gfortran version is



program main
implicit none
character*100 :: line
integer :: ierr, i
open(10, file="test.txt", action="read")
read(10, '(A)' ,iostat=ierr) line
read(line, "(6X, I5)") i
print*, i
end program


The mpif90 version is



program main
implicit none
include "mpif.h"
character*100 :: line
integer :: ierr, i, procID

call mpi_init(ierr)
call mpi_comm_rank(mpi_comm_world,procID,ierr)
if (procID==0) then
open(10, file="test.txt", action="read")
read(10, '(A)' ,iostat=ierr) line
read(line, "(6X, I5)") i
print*, i
endif
call mpi_finalize(ierr)
endprogram


the test.txt file contains that



TEST 1


  1. The gfortran version gives correct answer 1


  2. mpif90 version uses mpif90 compiler to compile the program and use mpirun -n 4 ./a.out to run the program the outcome is


    At line 12 of file read.f90

    Fortran runtime error: Bad value during integer read




Why there is such a problem? Can anyone fix this?










share|improve this question






















  • mpif90 might be anything. It is just a wrapper around some compiler. Please tell use which compiler it is. What does mpif90 -v return? Which MPI library have you installed?

    – Vladimir F
    Nov 14 '18 at 9:05











  • You are using iostat=ierr, but then you are not checking the value of ierr. You can't do that. Either remove the iostat or do check the value returned.

    – Vladimir F
    Nov 14 '18 at 9:07












  • mpif90 -v returns that "mpifort for MPICH version 3.2 gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3)"

    – Haomiao.Zhang
    Nov 14 '18 at 10:42












  • Thanks, I get it. I have used the anaconda's mpif90 which cause such problem. After reinstall MPICH, the problem is fixed. But I don't understand why anaconda's mpi could cause such problem.

    – Haomiao.Zhang
    Nov 14 '18 at 10:57
















1















There is a problem when I use the mpif90 compiler that complains that 'bad value during integer read'. However, when I use the gfortran compiler, there is no problem.



The gfortran version is



program main
implicit none
character*100 :: line
integer :: ierr, i
open(10, file="test.txt", action="read")
read(10, '(A)' ,iostat=ierr) line
read(line, "(6X, I5)") i
print*, i
end program


The mpif90 version is



program main
implicit none
include "mpif.h"
character*100 :: line
integer :: ierr, i, procID

call mpi_init(ierr)
call mpi_comm_rank(mpi_comm_world,procID,ierr)
if (procID==0) then
open(10, file="test.txt", action="read")
read(10, '(A)' ,iostat=ierr) line
read(line, "(6X, I5)") i
print*, i
endif
call mpi_finalize(ierr)
endprogram


the test.txt file contains that



TEST 1


  1. The gfortran version gives correct answer 1


  2. mpif90 version uses mpif90 compiler to compile the program and use mpirun -n 4 ./a.out to run the program the outcome is


    At line 12 of file read.f90

    Fortran runtime error: Bad value during integer read




Why there is such a problem? Can anyone fix this?










share|improve this question






















  • mpif90 might be anything. It is just a wrapper around some compiler. Please tell use which compiler it is. What does mpif90 -v return? Which MPI library have you installed?

    – Vladimir F
    Nov 14 '18 at 9:05











  • You are using iostat=ierr, but then you are not checking the value of ierr. You can't do that. Either remove the iostat or do check the value returned.

    – Vladimir F
    Nov 14 '18 at 9:07












  • mpif90 -v returns that "mpifort for MPICH version 3.2 gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3)"

    – Haomiao.Zhang
    Nov 14 '18 at 10:42












  • Thanks, I get it. I have used the anaconda's mpif90 which cause such problem. After reinstall MPICH, the problem is fixed. But I don't understand why anaconda's mpi could cause such problem.

    – Haomiao.Zhang
    Nov 14 '18 at 10:57














1












1








1








There is a problem when I use the mpif90 compiler that complains that 'bad value during integer read'. However, when I use the gfortran compiler, there is no problem.



The gfortran version is



program main
implicit none
character*100 :: line
integer :: ierr, i
open(10, file="test.txt", action="read")
read(10, '(A)' ,iostat=ierr) line
read(line, "(6X, I5)") i
print*, i
end program


The mpif90 version is



program main
implicit none
include "mpif.h"
character*100 :: line
integer :: ierr, i, procID

call mpi_init(ierr)
call mpi_comm_rank(mpi_comm_world,procID,ierr)
if (procID==0) then
open(10, file="test.txt", action="read")
read(10, '(A)' ,iostat=ierr) line
read(line, "(6X, I5)") i
print*, i
endif
call mpi_finalize(ierr)
endprogram


the test.txt file contains that



TEST 1


  1. The gfortran version gives correct answer 1


  2. mpif90 version uses mpif90 compiler to compile the program and use mpirun -n 4 ./a.out to run the program the outcome is


    At line 12 of file read.f90

    Fortran runtime error: Bad value during integer read




Why there is such a problem? Can anyone fix this?










share|improve this question














There is a problem when I use the mpif90 compiler that complains that 'bad value during integer read'. However, when I use the gfortran compiler, there is no problem.



The gfortran version is



program main
implicit none
character*100 :: line
integer :: ierr, i
open(10, file="test.txt", action="read")
read(10, '(A)' ,iostat=ierr) line
read(line, "(6X, I5)") i
print*, i
end program


The mpif90 version is



program main
implicit none
include "mpif.h"
character*100 :: line
integer :: ierr, i, procID

call mpi_init(ierr)
call mpi_comm_rank(mpi_comm_world,procID,ierr)
if (procID==0) then
open(10, file="test.txt", action="read")
read(10, '(A)' ,iostat=ierr) line
read(line, "(6X, I5)") i
print*, i
endif
call mpi_finalize(ierr)
endprogram


the test.txt file contains that



TEST 1


  1. The gfortran version gives correct answer 1


  2. mpif90 version uses mpif90 compiler to compile the program and use mpirun -n 4 ./a.out to run the program the outcome is


    At line 12 of file read.f90

    Fortran runtime error: Bad value during integer read




Why there is such a problem? Can anyone fix this?







fortran mpi






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 14 '18 at 7:46









Haomiao.ZhangHaomiao.Zhang

82




82












  • mpif90 might be anything. It is just a wrapper around some compiler. Please tell use which compiler it is. What does mpif90 -v return? Which MPI library have you installed?

    – Vladimir F
    Nov 14 '18 at 9:05











  • You are using iostat=ierr, but then you are not checking the value of ierr. You can't do that. Either remove the iostat or do check the value returned.

    – Vladimir F
    Nov 14 '18 at 9:07












  • mpif90 -v returns that "mpifort for MPICH version 3.2 gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3)"

    – Haomiao.Zhang
    Nov 14 '18 at 10:42












  • Thanks, I get it. I have used the anaconda's mpif90 which cause such problem. After reinstall MPICH, the problem is fixed. But I don't understand why anaconda's mpi could cause such problem.

    – Haomiao.Zhang
    Nov 14 '18 at 10:57


















  • mpif90 might be anything. It is just a wrapper around some compiler. Please tell use which compiler it is. What does mpif90 -v return? Which MPI library have you installed?

    – Vladimir F
    Nov 14 '18 at 9:05











  • You are using iostat=ierr, but then you are not checking the value of ierr. You can't do that. Either remove the iostat or do check the value returned.

    – Vladimir F
    Nov 14 '18 at 9:07












  • mpif90 -v returns that "mpifort for MPICH version 3.2 gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3)"

    – Haomiao.Zhang
    Nov 14 '18 at 10:42












  • Thanks, I get it. I have used the anaconda's mpif90 which cause such problem. After reinstall MPICH, the problem is fixed. But I don't understand why anaconda's mpi could cause such problem.

    – Haomiao.Zhang
    Nov 14 '18 at 10:57

















mpif90 might be anything. It is just a wrapper around some compiler. Please tell use which compiler it is. What does mpif90 -v return? Which MPI library have you installed?

– Vladimir F
Nov 14 '18 at 9:05





mpif90 might be anything. It is just a wrapper around some compiler. Please tell use which compiler it is. What does mpif90 -v return? Which MPI library have you installed?

– Vladimir F
Nov 14 '18 at 9:05













You are using iostat=ierr, but then you are not checking the value of ierr. You can't do that. Either remove the iostat or do check the value returned.

– Vladimir F
Nov 14 '18 at 9:07






You are using iostat=ierr, but then you are not checking the value of ierr. You can't do that. Either remove the iostat or do check the value returned.

– Vladimir F
Nov 14 '18 at 9:07














mpif90 -v returns that "mpifort for MPICH version 3.2 gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3)"

– Haomiao.Zhang
Nov 14 '18 at 10:42






mpif90 -v returns that "mpifort for MPICH version 3.2 gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3)"

– Haomiao.Zhang
Nov 14 '18 at 10:42














Thanks, I get it. I have used the anaconda's mpif90 which cause such problem. After reinstall MPICH, the problem is fixed. But I don't understand why anaconda's mpi could cause such problem.

– Haomiao.Zhang
Nov 14 '18 at 10:57






Thanks, I get it. I have used the anaconda's mpif90 which cause such problem. After reinstall MPICH, the problem is fixed. But I don't understand why anaconda's mpi could cause such problem.

– Haomiao.Zhang
Nov 14 '18 at 10:57













0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53295277%2fmpif90-running-error-bad-value-during-integer-read%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53295277%2fmpif90-running-error-bad-value-during-integer-read%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kleinkühnau

Makov (Slowakei)

Deutsches Schauspielhaus