Iulian Grindeanu committed fae72f0

append error when build with netcdf only

wrong open mode

Comments (0)

Files changed (2)


   // if append mode, make sure we are in define mode; a simple open will not allow creation of new variables
   if (append)
-    NCFUNC(redef)(_fileId);
+  {
+    int errcode = NCFUNC(redef)(_fileId);
+    if (errcode != NC_NOERR)
+      ERRORR(MB_FAILURE, "Can't open file in  redefine mode");
+  }
   // First initialize all coordinates, then fill VarData for actual variables (and dimensions)
   // Check that for used coordinates we have found the tags
   for (std::set<std::string>::iterator setIt = usedCoordinates.begin();


   if (append)
     int omode = NC_WRITE;
     if (isParallel)
       success = NCFUNC(open)(myPcomm->proc_config().proc_comm(), file_name, omode, MPI_INFO_NULL, &fileId);
       success = NCFUNC(open)(MPI_COMM_SELF, file_name, omode, MPI_INFO_NULL, &fileId);
-    // This is a regular netcdf file
-    success = NCFUNC(open)(file_name, overwrite ? NC_CLOBBER : NC_NOCLOBBER, &fileId);
+    // This is a regular netcdf file, open in write mode
+    success = NCFUNC(open)(file_name, omode, &fileId);
     ERRORS(success, "Failed to open file for appending.");