This repository has been archived by the owner on Mar 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
rd_dpi.c
1683 lines (1394 loc) · 45 KB
/
rd_dpi.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/************************************************************************ *
* Goma - Multiphysics finite element software *
* Sandia National Laboratories *
* *
* Copyright (c) 2014 Sandia Corporation. *
* *
* Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, *
* the U.S. Government retains certain rights in this software. *
* *
* This software is distributed under the GNU General Public License. *
\************************************************************************/
/* rd_dpi.c -- routines for reading distributed processing information
*
*
* Notes:
* [1] The information is in netCDF format.
*
* [2] Typically, this augments EXODUS II finite element data.
*
* [3] Try to use netCDF names identical to the names of the
* structure elements defined in "dpi.h"
*
* [4] Read in arrays in one shot instead of an element at
* a time.
*
* [5] Allocate space as needed to hold the information. Use
* free_dpi() to release memory that was dynamically allocated
* here.
*
* [6] Two routes through code - netCDF 3, as originally intended
* and netCDF 2 as demanded by exigencies of working with
* EXODUS II
*
* [7] Assume basic skeleton space for the Dpi structure has been
* allocated. However, individual arrays, etc, will have space
* allocated for them in this routine.
*
* [8] In the future, a flag might indicate that "globally similar"
* information is to be read or not read. Such a capability
* would permit processor 0 to read the globally similar
* information. MPI could be used to broadcast it to every other
* processor and the read step could be trimmed to read only
* that information that is unique to that processor. Note
* that some globally similar information resides in the
* EXODUS II portion of the data as well. My impression is that
* startup and latency issues are more important than message
* length issues. If substantial savings in I/O time justifies
* the expenditure in programming complexity, then a conditional
* switch could be inserted to enable the reading of purelylocal
* or globally-similar data.
*
* Created: 1997/07/10 15:39 MDT [email protected]
*
* Revised: 1997/07/21 09:45 MDT [email protected]
*
* Revised: 1998/09/26 07:01 MDT [email protected]
*/
#define _RD_DPI_C
#include <config.h>
#include <stdio.h>
#ifdef STDC_HEADERS
#include <stdlib.h>
#endif
#include <string.h>
/*
* Use NETCDF_3 with NO_NETCDF_2 not defined!
* #define NO_NETCDF_2 for pure netCDF 3 - but still not yet.
*/
#define NETCDF_3
#include "netcdf.h"
/*
* I like these symbols as more lucid indicators of which netCDF we are
* using...
*
* Well, we need to maintain backwards compatibility...
*/
#define _RD_DPI_C
#ifndef NC_MAX_VAR_DIMS
#define NC_MAX_VAR_DIMS MAX_VAR_DIMS
#endif
#ifndef NC_MAX_NAME
#define NC_MAX_NAME MAX_NC_NAME
#endif
#ifndef NC_INT
#define NC_INT NC_LONG
#endif
/*
* Might need some NO_NETCDF_2 definitions here ...
*/
#include "map_names.h"
#include "std.h"
#include "aalloc.h"
#include "eh.h"
#include "exo_struct.h"
#include "dpi.h"
#include "rd_dpi.h"
#include "nodesc.h"
static int get_variable_call_count = 0;
#if 0
static int ProcID=-1;
#endif
/*
* Prototypes of functions defined here and needed only here.
*/
static void get_variable
PROTO((const int netcdf_unit,
const nc_type netcdf_type,
const int num_dimensions,
const int dimension_val_1,
const int dimension_val_2,
const int variable_identifier,
void *variable_address));
/* init_dpi_struct() -- initialize some defaults
*
* This is meant to be called right after allocation, to help setup some
* reasonable defaults to describe an empty data structure. Call it a poor
* man's constructor.
*
* Created: 1999/08/11 17:04 MDT [email protected]
*
* Revised:
*/
void
init_dpi_struct(Dpi *d)
{
if ( d == NULL )
{
EH(-1, "Empty structure to initialize?");
}
/*
* Set all elements in the structure to NULL to ensure that all
* pointers are set to NULL. Thus, we can check against NULL
* to see if a deallocation is necessary.
*/
(void) memset((void *)d, 0, sizeof(Dpi));
/*
* Initialize all of the dimensions to zero.
*/
d->len_eb_num_private_elems = 0;
d->len_elem_var_tab_global = 0;
d->len_elem_elem_list = 0;
d->len_node_description = 0;
d->len_ns_node_list = 0;
d->len_ns_distfact_list = 0;
d->len_ss_elem_list = 0;
d->len_ss_distfact_list = 0;
d->len_string = MAX_STR_LENGTH;
d->len_ptr_set_membership = 0;
d->len_set_membership = 0;
d->num_elem_blocks = 0;
d->num_elem_blocks_global = 0;
d->num_elems = 0;
d->num_global_node_descriptions = 0;
d->num_neighbors = 0;
d->num_node_sets = 0;
d->num_node_sets_global = 0;
d->num_nodes = 0;
d->num_props_eb = 0;
d->num_props_ns = 0;
d->num_props_ss = 0;
d->num_side_sets = 0;
d->num_side_sets_global = 0;
d->num_universe_nodes = 0;
d->undefined_basic_eqnvar_id = UNDEFINED_EQNVARID;
d->len_node_description = LEN_NODE_DESCRIPTION;
return;
}
/* init_dpi_version() -- make space and initialize the Dpi version string
*
* Take HKM's advice. Make space for a version string to manage backward
* incompatibilities with more grace and less hacking than previously
* possible...
*
* Note: This only makes space! You still must put a version string in the
* variable that reflects how old or new is the data you're reading
* or writing.
*
* Created: 1999/11/15 13:28 MST [email protected]
*/
void
init_dpi_version(Dpi *d)
{
int i;
int len;
if ( d == NULL )
{
EH(-1, "Allocate b4 U initialize!");
}
len = d->len_string;
if ( len < 1 )
{
EH(-1, "Not enough space to place a version string!");
}
d->dpi_version_string = (char *) smalloc((len+3)*sizeof(char));
for ( i=0; i<len+3; i++)
{
d->dpi_version_string[i] = '\0';
}
return;
}
/* exo_dpi_clone -- transfer needed global monolith data to child piece
*
*
* Notes: Avert aliasing problems by allocating full-fledged arrays for dpi
* that won't disappear if the monolith does.
*
* Created: 1999/08/24 11:44 MDT [email protected]
*/
void
exo_dpi_clone(Exo_DB *exo,
Dpi *dpi)
{
int len;
dpi->num_nodes_global = exo->num_nodes;
dpi->num_elems_global = exo->num_elems;
dpi->num_elem_blocks_global = exo->num_elem_blocks;
dpi->num_node_sets_global = exo->num_node_sets;
dpi->num_side_sets_global = exo->num_side_sets;
/*
* Allocate and fill arrays for element blocks...
*/
len = dpi->num_elem_blocks_global * sizeof(int);
dpi->eb_id_global = smalloc(len);
memcpy(dpi->eb_id_global, exo->eb_id, len);
dpi->eb_num_elems_global = smalloc(len);
memcpy(dpi->eb_num_elems_global, exo->eb_num_elems, len);
/*
* Allocate and fill arrays for node sets...
*/
len = dpi->num_node_sets_global * sizeof(int);
dpi->ns_id_global = smalloc(len);
memcpy(dpi->ns_id_global, exo->ns_id, len);
dpi->ns_num_nodes_global = smalloc(len);
memcpy(dpi->ns_num_nodes_global, exo->ns_num_nodes, len);
dpi->ns_num_distfacts_global = smalloc(len);
memcpy(dpi->ns_num_distfacts_global, exo->ns_num_distfacts, len);
/*
* Allocate and fill arrays for side sets...
*/
len = dpi->num_side_sets_global * sizeof(int);
dpi->ss_id_global = smalloc(len);
memcpy(dpi->ss_id_global, exo->ss_id, len);
dpi->ss_num_sides_global = smalloc(len);
memcpy(dpi->ss_num_sides_global, exo->ss_num_sides, len);
dpi->ss_num_distfacts_global = smalloc(len);
memcpy(dpi->ss_num_distfacts_global, exo->ss_num_distfacts, len);
return;
}
int
rd_dpi(Dpi *d,
char *fn,
int verbosity)
{
int err;
int i;
int len;
#ifdef NETCDF_3
int dim[NC_MAX_VAR_DIMS];
#endif
#ifdef NETCDF_2
/* int tim[NC_MAX_VAR_DIMS]; This is ludicrous... */
long dim[NC_MAX_VAR_DIMS];
#endif
long count[NC_MAX_VAR_DIMS];
long start[NC_MAX_VAR_DIMS];
int status;
int u; /* short hand for unit... */
struct Shadow_Identifiers si;
memset(&si, 0, sizeof(struct Shadow_Identifiers));
status = 0;
for ( i=0; i<NC_MAX_VAR_DIMS; i++)
{
start[i] = 0;
dim[i] = 1;
count[i] = 1;
}
/* Gratuitous use to placate SGI cc warnings! */
if ( start[0] != 0 || dim[0] != 1 || count[0] != 1 ) exit(2);
/*
* From the C interface guide, the basic calling sequence is given
* for reading dimensions and variables from a netCDF dataset for the
* case
*
* when the names of the dimensions and variables are known
*
* NETCDF 3:
*
* nc_open();
* nc_inq_dimid();
* nc_inq_varid();
* nc_get_att();
* nc_get_var();
* nc_close();
*
* NETCDF 2:
*
* ncopen();
* ncdimid();
* ncvarid();
* ncattget();
* ncvarget();
* ncclose();
*
*/
/*
* 1. Open the file.
*/
#ifdef NETCDF_3
err = nc_open(fn, NC_NOWRITE, &u);
if ( err != NC_NOERR )
{
EH(-1, "nc_open() problem.");
}
#endif
#ifdef NETCDF_2
err = ncopen(fn, NC_NOWRITE);
EH(err, "ncopen() problem.");
u = err;
#endif
#ifdef DEBUG
fprintf(stderr, "just ncopen-ed file \"%s\" on unit %d\n", fn, u);
#endif
/*
* 2. Get dimension identifiers.
*
* These are determined from their names which are defined in dpi.h.
*
* These integer dimension IDs, if read properly from the open file,
* are stuck into the Shadow Identifiers si structure for later use.
*
* Briefly, the "TRUE" and "FALSE" arguments you see refer to whether
* it is critical that this particular dimension exist in the database.
* Often, a FALSE flag is desirable for objects of zero length that
* do not exist in this case.
*/
getdid(u, DIM_LEN_EB_NUM_PRIVATE_ELEMS, FALSE,
&si.len_eb_num_private_elems);
getdid(u, DIM_LEN_ELEM_VAR_TAB_GLOBAL, FALSE,
&si.len_elem_var_tab_global);
getdid(u, DIM_LEN_NODE_DESCRIPTION, TRUE,
&si.len_node_description);
/*
* Found some cases of split up pieces that didn't have any lists,
* i.e., there lengths are zero. In that case, netCDF likes it better
* to not even ask.
*/
getdid(u, DIM_LEN_NS_NODE_LIST, FALSE,
&si.len_ns_node_list);
getdid(u, DIM_LEN_NS_DISTFACT_LIST, FALSE,
&si.len_ns_distfact_list);
getdid(u, DIM_LEN_SS_ELEM_LIST, FALSE,
&si.len_ss_elem_list);
getdid(u, DIM_LEN_SS_DISTFACT_LIST, FALSE,
&si.len_ss_distfact_list);
getdid(u, DIM_LEN_STRING, TRUE,
&si.len_string);
getdid(u, DIM_LEN_PTR_SET_MEMBERSHIP, TRUE,
&si.len_ptr_set_membership);
getdid(u, DIM_LEN_SET_MEMBERSHIP, TRUE,
&si.len_set_membership);
getdid(u, DIM_NUM_ELEM_BLOCKS, FALSE,
&si.num_elem_blocks);
getdid(u, DIM_NUM_ELEM_BLOCKS_GLOBAL, FALSE,
&si.num_elem_blocks_global);
getdid(u, DIM_NUM_ELEMS, TRUE,
&si.num_elems);
getdid(u, DIM_NUM_GLOBAL_NODE_DESCRIPTIONS, TRUE,
&si.num_global_node_descriptions);
getdid(u, DIM_NUM_NEIGHBORS, FALSE,
&si.num_neighbors);
getdid(u, DIM_NUM_NODE_SETS, FALSE,
&si.num_node_sets);
getdid(u, DIM_NUM_NODE_SETS_GLOBAL, FALSE,
&si.num_node_sets_global);
getdid(u, DIM_NUM_NODES, TRUE,
&si.num_nodes);
getdid(u, DIM_NUM_PROPS_EB, FALSE,
&si.num_props_eb);
getdid(u, DIM_NUM_PROPS_NS, FALSE,
&si.num_props_ns);
getdid(u, DIM_NUM_PROPS_SS, FALSE,
&si.num_props_ss);
getdid(u, DIM_NUM_SIDE_SETS, FALSE,
&si.num_side_sets);
getdid(u, DIM_NUM_SIDE_SETS_GLOBAL, FALSE,
&si.num_side_sets_global);
getdid(u, DIM_NUM_UNIVERSE_NODES, TRUE,
&si.num_universe_nodes);
/*
* 3. Using the dimension IDs, inquire of the dimension values. Load
* those values into the Dpi structure.
*
* These dimension values are important so that we know how much
* space to allocate to hold array variables below...
*
* getdim(netcdf_unit, dimension_id, address of the answer);
*/
getdim(u, si.len_eb_num_private_elems, &d->len_eb_num_private_elems);
getdim(u, si.len_elem_var_tab_global, &d->len_elem_var_tab_global);
getdim(u, si.len_node_description, &d->len_node_description);
getdim(u, si.len_ns_node_list, &d->len_ns_node_list);
getdim(u, si.len_ns_distfact_list, &d->len_ns_distfact_list);
getdim(u, si.len_ss_elem_list, &d->len_ss_elem_list);
getdim(u, si.len_ss_distfact_list, &d->len_ss_distfact_list);
getdim(u, si.len_string, &d->len_string);
getdim(u, si.len_ptr_set_membership, &d->len_ptr_set_membership);
getdim(u, si.len_set_membership, &d->len_set_membership);
getdim(u, si.num_elem_blocks, &d->num_elem_blocks);
getdim(u, si.num_elem_blocks_global, &d->num_elem_blocks_global);
getdim(u, si.num_elems, &d->num_elems);
getdim(u, si.num_global_node_descriptions, &d->num_global_node_descriptions);
getdim(u, si.num_neighbors, &d->num_neighbors);
getdim(u, si.num_node_sets, &d->num_node_sets);
getdim(u, si.num_node_sets_global, &d->num_node_sets_global);
getdim(u, si.num_nodes, &d->num_nodes);
getdim(u, si.num_props_eb, &d->num_props_eb);
getdim(u, si.num_props_ns, &d->num_props_ns);
getdim(u, si.num_props_ss, &d->num_props_ss);
getdim(u, si.num_side_sets, &d->num_side_sets);
getdim(u, si.num_side_sets_global, &d->num_side_sets_global);
getdim(u, si.num_universe_nodes, &d->num_universe_nodes);
#ifdef DEBUG
fprintf(stderr, "Processor %d has d->num_side_sets = %d\n", ProcID,
d->num_side_sets);
fprintf(stderr, "Processor %d has d->num_elem_blocks = %d\n", ProcID,
d->num_elem_blocks);
fprintf(stderr, "Processor %d has d->num_side_sets_global = %d\n", ProcID,
d->num_side_sets_global);
#endif
/*
* 4. Get variable identifiers from netCDF.
*
* The Booleans are set only roughly based on what "ought" to exist.
* If you deem looser or tighter criteria, then by all means change
* them to suit your needs.
*/
getvid(u, VAR_DPI_VERSION_STRING, FALSE,
&si.dpi_version_string);
getvid(u, VAR_EB_ELEM_TYPE_GLOBAL, FALSE, /* New! */
&si.eb_elem_type_global);
getvid(u, VAR_EB_ID_GLOBAL, FALSE,
&si.eb_id_global);
getvid(u, VAR_EB_INDEX_GLOBAL, FALSE,
&si.eb_index_global);
getvid(u, VAR_EB_NUM_ATTR_GLOBAL, FALSE, /* New! */
&si.eb_num_attr_global);
getvid(u, VAR_EB_NUM_ELEMS_GLOBAL, FALSE,
&si.eb_num_elems_global);
getvid(u, VAR_EB_NUM_NODES_PER_ELEM_GLOBAL, FALSE, /* New! */
&si.eb_num_nodes_per_elem_global);
getvid(u, VAR_EB_NUM_PRIVATE_ELEMS, FALSE,
&si.eb_num_private_elems);
getvid(u, VAR_EB_PROP_GLOBAL, FALSE,
&si.eb_prop_global);
getvid(u, VAR_ELEM_INDEX_GLOBAL, TRUE, /* New! */
&si.elem_index_global);
getvid(u, VAR_ELEM_VAR_TAB_GLOBAL, FALSE, /* New! */
&si.elem_var_tab_global);
getvid(u, VAR_GLOBAL_NODE_DESCRIPTION, TRUE,
&si.global_node_description);
getvid(u, VAR_MY_NAME, TRUE,
&si.my_name);
getvid(u, VAR_NEIGHBOR, FALSE,
&si.neighbor);
getvid(u, VAR_NODE_INDEX_GLOBAL, TRUE, /* New! */
&si.node_index_global);
getvid(u, VAR_NS_DISTFACT_INDEX_GLOBAL, FALSE, /* New! */
&si.ns_distfact_index_global);
getvid(u, VAR_NS_DISTFACT_LEN_GLOBAL, FALSE, /* New! */
&si.ns_distfact_len_global);
getvid(u, VAR_NS_DISTFACT_LIST_INDEX_GLOBAL, FALSE, /* New! */
&si.ns_distfact_list_index_global);
getvid(u, VAR_NS_ID_GLOBAL, FALSE,
&si.ns_id_global);
getvid(u, VAR_NS_INDEX_GLOBAL, FALSE,
&si.ns_index_global);
getvid(u, VAR_NS_NODE_INDEX_GLOBAL, FALSE, /* New! */
&si.ns_node_index_global);
getvid(u, VAR_NS_NODE_LEN_GLOBAL, FALSE, /* New! */
&si.ns_node_len_global);
getvid(u, VAR_NS_NODE_LIST_INDEX_GLOBAL, FALSE, /* New! */
&si.ns_node_list_index_global);
getvid(u, VAR_NS_NUM_DISTFACTS_GLOBAL, FALSE,
&si.ns_num_distfacts_global);
getvid(u, VAR_NS_NUM_NODES_GLOBAL, FALSE,
&si.ns_num_nodes_global);
getvid(u, VAR_NS_PROP_GLOBAL, FALSE,
&si.ns_prop_global);
getvid(u, VAR_NUM_BOUNDARY_NODES, TRUE,
&si.num_boundary_nodes);
getvid(u, VAR_NUM_DOFS_GLOBAL, TRUE,
&si.num_dofs_global);
getvid(u, VAR_NUM_ELEMS_GLOBAL, TRUE,
&si.num_elems_global);
getvid(u, VAR_NUM_EXTERNAL_NODES, TRUE,
&si.num_external_nodes);
getvid(u, VAR_NUM_INTERNAL_NODES, TRUE,
&si.num_internal_nodes);
getvid(u, VAR_NUM_NODES_GLOBAL, TRUE,
&si.num_nodes_global);
getvid(u, VAR_PTR_SET_MEMBERSHIP, TRUE,
&si.ptr_set_membership);
getvid(u, VAR_SET_MEMBERSHIP, TRUE,
&si.set_membership);
getvid(u, VAR_SS_DISTFACT_INDEX_GLOBAL, FALSE, /* New! */
&si.ss_distfact_index_global);
getvid(u, VAR_SS_DISTFACT_LEN_GLOBAL, FALSE, /* New! */
&si.ss_distfact_len_global);
getvid(u, VAR_SS_DISTFACT_LIST_INDEX_GLOBAL, FALSE, /* New! */
&si.ss_distfact_list_index_global);
getvid(u, VAR_SS_ELEM_INDEX_GLOBAL, FALSE, /* New! */
&si.ss_elem_index_global);
getvid(u, VAR_SS_ELEM_LEN_GLOBAL, FALSE, /* New! */
&si.ss_elem_len_global);
getvid(u, VAR_SS_ELEM_LIST_INDEX_GLOBAL, FALSE, /* New! */
&si.ss_elem_list_index_global);
getvid(u, VAR_SS_NODE_LEN_GLOBAL, FALSE, /* New! */
&si.ss_node_len_global);
getvid(u, VAR_SS_ID_GLOBAL, FALSE,
&si.ss_id_global);
getvid(u, VAR_SS_INDEX_GLOBAL, FALSE,
&si.ss_index_global);
getvid(u, VAR_SS_NUM_DISTFACTS_GLOBAL, FALSE,
&si.ss_num_distfacts_global);
getvid(u, VAR_SS_NUM_SIDES_GLOBAL, FALSE,
&si.ss_num_sides_global);
getvid(u, VAR_SS_PROP_GLOBAL, FALSE,
&si.ss_prop_global);
getvid(u, VAR_UNDEFINED_BASIC_EQNVAR_ID, TRUE,
&si.undefined_basic_eqnvar_id);
/*
* 5. Allocate space to hold array variables.
*
* a. Should verify that these dimensions are reasonable
* numbers 0 < dimval < humongous
*
* b. Simple scalar variables are not allocated here - they got
* their space when *d became meaningful.
*/
len = d->len_string;
if ( len > 0 )
{
d->dpi_version_string = (char *) smalloc(len*sizeof(char));
for ( i=0; i<len; i++)
{
d->dpi_version_string[i] = '\0';
}
}
len = d->num_elems;
if ( len > 0 )
{
d->elem_index_global = (int *) smalloc(len*sizeof(int));
}
len = d->num_elem_blocks_global;
if ( len > 0 )
{
d->eb_id_global = (int *) smalloc(len*sizeof(int));
d->eb_num_attr_global = (int *) smalloc(len*sizeof(int));
d->eb_num_elems_global = (int *) smalloc(len*sizeof(int));
d->eb_num_nodes_per_elem_global = (int *) smalloc(len*sizeof(int));
d->eb_elem_type_global = (char **) smalloc(len*sizeof(char *));
d->eb_elem_type_global[0] = (char *) smalloc(len*(MAX_STR_LENGTH+1)*
sizeof(char));
for ( i=1; i<len; i++)
{
d->eb_elem_type_global[i] = ( d->eb_elem_type_global[i-1] +
(MAX_STR_LENGTH+1) );
}
}
len = d->num_props_eb;
if ( len > 1 ) /* Props are special ID is implicit. */
{
d->eb_prop_global = (int **) smalloc(len * sizeof(int *));
d->eb_prop_global[0] = (int *) smalloc(len * (d->num_elem_blocks_global) * sizeof(int));
for ( i=1; i<len; i++)
{
d->eb_prop_global[i] = ( d->eb_prop_global[i-1] + d->num_elem_blocks_global );
}
}
if ( d->num_props_ns > 1 ) /* Props are special, ID is implicit. */
{
d->ns_prop_global = (int **) smalloc(d->num_props_ns * sizeof(int *));
d->ns_prop_global[0] = (int *) smalloc(d->num_props_ns*
d->num_node_sets_global*
sizeof(int));
for ( i=1; i<d->num_props_ns; i++)
{
d->ns_prop_global[i] = ( d->ns_prop_global[i-1] +
d->num_node_sets_global );
}
}
if ( d->num_props_ss > 1 ) /* Props are special, ID is implicit. */
{
d->ss_prop_global = (int **) smalloc(d->num_props_ss * sizeof(int *));
d->ss_prop_global[0] = (int *) smalloc(d->num_props_ss*
d->num_side_sets_global*
sizeof(int));
for ( i=1; i<d->num_props_ss; i++)
{
d->ss_prop_global[i] = ( d->ss_prop_global[i-1] +
d->num_side_sets_global );
}
}
len = d->num_elem_blocks;
if ( len > 0 )
{
d->eb_index_global = (int *) smalloc(len * sizeof(int));
d->eb_num_private_elems = (int *) smalloc(len * sizeof(int));
}
len = d->len_elem_var_tab_global;
if ( len > 0 )
{
d->elem_var_tab_global = ( int *) smalloc(len*sizeof(int));
}
if ( d->num_global_node_descriptions > 0 )
{
d->global_node_description =
(int **) smalloc(d->num_global_node_descriptions * sizeof(int *));
d->global_node_description[0] =
(int *) smalloc(d->num_global_node_descriptions*
d->len_node_description*sizeof(int));
for ( i=1; i<d->num_global_node_descriptions; i++)
{
d->global_node_description[i] = ( d->global_node_description[i-1] +
d->len_node_description );
}
}
len = d->num_nodes;
if ( len > 0 )
{
d->node_index_global = (int *) smalloc(len*sizeof(int));
}
if ( d->num_neighbors > 0 )
{
d->neighbor = (int *) smalloc(d->num_neighbors*sizeof(int));
}
len = d->num_node_sets_global;
if ( len > 0 )
{
d->ns_id_global = (int *) smalloc(len*sizeof(int));
d->ns_num_distfacts_global = (int *) smalloc(len*sizeof(int));
d->ns_num_nodes_global = (int *) smalloc(len*sizeof(int));
d->ns_node_index_global = (int *) smalloc(len*sizeof(int));
d->ns_distfact_index_global = (int *) smalloc(len*sizeof(int));
}
if ( d->num_node_sets > 0 )
{
d->ns_index_global = (int *) smalloc(d->num_node_sets*sizeof(int));
}
if ( d->len_ns_node_list > 0 )
{
d->ns_node_list_index_global = (int *)
smalloc(d->len_ns_node_list*sizeof(int));
}
if ( d->len_ns_distfact_list > 0 )
{
d->ns_distfact_list_index_global = (int *)
smalloc(d->len_ns_distfact_list*sizeof(int));
}
if ( d->len_ptr_set_membership > 0 )
{
d->ptr_set_membership = (int *) smalloc(d->len_ptr_set_membership*
sizeof(int));
}
if ( d->len_set_membership > 0 )
{
d->set_membership = (int *) smalloc(d->len_set_membership*sizeof(int));
}
len = d->num_side_sets_global;
if ( len > 0 )
{
d->ss_distfact_index_global = (int *) smalloc(len*sizeof(int));
d->ss_elem_index_global = (int *) smalloc(len*sizeof(int));
d->ss_id_global = (int *) smalloc(len*sizeof(int));
d->ss_num_distfacts_global = (int *) smalloc(len*sizeof(int));
d->ss_num_sides_global = (int *) smalloc(len*sizeof(int));
}
if ( d->len_ss_elem_list > 0 )
{
d->ss_elem_list_index_global = (int *)
smalloc(d->len_ss_elem_list*sizeof(int));
}
if ( d->len_ss_distfact_list > 0 )
{
d->ss_distfact_list_index_global = (int *)
smalloc(d->len_ss_distfact_list*sizeof(int));
}
if ( d->num_side_sets > 0 )
{
d->ss_index_global = (int *) smalloc(d->num_side_sets*
sizeof(int));
}
/*
* 6. Get variables - this is messy. Netcdf 3 wants a different routine
* for each type. NetCDF 2 wants to know all the dimensions! Attempt
* to hide the messy details in get_variable()...
*/
if ( si.dpi_version_string < 0 )
{
strcpy(d->dpi_version_string, "0.9");
}
else
{
get_variable(u, NC_CHAR, 1,
d->len_string, -1,
si.dpi_version_string, d->dpi_version_string);
}
get_variable(u, NC_CHAR, 2,
d->num_elem_blocks_global, d->len_string,
si.eb_elem_type_global, &(d->eb_elem_type_global[0][0]));
get_variable(u, NC_INT, 1,
d->num_elem_blocks_global, -1,
si.eb_id_global, d->eb_id_global);
get_variable(u, NC_INT, 1,
d->num_elem_blocks, -1,
si.eb_index_global, d->eb_index_global);
get_variable(u, NC_INT, 1,
d->num_elem_blocks_global, -1,
si.eb_num_attr_global, d->eb_num_attr_global);
get_variable(u, NC_INT, 1,
d->num_elem_blocks_global, -1,
si.eb_num_elems_global, d->eb_num_elems_global);
get_variable(u, NC_INT, 1,
d->num_elem_blocks_global, -1,
si.eb_num_nodes_per_elem_global,
d->eb_num_nodes_per_elem_global);
get_variable(u, NC_INT, 1,
d->num_elem_blocks, -1,
si.eb_num_private_elems, d->eb_num_private_elems);
if ( d->num_props_eb > 1 )
{
get_variable(u, NC_INT, 2,
d->num_props_eb, d->num_elem_blocks_global,
si.eb_prop_global, &(d->eb_prop_global[0][0]));
}
get_variable(u, NC_INT, 1,
d->len_elem_var_tab_global, -1,
si.elem_var_tab_global, d->elem_var_tab_global);
if ( d->num_elems > 0 )
{
get_variable(u, NC_INT, 1,
d->num_elems, -1,
si.elem_index_global, d->elem_index_global);
}
get_variable(u, NC_INT, 2,
d->num_global_node_descriptions, d->len_node_description,
si.global_node_description,&(d->global_node_description[0][0]));
get_variable(u, NC_INT, 0,
-1, -1,
si.my_name, &(d->my_name));
get_variable(u, NC_INT, 1,
d->num_neighbors, -1,
si.neighbor, d->neighbor);
if ( d->num_nodes > 0 )
{
get_variable(u, NC_INT, 1,
d->num_nodes, -1,
si.node_index_global, d->node_index_global);
}
get_variable(u, NC_INT, 0,
-1, -1,
si.ns_distfact_len_global, &(d->ns_distfact_len_global));
get_variable(u, NC_INT, 0,
-1, -1,
si.ns_node_len_global, &(d->ns_node_len_global));
get_variable(u, NC_INT, 1,
d->num_node_sets_global, -1,
si.ns_id_global, d->ns_id_global);
get_variable(u, NC_INT, 1,
d->num_node_sets, -1,
si.ns_index_global, d->ns_index_global);
get_variable(u, NC_INT, 1,
d->len_ns_distfact_list, -1,
si.ns_distfact_list_index_global,
d->ns_distfact_list_index_global);
get_variable(u, NC_INT, 1,
d->num_node_sets_global, -1,
si.ns_distfact_index_global, d->ns_distfact_index_global);
get_variable(u, NC_INT, 1,
d->num_node_sets_global, -1,
si.ns_node_index_global, d->ns_node_index_global);
get_variable(u, NC_INT, 1,
d->len_ns_node_list, -1,
si.ns_node_list_index_global,
d->ns_node_list_index_global);
get_variable(u, NC_INT, 1,
d->num_node_sets_global, -1,
si.ns_num_distfacts_global, d->ns_num_distfacts_global);
get_variable(u, NC_INT, 1,
d->num_node_sets_global, -1,
si.ns_num_nodes_global, d->ns_num_nodes_global);
if ( d->num_props_ns > 1 )
{
get_variable(u, NC_INT, 2,
d->num_props_ns, d->num_node_sets_global,
si.ns_prop_global, &(d->ns_prop_global[0][0]));
}
get_variable(u, NC_INT, 0,
-1, -1,
si.num_boundary_nodes, &(d->num_boundary_nodes));
get_variable(u, NC_INT, 0,
-1, -1,
si.num_dofs_global, &(d->num_dofs_global));
get_variable(u, NC_INT, 0,
-1, -1,
si.num_elems_global, &(d->num_elems_global));
get_variable(u, NC_INT, 0,
-1, -1,
si.num_external_nodes, &(d->num_external_nodes));
get_variable(u, NC_INT, 0,
-1, -1,
si.num_internal_nodes, &(d->num_internal_nodes));
get_variable(u, NC_INT, 0,
-1, -1,
si.num_nodes_global, &(d->num_nodes_global));
get_variable(u, NC_INT, 1,
d->len_ptr_set_membership, -1,
si.ptr_set_membership, d->ptr_set_membership);
get_variable(u, NC_INT, 1,
d->len_set_membership, -1,
si.set_membership, d->set_membership);