Newsgroups: comp.parallel.mpi
From: Yon Han Chong <Y.H.Chong@cranfield.ac.uk>
Subject: Something strange: f90 array subscripts
Organization: Cranfield University
Date: Wed, 21 Aug 1996 17:33:24 +0100
Mime-Version: 1.0
Content-Type: text/plain; charset=euc-kr
Content-Transfer-Encoding: 7bit
Message-ID: <321B3A54.41C6@cranfield.ac.uk>

Currently, I am using LAM6.0 with Fortran 90. 

Followings are two very simular codes and in fact I think they should be
same but behaves differently. I am not sure it is something to do with
LAM implimentation or I shouldn't use Fortran 90's array subscripts like
this. Any comment will be appreciated.

This program does what I want to do:
---------------------------------------------------------------------

      program test_reshape

      implicit none

      include '/home/ca/aa945308/lib/lam/h/mpif.h'
      
      real, dimension(2,3) :: array1=
     &       reshape((/1.0,2.0,3.0,4.0,5.0,6.0/),(/2,3/))
      real, dimension(2,3) :: array2=0.0,buf1(3),buf2(3)
      integer :: my_id,ierr,status(MPI_STATUS_SIZE,2),req(2),i
      logical :: flag
      
      call mpi_init(flag,ierr)

      call mpi_comm_rank(MPI_COMM_WORLD, my_id, ierr)

      if (my_id==1) then
         call mpi_send(array1(2,1:3),3,MPI_REAL,0,1,
     &                        MPI_COMM_WORLD,req(1),ierr)
         call mpi_send(array1(1,1:3),3,MPI_REAL,0,2,
     &                        MPI_COMM_WORLD,req(2),ierr)
      else 
         call mpi_recv(array2(1,1:3),3,MPI_REAL,1,1,
     &                        MPI_COMM_WORLD,req(1),ierr)
         call mpi_recv(array2(2,1:3),3,MPI_REAL,1,2,
     &                        MPI_COMM_WORLD,req(2),ierr)
      end if
      
      if (my_id==0) print *,array2

      call mpi_finalize(ierr)

      end program test_reshape
---------------------------------------------------------------------

but this doesn't
---------------------------------------------------------------------
      program test_reshape

      implicit none

      include '/home/ca/aa945308/lib/lam/h/mpif.h'
      
      real, dimension(2,3) :: array1=
     &       reshape((/1.0,2.0,3.0,4.0,5.0,6.0/),(/2,3/))
      real, dimension(2,3) :: array2=0.0,buf1(3),buf2(3)
      integer :: my_id,ierr,status(MPI_STATUS_SIZE,2),req(2),i
      logical :: flag
      
      call mpi_init(flag,ierr)

      call mpi_comm_rank(MPI_COMM_WORLD, my_id, ierr)

      if (my_id==1) then
         call mpi_isend(array1(2,1:3),3,MPI_REAL,0,1,
     &                        MPI_COMM_WORLD,req(1),ierr)
         call mpi_isend(array1(1,1:3),3,MPI_REAL,0,2,
     &                        MPI_COMM_WORLD,req(2),ierr)
      else 
         call mpi_irecv(array2(1,1:3),3,MPI_REAL,1,1,
     &                        MPI_COMM_WORLD,req(1),ierr)
         call mpi_irecv(array2(2,1:3),3,MPI_REAL,1,2,
     &                        MPI_COMM_WORLD,req(2),ierr)
      end if
      call mpi_waitall(2,req,status,ierr)
      
      if (my_id==0) print *,array2

      call mpi_finalize(ierr)

      end program test_reshape
---------------------------------------------------------------------

Output of the first one is

   2.000000       1.000000       4.000000       3.000000       6.000000    
   5.000000    

Outpur of the second one is

  0.0000000E+00  0.0000000E+00  0.0000000E+00  0.0000000E+00
0.0000000E+00
  0.0000000E+00


-- 
-----------------------------------------------------------------
Yon Han Chong              |
Dept. of Aerospace Sci.    |   Tel: + 44 1234 750 111 ext.5356
College of Aeronautics     |   Fax: + 44 1234 752 149
Cranfield University       |   E-mail: Y.H.Chong@cranfield.ac.uk
United Kingdom             |
-----------------------------------------------------------------

