PageRenderTime 63ms CodeModel.GetById 1ms app.highlight 55ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://bitbucket.org/vijaysm/libmesh
C | 999 lines | 684 code | 214 blank | 101 comment | 88 complexity | a54d6173729383fb826619f574b3c4c7 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* testwt - test write an 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#include <stdlib.h>
 60#include <stdio.h>
 61#include "exodusII.h"
 62
 63int main (int argc, char **argv)
 64{
 65  int exoid, num_dim, num_nodes, num_elem, num_elem_blk;
 66  int num_elem_in_block[10], num_nodes_per_elem[10];
 67  int num_node_sets, num_side_sets, error;
 68  int i, j, k, kk, m, *elem_map, *connect;
 69  int node_list[100],elem_list[100],side_list[100];
 70  int ebids[10], ssids[10], nsids[10], nattr[10];
 71  int num_nodes_per_set[10], num_elem_per_set[10];
 72  int num_df_per_set[10];
 73  int  num_qa_rec, num_info;
 74  int num_glo_vars, num_nod_vars, num_ele_vars, num_nset_vars, num_sset_vars;
 75  int *truth_tab, *nset_tab, *sset_tab;
 76  int whole_time_step, num_time_steps;
 77  int CPU_word_size,IO_word_size;
 78  int prop_array[2];
 79
 80  float *glob_var_vals, *nodal_var_vals, *elem_var_vals, *nset_var_vals, *sset_var_vals;
 81  float time_value;
 82  float x[100], y[100], z[100];
 83  float attrib[1], dist_fact[100];
 84  char *coord_names[3], *qa_record[2][4], *info[3], *var_names[7];
 85  char *prop_names[2];
 86  char *eb_type[10];
 87   
 88  ex_opts (EX_VERBOSE|EX_ABORT);
 89
 90  /* Specify compute and i/o word size */
 91
 92  CPU_word_size = 0;                   /* sizeof(float) */
 93  IO_word_size = 4;                    /* (4 bytes) */
 94
 95  /* create EXODUS II file */
 96
 97  exoid = ex_create ("test.exo",       /* filename path */
 98		     EX_CLOBBER,      /* create mode */
 99		     &CPU_word_size,  /* CPU float word size in bytes */
100		     &IO_word_size);  /* I/O float word size in bytes */
101  printf ("after ex_create for test.exo, exoid = %d\n", exoid);
102  printf (" cpu word size: %d io word size: %d\n",CPU_word_size,IO_word_size);
103
104  /* ncopts = NC_VERBOSE; */
105
106  /* initialize file with parameters */
107
108  num_dim = 3;
109  num_nodes = 33;
110  num_elem = 7;
111  num_elem_blk = 7;
112  num_node_sets = 2;
113  num_side_sets = 5;
114
115  error = ex_put_init (exoid, "This is a test", num_dim, num_nodes, num_elem,
116		       num_elem_blk, num_node_sets, num_side_sets);
117
118  printf ("after ex_put_init, error = %d\n", error);
119
120  if (error) {
121    ex_close (exoid);
122    exit(-1);
123  }
124
125  /* write nodal coordinates values and names to database */
126
127  /* Quad #1 */
128  x[0] = 0.0; y[0] = 0.0; z[0] = 0.0;
129  x[1] = 1.0; y[1] = 0.0; z[1] = 0.0;
130  x[2] = 1.0; y[2] = 1.0; z[2] = 0.0;
131  x[3] = 0.0; y[3] = 1.0; z[3] = 0.0;
132
133  /* Quad #2 */
134  x[4]  =  1.0; y[4]  =  0.0; z[4]  =  0.0;
135  x[5]  =  2.0; y[5]  =  0.0; z[5]  =  0.0;
136  x[6]  =  2.0; y[6]  =  1.0; z[6]  =  0.0;
137  x[7]  =  1.0; y[7]  =  1.0; z[7]  =  0.0;
138
139  /* Hex #1 */
140  x[8]  =  0.0; y[8]  =  0.0; z[8]  =  0.0;
141  x[9]  = 10.0; y[9]  =  0.0; z[9]  =  0.0;
142  x[10] = 10.0; y[10] =  0.0; z[10] =-10.0;
143  x[11] =  1.0; y[11] =  0.0; z[11] =-10.0;
144  x[12] =  1.0; y[12] = 10.0; z[12] =  0.0;
145  x[13] = 10.0; y[13] = 10.0; z[13] =  0.0;
146  x[14] = 10.0; y[14] = 10.0; z[14] =-10.0;
147  x[15] =  1.0; y[15] = 10.0; z[15] =-10.0;
148
149  /* Tetra #1 */
150  x[16] =  0.0; y[16] =  0.0; z[16] =  0.0;
151  x[17] =  1.0; y[17] =  0.0; z[17] =  5.0;
152  x[18] = 10.0; y[18] =  0.0; z[18] =  2.0;
153  x[19] =  7.0; y[19] =  5.0; z[19] =  3.0;
154
155  /* Wedge #1 */
156  x[20] =  3.0; y[20] =  0.0; z[20] =  6.0;
157  x[21] =  6.0; y[21] =  0.0; z[21] =  0.0;
158  x[22] =  0.0; y[22] =  0.0; z[22] =  0.0;
159  x[23] =  3.0; y[23] =  2.0; z[23] =  6.0;
160  x[24] =  6.0; y[24] =  2.0; z[24] =  2.0;
161  x[25] =  0.0; y[25] =  2.0; z[25] =  0.0;
162
163  /* Tetra #2 */
164  x[26] =  2.7; y[26] =  1.7; z[26] =  2.7;
165  x[27] =  6.0; y[27] =  1.7; z[27] =  3.3;
166  x[28] =  5.7; y[28] =  1.7; z[28] =  1.7;
167  x[29] =  3.7; y[29] =  0.0; z[29] =  2.3;
168
169  /* 3d Tri */
170  x[30] =  0.0; y[30] =  0.0; z[30] =  0.0;
171  x[31] = 10.0; y[31] =  0.0; z[31] =  0.0;
172  x[32] = 10.0; y[32] = 10.0; z[32] = 10.0;
173
174  error = ex_put_coord (exoid, x, y, z);
175  printf ("after ex_put_coord, error = %d\n", error);
176
177  if (error) {
178    ex_close (exoid);
179    exit(-1);
180  }
181
182  coord_names[0] = "xcoor";
183  coord_names[1] = "ycoor";
184  coord_names[2] = "zcoor";
185
186  error = ex_put_coord_names (exoid, coord_names);
187  printf ("after ex_put_coord_names, error = %d\n", error);
188
189  if (error) {
190    ex_close (exoid);
191    exit(-1);
192  }
193
194  /* write element order map */
195
196  elem_map = (int *) calloc(num_elem, sizeof(int));
197
198  for (i=1; i<=num_elem; i++)
199    {
200      elem_map[i-1] = i;
201    }
202
203  error = ex_put_map (exoid, elem_map);
204  printf ("after ex_put_map, error = %d\n", error);
205
206  if (error) {
207    ex_close (exoid);
208    exit(-1);
209  }
210
211  free (elem_map);
212
213
214  /* write element block parameters */
215
216  num_elem_in_block[0] = 1;
217  num_elem_in_block[1] = 1;
218  num_elem_in_block[2] = 1;
219  num_elem_in_block[3] = 1;
220  num_elem_in_block[4] = 1;
221  num_elem_in_block[5] = 1;
222  num_elem_in_block[6] = 1;
223
224  num_nodes_per_elem[0] = 4; /* elements in block #1 are 4-node quads  */
225  num_nodes_per_elem[1] = 4; /* elements in block #2 are 4-node quads  */
226  num_nodes_per_elem[2] = 8; /* elements in block #3 are 8-node hexes  */
227  num_nodes_per_elem[3] = 4; /* elements in block #4 are 4-node tetras */
228  num_nodes_per_elem[4] = 6; /* elements in block #5 are 6-node wedges */
229  num_nodes_per_elem[5] = 8; /* elements in block #6 are 8-node tetras */
230  num_nodes_per_elem[6] = 3; /* elements in block #7 are 3-node tris   */
231
232  ebids[0] = 10;
233  ebids[1] = 11;
234  ebids[2] = 12;
235  ebids[3] = 13;
236  ebids[4] = 14;
237  ebids[5] = 15;
238  ebids[6] = 16;
239
240  nattr[0] = nattr[1] = nattr[2] = nattr[3] = 1;
241  nattr[4] = nattr[5] = nattr[6] = 1;
242   
243  eb_type[0] = "quad";
244  eb_type[1] = "quad";
245  eb_type[2] = "hex";
246  eb_type[3] = "tetra";
247  eb_type[4] = "wedge";
248  eb_type[5] = "tetra";
249  eb_type[6] = "tri";
250     
251  error = ex_put_concat_elem_block (exoid, ebids, eb_type,
252				    num_elem_in_block, num_nodes_per_elem,
253				    nattr, 0);
254  printf ("after ex_put_concat_elem_block, error = %d\n", error);
255
256  if (error) {
257    ex_close (exoid);
258    exit(-1);
259  }
260
261  /* write element block properties */
262
263  prop_names[0] = "MATL";
264  prop_names[1] = "DENSITY";
265  error = ex_put_prop_names(exoid,EX_ELEM_BLOCK,2,prop_names);
266  printf ("after ex_put_prop_names, error = %d\n", error);
267
268  if (error) {
269    ex_close (exoid);
270    exit(-1);
271  }
272
273  error = ex_put_prop(exoid, EX_ELEM_BLOCK, ebids[0], "MATL", 10);
274  printf ("after ex_put_prop, error = %d\n", error);
275  if (error) {
276    ex_close (exoid);
277    exit(-1);
278  }
279
280  error = ex_put_prop(exoid, EX_ELEM_BLOCK, ebids[1], "MATL", 20);
281  printf ("after ex_put_prop, error = %d\n", error);
282  if (error) {
283    ex_close (exoid);
284    exit(-1);
285  }
286
287  error = ex_put_prop(exoid, EX_ELEM_BLOCK, ebids[2], "MATL", 30);
288  printf ("after ex_put_prop, error = %d\n", error);
289  if (error) {
290    ex_close (exoid);
291    exit(-1);
292  }
293
294  error = ex_put_prop(exoid, EX_ELEM_BLOCK, ebids[3], "MATL", 40);
295  printf ("after ex_put_prop, error = %d\n", error);
296  if (error) {
297    ex_close (exoid);
298    exit(-1);
299  }
300
301  error = ex_put_prop(exoid, EX_ELEM_BLOCK, ebids[4], "MATL", 50);
302  printf ("after ex_put_prop, error = %d\n", error);
303  if (error) {
304    ex_close (exoid);
305    exit(-1);
306  }
307
308  error = ex_put_prop(exoid, EX_ELEM_BLOCK, ebids[5], "MATL", 60);
309  printf ("after ex_put_prop, error = %d\n", error);
310  if (error) {
311    ex_close (exoid);
312    exit(-1);
313  }
314
315  error = ex_put_prop(exoid, EX_ELEM_BLOCK, ebids[6], "MATL", 70);
316  printf ("after ex_put_prop, error = %d\n", error);
317  if (error) {
318    ex_close (exoid);
319    exit(-1);
320  }
321
322
323  /* write element connectivity */
324
325  connect = (int *) calloc(8, sizeof(int));
326  connect[0] = 1; connect[1] = 2; connect[2] = 3; connect[3] = 4;
327
328  error = ex_put_elem_conn (exoid, ebids[0], connect);
329  printf ("after ex_put_elem_conn, error = %d\n", error);
330  if (error) {
331    ex_close (exoid);
332    exit(-1);
333  }
334
335
336  connect[0] = 5; connect[1] = 6; connect[2] = 7; connect[3] = 8;
337
338  error = ex_put_elem_conn (exoid, ebids[1], connect);
339  printf ("after ex_put_elem_conn, error = %d\n", error);
340
341  if (error) {
342    ex_close (exoid);
343    exit(-1);
344  }
345
346  connect[0] = 9; connect[1] = 10; connect[2] = 11; connect[3] = 12;
347  connect[4] = 13; connect[5] = 14; connect[6] = 15; connect[7] = 16;
348
349  error = ex_put_elem_conn (exoid, ebids[2], connect);
350  printf ("after ex_put_elem_conn, error = %d\n", error);
351
352  if (error) {
353    ex_close (exoid);
354    exit(-1);
355  }
356
357  connect[0] = 17; connect[1] = 18; connect[2] = 19; connect[3] = 20;
358
359  error = ex_put_elem_conn (exoid, ebids[3], connect);
360  printf ("after ex_put_elem_conn, error = %d\n", error);
361
362  if (error) {
363    ex_close (exoid);
364    exit(-1);
365  }
366
367  connect[0] = 21; connect[1] = 22; connect[2] = 23;
368  connect[3] = 24; connect[4] = 25; connect[5] = 26;
369
370  error = ex_put_elem_conn (exoid, ebids[4], connect);
371  printf ("after ex_put_elem_conn, error = %d\n", error);
372
373  if (error) {
374    ex_close (exoid);
375    exit(-1);
376  }
377
378  connect[0] = 17; connect[1] = 18; connect[2] = 19; connect[3] = 20;
379  connect[4] = 27; connect[5] = 28; connect[6] = 30; connect[7] = 29;
380
381  error = ex_put_elem_conn (exoid, ebids[5], connect);
382  printf ("after ex_put_elem_conn, error = %d\n", error);
383
384  if (error) {
385    ex_close (exoid);
386    exit(-1);
387  }
388
389  connect[0] = 31; connect[1] = 32; connect[2] = 33;
390
391  error = ex_put_elem_conn (exoid, ebids[6], connect);
392  printf ("after ex_put_elem_conn, error = %d\n", error);
393
394  if (error) {
395    ex_close (exoid);
396    exit(-1);
397  }
398
399  free (connect);
400
401
402  /* write element block attributes */
403
404  attrib[0] = 3.14159;
405  error = ex_put_elem_attr (exoid, ebids[0], attrib);
406  printf ("after ex_put_elem_attr, error = %d\n", error);
407
408  if (error) {
409    ex_close (exoid);
410    exit(-1);
411  }
412
413  attrib[0] = 6.14159;
414  error = ex_put_elem_attr (exoid, ebids[1], attrib);
415  printf ("after ex_put_elem_attr, error = %d\n", error);
416
417  if (error) {
418    ex_close (exoid);
419    exit(-1);
420  }
421
422  error = ex_put_elem_attr (exoid, ebids[2], attrib);
423  printf ("after ex_put_elem_attr, error = %d\n", error);
424
425  if (error) {
426    ex_close (exoid);
427    exit(-1);
428  }
429
430  error = ex_put_elem_attr (exoid, ebids[3], attrib);
431  printf ("after ex_put_elem_attr, error = %d\n", error);
432
433  if (error) {
434    ex_close (exoid);
435    exit(-1);
436  }
437
438  error = ex_put_elem_attr (exoid, ebids[4], attrib);
439  printf ("after ex_put_elem_attr, error = %d\n", error);
440
441  if (error) {
442    ex_close (exoid);
443    exit(-1);
444  }
445
446  error = ex_put_elem_attr (exoid, ebids[5], attrib);
447  printf ("after ex_put_elem_attr, error = %d\n", error);
448
449  if (error) {
450    ex_close (exoid);
451    exit(-1);
452  }
453
454  error = ex_put_elem_attr (exoid, ebids[6], attrib);
455  printf ("after ex_put_elem_attr, error = %d\n", error);
456
457  if (error) {
458    ex_close (exoid);
459    exit(-1);
460  }
461
462  /* write individual node sets */
463
464
465  nsids[0] = 20; nsids[1] = 21;
466  num_nodes_per_set[0] = 5; num_nodes_per_set[1] = 3;
467  num_df_per_set[0] = 5; num_df_per_set[1] = 3;
468
469  error = ex_put_concat_node_sets (exoid, nsids, num_nodes_per_set,
470				   num_df_per_set, 0, 0, 0, 0);
471
472  printf ("after ex_put_concat_node_sets, error = %d\n", error);
473
474  if (error) {
475    ex_close (exoid);
476    exit(-1);
477  }
478
479  node_list[0] = 10; node_list[1] = 11; node_list[2] = 12; 
480  node_list[3] = 13; node_list[4] = 14; 
481
482  dist_fact[0] = 1.0; dist_fact[1] = 2.0; dist_fact[2] = 3.0;
483  dist_fact[3] = 4.0; dist_fact[4] = 5.0;
484
485  error = ex_put_node_set (exoid, 20, node_list);
486  printf ("after ex_put_node_set, error = %d\n", error);
487  if (error) {
488    ex_close (exoid);
489    exit(-1);
490  }
491
492  error = ex_put_node_set_dist_fact (exoid, 20, dist_fact);
493  printf ("after ex_put_node_set_dist_fact, error = %d\n", error);
494  if (error) {
495    ex_close (exoid);
496    exit(-1);
497  }
498
499  node_list[0] = 20; node_list[1] = 21; node_list[2] = 22; 
500
501  dist_fact[0] = 1.1; dist_fact[1] = 2.1; dist_fact[2] = 3.1;
502
503  error = ex_put_node_set (exoid, 21, node_list);
504  printf ("after ex_put_node_set, error = %d\n", error);
505  if (error) {
506    ex_close (exoid);
507    exit(-1);
508  }
509
510  error = ex_put_node_set_dist_fact (exoid, 21, dist_fact);
511  printf ("after ex_put_node_set_dist_fact, error = %d\n", error);
512  if (error) {
513    ex_close (exoid);
514    exit(-1);
515  }
516
517
518  error = ex_put_prop(exoid, EX_NODE_SET, 20, "FACE", 4);
519  printf ("after ex_put_prop, error = %d\n", error);
520  if (error) {
521    ex_close (exoid);
522    exit(-1);
523  }
524
525  error = ex_put_prop(exoid, EX_NODE_SET, 21, "FACE", 5);
526  printf ("after ex_put_prop, error = %d\n", error);
527
528  if (error) {
529    ex_close (exoid);
530    exit(-1);
531  }
532
533  prop_array[0] = 1000;
534  prop_array[1] = 2000;
535
536  error = ex_put_prop_array(exoid, EX_NODE_SET, "VELOCITY", prop_array);
537  printf ("after ex_put_prop_array, error = %d\n", error);
538  if (error) {
539    ex_close (exoid);
540    exit(-1);
541  }
542
543  /* Define the sideset params at one time, then write individually */
544  ssids[0] = 30;
545  ssids[1] = 31;
546  ssids[2] = 32;
547  ssids[3] = 33;
548  ssids[4] = 34;
549
550  num_elem_per_set[0] = 2;
551  num_elem_per_set[1] = 2;
552  num_elem_per_set[2] = 7;
553  num_elem_per_set[3] = 8;
554  num_elem_per_set[4] = 10;
555
556  num_df_per_set[0] = 4;
557  num_df_per_set[1] = 4;
558  num_df_per_set[2] = 0;
559  num_df_per_set[3] = 0;
560  num_df_per_set[4] = 0;
561
562  error = ex_put_concat_side_sets (exoid, ssids, num_elem_per_set,
563				   num_df_per_set, 0, 0, 0, 0, 0);
564  printf ("after ex_put_concat_side_sets, error = %d\n", error);
565
566  /* write individual side sets */
567
568  /* side set #1  - quad */
569
570  elem_list[0] = 2; elem_list[1] = 2;
571
572  side_list[0] = 4; side_list[1] = 2;
573
574  dist_fact[0] = 30.0; dist_fact[1] = 30.1; dist_fact[2] = 30.2;
575  dist_fact[3] = 30.3;
576
577  error = ex_put_side_set (exoid, 30, elem_list, side_list);
578  printf ("after ex_put_side_set, error = %d\n", error);
579
580  if (error) {
581    ex_close (exoid);
582    exit(-1);
583  }
584
585  error = ex_put_side_set_dist_fact (exoid, 30, dist_fact);
586  printf ("after ex_put_side_set_dist_fact, error = %d\n", error);
587
588  if (error) {
589    ex_close (exoid);
590    exit(-1);
591  }
592
593
594  /* side set #2  - quad, spanning 2 elements  */
595
596  elem_list[0] = 1; elem_list[1] = 2;
597
598  side_list[0] = 2; side_list[1] = 3;
599
600  dist_fact[0] = 31.0; dist_fact[1] = 31.1; dist_fact[2] = 31.2;
601  dist_fact[3] = 31.3;
602
603  error = ex_put_side_set (exoid, 31, elem_list, side_list);
604  printf ("after ex_put_side_set, error = %d\n", error);
605
606  if (error) {
607    ex_close (exoid);
608    exit(-1);
609  }
610
611  error = ex_put_side_set_dist_fact (exoid, 31, dist_fact);
612  printf ("after ex_put_side_set_dist_fact, error = %d\n", error);
613
614  if (error) {
615    ex_close (exoid);
616    exit(-1);
617  }
618
619
620  /* side set #3  - hex */
621
622  elem_list[0] = 3; elem_list[1] = 3;
623  elem_list[2] = 3; elem_list[3] = 3;
624  elem_list[4] = 3; elem_list[5] = 3;
625  elem_list[6] = 3;
626
627  side_list[0] = 5; side_list[1] = 3;
628  side_list[2] = 3; side_list[3] = 2;
629  side_list[4] = 4; side_list[5] = 1;
630  side_list[6] = 6;
631
632  error = ex_put_side_set (exoid, 32, elem_list, side_list);
633  printf ("after ex_put_side_set, error = %d\n", error);
634
635  if (error) {
636    ex_close (exoid);
637    exit(-1);
638  }
639
640
641  /* side set #4  - tetras */
642
643  elem_list[0] = 4; elem_list[1] = 4;
644  elem_list[2] = 4; elem_list[3] = 4;
645  elem_list[4] = 6; elem_list[5] = 6;
646  elem_list[6] = 6; elem_list[7] = 6;
647
648  side_list[0] = 1; side_list[1] = 2;
649  side_list[2] = 3; side_list[3] = 4;
650  side_list[4] = 1; side_list[5] = 2;
651  side_list[6] = 3; side_list[7] = 4;
652
653  error = ex_put_side_set (exoid, 33, elem_list, side_list);
654  printf ("after ex_put_side_set, error = %d\n", error);
655
656  if (error) {
657    ex_close (exoid);
658    exit(-1);
659  }
660
661
662  /* side set #5  - wedges and tris */
663
664  elem_list[0] = 5; elem_list[1] = 5;
665  elem_list[2] = 5; elem_list[3] = 5;
666  elem_list[4] = 5; elem_list[5] = 7;
667  elem_list[6] = 7; elem_list[7] = 7;
668  elem_list[8] = 7; elem_list[9] = 7;
669
670  side_list[0] = 1; side_list[1] = 2;
671  side_list[2] = 3; side_list[3] = 4;
672  side_list[4] = 5; side_list[5] = 1;
673  side_list[6] = 2; side_list[7] = 3;
674  side_list[8] = 4; side_list[9] = 5;
675
676  error = ex_put_side_set (exoid, 34, elem_list, side_list);
677  printf ("after ex_put_side_set, error = %d\n", error);
678
679  if (error) {
680    ex_close (exoid);
681    exit(-1);
682  }
683
684  error = ex_put_prop(exoid, EX_SIDE_SET, 30, "COLOR", 100);
685  printf ("after ex_put_prop, error = %d\n", error);
686
687  if (error) {
688    ex_close (exoid);
689    exit(-1);
690  }
691
692  error = ex_put_prop(exoid, EX_SIDE_SET, 31, "COLOR", 101);
693  printf ("after ex_put_prop, error = %d\n", error);
694
695  if (error) {
696    ex_close (exoid);
697    exit(-1);
698  }
699
700
701  /* write QA records; test empty and just blank-filled records */
702
703  num_qa_rec = 2;
704
705
706  qa_record[0][0] = "TESTWT";
707  qa_record[0][1] = "testwt";
708  qa_record[0][2] = "07/07/93";
709  qa_record[0][3] = "15:41:33";
710  qa_record[1][0] = "";
711  qa_record[1][1] = "                            ";
712  qa_record[1][2] = "";
713  qa_record[1][3] = "                        ";
714
715  error = ex_put_qa (exoid, num_qa_rec, qa_record);
716  printf ("after ex_put_qa, error = %d\n", error);
717
718  if (error) {
719    ex_close (exoid);
720    exit(-1);
721  }
722
723
724  /* write information records; test empty and just blank-filled records */
725
726  num_info = 3;
727
728
729  info[0] = "This is the first information record.";
730  info[1] = "";
731  info[2] = "                                     ";
732
733  error = ex_put_info (exoid, num_info, info);
734  printf ("after ex_put_info, error = %d\n", error);
735
736  if (error) {
737    ex_close (exoid);
738    exit(-1);
739  }
740
741
742
743  /* write results variables parameters and names */
744  num_glo_vars  = 1;
745  num_nod_vars  = 2;
746  num_ele_vars  = 3;
747  num_nset_vars = 4;
748  num_sset_vars = 7;
749
750  truth_tab = (int *) calloc ((num_elem_blk  * num_ele_vars),  sizeof(int));
751  nset_tab  = (int *) calloc ((num_node_sets * num_nset_vars), sizeof(int));
752  sset_tab  = (int *) calloc ((num_side_sets * num_sset_vars), sizeof(int));
753
754  k = 0;
755  for (i=0; i<num_elem_blk; i++) {
756    for (j=0; j<num_ele_vars; j++) {
757      truth_tab[k++] = 1;
758    }
759  }
760   
761  k = 0;
762  for (i=0; i<num_node_sets; i++) {
763    for (j=0; j<num_nset_vars; j++) {
764      if (k%2 == 0)
765	nset_tab[k++] = 1;
766      else
767	nset_tab[k++] = 0;
768    }
769  }
770   
771  k = 0;
772  for (i=0; i<num_side_sets; i++) {
773    for (j=0; j<num_sset_vars; j++) {
774      if (k%2 == 0)
775	sset_tab[k++] = 0;
776      else
777	sset_tab[k++] = 1;
778    }
779  }
780   
781  ex_put_all_var_param(exoid, num_glo_vars, num_nod_vars, num_ele_vars, truth_tab,
782		       num_nset_vars, nset_tab, num_sset_vars, sset_tab);
783  printf ("after ex_put_all_var_param, error = %d\n", error);
784
785  if (error) {
786    ex_close (exoid);
787    exit(-1);
788  }
789
790  free (truth_tab);
791  free (nset_tab);
792  free (sset_tab);
793   
794  var_names[0] = "glo_vars";
795  error = ex_put_var_names (exoid, "g", num_glo_vars, var_names);
796  printf ("after ex_put_var_names, error = %d\n", error);
797  if (error) {
798    ex_close (exoid);
799    exit(-1);
800  }
801
802  /*              12345678901234567890123456789012 */
803  var_names[0] = "node_variable_a_very_long_name_0";
804  var_names[1] = "nod_var1";
805  error = ex_put_var_names (exoid, "n", num_nod_vars, var_names);
806  printf ("after ex_put_var_names, error = %d\n", error);
807  if (error) {
808    ex_close (exoid);
809    exit(-1);
810  }
811
812
813
814  var_names[0] = "ele_var0";
815  var_names[1] = "ele_var1";
816  var_names[2] = "ele_var2";
817  error = ex_put_var_names (exoid, "e", num_ele_vars, var_names);
818  printf ("after ex_put_var_names, error = %d\n", error);
819  if (error) {
820    ex_close (exoid);
821    exit(-1);
822  }
823
824
825  var_names[0] = "nset_var0";
826  var_names[1] = "nset_var1";
827  var_names[2] = "nset_var2";
828  var_names[3] = "nset_var3";
829  error = ex_put_var_names (exoid, "m", num_nset_vars, var_names);
830  printf ("after ex_put_var_names, error = %d\n", error);
831  if (error) {
832    ex_close (exoid);
833    exit(-1);
834  }
835
836  var_names[0] = "sset_var0";
837  var_names[1] = "sset_var1";
838  var_names[2] = "sset_var2";
839  var_names[3] = "sset_var3";
840  var_names[4] = "sset_var4";
841  var_names[5] = "sset_var5";
842  var_names[6] = "sset_var6";
843  error = ex_put_var_names (exoid, "s", num_sset_vars, var_names);
844  printf ("after ex_put_var_names, error = %d\n", error);
845  if (error) {
846    ex_close (exoid);
847    exit(-1);
848  }
849
850
851  /* for each time step, write the analysis results;
852   * the code below fills the arrays glob_var_vals, 
853   * nodal_var_vals, and elem_var_vals with values for debugging purposes;
854   * obviously the analysis code will populate these arrays
855   */
856
857  whole_time_step = 1;
858  num_time_steps = 10;
859
860  glob_var_vals =  (float *) calloc (num_glo_vars, CPU_word_size);
861  nodal_var_vals = (float *) calloc (num_nodes, CPU_word_size);
862  elem_var_vals =  (float *) calloc (4, CPU_word_size);
863  nset_var_vals =  (float *) calloc (5, CPU_word_size);
864  sset_var_vals =  (float *) calloc (10, CPU_word_size);
865
866  for (i=0; i<num_time_steps; i++)
867    {
868      time_value = (float)(i+1)/100.;
869
870      /* write time value */
871
872      error = ex_put_time (exoid, whole_time_step, &time_value);
873      printf ("after ex_put_time, error = %d\n", error);
874
875      if (error) {
876	ex_close (exoid);
877	exit(-1);
878      }
879
880      /* write global variables */
881
882      for (j=0; j<num_glo_vars; j++) {
883	glob_var_vals[j] = (float)(j+2) * time_value;
884      }
885
886      error = ex_put_glob_vars (exoid, whole_time_step, num_glo_vars, 
887				glob_var_vals);
888      printf ("after ex_put_glob_vars, error = %d\n", error);
889
890      if (error) {
891	ex_close (exoid);
892	exit(-1);
893      }
894
895      /* write nodal variables */
896
897      for (k=1; k<=num_nod_vars; k++) {
898	for (j=0; j<num_nodes; j++) {
899	  nodal_var_vals[j] = (float)k + ((float)(j+1) * time_value);
900	}
901
902	error = ex_put_nodal_var (exoid, whole_time_step, k, num_nodes,
903				  nodal_var_vals);
904	printf ("after ex_put_nodal_var, error = %d\n", error);
905	if (error) {
906	  ex_close (exoid);
907	  exit(-1);
908	}
909
910      }
911
912      /* write element variables */
913
914      for (k=1; k<=num_ele_vars; k++) {
915	for (j=0; j<num_elem_blk; j++) {
916	  for (m=0; m<num_elem_in_block[j]; m++) {
917	    elem_var_vals[m] = (float)(k+1) + (float)(j+2) + 
918	      ((float)(m+1)*time_value);
919	  }
920	  error = ex_put_elem_var (exoid, whole_time_step, k, ebids[j],
921				   num_elem_in_block[j], elem_var_vals);
922	  printf ("after ex_put_elem_var, error = %d\n", error);
923	  if (error) {
924	    ex_close (exoid);
925	    exit(-1);
926	  }
927	}
928      }
929
930      /* write nodeset variables */
931
932      kk = 0;
933      for (j=0; j<num_node_sets; j++) {
934	for (k=0; k<num_nset_vars; k++) {
935	  if (kk++ % 2 == 0) {
936	    for (m=0; m<num_nodes_per_set[j]; m++) {
937	      nset_var_vals[m] = (float)(k+1) + (float)(j+2) + 
938		((float)(m+1)*time_value);
939	    }
940	    error = ex_put_nset_var (exoid, whole_time_step, k+1, nsids[j],
941				     num_nodes_per_set[j], nset_var_vals);
942	    printf ("after ex_put_nset_var, error = %d\n", error);
943	    if (error) {
944	      ex_close (exoid);
945	      exit(-1);
946	    }
947	  }
948	}
949      }
950
951      /* write sideset variables */
952
953      kk = 0;
954      for (j=0; j<num_side_sets; j++) {
955	for (k=0; k<num_sset_vars; k++) {
956	  if (kk++ % 2 != 0) {
957	    for (m=0; m<num_elem_per_set[j]; m++) {
958	      sset_var_vals[m] = (float)(k+1) + (float)(j+2) + 
959		((float)(m+1)*time_value);
960	    }
961	    error = ex_put_sset_var (exoid, whole_time_step, k+1, ssids[j],
962				     num_elem_per_set[j], sset_var_vals);
963	    printf ("after ex_put_sset_var, error = %d\n", error);
964	    if (error) {
965	      ex_close (exoid);
966	      exit(-1);
967	    }
968	  }
969	}
970      }
971
972      whole_time_step++;
973
974      /* update the data file; this should be done at the end of every time step
975       * to ensure that no data is lost if the analysis dies
976       */
977      error = ex_update (exoid);
978      printf ("after ex_update, error = %d\n", error);
979      if (error) {
980	ex_close (exoid);
981	exit(-1);
982      }
983    }
984  free(glob_var_vals);
985  free(nodal_var_vals);
986  free(elem_var_vals);
987  free(nset_var_vals);
988  free(sset_var_vals);
989
990  /* close the EXODUS files
991   */
992  error = ex_close (exoid);
993  printf ("after ex_close, error = %d\n", error);
994  if (error) {
995    ex_close (exoid);
996    exit(-1);
997  }
998  return 0;
999}