~ubuntu-branches/ubuntu/karmic/psicode/karmic

« back to all changes in this revision

Viewing changes to src/bin/cints/parsing.cc

  • Committer: Bazaar Package Importer
  • Author(s): Michael Banck, Michael Banck, Daniel Leidert
  • Date: 2009-02-23 00:12:02 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090223001202-rutldoy3dimfpesc
Tags: 3.4.0-1
* New upstream release.

[ Michael Banck ]
* debian/patches/01_DESTDIR.dpatch: Refreshed.
* debian/patches/02_FHS.dpatch: Removed, applied upstream.
* debian/patches/03_debian_docdir: Likewise.
* debian/patches/04_man.dpatch: Likewise.
* debian/patches/06_466828_fix_gcc_43_ftbfs.dpatch: Likewise.
* debian/patches/07_464867_move_executables: Fixed and refreshed.
* debian/patches/00list: Adjusted.
* debian/control: Improved description.
* debian/patches-held: Removed.
* debian/rules (install/psi3): Do not ship the ruby bindings for now.

[ Daniel Leidert ]
* debian/rules: Fix txtdir via DEB_MAKE_INSTALL_TARGET.
* debian/patches/01_DESTDIR.dpatch: Refreshed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*! \file
 
2
    \ingroup CINTS
 
3
    \brief Parse the input file and command line for CINTS specific options.
 
4
*/
 
5
#include<cstdio>
 
6
#include<cstdlib>
 
7
#include<cstring>
 
8
#include<cmath>
 
9
#include<vector>
 
10
#include<libipv1/ip_lib.h>
 
11
#include<libint/libint.h>
 
12
#include<libciomr/libciomr.h>
 
13
#include <psifiles.h>
 
14
 
 
15
#include"defines.h"
 
16
#define EXTERN
 
17
#include"global.h"
 
18
#include <stdexcept>
 
19
#ifdef INCLUDE_Fock
 
20
 #include"scf_parsing.h"
 
21
#endif
 
