avoid array overflows and silence compiler warnings from unused parameters

This commit is contained in:
Axel Kohlmeyer
2018-11-20 22:40:46 -05:00
parent 090fc7bc8a
commit a91d89b516
18 changed files with 32 additions and 31 deletions

View File

@ -13,9 +13,9 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include <mpi.h> #include <mpi.h>
#include <stdio.h> #include <cstdio>
#include <string.h> #include <cstring>
#include <stdlib.h> #include <cstdlib>
#include "msg.h" #include "msg.h"
@ -23,7 +23,7 @@ using namespace CSLIB_NS;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
Msg::Msg(int csflag, const void *ptr, MPI_Comm cworld) Msg::Msg(int csflag, const void * /* ptr */, MPI_Comm cworld)
{ {
world = cworld; world = cworld;
MPI_Comm_rank(world,&me); MPI_Comm_rank(world,&me);
@ -34,7 +34,7 @@ Msg::Msg(int csflag, const void *ptr, MPI_Comm cworld)
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
Msg::Msg(int csflag, const void *ptr) Msg::Msg(int csflag, const void * /* ptr */)
{ {
world = 0; world = 0;
me = 0; me = 0;

View File

@ -582,7 +582,7 @@ int PairReaxCOMP::write_reax_lists()
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void PairReaxCOMP::read_reax_forces(int vflag) void PairReaxCOMP::read_reax_forces(int /* vflag */)
{ {
#if defined(_OPENMP) #if defined(_OPENMP)
#pragma omp parallel for schedule(static) default(shared) #pragma omp parallel for schedule(static) default(shared)

View File

@ -220,7 +220,8 @@ void Add_dBond_to_ForcesOMP( reax_system *system, int i, int pj,
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void Add_dBond_to_Forces_NPTOMP( reax_system *system, int i, int pj, simulation_data *data, void Add_dBond_to_Forces_NPTOMP( reax_system *system, int i, int pj,
simulation_data * /* data */,
storage *workspace, reax_list **lists ) { storage *workspace, reax_list **lists ) {
reax_list *bonds = (*lists) + BONDS; reax_list *bonds = (*lists) + BONDS;
bond_data *nbr_j, *nbr_k; bond_data *nbr_j, *nbr_k;
@ -343,9 +344,9 @@ void Add_dBond_to_Forces_NPTOMP( reax_system *system, int i, int pj, simulation_
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int BOp_OMP( storage *workspace, reax_list *bonds, double bo_cut, int BOp_OMP( storage * /* workspace */, reax_list *bonds, double bo_cut,
int i, int btop_i, far_neighbor_data *nbr_pj, int i, int btop_i, far_neighbor_data *nbr_pj,
single_body_parameters *sbp_i, single_body_parameters *sbp_j, single_body_parameters * /* sbp_i */, single_body_parameters * /* sbp_j */,
two_body_parameters *twbp, two_body_parameters *twbp,
int btop_j, double C12, double C34, double C56, double BO, double BO_s, double BO_pi, double BO_pi2) { int btop_j, double C12, double C34, double C56, double BO, double BO_s, double BO_pi, double BO_pi2) {
int j; int j;
@ -419,8 +420,8 @@ int BOp_OMP( storage *workspace, reax_list *bonds, double bo_cut,
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void BOOMP( reax_system *system, control_params *control, simulation_data *data, void BOOMP( reax_system *system, control_params * /* control */, simulation_data * /* data */,
storage *workspace, reax_list **lists, output_controls *out_control ) storage *workspace, reax_list **lists, output_controls * /* out_control */)
{ {
#ifdef OMP_TIMING #ifdef OMP_TIMING
double endTimeBase, startTimeBase; double endTimeBase, startTimeBase;

View File

@ -42,9 +42,9 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void BondsOMP( reax_system *system, control_params *control, void BondsOMP( reax_system *system, control_params * /* control */,
simulation_data *data, storage *workspace, reax_list **lists, simulation_data *data, storage *workspace, reax_list **lists,
output_controls *out_control ) output_controls * /* out_control */)
{ {
#ifdef OMP_TIMING #ifdef OMP_TIMING
double endTimeBase, startTimeBase; double endTimeBase, startTimeBase;

View File

@ -79,7 +79,7 @@ void Init_Force_FunctionsOMP( control_params *control )
void Compute_Bonded_ForcesOMP( reax_system *system, control_params *control, void Compute_Bonded_ForcesOMP( reax_system *system, control_params *control,
simulation_data *data, storage *workspace, simulation_data *data, storage *workspace,
reax_list **lists, output_controls *out_control, reax_list **lists, output_controls *out_control,
MPI_Comm comm ) MPI_Comm /* comm */)
{ {
int i; int i;
@ -105,7 +105,7 @@ void Compute_Bonded_ForcesOMP( reax_system *system, control_params *control,
void Compute_NonBonded_ForcesOMP( reax_system *system, control_params *control, void Compute_NonBonded_ForcesOMP( reax_system *system, control_params *control,
simulation_data *data, storage *workspace, simulation_data *data, storage *workspace,
reax_list **lists, output_controls *out_control, reax_list **lists, output_controls *out_control,
MPI_Comm comm ) MPI_Comm /* comm */)
{ {
/* van der Waals and Coulomb interactions */ /* van der Waals and Coulomb interactions */
#ifdef OMP_TIMING #ifdef OMP_TIMING
@ -133,7 +133,7 @@ void Compute_NonBonded_ForcesOMP( reax_system *system, control_params *control,
Saves enormous time & space! */ Saves enormous time & space! */
void Compute_Total_ForceOMP( reax_system *system, control_params *control, void Compute_Total_ForceOMP( reax_system *system, control_params *control,
simulation_data *data, storage *workspace, simulation_data *data, storage *workspace,
reax_list **lists, mpi_datatypes *mpi_data ) reax_list **lists, mpi_datatypes * /* mpi_data */)
{ {
#ifdef OMP_TIMING #ifdef OMP_TIMING
double startTimeBase,endTimeBase; double startTimeBase,endTimeBase;
@ -262,7 +262,7 @@ void Compute_Total_ForceOMP( reax_system *system, control_params *control,
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void Validate_ListsOMP( reax_system *system, storage *workspace, reax_list **lists, void Validate_ListsOMP( reax_system *system, storage * /*workspace */, reax_list **lists,
int step, int n, int N, int numH, MPI_Comm comm ) int step, int n, int N, int numH, MPI_Comm comm )
{ {
int i, comp, Hindex; int i, comp, Hindex;
@ -329,7 +329,7 @@ void Validate_ListsOMP( reax_system *system, storage *workspace, reax_list **lis
void Init_Forces_noQEq_OMP( reax_system *system, control_params *control, void Init_Forces_noQEq_OMP( reax_system *system, control_params *control,
simulation_data *data, storage *workspace, simulation_data *data, storage *workspace,
reax_list **lists, output_controls *out_control, reax_list **lists, output_controls * /* out_control */,
MPI_Comm comm ) { MPI_Comm comm ) {
#ifdef OMP_TIMING #ifdef OMP_TIMING
double startTimeBase, endTimeBase; double startTimeBase, endTimeBase;

View File

@ -45,7 +45,7 @@ using namespace LAMMPS_NS;
void Hydrogen_BondsOMP( reax_system *system, control_params *control, void Hydrogen_BondsOMP( reax_system *system, control_params *control,
simulation_data *data, storage *workspace, simulation_data *data, storage *workspace,
reax_list **lists, output_controls *out_control ) reax_list **lists, output_controls * /* out_control */)
{ {
#ifdef OMP_TIMING #ifdef OMP_TIMING
double endTimeBase, startTimeBase; double endTimeBase, startTimeBase;

View File

@ -48,8 +48,8 @@ extern int Init_Workspace(reax_system*, control_params*, storage*, MPI_Comm, cha
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int Init_ListsOMP( reax_system *system, control_params *control, int Init_ListsOMP( reax_system *system, control_params *control,
simulation_data *data, storage *workspace, reax_list **lists, simulation_data * /* data */, storage * /* workspace */,
mpi_datatypes *mpi_data, char *msg ) reax_list **lists, mpi_datatypes *mpi_data, char * /* msg */)
{ {
int i, total_hbonds, total_bonds, bond_cap, num_3body, cap_3body, Htop; int i, total_hbonds, total_bonds, bond_cap, num_3body, cap_3body, Htop;
int *hb_top, *bond_top; int *hb_top, *bond_top;

View File

@ -42,9 +42,9 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void Atom_EnergyOMP( reax_system *system, control_params *control, void Atom_EnergyOMP( reax_system *system, control_params * /* control */,
simulation_data *data, storage *workspace, reax_list **lists, simulation_data *data, storage *workspace, reax_list **lists,
output_controls *out_control ) output_controls * /* out_control */)
{ {
#ifdef OMP_TIMING #ifdef OMP_TIMING
double endTimeBase, startTimeBase; double endTimeBase, startTimeBase;

View File

@ -47,8 +47,8 @@ using namespace LAMMPS_NS;
void vdW_Coulomb_Energy_OMP( reax_system *system, control_params *control, void vdW_Coulomb_Energy_OMP( reax_system *system, control_params *control,
simulation_data *data, storage *workspace, simulation_data *data, storage *workspace,
reax_list **lists, output_controls *out_control ) { reax_list **lists, output_controls * /* out_control */ )
{
int natoms = system->n; int natoms = system->n;
reax_list *far_nbrs = (*lists) + FAR_NBRS; reax_list *far_nbrs = (*lists) + FAR_NBRS;
double p_vdW1 = system->reax_param.gp.l[28]; double p_vdW1 = system->reax_param.gp.l[28];
@ -254,7 +254,7 @@ void vdW_Coulomb_Energy_OMP( reax_system *system, control_params *control,
void Tabulated_vdW_Coulomb_Energy_OMP(reax_system *system,control_params *control, void Tabulated_vdW_Coulomb_Energy_OMP(reax_system *system,control_params *control,
simulation_data *data, storage *workspace, simulation_data *data, storage *workspace,
reax_list **lists, reax_list **lists,
output_controls *out_control ) { output_controls * /* out_control */) {
double SMALL = 0.0001; double SMALL = 0.0001;
int natoms = system->n; int natoms = system->n;

View File

@ -100,7 +100,7 @@ void Calculate_dCos_ThetaOMP( rvec dvec_ji, double d_ji, rvec dvec_jk, double d_
played by j which sits in the middle of the other two. */ played by j which sits in the middle of the other two. */
void Valence_AnglesOMP( reax_system *system, control_params *control, void Valence_AnglesOMP( reax_system *system, control_params *control,
simulation_data *data, storage *workspace, simulation_data *data, storage *workspace,
reax_list **lists, output_controls *out_control ) reax_list **lists, output_controls * /* out_control */)
{ {
#ifdef OMP_TIMING #ifdef OMP_TIMING

View File

@ -38,7 +38,7 @@ int Init_Output_Files( reax_system *system, control_params *control,
output_controls *out_control, mpi_datatypes *mpi_data, output_controls *out_control, mpi_datatypes *mpi_data,
char *msg ) char *msg )
{ {
char temp[MAX_STR]; char temp[MAX_STR+8];
int ret; int ret;
if( out_control->write_steps > 0 ){ if( out_control->write_steps > 0 ){

View File

@ -43,7 +43,7 @@ int Tokenize( char* s, char*** tok )
char *word; char *word;
int count=0; int count=0;
strncpy( test, s, MAX_LINE ); strncpy( test, s, MAX_LINE-1);
for( word = strtok(test, sep); word; word = strtok(NULL, sep) ) { for( word = strtok(test, sep); word; word = strtok(NULL, sep) ) {
strncpy( (*tok)[count], word, MAX_LINE ); strncpy( (*tok)[count], word, MAX_LINE );

View File

@ -315,7 +315,7 @@ int Init_Traj( reax_system *system, control_params *control,
output_controls *out_control, mpi_datatypes *mpi_data, output_controls *out_control, mpi_datatypes *mpi_data,
char *msg ) char *msg )
{ {
char fname[MAX_STR]; char fname[MAX_STR+8];
int atom_line_len[ NR_OPT_ATOM ] = { 0, 0, 0, 0, int atom_line_len[ NR_OPT_ATOM ] = { 0, 0, 0, 0,
ATOM_BASIC_LEN, ATOM_wV_LEN, ATOM_BASIC_LEN, ATOM_wV_LEN,
ATOM_wF_LEN, ATOM_FULL_LEN }; ATOM_wF_LEN, ATOM_FULL_LEN };