/[escript]/trunk/esysUtils/src/error.c
ViewVC logotype

Annotation of /trunk/esysUtils/src/error.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3975 - (hide annotations)
Thu Sep 20 01:54:06 2012 UTC (7 years, 2 months ago) by caltinay
File MIME type: text/plain
File size: 2469 byte(s)
Merged symbolic branch into trunk. Curious what daniel and spartacus have to
say...

1 ksteube 1312
2     /*******************************************************
3 ksteube 1811 *
4 jfenwick 3911 * Copyright (c) 2010-2012 by University of Queensland
5 ksteube 1811 * 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 jfenwick 3227 #include <string.h>
16     #include "error.h"
17 jgs 150
18     #ifdef _OPENMP
19     #include <omp.h>
20 ksteube 1312 #endif
21    
22 jfenwick 3231 #ifdef ESYS_MPI
23 ksteube 1312 #include "mpi_C.h"
24 bcumming 730 #else
25 jgs 150 #include <time.h>
26     #endif
27    
28    
29 jfenwick 3227
30     #define MIN(X,Y) ((X)<(Y)?(X):(Y))
31    
32    
33    
34     Esys_ErrorCodeType Esys_ErrorCode_=NO_ERROR;
35     char Esys_ErrorMsg_[LenErrorMsg_MAX]={'\0'};
36    
37 jgs 150 /* reset the error to NO_ERROR */
38 jfenwick 3227 void Esys_resetError(void) {
39     Esys_ErrorCode_=NO_ERROR;
40 jgs 150 }
41    
42     /* sets an error */
43 jfenwick 3227 void Esys_setError(Esys_ErrorCodeType err,__const char* msg) {
44 jgs 150 size_t lenMsg=strlen(msg);
45 jfenwick 3227 if (Esys_noError()) {
46 gross 2315 /* printf("error set = %d %s\n",err,msg); */
47 jfenwick 3227 Esys_ErrorCode_=err;
48     strncpy(Esys_ErrorMsg_,msg,MIN(LenErrorMsg_MAX,lenMsg));
49     Esys_ErrorMsg_[MIN(LenErrorMsg_MAX,lenMsg)]='\0';
50 jgs 150 }
51     }
52    
53     /* checks if there is no error */
54 jfenwick 3227 bool_t Esys_noError(void) {
55     Esys_ErrorCodeType err=Esys_getErrorType();
56 jgs 154 /* return (err==NO_ERROR || err==WARNING);*/
57     return (err==NO_ERROR);
58 jgs 150 }
59     /* This function checks if the pointer ptr has a target. If not an
60     error is raised and TRUE is returned. */
61    
62 jfenwick 3227 bool_t Esys_checkPtr(void* ptr) {
63 jgs 150 if (ptr==NULL) {
64 jfenwick 3227 Esys_setError(MEMORY_ERROR,"Out of memory.");
65 jgs 150 return TRUE;
66     } else {
67     return FALSE;
68     }
69     }
70    
71     /* This function returns a timer */
72 jfenwick 3227 double Esys_timer(void) {
73 jgs 150 double out;
74 bcumming 730
75 jfenwick 3231 #ifdef ESYS_MPI
76 bcumming 730 out = MPI_Wtime();
77     #else
78     #ifdef _OPENMP
79 jgs 150 out=omp_get_wtime();
80 bcumming 730 #else
81 jgs 150 out=((double) clock())/CLOCKS_PER_SEC;
82 bcumming 730 #endif
83     #endif
84 jgs 150 return out;
85     }
86    
87 gross 1564
88 gross 3327
89 jgs 150 /* return the error code */
90 jfenwick 3227 Esys_ErrorCodeType Esys_getErrorType(void) {
91     return Esys_ErrorCode_;
92 jgs 150 }
93    
94     /* return the error message */
95 jfenwick 3227 char* Esys_getErrorMessage(void) {
96     return Esys_ErrorMsg_;
97 jgs 150 }
98     /**************************************************************/

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision
svn:mergeinfo /branches/lapack2681/paso/src/Paso.c:2682-2741 /branches/pasowrap/esysUtils/src/error.c:3661-3674 /branches/py3_attempt2/esysUtils/src/error.c:3871-3891 /branches/restext/paso/src/Paso.c:2610-2624 /branches/ripleygmg_from_3668/esysUtils/src/error.c:3669-3791 /branches/stage3.0/paso/src/Paso.c:2569-2590 /branches/symbolic_from_3470/esysUtils/src/error.c:3471-3974 /branches/symbolic_from_3470/ripley/test/python/esysUtils/src/error.c:3517-3974 /release/3.0/paso/src/Paso.c:2591-2601 /trunk/ripley/test/python/esysUtils/src/error.c:3480-3515

  ViewVC Help
Powered by ViewVC 1.1.26