From 8b3c70165b8b59130172dabda5d68c4a2656277d Mon Sep 17 00:00:00 2001 From: Dmitry Morozov Date: Thu, 3 Jun 2021 14:33:14 +0000 Subject: [PATCH] Added QM input file name as command-line parameter for grompp Part of #3172 --- api/legacy/include/gromacs/fileio/filetypes.h | 4 +++- src/gromacs/fileio/filetypes.cpp | 5 +++-- src/gromacs/gmxpreprocess/grompp.cpp | 12 ++++++++++-- src/gromacs/options/filenameoption.cpp | 6 +++--- src/gromacs/options/optionfiletype.h | 1 + src/gromacs/utility/mdmodulesnotifiers.h | 15 ++++++++++++++- 6 files changed, 34 insertions(+), 9 deletions(-) diff --git a/api/legacy/include/gromacs/fileio/filetypes.h b/api/legacy/include/gromacs/fileio/filetypes.h index aefcdab357..3a47da0234 100644 --- a/api/legacy/include/gromacs/fileio/filetypes.h +++ b/api/legacy/include/gromacs/fileio/filetypes.h @@ -3,7 +3,8 @@ * * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. - * Copyright (c) 2013,2014,2015,2019,2020, by the GROMACS development team, led by + * Copyright (c) 2013,2014,2015,2019,2020 by the GROMACS development team. + * Copyright (c) 2021, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -85,6 +86,7 @@ enum GromacsFileType efXPM, efRND, efCSV, + efQMI, efNR }; diff --git a/src/gromacs/fileio/filetypes.cpp b/src/gromacs/fileio/filetypes.cpp index b3e9be6d20..0821908cd8 100644 --- a/src/gromacs/fileio/filetypes.cpp +++ b/src/gromacs/fileio/filetypes.cpp @@ -4,7 +4,7 @@ * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team. - * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by + * Copyright (c) 2018,2019,2020,2021, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -144,7 +144,8 @@ static const t_deffile deffile[efNR] = { { eftASC, ".cub", "pot", nullptr, "Gaussian cube file" }, { eftASC, ".xpm", "root", nullptr, "X PixMap compatible matrix file" }, { eftASC, "", "rundir", nullptr, "Run directory" }, - { eftASC, ".csv", "bench", nullptr, "CSV data file" } + { eftASC, ".csv", "bench", nullptr, "CSV data file" }, + { eftASC, ".inp", "topol-qmmm", nullptr, "Input file for QM program" } }; const char* ftp2ext(int ftp) diff --git a/src/gromacs/gmxpreprocess/grompp.cpp b/src/gromacs/gmxpreprocess/grompp.cpp index d33220a6f6..394143e8e6 100644 --- a/src/gromacs/gmxpreprocess/grompp.cpp +++ b/src/gromacs/gmxpreprocess/grompp.cpp @@ -1858,7 +1858,9 @@ int gmx_grompp(int argc, char* argv[]) { efEDR, "-e", nullptr, ffOPTRD }, /* This group is needed by the VMD viewer as the start configuration for IMD sessions: */ { efGRO, "-imd", "imdgroup", ffOPTWR }, - { efTRN, "-ref", "rotref", ffOPTRW | ffALLOW_MISSING } }; + { efTRN, "-ref", "rotref", ffOPTRW | ffALLOW_MISSING }, + /* This group is needed by the QMMM MDModule: */ + { efQMI, "-qmi", nullptr, ffOPTRD } }; #define NFILE asize(fnm) /* Command line options */ @@ -1930,9 +1932,15 @@ int gmx_grompp(int argc, char* argv[]) // to eventual notifications during pre-processing their data mdModules.subscribeToPreProcessingNotifications(); - // And notify MdModules of existing logger + // Notify MDModules of existing logger mdModules.notifiers().preProcessingNotifier_.notify(logger); + // Notify QMMM MDModule of external QM input file command-line option + { + gmx::QMInputFileName qmInputFileName = { ftp2bSet(efQMI, NFILE, fnm), ftp2fn(efQMI, NFILE, fnm) }; + mdModules.notifiers().preProcessingNotifier_.notify(qmInputFileName); + } + if (bVerbose) { GMX_LOG(logger.info) diff --git a/src/gromacs/options/filenameoption.cpp b/src/gromacs/options/filenameoption.cpp index 0c755aeced..b7c291d23a 100644 --- a/src/gromacs/options/filenameoption.cpp +++ b/src/gromacs/options/filenameoption.cpp @@ -81,9 +81,9 @@ struct FileTypeMapping }; //! Mappings from OptionFileType to file types in filetypes.h. -constexpr EnumerationArray sc_fileTypeMapping = { efTPS, efTPR, efTRX, - efEDR, efPDB, efNDX, - efXVG, efDAT, efCSV }; +constexpr EnumerationArray sc_fileTypeMapping = { efTPS, efTPR, efTRX, efEDR, + efPDB, efNDX, efXVG, efDAT, + efCSV, efQMI }; /******************************************************************** * FileTypeHandler diff --git a/src/gromacs/options/optionfiletype.h b/src/gromacs/options/optionfiletype.h index 70b672d857..619091cd39 100644 --- a/src/gromacs/options/optionfiletype.h +++ b/src/gromacs/options/optionfiletype.h @@ -62,6 +62,7 @@ enum class OptionFileType : int Plot, GenericData, Csv, + QMInput, Count }; diff --git a/src/gromacs/utility/mdmodulesnotifiers.h b/src/gromacs/utility/mdmodulesnotifiers.h index 9800efe324..101cb09d0f 100644 --- a/src/gromacs/utility/mdmodulesnotifiers.h +++ b/src/gromacs/utility/mdmodulesnotifiers.h @@ -138,6 +138,17 @@ struct MdRunInputFilename std::string mdRunFilename_; }; +/*! \libinternal \brief Notification for QM program input filename + * provided by user as command-line argument for grompp + */ +struct QMInputFileName +{ + //! Flag if QM Input File has been provided by user + bool hasQMInputFileName_ = false; + //! The name of the QM Input file (.inp) + std::string qmInputFileName_; +}; + /*! \libinternal * \brief Group of notifers to organize that MDModules * can receive callbacks they subscribe to. @@ -242,13 +253,15 @@ struct MDModulesNotifiers * IndexGroupsAndNames provides modules with atom indices and their names * KeyValueTreeObjectBuilder enables writing of module internal data to * .tpr files. + * QMInputFileName Allows QMMM module to know if user provided external QM input file */ BuildMDModulesNotifier::type preProcessingNotifier_; + KeyValueTreeObjectBuilder, + QMInputFileName>::type preProcessingNotifier_; /*! \brief Handles subscribing and calling checkpointing callback functions. * -- 2.22.0