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

#include <Rocin.h>

Inheritance diagram for Rocin:
Collaboration diagram for Rocin:

Public Types

typedef void(* RulesPtr )(const int &pane_id, const int &comm_rank, const int &comm_size, int *is_local)
 Pointer to a function to determine locality of a pane. More...
 

Public Member Functions

 Rocin ()
 Default constructor. More...
 
User interface
void read_by_control_file (const char *control_file_name, const char *window_name, const MPI_Comm *comm=NULL, char *time_level=NULL, const int *str_len=NULL)
 Create a single Roccom window by reading in the files specified by the given control file. More...
 
void read_window (const char *filename_patterns, const char *window_name, const MPI_Comm *comm=NULL, RulesPtr is_local=NULL, char *time_level=NULL, const int *str_len=NULL)
 Create a single Roccom window by reading in a list of files. More...
 
void read_windows (const char *filename_patterns, const char *window_prefix, const char *material_names=NULL, const MPI_Comm *comm=NULL, RulesPtr is_local=NULL, char *time_level=NULL, const int *str_len=NULL)
 Create a series of Roccom windows by reading in a list of files. More...
 
void obtain_attribute (const COM::Attribute *attribute_in, COM::Attribute *user_attribute, int *pane_id=NULL)
 Fill the destination (second) attribute from files using the data corresponding to the source (first) attribute. More...
 
void read_parameter_file (const char *file_name, const char *window_name, const MPI_Comm *comm=NULL)
 Read in parameters from a given file into the given window. More...
 

Static Protected Member Functions

Initialization and finalization
static void init (const std::string &mname)
 Initialize the module by registering it to Roccom with the given module name. More...
 
static void finalize (const std::string &mname)
 Finalize the module by deregistering it from Roccom. More...
 

Protected Attributes

MemberRulePtr m_is_local
 
std::set< int > m_pane_ids
 
int m_base
 
int m_offset
 
std::map< int32, COM_Typem_HDF2COM
 

Friends

Module loading and unloading
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...
 

Pane distribution

Assign panes onto different processes.

typedef void(Rocin::* MemberRulePtr )(const int &, const int &, const int &, int *)
 
void explicit_local (const int &pid, const int &comm_rank, const int &comm_size, int *il)
 
void cyclic_local (const int &pid, const int &comm_rank, const int &comm_size, int *il)
 
void blockcyclic_local (const int &pid, const int &comm_rank, const int &comm_size, int *il)
 
void register_panes (BlockMM_HDF4::iterator hdf4, const BlockMM_HDF4::iterator &hdf4End, const std::string &window, RulesPtr is_local, const MPI_Comm *comm, int rank, int nprocs)
 

Detailed Description

Definition at line 64 of file Rocin.h.

Member Typedef Documentation

typedef void(Rocin::* MemberRulePtr)(const int &, const int &, const int &, int *)
protected

Definition at line 191 of file Rocin.h.

typedef void(* RulesPtr)(const int &pane_id, const int &comm_rank, const int &comm_size, int *is_local)

Pointer to a function to determine locality of a pane.

Definition at line 70 of file Rocin.h.

Constructor & Destructor Documentation

Rocin ( )
inline

Default constructor.

Definition at line 67 of file Rocin.h.

Referenced by init().

67 : m_is_local( NULL), m_base(0), m_offset(0) {}
int m_base
Definition: Rocin.h:243
MemberRulePtr m_is_local
Definition: Rocin.h:241
int m_offset
Definition: Rocin.h:244

Here is the caller graph for this function:

Member Function Documentation

void blockcyclic_local ( const int &  pid,
const int &  comm_rank,
const int &  comm_size,
int *  il 
)
protected

Definition at line 2458 of file Rocin.C.

References m_base, and m_offset.

Referenced by read_by_control_file().

2460 {
2461  int proc = (pid-m_offset) / m_base;
2462  if ( proc>=comm_size) proc %= comm_size;
2463  *il = proc == comm_rank;
2464 }
int m_base
Definition: Rocin.h:243
int m_offset
Definition: Rocin.h:244

Here is the caller graph for this function:

void cyclic_local ( const int &  pid,
const int &  comm_rank,
const int &  comm_size,
int *  il 
)
protected

Definition at line 2452 of file Rocin.C.

References m_offset.

Referenced by read_by_control_file().

2454 {
2455  *il = (pid - m_offset) % comm_size == comm_rank;
2456 }
int m_offset
Definition: Rocin.h:244

Here is the caller graph for this function:

void explicit_local ( const int &  pid,
const int &  comm_rank,
const int &  comm_size,
int *  il 
)
protected

Definition at line 2446 of file Rocin.C.

References m_pane_ids.

Referenced by read_by_control_file().

2448 {
2449  *il = m_pane_ids.count(pid);
2450 }
std::set< int > m_pane_ids
Definition: Rocin.h:242

Here is the caller graph for this function:

void finalize ( const std::string &  mname)
staticprotected

Finalize the module by deregistering it from Roccom.

See Also
Rochdf_unload_module()

Definition at line 2417 of file Rocin.C.

References COM_delete_window(), COM_get_object(), and HDF4::finalize().

Referenced by Rocin_unload_module().

2417  {
2418  // Retrieve Rocin object from Roccom
2419  Rocin *rin;
2420  std::string glb=mname+".global";
2421 
2422  COM_get_object( glb.c_str(), 0, &rin);
2423 
2424  COM_delete_window( mname.c_str());
2425 
2426  // Delete the object
2427  delete rin;
2428  HDF4::finalize();
2429 }
void COM_delete_window(const char *wname)
Definition: roccom_c++.h:94
void COM_get_object(const char *wa_str, int pane_id, Type **addr)
Definition: roccom_c++.h:152
Definition: Rocin.h:64
static void finalize()
Destroy the I/O thread.
Definition: HDF4.C:128

Here is the call graph for this function:

Here is the caller graph for this function:

void init ( const std::string &  mname)
staticprotected

Initialize the module by registering it to Roccom with the given module name.

This function is called Rocin_load_module.

See Also
Rocin_load_module()

This data structure maps HDF4 data types to roccom data types.

Definition at line 2351 of file Rocin.C.

References COM_CHAR, COM_DOUBLE, COM_FLOAT, COM_INT, COM_METADATA, COM_MPI_COMM, COM_new_attribute(), COM_new_window(), COM_OBJECT, COM_RAWDATA, COM_set_member_function(), COM_set_object(), COM_STRING, COM_VOID, COM_window_init_done(), DEBUG_MSG, HDF4::init(), m_HDF2COM, MPI_COMM_SELF, obtain_attribute(), read_by_control_file(), read_parameter_file(), read_window(), read_windows(), and Rocin().

Referenced by Rocin_load_module().

