5 #include "protos_kpp.h"
12 change_chem_Makefile ( )
14 knode_t
* p1
, * p2
, * pm1
;
15 FILE * ch_Makefile
, * t_Makefile
;
18 char * org_Mf
= "chem/Makefile_org";
19 char * t_Mf
= "chem/Makefile.temp";
20 char * Mf
= "chem/Makefile";
21 char cp_command
[NAMELEN
];
22 char sub_string
[NAMELEN
];
31 ch_Makefile
= fopen(org_Mf
, "r" );
32 t_Makefile
= fopen(t_Mf
, "w" );
35 sprintf( cp_command
,"cp %s %s",t_Mf
,Mf
);
37 fprintf(t_Makefile
,"# \n");
38 fprintf(t_Makefile
,"# MANUAL CHANGES TO THIS FILE WILL BE LOST \n");
39 fprintf(t_Makefile
,"# ... EDIT Makefile_org INSTEAD ...\n");
40 fprintf(t_Makefile
,"# this file was written by gen_kpp.c \n\n");
44 /* loop over lines in chem/Makefile */
45 while ( fgets ( inln
, NAMELEN
, ch_Makefile
) != NULL
){
47 /* printf("%s ", inln ); */
48 fprintf(t_Makefile
, inln
);
50 /* if ( strncmp(inln, "MODULES",6) == 0){ */
52 if ( strncmp(inln
, " module_data_sorgam_vbs",29) == 0){
54 for ( p1
= KPP_packs
; p1
!= NULL
; p1
= p1
->next
) {
55 p2
= p1
->assoc_wrf_pack
;
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){
73 for ( p1
= KPP_packs
; p1
!= NULL
; p1
= p1
->next
,nchem_opts
++ ) {
75 p2
= p1
->assoc_wrf_pack
;
79 strcpy( kname
, p1
->name
);
81 fprintf(t_Makefile
, "module_kpp_%s_Parameters.o: module_kpp_%s_Precision.o \n\n",kname
, kname
);
82 fprintf(t_Makefile
, "module_kpp_%s_Update_Rconst.o: module_kpp_%s_Parameters.o \n\n",kname
, kname
);
83 fprintf(t_Makefile
, "module_kpp_%s_Jacobian.o: module_kpp_%s_Parameters.o module_kpp_%s_JacobianSP.o \n\n",kname
, kname
, kname
);
84 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
);
85 fprintf(t_Makefile
, "module_kpp_%s_interface.o: module_kpp_%s_Parameters.o module_kpp_%s_Precision.o module_kpp_%s_Integr.o module_kpp_%s_Update_Rconst.o module_wkppc_constants.o \n\n",kname
, kname
, kname
, kname
, kname
);
91 fprintf(t_Makefile
, "module_wkkpc_constants.o:\n\n");
93 p_string
= sub_string
;
95 sprintf( sub_string
,"kpp_mechanism_driver.o: " );
96 for ( p1
= KPP_packs
; p1
!= NULL
; p1
= p1
->next
) {
97 p2
= p1
->assoc_wrf_pack
;
100 strcpy( kname
, p1
->name
);
101 slen
= strlen( sub_string
);
102 sprintf( p_string
+slen
,"module_kpp_%s_interface.o ",kname
);
103 slen
= strlen( sub_string
);
105 if( chem_opts_cnt
< nchem_opts
) sprintf( p_string
+slen
,"\\");
106 fprintf(t_Makefile
, "%s\n", sub_string
);
107 sprintf( sub_string
,"\t" );
111 slen
= strlen( sub_string
);
112 if( slen
> 1 ) fprintf(t_Makefile
, "%s\n\n", sub_string
);
115 if ( strncmp(inln
, "OBJS",3) == 0){
116 fprintf(t_Makefile
, "\tkpp_mechanism_driver.o \\\n");
123 fclose( t_Makefile
);
124 fclose( ch_Makefile
);