ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/freemol/trunk/src/mengine/src/mengine.c
Revision: 119
Committed: Tue Jun 16 21:36:00 2009 UTC (11 years, 10 months ago) by wdelano
File size: 4966 byte(s)
Log Message:
printf( to fprintf(pcmlogfile,
Line File contents
1 /* NOTICE: this source code file has been modified for use with FreeMOL */
2
3 #define notKEG_DEBUG
4
5 #define EXTERN
6 #include "pcwin.h"
7 #include "pcmod.h"
8 #include "angles.h"
9 #include "attached.h"
10 #include "torsions.h"
11 #include "nonbond.h"
12 #include "bonds_ff.h"
13 #include "derivs.h"
14 #include "hess.h"
15 #include "atom_k.h"
16 #include "cutoffs.h"
17 #include "fix.h"
18 #include "vibrate.h"
19 #include "job_control.h"
20
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <unistd.h>
24 #include <string.h>
25 #include <time.h>
26 //#include <malloc.h>
27
28 struct t_minim_values {
29 int iprint, ndc, nconst;
30 float dielc;
31 } minim_values;
32
33 struct t_minim_control {
34 int type, method, field, added_const;
35 char added_path[256],added_name[256];
36 } minim_control;
37 EXTERN struct t_files {
38 int nfiles, append, batch, icurrent, ibatno;
39 } files;
40 char Savename[80];
41
42 /*
43 void initialize_pcmodel(char*);
44 void mmp22mod(int,int);
45 void pcmfin(int, int);
46 void initialize(void);
47 void mmxsub(int);
48 void check_numfile(int, char *);
49 void mac2mod(int, int);
50 void bbchk(void);
51 void type(void);
52 void initialize_gmmx(void);
53 void read_gmmxinp(char*, char*, char*, FILE*, int);
54 void run_gmmx(void);
55 void search_rings(int);
56 */
57
58
59 void usage(void) {
60 fprintf(stderr,"\nUsage: mengine [-hvdxi] reads sdf on stdin, writes on stdout\n\n"
61 "-h\tThis help page\n"
62 "-v\tVerbose output\n"
63 "-a\tAdd hydrogen atoms; delete existing ones\n"
64 "-d\tEvaluate dipole moment\n"
65 "-x\tEvaluate XlogP\n"
66 "-i\tEvaluate vibrational data\n\n");
67 }
68
69 /* ==================================================== */
70 int main(int argc, char *argv[])
71 {
72 int i;
73 FILE *infile;
74 char *line = NULL;
75
76 char *infilename = NULL;
77 char *outfilename = NULL;
78 char *mmff94filename = NULL;
79 char *mmxfilename = NULL;
80 char *logfilename = NULL;
81
82 int c;
83 int flags = 0;
84 clock_t start_time,end_time;
85
86 while ((c = getopt(argc, argv, "e:o:p:c:havdxi")) != -1) {
87 switch(c) {
88 case 'a':
89 flags = flags | DO_ADDH;
90 break;
91 case 'd':
92 flags = flags | DO_DIPOLE;
93 break;
94 case 'x':
95 flags = flags | DO_XLOGP;
96 break;
97 case 'i':
98 flags = flags | DO_VIBRATION;
99 break;
100 case 'v':
101 VERBOSE = 1;
102 break;
103 case 'h':
104 usage();
105 exit(-1);
106 case 'o':
107 outfilename = strdup(optarg);
108 break;
109 #if 0
110 // EXTERNAL PARAM FILES STILL NOT WORKING
111 // SOON THEY WILL
112 case 'p':
113 mmff94filename = strdup(optarg);
114 break;
115 case 'c':
116 mmxfilename = strdup(optarg);
117 break;
118 #endif
119 case 'e':
120 logfilename = strdup(optarg);
121 break;
122 case '?':
123 if (isprint (optopt))
124 fprintf (stderr, "Unknown option `-%c'.\n", optopt);
125 else
126 fprintf (stderr,
127 "Unknown option character `\\x%x'.\n",
128 optopt);
129 return 1;
130 default:
131 abort ();
132 }
133 }
134
135 argc -= optind;
136 argv += optind;
137
138 if (argc == 1)
139 infilename = strdup(argv[0]);
140
141 #ifdef KEG_DEBUG
142 if(!infilename)
143 infilename = strdup("aromatic.sdf");
144 if(!outfilename)
145 outfilename = strdup("output.sdf");
146 #endif
147
148 /* default behavior is to use the hardcoded parameter files */
149
150 if(!mmff94filename) mmff94filename = strdup("|mmff94"); /* hard-coded builtins */
151 if(!mmxfilename) mmxfilename = strdup("|mmxconst"); /* hard-coded builtins */
152
153 /* if no input file provide, then use standard input */
154
155 if(infilename) {
156 infile = fopen(infilename,"rb");
157 } else {
158 infile = stdin;
159 }
160
161 /* if no output file provided, then use standard output */
162
163 if(outfilename) {
164 pcmoutfile = fopen(outfilename,"wb");
165 } else {
166 pcmoutfile = stdout;
167 }
168
169 /* if no log file provided, then use standard error */
170
171 if(logfilename) {
172 pcmlogfile = fopen(logfilename,"wb");
173 } else {
174 pcmlogfile = stderr;
175 }
176
177 /* initialize the system using parameter file */
178
179 initialize_pcmodel(mmxfilename);
180 initialize();
181 minim_values.iprint = 0; //FALSE;
182 /* run the job */
183
184 #ifdef KEG_DEBUG
185 start_time = clock();
186 #endif
187 if (infile) {
188 read_gmmxinp(mmff94filename, infile, flags);
189 }
190 #ifdef KEG_DEBUG
191 end_time = clock();
192 fprintf(pcmlogfile,"Job time: %lu ticks\n",(end_time - start_time));
193 #endif
194 /* release temporary strings */
195
196 if(infilename) free(infilename);
197 if(outfilename) free(outfilename);
198 if(mmff94filename) free(mmff94filename);
199 if(mmxfilename) free(mmxfilename);
200 if(logfilename) free(logfilename);
201
202 /* close file handles */
203
204 if(infile && (infile!=stdin)) fclose(infile);
205 if(pcmoutfile && (pcmoutfile!=stdout)) fclose(pcmoutfile);
206 if(pcmlogfile && (pcmlogfile!=stderr)) fclose(pcmlogfile);
207
208 exit(0);
209 }