| 1 | //
 | 
|---|
| 2 | // mbptr12test.cc
 | 
|---|
| 3 | //
 | 
|---|
| 4 | // Copyright (C) Edward Valeev
 | 
|---|
| 5 | //
 | 
|---|
| 6 | // Author: Edward Valeev <edward.valeev@chemistry.gatech.edu>
 | 
|---|
| 7 | // Maintainer: EV
 | 
|---|
| 8 | //
 | 
|---|
| 9 | // This file is part of the SC Toolkit.
 | 
|---|
| 10 | //
 | 
|---|
| 11 | // The SC Toolkit is free software; you can redistribute it and/or modify
 | 
|---|
| 12 | // it under the terms of the GNU Library General Public License as published by
 | 
|---|
| 13 | // the Free Software Foundation; either version 2, or (at your option)
 | 
|---|
| 14 | // any later version.
 | 
|---|
| 15 | //
 | 
|---|
| 16 | // The SC Toolkit 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 Library General Public License for more details.
 | 
|---|
| 20 | //
 | 
|---|
| 21 | // You should have received a copy of the GNU Library General Public License
 | 
|---|
| 22 | // along with the SC Toolkit; see the file COPYING.LIB.  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 | #ifdef HAVE_CONFIG_H
 | 
|---|
| 29 | #include <scconfig.h>
 | 
|---|
| 30 | #endif
 | 
|---|
| 31 | 
 | 
|---|
| 32 | #include <string.h>
 | 
|---|
| 33 | 
 | 
|---|
| 34 | #include <sys/stat.h>
 | 
|---|
| 35 | #include <unistd.h>
 | 
|---|
| 36 | #include <new>
 | 
|---|
| 37 | 
 | 
|---|
| 38 | #include <util/keyval/keyval.h>
 | 
|---|
| 39 | #include <util/group/message.h>
 | 
|---|
| 40 | #include <util/group/pregtime.h>
 | 
|---|
| 41 | #include <util/misc/bug.h>
 | 
|---|
| 42 | #include <util/misc/formio.h>
 | 
|---|
| 43 | #include <util/state/stateio.h>
 | 
|---|
| 44 | #include <util/state/state_bin.h>
 | 
|---|
| 45 | 
 | 
|---|
| 46 | #include <math/scmat/repl.h>
 | 
|---|
| 47 | #include <math/scmat/dist.h>
 | 
|---|
| 48 | 
 | 
|---|
| 49 | #include <chemistry/molecule/coor.h>
 | 
|---|
| 50 | #include <chemistry/molecule/energy.h>
 | 
|---|
| 51 | 
 | 
|---|
| 52 | #include <chemistry/qc/scf/clhf.h>
 | 
|---|
| 53 | 
 | 
|---|
| 54 | #include <chemistry/qc/mbptr12/mbptr12.h>
 | 
|---|
| 55 | 
 | 
|---|
| 56 | using namespace std;
 | 
|---|
| 57 | using namespace sc;
 | 
|---|
| 58 | 
 | 
|---|
| 59 | // Force linkages:
 | 
|---|
| 60 | #ifndef __PIC__
 | 
|---|
| 61 | static ForceLink<CLHF> fl0a;
 | 
|---|
| 62 | 
 | 
|---|
| 63 | static ForceLink<MBPT2_R12> fl0e;
 | 
|---|
| 64 | 
 | 
|---|
| 65 | static ForceLink<ReplSCMatrixKit> fl6;
 | 
|---|
| 66 | static ForceLink<DistSCMatrixKit> fl7;
 | 
|---|
| 67 | 
 | 
|---|
| 68 | # ifdef HAVE_SYSV_IPC
 | 
|---|
| 69 | #   include <util/group/messshm.h>
 | 
|---|
| 70 |     static ForceLink<ShmMessageGrp> fl8;
 | 
|---|
| 71 | # endif
 | 
|---|
| 72 | static ForceLink<ProcMessageGrp> fl9;
 | 
|---|
| 73 | # ifdef HAVE_NX_H
 | 
|---|
| 74 | #  include <util/group/messpgon.h>
 | 
|---|
| 75 |     static ForceLink<ParagonMessageGrp> fl10;
 | 
|---|
| 76 | # endif
 | 
|---|
| 77 | #endif
 | 
|---|
| 78 | 
 | 
|---|
| 79 | Ref<RegionTimer> tim;
 | 
|---|
| 80 | Ref<MessageGrp> grp;
 | 
|---|
| 81 | 
 | 
|---|
| 82 | static Ref<MessageGrp>
 | 
|---|
| 83 | init_mp(const Ref<KeyVal>& keyval)
 | 
