Blame test/mpi/f90/attr/commattr4f90.f90

Packit Service c5cf8c
! This file created from f77/attr/commattr4f.f with f77tof90
Packit Service c5cf8c
! -*- Mode: Fortran; -*- 
Packit Service c5cf8c
!
Packit Service c5cf8c
!  (C) 2015 by Argonne National Laboratory.
Packit Service c5cf8c
!      See COPYRIGHT in top-level directory.
Packit Service c5cf8c
!
Packit Service c5cf8c
      program main
Packit Service c5cf8c
!
Packit Service c5cf8c
      use mpi
Packit Service c5cf8c
Packit Service c5cf8c
      integer    ierr
Packit Service c5cf8c
      integer    errs
Packit Service c5cf8c
      logical    found
Packit Service c5cf8c
      integer    comm2
Packit Service c5cf8c
      integer    key
Packit Service c5cf8c
      integer (kind=MPI_ADDRESS_KIND) extrastate, valin, valout, val
Packit Service c5cf8c
Packit Service c5cf8c
Packit Service c5cf8c
      errs = 0
Packit Service c5cf8c
!
Packit Service c5cf8c
!  initialize the mpi environment
Packit Service c5cf8c
!
Packit Service c5cf8c
      call mpi_init(ierr)
Packit Service c5cf8c
Packit Service c5cf8c
      call mpi_comm_create_keyval(MPI_COMM_DUP_FN, &
Packit Service c5cf8c
      &     MPI_NULL_DELETE_FN, &
Packit Service c5cf8c
      &     key, &
Packit Service c5cf8c
      &     extrastate, &
Packit Service c5cf8c
      &     ierr)
Packit Service c5cf8c
!
Packit Service c5cf8c
!  set a value for the attribute
Packit Service c5cf8c
!
Packit Service c5cf8c
      valin = huge(valin)
Packit Service c5cf8c
!
Packit Service c5cf8c
!  set attr in comm_world
Packit Service c5cf8c
!
Packit Service c5cf8c
      call mpi_comm_set_attr(MPI_COMM_WORLD, &
Packit Service c5cf8c
      &     key, &
Packit Service c5cf8c
      &     valin, &
Packit Service c5cf8c
      &     ierr)
Packit Service c5cf8c
      call mpi_comm_get_attr(MPI_COMM_WORLD, &
Packit Service c5cf8c
      &     key, &
Packit Service c5cf8c
      &     valout, &
Packit Service c5cf8c
      &     found, &
Packit Service c5cf8c
      &     ierr)
Packit Service c5cf8c
      if (found .neqv. .true.) then
Packit Service c5cf8c
         print *, "mpi_comm_set_attr reported key, but not found on ", &
Packit Service c5cf8c
      &        "mpi_comm_world"
Packit Service c5cf8c
         errs = errs + 1
Packit Service c5cf8c
      else if (valout .ne. valin) then
Packit Service c5cf8c
         print *, "key found, but valin does not match valout"
Packit Service c5cf8c
         print *, valout, " != ", valin
Packit Service c5cf8c
         errs = errs + 1
Packit Service c5cf8c
      end if
Packit Service c5cf8c
!
Packit Service c5cf8c
!  dup the communicator, attribute should follow
Packit Service c5cf8c
!
Packit Service c5cf8c
      call mpi_comm_dup(MPI_COMM_WORLD, &
Packit Service c5cf8c
      &     comm2, &
Packit Service c5cf8c
      &     ierr)
Packit Service c5cf8c
!
Packit Service c5cf8c
!  get the value for the attribute
Packit Service c5cf8c
!
Packit Service c5cf8c
      call mpi_comm_get_attr(comm2, &
Packit Service c5cf8c
      &     key, &
Packit Service c5cf8c
      &     valout, &
Packit Service c5cf8c
      &     found, &
Packit Service c5cf8c
      &     ierr)
Packit Service c5cf8c
      if (found .neqv. .true.) then
Packit Service c5cf8c
         print *, "mpi_comm_set_attr reported key, but not found on ", &
Packit Service c5cf8c
      &        "duped comm"
Packit Service c5cf8c
         errs = errs + 1
Packit Service c5cf8c
      else if (valout .ne. valin) then
Packit Service c5cf8c
         print *, "key found, but value does not match that on ", &
Packit Service c5cf8c
      &        "mpi_comm_world"
Packit Service c5cf8c
         print *, valout, " != ", valin
Packit Service c5cf8c
         errs = errs + 1
Packit Service c5cf8c
      end if
Packit Service c5cf8c
!
Packit Service c5cf8c
!     free the duped communicator
Packit Service c5cf8c
!
Packit Service c5cf8c
      call mpi_comm_free(comm2, ierr)
Packit Service c5cf8c
!
Packit Service c5cf8c
!     free keyval
Packit Service c5cf8c
!
Packit Service c5cf8c
      call mpi_comm_delete_attr(MPI_COMM_WORLD, &
Packit Service c5cf8c
      &     key, ierr)
Packit Service c5cf8c
      call mpi_comm_free_keyval(key, &
Packit Service c5cf8c
      &     ierr)
Packit Service c5cf8c
Packit Service c5cf8c
      call mtest_finalize( errs )
Packit Service c5cf8c
Packit Service c5cf8c
      end