2351  {
2352  HDF4::init();
2353 
2354  Rocin *rin = new Rocin();
2355 
2357  rin->m_HDF2COM[DFNT_CHAR8] = COM_CHAR;
2358  rin->m_HDF2COM[DFNT_INT32] = COM_INT;
2359  rin->m_HDF2COM[DFNT_FLOAT32] = COM_FLOAT;
2360  rin->m_HDF2COM[DFNT_FLOAT64] = COM_DOUBLE;
2361 
2362 #ifdef USE_CGNS
2363  rin->m_CGNS2COM[Character] = COM_CHAR;
2365  rin->m_CGNS2COM[Integer] = COM_INT;
2366  rin->m_CGNS2COM[RealSingle] = COM_FLOAT;
2367  rin->m_CGNS2COM[RealDouble] = COM_DOUBLE;
2368 #endif // USE_CGNS
2369 
2370  COM_new_window( mname.c_str(), MPI_COMM_SELF);
2371 
2372  std::string glb=mname+".global";
2373 
2374  DEBUG_MSG("Calling COM_new_attribute( name == '" << glb << "', position == 'w', datatype == COM_OBJECT, nComp == 1, units == '' )");
2375  COM_new_attribute( glb.c_str(), 'w', COM_OBJECT, 1, "");
2376  COM_set_object( glb.c_str(), 0, rin);
2377 
2378  // Register the function read_windows
2381  COM_set_member_function( (mname+".read_windows").c_str(),
2382  (Member_func_ptr)&Rocin::read_windows,
2383  glb.c_str(), "biiIIIBI", types);
2384 
2385  // Register the function read_window
2386  types[3] = COM_MPI_COMM; types[4] = COM_VOID;
2387  types[5] = COM_STRING; types[6] = COM_INT;
2388  COM_set_member_function( (mname+".read_window").c_str(),
2389  (Member_func_ptr)&Rocin::read_window,
2390  glb.c_str(), "biiIIBI", types);
2391 
2392  // Register the function read_by_control_file
2393  types[4] = COM_STRING; types[5] = COM_INT;
2394  COM_set_member_function( (mname+".read_by_control_file").c_str(),
2395  (Member_func_ptr)&Rocin::read_by_control_file,
2396  glb.c_str(), "biiIBI", types);
2397 
2398  // Register the function obtain_attribute
2399  types[1] = COM_METADATA;
2400  types[2] = COM_METADATA;
2401  types[3] = COM_INT;
2402  COM_set_member_function( (mname+".obtain_attribute").c_str(),
2403  (Member_func_ptr)&Rocin::obtain_attribute,
2404  glb.c_str(), "bioI", types);
2405 
2406  // Regsister the function read_parameter_file
2407  types[1] = COM_STRING;
2408  types[2] = COM_STRING;
2409  types[3] = COM_MPI_COMM;
2410  COM_set_member_function( (mname+".read_parameter_file").c_str(),
2411  (Member_func_ptr)&Rocin::read_parameter_file,
2412  glb.c_str(), "biiI", types);
2413 
2414  COM_window_init_done( mname.c_str());
2415 }
int COM_Type
Indices for derived data types.
Definition: roccom_basic.h:122
void read_windows(const char *filename_patterns, const char *window_prefix, const char *material_names=NULL, const MPI_Comm *comm=NULL, RulesPtr is_local=NULL, char *time_level=NULL, const int *str_len=NULL)
Create a series of Roccom windows by reading in a list of files.
Definition: Rocin.C:2786
here we put it at the!beginning of the common block The point to point and collective!routines know about but MPI_TYPE_STRUCT as yet does not!MPI_STATUS_IGNORE and MPI_STATUSES_IGNORE are similar objects!Until the underlying MPI library implements the C version of these are declared as arrays of MPI_STATUS_SIZE!The types and are OPTIONAL!Their values are zero if they are not available Note that!using these reduces the portability of MPI_IO INTEGER MPI_BOTTOM INTEGER MPI_DOUBLE_PRECISION INTEGER MPI_LOGICAL INTEGER MPI_2REAL INTEGER MPI_2DOUBLE_COMPLEX INTEGER MPI_LB INTEGER MPI_WTIME_IS_GLOBAL INTEGER MPI_COMM_SELF
void read_window(const char *filename_patterns, const char *window_name, const MPI_Comm *comm=NULL, RulesPtr is_local=NULL, char *time_level=NULL, const int *str_len=NULL)
Create a single Roccom window by reading in a list of files.
Definition: Rocin.C:2750
C/C++ Data types.
Definition: roccom_basic.h:129
void COM_set_object(const char *wa_str, int pane_id, Type *addr)
Definition: roccom_c++.h:144
static void init()
Create and start the I/O thread.
Definition: HDF4.C:108
void read_parameter_file(const char *file_name, const char *window_name, const MPI_Comm *comm=NULL)
Read in parameters from a given file into the given window.
#define DEBUG_MSG(x)
Definition: Rocin.C:77
Definition: Rocin.h:64
Rocin()
Default constructor.
Definition: Rocin.h:67
void COM_window_init_done(const char *w_str, int pane_changed=true)
Definition: roccom_c++.h:102
void COM_new_window(const char *wname, MPI_Comm c=MPI_COMM_NULL)
Definition: roccom_c++.h:86
std::map< int32, COM_Type > m_HDF2COM
Definition: Rocin.h:246
void obtain_attribute(const COM::Attribute *attribute_in, COM::Attribute *user_attribute, int *pane_id=NULL)
Fill the destination (second) attribute from files using the data corresponding to the source (first)...
Definition: Rocin.C:2431
void read_by_control_file(const char *control_file_name, const char *window_name, const MPI_Comm *comm=NULL, char *time_level=NULL, const int *str_len=NULL)
Create a single Roccom window by reading in the files specified by the given control file...
Definition: Rocin.C:2466
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_set_member_function(const char *wf_str, Member_func_ptr func, const char *wa_str, const char *intents, const COM_Type *types)
Definition: roccom_c++.h:330

Here is the call graph for this function:

Here is the caller graph for this function:

void obtain_attribute ( const COM::Attribute *  attribute_in,
COM::Attribute *  user_attribute,
int *  pane_id = NULL 
)

Fill the destination (second) attribute from files using the data corresponding to the source (first) attribute.

Note that the destination and the source attributes can be the same.

Parameters
attribute_insource attribute
user_attributedestination attribute
pane_idif present, then copy only the specific pane
See Also
obtain_attribute()

Definition at line 2431 of file Rocin.C.

References COM_assertion_msg.

Referenced by init(), plag_initgenxinterface(), rflo_modinterfacessolver::RFLO_InitAvgCoeffs::rflo_initavgcoeffs(), rflo_initflowsolver(), rflo_initgenxinterface(), and rflo_modinterfacesexternal::RFLO_SendBoundaryValuesAlpha::rflo_sendboundaryvaluesalpha().

2434 {
2435  // obtain a valid attribute object from user_attribute's name
2436  COM_assertion_msg((attribute_in != NULL && user_attribute != NULL),
2437  "Null attributes are not valid arguments to Rocin::obtain_attribute\n");
2438 
2439  if ( attribute_in != user_attribute) {
2440  COM::Window *win = user_attribute->window();
2441  win->inherit(const_cast<Attribute*>(attribute_in), user_attribute->name(),
2442  COM::Pane::INHERIT_COPY, true, NULL, pane_id?*pane_id:0);
2443  }
2444 }
#define COM_assertion_msg(EX, msg)

Here is the caller graph for this function:

void read_by_control_file ( const char *  control_file_name,
const char *  window_name,
const MPI_Comm *  comm = NULL,
char *  time_level = NULL,
const int *  str_len = NULL 
)

Create a single Roccom window by reading in the files specified by the given control file.

Parameters
control_file_namespecifies the control file.
window_namethe name of the window to be created.
commThe MPI communicator to use. If is NULL, the default communicator of Roccom will be used.
time_levelthe time stamp of the dataset to be read. If time level is NULL (default) or "", then the first time_level in the file will be assumed.
str_lenif present and positive, the time stamp of the dataset will be copied to the time_level string.

