Commits

Iulian Grindeanu committed fae72f0

append error when build with netcdf only

wrong open mode

Comments (0)

Files changed (2)

src/io/NCWriteHelper.cpp

 
   // 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();

src/io/WriteNC.cpp

 
   if (append)
   {
-#ifdef PNETCDF_FILE
     int omode = NC_WRITE;
+#ifdef PNETCDF_FILE
     if (isParallel)
       success = NCFUNC(open)(myPcomm->proc_config().proc_comm(), file_name, omode, MPI_INFO_NULL, &fileId);
     else
       success = NCFUNC(open)(MPI_COMM_SELF, file_name, omode, MPI_INFO_NULL, &fileId);
 #else
-    // 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);
 #endif
     ERRORS(success, "Failed to open file for appending.");
   }