#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char **argv)
{
int exoid, num_dim, num_nodes, num_elem, num_elem_blk;
int num_elem_in_block[10], num_total_nodes_per_blk[10];
int num_face_in_block[10], num_total_faces_per_blk[10];
int num_face_in_sset[10], num_nodes_in_nset[10];
int num_node_sets, num_side_sets,
error;
int i, j, k, m, *elem_map, *connect;
int node_list[100], elem_list[100], side_list[100];
int bids[10], ssids[10], nsids[10], nnpe[10];
int num_qa_rec, num_info;
int num_glo_vars, num_nod_vars, num_ele_vars, num_sset_vars, num_nset_vars;
int whole_time_step, num_time_steps;
int CPU_word_size, IO_word_size;
int prop_array[2];
float *glob_var_vals, *nodal_var_vals, *elem_var_vals;
float *sset_var_vals, *nset_var_vals;
float time_value;
float x[100], y[100], z[100];
float dist_fact[100];
char * coord_names[3], *qa_record[2][4], *info[3], *var_names[3];
char * block_names[10], *nset_names[10], *sset_names[10];
char * prop_names[2], *attrib_names[2];
char * title = "This is a test";
CPU_word_size = 0;
IO_word_size = 4;
&CPU_word_size,
&IO_word_size);
printf("after ex_create for test.exo, exoid = %d\n", exoid);
printf(" cpu word size: %d io word size: %d\n", CPU_word_size, IO_word_size);
{
num_dim = 3;
num_nodes = 14;
num_elem = 1;
num_elem_blk = 1;
num_node_sets = 0;
strcpy(par.
title, title);
printf("after ex_put_init_ext, error = %d\n", error);
if (error) {
exit(-1);
}
}
x[0] = 0.00000e+00;
y[0] = 0.00000e+00;
z[0] = 0.00000e+00;
x[1] = 2.00000e+00;
y[1] = 0.00000e+00;
z[1] = 0.00000e+00;
x[2] = 0.00000e+00;
y[2] = 2.00000e+00;
z[2] = 0.00000e+00;
x[3] = 2.00000e+00;
y[3] = 2.00000e+00;
z[3] = 0.00000e+00;
x[4] = 0.00000e+00;
y[4] = 0.00000e+00;
z[4] = 2.00000e+00;
x[5] = 2.00000e+00;
y[5] = 0.00000e+00;
z[5] = 2.00000e+00;
x[6] = 0.00000e+00;
y[6] = 2.00000e+00;
z[6] = 2.00000e+00;
x[7] = 2.00000e+00;
y[7] = 2.00000e+00;
z[7] = 2.00000e+00;
x[8] = 0.00000e+00;
y[8] = 3.50000e+00;
z[8] = 1.00000e+00;
x[9] = 2.00000e+00;
y[9] = 3.50000e+00;
z[9] = 1.00000e+00;
x[10] = 0.00000e+00;
y[10] = 3.00000e+00;
z[10] = 1.50000e+00;
x[11] = 2.00000e+00;
y[11] = 3.00000e+00;
z[11] = 1.50000e+00;
x[12] = 0.00000e+00;
y[12] = 3.00000e+00;
z[12] = 0.50000e+00;
x[13] = 2.00000e+00;
y[13] = 3.00000e+00;
z[13] = 0.50000e+00;
printf("after ex_put_coord, error = %d\n", error);
if (error) {
exit(-1);
}
coord_names[0] = "x";
coord_names[1] = "y";
coord_names[2] = "z";
printf("after ex_put_coord_names, error = %d\n", error);
if (error) {
exit(-1);
}
block_names[0] = "face_block_1";
num_face_in_block[0] = 15;
num_total_nodes_per_blk[0] = 54;
bids[0] = 10;
num_total_nodes_per_blk[0], 0, 0, 0);
printf("after ex_put_block, error = %d\n", error);
if (error) {
exit(-1);
}
connect = (int *)calloc(num_total_nodes_per_blk[0], sizeof(int));
i = 0;
j = 0;
connect[i++] = 5;
connect[i++] = 6;
connect[i++] = 8;
connect[i++] = 2;
connect[i++] = 1;
connect[i++] = 4;
connect[i++] = 6;
connect[i++] = 2;
connect[i++] = 4;
connect[i++] = 8;
connect[i++] = 8;
connect[i++] = 4;
connect[i++] = 1;
connect[i++] = 5;
connect[i++] = 1;
connect[i++] = 2;
connect[i++] = 6;
connect[i++] = 5;
connect[i++] = 5;
connect[i++] = 8;
connect[i++] = 7;
connect[i++] = 1;
connect[i++] = 2;
connect[i++] = 3;
connect[i++] = 4;
nnpe[j++] = 4;
connect[i++] = 5;
connect[i++] = 3;
connect[i++] = 4;
connect[i++] = 6;
nnpe[j++] = 4;
connect[i++] = 5;
connect[i++] = 1;
connect[i++] = 2;
connect[i++] = 6;
nnpe[j++] = 4;
connect[i++] = 6;
connect[i++] = 2;
connect[i++] = 4;
nnpe[j++] = 3;
connect[i++] = 5;
connect[i++] = 3;
connect[i++] = 1;
nnpe[j++] = 3;
assert(i == num_total_nodes_per_blk[0]);
assert(j == num_face_in_block[0]);
printf("after ex_put_conn, error = %d\n", error);
if (error) {
exit(-1);
}
free(connect);
connect = NULL;
printf("after ex_put_entity_count_per_polyhedra, error = %d\n", error);
if (error) {
exit(-1);
}
block_names[0] = "nfaced_1";
num_elem_in_block[0] = 1;
num_total_nodes_per_blk[0] = 6;
num_total_faces_per_blk[0] = 5;
bids[0] = 10;
num_total_faces_per_blk[0], 0);
printf("after ex_put_block, error = %d\n", error);
if (error) {
exit(-1);
}
printf("after ex_put_names, error = %d\n", error);
if (error) {
exit(-1);
}
printf("after ex_put_names, error = %d\n", error);
if (error) {
exit(-1);
}
connect = (int *)calloc(num_total_faces_per_blk[0], sizeof(int));
i = 0;
j = 0;
connect[i++] = 1;
connect[i++] = 2;
connect[i++] = 3;
connect[i++] = 4;
connect[i++] = 5;
nnpe[j++] = 5;
assert(i == num_total_faces_per_blk[0]);
assert(j == num_elem_in_block[0]);
printf("after ex_put_conn, error = %d\n", error);
if (error) {
exit(-1);
}
free(connect);
printf("after ex_put_entity_count_per_polyhedra, error = %d\n", error);
if (error) {
exit(-1);
}
num_qa_rec = 2;
qa_record[0][0] = "TESTWT-NFACED";
qa_record[0][1] = "testwt-nfaced";
qa_record[0][2] = "2010/02/15";
qa_record[0][3] = "06:35:15";
qa_record[1][0] = "";
qa_record[1][1] = " ";
qa_record[1][2] = "";
qa_record[1][3] = " ";
error =
ex_put_qa(exoid, num_qa_rec, qa_record);
printf("after ex_put_qa, error = %d\n", error);
if (error) {
exit(-1);
}
num_info = 3;
info[0] = "This is the first information record.";
info[1] = "";
info[2] = " ";
printf("after ex_put_info, error = %d\n", error);
if (error) {
exit(-1);
}
num_glo_vars = 1;
var_names[0] = "glo_vars";
printf("after ex_put_variable_param, error = %d\n", error);
if (error) {
exit(-1);
}
printf("after ex_put_variable_names, error = %d\n", error);
if (error) {
exit(-1);
}
num_nod_vars = 2;
var_names[0] = "node_variable_a_very_long_name_0";
printf("after ex_put_variable_param, error = %d\n", error);
if (error) {
exit(-1);
}
printf("after ex_put_variable_names, error = %d\n", error);
if (error) {
exit(-1);
}
num_ele_vars = 3;
var_names[0] = "ele_var0";
var_names[1] = "ele_var1";
var_names[2] = "ele_var2";
printf("after ex_put_variable_param, error = %d\n", error);
if (error) {
exit(-1);
}
printf("after ex_put_variable_names, error = %d\n", error);
if (error) {
exit(-1);
}
truth_tab = (int *)calloc((num_elem_blk * num_ele_vars), sizeof(int));
k = 0;
for (i = 0; i < num_elem_blk; i++) {
for (j = 0; j < num_ele_vars; j++) {
truth_tab[k++] = 1;
}
}
printf("after ex_put_elem_var_tab, error = %d\n", error);
if (error) {
exit(-1);
}
free(truth_tab);
whole_time_step = 1;
num_time_steps = 10;
glob_var_vals = (float *)calloc(num_glo_vars, CPU_word_size);
nodal_var_vals = (float *)calloc(num_nodes, CPU_word_size);
elem_var_vals = (float *)calloc(8, CPU_word_size);
for (i = 0; i < num_time_steps; i++) {
time_value = (float)(i + 1) / 100.;
error =
ex_put_time(exoid, whole_time_step, &time_value);
printf("after ex_put_time, error = %d\n", error);
if (error) {
exit(-1);
}
for (j = 0; j < num_glo_vars; j++) {
glob_var_vals[j] = (float)(j + 2) * time_value;
}
printf("after ex_put_glob_vars, error = %d\n", error);
if (error) {
exit(-1);
}
for (k = 1; k <= num_nod_vars; k++) {
for (j = 0; j < num_nodes; j++) {
nodal_var_vals[j] = (float)k + ((float)(j + 1) * time_value);
}
printf("after ex_put_nodal_var, error = %d\n", error);
if (error) {
exit(-1);
}
}
for (k = 1; k <= num_ele_vars; k++) {
for (j = 0; j < num_elem_blk; j++) {
for (m = 0; m < num_elem_in_block[j]; m++) {
elem_var_vals[m] = (float)(k + 1) + (float)(j + 2) + ((float)(m + 1) * time_value);
}
error =
ex_put_elem_var(exoid, whole_time_step, k, bids[j], num_elem_in_block[j],
elem_var_vals);
printf("after ex_put_elem_var, error = %d\n", error);
if (error) {
exit(-1);
}
}
}
whole_time_step++;
printf("after ex_update, error = %d\n", error);
if (error) {
exit(-1);
}
}
free(glob_var_vals);
free(nodal_var_vals);
free(elem_var_vals);
printf("after ex_close, error = %d\n", error);
if (error) {
exit(-1);
}
return 0;
}