LCOV - code coverage report
Current view: top level - main - main.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 12 15 80.0 %
Date: 2024-10-11 08:09:47 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2012-2023 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             : /**
      30             :   This main uses only the interface published in
      31             :   Plumed.h. The object file generated from this .cpp
      32             :   is the only part of the plumed library that should
      33             :   not be linked with external MD codes, so as
      34             :   to avoid linker error.
      35             : */
      36        3441 : int main(int argc,char**argv) {
      37             : #ifdef __PLUMED_HAS_MPI
      38             :   bool nompi=false;
      39        7165 :   for(unsigned iarg=1; iarg<argc; iarg++) {
      40        6546 :     if(!std::strcmp(argv[iarg],"--no-mpi")) nompi=true;
      41        6546 :     if(!std::strcmp(argv[iarg],"--mpi"))    nompi=false;
      42             : // stop at first non-option
      43        6546 :     if(argv[iarg] && argv[iarg][0]!='-') break;
      44             :   }
      45        3441 :   if(!nompi) MPI_Init(&argc,&argv);
      46             : #endif
      47        3441 :   int ret=0;
      48             : 
      49             :   try {
      50             :     PLMD::Plumed p;
      51             :     p.cmd("CLTool setArgc",&argc);
      52        3441 :     p.cmd("CLTool setArgv",argv);
      53             : #ifdef __PLUMED_HAS_MPI
      54        3441 :     if(!nompi) {
      55             :       MPI_Comm comm;
      56         336 :       MPI_Comm_dup(MPI_COMM_WORLD,&comm);
      57             :       p.cmd("CLTool setMPIComm",&comm);
      58             :     }
      59             : #endif
      60             :     p.cmd("CLTool run",&ret);
      61             : // end block deletes p also in case an exception occurs
      62           0 :   } catch(...) {
      63             : // exception is rethrown and results in a call to terminate
      64           0 :     throw;
      65           0 :   }
      66             : 
      67             : #ifdef __PLUMED_HAS_MPI
      68        3441 :   if(!nompi) MPI_Finalize();
      69             : #endif
      70        3441 :   return ret;
      71             : }

Generated by: LCOV version 1.15