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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 730 - (hide annotations)
Mon May 15 04:03:49 2006 UTC (13 years, 5 months ago) by bcumming
File MIME type: text/plain
File size: 3319 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 bcumming 730 #else
30     #ifdef PASO_MPI
31    
32     #else
33 jgs 150 #include <time.h>
34     #endif
35 bcumming 730 #endif
36 jgs 150
37     Paso_ErrorCodeType Paso_ErrorCode_=NO_ERROR;
38     char Paso_ErrorMsg_[LenErrorMsg_MAX]={'\0'};
39    
40     /* reset the error to NO_ERROR */
41     void Paso_resetError(void) {
42     Paso_ErrorCode_=NO_ERROR;
43     }
44    
45     /* sets an error */
46     void Paso_setError(Paso_ErrorCodeType err,char* msg) {
47     size_t lenMsg=strlen(msg);
48     if (Paso_noError()) {
49     Paso_ErrorCode_=err;
50     strncpy(Paso_ErrorMsg_,msg,MIN(LenErrorMsg_MAX,lenMsg));
51     Paso_ErrorMsg_[MIN(LenErrorMsg_MAX,lenMsg)]='\0';
52     }
53     }
54    
55     /* checks if there is no error */
56     bool_t Paso_noError(void) {
57     Paso_ErrorCodeType err=Paso_getErrorType();
58 jgs 154 /* return (err==NO_ERROR || err==WARNING);*/
59     return (err==NO_ERROR);
60 jgs 150 }
61     /* This function checks if the pointer ptr has a target. If not an
62     error is raised and TRUE is returned. */
63    
64     bool_t Paso_checkPtr(void* ptr) {
65     if (ptr==NULL) {
66     Paso_setError(MEMORY_ERROR,"Out of memory.");
67     return TRUE;
68     } else {
69     return FALSE;
70     }
71     }
72    
73     /* This function returns a timer */
74     double Paso_timer(void) {
75     double out;
76 bcumming 730
77     #ifdef PASO_MPI
78     out = MPI_Wtime();
79     #else
80     #ifdef _OPENMP
81 jgs 150 out=omp_get_wtime();
82 bcumming 730 #else
83 jgs 150 out=((double) clock())/CLOCKS_PER_SEC;
84 bcumming 730 #endif
85     #endif
86 jgs 150 return out;
87     }
88    
89     /* return the error code */
90     Paso_ErrorCodeType Paso_getErrorType(void) {
91     return Paso_ErrorCode_;
92     }
93    
94     /* return the error message */
95     char* Paso_getErrorMessage(void) {
96     return Paso_ErrorMsg_;
97     }
98    
99 bcumming 730 #ifdef PASO_MPI
100     /* checks that there is no error accross all processes in a communicator */
101     /* NOTE : does not make guarentee consistency of error string on each process */
102     bool_t Paso_MPI_noError( Paso_MPIInfo *mpi_info )
103     {
104     int errorLocal=0, errorGlobal=0;
105    
106     errorLocal = (int)Paso_noError();
107     MPI_Allreduce( &errorLocal, &errorGlobal, 1, MPI_INT, MPI_LAND, mpi_info->comm );
108    
109     return errorGlobal;
110     }
111     #endif
112 jgs 150 /**************************************************************/

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26