PLUTO
4.4-patch2
|
Memory allocation functions. More...
#include "pluto.h"
Functions | |
char * | Array1D (int nx, size_t dsize) |
void | FreeArray1D (void *v) |
char ** | Array2D (int nx, int ny, size_t dsize) |
void | FreeArray2D (void **m) |
char *** | Array3D (int nx, int ny, int nz, size_t dsize) |
void | FreeArray3D (void ***m) |
char **** | Array4D (int nx, int ny, int nz, int nv, size_t dsize) |
void | FreeArray4D (void ****m) |
char *** | ArrayBox (long int nrl, long int nrh, long int ncl, long int nch, long int ndl, long int ndh, size_t dsize) |
void | FreeArrayBox (double ***t, long nrl, long ncl, long ndl) |
double *** | ArrayMap (int nx, int ny, int nz, double *uptr) |
void | FreeArrayMap (double ***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) |
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.
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 |
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 |
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 |
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 |
char*** ArrayBox | ( | long int | nrl, |
long int | nrh, | ||
long int | ncl, | ||
long int | nch, | ||
long int | ndl, | ||
long int | ndh, | ||
size_t | dsize | ||
) |
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 |
double*** ArrayBoxMap | ( | int | nrl, |
int | nrh, | ||
int | ncl, | ||
int | nch, | ||
int | ndl, | ||
int | ndh, | ||
double * | uptr | ||
) |
Convert a one-dimensional array into a 3D array with given subscript range [low...high] for each direction.
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 |
void FreeArray1D | ( | void * | v | ) |
Free memory allocated by the pointer *v.
void FreeArray2D | ( | void ** | m | ) |
Free memory allocated by the double pointer **v.
void FreeArray3D | ( | void *** | m | ) |
Free memory allocated by the pointer ***v.
void FreeArray4D | ( | void **** | m | ) |
Free memory allocated by the pointer ****v.
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 |
void FreeArrayBoxMap | ( | double *** | t, |
int | nrl, | ||
int | nrh, | ||
int | ncl, | ||
int | nch, | ||
int | ndl, | ||
int | ndh | ||
) |
Free memory allocated with the ArrayBoxMap () function
void FreeArrayMap | ( | double *** | t | ) |
Free memory allocate with ArrayMap()