nc_varput_text

The nc_varput_text functions writes string data values into a netCDF variable of an open netCDF file. The file must be in data mode.

r = nc_varput_text(ncid, varid, rsStart, rsCount, svData)

Return Value

r is -1 in case an error occurred.

Parameters

ncid

Identifies the netCDF file.

varid

varid is the ID of a variable. The data type must be NC_CHAR. The variable must have two dimensions.

rvStart

rsStart is the start index. The index starts with 0.

rsCount

rsCount is the number of elemenst to write. rsCount must correspond to the variable’s first dimension.

svData

svData is a string vector.

Example

Beispiel

svData = ["Text1", "Another Text", "A Long Text"];
ncid = nc_create("d:/test.nc");
dimid1 = nc_dimdef(ncid, "n", len(svData));
dimid2 = nc_dimdef(ncid, "nChar", max(strlen(svData))); // longest text

varid = nc_vardef(ncid, "text", NC_CHAR, [dimid1, dimid2]);
nc_endef(ncid);
nc_varput_text(ncid, varid, 0, len(svData), svData);
nc_close(ncid);

id-885951