1C ----------------------------------------------------------------------
2C AMD, Copyright (c) by Timothy A. Davis, Patrick R.
3C Amestoy, and Iain S. Duff.  See ../README.txt for License.
4C email: DrTimothyAldenDavis@gmail.com
5C ----------------------------------------------------------------------
6
7C This program provides an example of how to call the Fortran version
8C of AMD.  It uses the same matrix as the amd_simple.c demo (in C).
9C Note that the diagonal entries are not present, and the matrix is
10C symmetric.
11
12        INTEGER N, NZ, J, K, P, IWLEN, PFREE, NCMPA
13        PARAMETER (N = 5, NZ = 10, IWLEN = 17)
14        INTEGER AP (N+1), AI (NZ), LAST (N), PE (N), LEN (N), ELEN (N),
15     $      IW (IWLEN), DEGREE (N), NV (N), NEXT (N), HEAD (N), W (N)
16        DATA AP / 1, 2,     5,     8,  9,  11/
17        DATA AI / 2, 1,3,5, 2,4,5, 3,  2,3   /
18
19C       load the matrix into the AMD workspace
20        DO 10 J = 1,N
21            PE (J) = AP (J)
22            LEN (J) = AP (J+1) - AP (J)
2310      CONTINUE
24        DO 20 P = 1,NZ
25            IW (P) = AI (P)
2620      CONTINUE
27        PFREE = NZ + 1
28
29C       order the matrix (destroys the copy of A in IW, PE, and LEN)
30        CALL AMD (N, PE, IW, LEN, IWLEN, PFREE, NV, NEXT, LAST, HEAD,
31     $      ELEN, DEGREE, NCMPA, W)
32
33        DO 60 K = 1, N
34            PRINT 50, K, LAST (K)
3550          FORMAT ('P (',I2,') = ', I2)
3660      CONTINUE
37        END
38