Definition at line 2466 of file Rocin.C.

References blockcyclic_local(), COM_assertion_msg, COM_get_default_communicator(), COMMPI_Initialized(), cyclic_local(), explicit_local(), files(), i, m_base, m_is_local, m_offset, m_pane_ids, min(), rank, read_window(), and sin.

Referenced by init().

2471 {
2472  const MPI_Comm default_comm=COM_get_default_communicator();
2473  const MPI_Comm comm_null=MPI_COMM_NULL;
2474  const MPI_Comm* myComm;
2475  int myRank, comm_size;
2476 
2477  // Determine the directory name of the control_file_name
2478  std::string dir_name = control_file_name;
2479  std::string::size_type pos = dir_name.find_last_of('/');
2480  if ( pos == std::string::npos)
2481  dir_name = "";
2482  else
2483  dir_name.erase( pos+1);
2484 
2485  if ( comm && *comm == MPI_COMM_NULL || !comm)
2486  myComm = COMMPI_Initialized() ? &default_comm : &comm_null;
2487  else
2488  myComm = comm;
2489 
2490  // Set myRank to a wild card if MPI is not initialized
2491  if ( !COMMPI_Initialized() || *myComm == MPI_COMM_NULL) {
2492  myRank = -1;
2493  comm_size = 1;
2494  }
2495  else {
2496  MPI_Comm_rank(*myComm, &myRank);
2497  MPI_Comm_size(*myComm, &comm_size);
2498  if(comm_size == 1)
2499  myRank = -1;
2500  }
2501 
2502  std::ifstream fin(control_file_name);
2503  if (!fin.is_open()) {
2504  std::cerr << "Rocstar: Error: read_by_control_file unable to open " << control_file_name
2505  << " for reading." << std::endl;
2506  return;
2507  }
2508 
2509  std::vector<std::string> patterns;
2510  std::string buffer;
2511  int rank = -54321;
2512  m_pane_ids.clear();
2513 
2514  while (!fin.eof()) {
2515  std::vector<std::string> local_patterns;
2516  while (!fin.eof() && (myRank<0 || rank != myRank) ) {
2517  if (buffer != "@Proc:") {
2518  fin >> buffer;
2519  continue;
2520  }
2521 
2522  while (fin.peek() == ' ' || fin.peek() == '\t' || fin.peek() == '\n')
2523  fin.get();
2524 
2525  if (fin.peek() == '*') {
2526  fin.get();
2527  rank = myRank;
2528  break;
2529  } else {
2530  fin >> rank;
2531  // If myRank is a wild card, then any rank will match with it.
2532  if (myRank < 0) {
2533  rank = myRank;
2534  break;
2535  } else if (rank == myRank)
2536  break;
2537  }
2538 
2539  buffer="";
2540  }
2541 
2542  if (fin.eof()) {
2543  if ( rank != myRank)
2544  std::cerr << "Rocstar: Error (read_by_control_file): control file "
2545  << control_file_name
2546  << " does not contain information for process " << myRank
2547  << std::endl;
2548  break;
2549  }
2550 
2551  fin >> buffer;
2552  if (buffer != "@Files:") {
2553  std::cerr << "Rocstar: Error (read_by_control_file): in control file "
2554  << control_file_name
2555  << ": expected '@Files' but found '" << buffer << '\''
2556  << std::endl;
2557  return;
2558  }
2559 
2560  fin >> buffer;
2561 
2562  while (buffer != "@Panes:" && buffer != "@Proc:") {
2563  // The @Panes section may not be present
2564  if (fin.eof()) break;
2565 
2566  std::string::size_type pos = buffer.find("%t");
2567  if (pos != std::string::npos)
2568  buffer.replace(pos, 2, time_level);
2569 
2570  pos = buffer.find('%');
2571  if ( pos != std::string::npos) {
2572  std::string::size_type pos_key =
2573  buffer.find_first_not_of("0123456789", pos+1);
2574 
2575  COM_assertion_msg( pos_key != std::string::npos,
2576  (std::string("Incomplete placeholder in file name ")+buffer).c_str());
2577 
2578  std::string width = buffer.substr(pos+1, pos_key-pos-1);
2579 
2580  int w = 4; // The default rankwidth is 4, if width is empty
2581  if ( !width.empty()) {
2582  std::istringstream sin(width);
2583  sin >> w;
2584  }
2585 
2586  std::ostringstream sout;
2587 
2588  switch( buffer[pos_key]) {
2589  case 'p': {
2590  // If myRank<0, then match the rank with any integer of width w
2591  if ( myRank<0)
2592  for ( int i=0; i<w; ++i) sout << "[0-9]";
2593  else
2594  sout << std::setfill('0') << std::setw(w) << myRank;
2595 
2596  break;
2597  }
2598  case 'i':
2599  case 'b': {
2600  // TODO: Use the mapping rule on the next line to distribute files.
2601  // For now, have all processes read all files that match the number
2602  // of digits for the block or pane ID in the filenames.
2603  for ( int i=0; i<w; ++i) sout << "[0-9]";
2604  break;
2605  }
2606  default:
2607  COM_assertion_msg( false, (std::string("Unknown keyword in file name ")+buffer).c_str());
2608  }
2609 
2610  buffer.replace(pos, pos_key - pos + 1, sout.str());
2611  }
2612 
2613  // Determine whether buffer has directory part. If not, prepend that
2614  // of the control file. If so, then use it as is.
2615  if ( !dir_name.empty()) {
2616 /*
2617  std::string::size_type pos = buffer.find_last_of('/');
2618  if ( pos == std::string::npos) buffer.insert(0, dir_name);
2619 */
2620  // when it is not absolute path and does not have same prefix
2621  if (buffer[0] != '/' &&
2622  strncmp(buffer.c_str(), dir_name.c_str(), std::min(buffer.size(), dir_name.size()))) buffer.insert(0, dir_name);
2623  }
2624 
2625  // Insert buffer into patterns.
2626  local_patterns.push_back(buffer);
2627 
2628  fin >> buffer;
2629  }
2630 
2631  // The @Panes section may not be present
2632  if (buffer == "@Proc:") {
2633  patterns.insert(patterns.end(), local_patterns.begin(),
2634  local_patterns.end());
2635  continue;
2636  }
2637 
2638  m_base = 0;
2639  m_offset = 0;
2640  m_is_local = NULL;
2641 
2642  if ( !fin.eof())
2643  fin >> buffer;
2644  else
2645  buffer = "-1";
2646 
2647  // Read in panes.
2648  if (buffer == "@Cyclic") {
2649  fin >> m_offset;
2651  } else if (buffer == "@BlockCyclic") {
2652  fin >> m_base;
2653  fin >> m_offset;
2655  } else if (buffer == "@Block" || buffer == "@BlockBlockCyclic") {
2656  int block;
2657  fin >> block;
2658  fin >> m_base;
2659  fin >> m_offset;
2660  int quot = block/comm_size, rem = block-quot*comm_size;
2661  if ( rank < rem) {
2662  m_base *= quot+1;
2663  }
2664  else {
2665  m_offset += rem;
2666  m_base *= quot;
2667  }
2669  } else if (buffer == "@All" || buffer == "*") {
2670  m_is_local = NULL;
2671  } else if (buffer[0] == '@' && buffer != "@Panes:" ) {
2672  if ( buffer != "@Proc:") { // Skip empty @Panes section.
2673  std::cerr << "Rocstar: Error (read_by_control_file): in control file "
2674  << control_file_name << ": expected pane info but found '"
2675  << buffer << '\'' << std::endl;
2676  return;
2677  } else {
2678  // ignore file when no pane
2679  local_patterns.clear();
2680  }
2681  } else {
2683 
2684  for (;;) {
2685  if (buffer[0] < '0' || buffer[0] > '9')
2686  break;
2687 
2688  std::istringstream sin(buffer);
2689  int p=-1;
2690 
2691  sin >> p;
2692 
2693  if ( p>=0) {
2694  m_pane_ids.insert(p);
2695  } else {
2696  break;
2697  }
2698 
2699  if (!fin.eof()) fin >> buffer;
2700  else break;
2701  }
2702  }
2703 
2704  patterns.insert(patterns.end(), local_patterns.begin(),
2705  local_patterns.end());
2706 
2707  if ( myRank >= 0 && rank == myRank) break;
2708  }
2709  fin.close();
2710 
2711  if ( myRank>=0 && rank != myRank)
2712  std::cerr << "Rocstar: Warning: Did not find matching control blocks for process " << myRank << std::endl;
2713 
2714  // If myRank is a wild card and panes aren't specified explicitly, then
2715  // make all panes local.
2716  if (myRank < 0 && m_is_local != &Rocin::explicit_local)
2717  m_is_local = NULL;
2718 
2719  // Convert the patterns into a single string
2720  std::string files;
2721  std::vector<std::string>::const_iterator p;
2722  for (p=patterns.begin(); p!=patterns.end(); ++p)
2723  files = files+" "+(*p).c_str();
2724 
2725  // Invoke read_window
2726  //std::cout << __FILE__ << __LINE__ << " files = " << files << std::endl;
2727  read_window(files.c_str(), window_name, myComm, NULL, time_level, str_len);
2728 
2729  m_pane_ids.clear();
2730  m_offset = 0;
2731  m_base = 0;
2732  m_is_local = NULL;
2733 }
void blockcyclic_local(const int &pid, const int &comm_rank, const int &comm_size, int *il)
Definition: Rocin.C:2458
#define COM_assertion_msg(EX, msg)
void read_window(const char *filename_patterns, const char *window_name, const MPI_Comm *comm=NULL, RulesPtr is_local=NULL, char *time_level=NULL, const int *str_len=NULL)
Create a single Roccom window by reading in a list of files.
Definition: Rocin.C:2750
int m_base
Definition: Rocin.h:243
std::set< int > m_pane_ids
Definition: Rocin.h:242
void cyclic_local(const int &pid, const int &comm_rank, const int &comm_size, int *il)
Definition: Rocin.C:2452
Definition: adj.h:203
NT & sin
blockLoc i
Definition: read.cpp:79
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:346
void explicit_local(const int &pid, const int &comm_rank, const int &comm_size, int *il)
Definition: Rocin.C:2446
static int rank
Definition: advectest.C:66
int COMMPI_Initialized()
Definition: commpi.h:168
MPI_Comm COM_get_default_communicator()
Definition: roccom_c++.h:69
MemberRulePtr m_is_local
Definition: Rocin.h:241
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation ** files(the"Software")
int m_offset
Definition: Rocin.h:244

