KTH framework for Nek5000 toolboxes; testing version  0.0.1
byte_mpi.f
Go to the documentation of this file.
1  subroutine byte_sync_mpi(mpi_fh)
2 
3  include 'mpif.h'
4 #ifndef NOMPIIO
5  call mpi_file_sync(mpi_fh,ierr)
6 #else
7  call exitti('MPI_file_sync unsupported!$',0)
8 #endif
9  return
10  end
11 C--------------------------------------------------------------------------
12  subroutine byte_open_mpi(fnamei,mpi_fh,ifro,ierr)
13 
14  include 'mpif.h'
15 
16  common /nekmpi/ nid,np,nekcomm,nekgroup,nekreal
17 
18  character fnamei*(*)
19  logical ifro
20 
21  character*132 fname
22  character*1 fname1(132)
23  equivalence(fname1,fname)
24 
25  l = ltrunc(fnamei,len(fnamei))
26  if(l+1.gt.len(fname))
27  $ call exitti('invalid string length$',l)
28 
29  call chcopy(fname1 ,fnamei ,l)
30  call chcopy(fname1(l+1),char(0),1)
31 
32  imode = mpi_mode_wronly+mpi_mode_create
33  if(ifro) then
34  imode = mpi_mode_rdonly
35  endif
36 
37 #ifndef NOMPIIO
38  call mpi_file_open(nekcomm,fname,imode,
39  & mpi_info_null,mpi_fh,ierr)
40 #else
41  call exitti('MPI_file_open unsupported!$',0)
42 #endif
43 
44  return
45  end
46 C--------------------------------------------------------------------------
47  subroutine byte_read_mpi(buf,icount,iorank,mpi_fh,ierr)
48 
49  include 'mpif.h'
50 
51  real*4 buf(1) ! buffer
52 
53  iout = icount ! icount is in 4-byte words
54 #ifndef NOMPIIO
55  call mpi_file_read_all(mpi_fh,buf,iout,mpi_real,
56  & mpi_status_ignore,ierr)
57 #else
58  call exitti('MPI_file_read_all unsupported!$',0)
59 #endif
60 
61  return
62  end
63 C--------------------------------------------------------------------------
64  subroutine byte_write_mpi(buf,icount,iorank,mpi_fh,ierr)
65 
66  include 'mpif.h'
67  common /nekmpi/ nid,np,nekcomm,nekgroup,nekreal
68 
69  real*4 buf(1) ! buffer
70 
71  iout = icount ! icount is in 4-byte words
72  if(iorank.ge.0 .and. nid.ne.iorank) iout = 0
73 #ifndef NOMPIIO
74  call mpi_file_write_all(mpi_fh,buf,iout,mpi_real,
75  & mpi_status_ignore,ierr)
76 #else
77  call exitti('MPI_file_write_all unsupported!$',0)
78 #endif
79 
80  return
81  end
82 C--------------------------------------------------------------------------
83  subroutine byte_close_mpi(mpi_fh,ierr)
84 
85  include 'mpif.h'
86 
87 #ifndef NOMPIIO
88  call mpi_file_close(mpi_fh,ierr)
89 #else
90  call exitti('MPI_file_close unsupported!$',0)
91 #endif
92 
93  return
94  end
95 C--------------------------------------------------------------------------
96  subroutine byte_set_view(ioff_in,mpi_fh)
97 
98  include 'mpif.h'
99  integer*8 ioff_in
100 
101  if(ioff_in.lt.0)
102  & call exitti('Invalid index in MPI_file_set_view!$',ioff_in)
103 #ifndef NOMPIIO
104  call mpi_file_set_view(mpi_fh,ioff_in,mpi_byte,mpi_byte,
105  & 'native',mpi_info_null,ierr)
106 #endif
107 
108  return
109  end
subroutine byte_open_mpi(fnamei, mpi_fh, ifro, ierr)
Definition: byte_mpi.f:13
subroutine byte_write_mpi(buf, icount, iorank, mpi_fh, ierr)
Definition: byte_mpi.f:65
subroutine byte_read_mpi(buf, icount, iorank, mpi_fh, ierr)
Definition: byte_mpi.f:48
subroutine byte_close_mpi(mpi_fh, ierr)
Definition: byte_mpi.f:84
subroutine byte_set_view(ioff_in, mpi_fh)
Definition: byte_mpi.f:97
subroutine byte_sync_mpi(mpi_fh)
Definition: byte_mpi.f:2
subroutine exitti(stringi, idata)
Definition: comm_mpi.f:535
function ltrunc(string, l)
Definition: math.f:494
subroutine chcopy(a, b, n)
Definition: math.f:281