LORENE
trigo_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 
24 
25 
26 /*
27  * Routine d'initialisation des tables trigo
28  * Version speciale FAX
29  *
30  * Entree:
31  * n nombre de degres de liberte
32  * Sortie:
33  * trigo_ini pointeur double* sur la table trigo
34  *
35  * Doit etre en zone critique
36  */
37 
38 /*
39  * $Id: trigo_ini.C,v 1.5 2016/12/05 16:18:04 j_novak Exp $
40  * $Log: trigo_ini.C,v $
41  * Revision 1.5 2016/12/05 16:18:04 j_novak
42  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
43  *
44  * Revision 1.4 2014/10/15 12:48:22 j_novak
45  * Corrected namespace declaration.
46  *
47  * Revision 1.3 2014/10/13 08:53:18 j_novak
48  * Lorene classes and functions now belong to the namespace Lorene.
49  *
50  * Revision 1.2 2014/10/06 15:18:47 j_novak
51  * Modified #include directives to use c++ syntax.
52  *
53  * Revision 1.1 2004/12/21 17:06:01 j_novak
54  * Added all files for using fftw3.
55  *
56  * Revision 1.5 2003/12/19 16:21:47 j_novak
57  * Shadow hunt
58  *
59  * Revision 1.4 2003/01/31 10:31:24 e_gourgoulhon
60  * Suppressed the directive #include <malloc.h> for malloc is defined
61  * in <stdlib.h>
62  *
63  * Revision 1.3 2002/10/16 14:36:57 j_novak
64  * Reorganization of #include instructions of standard C++, in order to
65  * use experimental version 3 of gcc.
66  *
67  * Revision 1.2 2002/09/09 13:00:40 e_gourgoulhon
68  * Modification of declaration of Fortran 77 prototypes for
69  * a better portability (in particular on IBM AIX systems):
70  * All Fortran subroutine names are now written F77_* and are
71  * defined in the new file C++/Include/proto_f77.h.
72  *
73  * Revision 1.1.1.1 2001/11/20 15:19:29 e_gourgoulhon
74  * LORENE
75  *
76  * Revision 2.1 1999/11/24 16:23:22 eric
77  * Modif affichage.
78  *
79  * Revision 2.0 1999/02/22 15:29:33 hyc
80  * *** empty log message ***
81  *
82  *
83  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/FFT991/trigo_ini.C,v 1.5 2016/12/05 16:18:04 j_novak Exp $
84  *
85  */
86 
87 // headers du C
88 #include <cmath>
89 #include <cstdlib>
90 
91 // Prototypes of F77 subroutines
92 #include "headcpp.h"
93 #include "proto_f77.h"
94 
95 namespace Lorene {
96 double *trigo_ini( int n )
97 {
98 // Variables locales statiques
99 // ---------------------------
100 #define NMAX 30 /* Nombre maximun de dimensions differentes */
101 static double *table_trigo[NMAX] ; /* Tableau des pointeurs sur les tableaux */
102 static int nwork = 0 ; /* Nombre de tableaux deja initialises */
103 static int tbn[NMAX] ; /* Tableau des points deja initialises */
104 static int trois = 3 ;
105 int indice ;
106 
107 {
108  // Ce nombre de points a-t-il deja ete utilise ?
109  indice = -1 ;
110  int i ;
111  for ( i=0 ; i < nwork ; i++ ) {
112  if ( tbn[i] == n ) indice = i ;
113  }
114 
115  // Initialisation
116  if (indice == -1) { /* Il faut une nouvelle initialisation */
117  if ( nwork >= NMAX ) {
118  cout << "trigo_ini : nwork >= NMAX !" << endl ;
119  abort() ;
120  }
121  indice = nwork ; nwork++ ; tbn[indice] = n ;
122 
123 // table_trigo[indice] = new double[3*n/2 + 1] ;
124  table_trigo[indice] = (double *) malloc( sizeof(double) * (3*n/2 + 1) ) ;
125  if ( table_trigo[indice] == 0 ) {
126  cout << "trigo_ini : malloc error !" << endl ;
127  abort() ;
128  }
129 
130  F77_fftrig( table_trigo[indice], &n, &trois ) ;
131  }
132 
133  } // Fin de zone critique
134 
135  // Valeurs de retour
136  return table_trigo[indice] ;
137 }
138 }
Lorene prototypes.
Definition: app_hor.h:67