Here is the call graph for this function:

Here is the caller graph for this function:

void read_parameter_file ( const char *  file_name,
const char *  window_name,
const MPI_Comm *  comm = NULL 
)

Read in parameters from a given file into the given window.

If the window exists, then only read in the values for the attributes which exist in the window. If not, then create the window and define all options as window attributes of base type of character strings. Process 0 of the communicator should read in the parameters, and then broadcast to all the processes. If comm is not specified, then use the communicator of the window as default. If an option is listed more than once in the parameter_file, then the last value for that option will overwrite the others.

Parameters
file_namethe file containing the parameters to be read in.
window_namewindow where parameters will be placed
commThe MPI communicator for parameter broadcast. If NULL, then the communicator of window_name will be used.

Definition at line 40 of file read_parameter_file.C.

References cimg_library::cimg::atof(), COM_assertion_msg, COM_BOOL, COM_CHAR, COM_DOUBLE, COM_DOUBLE_PRECISION, COM_FLOAT, COM_get_roccom(), COM_get_window_handle(), COM_INT, COM_INTEGER, COM_new_attribute(), COM_new_window(), COM_REAL, COM_resize_array(), COM_set_size(), COM_UNSIGNED, COM_window_init_done(), get_parameter_list(), i, and ni.

Referenced by init().

42  {
43 
44  // vector of (option,value) pairs
45  std::vector<std::pair<std::string,std::string> > param_list;
46  get_parameter_list(param_list, file_name);
47 
48  // Check to see if the window exists
49  // Roccom_base * rcom= COM_get_roccom();
50  COM::Roccom_base * rbase = COM_get_roccom();
51  int whandle = COM_get_window_handle(window_name);
52  COM::Window* param_window = NULL;
53  if(whandle >0)
54  param_window = rbase->get_window_object(whandle);
55  COM::Attribute* param_att = NULL;
56 
57  // if the parameter window already exists, then only read
58  // in attributes which exist in the window
59  if(param_window){
60  for(uint i =0, ni = param_list.size(); i<ni; ++i){
61 
62  param_att = param_window->attribute(param_list[i].first);
63 
64  if (param_att) {
65  COM_assertion_msg( param_att->location()=='w' &&
66  param_att->size_of_components()==1,
67  "The attribute must be a windowed scalar attribute.");
68  // Obtain address for the current attribute.
69  void *addr = param_att->pointer();
70  COM_assertion_msg( addr, "Unexpected null pointer");
71 
72  // Map value based on its type.
73  switch ( param_att->data_type()) {
74  case COM_INTEGER:
75  case COM_UNSIGNED:
76  case COM_INT: {
77  *(int*)addr = std::atoi( param_list[i].second.c_str());
78  break;
79  }
81  case COM_DOUBLE: {
82  // replace 'd' or 'D' by 'e'
83  char *p = const_cast< char* >( strpbrk(param_list[i].second.c_str(), "dD") );
84  if (p) *p = 'e';
85  *(double*)addr = std::atof( param_list[i].second.c_str());
86  break;
87  }
88  case COM_FLOAT:
89  case COM_REAL: {
90  char *p = const_cast< char* >( strpbrk(param_list[i].second.c_str(), "dD") );
91  if (p) *p = 'e';
92  *(float*)addr = std::atof( param_list[i].second.c_str());
93  break;
94  }
95  case COM_CHAR: {
96  int param_size = param_list[i].second.size();
97  COM_assertion_msg( param_size<param_att->size_of_items(),
98  "Attribute does not have enough space");
99 
100  strcpy( (char*)addr, param_list[i].second.c_str());
101  break;
102  }
103  case COM_BOOL: {
104  int param_size = param_list[i].second.size();
105  const char *str = param_list[i].second.c_str();
106  char val = str[0];
107  if (val == 'T') val = 1;
108  if (val == 'F') val = 0;
109  if (val == 'Y') val = 1;
110  if (val == 'N') val = 0;
111  if (val == '1') val = 1;
112  if (val == '0') val = 0;
113  COM_assertion_msg((val == 1 || val==0),
114  "Invalid boolean value (T or F)");
115 
116  *(char *)addr = val;
117  break;
118  }
119  default:
120  COM_assertion_msg(false, "Unsupported data type.");
121  }
122  }
123  }
124  }
125  // if the parameter window doesn't exist, then create it
126  // and populate it will all of the option value pairs
127  else{
128  if(param_comm)
129  COM_new_window(window_name, *param_comm);
130  else
131  COM_new_window(window_name);
132  std::string wname(window_name);
133  for(uint i =0, ni = param_list.size(); i<ni; ++i){
134  COM_new_attribute( (wname+"."+param_list[i].first).c_str(),
135  'w', COM_CHAR, 1, "");
136  int param_size = param_list[i].second.size();
137  COM_set_size( (wname+"."+param_list[i].first).c_str(),
138  0, param_size+1,0);
139  void *addr;
140  COM_resize_array( (wname+"."+param_list[i].first).c_str(), 0, &addr);
141  strcpy( (char*)addr, param_list[i].second.c_str());
142  }
143  // Create an empty pane so that the window will be written out by Rocout
144  COM_set_size((wname+".nc").c_str(),1,0);
145  COM_window_init_done(window_name);
146  }
147 }
#define COM_assertion_msg(EX, msg)
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
void get_parameter_list(std::vector< std::pair< std::string, std::string > > &param_list, const char *file_name)
C/C++ Data types.
Definition: roccom_basic.h:129
float atof(const char *const str)
Read a float number from a C-string.
Definition: CImg.h:4905
blockLoc i
Definition: read.cpp:79
void COM_window_init_done(const char *w_str, int pane_changed=true)
Definition: roccom_c++.h:102
void COM_new_window(const char *wname, MPI_Comm c=MPI_COMM_NULL)
Definition: roccom_c++.h:86
int COM_get_window_handle(const char *wname)
Definition: roccom_c++.h:404
void int int REAL REAL REAL *z blockDim dim * ni
Definition: read.cpp:77
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
COM_END_NAME_SPACE COM::Roccom_base * COM_get_roccom()
Definition: Roccom_base.h:537
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 read_window ( const char *  filename_patterns,
const char *  window_name,
const MPI_Comm *  comm = NULL,
RulesPtr  is_local = NULL,
char *  time_level = NULL,
const int *  str_len = NULL 
)

