5 # define rindex(X,Y) strrchr(X,Y)
6 # define index(X,Y) strchr(X,Y)
17 set_dim_strs_x ( node_t
*node
, char ddim
[3][2][NAMELEN
], char mdim
[3][2][NAMELEN
], char pdim
[3][2][NAMELEN
] , char * prepend
, int sw_disregard_stag
, int sw_reorder
, int sw_no_prepend_r1
)
25 if ( sw_no_prepend_r1
) {
30 if ( node
== NULL
) return(1) ;
31 for ( i
= 0 ; i
< 3 ; i
++ )
32 for ( j
= 0 ; j
< 2 ; j
++ )
34 strcpy(ddim
[i
][j
],"1") ;
35 strcpy(mdim
[i
][j
],"1") ;
36 strcpy(pdim
[i
][j
],"1") ;
39 for ( ii
= 0 ; ii
< ((node
->ndims
> 3)?3:node
->ndims
) ; ii
++ )
45 switch( p
->coord_axis
)
47 case(COORD_X
) : i
= 0 ; break ;
48 case(COORD_Y
) : i
= 2 ; break ;
49 case(COORD_Z
) : i
= 1 ; break ;
53 if ( p
->len_defined_how
== DOMAIN_STANDARD
)
56 if ( node
->proc_orient
== ALL_X_ON_PROC
) ornt
= "x" ;
57 else if ( node
->proc_orient
== ALL_Y_ON_PROC
) ornt
= "y" ;
63 switch( p
->coord_axis
)
65 case(COORD_X
) : d
= 'i' ; d1
= 'x' ; break ;
66 case(COORD_Y
) : d
= 'j' ; d1
= 'y' ; break ;
67 case(COORD_Z
) : d
= 'k' ; d1
= 'z' ; break ;
71 sprintf(ddim
[i
][0],"%s%cds",prepend
,d
) ;
72 sprintf(ddim
[i
][1],"MAX(1,%s%cde * %ssr_%c) ",prepend
,d
,r1
,d1
) ;
73 sprintf(mdim
[i
][0],"(%s%cms-1)*%ssr_%c+1",prepend
,d
,r1
,d1
) ;
74 sprintf(mdim
[i
][1],"MAX(1,%s%cme*%ssr_%c)",prepend
,d
,r1
,d1
) ;
75 sprintf(pdim
[i
][0],"(%s%cps-1)*%ssr_%c+1",prepend
,d
,r1
,d1
) ;
76 sprintf(pdim
[i
][1],"MAX(1,%s%cpe*%ssr_%c)",prepend
,d
,r1
,d1
) ;
79 if ( sw_3dvar_iry_kludge
) {
80 switch( p
->coord_axis
)
83 case(COORD_X
) : d
= 'i' ; stag
= (node
->stag_y
||sw_disregard_stag
)?"%s%cde":"(%s%cde-1)" ; break ;
84 case(COORD_Y
) : d
= 'j' ; stag
= (node
->stag_x
||sw_disregard_stag
)?"%s%cde":"(%s%cde-1)" ; break ;
86 case(COORD_Z
) : d
= 'k' ; stag
= (node
->stag_z
||sw_disregard_stag
)?"%s%cde":"(%s%cde-1)" ; break ;
87 default : stag
= "1" ; break ;
90 switch( p
->coord_axis
)
92 case(COORD_X
) : d
= 'i' ; stag
= (node
->stag_x
||sw_disregard_stag
)?"%s%cde":"(%s%cde-1)" ; break ;
93 case(COORD_Y
) : d
= 'j' ; stag
= (node
->stag_y
||sw_disregard_stag
)?"%s%cde":"(%s%cde-1)" ; break ;
94 case(COORD_Z
) : d
= 'k' ; stag
= (node
->stag_z
||sw_disregard_stag
)?"%s%cde":"(%s%cde-1)" ; break ;
95 default : stag
= "1" ; break ;
99 sprintf(ddim
[i
][0],"%s%cds",prepend
,d
) ;
100 sprintf(ddim
[i
][1],stag
,prepend
,d
) ; /* note that stag has printf format info in it */
101 sprintf(mdim
[i
][0],"%s%cms%s",prepend
,d
,ornt
) ;
102 sprintf(mdim
[i
][1],"%s%cme%s",prepend
,d
,ornt
) ;
103 sprintf(pdim
[i
][0],"%s%cps%s",prepend
,d
,ornt
) ;
104 if ( ! sw_disregard_stag
)
105 sprintf(pdim
[i
][1],"MIN( %s, %s%cpe%s )",ddim
[i
][1],prepend
,d
,ornt
) ;
107 sprintf(pdim
[i
][1],"%s%cpe%s",prepend
,d
,ornt
) ;
110 else if ( p
->len_defined_how
== NAMELIST
)
112 if ( !strcmp( p
->assoc_nl_var_s
, "1" ) )
114 sprintf(ddim
[i
][0],"1") ;
115 sprintf(mdim
[i
][0],"1") ;
116 sprintf(pdim
[i
][0],"1") ;
120 sprintf(ddim
[i
][0],"config_flags%%%s",p
->assoc_nl_var_s
) ;
121 sprintf(mdim
[i
][0],"config_flags%%%s",p
->assoc_nl_var_s
) ;
122 sprintf(pdim
[i
][0],"config_flags%%%s",p
->assoc_nl_var_s
) ;
124 sprintf(ddim
[i
][1],"config_flags%%%s",p
->assoc_nl_var_e
) ;
125 sprintf(mdim
[i
][1],"config_flags%%%s",p
->assoc_nl_var_e
) ;
126 sprintf(pdim
[i
][1],"config_flags%%%s",p
->assoc_nl_var_e
) ;
128 else if ( p
->len_defined_how
== CONSTANT
)
130 sprintf(ddim
[i
][0],"%d",p
->coord_start
) ;
131 sprintf(ddim
[i
][1],"%d",p
->coord_end
) ;
132 sprintf(mdim
[i
][0],"%d",p
->coord_start
) ;
133 sprintf(mdim
[i
][1],"%d",p
->coord_end
) ;
134 sprintf(pdim
[i
][0],"%d",p
->coord_start
) ;
135 sprintf(pdim
[i
][1],"%d",p
->coord_end
) ;
142 set_dim_strs ( node_t
*node
, char ddim
[3][2][NAMELEN
], char mdim
[3][2][NAMELEN
], char pdim
[3][2][NAMELEN
] , char * prepend
, int sw_disregard_stag
)
144 set_dim_strs_x ( node
, ddim
, mdim
, pdim
, prepend
, sw_disregard_stag
, 1, 0 ) ; /* 1 = reorder according to strg order */
145 return 0; /* SamT: bug fix: return a value */
148 /* version that doesn't permute according to index order -- always i, k, then j
149 useful for standard argument lists -- e.g. calls to interp in nesting */
151 set_dim_strs2 ( node_t
*node
, char ddim
[3][2][NAMELEN
], char mdim
[3][2][NAMELEN
], char pdim
[3][2][NAMELEN
] , char * prepend
, int sw_disregard_stag
)
153 set_dim_strs_x ( node
, ddim
, mdim
, pdim
, prepend
, sw_disregard_stag
, 0, 0 ) ; /* 0 = reorder according to strg order */
154 return 0; /* SamT: bug fix: return a value */
158 set_dim_strs3 ( node_t
*node
, char ddim
[3][2][NAMELEN
], char mdim
[3][2][NAMELEN
], char pdim
[3][2][NAMELEN
] , char * prepend
, int sw_disregard_stag
)
160 set_dim_strs_x ( node
, ddim
, mdim
, pdim
, prepend
, sw_disregard_stag
, 1, 1 ) ; /* 1 = reorder according to strg order */
161 return 0; /* SamT: bug fix: return a value */