15 #define RES_BIN_HEADER "HECMW_BINARY_RESULT"
23 static int write_bin_header(FILE* fp) {
29 if( fwrite( s,
sizeof(
char), n, fp) != n )
return -1;
31 sprintf( nbyte,
"%2d", n );
32 if( fwrite( nbyte,
sizeof(
char), 2, fp) != 2 )
return -1;
37 static int check_bin_header(FILE* fp) {
40 char buff[256], nbyte[3];
42 if( fread( buff,
sizeof(
char), n, fp) != n )
return 0;
43 if( fread( nbyte,
sizeof(
char), 2, fp) != 2 )
return 0;
46 return ( strcmp( buff, s ) == 0 );
54 if((fp = fopen(filename,
"rb")) ==
NULL) {
60 rcode = check_bin_header(fp);
72 static int bin_output_result_header(FILE *fp) {
89 static int bin_output_result_global(FILE *fp) {
90 int i,j,k,n,rc,ng_comp;
141 if(ng_comp == 0)
return 0;
151 for(j=0; j < ng_comp; j++) {
153 for(k=0; k < p->
n_dof; k++) {
167 static int bin_output_result_dataheader(FILE *fp) {
188 static int bin_output_result_node(FILE *fp) {
189 int i,j,k,n,rc,nn_comp;
214 if(nn_comp == 0)
return 0;
224 for(i=0; i <
nnode; i++) {
230 for(j=0; j < nn_comp; j++) {
232 for(k=0; k < p->
n_dof; k++) {
247 static int bin_output_result_elem(FILE *fp) {
248 int i,j,k,n,rc,ne_comp;
273 if(ne_comp == 0)
return 0;
283 for(i=0; i <
nelem; i++) {
289 for(j=0; j < ne_comp; j++) {
291 for(k=0; k < p->
n_dof; k++) {
306 static int bin_output_result_data(FILE *fp) {
310 if(bin_output_result_header(fp)) {
314 if(bin_output_result_global(fp)) {
324 if(bin_output_result_dataheader(fp)) {
327 if(bin_output_result_node(fp)) {
330 if(bin_output_result_elem(fp)) {
350 if ((fp = fopen(filename,
"wb")) ==
NULL) {
357 if (write_bin_header(fp))
goto error;
358 if (bin_output_result_data(fp))
goto error;
379 char *header, FILE *fp) {
390 while(len <
sizeof(
head)-1 && *p && *p !=
'\n') {
412 char *comment, FILE *fp) {
413 int i,j,k,n,m,rc,len;
417 if(comment ==
NULL) {
423 while(len <
sizeof(
comment_line)-1 && *p && *p !=
'\n') {
480 for(k=0; k < result->
ng_dof[j]; k++) {
502 int n_node,
int n_elem, FILE *fp) {
524 int n_node, FILE *fp) {
550 for(i=0; i < n_node; i++) {
557 for(k=0; k < result->
nn_dof[j]; k++) {
573 int n_elem, FILE *fp) {
599 for(i=0; i < n_elem; i++) {
606 for(k=0; k < result->
ne_dof[j]; k++) {
622 int n_node,
int n_elem,
char *header,
623 char *comment, FILE *fp) {
626 if(bin_output_result_header_ST(result, header, fp)) {
630 if(bin_output_result_global_ST(result, comment, fp)) {
634 if(bin_output_result_dataheader_ST(result, n_node, n_elem, fp)) {
637 if(bin_output_result_node_ST(result, n_node, fp)) {
640 if(bin_output_result_elem_ST(result, n_elem, fp)) {
651 int n_node,
int n_elem,
char *header,
char *comment) {
662 if ((fp = fopen(filename,
"wb")) ==
NULL) {
669 if (write_bin_header(fp))
goto error;
670 if (bin_output_result_data_ST(result, n_node, n_elem, header, comment, fp))
goto error;
782 for(k=0; k < result->
ng_dof[j]; k++) {
802 int *n_node,
int *n_elem, FILE *fp) {
823 static int bin_input_result_node(
struct hecmwST_result_data *result,
int n_node, FILE *fp) {
879 for(i=0; i < n_node; i++) {
885 for(k=0; k < result->
nn_dof[j]; k++) {
900 static int bin_input_result_elem(
struct hecmwST_result_data *result,
int n_elem, FILE *fp) {
956 for(i=0; i < n_elem; i++) {
962 for(k=0; k < result->
ne_dof[j]; k++) {
989 if(bin_input_result_header(result, fp)) {
994 if(bin_input_result_global(result, fp)) {
998 if(bin_input_result_dataheader(result, &n_node, &n_elem, fp)) {
1004 if(bin_input_result_node(result, n_node, fp)) {
1008 if(bin_input_result_elem(result, n_elem, fp)) {
1023 if((fp = fopen(filename,
"rb")) ==
NULL) {
1030 if(!check_bin_header(fp)) {
1035 result = bin_input_result_data(fp);
1036 if(result ==
NULL) {
void hecmw_set_endian_info(void)
int hecmw_write_bin(FILE *fp, const char *fmt,...)
int hecmw_read_bin(FILE *fp, const char *fmt,...)
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 hecmwST_result_data * HECMW_result_read_bin_by_fname(char *filename)
int HECMW_result_write_bin_by_fname(char *filename)
int HECMW_judge_result_bin_file(char *filename)
int HECMW_result_write_bin_ST_by_fname(char *filename, struct hecmwST_result_data *result, int n_node, int n_elem, char *header, char *comment)
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]
#define HECMW_assert(cond)
struct result_list * next