Gromacs
2024.3
|
#include "gmxpre.h"
#include "cmdlineinit.h"
#include <cstring>
#include <memory>
#include <utility>
#include "gromacs/commandline/cmdlinemodulemanager.h"
#include "gromacs/commandline/cmdlineoptionsmodule.h"
#include "gromacs/commandline/cmdlineprogramcontext.h"
#include "gromacs/utility/basenetwork.h"
#include "gromacs/utility/datafilefinder.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/futil.h"
#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/gmxmpi.h"
#include "gromacs/utility/init.h"
#include "gromacs/utility/programcontext.h"
#include "gromacs/utility/smalloc.h"
Implements functions from cmdlineinit.h.
Functions | |
void | gmx::anonymous_namespace{cmdlineinit.cpp}::broadcastWorld (int size, void *buffer) |
Broadcasts given data from rank zero to all other ranks. | |
void | gmx::anonymous_namespace{cmdlineinit.cpp}::broadcastArguments (int *argc, char ***argv) |
Broadcasts command-line arguments to all ranks. More... | |
CommandLineProgramContext & | gmx::initForCommandLine (int *argc, char ***argv) |
Initializes the GROMACS library for command-line use. More... | |
void | gmx::finalizeForCommandLine () |
Deinitializes the GROMACS library after initForCommandLine(). More... | |
int | gmx::processExceptionAtExitForCommandLine (const std::exception &ex) |
Handles an exception and deinitializes after initForCommandLine. More... | |
int | gmx::runCommandLineModule (int argc, char *argv[], ICommandLineModule *module) |
Implements a main() method that runs a single module. More... | |
int | gmx::runCommandLineModule (int argc, char *argv[], const char *name, const char *description, std::function< std::unique_ptr< ICommandLineOptionsModule >()> factory) |
Implements a main() method that runs a single module. More... | |
int | gmx_run_cmain (int argc, char *argv[], int(*mainFunction)(int, char *[])) |
Implements a main() method that runs a given C main function. More... | |
Variables | |
std::unique_ptr < CommandLineProgramContext > | gmx::anonymous_namespace{cmdlineinit.cpp}::g_commandLineContext |
Global context instance initialized in initForCommandLine(). | |
std::unique_ptr< DataFileFinder > | gmx::anonymous_namespace{cmdlineinit.cpp}::g_libFileFinder |
Global library data file finder that respects GMXLIB. | |
int gmx_run_cmain | ( | int | argc, |
char * | argv[], | ||
int(*)(int, char *[]) | mainFunction | ||
) |
Implements a main() method that runs a given C main function.
argc | argc passed to main(). |
argv | argv passed to main(). |
mainFunction | The main()-like method to wrap. |
This method creates a dummy command line module that does its processing by calling mainFunction
. It then runs this module as with gmx::runCommandLineModule(). This allows the resulting executable to handle common options and do other common actions (e.g., startup headers) without duplicate code in the main methods.
mainFunction
should call parse_common_args() to process its command-line arguments.
Usage:
Does not throw. All exceptions are caught and handled internally.