22
 
 
23
namespace psi { namespace CINTS {
 
24
  //! Main parsing routine for input.
 
25
  void parsing()
 
26
  {
 
27
    int errcod;
 
28
    int cutoff_exp;
 
29
    long int max_bytes;
 
30
  
 
31
    UserOptions.print_lvl = 1;
 
32
    errcod = ip_data("PRINT","%d",&(UserOptions.print_lvl),0);
 
33
    
 
34
    /*--- This piece of code from CPHF by Ed Seidl ---*/
 
35
    if (ip_exist("MEMORY", 0)) {
 
36
      fndcor(&max_bytes, infile, outfile);
 
37
      UserOptions.max_memory = max_bytes / sizeof(double);
 
38
    }
 
39
    else
 
40
      UserOptions.max_memory = MAX_NUM_DOUBLES;
 
41
    UserOptions.memory = UserOptions.max_memory;
 
42
    
 
43
    cutoff_exp = CUTOFF;
 
44
    errcod = ip_data("CUTOFF","%d",&cutoff_exp,0);
 
45
    UserOptions.cutoff = 1.0/pow(10.0,(double)cutoff_exp);
 
46
 
 
47
    UserOptions.fine_structure_alpha = 1.0;
 
48
    errcod = ip_data("FINE_STRUCTURE_ALPHA","%lf",&(UserOptions.fine_structure_alpha),0);
 
49
 
 
50
    UserOptions.make_oei = 1;
 
51
    UserOptions.make_fock = 0;
 
52
    UserOptions.make_eri = 1;
 
53
    UserOptions.symm_ints = 1;
 
54
    errcod = ip_boolean("MAKE_ERI",&(UserOptions.make_eri),0);
 
55
    
 
56
    errcod = ip_data("S_FILE","%d",&(IOUnits.itapS),0);
 
57
    errcod = ip_data("T_FILE","%d",&(IOUnits.itapT),0);
 
58
    errcod = ip_data("V_FILE","%d",&(IOUnits.itapV),0);
 
59
    if (UserOptions.make_eri)
 
60
      errcod = ip_data("ERI_FILE","%d",&(IOUnits.itap33),0);
 
61
    
 
62
    UserOptions.empirical_dispersion = 0;
 
63
    errcod = ip_boolean("EMPIRICAL_DISPERSION", 
 
64
      &UserOptions.empirical_dispersion, 0);
 
65
    
 
66
    UserOptions.scf_only = 0;
 
67
    errcod = ip_string("WFN",&UserOptions.wfn,0);
 
68
    if (UserOptions.wfn == NULL)
 
69
      throw std::domain_error("Keyword WFN is missing");
 
70
    if ((!strcmp("SCF",UserOptions.wfn)) || 
 
71
        (!strcmp("SCF_MVD",UserOptions.wfn)))
 
72
      UserOptions.scf_only = 1;
 
73
    
 
74
    UserOptions.num_threads = 1;
 
75
    errcod = ip_data("NUM_THREADS","%d",&(UserOptions.num_threads),0);
 
76
    if (UserOptions.num_threads < 1)
 
77
      UserOptions.num_threads = 1;
 
78
    
 
79
    UserOptions.restart = 0;
 
80
    errcod = ip_boolean("RESTART",&UserOptions.restart,0);
 
81
    if (UserOptions.restart) {
 
82
      errcod = ip_data("RESTART_TASK","%d",&UserOptions.restart_task,0);
 
83
      if (UserOptions.restart_task < 0)
 
84
        throw std::domain_error("RESTART_TASK < 0");
 
85
    }
 
86
    
 
87
    std::vector<double> temp(3);
 
88
    errcod = ip_double_array("ORIGIN", &temp[0], 3);
 
89
    if(errcod == IPE_OK) {
 
90
      UserOptions.origin.x = temp[0];
 
91
      UserOptions.origin.y = temp[1];
 
92
      UserOptions.origin.z = temp[2];
 
93
    }
 
94
    else {
 
95
      UserOptions.origin.x = 0;
 
96
      UserOptions.origin.y = 0;
 
97
      UserOptions.origin.z = 0;
 
98
    }
 
99
    UserOptions.origin.Z_nuc = 0;
 
100
 
 
101
    UserOptions.E_given = false;
 
102
    if (ip_exist("EFIELD",0)) {
 
103
      UserOptions.E_given = true;
 
104
      errcod = ip_double_array("EFIELD", UserOptions.E, 3);
 
105
      if(errcod != IPE_OK)
 
106
        throw std::runtime_error("Could not read EFIELD");
 
107
      else {
 
108
        // if the field is specified also need to query the frame        
 
109
        char* frame;
 
110
        errcod = ip_string("EFIELD_FRAME",&frame,0);
 
111
        if (errcod == IPE_OK) {
 
112
          if (!strcmp(frame,"CANONICAL"))
 
113
            UserOptions.E_frame = canonical;
 
114
          else if (!strcmp(frame,"REFERENCE"))
 
115
            UserOptions.E_frame = reference;
 
116
          else
 
117
            throw std::invalid_argument("Invalid value for keyword EFIELD_FRAME");
 
118
          free(frame);
 
119
        }
 
120
        else {
 
121
          UserOptions.E_frame = canonical;
 
122
        }
 
123
        
 
124
      }
 
125
    }
 
126
 
 
127
    return;
 
128
    
 
129
  }
 
130
  
 
131
  //! Parses the command line for options.
 
132
  void parsing_cmdline(int argc, char *argv[])
 
133
  {
 
134
    int i, errcod;
 
135
    char *refstring;
 
136
    
 
137
    for (i=1; i<argc; i++) {
 
138
      
 
139
      /*--- build Fock option ---*/
 
140
      if (strcmp(argv[i], "--fock") == 0) {
 
141
#ifdef INCLUDE_Fock
 
142
        scf_parsing();
 
143
        /*UserOptions.make_oei = 0;
 
144
          UserOptions.make_eri = 0;
 
145
          UserOptions.make_fock = 1;
 
146
          UserOptions.print_lvl = 0;
 
147
          UserOptions.symm_ints = 0;
 
148
          UserOptions.make_dft = 0;
 
149
          errcod = ip_string("REFERENCE",&refstring,0);
 
150
          if (errcod != IPE_OK)
 
151
          throw std::domain_error("REFERENCE keyword is missing");
 
152
          else if (!strcmp(refstring,"RHF") || !strcmp(refstring,""))
 
153
          UserOptions.reftype = rhf;
 
154
          else if (!strcmp(refstring,"ROHF"))
 
155
          UserOptions.reftype = rohf;
 
156
          else if (!strcmp(refstring,"UHF"))
 
157
          UserOptions.reftype = uhf;
 
158
          else if (!strcmp(refstring,"RKS")){
 
159
          UserOptions.reftype = rhf;
 
160
          UserOptions.make_dft = 1;
 
161
          }
 
162
          else if (!strcmp(refstring,"UKS")){
 
163
          UserOptions.reftype = uhf;
 
164
          UserOptions.make_dft = 1;
 
165
          }
 
166
          else
 
167
          throw std::domain_error("The specified REFERENCE not implemented");*/
 
168
#else
 
169
        throw std::domain_error("--fock option is not supported by your CINTS executable.\nRecompile the code including files in Fock subdirectory.");
 
170
#endif
 
171
        return;
 
172
      }
 
173
      
 
174
      /*--- build oeints option ---*/
 
175
      if (strcmp(argv[i], "--oeints") == 0) {
 
176
#ifdef INCLUDE_Default_Ints
 
177
        UserOptions.make_oei = 1;
 
178
        UserOptions.make_eri = 0;
 
179
        UserOptions.make_fock = 0;
 
180
        UserOptions.print_lvl = 0;
 
181
        UserOptions.symm_ints = 1;
 
182
        UserOptions.num_threads = 1;
 
183
#else
 
184
        throw std::domain_error("--oeints option is not supported by your CINTS executable.\nRecompile the code including files in Default_Ints subdirectory.");
 
185
#endif
 
186
        return;
 
187
      }
 
188
      
 
189
      /*--- build ERIs option ---*/
 
190
      if (strcmp(argv[i], "--teints") == 0) {
 
191
#ifdef INCLUDE_Default_Ints
 
192
        UserOptions.make_oei = 0;
 
193
        UserOptions.make_eri = 1;
 
194
        UserOptions.make_fock = 0;
 
195
        UserOptions.print_lvl = 0;
 
196
        UserOptions.symm_ints = 1;
 
197
        UserOptions.num_threads = 1;
 
198
#else
 
199
        throw std::domain_error("--teints option is not supported by your CINTS executable.\nRecompile the code including files in Default_Ints subdirectory.");
 
200
#endif
 
201
        return;
 
202
      }
 
203
      
 
204
      /*--- compute 1st derivatives option ---*/
 
205
      if (strcmp(argv[i], "--deriv1") == 0) {
 
206
#ifdef INCLUDE_Default_Deriv1
 
207
        UserOptions.make_oei = 0;
 
208
        UserOptions.make_eri = 0;
 
209
        UserOptions.make_fock = 0;
 
210
        UserOptions.make_deriv1 = 1;
 
211
        UserOptions.make_deriv1_mvd = 0;
 
212
        if (!strcmp("SCF_MVD",UserOptions.wfn))
 
213
          UserOptions.make_deriv1_mvd = 1;
 
214
        UserOptions.symm_ints = 0;
 
215
        UserOptions.dertype = strdup("FIRST");
 
216
        if (!strcmp("SCF",UserOptions.wfn)) {
 
217
          errcod = ip_string("REFERENCE",&refstring,0);
 
218
          if (errcod != IPE_OK)
 
219
            throw std::domain_error("REFERENCE keyword is missing");
 
220
          else if (!strcmp(refstring,"RHF") || !strcmp(refstring,""))
 
221
            UserOptions.reftype = rhf;
 
222
          else if (!strcmp(refstring,"ROHF"))
 
223
            UserOptions.reftype = rohf;
 
224
          else if (!strcmp(refstring,"UHF"))
 
225
            UserOptions.reftype = uhf;
 
226
          else if (!strcmp(refstring,"TWOCON"))
 
227
            UserOptions.reftype = twocon;
 
228
          else
 
229
            throw std::domain_error("SCF gradients with specified REFERENCE not implemented");
 
230
        }
 
231
    if (!strcmp("SCF_MVD",UserOptions.wfn)) {
 
232
          if (UserOptions.reftype != rhf)
 
233
            throw std::domain_error("SCF_MVD gradients with specified REFERENCE not implemented");
 
234
    }
 
235
        if ((strcmp("SCF",UserOptions.wfn)) && (strcmp("SCF_MVD",UserOptions.wfn))) 
 
236
          UserOptions.num_threads = 1;
 
237
#else
 
238
        throw std::domain_error("--deriv1 option is not supported by your CINTS executable.\nRecompile the code including files in Default_Deriv1 subdirectory.");
 
239
#endif
 
240
        return;
 
241
      }
 
242
      
 
243
      /*--- compute 1st derivative integrals option ---*/
 
244
      if (strcmp(argv[i], "--deriv1_ints") == 0) {
 
245
#ifdef INCLUDE_Default_Deriv1
 
246
        UserOptions.make_oei = 0;
 
247
        UserOptions.make_eri = 0;
 
248
        UserOptions.make_fock = 0;
 
249
        UserOptions.symm_ints = 1;
 
250
        UserOptions.make_deriv1 = 1;
 
251
        UserOptions.num_threads = 1;
 
252
        UserOptions.make_mkpt2_ints = 0;
 
253
#else
 
254
        throw std::domain_error("--deriv1_ints option is not supported by your CINTS executable.\nRecompile the code including files in Default_Deriv1 subdirectory.");
 
255
#endif
 
256
        return;
 
257
      }
 
258
      
 
259
      /*--- compute 2nd derivatives ---*/
 
260
      if(!strcmp(argv[i], "--deriv2")) {
 
261
#ifdef INCLUDE_Default_Deriv2
 
262
        UserOptions.make_oei = 0;
 
263
        UserOptions.make_eri = 0;
 
264
        UserOptions.make_fock = 0;
 
265
        UserOptions.symm_ints = 0;
 
266
        UserOptions.make_deriv2 = 1;
 
267
        UserOptions.make_mkpt2_ints = 0;
 
268
#else
 
269
        throw std::domain_error("--deriv2 option is not supported by your CINTS executable.\nRecompile the code including files in Default_Deriv2 subdirectory.");
 
270
#endif
 
271
        return;
 
272
      }
 
273
      
 
274
      /*--- compute one-electron property integrals option ---*/
 
275
      if (strcmp(argv[i], "--oeprop") == 0) {
 
276
#ifdef INCLUDE_OEProp_Ints
 
277
        UserOptions.make_oei = 0;
 
278
        UserOptions.make_eri = 0;
 
279
        UserOptions.make_fock = 0;
 
280
        UserOptions.make_oeprop = 1;
 
281
        UserOptions.symm_ints = 0;
 
282
        UserOptions.print_lvl = 0;
 
283
        UserOptions.make_mkpt2_ints = 0;
 
284
#else
 
285
        throw std::domain_error("--oeprop option is not supported by your CINTS executable.\nRecompile the code including files in OEProp_Ints subdirectory.");
 
286
#endif
 
287
        return;
 
288
      }
 
289
      
 
290
      /*--- compute MP2 energy option ---*/
 
291
      if (strcmp(argv[i], "--mp2") == 0) {
 
292
#ifdef INCLUDE_MP2
 
293
        UserOptions.make_oei = 0;
 
294
        UserOptions.make_eri = 0;
 
295
        UserOptions.make_fock = 0;
 
296
        UserOptions.make_deriv1 = 0;
 
297
        UserOptions.make_mp2 = 1;
 
298
        UserOptions.make_r12ints = 0;
 
299
        UserOptions.make_mp2r12 = 0;
 
300
        UserOptions.make_cc_bt2 = 0;
 
301
        UserOptions.symm_ints = 0;
 
302
        UserOptions.make_mkpt2_ints = 0;
 
303
        
 
304
        errcod = ip_string("REFERENCE",&refstring,0);
 
305
        if (errcod != IPE_OK)
 
306
          throw std::domain_error("REFERENCE keyword is missing");
 
307
        else if (!strcmp(refstring,"RHF") || !strcmp(refstring,""))
 
308
          UserOptions.reftype = rhf;
 
309
        else if (!strcmp(refstring,"UHF")) {
 
310
          UserOptions.reftype = uhf;
 
311
          throw std::domain_error("UMP2 energy evaluation is not yet implemented");
 
312
        }
 
313
        else
 
314
          throw std::domain_error("MP2 energy evaluation with specified REFERENCE not implemented");
 
315
#else
 
316
        throw std::domain_error("--mp2 option is not supported by your CINTS executable.\nRecompile the code including files in MP2 subdirectory.");
 
317
#endif
 
318
        return;
 
319
      }
 
320
      
 
321
      /*--- build te integrals for R12 methods option ---*/
 
322
      if (strcmp(argv[i], "--r12ints") == 0) {
 
323
#ifdef INCLUDE_R12_Ints
 
324
        UserOptions.make_oei = 0;
 
325
        UserOptions.make_eri = 0;
 
326
        UserOptions.make_fock = 0;
 
327
        UserOptions.make_deriv1 = 0;
 
328
        UserOptions.make_mp2 = 0;
 
329
        UserOptions.make_r12ints = 1;
 
330
        UserOptions.make_mp2r12 = 0;
 
331
        UserOptions.make_cc_bt2 = 0;
 
332
        UserOptions.symm_ints = 1;
 
333
        UserOptions.num_threads = 1;
 
334
        UserOptions.make_mkpt2_ints = 0;
 
335
#else
 
336
        throw std::domain_error("--r12ints option is not supported by your CINTS executable.\nRecompile the code including files in R12_Ints subdirectory.");
 
337
#endif
 
338
        return;
 
339
      }
 
340
      
 
341
      /*--- compute MP2-R12 energy option ---*/
 
342
      if (strcmp(argv[i], "--mp2r12") == 0) {
 
343
#ifdef INCLUDE_MP2R12
 
344
        UserOptions.make_oei = 0;
 
345
        UserOptions.make_eri = 0;
 
346
        UserOptions.make_fock = 0;
 
347
        UserOptions.make_deriv1 = 0;
 
348
        UserOptions.make_mp2 = 0;
 
349
        UserOptions.make_r12ints = 0;
 
350
        UserOptions.make_mp2r12 = 1;
 
351
        UserOptions.make_cc_bt2 = 0;
 
352
        UserOptions.symm_ints = 0;
 
353
        UserOptions.make_mkpt2_ints = 0;
 
354
        
 
355
        errcod = ip_string("REFERENCE",&refstring,0);
 
356
        if (errcod != IPE_OK)
 
357
          throw std::domain_error("REFERENCE keyword is missing");
 
358
        else if (!strcmp(refstring,"RHF") || !strcmp(refstring,""))
 
359
          UserOptions.reftype = rhf;
 
360
        else
 
361
          throw std::domain_error("Direct MP2-R12/A integrals transformation with specified REFERENCE not implemented");
 
362
#else
 
363
        throw std::domain_error("--mp2r12 option is not supported by your CINTS executable.\nRecompile the code including files in MP2R12 subdirectory.");
 
364
#endif
 
365
        return;
 
366
      }
 
367
      
 
368
      /*--- compute MkPT2 integrals option ---*/
 
369
      if (strcmp(argv[i], "--mkpt2") == 0) {
 
370
#ifdef INCLUDE_MkPT2
 
371
        UserOptions.make_oei = 0;
 
372
        UserOptions.make_eri = 0;
 
373
        UserOptions.make_fock = 0;
 
374
        UserOptions.make_deriv1 = 0;
 
375
        UserOptions.make_mp2 = 0;
 
376
        UserOptions.make_r12ints = 0;
 
377
        UserOptions.make_mp2r12 = 0;
 
378
        UserOptions.make_cc_bt2 = 0;
 
379
        UserOptions.symm_ints = 0;
 
380
        UserOptions.make_mkpt2_ints = 1;
 
381
 
 
382
        errcod = ip_string("REFERENCE",&refstring,0);
 
383
        if (errcod != IPE_OK)
 
384
          throw std::domain_error("REFERENCE keyword is missing");
 
385
        else if (!strcmp(refstring,"RHF") || !strcmp(refstring,""))
 
386
          UserOptions.reftype = rhf;
 
387
        else if (!strcmp(refstring,"ROHF"))
 
388
          UserOptions.reftype = rohf;
 
389
        else if (!strcmp(refstring,"TWOCON"))
 
390
          UserOptions.reftype = twocon;
 
391
        else
 
392
          throw std::domain_error("Direct MkPT2 integral computation with specified REFERENCE not implemented");
 
393
#else
 
394
        throw std::domain_error("--mkpt2 option is not supported by your CINTS executable.\nRecompile the code including files in MKPT2 subdirectory.");
 
395
#endif
 
396
        return;
 
397
      }
 
398
 
 
399
 
 
400
      /*--- compute 4-virtuals T2 contribution to CC equations ---*/
 
401
      if (strcmp(argv[i], "--cc_bt2") == 0) {
 
402
#ifdef INCLUDE_CC
 
403
        UserOptions.make_oei = 0;
 
404
        UserOptions.make_eri = 0;
 
405
        UserOptions.make_fock = 0;
 
406
        UserOptions.make_deriv1 = 0;
 
407
        UserOptions.make_mp2 = 0;
 
408
        UserOptions.make_mp2r12 = 0;
 
409
        UserOptions.make_cc_bt2 = 1;
 
410
        UserOptions.symm_ints = 0;
 
411
        UserOptions.print_lvl = 0;
 
412
        UserOptions.make_mkpt2_ints = 0;
 
413
        
 
414
        errcod = ip_string("REFERENCE",&refstring,0);
 
415
        if (errcod != IPE_OK)
 
416
          throw std::domain_error("REFERENCE keyword is missing");
 
417
        else if (!strcmp(refstring,"RHF") || !strcmp(refstring,""))
 
418
          UserOptions.reftype = rhf;
 
419
        else
 
420
          throw std::domain_error("Direct CC four-virtuals term computation with specified REFERENCE not implemented");
 
421
#else
 
422
        throw std::domain_error("--cc_bt2 option is not supported by your CINTS executable.\nRecompile the code including files in CC subdirectory.");
 
423
#endif
 
424
        return;
 
425
      }
 
426
      
 
427
      /*--- compute derivatives integrals over GIAOs ---*/
 
428
      if(!strcmp(argv[i], "--giao_deriv")) {
 
429
#ifdef INCLUDE_GIAO_Deriv
 
430
        UserOptions.make_oei = 0;
 
431
        UserOptions.make_eri = 0;
 
432
        UserOptions.make_fock = 0;
 
433
        UserOptions.symm_ints = 0;
 
434
        UserOptions.make_giao_deriv = 1;
 
435
        UserOptions.make_mkpt2_ints = 0;
 
436
#else
 
437
        throw std::domain_error("--giao_deriv option is not supported by your CINTS executable.\nRecompile the code including files in GIAO_Deriv subdirectory.");
 
438
#endif
 
439
        return;
 
440
      }
 
441
      
 
442
    }
 
443
    
 
444
    return;
 
445
  }
 
446
};
 
447
};