NetCDF 4.10.0
Loading...
Searching...
No Matches
dfile.c File Reference

File create and open functions. More...

#include "config.h"
#include <stdlib.h>
#include "ncdispatch.h"
#include "netcdf_mem.h"
#include "ncpathmgr.h"
#include "fbits.h"
Include dependency graph for dfile.c:

Go to the source code of this file.

Macros

#define nulldup(s)   ((s)?strdup(s):NULL)
 

Functions

static int check_create_mode (int mode)
 Check the create mode parameter for sanity.
 
int nc__create (const char *path, int cmode, size_t initialsz, size_t *chunksizehintp, int *ncidp)
 Create a netCDF file with some extra parameters controlling classic file caching.
 
int nc__create_mp (const char *path, int cmode, size_t initialsz, int basepe, size_t *chunksizehintp, int *ncidp)
 
int nc__enddef (int ncid, size_t h_minfree, size_t v_align, size_t v_minfree, size_t r_align)
 Leave define mode with performance tuning.
 
int nc__open (const char *path, int omode, size_t *chunksizehintp, int *ncidp)
 Open a netCDF file with extra performance parameters for the classic library.
 
int nc__open_mp (const char *path, int omode, int basepe, size_t *chunksizehintp, int *ncidp)
 
int nc__pseudofd (void)
 
int nc_abort (int ncid)
 No longer necessary for user to invoke manually.
 
int nc_close (int ncid)
 Close an open netCDF dataset.
 
int nc_close_memio (int ncid, NC_memio *memio)
 Do a normal close (see nc_close()) on an in-memory dataset, then return a copy of the final memory contents of the dataset.
 
int nc_create (const char *path, int cmode, int *ncidp)
 Create a new netCDF file.
 
int NC_create (const char *path0, int cmode, size_t initialsz, int basepe, size_t *chunksizehintp, int useparallel, void *parameters, int *ncidp)
 
int nc_create_mem (const char *path, int mode, size_t initialsize, int *ncidp)
 Create a netCDF file with the contents stored in memory.
 
int nc_def_user_format (int mode_flag, NC_Dispatch *dispatch_table, char *magic_number)
 Add handling of user-defined format.
 
int nc_enddef (int ncid)
 Leave define mode.
 
int nc_inq (int ncid, int *ndimsp, int *nvarsp, int *nattsp, int *unlimdimidp)
 Inquire about a file or group.
 
int nc_inq_base_pe (int ncid, int *pe)
 
int nc_inq_format (int ncid, int *formatp)
 Inquire about the binary format of a netCDF file as presented by the API.
 
int nc_inq_format_extended (int ncid, int *formatp, int *modep)
 Obtain more detailed (vis-a-vis nc_inq_format) format information about an open dataset.
 
int nc_inq_nvars (int ncid, int *nvarsp)
 Learn the number of variables in a file or group.
 
int nc_inq_path (int ncid, size_t *pathlen, char *path)
 Get the file pathname (or the opendap URL) which was used to open/create the ncid's file.
 
int nc_inq_type (int ncid, nc_type xtype, char *name, size_t *size)
 Inquire about a type.
 
int nc_inq_user_format (int mode_flag, NC_Dispatch **dispatch_table, char *magic_number)
 Inquire about user-defined format.
 
int nc_open (const char *path, int omode, int *ncidp)
 Open an existing netCDF file.
 
int NC_open (const char *path0, int omode, int basepe, size_t *chunksizehintp, int useparallel, void *parameters, int *ncidp)
 
int nc_open_mem (const char *path, int omode, size_t size, void *memory, int *ncidp)
 Open a netCDF file with the contents taken from a block of memory.
 
int nc_open_memio (const char *path, int omode, NC_memio *params, int *ncidp)
 Open a netCDF file with the contents taken from a block of memory.
 
int nc_redef (int ncid)
 Put open netcdf dataset into define mode.
 
int nc_set_base_pe (int ncid, int pe)
 
