/[escript]/trunk/esys2/finley/src/finleyC/Common.h
ViewVC logotype

Contents of /trunk/esys2/finley/src/finleyC/Common.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 123 - (show annotations)
Fri Jul 8 04:08:13 2005 UTC (14 years, 4 months ago) by jgs
File MIME type: text/plain
File size: 3649 byte(s)
Merge of development branch back to main trunk on 2005-07-08

1 /* $Id$ */
2
3 #ifndef INC_FINLEY_COMMON
4 #define INC_FINLEY_COMMON
5
6 /**************************************************************/
7
8 /* Finley finite element solver: common include file */
9
10 /**************************************************************/
11
12 /* Copyrights by ACcESS Australia, 2003 */
13 /* Version: $Id$ */
14
15 /**************************************************************/
16
17 /* some system values */
18
19 #include <float.h>
20 #include <stdio.h>
21 #include <limits.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <math.h>
25
26 #define LenString_MAX FILENAME_MAX*2
27 #define LenErrorMsg_MAX LenString_MAX
28
29 /* on some arcitectures it could be a good idea to use long rather than int */
30 /* this has not really been tested */
31
32 typedef int dim_t;
33 typedef int index_t;
34 typedef int bool_t;
35 typedef int type_t;
36 typedef int err_t;
37 #define INDEX_T_MAX INT_MAX
38 #define EPSILON DBL_EPSILON
39
40 /**************************************************************/
41
42 /* some useful functions: */
43
44 #define FALSE 0
45 #define TRUE 1
46 #define UNKNOWN -1
47 #define DBLE(_x_) (double)(_x_)
48 #define INDEX1(_X1_) (_X1_)
49 #define INDEX2(_X1_,_X2_,_N1_) ((_X1_)+(_N1_)*(_X2_))
50 #define INDEX3(_X1_,_X2_,_X3_,_N1_,_N2_) ((_X1_)+(_N1_)*INDEX2(_X2_,_X3_,_N2_))
51 #define INDEX4(_X1_,_X2_,_X3_,_X4_,_N1_,_N2_,_N3_) ((_X1_)+(_N1_)*INDEX3(_X2_,_X3_,_X4_,_N2_,_N3_))
52 #define INDEX5(_X1_,_X2_,_X3_,_X4_,_X5_,_N1_,_N2_,_N3_,_N4_) ((_X1_)+(_N1_)*INDEX4(_X2_,_X3_,_X4_,_X5_,_N2_,_N3_,_N4_))
53 #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_))
54
55 #define MAX(_arg1_,_arg2_) ((_arg1_)>(_arg2_) ? (_arg1_) : (_arg2_))
56 #define MIN(_arg1_,_arg2_) ((_arg1_)>(_arg2_) ? (_arg2_) : (_arg1_))
57 #define ABS(_arg_) MAX((_arg_),-(_arg_))
58 /**************************************************************/
59
60 /* memory allocation: */
61
62 #define TMPMEMALLOC(_LENGTH_,_TYPE_) (_TYPE_*) malloc(((size_t)(_LENGTH_))*sizeof(_TYPE_))
63 #define TMPMEMFREE(_PTR_) if ((void *)(_PTR_) != NULL ) { free(_PTR_); (_PTR_) = NULL; }
64 #ifdef __ECC
65 #define MEMALLOC(_LENGTH_,_TYPE_) (_TYPE_*) malloc(((size_t)(_LENGTH_))*sizeof(_TYPE_))
66 #define MEMFREE(_PTR_) if ((void *)(_PTR_) != NULL ) { free(_PTR_); (_PTR_) = NULL; }
67 #ifdef _OPENMP
68 #define THREAD_MEMALLOC(_LENGTH_,_TYPE_) (_TYPE_*) kmp_malloc(((size_t)(_LENGTH_))*sizeof(_TYPE_))
69 #define THREAD_MEMFREE(_PTR_) if ((void *)(_PTR_) != NULL ) { kmp_free(_PTR_); (_PTR_) = NULL; }
70 #else
71 #define THREAD_MEMALLOC(_LENGTH_,_TYPE_) TMPMEMALLOC(_LENGTH_,_TYPE_)
72 #define THREAD_MEMFREE(_PTR_) TMPMEMFREE(_PTR_)
73 #endif
74 #else
75 #define MEMALLOC(_LENGTH_,_TYPE_) (_TYPE_*) malloc(((size_t)(_LENGTH_))*sizeof(_TYPE_))
76 #define MEMFREE(_PTR_) if ((void *)(_PTR_) != NULL ) { free(_PTR_); (_PTR_) = NULL; }
77 #define THREAD_MEMALLOC(_LENGTH_,_TYPE_) TMPMEMALLOC(_LENGTH_,_TYPE_)
78 #define THREAD_MEMFREE(_PTR_) TMPMEMFREE(_PTR_)
79 #endif
80
81 #endif /* #ifndef INC_FINLEY_COMMON */
82
83 /*
84 * $Log$
85 * Revision 1.6 2005/07/08 04:07:48 jgs
86 * Merge of development branch back to main trunk on 2005-07-08
87 *
88 * Revision 1.5 2005/05/06 04:26:15 jgs
89 * Merge of development branch back to main trunk on 2005-05-06
90 *
91 * Revision 1.1.1.1.2.3 2005/06/29 02:34:48 gross
92 * some changes towards 64 integers in finley
93 *
94 * Revision 1.1.1.1.2.2 2005/04/14 06:53:11 gross
95 * a problem with header files fixed: bug appeared for case -O0 -g in the icc compiler only
96 *
97 * Revision 1.1.1.1.2.1 2004/11/24 01:37:13 gross
98 * some changes dealing with the integer overflow in memory allocation. Finley solves 4M unknowns now
99 *
100 *
101 *
102 */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26