From 4bc2d6f33259f69fbc9a1f22313c4abeabb7f3f0 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Mon, 10 Jan 2011 20:22:06 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@5519 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/lmptype.h | 40 ++++++++++++++++++++++------------------ src/thermo.cpp | 8 +++----- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/lmptype.h b/src/lmptype.h index ad29882261..5c5285be8a 100644 --- a/src/lmptype.h +++ b/src/lmptype.h @@ -28,12 +28,16 @@ // MPI_LMP_TAGINT = MPI data type corresponding to tagint // MPI_LMP_BIGINT = MPI data type corresponding to bigint -// NOTE: you may need to set MPI_LMP_BIGINT to MPI_LONG -// if your machine/MPI does not support "long long" data types + +// NOTE: +// if your machine/MPI does not support "long long" data types, +// but only "long" data types, then you will need to set +// MPI_LMP_BIGINT to MPI_LONG, LLONG_MAX to LONG_MAX, and "lld" to "ld" #ifndef LMP_LMPTYPE_H #define LMP_LMPTYPE_H +#include "limits.h" #include "stdint.h" namespace LAMMPS_NS { @@ -45,17 +49,17 @@ typedef int smallint; typedef int tagint; typedef int64_t bigint; -#define MAXSMALLINT 0x7FFFFFFF -#define MAXTAGINT 0x7FFFFFFF -#define MAXBIGINT 0x7FFFFFFFFFFFFFFFLL +#define MAXSMALLINT INT_MAX +#define MAXTAGINT INT_MAX +#define MAXBIGINT LLONG_MAX #define MPI_LMP_TAGINT MPI_INT #define MPI_LMP_BIGINT MPI_LONG_LONG #define TAGINT_FORMAT "%d" -#define BIGINT_FORMAT "%ld" +#define BIGINT_FORMAT "%lld" #define TAGINT_FORMAT_NL "%d\n" -#define BIGINT_FORMAT_NL "%ld\n" +#define BIGINT_FORMAT_NL "%lld\n" // for molecular problems that exceed 2 billion (2^31) atoms // 32-bit smallint, 64-bit tagint and bigint @@ -66,20 +70,20 @@ typedef int smallint; typedef int64_t tagint; typedef int64_t bigint; -#define MAXSMALLINT 0x7FFFFFFF -#define MAXTAGINT 0x7FFFFFFFFFFFFFFFLL -#define MAXBIGINT 0x7FFFFFFFFFFFFFFFLL +#define MAXSMALLINT INT_MAX +#define MAXTAGINT LLONG_MAX +#define MAXBIGINT LLONG_MAX #define MPI_LMP_TAGINT MPI_LONG_LONG #define MPI_LMP_BIGINT MPI_LONG_LONG -#define TAGINT_FORMAT "%ld" -#define BIGINT_FORMAT "%ld" -#define TAGINT_FORMAT_NL "%ld\n" -#define BIGINT_FORMAT_NL "%ld\n" +#define TAGINT_FORMAT "%lld" +#define BIGINT_FORMAT "%lld" +#define TAGINT_FORMAT_NL "%lld\n" +#define BIGINT_FORMAT_NL "%lld\n" */ -// for machines that don't support 64-bit ints +// for machines that do not support 64-bit ints // 32-bit smallint and tagint and bigint /* @@ -87,9 +91,9 @@ typedef int smallint; typedef int tagint; typedef int bigint; -#define MAXSMALLINT 0x7FFFFFFF -#define MAXTAGINT 0x7FFFFFFF -#define MAXBIGINT 0x7FFFFFFF +#define MAXSMALLINT INT_MAX +#define MAXTAGINT INT_MAX +#define MAXBIGINT INT_MAX #define MPI_LMP_TAGINT MPI_INT #define MPI_LMP_BIGINT MPI_INT diff --git a/src/thermo.cpp b/src/thermo.cpp index 2c0dbe93fa..a9c846d7f4 100644 --- a/src/thermo.cpp +++ b/src/thermo.cpp @@ -509,16 +509,14 @@ void Thermo::modify_params(int narg, char **arg) format_int_user = new char[n]; strcpy(format_int_user,arg[iarg+2]); if (format_bigint_user) delete [] format_bigint_user; - n = strlen(format_int_user) + 2; + n = strlen(format_int_user) + 3; format_bigint_user = new char[n]; char *ptr = strchr(format_int_user,'d'); if (ptr == NULL) error->all("Thermo_modify int format does not contain d character"); *ptr = '\0'; - if (sizeof(bigint) == 8) - sprintf(format_bigint_user,"%s%s%s",format_int_user,"ld",ptr+1); - else if (sizeof(bigint) == 4) - sprintf(format_bigint_user,"%s%s%s",format_int_user,"d",ptr+1); + sprintf(format_bigint_user,"%s%s%s",format_int_user, + BIGINT_FORMAT,ptr+1); *ptr = 'd'; } else if (strcmp(arg[iarg+1],"float") == 0) { if (format_float_user) delete [] format_float_user;