Blame view

fvn_sparse/AMD/Demo/amd_f77wrapper.c 3.24 KB
422234dc3   daniau   git-svn-id: https...
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
  /* ========================================================================= */
  /* === amd_f77wrapper ====================================================== */
  /* ========================================================================= */
  
  /* ------------------------------------------------------------------------- */
  /* AMD Copyright (c) by Timothy A. Davis,				     */
  /* Patrick R. Amestoy, and Iain S. Duff.  See ../README.txt for License.     */
  /* email: davis at cise.ufl.edu    CISE Department, Univ. of Florida.        */
  /* web: http://www.cise.ufl.edu/research/sparse/amd                          */
  /* ------------------------------------------------------------------------- */
  
  /* Fortran interface for the C-callable AMD library (int version only).  This
   * is HIGHLY non-portable.  You will need to modify this depending on how your
   * Fortran and C compilers behave.  Two examples are provided.
   *
   * To avoid using I/O, and to avoid the extra porting step of a Fortran
   * function, the status code is returned as the first entry in P (P [0] in C
   * and P (1) in Fortran) if an error occurs.  The error codes are negative
   * (-1: out of memory, -2: invalid matrix).
   *
   * For some C and Fortran compilers, the Fortran compiler appends a single "_"
   * after each routine name.  C doesn't do this, so the translation is made
   * here.  Some Fortran compilers don't append an underscore (xlf on IBM AIX,
   * for * example).
   *
   * Tested with the following compilers:
   * Solaris with cc and f77 from Sun WorkShop 6 update 1.
   * SGI Irix with MIPSpro cc and f77 compilers version 7.4
   * Linux with GNU gcc or Intel's icc, and GNU g77 Intel's ifc Fortran compiler.
   *	(any combination).  Note that with g77, a call to amd_order in Fortran
   *	gets translated to a call to amd_order__, with two underscores ("_").
   *	Thus, the Fortran names do not include an underscore.
   */
  
  #include "amd.h"
  #include <stdio.h>
  
  /* ------------------------------------------------------------------------- */
  /* Linux, Solaris, SGI */
  /* ------------------------------------------------------------------------- */
  
  void amdorder_ (int *n, const int *Ap, const int *Ai, int *P,
      double *Control, double *Info)
  {
      int result = amd_order (*n, Ap, Ai, P, Control, Info) ;
      if (result != AMD_OK && P) P [0] = result ;
  }
  
  void amddefaults_ (double *Control)
  {
      amd_defaults (Control) ;
  }
  
  void amdcontrol_ (double *Control)
  {
      fflush (stdout) ;
      amd_control (Control) ;
      fflush (stdout) ;
  }
  
  void amdinfo_ (double *Info)
  {
      fflush (stdout) ;
      amd_info (Info) ;
      fflush (stdout) ;
  }
  
  /* ------------------------------------------------------------------------- */
  /* IBM AIX.  Probably Windows, Compaq Alpha, and HP Unix as well. */
  /* ------------------------------------------------------------------------- */
  
  void amdorder (int *n, const int *Ap, const int *Ai, int *P,
      double *Control, double *Info)
  {
      int result = amd_order (*n, Ap, Ai, P, Control, Info) ;
      if (result != AMD_OK && P) P [0] = result ;
  }
  
  void amddefaults (double *Control)
  {
      amd_defaults (Control) ;
  }
  
  void amdcontrol (double *Control)
  {
      fflush (stdout) ;
      amd_control (Control) ;
      fflush (stdout) ;
  }
  
  void amdinfo (double *Info)
  {
      fflush (stdout) ;
      amd_info (Info) ;
      fflush (stdout) ;
  }