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