Matthew Turk avatar Matthew Turk committed be845ba

Fixing restarts by aligning ordering of lines in hierarchy in the read/write
routines, as well as updating criteria (possibly unnecessarily) for getting a
particle file name.

Comments (0)

Files changed (2)

src/enzo/New_Grid_ReadGrid.C

             ENZO_FAIL("error reading NumberOfParticles.");
     }
  
-    if (NumberOfParticles > 0) {
+    if (fscanf(fptr, "NumberOfActiveParticles = %"ISYM"\n", &NumberOfActiveParticles) != 1) {
+      ENZO_FAIL("error reading NumberOfActiveParticles.");
+    }
+    
+    if ((NumberOfParticles > 0) || (NumberOfActiveParticles > 0)) {
  
       /* Read particle file name. */
     
 
     /* 5) Read active particle info */
     
-    if (fscanf(fptr, "NumberOfActiveParticles = %"ISYM"\n", &NumberOfActiveParticles) != 1) {
-      ENZO_FAIL("error reading NumberOfActiveParticles.");
-    }
-    
-    if (NumberOfActiveParticles > 0) {
-      
-      /* Read particle file name. */
-      
-      if (fscanf(fptr, "ParticleFileName = %s\n", procfilename) != 1) {
-	ENZO_FAIL("Error reading ParticleFileName.");
-      }
-    }
-    
     // If HierarchyFile has different Ghostzones (which should be a parameter not a macro ...)
     // (useful in a restart with different hydro/mhd solvers) 
     int ghosts =DEFAULT_GHOST_ZONES;

src/enzo/New_Grid_WriteGrid.C

 
     fprintf(fptr, "NumberOfParticles   = %"ISYM"\n", NumberOfParticles);
 
-    fprintf(fptr, "NumberOfActiveParticles =%"ISYM"\n", NumberOfActiveParticles);
+    fprintf(fptr, "NumberOfActiveParticles = %"ISYM"\n", NumberOfActiveParticles);
 
-    if (NumberOfParticles > 0)
+    if ((NumberOfParticles > 0) || (NumberOfActiveParticles > 0))
       fprintf(fptr, "ParticleFileName = %s\n", procfilename); // must be same as above
  
     if (SelfGravity)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.