Exemple #1
0
void dimensions_destroy (Dimensions_t *dimensions)
{
    cell_dimensions_destroy (&dimensions->Cell) ;
    grid_dimensions_destroy (&dimensions->Grid) ;
    chip_dimensions_destroy (&dimensions->Chip) ;

    dimensions_init (dimensions) ;
}
Exemple #2
0
Dimensions_t *dimensions_calloc (void)
{
    Dimensions_t *dimensions = (Dimensions_t *) malloc (sizeof(Dimensions_t)) ;

    if (dimensions != NULL)

        dimensions_init (dimensions) ;

    return dimensions ;
}
Exemple #3
0
int harp_import_netcdf(const char *filename, harp_product **product)
{
    harp_product *new_product;
    netcdf_dimensions dimensions;
    int ncid;
    int result;

    if (filename == NULL)
    {
        harp_set_error(HARP_ERROR_INVALID_ARGUMENT, "filename is NULL (%s:%u)", __FILE__, __LINE__);
        return -1;
    }

    result = nc_open(filename, 0, &ncid);
    if (result != NC_NOERR)
    {
        harp_set_error(HARP_ERROR_NETCDF, "%s", nc_strerror(result));
        return -1;
    }

    if (verify_product(ncid) != 0)
    {
        nc_close(ncid);
        return -1;
    }

    if (harp_product_new(&new_product) != 0)
    {
        nc_close(ncid);
        return -1;
    }

    dimensions_init(&dimensions);

    if (read_product(ncid, new_product, &dimensions) != 0)
    {
        dimensions_done(&dimensions);
        harp_product_delete(new_product);
        nc_close(ncid);
        return -1;
    }

    dimensions_done(&dimensions);

    result = nc_close(ncid);
    if (result != NC_NOERR)
    {
        harp_set_error(HARP_ERROR_NETCDF, "%s", nc_strerror(result));
        harp_product_delete(new_product);
        return -1;
    }

    *product = new_product;
    return 0;
}
Exemple #4
0
int harp_export_netcdf(const char *filename, const harp_product *product)
{
    netcdf_dimensions dimensions;
    int result;
    int ncid;

    if (filename == NULL)
    {
        harp_set_error(HARP_ERROR_INVALID_ARGUMENT, "filename is NULL");
        return -1;
    }

    if (product == NULL)
    {
        harp_set_error(HARP_ERROR_INVALID_ARGUMENT, "product is NULL");
        return -1;
    }

    result = nc_create(filename, 0, &ncid);
    if (result != NC_NOERR)
    {
        harp_set_error(HARP_ERROR_NETCDF, "%s", nc_strerror(result));
        harp_add_error_message(" (%s)", filename);
        return -1;
    }

    dimensions_init(&dimensions);

    if (write_product(ncid, product, &dimensions) != 0)
    {
        harp_add_error_message(" (%s)", filename);
        nc_close(ncid);
        dimensions_done(&dimensions);
        return -1;
    }

    dimensions_done(&dimensions);

    result = nc_close(ncid);
    if (result != NC_NOERR)
    {
        harp_set_error(HARP_ERROR_NETCDF, "%s", nc_strerror(result));
        harp_add_error_message(" (%s)", filename);
        return -1;
    }

    return 0;
}