NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.
To learn about what's going on, see About the Archive Site.
Hi, I have revised the code a little and found the point of failure: NcDim *dim = file->add_dim("dim", (int) featureSpace->coordinate_system->size() ); NcDim *N = file->add_dim( "N", clusters.size() ); int var_id, dim_id; nc_inq_dimid( ncid, "dim", &dim_id ); int dims[1] = {dim_id}; nc_def_var( ncid, ss.str().c_str(), type_id, 1, dims, &var_id ); ... size_t start=0, len=clusters[ci].points.size(); status = nc_put_vara_double( nc_file_id, var_id, &start, &len, &data[0][0] ); check_nc_error( "nc_put_vara_double", status ); nc_put_vara_double returns status code -57, which according to the man page translates to: NC_EEDGE The specified edge lengths added to the specified corner would have referenced data out of range for the rank of the specified variable. For example, an edge length that is larger than the corresponding dimension length minus the corner index will cause an error. I revised the code again, making the dimension variable N 'unlimited' and the variables X1 ... X_n depending on N and d: NcDim *dim = file->add_dim("dim", (int) featureSpace->coordinate_system->size() ); NcDim *N = file->add_dim( "N", NC_UNLIMITED ); .... int var_id, dim_id, N_id; status = nc_inq_dimid( nc_file_id, "dim", &dim_id ); check_nc_error( "nc_inq_dimid", status ); status = nc_inq_dimid( nc_file_id, "N", &N_id ); check_nc_error( "nc_inq_dimid", status ); int dims[2] = {N_id,dim_id}; status = nc_def_var( nc_file_id, ss.str().c_str(), type_id, 2, dims, &var_id ); and now I get the following error: NC_EINVALCOORDS The specified corner indices were out of range for the rank of the specified variable. For example, a negative index, or an index that is larger than the corresponding dimension length will cause an error. Something I'm overlooking here! Anyone know what it is? Kind Regards, Jürgen
netcdfgroup
archives: