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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 757 - (hide annotations)
Mon Jun 26 13:12:56 2006 UTC (13 years, 3 months ago) by woo409
File MIME type: text/plain
File size: 4829 byte(s)
+ Merge of intelc_win32 branch (revision 741:755) with trunk. Tested on iVEC altix (run_tests and py_tests all pass)

1 jgs 150 /* $Id$ */
2    
3 dhawcroft 631 /*
4     ********************************************************************************
5 dhawcroft 633 * Copyright 2006 by ACcESS MNRF *
6 dhawcroft 631 * *
7     * http://www.access.edu.au *
8     * Primary Business: Queensland, Australia *
9     * Licensed under the Open Software License version 3.0 *
10     * http://www.opensource.org/licenses/osl-3.0.php *
11     ********************************************************************************
12     */
13    
14 jgs 150 #ifndef INC_PASO_COMMON
15     #define INC_PASO_COMMON
16    
17 gross 584
18    
19 jgs 150 /**************************************************************/
20    
21     /* Finley finite element solver: common include file */
22    
23     /**************************************************************/
24    
25     /* Copyrights by ACcESS Australia, 2003 */
26     /* Version: $Id$ */
27    
28     /**************************************************************/
29    
30     /* some system values */
31 woo409 757 #ifdef _WIN32 && __INTEL_COMPILER
32     #include <mathimf.h>
33     #else
34     #include <math.h>
35     #endif
36 jgs 150
37     #include <float.h>
38     #include <stdio.h>
39     #include <limits.h>
40     #include <stdlib.h>
41     #include <string.h>
42    
43     #define LenString_MAX FILENAME_MAX*2
44     #define LenErrorMsg_MAX LenString_MAX
45    
46     /* on some arcitectures it could be a good idea to use long rather than int */
47     /* this has not really been tested */
48    
49     typedef int dim_t;
50     typedef int index_t;
51     typedef int bool_t;
52     typedef int type_t;
53     typedef int err_t;
54    
55     #define INDEX_T_MAX INT_MAX
56     #define EPSILON DBL_EPSILON
57    
58     /**************************************************************/
59    
60     /* some useful functions: */
61    
62     #define FALSE 0
63     #define TRUE 1
64     #define UNKNOWN -1
65     #define DBLE(_x_) (double)(_x_)
66     #define INDEX1(_X1_) (_X1_)
67     #define INDEX2(_X1_,_X2_,_N1_) ((_X1_)+(_N1_)*(_X2_))
68     #define INDEX3(_X1_,_X2_,_X3_,_N1_,_N2_) ((_X1_)+(_N1_)*INDEX2(_X2_,_X3_,_N2_))
69     #define INDEX4(_X1_,_X2_,_X3_,_X4_,_N1_,_N2_,_N3_) ((_X1_)+(_N1_)*INDEX3(_X2_,_X3_,_X4_,_N2_,_N3_))
70     #define INDEX5(_X1_,_X2_,_X3_,_X4_,_X5_,_N1_,_N2_,_N3_,_N4_) ((_X1_)+(_N1_)*INDEX4(_X2_,_X3_,_X4_,_X5_,_N2_,_N3_,_N4_))
71     #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_))
72    
73     #define MAX(_arg1_,_arg2_) ((_arg1_)>(_arg2_) ? (_arg1_) : (_arg2_))
74     #define MIN(_arg1_,_arg2_) ((_arg1_)>(_arg2_) ? (_arg2_) : (_arg1_))
75     #define ABS(_arg_) MAX((_arg_),-(_arg_))
76     /**************************************************************/
77    
78     /* memory allocation: */
79    
80     #define TMPMEMALLOC(_LENGTH_,_TYPE_) (_TYPE_*) malloc(((size_t)(_LENGTH_))*sizeof(_TYPE_))
81     #define TMPMEMFREE(_PTR_) if ((void *)(_PTR_) != NULL ) { free(_PTR_); (_PTR_) = NULL; }
82     #ifdef __ECC
83 bcumming 730 //#define MEMALLOC(_LENGTH_,_TYPE_) (_TYPE_*) malloc(((size_t)(_LENGTH_))*sizeof(_TYPE_)); if( !(_LENGTH_) ) printf( "Trying malloc(0) at %s %d\n", __FILE__, __LINE__ ); //else printf( "malloc(%d) at %s %d\n", _LENGTH_, __FILE__, __LINE__ );
84 jgs 150 #define MEMALLOC(_LENGTH_,_TYPE_) (_TYPE_*) malloc(((size_t)(_LENGTH_))*sizeof(_TYPE_))
85     #define MEMFREE(_PTR_) if ((void *)(_PTR_) != NULL ) { free(_PTR_); (_PTR_) = NULL; }
86     #ifdef _OPENMP
87     #define THREAD_MEMALLOC(_LENGTH_,_TYPE_) (_TYPE_*) kmp_malloc(((size_t)(_LENGTH_))*sizeof(_TYPE_))
88     #define THREAD_MEMFREE(_PTR_) if ((void *)(_PTR_) != NULL ) { kmp_free(_PTR_); (_PTR_) = NULL; }
89     #else
90     #define THREAD_MEMALLOC(_LENGTH_,_TYPE_) TMPMEMALLOC(_LENGTH_,_TYPE_)
91     #define THREAD_MEMFREE(_PTR_) TMPMEMFREE(_PTR_)
92     #endif
93 bcumming 730 #define MEMREALLOC(_POINTER_,_LENGTH_,_TYPE_) if( (_POINTER_)!=NULL ){ _POINTER_ = (_TYPE_*)realloc((void*)(_POINTER_),((size_t)(_LENGTH_))*sizeof(_TYPE_) ); }else{ _POINTER_ = (_TYPE_*)malloc( ((size_t)(_LENGTH_))*sizeof(_TYPE_) ); }
94    
95 jgs 150 #else
96     #define MEMALLOC(_LENGTH_,_TYPE_) (_TYPE_*) malloc(((size_t)(_LENGTH_))*sizeof(_TYPE_))
97     #define MEMFREE(_PTR_) if ((void *)(_PTR_) != NULL ) { free(_PTR_); (_PTR_) = NULL; }
98     #define THREAD_MEMALLOC(_LENGTH_,_TYPE_) TMPMEMALLOC(_LENGTH_,_TYPE_)
99     #define THREAD_MEMFREE(_PTR_) TMPMEMFREE(_PTR_)
100 bcumming 730 #define MEMREALLOC(_POINTER_,_LENGTH_,_TYPE_) if( (_POINTER_)!=NULL ){ _POINTER_ = (_TYPE_*)realloc((void*)(_POINTER_),((size_t)(_LENGTH_))*sizeof(_TYPE_) ); }else{ _POINTER_ = (_TYPE_*)malloc( ((size_t)(_LENGTH_))*sizeof(_TYPE_) ); }
101 jgs 150 #endif
102    
103     #endif /* #ifndef INC_PASO_COMMON */
104    
105     /*
106     * $Log$
107     * Revision 1.2 2005/09/15 03:44:38 jgs
108     * Merge of development branch dev-02 back to main trunk on 2005-09-15
109     *
110     * Revision 1.1.2.1 2005/09/05 06:29:46 gross
111     * These files have been extracted from finley to define a stand alone libray for iterative
112     * linear solvers on the ALTIX. main entry through Paso_solve. this version compiles but
113     * has not been tested yet.
114     *
115     *
116     */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26