|
Packit |
0848f5 |
! This file created from test/mpi/f77/io/shpositionf.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 comm, fh, r, s, i
|
|
Packit |
0848f5 |
integer fileintsize
|
|
Packit |
0848f5 |
integer errs, err, ierr
|
|
Packit |
0848f5 |
character *(100) filename
|
|
Packit |
0848f5 |
integer (kind=MPI_OFFSET_KIND) offset
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
integer (kind=MPI_ADDRESS_KIND) aint
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
errs = 0
|
|
Packit |
0848f5 |
call MTest_Init( ierr )
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
filename = "iotest.txt"
|
|
Packit |
0848f5 |
comm = MPI_COMM_WORLD
|
|
Packit |
0848f5 |
call mpi_comm_size( comm, s, ierr )
|
|
Packit |
0848f5 |
call mpi_comm_rank( comm, r, ierr )
|
|
Packit |
0848f5 |
! Try writing the file, then check it
|
|
Packit |
0848f5 |
call mpi_file_open( comm, filename, MPI_MODE_RDWR + &
|
|
Packit |
0848f5 |
& MPI_MODE_CREATE, MPI_INFO_NULL, fh, ierr )
|
|
Packit |
0848f5 |
if (ierr .ne. MPI_SUCCESS) then
|
|
Packit |
0848f5 |
errs = errs + 1
|
|
Packit |
0848f5 |
if (errs .le. 10) then
|
|
Packit |
0848f5 |
call MTestPrintError( ierr )
|
|
Packit |
0848f5 |
endif
|
|
Packit |
0848f5 |
endif
|
|
Packit |
0848f5 |
!
|
|
Packit |
0848f5 |
! Get the size of an INTEGER in the file
|
|
Packit |
0848f5 |
call mpi_file_get_type_extent( fh, MPI_INTEGER, aint, ierr )
|
|
Packit |
0848f5 |
fileintsize = aint
|
|
Packit |
0848f5 |
!
|
|
Packit |
0848f5 |
! We let each process write in turn, getting the position after each
|
|
Packit |
0848f5 |
! write
|
|
Packit |
0848f5 |
do i=1, s
|
|
Packit |
0848f5 |
if (i .eq. r + 1) then
|
|
Packit |
0848f5 |
call mpi_file_write_shared( fh, i, 1, MPI_INTEGER, &
|
|
Packit |
0848f5 |
& MPI_STATUS_IGNORE, ierr )
|
|
Packit |
0848f5 |
if (ierr .ne. MPI_SUCCESS) then
|
|
Packit |
0848f5 |
errs = errs + 1
|
|
Packit |
0848f5 |
if (errs .le. 10) then
|
|
Packit |
0848f5 |
call MTestPrintError( ierr )
|
|
Packit |
0848f5 |
endif
|
|
Packit |
0848f5 |
endif
|
|
Packit |
0848f5 |
endif
|
|
Packit |
0848f5 |
call mpi_barrier( comm, ierr )
|
|
Packit |
0848f5 |
call mpi_file_get_position_shared( fh, offset, ierr )
|
|
Packit |
0848f5 |
if (offset .ne. fileintsize * i) then
|
|
Packit |
0848f5 |
errs = errs + 1
|
|
Packit |
0848f5 |
print *, r, ' Shared position is ', offset,' should be ', &
|
|
Packit |
0848f5 |
& fileintsize * i
|
|
Packit |
0848f5 |
endif
|
|
Packit |
0848f5 |
call mpi_barrier( comm, ierr )
|
|
Packit |
0848f5 |
enddo
|
|
Packit |
0848f5 |
call mpi_file_close( fh, ierr )
|
|
Packit |
0848f5 |
if (r .eq. 0) then
|
|
Packit |
0848f5 |
call mpi_file_delete( filename, MPI_INFO_NULL, ierr )
|
|
Packit |
0848f5 |
endif
|
|
Packit |
0848f5 |
if (ierr .ne. MPI_SUCCESS) then
|
|
Packit |
0848f5 |
errs = errs + 1
|
|
Packit |
0848f5 |
if (errs .le. 10) then
|
|
Packit |
0848f5 |
call MTestPrintError( ierr )
|
|
Packit |
0848f5 |
endif
|
|
Packit |
0848f5 |
endif
|
|
Packit |
0848f5 |
!
|
|
Packit |
0848f5 |
call MTest_Finalize( errs )
|
|
Packit |
0848f5 |
call mpi_finalize( ierr )
|
|
Packit |
0848f5 |
end
|