NetCDF  4.6.3
 All Data Structures Files Functions Variables Typedefs Macros Modules Pages
dfile.c File Reference

File create and open functions. More...

#include "config.h"
#include <stdlib.h>
#include "ncdispatch.h"
#include "netcdf_mem.h"
#include "ncwinpath.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...
 
static int closemagic (struct MagicFile *file)
 Close the file opened to check for magic number. More...
 
int fileno (FILE *)
 
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)
 Leave define mode with performance tuning. More...
 
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. More...
 
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. More...
 
static int NC_check_file_type (const char *path, int flags, int use_parallel, void *parameters, int *model, int *version)
 
int nc_close (int ncid)
 Close an open netCDF dataset. More...
 
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. More...
 
int nc_create (const char *path, int cmode, int *ncidp)
 Create a new netCDF file. More...
 
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. More...
 
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)
 Leave define mode. More...
 
int nc_inq (int ncid, int *ndimsp, int *nvarsp, int *nattsp, int *unlimdimidp)
 Inquire about a file or group. More...
 
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. More...
 
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. More...
 
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)
 Get the file pathname (or the opendap URL) which was used to open/create the ncid's file. More...
 
int nc_inq_type (int ncid, nc_type xtype, char *name, size_t *size)
 Inquire about a type. More...
 
int nc_inq_user_format (int mode_flag, NC_Dispatch **dispatch_table, char *magic_number)
 Inquire about user-defined format. More...
 
static int NC_interpret_magic_number (char *magic, int *model, int *version)
 Interpret the magic number found in the header of a netCDF file. 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)
 Open a netCDF file with the contents taken from a block of memory. More...
 
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. More...
 
int nc_redef (int ncid)
 Put open netcdf dataset into define mode. More...
 
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. More...
 
int nc_sync (int ncid)
 Synchronize an open netcdf dataset to disk. More...
 
static int openmagic (struct MagicFile *file)
 
static int readmagic (struct MagicFile *file, long pos, char *magic)
 

Variables

static char HDF5_SIGNATURE [MAGIC_NUMBER_LEN] = "\211HDF\r\n\032\n"
 
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

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.

Definition at line 1950 of file dfile.c.

static int closemagic ( struct MagicFile *  file)
static

Close the file opened to check for magic number.

Parameters
filepointer to the MagicFile struct for this open file.
Returns
NC_NOERR for success
NC_EPARINIT if there was a problem closing file with MPI (parallel builds only).
Author
Dennis Heimbigner

Definition at line 2595 of file dfile.c.

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 1836 of file dfile.c.

static int NC_interpret_magic_number ( char *  magic,
int *  model,
int *  version 
)
static

Interpret the magic number found in the header of a netCDF file.

This function interprets the magic number/string contained in the header of a netCDF file and sets the appropriate NC_FORMATX flags.

Parameters
[in]magicPointer to a character array with the magic number block.
[out]modelPointer to an integer to hold the corresponding netCDF type.
[out]versionPointer to an integer to hold the corresponding netCDF version.
Returns
NC_NOERR if a legitimate file type found
NC_ENOTNC otherwise

Definition at line 223 of file dfile.c.

Variable Documentation

int NC_initialized

True when dispatch table is initialized.


Return to the Main Unidata NetCDF page.
Generated on Sat Apr 6 2019 08:19:00 for NetCDF. NetCDF is a Unidata library.