facto_ini.C

00001 /*
00002  *   Copyright (c) 1999-2000 Jean-Alain Marck
00003  *   Copyright (c) 1999-2001 Eric Gourgoulhon
00004  *
00005  *   This file is part of LORENE.
00006  *
00007  *   LORENE is free software; you can redistribute it and/or modify
00008  *   it under the terms of the GNU General Public License as published by
00009  *   the Free Software Foundation; either version 2 of the License, or
00010  *   (at your option) any later version.
00011  *
00012  *   LORENE is distributed in the hope that it will be useful,
00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *   GNU General Public License for more details.
00016  *
00017  *   You should have received a copy of the GNU General Public License
00018  *   along with LORENE; if not, write to the Free Software
00019  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  *
00021  */
00022 
00023 
00024 char facto_ini_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/FFT991/facto_ini.C,v 1.2 2009/11/25 08:00:54 j_novak Exp $" ;
00025 
00026 
00027 /* 
00028  * Routine d'initialisation des tables de factorisation de n
00029  * Version speciale FAX
00030  *
00031  * Entree:
00032  *   n      nombre de degres de liberte
00033  * Sortie: 
00034  *   facto_ini  pointeur int* sur la table de factorisation de n 
00035  *
00036  * Cette routine doit etre entierement en zone critique
00037  *
00038  */
00039 
00040 /*
00041  * $Id: facto_ini.C,v 1.2 2009/11/25 08:00:54 j_novak Exp $
00042  * $Log: facto_ini.C,v $
00043  * Revision 1.2  2009/11/25 08:00:54  j_novak
00044  * Removed a #pragma directive
00045  *
00046  * Revision 1.1  2004/12/21 17:06:01  j_novak
00047  * Added all files for using fftw3.
00048  *
00049  * Revision 1.4  2003/01/31 10:31:24  e_gourgoulhon
00050  * Suppressed the directive #include <malloc.h> for malloc is defined
00051  * in <stdlib.h>
00052  *
00053  * Revision 1.3  2002/10/16 14:36:54  j_novak
00054  * Reorganization of #include instructions of standard C++, in order to
00055  * use experimental version 3 of gcc.
00056  *
00057  * Revision 1.2  2002/09/09 13:00:40  e_gourgoulhon
00058  * Modification of declaration of Fortran 77 prototypes for
00059  * a better portability (in particular on IBM AIX systems):
00060  * All Fortran subroutine names are now written F77_* and are
00061  * defined in the new file C++/Include/proto_f77.h.
00062  *
00063  * Revision 1.1.1.1  2001/11/20 15:19:29  e_gourgoulhon
00064  * LORENE
00065  *
00066  * Revision 2.1  1999/11/24  16:21:27  eric
00067  * Modif affichage.
00068  *
00069  * Revision 2.0  1999/02/22  15:38:52  hyc
00070  * *** empty log message ***
00071  *
00072  *
00073  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/FFT991/facto_ini.C,v 1.2 2009/11/25 08:00:54 j_novak Exp $
00074  *
00075  */
00076 
00077 // headers du C
00078 #include <math.h>
00079 #include <stdlib.h>
00080 
00081 // Prototypes of F77 subroutines
00082 #include "headcpp.h"
00083 #include "proto_f77.h"
00084 
00085 // Variable de loch
00086 //int loch_facto_ini = 0 ;
00087 
00088 int *facto_ini( int n )
00089 {
00090 
00091 // Variables locales statiques
00092 // ---------------------------
00093 #define NMAX    30          /* Nombre maximun de dimensions differentes */
00094 static  int     *table_facto[NMAX] ;    /* Tableau des pointeurs sur les tableaux */
00095 static  int nwork = 0 ;     /* Nombre de tableaux deja initialises */
00096 static  int tbn[NMAX] ;     /* Tableau des points deja initialises */
00097 static  int trois = 3 ;         // On aurait aime ecrire: "const int trois=3 ;"
00098 int indice ;
00099 
00100 
00101 //#pragma critical (loch_facto_ini)
00102 {
00103     // Ce nombre de points a-t-il deja ete utilise ?
00104     int i ;
00105     indice = -1 ;
00106     for ( i=0 ; i < nwork ; i++ ) {
00107     if ( tbn[i] == n ) indice = i ;
00108     }
00109 
00110 // Initialisation si necessaire
00111     if (indice == -1) { /* Il faut une nouvelle initialisation */
00112         if ( nwork >= NMAX ) {
00113             cout << "facto_ini : nwork >= NMAX !" << endl ; 
00114             abort() ; 
00115             }
00116         indice = nwork ; nwork++ ; tbn[indice] = n ;
00117 
00118         table_facto[indice] = (int *) malloc( sizeof(int) * 20 ) ;
00119 //      table_facto[indice] = new int[20] ;
00120         if ( table_facto[indice] == 0 ) {
00121             cout << "facto_ini : malloc error !" << endl ; 
00122             abort() ; 
00123             }
00124 
00125         F77_fax( table_facto[indice], &n, &trois ) ;
00126         }
00127 
00128 }   // Fin de zone critique
00129 
00130     // Valeurs de retour
00131     return table_facto[indice] ;
00132 
00133 }

Generated on Tue Feb 7 01:35:17 2012 for LORENE by  doxygen 1.4.6