Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Rocin.C File Reference

Implementation of Rocing for creation of Roccom window(s) from HDF files. More...

#include <algorithm>
#include <set>
#include <cmath>
#include <cstdlib>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <string>
#include <cstring>
#include <strings.h>
#include <errno.h>
#include <vector>
#include <list>
#include <glob.h>
#include <fnmatch.h>
#include <unistd.h>
#include <sys/types.h>
#include <dirent.h>
#include "Directory.H"
#include "Rocin.h"
Include dependency graph for Rocin.C:

Go to the source code of this file.

Classes

class  AutoCloser< T1, T2 >
 Automatically close open files, datasets, etc. More...
 

Macros

#define DEBUG_MSG(x)
 
#define HDF4_CHECK_RET(routine, args, retval)
 Perform HDF4 error-checking. More...
 
#define HDF4_CHECK(routine, args)   HDF4_CHECK_RET(routine, args, )
 

Functions

static int glob_error (const char *epath, int gerrno)
 Error callback for glob. More...
 
template<class T >
cast_err_func (int(*glob)(const char *, int, T, glob_t *), int(*errfunc)(const char *, int))
 Cast glob_error for portability (IBMSP has a different prototype) More...
 
static int32 FindFirstGeometryDataset (int32 sd_id, const std::string &geomFile, const std::string &matName, const std::string &label, int32 hIndex, int32 *index)
 Find the first geometry dataset for the given block. More...
 
static void scan_files_HDF4 (int pathc, char *pathv[], BlockMM_HDF4 &blocks, std::string &time, std::map< int32, COM_Type > &HDF2COM)
 Extract metadata from the list of files. More...
 
static void load_data_HDF4 (BlockMM_HDF4::iterator p, const BlockMM_HDF4::iterator &end, const std::string &window, const MPI_Comm *comm, int rank, int nprocs)
 
static void new_attributes (BlockMM_HDF4::iterator hdf4, const BlockMM_HDF4::iterator &hdf4End, const std::string &window, const MPI_Comm *comm, int rank, int nprocs)
 
static void broadcast_win_attributes (bool isEmpty, const std::string &window, const MPI_Comm *comm, int rank, int nprocs)
 
template<class BLOCK >
void free_blocks (BLOCK &blocks)
 
std::string CWD ()
 
void Rocin_load_module (const char *name)
 Load the module Rocin into Roccom using the given module name. More...
 
void Rocin_unload_module (const char *name)
 Unload the module Rocin from Roccom. More...
 
void COM_F_FUNC2 (rocin_load_module, ROCIN_LOAD_MODULE) const
 
void COM_F_FUNC2 (rocin_unload_module, ROCIN_UNLOAD_MODULE) const
 

Detailed Description

Implementation of Rocing for creation of Roccom window(s) from HDF files.

Definition in file Rocin.C.

Macro Definition Documentation

#define DEBUG_MSG (   x)
#define HDF4_CHECK (   routine,
  args 
)    HDF4_CHECK_RET(routine, args, )

Definition at line 170 of file Rocin.C.

Referenced by FindFirstGeometryDataset(), load_data_HDF4(), and scan_files_HDF4().

#define HDF4_CHECK_RET (   routine,
  args,
  retval 
)
Value:
{ \
if((routine args) == FAIL) { \
sleep(1); \
if((routine args) == FAIL) { \
sleep(1); \
if((routine args) == FAIL) { \
sleep(1); \
if((routine args) == FAIL) { \
std::cerr << "Rocstar: Error: " #routine " (line " \
<< __LINE__ << " in " << __FILE__ << ") failed: " \
<< HDF4::error_msg() << std::endl; \
retval; \
} } } } \
}
if(dy > dx)
static std::string error_msg()
return error message
Definition: HDF4.C:961
void sleep(const unsigned int milliseconds)
Sleep for a certain numbers of milliseconds.
Definition: CImg.h:4624

Perform HDF4 error-checking.

Check the return value of the HDF4 function and print an error message if it is FAIL

Parameters
routineThe HDF4 function to call. (Input)
argsThe argument list, in parentheses. (Input)
valThe return value. (Input)

Definition at line 144 of file Rocin.C.

Referenced by FindFirstGeometryDataset(), load_data_HDF4(), and scan_files_HDF4().

Function Documentation

static void broadcast_win_attributes ( bool  isEmpty,
const std::string &  window,
const MPI_Comm *  comm,
int  rank,
int  nprocs 
)
static

Definition at line 2153 of file Rocin.C.

References COM_free_buffer(), COM_get_array(), COM_get_attribute(), COM_get_attributes(), COM_get_sizeof(), empty(), and i.

Referenced by Rocin::read_windows().

2156 {
2157  // Build an MPI message to synchronize variable names.
2158  int empty = isEmpty ? 1 : 0;
2159  std::vector<int> is_empty(nprocs);
2160  if ( *comm != MPI_COMM_NULL)
2161  MPI_Allgather(&empty, 1, MPI_INT, &is_empty[0], 1, MPI_INT, *comm);
2162  else
2163  is_empty[0] = empty;
2164 
2165  // Broadcast from the nonempty processor with highest rank.
2166  int last_empty=-1, root=-1;
2167  for (int i=0; i<nprocs; ++i) {
2168  if ( is_empty[i]) last_empty = i;
2169  else root = i;
2170  }
2171 
2172  if ( last_empty<0) return; // No need to broadcast.
2173 
2174  // Obtain the list of attributes
2175  int na; char *atts;
2176  COM_get_attributes( window.c_str(), &na, &atts);
2177 
2178  // Loop through the attributes
2179  std::istringstream is(atts);
2180  for ( int i=0; i<na; ++i) {
2181  // Obtain the attribute name
2182  std::string aname; is >> aname;
2183  char loc;
2184  int type, ncomp;
2185 
2186  COM_get_attribute( (window+"."+aname).c_str(), &loc, &type, &ncomp, NULL);
2187  if ( loc !='w') continue; // Skip non-window attributes;
2188 
2189  void *addr;
2190  int count, strd;
2191  COM_get_array( (window+"."+aname).c_str(), 0, &addr, &strd, &count);
2192 
2193  int len = COM_get_sizeof( type, count*ncomp);
2194  if ( *comm != MPI_COMM_NULL)
2195  MPI_Bcast( addr, len, MPI_CHAR, root, *comm);
2196  }
2197  COM_free_buffer( &atts);
2198 }
void COM_get_attribute(const std::string wa_str, char *loc, int *type, int *ncomp, std::string *unit)
Definition: roccom_c++.h:269
void COM_get_array(const char *wa_str, int pane_id, void **addr, int *strd, int *cap)
Get the address for an attribute on a specific pane.
boolean empty(T_VertexSet s)
void COM_get_attributes(const char *wname, int *na, std::string &names)
Definition: roccom_c++.h:360
blockLoc i
Definition: read.cpp:79
int COM_get_sizeof(const COM_Type type, int c)
Definition: roccom_c++.h:560
void COM_free_buffer(int **buf)
Definition: roccom_c++.h:397

