16 gen_scalar_derefs ( char * dirname
)
18 scalar_derefs ( dirname
) ;
22 #define DIR_COPY_OUT 1
26 scalar_derefs ( char * dirname
)
30 char * fn
= "scalar_derefs.inc" ;
33 /* Had to increase size for SOA from 64*4096 to 64*7000, Manish Shrivastava 2010 */
34 char outstr
[64*7000] ;
36 if ( dirname
== NULL
) return(1) ;
37 if ( strlen(dirname
) > 0 )
38 { sprintf(fname
,"%s/%s",dirname
,fn
) ; }
40 { sprintf(fname
,"%s",fn
) ; }
42 if ((fp
= fopen( fname
, "w" )) == NULL
) return(1) ;
43 print_warning(fp
,fname
) ;
44 fprintf(fp
,"! BEGIN SCALAR DEREFS\n") ;
46 if ( sw_limit_args
) {
47 fprintf(fp
,"#undef CPY\n") ;
48 fprintf(fp
,"#undef CPYC\n") ;
49 fprintf(fp
,"#ifdef COPY_OUT\n") ;
50 scalar_derefs1 ( fp
, &Domain
, DIR_COPY_OUT
) ;
51 fprintf(fp
,"#else\n") ;
52 scalar_derefs1 ( fp
, &Domain
, DIR_COPY_IN
) ;
53 fprintf(fp
,"#endif\n") ;
55 fprintf(fp
,"! END SCALAR DEREFS\n") ;
56 close_the_file( fp
) ;
61 scalar_derefs1 ( FILE * fp
, node_t
* node
, int direction
)
67 if ( node
== NULL
) return(1) ;
68 for ( p
= node
->fields
; p
!= NULL
; p
= p
->next
)
70 if ( p
->node_kind
& I1
) continue ; /* short circuit any field that is not state */
71 /* short circuit DERIVED types */
72 if ( p
->type
->type_type
== DERIVED
) continue ;
73 /* short circuit non-scalars */
74 if ( p
->ndims
> 0 ) continue ;
77 (p
->node_kind
& FIELD
)
78 /* it is not a derived type -ajb */
79 || (p
->node_kind
& FIELD
&& (p
->type
->type_type
!= DERIVED
) )
83 for ( tag
= 1 ; tag
<= p
->ntl
; tag
++ )
85 strcpy(fname
,field_name(t4
,p
,(p
->ntl
>1)?tag
:0)) ;
87 if ( direction
== DIR_COPY_OUT
) {
88 fprintf(fp
, " grid%%%s = %s\n",fname
,fname
) ;
90 fprintf(fp
, " %s = grid%%%s\n",fname
,fname
) ;