Create a single Roccom window by reading in a list of files.

Read in metadata from files, and optionally read in array data as well.

Parameters
filename_patternsspecifies the patterns of the files to be read in. Patterns take the form of regular expressions in the same format as the shell commands use. Separate multiple patterns with empty space.
window_namethe name of the window to be created.
commThe MPI communicator to use. If is NULL, the default communicator of Roccom will be used.
is_locala function pointer which determines wheter a pane should be read by a process.
time_levelthe time stamp of the dataset to be read. If time level is NULL (default) or "", then the first time_level in the file will be assumed.
str_lenif present and positive, the time stamp of the dataset will be copied to the time_level string.
filename_patternsSpecifies patterns (reg. expressions) of files to be read in.
window_nameSpecifies a name of the window to be created.
commThe MPI communicator to use. If is NULL, the default communicator of Roccom will be used.
is_localA function pointer, which determines wheter a pane should be read by a process.
time_levelthe time stamp of the dataset to be read. If time level is NULL (default) or "", then the first time_level in the file will be used.
str_lenif present and positive, the time stamp of the dataset will be copied to the time_level string.

Definition at line 2750 of file Rocin.C.

References read_windows().

Referenced by init(), and read_by_control_file().

2756 {
2757  read_windows( filename_patterns, window_name, "", comm, is_local,
2758  time_level, str_len);
2759 }
void read_windows(const char *filename_patterns, const char *window_prefix, const char *material_names=NULL, const MPI_Comm *comm=NULL, RulesPtr is_local=NULL, char *time_level=NULL, const int *str_len=NULL)
Create a series of Roccom windows by reading in a list of files.
Definition: Rocin.C:2786
bool is_local(int pid, int comm_rank, int comm_size)

Here is the call graph for this function:

Here is the caller graph for this function:

void read_windows ( const char *  filename_patterns,
const char *  window_prefix,
const char *  material_names = NULL,
const MPI_Comm *  comm = NULL,
RulesPtr  is_local = NULL,
char *  time_level = NULL,
const int *  str_len = NULL 
)

Create a series of Roccom windows by reading in a list of files.

Read in metadata from files, and optionally read in array data as well Read in metadata from files, and optionally read in array data as well.

Parameters
filename_patternsspecifies the patterns of the files to be read in. Patterns take the form of regular expressions in the same format as the shell commands use. Separate multiple patterns with empty space.
window_prefixa prefix of the name(s) of the window(s) to be created. Actual window name is appended by a material name and there can be multiple materials per file.
material_namesa list of space-separated materials to be read from files. If material name is NULL (default), then "" will be used and it is assumed that files contain only one type of material.
commThe MPI communicator to use. If is NULL, the default communicator of Roccom will be used.
is_locala function pointer which determines wheter a pane should be read by a process.
time_levelthe time stamp of the dataset to be read. If time level is NULL (default) or "", then the first time_level in the file will be assumed.
str_lenif present and positive, the time stamp of the dataset will be copied to the time_level string.
filename_patternsSpecifies patterns (reg. expressions) of files to be read in.
window_prefixSpecifies a prefix of the name(s) of the window(s) to be created.
material_namesSpcifies a space-delimited list of materials to be read from the files.
commThe MPI communicator to use. If is NULL, the default communicator of Roccom will be used.
is_localA function pointer, which determines wheter a pane should be read by a process.
time_levelthe time stamp of the dataset to be read. If time level is NULL (default) or "", then the first time_level in the file will be used.
str_lenif present and positive, the time stamp of the dataset will be copied to the time_level string.

Definition at line 2786 of file Rocin.C.

References broadcast_win_attributes(), cast_err_func(), COM_get_default_communicator(), COM_new_window(), COM_window_init_done(), COMMPI_Initialized(), CWD(), DEBUG_MSG, free_blocks(), glob_error(), load_data_HDF4(), m_HDF2COM, new_attributes(), rank, register_panes(), scan_files_HDF4(), cimg_library::cimg::time(), and x.

Referenced by init(), and read_window().

