1 |
ksteube |
1312 |
|
2 |
|
|
/******************************************************* |
3 |
ksteube |
1811 |
* |
4 |
|
|
* Copyright (c) 2003-2008 by University of Queensland |
5 |
|
|
* Earth Systems Science Computational Center (ESSCC) |
6 |
|
|
* http://www.uq.edu.au/esscc |
7 |
|
|
* |
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 |
dhawcroft |
631 |
|
14 |
ksteube |
1811 |
|
15 |
jgs |
150 |
/**************************************************************/ |
16 |
|
|
|
17 |
|
|
/* Paso finite element solver */ |
18 |
|
|
|
19 |
|
|
/**************************************************************/ |
20 |
|
|
|
21 |
|
|
/* Copyrights by ACcESS Australia, 2003 */ |
22 |
|
|
/* Version: $Id$ */ |
23 |
|
|
|
24 |
|
|
/**************************************************************/ |
25 |
|
|
|
26 |
|
|
#include "Paso.h" |
27 |
ksteube |
1312 |
|
28 |
jgs |
150 |
#ifdef _OPENMP |
29 |
|
|
#include <omp.h> |
30 |
ksteube |
1312 |
#endif |
31 |
|
|
|
32 |
bcumming |
730 |
#ifdef PASO_MPI |
33 |
ksteube |
1312 |
#include "mpi_C.h" |
34 |
bcumming |
730 |
#else |
35 |
jgs |
150 |
#include <time.h> |
36 |
|
|
#endif |
37 |
|
|
|
38 |
|
|
Paso_ErrorCodeType Paso_ErrorCode_=NO_ERROR; |
39 |
|
|
char Paso_ErrorMsg_[LenErrorMsg_MAX]={'\0'}; |
40 |
|
|
|
41 |
|
|
/* reset the error to NO_ERROR */ |
42 |
|
|
void Paso_resetError(void) { |
43 |
|
|
Paso_ErrorCode_=NO_ERROR; |
44 |
|
|
} |
45 |
|
|
|
46 |
|
|
/* sets an error */ |
47 |
jfenwick |
2025 |
void Paso_setError(Paso_ErrorCodeType err,__const char* msg) { |
48 |
jgs |
150 |
size_t lenMsg=strlen(msg); |
49 |
|
|
if (Paso_noError()) { |
50 |
gross |
1361 |
printf("error set = %d %s\n",err,msg); |
51 |
jgs |
150 |
Paso_ErrorCode_=err; |
52 |
|
|
strncpy(Paso_ErrorMsg_,msg,MIN(LenErrorMsg_MAX,lenMsg)); |
53 |
|
|
Paso_ErrorMsg_[MIN(LenErrorMsg_MAX,lenMsg)]='\0'; |
54 |
|
|
} |
55 |
|
|
} |
56 |
|
|
|
57 |
|
|
/* checks if there is no error */ |
58 |
|
|
bool_t Paso_noError(void) { |
59 |
|
|
Paso_ErrorCodeType err=Paso_getErrorType(); |
60 |
jgs |
154 |
/* return (err==NO_ERROR || err==WARNING);*/ |
61 |
|
|
return (err==NO_ERROR); |
62 |
jgs |
150 |
} |
63 |
|
|
/* This function checks if the pointer ptr has a target. If not an |
64 |
|
|
error is raised and TRUE is returned. */ |
65 |
|
|
|
66 |
|
|
bool_t Paso_checkPtr(void* ptr) { |
67 |
|
|
if (ptr==NULL) { |
68 |
|
|
Paso_setError(MEMORY_ERROR,"Out of memory."); |
69 |
|
|
return TRUE; |
70 |
|
|
} else { |
71 |
|
|
return FALSE; |
72 |
|
|
} |
73 |
|
|
} |
74 |
|
|
|
75 |
|
|
/* This function returns a timer */ |
76 |
|
|
double Paso_timer(void) { |
77 |
|
|
double out; |
78 |
bcumming |
730 |
|
79 |
|
|
#ifdef PASO_MPI |
80 |
|
|
out = MPI_Wtime(); |
81 |
|
|
#else |
82 |
|
|
#ifdef _OPENMP |
83 |
jgs |
150 |
out=omp_get_wtime(); |
84 |
bcumming |
730 |
#else |
85 |
jgs |
150 |
out=((double) clock())/CLOCKS_PER_SEC; |
86 |
bcumming |
730 |
#endif |
87 |
|
|
#endif |
88 |
jgs |
150 |
return out; |
89 |
|
|
} |
90 |
gross |
1564 |
#ifndef _OPENMP |
91 |
|
|
int omp_get_max_threads(void) { |
92 |
|
|
return 1; |
93 |
|
|
} |
94 |
|
|
#endif |
95 |
jgs |
150 |
|
96 |
gross |
1564 |
|
97 |
jgs |
150 |
/* return the error code */ |
98 |
|
|
Paso_ErrorCodeType Paso_getErrorType(void) { |
99 |
|
|
return Paso_ErrorCode_; |
100 |
|
|
} |
101 |
|
|
|
102 |
|
|
/* return the error message */ |
103 |
|
|
char* Paso_getErrorMessage(void) { |
104 |
|
|
return Paso_ErrorMsg_; |
105 |
|
|
} |
106 |
|
|
/**************************************************************/ |