- Timestamp:
- Mar 9, 2017, 9:43:23 AM (8 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_StructOpt_integration_tests, AutomationFragmentation_failures, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_ChronosMutex, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, GeometryObjects, Gui_displays_atomic_force_velocity, IndependentFragmentGrids_IntegrationTest, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, PartialCharges_OrthogonalSummation, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, RotateToPrincipalAxisSystem_UndoRedo, StoppableMakroAction, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, Ubuntu_1604_changes, stable
- Children:
- 7672284
- Parents:
- ba1152
- git-author:
- Frederik Heber <heber@…> (03/08/17 08:11:59)
- git-committer:
- Frederik Heber <heber@…> (03/09/17 09:43:23)
- Location:
- src/Jobs
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Jobs/MPQCJob_Work.cpp
rba1152 rfbf005 1 /* 2 * Project: MoleCuilder 1 /* Project: MoleCuilder 3 2 * Description: creates and alters molecular systems 4 3 * Copyright (C) 2017 Frederik Heber. All rights reserved. 5 * 4 * 6 5 * 7 6 * This file is part of MoleCuilder. … … 21 20 */ 22 21 23 /* 24 * MPQCJobi_Work.cpp 22 /** \file MPCJob_Work.cpp 25 23 * 26 * Created on: Feb 20, 201727 * Author: heber24 * Function implementations for the class vector. 25 * 28 26 */ 29 30 27 31 28 // include config.h … … 34 31 #endif 35 32 33 #include <sstream> 34 35 #include "MPQCJob.hpp" 36 37 #include "CodePatterns/Log.hpp" 38 39 #ifdef HAVE_JOBMARKET 36 40 // include headers that implement a archive in simple text format 37 41 // otherwise BOOST_CLASS_EXPORT_IMPLEMENT has no effect 38 42 #include <boost/archive/text_oarchive.hpp> 39 43 #include <boost/archive/text_iarchive.hpp> 44 #include <boost/tokenizer.hpp> 40 45 41 #include " CodePatterns/MemDebug.hpp"46 #include "JobMarket/Results/FragmentResult.hpp" 42 47 43 #include "MPQCJob.hpp" 48 #include <fstream> 49 #include <iostream> 50 #include <stdlib.h> 44 51 45 #include <sstream> 52 #include <util/class/scexception.h> 53 #include <util/group/message.h> 46 54 47 #include " CodePatterns/Log.hpp"55 #include "mpqc.h" 48 56 57 using namespace std; 58 59 using namespace sc; 60 61 FragmentResult::ptr MPQCJob::Work() 62 { 63 char mpqc[] = "mpqc" ; 64 char **argv = new char*[1]; 65 argv[0] = &mpqc[0]; 66 int argc = 1; 67 68 // now comes the actual work 69 mpqc::InitValues initvalues; 70 int nfilebase = (int) inputfile.length(); 71 initvalues.in_char_array = new char[nfilebase + 1]; 72 strncpy(initvalues.in_char_array, inputfile.c_str(), nfilebase); 73 initvalues.in_char_array[nfilebase] = '\0'; 74 initvalues.grp = MessageGrp::get_default_messagegrp(); 75 // create unique, temporary name and check whether it exists 76 char *tempfilename = NULL; 77 { 78 std::ifstream test; 79 do { 80 if (initvalues.output != NULL) // free buffer from last round 81 delete initvalues.output; 82 char filename_template[] = "mpqc_temp_XXXXXX\0"; 83 char filename_suffix[] = ".in\0"; 84 tempfilename = (char *) malloc ( (strlen(filename_template)+strlen(filename_suffix)+2)*(sizeof(char))); 85 strncpy(tempfilename, mktemp(filename_template), strlen(filename_template)); 86 tempfilename[strlen(filename_template)] = '\0'; 87 strncat(tempfilename, filename_suffix, strlen(filename_suffix)); 88 initvalues.output = tempfilename; 89 //free(tempfilename); // don't free! output takes over pointer! 90 test.open(initvalues.output); 91 } while (test.good()); // test whether file does not(!) exist 92 test.close(); 93 } 94 // put info how to sample the density into MPQCData 95 MPQCData data(grid); 96 data.DoLongrange = DoLongrange; // set whether we sample the density 97 data.DoValenceOnly = DoValenceOnly; // set whether we sample just valence electron and nuclei densities 98 // now call work horse 99 try { 100 mpqc::mainFunction(initvalues, argc, argv, static_cast<void *>(&data)); 101 } 102 catch (SCException &e) { 103 cout << argv[0] << ": ERROR: SC EXCEPTION RAISED:" << endl 104 << e.what() 105 << endl; 106 detail::clean_up(); 107 } 108 109 //delete[] in_char_array; // is deleted in mainFunction() 110 if (initvalues.output != 0) { 111 free(tempfilename); 112 } 113 delete[] argv; 114 initvalues.grp = NULL; 115 116 // place into returnstream 117 std::stringstream returnstream; 118 boost::archive::text_oarchive oa(returnstream); 119 oa << data; 120 121 FragmentResult::ptr s( new FragmentResult(getId(), returnstream.str()) ); 122 if (s->exitflag != 0) 123 cerr << "Job #" << s->getId() << " failed to reach desired accuracy." << endl; 124 125 return s; 126 } 127 #else 49 128 FragmentResult::ptr MPQCJob::Work() 50 129 { … … 67 146 return ptr; 68 147 } 148 #endif 69 149 150 // we need to explicitly instantiate the serialization functions as 151 // its is only serialized through its base class FragmentJob 152 BOOST_CLASS_EXPORT_IMPLEMENT(MPQCJob) -
src/Jobs/Makefile.am
rba1152 rfbf005 56 56 57 57 lib_LTLIBRARIES += \ 58 libMolecuilderJobs.la 58 libMolecuilderJobs.la \ 59 libmolecuilder_mpqc_extract.la 59 60 noinst_LTLIBRARIES += \ 60 61 libMolecuilderJobs_Work.la 62 63 ### libmolecuilder_mpqc_extract.la 64 libmolecuilder_mpqc_extract_la_SOURCES = \ 65 Jobs/mpqc_extract.cc \ 66 $(top_srcdir)/ThirdParty/mpqc_open/src/bin/mpqc/mpqc.h 67 libmolecuilder_mpqc_extract_la_LDFLAGS = \ 68 $(AM_CPPFLAGS) \ 69 -L$(abs_top_builddir)/../JobMarket/src/JobMarket/.libs -Wl,-rpath,$(abs_top_builddir)/../JobMarket/src/JobMarket/.libs \ 70 -L$(abs_top_builddir)/../../src/.libs -Wl,-rpath,$(abs_top_builddir)/../../src/.libs \ 71 $(BOOST_SYSTEM_LDFLAGS) 72 libmolecuilder_mpqc_extract_la_CPPFLAGS = \ 73 $(AM_CPPFLAGS) \ 74 ${CodePatterns_CFLAGS} ${JobMarket_CFLAGS} \ 75 $(BOOST_SYSTEM_CFLAGS) \ 76 -DHAVE_MPQCDATA \ 77 -DHAVE_JOBMARKET \ 78 -I$(top_builddir)/ThirdParty/mpqc_open/src/lib \ 79 -I$(top_srcdir)/ThirdParty/mpqc_open/src/lib \ 80 -I$(top_srcdir)/ThirdParty/mpqc_open/src/bin/mpqc 81 libmolecuilder_mpqc_extract_la_LIBADD = \ 82 libMolecuilderJobs.la \ 83 libMolecuilderFragmentationSummation.la \ 84 -lboost_serialization 85 86 ### libMolecuilderJobs_Work.la 87 libMolecuilderJobs_Work_la_CPPFLAGS = \ 88 $(AM_CPPFLAGS) ${BOOST_CPPFLAGS} ${CodePatterns_CFLAGS} ${JobMarket_CFLAGS} -Dvmg_float=double -Dvmg_int=int $(VMG_CFLAGS) \ 89 -I$(top_builddir)/ThirdParty/mpqc_open/src/lib \ 90 -I$(top_srcdir)/ThirdParty/mpqc_open/src/lib \ 91 -I$(top_srcdir)/ThirdParty/mpqc_open/src/bin/mpqc 92 libMolecuilderJobs_Work_la_LDFLAGS = $(AM_LDFLAGS) 93 if CONDJOBMARKET 94 libMolecuilderJobs_Work_la_LDFLAGS += \ 95 $(JobMarket_LDFLAGS) 96 endif 97 98 ### libMolecuilderJobs.la 61 99 libMolecuilderJobs_la_includedir = $(includedir)/MoleCuilder/ 62 100 nobase_libMolecuilderJobs_la_include_HEADERS = $(JOBSHEADER) 63 libMolecuilderJobs_la_CPPFLAGS = $(AM_CPPFLAGS) ${BOOST_CPPFLAGS} ${CodePatterns_CFLAGS} ${JobMarket_CFLAGS} -Dvmg_float=double -Dvmg_int=int $(VMG_CFLAGS)64 libMolecuilderJobs_Work_la_CPPFLAGS =$(AM_CPPFLAGS) ${BOOST_CPPFLAGS} ${CodePatterns_CFLAGS} ${JobMarket_CFLAGS} -Dvmg_float=double -Dvmg_int=int $(VMG_CFLAGS)101 libMolecuilderJobs_la_CPPFLAGS = \ 102 $(AM_CPPFLAGS) ${BOOST_CPPFLAGS} ${CodePatterns_CFLAGS} ${JobMarket_CFLAGS} -Dvmg_float=double -Dvmg_int=int $(VMG_CFLAGS) 65 103 libMolecuilderJobs_la_LDFLAGS = $(AM_LDFLAGS) \ 66 104 $(BOOST_IOSTREAMS_LDFLAGS) \ 67 105 $(BOOST_SERIALIZATION_LDFLAGS) \ 68 106 $(BOOST_SYSTEM_LDFLAGS) 69 libMolecuilderJobs_Work_la_LDFLAGS = $(AM_LDFLAGS)70 if CONDJOBMARKET71 107 libMolecuilderJobs_la_LDFLAGS += \ 72 108 $(JobMarket_LDFLAGS) 73 libMolecuilderJobs_Work_la_LDFLAGS += \74 $(JobMarket_LDFLAGS)75 endif76 77 109 libMolecuilderJobs_la_LDFLAGS += \ 78 110 $(CodePatterns_LDFLAGS) … … 87 119 endif 88 120 endif 89 90 121 if CONDJOBMARKET 91 122 libMolecuilderJobs_la_LIBADD += \ 92 123 $(JobMarket_LIBS) 93 124 libMolecuilderJobs_Work_la_LIBADD = \ 125 $(top_builddir)/ThirdParty/mpqc_open/src/bin/mpqc/libmolecuilder_mpqc.la \ 126 libmolecuilder_mpqc_extract.la \ 94 127 $(JobMarket_LIBS) 95 128 endif
Note:
See TracChangeset
for help on using the changeset viewer.