Skip to content

File Read_netcdf.cu

FileList > src > Read_netcdf.cu

Go to the source code of this file

  • #include "Read_netcdf.h"

Public Functions

Type Name
std::string checkncvarname (int ncid, std::string stringA, std::string stringB, std::string stringC, std::string stringD, std::string stringE)
Check for the existence of NetCDF variable names and return the first found.
int nc_get_var1_T (int ncid, int varid, const size_t * startp, float * zsa)
int nc_get_var1_T (int ncid, int varid, const size_t * startp, double * zsa)
int nc_get_var_T (int ncid, int varid, float *& zb)
int nc_get_var_T (int ncid, int varid, double *& zb)
int nc_get_var_T (int ncid, int varid, int *& zb)
int nc_get_vara_T (int ncid, int varid, const size_t * startp, const size_t * countp, int *& zb)
int nc_get_vara_T (int ncid, int varid, const size_t * startp, const size_t * countp, float *& zb)
int nc_get_vara_T (int ncid, int varid, const size_t * startp, const size_t * countp, double *& zb)
void read2Dnc (int nx, int ny, char ncfile, float *& hh)
void read3Dnc (int nx, int ny, int ntheta, char ncfile, float *& ee)
void readATMstep (forcingmap ATMPmap, int steptoread, float *& Po)
Read atmospheric pressure data from NetCDF file for a specific time step.
void readWNDstep (forcingmap WNDUmap, forcingmap WNDVmap, int steptoread, float *& Uo, float *& Vo)
Read wind data from NetCDF files for a specific time step.
void readgridncsize (const std::string ncfilestr, const std::string varstr, std::string reftime, int & nx, int & ny, int & nt, double & dx, double & dy, double & dt, double & xo, double & yo, double & to, double & xmax, double & ymax, double & tmax, bool & flipx, bool & flipy)
Read grid size and metadata from a NetCDF file.
void readgridncsize (forcingmap & Fmap, Param XParam)
Read grid size and metadata for a forcing map.
void readgridncsize (T & Imap)
Read grid size and metadata for a generic map type.
template void readgridncsize< DynForcingP< float > > (DynForcingP< float > & Imap)
template void readgridncsize< StaticForcingP< float > > (StaticForcingP< float > & Imap)
template void readgridncsize< StaticForcingP< int > > (StaticForcingP< int > & Imap)
template void readgridncsize< deformmap< float > > (deformmap< float > & Imap)
template void readgridncsize< forcingmap > (forcingmap & Imap)
template void readgridncsize< inputmap > (inputmap & Imap)
int readncslev1 (std::string filename, std::string varstr, size_t indx, size_t indy, size_t indt, bool checkhh, double eps, T *& zsa)
Read a single level of data from a NetCDF file.
template int readncslev1< double > (std::string filename, std::string varstr, size_t indx, size_t indy, size_t indt, bool checkhh, double eps, double *& zsa)
template int readncslev1< float > (std::string filename, std::string varstr, size_t indx, size_t indy, size_t indt, bool checkhh, double eps, float *& zsa)
int readnctime (std::string filename, double *& time)
Read time variable from a NetCDF file.
int readnctime2 (int ncid, char * timecoordname, std::string refdate, size_t nt, double *& time)
Read time variable from a NetCDF file with reference date.
void readnczb (int nx, int ny, std::string ncfile, float *& zb)
int readvardata (std::string filename, std::string Varname, int step, T *& vardata, bool flipx, bool flipy)
Read variable data from a NetCDF file for a specific time step.
template int readvardata< double > (std::string filename, std::string Varname, int step, double *& vardata, bool flipx, bool flipy)
template int readvardata< float > (std::string filename, std::string Varname, int step, float *& vardata, bool flipx, bool flipy)
template int readvardata< int > (std::string filename, std::string Varname, int step, int *& vardata, bool flipx, bool flipy)
int readvarinfo (std::string filename, std::string Varname, size_t *& ddimU)
Read variable dimension info from a NetCDF file.

Public Functions Documentation

function checkncvarname

Check for the existence of NetCDF variable names and return the first found.

std::string checkncvarname (
    int ncid,
    std::string stringA,
    std::string stringB,
    std::string stringC,
    std::string stringD,
    std::string stringE
) 

