ScaLAPACK 2.1  2.1
ScaLAPACK: Scalable Linear Algebra PACKage
getpbbuf.c
Go to the documentation of this file.
1 #include "tools.h"
2 
3 char * getpbbuf( mess, length )
4 /*
5 * .. Scalar Arguments ..
6 */
7  int length;
8 /*
9 * .. Array Arguments ..
10 */
11  char * mess;
12 {
13 /*
14 * Purpose
15 * =======
16 *
17 * getpbbuf returns a pointer to a working buffer of size length alloca-
18 * ted for the PBLAS routines.
19 *
20 * ======================================================================
21 *
22 * .. Local Scalars ..
23 */
24  static char * pblasbuf = NULL;
25  static int pbbuflen = 0, mone = -1;
26 /* ..
27 * .. External Functions ..
28 */
29  void blacs_abort_();
30 /* ..
31 * .. Executable Statements ..
32 */
33  if( length >= 0 )
34  {
35  if( length > pbbuflen )
36  {
37  if( pblasbuf )
38  free( pblasbuf );
39  pblasbuf = (char *) malloc((unsigned)length);
40  if( !pblasbuf )
41  {
42  fprintf( stderr,
43  "PBLAS %s ERROR: Memory allocation failed\n",
44  mess );
45  blacs_abort_( &mone, &mone );
46  }
47  pbbuflen = length;
48  }
49  }
50  else if( pblasbuf )
51  {
52  free( pblasbuf );
53  pblasbuf = NULL;
54  pbbuflen = 0;
55  }
56  return( pblasbuf );
57 }
getpbbuf
char * getpbbuf(char *mess, int length)
Definition: getpbbuf.c:3
blacs_abort_
F_VOID_FUNC blacs_abort_(int *ConTxt, int *ErrNo)
Definition: blacs_abort_.c:6
tools.h