2793 {
2794  //std::cout << __FILE__ << __LINE__
2795  // << " filename_patterns = " << filename_patterns
2796  // << std::endl;
2797  const MPI_Comm default_comm=COM_get_default_communicator();
2798  const MPI_Comm comm_null=MPI_COMM_NULL;
2799  const MPI_Comm* myComm =
2800  COMMPI_Initialized()? (comm ? comm : &default_comm ) : &comm_null;
2801 
2802  int rank, nprocs;
2803  if ( *myComm != MPI_COMM_NULL) {
2804  MPI_Comm_rank(*myComm, &rank);
2805  MPI_Comm_size(*myComm, &nprocs);
2806  }
2807  else {
2808  rank = 0; nprocs=1;
2809  }
2810 
2811  DEBUG_MSG("time_level == " << (time_level == NULL ? "<Null>" : time_level));
2812  std::string time( time_level?time_level:"");
2813  DEBUG_MSG("time == " << time);
2814 
2815  std::set<std::string> materials;
2816  char* buffer;
2817  char* token;
2818 
2819  // Insert list of material names into materials.
2820  if (material_names != NULL) {
2821  buffer = new char[strlen(material_names)+1];
2822  strcpy(buffer, material_names);
2823 
2824  token = strtok(buffer, " \t\n");
2825  while (token != NULL) {
2826  materials.insert(token);
2827  token = strtok(NULL, " \t\n");
2828  }
2829  delete[] buffer;
2830  }
2831 
2832  buffer = new char[strlen(filename_patterns)+1];
2833  strcpy(buffer, filename_patterns);
2834 
2835  BlockMM_HDF4 blocks_HDF4;
2836 #ifdef USE_CGNS
2837  BlockMM_CGNS blocks_CGNS;
2838 #endif // USE_CGNS
2839 
2840  token = strtok(buffer, " \t\n");
2841  if (token != NULL) {
2842 #ifndef _NO_GLOB_
2843  glob_t globbuf;
2844 
2845  glob(token, 0, cast_err_func(glob,glob_error), &globbuf);
2846  token = strtok(NULL, " \t\n");
2847  while (token != NULL) {
2848  glob(token, GLOB_APPEND, cast_err_func(glob,glob_error), &globbuf);
2849  token = strtok(NULL, " \t\n");
2850  }
2851 
2852  if ( globbuf.gl_pathc==0 && buffer[0]!='\0')
2853  std::cerr << "Rocstar: Warning: Found no matching files for pattern "
2854  << buffer << std::endl;
2855 
2856  // Extracts metadata from a list of files.
2857  // Opens each file, scans dataset, identifies windows, panes, and attribute
2858  // Puts this information into blocks.
2859  // MS
2860  //std::cout << __FILE__ << __LINE__
2861  // << "gl_pathv = " << globbuf.gl_pathv[0]
2862  // << std::endl;
2863  // search for hdf or cgns
2864  bool isHDF = false;
2865  bool isCGNS = false;
2866  if ((std::string(globbuf.gl_pathv[0])).find(".hdf") != std::string::npos){
2867  isHDF = true;
2868  std::cout << "npos = " << (std::string(globbuf.gl_pathv[0])).find(".hdf") <<std::endl;
2869  }
2870  isCGNS = isHDF ? false:true;
2871  //std::cout << "isHdf = " << isHDF << " isCGNS = " << isCGNS << std::endl;
2872  // MS End
2873  if (isHDF){
2874  scan_files_HDF4(globbuf.gl_pathc, globbuf.gl_pathv, blocks_HDF4, time,
2875  m_HDF2COM);
2876  //std::cout << "Read HDF!" << std::endl;
2877  } else {
2878 #ifdef USE_CGNS
2879  scan_files_CGNS(globbuf.gl_pathc, globbuf.gl_pathv, blocks_CGNS, time,
2880  m_CGNS2COM);
2881  //std::cout << "Read CGNS!" << std::endl;
2882 #endif
2883  }
2884 // Original
2885 //#ifndef USE_CGNS
2886 // scan_files_HDF4(globbuf.gl_pathc, globbuf.gl_pathv, blocks_HDF4, time,
2887 // m_HDF2COM);
2888 //#else
2889 // scan_files_CGNS(globbuf.gl_pathc, globbuf.gl_pathv, blocks_CGNS, time,
2890 // m_CGNS2COM);
2891 //#endif
2892 // Original End
2893  globfree(&globbuf);
2894 #else // No glob function on this system
2895  // Create a char** of n filenames matching patterns stored in buffer
2896  // each token is a new pattern
2897  std::list<std::string> matching_filenames;
2898  while (token != NULL) {
2899  std::string dirname(CWD());
2900  std::string tstring(token);
2901  std::string::size_type x = tstring.find_last_of("/");
2902  if(x != std::string::npos){
2903  dirname += ("/" + tstring.substr(0,x));
2904  tstring.erase(0,x+1);
2905  }
2906  Directory directory(dirname);
2907  if(directory){
2908  Directory::iterator di = directory.begin();
2909  while(di != directory.end()){
2910  if(!fnmatch(tstring.c_str(),di->c_str(),0))
2911  matching_filenames.push_back(dirname + "/" + *di);
2912  di++;
2913  }
2914  }
2915  token = strtok(NULL, " \t\n");
2916  }
2917  if(matching_filenames.empty() && buffer[0] != '\0')
2918  std::cerr << "Rocstar: Warning: Found no matching files for pattern "
2919  << buffer << std::endl;
2920  unsigned int nmatch = matching_filenames.size();
2921  std::vector<char *> matches(nmatch);
2922  std::list<std::string>::iterator li = matching_filenames.begin();
2923  unsigned int ccount = 0;
2924  while(li != matching_filenames.end()){
2925  unsigned int lis = li->size();
2926  matches[ccount++] = new char [lis+1];
2927  strcpy(matches[ccount-1],li->c_str());
2928  matches[ccount-1][lis] = '\0';
2929  li++;
2930  }
2931 #ifndef USE_CGNS
2932  scan_files_HDF4(nmatch, &matches[0], blocks_HDF4, time,
2933  m_HDF2COM);
2934 #else
2935  scan_files_CGNS(nmatch, &matches[0], blocks_CGNS, time,
2936  m_CGNS2COM);
2937 #endif
2938  ccount = 0;
2939  while(ccount < nmatch){
2940  if(matches[ccount])
2941  delete [] matches[ccount];
2942  ccount++;
2943  }
2944 #endif
2945  }
2946 
2947  delete[] buffer;
2948 
2949  // Copy out time level
2950  if ( time_level && str_len && *str_len) {
2951  // TODO: Run MPI_Allgather to send time level to those with no data
2952  // and check whether all processes obtained the same non-empty time level.
2953  std::strncpy( time_level, time.c_str(), *str_len-1);
2954  time_level[*str_len-1] = '\0';
2955  }
2956 
2957  std::string name;
2958  std::set<std::string>::iterator p = materials.begin();
2959  std::pair<BlockMM_HDF4::iterator, BlockMM_HDF4::iterator> range_HDF4;
2960 #ifdef USE_CGNS
2961  std::pair<BlockMM_CGNS::iterator, BlockMM_CGNS::iterator> range_CGNS;
2962 #endif // USE_CGNS
2963 
2964  if (materials.empty()) {
2965  // Default value of material_names is NULL
2966  // we assume the file only contains one type of material, and
2967  // the window name is the window_prefix.
2968  range_HDF4.first = blocks_HDF4.begin();
2969  range_HDF4.second = blocks_HDF4.end();
2970 #ifdef USE_CGNS
2971  range_CGNS.first = blocks_CGNS.begin();
2972  range_CGNS.second = blocks_CGNS.end();
2973 #endif // USE_CGNS
2974  name = window_prefix;
2975 
2976  COM_new_window(name.c_str(), *myComm);
2977 
2978  new_attributes( range_HDF4.first, range_HDF4.second,
2979 #ifdef USE_CGNS
2980  range_CGNS.first, range_CGNS.second,
2981 #endif // USE_CGNS
2982  name, myComm, rank, nprocs);
2983  register_panes( range_HDF4.first, range_HDF4.second,
2984 #ifdef USE_CGNS
2985  range_CGNS.first, range_CGNS.second,
2986 #endif // USE_CGNS
2987  name, is_local, myComm, rank, nprocs);
2988 
2989  load_data_HDF4(range_HDF4.first, range_HDF4.second,
2990  name, myComm, rank, nprocs);
2991 #ifdef USE_CGNS
2992  load_data_CGNS(range_CGNS.first, range_CGNS.second,
2993  name, myComm, rank, nprocs);
2994 #endif // USE_CGNS
2995 
2996  broadcast_win_attributes( range_HDF4.first == range_HDF4.second
2997 #ifdef USE_CGNS
2998  && range_CGNS.first == range_CGNS.second
2999 #endif // USE_CGNS
3000  , name, myComm, rank, nprocs);
3001 
3002  COM_window_init_done(name.c_str());
3003  } else {
3004 
3005  // Iterate through each material (one window per material).
3006  while (p != materials.end()) {
3007  if (blocks_HDF4.count(*p) == 0
3008 #ifdef USE_CGNS
3009  && blocks_CGNS.count(*p) == 0
3010 #endif // USE_CGNS
3011  ) {
3012  std::cerr << "Rocstar: Warning (read_windows): could not find '" << *p << "'."
3013  << std::endl;
3014  ++p; // Increment p.
3015  continue;
3016  }
3017 
3018  range_HDF4 = blocks_HDF4.equal_range(*p);
3019 #ifdef USE_CGNS
3020  range_CGNS = blocks_CGNS.equal_range(*p);
3021 #endif // USE_CGNS
3022  name = window_prefix + *p;
3023 
3024  COM_new_window(name.c_str(), *myComm);
3025 
3026  new_attributes( range_HDF4.first, range_HDF4.second,
3027 #ifdef USE_CGNS
3028  range_CGNS.first, range_CGNS.second,
3029 #endif // USE_CGNS
3030  name, myComm, rank, nprocs);
3031  register_panes( range_HDF4.first, range_HDF4.second,
3032 #ifdef USE_CGNS
3033  range_CGNS.first, range_CGNS.second,
3034 #endif // USE_CGNS
3035  name, is_local, myComm, rank, nprocs);
3036 
3037  load_data_HDF4(range_HDF4.first, range_HDF4.second,
3038  name, myComm, rank, nprocs);
3039 #ifdef USE_CGNS
3040  load_data_CGNS(range_CGNS.first, range_CGNS.second,
3041  name, myComm, rank, nprocs);
3042 #endif // USE_CGNS
3043 
3044  broadcast_win_attributes( range_HDF4.first == range_HDF4.second
3045 #ifdef USE_CGNS
3046  && range_CGNS.first == range_CGNS.second
3047 #endif // USE_CGNS
3048  , name, myComm, rank, nprocs);
3049 
3050  COM_window_init_done(name.c_str());
3051 
3052  ++p;
3053  }
3054  }
3055 
3056  // Free memory.
3057  free_blocks(blocks_HDF4);
3058 #ifdef USE_CGNS
3059  free_blocks(blocks_CGNS);
3060 #endif // USE_CGNS
3061 }
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)
Definition: Rocin.C:882
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)
Definition: Rocin.C:130
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.
Definition: Rocin.C:340
void register_panes(BlockMM_HDF4::iterator hdf4, const BlockMM_HDF4::iterator &hdf4End, const std::string &window, RulesPtr is_local, const MPI_Comm *comm, int rank, int nprocs)
Definition: Rocin.C:2200
static void broadcast_win_attributes(bool isEmpty, const std::string &window, const MPI_Comm *comm, int rank, int nprocs)
Definition: Rocin.C:2153
bool is_local(int pid, int comm_rank, int comm_size)
#define DEBUG_MSG(x)
Definition: Rocin.C:77
void int int REAL * x
Definition: read.cpp:74
void COM_window_init_done(const char *w_str, int pane_changed=true)
Definition: roccom_c++.h:102
void COM_new_window(const char *wname, MPI_Comm c=MPI_COMM_NULL)
Definition: roccom_c++.h:86
std::map< int32, COM_Type > m_HDF2COM
Definition: Rocin.h:246
std::string CWD()
Definition: Rocin.C:2762
void free_blocks(BLOCK &blocks)
Definition: Rocin.C:2342
std::multimap< std::string, Block_HDF4 * > BlockMM_HDF4
Definition: rocin_block.h:102
unsigned long time()
Get the value of a system timer with a millisecond precision.
Definition: CImg.h:4605
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)
Definition: Rocin.C:2032
static int rank
Definition: advectest.C:66
static int glob_error(const char *epath, int gerrno)
Error callback for glob.
Definition: Rocin.C:119
int COMMPI_Initialized()
Definition: commpi.h:168
MPI_Comm COM_get_default_communicator()
Definition: roccom_c++.h:69

