diff --git a/src/library.cpp b/src/library.cpp index a474f6a167..857883c0d9 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -4979,60 +4979,63 @@ int lammps_get_last_error_message(void *handle, char *buffer, int buf_size) { } // ---------------------------------------------------------------------- -// MDI functions +// MolSSI Drive Interface functions // ---------------------------------------------------------------------- /** Initialize an instance of LAMMPS as an MDI plugin - -\verbatim embed:rst -This function is called by the MDI Library when LAMMPS is run as a -plugin, and should not otherwise be used. The function initializes -MDI, then initializes an instance of LAMMPS. The command-line -arguments ``argc`` and ``argv`` used to initialize LAMMPS are recieved -from MDI. The LAMMPS instance runs an input file, which must include the -``mdi_engine`` command; when LAMMPS executes this command, it will begin -listening for commands from the driver. The name of the input file is -obtained from the ``-in`` command-line argument, which must be provided -by the driver. -\endverbatim * - * \param command string buffer corresponding to the command to be executed - * \param comm MDI communicator that can be used to communicated with the driver. - * \param class_obj pointer to an instance of an mdi/engine fix cast to ``void *``. +\verbatim embed:rst + +This function is called by the MolSSI Driver Interface library (MDI) +when LAMMPS is run as a plugin, and should not otherwise be used. + +The function initializes MDI, then creates and initializes an instance +of LAMMPS. The command-line arguments ``argc`` and ``argv`` used to +initialize LAMMPS are recieved from MDI. The LAMMPS instance runs an +input file, which must include the ``mdi_engine`` command; when LAMMPS +executes this command, it will begin listening for commands from the +driver. The name of the input file is obtained from the ``-in`` +command-line argument, which must be provided by the MDI driver. + +\endverbatim + * \param command string buffer corresponding to the command to be executed + * \param comm MDI communicator that can be used to communicated with the driver. + * \param class_obj pointer to an instance of an mdi/engine fix cast to ``void *``. * \return 0 on no error. */ int MDI_Plugin_init_lammps() { // initialize MDI int mdi_argc; - char** mdi_argv; - if ( MDI_Plugin_get_argc(&mdi_argc) ) + char **mdi_argv; + if (MDI_Plugin_get_argc(&mdi_argc)) MPI_Abort(MPI_COMM_WORLD, 1); - if ( MDI_Plugin_get_argv(&mdi_argv) ) + if (MDI_Plugin_get_argv(&mdi_argv)) MPI_Abort(MPI_COMM_WORLD, 1); - if ( MDI_Init(&mdi_argc, &mdi_argv) ) + if (MDI_Init(&mdi_argc, &mdi_argv)) MPI_Abort(MPI_COMM_WORLD, 1); // get the MPI intra-communicator for this code MPI_Comm mpi_world_comm = MPI_COMM_WORLD; - if ( MDI_MPI_get_world_comm(&mpi_world_comm) ) + if (MDI_MPI_get_world_comm(&mpi_world_comm)) MPI_Abort(MPI_COMM_WORLD, 1); // find the -in argument int iarg = 0; char *filename; bool found_filename = false; - while( iarg < mdi_argc && !found_filename ) { - if (strcmp(mdi_argv[iarg],"-in") == 0 || - strcmp(mdi_argv[iarg],"-i") == 0) { + while(iarg < mdi_argc && !found_filename) { + + if ((strcmp(mdi_argv[iarg],"-in") == 0) + || (strcmp(mdi_argv[iarg],"-i") == 0)) { + if (iarg+2 > mdi_argc) - MPI_Abort(MPI_COMM_WORLD, 1); + MPI_Abort(MPI_COMM_WORLD, 1); filename = mdi_argv[iarg+1]; found_filename = true; // remove -in argument from the command list mdi_argc -= 2; - for (int jarg=iarg; jarg < mdi_argc; jarg++) { - mdi_argv[jarg] = mdi_argv[jarg+2]; - } + for (int jarg=iarg; jarg < mdi_argc; jarg++) + mdi_argv[jarg] = mdi_argv[jarg+2]; } iarg++; } @@ -5048,30 +5051,30 @@ int MDI_Plugin_init_lammps() } /** Execute an MDI command - -\verbatim embed:rst -This function is called by the MDI Library when LAMMPS is run as a -plugin, and should not otherwise be used. The function executes a -single command from an external MDI driver. If the LAMMPS library -was compiled without ``-DLMP_USER_MDI``, the function will fail and -return a "1". -\endverbatim * +\verbatim embed:rst + +This function is called by the MolSSI Driver Interface Library (MDI) +when LAMMPS is run as a plugin, and should not otherwise be used. The +function executes a single command from an external MDI driver. If the +LAMMPS library was compiled without ``-DLMP_USER_MDI``, the function +will fail and return a "1". + +\endverbatim * \param command string buffer corresponding to the command to be executed * \param comm MDI communicator that can be used to communicated with the driver. * \param class_obj pointer to an instance of an mdi/engine fix cast to ``void *``. * \return 0 on no error, 1 on error. */ -int lammps_execute_mdi_command(const char* command, MDI_Comm comm, void* class_obj) +int lammps_execute_mdi_command(const char *command, MDI_Comm comm, void *class_obj) { #if defined(LMP_USER_MDI) - FixMDIEngine *mdi_fix = (FixMDIEngine*) class_obj; + FixMDIEngine *mdi_fix = (FixMDIEngine *) class_obj; return mdi_fix->execute_command(command, comm); #else return 1; #endif } - // Local Variables: // fill-column: 72 // End: