get_ncidΒΆ

get_ncid

ncid = get_ncid()

Returns the handle of the NC file that is currently being processed by the formula interpreter.

This function is typically used inside formulas (_fi_*) and condition functions (_fiis_*) to query attributes or other information from the active NC file (see Formula Interpreter 3 - Creating Script Formulas).

Return Value

ncid

Handle of the active NC file. Use this handle with functions such as nc_attinq_datatype or nc_attget to read information from the file.

Returns -1 if no NC file is currently active.

Example

The following condition function checks whether the active NC file has the global attribute PEtrol___DIesel set to "DI":

def _fiis_diesel()
{
    ncid = get_ncid();
    if (ncid == -1) {
        error();
        return FALSE;
    }
    if (nc_attinq_datatype(ncid, NC_GLOBAL, "PEtrol___DIesel") == NC_CHAR) {
        ssEngineType = nc_attget(ncid, NC_GLOBAL, "PEtrol___DIesel");
        if (ssEngineType == "DI") {
            return TRUE;
        }
    }
    return FALSE;
}

History

Version

Description

R2012 (5.40.0)

New documentation.

5.7

New.

id-1863465