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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1361 - (hide annotations)
Fri Dec 14 09:26:51 2007 UTC (11 years, 11 months ago) by gross
Original Path: trunk/paso/src/Paso.c
File MIME type: text/plain
File size: 2730 byte(s)
first steps towards a flux controlled transport solver.
1 ksteube 1312
2 jgs 150 /* $Id$ */
3    
4 ksteube 1312 /*******************************************************
5     *
6     * Copyright 2003-2007 by ACceSS MNRF
7     * Copyright 2007 by University of Queensland
8     *
9     * http://esscc.uq.edu.au
10     * Primary Business: Queensland, Australia
11     * Licensed under the Open Software License version 3.0
12     * http://www.opensource.org/licenses/osl-3.0.php
13     *
14     *******************************************************/
15 dhawcroft 631
16 jgs 150 /**************************************************************/
17    
18     /* Paso finite element solver */
19    
20     /**************************************************************/
21    
22     /* Copyrights by ACcESS Australia, 2003 */
23     /* Version: $Id$ */
24    
25     /**************************************************************/
26    
27     #include "Paso.h"
28 ksteube 1312
29 jgs 150 #ifdef _OPENMP
30     #include <omp.h>
31 ksteube 1312 #endif
32    
33 bcumming 730 #ifdef PASO_MPI
34 ksteube 1312 #include "mpi_C.h"
35 bcumming 730 #else
36 jgs 150 #include <time.h>
37     #endif
38    
39     Paso_ErrorCodeType Paso_ErrorCode_=NO_ERROR;
40     char Paso_ErrorMsg_[LenErrorMsg_MAX]={'\0'};
41    
42     /* reset the error to NO_ERROR */
43     void Paso_resetError(void) {
44     Paso_ErrorCode_=NO_ERROR;
45     }
46    
47     /* sets an error */
48     void Paso_setError(Paso_ErrorCodeType err,char* msg) {
49     size_t lenMsg=strlen(msg);
50     if (Paso_noError()) {
51 gross 1361 printf("error set = %d %s\n",err,msg);
52 jgs 150 Paso_ErrorCode_=err;
53     strncpy(Paso_ErrorMsg_,msg,MIN(LenErrorMsg_MAX,lenMsg));
54     Paso_ErrorMsg_[MIN(LenErrorMsg_MAX,lenMsg)]='\0';
55     }
56     }
57    
58     /* checks if there is no error */
59     bool_t Paso_noError(void) {
60     Paso_ErrorCodeType err=Paso_getErrorType();
61 jgs 154 /* return (err==NO_ERROR || err==WARNING);*/
62     return (err==NO_ERROR);
63 jgs 150 }
64     /* This function checks if the pointer ptr has a target. If not an
65     error is raised and TRUE is returned. */
66    
67     bool_t Paso_checkPtr(void* ptr) {
68     if (ptr==NULL) {
69     Paso_setError(MEMORY_ERROR,"Out of memory.");
70     return TRUE;
71     } else {
72     return FALSE;
73     }
74     }
75    
76     /* This function returns a timer */
77     double Paso_timer(void) {
78     double out;
79 bcumming 730
80     #ifdef PASO_MPI
81     out = MPI_Wtime();
82     #else
83     #ifdef _OPENMP
84 jgs 150 out=omp_get_wtime();
85 bcumming 730 #else
86 jgs 150 out=((double) clock())/CLOCKS_PER_SEC;
87 bcumming 730 #endif
88     #endif
89 jgs 150 return out;
90     }
91    
92     /* return the error code */
93     Paso_ErrorCodeType Paso_getErrorType(void) {
94     return Paso_ErrorCode_;
95     }
96    
97     /* return the error message */
98     char* Paso_getErrorMessage(void) {
99     return Paso_ErrorMsg_;
100     }
101     /**************************************************************/

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26