Overture  Version 25
wdhdefs.h
Go to the documentation of this file.
1 // Bill's useful definitions
2 #ifndef WDHDEFS_H
3 #define WDHDEFS_H "wdhdefs.h"
4 
5 #ifndef NO_APP
6 #include "OvertureDefine.h"
7 #include <A++.h>
8 #endif
9 
10 #ifndef NO_APP
11 #include "aString.H"
12 #else
13 #include "GUIDefine.h"
14 #include <string>
15 #ifndef aString
16 #define aString std::string
17 #endif
18 #endif
19 
20 #include "GUITypes.h"
21 
22 extern int debug; // variable used for debugging
23 
24 const int axis1 = 0; // names for the 3 parameter axes
25 const int axis2 = 1;
26 const int axis3 = 2;
27 
28 const int xAxis = 0; // names for the 3 cartesian coordinate directions
29 const int yAxis = 1;
30 const int zAxis = 2;
31 
32 const int Start = 0; // names for left/right top/bottom back/front
33 const int End = 1;
34 
35 
36 #define sprintf2(a,b) (sprintf(a,b),a)
37 #define sprintf3(a,b,c) (sprintf(a,b,c),a)
38 #define sprintf4(a,b,c,d) (sprintf(a,b,c,d),a)
39 #define sprintf5(a,b,c,d,e) (sprintf(a,b,c,d,e),a)
40 #define sprintf6(a,b,c,d,e,f) (sprintf(a,b,c,d,e,f),a)
41 #define sprintf7(a,b,c,d,e,f,g) (sprintf(a,b,c,d,e,f,g),a)
42 #define sprintf8(a,b,c,d,e,f,g,h) (sprintf(a,b,c,d,e,f,g,h),a)
43 #define sprintf9(a,b,c,d,e,f,g,h,i) (sprintf(a,b,c,d,e,f,g,h,i),a)
44 
45 // sprintf like routine that returns the formated string s
46 extern aString sPrintF(const char *format, ...);
47 extern char* sPrintF(char *s, const char *format, ...);
48 extern aString& sPrintF(aString & s, const char *format, ...);
49 
50 extern int
51 sScanF(const aString & s, const char *format,
52  void *p0,
53  void *p1=NULL,
54  void *p2=NULL,
55  void *p3=NULL,
56  void *p4=NULL,
57  void *p5=NULL,
58  void *p6=NULL,
59  void *p7=NULL,
60  void *p8=NULL,
61  void *p9=NULL,
62  void *p10=NULL,
63  void *p11=NULL,
64  void *p12=NULL,
65  void *p13=NULL,
66  void *p14=NULL,
67  void *p15=NULL,
68  void *p16=NULL,
69  void *p17=NULL,
70  void *p18=NULL,
71  void *p19=NULL,
72  void *p20=NULL,
73  void *p21=NULL,
74  void *p22=NULL,
75  void *p23=NULL,
76  void *p24=NULL,
77  void *p25=NULL,
78  void *p26=NULL,
79  void *p27=NULL,
80  void *p28=NULL,
81  void *p29=NULL );
82 
83 extern int
84 fScanF(FILE *file, const char *format,
85  void *p0,
86  void *p1=NULL,
87  void *p2=NULL,
88  void *p3=NULL,
89  void *p4=NULL,
90  void *p5=NULL,
91  void *p6=NULL,
92  void *p7=NULL,
93  void *p8=NULL,
94  void *p9=NULL,
95  void *p10=NULL,
96  void *p11=NULL,
97  void *p12=NULL,
98  void *p13=NULL,
99  void *p14=NULL,
100  void *p15=NULL,
101  void *p16=NULL,
102  void *p17=NULL,
103  void *p18=NULL,
104  void *p19=NULL,
105  void *p20=NULL,
106  void *p21=NULL,
107  void *p22=NULL,
108  void *p23=NULL,
109  void *p24=NULL,
110  void *p25=NULL,
111  void *p26=NULL,
112  void *p27=NULL,
113  void *p28=NULL,
114  void *p29=NULL
115  );
116 
117 
118 //kkc #ifndef NO_APP
119 // These versions only print on processor 0
120 void printF(const char *format, ...);
121 void fPrintF(FILE *file, const char *format, ...);
122 //kkc #endif
123 
124 //--------------------------------------------------------------------------------------
125 // Read a line from standard input
126 // char s[] : char array in which to store the line
127 // lim : maximum number of chars that can be saved in s
128 //-------------------------------------------------------------------------------------
129 int getLine( char s[], int lim);
130 int getLine( aString &answer );
131 
132 // conversion routine used by sscanf to convert %e to %le and %f to %lf when OV_USE_DOUBLE is defined
133 aString ftor(const char *s);
134 
135 // *wdh* 100109 GUITypes::real getCPU();
136 // inline this for performance
137 #define SECOND EXTERN_C_NAME(second)
138 extern "C" {
139  void SECOND( real & time );
140 }
141 
143 {
144  #ifndef USE_PPP
145  real time;
146  SECOND( time );
147  return time;
148  #else
149  #ifdef OV_USE_DOUBLE
150  return MPI_Wtime();
151  #else
152  return (real)MPI_Wtime();
153  #endif
154  #endif
155 }
156 
157 
158 // **** here are global variables that are initialized in initOvertureGlobalVariables()****
159 extern const GUITypes::real Pi;
160 extern const GUITypes::real twoPi;
161 
162 extern const aString nullString; // null string for default arguments
163 extern const aString blankString; // blank string for default arguments
164 #ifndef NO_APP
165 extern const Index nullIndex;
166 extern const Range nullRange;
167 extern const Range faceRange;
168 #endif
169 
170 int
171 helpOverture( const aString & documentPrefix, const aString & label );
172 
173 #ifndef NO_APP
174 
175 #ifndef USE_PPP
176 #define GET_NUMBER_OF_ARRAYS Array_Domain_Type::getNumberOfArraysInUse()
177 #else
178 #define GET_NUMBER_OF_ARRAYS 0
179 #endif
180 
181 #endif
182 
183 // ------------------------------------------------------------------------------------------
184 // ----------- Macros that access the serial array from a P++ parallel array ---------------
185 // ------------------------------------------------------------------------------------------
186 #ifdef USE_PPP
187 
188 #define OV_GET_SERIAL_ARRAY(TYPE,U,ULOCAL) TYPE ## SerialArray ULOCAL; getLocalArrayWithGhostBoundaries(U,ULOCAL);
189 #define OV_GET_SERIAL_ARRAY_CONST(TYPE,U,ULOCAL) TYPE ## SerialArray ULOCAL; getLocalArrayWithGhostBoundaries(U,ULOCAL);
190 #define OV_GET_SERIAL_ARRAY_CONDITIONAL(TYPE,U,ULOCAL,CONDITION) \
191 TYPE ## SerialArray ULOCAL; if( CONDITION ) getLocalArrayWithGhostBoundaries(U,ULOCAL);
192 
193 #else
194 
195 #define OV_GET_SERIAL_ARRAY(TYPE,U,ULOCAL) TYPE ## SerialArray & ULOCAL = U;
196 #define OV_GET_SERIAL_ARRAY_CONST(TYPE,U,ULOCAL) const TYPE ## SerialArray & ULOCAL = U;
197 
198 #define OV_GET_SERIAL_ARRAY_CONDITIONAL(TYPE,U,ULOCAL,CONDITION) TYPE ## SerialArray & ULOCAL = U;
199 
200 #endif
201 
202 
203 #endif // WDHDEFS_H