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