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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1388 - (show annotations)
Fri Jan 11 07:45:58 2008 UTC (11 years, 8 months ago) by trankine
File MIME type: text/plain
File size: 2730 byte(s)
And get the *(&(*&(* name right
1
2 /* $Id$ */
3
4 /*******************************************************
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
16 /**************************************************************/
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
29 #ifdef _OPENMP
30 #include <omp.h>
31 #endif
32
33 #ifdef PASO_MPI
34 #include "mpi_C.h"
35 #else
36 #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 printf("error set = %d %s\n",err,msg);
52 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 /* return (err==NO_ERROR || err==WARNING);*/
62 return (err==NO_ERROR);
63 }
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
80 #ifdef PASO_MPI
81 out = MPI_Wtime();
82 #else
83 #ifdef _OPENMP
84 out=omp_get_wtime();
85 #else
86 out=((double) clock())/CLOCKS_PER_SEC;
87 #endif
88 #endif
89 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