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