Here is the call graph for this function:

Here is the caller graph for this function:

T cast_err_func ( int(*)(const char *, int, T, glob_t *)  glob,
int(*)(const char *, int)  errfunc 
)
inline

Cast glob_error for portability (IBMSP has a different prototype)

Definition at line 130 of file Rocin.C.

Referenced by Rocin::read_windows().

132 { return reinterpret_cast<T>(errfunc); }

Here is the caller graph for this function:

void COM_F_FUNC2 ( rocin_load_module  ,
ROCIN_LOAD_MODULE   
) const

Definition at line 3072 of file Rocin.C.

References Mesquite::length(), and Rocin_load_module().

3073 { Rocin_load_module( std::string(name, length).c_str()); }
void Rocin_load_module(const char *name)
Load the module Rocin into Roccom using the given module name.
Definition: Rocin.C:3063
double length(Vector3D *const v, int n)

Here is the call graph for this function:

void COM_F_FUNC2 ( rocin_unload_module  ,
ROCIN_UNLOAD_MODULE   
) const

Definition at line 3074 of file Rocin.C.

References Mesquite::length(), and Rocin_unload_module().

3075 { Rocin_unload_module( std::string(name, length).c_str()); }
double length(Vector3D *const v, int n)
void Rocin_unload_module(const char *name)
Unload the module Rocin from Roccom.
Definition: Rocin.C:3066

Here is the call graph for this function:

std::string CWD ( )

Definition at line 2762 of file Rocin.C.

Referenced by Rocin::read_windows().

2763 {
2764  char buf[1024];
2765  return(std::string(getcwd(buf,1024)));
2766 }

Here is the caller graph for this function:

static int32 FindFirstGeometryDataset ( int32  sd_id,
const std::string &  geomFile,
const std::string &  matName,
const std::string &  label,
int32  hIndex,
int32 *  index 
)
static

Find the first geometry dataset for the given block.

The dataset may be right after the block header or in an external file. The caller is responsible for closing the sd_id.

Definition at line 285 of file Rocin.C.

References HDF4_CHECK, HDF4_CHECK_RET, MAX_NC_NAME, MAX_NC_VARS, rank, HDF4::SDend(), HDF4::SDendaccess(), HDF4::SDfileinfo(), HDF4::SDgetdatastrs(), HDF4::SDstart(), HDF4::Select(), and cimg_library::cimg::strcasecmp().

Referenced by scan_files_HDF4().

289 {
290  int32 geom_id;
291  if (geomFile.empty()) {
292  // We're not using a separate geometry file, so just return the dataset
293  // immediately after the block header.
294  geom_id = sd_id;
295  *index = hIndex + 1;
296  return geom_id;
297  }
298 
299  // Open the geometry file.
300  HDF4_CHECK_RET(geom_id = HDF4::SDstart, (geomFile.c_str(), DFACC_READ),
301  return FAIL);
302 
303  // Get the number of datasets.
304  int32 dsCount = MAX_NC_VARS, nAttrs, status;
305  HDF4_CHECK(HDF4::SDfileinfo, (geom_id, &dsCount, &nAttrs));
306 
307  int32 sds_id, rank, size[5], dType;
308  char name[MAX_NC_NAME];
309  // We're looking for the dataset for this material and section.
310  std::string target = matName + '|' + label;
311 
312  // Scan through the datasets of the geometry file.
313  for (*index=0; *index<dsCount; ++(*index)) {
314  HDF4_CHECK_RET(sds_id = HDF4::Select,
315  (geom_id, *index, name, &rank, size, &dType, &nAttrs, dsCount),
316  HDF4::SDend(geom_id); return FAIL);
317 
319  (sds_id, NULL, NULL, NULL, name, MAX_NC_NAME),
320  HDF4::SDendaccess(sds_id); continue);
321  HDF4::SDendaccess(sds_id);
322 
323  // Check if this is the right dataset.
324  if (strcasecmp(target.c_str(), name) == 0) { // We've found it!
325  return geom_id;
326  }
327  }
328 
329  // No luck.
330  HDF4::SDend(geom_id);
331  return FAIL;
332 }
#define MAX_NC_VARS
static intn SDend(int32 sd_id)
Definition: HDF4.C:200
static intn SDendaccess(int32 sds_id)
Definition: HDF4.C:288
#define MAX_NC_NAME
#define HDF4_CHECK(routine, args)
Definition: Rocin.C:170
int strcasecmp(const char *const s1, const char *const s2)
Compare two C-strings, ignoring the case.
Definition: CImg.h:4928
static int32 Select(int32 sd_id, int32 &index, char *name, int32 *rank, int32 *size, int32 *dType, int32 *nAttrs, int32 dsCount=-1)
&quot;Open&quot; and &quot;close&quot; HDF files efficiently.
Definition: HDF4.C:675
#define HDF4_CHECK_RET(routine, args, retval)
Perform HDF4 error-checking.
Definition: Rocin.C:144
static intn SDfileinfo(int32 id, int32 *dsCount, int32 *nAttrs)
Definition: HDF4.C:219
static int32 SDstart(const char *filename, int32 accessMode)
Definition: HDF4.C:177
static intn SDgetdatastrs(int32 sds_id, char *label, char *units, char *format, char *coordsys, intn length)
Definition: HDF4.C:376
static int rank
Definition: advectest.C:66

Here is the call graph for this function:

Here is the caller graph for this function:

void free_blocks ( BLOCK &  blocks)

Definition at line 2342 of file Rocin.C.

Referenced by Rocin::read_windows().

2343 {
2344  typename BLOCK::iterator p;
2345  for (p=blocks.begin(); p!=blocks.end(); ++p)
2346  delete (*p).second;
2347 
2348  blocks.clear();
2349 }
bool blocks
Input data is block-structured grid.
Definition: hdf2pltV2.C:51

Here is the caller graph for this function:

static int glob_error ( const char *  epath,
int  gerrno 
)
static

Error callback for glob.

Definition at line 119 of file Rocin.C.

References COMMPI_Initialized().

Referenced by Rocin::read_windows().

120 {
121  if ( !COMMPI_Initialized())
122  std::cerr << "Rocstar: Error (glob): error in pattern `" << epath << "': "
123  << strerror(gerrno) << std::endl;
124  return 0;
125 }
int COMMPI_Initialized()
Definition: commpi.h:168

Here is the call graph for this function:

Here is the caller graph for this function:

static void load_data_HDF4 ( BlockMM_HDF4::iterator  p,
const BlockMM_HDF4::iterator &  end,
const std::string &  window,
const MPI_Comm *  comm,
int  rank,
int  nprocs 
)
static

Definition at line 882 of file Rocin.C.

