Commits

Ji-hoon Kim  committed 933e551

Now reads in HDF4 data formats when restarting, but outputs in packed-HDF5 formats. You should use "make machine-orange-hdf4" or adequate HDF4 libraries. Some changes in enzo.C and Group_ReadAllData.C so that it gracefully checks which data format the input files are in.

  • Participants
  • Parent commits 0e495b5
  • Branches hdf4

Comments (0)

Files changed (5)

File src/enzo/ExternalBoundary_ReadExternalBoundary.C

  
     file_id = H5Fopen(hdfname, H5F_ACC_RDONLY, H5P_DEFAULT);
     if (io_log) fprintf(log_fptr, "H5Fopen id: %"ISYM"\n", file_id);
-    if( file_id == h5_error ){my_exit(EXIT_FAILURE);}
+    //    if( file_id == h5_error ){my_exit(EXIT_FAILURE);}
+    if( file_id == h5_error ){return FAIL;}
  
     /* loop over faces, reading each */
  

File src/enzo/Group_ReadAllData.C

 	    MetaData.BoundaryConditionName);
     ENZO_FAIL("");
   }
+
+  // Below, ENZO_FAIL is changed to "return FAIL" to deal with various data formats including HDF4, HDF5, packed-HDF5
+  // because boundary should be the one that distinguishes these different data formats.
+  // This will allow a graceful exit when the dataformat is not packed-HDF5.
+  // - Ji-hoon Kim
+
   if(LoadGridDataAtStart){    
     if (Exterior->ReadExternalBoundary(fptr) == FAIL) {
       fprintf(stderr, "Error in ReadExternalBoundary (%s).\n",
 	      MetaData.BoundaryConditionName);
-      ENZO_FAIL("");
+      return FAIL;
+      //ENZO_FAIL("");  
     }
   }else{
     if (Exterior->ReadExternalBoundary(fptr, TRUE, FALSE) == FAIL) {
       fprintf(stderr, "Error in ReadExternalBoundary (%s).\n",
 	      MetaData.BoundaryConditionName);
-      ENZO_FAIL("");
+      return FAIL;
+      //ENZO_FAIL("");
     }
   }
   strcat(MetaData.BoundaryConditionName, hdfsuffix);

File src/enzo/Make.mach.orange-hdf4

 #-----------------------------------------------------------------------
 
 LOCAL_MPI_INSTALL    = /afs/slac/Packages/OpenMPI/
-LOCAL_MPI_INSTALL    = /afs/slac/package/OpenMPI/1.2.5/amd64_linux26
-LOCAL_HDF5_INSTALL   = /u/ki/mturk/Research/local/yt-x86_64/
+LOCAL_MPI_INSTALL    = /afs/slac/package/OpenMPI/1.2.5/amd64_linux26/
+LOCAL_HDF5_INSTALL   = /afs/slac/g/ki/software/hdf5/1.6.6/amd64_linux26/
+LOCAL_HDF4_INSTALL   = /afs/slac/g/ki/software/hdf4/amd64_linux26
 LOCAL_PYTHON_INSTALL = /u/ki/mturk/Research/local/yt-x86_64/
 
 #-----------------------------------------------------------------------
 
 LOCAL_INCLUDES_MPI    = 
 LOCAL_INCLUDES_HDF5   = -I$(LOCAL_HDF5_INSTALL)/include
+LOCAL_INCLUDES_HDF4   = -I$(LOCAL_HDF4_INSTALL)/include
 LOCAL_INCLUDES_IOBUF  = -I$(IOBUF_INC)
 LOCAL_INCLUDES_PYTHON = -I$(LOCAL_PYTHON_INSTALL)/include/python2.6/ \
                         -I$(LOCAL_PYTHON_INSTALL)/lib/python2.6/site-packages/numpy/core/include
 
-MACH_INCLUDES         = $(LOCAL_INCLUDES_HDF5) $(LOCAL_INCLUDES_SPRNG) $(LOCAL_INCLUDES_PYTHON)
+MACH_INCLUDES         = $(LOCAL_INCLUDES_HDF5) $(LOCAL_INCLUDES_HDF4) $(LOCAL_INCLUDES_SPRNG) $(LOCAL_INCLUDES_PYTHON)
 
 MACH_INCLUDES_MPI     = $(LOCAL_INCLUDES_MPI)
 MACH_INCLUDES_HYPRE   = $(LOCAL_INCLUDES_HYPRE)
 
 LOCAL_LIBS_MPI    = 
 LOCAL_LIBS_HDF5   = -L$(LOCAL_HDF5_INSTALL)/lib -lhdf5 -lz 
