Home > coriolis > bigone > PROJETS > UVMAT.new > read_ncvar.m

# read_ncvar

## PURPOSE

'read_ncvar': reads a list of fields and constants in a netcdf file

## SYNOPSIS

function [cte_detect,var_detect,cte_read,var_read,choice,cte2_detect,var2_detect,cte2_read,var2_read,choice2]=read_ncvar(filename,cte1,nb1,var1,cte2,nb2,var2)

## DESCRIPTION

    'read_ncvar': reads a list of fields and constants in a netcdf file
    ------------------------------------------------------------------
    [cte_detect,var_detect,cte_read,var_read,choice,cte2_detect,var2_detect,cte2_read,var2_read]=...
     read_netcdf(filename,cte1,nb1,var1,cte2,nb2,var2,option)
    OUTPUT:
    cte_detect: array with the dimension of cte1 or cte2 (option 'or'), =1 if the constant is detected 0 else.
    var_detect: like cte_detect for the variables
    cte_read: list of the values for the constants (global attributes), =0 if not detected
    var_read(ind,:): variable array number ind, the variable #i is determined as var_read(ind(i),:), with ind=cumsum(var_detect);
    choice=1 if the first list is chosen (or with the option 'and'), 2 else.
    cte2_detect,var2_detect, cte2_read,var2_read, second set of v ctes and variables (only with the option 'and')

    INPUT:
    filename (netcdf file)
    cte1: cell array listing the constants (global attributes) to read
    nb1: name the constant in the netcdf file giving the length of var1 (if absent no variable is read)
        if nb1 is a cell array, nb1{i} corresponds to the choice by order of priority (as given by varname_generator)
        and cte{i,:} is the corresponding list of constants
    var1{i,:}: list of variables arrays to read by order of priority with length nb1{i}
    cte2,nb2,var2: second list of cte and variables (optional)

     related FUNCTION
     'varname_generator.m': generates the appropriate list of variables and constants

## CROSS-REFERENCE INFORMATION

This function calls:

- nc2struct 'nc2struct': transform a netcdf file in a corresponding matlab structure

This function is called by:

- read_ncdata 'read_ncdata': reads variables from netcdf files, recognizing civx data.
- read_ncfield 'read_ncfield': reads one or two velocity fields and associated parameters from a file .