Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patch for #388 - setting global _FillValue #389

Merged
merged 2 commits into from
Mar 30, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 51 additions & 3 deletions libdispatch/dattput.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ apply.
\param value Pointer to one or more values.

\returns ::NC_NOERR No error.
\returns ::NC_EINVAL More than one value for _FillValue or trying to set global _FillValue.
\returns ::NC_EINVAL More than one value for _FillValue.
\returns ::NC_EGLOBAL Trying to set global _FillValue.
\returns ::NC_ENOTVAR Couldn't find varid.
\returns ::NC_EBADTYPE Fill value and var must be same type.
\returns ::NC_ENOMEM Out of memory
Expand All @@ -53,6 +54,9 @@ nc_put_att_string(int ncid, int varid, const char *name,
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
/* set global _FillValue is not allowed */
if (varid == NC_GLOBAL && name != NULL && !strcmp(name, _FillValue))
return NC_EGLOBAL;
return ncp->dispatch->put_att(ncid, varid, name, NC_STRING,
len, (void*)value, NC_STRING);
}
Expand Down Expand Up @@ -87,7 +91,8 @@ apply.
\param value Pointer to one or more values.

\returns ::NC_NOERR No error.
\returns ::NC_EINVAL More than one value for _FillValue or trying to set global _FillValue.
\returns ::NC_EINVAL More than one value for _FillValue.
\returns ::NC_EGLOBAL Trying to set global _FillValue.
\returns ::NC_ENOTVAR Couldn't find varid.
\returns ::NC_EBADTYPE Fill value and var must be same type.
\returns ::NC_ENOMEM Out of memory
Expand Down Expand Up @@ -141,6 +146,9 @@ int nc_put_att_text(int ncid, int varid, const char *name,
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
/* set global _FillValue is not allowed */
if (varid == NC_GLOBAL && name != NULL && !strcmp(name, _FillValue))
return NC_EGLOBAL;
return ncp->dispatch->put_att(ncid, varid, name, NC_CHAR, len,
(void *)value, NC_CHAR);
}
Expand Down Expand Up @@ -182,7 +190,8 @@ apply.
\param value Pointer to one or more values.

