Commits

Matthew Turk committed 084b252 Merge

Merge

Comments (0)

Files changed (1)

src/enzo/grid/utilities/Grid_WriteGrid.C

   //if(WriteEverything==TRUE)CopyOnlyActive = FALSE;
  
   char *ParticlePositionLabel[] =
+     {"position_x", "position_y", "position_z"};
+  char *ParticleVelocityLabel[] =
+     {"velocity_x", "velocity_y", "velocity_z"};
+  char *OldParticlePositionLabel[] =
      {"particle_position_x", "particle_position_y", "particle_position_z"};
-  char *ParticleVelocityLabel[] =
+  char *OldParticleVelocityLabel[] =
      {"particle_velocity_x", "particle_velocity_y", "particle_velocity_z"};
-#ifdef WINDS
-  char *ParticleAttributeLabel[] =
-    {"creation_time", "dynamical_time", "metallicity_fraction", "particle_jet_x", 
-     "particle_jet_y", "particle_jet_z", "typeia_fraction"};
-#else
-  char *ParticleAttributeLabel[] = 
-    {"creation_time", "dynamical_time", "metallicity_fraction", "typeia_fraction"};
-#endif
   char *SmoothedDMLabel[] = {"Dark_Matter_Density", "Velocity_Dispersion",
 			     "Particle_x-velocity", "Particle_y-velocity",
 			     "Particle_z-velocity"};
  
   /* ------------------------------------------------------------------- */
   /* 3) Save particle quantities. */
+
+  hid_t ParticleGroupID = h5_error;
  
   if (NumberOfParticles > 0) {
 
+    if (ParticleGroupID == h5_error) {
+        ParticleGroupID = H5Gcreate(group_id, "Particles", 0);
+    }
+
+    hid_t dm_group_id = H5Gcreate(ParticleGroupID, "DarkMatter", 0);
     /* Sort particles according to their identifier. */
 
     this->SortParticlesByNumber();
 
     for (dim = 0; dim < GridRank; dim++) {
       this->write_dataset(1, TempIntArray, ParticlePositionLabel[dim],
-          group_id, HDF5_FILE_PREC, (VOIDP) ParticlePosition[dim], FALSE);
+          dm_group_id, HDF5_FILE_PREC, (VOIDP) ParticlePosition[dim], FALSE);
+      H5Lcreate_hard(dm_group_id, ParticlePositionLabel[dim], 
+                     group_id, OldParticlePositionLabel[dim],
+                     H5P_DEFAULT, H5P_DEFAULT);
     }
 
     /* Copy particle velocities to temp and write them. */
 
     for (dim = 0; dim < GridRank; dim++) {
       this->write_dataset(1, TempIntArray, ParticleVelocityLabel[dim],
-          group_id, HDF5_REAL, (VOIDP) ParticleVelocity[dim], FALSE);
+          dm_group_id, HDF5_REAL, (VOIDP) ParticleVelocity[dim], FALSE);
+      H5Lcreate_hard(dm_group_id, ParticleVelocityLabel[dim], 
+                     group_id, OldParticleVelocityLabel[dim],
+                     H5P_DEFAULT, H5P_DEFAULT);
     }
 
     /* Copy mass to temp and write it. */
 
-    this->write_dataset(1, TempIntArray, "particle_mass",
-        group_id, HDF5_REAL, (VOIDP) ParticleMass, FALSE);
+    this->write_dataset(1, TempIntArray, "mass",
+        dm_group_id, HDF5_REAL, (VOIDP) ParticleMass, FALSE);
+    H5Lcreate_hard(dm_group_id, "mass",
+                   group_id, "particle_mass",
+                   H5P_DEFAULT, H5P_DEFAULT);
 
-    this->write_dataset(1, TempIntArray, "particle_index",
-        group_id, HDF5_PINT, (VOIDP) ParticleNumber, FALSE);
+    this->write_dataset(1, TempIntArray, "index",
+        dm_group_id, HDF5_PINT, (VOIDP) ParticleNumber, FALSE);
+    H5Lcreate_hard(dm_group_id, "index",
+                   group_id, "particle_index",
+                   H5P_DEFAULT, H5P_DEFAULT);
 
     /* Copy type to temp and write it. */
 
       file_dsp_id = H5Screate_simple((Eint32) 1, TempIntArray, NULL);
       if( file_dsp_id == h5_error ){ENZO_FAIL("Can't create particle_type dataspace");}
 
-      dset_id =  H5Dcreate(group_id, "particle_type", HDF5_FILE_INT, file_dsp_id, H5P_DEFAULT);
+      dset_id =  H5Dcreate(dm_group_id, "particle_type", HDF5_FILE_INT, file_dsp_id, H5P_DEFAULT);
       if( dset_id == h5_error ){ENZO_FAIL("Can't create particle_type dataset");}
 
       h5_status = H5Dwrite(dset_id, HDF5_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,
 
     /* Copy particle attributes to temp and write them. */
 
-    for (j = 0; j < NumberOfParticleAttributes; j++) {
+    /* clean up */
 
-      this->write_dataset(1, TempIntArray, ParticleAttributeLabel[j],
-          group_id, HDF5_REAL, (VOIDP) ParticleAttribute[j], FALSE);
-    }
-
-    /* clean up */
+    H5Gclose(dm_group_id);
 
     delete [] temp;
 
   if (NumberOfActiveParticles > 0) {
     /* Iterate over the enabled active particle types */
 
-    hid_t ActiveParticleGroupID = H5Gcreate(group_id, "ActiveParticles", 0);
+    if (ParticleGroupID == h5_error) {
+        ParticleGroupID = H5Gcreate(group_id, "Particles", 0);
+    }
 
     for (i = 0; i < EnabledActiveParticlesCount; i++)
       {
         ActiveParticleTypeToEvaluate->WriteParticles(
             this->ActiveParticles, i, NumberOfActiveParticles,
             ActiveParticleTypeToEvaluate->particle_name,
-            ActiveParticleGroupID);
+            ParticleGroupID);
 						     
       }
 
-    H5Gclose(ActiveParticleGroupID);
 
   }  // end: if (NumberOfActiveParticles > 0)
+
+  if (ParticleGroupID != h5_error) {
+    H5Gclose(ParticleGroupID);
+  }
   
   /* Close HDF group and file. */