LAM/MPI logo

LAM/MPI General User's Mailing List Archives

  |   Home   |   Download   |   Documentation   |   FAQ   |   all just in this list

From: Vishal Sahay (vsahay_at_[hidden])
Date: 2004-03-31 11:46:30


Hi --

You would need to have include 'mpif.h' in your subroutine to make this
work. Your previous include is in the scope of "program sph" and does not
extend to the subroutine.

If you dont have the include in your subroutine, the value of
MPI_COMM_WORLD is random, hence the MPI calls (mpi_comm_size, ...) having
MPI_COMM_WORLD as the argument fails due to invalid MPI_COMM_WORLD value.

This would not throw compile time errors as in C, because (as you may see
in mpif.h) fortran does not have the concept of function prototypes. It
creates its own. Hence there won't be prototyping errors as you could
expect in C.

Hope this helps!

-Vishal

On Wed, 31 Mar 2004, Roberto Pasianot wrote:

#
# You must initialize MPI environment in main not in subroutine.
# Cheers. Roberto.
#
#
# On Wed, 31 Mar 2004, [iso-8859-1] Mathias Brito wrote:
#
# > I tried to run this code after compile it, and it
# > did't run. Can somebody help me with this?
# >
# > program sph
# > include 'mpif.h'
# > call data_
# > end
# >
# > subroutine data_
# > C
# > integer nprocs, rank, ierror
# > integer start_address, address
# > integer x
# > integer l(2), d(2), t(2)
# > real c
# > C
# > call mpi_init(ierror)
# > call mpi_comm_size(MPI_COMM_WORLD, nprocs,
# > ierror)
# > call mpi_comm_rank(MPI_COMM_WORLD, rank,
# > ierror)
# > C
# > l(1) = 1
# > l(2) = 1
# >
# > call mpi_address(x, start_address, ierror)
# > d(1) = 0
# > call mpi_address(c, address, ierror)
# > d(2) = address - start_address
# >
# > t(1) = MPI_INTEGER
# > t(2) = MPI_REAL
# >
# > call mpi_type_struct(2, l, d, t, packz,
# > ierror)
# > call mpi_type_commit(packz, ierror)
# > call mpi_finalize(ierror)
# >
# > end
# >
# >
# > =====
# > Mathias Brito
# > Universidade Estadual de Santa Cruz - UESC
# > Departamento de Ciências Exatas e Tecnológicas
# > Estudante do Curso de Ciência da Computação
# >
# > ______________________________________________________________________
# >
# > Yahoo! Mail - O melhor e-mail do Brasil! Abra sua conta agora:
# > http://br.yahoo.com/info/mail.html
# > _______________________________________________
# > This list is archived at http://www.lam-mpi.org/MailArchives/lam/
# >
#
#
# _______________________________________________
# This list is archived at http://www.lam-mpi.org/MailArchives/lam/
#