[mpich-discuss] gfortran and mpich2 interaction

jdelia at intec.unl.edu.ar jdelia at intec.unl.edu.ar
Fri May 9 16:12:13 CDT 2008


Hi Anthony,

Thank you for your really quick and precise feedback!

Your suggestion about to use "call flush (6)" works very nice. I only  
have to change to the gfortran flag "-std=gnu". The fixed sample  
program is included at the end of this reply.

Regards,
Jorge.

---
Anthony Chan <chan at mcs.anl.gov> ha escrito:

> Did you try putting a flush() statement before the read() ?
> BTW, I would think that it is more portable to read data
> from a file than from stdin.
>
> A.Chan


! -----------------------------------------------------------------
! MPICH2
!  which mpif90
!  mpif90 --version
!  mpif90 -Wall -std=gnu -fPIC -o testinputmpi.exe testinputmpi.f90
!  mpdboot -n 5 -f ~/mpd.hosts
!  mpdtrace
!  mpdringtest
!  mpiexec -machinefile ~/machi.dat -np 2 testinputmpi.exe
!  mpdallexit
!
! -----------------------------------------------------------------
program testinputmpi
   use mpi
   implicit none
   integer :: myid, siza, ierr, master=0, n
   !
   call MPI_Init (ierr)
   call MPI_Comm_size (MPI_COMM_WORLD, siza, ierr) ! number of processes
   call MPI_Comm_rank (MPI_COMM_WORLD, myid, ierr) ! my rank
   !
   if (myid == master) then
     ! alternative 1
     write (*,*)
     write (*,*) " matrix rank ; n : ? "
     call flush (6)
     read  (*,*) n
     write (*,*) " matrix rank ; n = ", n
     ! alternative 2
     write (6,*)
     write (6,*) " matrix rank ; n : ? "
     call flush (6)
     read  (5,*) n
     write (6,*) " matrix rank ; n = ", n
     ! alternative 3
     print  *
     print  *,   " matrix rank ; n : ? "
     call flush (6)
     read  (*,*) n
     print  *,   " matrix rank ; n = ", n
   else
     write (*,*) "hellow from ", myid, " of ", siza, "processes"
   end if
   !
   call MPI_Finalize (ierr)
   !
end program
! -------------------------------------------------------------------
$ mpiexec -machinefile ~/machi.dat -np 2 testinputmpi.exe

   matrix rank ; n : ?
4
   matrix rank ; n =            4

   matrix rank ; n : ?
8
   matrix rank ; n =            8

   matrix rank ; n : ?
12
   matrix rank ; n =            12
  hellow from            1  of            2 processes
---

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.




More information about the mpich-discuss mailing list