MINC routines

Error handling for MINC routines is the same as for NetCDF functions, with the exception that routines returning pointers will return NULL instead of MI_ERROR when an error occurs. Error codes (returned in ncerr) can be found in the header file minc.h.

General convenience functions

miexpand_file : Routine to expand a minc file that has been compressed with compress, pack, gzip or zip (using gunzip, zcat or pcat). The name of the temporary minc file is returned -- this string must be freed by the caller. If the file specified by path is not compressed, then its name is returned. *create_tempfile is set to TRUE if a temporary file is created (and the caller needs to delete the file), FALSE if the original file name is returned. If tempfile is NULL, then the routine generates its own temporary file name, otherwise, the user provided name is used. If header_only is TRUE, then the routine will expand only enough of the file to read the header.

public char *miexpand_file(char *path, char *tempfile, int header_only, 
                           int *created_tempfile);

miopen : Like ncopen, but will temporarily uncompress files (compress, pack, gzip, zip) opened with mode NC_NOWRITE.

public int miopen(char *path, int mode);

micreate : Like nccreate. May be enhanced in the future.

public int micreate(char *path, int cmode);

miclose : Like ncclose, but finishes up for miopen and micreate.

public int miclose(int cdfid);

miattget : Like ncattget, but the caller specifies the desired numeric type and maximum number of values to get. Type is specified with datatype (the sign is the default for the type: MI_UNSIGNED for NC_BYTE and MI_SIGNED otherwise). max_length gives the maximum number of values to get and att_length returns the number of values actually read. An error will occur if the attribute type is not numeric.

public int miattget(int cdfid, int varid, char *name, nc_type datatype,
                    int max_length, void *value, int *att_length);

miattget1 : Like miattget, but only one value is returned. If there is more than one value, an error occurs.

public int miattget1(int cdfid, int varid, char *name, nc_type datatype,
                    void *value);

miattgetstr : Gets a string value from an attribute. maxlen gives the maximum number of characters to be returned (including the terminating '\0'). The string is written to the array specified by value and a pointer to the string is returned.

public char *miattgetstr(int cdfid, int varid, char *name, 
                         int maxlen, char *value);

miattputint : Write an integer attribute.

public int miattputint(int cdfid, int varid, char *name, int value);

miattputdbl : Write a double precision attribute.

public int miattputdbl(int cdfid, int varid, char *name, double value);

miattputstr : Write a string attribute.

public int miattputstr(int cdfid, int varid, char *name, char *value);

mivarget : Like ncvarget, but the caller specifies the desired numeric type and sign (either MI_SIGNED or MI_UNSIGNED).

public int mivarget(int cdfid, int varid, long start[], long count[],
                    nc_type datatype, char *sign, void *values);

mivarget1 : Like ncvarget1, but the caller specifies the desired numeric type and sign.

public int mivarget1(int cdfid, int varid, long mindex[],
                     nc_type datatype, char *sign, void *value);

mivarput : Like ncvarput, but the caller specifies the numeric type and sign of the values being passed.

public int mivarput(int cdfid, int varid, long start[], long count[],
                    nc_type datatype, char *sign, void *values);

mivarput1 : Like ncvarput1, but the caller specifies the numeric type and sign of the values being passed.

public int mivarput1(int cdfid, int varid, long mindex[],
                     nc_type datatype, char *sign, void *value);

miset_coords : Set nvals values of the coordinate vector coords to value. A pointer to coords is returned.

public long *miset_coords(int nvals, long value, long coords[]);

mitranslate_coords : Translates the coordinate vector incoords for subscripting variable invar of file cdfid to vector outcoords for subscripting variable outvar. This is useful when two variables have similar dimensions, but not necessarily the same order of dimensions. If invar has a dimension that is not in outvar, then the corresponding coordinate is ignored. If outvar has a dimension that is not in invar, then the corresponding coordinate is not modified. A pointer to outcoords is returned.

public long *mitranslate_coords(int cdfid, 
                                int invar,  long incoords[],
                                int outvar, long outcoords[]);

micopy_all_atts : Copy all of the attributes of one variable to another (possibly across files).

public int micopy_all_atts(int incdfid, int invarid, 
                           int outcdfid, int outvarid);

micopy_var_def : Copy a variable definition (including attributes) from one file to another. outcdfid must be in define mode. The id of the newly created variable is returned.

public int micopy_var_def(int incdfid, int invarid, int outcdfid);

micopy_var_values : Copy a variable's values from one file to another. incdfid and outcdfid must be in data mode.

public int micopy_var_values(int incdfid, int invarid, 
                             int outcdfid, int outvarid);

micopy_all_var_defs : Copy all variable definitions from one file to another, excluding a list of variables. The list of nexclude variable id's is given in excluded_vars. outcdfid must be in define mode.

public int micopy_all_var_defs(int incdfid, int outcdfid, int nexclude,
                               int excluded_vars[]);

micopy_all_var_values : Copy all variable values from one file to another, excluding a list of variables. The list of nexclude variable id's is given in excluded_vars. outcdfid must be in data mode.

public int micopy_all_var_values(int incdfid, int outcdfid, int nexclude,
                                 int excluded_vars[]);