SURFEX v8.1
General documentation of Surfex
mpl_open_mod.F90
Go to the documentation of this file.
2 !
3 ! Purpose. open an MPIIO file
4 ! --------
5 !
6 !
7 ! Interface.
8 ! ----------
9 ! call mpl_open(...)
10 !
11 ! Explicit arguments :
12 ! --------------------
13 !
14 ! input arguments:
15 ! ktype - 1 = open for reading , 2 = writing
16 ! kname - Name of the file
17 ! output arguments:
18 ! kfptr - handle for file pointer
19 ! kerror - error code
20 !
21 ! Implicit arguments :
22 ! --------------------
23 !
24 ! Method.
25 ! -------
26 ! MPL supports 4 styles of MPIIO
27 !
28 ! kop = 1 - Blocking, non collective, shared file pointer
29 ! using MPI_FILE_WRITE_SHARED,
30 ! MPI_FILE_READ_SHARED
31 ! kop = 2 - Blocking, collective, ordered, shared file pointer
32 ! using MPI_FILE_WRITE_ORDERED,
33 ! MPI_FILE_READ_ORDERED
34 ! kop = 3 - Non Blocking, non collective, shared file pointer
35 ! using MPI_FILE_IWRITE_SHARED,
36 ! MPI_FILE_IREAD_SHARED
37 ! and MPI_WAIT
38 ! kop = 4 - Non Blocking, collective, ordered, shared file pointer
39 ! using MPI_FILE_WRITE_ORDERED_BEGIN/END,
40 ! MPI_FILE_READ_ORDERED_BEGIN/END
41 !
42 !
43 ! Externals.
44 ! ----------
45 !
46 ! Reference.
47 ! ----------
48 ! none yet
49 !
50 ! Author.
51 ! -------
52 ! G.Mozdzynski
53 !
54 ! Modifications.
55 ! --------------
56 ! Original : 2000-12-08 (Based on MPE_OPEN)
57 ! R. EL Khatib 24-May-2011 Change ifdef MPI2 into ifndef MPI1
58 ! -----------------------------------------------------------------
59 !
60 USE parkind1 ,ONLY : jpim ,jprb
61 
62 USE mpl_mpif
66 
67 IMPLICIT NONE
68 
69 PRIVATE
70 PUBLIC mpl_open
71 
72 CONTAINS
73 
74 SUBROUTINE mpl_open(KFPTR,KTYPE,KNAME,KERROR)
75 
76 
77 #ifdef USE_8_BYTE_WORDS
78  USE mpi4to8, ONLY : &
79  mpi_file_open => mpi_file_open8
80 #endif
81 
82 INTEGER(KIND=JPIM),INTENT(IN) :: KTYPE
83 INTEGER(KIND=JPIM),INTENT(OUT) :: KFPTR,KERROR
84 CHARACTER*(*) KNAME
85 INTEGER(KIND=JPIM) :: MODE,INFO
86 
87 #ifndef MPI1
88 
89 !
90 ! -----------------------------------------------------------------
91 !
92 ! 1. Preamble
93 ! --------
94 !
95 IF( mpl_rank > mpl_numio ) THEN
96  kerror = -1
97  RETURN
98 ENDIF
99 
100 IF( ktype == 1 ) THEN
101  mode = mpi_mode_rdonly
102 ELSEIF( ktype == 2 ) THEN
103  mode = mpi_mode_wronly + mpi_mode_create
104 ELSE
105  kerror = -1
106  RETURN
107 ENDIF
108 
109 info = mpi_info_null
110 
111 ! -----------------------------------------------------------------
112 !
113 ! 2. open the file
114 ! ----------------------
115 
116 CALL mpi_file_open(mpl_comm_io,kname,mode,info,kfptr,kerror)
117 !
118 !
119 ! -----------------------------------------------------------------
120 #else
121 
122 CALL abor1('MPL_OPEN not built with MPI2')
123 
124 #endif
125 
126 RETURN
127 END SUBROUTINE mpl_open
128 
129 END MODULE mpl_open_mod
integer, parameter jpim
Definition: parkind1.F90:13
subroutine abor1(CDTEXT)
Definition: abor1.F90:2
integer(kind=jpim), public mpl_numio
integer, parameter jprb
Definition: parkind1.F90:32
integer(kind=jpim), public mpl_comm_io
integer(kind=jpim) mpl_rank
subroutine, public mpl_open(KFPTR, KTYPE, KNAME, KERROR)