References COM_DOUBLE, COM_get_array(), COM_get_status(), COM_INT, COM_resize_array(), DEBUG_MSG, HDF4_CHECK, HDF4_CHECK_RET, i, Block_HDF4::m_file, Block_HDF4::m_geomFile, Block_HDF4::m_gridInfo, Block_HDF4::m_indices, Block_HDF4::m_numNodes, Block_HDF4::m_paneId, Block_HDF4::m_variables, max(), q, s, HDF4::SDend(), HDF4::SDendaccess(), HDF4::SDreaddata(), HDF4::SDselect(), HDF4::SDstart(), sin, and Block_HDF4::time_level.

Referenced by Rocin::read_windows().

886 {
887  int local, i, ne = 0;
888  Block_HDF4* block;
889  std::string name;
890  bool structured = 0;
891  int32 sd_id = 0, sds_id, start[3], size[3];
892  void* data;
893  std::vector<int32>::iterator r;
894  std::vector<GridInfo_HDF4>::iterator s;
895  int with_pane=0;
896 
897  for ( ; p!=end; ++p, ++with_pane) {
898  block = (*p).second;
899 
900  // Panes are a local construct, so make sure that this pane is local.
901  local = COM_get_status( window.c_str(), block->m_paneId)>=0;
902 
903  if (!local) continue;
904 
905  if (block->m_geomFile.empty()) {
907  (block->m_file.c_str(), DFACC_READ),
908  continue);
909  } else {
911  (block->m_geomFile.c_str(), DFACC_READ),
912  continue);
913  }
914 
915  structured = (block->m_gridInfo.size() &&
916  block->m_gridInfo.front().m_name.substr(0,3)== ":st");
917 
918  // Let Roccom manage memory for nodal coordinates
919  // Moved allocation outside of dimension loop. Not sure if this fully
920  // accounts for single registration of "nc" versus "1-nc", "2-nc", etc.
921 
922  name = window + ".nc";
923  DEBUG_MSG("Calling COM_resize_array( name == '" << name << "', paneid == " << block->m_paneId << ", ptr == NULL, arg == 0 )");
924  COM_resize_array(name.c_str(), block->m_paneId, NULL, 1);
925 
926  // Read the nodal coordinates.
927  for (i=0; i<3; ++i) {
928  // Read the mesh only if number of nodes is positive
929  name = window + '.' + (char)('1' + i) + "-nc";
930  COM_get_array(name.c_str(), block->m_paneId, &data);
931 
932  if (block->m_numNodes && data) {
933  HDF4_CHECK_RET(sds_id = HDF4::SDselect, (sd_id, block->m_indices[i]),
934  continue);
936 
937  if (structured) {
938  start[0] = start[1] = start[2] = 0;
940  (sds_id, start, NULL, block->m_gridInfo.front().m_size, data));
941  } else {
942  start[0] = 0;
943  size[0] = block->m_numNodes;
944  HDF4_CHECK(HDF4::SDreaddata, (sds_id, start, NULL, size, data));;
945  }
946 #ifdef DEBUG_DUMP_PREFIX
947  {
948  std::ofstream fout((DEBUG_DUMP_PREFIX + name + '.' + block->time_level + ".hdf").c_str());
949  DebugDump(fout, block->m_numNodes, COM_DOUBLE, data);
950  }
951 #endif // DEBUG_DUMP_PREFIX
952  }
953  }
954 
955  // Read the connectivity tables.
956  if (!structured) {
957  ne = 0;
958  for (s=block->m_gridInfo.begin(); s!=block->m_gridInfo.end(); ++s) {
959  name = window + "." + (*s).m_name;
960  DEBUG_MSG("Calling COM_resize_array( name == '" << name << "', paneid == " << block->m_paneId << ", ptr == " << &data << ", arg == 1 )");
961  COM_resize_array(name.c_str(), block->m_paneId, &data, 1);
962 
963  start[0] = start[1] = 0;
964  std::istringstream sin((*s).m_name);
965  sin.get(); sin.get(); // Get rid if the leading two letter.
966  sin >> size[0];
967  size[1] = (*s).m_numElements;
968  ne += (*s).m_numElements;
969 
970  if ( size[1] && data) {
971  HDF4_CHECK_RET(sds_id = HDF4::SDselect, (sd_id, (*s).m_index),
972  continue);
973  HDF4_CHECK(HDF4::SDreaddata, (sds_id, start, NULL, size, data));
974 #ifdef DEBUG_DUMP_PREFIX
975  {
976  std::ofstream fout((DEBUG_DUMP_PREFIX + name + '.' + block->time_level + ".hdf").c_str());
977  DebugDump(fout, size[0] * size[1], COM_INT, data);
978  }
979 #endif // DEBUG_DUMP_PREFIX
980  HDF4::SDendaccess(sds_id);
981  }
982  }
983  }
984 
985  if (!block->m_geomFile.empty()) {
986  HDF4::SDend(sd_id);
987  HDF4_CHECK_RET(sd_id = HDF4::SDstart, (block->m_file.c_str(), DFACC_READ),
988  continue);
989  }
990 
991  // Read the attribute data.
992  std::vector<VarInfo_HDF4>::iterator q;
993  for (q=block->m_variables.begin(); q!=block->m_variables.end(); ++q) {
994  // Skip NULL attributes.
995  if ( (*q).m_is_null[0]) continue;
996  // Read in window attribute only for the first pane.
997  if ( with_pane && (*q).m_position=='w') continue;
998 
999  int loop = 1;
1000 
1001  //edited
1002  name = window + '.' + (*q).m_name;
1003  if ( (*q).m_position!='w') { // Allocate for nonwindow attribute
1004  DEBUG_MSG("Calling COM_resize_array( name == '" << name << "', paneid == " << block->m_paneId << ", ptr == " << &data << ", arg == 1 )");
1005  COM_resize_array(name.c_str(), block->m_paneId, &data,1);
1006  } else {
1007  COM_get_array(name.c_str(), 0, &data);
1008  }
1009 
1010  for (r=(*q).m_indices.begin();
1011  r!=(*q).m_indices.end(); ++r, ++loop) {
1012 
1013  // If scalar, name = window.attribute
1014  // If vector, name = window.#-attribute
1015  if( (*q).m_indices.size()==1)
1016  name = window + '.' + (*q).m_name;
1017  else {
1018  std::ostringstream sout;
1019  sout << window << '.' << loop << '-' << (*q).m_name;
1020  name = sout.str();
1021  }
1022 
1023  COM_get_array(name.c_str(), block->m_paneId,&data);
1024 
1025  bool nonempty;
1026  if (structured && ((*q).m_position=='n' || (*q).m_position=='e')) {
1027  start[0] = start[1] = start[2] = 0;
1028  if ((*q).m_position == 'n') {
1029  size[0] = block->m_gridInfo.front().m_size[0];
1030  size[1] = block->m_gridInfo.front().m_size[1];
1031  size[2] = block->m_gridInfo.front().m_size[2];
1032  } else {
1033  size[0] = std::max(int32(1),
1034  block->m_gridInfo.front().m_size[0]-1);
1035  size[1] = std::max(int32(1),
1036  block->m_gridInfo.front().m_size[1]-1);
1037  size[2] = std::max(int32(1),
1038  block->m_gridInfo.front().m_size[2]-1);
1039  }
1040 
1041  nonempty = block->m_numNodes && data;
1042 
1043  } else {
1044  start[0] = 0;
1045  size[0] = (*q).m_nitems;
1046 
1047  nonempty = size[0] && data;
1048  }
1049 
1050  if ( nonempty) {
1051  HDF4_CHECK_RET(sds_id = HDF4::SDselect, (sd_id, *r), continue);
1052  HDF4_CHECK(HDF4::SDreaddata, (sds_id, start, NULL, size, data));
1053 #ifdef DEBUG_DUMP_PREFIX
1054  {
1055  std::ofstream fout((DEBUG_DUMP_PREFIX + name + '.' + block->time_level + ".hdf").c_str());
1056  DebugDump(fout, (*q).m_nitems, (*q).m_dataType, data);
1057  }
1058 #endif // DEBUG_DUMP_PREFIX
1059  HDF4::SDendaccess(sds_id);
1060  }
1061  }
1062  }
1063  HDF4::SDend(sd_id);
1064  }
1065 }
static int32 SDselect(int32 sd_id, int32 index)
Definition: HDF4.C:268
int m_numNodes
Number of nodes in the mesh.
Definition: rocin_block.h:97
static intn SDend(int32 sd_id)
Definition: HDF4.C:200
double s
Definition: blastest.C:80
static intn SDendaccess(int32 sds_id)
Definition: HDF4.C:288
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
void COM_get_array(const char *wa_str, int pane_id, void **addr, int *strd, int *cap)
Get the address for an attribute on a specific pane.
int32 m_indices[3]
HDF4 dataset indices of the nodal coordinates.
Definition: rocin_block.h:93
Struct containing necessary information for a pane.
Definition: rocin_block.h:81
Automatically close open files, datasets, etc.
Definition: Rocin.C:179
std::string m_geomFile
External geometry file (may be empty).
Definition: rocin_block.h:92
#define HDF4_CHECK(routine, args)
Definition: Rocin.C:170
Definition: adj.h:203
std::vector< GridInfo_HDF4 > m_gridInfo
Dimensions or conn table(s)
Definition: rocin_block.h:99
int m_paneId
The pane id.
Definition: rocin_block.h:94
std::string m_file
Data file.
Definition: rocin_block.h:91
NT & sin
#define DEBUG_MSG(x)
Definition: Rocin.C:77
#define HDF4_CHECK_RET(routine, args, retval)
Perform HDF4 error-checking.
Definition: Rocin.C:144
static intn SDreaddata(int32 sds_id, int32 *start, int32 *stride, int32 *end, VOIDP data)
Definition: HDF4.C:467
blockLoc i
Definition: read.cpp:79
NT q
static int32 SDstart(const char *filename, int32 accessMode)
Definition: HDF4.C:177
std::vector< VarInfo_HDF4 > m_variables
Info on each variable.
Definition: rocin_block.h:100
void COM_resize_array(const char *wa_str, int pane_id=0, void **addr=NULL, int strd=-1, int cap=0)
Resize an attribute on a specific pane and return the address by setting addr.
Definition: roccom_c++.h:200
int COM_get_status(const char *waname, const int pane_id)
Definition: roccom_c++.h:431
std::string time_level
The dataset&#39;s time stamp.
Definition: rocin_block.h:95

