/[escript]/trunk/paso/src/Common.h
ViewVC logotype

Contents of /trunk/paso/src/Common.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 584 - (show annotations)
Thu Mar 9 23:03:38 2006 UTC (13 years, 6 months ago) by gross
File MIME type: text/plain
File size: 3395 byte(s)
eigenvalues: compiles and passes tests on altix now
1 /* $Id$ */
2
3 #ifndef INC_PASO_COMMON
4 #define INC_PASO_COMMON
5
6
7
8 /**************************************************************/
9
10 /* Finley finite element solver: common include file */
11
12 /**************************************************************/
13
14 /* Copyrights by ACcESS Australia, 2003 */
15 /* Version: $Id$ */
16
17 /**************************************************************/
18
19 /* some system values */
20
21 #include <float.h>
22 #include <stdio.h>
23 #include <limits.h>
24 #include <stdlib.h>
25 #include <string.h>
26 #include <math.h>
27
28 #define LenString_MAX FILENAME_MAX*2
29 #define LenErrorMsg_MAX LenString_MAX
30
31 /* on some arcitectures it could be a good idea to use long rather than int */
32 /* this has not really been tested */
33
34 typedef int dim_t;
35 typedef int index_t;
36 typedef int bool_t;
37 typedef int type_t;
38 typedef int err_t;
39
40 #define INDEX_T_MAX INT_MAX
41 #define EPSILON DBL_EPSILON
42
43 /**************************************************************/
44
45 /* some useful functions: */
46
47 #define FALSE 0
48 #define TRUE 1
49 #define UNKNOWN -1
50 #define DBLE(_x_) (double)(_x_)
51 #define INDEX1(_X1_) (_X1_)
52 #define INDEX2(_X1_,_X2_,_N1_) ((_X1_)+(_N1_)*(_X2_))
53 #define INDEX3(_X1_,_X2_,_X3_,_N1_,_N2_) ((_X1_)+(_N1_)*INDEX2(_X2_,_X3_,_N2_))
54 #define INDEX4(_X1_,_X2_,_X3_,_X4_,_N1_,_N2_,_N3_) ((_X1_)+(_N1_)*INDEX3(_X2_,_X3_,_X4_,_N2_,_N3_))
55 #define INDEX5(_X1_,_X2_,_X3_,_X4_,_X5_,_N1_,_N2_,_N3_,_N4_) ((_X1_)+(_N1_)*INDEX4(_X2_,_X3_,_X4_,_X5_,_N2_,_N3_,_N4_))
56 #define INDEX6(_X1_,_X2_,_X3_,_X4_,_X5_,_X6_,_N1_,_N2_,_N3_,_N4_,_N5_) ((_X1_)+(_N1_)*INDEX5(_X2_,_X3_,_X4_,_X5_,_X6_,_N2_,_N3_,_N4_,_N5_))
57
58 #define MAX(_arg1_,_arg2_) ((_arg1_)>(_arg2_) ? (_arg1_) : (_arg2_))
59 #define MIN(_arg1_,_arg2_) ((_arg1_)>(_arg2_) ? (_arg2_) : (_arg1_))
60 #define ABS(_arg_) MAX((_arg_),-(_arg_))
61 /**************************************************************/
62
63 /* memory allocation: */
64
65 #define TMPMEMALLOC(_LENGTH_,_TYPE_) (_TYPE_*) malloc(((size_t)(_LENGTH_))*sizeof(_TYPE_))
66 #define TMPMEMFREE(_PTR_) if ((void *)(_PTR_) != NULL ) { free(_PTR_); (_PTR_) = NULL; }
67 #ifdef __ECC
68 #define MEMALLOC(_LENGTH_,_TYPE_) (_TYPE_*) malloc(((size_t)(_LENGTH_))*sizeof(_TYPE_))
69 #define MEMFREE(_PTR_) if ((void *)(_PTR_) != NULL ) { free(_PTR_); (_PTR_) = NULL; }
70 #ifdef _OPENMP
71 #define THREAD_MEMALLOC(_LENGTH_,_TYPE_) (_TYPE_*) kmp_malloc(((size_t)(_LENGTH_))*sizeof(_TYPE_))
72 #define THREAD_MEMFREE(_PTR_) if ((void *)(_PTR_) != NULL ) { kmp_free(_PTR_); (_PTR_) = NULL; }
73 #else
74 #define THREAD_MEMALLOC(_LENGTH_,_TYPE_) TMPMEMALLOC(_LENGTH_,_TYPE_)
75 #define THREAD_MEMFREE(_PTR_) TMPMEMFREE(_PTR_)
76 #endif
77 #else
78 #define MEMALLOC(_LENGTH_,_TYPE_) (_TYPE_*) malloc(((size_t)(_LENGTH_))*sizeof(_TYPE_))
79 #define MEMFREE(_PTR_) if ((void *)(_PTR_) != NULL ) { free(_PTR_); (_PTR_) = NULL; }
80 #define THREAD_MEMALLOC(_LENGTH_,_TYPE_) TMPMEMALLOC(_LENGTH_,_TYPE_)
81 #define THREAD_MEMFREE(_PTR_) TMPMEMFREE(_PTR_)
82 #endif
83
84 #endif /* #ifndef INC_PASO_COMMON */
85
86 /*
87 * $Log$
88 * Revision 1.2 2005/09/15 03:44:38 jgs
89 * Merge of development branch dev-02 back to main trunk on 2005-09-15
90 *
91 * Revision 1.1.2.1 2005/09/05 06:29:46 gross
92 * These files have been extracted from finley to define a stand alone libray for iterative
93 * linear solvers on the ALTIX. main entry through Paso_solve. this version compiles but
94 * has not been tested yet.
95 *
96 *
97 */

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26