/[escript]/trunk/paso/src/Paso.c
ViewVC logotype

Annotation of /trunk/paso/src/Paso.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 633 - (hide annotations)
Thu Mar 23 05:37:00 2006 UTC (14 years ago) by dhawcroft
File MIME type: text/plain
File size: 2822 byte(s)


1 jgs 150 /* $Id$ */
2    
3 dhawcroft 631
4     /*
5     ********************************************************************************
6 dhawcroft 633 * Copyright 2006 by ACcESS MNRF *
7 dhawcroft 631 * *
8     * http://www.access.edu.au *
9     * Primary Business: Queensland, Australia *
10     * Licensed under the Open Software License version 3.0 *
11     * http://www.opensource.org/licenses/osl-3.0.php *
12     ********************************************************************************
13     */
14    
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     #ifdef _OPENMP
28     #include <omp.h>
29     #else
30     #include <time.h>
31     #endif
32    
33     Paso_ErrorCodeType Paso_ErrorCode_=NO_ERROR;
34     char Paso_ErrorMsg_[LenErrorMsg_MAX]={'\0'};
35    
36     /* reset the error to NO_ERROR */
37     void Paso_resetError(void) {
38     Paso_ErrorCode_=NO_ERROR;
39     }
40    
41     /* sets an error */
42     void Paso_setError(Paso_ErrorCodeType err,char* msg) {
43     size_t lenMsg=strlen(msg);
44     if (Paso_noError()) {
45     Paso_ErrorCode_=err;
46     strncpy(Paso_ErrorMsg_,msg,MIN(LenErrorMsg_MAX,lenMsg));
47     Paso_ErrorMsg_[MIN(LenErrorMsg_MAX,lenMsg)]='\0';
48     }
49     }
50    
51     /* checks if there is no error */
52     bool_t Paso_noError(void) {
53     Paso_ErrorCodeType err=Paso_getErrorType();
54 jgs 154 /* return (err==NO_ERROR || err==WARNING);*/
55     return (err==NO_ERROR);
56 jgs 150 }
57     /* This function checks if the pointer ptr has a target. If not an
58     error is raised and TRUE is returned. */
59    
60     bool_t Paso_checkPtr(void* ptr) {
61     if (ptr==NULL) {
62     Paso_setError(MEMORY_ERROR,"Out of memory.");
63     return TRUE;
64     } else {
65     return FALSE;
66     }
67     }
68    
69     /* This function returns a timer */
70     double Paso_timer(void) {
71     double out;
72     #ifdef _OPENMP
73     out=omp_get_wtime();
74     #else
75     out=((double) clock())/CLOCKS_PER_SEC;
76     #endif
77     return out;
78     }
79    
80     /* return the error code */
81     Paso_ErrorCodeType Paso_getErrorType(void) {
82     return Paso_ErrorCode_;
83     }
84    
85     /* return the error message */
86     char* Paso_getErrorMessage(void) {
87     return Paso_ErrorMsg_;
88     }
89    
90     /**************************************************************/

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26