Here is the call graph for this function:

Here is the caller graph for this function:

static void new_attributes ( BlockMM_HDF4::iterator  hdf4,
const BlockMM_HDF4::iterator &  hdf4End,
const std::string &  window,
const MPI_Comm *  comm,
int  rank,
int  nprocs 
)
static

Definition at line 2032 of file Rocin.C.

References COM_new_attribute(), COM_resize_array(), COM_set_size(), DEBUG_MSG, i, q, and sin.

Referenced by Rocin::read_windows().

2040 {
2041 
2042  // Build an MPI message to synchronize variable names.
2043  std::ostringstream sout;
2044  std::set<std::string> added;
2045 
2046  while (hdf4 != hdf4End) {
2047  std::vector<VarInfo_HDF4> &vars = hdf4->second->m_variables;
2048  std::vector<VarInfo_HDF4>::const_iterator q;
2049 
2050  for (q=vars.begin(); q!=vars.end(); ++q){
2051  if (added.count((*q).m_name) == 0) {
2052  sout << (*q).m_name << '!' << (*q).m_position << '!'
2053  << (*q).m_dataType << '!' << (*q).m_indices.size()
2054  << '!' << (*q).m_units << '!';
2055  if ( (*q).m_position=='w')
2056  sout << (*q).m_nitems << '!' << (*q).m_ng;
2057  sout << '|';
2058  added.insert((*q).m_name);
2059  }
2060  }
2061  ++hdf4;
2062  }
2063 
2064 #ifdef USE_CGNS
2065  while (cgns != cgnsEnd) {
2066  std::vector<VarInfo_CGNS> &vars = cgns->second->m_variables;
2067  std::vector<VarInfo_CGNS>::const_iterator q;
2068 
2069  for (q=vars.begin(); q!=vars.end(); ++q){
2070  if (added.count((*q).m_name) == 0) {
2071  sout << (*q).m_name << '!' << (*q).m_position << '!'
2072  << (*q).m_dataType << '!' << (*q).m_indices.size()
2073  << '!' << (*q).m_units << '!';
2074  if ( (*q).m_position=='w')
2075  sout << (*q).m_nitems << '!' << (*q).m_ng;
2076  sout << '|';
2077  added.insert((*q).m_name);
2078  }
2079  }
2080  ++cgns;
2081  }
2082 #endif // USE_CGNS
2083 
2084  // Get the lengths of all of the messages.
2085  std::string msg = sout.str();
2086  int len = msg.length();
2087  std::vector<int> lengths(nprocs);
2088  if ( *comm != MPI_COMM_NULL)
2089  MPI_Allgather(&len, 1, MPI_INT, &lengths[0], 1, MPI_INT, *comm);
2090  else
2091  lengths[0] = len;
2092 
2093  // Compute the total length and displacements for each process's message.
2094  int globlen = lengths[0];
2095  std::vector<int> disp(nprocs, 0);
2096  for (int i=1; i<nprocs; ++i) {
2097  globlen += lengths[i];
2098  disp[i] = disp[i-1] + lengths[i-1];
2099  }
2100 
2101  // Give each process a huge glob with every attribute of every process.
2102  std::vector<char> buffer(len+1,'\0');
2103  std::vector<char> glob(globlen+1,'\0');
2104  std::strcpy( &buffer[0], msg.c_str());
2105  if ( *comm != MPI_COMM_NULL)
2106  MPI_Allgatherv(&buffer[0], len, MPI_CHAR, &glob[0], &lengths[0], &disp[0],
2107  MPI_CHAR, *comm);
2108  else
2109  glob = buffer;
2110 
2111 //std::cout << "glob == \"" << &glob[0] << '"' << std::endl;
2112  std::string name;
2113  char buf[256];
2114  char position;
2115  COM_Type dType;
2116  int numComponents;
2117  char* token = &glob[0];
2118  added.clear();
2119  // printf("parsing string: '%s'\n",token);
2120  while (1) {
2121  char *nextToken = strchr(token,'|');
2122  if (nextToken==0) break;
2123  *nextToken++=0; /* eliminate and advance over separator */
2124  // printf("parsed token: '%s'\n",token);
2125  std::istringstream sin(token);
2126  sin.getline(buf, sizeof(buf), '!');
2127  if (added.count(buf) == 0) {
2128  added.insert(buf);
2129  name = window + '.';
2130  name += buf;
2131  position = sin.get(); sin.get();
2132  sin >> dType; sin.get();
2133  sin >> numComponents; sin.get();
2134  sin.getline(buf, sizeof(buf), '!');
2135  DEBUG_MSG("Calling COM_new_attribute( name == '" << name << "', position == '" << position << "', datatype == " << dType << ", nComp == " << numComponents << ", units == '" << buf << "' )");
2136  COM_new_attribute(name.c_str(), position, dType, numComponents, buf);
2137 
2138  if ( position == 'w') { // Set size and allocate for window attributes
2139  int nitems, ng;
2140  sin >> nitems; sin.get();
2141  sin >> ng; sin.get();
2142  DEBUG_MSG("Calling COM_set_size( name == '" << name << "', paneid == 0, nitems == " << nitems << ", nghost == " << ng << " )");
2143  COM_set_size(name.c_str(), 0, nitems, ng);
2144  DEBUG_MSG("Calling COM_resize_array( name == '" << name << "', paneid == 0 )");
2145  COM_resize_array(name.c_str(), 0);
2146  }
2147  }
2148  token = nextToken;
2149  }
2150 }
int COM_Type
Indices for derived data types.
Definition: roccom_basic.h:122
void COM_set_size(const char *wa_str, int pane_id, int size, int ng=0)
Set sizes of for a specific attribute.
Definition: roccom_c++.h:136
NT & sin
#define DEBUG_MSG(x)
Definition: Rocin.C:77
blockLoc i
Definition: read.cpp:79
NT q
void COM_new_attribute(const char *wa_str, const char loc, const int type, int ncomp, const char *unit)
Registering an attribute type.
Definition: roccom_c++.h:118
void COM_resize_array(const char *wa_str, int pane_id=0, void **addr=NULL, int strd=-1, int cap=0)
Resize an attribute on a specific pane and return the address by setting addr.
Definition: roccom_c++.h:200

