38 const char* file_name);
41 const char* window_name,
42 const MPI_Comm *param_comm){
45 std::vector<std::pair<std::string,std::string> > param_list;
52 COM::Window* param_window = NULL;
54 param_window = rbase->get_window_object(whandle);
55 COM::Attribute* param_att = NULL;
60 for(uint
i =0,
ni = param_list.size();
i<
ni; ++
i){
62 param_att = param_window->attribute(param_list[
i].first);
66 param_att->size_of_components()==1,
67 "The attribute must be a windowed scalar attribute.");
69 void *addr = param_att->pointer();
73 switch ( param_att->data_type()) {
77 *(
int*)addr = std::atoi( param_list[
i].second.c_str());
83 char *p =
const_cast< char*
>( strpbrk(param_list[
i].second.c_str(),
"dD") );
85 *(
double*)addr =
std::atof( param_list[
i].second.c_str());
90 char *p =
const_cast< char*
>( strpbrk(param_list[
i].second.c_str(),
"dD") );
92 *(
float*)addr =
std::atof( param_list[
i].second.c_str());
96 int param_size = param_list[
i].second.size();
98 "Attribute does not have enough space");
100 strcpy( (
char*)addr, param_list[
i].second.c_str());
104 int param_size = param_list[
i].second.size();
105 const char *str = param_list[
i].second.c_str();
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;
114 "Invalid boolean value (T or F)");
132 std::string wname(window_name);
133 for(uint
i =0,
ni = param_list.size();
i<
ni; ++
i){
136 int param_size = param_list[
i].second.size();
141 strcpy( (
char*)addr, param_list[
i].second.c_str());
150 for(
int i=start,
ni=str.size();
i<
ni&&str[
i]!=c; ++
i){
151 if(str[
i] ==
' ' || str[
i] ==
'\t'){
159 const char* file_name){
162 std::ifstream param_file(file_name);
164 "Specified parameter file not found.");
166 string cur_line,
option, value;
167 string::size_type cur_pos;
169 while (getline(param_file,cur_line)){
171 cur_pos = cur_line.find(
'#');
172 if(cur_pos != string::npos)
173 cur_line.erase(cur_pos, cur_line.size()-cur_pos);
180 if(cur_line.size()==0)
184 cur_pos = cur_line.find_first_of(
"=");
186 (std::string(
"Parameter file '")
187 + file_name +
"' has an invalid line.").c_str());
189 option.assign(cur_line,0,cur_pos);
190 value.assign(cur_line,cur_pos+1,string::npos);
197 cur_pos = value.find(
'"');
198 if(cur_pos != string::npos){
200 "Parameter file has invalid value format");
202 cur_pos = value.rfind(
'"');
206 "Parameter file has invalid value format");
207 value.erase(cur_pos,1);
209 "Parameter file has invalid value format");
213 cur_pos = option.find_first_of(
"\"");
215 "Unexpected quotation mark found in an option.");
217 param_list.push_back(std::make_pair(option,value));
Contains the wrapper routines for C++ binding of Roccom API.
const char * option(const char *const name, const int argc, const char *const *const argv, const char *defaut, const char *const usage=0)
#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.
void get_parameter_list(std::vector< std::pair< std::string, std::string > > ¶m_list, const char *file_name)
float atof(const char *const str)
Read a float number from a C-string.
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.
void eat_whitespace_until(std::string &str, const char &c, int start=0)
void COM_window_init_done(const char *w_str, int pane_changed=true)
void COM_new_window(const char *wname, MPI_Comm c=MPI_COMM_NULL)
Rocin creates a series of Roccom windows by reading in a list of files.
int COM_get_window_handle(const char *wname)
void int int REAL REAL REAL *z blockDim dim * ni
void COM_new_attribute(const char *wa_str, const char loc, const int type, int ncomp, const char *unit)
Registering an attribute type.
COM_END_NAME_SPACE COM::Roccom_base * COM_get_roccom()
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.