This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Hi Again, Todd, > I'm trying to compile and install netcdf version 4.1.3 and > cannot. Please see attached files detailing issue. > *** Testing netCDF attributes. > *** testing attribute renaming for memory leak, like nc_test...FAIL: tst_atts > ================================================ > 1 of 10 tests failed That's the first time I've ever seen that test fail. If it's convenient, could you edit the nc_test/tst_atts.c file to help locate where the error is occurring? What would be sufficient is replacing the "main" function starting at line 2472 in that file with the appended version of "main" that has more instrumentation to show what's happening. Then run "make check" in that directory and send us the output. If you don't have time for this, an alternative would be to try the new netCDF-4.2 release to see if you have any better luck with that. However, the test program that's failing is no different in version 4.2, although there have been various bug fixes in the library. For details how to get it, see this announcement: http://www.unidata.ucar.edu/software/netcdf/#netcdf_relnotes Thanks! --Russ int main(int argc, char **argv) { printf("\n*** Testing netCDF attributes.\n"); printf("*** testing attribute renaming for memory leak, like nc_test..."); { #define A1_NAME "a" #define B1_NAME "b" #define VAR_NAME "var" int ncid, nvars, v, natts, varid; char name_in[NC_MAX_NAME + 1]; char char_data = 'a'; /* Create a file with a var with two atts. */ printf("\nabout to call: if (nc_create(FILE_NAME, NC_NETCDF4|NC_CLASSIC_MODEL|NC_CLOBBER, &ncid)) ERR;\n"); if (nc_create(FILE_NAME, NC_NETCDF4|NC_CLASSIC_MODEL|NC_CLOBBER, &ncid)) ERR; printf("about to call: if (nc_def_var(ncid, VAR_NAME, NC_INT, 0, NULL, &varid)) ERR;\n"); if (nc_def_var(ncid, VAR_NAME, NC_INT, 0, NULL, &varid)) ERR; printf("about to call: if (nc_put_att(ncid, varid, A1_NAME, NC_CHAR, 1, &char_data)) ERR;\n"); if (nc_put_att(ncid, varid, A1_NAME, NC_CHAR, 1, &char_data)) ERR; printf("about to call: if (nc_put_att(ncid, varid, B1_NAME, NC_CHAR, 1, &char_data)) ERR;\n"); if (nc_put_att(ncid, varid, B1_NAME, NC_CHAR, 1, &char_data)) ERR; /* Add a global attribute A1_NAME. */ printf("about to call: if (nc_put_att(ncid, NC_GLOBAL, A1_NAME, NC_CHAR, 1, &char_data)) ERR;\n"); if (nc_put_att(ncid, NC_GLOBAL, A1_NAME, NC_CHAR, 1, &char_data)) ERR; /* Change the name of the first att of each variable to * A1_NAME. Then copy the global att called A1_NAME, overwriting * the one we just changed. */ printf("about to call: if (nc_inq_nvars(ncid, &nvars)) ERR;\n"); if (nc_inq_nvars(ncid, &nvars)) ERR; if (nvars != 1) ERR_RET; printf("about to call: if (nc_inq_varnatts(ncid, 0, &natts)) ERR;\n"); if (nc_inq_varnatts(ncid, 0, &natts)) ERR; if (natts != 2) ERR; printf("about to call: if (nc_copy_att(ncid, NC_GLOBAL, A1_NAME, ncid, 0)) ERR;\n"); if (nc_copy_att(ncid, NC_GLOBAL, A1_NAME, ncid, 0)) ERR; printf("about to call: if (nc_close(ncid)) ERR;\n"); if (nc_close(ncid)) ERR; /* Reopen the file and check it. */ printf("about to call: if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR;\n"); if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR; printf("about to call: if (nc_inq_nvars(ncid, &nvars)) ERR;\n"); if (nc_inq_nvars(ncid, &nvars)) ERR; if (nvars != 1) ERR_RET; for (v = 0; v < nvars; v++) { printf("about to call: if (nc_inq_varnatts(ncid, v, &natts)) ERR_RET;\n"); if (nc_inq_varnatts(ncid, v, &natts)) ERR_RET; if (natts) { printf("about to call: if (nc_inq_attname(ncid, v, 0, name_in)) ERR_RET;\n"); if (nc_inq_attname(ncid, v, 0, name_in)) ERR_RET; printf("about to call: if (strcmp(name_in, A1_NAME)) ERR_RET;\n"); if (strcmp(name_in, A1_NAME)) ERR_RET; } } printf("about to call: if (nc_close(ncid)) ERR;\n"); if (nc_close(ncid)) ERR; } SUMMARIZE_ERR; printf("*** testing attribute renaming for memory leak, like nc_test..."); { #define NVARS 136 #define A_NAME "a" int ncid, nvars, v, natts; char name_in[NC_MAX_NAME + 1]; char char_data = 'a'; /* Create the same file as nc_test uses (almost). */ if (create_file()) ERR; /* Open the file. */ if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR; if (nc_redef(ncid)) ERR; /* Add a global attribute A_NAME. */ if (nc_put_att(ncid, NC_GLOBAL, A_NAME, NC_CHAR, 1, &char_data)) ERR; /* Change the name of the first att of each variable to * A_NAME. Then copy the global att called A_NAME, overwriting * the one we just changed. */ if (nc_inq_nvars(ncid, &nvars)) ERR; if (nvars != NVARS) ERR_RET; for (v = 0; v < nvars; v++) { if (nc_inq_varnatts(ncid, v, &natts)) ERR_RET; if (natts) { if (nc_inq_attname(ncid, v, 0, name_in)) ERR_RET; if (nc_rename_att(ncid, v, name_in, A_NAME)) ERR_RET; if (nc_copy_att(ncid, NC_GLOBAL, A_NAME, ncid, v)) ERR_RET; } } if (nc_close(ncid)) ERR; /* Reopen the file and check it. */ if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR; if (nc_inq_nvars(ncid, &nvars)) ERR; if (nvars != NVARS) ERR_RET; for (v = 0; v < nvars; v++) { if (nc_inq_varnatts(ncid, v, &natts)) ERR_RET; if (natts) { if (nc_inq_attname(ncid, v, 0, name_in)) ERR_RET; if (strcmp(name_in, A_NAME)) ERR_RET; } } if (nc_close(ncid)) ERR; } SUMMARIZE_ERR; FINAL_RESULTS; } Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: GNP-293876 Department: Support netCDF Priority: Normal Status: Closed