Here is the call graph for this function:

Here is the caller graph for this function:

void Rocin_load_module ( const char *  name)

Load the module Rocin into Roccom using the given module name.

This module provides three subroutines: "read_windows", "read_by_control_file", and "obtain_attribute".

Definition at line 3063 of file Rocin.C.

References Rocin::init().

Referenced by COM_F_FUNC2(), main(), read_pane_sp(), and RFC_Window_base::read_sdv().

3064 { Rocin::init( std::string(name)); }
static void init(const std::string &mname)
Initialize the module by registering it to Roccom with the given module name.
Definition: Rocin.C:2351

Here is the call graph for this function:

Here is the caller graph for this function:

void Rocin_unload_module ( const char *  name)

Unload the module Rocin from Roccom.

Definition at line 3066 of file Rocin.C.

References Rocin::finalize().

Referenced by COM_F_FUNC2(), read_pane_sp(), and RFC_Window_base::read_sdv().

3067 { Rocin::finalize( std::string(name)); }
static void finalize(const std::string &mname)
Finalize the module by deregistering it from Roccom.
Definition: Rocin.C:2417

Here is the call graph for this function:

Here is the caller graph for this function:

static void scan_files_HDF4 ( int  pathc,
char *  pathv[],
BlockMM_HDF4 blocks,
std::string &  time,
std::map< int32, COM_Type > &  HDF2COM 
)
static

Extract metadata from the list of files.

Open each file, scan the datasets, identify the windows, panes, and attributes.

          istringstream is apparently fragile, so we'll use atoi instead.

      std::istringstream sin2(ghost);

      sin2 >> gc;

Check if there are more data. if (!sin2.eof()) { if (sin2.get() == ',') { ghostPoints = gc; sin2 >> gc; } } if (gc < 0) std::cerr << "Rocstar: Error: Bad num ghosts " << gc << " from string: " << ghost << std::endl; ghostCells.push_back(gc); Check if there are more data. while (!sin2.eof()) { if (sin2.get() == ',') { sin2 >> gc; if (gc < 0) std::cerr << "Rocstar: Error: Bad ghosts " << gc << std::endl; ghostCells.push_back(gc); } }

Definition at line 340 of file Rocin.C.

References COM_assertion_msg, DEBUG_MSG, FindFirstGeometryDataset(), HDF4_CHECK, HDF4_CHECK_RET, i, Block_HDF4::m_gridInfo, VarInfo_HDF4::m_indices, VarInfo_HDF4::m_is_null, VarInfo_HDF4::m_name, Block_HDF4::m_numGhostNodes, Block_HDF4::m_numNodes, Block_HDF4::m_variables, MAX_NC_NAME, offset(), rank, HDF4::SDend(), HDF4::SDendaccess(), HDF4::SDfileinfo(), HDF4::SDgetdatastrs(), HDF4::SDreaddata(), HDF4::SDstart(), HDF4::Select(), sin, cimg_library::cimg::strcasecmp(), and cimg_library::cimg::strncasecmp().

Referenced by Rocin::read_windows().