Checks up to five possible variable names in a NetCDF file and returns the first one that exists.

Parameters:

  • ncid NetCDF file ID
  • stringA First variable name to check
  • stringB Second variable name to check
  • stringC Third variable name to check
  • stringD Fourth variable name to check
  • stringE Fifth variable name to check

Returns:

The first variable name found in the NetCDF file, or an empty string if none are found.


function nc_get_var1_T

inline int nc_get_var1_T (
    int ncid,
    int varid,
    const size_t * startp,
    float * zsa
) 

function nc_get_var1_T

inline int nc_get_var1_T (
    int ncid,
    int varid,
    const size_t * startp,
    double * zsa
) 

function nc_get_var_T

inline int nc_get_var_T (
    int ncid,
    int varid,
    float *& zb
) 

function nc_get_var_T

inline int nc_get_var_T (
    int ncid,
    int varid,
    double *& zb
) 

function nc_get_var_T

inline int nc_get_var_T (
    int ncid,
    int varid,
    int *& zb
) 

function nc_get_vara_T

inline int nc_get_vara_T (
    int ncid,
    int varid,
    const size_t * startp,
    const size_t * countp,
    int *& zb
) 

function nc_get_vara_T

inline int nc_get_vara_T (
    int ncid,
    int varid,
    const size_t * startp,
    const size_t * countp,
    float *& zb
) 

function nc_get_vara_T

inline int nc_get_vara_T (
    int ncid,
    int varid,
    const size_t * startp,
    const size_t * countp,
    double *& zb
) 

function read2Dnc

void read2Dnc (
    int nx,
    int ny,
    char ncfile,
    float *& hh
) 

function read3Dnc

void read3Dnc (
    int nx,
    int ny,
    int ntheta,
    char ncfile,
    float *& ee
) 

function readATMstep

Read atmospheric pressure data from NetCDF file for a specific time step.

void readATMstep (
    forcingmap ATMPmap,
    int steptoread,
    float *& Po
) 

Reads atmospheric pressure data from a NetCDF file for a given time step. Atm pressure is same as wind we only read floats and that is plenty for real world application.

Parameters:

  • ATMPmap Forcing map for atmospheric pressure
  • steptoread Time step to read
  • Po Output array for pressure data

function readWNDstep

Read wind data from NetCDF files for a specific time step.

void readWNDstep (
    forcingmap WNDUmap,
    forcingmap WNDVmap,
    int steptoread,
    float *& Uo,
    float *& Vo
) 

Reads U and V wind components from NetCDF files for a given time step. By default we want to read wind info as float because it will reside in a texture. the value is converted to the apropriate type only when it is used. so there is no need to template this function

Parameters:

  • WNDUmap Forcing map for U wind
  • WNDVmap Forcing map for V wind
  • steptoread Time step to read
  • Uo Output array for U wind
  • Vo Output array for V wind

function readgridncsize

Read grid size and metadata from a NetCDF file.

void readgridncsize (
    const std::string ncfilestr,
    const std::string varstr,
    std::string reftime,
    int & nx,
    int & ny,
    int & nt,
    double & dx,
    double & dy,
    double & dt,
    double & xo,
    double & yo,
    double & to,
    double & xmax,
    double & ymax,
    double & tmax,
    bool & flipx,
    bool & flipy
) 

Reads dimensions, coordinates, and time information for a variable in a NetCDF file.

Parameters:

  • ncfilestr NetCDF filename
  • varstr Variable name
  • reftime Reference time string
  • nx Number of x grid points
  • ny Number of y grid points
  • nt Number of time steps
  • dx Grid spacing in x
  • dy Grid spacing in y
  • dt Time step size
  • xo Origin x
  • yo Origin y
  • to Origin time
  • xmax Maximum x
  • ymax Maximum y
  • tmax Maximum time
  • flipx Flip x axis
  • flipy Flip y axis

function readgridncsize

Read grid size and metadata for a forcing map.

void readgridncsize (
    forcingmap & Fmap,
    Param XParam
) 

Reads grid size and metadata for a forcing map using model parameters.

Parameters:


function readgridncsize

Read grid size and metadata for a generic map type.

template<class T>
void readgridncsize (
    T & Imap
) 

Reads grid size and metadata for a generic map type (inputmap, forcingmap, etc.).

