Blame test/mpi/f90/rma/baseattrwinf90.f90

Packit 0848f5
! This file created from test/mpi/f77/rma/baseattrwinf.f with f77tof90
Packit 0848f5
! -*- Mode: Fortran; -*- 
Packit 0848f5
!
Packit 0848f5
!  (C) 2003 by Argonne National Laboratory.
Packit 0848f5
!      See COPYRIGHT in top-level directory.
Packit 0848f5
!
Packit 0848f5
      program main
Packit 0848f5
      use mpi
Packit 0848f5
      integer (kind=MPI_ADDRESS_KIND) extrastate, valin, valout, val
Packit 0848f5
Packit 0848f5
      logical flag
Packit 0848f5
      integer ierr, errs
Packit 0848f5
      integer base(1024)
Packit 0848f5
      integer disp
Packit 0848f5
      integer win
Packit 0848f5
      integer commsize
Packit 0848f5
! Include addsize defines asize as an address-sized integer
Packit 0848f5
      integer (kind=MPI_ADDRESS_KIND) asize
Packit 0848f5
Packit 0848f5
Packit 0848f5
      errs = 0
Packit 0848f5
      
Packit 0848f5
      call mtest_init( ierr )
Packit 0848f5
      call mpi_comm_size( MPI_COMM_WORLD, commsize, ierr )
Packit 0848f5
Packit 0848f5
! Create a window; then extract the values 
Packit 0848f5
      asize    = 1024
Packit 0848f5
      disp = 4
Packit 0848f5
      call MPI_Win_create( base, asize, disp, MPI_INFO_NULL,  &
Packit 0848f5
      &  MPI_COMM_WORLD, win, ierr )
Packit 0848f5
!
Packit 0848f5
! In order to check the base, we need an address-of function.
Packit 0848f5
! We use MPI_Get_address, even though that isn't strictly correct
Packit 0848f5
      call MPI_Win_get_attr( win, MPI_WIN_BASE, valout, flag, ierr )
Packit 0848f5
      if (.not. flag) then
Packit 0848f5
         errs = errs + 1
Packit 0848f5
         print *, "Could not get WIN_BASE"
Packit 0848f5
!
Packit 0848f5
! There is no easy way to get the actual value of base to compare 
Packit 0848f5
! against.  MPI_Address gives a value relative to MPI_BOTTOM, which 
Packit 0848f5
! is different from 0 in Fortran (unless you can define MPI_BOTTOM
Packit 0848f5
! as something like %pointer(0)).
Packit 0848f5
!      else
Packit 0848f5
!
Packit 0848f5
!C For this Fortran 77 version, we use the older MPI_Address function
Packit 0848f5
!         call MPI_Address( base, baseadd, ierr )
Packit 0848f5
!         if (valout .ne. baseadd) then
Packit 0848f5
!           errs = errs + 1
Packit 0848f5
!           print *, "Got incorrect value for WIN_BASE (", valout, 
Packit 0848f5
!     &             ", should be ", baseadd, ")"
Packit 0848f5
!         endif
Packit 0848f5
      endif
Packit 0848f5
Packit 0848f5
      call MPI_Win_get_attr( win, MPI_WIN_SIZE, valout, flag, ierr )
Packit 0848f5
      if (.not. flag) then
Packit 0848f5
         errs = errs + 1
Packit 0848f5
         print *, "Could not get WIN_SIZE"
Packit 0848f5
      else
Packit 0848f5
        if (valout .ne. asize) then
Packit 0848f5
            errs = errs + 1
Packit 0848f5
            print *, "Got incorrect value for WIN_SIZE (", valout,  &
Packit 0848f5
      &        ", should be ", asize, ")"
Packit 0848f5
         endif
Packit 0848f5
      endif
Packit 0848f5
Packit 0848f5
      call MPI_Win_get_attr( win, MPI_WIN_DISP_UNIT, valout, flag, ierr)
Packit 0848f5
      if (.not. flag) then
Packit 0848f5
         errs = errs + 1
Packit 0848f5
         print *, "Could not get WIN_DISP_UNIT"
Packit 0848f5
      else
Packit 0848f5
         if (valout .ne. disp) then
Packit 0848f5
            errs = errs + 1
Packit 0848f5
            print *, "Got wrong value for WIN_DISP_UNIT (", valout,  &
Packit 0848f5
      &               ", should be ", disp, ")"
Packit 0848f5
         endif
Packit 0848f5
      endif
Packit 0848f5
Packit 0848f5
      call MPI_Win_free( win, ierr )
Packit 0848f5
Packit 0848f5
      call mtest_finalize( errs )
Packit 0848f5
      call MPI_Finalize( ierr )
Packit 0848f5
Packit 0848f5
      end