5164
|
1 /* ========================================================================= */ |
|
2 /* === amd_f77wrapper ====================================================== */ |
|
3 /* ========================================================================= */ |
|
4 |
|
5 /* ------------------------------------------------------------------------- */ |
|
6 /* AMD Version 1.1 (Jan. 21, 2004), Copyright (c) 2004 by Timothy A. Davis, */ |
|
7 /* Patrick R. Amestoy, and Iain S. Duff. See ../README for License. */ |
|
8 /* email: davis@cise.ufl.edu CISE Department, Univ. of Florida. */ |
|
9 /* web: http://www.cise.ufl.edu/research/sparse/amd */ |
|
10 /* ------------------------------------------------------------------------- */ |
|
11 |
|
12 /* Fortran interface for the C-callable AMD library (int version only). This |
|
13 * is HIGHLY non-portable. You will need to modify this depending on how your |
|
14 * Fortran and C compilers behave. Two examples are provided. |
|
15 * |
|
16 * To avoid using I/O, and to avoid the extra porting step of a Fortran |
|
17 * function, the status code is returned as the first entry in P (P [0] in C |
|
18 * and P (1) in Fortran) if an error occurs. The error codes are negative |
|
19 * (-1: out of memory, -2: invalid matrix). |
|
20 * |
|
21 * For some C and Fortran compilers, the Fortran compiler appends a single "_" |
|
22 * after each routine name. C doesn't do this, so the translation is made |
|
23 * here. Some Fortran compilers don't append an underscore (xlf on IBM AIX, |
|
24 * for * example). |
|
25 * |
|
26 * Tested with the following compilers: |
|
27 * Solaris with cc and f77 from Sun WorkShop 6 update 1. |
|
28 * SGI Irix with MIPSpro cc and f77 compilers version 7.4 |
|
29 * Linux with GNU gcc or Intel's icc, and GNU g77 Intel's ifc Fortran compiler. |
|
30 * (any combination). Note that with g77, a call to amd_order in Fortran |
|
31 * gets translated to a call to amd_order__, with two underscores ("_"). |
|
32 * Thus, the Fortran names do not include an underscore. |
|
33 */ |
|
34 |
|
35 #include "amd.h" |
|
36 #include <stdio.h> |
|
37 |
|
38 /* ------------------------------------------------------------------------- */ |
|
39 /* Linux, Solaris, SGI */ |
|
40 /* ------------------------------------------------------------------------- */ |
|
41 |
|
42 void amdorder_ (int *n, const int *Ap, const int *Ai, int *P, |
|
43 double *Control, double *Info) |
|
44 { |
|
45 int result = amd_order (*n, Ap, Ai, P, Control, Info) ; |
|
46 if (result != AMD_OK && P) P [0] = result ; |
|
47 } |
|
48 |
|
49 void amddefaults_ (double *Control) |
|
50 { |
|
51 amd_defaults (Control) ; |
|
52 } |
|
53 |
|
54 void amdcontrol_ (double *Control) |
|
55 { |
|
56 fflush (stdout) ; |
|
57 amd_control (Control) ; |
|
58 fflush (stdout) ; |
|
59 } |
|
60 |
|
61 void amdinfo_ (double *Info) |
|
62 { |
|
63 fflush (stdout) ; |
|
64 amd_info (Info) ; |
|
65 fflush (stdout) ; |
|
66 } |
|
67 |
|
68 void amdpreproc_ (int *n, const int *Ap, const int *Ai, int *Rp, int *Ri) |
|
69 { |
|
70 int result = amd_preprocess (*n, Ap, Ai, Rp, Ri) ; |
|
71 if (result != AMD_OK && Rp) Rp [0] = result ; |
|
72 } |
|
73 |
|
74 /* ------------------------------------------------------------------------- */ |
|
75 /* IBM AIX. Probably Windows, Compaq Alpha, and HP Unix as well. */ |
|
76 /* ------------------------------------------------------------------------- */ |
|
77 |
|
78 void amdorder (int *n, const int *Ap, const int *Ai, int *P, |
|
79 double *Control, double *Info) |
|
80 { |
|
81 int result = amd_order (*n, Ap, Ai, P, Control, Info) ; |
|
82 if (result != AMD_OK && P) P [0] = result ; |
|
83 } |
|
84 |
|
85 void amddefaults (double *Control) |
|
86 { |
|
87 amd_defaults (Control) ; |
|
88 } |
|
89 |
|
90 void amdcontrol (double *Control) |
|
91 { |
|
92 fflush (stdout) ; |
|
93 amd_control (Control) ; |
|
94 fflush (stdout) ; |
|
95 } |
|
96 |
|
97 void amdinfo (double *Info) |
|
98 { |
|
99 fflush (stdout) ; |
|
100 amd_info (Info) ; |
|
101 fflush (stdout) ; |
|
102 } |
|
103 |
|
104 void amdpreproc (int *n, const int *Ap, const int *Ai, int *Rp, int *Ri) |
|
105 { |
|
106 int result = amd_preprocess (*n, Ap, Ai, Rp, Ri) ; |
|
107 if (result != AMD_OK && Rp) Rp [0] = result ; |
|
108 } |