Here is the call graph for this function:

Here is the caller graph for this function:

void register_panes ( BlockMM_HDF4::iterator  hdf4,
const BlockMM_HDF4::iterator &  hdf4End,
const std::string &  window,
RulesPtr  is_local,
const MPI_Comm *  comm,
int  rank,
int  nprocs 
)
protected

Definition at line 2200 of file Rocin.C.

References COM_DOUBLE, COM_new_attribute(), COM_set_array(), COM_set_size(), DEBUG_MSG, is_local(), Block_HDF4::m_gridInfo, m_is_local, Block_HDF4::m_numGhostNodes, Block_HDF4::m_numNodes, Block_HDF4::m_paneId, Block_HDF4::m_units, Block_HDF4::m_variables, and q.

Referenced by read_windows().

2208 {
2209  int local;
2210  std::string name;
2211  bool is_first=true;
2212  for ( ; hdf4!=hdf4End; ++hdf4) {
2213  Block_HDF4* block = (*hdf4).second;
2214 
2215  // Panes are a local construct, so make sure that this pane is local.
2216  if ( m_is_local)
2217  (this->*m_is_local)(block->m_paneId, rank, nprocs, &local);
2218  else if (is_local)
2219  is_local(block->m_paneId, rank, nprocs, &local);
2220  else
2221  local = 1;
2222 
2223  if (!local) continue;
2224 
2225  // Register the mesh unit & number of nodes
2226  name = window + ".nc";
2227  if (is_first && !block->m_units.empty()) {
2228 
2229  DEBUG_MSG("Calling COM_new_attribute( name == '" << name << "', position == 'n', datatype == COM_DOUBLE, nComp == 3, units == '" << block->m_units << "' )");
2230  COM_new_attribute(name.c_str(),'n',COM_DOUBLE,3,block->m_units.c_str());
2231  is_first = false;
2232  }
2233 
2234  DEBUG_MSG("Calling COM_set_size( name == '" << name << "', paneid == " << block->m_paneId << ", nitems == " << block->m_numNodes << ", nghost == " << block->m_numGhostNodes << " )");
2235  COM_set_size(name.c_str(), block->m_paneId,
2236  block->m_numNodes,block->m_numGhostNodes);
2237 
2238  // Register the connectivity tables or the mesh dimensions
2239  // need to specify attribute names for multiple connectivity tables
2240  if (block->m_gridInfo.size() &&
2241  block->m_gridInfo.front().m_name.substr(0,3) == ":st") {
2242  int mysize[3], ndim = block->m_gridInfo.front().m_name[3] - '0';
2243  mysize[0] = block->m_gridInfo.front().m_size[2];
2244  mysize[1] = block->m_gridInfo.front().m_size[1];
2245  mysize[2] = block->m_gridInfo.front().m_size[0];
2246  name = window + '.' + block->m_gridInfo.front().m_name;
2247 
2248  DEBUG_MSG("Calling COM_set_size( name == '" << name << "', paneid == " << block->m_paneId << ", nitems == " << ndim << ", nghost == " << block->m_gridInfo.front().m_numGhostElements << " )");
2249  COM_set_size(name.c_str(), block->m_paneId, ndim,
2250  block->m_gridInfo.front().m_numGhostElements);
2251  COM_set_array(name.c_str(),block->m_paneId,mysize);
2252  } else {
2253  std::vector<GridInfo_HDF4>::iterator q;
2254  for (q=block->m_gridInfo.begin(); q!=block->m_gridInfo.end(); ++q){
2255  name = window + "." + (*q).m_name;
2256  DEBUG_MSG("Calling COM_set_size( name == '" << name << "', paneid == " << block->m_paneId << ", nitems == " << (*q).m_numElements << ", nghost == " << (*q).m_numGhostElements << " )");
2257  COM_set_size(name.c_str(), block->m_paneId,
2258  (*q).m_numElements, (*q).m_numGhostElements);
2259  }
2260  }
2261 
2262  // Set sizes for pane attributes.
2263  std::vector<VarInfo_HDF4> &vars = block->m_variables;
2264  std::vector<VarInfo_HDF4>::const_iterator q;
2265 
2266  for ( q=vars.begin(); q!=vars.end(); ++q) {
2267  if ( (*q).m_position == 'p' || (*q).m_position == 'c') {
2268  name = window + "." + (*q).m_name;
2269  DEBUG_MSG("Calling COM_set_size( name == '" << name << "', paneid == " << block->m_paneId << ", nitems == " << (*q).m_nitems << ", nghost == " << (*q).m_ng << " )");
2270  COM_set_size( name.c_str(), block->m_paneId,
2271  (*q).m_nitems, (*q).m_ng);
2272  }
2273  }
2274  }
2275 
2276 #ifdef USE_CGNS
2277  for ( ; cgns!=cgnsEnd; ++cgns) {
2278  Block_CGNS* block = (*cgns).second;
2279 
2280  // Panes are a local construct, so make sure that this pane is local.
2281  if ( m_is_local)
2282  (this->*m_is_local)(block->m_paneId, rank, nprocs, &local);
2283  else if (is_local)
2284  is_local(block->m_paneId, rank, nprocs, &local);
2285  else
2286  local = 1;
2287 
2288  if (!local) continue;
2289 
2290  // Register the mesh unit & number of nodes
2291  name = window + ".nc";
2292  if (is_first && !block->m_units.empty()) {
2293 
2294  DEBUG_MSG("Calling COM_new_attribute( name == '" << name << "', position == 'n', datatype == COM_DOUBLE, nComp == 3, units == '" << block->m_units << "' )");
2295  COM_new_attribute(name.c_str(),'n',COM_DOUBLE,3,block->m_units.c_str());
2296  is_first = false;
2297  }
2298 
2299  DEBUG_MSG("Calling COM_set_size( name == '" << name << "', paneid == " << block->m_paneId << ", nitems == " << block->m_numNodes << ", nghost == " << block->m_numGhostNodes << " )");
2300  COM_set_size(name.c_str(), block->m_paneId,
2301  block->m_numNodes,block->m_numGhostNodes);
2302 
2303  // Register the connectivity tables or the mesh dimensions
2304  // need to specify attribute names for multiple connectivity tables
2305  if (block->m_gridInfo.size() &&
2306  block->m_gridInfo.front().m_name.substr(0,3) == ":st") {
2307  int ndim = block->m_gridInfo.front().m_name[3] - '0';
2308  name = window + '.' + block->m_gridInfo.front().m_name;
2309 
2310  DEBUG_MSG("Calling COM_set_size( name == '" << name << "', paneid == " << block->m_paneId << ", nitems == " << ndim << ", nghost == " << block->m_gridInfo.front().m_numGhostElements << " )");
2311  COM_set_size(name.c_str(), block->m_paneId, ndim,
2312  block->m_gridInfo.front().m_numGhostElements);
2313  COM_set_array(name.c_str(), block->m_paneId,
2314  block->m_gridInfo.front().m_size);
2315  } else {
2316  std::vector<GridInfo_CGNS>::iterator q;
2317  for (q=block->m_gridInfo.begin(); q!=block->m_gridInfo.end(); ++q){
2318  name = window + "." + (*q).m_name;
2319  DEBUG_MSG("Calling COM_set_size( name == '" << name << "', paneid == " << block->m_paneId << ", nitems == " << (*q).m_numElements << ", nghost == " << (*q).m_numGhostElements << " )");
2320  COM_set_size(name.c_str(), block->m_paneId,
2321  (*q).m_numElements, (*q).m_numGhostElements);
2322  }
2323  }
2324 
2325  // Set sizes for pane attributes.
2326  std::vector<VarInfo_CGNS> &vars = block->m_variables;
2327  std::vector<VarInfo_CGNS>::const_iterator q;
2328 
2329  for ( q=vars.begin(); q!=vars.end(); ++q) {
2330  if ( (*q).m_position == 'p' || (*q).m_position == 'c') {
2331  name = window + "." + (*q).m_name;
2332  DEBUG_MSG("Calling COM_set_size( name == '" << name << "', paneid == " << block->m_paneId << ", nitems == " << (*q).m_nitems << ", nghost == " << (*q).m_ng << " )");
2333  COM_set_size( name.c_str(), block->m_paneId,
2334  (*q).m_nitems, (*q).m_ng);
2335  }
2336  }
2337  }
2338 #endif // USE_CGNS
2339 }
int m_numGhostNodes
Number of ghost nodes in a mesh.
Definition: rocin_block.h:98
int m_numNodes
Number of nodes in the mesh.
Definition: rocin_block.h:97
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
Struct containing necessary information for a pane.
Definition: rocin_block.h:81
bool is_local(int pid, int comm_rank, int comm_size)
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
#define DEBUG_MSG(x)
Definition: Rocin.C:77
std::string m_units
The mesh&#39;s units of measurement.
Definition: rocin_block.h:96
void COM_set_array(const char *wa_str, int pane_id, void *addr, int strd=0, int cap=0)
Associates an array with an attribute for a specific pane.
Definition: roccom_c++.h:156
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
static int rank
Definition: advectest.C:66
std::vector< VarInfo_HDF4 > m_variables
Info on each variable.
Definition: rocin_block.h:100
MemberRulePtr m_is_local
Definition: Rocin.h:241

Here is the call graph for this function:

Here is the caller graph for this function:

Friends And Related Function Documentation

void Rocin_load_module ( const char *  name)
friend

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.

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
void Rocin_unload_module ( const char *  name)
friend

Unload the module Rocin from Roccom.

Definition at line 3066 of file Rocin.C.

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

Member Data Documentation

int m_base
protected

Definition at line 243 of file Rocin.h.

Referenced by blockcyclic_local(), and read_by_control_file().

std::map<int32, COM_Type> m_HDF2COM
protected

Definition at line 246 of file Rocin.h.

Referenced by init(), and read_windows().

MemberRulePtr m_is_local
protected

Definition at line 241 of file Rocin.h.

Referenced by read_by_control_file(), and register_panes().

int m_offset
protected

Definition at line 244 of file Rocin.h.

Referenced by blockcyclic_local(), cyclic_local(), and read_by_control_file().

std::set<int> m_pane_ids
protected

Definition at line 242 of file Rocin.h.

Referenced by explicit_local(), and read_by_control_file().


The documentation for this class was generated from the following files: