1 | #include <stdio.h> |
---|
2 | #include <stdlib.h> |
---|
3 | #include <string.h> |
---|
4 | #include <strings.h> |
---|
5 | |
---|
6 | #include "registry.h" |
---|
7 | #include "protos.h" |
---|
8 | #include "data.h" |
---|
9 | |
---|
10 | #define MAXTOKENS 30 |
---|
11 | |
---|
12 | int |
---|
13 | init_dim_table() |
---|
14 | { |
---|
15 | Dim = NULL ; |
---|
16 | return(0) ; |
---|
17 | } |
---|
18 | |
---|
19 | node_t * |
---|
20 | new_node ( int kind ) |
---|
21 | { node_t *p ; p = (node_t *)malloc(sizeof(node_t)) ; bzero(p,sizeof(node_t)); p->node_kind = kind ; return (p) ; } |
---|
22 | |
---|
23 | int |
---|
24 | add_node_to_end ( node_t * node , node_t ** list ) |
---|
25 | { |
---|
26 | node_t * p ; |
---|
27 | if ( *list == NULL ) |
---|
28 | { *list = node ; } |
---|
29 | else |
---|
30 | { |
---|
31 | for ( p = *list ; p->next != NULL ; p = p->next ) ; |
---|
32 | p->next = node ; |
---|
33 | } |
---|
34 | return(0) ; |
---|
35 | } |
---|
36 | |
---|
37 | int |
---|
38 | add_node_to_end_4d ( node_t * node , node_t ** list ) |
---|
39 | { |
---|
40 | node_t * p ; |
---|
41 | if ( *list == NULL ) |
---|
42 | { *list = node ; } |
---|
43 | else |
---|
44 | { |
---|
45 | for ( p = *list ; p->next4d != NULL ; p = p->next4d ) ; |
---|
46 | p->next4d = node ; |
---|
47 | } |
---|
48 | return(0) ; |
---|
49 | } |
---|
50 | |
---|
51 | #if 0 |
---|
52 | int |
---|
53 | show_nodelist( node_t * p ) |
---|
54 | { |
---|
55 | show_nodelist1( p , 0 ) ; |
---|
56 | } |
---|
57 | |
---|
58 | show_nodelist1( node_t * p , int indent ) |
---|
59 | { |
---|
60 | if ( p == NULL ) return(0) ; |
---|
61 | show_node1( p, indent) ; |
---|
62 | show_nodelist1( p->next, indent ) ; |
---|
63 | } |
---|
64 | |
---|
65 | int |
---|
66 | show_node( node_t * p ) |
---|
67 | { |
---|
68 | return(show_node1(p,0)) ; |
---|
69 | } |
---|
70 | |
---|
71 | int |
---|
72 | show_node1( node_t * p, int indent ) |
---|
73 | { |
---|
74 | char spaces[] = " " ; |
---|
75 | char tmp[25] , t1[25] , t2[25] ; |
---|
76 | char * x, *ca, *ld, *ss, *se, *sg ; |
---|
77 | char *nodekind ; |
---|
78 | node_t * q ; |
---|
79 | int nl ; |
---|
80 | int i ; |
---|
81 | |
---|
82 | if ( p == NULL ) return(1) ; |
---|
83 | strcpy(tmp, spaces) ; |
---|
84 | if ( indent >= 0 && indent < 20 ) tmp[indent] = '\0' ; |
---|
85 | |
---|
86 | // this doesn't make much sense any more, ever since node_kind was |
---|
87 | // changed to a bit mask |
---|
88 | if ( p->node_kind & RCONFIG ) nodekind = "RCONFIG" ; |
---|
89 | else if ( p->node_kind & I1 ) nodekind = "I1" ; |
---|
90 | else if ( p->node_kind & FIELD ) nodekind = "FIELD" ; |
---|
91 | else if ( p->node_kind & FOURD ) nodekind = "FOURD" ; |
---|
92 | else if ( p->node_kind & MEMBER ) nodekind = "MEMBER" ; |
---|
93 | else if ( p->node_kind & RCONFIG ) nodekind = "RCONFIG" ; |
---|
94 | |
---|
95 | if ( !p->scalar_array_member ) |
---|
96 | { |
---|
97 | switch ( p->node_kind ) |
---|
98 | { |
---|
99 | case RCONFIG : |
---|
100 | case I1 : |
---|
101 | case FIELD : |
---|
102 | case FOURD : |
---|
103 | case MEMBER : |
---|
104 | fprintf(stderr,"%s%s : %10s ndims %1d\n",tmp,nodekind,p->name, p->ndims) ; |
---|
105 | for ( i = 0 ; i < p->ndims ; i++ ) |
---|
106 | { |
---|
107 | sg = "" ; |
---|
108 | switch ( p->dims[i]->coord_axis ) { |
---|
109 | case COORD_X : ca = "X" ; if ( p->stag_x ) sg = "*" ; break ; |
---|
110 | case COORD_Y : ca = "Y" ; if ( p->stag_y ) sg = "*" ; break ; |
---|
111 | case COORD_Z : ca = "Z" ; if ( p->stag_z ) sg = "*" ; break ; |
---|
112 | case COORD_C : ca = "C" ; break ; |
---|
113 | } |
---|
114 | switch ( p->dims[i]->len_defined_how ) { |
---|
115 | case DOMAIN_STANDARD : ld = "STANDARD" ; ss = "" ; se = "" ; break ; |
---|
116 | case NAMELIST : ld = "NAMELIST" ; ss = p->dims[i]->associated_namelist_variable ; se="" ; break ; |
---|
117 | case CONSTANT : ld = "CONSTANT" ; sprintf(t1,"%d",p->dims[i]->coord_start) ; ss = t1 ; |
---|
118 | sprintf(t2,"%d",p->dims[i]->coord_end ) ; se = t2 ; |
---|
119 | break ; |
---|
120 | } |
---|
121 | fprintf(stderr," dim %1d: %c %2s%s %10s %10s %10s\n",i,p->dims[i]->dim_name,ca,sg,ld,ss,se) ; |
---|
122 | } |
---|
123 | nl = 0 ; |
---|
124 | if ( strlen( p->use ) > 0 ) { |
---|
125 | nl = 1 ; fprintf(stderr," use: %s",p->use) ; |
---|
126 | if ( p->scalar_array_member ) fprintf(stderr,"(4D)") ; |
---|
127 | } |
---|
128 | if ( strlen( p->dname ) > 0 ) { nl = 1 ; fprintf(stderr," dname: %s",p->dname) ; } |
---|
129 | if ( strlen( p->descrip ) > 0 ) { nl = 1 ; fprintf(stderr," descrip: %s",p->descrip) ; } |
---|
130 | if ( nl == 1 ) fprintf(stderr,"\n") ; |
---|
131 | show_node1( p->type, indent+1 ) ; |
---|
132 | break ; |
---|
133 | case TYPE : |
---|
134 | x = "derived" ; |
---|
135 | if ( p->type_type == SIMPLE ) x = "simple" ; |
---|
136 | fprintf(stderr,"%sTYPE : %10s %s ndims %1d\n",tmp,p->name,x, p->ndims) ; |
---|
137 | show_nodelist1( p->fields, indent+1 ) ; |
---|
138 | break ; |
---|
139 | case DIM : |
---|
140 | break ; |
---|
141 | default : |
---|
142 | break ; |
---|
143 | } |
---|
144 | } |
---|
145 | show_nodelist1( p->members , indent+2 ) ; |
---|
146 | return(0) ; |
---|
147 | } |
---|
148 | #endif |
---|
149 | |
---|
150 | int |
---|
151 | set_mark ( int val , node_t * lst ) |
---|
152 | { |
---|
153 | node_t * p ; |
---|
154 | if ( lst == NULL ) return(0) ; |
---|
155 | for ( p = lst ; p != NULL ; p = p->next ) |
---|
156 | { |
---|
157 | p->mark = val ; |
---|
158 | set_mark( val , p->fields ) ; |
---|
159 | set_mark( val , p->members ) ; |
---|
160 | } |
---|
161 | return(0) ; |
---|
162 | } |
---|
163 | |
---|
164 | int |
---|
165 | set_mark_4d ( int val , node_t * lst ) |
---|
166 | { |
---|
167 | node_t * p ; |
---|
168 | if ( lst == NULL ) return(0) ; |
---|
169 | for ( p = lst ; p != NULL ; p = p->next4d ) |
---|
170 | { |
---|
171 | p->mark = val ; |
---|
172 | set_mark( val , p->fields ) ; |
---|
173 | set_mark( val , p->members ) ; |
---|
174 | } |
---|
175 | return(0) ; |
---|
176 | } |
---|
177 | |
---|