19 static int output_result_header(FILE *fp) {
26 rc = fprintf(fp,
"%s\n",
head);
36 static int output_result_global(FILE *fp) {
37 int i,j,k,n,rc,ng_comp;
41 rc = fprintf(fp,
"*comment\n");
53 rc = fprintf(fp,
"*global\n");
69 rc = fprintf(fp,
"%d%c", p->
n_dof, (n+1)%
COL_INT ?
' ' :
'\n');
77 rc = fprintf(fp,
"\n");
86 rc = fprintf(fp,
"%s\n", p->
label);
95 if(ng_comp == 0)
return 0;
106 for(j=0; j < ng_comp; j++) {
108 for(k=0; k < p->
n_dof; k++) {
109 rc = fprintf(fp,
"%.16E%c", p->
ptr[k], (n+1)%
COL_DOUBLE ?
' ' :
'\n');
118 rc = fprintf(fp,
"\n");
130 static int output_result_dataheader(FILE *fp) {
134 rc = fprintf(fp,
"%d %d\n", nnode, nelem);
151 static int output_result_node(FILE *fp) {
152 int i,j,k,n,rc,nn_comp;
158 rc = fprintf(fp,
"%d%c", p->
n_dof, (n+1)%
COL_INT ?
' ' :
'\n');
166 rc = fprintf(fp,
"\n");
175 rc = fprintf(fp,
"%s\n", p->
label);
184 if(nn_comp == 0)
return 0;
194 for(i=0; i <
nnode; i++) {
201 for(j=0; j < nn_comp; j++) {
203 for(k=0; k < p->
n_dof; k++) {
213 rc = fprintf(fp,
"\n");
226 static int output_result_elem(FILE *fp) {
227 int i,j,k,n,rc,ne_comp;
233 rc = fprintf(fp,
"%d%c", p->
n_dof, (n+1)%
COL_INT ?
' ' :
'\n');
241 rc = fprintf(fp,
"\n");
250 rc = fprintf(fp,
"%s\n", p->
label);
259 if(ne_comp == 0)
return 0;
269 for(i=0; i <
nelem; i++) {
276 for(j=0; j < ne_comp; j++) {
278 for(k=0; k < p->
n_dof; k++) {
288 rc = fprintf(fp,
"\n");
301 static int output_result_data(FILE *fp) {
305 if(output_result_header(fp)) {
309 if(output_result_global(fp)) {
313 rc = fprintf(fp,
"*data\n");
319 if(output_result_dataheader(fp)) {
322 if(output_result_node(fp)) {
325 if(output_result_elem(fp)) {
345 if ((fp = fopen(filename,
"w")) ==
NULL) {
351 if (output_result_data(fp)) {
373 static int output_result_header_ST(
struct hecmwST_result_data *result,
char *header, FILE *fp) {
384 while(len <
sizeof(
head)-1 && *p && *p !=
'\n') {
395 rc = fprintf(fp,
"%s\n",
head);
405 static int output_result_global_ST(
struct hecmwST_result_data *result,
char *comment, FILE *fp) {
410 if(comment ==
NULL) {
416 while(len <
sizeof(
comment_line)-1 && *p && *p !=
'\n') {
424 rc = fprintf(fp,
"*comment\n");
429 rc = fprintf(fp,
"%s\n", comment);
437 rc = fprintf(fp,
"*global\n");
453 rc = fprintf(fp,
"%d%c", result->
ng_dof[i], (n+1)%
COL_INT ?
' ' :
'\n');
461 rc = fprintf(fp,
"\n");
481 for(k=0; k < result->
ng_dof[j]; k++) {
491 rc = fprintf(fp,
"\n");
499 rc = fprintf(fp,
"*data\n");
510 int n_node,
int n_elem, FILE *fp) {
514 rc = fprintf(fp,
"%d %d\n", n_node, n_elem);
531 static int output_result_node_ST(
struct hecmwST_result_data *result,
int n_node, FILE *fp) {
537 rc = fprintf(fp,
"%d%c", result->
nn_dof[i], (n+1)%
COL_INT ?
' ' :
'\n');
545 rc = fprintf(fp,
"\n");
554 rc = fprintf(fp,
"%s\n", result->
node_label[i]);
564 for(i=0; i < n_node; i++) {
572 for(k=0; k < result->
nn_dof[j]; k++) {
583 rc = fprintf(fp,
"\n");
595 static int output_result_elem_ST(
struct hecmwST_result_data *result,
int n_elem, FILE *fp) {
601 rc = fprintf(fp,
"%d%c", result->
ne_dof[i], (n+1)%
COL_INT ?
' ' :
'\n');
609 rc = fprintf(fp,
"\n");
618 rc = fprintf(fp,
"%s\n", result->
elem_label[i]);
628 for(i=0; i < n_elem; i++) {
636 for(k=0; k < result->
ne_dof[j]; k++) {
647 rc = fprintf(fp,
"\n");
659 static int output_result_data_ST(
struct hecmwST_result_data *result,
int n_node,
int n_elem,
660 char *header,
char *comment, FILE *fp) {
663 if(output_result_header_ST(result, header, fp)) {
667 if(output_result_global_ST(result, comment, fp)) {
671 if(output_result_dataheader_ST(result, n_node, n_elem, fp)) {
674 if(output_result_node_ST(result, n_node, fp)) {
677 if(output_result_elem_ST(result, n_elem, fp)) {
688 int n_node,
int n_elem,
char *header,
char *comment) {
699 if ((fp = fopen(filename,
"w")) ==
NULL) {
705 if (output_result_data_ST(result, n_node, n_elem, header, comment, fp)) {
727 static int get_line(
char *buf,
int bufsize, FILE *fp) {
728 if(fgets(buf, bufsize, fp) ==
NULL) {
800 while(i < result->ng_component) {
801 p = strtok(buf,
DELIM);
810 rc = sscanf(p,
"%d", &result->
ng_dof[i]);
863 p = strtok(buf,
DELIM);
894 int *n_node,
int *n_elem, FILE *fp) {
900 if(sscanf(
line_buf,
"%d%d", n_node, n_elem) != 2) {
940 while(i < result->nn_component) {
941 p = strtok(buf,
DELIM);
950 rc = sscanf(p,
"%d", &result->
nn_dof[i]);
1009 while(i < n*n_node) {
1010 p = strtok(buf,
DELIM);
1023 rc = sscanf(p,
"%lf", &result->
node_val_item[i-label_counter]);
1062 while(i < result->ne_component) {
1064 p = strtok(buf,
DELIM);
1073 rc = sscanf(p,
"%d", &result->
ne_dof[i]);
1133 while(i < n*n_elem) {
1134 p = strtok(buf,
DELIM);
1147 rc = sscanf(p,
"%lf", &result->
elem_val_item[i-label_counter]);
1171 if(result ==
NULL) {
1175 if(input_result_header(result, fp)) {
1179 if(input_result_global(result, fp)) {
1183 if(input_result_dataheader(result, &n_node, &n_elem, fp)) {
1188 if(input_result_node(result, n_node, fp)) {
1191 if(input_result_elem(result, n_elem, fp)) {
1204 if((fp = fopen(filename,
"r")) ==
NULL) {
1209 result = input_result_data(fp);
1210 if(result ==
NULL) {
int HECMW_ctrl_is_subdir(void)
int HECMW_ctrl_make_subdir(char *filename)
int HECMW_set_error(int errorno, const char *fmt,...)
#define HECMW_calloc(nmemb, size)
#define HECMW_malloc(size)
char * HECMW_strmsg(int msgno)
struct result_list * node_list
struct result_list * elem_list
char line_buf[LINEBUF_SIZE+1]
int HECMW_result_count_ne_comp(void)
int HECMW_result_count_ng_comp(void)
struct result_list * global_list
char comment_line[HECMW_MSG_LEN+1]
int HECMW_result_count_nn_comp(void)
char head[HECMW_HEADER_LEN+1]
struct hecmwST_result_data * HECMW_result_read_txt_by_fname(char *filename)
int HECMW_result_write_txt_by_fname(char *filename)
int HECMW_result_write_txt_ST_by_fname(char *filename, struct hecmwST_result_data *result, int n_node, int n_elem, char *header, char *comment)
#define HECMW_assert(cond)
struct result_list * next