Template parameters:

  • T Map type

Parameters:

  • Imap Map structure

function readgridncsize< DynForcingP< float > >

template void readgridncsize< DynForcingP< float > > (
    DynForcingP < float > & Imap
) 

function readgridncsize< StaticForcingP< float > >

template void readgridncsize< StaticForcingP< float > > (
    StaticForcingP < float > & Imap
) 

function readgridncsize< StaticForcingP< int > >

template void readgridncsize< StaticForcingP< int > > (
    StaticForcingP < int > & Imap
) 

function readgridncsize< deformmap< float > >

template void readgridncsize< deformmap< float > > (
    deformmap < float > & Imap
) 

function readgridncsize< forcingmap >

template void readgridncsize< forcingmap > (
    forcingmap & Imap
) 

function readgridncsize< inputmap >

template void readgridncsize< inputmap > (
    inputmap & Imap
) 

function readncslev1

Read a single level of data from a NetCDF file.

template<class T>
int readncslev1 (
    std::string filename,
    std::string varstr,
    size_t indx,
    size_t indy,
    size_t indt,
    bool checkhh,
    double eps,
    T *& zsa
) 

Reads a single level of data for a variable from a NetCDF file.

Template parameters:

  • T Data type

Parameters:

  • filename NetCDF filename
  • varstr Variable name
  • indx X index
  • indy Y index
  • indt Time index
  • checkhh Check for missing values
  • eps Epsilon for missing value detection
  • zsa Output array for data

Returns:

Status code


function readncslev1< double >

template int readncslev1< double > (
    std::string filename,
    std::string varstr,
    size_t indx,
    size_t indy,
    size_t indt,
    bool checkhh,
    double eps,
    double *& zsa
) 

function readncslev1< float >

template int readncslev1< float > (
    std::string filename,
    std::string varstr,
    size_t indx,
    size_t indy,
    size_t indt,
    bool checkhh,
    double eps,
    float *& zsa
) 

function readnctime

Read time variable from a NetCDF file.

int readnctime (
    std::string filename,
    double *& time
) 

Reads the time variable from a NetCDF file into a double array.

Parameters:

  • filename NetCDF filename
  • time Output array for time values

Returns:

Status code


function readnctime2

Read time variable from a NetCDF file with reference date.

int readnctime2 (
    int ncid,
    char * timecoordname,
    std::string refdate,
    size_t nt,
    double *& time
) 

Reads the time variable from a NetCDF file using a reference date and time coordinate name.

Parameters:

  • ncid NetCDF file ID
  • timecoordname Time coordinate variable name
  • refdate Reference date string
  • nt Number of time steps
  • time Output array for time values

Returns:

Status code


function readnczb

void readnczb (
    int nx,
    int ny,
    std::string ncfile,
    float *& zb
) 

function readvardata

Read variable data from a NetCDF file for a specific time step.

template<class T>
int readvardata (
    std::string filename,
    std::string Varname,
    int step,
    T *& vardata,
    bool flipx,
    bool flipy
) 

Reads data for a variable from a NetCDF file for a given time step, with optional axis flipping.

Template parameters:

  • T Data type

Parameters:

  • filename NetCDF filename
  • Varname Variable name
  • step Time step to read
  • vardata Output array for data
  • flipx Flip x axis
  • flipy Flip y axis

Returns:

Status code


function readvardata< double >

template int readvardata< double > (
    std::string filename,
    std::string Varname,
    int step,
    double *& vardata,
    bool flipx,
    bool flipy
) 

function readvardata< float >

template int readvardata< float > (
    std::string filename,
    std::string Varname,
    int step,
    float *& vardata,
    bool flipx,
    bool flipy
) 

function readvardata< int >

template int readvardata< int > (
    std::string filename,
    std::string Varname,
    int step,
    int *& vardata,
    bool flipx,
    bool flipy
) 

function readvarinfo

Read variable dimension info from a NetCDF file.

int readvarinfo (
    std::string filename,
    std::string Varname,
    size_t *& ddimU
) 

Reads the dimensions for a variable in a NetCDF file.

Parameters:

  • filename NetCDF filename
  • Varname Variable name
  • ddimU Output array for dimension sizes

Returns:

Number of dimensions



The documentation for this class was generated from the following file src/Read_netcdf.cu