[mpich-discuss] Is MPI developed for Fortran as well as C?

Hossein Beiramy beiramy_hossein at yahoo.com
Fri Apr 8 05:11:39 CDT 2011


Dear Chan,
I use a PC with following specification: 
Windows 7 OS, 64 Bit, 4 GB of RAM, Intel® Core(TM)2Duo CPU 3.34 GHz 
In my small project, I want to send and receive an array of data type. In the following, I have explained my small project. Source code also is attached. 
 
I defined Particle data type that contains 4 INTEGER4, 11 INTEGER2, 2 LOGICAL and 2 INTEGER4 array with size 6. To define an MPI data type for the particle data type, first I defined columntype type for INTEGER4 array with size 6. Then I structured particletype and committed it. I defined two array (p,particles) of type particletype and allocated them: 
ALLOCATE(particles(0:NELEM));ALLOCATE(p(0:1010)). 
I initialized particles array. For sending specific segments of particles array from server process (rank=0) to array P on Client processes, I defined indextype MPI data type. I want to get the array on client processes without gap and continuancely.
On the Client process last cell have not received truly. Even in sending one cell result are as following:
D:\Console1\Debug>mpiexec -n 2 Console1.exe
 rank=            1  p=           1           7      8     18 F T  -842150451  -842150451  -842150451  -842150451  -842150451  -842150451
Previously a similar question has been mention about sending structured data of structures. This discussion also is attached.
--- On Thu, 4/7/11, Anthony Chan <chan at mcs.anl.gov> wrote:


From: Anthony Chan <chan at mcs.anl.gov>
Subject: Re: [mpich-discuss] Is MPI developed for Fortran as well as C?
To: mpich-discuss at mcs.anl.gov
Date: Thursday, April 7, 2011, 8:36 PM




----- Original Message -----
> Dear all,
> Is MPI developed for Fortran as well as C?
> 

MPI standard defines a Fortran binding which is provided by MPICH2.
Do you have trouble in compiling/running the sample code or you have
trouble install MPICH2.

A.Chan

> 
> 
> I work on a Fortran project and I want to do massage passing works
> between nodes with MPI routines. I was able to send and receive simple
> arrays but for sending and receiving an array of data type, it did not
> work. In the attached files I have sent my previous Email that I had
> sent to MPICH Discuss mailing list. In the Email I have reported
> examination result of an example that I have gotten from Prof.
> zkovacs. In that Email someone else, also have discussed. Prof.
> zkovacs had wanted to send and receive an array of data type in C
> programming language. I want to do similar work in Fortran.
> 
> 
> 
> 
> 
> 
> Please give your opinion or in case that development of MPICH for
> Fortran is not completed, introduce other implementation of MPI for
> Fortran.
> Another question. I want to write equivalent code of following C code
> in Fortran. C code works truly but Fortran code does not. What is the
> problem?
> Attached files contain *.pdf file of previous Email and following
> example. Also source code files are attached.
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> #include "mpi.h"
> #include <stdio.h>
> #include <stdlib.h>
> 
> int main (int argc, char *argv[])
> {
> int position, i, j, a[2], myrank, num_proc;
> char buff[1000];
> MPI_Status stat;
> MPI_Init(&argc, &argv);
> MPI_Comm_size(MPI_COMM_WORLD, &num_proc );
> MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
> if (myrank == 0)
> {
> /* SENDER CODE */
> i = 1; j = 2; a[0] = 3;
> printf( "Proc %d: sending %u %u %u.th portion to proc 0.\n", myrank,
> i, j, a );
> position = 0;
> MPI_Pack(&i, 1, MPI_INT, buff, 1000, &position, MPI_COMM_WORLD);
> MPI_Pack(&j, 1, MPI_INT, buff, 1000, &position, MPI_COMM_WORLD);
> MPI_Send( buff, position, MPI_PACKED, 1, 0, MPI_COMM_WORLD);
> }
> else /* RECEIVER CODE */
> {
> MPI_Recv( a, 2, MPI_INT, 0, 0, MPI_COMM_WORLD,&stat);
> printf( "Proc %d: reciving %u %u %u.th portion to proc 0.\n", myrank,
> i, j, a[0] );
> }
> MPI_Finalize();
> return 0;
> }
> 
> 
> 
> program main
> implicit none
> include 'mpif.h'
> integer a(0:1)
> integer position, i, j, a(0:1), rank, numtasks;
> character buff(0:1000);
> integer stat(MPI_STATUS_SIZE)
> call MPI_INIT(ierr)
> call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr)
> call MPI_COMM_SIZE(MPI_COMM_WORLD, numtasks, ierr)
> if (rank == 0) then
> !/* SENDER CODE */
> position = 0;
> i=1;j=2;
> CALL MPI_Pack(i, 1, MPI_INTEGER, buff, 1000, position, MPI_COMM_WORLD,
> ierr);
> CALL MPI_Pack(j, 1, MPI_INTEGER, buff, 1000, position, MPI_COMM_WORLD,
> ierr);
> CALL MPI_Send( buff, position, MPI_PACKED, 1, 0, MPI_COMM_WORLD,
> ierr);
> else !/* RECEIVER CODE */
> CALL MPI_Recv( a, 2, MPI_INTEGER, 0, 0, MPI_COMM_WORLD, ierr);
> position = 0;
> CALL MPI_Unpack(a, 2, position, i, 1, MPI_INTEGER, MPI_COMM_WORLD,
> ierr);
> CALL MPI_Unpack(a, 2, position, j, 1, MPI_INTEGER, MPI_COMM_WORLD,
> ierr);
> Write(*,*) 'i , j = ' , i,j
> END IF
> call MPI_FINALIZE(ierr)
> end program main
> 
> 
> 
> Best Regards,
> --
> Hossein Beyrami
> 
> 
> 
> 
> _______________________________________________
> mpich-discuss mailing list
> mpich-discuss at mcs.anl.gov
> https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss
_______________________________________________
mpich-discuss mailing list
mpich-discuss at mcs.anl.gov
https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/mpich-discuss/attachments/20110408/0e8cd878/attachment-0001.htm>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: array_of_data_type.F90
URL: <http://lists.mcs.anl.gov/pipermail/mpich-discuss/attachments/20110408/0e8cd878/attachment-0001.diff>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Email.txt
URL: <http://lists.mcs.anl.gov/pipermail/mpich-discuss/attachments/20110408/0e8cd878/attachment-0001.txt>


More information about the mpich-discuss mailing list