Octopus
metis.F90
Go to the documentation of this file.
1!! Copyright (C) 2013 M. Oliveira
2!!
3!! This program is free software; you can redistribute it and/or modify
4!! it under the terms of the GNU General Public License as published by
5!! the Free Software Foundation; either version 2, or (at your option)
6!! any later version.
7!!
8!! This program is distributed in the hope that it will be useful,
9!! but WITHOUT ANY WARRANTY; without even the implied warranty of
10!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11!! GNU General Public License for more details.
12!!
13!! You should have received a copy of the GNU General Public License
14!! along with this program; if not, write to the Free Software
15!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16!! 02110-1301, USA.
17!!
18
19#include "global.h"
20
21! -----------------------------------------------------------------------
23! -----------------------------------------------------------------------
24
25module metis_oct_m
26 use, intrinsic :: iso_fortran_env
27 use mpi_oct_m
28 implicit none
29
30 public
31
32 ! Options codes (copied from metis.h)
33 integer, parameter :: &
34 METIS_OPTION_PTYPE = 1, &
49 metis_option_nseps = 16, &
52 metis_option_help = 19, &
57 metis_option_gtype = 24, &
59
60 !Error code from metis.h
61 integer, parameter :: &
62 METIS_OK = 1, & !< Returned normally
63 metis_error_input = -2, &
64 metis_error_memory = -3, &
65 metis_error = -4
66
67 ! define the integer kind as needed for the metis installation
68#if METIS_IDXTYPEWIDTH == 64
69 integer, parameter :: imetis = int64
70 type(MPI_Datatype), parameter :: MPI_METIS_INT = mpi_integer8
71#else
72 integer, parameter :: imetis = int32
73 type(MPI_Datatype), parameter :: MPI_METIS_INT = mpi_integer
74#endif
75
76 interface
77
78#if defined(HAVE_PARMETIS) || defined(HAVE_METIS)
79 subroutine oct_metis_setdefaultoptions(options)
80 import :: imetis
81 implicit none
82 integer(imetis), intent(inout) :: options
83 end subroutine oct_metis_setdefaultoptions
84
85 integer function oct_metis_partgraphrecursive(nvtxs, ncon, xadj, adjncy, nparts, tpwgts, ubvec, options, objval, part)
86 use, intrinsic :: iso_fortran_env
87 import :: imetis
88 implicit none
89 integer(imetis), intent(in) :: nvtxs
90 integer(imetis), intent(in) :: ncon
91 integer(imetis), intent(in) :: xadj
92 integer(imetis), intent(in) :: adjncy
93 integer(imetis), intent(in) :: nparts
94 real(real32), intent(in) :: tpwgts
96 real(real32), intent(in) :: ubvec
98 integer(imetis), intent(in) :: options
99 integer(imetis), intent(out) :: objval
101 integer(imetis), intent(out) :: part
104
105 integer function oct_metis_partgraphkway(nvtxs, ncon, xadj, adjncy, nparts, tpwgts, ubvec, options, objval, part)
106 use, intrinsic :: iso_fortran_env
107 import :: imetis
108 implicit none
109 integer(imetis), intent(in) :: nvtxs
110 integer(imetis), intent(in) :: ncon
111 integer(imetis), intent(in) :: xadj
112 integer(imetis), intent(in) :: adjncy
113 integer(imetis), intent(in) :: nparts
114 real(real32), intent(in) :: tpwgts
116 real(real32), intent(in) :: ubvec
118 integer(imetis), intent(in) :: options
119 integer(imetis), intent(out) :: objval
121 integer(imetis), intent(out) :: part
123 end function oct_metis_partgraphkway
124
125#endif
126#if defined(HAVE_PARMETIS)
127
128 subroutine oct_parmetis_v3_partkway(vtxdist, xadj, adjncy, ncon, nparts, tpwgts, ubvec, options, edgecut, part, comm)
129 use, intrinsic :: iso_fortran_env
130 import :: imetis
131 implicit none
132 integer(imetis), intent(in) :: vtxdist
134 integer(imetis), intent(in) :: xadj
135 integer(imetis), intent(in) :: adjncy
136 integer(imetis), intent(in) :: ncon
138 integer(imetis), intent(in) :: nparts
141 real(real32), intent(in) :: tpwgts
148 real(real32), intent(in) :: ubvec
151 integer(imetis), intent(in) :: options
154 integer(imetis), intent(out) :: edgecut
156 integer(imetis), intent(out) :: part
159 integer, intent(in) :: comm
160 end subroutine oct_parmetis_v3_partkway
161
162#endif
163 end interface
164
165 interface i4_to_imetis
167 end interface i4_to_imetis
168
169 interface imetis_to_i4
170 module procedure imetis_to_i4_0, imetis_to_i4_1
171 end interface imetis_to_i4
173 interface i8_to_imetis
174 module procedure i8_to_imetis_0, i8_to_imetis_1
175 end interface i8_to_imetis
176
177 interface imetis_to_i8
179 end interface imetis_to_i8
180
181contains
182
183 integer(imetis) pure function i4_to_imetis_0(ii)
184 integer(int32), intent(in) :: ii
185
186 i4_to_imetis_0 = int(ii, imetis)
187 end function i4_to_imetis_0
188
189 integer(int32) pure function imetis_to_i4_0(ii)
190 integer(imetis), intent(in) :: ii
191
192 imetis_to_i4_0 = int(ii, int32)
193 end function imetis_to_i4_0
194
195 pure function i4_to_imetis_1(ii)
196 integer(int32), intent(in) :: ii(:)
197 integer(imetis) :: i4_to_imetis_1(lbound(ii, 1):ubound(ii, 1))
199 i4_to_imetis_1 = int(ii, imetis)
200 end function i4_to_imetis_1
201
202 pure function imetis_to_i4_1(ii)
203 integer(imetis), intent(in) :: ii(:)
204 integer(int32) :: imetis_to_i4_1(lbound(ii, 1, kind=imetis):ubound(ii, 1, kind=imetis))
205
206 imetis_to_i4_1 = int(ii, int32)
207 end function imetis_to_i4_1
208
209 integer(imetis) pure function i8_to_imetis_0(ii)
210 integer(int64), intent(in) :: ii
211
212 i8_to_imetis_0 = int(ii, imetis)
213 end function i8_to_imetis_0
214
215 integer(int64) pure function imetis_to_i8_0(ii)
216 integer(imetis), intent(in) :: ii
217
218 imetis_to_i8_0 = int(ii, int64)
219 end function imetis_to_i8_0
220
221 pure function i8_to_imetis_1(ii)
222 integer(int64), intent(in) :: ii(:)
223 integer(imetis) :: i8_to_imetis_1(lbound(ii, 1, kind=int64):ubound(ii, 1, kind=int64))
224
225 i8_to_imetis_1 = int(ii, imetis)
226 end function i8_to_imetis_1
227
228 pure function imetis_to_i8_1(ii)
229 integer(imetis), intent(in) :: ii(:)
230 integer(int64) :: imetis_to_i8_1(lbound(ii, 1, kind=imetis):ubound(ii, 1, kind=imetis))
231
232 imetis_to_i8_1 = int(ii, int64)
233 end function imetis_to_i8_1
234end module metis_oct_m
235
236!! Local Variables:
237!! mode: f90
238!! coding: utf-8
239!! End:
This module contains interfaces for METIS and PARMETIS routines.
Definition: metis.F90:118
integer, parameter metis_option_tpwgts
Definition: metis.F90:126
integer, parameter metis_option_rtype
Definition: metis.F90:126
pure integer(int64) function, dimension(lbound(ii, 1, kind=imetis):ubound(ii, 1, kind=imetis)) imetis_to_i8_1(ii)
Definition: metis.F90:322
pure integer(int32) function, dimension(lbound(ii, 1, kind=imetis):ubound(ii, 1, kind=imetis)) imetis_to_i4_1(ii)
Definition: metis.F90:296
integer, parameter metis_option_balance
Definition: metis.F90:126
pure integer(imetis) function, dimension(lbound(ii, 1, kind=int64):ubound(ii, 1, kind=int64)) i8_to_imetis_1(ii)
Definition: metis.F90:315
integer, parameter metis_option_minconn
Definition: metis.F90:126
integer, parameter metis_option_numbering
Definition: metis.F90:126
integer, parameter metis_option_seed
Definition: metis.F90:126
integer, parameter metis_option_no2hop
Definition: metis.F90:126
integer, parameter metis_error_memory
Returned due to insufficient memory.
Definition: metis.F90:154
integer, parameter metis_option_objtype
Definition: metis.F90:126
integer, parameter metis_option_dbglvl
Definition: metis.F90:126
pure integer(imetis) function, dimension(lbound(ii, 1):ubound(ii, 1)) i4_to_imetis_1(ii)
Definition: metis.F90:289
integer, parameter metis_option_pfactor
Definition: metis.F90:126
integer, parameter metis_option_ncuts
Definition: metis.F90:126
integer, parameter metis_option_ctype
Definition: metis.F90:126
integer, parameter metis_option_niter
Definition: metis.F90:126
integer, parameter metis_option_gtype
Definition: metis.F90:126
integer(int32) pure function imetis_to_i4_0(ii)
Definition: metis.F90:283
integer(int64) pure function imetis_to_i8_0(ii)
Definition: metis.F90:309
integer, parameter metis_error_input
Returned due to erroneous inputs and/or options.
Definition: metis.F90:154
integer, parameter metis_option_help
Definition: metis.F90:126
integer, parameter metis_option_nooutput
Definition: metis.F90:126
integer, parameter metis_option_ncommon
Definition: metis.F90:126
integer, parameter metis_option_contig
Definition: metis.F90:126
integer(imetis) pure function i8_to_imetis_0(ii)
Definition: metis.F90:303
integer, parameter metis_option_ufactor
Definition: metis.F90:126
integer, parameter metis_option_ccorder
Definition: metis.F90:126
integer, parameter metis_option_compress
Definition: metis.F90:126
integer(imetis) pure function i4_to_imetis_0(ii)
Definition: metis.F90:277
integer, parameter metis_error
Some other errors.
Definition: metis.F90:154
integer, parameter imetis
Definition: metis.F90:165
integer, parameter metis_option_iptype
Definition: metis.F90:126
integer, parameter metis_option_nseps
Definition: metis.F90:126
integer, parameter metis_option_ubvec
Definition: metis.F90:126