vic/vic_run/src/alloc_and_free.c
void
malloc_3d_double(size_t    *shape,
                 double ****array)
{
    size_t i;
    size_t j;

    *array = malloc(shape[0] * sizeof(*(*array)));
    check_alloc_status(*array, "Memory allocation error.");

    for (i = 0; i < shape[0]; i++) {
        (*array)[i] = malloc(shape[1] * sizeof(*((*array)[i])));
        check_alloc_status((*array)[i], "Memory allocation error.");
        for (j = 0; j < shape[1]; j++) {
            (*array)[i][j] = malloc(shape[2] * sizeof(*((*array)[i][j])));
            check_alloc_status((*array)[i][j], "Memory allocation error.");
        }
    }
}
/******************************************************************************
 * @brief    This subroutine allocates memory for a 3-dimensional double array
 *****************************************************************************/
@brief    This subroutine allocates memory for a 3-dimensional double array
@brief This subroutine allocates memory for a 3 - dimensional double array
void
malloc_3d_double(size_t    *shape,
                 double ****array)
{
    size_t i;
    size_t j;
    *array = malloc(shape[0] * sizeof(*(*array)));
    check_alloc_status(*array, "Memory allocation error.");
    for (i = 0; i < shape[0]; i++) {
        (*array)[i] = malloc(shape[1] * sizeof(*((*array)[i])));
        check_alloc_status((*array)[i], "Memory allocation error.");
        for (j = 0; j < shape[1]; j++) {
            (*array)[i][j] = malloc(shape[2] * sizeof(*((*array)[i][j])));
            check_alloc_status((*array)[i][j], "Memory allocation error.");
        }
    }
}
void malloc_3d_double ( size_t * shape , double * * * * array ) { size_t i ; size_t j ; * array = malloc ( shape [ 0 ] * sizeof ( * ( * array ) ) ) ; check_alloc_status ( * array , " " ) ; for ( i = 0 ; i < shape [ 0 ] ; i ++ ) { ( * array ) [ i ] = malloc ( shape [ 1 ] * sizeof ( * ( ( * array ) [ i ] ) ) ) ; check_alloc_status ( ( * array ) [ i ] , " " ) ; for ( j = 0 ; j < shape [ 1 ] ; j ++ ) { ( * array ) [ i ] [ j ] = malloc ( shape [ 2 ] * sizeof ( * ( ( * array ) [ i ] [ j ] ) ) ) ; check_alloc_status ( ( * array ) [ i ] [ j ] , " " ) ; } } }
@brief    This subroutine allocates memory for a 3-dimensional double array
@brief This subroutine allocates memory for a 3 - dimensional double array