PageRenderTime 8ms CodeModel.GetById 3ms app.highlight 97ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://bitbucket.org/vijaysm/libmesh
C | 900 lines | 579 code | 208 blank | 113 comment | 83 complexity | cdf187aae666892d606ee6d7dc223677 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* testrdd - read exodus file test.exo created by testwt - double precision
 37*
 38* author - Sandia National Laboratories
 39*          Larry A. Schoof - Original
 40*
 41*
 42* environment - UNIX
 43*
 44* entry conditions -
 45*   input parameters:
 46*       int     exoid                   exodus file id
 47*
 48* exit conditions -
 49*
 50* revision history -
 51*
 52*   Original L. A. Schoof
 53*   04/05/93 V.R. Yarberry - revised so that output resembles Fortran version
 54*   06/25/93 VRY - revised to match 2.00 API.
 55*
 56*****************************************************************************/
 57
 58#include <stdlib.h>
 59#include <stdio.h>
 60#include "netcdf.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, num_node_sets;
 66   int num_side_sets, error;
 67   int i, j, k, node_ctr;
 68   int *elem_map, *connect, *node_list, *node_ctr_list, *elem_list, *side_list;
 69   int *ids;
 70   int *num_nodes_per_set, *num_elem_per_set;
 71   int *num_df_per_set;
 72   int *node_ind, *elem_ind, *df_ind, num_qa_rec, num_info;
 73   int num_glo_vars, num_nod_vars, num_ele_vars;
 74   int *truth_tab;
 75   int num_time_steps;
 76   int *num_elem_in_block, *num_nodes_per_elem, *num_attr;
 77   int num_nodes_in_set, num_elem_in_set;
 78   int num_sides_in_set, num_df_in_set;
 79   int list_len = 0;
 80   int elem_list_len = 0;
 81   int node_list_len = 0;
 82   int df_list_len = 0;
 83   int node_num, time_step, var_index, beg_time, end_time, elem_num;
 84   int CPU_word_size,IO_word_size;
 85   int num_props, prop_value, *prop_values;
 86
 87   double time_value, *time_values, *var_values;
 88   double *x, *y, *z;
 89   double attrib[1], *dist_fact;
 90   float version, fdum;
 91
 92   char *coord_names[3], *qa_record[2][4], *info[3], *var_names[3];
 93   char title[MAX_LINE_LENGTH+1], elem_type[MAX_STR_LENGTH+1];
 94   char *cdum = 0;
 95   char *prop_names[3];
 96
 97   CPU_word_size = 8;                   /* sizeof(double) */
 98   IO_word_size = 0;                    /* use what is stored in file */
 99
