5 # define rindex(X,Y) strrchr(X,Y)
6 # define index(X,Y) strchr(X,Y)
20 p
= new_node(TYPE
) ; p
->type_type
= SIMPLE
; strcpy( p
->name
, "integer" ) ; add_node_to_end ( p
, &Type
) ;
21 p
= new_node(TYPE
) ; p
->type_type
= SIMPLE
; strcpy( p
->name
, "real" ) ; add_node_to_end ( p
, &Type
) ;
22 p
= new_node(TYPE
) ; p
->type_type
= SIMPLE
; strcpy( p
->name
, "logical" ) ; add_node_to_end ( p
, &Type
) ;
23 p
= new_node(TYPE
) ; p
->type_type
= SIMPLE
; strcpy( p
->name
, "character*256" ) ; add_node_to_end ( p
, &Type
) ;
24 p
= new_node(TYPE
) ; p
->type_type
= SIMPLE
; strcpy( p
->name
, "doubleprecision" ) ; add_node_to_end ( p
, &Type
) ;
29 set_state_dims ( char * dims
, node_t
* node
)
37 if ( dims
== NULL
) dims
= "-" ;
39 node
->proc_orient
= ALL_Z_ON_PROC
; /* default */
41 node
->boundary_array
= 0 ;
47 for ( c
= dims
; *c
; c
++ )
49 if ( *c
== 'f' && ! inbrace
)
51 node
->scalar_array_member
= 1 ;
54 else if ( *c
== 't' && ! inbrace
)
56 node
->has_scalar_array_tendencies
= 1 ;
59 else if ( *c
== 'x' && ! inbrace
)
61 node
->proc_orient
= ALL_X_ON_PROC
;
64 else if ( *c
== 'y' && ! inbrace
)
66 node
->proc_orient
= ALL_Y_ON_PROC
;
69 else if ( *c
== 'b' && ! inbrace
)
71 node
->boundary_array
= 1 ;
74 else if ( *c
== '*' && ! inbrace
)
76 /* next dimspec seen represents a subgrid */
80 else if ( *c
== '-' && ! inbrace
)
84 else if ( *c
== '{' && ! inbrace
)
90 else if ( *c
== '}' && inbrace
)
96 else if ( modifiers
== 0 )
98 if ( *c
== '}' && inbrace
) { inbrace
= 0 ; }
99 else { int n
= strlen(dspec
) ; dspec
[n
] = *c
; dspec
[n
+1]='\0' ; }
103 if (( d
= get_dim_entry ( dspec
)) == NULL
) { return(1) ; }
104 d1
= new_node( DIM
) ; /* make a copy */
106 if ( star
) { d1
->subgrid
= 1 ; node
->subgrid
|= (1<<node
->ndims
) ; } /* Mark the node has having a subgrid dim */
107 node
->dims
[node
->ndims
++] = d1
;
116 get_4d_entry ( char * name
)
119 if ( name
== NULL
) return (NULL
) ;
120 for ( p
= FourD
; p
!= NULL
; p
= p
->next4d
)
122 if ( !strcmp( p
->name
, name
) )
131 get_type_entry ( char * typename
)
133 return(get_entry(typename
,Type
)) ;
137 get_rconfig_entry ( char * name
)
140 if ((p
=get_entry(name
,Domain
.fields
))==NULL
) return(NULL
) ;
141 if (p
->node_kind
& RCONFIG
) return(p
) ;
146 get_entry ( char * name
, node_t
* node
)
149 if ( name
== NULL
) return (NULL
) ;
150 if ( node
== NULL
) return (NULL
) ;
151 for ( p
= node
; p
!= NULL
; p
= p
->next
)
153 if ( !strcmp( name
, "character" ) )
155 if ( !strncmp( p
->name
, name
, 9 ) )
160 if ( !strcmp( p
->name
, name
) )
169 /* this gets the entry for the node even if it */
170 /* is a derived data structure; does this by following */
171 /* the fully specified f90 reference. For example: */
172 /* "xa%f" for the field of derived type xa. */
173 /* note it will also take care to ignore the _1 or _2 */
174 /* suffixes from variables that have ntl > 1 */
175 /* 11/10/2001 -- added use field; if the entry has a use */
176 /* that starts with "dyn_" and use doesn't correspond to */
177 /* that, skip that entry and continue */
180 get_entry_r ( char * name
, char * use
, node_t
* node
)
183 char tmp
[NAMELEN
], *t1
, *t2
;
185 if ( name
== NULL
) return (NULL
) ;
186 if ( node
== NULL
) return (NULL
) ;
188 for ( p
= node
; p
!= NULL
; p
= p
->next
)
190 strcpy( tmp
, name
) ;
192 /* first check for exact match */
193 if ( !strcmp( p
->name
, tmp
) )
199 if ((t1
= index(tmp
,'%'))!= NULL
) *t1
= '\0' ;
203 if (( t2
= rindex( tmp
, '_' )) != NULL
)
205 /* be sure it really is an integer that follows the _ and that */
206 /* that is that is the last character */
207 if ((*(t2
+1) >= '0' && *(t2
+1) <= '9') && *(t2
+2)=='\0') *t2
= '\0' ;
211 /* also allow _tend */
212 if (( t2
= rindex( tmp
, '_' )) != NULL
) {
213 if (!strcmp(t2
,"_tend")) *t2
= '\0' ;
216 /* also allow _tend */
217 if (( t2
= rindex( tmp
, '_' )) != NULL
) {
218 if (!strcmp(t2
,"_old")) *t2
= '\0' ;
221 if ( !strcmp( p
->name
, tmp
) )
223 if ( t1
!= NULL
) return( get_entry_r( t1
+1 , use
, p
->type
->fields
) ) ;
231 get_dimnode_for_coord ( node_t
* node
, int coord_axis
)
234 if ( node
== NULL
) return(NULL
) ;
235 for ( i
= 0 ; i
< node
->ndims
; i
++ )
237 if ( node
->dims
[i
] == NULL
) continue ;
238 if ( node
->dims
[i
]->coord_axis
== coord_axis
)
240 return(node
->dims
[i
]) ;
247 get_index_for_coord ( node_t
* node
, int coord_axis
)
250 if ( node
== NULL
) return( -1 ) ;
251 for ( i
= 0 ; i
< node
->ndims
; i
++ )
253 if ( node
->dims
[i
] == NULL
) continue ;
254 if ( node
->dims
[i
]->coord_axis
== coord_axis
)
264 set_mem_order( node_t
* node
, char * str
, int n
)
269 if ( str
== NULL
|| node
== NULL
) return(NULL
) ;
271 if ( node
->boundary_array
)
273 strcpy(str
, "C") ; /* if this is called for a boundary array, just give it a */
274 /* "reasonable" value and move on. */
278 if ( node
->ndims
<= 0 )
280 strcat(str
,"0") ; return(str
) ;
282 for ( i
= 0 ; i
< node
->ndims
&& i
< n
; i
++ )
285 switch( p
->coord_axis
)
287 case(COORD_X
) : strcat(str
,"X") ; break ;
288 case(COORD_Y
) : strcat(str
,"Y") ; break ;
289 case(COORD_Z
) : strcat(str
,"Z") ; break ;
290 case(COORD_C
) : strcat(str
,"C") ; break ;