Skip to content

netcdf built with hdf5 1.10.8 error after 'nc_def_var_fletcher32' #2189

@abhibaruah

Description

@abhibaruah

NetCDF version: v4.8.1
OS: Linux 10
Compiler gcc 8.3.0

I am a developer at The MathWorks Inc. For MATLAB, we were building netcdf with hdf5-1.8.12.
However, we are trying to change netcdf's dependency on hdf5 to v1.10.8.

I built netcdf successfully with hdf5 1.10.8. However, while qualifying I started seeing some of our tests fail, which I have narrowed down to an issue with 'nc_def_var_fletcher'.

I am attaching a C repro code below, which works fine when netcdf 4.8.1 is built with hdf5 1.8.12.

However, when netcdf 4.8.1 is built with hdf5 1.10.8, 'nc_close' on line 35 gives the error code -101 (NC_EHDFERR)
The error does not occur if the datatype (xtype) in 'nc_def_var' is anything other than NC_STRING.
Also, the error does not occur if the call to 'nc_def_var_fletcher32' is removed.

Any help in resolving this would be highly appreciated.

#include <iostream>
#include <vector>
#include "netcdf.h"

void checkErrorCode(int status, const char* message){
    if (status != NC_NOERR){
        std::cout << "Error code: " << status << " from " << message << std::endl;
    }
}

int main(int argc, const char * argv[]) {
    
    int ncid;
    int retval;
    
    retval = nc_create("myfile.nc", NC_NETCDF4, &ncid);
    checkErrorCode(retval, "nc_create");
    
    // Define dimensions
    int dimid_a;
	int dimlen = 100;
    retval = nc_def_dim(ncid, "a", dimlen, &dimid_a);
    checkErrorCode(retval, "nc_def_dim for 'a'");
    
    // Define variable
    int varid;
	int dimids[1] = {dimid_a};
    retval = nc_def_var(ncid, "var", NC_STRING, 1, dimids, &varid);
    checkErrorCode(retval, "nc_def_var");
        
    
    retval = nc_def_var_fletcher32(ncid, varid, true);
    checkErrorCode(retval, "nc_def_var_fletcher32");

    retval = nc_close(ncid);
    checkErrorCode(retval, "nc_close");
    
    
    return retval;
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions