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  * OVERVIEW
38  *
39  * This file contains jacket routines written in C for interfacing Fortran
40  * ExodusII function calls to the actual C binding for ExodusII.
41 
42  * In general, these functions handle
43  * character-string parameter conventions, convert between
44  * column-major-order arrays and row-major-order arrays, and map between
45  * array indices beginning at one and array indices beginning at zero.
46  *
47  */
48 
49 /* LINTLIBRARY */
50 #include <ctype.h>
51 #include <string.h>
52 #include <stdio.h>
53 #include <stdlib.h>
54 #include "netcdf.h"
55 #include "exodusII.h"
56 #include "exodusII_int.h"
57 
58 /*
59  * The Build64 is for the "normal" SEACAS build which uses compiler
60  * options to change reals and integers into 8-byte quantities.  The
61  * routines in addrwrap.F are used to down-convert the 8-byte integers
62  * into 4-byte integers which then call through to the routines in
63  * this file which have a '4' or '4_' appended to the routine name.
64  * These routines then call through to the C API routines.
65  *
66  * If DEFAULT_REAL_INT is defined, then the build is to build a
67  * fortran library interface that takes 4-byte ints and either 4-byte
68  * or 8-byte floating point (real/double) variables. In this case, the
69  * addrwrap routines are not built and a fortran client will call the
70  * routines in this file directly.
71  *
72  */
73 
74 #if defined(Build64) && !defined(DEFAULT_REAL_INT)
75 /* 64-bit */
76 #define real double
77 #define entity_id ex_entity_id
78 #ifdef ADDC_
79 #define F2C(name) name##4_
80 #else
81 #define F2C(name) name##4
82 #endif
83 
84 #else
85 /* 32-bit */
86 #define real float
87 #define entity_id int
88 #ifdef ADDC_
89 #define F2C(name) name##_
90 #else
91 #define F2C(name) name
92 #endif
93 #endif
94 
95 extern int      ncopts;         /* default is (NC_FATAL | NC_VERBOSE) */
96 extern int      exerrval;       /* global integer that contains a
97                                  * Exodus-specific error code */
98 
99 /* blank fill C string to make FORTRAN string */
100 static void
ex_fcdcpy(char * fstring,int fslen,char * sstring)101 ex_fcdcpy(char *fstring,        /* output string to be blank-filled */
102           int fslen,            /* length of output string */
103           char *sstring)
104 {                               /* input string, null-terminated */
105   int             i, len;
106 
107   if (sstring != NULL) {
108     len = strlen(sstring);
109     if (len > fslen)
110       len = fslen;
111 
112     for (i = 0; i < len; i++)
113       *(fstring + i) = *(sstring + i);
114     for (i = len; i < fslen; i++)
115       *(fstring + i) = ' ';
116   } else {
117     for (i = 0; i < fslen; i++)
118       *(fstring + i) = ' ';
119   }
120 }
121 
122 /* copy function used to copy strings and strip trailing blanks */
123 static void
ex_fstrncpy(char * target,char * source,int maxlen)124 ex_fstrncpy(char *target,       /* space to be copied into */
125             char *source,       /* string to be copied */
126             int maxlen)
127 {                               /* maximum length of *source */
128   int             len = maxlen;
129 
130   while (len-- && *source != '\0')
131     *target++ = *source++;
132 
133   len = maxlen;
134   while (len-- && *(--target) == ' ');  /* strip blanks */
135   *(++target) = '\0';           /* insert new EOS marker */
136 }
137 
138 /* copy function used to copy strings terminated with blanks */
139 static void
ex_nstrncpy(char * target,char * source,int maxlen)140 ex_nstrncpy(char *target,       /* space to be copied into */
141             char *source,       /* string to be copied */
142             int maxlen)
143 {                               /* maximum length of *source */
144   while (maxlen-- && *source != ' ')
145     *target++ = *source++;
146   *target = '\0';
147 }
148 
149 /* Above are utility functions used below                                   */
150 /* ======================================================================== */
151 /* Below are the exodus API functions                                       */
152 /*
153  * Adding a new function:
154  * +  Protect the name with the f2c (uppercase) macro which will add/not add '4' and or '_'
155  *    depending on the compilation mode.
156  *
157  * +  float/double arguments are declared as 'real' which will be replaced with float or double.
158  *
159  * +  If there are any character arguments 'X', then add an int* argument 'Xlen' at end of argument list
160  *    This will contain the length of the passed in character argument.
161  *
162  * +  Look at existing functions for guidance...
163  */
164 
165 /*
166  * create an EXODUS II file
167  */
168 int
F2C(excre)169 F2C(excre) (char *path,
170             int *clobmode,
171             int *cpu_word_size,
172             int *io_word_size,
173             int *ierr,
174             int pathlen)
175 {
176   char           *name;
177   int             idexo;
178 
179   if (!(name = malloc((pathlen + 1) * sizeof(char)))) {
180     *ierr = EX_MEMFAIL;
181     return (EX_FATAL);
182   }
183   (void) ex_nstrncpy(name, path, pathlen);
184 
185   if ((idexo = ex_create(name, *clobmode, cpu_word_size, io_word_size)) != EX_FATAL) {
186     free(name);
187     *ierr = 0;
188     return (idexo);
189   }
190   free(name);
191   *ierr = exerrval;
192   return (EX_FATAL);
193 }
194 
195 /*
196  * open an EXODUS II file
197  */
198 int
F2C(exopen)199 F2C(exopen) (char *path,
200              int *mode,
201              int *cpu_word_size,
202              int *io_word_size,
203              float *version,    /* This is float always; not real */
204              int *ierr,
205              int pathlen)
206 {
207   char           *name;
208   int             idexo;
209 
210   if (!(name = malloc((pathlen + 1) * sizeof(char)))) {
211     *ierr = EX_MEMFAIL;
212     return (EX_FATAL);
213   }
214   (void) ex_nstrncpy(name, path, pathlen);
215   if ((idexo = ex_open(name, *mode, cpu_word_size, io_word_size, version)) != EX_FATAL) {
216     free(name);
217     *ierr = 0;
218     return (idexo);
219   }
220   free(name);
221   *ierr = EX_FATAL;
222   return (EX_FATAL);
223 }
224 
225 /*
226  * close an EXODUS II file
227  */
228 void
F2C(exclos)229 F2C(exclos) (int *idexo, int *ierr)
230 {
231   *ierr = ex_close(*idexo);
232 }
233 
234 /*
235  * update an EXODUS II file
236  */
237 void
F2C(exupda)238 F2C(exupda) (int *idexo, int *ierr)
239 {
240   *ierr = ex_update(*idexo);
241 }
242 
243 /*
244  * write initialization parameters
245  */
246 void
F2C(expini)247 F2C(expini) (int *idexo,
248              char *title,
249              void_int *num_dim,
250              void_int *num_nodes,
251              void_int *num_elem,
252              void_int *num_elem_blk,
253              void_int *num_node_sets,
254              void_int *num_side_sets,
255              int *ierr,
256              int titlelen)
257 {
258   int             slen;
259   char           *name;
260 
261   slen = MAX_LINE_LENGTH;       /* max line size */
262   if (titlelen != MAX_LINE_LENGTH) {
263     slen = titlelen;
264   }
265   name = malloc((slen + 1) * sizeof(char));
266   (void) ex_fstrncpy(name, title, slen);
267 
268   if (ex_int64_status(*idexo) & EX_BULK_INT64_API) {
269     int64_t *n_dim 	 = num_dim;
270     int64_t *n_nodes 	 = num_nodes;
271     int64_t *n_elem  	 = num_elem;
272     int64_t *n_elem_blk  = num_elem_blk;
273     int64_t *n_node_sets = num_node_sets;
274     int64_t *n_side_sets = num_side_sets;
275 
276     *ierr = ex_put_init(*idexo, name, *n_dim, *n_nodes, *n_elem,
277 			*n_elem_blk, *n_node_sets, *n_side_sets);
278   } else {
279     int *n_dim 	     = num_dim;
280     int *n_nodes     = num_nodes;
281     int *n_elem      = num_elem;
282     int *n_elem_blk  = num_elem_blk;
283     int *n_node_sets = num_node_sets;
284     int *n_side_sets = num_side_sets;
285 
286     *ierr = ex_put_init(*idexo, name, *n_dim, *n_nodes, *n_elem,
287 			*n_elem_blk, *n_node_sets, *n_side_sets);
288   }
289   free(name);
290 }
291 
292 /*
293  * read initialization parameters
294  */
295 void
F2C(exgini)296 F2C(exgini) (int *idexo,
297              char *title,
298              void_int *num_dim,
299              void_int *num_nodes,
300              void_int *num_elem,
301              void_int *num_elem_blk,
302              void_int *num_node_sets,
303              void_int *num_side_sets,
304              int *ierr,
305              int titlelen)
306 {
307   int             slen;
308   char           *name;
309 
310   *ierr = 0;
311   slen = MAX_LINE_LENGTH;       /* max line size */
312   if (titlelen != MAX_LINE_LENGTH) {
313     slen = titlelen;
314   }
315   name = malloc((slen + 1) * sizeof(char));
316   memset(name, 0, slen + 1);
317 
318   *ierr = ex_get_init(*idexo, name, num_dim, num_nodes, num_elem, num_elem_blk,
319                       num_node_sets, num_side_sets);
320 
321   ex_fcdcpy(title, slen, name);
322   free(name);
323 }
324 
325 /*
326  * write QA records
327  */
328 void
F2C(expqa)329 F2C(expqa) (int *idexo,
330             int *num_qa_records,
331             char *qa_record,
332             int *ierr,
333             int qa_recordlen)
334 {
335   char            errmsg[MAX_ERR_LENGTH];
336   char          **sptr;         /* internal string pointer array for malloc
337                                  * use */
338   int             i, ii, iii, slen, alen;
339 
340   *ierr = 0;                    /* default no errror */
341 
342   slen = MAX_STR_LENGTH;        /* max str size */
343   if (qa_recordlen != MAX_STR_LENGTH) {
344     slen = qa_recordlen;
345   }
346   alen = 4;                     /* qa records are 4 strings deep */
347 
348   /* Allocate space for the name ptr array */
349   if (!(sptr = malloc(((*num_qa_records) * alen + 1) * sizeof(char *)))) {
350     *ierr = EX_MEMFAIL;
351     return;
352   }
353   /*
354    * Allocate space for each of the strings, where size = slen, place
355    * ptr into str ptr array,  and Copy Fortran qa records to staging
356    * space
357    */
358   iii = 0;                      /* offset counter */
359   for (i = 0; i < *num_qa_records; i++) {
360     for (ii = 0; ii < alen; ii++) {
361       *(sptr + iii) = malloc((slen + 1) * sizeof(char));
362       if (*(sptr + iii) == 0) {
363         free(sptr);             /* free up array ptr space */
364         *ierr = EX_MEMFAIL;
365         sprintf(errmsg,
366           "Error: failed to allocate space for qa record %d for file id %d",
367                 i, *idexo);
368         ex_err("expqa", errmsg, EX_MEMFAIL);
369         return;
370       }
371       /* copy fortran string into allocated space */
372       ex_fstrncpy(*(sptr + iii), qa_record + iii * qa_recordlen, slen);
373       iii++;                    /* bump char array pointer */
374     }
375   }
376   *(sptr + iii) = 0;            /* set last pointer to null */
377 
378   if (ex_put_qa(*idexo, *num_qa_records, (void *) sptr) == EX_FATAL)
379     *ierr = EX_FATAL;
380 
381   /* Free up the space we used */
382   iii = 0;
383   for (i = 0; i < *num_qa_records; i++) {
384     for (ii = 0; ii < alen; ii++) {
385       free(*(sptr + iii));      /* First free up string space */
386       iii++;
387     }
388   }
389   free(sptr);                   /* Then free up array ptr space */
390 }
391 
392 /*
393  * read QA records
394  */
395 void
F2C(exgqa)396 F2C(exgqa) (int *idexo,
397             char *qa_record,
398             int *ierr,
399             int qa_recordlen)
400 {
401   int             num_qa_records;
402   char          **sptr;         /* internal string pointer array for malloc
403                                  * use */
404   int             i, ii, iii, slen, alen;
405 
406   *ierr = 0;                    /* default no errror */
407 
408   slen = MAX_STR_LENGTH;        /* max str size */
409   if (qa_recordlen != MAX_STR_LENGTH) {
410     slen = qa_recordlen;
411   }
412   alen = 4;                     /* qa records are 4 strings deep */
413 
414   /* do ExodusII C call to find out how many qa records are avail */
415   num_qa_records = ex_inquire_int(*idexo, EX_INQ_QA);
416 
417   /* Allocate space for the QA string ptr array */
418   if (!(sptr = malloc((num_qa_records * alen + 1) * sizeof(char *)))) {
419     *ierr = EX_MEMFAIL;
420     return;
421   }
422   /*
423    * Step 1: Allocate space for each of the strings, where size = slen,
424    * place string ptr into str ptr array. Step 2: Call routine to get
425    * qa records Step 3: Copy C qa records to passed Fortran array space
426    */
427 
428   iii = 0;                      /* offset counter */
429   for (i = 0; i < num_qa_records; i++) {        /* pointer allocation loop */
430     for (ii = 0; ii < alen; ii++) {
431       *(sptr + iii) = malloc((slen + 1) * sizeof(char));
432       if (*(sptr + iii) == 0) {
433         *ierr = EX_MEMFAIL;
434         return;
435       }
436       iii++;                    /* bump char array pointer */
437     }
438   }
439   *(sptr + iii) = 0;            /* null out last pointer */
440 
441   /* do ExodusII C call to get qa records */
442   if (ex_get_qa(*idexo, (void *) sptr) == EX_FATAL) {
443     *ierr = EX_FATAL;
444     return;
445   }
446   iii = 0;                      /* offset counter */
447   for (i = 0; i < num_qa_records; i++) {        /* string copy loop */
448     for (ii = 0; ii < alen; ii++) {
449       /* copy fortran string into allocated space */
450       ex_fcdcpy(qa_record + iii * qa_recordlen, slen, *(sptr + iii));
451       iii++;                    /* bump char array pointer */
452     }
453   }
454 
455   /* Free up the space we used */
456   iii = 0;
457   for (i = 0; i < num_qa_records; i++) {
458     for (ii = 0; ii < alen; ii++) {
459       free(*(sptr + iii));      /* First free up string space */
460       iii++;
461     }
462   }
463   free(sptr);                   /* Then free up array ptr space */
464 }
465 
466 /*
467  * write information records
468  */
469 void
F2C(expinf)470 F2C(expinf) (int *idexo,
471              int *num_info,
472              char *info,
473              int *ierr,
474              int infolen)
475 {
476   char          **aptr;         /* internal string array pointer for malloc
477                                  * use */
478   char           *sptr;         /* internal string pointer for malloc use */
479   int             i, slen;
480 
481   *ierr = 0;                    /* default no errror */
482   slen = MAX_LINE_LENGTH;       /* max str size */
483   if (infolen != MAX_LINE_LENGTH) {
484     slen = infolen;
485   }
486   /* Allocate space for the string ptr array */
487   if (!(aptr = malloc(((*num_info) + 1) * sizeof(char *)))) {
488     *ierr = EX_MEMFAIL;
489     return;
490   }
491   /* Allocate staging space for the info records */
492   if (!(sptr = malloc(*num_info * (slen + 1) * sizeof(char)))) {
493     free(aptr);                 /* Free up string ptr array */
494     *ierr = EX_MEMFAIL;
495     return;
496   }
497   /* Copy Fortran info records to staging space */
498   for (i = 0; i < *num_info; i++) {
499     *(aptr + i) = sptr + i * (slen + 1);        /* put address into ptr array */
500     ex_fstrncpy(*(aptr + i), info + i * infolen, slen); /* copy string into
501                                                          * buffer */
502   }
503   *(aptr + i) = 0;              /* null out last ptr */
504   if (ex_put_info(*idexo, *num_info, aptr) == EX_FATAL) {
505     *ierr = EX_FATAL;
506     free(sptr);                 /* Free up string staging area */
507     free(aptr);                 /* Free up string ptr array */
508     return;
509   }
510   free(sptr);                   /* Free up string staging area */
511   free(aptr);                   /* Free up string ptr array */
512 }
513 
514 /*
515  * read information records
516  */
517 void
F2C(exginf)518 F2C(exginf) (int *idexo,
519              char *info,
520              int *ierr,
521              int infolen)
522 {
523   char          **aptr;         /* internal string array pointer for malloc
524                                  * use */
525   char           *sptr;         /* internal string pointer for malloc use */
526   int             i, slen, num_info;
527 
528   *ierr = 0;                    /* default no errror */
529 
530   /* do exodusII C call to find out how many info records are avail */
531   num_info = ex_inquire_int(*idexo, EX_INQ_INFO);
532 
533   slen = MAX_LINE_LENGTH;       /* max str size */
534   if (infolen != MAX_LINE_LENGTH) {
535     slen = infolen;
536   }
537   /*
538    * Step 1: Allocate space for string ptr array Step 2: Allocate space
539    * for info record strings, and put pointers into str ptr array Step
540    * 3: Do ExodusII call to get records Step 4: Copy strings into
541    * passed Fortran buffer space
542    */
543 
544   /* Allocate space for the string ptr array */
545   if (!(aptr = malloc((num_info + 1) * sizeof(char *)))) {
546     *ierr = EX_MEMFAIL;
547     return;
548   }
549   /* Allocate block of space for info strings */
550   if (!(sptr = malloc(num_info * (slen + 1) * sizeof(char)))) {
551     free(aptr);                 /* Free up string ptr array */
552     *ierr = EX_MEMFAIL;
553     return;
554   }
555   for (i = 0; i < num_info; i++)/* Put pointers to the info records in ptr
556                                  * array */
557     *(aptr + i) = sptr + i * (slen + 1);        /* put ptr in string ptr
558                                                  * array */
559   *(aptr + i) = 0;              /* null out last pointer */
560 
561   /* Do exodusII call to get info records */
562   if (ex_get_info(*idexo, aptr) == EX_FATAL) {
563     *ierr = EX_FATAL;
564     free(sptr);
565     free(aptr);
566     return;
567   }
568   for (i = 0; i < num_info; i++) {      /* Copy Fortran info records to
569                                          * staging space */
570     ex_fcdcpy(info + i * infolen, slen, *(aptr + i));   /* copy string into
571                                                          * buffer */
572     /** printf("[exginf] rec: %d , %s\n",i,*(aptr+i)); **/
573   }
574 
575   free(sptr);                   /* Free up string staging area */
576   free(aptr);                   /* Free up string ptr array */
577 
578 }
579 
580 /*
581  * write nodal coordinates
582  */
583 void
F2C(expcor)584 F2C(expcor) (int *idexo,
585              real * x_coor,
586              real * y_coor,
587              real * z_coor,
588              int *ierr)
589 {
590   *ierr = ex_put_coord(*idexo, x_coor, y_coor, z_coor);
591 }
592 
593 /*
594  * read nodal coordinates
595  */
596 void
F2C(exgcor)597 F2C(exgcor) (int *idexo,
598              real * x_coor,
599              real * y_coor,
600              real * z_coor,
601              int *ierr)
602 {
603   *ierr = ex_get_coord(*idexo, x_coor, y_coor, z_coor);
604 }
605 
606 /*
607  * write coordinate names
608  */
609 void
F2C(expcon)610 F2C(expcon) (int *idexo,
611              char *coord_names,
612              int *ierr,
613              int coord_nameslen)
614 {
615   char          **aptr;         /* internal array of string pointers for
616                                  * malloc use */
617   char           *sptr;         /* internal string pointer for malloc use */
618   int             i, ndim, slen;
619 
620   *ierr = 0;                    /* default no errror */
621 
622   slen = ex_inquire_int(*idexo, EX_INQ_DB_MAX_ALLOWED_NAME_LENGTH);     /* max str size */
623   if (coord_nameslen < slen) {
624     slen = coord_nameslen;
625   }
626   /* do ExodusII C call to find out how many dimensions  */
627   ndim = ex_inquire_int(*idexo, EX_INQ_DIM);
628 
629   /* Allocate space for the name ptr array */
630   if (!(aptr = malloc((ndim + 1) * sizeof(char *)))) {
631     *ierr = EX_MEMFAIL;
632     return;
633   }
634   /*
635    * Allocate a block of space for the strings, where size = slen,
636    * place ptrs into str ptr array,  and Copy Fortran coordinate names
637    * to staging space
638    */
639 
640   if (!(sptr = malloc(ndim * (slen + 1) * sizeof(char)))) {
641     *ierr = EX_MEMFAIL;
642     free(aptr);
643     return;
644   }
645   for (i = 0; i < ndim; i++) {
646     *(aptr + i) = sptr + i * (slen + 1);
647     /* copy fortran string into allocated space */
648     ex_fstrncpy(*(aptr + i), coord_names + i * coord_nameslen, slen);
649   }
650   *(aptr + i) = 0;              /* set last pointer to null */
651 
652   if (ex_put_coord_names(*idexo, aptr) == EX_FATAL) {
653     *ierr = EX_FATAL;
654   }
655   /* Free up the space we used */
656   free(sptr);                   /* First free up string space */
657   free(aptr);                   /* Then free up array ptr space */
658 }
659 /*
660  * read coordinate names
661  */
662 void
F2C(exgcon)663 F2C(exgcon) (int *idexo,
664              char *coord_names,
665              int *ierr,
666              int coord_nameslen)
667 {
668   char          **aptr;         /* internal string array pointer for malloc
669                                  * use */
670   char           *sptr;         /* internal string pointer for malloc use */
671   int             ndim;
672   int             i, slen;
673 
674   *ierr = 0;                    /* default no error */
675 
676   slen = ex_inquire_int(*idexo, EX_INQ_MAX_READ_NAME_LENGTH); /* max string size */
677   if (coord_nameslen < slen) {
678     slen = coord_nameslen;
679   }
680   /* do ExodusII C call to find out how many dimensions */
681   ndim = ex_inquire_int(*idexo, EX_INQ_DIM);
682 
683   /* allocate memory to stage the coordinate name ptrs into */
684   if (!(aptr = malloc((ndim + 1) * sizeof(char *)))) {
685     *ierr = EX_MEMFAIL;
686     return;
687   }
688   /* allocate a block of memory to stage the coordinate names into */
689   if (!(sptr = malloc(ndim * (slen + 1) * sizeof(char)))) {
690     *ierr = EX_MEMFAIL;
691     free(aptr);                 /* free up array ptr space */
692     return;
693   }
694   for (i = 0; i < ndim; i++) {  /* put pointers to staging space into ptr
695                                  * array */
696     *(aptr + i) = sptr + i * (slen + 1);
697   }
698 
699   /* do ExodusII C call to get coord name records */
700   if (ex_get_coord_names(*idexo, aptr) == EX_FATAL) {
701     *ierr = EX_FATAL;
702     free(sptr);                 /* free up string space */
703     free(aptr);                 /* free up array ptr space */
704     return;
705   }
706   /* copy C strings to Fortran arrays */
707   memset(coord_names, 0, ndim * coord_nameslen);
708   for (i = 0; i < ndim; i++) {
709     ex_fcdcpy(coord_names + i * coord_nameslen, slen, *(aptr + i));     /* copy and blank fill */
710   }
711 
712   free(sptr);                   /* Free up string buffer space */
713   free(aptr);                   /* Finally, free up array ptr space */
714   return;
715 }
716 
717 /*
718  * write element order map
719  */
720 void
F2C(expmap)721 F2C(expmap) (int *idexo,
722              void_int *elem_map,
723              int *ierr)
724 {
725   *ierr = ex_put_map(*idexo, elem_map);
726 }
727 
728 /*
729  * read element order map
730  */
731 void
F2C(exgmap)732 F2C(exgmap) (int *idexo,
733              void_int *elem_map,
734              int *ierr)
735 {
736   *ierr = ex_get_map(*idexo, elem_map);
737 }
738 
739 /*
740  * write concatenated element block parameters
741  */
742 void
F2C(expclb)743 F2C(expclb) (int *idexo,
744              void_int *elem_blk_id,
745              char *elem_type,
746              void_int *num_elem_this_blk,
747              void_int *num_nodes_per_elem,
748              void_int *num_attr,
749              int *create_maps,
750              int *ierr,
751              int elem_typelen)
752 {
753   size_t          num_elem_blk;
754 
755   char          **aptr;         /* ptr to temp staging space for string array
756                                  * ptrs */
757   char           *sptr;         /* ptr to temp staging space for strings */
758   size_t          i, slen;
759 
760   *ierr = 0;                    /* default no error */
761 
762   num_elem_blk = ex_inquire_int(*idexo, EX_INQ_ELEM_BLK);
763 
764   slen = MAX_STR_LENGTH;        /* max str size */
765   if (elem_typelen != MAX_STR_LENGTH) {
766     slen = elem_typelen;
767   }
768   /* allocate memory for pointer array */
769   if (!(aptr = malloc((num_elem_blk + 1) * sizeof(char *)))) {
770     *ierr = EX_MEMFAIL;
771     return;
772   }
773   /* allocate memory to stage the element type name into */
774   if (!(sptr = malloc(num_elem_blk * (slen + 1) * sizeof(char)))) {
775     *ierr = EX_MEMFAIL;
776     return;
777   }
778   /* Copy element type names from Fortran array to staging area */
779   for (i = 0; i < num_elem_blk; i++) {
780     *(aptr + i) = sptr + i * (slen + 1);        /* put address into ptr array */
781     ex_fstrncpy(*(aptr + i), elem_type + i * elem_typelen, slen);       /* copy string into
782                                                                          * buffer */
783   }
784   *(aptr + i) = 0;              /* null out last ptr */
785 
786   if (ex_put_concat_elem_block(*idexo, elem_blk_id, aptr, num_elem_this_blk,
787                   num_nodes_per_elem, num_attr, *create_maps) == EX_FATAL) {
788     *ierr = EX_FATAL;
789   }
790   free(sptr);
791   free(aptr);
792 }
793 
794 /*
795  * write element block parameters
796  */
797 void
F2C(expelb)798 F2C(expelb) (int *idexo,
799              entity_id *elem_blk_id,
800              char *elem_type,
801              void_int *num_elem_this_blk,
802              void_int *num_nodes_per_elem,
803              void_int *num_attr,
804              int *ierr,
805              int elem_typelen)
806 {
807   char           *sptr;         /* internal string pointer for malloc use */
808   int             slen;
809 
810   *ierr = 0;                    /* default no error */
811 
812   slen = MAX_STR_LENGTH;        /* max str size */
813   if (elem_typelen != MAX_STR_LENGTH) {
814     slen = elem_typelen;
815   }
816   /* allocate memory to stage the element type name into */
817   if (!(sptr = malloc((slen + 1) * sizeof(char)))) {
818     *ierr = EX_MEMFAIL;
819     return;
820   }
821   /* Copy element type names from Fortran array to staging area */
822   ex_fstrncpy(sptr, elem_type, slen);
823 
824   if (ex_int64_status(*idexo) & EX_BULK_INT64_API) {
825     int64_t *n_elem_this_blk  = num_elem_this_blk;
826     int64_t *n_nodes_per_elem = num_nodes_per_elem;
827     int64_t *n_attr           = num_attr;
828 
829     *ierr = ex_put_elem_block(*idexo, *elem_blk_id, sptr, *n_elem_this_blk,
830 			      *n_nodes_per_elem, *n_attr);
831   } else {
832     int *n_elem_this_blk  = num_elem_this_blk;
833     int *n_nodes_per_elem = num_nodes_per_elem;
834     int *n_attr           = num_attr;
835 
836     *ierr = ex_put_elem_block(*idexo, *elem_blk_id, sptr, *n_elem_this_blk,
837 			      *n_nodes_per_elem, *n_attr);
838   }
839   free(sptr);
840 }
841 
842 /*
843  * read element block parameters
844  */
845 void
F2C(exgelb)846 F2C(exgelb) (int *idexo,
847              entity_id *elem_blk_id,
848              char *elem_type,
849              void_int *num_elem_this_blk,
850              void_int *num_nodes_per_elem,
851              void_int *num_attr,
852              int *ierr,
853              int elem_typelen)
854 {
855   char           *sptr;         /* internal string pointer for malloc use */
856   int             slen;
857 
858   *ierr = 0;
859 
860   slen = MAX_STR_LENGTH;        /* max str size */
861   if (elem_typelen != MAX_STR_LENGTH) {
862     slen = elem_typelen;
863   }
864   /* allocate memory to stage the element type names into */
865   if (!(sptr = malloc((slen + 1) * sizeof(char)))) {
866     *ierr = EX_MEMFAIL;
867     return;
868   }
869   if (ex_get_elem_block(*idexo, *elem_blk_id, sptr, num_elem_this_blk,
870                         num_nodes_per_elem, num_attr) == EX_FATAL) {
871     *ierr = EX_FATAL;
872     return;
873   }
874   /* Copy element type name from staging area to Fortran array */
875   memset(elem_type, 0, elem_typelen);
876   ex_fcdcpy(elem_type, slen, sptr);
877   free(sptr);
878 
879 }
880 
881 /*
882  * read element blocks IDs
883  */
884 void
F2C(exgebi)885 F2C(exgebi) (int *idexo,
886              void_int *elem_blk_ids,
887              int *ierr)
888 {
889   *ierr = ex_get_elem_blk_ids(*idexo, elem_blk_ids);
890 }
891 
892 /*
893  * write element block connectivity
894  */
895 void
F2C(expelc)896 F2C(expelc) (int *idexo,
897              entity_id *elem_blk_id,
898              void_int *connect,
899              int *ierr)
900 {
901   *ierr = ex_put_elem_conn(*idexo, *elem_blk_id, connect);
902 }
903 
904 /*
905  * read element block connectivity
906  */
907 void
F2C(exgelc)908 F2C(exgelc) (int *idexo,
909              entity_id *elem_blk_id,
910              void_int *connect,
911              int *ierr)
912 {
913   *ierr = ex_get_elem_conn(*idexo, *elem_blk_id, connect);
914 }
915 
916 /*
917  * write entity count-per-polyhedra information for nsided block
918  */
919 void
F2C(expecpp)920 F2C(expecpp) (int *idexo,
921               int *obj_type,
922               entity_id *elem_blk_id,
923               int *counts,
924               int *ierr)
925 {
926   *ierr = ex_put_entity_count_per_polyhedra(*idexo, (ex_entity_type) * obj_type, *elem_blk_id, counts);
927 }
928 
929 /*
930  * read entity count-per-polyhedra information for nsided block
931  */
932 void
F2C(exgecpp)933 F2C(exgecpp) (int *idexo,
934               int *obj_type,
935               entity_id *elem_blk_id,
936               int *counts,
937               int *ierr)
938 {
939   *ierr = ex_get_entity_count_per_polyhedra(*idexo, (ex_entity_type) * obj_type, *elem_blk_id, counts);
940 }
941 
942 /*
943  * write element block attributes
944  */
945 void
F2C(expeat)946 F2C(expeat) (int *idexo,
947              entity_id *elem_blk_id,
948              real * attrib,
949              int *ierr)
950 {
951   *ierr = ex_put_elem_attr(*idexo, *elem_blk_id, attrib);
952 }
953 
954 
955 /*
956  * read element block attributes
957  */
958 void
F2C(exgeat)959 F2C(exgeat) (int *idexo,
960              entity_id *elem_blk_id,
961              real * attrib,
962              int *ierr)
963 {
964   *ierr = ex_get_elem_attr(*idexo, *elem_blk_id, attrib);
965 }
966 
967 /*
968  * read element block attribute names
969  */
970 void
F2C(exgean)971 F2C(exgean) (int *idexo,
972              entity_id *elem_blk_id,
973              int *num_attr,
974              char *names,
975              int *ierr,
976              int nameslen)
977 {
978   char          **aptr;         /* ptr to temp staging space for string array
979                                  * ptrs */
980   char           *sptr;         /* ptr to temp staging space for strings */
981   int             i, slen;
982 
983   *ierr = 0;                    /* default no errror */
984 
985   slen = ex_inquire_int(*idexo, EX_INQ_MAX_READ_NAME_LENGTH); /* max string size */
986   if (nameslen < slen) {
987     slen = nameslen;
988   }
989   /* allocate memory to for pointer array */
990   if (!(aptr = malloc((*num_attr + 1) * sizeof(char *)))) {
991     *ierr = EX_MEMFAIL;
992     return;
993   }
994   /* Allocate staging space for the variable names */
995   if (!(sptr = malloc(*num_attr * (slen + 1) * sizeof(char)))) {
996     *ierr = EX_MEMFAIL;
997     free(aptr);                 /* Free up string ptr array */
998     return;
999   }
1000   for (i = 0; i < *num_attr; i++)
1001     *(aptr + i) = sptr + i * (slen + 1);        /* put address into ptr array */
1002   *(aptr + i) = 0;              /* null out last ptr */
1003 
1004   *ierr = 0;
1005   if (ex_get_elem_attr_names(*idexo, *elem_blk_id, aptr) == EX_FATAL) {
1006     *ierr = EX_FATAL;
1007     free(sptr);                 /* free up allocated space */
1008     free(aptr);
1009   }
1010   /* Copy Fortran names from staging space */
1011   memset(names, 0, *num_attr * nameslen);
1012   for (i = 0; i < *num_attr; i++) {
1013     ex_fcdcpy(names + i * nameslen, slen, *(aptr + i)); /* copy str into Fortran
1014                                                          * buffer */
1015   }
1016 
1017   free(sptr);                   /* Free up string staging area */
1018   free(aptr);                   /* Free up string ptr array */
1019 }
1020 
1021 /*
1022  * write element block attribute names
1023  */
1024 void
F2C(expean)1025 F2C(expean) (int *idexo,
1026              entity_id *elem_blk_id,
1027              int *num_attr,
1028              char *names,
1029              int *ierr,
1030              int nameslen)
1031 {
1032   char          **aptr;         /* ptr to temp staging space for string array
1033                                  * ptrs */
1034   char           *sptr;         /* ptr to temp staging space for strings */
1035   int             i, slen;
1036 
1037   *ierr = 0;                    /* default no errror */
1038 
1039   slen = ex_inquire_int(*idexo, EX_INQ_DB_MAX_ALLOWED_NAME_LENGTH);     /* max str size */
1040   if (nameslen < slen) {
1041     slen = nameslen;
1042   }
1043   /* allocate memory to for pointer array */
1044   if (!(aptr = malloc((*num_attr + 1) * sizeof(char *)))) {
1045     *ierr = EX_MEMFAIL;
1046     return;
1047   }
1048   /* Allocate staging space for the variable names */
1049   if (!(sptr = malloc(*num_attr * (slen + 1) * sizeof(char)))) {
1050     *ierr = EX_MEMFAIL;
1051     free(aptr);                 /* Free up string ptr array */
1052     return;
1053   }
1054   /* Copy Fortran names to staging space */
1055   for (i = 0; i < *num_attr; i++) {
1056     *(aptr + i) = sptr + i * (slen + 1);        /* put address into ptr array */
1057     ex_fstrncpy(*(aptr + i), names + i * nameslen, slen);       /* copy string into
1058                                                                  * buffer */
1059   }
1060   *(aptr + i) = 0;              /* null out last ptr */
1061 
1062   *ierr = 0;
1063   if (ex_put_elem_attr_names(*idexo, *elem_blk_id, aptr) == EX_FATAL) {
1064     *ierr = EX_FATAL;
1065   }
1066   free(sptr);                   /* Free up string staging area */
1067   free(aptr);                   /* Free up string ptr array */
1068 }
1069 
1070 /*
1071  * write object names
1072  */
1073 void
F2C(expnams)1074 F2C(expnams) (int *idexo,
1075               int *type,
1076               int *num_obj,
1077               char *names,
1078               int *ierr,
1079               int nameslen)
1080 {
1081   char          **aptr;         /* ptr to temp staging space for string array
1082                                  * ptrs */
1083   char           *sptr;         /* ptr to temp staging space for strings */
1084   int             i, slen;
1085 
1086   *ierr = 0;                    /* default no errror */
1087 
1088   slen = ex_inquire_int(*idexo, EX_INQ_DB_MAX_ALLOWED_NAME_LENGTH);     /* max str size */
1089   if (nameslen < slen) {
1090     slen = nameslen;
1091   }
1092   /* allocate memory for pointer array */
1093   if (!(aptr = malloc((*num_obj + 1) * sizeof(char *)))) {
1094     *ierr = EX_MEMFAIL;
1095     return;
1096   }
1097   /* Allocate staging space for the variable names */
1098   if (!(sptr = malloc(*num_obj * (slen + 1) * sizeof(char)))) {
1099     free(aptr);                 /* Free up string ptr array */
1100     *ierr = EX_MEMFAIL;
1101     return;
1102   }
1103   /* Copy Fortran names to staging space */
1104   for (i = 0; i < *num_obj; i++) {
1105     *(aptr + i) = sptr + i * (slen + 1);        /* put address into ptr array */
1106     ex_fstrncpy(*(aptr + i), names + i * nameslen, slen);       /* copy string into
1107                                                                  * buffer */
1108   }
1109   *(aptr + i) = 0;              /* null out last ptr */
1110   /* do ExodusII C call to write results variables names */
1111   if (ex_put_names(*idexo, (ex_entity_type) * type, aptr) == EX_FATAL) {
1112     *ierr = EX_FATAL;
1113   }
1114   free(sptr);                   /* Free up string staging area */
1115   free(aptr);                   /* Free up string ptr array */
1116 }
1117 
1118 /*
1119  * read object names
1120  */
1121 void
F2C(exgnams)1122 F2C(exgnams) (int *idexo,
1123               int *type,
1124               int *num_obj,
1125               char *names,
1126               int *ierr,
1127               int nameslen)
1128 {
1129   char          **aptr;         /* ptr to temp staging space for string array
1130                                  * ptrs */
1131   char           *sptr;         /* ptr to temp staging space for strings */
1132   int             i, slen;
1133 
1134   *ierr = 0;                    /* default no errror */
1135 
1136   slen = ex_inquire_int(*idexo, EX_INQ_MAX_READ_NAME_LENGTH); /* max string size */
1137   if (nameslen < slen) {
1138     slen = nameslen;
1139   }
1140   /* allocate memory to for pointer array */
1141   if (!(aptr = malloc((*num_obj + 1) * sizeof(char *)))) {
1142     *ierr = EX_MEMFAIL;
1143     return;
1144   }
1145   /* Allocate staging space for the variable names */
1146   if (!(sptr = malloc(*num_obj * (slen + 1) * sizeof(char)))) {
1147     *ierr = EX_MEMFAIL;
1148     free(aptr);                 /* Free up string ptr array */
1149     return;
1150   }
1151   for (i = 0; i < *num_obj; i++)
1152     *(aptr + i) = sptr + i * (slen + 1);        /* put address into ptr array */
1153   *(aptr + i) = 0;              /* null out last ptr */
1154 
1155   /* do ExodusII C call to read results variables names */
1156   if (ex_get_names(*idexo, (ex_entity_type) * type, aptr) == EX_FATAL) {
1157     *ierr = EX_FATAL;
1158     free(sptr);                 /* free up allocated space */
1159     free(aptr);
1160     return;
1161   }
1162   /* Copy Fortran names from staging space */
1163   memset(names, 0, *num_obj * nameslen);
1164   for (i = 0; i < *num_obj; i++) {
1165     ex_fcdcpy(names + i * nameslen, slen, *(aptr + i)); /* copy str into Fortran
1166                                                          * buffer */
1167   }
1168 
1169   free(sptr);                   /* Free up string staging area */
1170   free(aptr);                   /* Free up string ptr array */
1171 }
1172 
1173 /*
1174  * write property array names
1175  */
1176 void
F2C(exppn)1177 F2C(exppn) (int *idexo,
1178             int *obj_type,
1179             int *num_props,
1180             char *prop_names,
1181             int *ierr,
1182             int prop_nameslen)
1183 {
1184   char          **aptr;         /* internal string array pointer for malloc
1185                                  * use */
1186   char           *sptr;         /* internal string pointer for malloc use */
1187   int             i, slen;
1188 
1189   *ierr = 0;
1190 
1191   slen = ex_inquire_int(*idexo, EX_INQ_DB_MAX_ALLOWED_NAME_LENGTH);     /* max str size */
1192   if (prop_nameslen < slen) {
1193     slen = prop_nameslen;
1194   }
1195   /* Allocate space for the name ptr array */
1196   if (!(aptr = malloc((*num_props + 1) * sizeof(char *)))) {
1197     *ierr = EX_MEMFAIL;
1198     return;
1199   }
1200   /*
1201    * Allocate a block of space for the strings, where size = slen,
1202    * place ptrs into str ptr array,  and Copy Fortran coordinate names
1203    * to staging space
1204    */
1205 
1206   if (!(sptr = malloc((*num_props) * (slen + 1) * sizeof(char)))) {
1207     *ierr = EX_MEMFAIL;
1208     free(aptr);
1209     return;
1210   }
1211   for (i = 0; i < *num_props; i++) {
1212     *(aptr + i) = sptr + i * (slen + 1);
1213     /* copy fortran string into allocated space */
1214     ex_fstrncpy(*(aptr + i), prop_names + i * prop_nameslen, slen);
1215   }
1216   *(aptr + i) = 0;              /* set last pointer to null */
1217 
1218   if (ex_put_prop_names(*idexo, (ex_entity_type) * obj_type, *num_props, aptr) == EX_FATAL) {
1219     *ierr = EX_FATAL;
1220   }
1221   /* Free up the space we used */
1222   free(sptr);                   /* First free up string space */
1223   free(aptr);                   /* Then free up array ptr space */
1224 }
1225 
1226 
1227 /*
1228  * read property array names
1229  */
1230 void
F2C(exgpn)1231 F2C(exgpn) (int *idexo,
1232             int *obj_type,
1233             char *prop_names,
1234             int *ierr,
1235             int prop_nameslen)
1236 {
1237   char            errmsg[MAX_ERR_LENGTH];
1238   char          **aptr;         /* internal string array pointer for malloc
1239                                  * use */
1240   char           *sptr;         /* internal string pointer for malloc use */
1241   int             i, slen;
1242   ex_inquiry      inq_code;
1243   int             num_props;
1244 
1245   *ierr = 0;
1246 
1247   slen = ex_inquire_int(*idexo, EX_INQ_MAX_READ_NAME_LENGTH); /* max string size */
1248   if (prop_nameslen < slen) {
1249     slen = prop_nameslen;
1250   }
1251   switch ((ex_entity_type) * obj_type) {
1252   case EX_ELEM_BLOCK:
1253     inq_code = EX_INQ_EB_PROP;
1254     break;
1255   case EX_NODE_SET:
1256     inq_code = EX_INQ_NS_PROP;
1257     break;
1258   case EX_SIDE_SET:
1259     inq_code = EX_INQ_SS_PROP;
1260     break;
1261   case EX_ELEM_MAP:
1262     inq_code = EX_INQ_EM_PROP;
1263     break;
1264   case EX_NODE_MAP:
1265     inq_code = EX_INQ_NM_PROP;
1266     break;
1267   default:
1268     exerrval = EX_BADPARAM;
1269     *ierr = EX_BADPARAM;
1270     sprintf(errmsg, "Error: object type %d not supported; file id %d",
1271             *obj_type, *idexo);
1272     ex_err("exgpn", errmsg, exerrval);
1273     return;
1274   }
1275 
1276 
1277   /* do ExodusII C call to find out how many properties */
1278   num_props = ex_inquire_int(*idexo, inq_code);
1279 
1280   /* Allocate space for the name ptr array */
1281   if (!(aptr = malloc((num_props + 1) * sizeof(char *)))) {
1282     *ierr = EX_MEMFAIL;
1283     return;
1284   }
1285   /*
1286    * Allocate a block of space for the strings, where size = slen,
1287    * place ptrs into str ptr array,  and Copy Fortran coordinate names
1288    * to staging space
1289    */
1290 
1291   if (!(sptr = malloc(num_props * (slen + 1) * sizeof(char)))) {
1292     *ierr = EX_MEMFAIL;
1293     free(aptr);
1294     return;
1295   }
1296   memset(sptr, 0, num_props * (slen + 1));
1297 
1298   for (i = 0; i < num_props; i++)
1299     *(aptr + i) = sptr + i * (slen + 1);        /* put ptrs to staging space
1300                                                  * into ptr array */
1301   *(aptr + i) = 0;              /* set last pointer to null */
1302 
1303   /* do ExodusII C call to get property name records */
1304   if (ex_get_prop_names(*idexo, (ex_entity_type) * obj_type, aptr) == EX_FATAL) {
1305     *ierr = EX_FATAL;
1306     free(sptr);                 /* free up string space */
1307     free(aptr);                 /* free up array ptr space */
1308     return;
1309   }
1310   /* copy C strings to Fortran arrays */
1311   memset(prop_names, 0, num_props * prop_nameslen);
1312   for (i = 0; i < num_props; i++) {
1313     ex_fcdcpy(prop_names + i * prop_nameslen, slen, *(aptr + i));       /* copy and blank fill */
1314   }
1315 
1316   /* Free up the space we used */
1317   free(sptr);                   /* First free up string space */
1318   free(aptr);                   /* Then free up array ptr space */
1319 }
1320 
1321 /*
1322  * write object property
1323  */
1324 void
F2C(expp)1325 F2C(expp) (int *idexo,
1326            int *obj_type,
1327            entity_id *obj_id,
1328            char *prop_name,
1329            entity_id *value,
1330            int *ierr,
1331            int prop_namelen)
1332 {
1333   char           *sptr;         /* internal string pointer for malloc use */
1334   int             slen;
1335 
1336   *ierr = 0;
1337 
1338   slen = ex_inquire_int(*idexo, EX_INQ_DB_MAX_ALLOWED_NAME_LENGTH);     /* max str size */
1339   if (prop_namelen < slen) {
1340     slen = prop_namelen;
1341   }
1342   /* allocate memory to stage the property name into */
1343   if (!(sptr = malloc((slen + 1) * sizeof(char)))) {
1344     *ierr = EX_MEMFAIL;
1345     return;
1346   }
1347   /* Copy property name from Fortran string to staging area */
1348   ex_fstrncpy(sptr, prop_name, slen);
1349 
1350   *ierr = ex_put_prop(*idexo, (ex_entity_type) * obj_type, *obj_id, sptr, *value);
1351 
1352   free(sptr);
1353 }
1354 
1355 /*
1356  * read object property
1357  */
1358 void
F2C(exgp)1359 F2C(exgp) (int *idexo,
1360            int *obj_type,
1361            entity_id *obj_id,
1362            char *prop_name,
1363            void_int *value,
1364            int *ierr,
1365            int prop_namelen)
1366 {
1367   char           *sptr;         /* internal string pointer for malloc use */
1368   int             slen;
1369 
1370   *ierr = 0;
1371 
1372   slen = ex_inquire_int(*idexo, EX_INQ_MAX_READ_NAME_LENGTH); /* max string size */
1373   if (prop_namelen < slen) {
1374     slen = prop_namelen;
1375   }
1376   /* allocate memory to stage the property name into */
1377   if (!(sptr = malloc((slen + 1) * sizeof(char)))) {
1378     *ierr = EX_MEMFAIL;
1379   }
1380   /* Copy property name from Fortran string to staging area */
1381   ex_fstrncpy(sptr, prop_name, slen);
1382 
1383   /* use exodusII C routine to get the property value */
1384   if (ex_get_prop(*idexo, (ex_entity_type) * obj_type, *obj_id, sptr, value) == EX_FATAL) {
1385     *ierr = EX_FATAL;
1386   }
1387   free(sptr);
1388 }
1389 
1390 /*
1391  * read object property array
1392  */
1393 void
F2C(exgpa)1394 F2C(exgpa) (int *idexo,
1395             int *obj_type,
1396             char *prop_name,
1397             void_int *values,
1398             int *ierr,
1399             int prop_namelen)
1400 {
1401   char           *sptr;         /* internal string pointer for malloc use */
1402   int             slen;
1403 
1404   *ierr = 0;
1405 
1406   slen = ex_inquire_int(*idexo, EX_INQ_MAX_READ_NAME_LENGTH); /* max string size */
1407   if (prop_namelen < slen) {
1408     slen = prop_namelen;
1409   }
1410   /* allocate memory to stage the property name into */
1411   if (!(sptr = malloc((slen + 1) * sizeof(char)))) {
1412     *ierr = EX_MEMFAIL;
1413   }
1414   memset(sptr, 0, slen + 1);
1415 
1416   /* Copy property name from Fortran string to staging area */
1417   ex_fstrncpy(sptr, prop_name, slen);
1418 
1419 
1420   /* use exodusII C routine to get the values array */
1421   if (ex_get_prop_array(*idexo, (ex_entity_type) * obj_type, sptr, values) == EX_FATAL) {
1422     *ierr = EX_FATAL;
1423   }
1424   free(sptr);
1425 }
1426 
1427 /*
1428  * write object property array
1429  */
1430 void
F2C(exppa)1431 F2C(exppa) (int *idexo,
1432             int *obj_type,
1433             char *prop_name,
1434             void_int *values,
1435             int *ierr,
1436             int prop_namelen)
1437 {
1438   char           *sptr;         /* internal string pointer for malloc use */
1439   int             slen;
1440 
1441   *ierr = 0;
1442 
1443   slen = ex_inquire_int(*idexo, EX_INQ_DB_MAX_ALLOWED_NAME_LENGTH);     /* max str size */
1444   if (prop_namelen < slen) {
1445     slen = prop_namelen;
1446   }
1447   /* allocate memory to stage the property name into */
1448   if (!(sptr = malloc((slen + 1) * sizeof(char)))) {
1449     *ierr = EX_MEMFAIL;
1450   }
1451   /* Copy property name from Fortran string to staging area */
1452   ex_fstrncpy(sptr, prop_name, slen);
1453 
1454 
1455   /* Use exodusII C routine to store the property values */
1456   if (ex_put_prop_array(*idexo, (ex_entity_type) * obj_type, sptr, values) == EX_FATAL) {
1457     *ierr = EX_FATAL;
1458   }
1459   free(sptr);
1460 }
1461 
1462 /*
1463  * write node set parameters
1464  */
1465 void
F2C(expnp)1466 F2C(expnp) (int *idexo,
1467             entity_id *node_set_id,
1468             void_int *num_nodes_in_set,
1469             void_int *num_dist_in_set,
1470             int *ierr)
1471 {
1472   if (ex_int64_status(*idexo) & EX_BULK_INT64_API) {
1473     int64_t nnis = *(int64_t*)num_nodes_in_set;
1474     int64_t ndis = *(int64_t*)num_dist_in_set;
1475     *ierr = ex_put_node_set_param(*idexo, *node_set_id, nnis, ndis);
1476   } else {
1477     int nnis = *(int*)num_nodes_in_set;
1478     int ndis = *(int*)num_dist_in_set;
1479     *ierr = ex_put_node_set_param(*idexo, *node_set_id, nnis, ndis);
1480   }
1481 }
1482 
1483 /*
1484  * read node set parameters
1485  */
1486 void
F2C(exgnp)1487 F2C(exgnp) (int *idexo,
1488             entity_id *node_set_id,
1489             void_int *num_nodes_in_set,
1490             void_int *num_dist_in_set,
1491             int *ierr)
1492 {
1493   *ierr = ex_get_node_set_param(*idexo, *node_set_id, num_nodes_in_set, num_dist_in_set);
1494 }
1495 
1496 /*
1497  * write node set
1498  */
1499 void
F2C(expns)1500 F2C(expns) (int *idexo,
1501             entity_id *node_set_id,
1502             void_int *node_set_node_list,
1503             int *ierr)
1504 {
1505   *ierr = ex_put_node_set(*idexo, *node_set_id, node_set_node_list);
1506 }
1507 
1508 /*
1509  * write node set dist factors
1510  */
1511 void
F2C(expnsd)1512 F2C(expnsd) (int *idexo,
1513              entity_id *node_set_id,
1514              real * node_set_dist_fact,
1515              int *ierr)
1516 {
1517   *ierr = ex_put_node_set_dist_fact(*idexo, *node_set_id, node_set_dist_fact);
1518 }
1519 
1520 /*
1521  * read node set
1522  */
1523 void
F2C(exgns)1524 F2C(exgns) (int *idexo,
1525             entity_id *node_set_id,
1526             void_int *node_set_node_list,
1527             int *ierr)
1528 {
1529   *ierr = ex_get_node_set(*idexo, *node_set_id, node_set_node_list);
1530 }
1531 
1532 /*
1533  * read node set dist factors
1534  */
1535 void
F2C(exgnsd)1536 F2C(exgnsd) (int *idexo,
1537              entity_id *node_set_id,
1538              real * node_set_dist_fact,
1539              int *ierr)
1540 {
1541   *ierr = ex_get_node_set_dist_fact(*idexo, *node_set_id, node_set_dist_fact);
1542 }
1543 
1544 
1545 /*
1546  * read node sets IDs
1547  */
1548 void
F2C(exgnsi)1549 F2C(exgnsi) (int *idexo,
1550              void_int *node_set_ids,
1551              int *ierr)
1552 {
1553   *ierr = ex_get_node_set_ids(*idexo, node_set_ids);
1554 }
1555 
1556 /*
1557  * write concatenated node sets
1558  */
1559 void
F2C(expcns)1560 F2C(expcns) (int *idexo,
1561              void_int *node_set_ids,
1562              void_int *num_nodes_per_set,
1563              void_int *num_dist_per_set,
1564              void_int *node_sets_node_index,
1565              void_int *node_sets_dist_index,
1566              void_int *node_sets_node_list,
1567              real * node_sets_dist_fact,
1568              int *ierr)
1569 {
1570   size_t num_node_sets, i;
1571   int int_size;
1572 
1573   void_int *node_index_ptr, *dist_index_ptr;
1574 
1575   *ierr = 0;
1576 
1577   num_node_sets = ex_inquire_int(*idexo, EX_INQ_NODE_SETS);
1578 
1579   int_size = sizeof(int);
1580   if (ex_int64_status(*idexo) & EX_BULK_INT64_API) {
1581     int_size = sizeof(int64_t);
1582   }
1583 
1584   /* allocate memory for C node index array */
1585   if (!(node_index_ptr = malloc(num_node_sets * int_size))) {
1586     *ierr = EX_MEMFAIL;
1587     return;
1588   }
1589   /* allocate memory for C dist factor index array */
1590   if (!(dist_index_ptr = malloc(num_node_sets * int_size))) {
1591     free(node_index_ptr);
1592     *ierr = EX_MEMFAIL;
1593     return;
1594   }
1595 
1596   if (int_size == sizeof(int64_t)) {
1597     for (i = 0; i < num_node_sets; i++) { /* change from 1-based to 0 index */
1598       ((int64_t*)node_index_ptr)[i] = ((int64_t*)node_sets_node_index)[i] - 1;
1599       ((int64_t*)dist_index_ptr)[i] = ((int64_t*)node_sets_dist_index)[i] - 1;
1600     }
1601   } else {
1602     for (i = 0; i < num_node_sets; i++) { /* change from 1-based to 0 index */
1603       ((int*)node_index_ptr)[i] = ((int*)node_sets_node_index)[i] - 1;
1604       ((int*)dist_index_ptr)[i] = ((int*)node_sets_dist_index)[i] - 1;
1605     }
1606   }
1607 
1608   *ierr = ex_put_concat_node_sets(*idexo, node_set_ids, num_nodes_per_set,
1609 				  num_dist_per_set, node_index_ptr,
1610 				  dist_index_ptr, node_sets_node_list,
1611 				  node_sets_dist_fact);
1612   free(node_index_ptr);
1613   free(dist_index_ptr);
1614 }
1615 
1616 /*
1617  * read concatenated node sets
1618  */
1619 void
F2C(exgcns)1620 F2C(exgcns) (int *idexo,
1621              void_int *node_set_ids,
1622              void_int *num_nodes_per_set,
1623              void_int *num_dist_per_set,
1624              void_int *node_sets_node_index,
1625              void_int *node_sets_dist_index,
1626              void_int *node_sets_node_list,
1627              real * node_sets_dist_fact,
1628              int *ierr)
1629 {
1630   size_t num_node_sets, i;
1631 
1632   *ierr = ex_get_concat_node_sets(*idexo, node_set_ids, num_nodes_per_set,
1633 				  num_dist_per_set, node_sets_node_index,
1634 				  node_sets_dist_index, node_sets_node_list,
1635 				  node_sets_dist_fact);
1636 
1637   num_node_sets = ex_inquire_int(*idexo, EX_INQ_NODE_SETS);
1638 
1639   if (ex_int64_status(*idexo) & EX_BULK_INT64_API) {
1640     for (i = 0; i < num_node_sets; i++) { /* change from 0-based to 1 index */
1641       ((int64_t*)node_sets_node_index)[i] += 1;
1642       ((int64_t*)node_sets_dist_index)[i] += 1;
1643     }
1644   } else {
1645     for (i = 0; i < num_node_sets; i++) { /* change from 0-based to 1 index */
1646       ((int*)node_sets_node_index)[i] += 1;
1647       ((int*)node_sets_dist_index)[i] += 1;
1648     }
1649   }
1650 }
1651 
1652 /*
1653  * write side set parameters
1654  */
1655 void
F2C(expsp)1656 F2C(expsp) (int *idexo,
1657             entity_id *side_set_id,
1658             void_int *num_sides_in_set,
1659             void_int *num_df_in_set,
1660             int *ierr)
1661 {
1662   if (ex_int64_status(*idexo) & EX_BULK_INT64_API) {
1663     int64_t nsis = *(int64_t*)num_sides_in_set;
1664     int64_t ndis = *(int64_t*)num_df_in_set;
1665     *ierr = ex_put_side_set_param(*idexo, *side_set_id, nsis, ndis);
1666   } else {
1667     int nsis = *(int*)num_sides_in_set;
1668     int ndis = *(int*)num_df_in_set;
1669     *ierr = ex_put_side_set_param(*idexo, *side_set_id, nsis, ndis);
1670   }
1671 }
1672 
1673 /*
1674  * read side set parameters
1675  */
1676 void
F2C(exgsp)1677 F2C(exgsp) (int *idexo,
1678             entity_id *side_set_id,
1679             void_int *num_sides_in_set,
1680             void_int *num_df_in_set,
1681             int *ierr)
1682 {
1683   *ierr = ex_get_side_set_param(*idexo, *side_set_id, num_sides_in_set, num_df_in_set);
1684 }
1685 
1686 /*
1687  * get side set node list length
1688  */
1689 void
F2C(exgsnl)1690 F2C(exgsnl) (int *idexo,
1691              entity_id *side_set_id,
1692              void_int *num_nodes_in_set,
1693              int *ierr)
1694 {
1695   *ierr = ex_get_side_set_node_list_len(*idexo, *side_set_id, num_nodes_in_set);
1696 }
1697 
1698 /*
1699  * write side set
1700  */
1701 void
F2C(expss)1702 F2C(expss) (int *idexo,
1703             entity_id *side_set_id,
1704             void_int *side_set_elem_list,
1705             void_int *side_set_side_list,
1706             int *ierr)
1707 {
1708   *ierr = ex_put_side_set(*idexo, *side_set_id, side_set_elem_list, side_set_side_list);
1709 }
1710 
1711 /*
1712  * read side set
1713  */
1714 void
F2C(exgss)1715 F2C(exgss) (int *idexo,
1716             entity_id *side_set_id,
1717             void_int *side_set_elem_list,
1718             void_int *side_set_side_list,
1719             int *ierr)
1720 {
1721   *ierr = ex_get_side_set(*idexo, *side_set_id, side_set_elem_list, side_set_side_list);
1722 }
1723 
1724 /*
1725  * write side set distribution factors
1726  */
1727 void
F2C(expssd)1728 F2C(expssd) (int *idexo,
1729              entity_id *side_set_id,
1730              real * side_set_dist_fact,
1731              int *ierr)
1732 {
1733   *ierr = ex_put_side_set_dist_fact(*idexo, *side_set_id, side_set_dist_fact);
1734 }
1735 
1736 /*
1737  * read side set distribution factors
1738  */
1739 void
F2C(exgssd)1740 F2C(exgssd) (int *idexo,
1741              entity_id *side_set_id,
1742              real * side_set_dist_fact,
1743              int *ierr)
1744 {
1745   *ierr = ex_get_side_set_dist_fact(*idexo, *side_set_id, side_set_dist_fact);
1746 }
1747 
1748 /*
1749  * read side sets IDs
1750  */
1751 void
F2C(exgssi)1752 F2C(exgssi) (int *idexo,
1753              void_int *side_set_ids,
1754              int *ierr)
1755 {
1756   *ierr = ex_get_side_set_ids(*idexo, side_set_ids);
1757 }
1758 
1759 /*
1760  * write concatenated side sets
1761  */
1762 void
F2C(expcss)1763 F2C(expcss) (int *idexo,
1764              void_int *side_set_ids,
1765              void_int *num_elem_per_set,
1766              void_int *num_dist_per_set,
1767              void_int *side_sets_elem_index,
1768              void_int *side_sets_dist_index,
1769              void_int *side_sets_elem_list,
1770              void_int *side_sets_side_list,
1771              real * side_sets_dist_fact,
1772              int *ierr)
1773 {
1774   size_t num_side_sets, i;
1775   void_int *elem_index_ptr, *dist_index_ptr;
1776   int int_size;
1777 
1778   *ierr = 0;
1779 
1780   num_side_sets = ex_inquire_int(*idexo, EX_INQ_SIDE_SETS);
1781 
1782   int_size = sizeof(int);
1783   if (ex_int64_status(*idexo) & EX_BULK_INT64_API) {
1784     int_size = sizeof(int64_t);
1785   }
1786 
1787   /* allocate memory for C element index array */
1788   if (!(elem_index_ptr = malloc(num_side_sets * int_size))) {
1789     *ierr = EX_MEMFAIL;
1790     return;
1791   }
1792 
1793   /* allocate memory for C dist factor index array */
1794   if (!(dist_index_ptr = malloc(num_side_sets * int_size))) {
1795     free(elem_index_ptr);
1796     *ierr = EX_MEMFAIL;
1797     return;
1798   }
1799 
1800   if (int_size == sizeof(int64_t)) {
1801     for (i = 0; i < num_side_sets; i++) { /* change from 1-based to 0 index */
1802       ((int64_t*)elem_index_ptr)[i] = ((int64_t*)side_sets_elem_index)[i] - 1;
1803       ((int64_t*)dist_index_ptr)[i] = ((int64_t*)side_sets_dist_index)[i] - 1;
1804     }
1805   } else {
1806     for (i = 0; i < num_side_sets; i++) { /* change from 1-based to 0 index */
1807       ((int*)elem_index_ptr)[i] = ((int*)side_sets_elem_index)[i] - 1;
1808       ((int*)dist_index_ptr)[i] = ((int*)side_sets_dist_index)[i] - 1;
1809     }
1810   }
1811 
1812   *ierr = ex_put_concat_side_sets(*idexo, side_set_ids, num_elem_per_set,
1813 				  num_dist_per_set, elem_index_ptr,
1814 				  dist_index_ptr, side_sets_elem_list,
1815 				  side_sets_side_list, side_sets_dist_fact);
1816   free(elem_index_ptr);
1817   free(dist_index_ptr);
1818 }
1819 
1820 /*
1821  * read concatenated side sets
1822  */
1823 void
F2C(exgcss)1824 F2C(exgcss) (int *idexo,
1825              void_int *side_set_ids,
1826              void_int *num_elem_per_set,
1827              void_int *num_dist_per_set,
1828              void_int *side_sets_elem_index,
1829              void_int *side_sets_dist_index,
1830              void_int *side_sets_elem_list,
1831              void_int *side_sets_side_list,
1832              real * side_sets_dist_fact,
1833              int *ierr)
1834 {
1835   size_t i, num_side_sets;
1836 
1837   *ierr = 0;
1838 
1839   num_side_sets = ex_inquire_int(*idexo, EX_INQ_SIDE_SETS);
1840 
1841   *ierr = ex_get_concat_side_sets(*idexo, side_set_ids, num_elem_per_set,
1842 				  num_dist_per_set, side_sets_elem_index,
1843 				  side_sets_dist_index, side_sets_elem_list,
1844 				  side_sets_side_list, side_sets_dist_fact);
1845 
1846   if (ex_int64_status(*idexo) & EX_BULK_INT64_API) {
1847     for (i = 0; i < num_side_sets; i++) { /* change from 0-based to 1 index */
1848       ((int64_t*)side_sets_elem_index)[i] += 1;
1849       ((int64_t*)side_sets_dist_index)[i] += 1;
1850     }
1851   } else {
1852     for (i = 0; i < num_side_sets; i++) { /* change from 0-based to 1 index */
1853       ((int*)side_sets_elem_index)[i] += 1;
1854       ((int*)side_sets_dist_index)[i] += 1;
1855     }
1856   }
1857 }
1858 
1859 /*
1860  * read concatenated side sets (no dist factors)
1861  */
1862 void
F2C(exgcssf)1863 F2C(exgcssf) (int *idexo,
1864               void_int *side_set_ids,
1865               void_int *num_elem_per_set,
1866               void_int *num_dist_per_set,
1867               void_int *side_sets_elem_index,
1868               void_int *side_sets_dist_index,
1869               void_int *side_sets_elem_list,
1870               void_int *side_sets_side_list,
1871               int *ierr)
1872 {
1873   size_t i, num_side_sets;
1874 
1875   num_side_sets = ex_inquire_int(*idexo, EX_INQ_SIDE_SETS);
1876 
1877   *ierr = ex_get_concat_side_sets(*idexo, side_set_ids, num_elem_per_set,
1878 				  num_dist_per_set, side_sets_elem_index,
1879 				  side_sets_dist_index, side_sets_elem_list,
1880 				  side_sets_side_list, 0);
1881 
1882   if (ex_int64_status(*idexo) & EX_BULK_INT64_API) {
1883     for (i = 0; i < num_side_sets; i++) { /* change from 0-based to 1 index */
1884       ((int64_t*)side_sets_elem_index)[i] += 1;
1885       ((int64_t*)side_sets_dist_index)[i] += 1;
1886     }
1887   } else {
1888     for (i = 0; i < num_side_sets; i++) { /* change from 0-based to 1 index */
1889       ((int*)side_sets_elem_index)[i] += 1;
1890       ((int*)side_sets_dist_index)[i] += 1;
1891     }
1892   }
1893 }
1894 
1895 /*
1896  * write results variables parameters
1897  */
1898 void
F2C(expvp)1899 F2C(expvp) (int *idexo,
1900             char *var_type,
1901             int *num_vars,
1902             int *ierr,
1903             int var_typelen)
1904 {
1905   *ierr = ex_put_var_param(*idexo, var_type, *num_vars);
1906 }
1907 
1908 /*
1909  * read results variables parameters
1910  */
1911 void
F2C(exgvp)1912 F2C(exgvp) (int *idexo,
1913             char *var_type,
1914             int *num_vars,
1915             int *ierr,
1916             int var_typelen)
1917 {
1918   *ierr = ex_get_var_param(*idexo, var_type, num_vars);
1919 }
1920 
1921 /*
1922  * write results variables names
1923  */
1924 void
F2C(expvan)1925 F2C(expvan) (int *idexo,
1926              char *var_type,
1927              int *num_vars,
1928              char *var_names,
1929              int *ierr,
1930              int var_typelen,
1931              int var_nameslen)
1932 {
1933   char          **aptr;         /* ptr to temp staging space for string array
1934                                  * ptrs */
1935   char           *sptr;         /* ptr to temp staging space for strings */
1936   int             i, slen;
1937 
1938   *ierr = 0;                    /* default no errror */
1939 
1940   slen = ex_inquire_int(*idexo, EX_INQ_DB_MAX_ALLOWED_NAME_LENGTH);     /* max str size */
1941   if (var_nameslen < slen) {
1942     slen = var_nameslen;
1943   }
1944   /* allocate memory for pointer array */
1945   if (!(aptr = malloc((*num_vars + 1) * sizeof(char *)))) {
1946     *ierr = EX_MEMFAIL;
1947     return;
1948   }
1949   /* Allocate staging space for the variable names */
1950   if (!(sptr = malloc(*num_vars * (slen + 1) * sizeof(char)))) {
1951     free(aptr);                 /* Free up string ptr array */
1952     *ierr = EX_MEMFAIL;
1953     return;
1954   }
1955   /* Copy Fortran variable names to staging space */
1956   for (i = 0; i < *num_vars; i++) {
1957     *(aptr + i) = sptr + i * (slen + 1);        /* put address into ptr array */
1958     ex_fstrncpy(*(aptr + i), var_names + i * var_nameslen, slen);       /* copy string into
1959                                                                          * buffer */
1960   }
1961   *(aptr + i) = 0;              /* null out last ptr */
1962   /* do ExodusII C call to write results variables names */
1963   if (ex_put_var_names(*idexo, var_type, *num_vars, aptr) == EX_FATAL) {
1964     *ierr = EX_FATAL;
1965   }
1966   free(sptr);                   /* Free up string staging area */
1967   free(aptr);                   /* Free up string ptr array */
1968 }
1969 /*
1970  * read results variables names
1971  */
1972 void
F2C(exgvan)1973 F2C(exgvan) (int *idexo,
1974              char *var_type,
1975              int *num_vars,
1976              char *var_names,
1977              int *ierr,
1978              int var_typelen,
1979              int var_nameslen)
1980 {
1981   char          **aptr;         /* ptr to temp staging space for string array
1982                                  * ptrs */
1983   char           *sptr;         /* ptr to temp staging space for strings */
1984   int             i, slen;
1985 
1986   *ierr = 0;                    /* default no errror */
1987 
1988   slen = ex_inquire_int(*idexo, EX_INQ_MAX_READ_NAME_LENGTH); /* max string size */
1989   if (var_nameslen < slen) {
1990     slen = var_nameslen;
1991   }
1992   /* allocate memory to for pointer array */
1993   if (!(aptr = malloc((*num_vars + 1) * sizeof(char *)))) {
1994     *ierr = EX_MEMFAIL;
1995     return;
1996   }
1997   /* Allocate staging space for the variable names */
1998   if (!(sptr = malloc(*num_vars * (slen + 1) * sizeof(char)))) {
1999     *ierr = EX_MEMFAIL;
2000     free(aptr);                 /* Free up string ptr array */
2001     return;
2002   }
2003   for (i = 0; i < *num_vars; i++)
2004     *(aptr + i) = sptr + i * (slen + 1);        /* put address into ptr array */
2005   *(aptr + i) = 0;              /* null out last ptr */
2006 
2007   /* do ExodusII C call to read results variables names */
2008   if (ex_get_var_names(*idexo, var_type, *num_vars, aptr) == EX_FATAL) {
2009     *ierr = EX_FATAL;
2010     free(sptr);                 /* free up allocated space */
2011     free(aptr);
2012     return;
2013   }
2014   /* Copy Fortran variable names to staging space */
2015   memset(var_names, 0, *num_vars * var_nameslen);
2016   for (i = 0; i < *num_vars; i++) {
2017     ex_fcdcpy(var_names + i * var_nameslen, slen, *(aptr + i)); /* copy str into Fortran
2018                                                                  * buffer */
2019   }
2020 
2021   free(sptr);                   /* Free up string staging area */
2022   free(aptr);                   /* Free up string ptr array */
2023 }
2024 
2025 /*
2026  * write element variable truth table
2027  */
2028 void
F2C(expvtt)2029 F2C(expvtt) (int *idexo,
2030              int *num_elem_blk,
2031              int *num_elem_var,
2032              int *elem_var_tab,
2033              int *ierr)
2034 {
2035   *ierr = ex_put_elem_var_tab(*idexo, *num_elem_blk, *num_elem_var, elem_var_tab);
2036 }
2037 
2038 /*
2039  * write nodeset variable truth table
2040  */
2041 void
F2C(expnstt)2042 F2C(expnstt) (int *idexo,
2043               int *num_entity,
2044               int *num_var,
2045               int *var_tab,
2046               int *ierr)
2047 {
2048   *ierr = ex_put_nset_var_tab(*idexo, *num_entity, *num_var, var_tab);
2049 }
2050 
2051 /*
2052  * write sideset variable truth table
2053  */
2054 void
F2C(expsstt)2055 F2C(expsstt) (int *idexo,
2056               int *num_entity,
2057               int *num_var,
2058               int *var_tab,
2059               int *ierr)
2060 {
2061   *ierr = ex_put_sset_var_tab(*idexo, *num_entity, *num_var, var_tab);
2062 }
2063 
2064 /*
2065  * read element variable truth table
2066  */
2067 void
F2C(exgvtt)2068 F2C(exgvtt) (int *idexo,
2069              int *num_elem_blk,
2070              int *num_elem_var,
2071              int *elem_var_tab,
2072              int *ierr)
2073 {
2074   *ierr = ex_get_elem_var_tab(*idexo, *num_elem_blk, *num_elem_var, elem_var_tab);
2075 }
2076 
2077 /*
2078  * read nodeset variable truth table
2079  */
2080 void
F2C(exgnstt)2081 F2C(exgnstt) (int *idexo,
2082               int *num_entity,
2083               int *num_var,
2084               int *var_tab,
2085               int *ierr)
2086 {
2087   *ierr = ex_get_nset_var_tab(*idexo, *num_entity, *num_var, var_tab);
2088 }
2089 
2090 /*
2091  * read sideset variable truth table
2092  */
2093 void
F2C(exgsstt)2094 F2C(exgsstt) (int *idexo,
2095               int *num_entity,
2096               int *num_var,
2097               int *var_tab,
2098               int *ierr)
2099 {
2100   *ierr = ex_get_sset_var_tab(*idexo, *num_entity, *num_var, var_tab);
2101 }
2102 
2103 /*
2104  * write global variable values at time step
2105  */
2106 void
F2C(expgv)2107 F2C(expgv) (int *idexo,
2108             int *time_step,
2109             int *num_glob_vars,
2110             real * glob_var_vals,
2111             int *ierr)
2112 {
2113   *ierr = ex_put_glob_vars(*idexo, *time_step, *num_glob_vars, glob_var_vals);
2114 }
2115 
2116 /*
2117  * read global variable values at a time step
2118  */
2119 void
F2C(exggv)2120 F2C(exggv) (int *idexo,
2121             int *time_step,
2122             int *num_glob_vars,
2123             real * glob_var_vals,
2124             int *ierr)
2125 {
2126   *ierr = ex_get_glob_vars(*idexo, *time_step, *num_glob_vars, glob_var_vals);
2127 }
2128 
2129 /*
2130  * read global variable values through time
2131  */
2132 void
F2C(exggvt)2133 F2C(exggvt) (int *idexo,
2134              int *glob_var_index,
2135              int *beg_time_step,
2136              int *end_time_step,
2137              real * glob_var_vals,
2138              int *ierr)
2139 {
2140   *ierr = ex_get_glob_var_time(*idexo, *glob_var_index, *beg_time_step, *end_time_step, glob_var_vals);
2141 }
2142 
2143 /*
2144  * write nodal variable values at a time step
2145  */
2146 void
F2C(expnv)2147 F2C(expnv) (int *idexo,
2148             int *time_step,
2149             int *nodal_var_index,
2150             void_int *num_nodes,
2151             real * nodal_var_vals,
2152             int *ierr)
2153 {
2154   int64_t nnodes;
2155   if (ex_int64_status(*idexo) & EX_BULK_INT64_API) {
2156     nnodes = *(int64_t*)num_nodes;
2157   } else {
2158     nnodes = *(int*)num_nodes;
2159   }
2160 
2161   *ierr = ex_put_nodal_var(*idexo, *time_step, *nodal_var_index, nnodes, nodal_var_vals);
2162 }
2163 
2164 /*
2165  * read nodal variable values at a time step
2166  */
2167 void
F2C(exgnv)2168 F2C(exgnv) (int *idexo,
2169             int *time_step,
2170             int *nodal_var_index,
2171             void_int *num_nodes,
2172             real * nodal_var_vals,
2173             int *ierr)
2174 {
2175   int64_t nnodes;
2176   if (ex_int64_status(*idexo) & EX_BULK_INT64_API) {
2177     nnodes = *(int64_t*)num_nodes;
2178   } else {
2179     nnodes = *(int*)num_nodes;
2180   }
2181 
2182   *ierr = ex_get_nodal_var(*idexo, *time_step, *nodal_var_index, nnodes, nodal_var_vals);
2183 }
2184 
2185 /*
2186  * read nodal variable values through time
2187  */
2188 void
F2C(exgnvt)2189 F2C(exgnvt) (int *idexo,
2190              int *nodal_var_index,
2191              void_int *node_number,
2192              int *beg_time_step,
2193              int *end_time_step,
2194              real * nodal_var_vals,
2195              int *ierr)
2196 {
2197   int64_t nnode;
2198   if (ex_int64_status(*idexo) & EX_BULK_INT64_API) {
2199     nnode = *(int64_t*)node_number;
2200   } else {
2201     nnode = *(int*)node_number;
2202   }
2203 
2204   *ierr = ex_get_nodal_var_time(*idexo, *nodal_var_index, nnode, *beg_time_step, *end_time_step, nodal_var_vals);
2205 }
2206 
2207 /*
2208  * write element variable values at a time step
2209  */
2210 void
F2C(expev)2211 F2C(expev) (int *idexo,
2212             int *time_step,
2213             int *elem_var_index,
2214             entity_id *elem_blk_id,
2215             void_int *num_elem_this_blk,
2216             real * elem_var_vals,
2217             int *ierr)
2218 {
2219   int64_t neblk;
2220   if (ex_int64_status(*idexo) & EX_BULK_INT64_API) {
2221     neblk = *(int64_t*)num_elem_this_blk;
2222   } else {
2223     neblk = *(int*)num_elem_this_blk;
2224   }
2225 
2226   *ierr = ex_put_elem_var(*idexo, *time_step, *elem_var_index, *elem_blk_id, neblk, elem_var_vals);
2227 }
2228 
2229 /*
2230  * read element variable values at a time step
2231  */
2232 void
F2C(exgev)2233 F2C(exgev) (int *idexo,
2234             int *time_step,
2235             int *elem_var_index,
2236             entity_id *elem_blk_id,
2237             void_int *num_elem_this_blk,
2238             real * elem_var_vals,
2239             int *ierr)
2240 {
2241   int64_t neblk;
2242   if (ex_int64_status(*idexo) & EX_BULK_INT64_API) {
2243     neblk = *(int64_t*)num_elem_this_blk;
2244   } else {
2245     neblk = *(int*)num_elem_this_blk;
2246   }
2247 
2248   *ierr = ex_get_elem_var(*idexo, *time_step, *elem_var_index, *elem_blk_id, neblk, elem_var_vals);
2249 }
2250 
2251 /*
2252  * read element variable values through time
2253  */
2254 void
F2C(exgevt)2255 F2C(exgevt) (int *idexo,
2256              int *elem_var_index,
2257              void_int *elem_number,
2258              int *beg_time_step,
2259              int *end_time_step,
2260              real * elem_var_vals,
2261              int *ierr)
2262 {
2263   int64_t el_num;
2264   if (ex_int64_status(*idexo) & EX_BULK_INT64_API) {
2265     el_num = *(int64_t*)elem_number;
2266   } else {
2267     el_num = *(int*)elem_number;
2268   }
2269 
2270   *ierr = ex_get_elem_var_time(*idexo, *elem_var_index, el_num, *beg_time_step, *end_time_step, elem_var_vals);
2271 }
2272 
2273 /*
2274  * write nodeset variable values at a time step
2275  */
2276 void
F2C(expnsv)2277 F2C(expnsv) (int *idexo,
2278              int *time_step,
2279              int *var_index,
2280              entity_id *id,
2281              void_int *num_entity,
2282              real * var_vals,
2283              int *ierr)
2284 {
2285   int64_t n_entity;
2286   if (ex_int64_status(*idexo) & EX_BULK_INT64_API) {
2287     n_entity = *(int64_t*)num_entity;
2288   } else {
2289     n_entity = *(int*)num_entity;
2290   }
2291 
2292   *ierr = ex_put_nset_var(*idexo, *time_step, *var_index, *id, n_entity, var_vals);
2293 }
2294 
2295 /*
2296  * read nodeset variable values at a time step
2297  */
2298 void
F2C(exgnsv)2299 F2C(exgnsv) (int *idexo,
2300              int *time_step,
2301              int *var_index,
2302              entity_id *id,
2303              void_int *num_entity,
2304              real * var_vals,
2305              int *ierr)
2306 {
2307   int64_t n_entity;
2308   if (ex_int64_status(*idexo) & EX_BULK_INT64_API) {
2309     n_entity = *(int64_t*)num_entity;
2310   } else {
2311     n_entity = *(int*)num_entity;
2312   }
2313 
2314   *ierr = ex_get_nset_var(*idexo, *time_step, *var_index, *id, n_entity, var_vals);
2315 }
2316 
2317 /*
2318  * write sideset variable values at a time step
2319  */
2320 void
F2C(expssv)2321 F2C(expssv) (int *idexo,
2322              int *time_step,
2323              int *var_index,
2324              entity_id *id,
2325              void_int *num_entity,
2326              real * var_vals,
2327              int *ierr)
2328 {
2329   int64_t n_entity;
2330   if (ex_int64_status(*idexo) & EX_BULK_INT64_API) {
2331     n_entity = *(int64_t*)num_entity;
2332   } else {
2333     n_entity = *(int*)num_entity;
2334   }
2335 
2336   *ierr = ex_put_sset_var(*idexo, *time_step, *var_index, *id, n_entity, var_vals);
2337 }
2338 
2339 /*
2340  * read sideset variable values at a time step
2341  */
2342 void
F2C(exgssv)2343 F2C(exgssv) (int *idexo,
2344              int *time_step,
2345              int *var_index,
2346              entity_id *id,
2347              void_int *num_entity,
2348              real * var_vals,
2349              int *ierr)
2350 {
2351   int64_t n_entity;
2352   if (ex_int64_status(*idexo) & EX_BULK_INT64_API) {
2353     n_entity = *(int64_t*)num_entity;
2354   } else {
2355     n_entity = *(int*)num_entity;
2356   }
2357 
2358   *ierr = ex_get_sset_var(*idexo, *time_step, *var_index, *id, n_entity, var_vals);
2359 }
2360 
2361 /*
2362  * write time value for a time step
2363  */
2364 void
F2C(exptim)2365 F2C(exptim) (int *idexo,
2366              int *time_step,
2367              real * time_value,
2368              int *ierr)
2369 {
2370   *ierr = ex_put_time(*idexo, *time_step, time_value);
2371 }
2372 
2373 /*
2374  * read time value for a time step
2375  */
2376 void
F2C(exgtim)2377 F2C(exgtim) (int *idexo,
2378              int *time_step,
2379              real * time_value,
2380              int *ierr)
2381 {
2382   *ierr = ex_get_time(*idexo, *time_step, time_value);
2383 }
2384 
2385 /*
2386  * read all time values
2387  */
2388 void
F2C(exgatm)2389 F2C(exgatm) (int *idexo,
2390              real * time_values,
2391              int *ierr)
2392 {
2393   *ierr = ex_get_all_times(*idexo, time_values);
2394 }
2395 
2396 /*
2397  * inquire EXODUS parameters
2398  */
2399 void
F2C(exinq)2400 F2C(exinq) (int *idexo,
2401             int *req_info,
2402             void_int *ret_int,
2403             float *ret_float,
2404             char *ret_char,
2405             int *ierr,
2406             int ret_charlen)
2407 {
2408   *ierr = ex_inquire(*idexo, (ex_inquiry) * req_info, ret_int, ret_float, ret_char);
2409 }
2410 
2411 /*
2412  * inquire integer EXODUS parameters
2413  */
2414 int64_t
F2C(exinqi)2415 F2C(exinqi) (int *idexo,
2416             int *req_info)
2417 {
2418   return ex_inquire_int(*idexo, (ex_inquiry) *req_info);
2419 }
2420 
2421 /*
2422  * convert side set node lists to side set side lists
2423  */
2424 void
F2C(excn2s)2425 F2C(excn2s) (int *idexo,
2426              void_int *num_elem_per_set,
2427              void_int *num_nodes_per_set,
2428              void_int *side_sets_elem_index,
2429              void_int *side_sets_node_index,
2430              void_int *side_sets_elem_list,
2431              void_int *side_sets_node_list,
2432              void_int *side_sets_side_list,
2433              int *ierr)
2434 {
2435   *ierr = ex_cvt_nodes_to_sides(*idexo,
2436 				num_elem_per_set,
2437 				num_nodes_per_set,
2438 				NULL, /* unused */
2439 				NULL, /* unused */
2440 				side_sets_elem_list,
2441 				side_sets_node_list,
2442 				side_sets_side_list);
2443 }
2444 
2445 /*
2446  * read side set node list
2447  */
2448 void
F2C(exgssn)2449 F2C(exgssn) (int *idexo,
2450              entity_id *side_set_id,
2451              int *side_set_node_cnt_list,
2452              void_int *side_set_node_list,
2453              int *ierr)
2454 {
2455   *ierr = ex_get_side_set_node_list(*idexo, *side_set_id, side_set_node_cnt_list, side_set_node_list);
2456 }
2457 
2458 /*
2459  * read side set node count
2460  */
2461 void
F2C(exgssc)2462 F2C(exgssc) (int *idexo,
2463              entity_id *side_set_id,
2464              int *side_set_node_cnt_list,
2465              int *ierr)
2466 {
2467   *ierr = ex_get_side_set_node_count(*idexo, *side_set_id, side_set_node_cnt_list);
2468 }
2469 
2470 /*
2471  * read concatenated side set node count
2472  */
2473 void
F2C(exgcssc)2474 F2C(exgcssc) (int *idexo,
2475               int *side_set_node_cnt_list,
2476               int *ierr)
2477 {
2478   *ierr = ex_get_concat_side_set_node_count(*idexo, side_set_node_cnt_list);
2479 }
2480 
2481 /* ex_get_coordinate_frames -- read coordinate frames */
2482 void
F2C(exgfrm)2483 F2C(exgfrm) (int *idexo,
2484              int *nframeo,
2485              void_int *cfids,
2486              real * coord,
2487              int *tags,
2488              int *ierr)
2489 {
2490   int             i;
2491   char           *ctags = NULL;
2492 
2493   /* Determine number of coordinate frames stored in file */
2494   int             nframe = ex_inquire_int(*idexo, EX_INQ_COORD_FRAMES);
2495 
2496   if (nframe != *nframeo) {
2497     *ierr = EX_FATAL;
2498     return;
2499   }
2500   /* Create array of characters to store tags... */
2501   if (nframe > 0) {
2502     if (!(ctags = calloc(nframe, sizeof(char)))) {
2503       *ierr = EX_MEMFAIL;
2504       return;
2505     }
2506     *ierr = 0;
2507 
2508     if (ex_get_coordinate_frames(*idexo, &nframe, cfids, coord, ctags) == EX_FATAL) {
2509       *ierr = EX_FATAL;
2510       return;
2511     }
2512     /* Convert character tags back to integer tags for fortran */
2513     for (i = 0; i < nframe; i++) {
2514       if (ctags[i] == 'R' || ctags[i] == 'r')
2515         tags[i] = EX_CF_RECTANGULAR;
2516       else if (ctags[i] == 'C' || ctags[i] == 'c')
2517         tags[i] = EX_CF_CYLINDRICAL;
2518       else if (ctags[i] == 'S' || ctags[i] == 's')
2519         tags[i] = EX_CF_SPHERICAL;
2520     }
2521     free(ctags);
2522   }
2523 }
2524 
2525 /* ex_put_coordinate_frames -- define/write coordinate frames */
2526 void
F2C(expfrm)2527 F2C(expfrm) (int *idexo,
2528              int *nframe,
2529              void_int *cfids,
2530              real * coord,
2531              int *tags,
2532              int *ierr)
2533 {
2534   int             i;
2535   char           *ctags = NULL;
2536 
2537   /* Create array of characters to store tags... */
2538   if (*nframe > 0) {
2539     if (!(ctags = calloc(*nframe, sizeof(char)))) {
2540       *ierr = EX_MEMFAIL;
2541       return;
2542     }
2543     /* Convert fortran integer tags to C API character tags */
2544     for (i = 0; i < *nframe; i++) {
2545       if (tags[i] == EX_CF_RECTANGULAR)
2546         ctags[i] = 'R';
2547       else if (tags[i] == EX_CF_CYLINDRICAL)
2548         ctags[i] = 'C';
2549       else if (tags[i] == EX_CF_SPHERICAL)
2550         ctags[i] = 'S';
2551     }
2552 
2553     *ierr = 0;
2554 
2555     if (ex_put_coordinate_frames(*idexo, *nframe, cfids, coord, ctags) == EX_FATAL) {
2556       *ierr = EX_FATAL;
2557       return;
2558     }
2559     free(ctags);
2560   }
2561 }
2562 
2563 
2564 /* Routine to return floating point word size */
2565 int
F2C(excpws)2566 F2C(excpws) ()
2567 {
2568   return (ex_get_cpu_ws());
2569 }
2570 
2571 /* Routine to return large model setting */
2572 int
F2C(exlgmd)2573 F2C(exlgmd) (int *idexo)
2574 {
2575   return (ex_large_model(*idexo));
2576 }
2577 
2578 
2579 /* Generalized error handling function */
2580 void
F2C(exerr)2581 F2C(exerr) (char *pname,
2582             char *err_string,
2583             int *errcode,
2584             int pnamelen,
2585             int err_stringlen)
2586 {
2587 
2588   char           *proc_name, *error_string;
2589   if (!(proc_name = malloc((pnamelen + 1) * sizeof(char)))) {
2590     ex_err("exerr", "Error: failed to allocate space for process name buffer",
2591            EX_MEMFAIL);
2592     return;
2593   }
2594   if (!(error_string = malloc((err_stringlen + 1) * sizeof(char)))) {
2595     free(proc_name);
2596     ex_err("exerr", "Error: failed to allocate space for error msg buffer",
2597            EX_MEMFAIL);
2598     return;
2599   }
2600   ex_fstrncpy(proc_name, pname, pnamelen);
2601   ex_fstrncpy(error_string, err_string, err_stringlen);
2602   ex_err(proc_name, error_string, *errcode);
2603   free(proc_name);
2604   free(error_string);
2605 }
2606 
2607 /* Error message reporting options setting function */
2608 void
F2C(exopts)2609 F2C(exopts) (int *option_val,
2610              int *ierr)
2611 {
2612   *ierr = 0;
2613   ex_opts((ex_options) * option_val);
2614   if (exerrval != 0) {
2615     *ierr = EX_FATAL;
2616   }
2617 }
2618 
2619 void
F2C(exmxnm)2620 F2C(exmxnm) (int *idexo,
2621              int *length,
2622              int *ierr)
2623 {
2624   *ierr = ex_set_max_name_length(*idexo, *length);
2625 }
2626 
2627 /*
2628  * copy EXODUS file
2629  */
2630 void
F2C(excopy)2631 F2C(excopy) (int *idexo_in,
2632              int *idexo_out,
2633              int *ierr)
2634 {
2635   *ierr = ex_copy(*idexo_in, *idexo_out);
2636 }
2637 
2638 /*
2639  * get element map
2640  */
2641 void
2642 
F2C(exgem)2643 F2C(exgem) (int *idexo,
2644             entity_id *map_id,
2645             void_int *elem_map,
2646             int *ierr)
2647 {
2648   *ierr = ex_get_num_map(*idexo, EX_ELEM_MAP, *map_id, elem_map);
2649 }
2650 
2651 /*
2652  * get partial_element map
2653  */
2654 void
F2C(exgpem)2655 F2C(exgpem) (int *idexo,
2656              entity_id *map_id,
2657              void_int *start,
2658              void_int *count,
2659              void_int *elem_map,
2660              int *ierr)
2661 {
2662   int64_t st, cnt;
2663   if (ex_int64_status(*idexo) & EX_BULK_INT64_API) {
2664     st = *(int64_t*)start;
2665     cnt = *(int64_t*)count;
2666   } else {
2667     st = *(int*)start;
2668     cnt = *(int*)count;
2669   }
2670 
2671   *ierr = ex_get_partial_num_map(*idexo, EX_ELEM_MAP, *map_id, st, cnt, elem_map);
2672 }
2673 
2674 /*
2675  * get element number map
2676  */
2677 void
F2C(exgenm)2678 F2C(exgenm) (int *idexo,
2679              void_int *elem_map,
2680              int *ierr)
2681 {
2682   *ierr = ex_get_id_map(*idexo, EX_ELEM_MAP, elem_map);
2683 }
2684 
2685 /*
2686  * get map parameters
2687  */
2688 void
F2C(exgmp)2689 F2C(exgmp) (int *idexo,
2690             int *num_node_maps,
2691             int *num_elem_maps,
2692             int *ierr)
2693 {
2694   *ierr = ex_get_map_param(*idexo, num_node_maps, num_elem_maps);
2695 }
2696 
2697 /*
2698  * get node map
2699  */
2700 void
F2C(exgnm)2701 F2C(exgnm) (int *idexo,
2702             entity_id *map_id,
2703             void_int *node_map,
2704             int *ierr)
2705 {
2706   *ierr = ex_get_num_map(*idexo, EX_NODE_MAP, *map_id, node_map);
2707 }
2708 
2709 /*
2710  * get node number map
2711  */
2712 void
F2C(exgnnm)2713 F2C(exgnnm) (int *idexo,
2714              void_int *node_map,
2715              int *ierr)
2716 {
2717   *ierr = ex_get_id_map(*idexo, EX_NODE_MAP, node_map);
2718 }
2719 
2720 /*
2721  * read results variables names
2722  */
2723 void
F2C(exgvnm)2724 F2C(exgvnm) (int *idexo,
2725              char *var_type,
2726              int *var_index,
2727              char *var_name,
2728              int *ierr,
2729              int var_typelen,
2730              int var_namelen)
2731 {
2732   char           *sptr;         /* ptr to temp staging space for string */
2733   int             slen;
2734   *ierr = 0;                    /* default no errror */
2735 
2736   slen = ex_inquire_int(*idexo, EX_INQ_MAX_READ_NAME_LENGTH); /* max string size */
2737   if (var_namelen < slen) {
2738     slen = var_namelen;
2739   }
2740   /* Allocate staging space for the variable name */
2741   if (!(sptr = malloc((slen + 1) * sizeof(char)))) {
2742     *ierr = EX_MEMFAIL;
2743     return;
2744   }
2745   /* do ExodusII C call to read results variables names */
2746   if (ex_get_var_name(*idexo, var_type, *var_index, sptr) == EX_FATAL) {
2747     *ierr = EX_FATAL;
2748     free(sptr);                 /* free up allocated space */
2749     return;
2750   }
2751   /* Copy Fortran variable names to staging space */
2752   /** printf("[exgvnm] var_name(%d): %s\n",*var_index,sptr)); **/
2753   memset(var_name, 0, var_namelen);
2754   ex_fcdcpy(var_name, slen, sptr);      /* copy string into Fortran buffer */
2755 
2756   free(sptr);                   /* Free up string staging area */
2757 }
2758 
2759 /*
2760  * put element map
2761  */
2762 void
F2C(expem)2763 F2C(expem) (int *idexo,
2764             entity_id *map_id,
2765             void_int *elem_map,
2766             int *ierr)
2767 {
2768   *ierr = ex_put_num_map(*idexo, EX_ELEM_MAP, *map_id, elem_map);
2769 }
2770 
2771 /*
2772  * put partial element map
2773  */
2774 void
F2C(exppem)2775 F2C(exppem) (int *idexo,
2776              entity_id *map_id,
2777              void_int *start,
2778              void_int *count,
2779              void_int *elem_map,
2780              int *ierr)
2781 {
2782   int64_t st, cnt;
2783   if (ex_int64_status(*idexo) & EX_BULK_INT64_API) {
2784     st = *(int64_t*)start;
2785     cnt = *(int64_t*)count;
2786   } else {
2787     st = *(int*)start;
2788     cnt = *(int*)count;
2789   }
2790   *ierr = ex_put_partial_num_map(*idexo, EX_ELEM_MAP, *map_id, st, cnt, elem_map);
2791 }
2792 
2793 /*
2794  * put element number map
2795  */
2796 void
F2C(expenm)2797 F2C(expenm) (int *idexo,
2798              void_int *elem_map,
2799              int *ierr)
2800 {
2801   *ierr = ex_put_id_map(*idexo, EX_ELEM_MAP, elem_map);
2802 }
2803 
2804 /*
2805  * put map parameters
2806  */
2807 void
F2C(expmp)2808 F2C(expmp) (int *idexo,
2809             int *num_node_maps,
2810             int *num_elem_maps,
2811             int *ierr)
2812 {
2813   *ierr = ex_put_map_param(*idexo, *num_node_maps, *num_elem_maps);
2814 }
2815 
2816 /*
2817  * put node map
2818  */
2819 void
F2C(expnm)2820 F2C(expnm) (int *idexo,
2821             entity_id *map_id,
2822             void_int *node_map,
2823             int *ierr)
2824 {
2825   *ierr = ex_put_num_map(*idexo, EX_NODE_MAP, *map_id, node_map);
2826 }
2827 
2828 /*
2829  * put node number map
2830  */
2831 void
F2C(expnnm)2832 F2C(expnnm) (int *idexo,
2833              void_int *node_map,
2834              int *ierr)
2835 {
2836   *ierr = ex_put_id_map(*idexo, EX_NODE_MAP, node_map);
2837 }
2838 
2839 /*
2840  * write results variable name
2841  */
2842 void
F2C(expvnm)2843 F2C(expvnm) (int *idexo,
2844              char *var_type,
2845              int *var_index,
2846              char *var_name,
2847              int *ierr,
2848              int var_typelen,
2849              int var_namelen)
2850 {
2851   char           *sptr;         /* ptr to temp staging space for string */
2852   int             slen;
2853   *ierr = 0;                    /* default no errror */
2854 
2855   slen = ex_inquire_int(*idexo, EX_INQ_DB_MAX_ALLOWED_NAME_LENGTH);     /* max str size */
2856   if (var_namelen < slen) {
2857     slen = var_namelen;
2858   }
2859   /* Allocate staging space for the variable name */
2860   if (!(sptr = (char *) malloc((slen + 1) * sizeof(char)))) {
2861     *ierr = EX_MEMFAIL;
2862     return;
2863   }
2864   ex_fstrncpy(sptr, var_name, slen);    /* copy string into buffer */
2865 
2866 
2867   /* do ExodusII C call to write results variable name */
2868   if (ex_put_var_name(*idexo, var_type, *var_index, sptr) == EX_FATAL) {
2869     *ierr = EX_FATAL;
2870     free(sptr);                 /* free up allocated space */
2871     return;
2872   }
2873   free(sptr);                   /* Free up string staging area */
2874 }
2875 
2876 /*
2877  *  Get initial information from nemesis file
2878  */
2879 void
F2C(exgii)2880 F2C(exgii)(int	*idne,
2881 	   int	*nproc,
2882 	   int	*nproc_in_f,
2883 	   char	*ftype,
2884 	   int  *ierr,
2885 	   size_t ftypelen)
2886 {
2887   size_t slen = 1;
2888   char *file_type;
2889 
2890   /* WARNING: ftypelen SHOULD be 1, but may not be depending on how
2891               the Fortran programmer passed it. It is best at
2892               this time to hard code it per NEPII spec. */
2893   if (ftypelen != 1) {
2894 #if defined(EXODUS_STRING_LENGTH_WARNING)
2895     char errmsg[MAX_ERR_LENGTH];
2896     sprintf(errmsg,"Warning: file type string length is %d in file id %d\n",
2897             ftypelen, *idne);
2898     ex_err("negii",errmsg,EX_MSG);
2899 #endif
2900     slen = ftypelen;
2901   }
2902 
2903   file_type = (char *) malloc((slen+1)*sizeof(char));
2904 
2905   if ((*ierr = ex_get_init_info(*idne, nproc, nproc_in_f, file_type)) != 0) {
2906     char errmsg[MAX_ERR_LENGTH];
2907     sprintf(errmsg,
2908 	    "Error: failed to get initial information from file id %d",
2909 	    *idne);
2910     ex_err("negii",errmsg,EX_MSG);
2911   }
2912 
2913   if (*ierr == 0)
2914     ex_fcdcpy (ftype, slen, file_type);
2915 
2916   free(file_type);
2917 }
2918 
2919 /*
2920  *  Write initial information from nemesis file
2921  */
2922 void
F2C(expii)2923 F2C(expii)(int	*idne,
2924 	   int	*nproc,
2925 	   int	*nproc_in_f,
2926 	   char	*ftype,
2927 	   int  *ierr,
2928 	   size_t ftypelen)
2929 {
2930 
2931   char errmsg[MAX_ERR_LENGTH];
2932 
2933   size_t slen = 1;
2934   char *file_type;
2935 
2936   /* WARNING: ftypelen SHOULD be 1, but may not be depending on how
2937               the Fortran programmer passed it. It is best at
2938               this time to hard code it per NEPII spec. */
2939   if (ftypelen != 1) {
2940     slen = ftypelen;
2941 #if defined(EXODUS_STRING_LENGTH_WARNING)
2942     sprintf(errmsg,"Warning: file type string length is %d in file id %d\n",
2943             ftypelen, *idne);
2944     ex_err("nepii",errmsg,EX_MSG);
2945 #endif
2946   }
2947 
2948   file_type = (char *) malloc((slen+1)*sizeof(char));
2949 
2950   ex_fstrncpy (file_type, ftype, slen);
2951 
2952   if ((*ierr = ex_put_init_info(*idne, *nproc, *nproc_in_f, file_type)) != 0)
2953   {
2954     sprintf(errmsg,
2955 	    "Error: failed to put initial information in file id %d",
2956 	    *idne);
2957     ex_err("nepii",errmsg,EX_MSG);
2958   }
2959 
2960   free(file_type);
2961 }
2962 
2963 /*
2964  * Read initial global information
2965  */
2966 void
F2C(exgig)2967 F2C(exgig)(int	*idne,
2968 	   void_int	*nnodes_g,
2969 	   void_int	*nelems_g,
2970 	   void_int	*nelem_blks_g,
2971 	   void_int	*nnode_sets_g,
2972 	   void_int	*nside_sets_g,
2973 	   int	*ierr)
2974 {
2975   if ((*ierr = ex_get_init_global(*idne, nnodes_g, nelems_g, nelem_blks_g,
2976                                   nnode_sets_g, nside_sets_g)) != 0) {
2977     char errmsg[MAX_ERR_LENGTH];
2978     sprintf(errmsg,
2979 	    "Error: failed to read initial global information from file id %d",
2980 	    *idne);
2981     ex_err("negig",errmsg,EX_MSG);
2982   }
2983 }
2984 
2985 /*
2986  * Write initial global information
2987  */
2988 void
F2C(expig)2989 F2C(expig)(int	*idne,
2990 	   void_int	*nnodes_g,
2991 	   void_int	*nelems_g,
2992 	   void_int	*nelem_blks_g,
2993 	   void_int	*nnode_sets_g,
2994 	   void_int	*nside_sets_g,
2995 	   int	*ierr)
2996 {
2997   if (ex_int64_status(*idne) & EX_BULK_INT64_API) {
2998     int64_t *n_nnodes_g = (int64_t*)nnodes_g;
2999     int64_t *n_nelems_g = (int64_t*)nelems_g;
3000     int64_t *n_nelem_blks_g = (int64_t*)nelem_blks_g;
3001     int64_t *n_nnode_sets_g = (int64_t*)nnode_sets_g;
3002     int64_t *n_nside_sets_g = (int64_t*)nside_sets_g;
3003     *ierr =  ex_put_init_global(*idne, *n_nnodes_g, *n_nelems_g, *n_nelem_blks_g,
3004 				*n_nnode_sets_g, *n_nside_sets_g);
3005   } else {
3006     int *n_nnodes_g = (int*)nnodes_g;
3007     int *n_nelems_g = (int*)nelems_g;
3008     int *n_nelem_blks_g = (int*)nelem_blks_g;
3009     int *n_nnode_sets_g = (int*)nnode_sets_g;
3010     int *n_nside_sets_g = (int*)nside_sets_g;
3011     *ierr =  ex_put_init_global(*idne, *n_nnodes_g, *n_nelems_g, *n_nelem_blks_g,
3012 				*n_nnode_sets_g, *n_nside_sets_g);
3013   }
3014 
3015   if (*ierr != 0) {
3016     char errmsg[MAX_ERR_LENGTH];
3017     sprintf(errmsg,
3018 	    "Error: failed to store initial global information in file id %d",
3019 	    *idne);
3020     ex_err("nepig",errmsg,EX_MSG);
3021   }
3022 }
3023 
3024 /*
3025  * Read load balance parameters
3026  */
3027 void
F2C(exglbp)3028 F2C(exglbp)(int	*idne,
3029 	    void_int	*nint_nodes,
3030 	    void_int	*nbor_nodes,
3031 	    void_int	*next_nodes,
3032 	    void_int	*nint_elems,
3033 	    void_int	*nbor_elems,
3034 	    void_int	*nnode_cmaps,
3035 	    void_int	*nelem_cmaps,
3036 	    int	*processor,
3037 	    int	*ierr)
3038 {
3039   if ((*ierr = ex_get_loadbal_param(*idne, nint_nodes, nbor_nodes,
3040                                     next_nodes, nint_elems, nbor_elems,
3041                                     nnode_cmaps, nelem_cmaps, *processor)) != 0) {
3042     char errmsg[MAX_ERR_LENGTH];
3043     sprintf(errmsg,
3044 	    "Error: failed to read load balance parameters from file id %d",
3045 	    *idne);
3046     ex_err("neglbp",errmsg,EX_MSG);
3047   }
3048 }
3049 
3050 /*
3051  * Write load balance parameters
3052  */
3053 void
F2C(explbp)3054 F2C(explbp)(int	*idne,
3055 	    void_int	*nint_nodes,
3056 	    void_int	*nbor_nodes,
3057 	    void_int	*next_nodes,
3058 	    void_int	*nint_elems,
3059 	    void_int	*nbor_elems,
3060 	    void_int	*nnode_cmaps,
3061 	    void_int	*nelem_cmaps,
3062 	    int	*processor,
3063 	    int	*ierr)
3064 {
3065   if (ex_int64_status(*idne) & EX_BULK_INT64_API) {
3066     int64_t *n_nint_nodes = (int64_t*)nint_nodes;
3067     int64_t *n_nbor_nodes = (int64_t*)nbor_nodes;
3068     int64_t *n_next_nodes = (int64_t*)next_nodes;
3069     int64_t *n_nint_elems = (int64_t*)nint_elems;
3070     int64_t *n_nbor_elems = (int64_t*)nbor_elems;
3071     int64_t *n_nnode_cmaps = (int64_t*)nnode_cmaps;
3072     int64_t *n_nelem_cmaps = (int64_t*)nelem_cmaps;
3073     *ierr = ex_put_loadbal_param(*idne, *n_nint_nodes, *n_nbor_nodes,
3074 				 *n_next_nodes, *n_nint_elems, *n_nbor_elems,
3075 				 *n_nnode_cmaps, *n_nelem_cmaps,
3076 				 *processor);
3077   } else {
3078     int *n_nint_nodes = (int*)nint_nodes;
3079     int *n_nbor_nodes = (int*)nbor_nodes;
3080     int *n_next_nodes = (int*)next_nodes;
3081     int *n_nint_elems = (int*)nint_elems;
3082     int *n_nbor_elems = (int*)nbor_elems;
3083     int *n_nnode_cmaps = (int*)nnode_cmaps;
3084     int *n_nelem_cmaps = (int*)nelem_cmaps;
3085     *ierr = ex_put_loadbal_param(*idne, *n_nint_nodes, *n_nbor_nodes,
3086 				 *n_next_nodes, *n_nint_elems, *n_nbor_elems,
3087 				 *n_nnode_cmaps, *n_nelem_cmaps,
3088 				 *processor);
3089   }
3090   if (*ierr != 0) {
3091     char errmsg[MAX_ERR_LENGTH];
3092     sprintf(errmsg,
3093 	    "Error: failed to store load balance parameters in file id %d",
3094 	    *idne);
3095     ex_err("neplbp",errmsg,EX_MSG);
3096   }
3097 }
3098 
3099 /*
3100  * Write concatenated load balance parameters
3101  */
3102 void
F2C(explbpc)3103 F2C(explbpc)(int *idne,
3104 	     void_int *nint_nodes,
3105 	     void_int *nbor_nodes,
3106 	     void_int *next_nodes,
3107 	     void_int *nint_elems,
3108 	     void_int *nbor_elems,
3109 	     void_int *nnode_cmaps,
3110 	     void_int *nelem_cmaps,
3111 	     int *ierr)
3112 {
3113   if ((*ierr = ex_put_loadbal_param_cc(*idne, nint_nodes, nbor_nodes,
3114                                        next_nodes, nint_elems, nbor_elems,
3115                                        nnode_cmaps, nelem_cmaps)) != 0) {
3116     char errmsg[MAX_ERR_LENGTH];
3117     sprintf(errmsg,
3118 	    "Error: failed to store load balance parameters in file id %d",
3119 	    *idne);
3120     ex_err("neplbpc",errmsg,EX_MSG);
3121   }
3122 }
3123 
3124 /*
3125  * Read global node set parameters
3126  */
3127 void
F2C(exgnspg)3128 F2C(exgnspg)(int *idne,
3129 	     void_int *ns_ids_glob,
3130 	     void_int *ns_n_cnt_glob,
3131 	     void_int *ns_df_cnt_glob,
3132 	     int *ierr)
3133 {
3134   if ((*ierr = ex_get_ns_param_global(*idne, ns_ids_glob, ns_n_cnt_glob, ns_df_cnt_glob)) != 0) {
3135     char errmsg[MAX_ERR_LENGTH];
3136     sprintf(errmsg,
3137 	    "Error: failed to read global node set parameters from file id %d",
3138 	    *idne);
3139     ex_err("negnspg",errmsg,EX_MSG);
3140   }
3141 }
3142 
3143 /*
3144  * Write global node set parameters
3145  */
3146 void
F2C(expnspg)3147 F2C(expnspg)(int *idne,
3148 	     void_int *global_ids,
3149 	     void_int *global_n_cnts,
3150 	     void_int *global_df_cnts,
3151 	     int *ierr)
3152 {
3153   if ((*ierr = ex_put_ns_param_global(*idne, global_ids, global_n_cnts, global_df_cnts)) != 0)
3154   {
3155     char errmsg[MAX_ERR_LENGTH];
3156     sprintf(errmsg,
3157 	    "Error: failed to store global node set parameters in file id %d",
3158 	    *idne);
3159     ex_err("nepnspg",errmsg,EX_MSG);
3160   }
3161 }
3162 
3163 /*
3164  * Read global side set parameters
3165  */
3166 void
F2C(exgsspg)3167 F2C(exgsspg)(int *idne,
3168 	     void_int *ss_ids_glob,
3169 	     void_int *ss_n_cnt_glob,
3170 	     void_int *ss_df_cnt_glob,
3171 	     int *ierr)
3172 {
3173 
3174   if ((*ierr = ex_get_ss_param_global(*idne, ss_ids_glob, ss_n_cnt_glob, ss_df_cnt_glob)) != 0)
3175   {
3176     char errmsg[MAX_ERR_LENGTH];
3177     sprintf(errmsg,
3178 	    "Error: failed to read global side set parameters from file id %d",
3179 	    *idne);
3180     ex_err("negsspg",errmsg,EX_MSG);
3181   }
3182 }
3183 
3184 /*
3185  * Write global side set parameters
3186  */
3187 void
F2C(expsspg)3188 F2C(expsspg)(int *idne,
3189 	     void_int *global_ids,
3190 	     void_int *global_el_cnts,
3191 	     void_int *global_df_cnts,
3192 	     int *ierr)
3193 {
3194   if ((*ierr = ex_put_ss_param_global(*idne, global_ids, global_el_cnts, global_df_cnts)) != 0) {
3195     char errmsg[MAX_ERR_LENGTH];
3196     sprintf(errmsg,
3197 	    "Error: failed to store global side set parameters in file id %d",
3198 	    *idne);
3199     ex_err("nepsspg",errmsg,EX_MSG);
3200   }
3201 }
3202 
3203 /*
3204  * Read global element block information
3205  */
3206 void
F2C(exgebig)3207 F2C(exgebig)(int *idne,
3208 	     void_int *el_blk_ids,
3209 	     void_int *el_blk_cnts,
3210 	     int *ierr)
3211 {
3212   if ((*ierr = ex_get_eb_info_global(*idne, el_blk_ids, el_blk_cnts)) != 0) {
3213     char errmsg[MAX_ERR_LENGTH];
3214     sprintf(errmsg,
3215 	    "Error: failed to read global element block info from file id %d",
3216 	    *idne);
3217     ex_err("negebig",errmsg,EX_MSG);
3218   }
3219 }
3220 
3221 /*
3222  * Write global element block information
3223  */
3224 void
F2C(expebig)3225 F2C(expebig)(int *idne,
3226 	     void_int *el_blk_ids,
3227 	     void_int *el_blk_cnts,
3228 	     int *ierr)
3229 {
3230   if ((*ierr = ex_put_eb_info_global(*idne, el_blk_ids, el_blk_cnts)) != 0) {
3231     char errmsg[MAX_ERR_LENGTH];
3232     sprintf(errmsg,
3233 	    "Error: failed to store global element block info in file id %d",
3234 	    *idne);
3235     ex_err("nepebig",errmsg,EX_MSG);
3236   }
3237 }
3238 
3239 /*
3240  * Read side set element list and side set side list
3241  */
3242 void
F2C(exgnss)3243 F2C(exgnss)(int *idne,
3244 	    entity_id *ss_id,
3245 	    void_int *start,
3246 	    void_int *count,
3247 	    void_int *ss_elem_list,
3248 	    void_int *ss_side_list,
3249 	    int *ierr)
3250 {
3251   int64_t st, cnt;
3252   if (ex_int64_status(*idne) & EX_BULK_INT64_API) {
3253     st = *(int64_t*)start;
3254     cnt = *(int64_t*)count;
3255   } else {
3256     st = *(int*)start;
3257     cnt = *(int*)count;
3258   }
3259 
3260   if ((*ierr = ex_get_n_side_set(*idne, *ss_id, st, cnt, ss_elem_list, ss_side_list)) != 0) {
3261     char errmsg[MAX_ERR_LENGTH];
3262     sprintf(errmsg,
3263 	    "Error: failed to read side set element list from file id %d",
3264 	    *idne);
3265     ex_err("negnss",errmsg,EX_MSG);
3266   }
3267 }
3268 
3269 /*
3270  * Write side set element list and side set side list
3271  */
3272 void
F2C(expnss)3273 F2C(expnss)(int *idne,
3274 	    entity_id *ss_id,
3275 	    void_int *start,
3276 	    void_int *count,
3277 	    void_int *ss_elem_list,
3278 	    void_int *ss_side_list,
3279 	    int *ierr)
3280 {
3281   int64_t st, cnt;
3282   if (ex_int64_status(*idne) & EX_BULK_INT64_API) {
3283     st = *(int64_t*)start;
3284     cnt = *(int64_t*)count;
3285   } else {
3286     st = *(int*)start;
3287     cnt = *(int*)count;
3288   }
3289 
3290   if ((*ierr = ex_put_n_side_set(*idne, *ss_id, st, cnt, ss_elem_list, ss_side_list)) != 0) {
3291     char errmsg[MAX_ERR_LENGTH];
3292     sprintf(errmsg,
3293 	    "Error: failed to write side set element list to file id %d",
3294 	    *idne);
3295     ex_err("nepnss",errmsg,EX_MSG);
3296   }
3297 }
3298 
3299 /*
3300  * Read side set distribution factor
3301  */
3302 void
F2C(exgnssd)3303 F2C(exgnssd)(int *idne,
3304 	     entity_id *ss_id,
3305 	     void_int *start,
3306 	     void_int *count,
3307 	     real *ss_df,
3308 	     int *ierr)
3309 {
3310   int64_t st, cnt;
3311   if (ex_int64_status(*idne) & EX_BULK_INT64_API) {
3312     st = *(int64_t*)start;
3313     cnt = *(int64_t*)count;
3314   } else {
3315     st = *(int*)start;
3316     cnt = *(int*)count;
3317   }
3318 
3319   if ((*ierr = ex_get_n_side_set_df(*idne, *ss_id, st, cnt, ss_df)) != 0) {
3320     char errmsg[MAX_ERR_LENGTH];
3321     sprintf(errmsg,
3322 	    "Error: failed to read side set dist factor from file id %d",
3323 	    *idne);
3324     ex_err("negnssd",errmsg,EX_MSG);
3325   }
3326 }
3327 
3328 /*
3329  * Write side set distribution factor
3330  */
3331 void
F2C(expnssd)3332 F2C(expnssd)(int *idne,
3333 	     entity_id *ss_id,
3334 	     void_int *start,
3335 	     void_int *count,
3336 	     real *ss_df,
3337 	     int *ierr)
3338 {
3339   int64_t st, cnt;
3340   if (ex_int64_status(*idne) & EX_BULK_INT64_API) {
3341     st = *(int64_t*)start;
3342     cnt = *(int64_t*)count;
3343   } else {
3344     st = *(int*)start;
3345     cnt = *(int*)count;
3346   }
3347 
3348   if ((*ierr = ex_put_n_side_set_df(*idne, *ss_id, st, cnt, ss_df)) != 0) {
3349     char errmsg[MAX_ERR_LENGTH];
3350     sprintf(errmsg,
3351 	    "Error: failed to write side set dist factor to file id %d",
3352 	    *idne);
3353     ex_err("nepnssd",errmsg,EX_MSG);
3354   }
3355 }
3356 
3357 /*
3358  * Read node set list for a single node set
3359  */
3360 void
F2C(exgnns)3361 F2C(exgnns)(int *idne,
3362 	    entity_id *ns_id,
3363 	    void_int *start,
3364 	    void_int *count,
3365 	    void_int *ns_node_list,
3366 	    int *ierr)
3367 {
3368   int64_t st, cnt;
3369   if (ex_int64_status(*idne) & EX_BULK_INT64_API) {
3370     st = *(int64_t*)start;
3371     cnt = *(int64_t*)count;
3372   } else {
3373     st = *(int*)start;
3374     cnt = *(int*)count;
3375   }
3376 
3377   if ((*ierr = ex_get_n_node_set(*idne, *ns_id, st, cnt,ns_node_list)) != 0) {
3378     char errmsg[MAX_ERR_LENGTH];
3379     sprintf(errmsg,
3380 	    "Error: failed to read node set node list from file id %d",
3381 	    *idne);
3382     ex_err("negnns",errmsg,EX_MSG);
3383   }
3384 }
3385 
3386 /*
3387  * Write node set list for a single node set
3388  */
3389 void
F2C(expnns)3390 F2C(expnns)(int *idne,
3391 	    entity_id *ns_id,
3392 	    void_int *start,
3393 	    void_int *count,
3394 	    void_int *ns_node_list,
3395 	    int *ierr)
3396 {
3397   int64_t st, cnt;
3398   if (ex_int64_status(*idne) & EX_BULK_INT64_API) {
3399     st = *(int64_t*)start;
3400     cnt = *(int64_t*)count;
3401   } else {
3402     st = *(int*)start;
3403     cnt = *(int*)count;
3404   }
3405 
3406   if ((*ierr = ex_put_n_node_set(*idne, *ns_id, st, cnt, ns_node_list)) != 0) {
3407     char errmsg[MAX_ERR_LENGTH];
3408     sprintf(errmsg,
3409 	    "Error: failed to write node set node list to file id %d",
3410 	    *idne);
3411     ex_err("nepnns",errmsg,EX_MSG);
3412   }
3413 }
3414 
3415 /*
3416  * Read node set distribution factor
3417  */
3418 void
F2C(exgnnsd)3419 F2C(exgnnsd)(int *idne,
3420 	     entity_id *ns_id,
3421 	     void_int *start,
3422 	     void_int *count,
3423 	     real *ns_df,
3424 	     int *ierr)
3425 {
3426   int64_t st, cnt;
3427   if (ex_int64_status(*idne) & EX_BULK_INT64_API) {
3428     st = *(int64_t*)start;
3429     cnt = *(int64_t*)count;
3430   } else {
3431     st = *(int*)start;
3432     cnt = *(int*)count;
3433   }
3434 
3435   if ((*ierr = ex_get_n_node_set_df(*idne, *ns_id, st, cnt, ns_df)) != 0) {
3436     char errmsg[MAX_ERR_LENGTH];
3437     sprintf(errmsg,
3438 	    "Error: failed to read node set dist factor from file id %d",
3439 	    *idne);
3440     ex_err("negnnsd",errmsg,EX_MSG);
3441   }
3442 }
3443 
3444 /*
3445  * Write node set distribution factor
3446  */
3447 void
F2C(expnnsd)3448 F2C(expnnsd)(int *idne,
3449 	     entity_id *ns_id,
3450 	     void_int *start,
3451 	     void_int *count,
3452 	     real *ns_df,
3453 	     int *ierr)
3454 {
3455   int64_t st, cnt;
3456   if (ex_int64_status(*idne) & EX_BULK_INT64_API) {
3457     st = *(int64_t*)start;
3458     cnt = *(int64_t*)count;
3459   } else {
3460     st = *(int*)start;
3461     cnt = *(int*)count;
3462   }
3463 
3464   if ((*ierr = ex_put_n_node_set_df(*idne, *ns_id, st, cnt, ns_df)) != 0) {
3465     char errmsg[MAX_ERR_LENGTH];
3466     sprintf(errmsg,
3467 	    "Error: failed to write node set dist factor to file id %d",
3468 	    *idne);
3469     ex_err("nepnnsd",errmsg,EX_MSG);
3470   }
3471 }
3472 
3473 /*
3474  * Read coordinates of the nodes
3475  */
3476 void
F2C(exgncor)3477 F2C(exgncor)(int *idne,
3478 	     void_int *start,
3479 	     void_int *count,
3480 	     real *x_coor,
3481 	     real *y_coor,
3482 	     real *z_coor,
3483 	     int *ierr)
3484 {
3485   int64_t st, cnt;
3486   if (ex_int64_status(*idne) & EX_BULK_INT64_API) {
3487     st = *(int64_t*)start;
3488     cnt = *(int64_t*)count;
3489   } else {
3490     st = *(int*)start;
3491     cnt = *(int*)count;
3492   }
3493 
3494   if ((*ierr = ex_get_n_coord(*idne, st, cnt, x_coor, y_coor, z_coor)) != 0) {
3495     char errmsg[MAX_ERR_LENGTH];
3496     sprintf(errmsg,
3497 	    "Error: failed to read node coordinates from file id %d",
3498 	    *idne);
3499     ex_err("negcor",errmsg,EX_MSG);
3500   }
3501 }
3502 
3503 /*
3504  * Write coordinates of the nodes
3505  */
3506 void
F2C(expncor)3507 F2C(expncor)(int *idne,
3508 	     void_int *start,
3509 	     void_int *count,
3510 	     real *x_coor,
3511 	     real *y_coor,
3512 	     real *z_coor,
3513 	     int *ierr)
3514 {
3515   int64_t st, cnt;
3516   if (ex_int64_status(*idne) & EX_BULK_INT64_API) {
3517     st = *(int64_t*)start;
3518     cnt = *(int64_t*)count;
3519   } else {
3520     st = *(int*)start;
3521     cnt = *(int*)count;
3522   }
3523 
3524   if ((*ierr = ex_put_n_coord(*idne, st, cnt, x_coor, y_coor, z_coor)) != 0) {
3525     char errmsg[MAX_ERR_LENGTH];
3526     sprintf(errmsg,
3527 	    "Error: failed to write node coordinates to file id %d",
3528 	    *idne);
3529     ex_err("nepcor",errmsg,EX_MSG);
3530   }
3531 }
3532 
3533 /*
3534  * Read an element block's connectivity list
3535  */
3536 void
F2C(exgnec)3537 F2C(exgnec)(int *idne,
3538 	    entity_id *elem_blk_id,
3539 	    void_int *start,
3540 	    void_int *count,
3541 	    void_int *connect,
3542 	    int *ierr)
3543 {
3544   int64_t st, cnt;
3545   if (ex_int64_status(*idne) & EX_BULK_INT64_API) {
3546     st = *(int64_t*)start;
3547     cnt = *(int64_t*)count;
3548   } else {
3549     st = *(int*)start;
3550     cnt = *(int*)count;
3551   }
3552 
3553   if ((*ierr = ex_get_n_elem_conn(*idne, *elem_blk_id, st, cnt, connect)) != 0) {
3554     char errmsg[MAX_ERR_LENGTH];
3555     sprintf(errmsg,
3556 	    "Error: failed to read element block connectivity from file id %d",
3557 	    *idne);
3558     ex_err("negnec",errmsg,EX_MSG);
3559   }
3560 }
3561 
3562 /*
3563  * Write an element block's connectivity list
3564  */
3565 void
F2C(expnec)3566 F2C(expnec)(int *idne,
3567 	    entity_id *elem_blk_id,
3568 	    void_int *start,
3569 	    void_int *count,
3570 	    void_int *connect,
3571 	    int *ierr)
3572 {
3573   int64_t st, cnt;
3574   if (ex_int64_status(*idne) & EX_BULK_INT64_API) {
3575     st = *(int64_t*)start;
3576     cnt = *(int64_t*)count;
3577   } else {
3578     st = *(int*)start;
3579     cnt = *(int*)count;
3580   }
3581 
3582   if ((*ierr = ex_put_n_elem_conn(*idne, *elem_blk_id, st, cnt, connect)) != 0) {
3583     char errmsg[MAX_ERR_LENGTH];
3584     sprintf(errmsg,
3585 	    "Error: failed to write element block connectivity to file id %d",
3586 	    *idne);
3587     ex_err("negnec",errmsg,EX_MSG);
3588   }
3589 }
3590 
3591 /*
3592  * Read an element block's attributes
3593  */
3594 void
F2C(exgneat)3595 F2C(exgneat)(int *idne,
3596 	     entity_id *elem_blk_id,
3597 	     void_int *start,
3598 	     void_int *count,
3599 	     real *attrib,
3600 	     int *ierr)
3601 {
3602   int64_t st, cnt;
3603   if (ex_int64_status(*idne) & EX_BULK_INT64_API) {
3604     st = *(int64_t*)start;
3605     cnt = *(int64_t*)count;
3606   } else {
3607     st = *(int*)start;
3608     cnt = *(int*)count;
3609   }
3610 
3611   if ((*ierr = ex_get_n_elem_attr(*idne, *elem_blk_id, st, cnt, attrib)) != 0) {
3612     char errmsg[MAX_ERR_LENGTH];
3613     sprintf(errmsg,
3614 	    "Error: failed to read element block attribute from file id %d",
3615 	    *idne);
3616     ex_err("negneat",errmsg,EX_MSG);
3617   }
3618 }
3619 
3620 /*
3621  * Write an element block's attributes
3622  */
3623 void
F2C(expneat)3624 F2C(expneat)(int *idne,
3625 	     entity_id *elem_blk_id,
3626 	     void_int *start,
3627 	     void_int *count,
3628 	     real *attrib,
3629 	     int *ierr)
3630 {
3631   int64_t st, cnt;
3632   if (ex_int64_status(*idne) & EX_BULK_INT64_API) {
3633     st = *(int64_t*)start;
3634     cnt = *(int64_t*)count;
3635   } else {
3636     st = *(int*)start;
3637     cnt = *(int*)count;
3638   }
3639 
3640   if ((*ierr = ex_put_n_elem_attr(*idne, *elem_blk_id, st, cnt, attrib)) != 0) {
3641     char errmsg[MAX_ERR_LENGTH];
3642     sprintf(errmsg,
3643 	    "Error: failed to write element block attribute to file id %d",
3644 	    *idne);
3645     ex_err("nepneat",errmsg,EX_MSG);
3646   }
3647 }
3648 
3649 /*
3650  * Read the element type for a specific element block
3651  */
3652 void
F2C(exgelt)3653 F2C(exgelt)(int *idne,
3654 	    entity_id *elem_blk_id,
3655 	    char *elem_type,
3656 	    int *ierr,
3657 	    size_t elem_typelen)
3658 {
3659   size_t slen = MAX_STR_LENGTH;
3660   char *etype;
3661 
3662   /* WARNING: ftypelen SHOULD be MAX_STR_LENGTH, but may not be depending
3663               on how the Fortran programmer passed it. It is best at
3664               this time to hard code it per NEMESIS spec. */
3665   if (elem_typelen != MAX_STR_LENGTH) {
3666 #if defined(EXODUS_STRING_LENGTH_WARNING)
3667     char errmsg[MAX_ERR_LENGTH];
3668     sprintf(errmsg,"Warning: element type string length is %d in file id %d\n",
3669             elem_typelen, *idne);
3670     ex_err("negelt",errmsg,EX_MSG);
3671 #endif
3672     slen = elem_typelen;
3673   }
3674 
3675   etype = (char *) malloc((slen+1)*sizeof(char));
3676 
3677   if ((*ierr = ex_get_elem_type(*idne, *elem_blk_id, etype)) != 0) {
3678     char errmsg[MAX_ERR_LENGTH];
3679     sprintf(errmsg,
3680 	    "Error: failed to read element block type from file id %d",
3681 	    *idne);
3682     ex_err("negelt",errmsg,EX_MSG);
3683   }
3684 
3685   if (*ierr == 0)
3686     ex_fcdcpy (elem_type, slen, etype);
3687 
3688   free(etype);
3689 }
3690 
3691 /*
3692  * Read a variable for an element block
3693  */
3694 void
F2C(exgnev)3695 F2C(exgnev)(int *idne,
3696 	    int *time_step,
3697 	    int *elem_var_index,
3698 	    entity_id *elem_blk_id,
3699 	    void_int *num_elem_this_blk,
3700 	    void_int *start,
3701 	    void_int *count,
3702 	    real *elem_var_vals,
3703 	    int *ierr)
3704 {
3705   int64_t st, cnt;
3706   if (ex_int64_status(*idne) & EX_BULK_INT64_API) {
3707     st = *(int64_t*)start;
3708     cnt = *(int64_t*)count;
3709   } else {
3710     st = *(int*)start;
3711     cnt = *(int*)count;
3712   }
3713 
3714   if ((*ierr = ex_get_n_var(*idne, *time_step, EX_ELEM_BLOCK, *elem_var_index,
3715 			    *elem_blk_id, st, cnt, elem_var_vals)) != 0) {
3716     char errmsg[MAX_ERR_LENGTH];
3717     sprintf(errmsg,
3718 	    "Error: failed to read element block variable from file id %d",
3719 	    *idne);
3720     ex_err("negnec",errmsg,EX_MSG);
3721   }
3722 }
3723 
3724 /*
3725  * Write a variable slab for an element block
3726  */
3727 void
F2C(expevs)3728 F2C(expevs)(int *idne,
3729 	    int *time_step,
3730 	    int *elem_var_index,
3731 	    entity_id *elem_blk_id,
3732 	    void_int *start,
3733 	    void_int *count,
3734 	    real *elem_var_vals,
3735 	    int *ierr)
3736 {
3737   int64_t st, cnt;
3738   if (ex_int64_status(*idne) & EX_BULK_INT64_API) {
3739     st = *(int64_t*)start;
3740     cnt = *(int64_t*)count;
3741   } else {
3742     st = *(int*)start;
3743     cnt = *(int*)count;
3744   }
3745 
3746   if ((*ierr = ex_put_elem_var_slab(*idne, *time_step, *elem_var_index,
3747                                     *elem_blk_id, st, cnt, elem_var_vals)) != 0) {
3748     char errmsg[MAX_ERR_LENGTH];
3749     sprintf(errmsg,
3750 	    "Error: failed to write elem block variable slab to file id %d",
3751 	    *idne);
3752     ex_err("negnec",errmsg,EX_MSG);
3753   }
3754 }
3755 
3756 /*
3757  * Read the values of a single nodal variable for a single time step
3758  */
3759 void
F2C(exgnnv)3760 F2C(exgnnv)(int *idne,
3761 	    int *time_step,
3762 	    int *nodal_var_index,
3763 	    void_int *start,
3764 	    void_int *count,
3765 	    real *nodal_vars,
3766 	    int *ierr)
3767 {
3768   int64_t st, cnt;
3769   if (ex_int64_status(*idne) & EX_BULK_INT64_API) {
3770     st = *(int64_t*)start;
3771     cnt = *(int64_t*)count;
3772   } else {
3773     st = *(int*)start;
3774     cnt = *(int*)count;
3775   }
3776 
3777   if ((*ierr = ex_get_n_var(*idne, *time_step, EX_NODAL, *nodal_var_index,
3778 			    1, st, cnt, nodal_vars)) != 0) {
3779     char errmsg[MAX_ERR_LENGTH];
3780     sprintf(errmsg,
3781 	    "Error: failed to read nodal variable from file id %d",
3782 	    *idne);
3783     ex_err("negnnv",errmsg,EX_MSG);
3784   }
3785 }
3786 
3787 /*
3788  * Write nodal variable slab
3789  */
3790 void
F2C(expnvs)3791 F2C(expnvs)(int *idne,
3792 	    int *time_step,
3793 	    int *nodal_var_index,
3794 	    void_int *start,
3795 	    void_int *count,
3796 	    real *nodal_var_vals,
3797 	    int *ierr)
3798 {
3799   int64_t st, cnt;
3800   if (ex_int64_status(*idne) & EX_BULK_INT64_API) {
3801     st = *(int64_t*)start;
3802     cnt = *(int64_t*)count;
3803   } else {
3804     st = *(int*)start;
3805     cnt = *(int*)count;
3806   }
3807 
3808   if ((*ierr = ex_put_nodal_var_slab(*idne, *time_step, *nodal_var_index,
3809                                      st, cnt, nodal_var_vals)) != 0) {
3810     char errmsg[MAX_ERR_LENGTH];
3811     sprintf(errmsg,
3812 	    "Error: failed to write nodal variable slab to file id %d",
3813 	    *idne);
3814     ex_err("nepnvs",errmsg,EX_MSG);
3815   }
3816 }
3817 
3818 /*
3819  * Read the element numbering map
3820  */
3821 void
F2C(exgnenm)3822 F2C(exgnenm)(int *idne,
3823 	     void_int *starte,
3824 	     void_int *num_ent,
3825 	     void_int *elem_map,
3826 	     int *ierr)
3827 {
3828   int64_t st, cnt;
3829   if (ex_int64_status(*idne) & EX_BULK_INT64_API) {
3830     st = *(int64_t*)starte;
3831     cnt = *(int64_t*)num_ent;
3832   } else {
3833     st = *(int*)starte;
3834     cnt = *(int*)num_ent;
3835   }
3836 
3837   if ((*ierr = ex_get_n_elem_num_map(*idne, st, cnt, elem_map)) != 0) {
3838     char errmsg[MAX_ERR_LENGTH];
3839     sprintf(errmsg,
3840 	    "Error: failed to read element numbering map from file id %d",
3841 	    *idne);
3842     ex_err("negnenm",errmsg,EX_MSG);
3843   }
3844 }
3845 
3846 /*
3847  * Write the element numbering map
3848  */
3849 void
F2C(expnenm)3850 F2C(expnenm)(int *idne,
3851 	     void_int *starte,
3852 	     void_int *num_ent,
3853 	     void_int *elem_map,
3854 	     int *ierr)
3855 {
3856   int64_t st, cnt;
3857   if (ex_int64_status(*idne) & EX_BULK_INT64_API) {
3858     st = *(int64_t*)starte;
3859     cnt = *(int64_t*)num_ent;
3860   } else {
3861     st = *(int*)starte;
3862     cnt = *(int*)num_ent;
3863   }
3864 
3865   if ((*ierr = ex_put_partial_id_map(*idne, EX_ELEM_MAP, st, cnt, elem_map)) != 0) {
3866     char errmsg[MAX_ERR_LENGTH];
3867     sprintf(errmsg,
3868 	    "Error: failed to write element numbering map to file id %d",
3869 	    *idne);
3870     ex_err("nepnenm",errmsg,EX_MSG);
3871   }
3872 }
3873 
3874 /*
3875  * Read the node numbering map
3876  */
3877 void
F2C(exgnnnm)3878 F2C(exgnnnm)(int *idne,
3879 	     void_int *startn,
3880 	     void_int *num_ent,
3881 	     void_int *node_map,
3882 	     int *ierr)
3883 {
3884   int64_t st, cnt;
3885   if (ex_int64_status(*idne) & EX_BULK_INT64_API) {
3886     st = *(int64_t*)startn;
3887     cnt = *(int64_t*)num_ent;
3888   } else {
3889     st = *(int*)startn;
3890     cnt = *(int*)num_ent;
3891   }
3892 
3893   if ((*ierr = ex_get_n_node_num_map(*idne, st, cnt, node_map)) != 0) {
3894     char errmsg[MAX_ERR_LENGTH];
3895     sprintf(errmsg,
3896 	    "Error: failed to read node numbering map from file id %d",
3897 	    *idne);
3898     ex_err("negnnnm",errmsg,EX_MSG);
3899   }
3900 }
3901 
3902 /*
3903  * Write the node numbering map
3904  */
3905 void
F2C(expnnnm)3906 F2C(expnnnm)(int *idne,
3907 	     void_int *startn,
3908 	     void_int *num_ent,
3909 	     void_int *node_map,
3910 	     int *ierr)
3911 {
3912   int64_t st, cnt;
3913   if (ex_int64_status(*idne) & EX_BULK_INT64_API) {
3914     st = *(int64_t*)startn;
3915     cnt = *(int64_t*)num_ent;
3916   } else {
3917     st = *(int*)startn;
3918     cnt = *(int*)num_ent;
3919   }
3920 
3921   if ((*ierr = ex_put_partial_id_map(*idne, EX_NODE_MAP, st, cnt, node_map)) != 0) {
3922     char errmsg[MAX_ERR_LENGTH];
3923     sprintf(errmsg,
3924 	    "Error: failed to write node numbering map to file id %d",
3925 	    *idne);
3926     ex_err("nepnnnm",errmsg,EX_MSG);
3927   }
3928 }
3929 
3930 /*
3931  * Read the node map for a processor
3932  */
3933 void
F2C(exgnmp)3934 F2C(exgnmp)(int *idne,
3935 	   void_int *node_mapi,
3936 	   void_int *node_mapb,
3937 	   void_int *node_mape,
3938 	   int *processor,
3939 	   int *ierr)
3940 {
3941   if ((*ierr = ex_get_processor_node_maps(*idne, node_mapi, node_mapb, node_mape, *processor)) != 0) {
3942     char errmsg[MAX_ERR_LENGTH];
3943     sprintf(errmsg,
3944 	    "Error: failed to read processor node map from file id %d",
3945 	    *idne);
3946     ex_err("negnm",errmsg,EX_MSG);
3947   }
3948 }
3949 
3950 /*
3951  * Write a node map for a processor
3952  */
3953 void
F2C(expnmp)3954 F2C(expnmp)(int *idne,
3955 	   void_int *node_mapi,
3956 	   void_int *node_mapb,
3957 	   void_int *node_mape,
3958 	   int *processor,
3959 	   int *ierr)
3960 {
3961   if ((*ierr = ex_put_processor_node_maps(*idne, node_mapi, node_mapb, node_mape, *processor)) != 0) {
3962     char errmsg[MAX_ERR_LENGTH];
3963     sprintf(errmsg,
3964 	    "Error: failed to write processor node map to file id %d",
3965 	    *idne);
3966     ex_err("nepnm",errmsg,EX_MSG);
3967   }
3968 }
3969 
3970 /*
3971  * Read the element map for a processor
3972  */
3973 void
F2C(exgemp)3974 F2C(exgemp)(int *idne,
3975 	   void_int *elem_mapi,
3976 	   void_int *elem_mapb,
3977 	   int *processor,
3978 	   int *ierr)
3979 {
3980   if ((*ierr = ex_get_processor_elem_maps(*idne, elem_mapi, elem_mapb, *processor)) != 0) {
3981     char errmsg[MAX_ERR_LENGTH];
3982     sprintf(errmsg,
3983 	    "Error: failed to read processor element map from file id %d",
3984 	    *idne);
3985     ex_err("negem",errmsg,EX_MSG);
3986   }
3987 }
3988 
3989 /*
3990  * Write the element map for a processor
3991  */
3992 void
F2C(expemp)3993 F2C(expemp)(int *idne,
3994 	   void_int *elem_mapi,
3995 	   void_int *elem_mapb,
3996 	   int *processor,
3997 	   int *ierr)
3998 {
3999   if ((*ierr = ex_put_processor_elem_maps(*idne, elem_mapi, elem_mapb, *processor)) != 0) {
4000     char errmsg[MAX_ERR_LENGTH];
4001     sprintf(errmsg,
4002 	    "Error: failed to write processor element map to file id %d",
4003 	    *idne);
4004     ex_err("nepem",errmsg,EX_MSG);
4005   }
4006 }
4007 
4008 /*
4009  * Read the communications map parameters for a single processor
4010  */
4011 void
F2C(exgcmp)4012 F2C(exgcmp)(int *idne,
4013 	    void_int *ncmap_ids,
4014 	    void_int *ncmap_node_cnts,
4015 	    void_int *ecmap_ids,
4016 	    void_int *ecmap_elem_cnts,
4017 	    int *processor,
4018 	    int *ierr)
4019 {
4020   if ((*ierr = ex_get_cmap_params(*idne, ncmap_ids, ncmap_node_cnts,
4021                                   ecmap_ids, ecmap_elem_cnts, *processor)) != 0) {
4022     char errmsg[MAX_ERR_LENGTH];
4023     sprintf(errmsg,
4024 	    "Error: failed to read comm map parameters from file id %d",
4025 	    *idne);
4026     ex_err("negcmp",errmsg,EX_MSG);
4027   }
4028 }
4029 
4030 /*
4031  * Write the communications map parameters for a single processor
4032  */
4033 void
F2C(expcmp)4034 F2C(expcmp)(int *idne,
4035 	    void_int *nmap_ids,
4036 	    void_int *nmap_node_cnts,
4037 	    void_int *emap_ids,
4038 	    void_int *emap_elem_cnts,
4039 	    int *processor,
4040 	    int *ierr)
4041 {
4042   if ((*ierr = ex_put_cmap_params(*idne, nmap_ids, nmap_node_cnts,
4043                                   emap_ids, emap_elem_cnts, *processor)) != 0) {
4044     char errmsg[MAX_ERR_LENGTH];
4045     sprintf(errmsg,
4046 	    "Error: failed to write comm map parameters to file id %d",
4047 	    *idne);
4048     ex_err("nepcmp",errmsg,EX_MSG);
4049   }
4050 }
4051 
4052 /*
4053  * Write the communications map parameters for all processors
4054  */
4055 void
F2C(expcmpc)4056 F2C(expcmpc)(int *idne,
4057 	     void_int *nmap_ids,
4058 	     void_int *nmap_node_cnts,
4059 	     void_int *nproc_ptrs,
4060 	     void_int *emap_ids,
4061 	     void_int *emap_elem_cnts,
4062 	     void_int *eproc_ptrs,
4063 	     int *ierr)
4064 {
4065   if ((*ierr = ex_put_cmap_params_cc(*idne, nmap_ids, nmap_node_cnts,
4066                                      nproc_ptrs, emap_ids, emap_elem_cnts,
4067                                      eproc_ptrs)) != 0) {
4068     char errmsg[MAX_ERR_LENGTH];
4069     sprintf(errmsg,
4070 	    "Error: failed to write comm map parameters to file id %d",
4071 	    *idne);
4072     ex_err("nepcmpc",errmsg,EX_MSG);
4073   }
4074 }
4075 
4076 /*
4077  * Read the nodal communications map for a single processor
4078  */
4079 void
F2C(exgncm)4080 F2C(exgncm)(int *idne,
4081 	    entity_id *map_id,
4082 	    void_int *node_ids,
4083 	    void_int *proc_ids,
4084 	    int *processor,
4085 	    int *ierr)
4086 {
4087   if ((*ierr = ex_get_node_cmap(*idne, *map_id, node_ids, proc_ids, *processor)) != 0) {
4088     char errmsg[MAX_ERR_LENGTH];
4089     sprintf(errmsg,
4090 	    "Error: failed to read nodal communications map from file id %d",
4091 	    *idne);
4092     ex_err("negncm",errmsg,EX_MSG);
4093   }
4094 }
4095 
4096 /*
4097  * Write the nodal communications map for a single processor
4098  */
4099 void
F2C(expncm)4100 F2C(expncm)(int *idne,
4101 	    entity_id *map_id,
4102 	    void_int *node_ids,
4103 	    void_int *proc_ids,
4104 	    int *processor,
4105 	    int *ierr)
4106 {
4107   if ((*ierr = ex_put_node_cmap(*idne, *map_id, node_ids, proc_ids, *processor)) != 0) {
4108     char errmsg[MAX_ERR_LENGTH];
4109     sprintf(errmsg,
4110 	    "Error: failed to write nodal communications map to file id %d",
4111 	    *idne);
4112     ex_err("nepncm",errmsg,EX_MSG);
4113   }
4114 }
4115 
4116 /*
4117  * Read the elemental communications map for a single processor
4118  */
4119 void
F2C(exgecm)4120 F2C(exgecm)(int *idne,
4121 	    entity_id *map_id,
4122 	    void_int *elem_ids,
4123 	    void_int *side_ids,
4124 	    void_int *proc_ids,
4125 	    int *processor,
4126 	    int *ierr)
4127 {
4128   if ((*ierr = ex_get_elem_cmap(*idne, *map_id, elem_ids, side_ids, proc_ids, *processor)) != 0) {
4129     char errmsg[MAX_ERR_LENGTH];
4130     sprintf(errmsg,
4131 	    "Error: failed to read elemental comm map from file id %d",
4132 	    *idne);
4133     ex_err("negecm",errmsg,EX_MSG);
4134   }
4135 }
4136 
4137 /*
4138  * Write the elemental communications map for a single processor
4139  */
4140 void
F2C(expecm)4141 F2C(expecm)(int *idne,
4142 	    entity_id *map_id,
4143 	    void_int *elem_ids,
4144 	    void_int *side_ids,
4145 	    void_int *proc_ids,
4146 	    int *processor,
4147 	    int *ierr)
4148 {
4149   if ((*ierr = ex_put_elem_cmap(*idne, *map_id, elem_ids, side_ids, proc_ids, *processor)) != 0) {
4150     char errmsg[MAX_ERR_LENGTH];
4151     sprintf(errmsg,
4152 	    "Error: failed to write elemental comm map to file id %d",
4153 	    *idne);
4154     ex_err("nepecm",errmsg,EX_MSG);
4155   }
4156 }
4157