100   ex_opts (EX_VERBOSE | EX_ABORT );
101
102/* open EXODUS II files */
103
104   exoid = ex_open ("test.exo",         /* filename path */
105                     EX_READ,           /* access mode = READ */
106                     &CPU_word_size,    /* CPU word size */
107                     &IO_word_size,     /* IO word size */
108                     &version);         /* ExodusII library version */
109
110   printf ("\nafter ex_open\n");
111   if (exoid < 0) exit(1);
112
113   printf ("test.exo is an EXODUSII file; version %4.2f\n",
114            version);
115   printf ("         CPU word size %1d\n",CPU_word_size);
116   printf ("         I/O word size %1d\n",IO_word_size);
117
118   /* ncopts = NC_VERBOSE; */
119
120/* read database parameters */
121
122   error = ex_get_init (exoid, title, &num_dim, &num_nodes, &num_elem,
123                        &num_elem_blk, &num_node_sets, &num_side_sets);
124
125   printf ("after ex_get_init, error = %3d\n", error);
126
127   printf ("database parameters:\n");
128   printf ("title =  '%s'\n",title);
129   printf ("num_dim = %3d\n",num_dim);
130   printf ("num_nodes = %3d\n",num_nodes);
131   printf ("num_elem = %3d\n",num_elem);
132   printf ("num_elem_blk = %3d\n",num_elem_blk);
133   printf ("num_node_sets = %3d\n",num_node_sets);
134   printf ("num_side_sets = %3d\n",num_side_sets);
135
136/* read nodal coordinates values and names from database */
137
138   x = (double *) calloc(num_nodes, sizeof(double));
139   y = (double *) calloc(num_nodes, sizeof(double));
140   if (num_dim >= 3)
141     z = (double *) calloc(num_nodes, sizeof(double));
142   else
143     z = 0;
144
145
146   error = ex_get_coord (exoid, x, y, z);
147   printf ("\nafter ex_get_coord, error = %3d\n", error);
148
149   printf ("x coords = \n");
150   for (i=0; i<num_nodes; i++)
151   {
152      printf ("%5.1f\n", x[i]);
153   }
154
155   printf ("y coords = \n");
156   for (i=0; i<num_nodes; i++)
157   {
158      printf ("%5.1f\n", y[i]);
159   }
160
161   if (num_dim >= 3)
162   {
163     printf ("z coords = \n");
164     for (i=0; i<num_nodes; i++)
165     {
166        printf ("%5.1f\n", z[i]);
167     }
168   }
169
170
171/*
172   error = ex_get_1_coord (exoid, 2, x, y, z);
173   printf ("\nafter ex_get_1_coord, error = %3d\n", error);
174
175   printf ("x coord of node 2 = \n");
176   printf ("%f \n", x[0]);
177
178   printf ("y coord of node 2 = \n");
179   printf ("%f \n", y[0]);
180*/
181   free (x);
182   free (y);
183   if (num_dim >= 3)
184     free (z);
185
186
187   for (i=0; i<num_dim; i++)
188   {
189      coord_names[i] = (char *) calloc ((MAX_STR_LENGTH+1), sizeof(char));
190   }
191
192   error = ex_get_coord_names (exoid, coord_names);
193   printf ("\nafter ex_get_coord_names, error = %3d\n", error);
194
195   printf ("x coord name = '%s'\n", coord_names[0]);
196   printf ("y coord name = '%s'\n", coord_names[1]);
197
198   for (i=0; i<num_dim; i++)
199     free(coord_names[i]);
200
201
202/* read element order map */
203
204   elem_map = (int *) calloc(num_elem, sizeof(int));
205
206   error = ex_get_map (exoid, elem_map);
207   printf ("\nafter ex_get_map, error = %3d\n", error);
208
209   for (i=0; i<num_elem; i++)
210   {
211      printf ("elem_map(%d) = %d \n", i, elem_map[i]);
212   }
213
214   free (elem_map);
215
216/* read element block parameters */
217
218   ids = (int *) calloc(num_elem_blk, sizeof(int));
219   num_elem_in_block = (int *) calloc(num_elem_blk, sizeof(int));
220   num_nodes_per_elem = (int *) calloc(num_elem_blk, sizeof(int));
221   num_attr = (int *) calloc(num_elem_blk, sizeof(int));
222
223   error = ex_get_elem_blk_ids (exoid, ids);
224   printf ("\nafter ex_get_elem_blk_ids, error = %3d\n", error);
225
226   for (i=0; i<num_elem_blk; i++)
227   {
228     error = ex_get_elem_block (exoid, ids[i], elem_type,
229                                &(num_elem_in_block[i]), 
230                                &(num_nodes_per_elem[i]), &(num_attr[i]));
231     printf ("\nafter ex_get_elem_block, error = %d\n", error);
232
233     printf ("element block id = %2d\n",ids[i]);
234     printf ("element type = '%s'\n", elem_type);
235     printf ("num_elem_in_block = %2d\n",num_elem_in_block[i]);
236     printf ("num_nodes_per_elem = %2d\n",num_nodes_per_elem[i]);
237     printf ("num_attr = %2d\n",num_attr[i]);
238   }
239
240   /* read element block properties */
241   error = ex_inquire (exoid, EX_INQ_EB_PROP, &num_props, &fdum, cdum);
242   printf ("\nafter ex_inquire, error = %d\n", error);
243   printf ("\nThere are %2d properties for each element block\n", num_props);
244
245   for (i=0; i<num_props; i++)
246   {
247      prop_names[i] = (char *) calloc ((MAX_STR_LENGTH+1), sizeof(char));
248   }
249
250   error = ex_get_prop_names(exoid,EX_ELEM_BLOCK,prop_names);
251   printf ("after ex_get_prop_names, error = %d\n", error);
252
253
254   for (i=0; i<num_props; i++)
255   {
256     for (j=0; j<num_elem_blk; j++)
257     {
258       error = ex_get_prop(exoid, EX_ELEM_BLOCK, ids[j], prop_names[i],
259                           &prop_value);
260       if (error == 0)
261         printf ("element block %2d, property(%2d): '%s'= %5d\n",
262                  j+1, i+1, prop_names[i], prop_value);
263       else
264         printf ("after ex_get_prop, error = %d\n", error);
265     }
266   }
267
268   for (i=0; i<num_props; i++)
269     free(prop_names[i]);
270
271/* read element connectivity */
272
273   for (i=0; i<num_elem_blk; i++)
274   {
275      connect = (int *) calloc((num_nodes_per_elem[i] * num_elem_in_block[i]), 
276                                sizeof(int));
277
278      error = ex_get_elem_conn (exoid, ids[i], connect);
279      printf ("\nafter ex_get_elem_conn, error = %d\n", error);
280
281
282      printf ("connect array for elem block %2d\n", ids[i]);
283
284      for (j=0; j<num_nodes_per_elem[i]; j++)
285      {
286         printf ("%3d\n", connect[j]);
287      }
288/*
289      error = ex_get_1_elem_conn (exoid, 1, ids[i], connect);
290      printf ("\nafter ex_get_elem_conn, error = %d\n", error);
291
292      printf ("node list for first element of element block %d \n ", ids[i]);
293      for (j=0; j<num_nodes_per_elem[i]; j++)
294      {
295         printf ("%d \n", connect[j]);
296      }
297*/
298      free (connect);
299
300   }
301
302/* read element block attributes */
303
304   for (i=0; i<num_elem_blk; i++)
305   {
306      error = ex_get_elem_attr (exoid, ids[i], attrib);
307      printf ("\n after ex_get_elem_attr, error = %d\n", error);
308
309      if (error == 0)
310         printf ("element block %d attributes = %10.8f\n", ids[i], *attrib);
311   }
312
313   free (ids);
314   free (num_nodes_per_elem);
315   free (num_attr);
316
317/* read individual node sets */
318
319   ids = (int *) calloc(num_node_sets, sizeof(int));
320
321   error = ex_get_node_set_ids (exoid, ids);
322   printf ("\nafter ex_get_node_set_ids, error = %3d\n", error);
323
324   for (i=0; i<num_node_sets; i++)
325   {
326      error = ex_get_node_set_param (exoid, ids[i],
327                                      &num_nodes_in_set, &num_df_in_set);
328      printf ("\nafter ex_get_node_set_param, error = %3d\n", error);
329
330      printf ("\nnode set %2d parameters: \n", ids[i]);
331      printf ("num_nodes = %2d\n", num_nodes_in_set);
332
333      node_list = (int *) calloc(num_nodes_in_set, sizeof(int));
334      dist_fact = (double *) calloc(num_nodes_in_set, sizeof(double));
335
336      error = ex_get_node_set (exoid, ids[i], node_list);
337      printf ("\nafter ex_get_node_set, error = %3d\n", error);
338
339      if (num_df_in_set > 0)
340      {
341        error = ex_get_node_set_dist_fact (exoid, ids[i], dist_fact);
342        printf ("\nafter ex_get_node_set_dist_fact, error = %3d\n", error);
343      }
344
345      printf ("\nnode list for node set %2d\n", ids[i]);
346
347      for (j=0; j<num_nodes_in_set; j++)
348      {
349         printf ("%3d\n", node_list[j]);
350      }
351
352      if (num_df_in_set > 0)
353      {
354        printf ("dist factors for node set %2d\n", ids[i]);
355
356        for (j=0; j<num_nodes_in_set; j++)
357        {
358           printf ("%5.2f\n", dist_fact[j]);
359        }
360      }
361      else
362        printf ("no dist factors for node set %2d\n", ids[i]);
363
364      free (node_list);
365      free (dist_fact);
366   }
367   free(ids);
368
369   /* read node set properties */
370   error = ex_inquire (exoid, EX_INQ_NS_PROP, &num_props, &fdum, cdum);
371   printf ("\nafter ex_inquire, error = %d\n", error);
372   printf ("\nThere are %2d properties for each node set\n", num_props);
373
374   for (i=0; i<num_props; i++)
375   {
376      prop_names[i] = (char *) calloc ((MAX_STR_LENGTH+1), sizeof(char));
377   }
378   prop_values = (int *) calloc (num_node_sets, sizeof(int));
379
380   error = ex_get_prop_names(exoid,EX_NODE_SET,prop_names);
381   printf ("after ex_get_prop_names, error = %d\n", error);
382
383   for (i=0; i<num_props; i++)
384   {
385     error = ex_get_prop_array(exoid, EX_NODE_SET, prop_names[i],
386                         prop_values);
387     if (error == 0)
388       for (j=0; j<num_node_sets; j++)
389         printf ("node set %2d, property(%2d): '%s'= %5d\n",
390                  j+1, i+1, prop_names[i], prop_values[j]);
391     else
392       printf ("after ex_get_prop_array, error = %d\n", error);
393   }
394   for (i=0; i<num_props; i++)
395     free(prop_names[i]);
396   free(prop_values);
397
398/* read concatenated node sets; this produces the same information as
399 * the above code which reads individual node sets
400 */
401
402   error = ex_inquire (exoid, EX_INQ_NODE_SETS, &num_node_sets, &fdum, cdum);
403   printf ("\nafter ex_inquire, error = %3d\n",error);
404
405   ids = (int *) calloc(num_node_sets, sizeof(int));
406   num_nodes_per_set = (int *) calloc(num_node_sets, sizeof(int));
407   num_df_per_set = (int *) calloc(num_node_sets, sizeof(int));
408   node_ind = (int *) calloc(num_node_sets, sizeof(int));
409   df_ind = (int *) calloc(num_node_sets, sizeof(int));
410
411   error = ex_inquire (exoid, EX_INQ_NS_NODE_LEN, &list_len, &fdum, cdum);
412   printf ("\nafter ex_inquire: EX_INQ_NS_NODE_LEN = %d, error = %3d\n",
413            list_len, error);
414
415   node_list = (int *) calloc(list_len, sizeof(int));
416
417   error = ex_inquire (exoid, EX_INQ_NS_DF_LEN, &list_len, &fdum, cdum);
418   printf ("\nafter ex_inquire: EX_INQ_NS_DF_LEN = %d, error = %3d\n",
419            list_len, error);
420   dist_fact = (double *) calloc(list_len, sizeof(double));
421
422   error = ex_get_concat_node_sets (exoid,ids,num_nodes_per_set,num_df_per_set,
423                                    node_ind, df_ind, node_list, dist_fact);
424   printf ("\nafter ex_get_concat_node_sets, error = %3d\n", error);
425
426   printf ("\nconcatenated node set info\n");
427
428   printf ("ids = \n");
429   for (i=0; i<num_node_sets; i++) printf ("%3d\n", ids[i]);
430
431   printf ("num_nodes_per_set = \n");
432   for (i=0; i<num_node_sets; i++) printf ("%3d\n", num_nodes_per_set[i]);
433
434   printf ("node_ind = \n");
435   for (i=0; i<num_node_sets; i++) printf ("%3d\n", node_ind[i]);
436
437   printf ("node_list = \n");
438   for (i=0; i<list_len; i++) printf ("%3d\n", node_list[i]);
439
440   printf ("dist_fact = \n");
441   for (i=0; i<list_len; i++) printf ("%5.3f\n", dist_fact[i]);
442
443   free (ids);
444   free (num_nodes_per_set);
445   free (df_ind);
446   free (node_ind);
447   free (num_df_per_set);
448   free (node_list);
449   free (dist_fact);
450
451
452/* read individual side sets */
453
454   ids = (int *) calloc(num_side_sets, sizeof(int));
455
456   error = ex_get_side_set_ids (exoid, ids);
457   printf ("\nafter ex_get_side_set_ids, error = %3d\n", error);
458
459   for (i=0; i<num_side_sets; i++)
460   {
461      error = ex_get_side_set_param (exoid, ids[i], &num_sides_in_set, 
462                                     &num_df_in_set);
463      printf ("\nafter ex_get_side_set_param, error = %3d\n", error);
464
465      printf ("side set %2d parameters:\n",ids[i]);
466      printf ("num_sides = %3d\n",num_sides_in_set);
467      printf ("num_dist_factors = %3d\n", num_df_in_set);
468
469
470      /* Note: The # of elements is same as # of sides!  */
471      num_elem_in_set = num_sides_in_set;
472      elem_list = (int *) calloc(num_elem_in_set, sizeof(int));
473      side_list = (int *) calloc(num_sides_in_set, sizeof(int));
474      node_ctr_list = (int *) calloc(num_elem_in_set, sizeof(int));
475      node_list = (int *) calloc(num_elem_in_set*21, sizeof(int));
476      dist_fact = (double *) calloc(num_df_in_set, sizeof(double));
477
478      error = ex_get_side_set (exoid, ids[i], elem_list, side_list);
479      printf ("\nafter ex_get_side_set, error = %3d\n", error);
480
481      error = ex_get_side_set_node_list (exoid, ids[i], node_ctr_list,
482                                         node_list);
483      printf ("\nafter ex_get_side_set_node_list, error = %3d\n", error);
484
485      if (num_df_in_set > 0)
486      {
487        error = ex_get_side_set_dist_fact (exoid, ids[i], dist_fact);
488        printf ("\nafter ex_get_side_set_dist_fact, error = %3d\n", error);
489      }
490
491      printf ("element list for side set %2d\n", ids[i]);
492
493      for (j=0; j<num_elem_in_set; j++)
494      {
495         printf ("%3d\n", elem_list[j]);
496      }
497
498      printf ("side list for side set %2d\n", ids[i]);
499      for (j=0; j<num_sides_in_set; j++)
500      {
501         printf ("%3d\n", side_list[j]);
502      }
503
504      node_ctr = 0;
505      printf ("node list for side set %2d\n", ids[i]);
506      for (k=0; k<num_elem_in_set; k++)
507      {
508        for (j=0; j<node_ctr_list[k]; j++)
509        {
510          printf ("%3d\n", node_list[node_ctr+j]);
511        }
512        node_ctr += node_ctr_list[k];
513      }
514
515      if (num_df_in_set > 0)
516      {
517        printf ("dist factors for side set %2d\n", ids[i]); 
518
519        for (j=0; j<num_df_in_set; j++)
520        {
521           printf ("%5.3f\n", dist_fact[j]);
522        }
523      }
524      else
525        printf ("no dist factors for side set %2d\n", ids[i]);
526
527      free (elem_list);
528      free (side_list);
529      free (node_ctr_list);
530      free (node_list);
531      free (dist_fact);
532   }
533
534   /* read side set properties */
535   error = ex_inquire (exoid, EX_INQ_SS_PROP, &num_props, &fdum, cdum);
536   printf ("\nafter ex_inquire, error = %d\n", error);
537   printf ("\nThere are %2d properties for each side set\n", num_props);
538
539   for (i=0; i<num_props; i++)
540   {
541      prop_names[i] = (char *) calloc ((MAX_STR_LENGTH+1), sizeof(char));
542   }
543
544   error = ex_get_prop_names(exoid,EX_SIDE_SET,prop_names);
545   printf ("after ex_get_prop_names, error = %d\n", error);
546
547
548   for (i=0; i<num_props; i++)
549   {
550     for (j=0; j<num_side_sets; j++)
551     {
552       error = ex_get_prop(exoid, EX_SIDE_SET, ids[j], prop_names[i],
553                           &prop_value);
554       if (error == 0)
555         printf ("side set %2d, property(%2d): '%s'= %5d\n",
556                  j+1, i+1, prop_names[i], prop_value);
557       else
558         printf ("after ex_get_prop, error = %d\n", error);
559     }
560   }
561   for (i=0; i<num_props; i++)
562     free(prop_names[i]);
563   free (ids);
564
565   error = ex_inquire (exoid, EX_INQ_SIDE_SETS, &num_side_sets, &fdum, cdum);
566   printf ("\nafter ex_inquire: EX_INQ_SIDE_SETS = %d,  error = %d\n",
567            num_side_sets, error);
568
569   if (num_side_sets > 0)
570   {
571     error = ex_inquire(exoid, EX_INQ_SS_ELEM_LEN, &elem_list_len, &fdum, cdum);
572     printf ("\nafter ex_inquire: EX_INQ_SS_ELEM_LEN = %d,  error = %d\n",
573              elem_list_len, error);
574
575     error = ex_inquire(exoid, EX_INQ_SS_NODE_LEN, &node_list_len, &fdum, cdum);
576     printf ("\nafter ex_inquire: EX_INQ_SS_NODE_LEN = %d,  error = %d\n",
577              node_list_len, error);
578
579     error = ex_inquire(exoid, EX_INQ_SS_DF_LEN, &df_list_len, &fdum, cdum);
580     printf ("\nafter ex_inquire: EX_INQ_SS_DF_LEN = %d,  error = %d\n",
581              df_list_len, error);
582   }
583
584/* read concatenated side sets; this produces the same information as
585 * the above code which reads individual side sets
586 */
587
588/* concatenated side set read */
589
590   ids = (int *) calloc(num_side_sets, sizeof(int));
591   num_elem_per_set = (int *) calloc(num_side_sets, sizeof(int));
592   num_df_per_set = (int *) calloc(num_side_sets, sizeof(int));
593   elem_ind = (int *) calloc(num_side_sets, sizeof(int));
594   df_ind = (int *) calloc(num_side_sets, sizeof(int));
595   elem_list = (int *) calloc(elem_list_len, sizeof(int));
596   side_list = (int *) calloc(elem_list_len, sizeof(int));
597   dist_fact = (double *) calloc(df_list_len, sizeof(double));
598
599   error = ex_get_concat_side_sets (exoid, ids, num_elem_per_set, 
600                                    num_df_per_set, elem_ind, df_ind, 
601                                    elem_list, side_list, dist_fact);
602   printf ("\nafter ex_get_concat_side_sets, error = %3d\n", error);
603
604   printf ("concatenated side set info\n");
605
606   printf ("ids = \n");
607   for (i=0; i<num_side_sets; i++) printf ("%3d\n", ids[i]);
608
609   printf ("num_elem_per_set = \n");
610   for (i=0; i<num_side_sets; i++) printf ("%3d\n", num_elem_per_set[i]);
611
612   printf ("num_dist_per_set = \n");
613   for (i=0; i<num_side_sets; i++) printf ("%3d\n", num_df_per_set[i]);
614
615   printf ("elem_ind = \n");
616   for (i=0; i<num_side_sets; i++) printf ("%3d\n", elem_ind[i]);
617
618   printf ("dist_ind = \n");
619   for (i=0; i<num_side_sets; i++) printf ("%3d\n", df_ind[i]);
620
621   printf ("elem_list = \n");
622   for (i=0; i<elem_list_len; i++) printf ("%3d\n", elem_list[i]);
623
624   printf ("side_list = \n");
625   for (i=0; i<elem_list_len; i++) printf ("%3d\n", side_list[i]);
626
627   printf ("dist_fact = \n");
628   for (i=0; i<df_list_len; i++) printf ("%5.3f\n", dist_fact[i]);
629
630   free (ids);
631   free (num_elem_per_set);
632   free (num_df_per_set);
633   free (df_ind);
634   free (elem_ind);
635   free (elem_list);
636   free (side_list);
637   free (dist_fact);
638
639/* end of concatenated side set read */
640
641/* read QA records */
642
643   ex_inquire (exoid, EX_INQ_QA, &num_qa_rec, &fdum, cdum);
644
645   for (i=0; i<num_qa_rec; i++)
646   {
647      for (j=0; j<4; j++)
648      {
649         qa_record[i][j] = (char *) calloc ((MAX_STR_LENGTH+1), sizeof(char));
650      }
651   }
652
653   error = ex_get_qa (exoid, qa_record); 
654   printf ("\nafter ex_get_qa, error = %3d\n", error);
655
656   printf ("QA records = \n");
657   for (i=0; i<num_qa_rec; i++) 
658   {
659     for (j=0; j<4; j++)
660     {
661       printf (" '%s'\n", qa_record[i][j]);
662       free(qa_record[i][j]);
663     }
664   }
665
666
667/* read information records */
668
669   error = ex_inquire (exoid, EX_INQ_INFO, &num_info, &fdum, cdum);
670   printf ("\nafter ex_inquire, error = %3d\n", error);
671
672   for (i=0; i<num_info; i++)
673   {
674      info[i] = (char *) calloc ((MAX_LINE_LENGTH+1), sizeof(char));
675   }
676
677   error = ex_get_info (exoid, info); 
678   printf ("\nafter ex_get_info, error = %3d\n", error);
679
680   printf ("info records = \n");
681   for (i=0; i<num_info; i++)
682   {
683     printf (" '%s'\n", info[i]);
684     free(info[i]);
685   }
686
687
688/* read global variables parameters and names */
689
690   error = ex_get_var_param (exoid, "g", &num_glo_vars);
691   printf ("\nafter ex_get_var_param, error = %3d\n", error);
692
693   for (i=0; i<num_glo_vars; i++)
694   {
695      var_names[i] = (char *) calloc ((MAX_STR_LENGTH+1), sizeof(char));
696   }
697
698   error = ex_get_var_names (exoid, "g", num_glo_vars, var_names);
699   printf ("\nafter ex_get_var_names, error = %3d\n", error);
700
701   printf ("There are %2d global variables; their names are :\n", 
702           num_glo_vars);
703   for (i=0; i<num_glo_vars; i++)
704   {
705      printf (" '%s'\n", var_names[i]);
706      free(var_names[i]);
707   }
708
709
710/* read nodal variables parameters and names */
711
712   error = ex_get_var_param (exoid, "n", &num_nod_vars);
713   printf ("\nafter ex_get_var_param, error = %3d\n", error);
714
715   for (i=0; i<num_nod_vars; i++)
716   {
717      var_names[i] = (char *) calloc ((MAX_STR_LENGTH+1), sizeof(char));
718   }
719
720   error = ex_get_var_names (exoid, "n", num_nod_vars, var_names);
721   printf ("\nafter ex_get_var_names, error = %3d\n", error);
722
723   printf ("There are %2d nodal variables; their names are :\n", num_nod_vars);
724   for (i=0; i<num_nod_vars; i++)
725   {
726      printf (" '%s'\n", var_names[i]);
727      free(var_names[i]);
728   }
729
730/* read element variables parameters and names */
731
732   error = ex_get_var_param (exoid, "e", &num_ele_vars);
733   printf ("\nafter ex_get_var_param, error = %3d\n", error);
734
735   for (i=0; i<num_ele_vars; i++)
736   {
737      var_names[i] = (char *) calloc ((MAX_STR_LENGTH+1), sizeof(char));
738   }
739
740   error = ex_get_var_names (exoid, "e", num_ele_vars, var_names);
741   printf ("\nafter ex_get_var_names, error = %3d\n", error);
742
743   printf ("There are %2d element variables; their names are :\n", 
744            num_ele_vars);
745   for (i=0; i<num_ele_vars; i++)
746   {
747      printf (" '%s'\n", var_names[i]);
748      free(var_names[i]);
749   }
750
751
752/* read element variable truth table */
753
754   truth_tab = (int *) calloc ((num_elem_blk*num_ele_vars), sizeof(int));
755
756   error = ex_get_elem_var_tab (exoid, num_elem_blk, num_ele_vars, truth_tab);
757   printf ("\nafter ex_get_elem_var_tab, error = %3d\n", error);
758
759   printf ("This is the element variable truth table:\n");
760
761   k = 0;
762   for (i=0; i<num_elem_blk*num_ele_vars; i++)
763   {
764      printf ("%2d\n", truth_tab[k++]);
765   }
766   free (truth_tab);
767
768/* determine how many time steps are stored */
769
770   error = ex_inquire (exoid, EX_INQ_TIME, &num_time_steps, &fdum, cdum);
771   printf ("\nafter ex_inquire, error = %3d\n", error);
772   printf ("There are %2d time steps in the database.\n", num_time_steps);
773
774/* read time value at one time step */
775
776   time_step = 3;
777   error = ex_get_time (exoid, time_step, &time_value);
778   printf ("\nafter ex_get_time, error = %3d\n", error);
779
780   printf ("time value at time step %2d = %5.3f\n", time_step, time_value);
781
782/* read time values at all time steps */
783
784   time_values = (double *) calloc (num_time_steps, sizeof(double));
785
786   error = ex_get_all_times (exoid, time_values);
787   printf ("\nafter ex_get_all_times, error = %3d\n", error);
788
789   printf ("time values at all time steps are:\n");
790   for (i=0; i<num_time_steps; i++) printf ("%5.3f\n", time_values[i]);
791
792   free (time_values);
793
794/* read all global variables at one time step */
795
796   var_values = (double *) calloc (num_glo_vars, sizeof(double));
797
798   error = ex_get_glob_vars (exoid, time_step, num_glo_vars, var_values);
799   printf ("\nafter ex_get_glob_vars, error = %3d\n", error);
800
801   printf ("global variable values at time step %2d\n", time_step);
802   for (i=0; i<num_glo_vars; i++) printf ("%5.3f\n", var_values[i]);
803
804   free (var_values); 
805
806/* read a single global variable through time */
807
808   var_index = 1;
809   beg_time = 1;
810   end_time = -1;
811
812   var_values = (double *) calloc (num_time_steps, sizeof(double));
813
814   error = ex_get_glob_var_time (exoid, var_index, beg_time, end_time, 
815                                 var_values);
816   printf ("\nafter ex_get_glob_var_time, error = %3d\n", error);
817
818   printf ("global variable %2d values through time:\n", var_index);
819   for (i=0; i<num_time_steps; i++) printf ("%5.3f\n", var_values[i]);
820
821   free (var_values); 
822
823/* read a nodal variable at one time step */
824
825   var_values = (double *) calloc (num_nodes, sizeof(double));
826
827   error = ex_get_nodal_var (exoid, time_step, var_index, num_nodes, 
828                             var_values);
829   printf ("\nafter ex_get_nodal_var, error = %3d\n", error);
830
831   printf ("nodal variable %2d values at time step %2d\n", var_index, 
832           time_step);
833   for (i=0; i<num_nodes; i++) printf ("%5.3f\n", var_values[i]);
834
835   free (var_values); 
836
837/* read a nodal variable through time */
838
839   var_values = (double *) calloc (num_time_steps, sizeof(double));
840
841   node_num = 1;
842   error = ex_get_nodal_var_time (exoid, var_index, node_num, beg_time, 
843                                  end_time, var_values);
844   printf ("\nafter ex_get_nodal_var_time, error = %3d\n", error);
845
846   printf ("nodal variable %2d values for node %2d through time:\n", var_index,
847           node_num);
848   for (i=0; i<num_time_steps; i++) printf ("%5.3f\n", var_values[i]);
849
850   free (var_values); 
851
852/* read an element variable at one time step */
853
854   ids = (int *) calloc(num_elem_blk, sizeof(int));
855
856   error = ex_get_elem_blk_ids (exoid, ids);
857   printf ("\n after ex_get_elem_blk_ids, error = %3d\n", error);
858
859   for (i=0; i<num_elem_blk; i++)
860   {
861      var_values = (double *) calloc (num_elem_in_block[i], sizeof(double));
862
863      error = ex_get_elem_var (exoid, time_step, var_index, ids[i], 
864                               num_elem_in_block[i], var_values);
865      printf ("\nafter ex_get_elem_var, error = %3d\n", error);
866
867      if (!error)
868      {
869         printf 
870    ("element variable %2d values of element block %2d at time step %2d\n",
871            var_index, ids[i], time_step);
872         for (j=0; j<num_elem_in_block[i]; j++) 
873            printf ("%5.3f\n", var_values[j]);
874      }
875
876      free (var_values); 
877   }
878   free (num_elem_in_block);
879   free(ids);
880
881/* read an element variable through time */
882
883   var_values = (double *) calloc (num_time_steps, sizeof(double));
884
885   var_index = 2;
886   elem_num = 2;
887   error = ex_get_elem_var_time (exoid, var_index, elem_num, beg_time, 
888                                  end_time, var_values);
889   printf ("\nafter ex_get_elem_var_time, error = %3d\n", error);
890
891   printf ("element variable %2d values for element %2d through time:\n", 
892           var_index, elem_num);
893   for (i=0; i<num_time_steps; i++) printf ("%5.3f\n", var_values[i]);
894
895   free (var_values); 
896
897   error = ex_close (exoid);
898   printf ("\nafter ex_close, error = %3d\n", error);
899   return 0;
900}