int nc_set_fill (int ncid, int fillmode, int *old_modep)
 Change the fill-value mode to improve write performance.
 
int nc_sync (int ncid)
 Synchronize an open netcdf dataset to disk.
 
static int udf_formatx_to_index (int formatx)
 Helper function to convert NC_FORMATX_UDFn to array index (0-9).
 
static int udf_mode_to_index (int mode_flag)
 Helper function to convert NC_UDFn mode flag to array index (0-9).
 

Variables

static int pseudofd = 0
 
NC_DispatchUDF_dispatch_tables [NC_MAX_UDF_FORMATS] = {NULL}
 
char UDF_magic_numbers [NC_MAX_UDF_FORMATS][NC_MAX_MAGIC_NUMBER_LEN+1] = {{0}}
 

Detailed Description

File create and open functions.

These functions end up calling functions in one of the dispatch layers (netCDF-4, dap server, etc).

Copyright 2018 University Corporation for Atmospheric Research/Unidata. See COPYRIGHT file for more info.

Definition in file dfile.c.

Macro Definition Documentation

◆ nulldup

#define nulldup (   s)    ((s)?strdup(s):NULL)

Definition at line 44 of file dfile.c.

Function Documentation

◆ nc__create_mp()

int nc__create_mp ( const char *  path,
int  cmode,
size_t  initialsz,
int  basepe,
size_t *  chunksizehintp,
int *  ncidp 
)

Definition at line 577 of file dfile.c.

◆ nc__open_mp()

int nc__open_mp ( const char *  path,
int  omode,
int  basepe,
size_t *  chunksizehintp,
int *  ncidp 
)

Definition at line 908 of file dfile.c.

◆ nc_inq_base_pe()

int nc_inq_base_pe ( int  ncid,
int *  pe 
)

Definition at line 1531 of file dfile.c.

◆ nc_inq_nvars()

int nc_inq_nvars ( int  ncid,
int *  nvarsp 
)

Learn the number of variables in a file or group.

Parameters
ncidFile and group ID.
nvarspPointer that gets number of variables. Ignored if NULL.
Returns
NC_NOERR No error.
NC_EBADID Bad ncid.
Author
Glenn Davis, Ed Hartnett, Dennis Heimbigner

Definition at line 1688 of file dfile.c.

◆ nc_set_base_pe()

int nc_set_base_pe ( int  ncid,
int  pe 
)

Definition at line 1555 of file dfile.c.

◆ udf_formatx_to_index()

static int udf_formatx_to_index ( int  formatx)
static

Helper function to convert NC_FORMATX_UDFn to array index (0-9).

Parameters
formatxThe format constant (NC_FORMATX_UDF0 through NC_FORMATX_UDF9)
Returns
Array index 0-9, or -1 if not a valid UDF format constant
Note
Handles the gap in format numbering: UDF0=8, UDF1=9, UDF2=11, UDF3=12, etc. (NC_FORMATX_NCZARR=10 occupies the slot between UDF1 and UDF2)

Definition at line 87 of file dfile.c.

◆ udf_mode_to_index()

static int udf_mode_to_index ( int  mode_flag)
static

Helper function to convert NC_UDFn mode flag to array index (0-9).

Parameters
mode_flagThe mode flag (NC_UDF0 through NC_UDF9)
Returns
Array index 0-9, or -1 if not a valid UDF flag or multiple UDF flags set
Note
UDF flags are not sequential in bit positions due to conflicts with NC_NOATTCREORD (0x20000) and NC_NODIMSCALE_ATTACH (0x40000)

Definition at line 59 of file dfile.c.

Variable Documentation

◆ UDF_dispatch_tables

NC_Dispatch* UDF_dispatch_tables[NC_MAX_UDF_FORMATS] = {NULL}

Definition at line 51 of file dfile.c.

◆ UDF_magic_numbers

char UDF_magic_numbers[NC_MAX_UDF_FORMATS][NC_MAX_MAGIC_NUMBER_LEN+1] = {{0}}

Definition at line 52 of file dfile.c.