PageRenderTime 71ms CodeModel.GetById 2ms app.highlight 62ms RepoModel.GetById 1ms app.codeStats 1ms

/contrib/exodusii/5.22b/exodus/cbind/test/testwtbig.c

https://bitbucket.org/vijaysm/libmesh
C | 776 lines | 342 code | 168 blank | 266 comment | 14 complexity | 83f2f8725f367c4dbc3fe775a8920839 MD5 | raw file
  1/*
  2 * Copyright (c) 2005 Sandia Corporation. Under the terms of Contract
  3 * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Governement
  4 * retains certain rights in this software.
  5 * 
  6 * Redistribution and use in source and binary forms, with or without
  7 * modification, are permitted provided that the following conditions are
  8 * met:
  9 * 
 10 *     * Redistributions of source code must retain the above copyright
 11 *       notice, this list of conditions and the following disclaimer.
 12 * 
 13 *     * Redistributions in binary form must reproduce the above
 14 *       copyright notice, this list of conditions and the following
 15 *       disclaimer in the documentation and/or other materials provided
 16 *       with the distribution.  
 17 * 
 18 *     * Neither the name of Sandia Corporation nor the names of its
 19 *       contributors may be used to endorse or promote products derived
 20 *       from this software without specific prior written permission.
 21 * 
 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 33 * 
 34 */
 35/*****************************************************************************
 36*
 37* testwtbig - test write a BIG ExodusII database file
 38*
 39* author - Sandia National Laboratories
 40*          Larry A. Schoof - Original
 41*          Vic Yarberry    - Added headers and error logging
 42*               7/7/93          Modified for use with Exodus 2.00
 43*
 44*          
 45* environment - UNIX
 46*
 47* entry conditions - 
 48*
 49* exit conditions - 
 50*
 51* revision history - 
 52*
 53*  This is a test program for the C binding of the EXODUS II 
 54*  database write routines.
 55*
 56*
 57*****************************************************************************/
 58
 59#define BIG 100000
 60
 61#include <stdlib.h>
 62#include <stdio.h>
 63#include "netcdf.h"
 64#include "exodusII.h"
 65
 66int main (int argc, char **argv)
 67{
 68   int exoid, num_dim, num_nodes, num_elem, num_elem_blk;
 69   int num_elem_in_block[10], num_nodes_per_elem[10];
 70   int num_node_sets, num_sides, num_side_sets, error;
 71   int i, j, k, m, *elem_map, *connect;
 72   int node_list[100],elem_list[100],side_list[100];
 73   int ebids[10], ids[10];
 74   int num_sides_per_set[10], num_nodes_per_set[10], num_elem_per_set[10];
 75   int num_df_per_set[10];
 76   int df_ind[10], node_ind[10], elem_ind[10], side_ind[10];
 77   int  num_qa_rec, num_info;
 78   int num_glo_vars, num_nod_vars, num_ele_vars;
 79   int *truth_tab;
 80   int whole_time_step, num_time_steps;
 81   int ndims, nvars, ngatts, recdim;
 82   int CPU_word_size,IO_word_size;
 83   int prop_array[2];
 84
 85   float *glob_var_vals, *nodal_var_vals, *elem_var_vals;
 86   float time_value;
 87   float *x, *y, *z, *dummy;
 88   float attrib[1], dist_fact[100];
 89   char *coord_names[3], *qa_record[2][4], *info[3], *var_names[3];
 90   char tmpstr[80];
 91   char *prop_names[2];
 92
 93   ex_opts (EX_VERBOSE | EX_ABORT);
 94
 95   dummy = 0; /* assign this so the Cray compiler doesn't complain */
 96
 97/* Specify compute and i/o word size */
 98
 99   CPU_word_size = 0;                   /* sizeof(float) */
100   IO_word_size = 4;                    /* (4 bytes) */
101
102/* create EXODUS II file */
103
104   exoid = ex_create ("test.exo",       /* filename path */
105                       EX_CLOBBER,      /* create mode */
106                       &CPU_word_size,  /* CPU float word size in bytes */
107                       &IO_word_size);  /* I/O float word size in bytes */
108   printf ("after ex_create for test.exo, exoid = %d\n", exoid);
109   printf (" cpu word size: %d io word size: %d\n",CPU_word_size,IO_word_size);
110
111   /* ncopts = NC_VERBOSE; */
112
113/* initialize file with parameters */
114
115   num_dim = 3;
116   num_nodes = BIG;
117   num_elem = BIG;
118   num_elem_blk = 5;
119   num_node_sets = 2;
120   num_side_sets = 5;
121
122   error = ex_put_init (exoid, "This is a test", num_dim, num_nodes, num_elem,
123                        num_elem_blk, num_node_sets, num_side_sets);
124
125   printf ("after ex_put_init, error = %d\n", error);
126
127/* write nodal coordinates values and names to database */
128
129   if (!(x = (float *) calloc(BIG, sizeof(float))))
130   {
131     printf ("couldn't allocate memory for x node array%d\n");
132     exit(1);
133   }
134
135   if (!(y = (float *) calloc(BIG, sizeof(float))))
136   {
137     printf ("couldn't allocate memory for y node array%d\n");
138     exit(1);
139   }
140
141   if (!(z = (float *) calloc(BIG, sizeof(float))))
142   {
143     printf ("couldn't allocate memory for z node array%d\n");
144     exit(1);
145   }
146
147   for (i=0; i<num_nodes; i++)
148   {
149     /* dummy up the coordinate space */
150     x[i]=i;
151     y[i]=i+.1;
152     z[i]=i+.2;
153   }
154
155   error = ex_put_coord (exoid, x, y, z);
156   printf ("after ex_put_coord, error = %d\n", error);
157
158
159   coord_names[0] = "xcoor";
160   coord_names[1] = "ycoor";
161   coord_names[2] = "zcoor";
162
163   error = ex_put_coord_names (exoid, coord_names);
164   printf ("after ex_put_coord_names, error = %d\n", error);
165
166
167/* write element order map */
168
169   elem_map = (int *) calloc(num_elem, sizeof(int));
170
171   for (i=1; i<=num_elem; i++)
172   {
173      elem_map[i-1] = i;
174   }
175
176   error = ex_put_map (exoid, elem_map);
177   printf ("after ex_put_map, error = %d\n", error);
178
179   free (elem_map);
180
181
182/* write element block parameters */
183
184   num_elem_in_block[0] = 1;
185   num_elem_in_block[1] = 1;
186   num_elem_in_block[2] = 1;
187   num_elem_in_block[3] = 1;
188   num_elem_in_block[4] = 1;
189
190   num_nodes_per_elem[0] = 4; /* elements in block #1 are 4-node quads  */
191   num_nodes_per_elem[1] = 4; /* elements in block #2 are 4-node quads  */
192   num_nodes_per_elem[2] = 8; /* elements in block #3 are 8-node hexes  */
193   num_nodes_per_elem[3] = 4; /* elements in block #3 are 4-node tetras */
194   num_nodes_per_elem[4] = 6; /* elements in block #3 are 6-node wedges */
195
196   ebids[0] = 10;
197   ebids[1] = 11;
198   ebids[2] = 12;
199   ebids[3] = 13;
200   ebids[4] = 14;
201
202   error = ex_put_elem_block (exoid, ebids[0], "quad", num_elem_in_block[0],
203                              num_nodes_per_elem[0], 1);
204   printf ("after ex_put_elem_block, error = %d\n", error);
205
206   error = ex_put_elem_block (exoid, ebids[1], "quad", num_elem_in_block[1],
207                               num_nodes_per_elem[1], 1);
208   printf ("after ex_put_elem_block, error = %d\n", error);
209
210   error = ex_put_elem_block (exoid, ebids[2], "hex", num_elem_in_block[2],
211                               num_nodes_per_elem[2], 1);
212   printf ("after ex_put_elem_block, error = %d\n", error);
213
214   error = ex_put_elem_block (exoid, ebids[3], "tetra", num_elem_in_block[3],
215                               num_nodes_per_elem[3], 1);
216   printf ("after ex_put_elem_block, error = %d\n", error);
217
218   error = ex_put_elem_block (exoid, ebids[4], "wedge", num_elem_in_block[4],
219                               num_nodes_per_elem[4], 1);
220   printf ("after ex_put_elem_block, error = %d\n", error);
221
222/* write element block properties */
223
224   prop_names[0] = "MATL";
225   prop_names[1] = "DENSITY";
226   error = ex_put_prop_names(exoid,EX_ELEM_BLOCK,2,prop_names);
227   printf ("after ex_put_prop_names, error = %d\n", error);
228
229   error = ex_put_prop(exoid, EX_ELEM_BLOCK, ebids[0], "MATL", 10);
230   printf ("after ex_put_prop, error = %d\n", error);
231   error = ex_put_prop(exoid, EX_ELEM_BLOCK, ebids[1], "MATL", 20);
232   printf ("after ex_put_prop, error = %d\n", error);
233   error = ex_put_prop(exoid, EX_ELEM_BLOCK, ebids[2], "MATL", 30);
234   printf ("after ex_put_prop, error = %d\n", error);
235   error = ex_put_prop(exoid, EX_ELEM_BLOCK, ebids[3], "MATL", 40);
236   printf ("after ex_put_prop, error = %d\n", error);
237   error = ex_put_prop(exoid, EX_ELEM_BLOCK, ebids[4], "MATL", 50);
238   printf ("after ex_put_prop, error = %d\n", error);
239
240/* write element connectivity */
241
242   connect = (int *) calloc(8, sizeof(int));
243   connect[0] = 1; connect[1] = 2; connect[2] = 3; connect[3] = 4;
244
245   error = ex_put_elem_conn (exoid, ebids[0], connect);
246   printf ("after ex_put_elem_conn, error = %d\n", error);
247
248   connect[0] = 5; connect[1] = 6; connect[2] = 7; connect[3] = 8;
249
250   error = ex_put_elem_conn (exoid, ebids[1], connect);
251   printf ("after ex_put_elem_conn, error = %d\n", error);
252
253   connect[0] = 9; connect[1] = 10; connect[2] = 11; connect[3] = 12;
254   connect[4] = 13; connect[5] = 14; connect[6] = 15; connect[7] = 16;
255
256   error = ex_put_elem_conn (exoid, ebids[2], connect);
257   printf ("after ex_put_elem_conn, error = %d\n", error);
258
259   connect[0] = 17; connect[1] = 18; connect[2] = 19; connect[3] = 20;
260
261   error = ex_put_elem_conn (exoid, ebids[3], connect);
262   printf ("after ex_put_elem_conn, error = %d\n", error);
263
264   connect[0] = 21; connect[1] = 22; connect[2] = 23;
265   connect[3] = 24; connect[4] = 25; connect[5] = 26;
266
267   error = ex_put_elem_conn (exoid, ebids[4], connect);
268   printf ("after ex_put_elem_conn, error = %d\n", error);
269
270   free (connect);
271
272
273/* write element block attributes */
274
275   attrib[0] = 3.14159;
276   error = ex_put_elem_attr (exoid, ebids[0], attrib);
277   printf ("after ex_put_elem_attr, error = %d\n", error);
278
279   attrib[0] = 6.14159;
280   error = ex_put_elem_attr (exoid, ebids[1], attrib);
281   printf ("after ex_put_elem_attr, error = %d\n", error);
282
283   error = ex_put_elem_attr (exoid, ebids[2], attrib);
284   printf ("after ex_put_elem_attr, error = %d\n", error);
285
286   error = ex_put_elem_attr (exoid, ebids[3], attrib);
287   printf ("after ex_put_elem_attr, error = %d\n", error);
288
289   error = ex_put_elem_attr (exoid, ebids[4], attrib);
290   printf ("after ex_put_elem_attr, error = %d\n", error);
291
292/* write individual node sets */
293
294
295   error = ex_put_node_set_param (exoid, 20, 5, 5);
296   printf ("after ex_put_node_set_param, error = %d\n", error);
297
298   node_list[0] = 10; node_list[1] = 11; node_list[2] = 12; 
299   node_list[3] = 13; node_list[4] = 14; 
300
301   dist_fact[0] = 1.0; dist_fact[1] = 2.0; dist_fact[2] = 3.0;
302   dist_fact[3] = 4.0; dist_fact[4] = 5.0;
303
304   error = ex_put_node_set (exoid, 20, node_list);
305   printf ("after ex_put_node_set, error = %d\n", error);
306   error = ex_put_node_set_dist_fact (exoid, 20, dist_fact);
307   printf ("after ex_put_node_set_dist_fact, error = %d\n", error);
308
309   error = ex_put_node_set_param (exoid, 21, 3, 3);
310   printf ("after ex_put_node_set_param, error = %d\n", error);
311
312   node_list[0] = 20; node_list[1] = 21; node_list[2] = 22; 
313
314   dist_fact[0] = 1.1; dist_fact[1] = 2.1; dist_fact[2] = 3.1;
315
316   error = ex_put_node_set (exoid, 21, node_list);
317   printf ("after ex_put_node_set, error = %d\n", error);
318   error = ex_put_node_set_dist_fact (exoid, 21, dist_fact);
319   printf ("after ex_put_node_set_dist_fact, error = %d\n", error);
320
321   error = ex_put_prop(exoid, EX_NODE_SET, 20, "FACE", 4);
322   printf ("after ex_put_prop, error = %d\n", error);
323   error = ex_put_prop(exoid, EX_NODE_SET, 21, "FACE", 5);
324   printf ("after ex_put_prop, error = %d\n", error);
325
326   prop_array[0] = 1000;
327   prop_array[1] = 2000;
328
329   error = ex_put_prop_array(exoid, EX_NODE_SET, "VELOCITY", prop_array);
330   printf ("after ex_put_prop_array, error = %d\n", error);
331
332
333/* write concatenated node sets; this produces the same information as
334 * the above code which writes individual node sets
335 */
336
337/* THIS SECTION IS COMMENTED OUT
338
339   ids[0] = 20; ids[1] = 21;
340
341   num_nodes_per_set[0] = 5; num_nodes_per_set[1] = 3;
342
343   node_ind[0] = 0; node_ind[1] = 5;
344
345   node_list[0] = 10; node_list[1] = 11; node_list[2] = 12; 
346   node_list[3] = 13; node_list[4] = 14; 
347   node_list[5] = 20; node_list[6] = 21; node_list[7] = 22;
348
349   num_df_per_set[0] = 5; num_df_per_set[1] = 3;
350
351   df_ind[0] = 0; df_ind[1] = 5;
352
353   dist_fact[0] = 1.0; dist_fact[1] = 2.0; dist_fact[2] = 3.0; 
354   dist_fact[3] = 4.0; dist_fact[4] = 5.0; 
355   dist_fact[5] = 1.1; dist_fact[6] = 2.1; dist_fact[7] = 3.1;
356
357   error = ex_put_concat_node_sets (exoid, ids, num_nodes_per_set,
358                                    num_df_per_set, node_ind,
359                                    df_ind, node_list, dist_fact);
360   printf ("after ex_put_concat_node_sets, error = %d\n", error);
361
362   error = ex_put_prop(exoid, EX_NODE_SET, 20, "FACE", 4);
363   printf ("after ex_put_prop, error = %d\n", error);
364   error = ex_put_prop(exoid, EX_NODE_SET, 21, "FACE", 5);
365   printf ("after ex_put_prop, error = %d\n", error);
366
367   prop_array[0] = 1000;
368   prop_array[1] = 2000;
369
370   error = ex_put_prop_array(exoid, EX_NODE_SET, "VELOCITY", prop_array);
371   printf ("after ex_put_prop_array, error = %d\n", error);
372
373   END COMMENTED OUT SECTION */
374
375
376/* write individual side sets */
377
378   /* side set #1  - quad */
379
380   error = ex_put_side_set_param (exoid, 30, 2, 4);
381   printf ("after ex_put_side_set_param, error = %d\n", error);
382
383   elem_list[0] = 2; elem_list[1] = 2;
384
385   side_list[0] = 4; side_list[1] = 2;
386
387   dist_fact[0] = 30.0; dist_fact[1] = 30.1; dist_fact[2] = 30.2;
388   dist_fact[3] = 30.3;
389
390   error = ex_put_side_set (exoid, 30, elem_list, side_list);
391   printf ("after ex_put_side_set, error = %d\n", error);
392
393   error = ex_put_side_set_dist_fact (exoid, 30, dist_fact);
394   printf ("after ex_put_side_set_dist_fact, error = %d\n", error);
395
396
397   /* side set #2  - quad, spanning 2 elements  */
398
399   error = ex_put_side_set_param (exoid, 31, 2, 4);
400   printf ("after ex_put_side_set_param, error = %d\n", error);
401
402   elem_list[0] = 1; elem_list[1] = 2;
403
404   side_list[0] = 2; side_list[1] = 3;
405
406   dist_fact[0] = 31.0; dist_fact[1] = 31.1; dist_fact[2] = 31.2;
407   dist_fact[3] = 31.3;
408
409   error = ex_put_side_set (exoid, 31, elem_list, side_list);
410   printf ("after ex_put_side_set, error = %d\n", error);
411
412   error = ex_put_side_set_dist_fact (exoid, 31, dist_fact);
413   printf ("after ex_put_side_set_dist_fact, error = %d\n", error);
414
415
416   /* side set #3  - hex */
417
418   error = ex_put_side_set_param (exoid, 32, 7, 0);
419   printf ("after ex_put_side_set_param, error = %d\n", error);
420
421   elem_list[0] = 3; elem_list[1] = 3;
422   elem_list[2] = 3; elem_list[3] = 3;
423   elem_list[4] = 3; elem_list[5] = 3;
424   elem_list[6] = 3;
425
426   side_list[0] = 5; side_list[1] = 3;
427   side_list[2] = 3; side_list[3] = 2;
428   side_list[4] = 4; side_list[5] = 1;
429   side_list[6] = 6;
430
431   error = ex_put_side_set (exoid, 32, elem_list, side_list);
432   printf ("after ex_put_side_set, error = %d\n", error);
433
434
435   /* side set #4  - tetras */
436
437   error = ex_put_side_set_param (exoid, 33, 4, 0);
438   printf ("after ex_put_side_set_param, error = %d\n", error);
439
440   elem_list[0] = 4; elem_list[1] = 4;
441   elem_list[2] = 4; elem_list[3] = 4;
442
443   side_list[0] = 1; side_list[1] = 2;
444   side_list[2] = 3; side_list[3] = 4;
445
446   error = ex_put_side_set (exoid, 33, elem_list, side_list);
447   printf ("after ex_put_side_set, error = %d\n", error);
448
449
450   /* side set #5  - wedges */
451
452   error = ex_put_side_set_param (exoid, 34, 5, 0);
453   printf ("after ex_put_side_set_param, error = %d\n", error);
454
455   elem_list[0] = 5; elem_list[1] = 5;
456   elem_list[2] = 5; elem_list[3] = 5;
457   elem_list[4] = 5;
458
459   side_list[0] = 1; side_list[1] = 2;
460   side_list[2] = 3; side_list[3] = 4;
461   side_list[4] = 5;
462
463   error = ex_put_side_set (exoid, 34, elem_list, side_list);
464   printf ("after ex_put_side_set, error = %d\n", error);
465
466   /* END COMMENTED OUT SECTION */
467
468/* write concatenated side sets; this produces the same information as
469 * the above code which writes individual side sets
470 */
471
472/* THIS SECTION IS COMMENTED OUT
473
474   ids[0] = 30;
475   ids[1] = 31;
476   ids[2] = 32;
477   ids[3] = 33;
478   ids[4] = 34;
479
480   node_list[0] = 8; node_list[1] = 5;
481   node_list[2] = 6; node_list[3] = 7;
482
483   node_list[4] = 2; node_list[5] = 3;
484   node_list[6] = 7; node_list[7] = 8;
485
486   node_list[8] = 9; node_list[9] = 12;
487   node_list[10] = 11; node_list[11] = 10;
488
489   node_list[12] = 11; node_list[13] = 12;
490   node_list[14] = 16; node_list[15] = 15;
491 
492   node_list[16] = 16; node_list[17] = 15;
493   node_list[18] = 11; node_list[19] = 12;
494
495   node_list[20] = 10; node_list[21] = 11;
496   node_list[22] = 15; node_list[23] = 14;
497
498   node_list[24] = 13; node_list[25] = 16;
499   node_list[26] = 12; node_list[27] =  9;
500
501   node_list[28] = 14; node_list[29] = 13;
502   node_list[30] =  9; node_list[31] = 10;
503
504   node_list[32] = 16; node_list[33] = 13;
505   node_list[34] = 14; node_list[35] = 15;
506
507   node_list[36] = 17; node_list[37] = 18;
508   node_list[38] = 20;
509
510   node_list[39] = 18; node_list[40] = 19;
511   node_list[41] = 20;
512
513   node_list[42] = 20; node_list[43] = 19;
514   node_list[44] = 17;
515
516   node_list[45] = 19; node_list[46] = 18;
517   node_list[47] = 17;
518
519   node_list[48] = 25; node_list[49] = 24;
520   node_list[50] = 21; node_list[51] = 22;
521
522   node_list[52] = 26; node_list[53] = 25;
523   node_list[54] = 22; node_list[55] = 23;
524
525   node_list[56] = 26; node_list[57] = 23;
526   node_list[58] = 21; node_list[59] = 24;
527
528   node_list[60] = 23; node_list[61] = 22;
529   node_list[62] = 21;
530
531   node_list[63] = 24; node_list[64] = 25;
532   node_list[65] = 26;
533
534   node_ind[0] = 0;
535   node_ind[1] = 4;
536   node_ind[2] = 8;
537   node_ind[3] = 36;
538   node_ind[4] = 47;
539
540   num_elem_per_set[0] = 2;
541   num_elem_per_set[1] = 2;
542   num_elem_per_set[2] = 7;
543   num_elem_per_set[3] = 4;
544   num_elem_per_set[4] = 5;
545
546   num_nodes_per_set[0] = 4;
547   num_nodes_per_set[1] = 4;
548   num_nodes_per_set[2] = 28;
549   num_nodes_per_set[3] = 12;
550   num_nodes_per_set[4] = 18;
551
552   elem_ind[0] = 0;
553   elem_ind[1] = 2;
554   elem_ind[2] = 4;
555   elem_ind[3] = 11;
556   elem_ind[4] = 15;
557
558   elem_list[0] = 2; elem_list[1] = 2;
559   elem_list[2] = 1; elem_list[3] = 2;
560   elem_list[4] = 3; elem_list[5] = 3;
561   elem_list[6] = 3; elem_list[7] = 3;
562   elem_list[8] = 3; elem_list[9] = 3;
563   elem_list[10] = 3; elem_list[11] = 4;
564   elem_list[12] = 4; elem_list[13] = 4;
565   elem_list[14] = 4; elem_list[15] = 5;
566   elem_list[16] = 5; elem_list[17] = 5;
567   elem_list[18] = 5; elem_list[19] = 5;
568
569   error = ex_cvt_nodes_to_sides(exoid,
570                         num_elem_per_set,
571                         num_nodes_per_set,
572                         elem_ind,
573                         node_ind,
574                         elem_list,
575                         node_list,
576                         side_list);
577   printf ("after ex_cvt_nodes_to_sides, error = %d\n", error);
578
579   num_df_per_set[0] = 4;
580   num_df_per_set[1] = 4;
581   num_df_per_set[2] = 0;
582   num_df_per_set[3] = 0;
583   num_df_per_set[4] = 0;
584
585   df_ind[0] = 0;
586   df_ind[1] = 4;
587
588   dist_fact[0] = 30.0; dist_fact[1] = 30.1;
589   dist_fact[2] = 30.2; dist_fact[3] = 30.3;
590
591   dist_fact[4] = 31.0; dist_fact[5] = 31.1;
592   dist_fact[6] = 31.2; dist_fact[7] = 31.3;
593
594   error = ex_put_concat_side_sets (exoid, ids, num_elem_per_set,
595                                    num_df_per_set, elem_ind, df_ind,
596                                    elem_list, side_list, dist_fact);
597   printf ("after ex_put_concat_side_sets, error = %d\n", error);
598
599   /* END COMMENTED OUT SECTION */
600
601   error = ex_put_prop(exoid, EX_SIDE_SET, 30, "COLOR", 100);
602   printf ("after ex_put_prop, error = %d\n", error);
603
604   error = ex_put_prop(exoid, EX_SIDE_SET, 31, "COLOR", 101);
605   printf ("after ex_put_prop, error = %d\n", error);
606
607
608/* write QA records */
609
610   num_qa_rec = 2;
611
612
613   qa_record[0][0] = "TESTWT";
614   qa_record[0][1] = "testwt";
615   qa_record[0][2] = "07/07/93";
616   qa_record[0][3] = "15:41:33";
617   qa_record[1][0] = "FASTQ";
618   qa_record[1][1] = "fastq";
619   qa_record[1][2] = "07/07/93";
620   qa_record[1][3] = "16:41:33";
621
622   error = ex_put_qa (exoid, num_qa_rec, qa_record);
623   printf ("after ex_put_qa, error = %d\n", error);
624
625
626/* write information records */
627
628   num_info = 3;
629
630
631   info[0] = "This is the first information record.";
632   info[1] = "This is the second information record.";
633   info[2] = "This is the third information record.";
634
635   error = ex_put_info (exoid, num_info, info);
636   printf ("after ex_put_info, error = %d\n", error);
637
638
639
640/* write results variables parameters and names */
641
642   num_glo_vars = 1;
643
644   var_names[0] = "glo_vars";
645
646   error = ex_put_var_param (exoid, "g", num_glo_vars);
647   printf ("after ex_put_var_param, error = %d\n", error);
648   error = ex_put_var_names (exoid, "g", num_glo_vars, var_names);
649   printf ("after ex_put_var_names, error = %d\n", error);
650
651
652   num_nod_vars = 2;
653
654   var_names[0] = "nod_var0";
655   var_names[1] = "nod_var1";
656
657   error = ex_put_var_param (exoid, "n", num_nod_vars);
658   printf ("after ex_put_var_param, error = %d\n", error);
659   error = ex_put_var_names (exoid, "n", num_nod_vars, var_names);
660   printf ("after ex_put_var_names, error = %d\n", error);
661
662   num_ele_vars = 3;
663
664   var_names[0] = "ele_var0";
665   var_names[1] = "ele_var1";
666   var_names[2] = "ele_var2";
667
668   error = ex_put_var_param (exoid, "e", num_ele_vars);
669   printf ("after ex_put_var_param, error = %d\n", error);
670   error = ex_put_var_names (exoid, "e", num_ele_vars, var_names);
671   printf ("after ex_put_var_names, error = %d\n", error);
672
673
674/* write element variable truth table */
675
676   truth_tab = (int *) calloc ((num_elem_blk*num_ele_vars), sizeof(int));
677
678   k = 0;
679   for (i=0; i<num_elem_blk; i++)
680   {
681      for (j=0; j<num_ele_vars; j++)
682      {
683         truth_tab[k++] = 1;
684      }
685   }
686
687   error = ex_put_elem_var_tab (exoid, num_elem_blk, num_ele_vars, truth_tab);
688   printf ("after ex_put_elem_var_tab, error = %d\n", error);
689
690   free (truth_tab);
691
692
693/* for each time step, write the analysis results;
694 * the code below fills the arrays glob_var_vals, 
695 * nodal_var_vals, and elem_var_vals with values for debugging purposes;
696 * obviously the analysis code will populate these arrays
697 */
698
699   whole_time_step = 1;
700   num_time_steps = 10;
701
702   glob_var_vals = (float *) calloc (num_glo_vars, CPU_word_size);
703   nodal_var_vals = (float *) calloc (num_nodes, CPU_word_size);
704   elem_var_vals = (float *) calloc (4, CPU_word_size);
705
706   for (i=0; i<num_time_steps; i++)
707   {
708     time_value = (float)(i+1)/100.;
709
710/* write time value */
711
712     error = ex_put_time (exoid, whole_time_step, &time_value);
713     printf ("after ex_put_time, error = %d\n", error);
714
715/* write global variables */
716
717     for (j=0; j<num_glo_vars; j++)
718     {
719       glob_var_vals[j] = (float)(j+2) * time_value;
720     }
721
722     error = ex_put_glob_vars (exoid, whole_time_step, num_glo_vars, 
723                               glob_var_vals);
724     printf ("after ex_put_glob_vars, error = %d\n", error);
725
726/* write nodal variables */
727
728     for (k=1; k<=num_nod_vars; k++)
729     {
730       for (j=0; j<num_nodes; j++)
731       {
732         nodal_var_vals[j] = (float)k + ((float)(j+1) * time_value);
733       }
734
735       error = ex_put_nodal_var (exoid, whole_time_step, k, num_nodes,
736                                 nodal_var_vals);
737       printf ("after ex_put_nodal_var, error = %d\n", error);
738     }
739
740/* write element variables */
741
742     for (k=1; k<=num_ele_vars; k++)
743     {
744       for (j=0; j<num_elem_blk; j++)
745       {
746         for (m=0; m<num_elem_in_block[j]; m++)
747         {
748           elem_var_vals[m] = (float)(k+1) + (float)(j+2) + 
749                              ((float)(m+1)*time_value);
750           /* printf("elem_var_vals[%d]: %f\n",m,elem_var_vals[m]); */
751         }
752         error = ex_put_elem_var (exoid, whole_time_step, k, ebids[j],
753                                  num_elem_in_block[j], elem_var_vals);
754         printf ("after ex_put_elem_var, error = %d\n", error);
755       }
756     }
757
758     whole_time_step++;
759
760/* update the data file; this should be done at the end of every time step
761 * to ensure that no data is lost if the analysis dies
762 */
763     error = ex_update (exoid);
764     printf ("after ex_update, error = %d\n", error);
765   }
766   free(glob_var_vals);
767   free(nodal_var_vals);
768   free(elem_var_vals);
769
770
771/* close the EXODUS files
772 */
773   error = ex_close (exoid);
774   printf ("after ex_close, error = %d\n", error);
775   return 0;
776}