\returns ::NC_NOERR No error.
\returns ::NC_EINVAL More than one value for _FillValue or trying to set global _FillValue.
\returns ::NC_EINVAL More than one value for _FillValue.
\returns ::NC_EGLOBAL Trying to set global _FillValue.
\returns ::NC_ENOTVAR Couldn't find varid.
\returns ::NC_EBADTYPE Fill value and var must be same type.
\returns ::NC_ENOMEM Out of memory
Expand Down Expand Up @@ -232,6 +241,9 @@ nc_put_att(int ncid, int varid, const char *name, nc_type xtype,
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
/* set global _FillValue is not allowed */
if (varid == NC_GLOBAL && name != NULL && !strcmp(name, _FillValue))
return NC_EGLOBAL;
return ncp->dispatch->put_att(ncid, varid, name, xtype, len,
value, xtype);
}
Expand All @@ -243,6 +255,9 @@ nc_put_att_schar(int ncid, int varid, const char *name,
NC *ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
/* set global _FillValue is not allowed */
if (varid == NC_GLOBAL && name != NULL && !strcmp(name, _FillValue))
return NC_EGLOBAL;
return ncp->dispatch->put_att(ncid, varid, name, xtype, len,
(void *)value, NC_BYTE);
}
Expand All @@ -254,6 +269,9 @@ nc_put_att_uchar(int ncid, int varid, const char *name,
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
/* set global _FillValue is not allowed */
if (varid == NC_GLOBAL && name != NULL && !strcmp(name, _FillValue))
return NC_EGLOBAL;
return ncp->dispatch->put_att(ncid, varid, name, xtype, len,
(void *)value, NC_UBYTE);
}
Expand All @@ -265,6 +283,9 @@ nc_put_att_short(int ncid, int varid, const char *name,
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
/* set global _FillValue is not allowed */
if (varid == NC_GLOBAL && name != NULL && !strcmp(name, _FillValue))
return NC_EGLOBAL;
return ncp->dispatch->put_att(ncid, varid, name, xtype, len,
(void *)value, NC_SHORT);
}
Expand All @@ -276,6 +297,9 @@ nc_put_att_int(int ncid, int varid, const char *name,
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
/* set global _FillValue is not allowed */
if (varid == NC_GLOBAL && name != NULL && !strcmp(name, _FillValue))
return NC_EGLOBAL;
return ncp->dispatch->put_att(ncid, varid, name, xtype, len,
(void *)value, NC_INT);
}
Expand All @@ -287,6 +311,9 @@ nc_put_att_long(int ncid, int varid, const char *name,
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
/* set global _FillValue is not allowed */
if (varid == NC_GLOBAL && name != NULL && !strcmp(name, _FillValue))
return NC_EGLOBAL;
return ncp->dispatch->put_att(ncid, varid, name, xtype, len,
(void *)value, longtype);
}
Expand All @@ -298,6 +325,9 @@ nc_put_att_float(int ncid, int varid, const char *name,
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
/* set global _FillValue is not allowed */
if (varid == NC_GLOBAL && name != NULL && !strcmp(name, _FillValue))
return NC_EGLOBAL;
return ncp->dispatch->put_att(ncid, varid, name, xtype, len,
(void *)value, NC_FLOAT);
}
Expand All @@ -309,6 +339,9 @@ nc_put_att_double(int ncid, int varid, const char *name,
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
/* set global _FillValue is not allowed */
if (varid == NC_GLOBAL && name != NULL && !strcmp(name, _FillValue))
return NC_EGLOBAL;
return ncp->dispatch->put_att(ncid, varid, name, xtype, len,
(void *)value, NC_DOUBLE);
}
Expand All @@ -320,6 +353,9 @@ nc_put_att_ubyte(int ncid, int varid, const char *name,
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
/* set global _FillValue is not allowed */
if (varid == NC_GLOBAL && name != NULL && !strcmp(name, _FillValue))
return NC_EGLOBAL;
return ncp->dispatch->put_att(ncid, varid, name, xtype, len,
(void *)value, NC_UBYTE);
}
Expand All @@ -331,6 +367,9 @@ nc_put_att_ushort(int ncid, int varid, const char *name,
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
/* set global _FillValue is not allowed */
if (varid == NC_GLOBAL && name != NULL && !strcmp(name, _FillValue))
return NC_EGLOBAL;
return ncp->dispatch->put_att(ncid, varid, name, xtype, len,
(void *)value, NC_USHORT);
}
Expand All @@ -342,6 +381,9 @@ nc_put_att_uint(int ncid, int varid, const char *name,
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
/* set global _FillValue is not allowed */
if (varid == NC_GLOBAL && name != NULL && !strcmp(name, _FillValue))
return NC_EGLOBAL;
return ncp->dispatch->put_att(ncid, varid, name, xtype, len,
(void *)value, NC_UINT);
}
Expand All @@ -354,6 +396,9 @@ nc_put_att_longlong(int ncid, int varid, const char *name,
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
/* set global _FillValue is not allowed */
if (varid == NC_GLOBAL && name != NULL && !strcmp(name, _FillValue))
return NC_EGLOBAL;
return ncp->dispatch->put_att(ncid, varid, name, xtype, len,
(void *)value, NC_INT64);
}
Expand All @@ -366,6 +411,9 @@ nc_put_att_ulonglong(int ncid, int varid, const char *name,
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
/* set global _FillValue is not allowed */
if (varid == NC_GLOBAL && name != NULL && !strcmp(name, _FillValue))
return NC_EGLOBAL;
return ncp->dispatch->put_att(ncid, varid, name, xtype, len,
(void *)value, NC_UINT64);
}