NetCDF  4.8.0
dfile.c File Reference
#include "config.h"
#include <stdlib.h>
#include "ncdispatch.h"
#include "netcdf_mem.h"
#include "ncpathmgr.h"
#include "fbits.h"

Go to the source code of this file.

Functions

static int check_create_mode (int mode)
 Check the create mode parameter for sanity. More...
 
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. More...
 
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)
 
int nc__open (const char *path, int omode, size_t *chunksizehintp, int *ncidp)
 
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)
 
int nc_close (int ncid)
 
int nc_close_memio (int ncid, NC_memio *memio)
 
int nc_create (const char *path, int cmode, int *ncidp)
 
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)
 
int nc_def_user_format (int mode_flag, NC_Dispatch *dispatch_table, char *magic_number)
 Add handling of user-defined format. More...
 
int nc_enddef (int ncid)
 
int nc_inq (int ncid, int *ndimsp, int *nvarsp, int *nattsp, int *unlimdimidp)
 
int nc_inq_base_pe (int ncid, int *pe)
 
int nc_inq_format (int ncid, int *formatp)
 
int nc_inq_format_extended (int ncid, int *formatp, int *modep)
 
int nc_inq_nvars (int ncid, int *nvarsp)
 Learn the number of variables in a file or group. More...
 
int nc_inq_path (int ncid, size_t *pathlen, char *path)
 
int nc_inq_type (int ncid, nc_type xtype, char *name, size_t *size)
 
int nc_inq_user_format (int mode_flag, NC_Dispatch **dispatch_table, char *magic_number)
 Inquire about user-defined format. More...
 
int nc_open (const char *path, int omode, int *ncidp)
 Open an existing netCDF file. More...
 
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)
 
int nc_open_memio (const char *path, int omode, NC_memio *params, int *ncidp)
 
int nc_redef (int ncid)
 
int nc_set_base_pe (int ncid, int pe)
 
int nc_set_fill (int ncid, int fillmode, int *old_modep)
 
int nc_sync (int ncid)
 

Variables

int NC_initialized
 True when dispatch table is initialized. More...
 
static int pseudofd = 0
 
NC_Dispatch * UDF0_dispatch_table = NULL
 
char UDF0_magic_number [NC_MAX_MAGIC_NUMBER_LEN+1] = ""
 
NC_Dispatch * UDF1_dispatch_table = NULL
 
char UDF1_magic_number [NC_MAX_MAGIC_NUMBER_LEN+1] = ""
 

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.

Function Documentation

◆ check_create_mode()

static int check_create_mode ( int  mode)
static

Check the create mode parameter for sanity.

Some create flags cannot be used if corresponding library features are enabled during the build. This function does a pre-check of the mode flag before calling the dispatch layer nc_create functions.

Parameters
modeThe creation mode flag.
Returns
NC_NOERR No error.
NC_ENOTBUILT Requested feature not built into library
NC_EINVAL Invalid combination of modes.
Author
Ed Hartnett

Definition at line 1759 of file dfile.c.

◆ nc__create_mp()

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

Create a file with special (deprecated) Cray settings.

Deprecated:
This function was used in the old days with the Cray at NCAR. The Cray is long gone, and this call is supported only for backward compatibility. Use nc_create() instead.
Parameters
pathFile name.
cmodeCreate mode.
initialszInitial size of metadata region for classic files, ignored for other files.
basepeDeprecated parameter from the Cray days.
chunksizehintpA pointer to the chunk size hint. This only applies to classic files.
ncidpPointer that gets ncid.
Returns
NC_NOERR No error.
Author
Glenn Davis

Definition at line 534 of file dfile.c.

◆ nc__open_mp()

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

Open a netCDF file with extra parameters for Cray.

Deprecated:
This function was used in the old days with the Cray at NCAR. The Cray is long gone, and this call is supported only for backward compatibility. Use nc_open() instead.
Parameters
pathThe file name of the new netCDF dataset.
omodeOpen mode.
basepeDeprecated parameter from the Cray days.
chunksizehintpA pointer to the chunk size hint. This only applies to classic files.
ncidpPointer to location where returned netCDF ID is to be stored.
Returns
NC_NOERR
Author
Glenn Davis

Definition at line 865 of file dfile.c.

◆ nc__pseudofd()

int nc__pseudofd ( void  )

Create a pseudo file descriptor that does not overlap real file descriptors

Returns
pseudo file number
Author
Dennis Heimbigner

Definition at line 2158 of file dfile.c.

◆ NC_create()

int NC_create ( const char *  path0,
int  cmode,
size_t  initialsz,
int  basepe,
size_t *  chunksizehintp,
int  useparallel,
void *  parameters,
int *  ncidp 
)

Create a file, calling the appropriate dispatch create call.

For create, we have the following pieces of information to use to determine the dispatch table:

  • path
  • cmode
Parameters
path0The file name of the new netCDF dataset.
cmodeThe creation mode flag, the same as in nc_create().
initialszThis parameter sets the initial size of the file at creation time. This only applies to classic files.
basepeDeprecated parameter from the Cray days.
chunksizehintpA pointer to the chunk size hint. This only applies to classic files.
useparallelNon-zero if parallel I/O is to be used on this file.
parametersPointer to MPI comm and info.
ncidpPointer to location where returned netCDF ID is to be stored.
Returns
NC_NOERR No error.
Author
Dennis Heimbigner, Ed Hartnett, Ward Fisher

Definition at line 1824 of file dfile.c.

◆ nc_inq_base_pe()

int nc_inq_base_pe ( int  ncid,
int *  pe 
)

Learn base PE.

Deprecated:
This function was used in the old days with the Cray at NCAR. The Cray is long gone, and this call is now meaningless. The value returned for pe is always 0.
Parameters
ncidFile and group ID.
pePointer for base PE.
Returns
NC_NOERR No error.
NC_EBADID Invalid ncid passed.
Author
Glenn Davis

Definition at line 1488 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 1645 of file dfile.c.

◆ NC_open()

int NC_open ( const char *  path0,
int  omode,
int  basepe,
size_t *  chunksizehintp,
int  useparallel,
void *  parameters,
int *  ncidp 
)

Open a netCDF file (or remote dataset) calling the appropriate dispatch function.

For open, we have the following pieces of information to use to determine the dispatch table.

  • table specified by override
  • path
  • omode
  • the contents of the file (if it exists), basically checking its magic number.
Parameters
path0Path to the file to open.
omodeOpen mode.
basepeBase processing element (ignored).
chunksizehintpSize hint for classic files.
useparallelIf true use parallel I/O.
parametersExtra parameters for the open.
ncidpPointer that gets ncid.
Returns
NC_NOERR No error.
Author
Dennis Heimbigner

Definition at line 1962 of file dfile.c.

◆ nc_set_base_pe()

int nc_set_base_pe ( int  ncid,
int  pe 
)

Sets base processing element (ignored).

Deprecated:
This function was used in the old days with the Cray at NCAR. The Cray is long gone, and this call is supported only for backward compatibility.
Parameters
ncidFile ID.
peBase PE.
Returns
NC_NOERR No error.
NC_EBADID Invalid ncid passed.
Author
Glenn Davis

Definition at line 1512 of file dfile.c.

Variable Documentation

◆ NC_initialized

int NC_initialized

True when dispatch table is initialized.

◆ pseudofd

int pseudofd = 0
static

Static counter for pseudo file descriptors (incremented)

Definition at line 2148 of file dfile.c.