source: src/bin/mpqc/mpqc.cc@ 1c7075

Last change on this file since 1c7075 was 1c7075, checked in by Frederik Heber <heber@…>, 13 years ago

Placed const char devnull as global const.

  • Property mode set to 100644
File size: 40.3 KB
Line 
1//
2// mpqc.cc
3//
4// Copyright (C) 1996 Limit Point Systems, Inc.
5//
6// Author: Edward Seidl <seidl@janed.com>
7// Maintainer: LPS
8//
9// This file is part of MPQC.
10//
11// MPQC is free software; you can redistribute it and/or modify
12// it under the terms of the GNU General Public License as published by
13// the Free Software Foundation; either version 2, or (at your option)
14// any later version.
15//
16// MPQC is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19// GNU General Public License for more details.
20//
21// You should have received a copy of the GNU General Public License
22// along with the MPQC; see the file COPYING. If not, write to
23// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24//
25// The U.S. Government is granted a limited license as per AL 91-7.
26//
27
28// This is needed to make GNU extensions available, such as
29// feenableexcept and fedisableexcept.
30#ifndef _GNU_SOURCE
31# define _GNU_SOURCE
32#endif
33
34#ifdef HAVE_CONFIG_H
35#include <scconfig.h>
36#endif
37
38#ifdef HAVE_TIME_H
39#include <time.h>
40#endif
41
42#include <scdirlist.h>
43
44#include <new>
45#include <stdexcept>
46#include <string.h>
47#include <unistd.h>
48#include <sys/stat.h>
49#include <fstream>
50
51#include <boost/bind.hpp>
52#include <boost/function.hpp>
53
54#include <scconfig.h>
55#ifdef HAVE_SSTREAM
56# include <sstream>
57#else
58# include <strstream.h>
59#endif
60
61#ifdef HAVE_SYS_RESOURCE_H
62# include <sys/resource.h>
63#endif
64#ifdef HAVE_SYS_TIME_H
65# include <sys/time.h>
66#endif
67
68#include <util/options/GetLongOpt.h>
69#include <util/class/scexception.h>
70#include <util/misc/newstring.h>
71#include <util/keyval/keyval.h>
72#include <util/state/state_bin.h>
73#include <util/group/message.h>
74#include <util/group/memory.h>
75#include <util/group/mstate.h>
76#include <util/group/thread.h>
77#include <util/group/pregtime.h>
78#include <util/misc/bug.h>
79#include <util/misc/formio.h>
80#include <util/misc/exenv.h>
81#ifdef HAVE_CHEMISTRY_CCA
82 #include <util/misc/ccaenv.h>
83#endif
84#include <util/render/render.h>
85
86#include <math/optimize/opt.h>
87
88#include <chemistry/molecule/coor.h>
89#include <chemistry/molecule/energy.h>
90#include <chemistry/molecule/molfreq.h>
91#include <chemistry/molecule/fdhess.h>
92#include <chemistry/molecule/formula.h>
93#include <chemistry/qc/wfn/wfn.h>
94
95// Force linkages:
96#include <util/group/linkage.h>
97#include <chemistry/qc/wfn/linkage.h>
98#include <chemistry/qc/scf/linkage.h>
99#include <chemistry/qc/dft/linkage.h>
100#include <chemistry/qc/mbpt/linkage.h>
101#ifdef HAVE_SC_SRC_LIB_CHEMISTRY_QC_MBPTR12
102# include <chemistry/qc/mbptr12/linkage.h>
103#endif
104#ifdef HAVE_SC_SRC_LIB_CHEMISTRY_QC_CINTS
105# include <chemistry/qc/cints/linkage.h>
106#endif
107//#include <chemistry/qc/psi/linkage.h>
108#include <util/state/linkage.h>
109#ifdef HAVE_SC_SRC_LIB_CHEMISTRY_QC_CC
110# include <chemistry/qc/cc/linkage.h>
111#endif
112#ifdef HAVE_SC_SRC_LIB_CHEMISTRY_QC_PSI
113# include <chemistry/qc/psi/linkage.h>
114#endif
115#ifdef HAVE_SC_SRC_LIB_CHEMISTRY_QC_INTCCA
116# include <chemistry/qc/intcca/linkage.h>
117#endif
118
119#ifdef HAVE_MPI
120#define MPICH_SKIP_MPICXX
121#include <mpi.h>
122#include <util/group/messmpi.h>
123#endif
124
125using namespace std;
126using namespace sc;
127
128#include "mpqcin.h"
129
130//////////////////////////////////////////////////////////////////////////
131
132const KeyValValueboolean truevalue(1), falsevalue(0);
133const char *devnull = "/dev/null";
134
135
136static void
137trash_stack_b(int &i, char *&ichar)
138{
139 char stack;
140 ichar = &stack;
141 ichar -= 10;
142 for (i=0; i<1000; i++) {
143 *ichar-- = 0xfe;
144 }
145}
146
147static void
148trash_stack()
149{
150 int i;
151 char *ichar;
152 trash_stack_b(i,ichar);
153}
154
155static void
156clean_up(void)
157{
158 MemoryGrp::set_default_memorygrp(0);
159 MessageGrp::set_default_messagegrp(0);
160 ThreadGrp::set_default_threadgrp(0);
161 SCMatrixKit::set_default_matrixkit(0);
162 Integral::set_default_integral(0);
163 RegionTimer::set_default_regiontimer(0);
164}
165
166#include <signal.h>
167
168#ifdef HAVE_FENV_H
169# include <fenv.h>
170#endif
171
172static void
173print_unseen(const Ref<ParsedKeyVal> &parsedkv,
174 const char *input)
175{
176 if (parsedkv->have_unseen()) {
177 ExEnv::out0() << endl;
178 ExEnv::out0() << indent
179 << "The following keywords in \"" << input << "\" were ignored:"
180 << endl;
181 ExEnv::out0() << incindent;
182 parsedkv->print_unseen(ExEnv::out0());
183 ExEnv::out0() << decindent;
184 }
185}
186
187double EvaluateDensity(
188 SCVector3 &r,
189 Ref<Integral> &intgrl,
190 GaussianBasisSet::ValueData &vdat,
191 Ref<Wavefunction> &wfn);
192
193/** Places all known options into \a options and parses them from argc,argv.
194 *
195 * \param options options structure
196 * \param argc argument count
197 * \param argv argument array
198 * \return return value by GetLongOpt::parse() function
199 */
200int ParseOptions(
201 GetLongOpt &options,
202 int argc,
203 char **argv)
204{
205 options.usage("[options] [filename]");
206 options.enroll("f", GetLongOpt::MandatoryValue,
207 "the name of an object format input file", 0);
208 options.enroll("o", GetLongOpt::MandatoryValue,
209 "the name of the output file", 0);
210 options.enroll("n", GetLongOpt::NoValue,
211 "listen for incoming object format input files", 0);
212 options.enroll("messagegrp", GetLongOpt::MandatoryValue,
213 "which message group to use", 0);
214 options.enroll("threadgrp", GetLongOpt::MandatoryValue,
215 "which thread group to use", 0);
216 options.enroll("memorygrp", GetLongOpt::MandatoryValue,
217 "which memory group to use", 0);
218 options.enroll("integral", GetLongOpt::MandatoryValue,
219 "which integral evaluator to use", 0);
220 options.enroll("l", GetLongOpt::MandatoryValue, "basis set limit", "0");
221 options.enroll("W", GetLongOpt::MandatoryValue,
222 "set the working directory", ".");
223 options.enroll("c", GetLongOpt::NoValue, "check input then exit", 0);
224 options.enroll("v", GetLongOpt::NoValue, "print the version number", 0);
225 options.enroll("w", GetLongOpt::NoValue, "print the warranty", 0);
226 options.enroll("L", GetLongOpt::NoValue, "print the license", 0);
227 options.enroll("k", GetLongOpt::NoValue, "print key/value assignments", 0);
228 options.enroll("i", GetLongOpt::NoValue, "convert simple to OO input", 0);
229 options.enroll("d", GetLongOpt::NoValue, "debug", 0);
230 options.enroll("h", GetLongOpt::NoValue, "print this message", 0);
231 options.enroll("cca-path", GetLongOpt::OptionalValue,
232 "cca component path", "");
233 options.enroll("cca-load", GetLongOpt::OptionalValue,
234 "cca components to load", "");
235
236 int optind = options.parse(argc, argv);
237
238 return optind;
239}
240
241/** Checks for each known option and acts accordingly.
242 *
243 * \param options option structure
244 * \param *output name of outputfile on return
245 * \param *outstream open output stream on return
246 */
247void ComputeOptions(
248 GetLongOpt &options,
249 const char *&output,
250 ostream *&outstream)
251{
252 output = options.retrieve("o");
253 outstream = 0;
254 if (output != 0) {
255 outstream = new ofstream(output);
256 ExEnv::set_out(outstream);
257 }
258
259 if (options.retrieve("h")) {
260 ExEnv::out0()
261 << indent << "MPQC version " << SC_VERSION << endl
262 << indent << "compiled for " << TARGET_ARCH << endl
263 << SCFormIO::copyright << endl;
264 options.usage(ExEnv::out0());
265 exit(0);
266 }
267
268 if (options.retrieve("v")) {
269 ExEnv::out0()
270 << indent << "MPQC version " << SC_VERSION << endl
271 << indent << "compiled for " << TARGET_ARCH << endl
272 << SCFormIO::copyright;
273 exit(0);
274 }
275
276 if (options.retrieve("w")) {
277 ExEnv::out0()
278 << indent << "MPQC version " << SC_VERSION << endl
279 << indent << "compiled for " << TARGET_ARCH << endl
280 << SCFormIO::copyright << endl
281 << SCFormIO::warranty;
282 exit(0);
283 }
284
285 if (options.retrieve("L")) {
286 ExEnv::out0()
287 << indent << "MPQC version " << SC_VERSION << endl
288 << indent << "compiled for " << TARGET_ARCH << endl
289 << SCFormIO::copyright << endl
290 << SCFormIO::license;
291 exit(0);
292 }
293
294 if (options.retrieve("d"))
295 SCFormIO::set_debug(1);
296
297 // set the working dir
298 if (strcmp(options.retrieve("W"),"."))
299 int retval = chdir(options.retrieve("W"));
300
301 // check that n and f/o are not given at the same time
302 if ((options.retrieve("n")) && ((options.retrieve("f")) || (options.retrieve("o")))) {
303 throw invalid_argument("-n must not be given with -f or -o");
304 }
305}
306
307/** Sets object and generic input file names.
308 *
309 * \param object_input filename of object-oriented input
310 * \param generic_input filename of generic input
311 * \param options option structure
312 * \param argc argument count
313 * \param argv argument array
314 */
315void getInputFileNames(
316 const char *&object_input,
317 const char *&generic_input,
318 GetLongOpt &options,
319 int argc,
320 char **argv)
321{
322 // initialize keyval input
323 object_input = options.retrieve("f");
324 generic_input = 0;
325 if (argc - optind == 0) {
326 generic_input = 0;
327 }
328 else if (argc - optind == 1) {
329 generic_input = argv[optind];
330 }
331 else {
332 options.usage();
333 throw invalid_argument("extra arguments given");
334 }
335
336 if (object_input == 0 && generic_input == 0) {
337 generic_input = "mpqc.in";
338 }
339 else if (object_input && generic_input) {
340 options.usage();
341 throw invalid_argument("only one of -f and a file argument can be given");
342 }
343}
344
345/** Gets the MPI Message group.
346 *
347 * \param grp reference to obtained group
348 * \param argc argument count
349 * \param argv argument array
350 */
351void getMessageGroup(
352 Ref<MessageGrp> &grp,
353 int argc,
354 char **argv)
355{
356#if defined(HAVE_MPI) && defined(ALWAYS_USE_MPI)
357 grp = new MPIMessageGrp(&argc, &argv);
358#endif
359 if (grp.null()) grp = MessageGrp::initial_messagegrp(argc, argv);
360 if (grp.nonnull())
361 MessageGrp::set_default_messagegrp(grp);
362 else
363 grp = MessageGrp::get_default_messagegrp();
364}
365
366/** Sets the base name of output files.
367 *
368 * \param input input file name
369 * \param output output file name
370 */
371void setOutputBaseName(const char *input, const char *output)
372{
373 const char *basename_source;
374 if (output) basename_source = output;
375 else basename_source = input;
376 int nfilebase = (int) (::strrchr(basename_source, '.') - basename_source);
377 char *basename = new char[nfilebase + 1];
378 strncpy(basename, basename_source, nfilebase);
379 basename[nfilebase] = '\0';
380 SCFormIO::set_default_basename(basename);
381 delete[] basename;
382}
383
384/** Prints current key values.
385 *
386 * \param keyval key value structure
387 * \param opt optimization structure
388 * \param molname name of molecule
389 * \param restartfile name of restartfile
390 */
391void printOptions(
392 Ref<KeyVal> &keyval,
393 Ref<Optimize> &opt,
394 const char *molname,
395 const char *restartfile)
396{
397 int restart = keyval->booleanvalue("restart",truevalue);
398
399 int checkpoint = keyval->booleanvalue("checkpoint",truevalue);
400
401 int savestate = keyval->booleanvalue("savestate",truevalue);
402
403 int do_energy = keyval->booleanvalue("do_energy",truevalue);
404
405 int do_grad = keyval->booleanvalue("do_gradient",falsevalue);
406
407 int do_opt = keyval->booleanvalue("optimize",truevalue);
408
409 int do_pdb = keyval->booleanvalue("write_pdb",falsevalue);
410
411 int print_mole = keyval->booleanvalue("print_mole",truevalue);
412
413 int print_timings = keyval->booleanvalue("print_timings",truevalue);
414
415 // sanity checks for the benefit of reasonable looking output
416 if (opt.null()) do_opt=0;
417
418 ExEnv::out0() << endl << indent
419 << "MPQC options:" << endl << incindent
420 << indent << "matrixkit = <"
421 << SCMatrixKit::default_matrixkit()->class_name() << ">" << endl
422 << indent << "filename = " << molname << endl
423 << indent << "restart_file = " << restartfile << endl
424 << indent << "restart = " << (restart ? "yes" : "no") << endl
425 << indent << "checkpoint = " << (checkpoint ? "yes" : "no") << endl
426 << indent << "savestate = " << (savestate ? "yes" : "no") << endl
427 << indent << "do_energy = " << (do_energy ? "yes" : "no") << endl
428 << indent << "do_gradient = " << (do_grad ? "yes" : "no") << endl
429 << indent << "optimize = " << (do_opt ? "yes" : "no") << endl
430 << indent << "write_pdb = " << (do_pdb ? "yes" : "no") << endl
431 << indent << "print_mole = " << (print_mole ? "yes" : "no") << endl
432 << indent << "print_timings = " << (print_timings ? "yes" : "no")
433 << endl << decindent;
434
435}
436
437/** Saves the current state to checkpoint file.
438 *
439 * \param keyval key value structure
440 * \param opt optimization structure
441 * \param grp message group
442 * \param mole MolecularEnergy object
443 * \param molname name of molecule
444 * \param ckptfile name of check point file
445 */
446void saveState(
447 char *wfn_file,
448 int savestate,
449 Ref<Optimize> &opt,
450 Ref<MessageGrp> &grp,
451 Ref<MolecularEnergy> &mole,
452 char *&molname,
453 char *&ckptfile)
454{
455 // function stuff
456 if (savestate) {
457 if (opt.nonnull()) {
458 if (grp->me() == 0) {
459 ckptfile = new char[strlen(molname)+6];
460 sprintf(ckptfile,"%s.ckpt",molname);
461 }
462 else {
463 ckptfile = new char[strlen(devnull)+1];
464 strcpy(ckptfile, devnull);
465 }
466
467 StateOutBin so(ckptfile);
468 SavableState::save_state(opt.pointer(),so);
469 so.close();
470
471 delete[] ckptfile;
472 }
473
474 if (mole.nonnull()) {
475 if (grp->me() == 0) {
476 if (wfn_file == 0) {
477 wfn_file = new char[strlen(molname)+6];
478 sprintf(wfn_file,"%s.wfn",molname);
479 }
480 }
481 else {
482 delete[] wfn_file;
483 wfn_file = new char[strlen(devnull)+1];
484 strcpy(wfn_file, devnull);
485 }
486
487 StateOutBin so(wfn_file);
488 SavableState::save_state(mole.pointer(),so);
489 so.close();
490
491 }
492 }
493 delete[] wfn_file;
494}
495
496/** Sets up indentation and output modes.
497 *
498 * \param grp message group
499 */
500void setupSCFormIO(
501 Ref<MessageGrp> &grp
502 )
503{
504 SCFormIO::setindent(ExEnv::outn(), 2);
505 SCFormIO::setindent(ExEnv::errn(), 2);
506 SCFormIO::setindent(cout, 2);
507 SCFormIO::setindent(cerr, 2);
508
509 SCFormIO::set_printnode(0);
510 if (grp->n() > 1)
511 SCFormIO::init_mp(grp->me());
512}
513
514/** Initialises the timer.
515 *
516 * \param grp message group
517 * \param keyval key value structure
518 * \param tim timing structure
519 */
520void initTimings(
521 Ref<MessageGrp> &grp,
522 Ref<KeyVal> &keyval,
523 Ref<RegionTimer> &tim
524 )
525{
526 grp->sync(); // make sure nodes are sync'ed before starting timings
527 if (keyval->exists("timer")) tim << keyval->describedclassvalue("timer");
528 else tim = new ParallelRegionTimer(grp,"mpqc",1,1);
529 RegionTimer::set_default_regiontimer(tim);
530
531 if (tim.nonnull()) tim->enter("input");
532}
533
534/** Prints the header of the output.
535 *
536 * \param tim timing structure
537 */
538void makeAnnouncement(
539 Ref<RegionTimer> &tim
540 )
541{
542 const char title1[] = "MPQC: Massively Parallel Quantum Chemistry";
543 int ntitle1 = sizeof(title1);
544 const char title2[] = "Version " SC_VERSION;
545 int ntitle2 = sizeof(title2);
546 ExEnv::out0() << endl;
547 ExEnv::out0() << indent;
548 for (int i=0; i<(80-ntitle1)/2; i++) ExEnv::out0() << ' ';
549 ExEnv::out0() << title1 << endl;
550 ExEnv::out0() << indent;
551 for (int i=0; i<(80-ntitle2)/2; i++) ExEnv::out0() << ' ';
552 ExEnv::out0() << title2 << endl << endl;
553
554 const char *tstr = 0;
555#if defined(HAVE_TIME) && defined(HAVE_CTIME)
556 time_t t;
557 time(&t);
558 tstr = ctime(&t);
559#endif
560 if (!tstr) {
561 tstr = "UNKNOWN";
562 }
563
564 ExEnv::out0()
565 << indent << scprintf("Machine: %s", TARGET_ARCH) << endl
566 << indent << scprintf("User: %s@%s",
567 ExEnv::username(), ExEnv::hostname()) << endl
568 << indent << scprintf("Start Time: %s", tstr) << endl;
569}
570
571/** Parse the input file into the key value container.
572 *
573 * \param grp message group
574 * \param parsedkev keyvalue container on return
575 * \param options options structure
576 * \param input input file name
577 * \param generic_input filename of generic input
578 */
579void parseInputfile(
580 Ref<MessageGrp> &grp,
581 Ref<ParsedKeyVal> &parsedkv,
582 GetLongOpt &options,
583 const char *&input,
584 const char *&generic_input
585 )
586{
587 // read the input file on only node 0
588 char *in_char_array;
589 if (grp->me() == 0) {
590 ifstream is(input);
591#ifdef HAVE_SSTREAM
592 ostringstream ostrs;
593 is >> ostrs.rdbuf();
594 int n = 1 + strlen(ostrs.str().c_str());
595 in_char_array = strcpy(new char[n],ostrs.str().c_str());
596#else
597 ostrstream ostrs;
598 is >> ostrs.rdbuf();
599 ostrs << ends;
600 in_char_array = ostrs.str();
601 int n = ostrs.pcount();
602#endif
603 grp->bcast(n);
604 grp->bcast(in_char_array, n);
605 }
606 else {
607 int n;
608 grp->bcast(n);
609 in_char_array = new char[n];
610 grp->bcast(in_char_array, n);
611 }
612
613 int use_simple_input;
614 if (generic_input && grp->me() == 0) {
615 MPQCIn mpqcin;
616 use_simple_input = mpqcin.check_string(in_char_array);
617 }
618 else {
619 use_simple_input = 0;
620 }
621 grp->bcast(use_simple_input);
622
623 if (use_simple_input) {
624 MPQCIn mpqcin;
625 char *simple_input_text = mpqcin.parse_string(in_char_array);
626 if (options.retrieve("i")) {
627 ExEnv::out0() << "Generated object-oriented input file:" << endl
628 << simple_input_text
629 << endl;
630 exit(0);
631 }
632 parsedkv = new ParsedKeyVal();
633 parsedkv->parse_string(simple_input_text);
634 delete[] simple_input_text;
635 }
636 else {
637 parsedkv = new ParsedKeyVal();
638 parsedkv->parse_string(in_char_array);
639 }
640 delete[] in_char_array;
641}
642
643/** Get the thread group.
644 *
645 * \param keyval keyvalue container
646 * \param thread thread group on return
647 * \param argc argument count
648 * \param argv argument array
649 */
650void getThreadGroup(
651 Ref<KeyVal> &keyval,
652 Ref<ThreadGrp> &thread,
653 int argc,
654 char **argv)
655{
656 //first try the commandline and environment
657 thread = ThreadGrp::initial_threadgrp(argc, argv);
658
659 // if we still don't have a group, try reading the thread group
660 // from the input
661 if (thread.null()) {
662 thread << keyval->describedclassvalue("thread");
663 }
664
665 if (thread.nonnull())
666 ThreadGrp::set_default_threadgrp(thread);
667 else
668 thread = ThreadGrp::get_default_threadgrp();
669}
670
671/** Get the memory group.
672 *
673 * \param keyval keyvalue container
674 * \param memory memory group on return
675 * \param argc argument count
676 * \param argv argument array
677 */
678void getMemoryGroup(
679 Ref<KeyVal> &keyval,
680 Ref<MemoryGrp> &memory,
681 int argc,
682 char **argv)
683{
684 // first try the commandline and environment
685 memory = MemoryGrp::initial_memorygrp(argc, argv);
686
687 // if we still don't have a group, try reading the memory group
688 // from the input
689 if (memory.null()) {
690 memory << keyval->describedclassvalue("memory");
691 }
692
693 if (memory.nonnull())
694 MemoryGrp::set_default_memorygrp(memory);
695 else
696 memory = MemoryGrp::get_default_memorygrp();
697}
698
699/** Prepares CCA component if available.
700 *
701 * \param keyval keyvalue container
702 * \param options parsed command line options
703 */
704void prepareCCA(
705 Ref<KeyVal> &keyval,
706 GetLongOpt &options
707 )
708{
709#ifdef HAVE_CHEMISTRY_CCA
710 // initialize cca framework
711 KeyValValuestring emptystring("");
712 bool do_cca = keyval->booleanvalue("do_cca",falsevalue);
713
714 string cca_path(options.retrieve("cca-path"));
715 string cca_load(options.retrieve("cca-load"));
716 if(cca_path.size()==0)
717 cca_path = keyval->stringvalue("cca_path",emptystring);
718 if(cca_load.size()==0)
719 cca_load = keyval->stringvalue("cca_load",emptystring);
720
721 if( !do_cca && (cca_load.size() > 0 || cca_path.size() > 0) )
722 do_cca = true;
723
724 if(cca_path.size()==0) {
725 #ifdef CCA_PATH
726 cca_path = CCA_PATH;
727 #endif
728 }
729 if(cca_load.size()==0) {
730 cca_load += "MPQC.IntegralEvaluatorFactory";
731 }
732
733 if( cca_load.size() > 0 && cca_path.size() > 0 && do_cca ) {
734 string cca_args = "--path " + cca_path + " --load " + cca_load;
735 ExEnv::out0() << endl << indent << "Initializing CCA framework with args: "
736 << endl << indent << cca_args << endl;
737 CCAEnv::init( cca_args );
738 }
739#endif
740}
741
742/** Setup debugger.
743 *
744 * \param keyval keyvalue container
745 * \param grp message group
746 * \param debugger debugger structure
747 * \param options parsed command line options
748 * \param argv argument array
749 */
750void setupDebugger(
751 Ref<KeyVal> &keyval,
752 Ref<MessageGrp> &grp,
753 Ref<Debugger> &debugger,
754 GetLongOpt &options,
755 char **argv)
756{
757 debugger << keyval->describedclassvalue("debug");
758 if (debugger.nonnull()) {
759 Debugger::set_default_debugger(debugger);
760 debugger->set_exec(argv[0]);
761 debugger->set_prefix(grp->me());
762 if (options.retrieve("d"))
763 debugger->debug("Starting debugger because -d given on command line.");
764 }
765}
766
767/** Get integral factory.
768 *
769 * \param keyval keyvalue container
770 * \param integral integral group on return
771 * \param argc argument count
772 * \param argv argument array
773 */
774void getIntegralFactory(
775 Ref<KeyVal> &keyval,
776 Ref<Integral> &integral,
777 int argc,
778 char **argv)
779{
780 // first try commandline and environment
781 integral = Integral::initial_integral(argc, argv);
782
783 // if we still don't have a integral, try reading the integral
784 // from the input
785 if (integral.null()) {
786 integral << keyval->describedclassvalue("integrals");
787 }
788
789 if (integral.nonnull())
790 Integral::set_default_integral(integral);
791 else
792 integral = Integral::get_default_integral();
793
794}
795
796void performRestart(
797 Ref<KeyVal> &keyval,
798 Ref<MessageGrp> &grp,
799 Ref<Optimize> &opt,
800 Ref<MolecularEnergy> &mole,
801 char *&restartfile
802 )
803{
804 int restart = keyval->booleanvalue("restart",truevalue);
805 struct stat sb;
806 int statresult, statsize;
807 if (restart) {
808 if (grp->me() == 0) {
809 statresult = stat(restartfile,&sb);
810 statsize = (statresult==0) ? sb.st_size : 0;
811 }
812 grp->bcast(statresult);
813 grp->bcast(statsize);
814 }
815 if (restart && statresult==0 && statsize) {
816 BcastStateInBin si(grp,restartfile);
817 if (keyval->exists("override")) {
818 si.set_override(new PrefixKeyVal(keyval,"override"));
819 }
820 char *suf = strrchr(restartfile,'.');
821 if (!strcmp(suf,".wfn")) {
822 mole << SavableState::key_restore_state(si,"mole");
823 ExEnv::out0() << endl
824 << indent << "Restored <" << mole->class_name()
825 << "> from " << restartfile << endl;
826
827 opt << keyval->describedclassvalue("opt");
828 if (opt.nonnull())
829 opt->set_function(mole.pointer());
830 }
831 else {
832 opt << SavableState::key_restore_state(si,"opt");
833 if (opt.nonnull()) {
834 mole << opt->function();
835 ExEnv::out0() << endl << indent
836 << "Restored <Optimize> from " << restartfile << endl;
837 }
838 }
839 } else {
840 mole << keyval->describedclassvalue("mole");
841 opt << keyval->describedclassvalue("opt");
842 }
843}
844
845char *setMolecularCheckpointFile(
846 Ref<KeyVal> &keyval,
847 Ref<MessageGrp> &grp,
848 Ref<MolecularEnergy> &mole,
849 char *mole_ckpt_file
850 )
851{
852 int checkpoint = keyval->booleanvalue("checkpoint",truevalue);
853 int checkpoint_freq = keyval->intvalue("checkpoint_freq",KeyValValueint(1));
854 if (mole.nonnull()) {
855 MolecularFormula mf(mole->molecule());
856 ExEnv::out0() << endl << indent
857 << "Molecular formula " << mf.formula() << endl;
858 if (checkpoint) {
859 mole->set_checkpoint();
860 if (grp->me() == 0) mole->set_checkpoint_file(mole_ckpt_file);
861 else mole->set_checkpoint_file(devnull);
862 mole->set_checkpoint_freq(checkpoint_freq);
863 }
864 }
865}
866
867/** Checks whether limit on command-line exceeds the basis functions.
868 *
869 * \param options parsed command-line options
870 * \param mole molecular energy object
871 * \return 0 - not exceeded, 1 - exceeded
872 */
873int checkBasisSetLimit(
874 GetLongOpt &options,
875 Ref<MolecularEnergy> &mole
876 )
877{
878 int check = (options.retrieve("c") != 0);
879 int limit = atoi(options.retrieve("l"));
880 if (limit) {
881 Ref<Wavefunction> wfn; wfn << mole;
882 if (wfn.nonnull() && wfn->ao_dimension()->n() > limit) {
883 ExEnv::out0() << endl << indent
884 << "The limit of " << limit << " basis functions has been exceeded."
885 << endl;
886 check = 1;
887 }
888 }
889 return check;
890}
891
892int
893try_main(int argc, char *argv[])
894{
895 //trash_stack();
896
897 int i;
898 atexit(clean_up);
899
900#ifdef HAVE_FEENABLEEXCEPT
901 // this uses a glibc extension to trap on individual exceptions
902# ifdef FE_DIVBYZERO
903 feenableexcept(FE_DIVBYZERO);
904# endif
905# ifdef FE_INVALID
906 feenableexcept(FE_INVALID);
907# endif
908# ifdef FE_OVERFLOW
909 feenableexcept(FE_OVERFLOW);
910# endif
911#endif
912
913#ifdef HAVE_FEDISABLEEXCEPT
914 // this uses a glibc extension to not trap on individual exceptions
915# ifdef FE_UNDERFLOW
916 fedisableexcept(FE_UNDERFLOW);
917# endif
918# ifdef FE_INEXACT
919 fedisableexcept(FE_INEXACT);
920# endif
921#endif
922
923#if defined(HAVE_SETRLIMIT)
924 struct rlimit rlim;
925 rlim.rlim_cur = 0;
926 rlim.rlim_max = 0;
927 setrlimit(RLIMIT_CORE,&rlim);
928#endif
929
930 ExEnv::init(argc, argv);
931
932 // parse commandline options
933 GetLongOpt options;
934 int optind = ParseOptions(options, argc, argv);
935 const char *output = 0;
936 ostream *outstream = 0;
937 ComputeOptions(options, output, outstream);
938
939 // get the message group. first try the commandline and environment
940 Ref<MessageGrp> grp;
941 getMessageGroup(grp, argc, argv);
942
943 // get input file names, either object-oriented or generic
944 const char *object_input = 0;
945 const char *generic_input = 0;
946 getInputFileNames(object_input, generic_input, options, argc, argv);
947 const char *input;
948 if (object_input) input = object_input;
949 if (generic_input) input = generic_input;
950
951 // parse input into keyvalue container
952 Ref<ParsedKeyVal> parsedkv;
953 parseInputfile(grp, parsedkv, options, input, generic_input);
954 if (options.retrieve("k")) parsedkv->verbose(1);
955 Ref<KeyVal> keyval = new PrefixKeyVal(parsedkv.pointer(),"mpqc");
956
957 // get the basename for output files
958 setOutputBaseName(input, output);
959
960 // set up output classes
961 setupSCFormIO(grp);
962
963 // initialize timing for mpqc
964 Ref<RegionTimer> tim;
965 initTimings(grp, keyval, tim);
966
967 // announce ourselves
968 makeAnnouncement(tim);
969
970 // get the thread group.
971 Ref<ThreadGrp> thread;
972 getThreadGroup(keyval, thread, argc, argv);
973
974 // get the memory group.
975 Ref<MemoryGrp> memory;
976 getMemoryGroup(keyval, memory, argc, argv);
977
978 ExEnv::out0() << indent
979 << "Using " << grp->class_name()
980 << " for message passing (number of nodes = " << grp->n() << ")." << endl
981 << indent
982 << "Using " << thread->class_name()
983 << " for threading (number of threads = " << thread->nthread() << ")." << endl
984 << indent
985 << "Using " << memory->class_name()
986 << " for distributed shared memory." << endl
987 << indent
988 << "Total number of processors = " << grp->n() * thread->nthread() << endl;
989
990 // prepare CCA if available
991 prepareCCA(keyval, options);
992
993 // now set up the debugger
994 Ref<Debugger> debugger;
995 setupDebugger(keyval, grp, debugger, options, argv);
996
997 // now check to see what matrix kit to use
998 if (keyval->exists("matrixkit"))
999 SCMatrixKit::set_default_matrixkit(
1000 dynamic_cast<SCMatrixKit*>(
1001 keyval->describedclassvalue("matrixkit").pointer()));
1002
1003 // get the integral factory.
1004 Ref<Integral> integral;
1005 getIntegralFactory(keyval, integral, argc, argv);
1006 ExEnv::out0() << endl << indent
1007 << "Using " << integral->class_name()
1008 << " by default for molecular integrals evaluation" << endl << endl;
1009
1010 // check for a molecular energy and optimizer
1011 const char *basename = SCFormIO::default_basename();
1012 KeyValValueString molnamedef(basename);
1013 char * molname = keyval->pcharvalue("filename", molnamedef);
1014 if (strcmp(molname, basename))
1015 SCFormIO::set_default_basename(molname);
1016
1017 char * ckptfile = new char[strlen(molname)+6];
1018 sprintf(ckptfile,"%s.ckpt",molname);
1019
1020 KeyValValueString restartfiledef(ckptfile);
1021 char * restartfile = keyval->pcharvalue("restart_file", restartfiledef);
1022
1023 char * wfn_file = keyval->pcharvalue("wfn_file");
1024 if (wfn_file == 0) {
1025 wfn_file = new char[strlen(molname)+6];
1026 sprintf(wfn_file,"%s.wfn",molname);
1027 }
1028 char *mole_ckpt_file = new char[strlen(wfn_file)+1];
1029 sprintf(mole_ckpt_file,"%s",wfn_file);
1030
1031 int restart = keyval->booleanvalue("restart",truevalue);
1032
1033 int checkpoint = keyval->booleanvalue("checkpoint",truevalue);
1034 int checkpoint_freq = keyval->intvalue("checkpoint_freq",KeyValValueint(1));
1035
1036 int savestate = keyval->booleanvalue("savestate",truevalue);
1037
1038 // setup molecular energy and optimization instances
1039 Ref<MolecularEnergy> mole;
1040 Ref<Optimize> opt;
1041
1042 // read in restart file if we do restart
1043 performRestart(keyval, grp, opt, mole, restartfile);
1044
1045 // setup molecule checkpoint file
1046 setMolecularCheckpointFile(keyval, grp, mole, mole_ckpt_file);
1047 delete[] mole_ckpt_file;
1048
1049 if (checkpoint && opt.nonnull()) {
1050 opt->set_checkpoint();
1051 if (grp->me() == 0) opt->set_checkpoint_file(ckptfile);
1052 else opt->set_checkpoint_file(devnull);
1053 }
1054
1055 // see if frequencies are wanted
1056 Ref<MolecularHessian> molhess;
1057 molhess << keyval->describedclassvalue("hess");
1058 Ref<MolecularFrequencies> molfreq;
1059 molfreq << keyval->describedclassvalue("freq");
1060
1061 // check basis set limit
1062 const int check = checkBasisSetLimit(options, mole);
1063 if (check) {
1064 ExEnv::out0() << endl << indent
1065 << "Exiting since the check option is on." << endl;
1066 exit(0);
1067 }
1068
1069 if (tim.nonnull()) tim->change("calc");
1070
1071 int do_energy = keyval->booleanvalue("do_energy",truevalue);
1072
1073 int do_grad = keyval->booleanvalue("do_gradient",falsevalue);
1074
1075 int do_opt = keyval->booleanvalue("optimize",truevalue);
1076
1077 int do_pdb = keyval->booleanvalue("write_pdb",falsevalue);
1078
1079 int print_mole = keyval->booleanvalue("print_mole",truevalue);
1080
1081 int print_timings = keyval->booleanvalue("print_timings",truevalue);
1082
1083 // print all current options (keyvalues)
1084 printOptions(keyval, opt, molname, restartfile);
1085
1086 // see if any pictures are desired
1087 Ref<Render> renderer;
1088 renderer << keyval->describedclassvalue("renderer");
1089
1090 // If we have a renderer, then we will read in some more info
1091 // below. Otherwise we can get rid of the keyval's, to eliminate
1092 // superfluous references to objects that we might otherwise be
1093 // able to delete. We cannot read in the remaining rendering
1094 // objects now, since some of their KeyVal CTOR's are heavyweight,
1095 // requiring optimized geometries, etc.
1096 if (renderer.null()) {
1097 if (parsedkv.nonnull()) print_unseen(parsedkv, input);
1098 keyval = 0;
1099 parsedkv = 0;
1100 }
1101
1102 delete[] restartfile;
1103 delete[] ckptfile;
1104
1105 int ready_for_freq = 1;
1106 if (mole.nonnull()) {
1107 if (((do_opt && opt.nonnull()) || do_grad)
1108 && !mole->gradient_implemented()) {
1109 ExEnv::out0() << indent
1110 << "WARNING: optimization or gradient requested but the given"
1111 << endl
1112 << " MolecularEnergy object cannot do gradients."
1113 << endl;
1114 }
1115
1116 if (do_opt && opt.nonnull() && mole->gradient_implemented()) {
1117 int result = opt->optimize();
1118 if (result) {
1119 ExEnv::out0() << indent
1120 << "The optimization has converged." << endl << endl;
1121 ExEnv::out0() << indent
1122 << scprintf("Value of the MolecularEnergy: %15.10f",
1123 mole->energy())
1124 << endl << endl;
1125 } else {
1126 ExEnv::out0() << indent
1127 << "The optimization has NOT converged." << endl << endl;
1128 ready_for_freq = 0;
1129 }
1130 } else if (do_grad && mole->gradient_implemented()) {
1131 mole->do_gradient(1);
1132 ExEnv::out0() << endl << indent
1133 << scprintf("Value of the MolecularEnergy: %15.10f",
1134 mole->energy())
1135 << endl;
1136 if (mole->value_result().actual_accuracy()
1137 > mole->value_result().desired_accuracy()) {
1138 ExEnv::out0() << indent
1139 << "WARNING: desired accuracy not achieved in energy" << endl;
1140 }
1141 ExEnv::out0() << endl;
1142 // Use result_noupdate since the energy might not have converged
1143 // to the desired accuracy in which case grabbing the result will
1144 // start up the calculation again. However the gradient might
1145 // not have been computed (if we are restarting and the gradient
1146 // isn't in the save file for example).
1147 RefSCVector grad;
1148 if (mole->gradient_result().computed()) {
1149 grad = mole->gradient_result().result_noupdate();
1150 }
1151 else {
1152 grad = mole->gradient();
1153 }
1154 if (grad.nonnull()) {
1155 grad.print("Gradient of the MolecularEnergy:");
1156 if (mole->gradient_result().actual_accuracy()
1157 > mole->gradient_result().desired_accuracy()) {
1158 ExEnv::out0() << indent
1159 << "WARNING: desired accuracy not achieved in gradient" << endl;
1160 }
1161 }
1162 } else if (do_energy && mole->value_implemented()) {
1163 ExEnv::out0() << endl << indent
1164 << scprintf("Value of the MolecularEnergy: %15.10f",
1165 mole->energy())
1166 << endl << endl;
1167 }
1168 }
1169
1170 if (tim.nonnull()) tim->exit("calc");
1171
1172 // save this before doing the frequency stuff since that obsoletes the
1173 saveState(wfn_file, savestate, opt, grp, mole, molname, ckptfile);
1174
1175 // Frequency calculation.
1176 if (ready_for_freq && molfreq.nonnull()) {
1177 RefSymmSCMatrix xhessian;
1178 if (molhess.nonnull()) {
1179 // if "hess" input was given, use it to compute the hessian
1180 xhessian = molhess->cartesian_hessian();
1181 }
1182 else if (mole->hessian_implemented()) {
1183 // if mole can compute the hessian, use that hessian
1184 xhessian = mole->get_cartesian_hessian();
1185 }
1186 else if (mole->gradient_implemented()) {
1187 // if mole can compute gradients, use gradients at finite
1188 // displacements to compute the hessian
1189 molhess = new FinDispMolecularHessian(mole);
1190 xhessian = molhess->cartesian_hessian();
1191 }
1192 else {
1193 ExEnv::out0() << "mpqc: WARNING: Frequencies cannot be computed" << endl;
1194 }
1195
1196 if (xhessian.nonnull()) {
1197 char *hessfile = SCFormIO::fileext_to_filename(".hess");
1198 MolecularHessian::write_cartesian_hessian(hessfile,
1199 mole->molecule(), xhessian);
1200 delete[] hessfile;
1201
1202 molfreq->compute_frequencies(xhessian);
1203 // DEGENERACY IS NOT CORRECT FOR NON-SINGLET CASES:
1204 molfreq->thermochemistry(1);
1205 }
1206 }
1207
1208 if (renderer.nonnull()) {
1209 Ref<RenderedObject> rendered;
1210 rendered << keyval->describedclassvalue("rendered");
1211 Ref<AnimatedObject> animated;
1212 animated << keyval->describedclassvalue("rendered");
1213 if (rendered.nonnull()) {
1214 if (tim.nonnull()) tim->enter("render");
1215 if (grp->me() == 0) renderer->render(rendered);
1216 if (tim.nonnull()) tim->exit("render");
1217 }
1218 else if (animated.nonnull()) {
1219 if (tim.nonnull()) tim->enter("render");
1220 if (grp->me() == 0) renderer->animate(animated);
1221 if (tim.nonnull()) tim->exit("render");
1222 }
1223 else {
1224 if (tim.nonnull()) tim->enter("render");
1225 int n = keyval->count("rendered");
1226 for (i=0; i<n; i++) {
1227 rendered << keyval->describedclassvalue("rendered",i);
1228 animated << keyval->describedclassvalue("rendered",i);
1229 if (rendered.nonnull()) {
1230 // make sure the object has a name so we don't overwrite its file
1231 if (rendered->name() == 0) {
1232 char ic[64];
1233 sprintf(ic,"%02d",i);
1234 rendered->set_name(ic);
1235 }
1236 if (grp->me() == 0) renderer->render(rendered);
1237 }
1238 else if (animated.nonnull()) {
1239 // make sure the object has a name so we don't overwrite its file
1240 if (animated->name() == 0) {
1241 char ic[64];
1242 sprintf(ic,"%02d",i);
1243 animated->set_name(ic);
1244 }
1245 if (grp->me() == 0) renderer->animate(animated);
1246 }
1247 }
1248 if (tim.nonnull()) tim->exit("render");
1249 }
1250 Ref<MolFreqAnimate> molfreqanim;
1251 molfreqanim << keyval->describedclassvalue("animate_modes");
1252 if (ready_for_freq && molfreq.nonnull()
1253 && molfreqanim.nonnull()) {
1254 if (tim.nonnull()) tim->enter("render");
1255 molfreq->animate(renderer, molfreqanim);
1256 if (tim.nonnull()) tim->exit("render");
1257 }
1258 }
1259
1260 if (mole.nonnull()) {
1261 if (print_mole)
1262 mole->print(ExEnv::out0());
1263
1264 if (do_pdb && grp->me() == 0) {
1265 ckptfile = new char[strlen(molname)+5];
1266 sprintf(ckptfile, "%s.pdb", molname);
1267 ofstream pdbfile(ckptfile);
1268 mole->molecule()->print_pdb(pdbfile);
1269 delete[] ckptfile;
1270 }
1271
1272 }
1273 else {
1274 ExEnv::out0() << "mpqc: The molecular energy object is null" << endl
1275 << " make sure \"mole\" specifies a MolecularEnergy derivative"
1276 << endl;
1277 }
1278 if (parsedkv.nonnull()) print_unseen(parsedkv, input);
1279
1280 if (print_timings)
1281 if (tim.nonnull()) tim->print(ExEnv::out0());
1282
1283 // here, we may gather the results
1284 // we start to construct the MPQC_Data object
1285 {
1286 Ref<Wavefunction> wfn;
1287 wfn << mole;
1288 ExEnv::out0() << "The number of atomic orbitals: " << wfn->ao_dimension()->n() << endl;
1289 ExEnv::out0() << "The AO density matrix is ";
1290 wfn->ao_density()->print(ExEnv::out0());
1291 ExEnv::out0() << "The natural density matrix is ";
1292 wfn->natural_density()->print(ExEnv::out0());
1293 ExEnv::out0() << "The Gaussian basis is " << wfn->basis()->name() << endl;
1294 ExEnv::out0() << "The Gaussians sit at the following centers: " << endl;
1295 for (int nr = 0; nr< wfn->basis()->ncenter(); ++nr) {
1296 ExEnv::out0() << nr << " basis function has its center at ";
1297 for (int i=0; i < 3; ++i)
1298 ExEnv::out0() << wfn->basis()->r(nr,i) << "\t";
1299 ExEnv::out0() << endl;
1300 }
1301 // GaussianShell is the actual orbital functions it seems ...
1302 //ExEnv::out0() << "There are the following Gaussian Shells: " << endl;
1303 SCVector3 r;
1304 r.x() = r.y() = r.z() = 10;
1305 ExEnv::out0() << "We get the following value at " << r << "." << endl;
1306 Ref<Integral> intgrl = Integral::get_default_integral();
1307 GaussianBasisSet::ValueData vdat(wfn->basis(), integral);
1308 ExEnv::out0() << "Value at (10,10,10) is " << EvaluateDensity(r, intgrl, vdat, wfn) << endl;
1309 boost::function<double (SCVector3 &r)> evaluator =
1310 boost::bind(&EvaluateDensity, _1, boost::ref(intgrl), boost::ref(vdat), boost::ref(wfn));
1311 ExEnv::out0() << "Check against values at " << r << "." << endl;
1312 int nbasis = wfn->basis()->nbasis();
1313 double *b_val = new double[nbasis];
1314 wfn->basis()->values(r, &vdat, b_val);
1315 for (int i=0; i<nbasis; i++) {
1316 //ExEnv::out0() << "Shell nr. " << nr << ": ";
1317 ExEnv::out0() << "Value at (10,10,10) is " << b_val[i] << endl;
1318 }
1319 // perform test integration of density
1320 double delta = 1.;
1321 double sum = 0.;
1322 for (r.x() = -10. ; r.x() < 10.; r.x() += delta)
1323 for (r.y() = -10. ; r.y() < 10.; r.y() += delta)
1324 for (r.z() = -10. ; r.z() < 10.; r.z() += delta) {
1325 wfn->basis()->values(r, &vdat, b_val);
1326 for (int i=0; i<nbasis; i++)
1327 sum += wfn->ao_density()->get_element(i,i)*b_val[i];
1328 }
1329 sum /= pow(20/delta,3);
1330 ExEnv::out0() << "Sum over domain [0:20]^3 with " << delta << " delta is " << sum << "." << endl;
1331 delete[] b_val;
1332 }
1333
1334 delete[] molname;
1335 SCFormIO::set_default_basename(0);
1336
1337 renderer = 0;
1338 molfreq = 0;
1339 molhess = 0;
1340 opt = 0;
1341 mole = 0;
1342 integral = 0;
1343 debugger = 0;
1344 thread = 0;
1345 tim = 0;
1346 keyval = 0;
1347 parsedkv = 0;
1348 grp = 0;
1349 memory = 0;
1350 clean_up();
1351
1352#if defined(HAVE_TIME) && defined(HAVE_CTIME)
1353 time_t t;
1354 time(&t);
1355 const char *tstr = ctime(&t);
1356#endif
1357 if (!tstr) {
1358 tstr = "UNKNOWN";
1359 }
1360 ExEnv::out0() << endl
1361 << indent << scprintf("End Time: %s", tstr) << endl;
1362
1363 if (output != 0) {
1364 ExEnv::set_out(&cout);
1365 delete outstream;
1366 }
1367
1368 return 0;
1369}
1370
1371double EvaluateDensity(SCVector3 &r, Ref<Integral> &intgrl, GaussianBasisSet::ValueData &vdat, Ref<Wavefunction> &wfn)
1372{
1373 ExEnv::out0() << "We get the following values at " << r << "." << endl;
1374 int nbasis = wfn->basis()->nbasis();
1375 double *b_val = new double[nbasis];
1376 wfn->basis()->values(r, &vdat, b_val);
1377 double sum=0.;
1378 for (int i=0; i<nbasis; i++)
1379 sum += b_val[i];
1380 delete[] b_val;
1381 return sum;
1382}
1383
1384int
1385main(int argc, char *argv[])
1386{
1387 try {
1388 try_main(argc, argv);
1389 }
1390 catch (SCException &e) {
1391 cout << argv[0] << ": ERROR: SC EXCEPTION RAISED:" << endl
1392 << e.what()
1393 << endl;
1394 clean_up();
1395 throw;
1396 }
1397 catch (bad_alloc &e) {
1398 cout << argv[0] << ": ERROR: MEMORY ALLOCATION FAILED:" << endl
1399 << e.what()
1400 << endl;
1401 clean_up();
1402 throw;
1403 }
1404 catch (exception &e) {
1405 cout << argv[0] << ": ERROR: EXCEPTION RAISED:" << endl
1406 << e.what()
1407 << endl;
1408 clean_up();
1409 throw;
1410 }
1411 catch (...) {
1412 cout << argv[0] << ": ERROR: UNKNOWN EXCEPTION RAISED" << endl;
1413 clean_up();
1414 throw;
1415 }
1416 return 0;
1417}
1418
1419/////////////////////////////////////////////////////////////////////////////
1420
1421// Local Variables:
1422// mode: c++
1423// c-file-style: "ETS"
1424// End:
Note: See TracBrowser for help on using the repository browser.