|---|
| 84 | {
 | 
|---|
| 85 |   // if we are on a paragon then use a ParagonMessageGrp
 | 
|---|
| 86 |   // otherwise read the message group from the input file
 | 
|---|
| 87 |   grp << keyval->describedclassvalue("message");
 | 
|---|
| 88 | 
 | 
|---|
| 89 |   if (grp.nonnull()) MessageGrp::set_default_messagegrp(grp);
 | 
|---|
| 90 |   else grp = MessageGrp::get_default_messagegrp();
 | 
|---|
| 91 | 
 | 
|---|
| 92 |   Ref<Debugger> debugger; debugger << keyval->describedclassvalue(":debug");
 | 
|---|
| 93 |   // Let the debugger know the name of the executable and the node
 | 
|---|
| 94 |   if (debugger.nonnull()) {
 | 
|---|
| 95 |     debugger->set_exec("mbptr12test");
 | 
|---|
| 96 |     debugger->set_prefix(grp->me());
 | 
|---|
| 97 |     debugger->debug("curt is a hog");
 | 
|---|
| 98 |   }
 | 
|---|
| 99 |   
 | 
|---|
| 100 |   tim = new ParallelRegionTimer(grp,"mbptr12test",1,0);
 | 
|---|
| 101 |   RegionTimer::set_default_regiontimer(tim);
 | 
|---|
| 102 | 
 | 
|---|
| 103 |   SCFormIO::set_printnode(0);
 | 
|---|
| 104 |   SCFormIO::init_mp(grp->me());
 | 
|---|
| 105 |   //SCFormIO::set_debug(1);
 | 
|---|
| 106 | 
 | 
|---|
| 107 |   SCFormIO::setindent(ExEnv::out0(), 2);
 | 
|---|
| 108 |   SCFormIO::setindent(cerr, 2);
 | 
|---|
| 109 |   
 | 
|---|
| 110 |   return grp;
 | 
|---|
| 111 | }
 | 
|---|
| 112 | 
 | 
|---|
| 113 | main(int argc, char**argv)
 | 
|---|
| 114 | {
 | 
|---|
| 115 |   const char *input =      (argc > 1)? argv[1] : SRCDIR "/mbptr12test.in";
 | 
|---|
| 116 |   const char *keyword =    (argc > 2)? argv[2] : "mole";
 | 
|---|
| 117 |   const char *optkeyword = (argc > 3)? argv[3] : "opt";
 | 
|---|
| 118 | 
 | 
|---|
| 119 |   // open keyval input
 | 
|---|
| 120 |   Ref<KeyVal> rpkv(new ParsedKeyVal(input));
 | 
|---|
| 121 | 
 | 
|---|
| 122 |   init_mp(rpkv);
 | 
|---|
| 123 | 
 | 
|---|
| 124 |   tim->enter("input");
 | 
|---|
| 125 |   
 | 
|---|
| 126 |   if (rpkv->exists("matrixkit")) {
 | 
|---|
| 127 |     Ref<SCMatrixKit> kit; kit << rpkv->describedclassvalue("matrixkit");
 | 
|---|
| 128 |     SCMatrixKit::set_default_matrixkit(kit);
 | 
|---|
| 129 |   }
 | 
|---|
| 130 |   
 | 
|---|
| 131 |   struct stat sb;
 | 
|---|
| 132 |   Ref<MolecularEnergy> mole;
 | 
|---|
| 133 | 
 | 
|---|
| 134 |   if (stat("mbptr12test.ckpt",&sb)==0 && sb.st_size) {
 | 
|---|
| 135 |     StateInBin si("mbptr12test.ckpt");
 | 
|---|
| 136 |     //    opt << SavableState::restore_state(si);
 | 
|---|
| 137 |     //    mole << opt->function();
 | 
|---|
| 138 |   } else {
 | 
|---|
| 139 |     mole << rpkv->describedclassvalue(keyword);
 | 
|---|
| 140 |   }
 | 
|---|
| 141 | 
 | 
|---|
| 142 |   tim->exit("input");
 | 
|---|
| 143 | 
 | 
|---|
| 144 |   if (mole.nonnull()) {
 | 
|---|
| 145 |     ExEnv::out0() << indent << "energy: " << mole->energy() << endl;
 | 
|---|
| 146 |     if (mole->value_implemented()) {
 | 
|---|
| 147 |       ExEnv::out0() << indent
 | 
|---|
| 148 |                    << scprintf("value of mole is %20.15f\n\n", mole->energy());
 | 
|---|
| 149 |     }
 | 
|---|
| 150 | 
 | 
|---|
| 151 |     mole->print(ExEnv::out0());
 | 
|---|
| 152 |   }
 | 
|---|
| 153 | 
 | 
|---|
| 154 |   StateOutBin so("mbptr12test.wfn");
 | 
|---|
| 155 |   SavableState::save_state(mole.pointer(),so);
 | 
|---|
| 156 |   
 | 
|---|
| 157 |   tim->print(ExEnv::out0());
 | 
|---|
| 158 | 
 | 
|---|
| 159 |   tim = 0;
 | 
|---|
| 160 |   grp = 0;
 | 
|---|
| 161 |   RegionTimer::set_default_regiontimer(0);
 | 
|---|
| 162 |   MessageGrp::set_default_messagegrp(0);
 | 
|---|
| 163 | 
 | 
|---|
| 164 |   return 0;
 | 
|---|
| 165 | }
 | 
|---|
| 166 | 
 | 
|---|
| 167 | /////////////////////////////////////////////////////////////////////////////
 | 
|---|
| 168 | 
 | 
|---|
| 169 | // Local Variables:
 | 
|---|
| 170 | // mode: c++
 | 
|---|
| 171 | // c-file-style: "CLJ-CONDENSED"
 | 
|---|
| 172 | // End:
 | 
|---|