4 main( int argc
, char *argv
[] )
9 char wrf_error_fatal_str
[256] ;
10 char surface_driver_str
[256] ;
11 char radiation_driver_str
[256] ;
12 char cumulus_driver_str
[256] ;
13 char pbl_driver_str
[256] ;
22 fprintf(stderr
,"usage: %s file\n",argv
[0]) ;
24 if ((fp
= fopen(argv
[1],"r"))==NULL
) {
25 fprintf(stderr
,"cannot open %s for reading\n",argv
[1]) ;
28 while ( fgets( linei
, 2048, fp
) != NULL
) {
30 if ( linei
[0] != '#' ) drop_comment( linei
) ;
32 for ( p
= linei
, q
= lineo
, firstp
= *p
; *p
; p
++ ) {
33 if ( !inacall
&& (*(p
+0) == 'c' || *(p
+0) == 'C' ) &&
34 (*(p
+1) == 'a' || *(p
+1) == 'A' ) &&
35 (*(p
+2) == 'l' || *(p
+2) == 'L' ) &&
36 (*(p
+3) == 'l' || *(p
+3) == 'L' ) && firstp
!= '#' )
39 strncpy(q
,p
,4) ; q
+=4 ;
40 ns
= 1 ; while ( *(p
+3+ns
) && *(p
+3+ns
) != '\n' &&
42 *(p
+3+ns
) == '\t' )) { *q
++ = *(p
+3+ns
) ; ns
++ ; }
44 strncpy(wrf_error_fatal_str
, p
+3+ns
,15+1) ; change_to_lower(wrf_error_fatal_str
,15+1 ) ; /* 15, but add one to check for '3' */
45 strncpy(surface_driver_str
, p
+3+ns
,14) ; change_to_lower(surface_driver_str
,14) ;
46 strncpy(radiation_driver_str
, p
+3+ns
,16) ; change_to_lower(radiation_driver_str
,16) ;
47 strncpy(cumulus_driver_str
, p
+3+ns
,14) ; change_to_lower(cumulus_driver_str
,14) ;
48 strncpy(pbl_driver_str
, p
+3+ns
,10) ; change_to_lower(pbl_driver_str
,10) ;
50 if ( !strncmp( wrf_error_fatal_str
, "wrf_error_fatal", 15 ) && wrf_error_fatal_str
[15] != '3' )
52 ns2
= 1 ; while ( *(p
+3+ns
+14+ns2
) && *(p
+3+ns
+14+ns2
) != '\n' &&
53 (*(p
+3+ns
+14+ns2
) == ' ' ) ) ns2
++ ;
54 if ( *(p
+3+ns
+14+ns2
) == '(' ) {
57 printf("wrf_error_fatal3(__FILE__,__LINE__,&\n") ;
58 ns2
= 1 ; while ( *(p
+3+ns
+14+ns2
) && *(p
+3+ns
+14+ns2
) != '\n' &&
59 (*(p
+3+ns
+14+ns2
) == ' ' ||
60 *(p
+3+ns
+14+ns2
) == '(' ||
61 *(p
+3+ns
+14+ns2
) == '\t' ||
62 *(p
+3+ns
+14+ns2
) == '&' )) ns2
++ ;
63 if( *(p
+3+ns
+14+ns2
) != '\n') printf("%s",(p
+3+ns
+14+ns2
)) ;
69 } else if ( !strncmp ( surface_driver_str
, "surface_driver", 14 ) ||
70 !strncmp ( radiation_driver_str
, "radiation_driver", 16) ||
71 !strncmp ( cumulus_driver_str
, "cumulus_driver", 14) ||
72 !strncmp ( pbl_driver_str
, "pbl_driver", 10)
74 strcpy(lineo
,p
+3+ns
) ;
76 while ( fgets( linei
, 2048, fp
) != NULL
) {
77 for ( q
= linei
; *q
; q
++ ) {
78 if (*q
=='!') { *q
= '\n' ; *(q
+1) = '\0' ; break ; }
80 for ( q
= linei
; *q
; q
++ ) {
81 if ( *q
== '(' ) inparen
++ ;
82 else if ( *q
== ')' ) inparen
-- ;
89 for(q
=lineo
,r
=lineo
;*q
;q
++) {
90 if (*q
== '#' && *(q
-1) == '\n') { /* CPP def. copy as is*/
95 if ( *q
== '\n' ) break ;
98 if ( *q
== ' ' || *q
== '\n' || *q
== '&' ) continue ;
103 for(q
=lineo
,col
=130-5;*q
;q
++) {
105 if ( *q
== '\n' ) { if (*(q
+1) != '#') { putchar('&') ; } ; col
= 131 ; }
109 putchar('&') ; putchar('\n') ; putchar('&') ;
131 drop_comment( char * linei
)
134 char inquote
= '\0' ;
136 for ( p
= linei
; *p
; p
++ )
138 if ( *p
== '\'' ) { if ( inquote
== *p
) { inquote
= '\0' ; } else { inquote
= *p
; } }
139 if ( *p
== '"' ) { if ( inquote
== *p
) { inquote
= '\0' ; } else { inquote
= *p
; } }
140 if ( !inquote
&& *p
== '!' ) {
141 /* let us make sure this is not an OMP directive shall we? */
142 for ( q
= p
; *q
; q
++ ) {
144 (*(q
+1) == 'o' || *(q
+1) == 'O') &&
145 (*(q
+2) == 'm' || *(q
+2) == 'M') &&
146 (*(q
+3) == 'p' || *(q
+3) == 'P') ) return(0) ;
148 *p
= '\n' ; *(p
+1) = '\0' ; return(0) ;
154 change_to_lower( char * s
, int n
)
157 for ( i
= 0 ; i
< n
; i
++ )
159 if ( s
[i
] >= 'A' && s
[i
] <= 'Z' ) s
[i
] = s
[i
] - 'A' + 'a' ;