Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Rocout.h
Go to the documentation of this file.
1 /* *******************************************************************
2  * Rocstar Simulation Suite *
3  * Copyright@2015, Illinois Rocstar LLC. All rights reserved. *
4  * *
5  * Illinois Rocstar LLC *
6  * Champaign, IL *
7  * www.illinoisrocstar.com *
8  * sales@illinoisrocstar.com *
9  * *
10  * License: See LICENSE file in top level of distribution package or *
11  * http://opensource.org/licenses/NCSA *
12  *********************************************************************/
13 /* *******************************************************************
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
16  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
17  * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
20  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
21  * USE OR OTHER DEALINGS WITH THE SOFTWARE. *
22  *********************************************************************/
28 /* Author John Norris
29  * Initial date: May 17, 2004
30  */
31 
32 
33 #ifndef _ROCOUT_H_
34 #define _ROCOUT_H_
35 
36 #include <map>
37 #include "roccom.h"
38 #include "HDF4.h"
39 #include "roccom_devel.h"
40 
41 #ifdef USE_CGNS
42 #include "Rocout_cgns.h"
43 #define MODE_READ CG_MODE_READ
44 #define MODE_WRITE CG_MODE_WRITE
45 #define MODE_MODIFY CG_MODE_MODIFY
46 #endif // USE_CGNS
47 
64 void write_attr_CGNS(const std::string& fname, const std::string& mfile,
65  const COM::Attribute* attr, const char* material,
66  const char* timelevel, int pane_id,
67  const std::string& ghosthandle,
68  const std::string& errorhandle, int mode);
69 
73 extern "C" void Rocout_load_module( const char *name);
77 extern "C" void Rocout_unload_module( const char *name);
78 //\}
79 
80 
81 class Rocout : public COM_Object {
82  public:
97  void write_attribute( const char* filename_pre,
98  const COM::Attribute* attr,
99  const char* material,
100  const char* timelevel,
101  const char* mfile_pre=NULL,
102  const MPI_Comm* comm=NULL,
103  const int* pane_id=NULL);
104 
116  void put_attribute( const char* filename_pre,
117  const COM::Attribute* attr,
118  const char* material,
119  const char* timelevel,
120  const char* mfile_pre=NULL,
121  const MPI_Comm* comm=NULL,
122  const int* pane_id=NULL);
123 
135  void add_attribute( const char* filename_pre,
136  const COM::Attribute* attr,
137  const char* material,
138  const char* timelevel,
139  const char* mfile_pre=NULL,
140  const MPI_Comm* comm=NULL,
141  const int* pane_id=NULL);
142 
145  void sync();
146 
153  void write_rocin_control_file( const char* window_name,
154  const char* file_prefixes,
155  const char* control_file_name);
156 
163  void set_option( const char* option_name,
164  const char* option_val);
165 
177  void write_parameter_file( const char* file_name,
178  const char* window_name,
179  const MPI_Comm *comm = NULL);
180 
185  void read_control_file( const char* filename);
186  //\}
187 
188 protected:
197  static
198  void init(const std::string &mname);
199 
203  static
204  void finalize(const std::string &mname);
205  //\}
206 
210  friend void Rocout_load_module( const char *name);
211  friend void Rocout_unload_module( const char *name);
212  //\}
213 
221  static
222  void* write_attr_internal(void* attrInfo);
223 
231  std::string get_fname(const std::string& pre, int rank = -1,
232  const int paneId = 0, bool check = false);
233  //\}
234 
235  std::map<std::string, std::string> _options;
236 # ifdef USE_PTHREADS
237  std::vector<pthread_t> _writers;
238  static Semaphore _writesem;
239 # endif // USE_PTHREADS
240 };
241 
242 #endif
243 
244 
245 
246 
247 
248 
std::string get_fname(const std::string &pre, int rank=-1, const int paneId=0, bool check=false)
Builds a filename from the given prefix and rank.
Definition: Rocout.C:825
static void finalize(const std::string &mname)
Finalize the module by deregistering it from Roccom.
Definition: Rocout.C:213
void write_parameter_file(const char *file_name, const char *window_name, const MPI_Comm *comm=NULL)
Write out the parameters defined in the fiven window into a parameter file.
void set_option(const char *option_name, const char *option_val)
Set an option for Rocout, such as controlling the output format.
Definition: Rocout.C:552
void put_attribute(const char *filename_pre, const COM::Attribute *attr, const char *material, const char *timelevel, const char *mfile_pre=NULL, const MPI_Comm *comm=NULL, const int *pane_id=NULL)
Write a (possibly aggregate) attribute to a new file.
Definition: Rocout.C:286
Declaration of Rocout CGNS routines.
This file contains the prototypes for Roccom API.
static void * write_attr_internal(void *attrInfo)
Does the actual writing to file.
Definition: Rocout.C:670
Definition: Sync.h:65
void add_attribute(const char *filename_pre, const COM::Attribute *attr, const char *material, const char *timelevel, const char *mfile_pre=NULL, const MPI_Comm *comm=NULL, const int *pane_id=NULL)
Append a (possibly aggregate) attribute to a file.
Definition: Rocout.C:329
void write_attr_CGNS(const std::string &fname, const std::string &mfile, const COM::Attribute *attr, const char *material, const char *timelevel, int pane_id, const std::string &ghosthandle, const std::string &errorhandle, int mode)
Write the data for the given attribute to file.
Definition: Rocout_cgns.C:884
void write_attribute(const char *filename_pre, const COM::Attribute *attr, const char *material, const char *timelevel, const char *mfile_pre=NULL, const MPI_Comm *comm=NULL, const int *pane_id=NULL)
Write a (possibly aggregate) attribute to a file.
Definition: Rocout.C:246
void sync()
Wait for the completion of an asychronous write operation.
Definition: Rocout.C:491
Definition: Rocout.h:81
std::map< std::string, std::string > _options
Definition: Rocout.h:235
static void init(const std::string &mname)
Initialize the module by registering it to Roccom with the given module name.
Definition: Rocout.C:139
void write_rocin_control_file(const char *window_name, const char *file_prefixes, const char *control_file_name)
Generate a control file for Rocin.
Definition: Rocout.C:361
void Rocout_load_module(const char *name)
Load the module Rocout into Roccom using the given module name.
Definition: Rocout.C:934
friend void Rocout_load_module(const char *name)
Load the module Rocout into Roccom using the given module name.
Definition: Rocout.C:934
static int rank
Definition: advectest.C:66
friend void Rocout_unload_module(const char *name)
Unload the module Rocout from Roccom.
Definition: Rocout.C:937
void read_control_file(const char *filename)
Set options for Rocout via a control file.
Definition: Rocout.C:580
void Rocout_unload_module(const char *name)
Unload the module Rocout from Roccom.
Definition: Rocout.C:937