|
Packit |
0848f5 |
! This file created from test/mpi/f77/io/fileinfof.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 ierr, errs
|
|
Packit |
0848f5 |
integer fh, info1, info2, rank
|
|
Packit |
0848f5 |
logical flag
|
|
Packit |
0848f5 |
character*(50) filename
|
|
Packit |
0848f5 |
character*(MPI_MAX_INFO_KEY) mykey
|
|
Packit |
0848f5 |
character*(MPI_MAX_INFO_VAL) myvalue
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
errs = 0
|
|
Packit |
0848f5 |
call mtest_init( ierr )
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
call mpi_comm_rank( MPI_COMM_WORLD, rank, ierr )
|
|
Packit |
0848f5 |
!
|
|
Packit |
0848f5 |
! Open a simple file
|
|
Packit |
0848f5 |
ierr = -1
|
|
Packit |
0848f5 |
filename = "iotest.txt"
|
|
Packit |
0848f5 |
call mpi_file_open( MPI_COMM_WORLD, 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 |
call MTestPrintError( ierr )
|
|
Packit |
0848f5 |
endif
|
|
Packit |
0848f5 |
!
|
|
Packit |
0848f5 |
! Try to set one of the available info hints
|
|
Packit |
0848f5 |
call mpi_info_create( info1, ierr )
|
|
Packit |
0848f5 |
call mpi_info_set( info1, "access_style", &
|
|
Packit |
0848f5 |
& "read_once,write_once", ierr )
|
|
Packit |
0848f5 |
ierr = -1
|
|
Packit |
0848f5 |
call mpi_file_set_info( fh, info1, ierr )
|
|
Packit |
0848f5 |
if (ierr .ne. MPI_SUCCESS) then
|
|
Packit |
0848f5 |
errs = errs + 1
|
|
Packit |
0848f5 |
call MTestPrintError( ierr )
|
|
Packit |
0848f5 |
endif
|
|
Packit |
0848f5 |
call mpi_info_free( info1, ierr )
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
ierr = -1
|
|
Packit |
0848f5 |
call mpi_file_get_info( fh, info2, ierr )
|
|
Packit |
0848f5 |
if (ierr .ne. MPI_SUCCESS) then
|
|
Packit |
0848f5 |
errs = errs + 1
|
|
Packit |
0848f5 |
call MTestPrintError( ierr )
|
|
Packit |
0848f5 |
endif
|
|
Packit |
0848f5 |
call mpi_info_get( info2, "filename", MPI_MAX_INFO_VAL, &
|
|
Packit |
0848f5 |
& myvalue, flag, ierr )
|
|
Packit |
0848f5 |
!
|
|
Packit |
0848f5 |
! An implementation isn't required to provide the filename (though
|
|
Packit |
0848f5 |
! a high-quality implementation should)
|
|
Packit |
0848f5 |
if (flag) then
|
|
Packit |
0848f5 |
! If we find it, we must have the correct name
|
|
Packit |
0848f5 |
if (myvalue(1:10) .ne. filename(1:10) .or. &
|
|
Packit |
0848f5 |
& myvalue(11:11) .ne. ' ') then
|
|
Packit |
0848f5 |
errs = errs + 1
|
|
Packit |
0848f5 |
print *, ' Returned wrong value for the filename'
|
|
Packit |
0848f5 |
endif
|
|
Packit |
0848f5 |
endif
|
|
Packit |
0848f5 |
call mpi_info_free( info2, ierr )
|
|
Packit |
0848f5 |
!
|
|
Packit |
0848f5 |
call mpi_file_close( fh, ierr )
|
|
Packit |
0848f5 |
call mpi_barrier( MPI_COMM_WORLD, ierr )
|
|
Packit |
0848f5 |
if (rank .eq. 0) then
|
|
Packit |
0848f5 |
call mpi_file_delete( filename, MPI_INFO_NULL, ierr )
|
|
Packit |
0848f5 |
endif
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
call mtest_finalize( errs )
|
|
Packit |
0848f5 |
call mpi_finalize( ierr )
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
end
|