343 {
344  int32 sd_id, geom_id, sds_id, nDataSets, nAttrs, index, index3;
345  int32 rank, dType, start[1];
346  int32 size[5] = { 0, 0, 0, 0, 0 };
347  int32 geomIdx[3];
348  char name[MAX_NC_NAME], label[MAX_NC_NAME];
349  char timeLevel[MAX_NC_NAME], units[MAX_NC_NAME];
350  char matName[MAX_NC_NAME], varName[MAX_NC_NAME], varType[MAX_NC_NAME];
351  int xyz;
352  int numPoints=0, ghostPoints, gc, gridType=0;
353  std::vector<int> ghostCells;
354  char grid[32], ghost[32], location;
355  std::string geomFile;
356  char buffer[1024];
357  Block_HDF4* block;
358  int i;
359 
360  blocks.clear();
361 
362  // Iterate through each file.
363  for (i=0; i<pathc; ++i) {
364  // Make sure this is an HDF file.
365  if (strcmp(&pathv[i][strlen(pathv[i])-4], ".hdf") != 0
366  && strcmp(&pathv[i][strlen(pathv[i])-5], ".hdf4") != 0)
367  continue;
368 
369  HDF4_CHECK_RET(sd_id = HDF4::SDstart, (pathv[i], DFACC_READ), continue);
370  AutoCloser<int32, intn> auto0(sd_id, HDF4::SDend);
371 
372  // Determine the number of datasets.
373  HDF4_CHECK_RET(HDF4::SDfileinfo, (sd_id, &nDataSets, &nAttrs),
374  continue);
375 
376  // Iterate through the datasets.
377  for (index=0; index<nDataSets; ++index) {
378  // Select each non-"fakeDim" dataset in the file.
379  HDF4_CHECK_RET(sds_id = HDF4::Select,
380  (sd_id, index, name, &rank, size, &dType, &nAttrs, nDataSets),
381  continue);
382 
383  {
385 
386  // Get the paneId ('label'), time level ('timeLevel'),
387  // dataset type ('varName'), and window name ('matName').
389  (sds_id, label, timeLevel, varName, matName, MAX_NC_NAME),
390  continue);
391 
392  // If this isn't a block header, then it isn't interesting.
393  if (strncasecmp(varName, "block header", 12) != 0) {
394  continue;
395  } else {
396  // Otherwise, set the time level if not yet set, and skip
397  // the blocks that have different time levels.
398  if (time.empty())
399  time = timeLevel;
400  else if (time != timeLevel)
401  continue;
402  }
403 
404  // Block header datasets should have only one dimension.
405  if (rank != 1) {
406  std::cerr << "Rocstar: Warning: Dataset " << index << " in file " << pathv[i]
407  << " is marked as a block header, but its rank is not 1 "
408  << "(rank == " << rank << ')' << std::endl;
409  continue;
410  }
411 
412  ghostCells.clear();
413  geomFile.erase();
414  if (dType == DFNT_CHAR8) {
415  // This data file is written for version 1.1. Good!
416  start[0] = 0;
417  std::vector<char8> data(size[0]);
419  (sds_id, start, NULL, size, (VOIDP)&data[0]),
420  continue);
421 
422  // Parse the data into grid type, ghost info, and external
423  // geometry file.
424  std::istringstream sin(&data[0]);
425  sin.getline(grid, sizeof(grid), '|');
426  sin.getline(ghost, sizeof(ghost), '|');
427  buffer[0] = '\0';
428  sin >> buffer;
429 
430  // The first token is the grid type.
431  if (strcasecmp(grid, "structured") == 0 || strcmp(grid, "2") == 0) {
432  gridType = 2;
433  } else if (strcasecmp(grid, "unstructured") == 0
434  || strcmp(grid, "3") == 0) {
435  gridType = 3;
436  } else if (strcasecmp(grid, "discontinuous") == 0
437  || strcmp(grid, "4") == 0) {
438  gridType = 4;
439  } else if (strcasecmp(grid, "polydata") == 0
440  || strcmp(grid, "5") == 0) {
441  gridType = 5;
442  } else {
443  std::cerr << "Rocstar: Warning: The block header (dataset " << index
444  << " in file " << pathv[i] << ") does not have a "
445  << "valid grid type (grid = " << grid << ')'
446  << std::endl;
447  }
448 
449  // The second token is the number of ghost points and cells. If
450  // there is a single number, then this is (probably) the number of
451  // layers of ghost cells on a structured grid. Otherwise, it's the
452  // number of ghost points followed by the number of ghost cells of
453  // each connectivity table of an unstructured grid.
454  // WARNING: When using external grid files, the ghost data will
455  // probably not be accurate!
456 
457  ghostPoints = 0;
484  gc = atoi(ghost);
485  char* c = strchr(ghost, ',');
486  if (c != NULL) {
487  ++c;
488  ghostPoints = gc;
489  gc = atoi(c);
490  c = strchr(c, ',');
491  }
492  if (gc < 0) std::cerr << "Rocstar: Warning: Bad num ghosts " << gc << " from string: " << ghost << std::endl;
493  ghostCells.push_back(gc);
494  // Check if there are more data.
495  while (c != NULL) {
496  ++c;
497  gc = atoi(c);
498  c = strchr(c, ',');
499  if (gc < 0) std::cerr << "Rocstar: Warning: Bad ghosts " << gc << std::endl;
500  ghostCells.push_back(gc);
501  }
502 
503  // The third token (if present) is an external geometry file.
504  if (buffer[0] != '\0') {
505  if (buffer[0] == '/') {
506  geomFile = buffer;
507  } else {
508  // Normalize the filename.
509  geomFile = pathv[i];
510  std::string::size_type pos = geomFile.find_last_of('/');
511  if (pos != std::string::npos) {
512  geomFile.erase(pos + 1);
513  geomFile += buffer;
514 
515  // If normalized filename does not exist, then
516  // try to find the mesh file with the given name.
517  struct stat sb;
518  if (stat(geomFile.c_str(), &sb) != 0)
519  geomFile = buffer;
520  }
521  else
522  geomFile = buffer;
523  }
524 
525  // Make sure the file exists.
526  struct stat sb;
527  if (stat(geomFile.c_str(), &sb) != 0) {
528  std::cerr << "Rocstar: Warning: The block header (dataset " << index
529  << " in file " << pathv[i] << ") has an invalid "
530  << "filename for the external geometry data. The "
531  << "file does not exist: " << geomFile << std::endl;
532  continue;
533  }
534  }
535  } else {
536  std::cerr << "Rocstar: Warning: Dataset " << index << " in file " << pathv[i]
537  << " is marked as a block header, but its datatype is "
538  << "not char8." << std::endl;
539  continue;
540  }
541  }
542 
543  geom_id = FindFirstGeometryDataset(sd_id, geomFile, matName, label,
544  index, &index3);
545  if (geom_id == FAIL) {
546  std::cerr << "Rocstar: Warning: Could not open geometry dataset for section "
547  << label << " of material " << matName << std::endl;
548  continue;
549  }
550 
551  // Collect data on the nodal coordinate datasets.
552  for (xyz=0; xyz<6; xyz+=2,++index3) {
553  HDF4_CHECK_RET(sds_id = HDF4::Select,
554  (geom_id, index3, name, &rank, size, &dType, &nAttrs),
555  continue);
557 
558  geomIdx[xyz/2] = index3;
559 
560  if (xyz == 0) {
561  units[0] = '\0';
562  if ((gridType == 2 && rank != 3) || (gridType != 2 && rank != 1)) {
563  numPoints = size[0] = size[1] = size[2] = 0;
564  geomIdx[0] = geomIdx[1] = geomIdx[2] = FAIL;
565  break;
566  }
567 
569  (sds_id, name, units, NULL, varType, MAX_NC_NAME));
570 
571  if (gridType == 2) {
572  numPoints = size[0] * size[1] * size[2];
573  } else {
574  char* pos = strchr(name, '|');
575 
576  if (pos && *(pos+2)=='0')
577  numPoints = ghostPoints = 0; // Empty pane.
578  else {
579  numPoints = size[0];
580  // Get a trustworthy count of the number of ghost nodes.
581  std::istringstream in(pos+3);
582  in >> ghostPoints;
583  }
584  }
585  }
586  }
587 
588  // Determine the pane id. Skip any non-numeric prefix such as "block".
589  std::string lbl(label);
590  std::string::size_type pos = lbl.find_first_of("0123456789");
591  if (pos != std::string::npos)
592  lbl.erase(0, pos);
593 
594  std::istringstream sin(lbl);
595  int paneId;
596  sin >> paneId;
597 
598  // Create and initialize a Block object.
599  block = new Block_HDF4(pathv[i], geomFile, geomIdx, paneId, timeLevel,
600  units, numPoints, ghostPoints);
601 
602  // Add grid info.
603  if (gridType == 2) {
604  // Structured grids only have dimensions.
605  block->m_gridInfo.push_back(GridInfo_HDF4(size, ghostCells[0]));
606  } else {
607  // Get info for each connectivity table. If we were given ghost
608  // cell info, then we know how many connectivity tables we have.
609  // Otherwise we have to keep going until we find a dataset that is
610  // obviously not a connectivity table.
611  std::vector<int>::iterator p;
612  for (p=ghostCells.begin();
613  ghostCells.empty() || p!=ghostCells.end();
614  ++p,++index3) {
615  sds_id = HDF4::Select(geom_id, index3, name, &rank, size,
616  &dType, &nAttrs);
617  if (sds_id == FAIL) {
618  if (!ghostCells.empty())
619  std::cerr << "Rocstar: Warning: Select() failed on connectivity dataset "
620  << index3 << " in file "
621  << (geomFile.empty() ? pathv[i] : geomFile.c_str())
622  << std::endl;
623  break;
624  }
626 
627  // If the rank isn't 2, then it's not a connectivity table.
628  if (rank != 2) {
629  break;
630  }
631 
632  // Get metadata on the connectivity table.
634  (sds_id, label, units, varName, varType, MAX_NC_NAME),
635  continue);
636 
637  int ghostCount = 0;
638  if (!ghostCells.empty())
639  ghostCount = *p;
640 
641  // A connectivity table must start with ':'
642  if (varName[0] != ':') { /* Old, pre-roccom3 dataset */
643  /* HIDEOUS HACK: should figure out real element type */
644  if (gridType == 3 || gridType == 4) {
645  if (size[0] == 4)
646  strcpy(varName,":T4:");
647  else if (size[0] == 5)
648  strcpy(varName,":P5:");
649  else if (size[0] == 6)
650  strcpy(varName,":P6:");
651  else if (size[0] == 8)
652  strcpy(varName,":B8:");
653  else if (size[0] == 10)
654  strcpy(varName,":T10:");
655  else if (size[0] == 20)
656  strcpy(varName,":B20:");
657  else
658  strcpy(varName,":unknown");
659  } else if (gridType == 5) {
660  if (size[0] == 3)
661  strcpy(varName,":t3:");
662  else if (size[0] == 4)
663  strcpy(varName,":q4:");
664  else if (size[0] == 6)
665  strcpy(varName,":t6:");
666  else if (size[0] == 8)
667  strcpy(varName,":q8:");
668  else
669  strcpy(varName,":unknown");
670  } else {
671  strcpy(varName,":unknown");
672  }
673 
674  if (1) {
675  std::cerr << "Rocstar: Warning: reading old-style connectivity dataset "
676  << varName << " from " << index3 << " in file "
677  << (geomFile.empty() ? pathv[i] : geomFile.c_str())
678  << std::endl;
679  }
680  } else {
681  // If the table is empty, set number of elements to 0.
682  char* pos = strchr(label, '|');
683  if (pos && *(pos+2)=='0') {
684  size[1] = ghostCount = 0;
685  } else {
686  // Get a trustworthy count of the number of ghost elements.
687  std::istringstream in(pos+3);
688  in >> ghostCount;
689  }
690  }
691 
692  if (size[1]<0 || ghostCount < 0) {
693  std::cerr << "Rocstar: Error: Bad number of element or ghosts for attribute " << varName << " nElem=" << size[1] << " nGhost=" << ghostCount << std::endl;
695  "Bad number of element or ghosts for attribute.");
696  }
697  // Store the mesh info.
698  block->m_gridInfo.push_back(GridInfo_HDF4(varName, size[1], ghostCount, index3));
699  }
700  }
701  if (geom_id != sd_id) {
702  HDF4::SDend(geom_id);
703  } else {
704  index = index3;
705  }
706 
707  // Now search for datasets with variable data.
708  for (++index; index<nDataSets; ++index) {
709  HDF4_CHECK_RET(sds_id = HDF4::Select,
710  (sd_id, index, name, &rank, size, &dType, &nAttrs, nDataSets),
711  continue);
713 
714  // Get metadata on the variable.
716  (sds_id, label, units, varName, varType, MAX_NC_NAME),
717  continue);
718 
719  if (varName[0] == '\0' || varName[0] == ':') {
720  // Hmm, this is a geometry dataset.
721  continue;
722  }
723 
724  if (strncasecmp(varName, "block header", 12) == 0) {
725  // We've found another block header. We're done.
726  // Reverse index by one, as it will be incremented by the outer-loop
727  --index;
728  break;
729  }
730 
731  // Determine the location. Format of label is (FIXME: complete?)
732  // "<component letter: 1,2,3,x,y,z>-<attribute>"
733  // "|<location letter: w,p,c,n,e>"
734  // " AT TIME <time SS.MMMUUU> "
735  int ng=0; bool is_null=false;
736  location = 'w';
737  if ( label[0] != ':') {
738  char* pos = strchr(label, '|');
739  if (pos == NULL) {
740  /* Old HDF file without nice labels. For backward compatability,
741  guess the data location from the size of the data:
742  */
743  int sz=size[0]; // Should this be size[rank-1]?
744 
745  location='p'; /* guess a panel attribute */
746 
747  int num=block->m_numNodes, g=block->m_numGhostNodes;
748  if (num==sz) {location='n'; ng=0; /* nodes */ }
749  num+=g;
750  if (num==sz) {location='n'; ng=g; /* nodes and ghosts */ }
751 
752  if (1) {
753  num=block->m_gridInfo[0].m_numElements; g=block->m_gridInfo[0].m_numGhostElements;
754  if (num==sz) {location='e'; ng=0; /* elements */ }
755  num+=g;
756  if (num==sz) {location='e'; ng=g; /* elements and ghosts */ }
757  }
758 
759  if (0) { /* annoying compatability warning */
760  std::cerr << "Rocstar: Warning: Compatability warning: guessing variable '"
761  << varName << "' in dataset " << index << " in file "
762  << pathv[i] << " with label " << label
763  << " is of type " << location
764  << "(" << sz << ")" << std::endl;
765  /* display size of variable */
766  std::cerr << " size of variable: ";
767  for (int i=0;i<rank;i++) std::cerr<<size[i]<<',';
768  std::cerr << std::endl;
769  }
770  }
771  else { /* New HDF file: gives location of data directly. */
772  location = *(pos + 1);
773  // Also obtain the number of ghost items
774  if ( *(pos+2) == '0')
775  { size[0] = ng = 0; is_null=true; }
776  else if ( (*(pos + 2)==',' || *(pos + 2)=='@'))
777  { ng = std::atoi( pos+3); is_null=*(pos + 2)=='@'; }
778  }
779  }
780 
781  // Determine which component of the variable we're analyzing.
782  std::istringstream str(varType);
783  int vType = 0;
784  str>> vType;
785 
786  int nc = 0;
787  switch (vType) {
788  case 0:
789  // Scalar data.
790  nc = 1;
791  break;
792 
793  case 1:
794  // First component of vector data.
795  nc = 3;
796  break;
797 
798  case 11:
799  // First component of tensor data.
800  nc = 9;
801  break;
802 
803  case 2: case 3: {
804  // Second or third component of vector data.
805  VarInfo_HDF4 &vi = block->m_variables.back();
806  if (vi.m_name != varName || vi.m_indices.size() != 3) {
807  // We shouldn't be seeing 2 or 3 before we see 1.
808  std::cerr << "Rocstar: Warning: Found a vector component named " << varName
809  << " for which there is no X component at "
810  << " dataset " << index << " (" << name
811  << ") in file " << pathv[i] << std::endl;
812  continue;
813  }
814  vi.m_indices[vType-1] = index;
815  vi.m_is_null[vType-1] = is_null;
816  continue;
817  }
818  case 12: case 13:
819  case 21: case 22: case 23:
820  case 31: case 32: case 33: {
821  // Second, third, etc component of tensor data.
822  VarInfo_HDF4 &vi = block->m_variables.back();
823  if (vi.m_name != varName || vi.m_indices.size() != 9) {
824  // We shouldn't be seeing any of these before we see 11.
825  std::cerr << "Rocstar: Warning: Found a tensor component named " << varName
826  << " for which there is no (0,0) component at "
827  << "dataset " << index << " (" << name
828  << ") in file " << pathv[i] << std::endl;
829  continue;
830  }
831  vi.m_indices[3*(vType/10)+(vType%10)-4] = index;
832  vi.m_is_null[3*(vType/10)+(vType%10)-4] = is_null;
833  continue;
834  }
835  default:
836  // I don't know what kind of variable this is supposed to be.
837  // Assuming scalar.
838  vType = 0;
839  nc = 1;
840  break;
841  }
842 
843  int offset = 0; // Starting point for actual attribute name.
844  if ( varName[0]>='0' && varName[0]<='9') {
845  if ( std::strncmp( varName, "1-", 2)==0)
846  offset = 2; // Skip the "1-" part
847  else { // Append to the back
848  VarInfo_HDF4 &vi = block->m_variables.back();
849  unsigned int id = std::atoi( varName);
850  const char *aName = std::strchr(varName, '-');
851 
852  if ( aName==NULL || vi.m_name != (aName+1) ||
853  vi.m_indices.size() != id-1) {
854  // The individual components must be stored consecutively
855  std::cerr << "Rocstar: Warning: Found a vector named " << vi.m_name
856  << " whose components are not stored together "
857  << " in file " << pathv[i] << std::endl;
858  continue;
859  }
860 
861  vi.m_indices.push_back( index);
862  vi.m_is_null.push_back( is_null);
863  DEBUG_MSG("Correction: variable '" << vi.m_name << "' actually has "
864  << vi.m_indices.size() << " components.");
865  continue;
866  }
867  }
868 
869  DEBUG_MSG("Found variable '" << &varName[offset] << "', location == '"
870  << location << "', nComp == " << nc << ", nItems == "
871  << size[0] << ", nGhost == " << ng << ", isNull == "
872  << is_null);
873  block->m_variables.push_back
874  (VarInfo_HDF4(&varName[offset], location, HDF2COM[dType],
875  units, nc, index, size[0], ng, is_null));
876  }
877  blocks.insert(BlockMM_HDF4::value_type(matName, block));
878  }
879  }
880 }
int m_numGhostNodes
Number of ghost nodes in a mesh.
Definition: rocin_block.h:98
Struct containing necessary information on a mesh of a pane.
Definition: rocin_block.h:55
std::vector< int32 > m_indices
HDF4 dataset indices for each component.
Definition: rocin_block.h:46
int m_numNodes
Number of nodes in the mesh.
Definition: rocin_block.h:97
static intn SDend(int32 sd_id)
Definition: HDF4.C:200
std::vector< bool > m_is_null
Whether or not a component in NULL.
Definition: rocin_block.h:49
#define COM_assertion_msg(EX, msg)
static intn SDendaccess(int32 sds_id)
Definition: HDF4.C:288
Struct containing necessary information for a pane.
Definition: rocin_block.h:81
Automatically close open files, datasets, etc.
Definition: Rocin.C:179
real *8 function offset(vNorm, x2, y2, z2)
Definition: PlaneNorm.f90:211
#define MAX_NC_NAME
int strncasecmp(const char *const s1, const char *const s2, const int l)
Compare the first n characters of two C-strings, ignoring the case.
Definition: CImg.h:4915
#define HDF4_CHECK(routine, args)
Definition: Rocin.C:170
Definition: adj.h:203
std::vector< GridInfo_HDF4 > m_gridInfo
Dimensions or conn table(s)
Definition: rocin_block.h:99
static int32 FindFirstGeometryDataset(int32 sd_id, const std::string &geomFile, const std::string &matName, const std::string &label, int32 hIndex, int32 *index)
Find the first geometry dataset for the given block.
Definition: Rocin.C:285
int strcasecmp(const char *const s1, const char *const s2)
Compare two C-strings, ignoring the case.
Definition: CImg.h:4928
NT & sin
#define DEBUG_MSG(x)
Definition: Rocin.C:77
static int32 Select(int32 sd_id, int32 &index, char *name, int32 *rank, int32 *size, int32 *dType, int32 *nAttrs, int32 dsCount=-1)
&quot;Open&quot; and &quot;close&quot; HDF files efficiently.
Definition: HDF4.C:675
#define HDF4_CHECK_RET(routine, args, retval)
Perform HDF4 error-checking.
Definition: Rocin.C:144
std::string m_name
Name of variable.
Definition: rocin_block.h:42
static intn SDreaddata(int32 sds_id, int32 *start, int32 *stride, int32 *end, VOIDP data)
Definition: HDF4.C:467
blockLoc i
Definition: read.cpp:79
Struct containing necessary information about an attribute in a window.
Definition: rocin_block.h:33
static intn SDfileinfo(int32 id, int32 *dsCount, int32 *nAttrs)
Definition: HDF4.C:219
bool blocks
Input data is block-structured grid.
Definition: hdf2pltV2.C:51
unsigned long time()
Get the value of a system timer with a millisecond precision.
Definition: CImg.h:4605
static int32 SDstart(const char *filename, int32 accessMode)
Definition: HDF4.C:177
static intn SDgetdatastrs(int32 sds_id, char *label, char *units, char *format, char *coordsys, intn length)
Definition: HDF4.C:376
static int rank
Definition: advectest.C:66
std::vector< VarInfo_HDF4 > m_variables
Info on each variable.
Definition: rocin_block.h:100

Here is the call graph for this function:

Here is the caller graph for this function: