/[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 121 - (show annotations)
Fri May 6 04:26:16 2005 UTC (14 years, 10 months ago) by jgs
File MIME type: text/plain
File size: 3365 byte(s)
Merge of development branch back to main trunk on 2005-05-06

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 maybelong;
33 #define MAYBELONG_MAX INT_MAX
34 #define EPSILON DBL_EPSILON
35
36 /**************************************************************/
37
38 /* some useful functions: */
39
40 #define FALSE 0
41 #define TRUE 1
42 #define UNKNOWN -1
43 #define DBLE(_x_) (double)(_x_)
44 #define INDEX1(_X1_) (_X1_)
45 #define INDEX2(_X1_,_X2_,_N1_) ((_X1_)+(_N1_)*(_X2_))
46 #define INDEX3(_X1_,_X2_,_X3_,_N1_,_N2_) ((_X1_)+(_N1_)*INDEX2(_X2_,_X3_,_N2_))
47 #define INDEX4(_X1_,_X2_,_X3_,_X4_,_N1_,_N2_,_N3_) ((_X1_)+(_N1_)*INDEX3(_X2_,_X3_,_X4_,_N2_,_N3_))
48 #define INDEX5(_X1_,_X2_,_X3_,_X4_,_X5_,_N1_,_N2_,_N3_,_N4_) ((_X1_)+(_N1_)*INDEX4(_X2_,_X3_,_X4_,_X5_,_N2_,_N3_,_N4_))
49 #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_))
50
51 #define MAX(_arg1_,_arg2_) ((_arg1_)>(_arg2_) ? (_arg1_) : (_arg2_))
52 #define MIN(_arg1_,_arg2_) ((_arg1_)>(_arg2_) ? (_arg2_) : (_arg1_))
53 #define ABS(_arg_) MAX((_arg_),-(_arg_))
54 /**************************************************************/
55
56 /* memory allocation: */
57
58 #define TMPMEMALLOC(_LENGTH_,_TYPE_) (_TYPE_*) malloc(((size_t)(_LENGTH_))*sizeof(_TYPE_))
59 #define TMPMEMFREE(_PTR_) if ((void *)(_PTR_) != NULL ) { free(_PTR_); (_PTR_) = NULL; }
60 #ifdef __ECC
61 #define MEMALLOC(_LENGTH_,_TYPE_) (_TYPE_*) malloc(((size_t)(_LENGTH_))*sizeof(_TYPE_))
62 #define MEMFREE(_PTR_) if ((void *)(_PTR_) != NULL ) { free(_PTR_); (_PTR_) = NULL; }
63 #ifdef _OPENMP
64 #define THREAD_MEMALLOC(_LENGTH_,_TYPE_) (_TYPE_*) kmp_malloc(((size_t)(_LENGTH_))*sizeof(_TYPE_))
65 #define THREAD_MEMFREE(_PTR_) if ((void *)(_PTR_) != NULL ) { kmp_free(_PTR_); (_PTR_) = NULL; }
66 #else
67 #define THREAD_MEMALLOC(_LENGTH_,_TYPE_) TMPMEMALLOC(_LENGTH_,_TYPE_)
68 #define THREAD_MEMFREE(_PTR_) TMPMEMFREE(_PTR_)
69 #endif
70 #else
71 #define MEMALLOC(_LENGTH_,_TYPE_) (_TYPE_*) malloc(((size_t)(_LENGTH_))*sizeof(_TYPE_))
72 #define MEMFREE(_PTR_) if ((void *)(_PTR_) != NULL ) { free(_PTR_); (_PTR_) = NULL; }
73 #define THREAD_MEMALLOC(_LENGTH_,_TYPE_) TMPMEMALLOC(_LENGTH_,_TYPE_)
74 #define THREAD_MEMFREE(_PTR_) TMPMEMFREE(_PTR_)
75 #endif
76
77 #endif /* #ifndef INC_FINLEY_COMMON */
78
79 /*
80 * $Log$
81 * Revision 1.5 2005/05/06 04:26:15 jgs
82 * Merge of development branch back to main trunk on 2005-05-06
83 *
84 * Revision 1.1.1.1.2.2 2005/04/14 06:53:11 gross
85 * a problem with header files fixed: bug appeared for case -O0 -g in the icc compiler only
86 *
87 * Revision 1.1.1.1.2.1 2004/11/24 01:37:13 gross
88 * some changes dealing with the integer overflow in memory allocation. Finley solves 4M unknowns now
89 *
90 *
91 *
92 */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26