PLUTO
al_alloc.c File Reference

ArrayLib allocation routine. More...

#include "al_hidden.h"
Include dependency graph for al_alloc.c:

Go to the source code of this file.

Functions

void * AL_Allocate_array (int sz_ptr)
 

Variables

SZsz_stack [AL_MAX_ARRAYS]
 
int stack_ptr [AL_MAX_ARRAYS]
 

Detailed Description

ArrayLib allocation routine.

ArrayLib allocation routine

Authors
A. Malagoli (University of Chicago)
Date
Jul 17, 1999

Definition in file al_alloc.c.

Function Documentation

void* AL_Allocate_array ( int  sz_ptr)

Allocate the local buffer for a distributed array

Parameters
[in]sz_ptrpointer to SZ array (integer)

Definition at line 25 of file al_alloc.c.

31 {
32  char *a;
33  int myrank, nproc;
34  int size;
35  long int buffsize;
36  MPI_Comm comm;
37  SZ *s;
38 
39 
40 
41  /* DIAGNOSTICS
42  Check that sz_ptr points to an allocated SZ
43  */
44  if( stack_ptr[sz_ptr] == AL_STACK_FREE){
45  printf("AL_Allocate_array: wrong SZ pointer\n");
46  }
47 
48  s = sz_stack[sz_ptr];
49 
50  myrank = s->rank;
51  nproc = s->size;
52  comm = s->comm;
53 
54  buffsize = s->buffsize;
55 
56  MPI_Type_size(s->type, &size);
57 
58  if( !(a = (char *)AL_CALLOC_((int) buffsize,size)) ){
59  printf("[%d] AL_Allocate_array: allocation error\n",myrank);
60  return 0;
61  }
62 
63  /* DIAGNOSTICS */
64 #ifdef DEBUG
65  printf("AL_Allocate_array: allocated %ld bytes\n",buffsize*size);
66 #endif
67 
68  return (void *)a;
69 }
static double a
Definition: init.c:135
#define AL_CALLOC_(nelem, size)
Definition: al_defs.h:34
#define AL_STACK_FREE
Definition: al_codes.h:24
int rank
Definition: al_hidden.h:44
int stack_ptr[AL_MAX_ARRAYS]
Definition: al_szptr_.c:26
#define s
int size
Definition: al_hidden.h:45
MPI_Comm comm
Definition: al_hidden.h:47
long int buffsize
Definition: al_hidden.h:52
MPI_Datatype type
Definition: al_hidden.h:40
Definition: al_hidden.h:38
SZ * sz_stack[AL_MAX_ARRAYS]
Definition: al_szptr_.c:18

Variable Documentation

int stack_ptr[AL_MAX_ARRAYS]

Definition at line 26 of file al_szptr_.c.

SZ* sz_stack[AL_MAX_ARRAYS]

Definition at line 18 of file al_szptr_.c.