Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 : Copyright (c) 2012-2019 The plumed team
3 : (see the PEOPLE file at the root of the distribution for a list of names)
4 :
5 : See http://www.plumed.org for more information.
6 :
7 : This file is part of plumed, version 2.
8 :
9 : plumed is free software: you can redistribute it and/or modify
10 : it under the terms of the GNU Lesser General Public License as published by
11 : the Free Software Foundation, either version 3 of the License, or
12 : (at your option) any later version.
13 :
14 : plumed is distributed in the hope that it will be useful,
15 : but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : GNU Lesser General Public License for more details.
18 :
19 : You should have received a copy of the GNU Lesser General Public License
20 : along with plumed. If not, see <http://www.gnu.org/licenses/>.
21 : +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
22 : #include "wrapper/Plumed.h"
23 : #include <cstring>
24 :
25 : #ifdef __PLUMED_HAS_MPI
26 : #include <mpi.h>
27 : #endif
28 :
29 : using namespace std;
30 :
31 : /**
32 : This main uses only the interface published in
33 : Plumed.h. The object file generated from this .cpp
34 : is the only part of the plumed library that should
35 : not be linked with external MD codes, so as
36 : to avoid linker error.
37 : */
38 1597 : int main(int argc,char**argv) {
39 : #ifdef __PLUMED_HAS_MPI
40 : bool nompi=false;
41 1597 : if(argc>1 && !strcmp(argv[1],"--no-mpi")) nompi=true;
42 1597 : if(argc>1 && !strcmp(argv[1],"--mpi")) nompi=false;
43 1597 : if(!nompi) MPI_Init(&argc,&argv);
44 : #endif
45 1597 : int ret=0;
46 :
47 1597 : PLMD::Plumed* p=new PLMD::Plumed;
48 : p->cmd("CLTool setArgc",&argc);
49 1597 : p->cmd("CLTool setArgv",argv);
50 : #ifdef __PLUMED_HAS_MPI
51 1597 : if(!nompi) {
52 : MPI_Comm comm;
53 355 : MPI_Comm_dup(MPI_COMM_WORLD,&comm);
54 : p->cmd("CLTool setMPIComm",&comm);
55 : }
56 : #endif
57 : p->cmd("CLTool run",&ret);
58 1597 : delete p;
59 :
60 : #ifdef __PLUMED_HAS_MPI
61 1597 : if(!nompi) MPI_Finalize();
62 : #endif
63 1597 : return ret;
64 4791 : }
|