📄 expcab.c
字号:
cur_num_edge_blk=ex_get_file_item(exoid, ex_get_counter_list(EX_EDGE_BLOCK)); if (cur_num_edge_blk >= num_edge_blk) { exerrval = EX_FATAL; sprintf(errmsg, "Error: exceeded number of edge blocks (%ld) defined in file id %d", num_edge_blk,exoid); ex_err("ex_put_concat_all_blocks",errmsg,exerrval); goto error_ret; } /* NOTE: ex_inc_file_item is used to find the number of edge blocks for a specific file and returns that value incremented. */ cur_num_edge_blk=ex_inc_file_item(exoid, ex_get_counter_list(EX_EDGE_BLOCK)); if (param->num_edge_this_blk[iblk] == 0) /* Is this a NULL edge block? */ continue; /* define some dimensions and variables*/ if ((status = nc_def_dim(exoid, DIM_NUM_ED_IN_EBLK(cur_num_edge_blk+1), param->num_edge_this_blk[iblk],&numedbdim)) != NC_NOERR) { exerrval = status; if (status == NC_ENAMEINUSE) { /* duplicate entry */ sprintf(errmsg, "Error: edge block %d already defined in file id %d", param->edge_blk_id[iblk],exoid); } else { sprintf(errmsg, "Error: failed to define number of edges/block for block %d file id %d", param->edge_blk_id[iblk],exoid); } ex_err("ex_put_concat_all_blocks",errmsg,exerrval); goto error_ret; /* exit define mode and return */ } if ((status = nc_def_dim(exoid, DIM_NUM_NOD_PER_ED(cur_num_edge_blk+1), param->num_nodes_per_edge[iblk],&nednoddim)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to define number of nodes/edge for block %d in file id %d", param->edge_blk_id[iblk],exoid); ex_err("ex_put_concat_all_blocks",errmsg,exerrval); goto error_ret; /* exit define mode and return */ } /* edge attribute array */ EX_PREPARE_ATTRIB_ARRAY("edge",cur_num_edge_blk,DIM_NUM_ATT_IN_EBLK,param->num_attr_edge,param->edge_blk_id,VAR_EATTRIB,numedbdim,numattrdim,VAR_NAME_EATTRIB); EX_PREPARE_CONN("edge block",cur_num_edge_blk,param->edge_blk_id,numedbdim,VAR_EBCONN,nednoddim); /* store edge type as attribute of connectivity variable */ if ((status = nc_put_att_text(exoid, connid, ATT_NAME_ELB, strlen(param->edge_type[iblk])+1, (void*)param->edge_type[iblk])) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to store edge type name %s in file id %d", param->edge_type[iblk],exoid); ex_err("ex_put_concat_all_blocks",errmsg,exerrval); goto error_ret; /* exit define mode and return */ } } /* Iterate over face blocks ... */ for (iblk = 0; iblk < num_face_blk; ++iblk) { cur_num_face_blk=ex_get_file_item(exoid, ex_get_counter_list(EX_FACE_BLOCK)); if (cur_num_face_blk >= num_face_blk) { exerrval = EX_FATAL; sprintf(errmsg, "Error: exceeded number of face blocks (%ld) defined in file id %d", num_face_blk,exoid); ex_err("ex_put_concat_all_blocks",errmsg,exerrval); goto error_ret; } /* NOTE: ex_inc_file_item is used to find the number of edge blocks for a specific file and returns that value incremented. */ cur_num_face_blk=ex_inc_file_item(exoid, ex_get_counter_list(EX_FACE_BLOCK)); if (param->num_face_this_blk[iblk] == 0) /* Is this a NULL face block? */ continue; /* define some dimensions and variables*/ if ((status = nc_def_dim (exoid, DIM_NUM_FA_IN_FBLK(cur_num_face_blk+1), param->num_face_this_blk[iblk],&numfabdim)) != NC_NOERR) { exerrval = status; if (status == NC_ENAMEINUSE) { /* duplicate entry */ sprintf(errmsg, "Error: face block %d already defined in file id %d", param->face_blk_id[iblk],exoid); } else { sprintf(errmsg, "Error: failed to define number of faces/block for block %d file id %d", param->face_blk_id[iblk],exoid); } ex_err("ex_put_concat_all_blocks",errmsg,exerrval); goto error_ret; /* exit define mode and return */ } if ((status = nc_def_dim (exoid, DIM_NUM_NOD_PER_FA(cur_num_face_blk+1), param->num_nodes_per_face[iblk],&nfanoddim)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to define number of nodes/face for block %d in file id %d", param->face_blk_id[iblk],exoid); ex_err("ex_put_concat_all_blocks",errmsg,exerrval); goto error_ret; /* exit define mode and return */ } /* edge attribute array */ EX_PREPARE_ATTRIB_ARRAY("face",cur_num_face_blk,DIM_NUM_ATT_IN_FBLK,param->num_attr_face,param->face_blk_id,VAR_FATTRIB,numfabdim,numattrdim,VAR_NAME_FATTRIB); EX_PREPARE_CONN("face block",cur_num_face_blk,param->face_blk_id,numfabdim,VAR_FBCONN,nfanoddim); /* store face type as attribute of connectivity variable */ if ((status = nc_put_att_text(exoid, connid, ATT_NAME_ELB, strlen(param->face_type[iblk])+1, (void*)param->face_type[iblk])) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to store face type name %s in file id %d", param->face_type[iblk],exoid); ex_err("ex_put_concat_all_blocks",errmsg,exerrval); goto error_ret; /* exit define mode and return */ } } /* Iterate over element blocks ... */ for (iblk = 0; iblk < num_elem_blk; ++iblk) { cur_num_elem_blk=ex_get_file_item(exoid, ex_get_counter_list(EX_ELEM_BLOCK)); if (cur_num_elem_blk >= num_elem_blk) { exerrval = EX_FATAL; sprintf(errmsg, "Error: exceeded number of element blocks (%ld) defined in file id %d", num_elem_blk,exoid); ex_err("ex_put_concat_all_blocks",errmsg,exerrval); goto error_ret; } /* NOTE: ex_inc_file_item is used to find the number of element blocks for a specific file and returns that value incremented. */ cur_num_elem_blk=ex_inc_file_item(exoid, ex_get_counter_list(EX_ELEM_BLOCK)); if (param->num_elem_this_blk[iblk] == 0) /* Is this a NULL element block? */ continue; /* define some dimensions and variables*/ if ((status = nc_def_dim (exoid, DIM_NUM_EL_IN_BLK(cur_num_elem_blk+1), param->num_elem_this_blk[iblk], &numelbdim)) != NC_NOERR) { exerrval = status; if (status == NC_ENAMEINUSE) { /* duplicate entry */ sprintf(errmsg, "Error: element block %d already defined in file id %d", param->elem_blk_id[iblk],exoid); } else { sprintf(errmsg, "Error: failed to define number of elements/block for block %d file id %d", param->elem_blk_id[iblk],exoid); } ex_err("ex_put_concat_all_blocks",errmsg,exerrval); goto error_ret; /* exit define mode and return */ } /* Always define DIM_NUM_NOD_PER_EL, even if zero. * Do not define DIM_NUM_EDG_PER_EL or DIM_NUM_FAC_PER_EL unless > 0. */ if ((status = nc_def_dim (exoid, DIM_NUM_NOD_PER_EL(cur_num_elem_blk+1), param->num_nodes_per_elem[iblk], &nelnoddim)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to define number of nodes/element for block %d in file id %d", param->elem_blk_id[iblk],exoid); ex_err("ex_put_concat_all_blocks",errmsg,exerrval); goto error_ret; /* exit define mode and return */ } if ( param->num_edges_per_elem[iblk] > 0 ) { if ((status = nc_def_dim (exoid, DIM_NUM_EDG_PER_EL(cur_num_elem_blk+1), param->num_edges_per_elem[iblk],&neledgdim)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to define number of edges/element for block %d in file id %d", param->elem_blk_id[iblk],exoid); ex_err("ex_put_concat_all_blocks",errmsg,exerrval); goto error_ret; /* exit define mode and return */ } } if ( param->num_faces_per_elem[iblk] > 0 ) { if ((status = nc_def_dim(exoid, DIM_NUM_FAC_PER_EL(cur_num_elem_blk+1), param->num_faces_per_elem[iblk],&nelfacdim)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to define number of faces/element for block %d in file id %d", param->elem_blk_id[iblk],exoid); ex_err("ex_put_concat_all_blocks",errmsg,exerrval); goto error_ret; /* exit define mode and return */ } } /* element attribute array */ EX_PREPARE_ATTRIB_ARRAY("element",cur_num_elem_blk,DIM_NUM_ATT_IN_BLK,param->num_attr_elem,param->elem_blk_id,VAR_ATTRIB,numelbdim,numattrdim,VAR_NAME_ATTRIB); /* element connectivity array */ EX_PREPARE_CONN("nodal",cur_num_elem_blk,param->elem_blk_id,numelbdim,VAR_CONN,nelnoddim); /* store element type as attribute of connectivity variable */ if ((status = nc_put_att_text(exoid, connid, ATT_NAME_ELB, strlen(param->elem_type[iblk])+1, (void*)param->elem_type[iblk])) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to store element type name %s in file id %d", param->elem_type[iblk],exoid); ex_err("ex_put_concat_all_blocks",errmsg,exerrval); goto error_ret; /* exit define mode and return */ } EX_PREPARE_CONN( "edge",cur_num_elem_blk,param->elem_blk_id,numelbdim,VAR_ECONN,neledgdim); EX_PREPARE_CONN( "face",cur_num_elem_blk,param->elem_blk_id,numelbdim,VAR_FCONN,nelfacdim); } /* Define the element map here to avoid a later redefine call */ if ( param->define_maps != 0 ) { int map_type; for ( map_type = 0; map_type < num_map_dims; ++map_type ) { if ((status = nc_inq_dimid(exoid, dim_size_maps[map_type], &dims[0])) != NC_NOERR) { exerrval = status; sprintf( errmsg, "Error: could not find map size dimension %s in file id %d", dim_size_maps[map_type], exoid ); ex_err( "ex_put_concat_all_blocks", errmsg, exerrval ); } for ( i = 1; i <= num_maps[map_type]; ++i ) { const char* mapname = ex_name_of_map( map_enums[map_type], i ); if (nc_inq_varid(exoid, mapname, &temp) != NC_NOERR) { if ((status = nc_def_var(exoid, mapname, NC_INT, 1, dims, &temp)) != NC_NOERR) { exerrval = status; if ( status == NC_ENAMEINUSE ) { sprintf( errmsg, "Error: number map %s already exists in file id %d", mapname, exoid ); } else { sprintf( errmsg, "Error: failed to create number map array %s in file id %d", mapname, exoid ); } ex_err( "ex_put_concat_all_blocks", errmsg, exerrval ); goto error_ret; /* exit define mode and return */ } } } } } /* leave define mode */ if ((status = nc_enddef (exoid)) != NC_NOERR) { exerrval = status; sprintf(errmsg, "Error: failed to complete element block definition in file id %d", exoid); ex_err("ex_put_concat_all_blocks",errmsg,exerrval); return (EX_FATAL); } return (EX_NOERR); /* Fatal error: exit definition mode and return */ error_ret: if (nc_enddef (exoid) != NC_NOERR) { /* exit define mode */ sprintf(errmsg, "Error: failed to complete definition for file id %d", exoid); ex_err("ex_put_concat_all_blocks",errmsg,exerrval); } return (EX_FATAL);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -