Commits

Vijay Mahadevan committed f90c3b0

Updating DMMoab interface to the latest PETSc changes related to PetscNew. Removing occurrences of stringstream and replacing with PetscSNPrintf for manipulating IO options.

  • Participants
  • Parent commits 21c662a

Comments (0)

Files changed (4)

File src/dm/impls/moab/dmmbio.cxx

 #define __FUNCT__ "DMMoab_GetWriteOptions_Private"
 static PetscErrorCode DMMoab_GetWriteOptions_Private(PetscInt fsetid, PetscInt numproc, PetscInt dim, MoabWriteMode mode, PetscInt dbglevel, const char* dm_opts, const char* extra_opts, const char** write_opts)
 {
-  std::ostringstream str;
+  PetscErrorCode ierr;
+  char wopts[PETSC_MAX_PATH_LEN];
 
   PetscFunctionBegin;
 
   // do parallel read unless only one processor
   if (numproc > 1) {
-    str << "PARALLEL=" << MoabWriteModes[mode] << ";";
-    if (fsetid>=0) str << "PARALLEL_COMM=" << fsetid << ";";
+    ierr = PetscSNPrintf(wopts, sizeof(wopts), "PARALLEL=%s;",MoabWriteModes[mode]);CHKERRQ(ierr);
+    if (fsetid>=0) {
+      ierr = PetscSNPrintf(wopts, sizeof(wopts), "%sPARALLEL_COMM=%d;",wopts,fsetid);CHKERRQ(ierr);
+    }
   }
 
   if (strlen(dm_opts)) {
-    str << dm_opts << ";";
+    ierr = PetscSNPrintf(wopts, sizeof(wopts), "%s%s;",wopts,dm_opts);CHKERRQ(ierr);
   }
 
-  if (dbglevel)
-    str << "CPUTIME;DEBUG_IO=" << dbglevel << ";";
-
-  if (extra_opts)
-    str << extra_opts ;
+  if (dbglevel) {
+    ierr = PetscSNPrintf(wopts, sizeof(wopts), "%sCPUTIME;DEBUG_IO=%d;",wopts,dbglevel);CHKERRQ(ierr);
+  }
 
-  *write_opts = str.str().c_str();
+  if (extra_opts) {
+    ierr = PetscSNPrintf(wopts, sizeof(wopts), "%s%s;",wopts,extra_opts);CHKERRQ(ierr);
+  }
+  *write_opts=wopts;
   PetscFunctionReturn(0);
 }
 

File src/dm/impls/moab/dmmbutil.cxx

 #define __FUNCT__ "DMMoab_GetReadOptions_Private"
 PetscErrorCode DMMoab_GetReadOptions_Private(PetscBool by_rank, PetscInt numproc, PetscInt dim, MoabReadMode mode, PetscInt dbglevel, const char* dm_opts, const char* extra_opts, const char** read_opts)
 {
-  std::ostringstream str;
+  char           ropts[PETSC_MAX_PATH_LEN];
+  PetscErrorCode ierr;
 
   PetscFunctionBegin;
   /* do parallel read unless using only one processor */
   if (numproc > 1) {
-    str << "PARALLEL=" << MoabReadModes[mode] << ";PARTITION=PARALLEL_PARTITION;PARTITION_DISTRIBUTE;";
-    str << "PARALLEL_RESOLVE_SHARED_ENTS;PARALLEL_GHOSTS=" << dim << ".0.1;";
-    if (by_rank)
-      str << "PARTITION_BY_RANK;";
+    ierr = PetscSNPrintf(ropts, sizeof(ropts), "PARALLEL=%s;PARTITION=PARALLEL_PARTITION;PARTITION_DISTRIBUTE;PARALLEL_RESOLVE_SHARED_ENTS;PARALLEL_GHOSTS=%d.0.1;",MoabReadModes[mode],dim);CHKERRQ(ierr);
+    if (by_rank) {
+      ierr = PetscSNPrintf(ropts, sizeof(ropts), "%sPARTITION_BY_RANK;",ropts);CHKERRQ(ierr);
+    }
   }
 
   if (strlen(dm_opts)) {
-    str << dm_opts << ";";
+    ierr = PetscSNPrintf(ropts, sizeof(ropts), "%s%s;",dm_opts);CHKERRQ(ierr);
   }
 
   if (dbglevel) {
-    str << "CPUTIME;DEBUG_IO=" << dbglevel << ";";
-    if (numproc>1)
-      str << "DEBUG_PIO=" << dbglevel << ";";
+    ierr = PetscSNPrintf(ropts, sizeof(ropts), "%sCPUTIME;DEBUG_IO=%d;",ropts,dbglevel);CHKERRQ(ierr);
+    if (numproc>1) {
+      ierr = PetscSNPrintf(ropts, sizeof(ropts), "%sDEBUG_PIO=%d;",ropts,dbglevel);CHKERRQ(ierr);
+    }
   }
 
-  if (extra_opts)
-    str << extra_opts;
+  if (extra_opts) {
+    ierr = PetscSNPrintf(ropts, sizeof(ropts), "%s%s;",ropts,extra_opts);CHKERRQ(ierr);
+  }
 
-  *read_opts = str.str().c_str();
+  *read_opts = ropts;
   PetscFunctionReturn(0);
 }
 

File src/dm/impls/moab/dmmbvec.cxx

   ierr = MPI_Allreduce(&lnative_vec, &gnative_vec, 1, MPI_INT, MPI_MAX, pcomm->comm());CHKERRQ(ierr);
 
   /* Create the MOAB internal data object */
-  ierr = PetscNew(Vec_MOAB,&vmoab);CHKERRQ(ierr);
+  ierr = PetscNew(&vmoab);CHKERRQ(ierr);
   vmoab->is_native_vec=(gnative_vec>0?PETSC_TRUE:PETSC_FALSE);
 
   if (!vmoab->is_native_vec) {

File src/dm/impls/moab/dmmoab.cxx

 
   PetscFunctionBegin;
   PetscValidHeaderSpecific(dm,DM_CLASSID,1);
-  ierr = PetscNewLog(dm,DM_Moab,&dm->data);CHKERRQ(ierr);
+  ierr = PetscNewLog(dm,(DM_Moab**)&dm->data);CHKERRQ(ierr);
 
   ((DM_Moab*)dm->data)->bs = 1;
   ((DM_Moab*)dm->data)->numFields = 1;