Skip to content

Commit 104dc7e

Browse files
committed
simplify metis
1 parent 232efc0 commit 104dc7e

File tree

1 file changed

+21
-54
lines changed

1 file changed

+21
-54
lines changed

src/metis.f90

+21-54
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,41 @@
1-
!! https://github.com/lanl/qmd-progress/
1+
!! https://people.math.sc.edu/Burkardt/f_src/metis_test/metis_test.f90
2+
! GNU LGPL license. Author: John Burkardt
23

34
program test_metis
45

5-
use, intrinsic:: iso_fortran_env, only: dp=>real64
6-
76
implicit none (type, external)
8-
!> 0 METIS_OPTION_PTYPE
9-
!> -- 0 METIS_PTYPE_RB
10-
!> -- 1 METIS_PTYPE_KWAY
11-
!> 1 METIS_OPTION_OBJTYPE,
12-
!> -- 0 METIS_OBJTYPE_CUT
13-
!> -- 1 METIS_OBJTYPE_VOL
14-
!> 2 METIS_OPTION_CTYPE,
15-
!> 3 METIS_OPTION_IPTYPE,
16-
!> 4 METIS_OPTION_RTYPE,
17-
!> 5 METIS_OPTION_DBGLVL,
18-
!> 6 METIS_OPTION_NITER,
19-
!> 7 METIS_OPTION_NCUTS,
20-
!> 8 METIS_OPTION_SEED,
21-
!> 9 METIS_OPTION_NO2HOP,
22-
!> 10 METIS_OPTION_MINCONN,
23-
!> 11 METIS_OPTION_CONTIG,
24-
!> 12 METIS_OPTION_COMPRESS,
25-
!> 13 METIS_OPTION_CCORDER,
26-
!> 14 METIS_OPTION_PFACTOR,
27-
!> 15 METIS_OPTION_NSEPS,
28-
!> 16 METIS_OPTION_UFACTOR,
29-
! 17 METIS_OPTION_NUMBERING,
30-
!> -- 0 C-style numbering is assumed that starts from 0
31-
!> -- 1 Fortran-style numbering is assumed that starts from 1
32-
!> Used for command-line parameter purposes
33-
!> 18 METIS_OPTION_HELP,
34-
!> 19 METIS_OPTION_TPWGTS,
35-
!> 20 METIS_OPTION_NCOMMON,
36-
!> 21 METIS_OPTION_NOOUTPUT,
37-
!> 22 METIS_OPTION_BALANCE,
38-
!> 23 METIS_OPTION_GTYPE,
39-
!> 24 METIS_OPTION_UBVEC
40-
integer, allocatable :: options(:)
41-
integer, parameter :: nvtxs=15, ncon=1
42-
integer :: xadj(nvtxs+1), adjncy(44), part(nvtxs), j, nparts, objval, refpart(nvtxs)
43-
integer, pointer :: vwgt=>null(), vsize=>null(), adjwgt=>null()
44-
real(dp), pointer :: tpwgts=>null(), ubvec=>null()
45-
46-
external :: METIS_SetDefaultOptions, METIS_PartGraphKway
477

48-
allocate(options(0:40))
8+
integer, parameter :: nvtxs=6, nedges=7, ncon=1, nparts =2
9+
integer :: xadj(nvtxs+1), adjncy(2*nedges), part(nvtxs), j, objval, refpart(nvtxs), adjwgt(2*nedges)
10+
integer :: options(40)
11+
integer, dimension(nvtxs) :: vwgt, vsize
12+
real :: tpwgts(nparts*ncon), ubvec(ncon)
4913

14+
external :: METIS_SetDefaultOptions, METIS_PartGraphKway
5015

5116
call METIS_SetDefaultOptions(options)
5217

53-
nparts=4
54-
objval=1
55-
options(0) = 1
56-
options(1) = 0
18+
options = 0
19+
options(7) = 10
5720
options(8) = 1
58-
options(17) = 1
21+
options(16) = 1
22+
options(17) = 30
23+
24+
ubvec = 1.001
25+
tpwgts = 0.5
5926

60-
part = 0
27+
vwgt = 1
28+
vsize = 1
29+
adjwgt = 1
6130

62-
xadj=[1, 3, 6, 9, 12, 14, 15, 21, 25, 29, 32, 34, 37, 40, 43, 45]
63-
adjncy=[2, 6, 1, 3, 7, 2, 4, 8, 3, 5, 9, 4, 10, 1, 7, 11, 12, 6, 8,&
64-
12, 3, 7, 9, 13, 4, 8, 10, 14, 5, 9, 15, 6, 12, 7, 11, 13, 8, 12, 14,&
65-
9, 13, 15, 10, 14]
31+
xadj=[0, 2, 5, 7, 9, 12, 14]
32+
adjncy=[1,3,0,4,2,1,5,0,4,3,1,5,4,2]
6633

6734
call METIS_PartGraphKway(nvtxs, ncon, xadj, adjncy, vwgt, vsize, adjwgt, nparts, tpwgts, ubvec, options, objval, part)
6835

6936
print '(15I3)', part
7037

71-
refpart = [3,1,1,2,4,3,4,2,2,4,3,1,1,2,4]
38+
refpart = [1,1,0,1,0,0]
7239

7340
if(any(part /= refpart)) error stop 'metis failed to order'
7441

0 commit comments

Comments
 (0)