LORENE
facto_ini.C
1/*
2 * Copyright (c) 1999-2000 Jean-Alain Marck
3 * Copyright (c) 1999-2001 Eric Gourgoulhon
4 *
5 * This file is part of LORENE.
6 *
7 * LORENE is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * LORENE is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with LORENE; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23
24char facto_ini_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/FFT991/facto_ini.C,v 1.5 2014/10/15 12:48:22 j_novak Exp $" ;
25
26
27/*
28 * Routine d'initialisation des tables de factorisation de n
29 * Version speciale FAX
30 *
31 * Entree:
32 * n nombre de degres de liberte
33 * Sortie:
34 * facto_ini pointeur int* sur la table de factorisation de n
35 *
36 * Cette routine doit etre entierement en zone critique
37 *
38 */
39
40/*
41 * $Id: facto_ini.C,v 1.5 2014/10/15 12:48:22 j_novak Exp $
42 * $Log: facto_ini.C,v $
43 * Revision 1.5 2014/10/15 12:48:22 j_novak
44 * Corrected namespace declaration.
45 *
46 * Revision 1.4 2014/10/13 08:53:18 j_novak
47 * Lorene classes and functions now belong to the namespace Lorene.
48 *
49 * Revision 1.3 2014/10/06 15:18:47 j_novak
50 * Modified #include directives to use c++ syntax.
51 *
52 * Revision 1.2 2009/11/25 08:00:54 j_novak
53 * Removed a #pragma directive
54 *
55 * Revision 1.1 2004/12/21 17:06:01 j_novak
56 * Added all files for using fftw3.
57 *
58 * Revision 1.4 2003/01/31 10:31:24 e_gourgoulhon
59 * Suppressed the directive #include <malloc.h> for malloc is defined
60 * in <stdlib.h>
61 *
62 * Revision 1.3 2002/10/16 14:36:54 j_novak
63 * Reorganization of #include instructions of standard C++, in order to
64 * use experimental version 3 of gcc.
65 *
66 * Revision 1.2 2002/09/09 13:00:40 e_gourgoulhon
67 * Modification of declaration of Fortran 77 prototypes for
68 * a better portability (in particular on IBM AIX systems):
69 * All Fortran subroutine names are now written F77_* and are
70 * defined in the new file C++/Include/proto_f77.h.
71 *
72 * Revision 1.1.1.1 2001/11/20 15:19:29 e_gourgoulhon
73 * LORENE
74 *
75 * Revision 2.1 1999/11/24 16:21:27 eric
76 * Modif affichage.
77 *
78 * Revision 2.0 1999/02/22 15:38:52 hyc
79 * *** empty log message ***
80 *
81 *
82 * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/FFT991/facto_ini.C,v 1.5 2014/10/15 12:48:22 j_novak Exp $
83 *
84 */
85
86// headers du C
87#include <cmath>
88#include <cstdlib>
89
90// Prototypes of F77 subroutines
91#include "headcpp.h"
92#include "proto_f77.h"
93
94namespace Lorene {
95int *facto_ini( int n )
96{
97
98// Variables locales statiques
99// ---------------------------
100#define NMAX 30 /* Nombre maximun de dimensions differentes */
101static int *table_facto[NMAX] ; /* Tableau des pointeurs sur les tableaux */
102static int nwork = 0 ; /* Nombre de tableaux deja initialises */
103static int tbn[NMAX] ; /* Tableau des points deja initialises */
104static int trois = 3 ; // On aurait aime ecrire: "const int trois=3 ;"
105int indice ;
106
107
108//#pragma critical (loch_facto_ini)
109{
110 // Ce nombre de points a-t-il deja ete utilise ?
111 int i ;
112 indice = -1 ;
113 for ( i=0 ; i < nwork ; i++ ) {
114 if ( tbn[i] == n ) indice = i ;
115 }
116
117// Initialisation si necessaire
118 if (indice == -1) { /* Il faut une nouvelle initialisation */
119 if ( nwork >= NMAX ) {
120 cout << "facto_ini : nwork >= NMAX !" << endl ;
121 abort() ;
122 }
123 indice = nwork ; nwork++ ; tbn[indice] = n ;
124
125 table_facto[indice] = (int *) malloc( sizeof(int) * 20 ) ;
126// table_facto[indice] = new int[20] ;
127 if ( table_facto[indice] == 0 ) {
128 cout << "facto_ini : malloc error !" << endl ;
129 abort() ;
130 }
131
132 F77_fax( table_facto[indice], &n, &trois ) ;
133 }
134
135} // Fin de zone critique
136
137 // Valeurs de retour
138 return table_facto[indice] ;
139
140}
141}
Lorene prototypes.
Definition app_hor.h:64