bool json_parse_sprinkler_configuration(const char* json_buffer, Sprinkler* sprinkler) { int current_token_index; TokenVector *tokens = token_vector_new(); jsmntok_t* current_token; size_t number_of_tokens; bool ret = true; // Parse json string if (!json_parse(json_buffer, tokens)) { add_to_log("json_parse_sprinkler_configuration: Could not parse json.", ERROR); token_vector_destroy(tokens); return false; } current_token = token_vector_get_pointer(tokens, 0); number_of_tokens = current_token->size; if (number_of_tokens <= 0 || current_token->type != JSMN_OBJECT) { add_to_log("json_parse_sprinkler_configuration: Could not parse json.", ERROR); token_vector_destroy(tokens); return false; } // iterate of all tokens, try to load configuration values current_token++; for ( current_token_index = 0; current_token_index < number_of_tokens ; ) { // Lets find out what to do with the key- if (TOKEN_STRING(json_buffer, *current_token, ID_TAG)) { // Id tag if (!token_to_int(json_buffer, (current_token+1), &sprinkler->id)) { ret = false; break; } } else if (TOKEN_STRING(json_buffer, *current_token, REFRESH_RATE_TAG)) { // Port index tag if (!token_to_uint(json_buffer, (current_token+1), &sprinkler->refresh_rate)) { ret = false; break; } } else if (TOKEN_STRING(json_buffer, *current_token, MAIN_VALF_DELAY_TAG)) { // Port index tag if (!token_to_int(json_buffer, (current_token+1), &sprinkler->main_valf_delay)) { ret = false; break; } } else if (TOKEN_STRING(json_buffer, *current_token, MAIN_VALF_TAG)) { // Port index tag if (!token_to_int(json_buffer, (current_token+1), &sprinkler->main_valf)) { ret = false; break; } } // else - ignore this key. current_token_index += 2; current_token += 2; } token_vector_destroy(tokens); return ret; }
void add_to_logs (long winref, int servref, const char *target, int level, const char *orig_str) { Logfile *log; int i; for (log = logfiles; log; log = log->next) { if (log->type == LOG_WINDOWS) { for (i = 0; i < MAX_TARGETS; i++) { if (log->refnums[i] == winref) { if (!mask_isset(&log->mask, level)) continue; time(&log->activity); add_to_log(log->refnum, log->log, winref, orig_str, log->mangler, log->rewrite); } } } if (log->type == LOG_SERVERS) { for (i = 0; i < MAX_TARGETS; i++) { if (log->refnums[i] == NOSERV || log->refnums[i] == servref) { if (!mask_isset(&log->mask, level)) continue; time(&log->activity); add_to_log(log->refnum, log->log, winref, orig_str, log->mangler, log->rewrite); } } } else if (log->type == LOG_TARGETS) { if (log->servref != NOSERV && (log->servref != servref)) continue; if (!mask_isset(&log->mask, level)) continue; if (log->targets && !target) continue; if (target && !find_in_list((List **)&log->targets, target, USE_WILDCARDS)) continue; /* OK! We want to log it now! */ time(&log->activity); add_to_log(log->refnum, log->log, winref, orig_str, log->mangler, log->rewrite); } } }
int main(int argc, char *argv[]) { int exoid; char *filename; int cpu_word_size = 8; int io_word_size = 0; float version = 0.0; banner(); if (argc != 3) { fprintf(stderr, "ERROR: Usage is exotec2 exo_in tec_out\n\n"); exit(1); } /* Open the files... */ filename = argv[1]; exoid = ex_open(filename, EX_READ, &cpu_word_size, &io_word_size, &version); if (exoid < 0) { fprintf(stderr, "Cannot open file '%s' - exiting.\n", filename); exit(1); } /* Write the tec file... */ filename = argv[2]; tec(exoid, filename); ex_close(exoid); add_to_log(argv[0], 0.0); }
bool send_request(const char* url, StringBuffer* response, StringBuffer* request, const bool IsPost) { bool ret = false; CURLcode res; CURL *curl = curl_easy_init(); char log_buffer[100]; if (curl) { struct curl_slist *headers = NULL; headers = curl_slist_append(headers, "Accept: application/json"); headers = curl_slist_append(headers, "Content-Type: application/json"); curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L); // Disable progress curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *) response); if (IsPost) { curl_easy_setopt(curl, CURLOPT_POST, 1); curl_easy_setopt(curl, CURLOPT_READFUNCTION, ReadMemoryCallback); curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (curl_off_t) request->write_pos); curl_easy_setopt(curl, CURLOPT_READDATA, (void *) request); } else curl_easy_setopt(curl, CURLOPT_HTTPGET, 1); /* Perform the request, res will get the return code */ res = curl_easy_perform(curl); /* Check for errors */ if (res == CURLE_OK) { snprintf(log_buffer, 100, "post_web_page() read %lu bytes from %s.", (long) response->write_pos, url); add_to_log(log_buffer, DUMP); ret = true; } else { snprintf(log_buffer, 100, "post_web_page() failed to load from %s. Error: %s", url, curl_easy_strerror(res)); add_to_log(log_buffer, ERROR); } curl_slist_free_all(headers); /* free the list again */ curl_easy_cleanup(curl); } return ret; }
void do_logchannel(unsigned long level, ChannelList *chan, char *format, ...) { if (!chan || !get_cset_int_var(chan->csets, CHANNEL_LOG_CSET)) return; if ((chan->log_level & level) && format) { char s[BIG_BUFFER_SIZE+1]; va_list args; va_start(args, format); vsnprintf(s, BIG_BUFFER_SIZE, format, args); va_end(args); add_to_log(chan->msglog_fp, now, s, logfile_line_mangler); } }
void job_run_dialog::on_end_process(wxProcessEvent &evt) { process_input(); int ndx = jobs_to_start[current_job]; int exit_code = evt.GetExitCode(); bool remove_job; wxString status; if (abort) { jobs[ndx].status = JOBS_ABORTED; status = Z("aborted"); remove_job = false; } else if (0 == exit_code) { jobs[ndx].status = JOBS_DONE; status = Z("completed OK"); remove_job = CJAR_NEVER != mdlg->options.clear_job_after_run_mode; } else if (1 == exit_code) { jobs[ndx].status = JOBS_DONE_WARNINGS; status = Z("completed with warnings"); remove_job = (CJAR_ALWAYS == mdlg->options.clear_job_after_run_mode) || (CJAR_WARNINGS == mdlg->options.clear_job_after_run_mode); } else { jobs[ndx].status = JOBS_FAILED; status = Z("failed"); remove_job = CJAR_ALWAYS == mdlg->options.clear_job_after_run_mode; } jobs[ndx].finished_on = wxGetUTCTime(); add_to_log(wxString::Format(Z("Finished job ID %d on %s: status '%s'"), jobs[ndx].id, format_date_time(jobs[ndx].finished_on).c_str(), status.c_str())); if (remove_job) { jobs.erase(jobs.begin() + ndx, jobs.begin() + ndx + 1); for (auto idx = 0u; jobs_to_start.size() > idx; ++idx) if (jobs_to_start[idx] >= ndx) jobs_to_start[idx]--; } mdlg->save_job_queue(); delete process; process = nullptr; out = nullptr; wxRemoveFile(opt_file_name); if (!abort) g_jobs->SetValue((current_job + 1) * 100); start_next_job(); }
bool json_parse_sensors(const char* json_buffer, ListElement* sensors) { bool ret = true; TokenVector *tokens = token_vector_new(); // Parse json string if (json_parse(json_buffer, tokens)) { if (!json_parse_sensors_internal(tokens, json_buffer, sensors)) { add_to_log("json_parse_sensors: Could not find sensors data.", ERROR); ret = false; } if (!json_parse_alarms_internal(tokens, json_buffer, sensors)) { add_to_log("json_parse_sensors: Could not find alarms data.", ERROR); ret = false; } } else { add_to_log("json_parse_sensors: Could not parse json.", ERROR); } token_vector_destroy(tokens); return ret; }
int main(int argc, char *argv[]) { #ifdef HAVE_MPI MPI_Init(&argc, &argv); #endif time_t begin_time = time(nullptr); std::string in_type = "exodusII"; bool ok = false; codename = argv[0]; size_t ind = codename.find_last_of("/", codename.size()); if (ind != std::string::npos) codename = codename.substr(ind+1, codename.size()); try { SystemInterface::show_version(); Ioss::Init::Initializer io; SystemInterface interface; ok = interface.parse_options(argc, argv); if (ok) { std::string in_file = interface.input_file(); std::string output_file = interface.output_file(); OUTPUT << "Input: '" << in_file << "', Type: " << in_type << '\n'; OUTPUT << "Output: '" << output_file << "', Type: matlab script\n\n"; ok = file_info(in_file, in_type, interface); } std::string success = ok ? "successful" : "unsuccessful"; OUTPUT << "\n" << codename << " execution " << success << ".\n"; } catch (std::exception &e) { std::cerr << "ERROR: (EXOMATLAB) Standard exception: " << e.what() << std::endl; } time_t end_time = time(nullptr); add_to_log(codename.c_str(), (int)(end_time - begin_time)); #ifdef HAVE_MPI MPI_Finalize(); #endif return ok ? EXIT_SUCCESS : EXIT_FAILURE; }
bool json_parse_irrigations(const char* json_buffer, ListElement* irrigations) { TokenVector *tokens = token_vector_new(); jsmntok_t* current_token; size_t number_of_tokens; int current_token_index; int irrigation_index; // Parse json string if (!json_parse(json_buffer, tokens)) { add_to_log("json_parse_irrigations: Could not parse json.", ERROR); token_vector_destroy(tokens); return false; } // expected json : [{"start_time":1350339360,"valf_id":4,"irrigation_mode":"time","amount":2}] current_token = token_vector_get_pointer(tokens, 0); number_of_tokens = current_token->size; if (number_of_tokens <= 0 || current_token->type != JSMN_ARRAY) { add_to_log("json_parse_irrigations: Could not parse json.", ERROR); token_vector_destroy(tokens); return false; } current_token++; current_token_index = 1; // iterate of all tokens, try to build valves for (irrigation_index = 0 ; irrigation_index < number_of_tokens; irrigation_index++) { const int next_irrigation_token_index = current_token_index+current_token->size; int number_of_processed_tokens = 0; time_t start_time=0; int valf_id=-1; enum IrrigationModes mode = TIME; size_t amount; if(current_token->type != JSMN_OBJECT ) { // Not an object, skip to the next token. current_token += current_token->size + 1; continue; } current_token_index++; current_token++; while(current_token_index < next_irrigation_token_index) { const int next_object_token = current_token_index + current_token->size+1; if (current_token->type != JSMN_STRING) {// Must be an error... current_token_index = next_object_token; current_token = token_vector_get_pointer(tokens, current_token_index); continue; } if ((current_token+1)->type == JSMN_PRIMITIVE) { int value; // Read the value if (!token_to_int(json_buffer, current_token+1, &value)) { // Error current_token_index = next_object_token; current_token = token_vector_get_pointer(tokens, current_token_index); continue; } if (TOKEN_STRING(json_buffer, *current_token, START_TIME_TAG)) { start_time = value; number_of_processed_tokens++; } else if (TOKEN_STRING(json_buffer, *current_token, VALF_ID_TAG)) { valf_id = value; number_of_processed_tokens++; } else if (TOKEN_STRING(json_buffer, *current_token, AMOUNT_TAG)) { amount = value; number_of_processed_tokens++; } // else - ignore this key. } else if ((current_token+1)->type == JSMN_STRING) { if (TOKEN_STRING(json_buffer, *current_token, IRRIGATION_MODE_TAG)) { if (TOKEN_STRING(json_buffer, *(current_token+1), IRRIGATION_MODE_TIME)) { mode = TIME; number_of_processed_tokens++; } else if (TOKEN_STRING(json_buffer, *(current_token+1), IRRIGATION_MODE_VOLUME)) { mode = VOLUME; number_of_processed_tokens++; } // TODO - what to do in case of an error? - currently ignore. } // else - ignore this key. } else { // Error current_token_index = next_object_token; current_token = token_vector_get_pointer(tokens, current_token_index); continue; } current_token_index += 2; current_token += 2; } if(number_of_processed_tokens >= 4) { // Create valf Irrigation* i = irrigation_create(); i->amount = amount; i->mode = mode; i->start_time = start_time; i->valf_id = valf_id; list_add(irrigations, i); } } token_vector_destroy(tokens); return true; }
bool json_parse_valves(const char* json_buffer, ListElement* valves) { TokenVector *tokens = token_vector_new(); jsmntok_t* current_token; size_t number_of_tokens; int current_token_index; int valf_index; // Parse json string if (!json_parse(json_buffer, tokens)) { add_to_log("json_parse_valves: Could not parse json.", ERROR); token_vector_destroy(tokens); return false; } // expected json : [{"id":4,"port_index":1},{"id":6,"port_index":2},{"id":5,"port_index":4}] current_token = token_vector_get_pointer(tokens, 0); number_of_tokens = current_token->size; if (number_of_tokens <= 0 || current_token->type != JSMN_ARRAY) { add_to_log("json_parse_valves: Could not parse json.", ERROR); token_vector_destroy(tokens); return false; } current_token++; current_token_index = 1; // iterate of all tokens, try to build valves for (valf_index = 0 ; valf_index < number_of_tokens; valf_index++) { const int next_valf_token_index = current_token_index+current_token->size; int port_index =-1, id=-1, value; if(current_token->type != JSMN_OBJECT ) { current_token += current_token->size + 1; continue; } current_token_index++; current_token++; while(current_token_index < next_valf_token_index) { const int next_object_token = current_token_index + current_token->size+1; if (current_token->type != JSMN_STRING) {// Must be an error... current_token_index = next_object_token; current_token = token_vector_get_pointer(tokens, current_token_index); continue; } if ((current_token+1)->type != JSMN_PRIMITIVE) {// Must be an error... current_token_index = next_object_token; current_token = token_vector_get_pointer(tokens, current_token_index); continue; } // Read the value if (!token_to_int(json_buffer, current_token+1, &value)) { current_token_index = next_object_token; current_token = token_vector_get_pointer(tokens, current_token_index); continue; } if (TOKEN_STRING(json_buffer, *current_token, ID_TAG)) { // Id tag id = value; } else if (TOKEN_STRING(json_buffer, *current_token, PORT_INDEX_TAG)) { // Port index tag port_index = value; } // else - ignore this key. current_token_index += 2; current_token += 2; } if(id>=0 && port_index>=0) { // Create valf Valf* v = valf_create(id, port_index); list_add(valves, v); } } token_vector_destroy(tokens); return true; }
int main (int argc, char *argv[]){ char **str2,*line,*curr; const char* ext=".exo"; int i,j,k,n,n1,cpu_word_size,io_word_size,exo_file, num_axes,num_nodes,num_elements,num_blocks, num_side_sets,num_node_sets,num_time_steps, num_global_vars, num_nodal_vars,num_element_vars,*ids,*iscr, *nsssides,*nssdfac,*elem_list,*side_list, *nnsnodes,*nnsdfac,*node_list; double *scr,*x,*y,*z, *escr; char * blknames = NULL; int *num_elem_in_block = NULL; /* QA Info */ printf("%s: %s, %s\n", qainfo[0], qainfo[2], qainfo[1]); /* usage message*/ if(argc != 2){ printf("%s matlab_file_name.\n",argv[0]); printf(" the matlab_file_name is required\n"); printf("%d", argc); exit(1); } /*open input file*/ mat_file = Mat_Open(argv[1], MAT_ACC_RDONLY); if (mat_file == NULL) { printf("Error opening matlab file %s\n", argv[1]); return(1); } /*open output file*/ cpu_word_size=sizeof(double); io_word_size=sizeof(double); /* QA records */ ext=".exo"; line = (char *) calloc (2049,sizeof(char)); strcpy(line,argv[1]); strtok(line,"."); strcat(line,ext); exo_file = ex_create(line,EX_CLOBBER,&cpu_word_size,&io_word_size); if (exo_file < 0){ printf("error creating %s\n",line); exit(1); } /* print */ fprintf(stderr,"translating %s to %s ... ",argv[1],line); /* read database parameters */ matGetInt("naxes", 1, 1,&num_axes); matGetInt("nnodes", 1, 1,&num_nodes); matGetInt("nelems", 1, 1,&num_elements); matGetInt("nblks", 1, 1,&num_blocks); matGetInt("nnsets", 1, 1,&num_node_sets); matGetInt("nssets", 1, 1,&num_side_sets); matGetInt("nsteps", 1, 1,&num_time_steps); matGetInt("ngvars", 1, 1,&num_global_vars); matGetInt("nnvars", 1, 1,&num_nodal_vars); matGetInt("nevars", 1, 1,&num_element_vars); /*export parameters */ ex_put_init(exo_file,line, num_axes,num_nodes,num_elements,num_blocks, num_node_sets,num_side_sets); free(line); if ( num_global_vars > 0 ){ ex_put_variable_param(exo_file,EX_GLOBAL,num_global_vars); } if ( num_nodal_vars > 0 ){ ex_put_variable_param(exo_file,EX_NODAL,num_nodal_vars); } if ( num_element_vars > 0 ){ ex_put_variable_param(exo_file,EX_ELEM_BLOCK,num_element_vars); } /* nodal coordinates */ x = (double *) calloc(num_nodes,sizeof(double)); y = (double *) calloc(num_nodes,sizeof(double)); if (num_axes == 3) z = (double *) calloc(num_nodes,sizeof(double)); else z = NULL; matGetDbl("x0", num_nodes, 1, x); matGetDbl("y0", num_nodes, 1, y); if (num_axes == 3) matGetDbl("z0", num_nodes,1,z); ex_put_coord(exo_file,x,y,z); free(x); free(y); if (num_axes == 3){ free(z); } /* side sets (section by dgriffi) */ if(num_side_sets > 0){ /* ssids */ ids = (int *) calloc(num_side_sets,sizeof(int)); matGetInt("ssids",num_side_sets, 1,ids); /* nsssides */ nsssides = (int *) calloc(num_side_sets,sizeof(int)); matGetInt("nsssides",num_side_sets,1,nsssides); /* nssdfac */ nssdfac = (int *) calloc(num_side_sets,sizeof(int)); matGetInt("nssdfac",num_side_sets,1,nssdfac); for(i=0;i<num_side_sets;i++){ char name[32]; ex_put_set_param(exo_file,EX_SIDE_SET,ids[i],nsssides[i],nssdfac[i]); elem_list = (int *) calloc(nsssides[i],sizeof(int)); side_list = (int *) calloc(nsssides[i],sizeof(int)); escr = (double *) calloc(nssdfac[i],sizeof(double)); sprintf(name,"sselem%02d",i+1); matGetInt(name,nsssides[i],1,elem_list); sprintf(name,"ssside%02d",i+1); matGetInt(name,nsssides[i],1,side_list); ex_put_set(exo_file,EX_SIDE_SET,ids[i],elem_list,side_list); free(elem_list); free(side_list); sprintf(name,"ssfac%02d",i+1); matGetDbl(name,nssdfac[i],1,escr); ex_put_set_dist_fact(exo_file,EX_SIDE_SET,ids[i],escr); free(escr); } free(nsssides); free(nssdfac); free(ids); } /* node sets (section by dgriffi) */ if(num_node_sets > 0){ /* nsids */ ids = (int *) calloc(num_node_sets,sizeof(int)); matGetInt("nsids",num_node_sets, 1,ids); /* nnsnodes */ nnsnodes = (int *) calloc(num_node_sets,sizeof(int)); matGetInt("nnsnodes",num_node_sets,1,nnsnodes); /* nnsdfac */ nnsdfac = (int *) calloc(num_node_sets,sizeof(int)); matGetInt("nnsdfac",num_node_sets,1,nnsdfac); for(i=0;i<num_node_sets;i++){ char name[32]; ex_put_set_param(exo_file,EX_NODE_SET,ids[i],nnsnodes[i],nnsdfac[i]); node_list = (int *) calloc(nnsnodes[i],sizeof(int)); escr = (double *) calloc(nnsdfac[i],sizeof(double)); sprintf(name,"nsnod%02d",i+1); matGetInt(name,nnsnodes[i],1,node_list); ex_put_set(exo_file,EX_NODE_SET,ids[i],node_list,NULL); free(node_list); sprintf(name,"nsfac%02d",i+1); matGetDbl(name,nnsdfac[i],1,escr); ex_put_set_dist_fact(exo_file,EX_NODE_SET,ids[i],escr); free(escr); } free(nnsdfac); free(nnsnodes); free(ids); } /* element blocks */ /* get elem block ids */ ids = (int *) calloc(num_blocks,sizeof(int)); matGetInt("blkids",num_blocks,1,ids); /* get elem block types */ blknames = (char *) calloc(num_blocks*(MAX_STR_LENGTH+1),sizeof(char)); matGetStr("blknames",blknames); num_elem_in_block = (int *) calloc(num_blocks,sizeof(int)); curr = blknames; curr = strtok(curr,"\n"); for(i=0;i<num_blocks;i++){ char name[32]; sprintf(name,"blk%02d",i+1); n1 = matArrNRow(name); n = matArrNCol(name); iscr = (int *) calloc(n*n1,sizeof(int)); matGetInt(name,n1,n,iscr); num_elem_in_block[i]=n; ex_put_elem_block(exo_file,ids[i],curr,n,n1,0); ex_put_conn(exo_file,EX_ELEM_BLOCK,ids[i],iscr,NULL,NULL); free(iscr); curr = strtok(NULL, "\n"); } free(blknames); /* time values */ if (num_time_steps > 0 ) { scr = (double *) calloc(num_time_steps,sizeof(double)); matGetDbl( "time", num_time_steps, 1,scr); for (i=0;i<num_time_steps;i++){ ex_put_time(exo_file,i+1,&scr[i]); } free(scr); } /* global variables */ if (num_global_vars > 0 ){ int max_name_length = ex_inquire_int(exo_file, EX_INQ_DB_MAX_USED_NAME_LENGTH); char *str = (char *) calloc(num_global_vars * (max_name_length+1), sizeof(char)); matGetStr("gnames",str); str2 = (char **) calloc(num_global_vars,sizeof(char*)); curr = strtok(str,"\n"); for(i=0;i<num_global_vars;i++){ str2[i]=curr; curr = strtok(NULL,"\n"); } ex_put_variable_names(exo_file, EX_GLOBAL, num_global_vars, str2); free(str); free(str2); { double * global_var_vals; double * temp; global_var_vals = (double *) calloc(num_global_vars*num_time_steps,sizeof(double)); temp = (double *) calloc(num_time_steps,sizeof(double)); for (j=0;j<num_global_vars;j++) { char name[32]; sprintf(name,"gvar%02d",j+1); matGetDbl(name,num_time_steps,1,temp); for (i=0; i < num_time_steps; i++) { global_var_vals[num_global_vars*i+j]=temp[i]; } } for (i=0; i<num_time_steps; i++) { size_t offset = num_global_vars * i; ex_put_var(exo_file,i+1,EX_GLOBAL,1,0,num_global_vars,&global_var_vals[offset]); } free(temp); free(global_var_vals); } } /* nodal variables */ /* section by dtg */ if (num_nodal_vars > 0){ int max_name_length = ex_inquire_int(exo_file, EX_INQ_DB_MAX_USED_NAME_LENGTH); char *str = (char *) calloc(num_nodal_vars * (max_name_length+1), sizeof(char)); matGetStr("nnames",str); str2 = (char **) calloc(num_nodal_vars,sizeof(char*)); curr = strtok(str,"\n"); for(i=0;i<num_nodal_vars;i++){ str2[i]=curr; curr = strtok(NULL,"\n"); } ex_put_variable_names(exo_file, EX_NODAL, num_nodal_vars, str2); free(str); free(str2); { double * nodal_var_vals; for (i=0;i<num_nodal_vars;i++) { char name[32]; nodal_var_vals = (double *) calloc(num_nodes*num_time_steps,sizeof(double)); sprintf(name,"nvar%02d",i+1); matGetDbl(name,num_nodes,num_time_steps,nodal_var_vals); for (j=0;j<num_time_steps;j++) { ex_put_var(exo_file,j+1,EX_NODAL,i+1,num_nodes,1,nodal_var_vals+num_nodes*j); } free(nodal_var_vals); } } } /* elemental variables */ /* section by dtg */ if (num_element_vars > 0){ int max_name_length = ex_inquire_int(exo_file, EX_INQ_DB_MAX_USED_NAME_LENGTH); char *str = (char *) calloc(num_element_vars * (max_name_length+1), sizeof(char)); matGetStr("enames",str); str2 = (char **) calloc(num_element_vars,sizeof(char*)); curr = strtok(str,"\n"); for(i=0;i<num_element_vars;i++){ str2[i]=curr; curr = strtok(NULL,"\n"); } ex_put_variable_names(exo_file, EX_ELEM_BLOCK, num_element_vars, str2); free(str); free(str2); { double * element_var_vals; for (i=0;i<num_element_vars;i++) { char name[32]; element_var_vals = (double *) calloc(num_elements*num_time_steps,sizeof(double)); sprintf(name,"evar%02d",i+1); matGetDbl(name,num_elements,num_time_steps,element_var_vals); n=0; for (j=0;j<num_time_steps;j++) { for (k=0;k<num_blocks;k++) { ex_put_var(exo_file,j+1,EX_ELEM_BLOCK, i+1,ids[k],num_elem_in_block[k],element_var_vals+n); n=n+num_elem_in_block[k]; } } free(element_var_vals); } } } free(ids); /* node and element number maps */ ids = (int *) calloc (num_nodes,sizeof(int)); if ( !matGetInt("node_num_map",num_nodes,1,ids)){ ex_put_node_num_map(exo_file,ids); } free(ids); ids = (int *) calloc (num_elements,sizeof(int)); if ( !matGetInt("elem_num_map",num_elements,1,ids)){ ex_put_elem_num_map(exo_file,ids); } free(ids); free(num_elem_in_block); /* close exo file */ ex_close(exo_file); /* close mat file */ Mat_Close(mat_file); /* */ fprintf(stderr,"done.\n"); /* exit status */ add_to_log("mat2exo", 0); return(0); }
void parse_notice(char *from, char **Args) { int type; char *to, *high = empty_string, *target, *line; NickList *nick = NULL; ChannelList *tmpc = NULL; char *newline = NULL; PasteArgs(Args, 1); to = Args[0]; line = Args[1]; if (!to || !line) return; if (!*to) { put_it("*** obsolete notice recieved. [%s]", line+1); return; } if (!from || !*from || !strcmp(get_server_itsname(from_server), from)) { parse_server_notice(from, line); return; } if (is_channel(to)) { target = to; type = PUBLIC_NOTICE_LIST; if ((tmpc = lookup_channel(to, from_server, CHAN_NOUNLINK))) nick = find_nicklist_in_channellist(from, tmpc, 0); } else { target = from; type = NOTICE_LIST; } update_stats(NOTICELIST, to, nick, tmpc, 0); set_display_target(target, LOG_NOTICE); doing_notice = 1; if ((check_ignore_notice(from, to, IGNORE_NOTICES, line, &high) == IGNORED)) goto notice_cleanup; if (!check_flooding(from, NOTICE_FLOOD, line, NULL)) goto notice_cleanup; if (!strchr(from, '.')) { notify_mark(from, FromUserHost, 1, 0); line = do_notice_ctcp(from, to, line); if (!*line) goto notice_cleanup; } if (sed && !do_hook(ENCRYPTED_NOTICE_LIST, "%s %s %s", from, to, line)) { #if 0 put_it("%s", convert_output_format(fget_string_var(FORMAT_ENCRYPTED_NOTICE_FSET), "%s %s %s %s", update_clock(GET_TIME), from, FromUserHost, line)); #endif sed = 0; goto notice_cleanup; } { char *free_me = NULL; char *s; free_me = newline = stripansi(line); if (wild_match("[*Wall*", line)) { char *channel = NULL, *p, *q; q = p = next_arg(newline, &newline); if ((p = strchr(p, '/'))) { p++; if (*p && *p == '\002') p++; channel = m_strdup(p); if ((p = strchr(channel, ']'))) *p++ = 0; q = channel; if (*q && q[strlen(q)-1] == '\002') q[strlen(q)-1] = 0; } if (channel && *channel) set_display_target(channel, LOG_WALL); else set_display_target(target, LOG_WALL); if (do_hook(type, "%s %s", from, line)) { s = convert_output_format(fget_string_var(FORMAT_BWALL_FSET), "%s %s %s %s %s", update_clock(GET_TIME), q, from, FromUserHost, newline); if (tmpc) add_to_log(tmpc->msglog_fp, now, s, logfile_line_mangler); put_it("%s", s); } add_last_type(&last_wall[0], 1, from, FromUserHost, NULL, line); logmsg(LOG_WALL, from, 0, "%s", line); /* addtabkey(from, "wall", 0);*/ new_free(&channel); } else { if (type == PUBLIC_NOTICE_LIST) { s = convert_output_format(fget_string_var(check_auto_reply(line)?FORMAT_PUBLIC_NOTICE_AR_FSET:FORMAT_PUBLIC_NOTICE_FSET), "%s %s %s %s %s", update_clock(GET_TIME), from, FromUserHost, to, newline); if (do_hook(type, "%s %s %s", from, to, line)) put_it("%s", s); } else { s = convert_output_format(fget_string_var(FORMAT_NOTICE_FSET), "%s %s %s %s", update_clock(GET_TIME), from, FromUserHost, newline); if (do_hook(type, "%s %s", from, line)) put_it("%s", s); } if (tmpc) add_to_log(tmpc->msglog_fp, now, s, logfile_line_mangler); logmsg(LOG_NOTICE, from, 0, "%s", line); add_last_type(&last_notice[0], MAX_LAST_MSG, from, FromUserHost, to, line); } new_free(&free_me); } notice_cleanup: if (beep_on_level & LOG_NOTICE) beep_em(1); reset_display_target(); doing_notice = 0; }
int main (int argc, char *argv[]) { char *version_string = "Algebraic Preprocessor (Aprepro)"; int c; time_t time_val; struct tm *time_structure; char *asc_time = NULL; char *include_file = NULL; #define NO_ARG 0 #define IS_ARG 1 #define OP_ARG 2 static struct option long_options[] = { {"debug", NO_ARG, 0, 'd'}, {"statistics", NO_ARG, 0, 's'}, {"copyright", NO_ARG, 0, 'C'}, {"comment", IS_ARG, 0, 'c'}, {"version", NO_ARG, 0, 'v'}, {"interactive", NO_ARG, 0, 'i'}, {"include", IS_ARG, 0, 'I'}, {"exit_on", NO_ARG, 0, 'e'}, {"help", NO_ARG, 0, 'h'}, {"nowarning", NO_ARG, 0, 'W'}, {"messages", NO_ARG, 0, 'M'}, {"quiet", NO_ARG, 0, 'q'}, {"immutable", NO_ARG, 0, 'X'}, {"one_based_index", NO_ARG, 0, '1'}, {NULL, NO_ARG, NULL, 0} }; int option_index = 0; extern int optind; extern char *optarg; myname = strrchr (argv[0], '/'); if (myname == NULL) myname = argv[0]; else myname++; /* Process command line options */ initialize_options(&ap_options); ap_options.end_on_exit = False; while ((c = getopt_long (argc, argv, "c:dDsSvViI:eEwWmMhHCqX1", long_options, &option_index)) != EOF) { switch (c) { case 'c': NEWSTR(optarg, ap_options.comment); break; case 'd': case 'D': ap_options.debugging = True; ap_options.info_msg = True; ap_options.warning_msg = True; break; case 's': case 'S': /* Print hash statistics */ ap_options.statistics = True; break; case 'C': /* Print copyright message */ ap_options.copyright = True; break; case 'v': case 'V': fprintf (stderr, "%s: (%s) %s\n", version_string, qainfo[2], qainfo[1]); break; case 'i': ap_options.interactive = True; break; case 'I': /* * Check whether optarg specifies a file or a directory * If a file, it is an include file, * If a directory, it is an include_path */ if (is_directory(optarg)) { NEWSTR(optarg, ap_options.include_path); } else { NEWSTR(optarg, include_file); } break; case 'e': case 'E': ap_options.end_on_exit = True; break; case 'W': ap_options.warning_msg = False; break; case 'q': ap_options.quiet = True; break; case 'M': ap_options.info_msg = True; break; case 'X': ap_options.immutable = True; break; case '1': ap_options.one_based_index = True; break; case 'h': case 'H': usage(); exit(EXIT_SUCCESS); break; case '?': default: /* getopt will print a message for us */ usage (); exit(EXIT_FAILURE); break; } } /* Process remaining options. If '=' in word, then it is of the form * var=value. Set the value. If '=' not found, process remaining * options as input and output files */ while (optind < argc && strchr(argv[optind], '=') && !strchr(argv[optind], '/')) { char *var, *val; double value; symrec *s; var = argv[optind++]; val = strchr (var, '='); if (val == NULL) { fprintf(stderr, "ERROR: '%s' is not a valid form for assiging a variable; it will not be defined\n", var); } else { *val++ = '\0'; if (!check_valid_var(var)) { fprintf(stderr, "ERROR: '%s' is not a valid form for a variable; it will not be defined\n", var); } else { if (strchr(val, '"') != NULL) { /* Should be a string variable */ char *pt = strrchr(val, '"'); if (pt != NULL) { val++; *pt = '\0'; if (var[0] == '_') s = putsym(var, SVAR, 0); else s = putsym(var, IMMSVAR, 0); NEWSTR(val, s->value.svar); } else { fprintf(stderr, "ERROR: Missing trailing \" in definition of variable '%s'; it will not be defined\n", var); } } else { int err = sscanf (val, "%lf", &value); if (err <= 0) { fprintf(stderr, "ERROR: Could not parse value in assignment of variable '%s'; it will not be defined\n", var); } else { if (var[0] == '_') s = putsym (var, VAR, 0); else s = putsym (var, IMMVAR, 0); s->value.var = value; } } } } } if (ap_options.copyright == True) copyright_output(); /* Assume stdin, recopy if and when it is changed */ yyin = stdin; yyout = stdout; if (argc > optind) { add_input_file(argv[optind]); } else { NEWSTR ("stdin", ap_file_list[nfile].name); SET_FILE_LIST (nfile, 0, False, 1); } if (argc > ++optind) { yyout = open_file(argv[optind], "w"); } else { /* Writing to stdout */ if (ap_options.interactive) setbuf (yyout, (char *) NULL); } state_immutable = ap_options.immutable; time_val = time ((time_t*)NULL); time_structure = localtime (&time_val); asc_time = asctime (time_structure); /* NOTE: asc_time includes \n at end of string */ if (!ap_options.quiet) { if (state_immutable) { fprintf (yyout, "%s Aprepro (%s) [immutable mode] %s", ap_options.comment, qainfo[2], asc_time); } else { fprintf (yyout, "%s Aprepro (%s) %s", ap_options.comment, qainfo[2], asc_time); } } if (include_file) { nfile++; add_input_file(include_file); /* Include file specified on command line is processed in immutable * state. Reverts back to global immutable state at end of file. */ state_immutable = True; echo = False; } srand((unsigned)time_val); init_table (ap_options.comment); yyparse (); if (ap_options.debugging > 0) dumpsym (VAR, 0); if (ap_options.statistics > 0) pstats (); add_to_log(myname, 0); return (EXIT_SUCCESS); } /* NOTREACHED */
void job_run_dialog::start_next_job() { t_update->Stop(); ++current_job; if ((static_cast<int>(jobs_to_start.size()) <= current_job) || cb_abort_after_current->IsChecked() || abort) { if ( abort || ( cb_abort_after_current->IsChecked() && (current_job < static_cast<int>(jobs_to_start.size())))) add_to_log(wxString::Format(Z("Aborted processing on %s"), format_date_time(wxGetUTCTime()).c_str())); else add_to_log(wxString::Format(Z("Finished processing on %s"), format_date_time(wxGetUTCTime()).c_str())); b_abort->Enable(false); cb_abort_after_current->Enable(false); b_ok->Enable(true); b_ok->SetFocus(); SetTitle(Z("mkvmerge has finished")); st_remaining_time->SetLabel(wxT("---")); st_remaining_time_total->SetLabel(wxT("---")); #if defined(SYS_WINDOWS) if (m_taskbar_progress) m_taskbar_progress->set_state(TBPF_NOPROGRESS); #endif return; } m_start_time = mtx::sys::get_current_time_millis(); m_next_remaining_time_update = m_start_time + 8000; st_remaining_time->SetLabel(Z("is being estimated")); #if defined(SYS_WINDOWS) if (m_taskbar_progress) { m_taskbar_progress->set_state(TBPF_NORMAL); m_taskbar_progress->set_value(current_job * 100, jobs_to_start.size() * 100); } #endif int ndx = jobs_to_start[current_job]; st_jobs->SetLabel(wxString::Format(Z("Processing job %d/%d"), current_job + 1, (int)jobs_to_start.size())); st_current->SetLabel(wxString::Format(Z("Current job ID %d:"), jobs[ndx].id)); mdlg->load(wxString::Format(wxT("%s/%d.mmg"), app->get_jobs_folder().c_str(), jobs[ndx].id), true); opt_file_name = get_temp_settings_file_name(); wxFile *opt_file; try { opt_file = new wxFile(opt_file_name, wxFile::write); } catch (...) { jobs[ndx].log->Printf(Z("Could not create a temporary file for mkvmerge's command line option called '%s' (error code %d, %s)."), opt_file_name.c_str(), errno, wxUCS(strerror(errno))); jobs[ndx].status = JOBS_FAILED; mdlg->save_job_queue(); if (process) { delete process; process = nullptr; } start_next_job(); return; } static const unsigned char utf8_bom[3] = {0xef, 0xbb, 0xbf}; opt_file->Write(utf8_bom, 3); opt_file->Write(wxT("--gui-mode\n")); mdlg->update_command_line(); wxArrayString *arg_list = &mdlg->get_command_line_args(); size_t i; for (i = 1; i < arg_list->Count(); i++) { if ((*arg_list)[i].Length() == 0) opt_file->Write(wxT("#EMPTY#")); else { std::string arg_utf8 = escape(wxMB((*arg_list)[i])); opt_file->Write(arg_utf8.c_str(), arg_utf8.length()); } opt_file->Write(wxT("\n")); } delete opt_file; process = new wxProcess(this, 1); process->Redirect(); wxString command_line = wxString::Format(wxT("\"%s\" \"@%s\""), (*arg_list)[0].c_str(), opt_file_name.c_str()); pid = wxExecute(command_line, wxEXEC_ASYNC, process); if (0 == pid) { wxLogError(wxT("Execution of '%s' failed."), command_line.c_str()); return; } out = process->GetInputStream(); *jobs[ndx].log = wxEmptyString; jobs[ndx].started_on = wxGetUTCTime(); jobs[ndx].finished_on = -1; add_to_log(wxString::Format(Z("Starting job ID %d (%s) on %s"), jobs[ndx].id, jobs[ndx].description->c_str(), format_date_time(jobs[ndx].started_on).c_str())); t_update->Start(100); }
int main (int argc, char *argv[]) { char *str,**str2,*(*qa_records)[4],*line, *oname, *dot, *filename; const char* ext=EXT; int i,j,k,n,n1,n2,cpu_word_size,io_word_size,exo_file,err, num_axes,num_nodes,num_elements,num_blocks, num_side_sets,num_node_sets,num_time_steps, num_qa_lines,num_info_lines,num_global_vars, num_nodal_vars,num_element_vars,num_nodeset_vars, num_sideset_vars, *ids,*iscr,*num_elem_in_block,*junk, *elem_list,*side_list, *nsssides,*nssdfac, *nnsnodes,*nnsdfac, nstr2, has_ss_dfac; float exo_version; double *scr,*x,*y,*z; oname=0; /* process arguments */ for (j=1; j< argc; j++){ if ( strcmp(argv[j],"-t")==0){ /* write text file (*.m) */ del_arg(&argc,argv,j); textfile=1; j--; continue; } if ( strcmp(argv[j],"-o")==0){ /* specify output file name */ del_arg(&argc,argv,j); if ( argv[j] ){ oname=(char*)calloc(strlen(argv[j])+10,sizeof(char)); strcpy(oname,argv[j]); del_arg(&argc,argv,j); printf("output file: %s\n",oname); } else { fprintf(stderr,"Invalid output file specification.\n"); return 2; } j--; continue; } } /* QA Info */ printf("%s: %s, %s\n", qainfo[0], qainfo[2], qainfo[1]); /* usage message*/ if(argc != 2){ printf("%s [options] exodus_file_name.\n",argv[0]); printf(" the exodus_file_name is required (exodusII only).\n"); printf(" Options:\n"); printf(" -t write a text (.m) file rather than a binary .mat\n"); printf(" -o output file name (rather than auto generate)\n"); printf(" ** note **\n"); printf("Binary files are written by default on all platforms with"); printf(" available libraries.\n"); exit(1); } /* open output file */ if ( textfile ) ext=".m"; if ( !oname ){ filename = (char*)malloc( strlen(argv[1])+10); strcpy(filename,argv[1]); dot=strrchr(filename,'.'); if ( dot ) *dot=0; strcat(filename,ext); } else { filename=oname; } if ( textfile ){ m_file = fopen(filename,"w"); if (!m_file ){ fprintf(stderr,"Unable to open %s\n",filename); exit(1); } } else { mat_file = Mat_CreateVer(filename, NULL, MAT_FT_MAT5); if (mat_file == NULL) { fprintf(stderr,"Unable to create matlab file %s\n",filename); exit(1); } } /* word sizes */ cpu_word_size=sizeof(double); io_word_size=0; /* open exodus file */ exo_file=ex_open(argv[1],EX_READ,&cpu_word_size,&io_word_size,&exo_version); if (exo_file < 0){ printf("error opening %s\n",argv[1]); exit(1); } /* print */ fprintf(stderr,"translating %s to %s ...\n",argv[1],filename); /* read database paramters */ line=(char *) calloc ((MAX_LINE_LENGTH+1),sizeof(char)); err = ex_get_init(exo_file,line, &num_axes,&num_nodes,&num_elements,&num_blocks, &num_node_sets,&num_side_sets); num_qa_lines = ex_inquire_int(exo_file,EX_INQ_QA); num_info_lines = ex_inquire_int(exo_file,EX_INQ_INFO); num_time_steps = ex_inquire_int(exo_file,EX_INQ_TIME); err=ex_get_variable_param(exo_file,EX_GLOBAL,&num_global_vars); err=ex_get_variable_param(exo_file,EX_NODAL,&num_nodal_vars); err=ex_get_variable_param(exo_file,EX_ELEM_BLOCK,&num_element_vars); err=ex_get_variable_param(exo_file,EX_NODE_SET,&num_nodeset_vars); err=ex_get_variable_param(exo_file,EX_SIDE_SET,&num_sideset_vars); /* export paramters */ PutInt("naxes", 1, 1,&num_axes); PutInt("nnodes", 1, 1,&num_nodes); PutInt("nelems", 1, 1,&num_elements); PutInt("nblks", 1, 1,&num_blocks); PutInt("nnsets", 1, 1,&num_node_sets); PutInt("nssets", 1, 1,&num_side_sets); PutInt("nsteps", 1, 1,&num_time_steps); PutInt("ngvars", 1, 1,&num_global_vars); PutInt("nnvars", 1, 1,&num_nodal_vars); PutInt("nevars", 1, 1,&num_element_vars); PutInt("nnsvars", 1, 1,&num_nodeset_vars); PutInt("nssvars", 1, 1,&num_sideset_vars); /* allocate -char- scratch space*/ n = num_info_lines; n = (n > num_global_vars) ? n : num_global_vars; n = (n > num_nodal_vars) ? n : num_nodal_vars; n = (n > num_element_vars) ? n : num_element_vars; n = (n > num_blocks) ? n : num_blocks; nstr2 = n; str2= (char **) calloc (n,sizeof(char *)); for (i=0;i<nstr2;i++) str2[i]=(char *) calloc ((MAX_LINE_LENGTH+1),sizeof(char)); str= (char *) calloc ((MAX_LINE_LENGTH+1)*n,sizeof(char)); /* title */ PutStr("Title",line); #if 0 /* QA records */ if (num_qa_lines > 0 ){ qa_records =(char *(*)[4]) calloc (num_qa_lines*4,sizeof(char **)); for (i=0;i<num_qa_lines;i++) for (j=0;j<4;j++) qa_records[i][j]=(char *) calloc ((MAX_STR_LENGTH+1),sizeof(char)); err=ex_get_qa(exo_file,qa_records); str[0]='\0'; for (i=0;i<num_qa_lines;i++){ for (j=0;j<4;j++) sprintf(str+strlen(str),"%s ",qa_records[i][j]); strcat(str,"\n"); } for (i=0;i<num_qa_lines;i++){ for (j=0;j<4;j++) free(qa_records[i][j]); } free(qa_records); } /* information records */ if (num_info_lines > 0 ){ err = ex_get_info(exo_file,str2); str[0]='\0'; for (i=0;i<num_info_lines;i++) sprintf(str+strlen(str),"%s\n",str2[i]); PutStr("info",str); str[0]='\0'; for (i=0;i<num_info_lines;i++) if (strncmp(str2[i],"cavi",4)==0) sprintf(str+strlen(str),"%s\n",str2[i]); PutStr("cvxp",str); } #endif /* nodal coordinates */ x = (double *) calloc(num_nodes,sizeof(double)); y = (double *) calloc(num_nodes,sizeof(double)); if (num_axes == 3) z = (double *) calloc(num_nodes,sizeof(double)); else z = NULL; err = ex_get_coord(exo_file,x,y,z); PutDbl("x0", num_nodes, 1, x); PutDbl("y0", num_nodes, 1, y); free(x); free(y); if (num_axes == 3){ PutDbl("z0",num_nodes,1, z); free(z); } /* side sets */ if(num_side_sets > 0){ ids=(int *) calloc(num_side_sets,sizeof(int)); err = ex_get_ids(exo_file,EX_SIDE_SET,ids); PutInt( "ssids",num_side_sets, 1,ids); nsssides = (int *) calloc(num_side_sets,sizeof(int)); /*dgriffi */ nssdfac = (int *) calloc(num_side_sets,sizeof(int)); /*dgriffi */ for (i=0;i<num_side_sets;i++){ err = ex_get_set_param(exo_file,EX_SIDE_SET, ids[i],&n1,&n2); nsssides[i]=n1; /* dgriffi */ nssdfac[i]=n2; /* dgriffi */ /* * the following provision is from Version 1.6 when there are no * distribution factors in exodus file */ has_ss_dfac = (n2 != 0); if(n2==0 || n1==n2){ printf(" WARNING: Exodus II file does not contain distribution factors.\n"); /* n1=number of faces, n2=number of df */ /* using distribution factors to determine number of nodes in the sideset causes a lot grief since some codes do not output distribution factors if they are all equal to 1. mkbhard: I am using the function call below to figure out the total number of nodes in this sideset. Some redundancy exists, but it works for now */ junk = (int*) calloc(n1,sizeof(int)); err = ex_get_side_set_node_count(exo_file,ids[i],junk); n2=0; /* n2 will be equal to the total number of nodes in the sideset */ for (j=0;j<n1;j++) n2+=junk[j]; free(junk); } iscr = (int *) calloc(n1+n2,sizeof(int)); err = ex_get_side_set_node_list(exo_file,ids[i],iscr,iscr+n1); /* number-of-nodes-per-side list */ sprintf(str,"ssnum%02d",i+1); PutInt(str,n1,1,iscr); /* nodes list */ sprintf(str,"ssnod%02d",i+1); PutInt(str,n2,1,iscr+n1); free(iscr); /* distribution-factors list */ scr = (double *) calloc (n2,sizeof(double)); if (has_ss_dfac) { ex_get_side_set_dist_fact(exo_file,ids[i],scr); } else { for (j=0; j<n2; j++) { scr[j] = 1.0; } } sprintf(str,"ssfac%02d",i+1); PutDbl(str,n2,1,scr); free(scr); /* element and side list for side sets (dgriffi) */ elem_list = (int *) calloc(n1, sizeof(int)); side_list = (int *) calloc(n1, sizeof(int)); err = ex_get_set(exo_file,EX_SIDE_SET,ids[i],elem_list,side_list); sprintf(str,"ssside%02d",i+1); PutInt(str,n1,1,side_list); sprintf(str,"sselem%02d",i+1); PutInt(str,n1,1,elem_list); free(elem_list); free(side_list); } /* Store # sides and # dis. factors per side set (dgriffi) */ PutInt("nsssides",num_side_sets,1,nsssides); PutInt("nssdfac",num_side_sets,1,nssdfac); free(ids); free(nsssides); free(nssdfac); } /* node sets (section by dgriffi) */ if(num_node_sets > 0){ ids=(int *) calloc(num_node_sets,sizeof(int)); err = ex_get_ids(exo_file,EX_NODE_SET, ids); PutInt( "nsids",num_node_sets, 1,ids); nnsnodes = (int *) calloc(num_node_sets,sizeof(int)); nnsdfac = (int *) calloc(num_node_sets,sizeof(int)); for (i=0;i<num_node_sets;i++){ err = ex_get_set_param(exo_file,EX_NODE_SET,ids[i],&n1,&n2); iscr = (int *) calloc(n1,sizeof(int)); err = ex_get_node_set(exo_file,ids[i],iscr); /* nodes list */ sprintf(str,"nsnod%02d",i+1); PutInt(str,n1,1,iscr); free(iscr); /* distribution-factors list */ scr = (double *) calloc (n2,sizeof(double)); ex_get_node_set_dist_fact(exo_file,ids[i],scr); sprintf(str,"nsfac%02d",i+1); PutDbl(str,n2,1,scr); free(scr); nnsnodes[i]=n1; nnsdfac[i]=n2; } /* Store # nodes and # dis. factors per node set */ PutInt("nnsnodes",num_node_sets,1,nnsnodes); PutInt("nnsdfac",num_node_sets,1,nnsdfac); free(ids); free(nnsdfac); free(nnsnodes); } /* element blocks */ ids=(int *) calloc(num_blocks,sizeof(int)); num_elem_in_block=(int *) calloc(num_blocks,sizeof(int)); err = ex_get_ids(exo_file,EX_ELEM_BLOCK,ids); PutInt( "blkids",num_blocks, 1,ids); for (i=0;i<num_blocks;i++) { err = ex_get_elem_block(exo_file,ids[i],str2[i],&n,&n1,&n2); num_elem_in_block[i]=n; iscr = (int *) calloc(n*n1,sizeof(int)); err = ex_get_conn(exo_file,EX_ELEM_BLOCK,ids[i],iscr, NULL, NULL); sprintf(str,"blk%02d",i+1); PutInt(str,n1,n,iscr); free(iscr); } str[0]='\0'; for (i=0;i<num_blocks;i++) sprintf(str+strlen(str),"%s\n",str2[i]); PutStr("blknames",str); /* time values */ if (num_time_steps > 0 ) { scr = (double *) calloc (num_time_steps,sizeof(double)); err= ex_get_all_times (exo_file,scr); PutDbl( "time", num_time_steps, 1,scr); free(scr); } /* global variables */ if (num_global_vars > 0 ) { err = ex_get_variable_names(exo_file,EX_GLOBAL,num_global_vars,str2); str[0]='\0'; for (i=0;i<num_global_vars;i++) sprintf(str+strlen(str),"%s\n",str2[i]); PutStr("gnames",str); scr = (double *) calloc (num_time_steps,sizeof(double)); for (i=0;i<num_global_vars;i++){ sprintf(str,"gvar%02d",i+1); err=ex_get_glob_var_time(exo_file,i+1,1,num_time_steps,scr); PutDbl(str,num_time_steps,1,scr); } free(scr); } /* nodal variables */ if (num_nodal_vars > 0 ) { err = ex_get_variable_names(exo_file,EX_NODAL,num_nodal_vars,str2); str[0]='\0'; for (i=0;i<num_nodal_vars;i++) sprintf(str+strlen(str),"%s\n",str2[i]); PutStr("nnames",str); scr = (double *) calloc (num_nodes*num_time_steps,sizeof(double)); for (i=0;i<num_nodal_vars;i++){ sprintf(str,"nvar%02d",i+1); for (j=0;j<num_time_steps;j++) err=ex_get_nodal_var(exo_file,j+1,i+1,num_nodes, scr+num_nodes*j); PutDbl(str,num_nodes,num_time_steps,scr); } free(scr); } /* element variables */ if (num_element_vars > 0 ) { err = ex_get_variable_names(exo_file,EX_ELEM_BLOCK,num_element_vars,str2); str[0]='\0'; for (i=0;i<num_element_vars;i++) sprintf(str+strlen(str),"%s\n",str2[i]); PutStr("enames",str); /* truth table */ iscr = (int *) calloc(num_element_vars*num_blocks, sizeof(int)); ex_get_elem_var_tab(exo_file,num_blocks,num_element_vars,iscr); for (i=0;i<num_element_vars;i++){ scr = (double *) calloc (num_elements*num_time_steps,sizeof(double)); n=0; sprintf(str,"evar%02d",i+1); for (j=0;j<num_time_steps;j++){ for (k=0;k<num_blocks;k++){ if(iscr[num_element_vars*k+i]==1) ex_get_elem_var(exo_file,j+1,i+1,ids[k],num_elem_in_block[k],scr+n); n=n+num_elem_in_block[k]; } } PutDbl(str,num_elements,num_time_steps,scr); free(scr); } free(iscr); } free(num_elem_in_block); free(ids); /* node and element number maps */ ex_opts(0); /* turn off error reporting. It is not an error to have no map*/ ids = (int *)malloc(num_nodes*sizeof(int)); err = ex_get_node_num_map(exo_file,ids); if ( err==0 ){ PutInt("node_num_map",num_nodes,1,ids); } free(ids); ids = (int *)malloc(num_elements*sizeof(int)); err = ex_get_elem_num_map(exo_file,ids); if ( err==0 ){ PutInt("elem_num_map",num_elements,1,ids); } free(ids); /* close exo file */ ex_close(exo_file); /* close mat file */ if ( textfile ) fclose(m_file); else Mat_Close(mat_file); /* */ fprintf(stderr,"done.\n"); free(filename); free(line); free(str); for (i=0;i<nstr2;i++) free(str2[i]); free(str2); /* exit status */ add_to_log("exo2mat", 0); return(0); }
int main(int argc, char *argv[]) { const char *salsa_cmd_file; int c; double g_start_t = second(); bool force_64_bit = false; int start_proc = 0; int num_proc = 0; int subcycles = 0; int cycle = -1; while ((c = getopt(argc, argv, "64Vhp:r:s:n:S:c:")) != -1) { switch (c) { case 'h': fprintf(stderr, " usage:\n"); fprintf(stderr, "\tnem_spread [-s <start_proc>] [-n <num_proc>] [-S <subcycles> -c <cycle>] [command_file]\n"); fprintf(stderr, "\t\tDecompose for processors <start_proc> to <start_proc>+<num_proc>\n"); fprintf(stderr, "\t\tDecompose for cycle <cycle> of <subcycle> groups\n"); fprintf(stderr, "\tnem_spread [-V] [-h] (show version or usage info)\n"); fprintf(stderr, "\tnem_spread [command file] [<-p Proc> <-r raid #>]\n"); exit(1); break; case 'V': printf("%s version %s\n", UTIL_NAME, VER_STR); exit(0); break; case 'p': /* Which proc to use? Also for compatability */ break; case 'r': /* raid number. Seems to be unused; left around for compatability */ break; case 's': /* Start with processor <x> */ sscanf(optarg, "%d", &start_proc); break; case 'n': /* Number of processors to output files for */ sscanf(optarg, "%d", &num_proc); break; case '6': case '4': force_64_bit = true; /* Force storing output mesh using 64bit integers */ break; case 'S': /* Number of subcycles to use (see below) */ sscanf(optarg, "%d", &subcycles); break; case 'c': /* Which cycle to spread (see below) */ sscanf(optarg, "%d", &cycle); break; } } if (optind >= argc) salsa_cmd_file = "nem_spread.inp"; else { salsa_cmd_file = argv[optind]; } printf("%s version %s\n", UTIL_NAME, VER_STR); /* initialize some variables */ ExoFile[0] = '\0'; Exo_LB_File[0] = '\0'; Exo_Res_File[0] = '\0'; Debug_Flag = -1; Num_Nod_Var = -1; Num_Elem_Var = -1; Num_Glob_Var = -1; Num_Nset_Var = -1; Num_Sset_Var = -1; PIO_Info.Dsk_List_Cnt = -1; PIO_Info.Num_Dsk_Ctrlrs = -1; PIO_Info.PDsk_Add_Fact = -1; PIO_Info.Zeros = -1; PIO_Info.NoSubdirectory = 0; PIO_Info.Par_Dsk_Root[0] = '\0'; PIO_Info.Par_Dsk_SubDirec[0] = '\0'; PIO_Info.Staged_Writes[0] = '\0'; // Read the ASCII input file and get the name of the mesh file // so we can determine the floating point and integer word sizes // needed to instantiate the templates... if (read_mesh_file_name(salsa_cmd_file) < 0) { static char yo[] = "nem_spread"; fprintf(stderr,"%s ERROR: Could not read in the the I/O command file" " \"%s\"!\n", yo, salsa_cmd_file); exit(1); } // Open the mesh file and determine word sizes... int io_ws = 0; int cpu_ws = sizeof(float); float version; int exoid = ex_open (ExoFile, EX_READ, &cpu_ws, &io_ws, &version); // See if any 64-bit integers stored on database... int int64api = 0; int int64db = ex_int64_status(exoid) & EX_ALL_INT64_DB; if (int64db != 0) { int64api = EX_ALL_INT64_API; } int status; if (io_ws == 4) { if (int64api) { NemSpread<float, int64_t> spreader; spreader.io_ws = io_ws; spreader.int64db = int64db; spreader.int64api = int64api; spreader.force64db = force_64_bit; spreader.Proc_Info[4] = start_proc; spreader.Proc_Info[5] = num_proc; status = nem_spread(spreader, salsa_cmd_file, subcycles, cycle); } else { NemSpread<float, int> spreader; spreader.io_ws = io_ws; spreader.int64db = int64db; spreader.int64api = int64api; spreader.force64db = force_64_bit; spreader.Proc_Info[4] = start_proc; spreader.Proc_Info[5] = num_proc; status = nem_spread(spreader, salsa_cmd_file, subcycles, cycle); } } else { if (int64api) { NemSpread<double, int64_t> spreader; spreader.io_ws = io_ws; spreader.int64db = int64db; spreader.int64api = int64api; spreader.force64db = force_64_bit; spreader.Proc_Info[4] = start_proc; spreader.Proc_Info[5] = num_proc; status = nem_spread(spreader, salsa_cmd_file, subcycles, cycle); } else { NemSpread<double, int> spreader; spreader.io_ws = io_ws; spreader.int64db = int64db; spreader.int64api = int64api; spreader.force64db = force_64_bit; spreader.Proc_Info[4] = start_proc; spreader.Proc_Info[5] = num_proc; status = nem_spread(spreader, salsa_cmd_file, subcycles, cycle); } } double g_end_t = second() - g_start_t; printf("The average run time was: %.2fs\n", g_end_t); ex_close(exoid); add_to_log(argv[0], g_end_t); return status; }
/* * put_echo: a display routine for echo that doesnt require an snprintf, * so it doesnt have that overhead, and it also doesnt have any size * limitations. The sky's the limit! */ void put_echo (const unsigned char *str) { add_to_log(0, irclog_fp, -1, str, 0, NULL); add_to_screen(str); }
void put_echo (char *str) { add_to_log(irclog_fp, 0, str, logfile_line_mangler); add_to_screen(str); }
int main (int argc, char *argv[]) { char *oname = nullptr, *dot = nullptr, *filename = nullptr; char str[32]; const char* ext=EXT; int n, n1,n2,err, num_axes,num_blocks, num_side_sets,num_node_sets,num_time_steps, num_info_lines,num_global_vars, num_nodal_vars,num_element_vars,num_nodeset_vars, num_sideset_vars; size_t num_nodes = 0; size_t num_elements = 0; int mat_version = 73; /* process arguments */ for (int j=1; j< argc; j++){ if ( strcmp(argv[j],"-t")==0){ /* write text file (*.m) */ del_arg(&argc,argv,j); textfile=1; j--; continue; } if ( strcmp(argv[j],"-h")==0){ /* write help info */ del_arg(&argc,argv,j); usage(); exit(1); } if ( strcmp(argv[j],"-d")==0){ /* write help info */ del_arg(&argc,argv,j); j--; debug = 1; continue; } if ( strcmp(argv[j],"-v73")==0){ /* Version 7.3 */ del_arg(&argc,argv,j); mat_version = 73; j--; continue; } // This matches the option used in matlab if ( (strcmp(argv[j],"-v7.3")==0) || (strcmp(argv[j],"-V7.3")==0)){ /* Version 7.3 */ del_arg(&argc,argv,j); mat_version = 73; j--; continue; } if ( strcmp(argv[j],"-v5")==0){ /* Version 5 (default) */ del_arg(&argc,argv,j); mat_version = 50; j--; continue; } if ( strcmp(argv[j],"-o")==0){ /* specify output file name */ del_arg(&argc,argv,j); if ( argv[j] ){ oname=(char*)calloc(strlen(argv[j])+10,sizeof(char)); strcpy(oname,argv[j]); del_arg(&argc,argv,j); std::cout << "output file: " << oname << "\n"; } else { std::cerr << "ERROR: Invalid output file specification.\n"; return 2; } j--; continue; } } /* QA Info */ printf("%s: %s, %s\n", qainfo[0], qainfo[2], qainfo[1]); /* usage message*/ if (argc != 2){ usage(); exit(1); } /* open output file */ if ( textfile ) ext=".m"; if ( !oname ){ filename = (char*)malloc( strlen(argv[1])+10); strcpy(filename,argv[1]); dot=strrchr(filename,'.'); if ( dot ) *dot='\0'; strcat(filename,ext); } else { filename=oname; } if ( textfile ){ m_file = fopen(filename,"w"); if (!m_file ){ std::cerr << "ERROR: Unable to open " << filename << "\n"; exit(1); } } else { if (mat_version == 50) { mat_file = Mat_CreateVer(filename, nullptr, MAT_FT_MAT5); } else if (mat_version == 73) { mat_file = Mat_CreateVer(filename, nullptr, MAT_FT_MAT73); } if (mat_file == nullptr) { std::cerr << "ERROR: Unable to create matlab file " << filename << "\n"; exit(1); } } /* word sizes */ int cpu_word_size=sizeof(double); int io_word_size=0; /* open exodus file */ float exo_version; int exo_file=ex_open(argv[1],EX_READ,&cpu_word_size,&io_word_size,&exo_version); if (exo_file < 0){ std::cerr << "ERROR: Cannot open " << argv[1] << "\n"; exit(1); } /* print */ std::cout << "\ttranslating " << argv[1] << " to " << filename << "...\n"; /* read database paramters */ char *line=(char *) calloc ((MAX_LINE_LENGTH+1),sizeof(char)); ex_get_init(exo_file,line, &num_axes,&num_nodes,&num_elements,&num_blocks, &num_node_sets,&num_side_sets); num_info_lines = ex_inquire_int(exo_file,EX_INQ_INFO); num_time_steps = ex_inquire_int(exo_file,EX_INQ_TIME); ex_get_variable_param(exo_file,EX_GLOBAL,&num_global_vars); ex_get_variable_param(exo_file,EX_NODAL,&num_nodal_vars); ex_get_variable_param(exo_file,EX_ELEM_BLOCK,&num_element_vars); ex_get_variable_param(exo_file,EX_NODE_SET,&num_nodeset_vars); ex_get_variable_param(exo_file,EX_SIDE_SET,&num_sideset_vars); /* export paramters */ PutInt("naxes", num_axes); PutInt("nnodes", num_nodes); PutInt("nelems", num_elements); PutInt("nblks", num_blocks); PutInt("nnsets", num_node_sets); PutInt("nssets", num_side_sets); PutInt("nsteps", num_time_steps); PutInt("ngvars", num_global_vars); PutInt("nnvars", num_nodal_vars); PutInt("nevars", num_element_vars); PutInt("nnsvars",num_nodeset_vars); PutInt("nssvars",num_sideset_vars); /* allocate -char- scratch space*/ int nstr2 = num_info_lines; nstr2 = std::max(nstr2, num_blocks); nstr2 = std::max(nstr2, num_node_sets); nstr2 = std::max(nstr2, num_side_sets); char **str2 = get_exodus_names(nstr2, 512); /* title */ PutStr("Title",line); /* information records */ if (num_info_lines > 0 ){ ex_get_info(exo_file,str2); std::string ostr; for (int i=0;i<num_info_lines;i++) { if (strlen(str2[i]) > 0) { ostr += str2[i]; ostr += "\n"; } } PutStr("info",ostr.c_str()); ostr = ""; for (int i=0;i<num_info_lines;i++) { if (strlen(str2[i]) > 0 && strncmp(str2[i],"cavi",4)==0) { ostr += str2[i]; ostr += "\n"; } } PutStr("cvxp",ostr.c_str()); } /* nodal coordinates */ { if (debug) {logger("Coordinates");} std::vector<double> x, y, z; x.resize(num_nodes); if (num_axes >= 2) y.resize(num_nodes); if (num_axes == 3) z.resize(num_nodes); ex_get_coord(exo_file,TOPTR(x), TOPTR(y), TOPTR(z)); PutDbl("x0", num_nodes, 1, TOPTR(x)); if (num_axes >= 2) { PutDbl("y0", num_nodes, 1, TOPTR(y)); } if (num_axes == 3){ PutDbl("z0",num_nodes,1, TOPTR(z)); } } /* side sets */ std::vector<int> num_sideset_sides(num_side_sets); std::vector<int> ids; if (num_side_sets > 0) { if (debug) {logger("Side Sets");} ids.resize(num_side_sets); ex_get_ids(exo_file,EX_SIDE_SET,TOPTR(ids)); PutInt( "ssids",num_side_sets, 1,TOPTR(ids)); std::vector<int> nssdfac(num_side_sets); std::vector<int> iscr; std::vector<int> jscr; std::vector<double> scr; std::vector<int> elem_list; std::vector<int> side_list; std::vector<int> junk; for (int i=0;i<num_side_sets;i++) { ex_get_set_param(exo_file,EX_SIDE_SET, ids[i],&n1,&n2); num_sideset_sides[i]=n1; nssdfac[i]=n2; /* * the following provision is from Version 1.6 when there are no * distribution factors in exodus file */ bool has_ss_dfac = (n2 != 0); if (n2==0 || n1==n2){ std::cerr << "WARNING: Exodus II file does not contain distribution factors.\n"; /* n1=number of faces, n2=number of df */ /* using distribution factors to determine number of nodes in the sideset causes a lot grief since some codes do not output distribution factors if they are all equal to 1. mkbhard: I am using the function call below to figure out the total number of nodes in this sideset. Some redundancy exists, but it works for now */ junk.resize(n1); ex_get_side_set_node_count(exo_file,ids[i],TOPTR(junk)); n2=0; /* n2 will be equal to the total number of nodes in the sideset */ for (int j=0; j<n1; j++) n2+=junk[j]; } iscr.resize(n1); jscr.resize(n2); ex_get_side_set_node_list(exo_file,ids[i],TOPTR(iscr),TOPTR(jscr)); /* number-of-nodes-per-side list */ sprintf(str,"ssnum%02d",i+1); PutInt(str,n1,1,TOPTR(iscr)); /* nodes list */ sprintf(str,"ssnod%02d",i+1); PutInt(str,n2,1,TOPTR(jscr)); /* distribution-factors list */ scr.resize(n2); if (has_ss_dfac) { ex_get_side_set_dist_fact(exo_file,ids[i], TOPTR(scr)); } else { for (int j=0; j<n2; j++) { scr[j] = 1.0; } } sprintf(str,"ssfac%02d",i+1); PutDbl(str,n2,1,TOPTR(scr)); /* element and side list for side sets (dgriffi) */ elem_list.resize(n1); side_list.resize(n1); ex_get_set(exo_file,EX_SIDE_SET,ids[i],TOPTR(elem_list),TOPTR(side_list)); sprintf(str,"ssside%02d",i+1); PutInt(str,n1,1,TOPTR(side_list)); sprintf(str,"sselem%02d",i+1); PutInt(str,n1,1,TOPTR(elem_list)); } /* Store # sides and # dis. factors per side set (dgriffi) */ PutInt("nsssides",num_side_sets,1,TOPTR(num_sideset_sides)); PutInt("nssdfac",num_side_sets,1,TOPTR(nssdfac)); } /* node sets (section by dgriffi) */ std::vector<int> num_nodeset_nodes(num_node_sets); if (num_node_sets > 0){ if (debug) {logger("Node Sets");} std::vector<int> iscr; std::vector<double> scr; ids.resize(num_node_sets); ex_get_ids(exo_file,EX_NODE_SET, TOPTR(ids)); PutInt( "nsids",num_node_sets, 1,TOPTR(ids)); std::vector<int> num_nodeset_df(num_node_sets); for (int i=0;i<num_node_sets;i++){ ex_get_set_param(exo_file,EX_NODE_SET,ids[i],&n1,&n2); iscr.resize(n1); ex_get_node_set(exo_file,ids[i],TOPTR(iscr)); /* nodes list */ sprintf(str,"nsnod%02d",i+1); PutInt(str,n1,1,TOPTR(iscr)); { /* distribution-factors list */ scr.resize(n2); ex_get_node_set_dist_fact(exo_file,ids[i],TOPTR(scr)); sprintf(str,"nsfac%02d",i+1); PutDbl(str,n2,1,TOPTR(scr)); } num_nodeset_nodes[i]=n1; num_nodeset_df[i]=n2; } /* Store # nodes and # dis. factors per node set */ PutInt("nnsnodes",num_node_sets,1,TOPTR(num_nodeset_nodes)); PutInt("nnsdfac",num_node_sets,1,TOPTR(num_nodeset_df)); } /* element blocks */ if (debug) {logger("Element Blocks");} std::vector<int> num_elem_in_block(num_blocks); { ids.resize(num_blocks); std::vector<int> iscr; ex_get_ids(exo_file,EX_ELEM_BLOCK,TOPTR(ids)); PutInt( "blkids",num_blocks, 1,TOPTR(ids)); for (int i=0;i<num_blocks;i++) { ex_get_elem_block(exo_file,ids[i],str2[i],&n,&n1,&n2); num_elem_in_block[i]=n; iscr.resize(n*n1); ex_get_conn(exo_file,EX_ELEM_BLOCK,ids[i],TOPTR(iscr), nullptr, nullptr); sprintf(str,"blk%02d",i+1); PutInt(str,n1,n,TOPTR(iscr)); } str[0]='\0'; for (int i=0;i<num_blocks;i++) { strcat(str, str2[i]); strcat(str, "\n"); } PutStr("blknames",str); } /* time values */ if (num_time_steps > 0 ) { if (debug) {logger("Time Steps");} std::vector<double> scr(num_time_steps); ex_get_all_times (exo_file, TOPTR(scr)); PutDbl( "time", num_time_steps, 1, TOPTR(scr)); } /* global variables */ if (num_global_vars > 0 ) { if (debug) {logger("Global Variables");} get_put_names(exo_file, EX_GLOBAL, num_global_vars, "gnames"); std::vector<double> scr(num_time_steps); for (int i=0;i<num_global_vars;i++){ sprintf(str,"gvar%02d",i+1); ex_get_glob_var_time(exo_file,i+1,1,num_time_steps,TOPTR(scr)); PutDbl(str,num_time_steps,1,TOPTR(scr)); } } /* nodal variables */ if (num_nodal_vars > 0 ) { if (debug) {logger("Nodal Variables");} if (debug) {logger("\tNames");} get_put_names(exo_file, EX_NODAL, num_nodal_vars, "nnames"); std::vector<double> scr(num_nodes*num_time_steps); for (int i=0; i<num_nodal_vars; i++){ sprintf(str,"nvar%02d",i+1); if (debug) {logger("\tReading");} for (int j=0; j<num_time_steps; j++) { ex_get_nodal_var(exo_file,j+1,i+1,num_nodes, &scr[num_nodes*j]); } if (debug) {logger("\tWriting");} PutDbl(str,num_nodes,num_time_steps,TOPTR(scr)); } } /* element variables */ if (num_element_vars > 0 ) { if (debug) {logger("Element Variables");} get_put_names(exo_file, EX_ELEM_BLOCK, num_element_vars, "enames"); get_put_vars(exo_file, EX_ELEM_BLOCK, num_blocks, num_element_vars, num_time_steps, num_elem_in_block, "evar%02d"); } /* nodeset variables */ if (num_nodeset_vars > 0 ) { if (debug) {logger("Nodeset Variables");} get_put_names(exo_file, EX_NODE_SET, num_nodeset_vars, "nsnames"); get_put_vars(exo_file, EX_NODE_SET, num_node_sets, num_nodeset_vars, num_time_steps, num_nodeset_nodes, "nsvar%02d"); } /* sideset variables */ if (num_sideset_vars > 0 ) { if (debug) {logger("Sideset Variables");} get_put_names(exo_file, EX_SIDE_SET, num_sideset_vars, "ssnames"); get_put_vars(exo_file, EX_SIDE_SET, num_side_sets, num_sideset_vars, num_time_steps, num_sideset_sides, "ssvar%02d"); } /* node and element number maps */ if (debug) {logger("Node and Element Number Maps");} ex_opts(0); /* turn off error reporting. It is not an error to have no map*/ ids.resize(num_nodes); err = ex_get_node_num_map(exo_file,TOPTR(ids)); if ( err==0 ){ PutInt("node_num_map",num_nodes,1,TOPTR(ids)); } ids.resize(num_elements); err = ex_get_elem_num_map(exo_file,TOPTR(ids)); if ( err==0 ){ PutInt("elem_num_map",num_elements,1,TOPTR(ids)); } if (debug) {logger("Closing file");} ex_close(exo_file); if ( textfile ) fclose(m_file); else Mat_Close(mat_file); std::cout << "done...\n"; free(filename); free(line); delete_exodus_names(str2, nstr2); /* exit status */ add_to_log("exo2mat", 0); return(0); }