Original WRF subgrid support version from John Michalakes without fire
[wrffire.git] / wrfv2_fire / chem / KPP / util / wkc / change_chem_Makefile.c
blobf633c797da7e932e82d059c38414fc49a4e8107d
1 #include <stdio.h>
4 #include "protos.h"
5 #include "protos_kpp.h"
6 #include "kpp_data.h"
11 int
12 change_chem_Makefile ( )
14 knode_t * p1, * p2, * pm1;
15 FILE * ch_Makefile, * t_Makefile;
16 char inln[4096];
17 char kname[NAMELEN];
18 char * org_Mf = "chem/Makefile_org";
19 char * t_Mf = "chem/Makefile.temp";
20 char * Mf = "chem/Makefile";
21 char cp_command[NAMELEN];
26 ch_Makefile = fopen(org_Mf, "r" );
27 t_Makefile = fopen(t_Mf, "w" );
30 sprintf( cp_command,"cp %s %s",t_Mf,Mf);
32 fprintf(t_Makefile,"# \n");
33 fprintf(t_Makefile,"# MANUAL CHANGES TO THIS FILE WILL BE LOST \n");
34 fprintf(t_Makefile,"# ... EDIT Makefile_org INSTEAD ...\n");
35 fprintf(t_Makefile,"# this file was written by gen_kpp.c \n\n");
39 /* loop over lines in chem/Makefile */
40 while ( fgets ( inln , 4096 , ch_Makefile ) != NULL ){
43 /* printf("%s ", inln ); */
44 fprintf(t_Makefile, inln);
49 /* if ( strncmp(inln, "MODULES",6) == 0){ */
51 if ( strncmp(inln, " module_data_sorgam",19) == 0){
54 for ( p1 = KPP_packs ; p1 != NULL ; p1 = p1->next ) {
55 p2 = p1->assoc_wrf_pack;
56 if ( p2 ) {
58 strcpy( kname, p1->name );
59 fprintf(t_Makefile, " module_kpp_%s_Integr.o \\\n",kname );
60 fprintf(t_Makefile, " module_kpp_%s_Precision.o \\\n",kname );
61 fprintf(t_Makefile, " module_kpp_%s_Parameters.o \\\n",kname );
62 fprintf(t_Makefile, " module_kpp_%s_Jacobian.o \\\n",kname );
63 fprintf(t_Makefile, " module_kpp_%s_JacobianSP.o \\\n",kname );
64 fprintf(t_Makefile, " module_kpp_%s_Update_Rconst.o \\\n",kname );
65 fprintf(t_Makefile, " module_kpp_%s_interface.o \\\n",kname );
68 fprintf(t_Makefile, " module_wkppc_constants.o \\\n");
71 if ( strncmp(inln, "# DEPENDENCIES",14) == 0){
74 for ( p1 = KPP_packs ; p1 != NULL ; p1 = p1->next ) {
76 p2 = p1->assoc_wrf_pack;
78 if ( p2 ) {
81 strcpy( kname, p1->name );
83 fprintf(t_Makefile, "module_kpp_%s_Jacobian.o: module_kpp_%s_JacobianSP.o \n\n",kname, kname );
85 fprintf(t_Makefile, "module_kpp_%s_Parameters.o: module_kpp_%s_Precision.o \n\n",kname, kname );
87 fprintf(t_Makefile, "module_kpp_%s_Integr.o: module_kpp_%s_Parameters.o module_kpp_%s_Jacobian.o module_kpp_%s_JacobianSP.o module_kpp_%s_Update_Rconst.o module_wkppc_constants.o \n\n",kname, kname, kname, kname, kname );
93 fprintf(t_Makefile, "module_wkkpc_constants.o:\n\n");
94 fprintf(t_Makefile, "module_kpp_%s_interface.o:\n\n");
99 if ( strncmp(inln, "OBJS",3) == 0){
100 fprintf(t_Makefile, "\tkpp_mechanism_driver.o \\\n");
107 fclose( t_Makefile );
108 fclose( ch_Makefile );
111 system(cp_command);