PLUTO
|
Memory allocation functions. More...
#include "pluto.h"
Go to the source code of this file.
Macros | |
#define | NONZERO_INITIALIZE |
Functions | |
void | FreeArray1D (void *v) |
void | FreeArray2D (void **m) |
void | FreeArray3D (void ***m) |
void | FreeArray4D (void ****m) |
char * | Array1D (int nx, size_t dsize) |
char ** | Array2D (int nx, int ny, size_t dsize) |
char *** | Array3D (int nx, int ny, int nz, size_t dsize) |
char **** | Array4D (int nx, int ny, int nz, int nv, size_t dsize) |
double *** | ArrayBox (long int nrl, long int nrh, long int ncl, long int nch, long int ndl, long int ndh) |
void | FreeArrayBox (double ***t, long nrl, long ncl, long ndl) |
double *** | ArrayMap (int nx, int ny, int nz, double *uptr) |
unsigned char *** | ArrayCharMap (int nx, int ny, int nz, unsigned char *uptr) |
void | FreeArrayMap (double ***t) |
void | FreeArrayCharMap (unsigned char ***t) |
double *** | ArrayBoxMap (int nrl, int nrh, int ncl, int nch, int ndl, int ndh, double *uptr) |
void | FreeArrayBoxMap (double ***t, int nrl, int nrh, int ncl, int nch, int ndl, int ndh) |
Memory allocation functions.
Provides essential functions for allocating and deallocating multi-dimensional arrays. The functions Array1D(), Array2D(), Array3D(), Array4D() can be used to allocate storage for 1-D, 2-D, 3-D and 4-D arrays of any data type with indices starting at 0. They are typically invoked from within a corresponding macros that handles type casting automatically, e.g.,
will allocate memory for a 1D char array with 20
elements and a 2D double arrays of 30x40
elements
The function ArrayBox() can be used to allocate memory for a double precision array with specified index range.
The functions ArrayMap() can be used to convert a one-dimensional array into a 3D array.
Definition in file arrays.c.
#define NONZERO_INITIALIZE |
char* Array1D | ( | int | nx, |
size_t | dsize | ||
) |
Allocate memory for a 1-D array of any basic data type starting at 0.
[in] | nx | number of elements to be allocated |
[in] | dsize | data-type of the array to be allocated |
Definition at line 80 of file arrays.c.
char** Array2D | ( | int | nx, |
int | ny, | ||
size_t | dsize | ||
) |
Allocate memory for a 2-D array of any basic data type.
[in] | nx | number of elements in the 2nd dimension |
[in] | ny | number of elements in the 1st dimension |
[in] | dsize | data-type of the array to be allocated |
Definition at line 108 of file arrays.c.
char*** Array3D | ( | int | nx, |
int | ny, | ||
int | nz, | ||
size_t | dsize | ||
) |
Allocate memory for a 3-D array of any basic data type.
[in] | nx | number of elements in the 3rd dimension |
[in] | ny | number of elements in the 2nd dimension |
[in] | nz | number of elements in the 1st dimension |
[in] | dsize | data-type of the array to be allocated |
Definition at line 149 of file arrays.c.
char**** Array4D | ( | int | nx, |
int | ny, | ||
int | nz, | ||
int | nv, | ||
size_t | dsize | ||
) |
Allocate memory for a 4-D array of any basic data type.
[in] | nx | number of elements in the 4th dimension |
[in] | ny | number of elements in the 3rd dimension |
[in] | nz | number of elements in the 2nd dimension |
[in] | nv | number of elements in the 1st dimension |
[in] | dsize | data-type of the array to be allocated |
Definition at line 222 of file arrays.c.
double*** ArrayBox | ( | long int | nrl, |
long int | nrh, | ||
long int | ncl, | ||
long int | nch, | ||
long int | ndl, | ||
long int | ndh | ||
) |
Allocate memory for a 3-D array in double precision with given subscript range [low...high] for each direction. Useful for staggered arrays which do not start at [0].
[in] | nrl | lower bound index for the 3rd dimension |
[in] | nrh | upper bound index for the 3rd dimension |
[in] | ncl | lower bound index for the 2nd dimension |
[in] | nch | upper bound index for the 2nd dimension |
[in] | ndl | lower bound index for the 1st dimension |
[in] | ndh | upper bound index for the 1st dimension |
Definition at line 341 of file arrays.c.
double*** ArrayBoxMap | ( | int | nrl, |
int | nrh, | ||
int | ncl, | ||
int | nch, | ||
int | ndl, | ||
int | ndh, | ||
double * | uptr | ||
) |
unsigned char*** ArrayCharMap | ( | int | nx, |
int | ny, | ||
int | nz, | ||
unsigned char * | uptr | ||
) |
double*** ArrayMap | ( | int | nx, |
int | ny, | ||
int | nz, | ||
double * | uptr | ||
) |
Convert a one dimensional array with (nx*ny*nz) elements into a 3D array with index range [0..nx-1][0..ny-1][0..nz-1]. This function is similar, conceptually, to Array3D() except that the memory area is already allocated.
[in] | uptr | pointer to 1D array |
[in] | nx | number of elements in the 3rd dimension |
[in] | ny | number of elements in the 2nd dimensions |
[in] | nz | number of elements in the 1st dimensions |
Definition at line 421 of file arrays.c.
void FreeArray1D | ( | void * | v | ) |
void FreeArray2D | ( | void ** | m | ) |
void FreeArray3D | ( | void *** | m | ) |
void FreeArray4D | ( | void **** | m | ) |
void FreeArrayBox | ( | double *** | t, |
long | nrl, | ||
long | ncl, | ||
long | ndl | ||
) |
Free memory allocated by the ArrayBox function.
[in] | t | pointer to an allocated memory area |
[in] | nrl | starting index of the array for the 3rd dimension |
[in] | ncl | starting index of the array for the 2nd dimension |
[in] | ndl | starting index of the array for the 1st dimension |
Definition at line 403 of file arrays.c.
void FreeArrayBoxMap | ( | double *** | t, |
int | nrl, | ||
int | nrh, | ||
int | ncl, | ||
int | nch, | ||
int | ndl, | ||
int | ndh | ||
) |
Free memory allocated with the ArrayBoxMap () function
void FreeArrayCharMap | ( | unsigned char *** | t | ) |
void FreeArrayMap | ( | double *** | t | ) |
Free memory allocate with ArrayMap()