Visitar URL original
checking if a variable is a record variable when using PnetCDF option · Issue #519 · E3SM-Project/scorpio · GitHub
Skip to content

checking if a variable is a record variable when using PnetCDF option #519

Open

Description

@wkliao

For PnetCDF, checking whether a variable is a record variable can just check the
first dimension, because CDF-1,2,5 formats allow only the first dimension to be
unlimited.

scorpio/src/clib/pio_nc.c

Lines 1353 to 1365 in ac679a5

int *p = (dimidsp) ? dimidsp : tmp_dimidsp;
int is_rec_var = file->varlist[varid].rec_var;
for(int i=0; (i<ndims) && (!is_rec_var); i++)
{
for(int j=0; (j<file->num_unlim_dimids) && (!is_rec_var); j++)
{
if(p[i] == file->unlim_dimids[j])
{
is_rec_var = 1;
}
}
}
file->varlist[varid].rec_var = is_rec_var;

The above code block can be simplified to the following.

int *p = (dimidsp) ? dimidsp : tmp_dimidsp;
file->varlist[varid].rec_var = (ndims > 0 && p[0] == NC_UNLIMITED) ? 1 : 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions