-
Notifications
You must be signed in to change notification settings - Fork 220
/
scotch_example_2.f90
143 lines (110 loc) · 4.29 KB
/
scotch_example_2.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
!***********************************************************
!* **
!* NAME : scotch_example_2.f90 **
!* **
!* AUTHOR : Francois PELLEGRINI **
!* Frederic COUDERC **
!* **
!* function : Fortran testbed for the LibSCOTCH **
!* library routines. **
!* **
!* DATES : # Version 5.1 : from : 24 jul 2010 **
!* to 24 jul 2010 **
!* **
!* NOTES : # This program is to be compiled with **
!* the 64-bit version of the libScotch. **
!* It can be deduced from the fact that **
!* SCOTCH_Num values are declared as **
!* "integer*8" quantities. **
!* **
!* # To be compiled with : gfortran **
!* scotch_example_2.f90 **
!* -L/scotch/lib/path/ -lscotch **
!* -lscotcherr -lz -lpthread **
!* **
!234567*****************************************************
PROGRAM Scotch_test
! USE IFPOSIX
implicit none
include "scotchf.h"
real*8, dimension(Scotch_graphdim) :: Scotchgraph
real*8, dimension(Scotch_stratdim) :: Scotchstrat
integer :: ierr, file_u
integer*8 :: nnt, nelt, i, j, k
integer*8 :: base, flag, nparts
integer*8, dimension(2) :: indxtab
integer*8 :: baseval, vertnbr, vertidx, vendidx, veloidx
integer*8 :: vlblidx, edgenbr, edgeidx, edloidx
real*8, dimension(:,:), allocatable :: coordinates
real*8, dimension(:,:), allocatable :: connectivity
real*8, dimension(:,:), allocatable :: neighbors
integer*8, dimension(:), allocatable :: part
write(6,*) 'Starting'
call ScotchFstratInit ( Scotchstrat(1), ierr )
if (ierr /= 0) then
write(6,*) 'Scotch error : cannot initialize graph'
STOP
endif
call ScotchFgraphInit ( Scotchgraph(1), ierr )
if (ierr /= 0) then
write(6,*) 'Scotch error : cannot initialize strat'
STOP
endif
open(10,iostat=ierr,file="bump.grf")
! call PXFFILENO (10, file_u, ierr)
file_u = FNUM (10)
base = 1
flag = 0
call ScotchFgraphLoad ( Scotchgraph(1), file_u, base, flag, ierr )
if (ierr /= 0) then
write(6,*) 'Scotch error : cannot load graph'
STOP
endif
close(10)
call ScotchFgraphData ( Scotchgraph(1), indxtab(1), baseval, &
vertnbr, vertidx, vendidx, veloidx, vlblidx, edgenbr, &
edgeidx, edloidx )
write(6,*) baseval, vertnbr, vertidx, vendidx, veloidx, vlblidx, &
edgenbr, edgeidx, edloidx
write(6,*) indxtab(vertidx)
write(6,*) indxtab(vendidx)
write(6,*) indxtab(veloidx)
write(6,*) indxtab(vlblidx)
write(6,*) indxtab(edgeidx)
write(6,*) indxtab(edloidx)
call ScotchFgraphCheck ( Scotchgraph(1), ierr )
if (ierr /= 0) then
write(6,*) 'ERROR Scotch : Invalid check'
STOP
endif
open (10,iostat=ierr,file="test.grf")
! call PXFFILENO (10, file_u, ierr)
file_u = FNUM (10)
call ScotchFgraphSave ( Scotchgraph(1), file_u, ierr )
if (ierr /= 0) then
write(6,*) 'ERROR Scotch : Invalid save '
STOP
endif
close(10)
nparts = 8
call ScotchFstratGraphMapChoose ( Scotchstrat(1), &
SCOTCH_STRATQUALITY, nparts, 0.01, ierr )
if (ierr /= 0) then
write(6,*) 'ERROR Scotch : Cannot initialize partitioning&
&strategy'
STOP
endif
allocate(part(1:vertnbr + 1))
call ScotchFgraphPart ( Scotchgraph(1), nparts, Scotchstrat(1), &
part(1), ierr )
if (ierr /= 0) then
write(6,*) 'ERROR Scotch : Cannot partition graph'
STOP
endif
do i=1,vertnbr + 1
write(10,*) i,part(i)
enddo
call ScotchFgraphExit ( Scotchgraph(1) )
call ScotchFstratExit ( Scotchstrat(1) )
write(6,*) 'Complete'
END PROGRAM Scotch_test