Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Rocout/test/param_test.C
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  *********************************************************************/
23 // $Id: param_test.C,v 1.5 2008/12/06 08:43:23 mtcampbe Exp $
24 // $Author: mtcampbe $
25 // $Date: 2008/12/06 08:43:23 $
26 
27 // $Log: param_test.C,v $
28 // Revision 1.5 2008/12/06 08:43:23 mtcampbe
29 // Updated license.
30 //
31 // Revision 1.4 2008/11/19 22:16:38 mtcampbe
32 // Added Illinois Open Source License/Copyright
33 //
34 // Revision 1.3 2005/06/18 22:26:10 jiao
35 // Fixed bug in casting char*
36 //
37 // Revision 1.2 2004/11/08 16:38:34 palexand
38 // Added a constant, WINDOW_EXISTS, to make it easier to switch between the
39 // case where the parameter window exists prior to calling
40 // Rocin::read_parameter_file, and the case where the parameter window doesn't
41 // exist.
42 //
43 // Revision 1.1 2004/11/04 20:03:31 palexand
44 // Initial versions. Supports Rocout::write_parameter_file(...) in serial.
45 //
46 // Revision 1.1 2004/11/03 20:12:45 palexand
47 // Initial versions.
48 //
49 
55 // Set WINDOW_EXISTS to 1 to test behavior if the parameter
56 // window exists prior to calling Rocin::read_parameter_file.
57 // Doing so will register a window with one attribute of
58 // the correct parameter format, "burnrate", and all other
59 // parameters in the parameter file will be discarded.
60 // If WINDOW_EXISTS is set to 0, then no parameter window
61 // will exist prior to calling Rocin::read_parameter_file,
62 // so all correctly formatted (option,value) pairs are registered.
63 #define WINDOW_EXISTS 0
64 
65 #include "Rocin.h"
66 #include "Rocout.h"
67 #include "Roccom_base.h"
68 #include "roccom.h"
69 #include "roccom_devel.h"
70 
71 #include <iostream>
72 #include <cstring>
73 #include <string>
74 
77 
78 using namespace std;
79 
80 int main(int argc, char *argv[]) {
81  COM_init( &argc, &argv);
82 
83  if ( argc < 3 || argc > 3 ) {
84  std::cout << "Usage: To test in serial: \n\t" << argv[0]
85  << " <parameter file in> <parameter file out>\n"
86  << std::endl;
87  exit(-1);
88  }
89 
90  const char *FILE_in = argv[1];
91  const char *FILE_out = argv[2];
92  const string winname("parameters");
93  //const string winname(argv[2]);
94 
96  //COM_set_verbose(10);
97 
100  int IN_param = COM_get_function_handle( "IN.read_parameter_file");
101  int OUT_param = COM_get_function_handle( "OUT.write_parameter_file");
102 
103  //===== Add some non parameter formatted attributes to the window
104  // a parameter formatted attribute is a windowed COM_CHAR attribute
105  // with 1 component
106  void* addr;
107 
108  if(WINDOW_EXISTS){
109  COM_new_window(winname.c_str());
110  COM_new_attribute( (winname+"."+"burnrate").c_str(),'w',COM_CHAR,1,"");
111  COM_set_size( (winname+"."+"burnrate").c_str(),0,6,0);
112  COM_resize_array( (winname+"."+"burnrate").c_str(),0,&addr);
113  ((char*&)addr) = "three";
114 
115  COM_new_attribute( (winname+"."+"notwindowed").c_str(),'p',COM_CHAR,1,"");
116  COM_set_size( (winname+"."+"notwindowed").c_str(),0,12,0);
117  COM_resize_array( (winname+"."+"notwindowed").c_str(),0,&addr);
118  ((char*&)addr) = "notwindowed";
119 
120  COM_new_attribute( (winname+"."+"wrongtype").c_str(),'w',COM_INT,1,"");
121  COM_set_size( (winname+"."+"wrongtype").c_str(),0,1,0);
122  COM_resize_array( (winname+"."+"wrongtype").c_str(),0,&addr);
123  ((int*&)addr)[1] = 1;
124 
125  COM_new_attribute( (winname+"."+"toomanycomps").c_str(),'w',COM_CHAR,2,"");
126  COM_set_size( (winname+"."+"toomanycomps").c_str(),0,13,0);
127  COM_resize_array( (winname+"."+"toomanycomps").c_str(),0,&addr);
128  ((char*&)addr) = "toomanycomps";
129 
130  COM_window_init_done(winname.c_str());
131  }
132 
133  //===== Read in parameter file using Rocin
134  COM_call_function(IN_param, FILE_in, (winname).c_str());
135 
136  //===== Write out using Rocout
137  COM_call_function( OUT_param, FILE_out, (winname).c_str());
138 
139  COM_print_profile("", "");
140  COM_finalize();
141 }
142 
143 
144 
145 
146 
147 
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
This file contains the prototypes for Roccom API.
C/C++ Data types.
Definition: roccom_basic.h:129
Rocout creates a series of Roccom windows by reading in a list of files.
void COM_finalize()
Definition: roccom_c++.h:59
void COM_print_profile(const char *fname, const char *header)
Definition: roccom_c++.h:557
Definition: Rocin.h:64
Definition: Rocout.h:81
void COM_window_init_done(const char *w_str, int pane_changed=true)
Definition: roccom_c++.h:102
#define WINDOW_EXISTS
A test program that reads in a given parameter file using Rocin and writes out the resulting paramete...
void COM_new_window(const char *wname, MPI_Comm c=MPI_COMM_NULL)
Definition: roccom_c++.h:86
void COM_set_profiling(int i)
Definition: roccom_c++.h:550
void COM_call_function(const int wf, int argc,...)
Definition: roccom_c.C:48
Rocin creates a series of Roccom windows by reading in a list of files.
int main(int argc, char *argv[])
Definition: blastest.C:94
void COM_init(int *argc, char ***argv)
Definition: roccom_c++.h:57
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
#define COM_LOAD_MODULE_STATIC_DYNAMIC(moduleName, windowString)
Definition: roccom_basic.h:111
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_function_handle(const char *wfname)
Definition: roccom_c++.h:428
#define COM_EXTERN_MODULE(moduleName)
Definition: roccom_basic.h:116
Contains declaration of the base class for Roccom implementations.