+LOCAL_LIBS_HDF4   = -L$(LOCAL_HDF4_INSTALL)/lib -lm -lmfhdf -lz -ldf -ljpeg 
 LOCAL_LIBS_PYTHON  = $(LOCAL_PYTHON_INSTALL)/lib/python2.6/config/libpython2.6.a
 
-LOCAL_LIBS_MACH   =  -L$(INT_DIR)/fc/10.1.018/@sys/lib/ \
+LOCAL_LIBS_MACH   =  -L$(INT_DIR)/fc/lib/ \
                      -limf -lifcore -lifport \
-                     -L$(INT_DIR)/cc/10.1.018/@sys/lib/ \
-                     -lstdc++ -lg2c \-lmfhdf -ldf -ljpeg \
-                     -L$(ARCH_PATH)/lib/ -lmfhdf -ldf -ljpeg
+                     -L$(INT_DIR)/cc/lib/ \
+                     -lstdc++ -lg2c 
 
-MACH_LIBS         = $(LOCAL_LIBS_HDF5) $(LOCAL_LIBS_MACH) $(LOCAL_LIBS_PYTHON)
+MACH_LIBS         = $(LOCAL_LIBS_HDF5) $(LOCAL_LIBS_HDF4) $(LOCAL_LIBS_MACH) $(LOCAL_LIBS_PYTHON)
 MACH_LIBS_MPI     = $(LOCAL_LIBS_MPI)

File src/enzo/ReadAllData.C

   }
 
 #ifdef USE_HDF4
-  fprintf(stderr, "I'm here in ReadAllData.C!\n");
   if (Exterior->ReadExternalBoundaryHDF4(fptr) == FAIL) {  
     fprintf(stderr, "Error in ReadExternalBoundary (%s).\n",           
             MetaData.BoundaryConditionName);                  

File src/enzo/enzo.C

     if (debug) printf("Reading parameter file %s\n", ParameterFile);
 
 
-#if USE_HDF5_GROUPS && !(USE_HDF4)
-    if (debug) fprintf(stderr, "Input with Group_ReadAllData\n");
+  // First expect to read in packed-HDF5
+
+    if (Group_ReadAllData(ParameterFile, &TopGrid, MetaData, &Exterior) == FAIL) {
+      if (MyProcessorNumber == ROOT_PROCESSOR) {
+	fprintf(stderr, "Error in Group_ReadAllData %s\n", ParameterFile);
+	fprintf(stderr, "Probably not in a packed-HDF5 format. Trying other read routines.\n");
+      }
+      // If not packed-HDF5, then try usual HDF5 or HDF4
+      if (ReadAllData(ParameterFile, &TopGrid, MetaData, &Exterior) == FAIL) {
+	if (MyProcessorNumber == ROOT_PROCESSOR)
+	  fprintf(stderr, "Error in ReadAllData %s.\n", ParameterFile);
+	my_exit(EXIT_FAILURE);
+      }
+    }
+
+
+    /*
+#if defined(USE_HDF5_GROUPS) && !defined(USE_HDF4)
     if (Group_ReadAllData(ParameterFile, &TopGrid, MetaData, &Exterior) == FAIL) {
       if (MyProcessorNumber == ROOT_PROCESSOR)
-	fprintf(stderr, "Error in ParameterFile %s.\n", ParameterFile);
+	fprintf(stderr, "Error in Group_ReadAllData %s.\n", ParameterFile);
       my_exit(EXIT_FAILURE);
     }
 #else 
-    if (debug) fprintf(stderr, "Input with ReadAllData\n");
     if (ReadAllData(ParameterFile, &TopGrid, MetaData, &Exterior) == FAIL) {
       if (MyProcessorNumber == ROOT_PROCESSOR)
-	fprintf(stderr, "Error in ParameterFile %s.\n", ParameterFile);
+	fprintf(stderr, "Error in ReadAllData %s.\n", ParameterFile);
       my_exit(EXIT_FAILURE);
     }
 #endif
+    */
+
  
     if (!ParallelRootGridIO && restart && TopGrid.NextGridThisLevel == NULL) {
       CommunicationPartitionGrid(&TopGrid, 0);  // partition top grid if necessary