LCOV - code coverage report
Current view: top level - main - main.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 15 18 83.3 %
Date: 2024-10-18 14:00:25 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        5263 : int main(int argc,char**argv) {
      37             : #ifdef __PLUMED_HAS_MPI
      38             :   bool nompi=false;
      39       10968 :   for(unsigned iarg=1; iarg<argc; iarg++) {
      40       10174 :     if(!std::strcmp(argv[iarg],"--no-mpi")) nompi=true;
      41       10174 :     if(!std::strcmp(argv[iarg],"--mpi"))    nompi=false;
      42             : // stop at first non-option
      43       10174 :     if(argv[iarg] && argv[iarg][0]!='-') break;
      44             :   }
      45        5263 :   if(!nompi) MPI_Init(&argc,&argv);
      46             : #endif
      47        5263 :   int ret=0;
      48             : 
      49             :   try {
      50             :     PLMD::Plumed p;
      51        5263 :     p.cmd("CLTool setArgc",&argc);
      52        5263 :     p.cmd("CLTool setArgv",argv, {argc});
      53             : #ifdef __PLUMED_HAS_MPI
      54        5263 :     if(!nompi) {
      55             :       MPI_Comm comm;
      56         352 :       MPI_Comm_dup(MPI_COMM_WORLD,&comm);
      57         704 :       p.cmd("CLTool setMPIComm",&comm);
      58             :     }
      59             : #endif
      60       10526 :     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        5263 :   if(!nompi) MPI_Finalize();
      69             : #endif
      70        5263 :   return ret;
      71             : }

Generated by: LCOV version 1.16