From 7b5c0b8343190b55bcdfa6e88036b51ae31c7afc Mon Sep 17 00:00:00 2001 From: Berk Hess Date: Mon, 12 Aug 2013 11:08:13 +0200 Subject: [PATCH] fixed parallel normal modes with PME When doing a normal mode calculation with PME and (thread-)MPI, the PME forces were incorrect. Also fixed some EM/NM output layout. Fixes #1308 Change-Id: Ia7862fa62e235336c546824afdcbe28f37b145c5 --- src/kernel/runner.c | 5 ++-- src/mdlib/minimize.c | 70 +++++++++++++++++++++++--------------------- 2 files changed, 39 insertions(+), 36 deletions(-) diff --git a/src/kernel/runner.c b/src/kernel/runner.c index 74f6a933ea..285f926414 100644 --- a/src/kernel/runner.c +++ b/src/kernel/runner.c @@ -385,7 +385,7 @@ static int get_nthreads_mpi(const gmx_hw_info_t *hwinfo, if (inputrec->eI == eiNM || EI_TPI(inputrec->eI)) { - /* Steps are divided over the nodes iso splitting the atoms */ + /* Dims/steps are divided over the nodes iso splitting the atoms */ min_atoms_per_mpi_thread = 0; } else @@ -1312,7 +1312,8 @@ int mdrunner(gmx_hw_opt_t *hw_opt, cr->duty = (DUTY_PP | DUTY_PME); npme_major = 1; npme_minor = 1; - if (!EI_TPI(inputrec->eI)) + /* NM and TPI perform single node energy calculations in parallel */ + if (!(inputrec->eI == eiNM || EI_TPI(inputrec->eI))) { npme_major = cr->nnodes; } diff --git a/src/mdlib/minimize.c b/src/mdlib/minimize.c index 250e64ae6b..2dfe20bf49 100644 --- a/src/mdlib/minimize.c +++ b/src/mdlib/minimize.c @@ -80,6 +80,7 @@ #include "pme.h" #include "bondf.h" #include "gmx_omp_nthreads.h" +#include "md_logging.h" typedef struct { @@ -138,25 +139,25 @@ static void warn_step(FILE *fp, real ftol, gmx_bool bLastStep, gmx_bool bConstra if (bLastStep) { sprintf(buffer, - "\nEnergy minimization reached the maximum number" - "of steps before the forces reached the requested" + "\nEnergy minimization reached the maximum number " + "of steps before the forces reached the requested " "precision Fmax < %g.\n", ftol); } else { sprintf(buffer, - "\nEnergy minimization has stopped, but the forces have" - "not converged to the requested precision Fmax < %g (which" - "may not be possible for your system). It stopped" - "because the algorithm tried to make a new step whose size" - "was too small, or there was no change in the energy since" - "last step. Either way, we regard the minimization as" - "converged to within the available machine precision," + "\nEnergy minimization has stopped, but the forces have " + "not converged to the requested precision Fmax < %g (which " + "may not be possible for your system). It stopped " + "because the algorithm tried to make a new step whose size " + "was too small, or there was no change in the energy since " + "last step. Either way, we regard the minimization as " + "converged to within the available machine precision, " "given your starting configuration and EM parameters.\n%s%s", ftol, sizeof(real) < sizeof(double) ? - "\nDouble precision normally gives you higher accuracy, but" - "this is often not needed for preparing to run molecular" + "\nDouble precision normally gives you higher accuracy, but " + "this is often not needed for preparing to run molecular " "dynamics.\n" : "", bConstrain ? @@ -2609,7 +2610,7 @@ double do_nm(FILE *fplog, t_commrec *cr, rvec mu_tot; rvec *fneg, *dfdx; gmx_bool bSparse; /* use sparse matrix storage format */ - size_t sz; + size_t sz=0; gmx_sparsematrix_t * sparse_matrix = NULL; real * full_matrix = NULL; em_state_t * state_work; @@ -2657,32 +2658,35 @@ double do_nm(FILE *fplog, t_commrec *cr, */ if (EEL_FULL(fr->eeltype) || fr->rlist == 0.0) { - fprintf(stderr, "Non-cutoff electrostatics used, forcing full Hessian format.\n"); + md_print_info(cr, fplog, "Non-cutoff electrostatics used, forcing full Hessian format.\n"); bSparse = FALSE; } else if (top_global->natoms < 1000) { - fprintf(stderr, "Small system size (N=%d), using full Hessian format.\n", top_global->natoms); + md_print_info(cr, fplog, "Small system size (N=%d), using full Hessian format.\n", top_global->natoms); bSparse = FALSE; } else { - fprintf(stderr, "Using compressed symmetric sparse Hessian format.\n"); + md_print_info(cr, fplog, "Using compressed symmetric sparse Hessian format.\n"); bSparse = TRUE; } - sz = DIM*top_global->natoms; + if (MASTER(cr)) + { + sz = DIM*top_global->natoms; - fprintf(stderr, "Allocating Hessian memory...\n\n"); + fprintf(stderr, "Allocating Hessian memory...\n\n"); - if (bSparse) - { - sparse_matrix = gmx_sparsematrix_init(sz); - sparse_matrix->compressed_symmetric = TRUE; - } - else - { - snew(full_matrix, sz*sz); + if (bSparse) + { + sparse_matrix = gmx_sparsematrix_init(sz); + sparse_matrix->compressed_symmetric = TRUE; + } + else + { + snew(full_matrix, sz*sz); + } } /* Initial values */ @@ -2721,16 +2725,14 @@ double do_nm(FILE *fplog, t_commrec *cr, /* if forces are not small, warn user */ get_state_f_norm_max(cr, &(inputrec->opts), mdatoms, state_work); - if (MASTER(cr)) + md_print_info(cr, fplog, "Maximum force:%12.5e\n", state_work->fmax); + if (state_work->fmax > 1.0e-3) { - fprintf(stderr, "Maximum force:%12.5e\n", state_work->fmax); - if (state_work->fmax > 1.0e-3) - { - fprintf(stderr, "Maximum force probably not small enough to"); - fprintf(stderr, " ensure that you are in an \nenergy well. "); - fprintf(stderr, "Be aware that negative eigenvalues may occur"); - fprintf(stderr, " when the\nresulting matrix is diagonalized.\n"); - } + md_print_info(cr, fplog, + "The force is probably not small enough to " + "ensure that you are at a minimum.\n" + "Be aware that negative eigenvalues may occur\n" + "when the resulting matrix is diagonalized.\n\n"); } /*********************************************************** -- 2.22.0