updated top-level README and version_decl for V4.5 (#1847)
[WRF.git] / chem / KPP / util / write_decomp / integr_edit.c
blob756e04d135fc0cdaddc175e491b4f87560a38955
1 #include <stdio.h>
2 #include <stdlib.h>
4 #define NAMELEN 4096
7 /* replace decomp routine in KPP Integr file */
10 main( int argc, char *argv[] )
13 char mechname[NAMELEN];
14 char intfname[NAMELEN], incfname[NAMELEN], tfname[NAMELEN];
15 char inln[NAMELEN], incln[NAMELEN];
16 char callln[NAMELEN], endln[NAMELEN] ;
17 char cp_command[NAMELEN];
19 int copyit, add_sub;
21 FILE * intf;
22 FILE * incf;
23 FILE * ofile;
26 argv++ ;
28 if ( *argv )
30 strcpy( mechname, *argv );
32 else
34 printf("ERROR: USAGE: integr_edit mech_name\n");
35 exit(11);
38 sprintf ( intfname, "module_kpp_%s_Integr.F", mechname);
39 sprintf ( incfname, "decomp_%s.inc", mechname);
40 sprintf ( tfname, "%s_new", intfname );
44 sprintf( cp_command,"cp %s %s",tfname, intfname);
46 intf = fopen( intfname , "r" );
47 incf = fopen( incfname , "r" );
48 ofile = fopen( tfname , "w" );
52 sprintf ( callln , " CALL %s_KppDecomp\0", mechname );
53 sprintf ( endln , "END MODULE");
55 /* loop over lines in Integr file */
56 while ( fgets ( inln , 4096 , intf ) != NULL ){
58 copyit=1;
61 /* replace call to decomp routine */
63 if ( !strncmp (inln, callln, strlen(callln)-1) ) {
65 printf(" integr_edit: replacing %s \n", inln);
67 fprintf(ofile, "!!! use direct adressing in decomp \n");
68 fprintf(ofile, "!!! %s", inln);
69 fprintf(ofile, "CALL decomp_%s ( A, ising )\n", mechname );
72 add_sub=1;
73 copyit=0;
77 /* add decomp routine w. direct referncing */
79 if ( !strncmp (inln, endln, strlen(endln)-1) ) {
81 if ( add_sub ){
82 printf(" %s ", inln );
83 while ( fgets ( incln , 4096 , incf ) != NULL ){
85 fprintf(ofile, "%s", incln);
89 fprintf(ofile, " \n\n\n");
96 /* copy line from original file */
97 if ( copyit ) {
99 fprintf(ofile, "%s", inln);
107 if ( ! add_sub ) {
108 printf(" integr_edit: Kept previous version. \n ");
113 fclose( intf );
114 fclose( incf );
115 fclose( ofile );
118 system(cp_command);
120 exit (0);