diff --git a/src/KSPACE/pppm.cpp b/src/KSPACE/pppm.cpp index 7c671d0a3c..40730df6ff 100644 --- a/src/KSPACE/pppm.cpp +++ b/src/KSPACE/pppm.cpp @@ -880,7 +880,7 @@ void PPPM::set_grid() // fluid-occupied volume used to estimate real-space error // zprd used rather than zprd_slab - double hx,hy,hz; + double h_x,h_y,h_z; if (!gewaldflag) g_ewald = sqrt(-log(precision*sqrt(natoms*cutoff*xprd*yprd*zprd) / @@ -893,31 +893,31 @@ void PPPM::set_grid() if (!gridflag) { double err; - hx = hy = hz = 1/g_ewald; + h_x = h_y = h_z = 1/g_ewald; - nx_pppm = static_cast (xprd/hx + 1); - ny_pppm = static_cast (yprd/hy + 1); - nz_pppm = static_cast (zprd_slab/hz + 1); + nx_pppm = static_cast (xprd/h_x + 1); + ny_pppm = static_cast (yprd/h_y + 1); + nz_pppm = static_cast (zprd_slab/h_z + 1); - err = rms(hx,xprd,natoms,q2,acons); + err = rms(h_x,xprd,natoms,q2,acons); while (err > precision) { - err = rms(hx,xprd,natoms,q2,acons); + err = rms(h_x,xprd,natoms,q2,acons); nx_pppm++; - hx = xprd/nx_pppm; + h_x = xprd/nx_pppm; } - err = rms(hy,yprd,natoms,q2,acons); + err = rms(h_y,yprd,natoms,q2,acons); while (err > precision) { - err = rms(hy,yprd,natoms,q2,acons); + err = rms(h_y,yprd,natoms,q2,acons); ny_pppm++; - hy = yprd/ny_pppm; + h_y = yprd/ny_pppm; } - err = rms(hz,zprd_slab,natoms,q2,acons); + err = rms(h_z,zprd_slab,natoms,q2,acons); while (err > precision) { - err = rms(hz,zprd_slab,natoms,q2,acons); + err = rms(h_z,zprd_slab,natoms,q2,acons); nz_pppm++; - hz = zprd_slab/nz_pppm; + h_z = zprd_slab/nz_pppm; } } @@ -929,9 +929,9 @@ void PPPM::set_grid() // adjust g_ewald for new grid size - hx = xprd/nx_pppm; - hy = yprd/ny_pppm; - hz = zprd_slab/nz_pppm; + h_x = xprd/nx_pppm; + h_y = yprd/ny_pppm; + h_z = zprd_slab/nz_pppm; if (!gewaldflag) { double gew1,gew2,dgew,f,fmid,hmin,rtb; @@ -939,12 +939,12 @@ void PPPM::set_grid() gew1 = 0.0; g_ewald = gew1; - f = diffpr(hx,hy,hz,q2,acons); + f = diffpr(h_x,h_y,h_z,q2,acons); - hmin = MIN(hx,MIN(hy,hz)); + hmin = MIN(h_x,MIN(h_y,h_z)); gew2 = 10/hmin; g_ewald = gew2; - fmid = diffpr(hx,hy,hz,q2,acons); + fmid = diffpr(h_x,h_y,h_z,q2,acons); if (f*fmid >= 0.0) error->all("Cannot compute PPPM G"); rtb = f < 0.0 ? (dgew=gew2-gew1,gew1) : (dgew=gew1-gew2,gew2); @@ -952,7 +952,7 @@ void PPPM::set_grid() while (fabs(dgew) > SMALL && fmid != 0.0) { dgew *= 0.5; g_ewald = rtb + dgew; - fmid = diffpr(hx,hy,hz,q2,acons); + fmid = diffpr(h_x,h_y,h_z,q2,acons); if (fmid <= 0.0) rtb = g_ewald; ncount++; if (ncount > LARGE) error->all("Cannot compute PPPM G"); @@ -961,9 +961,9 @@ void PPPM::set_grid() // final RMS precision - double lprx = rms(hx,xprd,natoms,q2,acons); - double lpry = rms(hy,yprd,natoms,q2,acons); - double lprz = rms(hz,zprd_slab,natoms,q2,acons); + double lprx = rms(h_x,xprd,natoms,q2,acons); + double lpry = rms(h_y,yprd,natoms,q2,acons); + double lprz = rms(h_z,zprd_slab,natoms,q2,acons); double lpr = sqrt(lprx*lprx + lpry*lpry + lprz*lprz) / sqrt(3.0); double spr = 2.0*q2 * exp(-g_ewald*g_ewald*cutoff*cutoff) / sqrt(natoms*cutoff*xprd*yprd*zprd_slab); @@ -1038,7 +1038,7 @@ double PPPM::rms(double h, double prd, bigint natoms, compute difference in real-space and kspace RMS precision ------------------------------------------------------------------------- */ -double PPPM::diffpr(double hx, double hy, double hz, double q2, double **acons) +double PPPM::diffpr(double h_x, double h_y, double h_z, double q2, double **acons) { double lprx,lpry,lprz,kspace_prec,real_prec; double xprd = domain->xprd; @@ -1046,9 +1046,9 @@ double PPPM::diffpr(double hx, double hy, double hz, double q2, double **acons) double zprd = domain->zprd; bigint natoms = atom->natoms; - lprx = rms(hx,xprd,natoms,q2,acons); - lpry = rms(hy,yprd,natoms,q2,acons); - lprz = rms(hz,zprd*slab_volfactor,natoms,q2,acons); + lprx = rms(h_x,xprd,natoms,q2,acons); + lpry = rms(h_y,yprd,natoms,q2,acons); + lprz = rms(h_z,zprd*slab_volfactor,natoms,q2,acons); kspace_prec = sqrt(lprx*lprx + lpry*lpry + lprz*lprz) / sqrt(3.0); real_prec = 2.0*q2 * exp(-g_ewald*g_ewald*cutoff*cutoff) / sqrt(static_cast(natoms)*cutoff*xprd*yprd*zprd); diff --git a/src/Makefile b/src/Makefile index 9348d688cd..3bc766272f 100755 --- a/src/Makefile +++ b/src/Makefile @@ -1,6 +1,6 @@ # LAMMPS multiple-machine Makefile -SHELL = /bin/sh +SHELL = /bin/bash #.IGNORE: # Definitions @@ -68,6 +68,7 @@ help: @cp -p *.cpp *.h Obj_$@ @cp MAKE/Makefile.$@ Obj_$@/Makefile @if [ ! -e Makefile.package ]; then make package-regenerate; fi + @if [ ! -e Makefile.package.settings ]; then make package-regenerate; fi @cp Makefile.package Makefile.package.settings Obj_$@ @cd Obj_$@; \ $(MAKE) $(MFLAGS) "OBJ = $(OBJ)" "INC = $(INC)" "EXE = ../$(EXE)" ../$(EXE) diff --git a/src/REAX/pair_reax_fortran.h b/src/REAX/pair_reax_fortran.h index 1900613c61..057ff7c1e1 100644 --- a/src/REAX/pair_reax_fortran.h +++ b/src/REAX/pair_reax_fortran.h @@ -26,10 +26,12 @@ #if __STDC__ #define CONS(a,b) a##b +#elif defined(_IBM) +#define CONS(a,b) a##b #else #define CONS(a,b) a/**/b -#warning "The following declaration is a test of the CONS macro." -#warning "If it fails with an error, pair_reax_fortran.h must be modified by hand." +#warning "The following declaration is a test of the CONS macro" +#warning "If it fails, pair_reax_fortran.h must be modified by hand" static int my_apples_my_oranges = 1; static int my_applesoroanges = CONS(my_apples,_my_oranges); #endif diff --git a/src/USER-CUDA/pppm_cuda.cpp b/src/USER-CUDA/pppm_cuda.cpp index 57698b104c..ffa5d17974 100644 --- a/src/USER-CUDA/pppm_cuda.cpp +++ b/src/USER-CUDA/pppm_cuda.cpp @@ -1305,7 +1305,7 @@ void PPPMCuda::set_grid() // fluid-occupied volume used to estimate real-space error // zprd used rather than zprd_slab - double hx,hy,hz; + double h_x,h_y,h_z; if (!gewaldflag) g_ewald = sqrt(-log(precision*sqrt(natoms*cutoff*xprd*yprd*zprd) / @@ -1318,31 +1318,31 @@ void PPPMCuda::set_grid() if (!gridflag) { double err; - hx = hy = hz = 1/g_ewald; + h_x = h_y = h_z = 1/g_ewald; - nx_pppm = static_cast (xprd/hx + 1); - ny_pppm = static_cast (yprd/hy + 1); - nz_pppm = static_cast (zprd_slab/hz + 1); + nx_pppm = static_cast (xprd/h_x + 1); + ny_pppm = static_cast (yprd/h_y + 1); + nz_pppm = static_cast (zprd_slab/h_z + 1); - err = rms(hx,xprd,natoms,q2,acons); + err = rms(h_x,xprd,natoms,q2,acons); while (err > precision) { - err = rms(hx,xprd,natoms,q2,acons); + err = rms(h_x,xprd,natoms,q2,acons); nx_pppm++; - hx = xprd/nx_pppm; + h_x = xprd/nx_pppm; } - err = rms(hy,yprd,natoms,q2,acons); + err = rms(h_y,yprd,natoms,q2,acons); while (err > precision) { - err = rms(hy,yprd,natoms,q2,acons); + err = rms(h_y,yprd,natoms,q2,acons); ny_pppm++; - hy = yprd/ny_pppm; + h_y = yprd/ny_pppm; } - err = rms(hz,zprd_slab,natoms,q2,acons); + err = rms(h_z,zprd_slab,natoms,q2,acons); while (err > precision) { - err = rms(hz,zprd_slab,natoms,q2,acons); + err = rms(h_z,zprd_slab,natoms,q2,acons); nz_pppm++; - hz = zprd_slab/nz_pppm; + h_z = zprd_slab/nz_pppm; } } @@ -1378,9 +1378,9 @@ void PPPMCuda::set_grid() // adjust g_ewald for new grid size - hx = xprd/nx_pppm; - hy = yprd/ny_pppm; - hz = zprd_slab/nz_pppm; + h_x = xprd/nx_pppm; + h_y = yprd/ny_pppm; + h_z = zprd_slab/nz_pppm; if (!gewaldflag) { double gew1,gew2,dgew,f,fmid,hmin,rtb; @@ -1388,12 +1388,12 @@ void PPPMCuda::set_grid() gew1 = 0.0; g_ewald = gew1; - f = diffpr(hx,hy,hz,q2,acons); + f = diffpr(h_x,h_y,h_z,q2,acons); - hmin = MIN(hx,MIN(hy,hz)); + hmin = MIN(h_x,MIN(h_y,h_z)); gew2 = 10/hmin; g_ewald = gew2; - fmid = diffpr(hx,hy,hz,q2,acons); + fmid = diffpr(h_x,h_y,h_z,q2,acons); if (f*fmid >= 0.0) error->all("Cannot compute PPPMCuda G"); rtb = f < 0.0 ? (dgew=gew2-gew1,gew1) : (dgew=gew1-gew2,gew2); @@ -1401,7 +1401,7 @@ void PPPMCuda::set_grid() while (fabs(dgew) > SMALL && fmid != 0.0) { dgew *= 0.5; g_ewald = rtb + dgew; - fmid = diffpr(hx,hy,hz,q2,acons); + fmid = diffpr(h_x,h_y,h_z,q2,acons); if (fmid <= 0.0) rtb = g_ewald; ncount++; if (ncount > LARGE) error->all("Cannot compute PPPMCuda G"); @@ -1410,9 +1410,9 @@ void PPPMCuda::set_grid() // final RMS precision - double lprx = rms(hx,xprd,natoms,q2,acons); - double lpry = rms(hy,yprd,natoms,q2,acons); - double lprz = rms(hz,zprd_slab,natoms,q2,acons); + double lprx = rms(h_x,xprd,natoms,q2,acons); + double lpry = rms(h_y,yprd,natoms,q2,acons); + double lprz = rms(h_z,zprd_slab,natoms,q2,acons); double lpr = sqrt(lprx*lprx + lpry*lpry + lprz*lprz) / sqrt(3.0); double spr = 2.0*q2 * exp(-g_ewald*g_ewald*cutoff*cutoff) / sqrt(natoms*cutoff*xprd*yprd*zprd_slab); diff --git a/src/lammps.cpp b/src/lammps.cpp index 87179e3290..85dc1ce67f 100644 --- a/src/lammps.cpp +++ b/src/lammps.cpp @@ -325,6 +325,8 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) if (mpisize != sizeof(bigint)) error->all("MPI_LMP_BIGINT and bigint in lmptype.h are not compatible"); + if (sizeof(tagint) == 8) error->all("64-bit atom IDs are not yet supported"); + // create CUDA class if USER-CUDA installed, unless explicitly switched off // instantiation creates dummy CUDA class if USER-CUDA is not installed diff --git a/src/lmptype.h b/src/lmptype.h index 9854934b04..a88e6d498a 100644 --- a/src/lmptype.h +++ b/src/lmptype.h @@ -19,16 +19,11 @@ // smallint must be an int, as defined by C compiler // tagint can be 32-bit or 64-bit int, must be >= smallint -// NOTE: 64-bit tagint is not yet supported // bigint can be 32-bit or 64-bit int, must be >= tagint // MPI_LMP_TAGINT = MPI data type corresponding to a tagint // MPI_LMP_BIGINT = MPI data type corresponding to a bigint -// NOTE: if your machine/MPI does not support "long long" ints, -// but only "long" ints, then you will need to change -// MPI_LONG_LONG to MPI_LONG, and atoll to atol - #ifndef LMP_LMPTYPE_H #define LMP_LMPTYPE_H @@ -39,6 +34,12 @@ #include "stdint.h" #include "inttypes.h" +// grrr - IBM Power6 does not provide this def in their system header files + +#ifndef PRId64 +#define PRId64 "ld" +#endif + namespace LAMMPS_NS { // reserve 2 hi bits in molecular system neigh list for special bonds flag @@ -47,9 +48,27 @@ namespace LAMMPS_NS { #define SBBITS 30 #define NEIGHMASK 0x3FFFFFFF -// default settings +// default to 32-bit smallint and tagint, 64-bit bigint + +#if !defined(LAMMPS_SMALLSMALL) && !defined(LAMMPS_BIGBIG) +#define LAMMPS_SMALLBIG +#endif + +// allow user override of LONGLONG to LONG, necessary for some machines/MPI + +#ifdef LAMMPS_LONGLONG_TO_LONG +#define MPI_LL MPI_LONG +#define ATOLL atoll +#else +#define MPI_LL MPI_LONG_LONG +#define ATOLL atol +#endif + +// for atomic problems that exceed 2 billion (2^31) atoms // 32-bit smallint and tagint, 64-bit bigint +#ifdef LAMMPS_SMALLBIG + typedef int smallint; typedef int tagint; typedef int64_t bigint; @@ -59,19 +78,21 @@ typedef int64_t bigint; #define MAXBIGINT INT64_MAX #define MPI_LMP_TAGINT MPI_INT -#define MPI_LMP_BIGINT MPI_LONG_LONG +#define MPI_LMP_BIGINT MPI_LL #define TAGINT_FORMAT "%d" #define BIGINT_FORMAT "%" PRId64 #define ATOTAGINT atoi -#define ATOBIGINT atoll +#define ATOBIGINT ATOLL + +#endif // for molecular problems that exceed 2 billion (2^31) atoms // 32-bit smallint, 64-bit tagint and bigint -// NOTE: 64-bit tagint is not yet supported -/* +#ifdef LAMMPS_BIGBIG + typedef int smallint; typedef int64_t tagint; typedef int64_t bigint; @@ -80,20 +101,22 @@ typedef int64_t bigint; #define MAXTAGINT INT64_MAX #define MAXBIGINT INT64_MAX -#define MPI_LMP_TAGINT MPI_LONG_LONG -#define MPI_LMP_BIGINT MPI_LONG_LONG +#define MPI_LMP_TAGINT MPI_LL +#define MPI_LMP_BIGINT MPI_LL #define TAGINT_FORMAT "%" PRId64 #define BIGINT_FORMAT "%" PRId64 -#define ATOTAGINT atoll -#define ATOBIGINT atoll -*/ +#define ATOTAGINT ATOLL +#define ATOBIGINT ATOLL + +#endif // for machines that do not support 64-bit ints // 32-bit smallint and tagint and bigint -/* +#ifdef LAMMPS_SMALLSMALL + typedef int smallint; typedef int tagint; typedef int bigint; @@ -110,11 +133,12 @@ typedef int bigint; #define ATOTAGINT atoi #define ATOBIGINT atoi -*/ + +#endif } -// settings to enable LAMMPS build under Windows +// settings to enable LAMMPS to build under Windows #ifdef _WIN32 #include "lmpwindows.h"