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