From f630468a047721245318e1fd76fbdfd49c437446 Mon Sep 17 00:00:00 2001 From: Olaf Lenz Date: Tue, 26 Feb 2013 12:25:34 +0100 Subject: [PATCH 1/7] Made code compile with C++ compiler. --- configure.ac | 2 +- src/communication.c | 75 ++++++------ src/communication.h | 6 +- src/constraint.c | 2 +- src/debug.c | 4 +- src/domain_decomposition.c | 6 +- src/elc.c | 6 +- src/errorhandling.c | 2 +- src/fft-common.c | 2 +- src/fft-common.h | 13 +- src/fft.c | 24 ++-- src/ghosts.c | 10 +- src/imd.c | 9 +- src/initialize.c | 3 +- src/interaction_data.c | 2 +- src/interaction_data.h | 2 +- src/layered.c | 4 +- src/mmm-common.c | 2 +- src/mmm2d.c | 12 +- src/nsquare.c | 4 +- src/p3m.c | 6 +- src/particle_data.c | 37 +++--- src/particle_data.h | 12 +- src/polymer.c | 58 +++++---- src/reaction.c | 1 + src/reaction.h | 2 +- src/statistics.c | 23 ++-- src/statistics_chain.c | 174 +++++++++++++-------------- src/statistics_correlation.c | 57 ++++----- src/statistics_observable.c | 59 ++++----- src/statistics_wallstuff.c | 3 +- src/tcl/angle_cosine_tcl.h | 4 +- src/tcl/angle_cossquare_tcl.h | 4 +- src/tcl/angle_harmonic_tcl.h | 8 +- src/tcl/binary_file_tcl.c | 4 +- src/tcl/blockfile_tcl.c | 8 +- src/tcl/grid_tcl.c | 2 +- src/tcl/iccp3m_tcl.c | 2 +- src/tcl/imd_tcl.c | 2 +- src/tcl/interaction_data_tcl.c | 2 +- src/tcl/interaction_data_tcl.h | 4 +- src/tcl/parser.h | 4 +- src/tcl/particle_data_tcl.c | 27 +++-- src/tcl/polymer_tcl.c | 4 +- src/tcl/random_tcl.c | 8 +- src/tcl/reaction_field_tcl.c | 2 +- src/tcl/reaction_field_tcl.h | 2 +- src/tcl/statistics_correlation_tcl.c | 53 ++++---- src/tcl/statistics_observable_tcl.c | 15 +-- src/tcl/statistics_observable_tcl.h | 1 - src/tcl/statistics_tcl.c | 12 +- src/tcl/uwerr_tcl.c | 4 +- src/topology.c | 2 +- src/utils.h | 5 +- src/uwerr.c | 6 +- src/uwerr.h | 1 - 56 files changed, 400 insertions(+), 408 deletions(-) diff --git a/configure.ac b/configure.ac index 844ad154c97..e4f164f7137 100644 --- a/configure.ac +++ b/configure.ac @@ -162,7 +162,7 @@ AC_DEFINE_UNQUOTED(MDINLINE,$mdinline,[How to inline functions]) ################################## # miscellaneous -AC_PROG_CC_STDC +#AC_PROG_CC_STDC AM_PROG_CC_C_O AC_C_CONST AC_HEADER_TIME diff --git a/src/communication.c b/src/communication.c index 622af62d46e..6ded2084dc6 100644 --- a/src/communication.c +++ b/src/communication.c @@ -155,7 +155,7 @@ const int N_CALLBACKS = sizeof(slave_callbacks)/sizeof(SlaveCallback*); #undef CB #define CB(name) #name, -char *names[] = { +const char *names[] = { CALLBACK_LIST }; @@ -299,7 +299,7 @@ void mpi_bcast_parameter_slave(int node, int i) void mpi_who_has() { Cell *cell; - int *sizes = malloc(sizeof(int)*n_nodes); + int *sizes = (int*)malloc(sizeof(int)*n_nodes); int *pdata = NULL; int pdata_s = 0, i, c; int pnode; @@ -353,7 +353,7 @@ void mpi_who_has_slave(int node, int param) if (n_part == 0) return; - sendbuf = malloc(sizeof(int)*n_part); + sendbuf = (int*)malloc(sizeof(int)*n_part); npart = 0; for (c = 0; c < local_cells.n; c++) { cell = local_cells.cell[c]; @@ -964,7 +964,7 @@ void mpi_send_vs_relative_slave(int pnode, int part) /********************* REQ_SET_BOND ********/ -int mpi_send_bond(int pnode, int part, int *bond, int delete) +int mpi_send_bond(int pnode, int part, int *bond, int deleteIt) { int bond_size, stat=0; @@ -973,7 +973,7 @@ int mpi_send_bond(int pnode, int part, int *bond, int delete) bond_size = (bond) ? bonded_ia_params[bond[0]].num + 1 : 0; if (pnode == this_node) { - stat = local_change_bond(part, bond, delete); + stat = local_change_bond(part, bond, deleteIt); on_particle_change(); return stat; } @@ -981,7 +981,7 @@ int mpi_send_bond(int pnode, int part, int *bond, int delete) MPI_Send(&bond_size, 1, MPI_INT, pnode, SOME_TAG, comm_cart); if (bond_size) MPI_Send(bond, bond_size, MPI_INT, pnode, SOME_TAG, comm_cart); - MPI_Send(&delete, 1, MPI_INT, pnode, SOME_TAG, comm_cart); + MPI_Send(&deleteIt, 1, MPI_INT, pnode, SOME_TAG, comm_cart); MPI_Recv(&stat, 1, MPI_INT, pnode, SOME_TAG, comm_cart, MPI_STATUS_IGNORE); on_particle_change(); return stat; @@ -989,7 +989,7 @@ int mpi_send_bond(int pnode, int part, int *bond, int delete) void mpi_send_bond_slave(int pnode, int part) { - int bond_size=0, *bond, delete=0, stat; + int bond_size=0, *bond, deleteIt=0, stat; if (pnode == this_node) { MPI_Recv(&bond_size, 1, MPI_INT, 0, SOME_TAG, comm_cart, MPI_STATUS_IGNORE); @@ -999,8 +999,8 @@ void mpi_send_bond_slave(int pnode, int part) } else bond = NULL; - MPI_Recv(&delete, 1, MPI_INT, 0, SOME_TAG, comm_cart, MPI_STATUS_IGNORE); - stat = local_change_bond(part, bond, delete); + MPI_Recv(&deleteIt, 1, MPI_INT, 0, SOME_TAG, comm_cart, MPI_STATUS_IGNORE); + stat = local_change_bond(part, bond, deleteIt); if (bond) free(bond); MPI_Send(&stat, 1, MPI_INT, 0, SOME_TAG, comm_cart); @@ -1338,38 +1338,41 @@ void mpi_gather_stats(int job, void *result, void *result_t, void *result_nb, vo switch (job) { case 1: mpi_call(mpi_gather_stats_slave, -1, 1); - energy_calc(result); + energy_calc((double*)result); break; case 2: - /* calculate and reduce (sum up) virials for 'analyze pressure' or 'analyze stress_tensor'*/ + /* calculate and reduce (sum up) virials for 'analyze pressure' or + 'analyze stress_tensor' */ mpi_call(mpi_gather_stats_slave, -1, 2); - pressure_calc(result,result_t,result_nb,result_t_nb,0); + pressure_calc((double*)result, (double*)result_t, + (double*)result_nb, (double*)result_t_nb,0); break; case 3: mpi_call(mpi_gather_stats_slave, -1, 3); - pressure_calc(result,result_t,result_nb,result_t_nb,1); + pressure_calc((double*)result, (double*)result_t, + (double*)result_nb, (double*)result_t_nb,1); break; case 4: mpi_call(mpi_gather_stats_slave, -1, 4); - predict_momentum_particles(result); + predict_momentum_particles((double*)result); break; #ifdef LB case 5: mpi_call(mpi_gather_stats_slave, -1, 5); - lb_calc_fluid_mass(result); + lb_calc_fluid_mass((double*)result); break; case 6: mpi_call(mpi_gather_stats_slave, -1, 6); - lb_calc_fluid_momentum(result); + lb_calc_fluid_momentum((double*)result); break; case 7: mpi_call(mpi_gather_stats_slave, -1, 7); - lb_calc_fluid_temp(result); + lb_calc_fluid_temp((double*)result); break; #ifdef LB_BOUNDARIES case 8: mpi_call(mpi_gather_stats_slave, -1, 8); - lb_collect_boundary_forces(result); + lb_collect_boundary_forces((double*)result); break; #endif #endif @@ -1429,7 +1432,7 @@ void mpi_local_stress_tensor(DoubleList *TensorInBin, int bins[3], int periodic[ mpi_call(mpi_local_stress_tensor_slave,-1,0); - TensorInBin_ = malloc(bins[0]*bins[1]*bins[2]*sizeof(DoubleList)); + TensorInBin_ = (DoubleList*)malloc(bins[0]*bins[1]*bins[2]*sizeof(DoubleList)); for ( i = 0 ; i < bins[0]*bins[1]*bins[2]; i++ ) { init_doublelist(&TensorInBin_[i]); alloc_doublelist(&TensorInBin_[i],9); @@ -1467,7 +1470,7 @@ void mpi_local_stress_tensor_slave(int ana_num, int job) { MPI_Bcast(range_start, 3, MPI_DOUBLE, 0, comm_cart); MPI_Bcast(range, 3, MPI_DOUBLE, 0, comm_cart); - TensorInBin = malloc(bins[0]*bins[1]*bins[2]*sizeof(DoubleList)); + TensorInBin = (DoubleList*)malloc(bins[0]*bins[1]*bins[2]*sizeof(DoubleList)); for ( i = 0 ; i < bins[0]*bins[1]*bins[2]; i++ ) { init_doublelist(&TensorInBin[i]); alloc_doublelist(&TensorInBin[i],9); @@ -1505,7 +1508,7 @@ void mpi_get_particles(Particle *result, IntList *bi) mpi_call(mpi_get_particles_slave, -1, bi != NULL); - sizes = malloc(sizeof(int)*n_nodes); + sizes = (int*)malloc(sizeof(int)*n_nodes); n_part = cells_get_n_particles(); /* first collect number of particles on each node */ @@ -1629,7 +1632,7 @@ void mpi_get_particles_slave(int pnode, int bi) /* get (unsorted) particle informations as an array of type 'particle' */ /* then get the particle information */ - result = malloc(n_part*sizeof(Particle)); + result = (Particle*)malloc(n_part*sizeof(Particle)); init_intlist(&local_bi); @@ -1843,12 +1846,12 @@ void mpi_bcast_constraint(int del_num) else if (del_num == -2) { /* delete all constraints */ n_constraints = 0; - constraints = realloc(constraints,n_constraints*sizeof(Constraint)); + constraints = (Constraint*)realloc(constraints,n_constraints*sizeof(Constraint)); } else { memcpy(&constraints[del_num],&constraints[n_constraints-1],sizeof(Constraint)); n_constraints--; - constraints = realloc(constraints,n_constraints*sizeof(Constraint)); + constraints = (Constraint*)realloc(constraints,n_constraints*sizeof(Constraint)); } on_constraint_change(); @@ -1860,18 +1863,18 @@ void mpi_bcast_constraint_slave(int node, int parm) #ifdef CONSTRAINTS if(parm == -1) { n_constraints++; - constraints = realloc(constraints,n_constraints*sizeof(Constraint)); + constraints = (Constraint*)realloc(constraints,n_constraints*sizeof(Constraint)); MPI_Bcast(&constraints[n_constraints-1], sizeof(Constraint), MPI_BYTE, 0, comm_cart); } else if (parm == -2) { /* delete all constraints */ n_constraints = 0; - constraints = realloc(constraints,n_constraints*sizeof(Constraint)); + constraints = (Constraint*)realloc(constraints,n_constraints*sizeof(Constraint)); } else { memcpy(&constraints[parm],&constraints[n_constraints-1],sizeof(Constraint)); n_constraints--; - constraints = realloc(constraints,n_constraints*sizeof(Constraint)); + constraints = (Constraint*)realloc(constraints,n_constraints*sizeof(Constraint)); } on_constraint_change(); @@ -2299,7 +2302,7 @@ int mpi_gather_runtime_errors(char **errors) return ES_OK; // gather the maximum length of the error messages - int *errcnt = malloc(n_nodes*sizeof(int)); + int *errcnt = (int*)malloc(n_nodes*sizeof(int)); MPI_Gather(&n_error_msg, 1, MPI_INT, errcnt, 1, MPI_INT, 0, comm_cart); for (int node = 0; node < n_nodes; node++) { @@ -2316,7 +2319,7 @@ int mpi_gather_runtime_errors(char **errors) } /* reset error message on master node */ - error_msg = realloc(error_msg, n_error_msg = 0); + error_msg = (char*)realloc(error_msg, n_error_msg = 0); free(errcnt); @@ -2332,18 +2335,18 @@ void mpi_gather_runtime_errors_slave(int node, int parm) if (n_error_msg > 0) { MPI_Send(error_msg, n_error_msg, MPI_CHAR, 0, 0, comm_cart); /* reset error message on slave node */ - error_msg = realloc(error_msg, n_error_msg = 0); + error_msg = (char*)realloc(error_msg, n_error_msg = 0); } } /********************* REQ_SET_EXCL ********/ -void mpi_send_exclusion(int part1, int part2, int delete) +void mpi_send_exclusion(int part1, int part2, int deleteIt) { #ifdef EXCLUSIONS mpi_call(mpi_send_exclusion_slave, part1, part2); - MPI_Bcast(&delete, 1, MPI_INT, 0, comm_cart); - local_change_exclusion(part1, part2, delete); + MPI_Bcast(&deleteIt, 1, MPI_INT, 0, comm_cart); + local_change_exclusion(part1, part2, deleteIt); on_particle_change(); #endif } @@ -2351,9 +2354,9 @@ void mpi_send_exclusion(int part1, int part2, int delete) void mpi_send_exclusion_slave(int part1, int part2) { #ifdef EXCLUSIONS - int delete=0; - MPI_Bcast(&delete, 1, MPI_INT, 0, comm_cart); - local_change_exclusion(part1, part2, delete); + int deleteIt=0; + MPI_Bcast(&deleteIt, 1, MPI_INT, 0, comm_cart); + local_change_exclusion(part1, part2, deleteIt); on_particle_change(); #endif } diff --git a/src/communication.h b/src/communication.h index 4736d4a4dd5..e483726d5e2 100644 --- a/src/communication.h +++ b/src/communication.h @@ -259,15 +259,15 @@ void mpi_send_mol_id(int node, int part, int mid); \param delete if true, do not add the bond, rather delete it if found \return 1 on success or 0 if not (e. g. bond to delete does not exist) */ -int mpi_send_bond(int pnode, int part, int *bond, int delete); +int mpi_send_bond(int pnode, int part, int *bond, int deleteIt); /** Issue REQ_SET_EXCLUSION: send exclusions. Also calls \ref on_particle_change. \param part identity of first particle of the exclusion. \param part2 identity of secnd particle of the exclusion. - \param delete if true, do not add the exclusion, rather delete it if found + \param deleteIt if true, do not add the exclusion, rather delete it if found */ -void mpi_send_exclusion(int part, int part2, int delete); +void mpi_send_exclusion(int part, int part2, int deleteIt); /** Issue REQ_REM_PART: remove a particle. diff --git a/src/constraint.c b/src/constraint.c index 18e5dbcf94b..9a33d744ff0 100644 --- a/src/constraint.c +++ b/src/constraint.c @@ -40,7 +40,7 @@ Constraint *constraints = NULL; Constraint *generate_constraint() { n_constraints++; - constraints = realloc(constraints,n_constraints*sizeof(Constraint)); + constraints = (Constraint*)realloc(constraints,n_constraints*sizeof(Constraint)); constraints[n_constraints-1].type = CONSTRAINT_NONE; constraints[n_constraints-1].part_rep.p.identity = -n_constraints; diff --git a/src/debug.c b/src/debug.c index bcdff00f198..dd4e7174144 100644 --- a/src/debug.c +++ b/src/debug.c @@ -198,8 +198,8 @@ void check_particles() /* check the consistency of particle_nodes */ /* to this aim the array is broadcasted temporarily */ if (this_node != 0) - particle_node = malloc((max_seen_particle + 1)*sizeof(int)); - is_here = malloc((max_seen_particle + 1)*sizeof(int)); + particle_node = (int*)malloc((max_seen_particle + 1)*sizeof(int)); + is_here = (int*)malloc((max_seen_particle + 1)*sizeof(int)); memset(is_here, 0, (max_seen_particle + 1)*sizeof(int)); MPI_Bcast(particle_node, max_seen_particle + 1, MPI_INT, 0, comm_cart); diff --git a/src/domain_decomposition.c b/src/domain_decomposition.c index 9ea18388b9b..e7819deace8 100644 --- a/src/domain_decomposition.c +++ b/src/domain_decomposition.c @@ -282,7 +282,7 @@ void dd_prepare_comm(GhostCommunicator *comm, int data_parts) comm->comm[cnt].type = GHOST_LOCL; comm->comm[cnt].node = this_node; /* Buffer has to contain Send and Recv cells -> factor 2 */ - comm->comm[cnt].part_lists = malloc(2*n_comm_cells[dir]*sizeof(ParticleList *)); + comm->comm[cnt].part_lists = (ParticleList**)malloc(2*n_comm_cells[dir]*sizeof(ParticleList *)); comm->comm[cnt].n_part_lists = 2*n_comm_cells[dir]; /* prepare folding of ghost positions */ if((data_parts & GHOSTTRANS_POSSHFTD) && boundary[2*dir+lr] != 0) @@ -309,7 +309,7 @@ void dd_prepare_comm(GhostCommunicator *comm, int data_parts) if((node_pos[dir]+i)%2==0) { comm->comm[cnt].type = GHOST_SEND; comm->comm[cnt].node = node_neighbors[2*dir+lr]; - comm->comm[cnt].part_lists = malloc(n_comm_cells[dir]*sizeof(ParticleList *)); + comm->comm[cnt].part_lists = (ParticleList**)malloc(n_comm_cells[dir]*sizeof(ParticleList *)); comm->comm[cnt].n_part_lists = n_comm_cells[dir]; /* prepare folding of ghost positions */ if((data_parts & GHOSTTRANS_POSSHFTD) && boundary[2*dir+lr] != 0) @@ -328,7 +328,7 @@ void dd_prepare_comm(GhostCommunicator *comm, int data_parts) if((node_pos[dir]+(1-i))%2==0) { comm->comm[cnt].type = GHOST_RECV; comm->comm[cnt].node = node_neighbors[2*dir+(1-lr)]; - comm->comm[cnt].part_lists = malloc(n_comm_cells[dir]*sizeof(ParticleList *)); + comm->comm[cnt].part_lists = (ParticleList**)malloc(n_comm_cells[dir]*sizeof(ParticleList *)); comm->comm[cnt].n_part_lists = n_comm_cells[dir]; lc[(dir+0)%3] = hc[(dir+0)%3] = 0+(1-lr)*(dd.cell_grid[(dir+0)%3]+1); diff --git a/src/elc.c b/src/elc.c index 2bccb2922b5..ab4beeb315b 100644 --- a/src/elc.c +++ b/src/elc.c @@ -1259,10 +1259,10 @@ void ELC_on_resort_particles() n_localpart = cells_get_n_particles(); n_scxcache = (int)(ceil(elc_params.far_cut/ux) + 1); n_scycache = (int)(ceil(elc_params.far_cut/uy) + 1); - scxcache = realloc(scxcache, n_scxcache*n_localpart*sizeof(SCCache)); - scycache = realloc(scycache, n_scycache*n_localpart*sizeof(SCCache)); + scxcache = (SCCache*)realloc(scxcache, n_scxcache*n_localpart*sizeof(SCCache)); + scycache = (SCCache*)realloc(scycache, n_scycache*n_localpart*sizeof(SCCache)); - partblk = realloc(partblk, n_localpart*8*sizeof(double)); + partblk = (double*)realloc(partblk, n_localpart*8*sizeof(double)); } int ELC_set_params(double maxPWerror, double gap_size, double far_cut, int neutralize, diff --git a/src/errorhandling.c b/src/errorhandling.c index 0e6e01d81b0..161b69defbd 100644 --- a/src/errorhandling.c +++ b/src/errorhandling.c @@ -42,7 +42,7 @@ char *runtime_error(int errlen) int curend = error_msg ? strlen(error_msg) : 0; n_error_msg = curend + errlen + 1; - error_msg = realloc(error_msg, n_error_msg); + error_msg = (char*)realloc(error_msg, n_error_msg); return error_msg + curend; } diff --git a/src/fft-common.c b/src/fft-common.c index c2046326eb8..76b8a006167 100644 --- a/src/fft-common.c +++ b/src/fft-common.c @@ -38,7 +38,7 @@ void fft_common_pre_init(fft_data_struct *fft) { for(int i=0;i<4;i++) { - fft->plan[i].group = malloc(1*n_nodes*sizeof(int)); + fft->plan[i].group = (int*)malloc(1*n_nodes*sizeof(int)); fft->plan[i].send_block = NULL; fft->plan[i].send_size = NULL; fft->plan[i].recv_block = NULL; diff --git a/src/fft-common.h b/src/fft-common.h index a62998c64bc..15540a2f25b 100644 --- a/src/fft-common.h +++ b/src/fft-common.h @@ -22,6 +22,7 @@ #define _FFT_COMMON_H #include +#include #if defined(P3M) || defined(DP3M) @@ -44,9 +45,9 @@ typedef struct { /** number of 1D FFTs. */ int n_ffts; /** plan for fft. */ - void *fftw_plan; + fftw_plan our_fftw_plan; /** function for fft. */ - void (*fft_function)(); + void (*fft_function)(fftw_plan); /** size of local mesh before communication. */ int old_mesh[3]; @@ -63,7 +64,7 @@ typedef struct { int *group; /** packing function for send blocks. */ - void (*pack_function)(); + void (*pack_function)(double*, double*, int*, int*, int*, int); /** Send block specification. 6 integers for each node: start[3], size[3]. */ int *send_block; /** Send block communication sizes. */ @@ -81,12 +82,12 @@ typedef struct { /** plan direction. (e.g. fftw makro)*/ int dir; /** plan for fft. */ - void *fftw_plan; + fftw_plan our_fftw_plan; /** function for fft. */ - void (*fft_function)(); + void (*fft_function)(fftw_plan); /** packing function for send blocks. */ - void (*pack_function)(); + void (*pack_function)(double*, double*, int*, int*, int*, int); } fft_back_plan; typedef struct { diff --git a/src/fft.c b/src/fft.c index 0dad6ddd47e..4d070aee696 100644 --- a/src/fft.c +++ b/src/fft.c @@ -85,8 +85,8 @@ int fft_init(double **data, int *ca_mesh_dim, int *ca_mesh_margin, fft.max_comm_size=0; fft.max_mesh_size=0; for(i=0;i<4;i++) { - n_id[i] = malloc(1*n_nodes*sizeof(int)); - n_pos[i] = malloc(3*n_nodes*sizeof(int)); + n_id[i] = (int*)malloc(1*n_nodes*sizeof(int)); + n_pos[i] = (int*)malloc(3*n_nodes*sizeof(int)); } /* === node grids === */ @@ -250,9 +250,9 @@ int fft_init(double **data, int *ca_mesh_dim, int *ca_mesh_margin, wisdom_status = fftw_import_wisdom_from_file(wisdom_file); fclose(wisdom_file); } - if(fft.init_tag==1) fftw_destroy_plan(fft.plan[i].fftw_plan); + if(fft.init_tag==1) fftw_destroy_plan(fft.plan[i].our_fftw_plan); //printf("fft.plan[%d].n_ffts=%d\n",i,fft.plan[i].n_ffts); - fft.plan[i].fftw_plan = + fft.plan[i].our_fftw_plan = fftw_plan_many_dft(1,&fft.plan[i].new_mesh[2],fft.plan[i].n_ffts, c_data,NULL,1,fft.plan[i].new_mesh[2], c_data,NULL,1,fft.plan[i].new_mesh[2], @@ -276,8 +276,8 @@ int fft_init(double **data, int *ca_mesh_dim, int *ca_mesh_margin, wisdom_status = fftw_import_wisdom_from_file(wisdom_file); fclose(wisdom_file); } - if(fft.init_tag==1) fftw_destroy_plan(fft.back[i].fftw_plan); - fft.back[i].fftw_plan = + if(fft.init_tag==1) fftw_destroy_plan(fft.back[i].our_fftw_plan); + fft.back[i].our_fftw_plan = fftw_plan_many_dft(1,&fft.plan[i].new_mesh[2],fft.plan[i].n_ffts, c_data,NULL,1,fft.plan[i].new_mesh[2], c_data,NULL,1,fft.plan[i].new_mesh[2], @@ -340,19 +340,19 @@ void fft_perform_forw(double *data) data[(2*i)+1] = 0; /* complex value */ } /* perform FFT (in/out is data)*/ - fftw_execute_dft(fft.plan[1].fftw_plan,c_data,c_data); + fftw_execute_dft(fft.plan[1].our_fftw_plan,c_data,c_data); /* ===== second direction ===== */ FFT_TRACE(fprintf(stderr,"%d: fft_perform_forw: dir 2:\n",this_node)); /* communication to current dir row format (in is data) */ fft_forw_grid_comm(fft.plan[2], data, fft.data_buf); /* perform FFT (in/out is fft.data_buf)*/ - fftw_execute_dft(fft.plan[2].fftw_plan,c_data_buf,c_data_buf); + fftw_execute_dft(fft.plan[2].our_fftw_plan,c_data_buf,c_data_buf); /* ===== third direction ===== */ FFT_TRACE(fprintf(stderr,"%d: fft_perform_forw: dir 3:\n",this_node)); /* communication to current dir row format (in is fft.data_buf) */ fft_forw_grid_comm(fft.plan[3], fft.data_buf, data); /* perform FFT (in/out is data)*/ - fftw_execute_dft(fft.plan[3].fftw_plan,c_data,c_data); + fftw_execute_dft(fft.plan[3].our_fftw_plan,c_data,c_data); //fft_print_global_fft_mesh(fft.plan[3],data,1,0); /* REMARK: Result has to be in data. */ @@ -370,21 +370,21 @@ void fft_perform_back(double *data) /* perform FFT (in is data) */ - fftw_execute_dft(fft.back[3].fftw_plan,c_data,c_data); + fftw_execute_dft(fft.back[3].our_fftw_plan,c_data,c_data); /* communicate (in is data)*/ fft_back_grid_comm(fft.plan[3],fft.back[3],data,fft.data_buf); /* ===== second direction ===== */ FFT_TRACE(fprintf(stderr,"%d: fft_perform_back: dir 2:\n",this_node)); /* perform FFT (in is fft.data_buf) */ - fftw_execute_dft(fft.back[2].fftw_plan,c_data_buf,c_data_buf); + fftw_execute_dft(fft.back[2].our_fftw_plan,c_data_buf,c_data_buf); /* communicate (in is fft.data_buf) */ fft_back_grid_comm(fft.plan[2],fft.back[2],fft.data_buf,data); /* ===== first direction ===== */ FFT_TRACE(fprintf(stderr,"%d: fft_perform_back: dir 1:\n",this_node)); /* perform FFT (in is data) */ - fftw_execute_dft(fft.back[1].fftw_plan,c_data,c_data); + fftw_execute_dft(fft.back[1].our_fftw_plan,c_data,c_data); /* throw away the (hopefully) empty complex component (in is data)*/ for(i=0;idata_parts)); comm->num = num; - comm->comm = malloc(num*sizeof(GhostCommunication)); + comm->comm = (GhostCommunication*)malloc(num*sizeof(GhostCommunication)); for(i=0; icomm[i].shift[0]=comm->comm[i].shift[1]=comm->comm[i].shift[2]=0.0; } @@ -129,7 +129,7 @@ void prepare_send_buffer(GhostCommunication *gc, int data_parts) n_s_buffer = calc_transmit_size(gc, data_parts); if (n_s_buffer > max_s_buffer) { max_s_buffer = n_s_buffer; - s_buffer = realloc(s_buffer, max_s_buffer); + s_buffer = (char*)realloc(s_buffer, max_s_buffer); } GHOST_TRACE(fprintf(stderr, "%d: will send %d\n", this_node, n_s_buffer)); @@ -197,7 +197,7 @@ void prepare_recv_buffer(GhostCommunication *gc, int data_parts) n_r_buffer = calc_transmit_size(gc, data_parts); if (n_r_buffer > max_r_buffer) { max_r_buffer = n_r_buffer; - r_buffer = realloc(r_buffer, max_r_buffer); + r_buffer = (char*)realloc(r_buffer, max_r_buffer); } GHOST_TRACE(fprintf(stderr, "%d: will get %d\n", this_node, n_r_buffer)); } @@ -355,7 +355,9 @@ void cell_cell_transfer(GhostCommunication *gc, int data_parts) void reduce_forces_sum(void *add, void *to, int *len, MPI_Datatype *type) { - ParticleForce *cadd = add, *cto = to; + ParticleForce + *cadd = (ParticleForce*)add, + *cto = (ParticleForce*)to; int i, clen = *len/sizeof(ParticleForce); #ifdef ADDITIONAL_CHECKS diff --git a/src/imd.c b/src/imd.c index e32fcc30862..b8424c36dff 100644 --- a/src/imd.c +++ b/src/imd.c @@ -28,13 +28,12 @@ #include #include #include "utils.h" -#include "vmdsock.h" #include "imd.h" #include "communication.h" #include "particle_data.h" #include "statistics_chain.h" #include "statistics_molecule.h" - +#include "vmdsock.h" #include typedef struct { @@ -205,7 +204,7 @@ int imd_trate(void *s, int32_t rate) { int imd_send_mdcomm(void *s,int32_t n,const int32_t *indices,const float *forces) { int32_t size = HEADERSIZE+16*n; - char *buf = malloc(sizeof(char)*size); + char *buf = (char*)malloc(sizeof(char)*size); int rc; fill_header((IMDheader *)buf, IMD_MDCOMM, n); @@ -218,7 +217,7 @@ int imd_send_mdcomm(void *s,int32_t n,const int32_t *indices,const float *forces int imd_send_energies(void *s, const IMDEnergies *energies) { int32_t size = HEADERSIZE+sizeof(IMDEnergies); - char *buf = malloc(sizeof(char)*size); + char *buf = (char*)malloc(sizeof(char)*size); int rc; fill_header((IMDheader *)buf, IMD_ENERGIES, 1); @@ -230,7 +229,7 @@ int imd_send_energies(void *s, const IMDEnergies *energies) { int imd_send_fcoords(void *s, int32_t n, const float *coords) { int32_t size = HEADERSIZE+12*n; - char *buf = malloc(sizeof(char)*size); + char *buf = (char*)malloc(sizeof(char)*size); int rc; fill_header((IMDheader *)buf, IMD_FCOORDS, n); diff --git a/src/initialize.c b/src/initialize.c index 31d30c74898..7a9281faa6d 100644 --- a/src/initialize.c +++ b/src/initialize.c @@ -72,8 +72,7 @@ static int reinit_magnetostatics = 0; static int lb_reinit_particles_gpu = 1; #endif -void on_program_start() -{ +void on_program_start() { EVENT_TRACE(fprintf(stderr, "%d: on_program_start\n", this_node)); /* tell Electric fence that we do realloc(0) on purpose. */ diff --git a/src/interaction_data.c b/src/interaction_data.c index e94ccb1d5f9..8fb92928f7e 100644 --- a/src/interaction_data.c +++ b/src/interaction_data.c @@ -721,7 +721,7 @@ void recalc_maximal_cutoff() max_cut = max_cut_bonded; } -char *get_name_of_bonded_ia(int i) { +const char *get_name_of_bonded_ia(int i) { switch (i) { case BONDED_IA_FENE: return "FENE"; diff --git a/src/interaction_data.h b/src/interaction_data.h index c92c026e31d..54639fc8819 100644 --- a/src/interaction_data.h +++ b/src/interaction_data.h @@ -952,7 +952,7 @@ MDINLINE int checkIfParticlesInteract(int i, int j) { } /// -char *get_name_of_bonded_ia(int i); +const char *get_name_of_bonded_ia(int i); #ifdef ADRESS int checkIfTF(TF_parameters *data); diff --git a/src/layered.c b/src/layered.c index 8313905eb34..28a260aab91 100644 --- a/src/layered.c +++ b/src/layered.c @@ -145,7 +145,7 @@ static void layered_prepare_comm(GhostCommunicator *comm, int data_parts) /* always sending/receiving 1 cell per time step */ for(c = 0; c < n; c++) { - comm->comm[c].part_lists = malloc(sizeof(ParticleList *)); + comm->comm[c].part_lists = (ParticleList**)malloc(sizeof(ParticleList *)); comm->comm[c].n_part_lists = 1; comm->comm[c].mpi_comm = comm_cart; } @@ -263,7 +263,7 @@ static void layered_prepare_comm(GhostCommunicator *comm, int data_parts) if (n != 0) { /* two cells: from and to */ for(c = 0; c < n; c++) { - comm->comm[c].part_lists = malloc(2*sizeof(ParticleList *)); + comm->comm[c].part_lists = (ParticleList**)malloc(2*sizeof(ParticleList *)); comm->comm[c].n_part_lists = 2; comm->comm[c].mpi_comm = comm_cart; comm->comm[c].node = this_node; diff --git a/src/mmm-common.c b/src/mmm-common.c index 9f1b8ca7d98..40f46f7ba19 100644 --- a/src/mmm-common.c +++ b/src/mmm-common.c @@ -114,7 +114,7 @@ void create_mod_psi_up_to(int new_n) if (new_n > n_modPsi) { int old = n_modPsi; n_modPsi = new_n; - modPsi = realloc(modPsi, 2*n_modPsi*sizeof(Polynom)); + modPsi = (Polynom*)realloc(modPsi, 2*n_modPsi*sizeof(Polynom)); binom = 1.0; for (n = 0; n < old; n++) diff --git a/src/mmm2d.c b/src/mmm2d.c index 0062160231e..1a25b34ac0e 100644 --- a/src/mmm2d.c +++ b/src/mmm2d.c @@ -1314,7 +1314,7 @@ double MMM2D_add_far(int f, int e) if (mmm2d_params.far_cut == 0.0) return 0.5*eng; - undone = malloc((n_scxcache + 1)*sizeof(int)); + undone = (int*)malloc((n_scxcache + 1)*sizeof(int)); prepare_scx_cache(); prepare_scy_cache(); @@ -1950,12 +1950,12 @@ void MMM2D_on_resort_particles() n_localpart = cells_get_n_particles(); n_scxcache = (int)(ceil(mmm2d_params.far_cut/ux) + 1); n_scycache = (int)(ceil(mmm2d_params.far_cut/uy) + 1); - scxcache = realloc(scxcache, n_scxcache*n_localpart*sizeof(SCCache)); - scycache = realloc(scycache, n_scycache*n_localpart*sizeof(SCCache)); + scxcache = (SCCache*)realloc(scxcache, n_scxcache*n_localpart*sizeof(SCCache)); + scycache = (SCCache*)realloc(scycache, n_scycache*n_localpart*sizeof(SCCache)); - partblk = realloc(partblk, n_localpart*8*sizeof(double)); - lclcblk = realloc(lclcblk, n_cells*8*sizeof(double)); - gblcblk = realloc(gblcblk, n_layers*8*sizeof(double)); + partblk = (double*)realloc(partblk, n_localpart*8*sizeof(double)); + lclcblk = (double*)realloc(lclcblk, n_cells*8*sizeof(double)); + gblcblk = (double*)realloc(gblcblk, n_layers*8*sizeof(double)); } MMM2D_self_energy(); } diff --git a/src/nsquare.c b/src/nsquare.c index e8afdc2d9cc..3ab49666fc7 100644 --- a/src/nsquare.c +++ b/src/nsquare.c @@ -65,7 +65,7 @@ static void nsq_prepare_comm(GhostCommunicator *comm, int data_parts) prepare_comm(comm, data_parts, n_nodes); /* every node has its dedicated comm step */ for(n = 0; n < n_nodes; n++) { - comm->comm[n].part_lists = malloc(sizeof(ParticleList *)); + comm->comm[n].part_lists = (ParticleList**)malloc(sizeof(ParticleList *)); comm->comm[n].part_lists[0] = &cells[n]; comm->comm[n].n_part_lists = 1; comm->comm[n].node = n; @@ -162,7 +162,7 @@ void nsq_balance_particles(int global_flag) return; int pp = cells_get_n_particles(); - int *ppnode = malloc(n_nodes*sizeof(int)); + int *ppnode = (int*)malloc(n_nodes*sizeof(int)); /* minimal difference between node shares */ int minshare = n_total_particles/n_nodes; int maxshare = minshare + 1; diff --git a/src/p3m.c b/src/p3m.c index a6b6006c668..6b98cb37641 100644 --- a/src/p3m.c +++ b/src/p3m.c @@ -1019,7 +1019,7 @@ void p3m_calc_differential_operator() int i,j; for(i=0;i<3;i++) { - p3m.d_op[i] = realloc(p3m.d_op[i], p3m.params.mesh[i]*sizeof(double)); + p3m.d_op[i] = (double*)realloc(p3m.d_op[i], p3m.params.mesh[i]*sizeof(double)); p3m.d_op[i][0] = 0; p3m.d_op[i][p3m.params.mesh[i]/2] = 0.0; @@ -1989,8 +1989,8 @@ void p3m_calc_kspace_stress (double* stress) { int jx, jy, jz, i, ind = 0; // ordering after fourier transform const int x = 2, y = 0, z = 1; - node_k_space_stress = malloc(9*sizeof(double)); - k_space_stress = malloc(9*sizeof(double)); + node_k_space_stress = (double*)malloc(9*sizeof(double)); + k_space_stress = (double*)malloc(9*sizeof(double)); for (i = 0; i < 9; i++) { node_k_space_stress[i] = 0.0; diff --git a/src/particle_data.c b/src/particle_data.c index 0d2c48f827f..4f32cb4b684 100644 --- a/src/particle_data.c +++ b/src/particle_data.c @@ -274,7 +274,7 @@ void updatePartCfg(int bonds_flag) if(partCfg) return; - partCfg = malloc(n_total_particles*sizeof(Particle)); + partCfg = (Particle*)malloc(n_total_particles*sizeof(Particle)); if (bonds_flag != WITH_BONDS) mpi_get_particles(partCfg, NULL); else @@ -304,7 +304,7 @@ int sortPartCfg() if (n_total_particles != max_seen_particle + 1) return 0; - sorted = malloc(n_total_particles*sizeof(Particle)); + sorted = (Particle*)malloc(n_total_particles*sizeof(Particle)); for(i = 0; i < n_total_particles; i++) memcpy(&sorted[partCfg[i].p.identity], &partCfg[i], sizeof(Particle)); free(partCfg); @@ -506,7 +506,7 @@ int get_particle_data(int part, Particle *data) int place_particle(int part, double p[3]) { - int new, i; + int i; int pnode, retcode = ES_PART_OK; if (part < 0) @@ -516,8 +516,7 @@ int place_particle(int part, double p[3]) build_particle_node(); pnode = (part <= max_seen_particle) ? particle_node[part] : -1; - new = (pnode == -1); - if (new) { + if (pnode == -1) { /* new particle, node by spatial position */ pnode = cell_structure.position_to_node(p); @@ -877,7 +876,7 @@ int set_particle_fix(int part, int flag) #endif -int change_particle_bond(int part, int *bond, int delete) +int change_particle_bond(int part, int *bond, int deleteIt) { int pnode; if (!particle_node) @@ -889,8 +888,8 @@ int change_particle_bond(int part, int *bond, int delete) if (pnode == -1) return ES_ERROR; - if(delete != 0 || bond == NULL) - delete = 1; + if(deleteIt != 0 || bond == NULL) + deleteIt = 1; if (bond != NULL) { if (bond[0] < 0 || bond[0] >= n_bonded_ia) { @@ -899,7 +898,7 @@ int change_particle_bond(int part, int *bond, int delete) return ES_ERROR; } } - return mpi_send_bond(pnode, part, bond, delete); + return mpi_send_bond(pnode, part, bond, deleteIt); } void remove_all_particles() @@ -973,7 +972,7 @@ void local_remove_particle(int part) pl->n--; } -void local_place_particle(int part, double p[3], int new) +void local_place_particle(int part, double p[3], int createNew) { Cell *cell; double pp[3]; @@ -988,7 +987,7 @@ void local_place_particle(int part, double p[3], int new) pp[2] = p[2]; fold_position(pp, i); - if (new) { + if (createNew) { /* allocate particle anew */ cell = cell_structure.position_to_cell(pp); if (!cell) { @@ -1074,7 +1073,7 @@ void added_particle(int part) } } -int local_change_bond(int part, int *bond, int delete) +int local_change_bond(int part, int *bond, int deleteIt) { IntList *bl; Particle *p; @@ -1082,7 +1081,7 @@ int local_change_bond(int part, int *bond, int delete) int i; p = local_particles[part]; - if (delete) + if (deleteIt) return try_delete_bond(p, bond); bond_size = bonded_ia_params[bond[0]].num + 1; @@ -1164,7 +1163,7 @@ void remove_all_bonds_to(int identity) } #ifdef EXCLUSIONS -void local_change_exclusion(int part1, int part2, int delete) +void local_change_exclusion(int part1, int part2, int deleteIt) { Cell *cell; int p, np, c; @@ -1185,7 +1184,7 @@ void local_change_exclusion(int part1, int part2, int delete) /* part1, if here */ part = local_particles[part1]; if (part) { - if (delete) + if (deleteIt) try_delete_exclusion(part, part2); else try_add_exclusion(part, part2); @@ -1194,7 +1193,7 @@ void local_change_exclusion(int part1, int part2, int delete) /* part2, if here */ part = local_particles[part2]; if (part) { - if (delete) + if (deleteIt) try_delete_exclusion(part, part1); else try_add_exclusion(part, part1); @@ -1352,7 +1351,7 @@ void add_partner(IntList *il, int i, int j, int distance) #ifdef EXCLUSIONS -int change_exclusion(int part1, int part2, int delete) +int change_exclusion(int part1, int part2, int deleteIt) { if (!particle_node) build_particle_node(); @@ -1364,7 +1363,7 @@ int change_exclusion(int part1, int part2, int delete) particle_node[part2] == -1) return ES_ERROR; - mpi_send_exclusion(part1, part2, delete); + mpi_send_exclusion(part1, part2, deleteIt); return ES_OK; } @@ -1387,7 +1386,7 @@ void auto_exclusion(int distance) /* setup bond partners and distance list. Since we need to identify particles via their identity, we use a full sized array */ - partners = malloc((max_seen_particle + 1)*sizeof(IntList)); + partners = (IntList*)malloc((max_seen_particle + 1)*sizeof(IntList)); for (p = 0; p <= max_seen_particle; p++) init_intlist(&partners[p]); diff --git a/src/particle_data.h b/src/particle_data.h index 0ad21c21191..5b208c14651 100644 --- a/src/particle_data.h +++ b/src/particle_data.h @@ -567,7 +567,7 @@ int set_particle_fix(int part, int flag); @return ES_OK on success or ES_ERROR if no success (e. g. particle or bond to delete does not exist) */ -int change_particle_bond(int part, int *bond, int delete); +int change_particle_bond(int part, int *bond, int deleteIt); #ifdef EXCLUSIONS /** Call only on the master node: change particle constraints. @@ -577,7 +577,7 @@ int change_particle_bond(int part, int *bond, int delete); @return ES_OK on success or ES_ERROR if no success (e. g. particles do not exist / did not have exclusion set) */ -int change_exclusion(int part, int part2, int delete); +int change_exclusion(int part, int part2, int deleteIt); /** remove all exclusions. */ void remove_all_exclusions(); @@ -631,7 +631,7 @@ int sortPartCfg(); @param p its new position @param new if true, the particle is allocated, else has to exists already */ -void local_place_particle(int part, double p[3], int new); +void local_place_particle(int part, double p[3], int createNew); /** Used by \ref mpi_place_particle, should not be used elsewhere. Called if on a different node a new particle was added. @@ -646,15 +646,15 @@ void added_particle(int part); @param delete if true, delete the bond instead of add @return ES_OK for add or successful delete, ES_ERROR else */ -int local_change_bond(int part, int *bond, int delete); +int local_change_bond(int part, int *bond, int deleteIt); /** Used for example by \ref mpi_send_exclusion. Locally add a exclusion to a particle. @param part1 the identity of the first exclusion partner @param part2 the identity of the second exclusion partner - @param delete if true, delete the exclusion instead of add + @param deleteIt if true, delete the exclusion instead of add */ -void local_change_exclusion(int part1, int part2, int delete); +void local_change_exclusion(int part1, int part2, int deleteIt); /** Used by \ref mpi_remove_particle, should not be used elsewhere. Remove a particle on this node. diff --git a/src/polymer.c b/src/polymer.c index 61a99ae620a..1021d896829 100644 --- a/src/polymer.c +++ b/src/polymer.c @@ -58,7 +58,7 @@ int mindist3(int part_id, double r_catch, int *ids) { double dx,dy,dz; int i, me, caught=0; - partCfgMD = malloc(n_total_particles*sizeof(Particle)); + partCfgMD = (Particle*)malloc(n_total_particles*sizeof(Particle)); mpi_get_particles(partCfgMD, NULL); me = -1; /* Since 'mpi_get_particles' returns the particles unsorted, it's most likely that 'partCfgMD[i].p.identity != i' --> prevent that! */ @@ -88,7 +88,7 @@ double mindist4(double pos[3]) { int i; if (n_total_particles ==0) return (dmin(dmin(box_l[0],box_l[1]),box_l[2])); - partCfgMD = malloc(n_total_particles*sizeof(Particle)); + partCfgMD = (Particle*)malloc(n_total_particles*sizeof(Particle)); mpi_get_particles(partCfgMD, NULL); for (i=0; i0) for(j=0;j0) + for(j=0;j '-1') for each polymer chain's end if it's not already been crosslinked (-> '-2'). */ - cross = malloc(2*N_P*sizeof(int)); crossL = 0; + cross = (int*)malloc(2*N_P*sizeof(int)); crossL = 0; for (i=0; i < 2*N_P; i++) if (link[i] > 0) { cross[i] = links[i][(int)dround(d_random()*(link[i]-1))]; crossL++; } else { cross[i] = -1+link[i]; crossL -= link[i]; } POLY_TRACE(for (i=0; i < 2*N_P; i++) printf("%d -> %d \t", i%2 ? (i+1)*MPC/2-1 : i*MPC/2, cross[i]); printf("=> %d\n",crossL); fflush(NULL) ); diff --git a/src/reaction.c b/src/reaction.c index cb389faec2a..8043353468a 100644 --- a/src/reaction.c +++ b/src/reaction.c @@ -27,6 +27,7 @@ #include "initialize.h" #include "forces.h" +reaction_struct reaction; #ifdef REACTIONS void setup_reaction() { diff --git a/src/reaction.h b/src/reaction.h index 0fb5a865651..fc3fdcb02a4 100644 --- a/src/reaction.h +++ b/src/reaction.h @@ -36,7 +36,7 @@ typedef struct { double back_rate; } reaction_struct; -reaction_struct reaction; +extern reaction_struct reaction; #ifdef REACTIONS /** broadcasts reaction parameters and sets up an entry in the ia_params, so diff --git a/src/statistics.c b/src/statistics.c index 30eb6d8010d..75aa05d4864 100644 --- a/src/statistics.c +++ b/src/statistics.c @@ -360,7 +360,8 @@ void calc_gyration_tensor(int type, double **_gt) double Smatrix[9],p1[3]; for (i=0; i<9; i++) Smatrix[i] = 0; - *_gt = gt = realloc(gt,16*sizeof(double)); /* 3*ev, rg, b, c, kappa, eve0[3], eve1[3], eve2[3]*/ + /* 3*ev, rg, b, c, kappa, eve0[3], eve1[3], eve2[3]*/ + *_gt = gt = (double*)realloc(gt,16*sizeof(double)); updatePartCfg(WITHOUT_BONDS); @@ -682,7 +683,7 @@ void calc_rdf_av(int *p1_types, int n_p1, int *p2_types, int n_p2, double volume, bin_volume, r_in, r_out; double *rdf_tmp, p1[3],p2[3]; - rdf_tmp = malloc(r_bins*sizeof(double)); + rdf_tmp = (double*)malloc(r_bins*sizeof(double)); if(n_p1 == n_p2) { for(i=0;i n_particle_types)) { fprintf(stderr,"WARNING: Type %i does not exist!",type); fflush(NULL); errexit(); } @@ -994,7 +995,7 @@ void calc_diffusion_profile(int dir, double xmin, double xmax, int nbins, int n_ // double *bins; int *label; - label = malloc(n_part*sizeof(int)); + label = (int*)malloc(n_part*sizeof(int)); /* calculation over last n_conf configurations */ t=n_configs-n_conf; @@ -1136,8 +1137,8 @@ int calc_radial_density_map (int xbins,int ybins,int thetabins,double xrange,dou xav = xav/(double)(beadcount); yav = yav/(double)(beadcount); thetabinwidth = 2*PI/(double)(thetabins); - thetaradii = malloc(thetabins*nbeadtypes*sizeof(double)); - thetacounts = malloc(thetabins*nbeadtypes*sizeof(int)); + thetaradii = (double*)malloc(thetabins*nbeadtypes*sizeof(double)); + thetacounts = (int*)malloc(thetabins*nbeadtypes*sizeof(int)); for ( bi = 0 ; bi < nbeadtypes ; bi++ ) { for ( t = 0 ; t < thetabins ; t++ ) { thetaradii[bi*thetabins+t] = 0.0; @@ -1253,7 +1254,7 @@ double calc_vanhove(int ptype, double rmin, double rmax, int rbins, int tmax, do void analyze_append() { int i; n_part_conf = n_total_particles; - configs = realloc(configs,(n_configs+1)*sizeof(double *)); + configs = (double**)realloc(configs,(n_configs+1)*sizeof(double *)); configs[n_configs] = (double *) malloc(3*n_part_conf*sizeof(double)); for(i=0; i r_min) && (dist < r_max)) { - ind = (int) ( (dist - r_min)*inv_bin_width ); - f1[ind]+= 1.0; - } - if (dist r_min) && (dist < r_max)) { - ind = (int) ( (dist - r_min)*inv_bin_width ); - f3[ind]+= 1.0; - } - } - } - for(c_i=0; c_i r_min) && (dist < r_max)) { - ind = (int) ( (dist - r_min)*inv_bin_width ); - f2[ind]+= 1.0; - } - } + ind = (int) ( (dist - r_min)*inv_bin_width ); + f1[ind]+= 1.0; + } + if (dist r_min) && (dist < r_max)) { + ind = (int) ( (dist - r_min)*inv_bin_width ); + f3[ind]+= 1.0; + } } + } + for(c_i=0; c_i r_min) && (dist < r_max)) { + ind = (int) ( (dist - r_min)*inv_bin_width ); + f2[ind]+= 1.0; + } + } + } /* normalization */ factor = box_l[0]*box_l[1]*box_l[2] *1.5/PI/(chain_n_chains*(chain_n_chains-1)); for(i=0; idim_corr; j++) { + for (unsigned j=0; jdim_corr; j++) { correlation_time[j] = 0.; } // here we still have to fix the stuff a bit! - for (j=0; jdim_corr; j++) { + for (unsigned j=0; jdim_corr; j++) { C_tau=1*self->dt; ok_flag=0; - for (k=1; kn_result-1; k++) { + for (unsigned k=1; kn_result-1; k++) { if (self->n_sweeps[k]==0) break; C_tau+=(self->result[k][j]/ (double) self->n_sweeps[k] - self->A_accumulated_average[j]*self->B_accumulated_average[j]/self->n_data/self->n_data)/(self->result[0][j]/self->n_sweeps[0])*self->dt*(self->tau[k]-self->tau[k-1]); @@ -374,7 +372,7 @@ int double_correlation_get_data( double_correlation* self ) { // We must now go through the hierarchy and make sure there is space for the new // datapoint. For every hierarchy level we have to decide if it necessary to move // something - int i,j,k; + int i,j; int highest_level_to_compress; unsigned int index_new, index_old, index_res; int error; @@ -424,19 +422,19 @@ int double_correlation_get_data( double_correlation* self ) { // Now we update the cumulated averages and variances of A and B self->n_data++; - for (k=0; kdim_A; k++) { + for (unsigned k=0; kdim_A; k++) { self->A_accumulated_average[k]+=self->A[0][self->newest[0]][k]; self->A_accumulated_variance[k]+=self->A[0][self->newest[0]][k]*self->A[0][self->newest[0]][k]; } // Here we check if it is an autocorrelation if (!self->autocorrelation) { - for (k=0; kdim_B; k++) { + for (unsigned k=0; kdim_B; k++) { self->B_accumulated_average[k]+=self->B[0][self->newest[0]][k]; self->B_accumulated_variance[k]+=self->B[0][self->newest[0]][k]*self->B[0][self->newest[0]][k]; } } - double* temp = malloc(self->dim_corr*sizeof(double)); + double* temp = (double*)malloc(self->dim_corr*sizeof(double)); if (!temp) return 4; // Now update the lowest level correlation estimates @@ -448,13 +446,13 @@ int double_correlation_get_data( double_correlation* self ) { if ( error != 0) return error; self->n_sweeps[j]++; - for (k = 0; k < self->dim_corr; k++) { + for (unsigned k = 0; k < self->dim_corr; k++) { self->result[j][k] += temp[k]; } } // Now for the higher ones - for ( i = 1; i < highest_level_to_compress+2; i++) { - for ( j = (self->tau_lin+1)/2+1; j < MIN(self->tau_lin+1, self->n_vals[i]); j++) { + for ( int i = 1; i < highest_level_to_compress+2; i++) { + for ( unsigned j = (self->tau_lin+1)/2+1; j < MIN(self->tau_lin+1, self->n_vals[i]); j++) { index_new = self->newest[i]; index_old = (self->newest[i] - j + self->tau_lin + 1) % (self->tau_lin + 1); index_res = self->tau_lin + (i-1)*self->tau_lin/2 + (j - self->tau_lin/2+1) -1; @@ -462,7 +460,7 @@ int double_correlation_get_data( double_correlation* self ) { if ( error != 0) return error; self->n_sweeps[index_res]++; - for (k = 0; k < self->dim_corr; k++) { + for (unsigned k = 0; k < self->dim_corr; k++) { self->result[index_res][k] += temp[k]; } } @@ -475,17 +473,17 @@ int double_correlation_finalize( double_correlation* self ) { // We must now go through the hierarchy and make sure there is space for the new // datapoint. For every hierarchy level we have to decide if it necessary to move // something - int i,j,k; + int i,j; int ll=0; // current lowest level int vals_ll=0; // number of values remaining in the lowest level int highest_level_to_compress; unsigned int index_new, index_old, index_res; int error; //int compress; - int tau_lin=self->tau_lin; + unsigned tau_lin=self->tau_lin; int hierarchy_depth=self->hierarchy_depth; - double* temp = malloc(self->dim_corr*sizeof(double)); + double* temp = (double*)malloc(self->dim_corr*sizeof(double)); // make a flag that the correlation is finalized self->finalized=1; @@ -495,13 +493,13 @@ int double_correlation_finalize( double_correlation* self ) { //printf ("tau_lin:%d, hierarchy_depth: %d\n",tau_lin,hierarchy_depth); //for(ll=0;lln_vals[ll]); for(ll=0;lln_vals[ll] > tau_lin+1 ) vals_ll = tau_lin + self->n_vals[ll]%2; + if (self->n_vals[ll] > tau_lin+1 ) vals_ll = tau_lin + self->n_vals[ll]%2; else vals_ll=self->n_vals[ll]; //printf("\nfinalizing level %d with %d vals initially\n",ll,vals_ll); - while(vals_ll) { + while (vals_ll) { // Check, if we will want to push the value from the lowest level - if(vals_ll % 2) { + if (vals_ll % 2) { highest_level_to_compress=ll; } else { highest_level_to_compress=-1; @@ -516,7 +514,7 @@ int double_correlation_finalize( double_correlation* self ) { while (highest_level_to_compress>-1) { //printf("test level %d for compression, n_vals=%d ... ",i,self->n_vals[i]); if ( self->n_vals[i]%2 ) { - if ( i < (hierarchy_depth - 1) && self->n_vals[i]> tau_lin) { + if ( i < (hierarchy_depth-1) && self->n_vals[i]> tau_lin) { //printf("YES\n"); highest_level_to_compress+=1; i++; @@ -559,7 +557,7 @@ int double_correlation_finalize( double_correlation* self ) { if ( error != 0) return error; self->n_sweeps[index_res]++; - for (k = 0; k < self->dim_corr; k++) { + for (unsigned k = 0; k < self->dim_corr; k++) { self->result[index_res][k] += temp[k]; } } @@ -577,11 +575,10 @@ int double_correlation_finalize( double_correlation* self ) { int identity ( double* input, unsigned int n_input, double* A, unsigned int dim_A) { - int i; if ( n_input != dim_A ) { return 5; } - for ( i = 0; i < dim_A; i++ ) { + for (unsigned i = 0; i < dim_A; i++ ) { A[i] = input[i]; } return 0; @@ -676,7 +673,6 @@ int square_distance_componentwise ( double* A, unsigned int dim_A, double* B, un int fcs_acf ( double* A, unsigned int dim_A, double* B, unsigned int dim_B, double* C, unsigned int dim_corr, void *args ) { DoubleList *wsquare = (DoubleList*)args; - int i; if (args == NULL ) return 1; if (!(dim_A == dim_B )) { @@ -685,20 +681,19 @@ int fcs_acf ( double* A, unsigned int dim_A, double* B, unsigned int dim_B, doub if ( dim_A / dim_corr != 3) { return 6; } - for ( i = 0; i < dim_corr; i++ ) + for (unsigned i = 0; i < dim_corr; i++ ) C[i] = 0; - for ( i = 0; i < dim_A; i++ ) { + for (unsigned i = 0; i < dim_A; i++ ) { C [i/3] -= ( (A[i]-B[i])*(A[i]-B[i]) ) / wsquare->e[i%3]; } - for ( i = 0; i < dim_corr; i++ ) + for (unsigned i = 0; i < dim_corr; i++ ) C[i] = exp(C[i]); return 0; } void autoupdate_correlations() { - int i; - for (i=0; icorrelations[i].dt*0.99999) { //printf("updating %d\n", i); diff --git a/src/statistics_observable.c b/src/statistics_observable.c index 2505a3a4ee2..c38c137c9ef 100644 --- a/src/statistics_observable.c +++ b/src/statistics_observable.c @@ -26,11 +26,10 @@ observable** observables = 0; int n_observables = 0; int observable_particle_velocities(void* idlist, double* A, unsigned int n_A) { - unsigned int i; IntList* ids; sortPartCfg(); ids=(IntList*) idlist; - for ( i = 0; in; i++ ) { + for (int i = 0; in; i++ ) { if (ids->e[i] >= n_total_particles) return 1; A[3*i + 0] = partCfg[ids->e[i]].m.v[0]/time_step; @@ -42,12 +41,11 @@ int observable_particle_velocities(void* idlist, double* A, unsigned int n_A) { #ifdef ELECTROSTATICS int observable_particle_currents(void* idlist, double* A, unsigned int n_A) { - unsigned int i; double charge; IntList* ids; sortPartCfg(); ids=(IntList*) idlist; - for ( i = 0; in; i++ ) { + for (int i = 0; in; i++ ) { if (ids->e[i] >= n_total_particles) return 1; charge = partCfg[ids->e[i]].p.q; @@ -59,13 +57,12 @@ int observable_particle_currents(void* idlist, double* A, unsigned int n_A) { } int observable_currents(void* idlist, double* A, unsigned int n_A) { - unsigned int i; double charge; double j[3] = {0. , 0., 0. } ; IntList* ids; sortPartCfg(); ids=(IntList*) idlist; - for ( i = 0; in; i++ ) { + for (int i = 0; in; i++ ) { if (ids->e[i] > n_total_particles) return 1; charge = partCfg[ids->e[i]].p.q; @@ -80,13 +77,12 @@ int observable_currents(void* idlist, double* A, unsigned int n_A) { } int observable_dipole_moment(void* idlist, double* A, unsigned int n_A) { - unsigned int i; double charge; double j[3] = {0. , 0., 0. } ; IntList* ids; sortPartCfg(); ids=(IntList*) idlist; - for ( i = 0; in; i++ ) { + for (int i = 0; in; i++ ) { if (ids->e[i] > n_total_particles) return 1; charge = partCfg[ids->e[i]].p.q; @@ -102,13 +98,12 @@ int observable_dipole_moment(void* idlist, double* A, unsigned int n_A) { #endif int observable_com_velocity(void* idlist, double* A, unsigned int n_A) { - unsigned int i; double v_com[3] = { 0. , 0., 0. } ; double total_mass = 0; IntList* ids; sortPartCfg(); ids=(IntList*) idlist; - for ( i = 0; in; i++ ) { + for (int i = 0; in; i++ ) { if (ids->e[i] >= n_total_particles) return 1; v_com[0] += PMASS(partCfg[ids->e[i]])*partCfg[ids->e[i]].m.v[0]/time_step; @@ -183,13 +178,12 @@ int observable_blocked_com_position(void* idlist, double* A, unsigned int n_A) { } int observable_com_position(void* idlist, double* A, unsigned int n_A) { - unsigned int i; double p_com[3] = { 0. , 0., 0. } ; double total_mass = 0; IntList* ids; sortPartCfg(); ids=(IntList*) idlist; - for ( i = 0; in; i++ ) { + for (int i = 0; in; i++ ) { if (ids->e[i] >= n_total_particles) return 1; p_com[0] += PMASS(partCfg[ids->e[i]])*partCfg[ids->e[i]].r.p[0]; @@ -205,12 +199,11 @@ int observable_com_position(void* idlist, double* A, unsigned int n_A) { int observable_com_force(void* idlist, double* A, unsigned int n_A) { - unsigned int i; double f_com[3] = { 0. , 0., 0. } ; IntList* ids; sortPartCfg(); ids=(IntList*) idlist; - for ( i = 0; in; i++ ) { + for (int i = 0; in; i++ ) { if (ids->e[i] >= n_total_particles) return 1; f_com[0] += partCfg[ids->e[i]].f.f[0]/time_step/time_step*2; @@ -250,7 +243,6 @@ int observable_blocked_com_force(void* idlist, double* A, unsigned int n_A) { int observable_density_profile(void* pdata_, double* A, unsigned int n_A) { - unsigned int i; int binx, biny, binz; double ppos[3]; int img[3]; @@ -261,10 +253,10 @@ int observable_density_profile(void* pdata_, double* A, unsigned int n_A) { ids=pdata->id_list; double bin_volume=(pdata->maxx-pdata->minx)*(pdata->maxy-pdata->miny)*(pdata->maxz-pdata->minz)/pdata->xbins/pdata->ybins/pdata->zbins; - for ( i = 0; in; i++ ) { + for (int i = 0; in; i++ ) { if (ids->e[i] >= n_total_particles) return 1; /* We use folded coordinates here */ @@ -456,7 +448,6 @@ void transform_to_cylinder_coordinates(double x, double y, double z_, double* r, } int observable_radial_density_profile(void* pdata_, double* A, unsigned int n_A) { - unsigned int i; int binr, binphi, binz; double ppos[3]; double r, phi, z; @@ -471,10 +462,10 @@ int observable_radial_density_profile(void* pdata_, double* A, unsigned int n_A) double phibinsize=(pdata->maxphi - pdata->minphi)/pdata->phibins; double zbinsize=(pdata->maxz - pdata->minz)/pdata->zbins; - for ( i = 0; i< n_A; i++ ) { + for (unsigned i = 0; i< n_A; i++ ) { A[i]=0; } - for ( i = 0; in; i++ ) { + for (int i = 0; in; i++ ) { if (ids->e[i] >= n_total_particles) return 1; /* We use folded coordinates here */ @@ -496,7 +487,6 @@ int observable_radial_density_profile(void* pdata_, double* A, unsigned int n_A) } int observable_radial_flux_density_profile(void* pdata_, double* A, unsigned int n_A) { - unsigned int i; int binr, binphi, binz; double ppos[3]; double r, phi, z; @@ -513,10 +503,10 @@ int observable_radial_flux_density_profile(void* pdata_, double* A, unsigned int double v[3]; double v_r, v_phi, v_z; - for ( i = 0; i< n_A; i++ ) { + for (unsigned i = 0; i< n_A; i++ ) { A[i]=0; } - for ( i = 0; in; i++ ) { + for (int i = 0; in; i++ ) { if (ids->e[i] >= n_total_particles) return 1; /* We use folded coordinates here */ @@ -545,7 +535,6 @@ int observable_radial_flux_density_profile(void* pdata_, double* A, unsigned int } int observable_flux_density_profile(void* pdata_, double* A, unsigned int n_A) { - unsigned int i; int binx, biny, binz; double ppos[3]; double x, y, z; @@ -562,10 +551,10 @@ int observable_flux_density_profile(void* pdata_, double* A, unsigned int n_A) { double v[3]; double v_x, v_y, v_z; - for ( i = 0; i< n_A; i++ ) { + for (unsigned i = 0; i< n_A; i++ ) { A[i]=0; } - for ( i = 0; in; i++ ) { + for (int i = 0; in; i++ ) { if (ids->e[i] >= n_total_particles) return 1; /* We use folded coordinates here */ @@ -597,11 +586,10 @@ int observable_flux_density_profile(void* pdata_, double* A, unsigned int n_A) { } int observable_particle_positions(void* idlist, double* A, unsigned int n_A) { - unsigned int i; IntList* ids; sortPartCfg(); ids=(IntList*) idlist; - for ( i = 0; in; i++ ) { + for (int i = 0; in; i++ ) { if (ids->e[i] >= n_total_particles) return 1; A[3*i + 0] = partCfg[ids->e[i]].r.p[0]; @@ -612,11 +600,10 @@ int observable_particle_positions(void* idlist, double* A, unsigned int n_A) { } int observable_particle_forces(void* idlist, double* A, unsigned int n_A) { - unsigned int i; IntList* ids; sortPartCfg(); ids=(IntList*) idlist; - for ( i = 0; in; i++ ) { + for (int i = 0; in; i++ ) { if (ids->e[i] >= n_total_particles) return 1; A[3*i + 0] = partCfg[ids->e[i]].f.f[0]/time_step/time_step*2; @@ -649,7 +636,7 @@ int observable_stress_tensor_acf_obs(void* params_p, double* A, unsigned int n_A int observable_structure_factor(void* params_p, double* A, unsigned int n_A) { // FIXME Currently scattering length is hardcoded as 1.0 - int i,j,k,l,p; + int l; int order, order2, n; double twoPI_L, C_sum, S_sum, qr; // DoubleList *scattering_length; @@ -663,20 +650,20 @@ int observable_structure_factor(void* params_p, double* A, unsigned int n_A) { sortPartCfg(); - for(p=0; p=1)) { C_sum = S_sum = 0.0; //printf("l: %d, n: %d %d %d\n",l,i,j,k); fflush(stdout); - for(p=0; p. */ -#ifndef ANGLE_TCL_H -#define ANGLE_TCL_H +#ifndef _ANGLE_COSINE_TCL_H +#define _ANGLE_COSINE_TCL_H /** \file angle_cosine_tcl.h * Tcl interface for \ref angle_cosine.h */ diff --git a/src/tcl/angle_cossquare_tcl.h b/src/tcl/angle_cossquare_tcl.h index 8f9672d7330..a3b11cffe9d 100644 --- a/src/tcl/angle_cossquare_tcl.h +++ b/src/tcl/angle_cossquare_tcl.h @@ -18,8 +18,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifndef ANGLE_TCL_H -#define ANGLE_TCL_H +#ifndef _ANGLE_COSSQUARE_TCL_H +#define _ANGLE_COSSQUARE_TCL_H /** \file angle__cossquare_tcl.h * Tcl interface for \ref angle_cossquare.h */ diff --git a/src/tcl/angle_harmonic_tcl.h b/src/tcl/angle_harmonic_tcl.h index 2f7b90310ac..185b370c3d8 100644 --- a/src/tcl/angle_harmonic_tcl.h +++ b/src/tcl/angle_harmonic_tcl.h @@ -18,18 +18,20 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifndef ANGLE_TCL_H -#define ANGLE_TCL_H +#ifndef _ANGLE_HARMONIC_TCL_H +#define _ANGLE_HARMONIC_TCL_H /** \file angle_harmonic_tcl.h * Tcl interface for \ref angle_harmonic.h */ +#include #include "parser.h" #include "interaction_data.h" #ifdef BOND_ANGLE /// parse parameters for the angle potential -int tclcommand_inter_parse_angle_harmonic(Tcl_Interp *interp, int bond_type, int argc, char **argv); +int tclcommand_inter_parse_angle_harmonic(Tcl_Interp *interp, int bond_type, + int argc, char **argv); /// int tclprint_to_result_angle_harmonicIA(Tcl_Interp *interp, Bonded_ia_parameters *params); diff --git a/src/tcl/binary_file_tcl.c b/src/tcl/binary_file_tcl.c index 80356332e61..70ec582fe99 100644 --- a/src/tcl/binary_file_tcl.c +++ b/src/tcl/binary_file_tcl.c @@ -77,7 +77,7 @@ int tclcommand_writemd(ClientData data, Tcl_Interp *interp, /* assemble rows */ argc -= 2; argv += 2; - row = malloc(sizeof(char)*argc); + row = (char*)malloc(sizeof(char)*argc); for (i = 0; i < argc; i++) { if (!strncmp(*argv, "posx", strlen(*argv))) { row[i] = POSX; @@ -243,7 +243,7 @@ int tclcommand_readmd(ClientData dummy, Tcl_Interp *interp, build_particle_node(); /* parse rows */ - row = malloc(header.n_rows*sizeof(char)); + row = (char*)malloc(header.n_rows*sizeof(char)); for (i = 0; i < header.n_rows; i++) { Tcl_Read(channel, (char *)&row[i], sizeof(char)); switch (row[i]) { diff --git a/src/tcl/blockfile_tcl.c b/src/tcl/blockfile_tcl.c index 2cbc408bda9..ee6946ff449 100644 --- a/src/tcl/blockfile_tcl.c +++ b/src/tcl/blockfile_tcl.c @@ -69,7 +69,7 @@ static int readchar(Tcl_Channel f) return c; } -static int writestring(Tcl_Channel f, char *s) +static int writestring(Tcl_Channel f, const char *s) { int l = strlen(s); return (Tcl_Write(f, s, l) == l); @@ -356,7 +356,7 @@ int tclcommand_blockfile(ClientData data, Tcl_Interp *interp, /* -------------- read unknown field ---------------------------- */ len = 21; /* blockfile_read_auto_ + \0 */ len += strlen(title); - name = malloc(len); + name = (char*)malloc(len); strcpy(name, "blockfile_read_auto_"); strcat(name, title); exists = Tcl_GetCommandInfo(interp, name, &cmdInfo); @@ -411,7 +411,7 @@ int tclcommand_blockfile(ClientData data, Tcl_Interp *interp, else { len = 21; /* blockfile_read_auto_ + \0 */ len += strlen(argv[3]); - name = malloc(len); + name = (char*)malloc(len); strcpy(name, "blockfile_read_auto_"); strcat(name, argv[3]); exists = Tcl_GetCommandInfo(interp, name, &cmdInfo); @@ -434,7 +434,7 @@ int tclcommand_blockfile(ClientData data, Tcl_Interp *interp, /* not a native action, try script support */ len = 12; /* blockfile_ + _ + \0 */ len += strlen(argv[2]) + strlen(argv[3]); - name = malloc(len); + name = (char*)malloc(len); strcpy(name, "blockfile_"); strcat(name, argv[2]); strcat(name, "_"); diff --git a/src/tcl/grid_tcl.c b/src/tcl/grid_tcl.c index 60fc5fbdb35..b1ac5e2d403 100644 --- a/src/tcl/grid_tcl.c +++ b/src/tcl/grid_tcl.c @@ -80,7 +80,7 @@ int tclcallback_periodicity(Tcl_Interp *interp, void *_data) int tclcallback_box_l(Tcl_Interp *interp, void *_data) { - double *data = _data; + double *data = (double*)_data; if ((data[0] <= 0) || (data[1] <= 0) || (data[2] <= 0)) { Tcl_AppendResult(interp, "illegal value", (char *) NULL); diff --git a/src/tcl/iccp3m_tcl.c b/src/tcl/iccp3m_tcl.c index 3298ca83b2a..acd30d93734 100644 --- a/src/tcl/iccp3m_tcl.c +++ b/src/tcl/iccp3m_tcl.c @@ -237,7 +237,7 @@ int tclcommand_iccp3m_parse_double_list(Tcl_Interp *interp, int n_ic, char *stri float temp; size= n_ic; - numbers = malloc((size)*sizeof(double)); + numbers = (double*)malloc((size)*sizeof(double)); cp = strdup(string); /* Make writable copy. */ token = strtok (cp, delimiters); diff --git a/src/tcl/imd_tcl.c b/src/tcl/imd_tcl.c index 56dcccb4da5..61327ac6baf 100644 --- a/src/tcl/imd_tcl.c +++ b/src/tcl/imd_tcl.c @@ -244,7 +244,7 @@ int tclcommand_imd_parse_pos(Tcl_Interp *interp, int argc, char **argv) } updatePartCfg(WITH_BONDS); - coord = malloc(n_total_particles*3*sizeof(float)); + coord = (float*)malloc(n_total_particles*3*sizeof(float)); /* sort partcles according to identities */ for (i = 0; i < n_total_particles; i++) { int dummy[3] = {0,0,0}; diff --git a/src/tcl/interaction_data_tcl.c b/src/tcl/interaction_data_tcl.c index 40b5f62045a..a9e2ab71596 100644 --- a/src/tcl/interaction_data_tcl.c +++ b/src/tcl/interaction_data_tcl.c @@ -72,7 +72,7 @@ #include "p3m-dipolar_tcl.h" #include "magnetic_non_p3m_methods_tcl.h" -// bonded +// Bonded #include "angle_tcl.h" #include "angle_harmonic_tcl.h" #include "angle_cosine_tcl.h" diff --git a/src/tcl/interaction_data_tcl.h b/src/tcl/interaction_data_tcl.h index 96260f25a56..45a19f20843 100644 --- a/src/tcl/interaction_data_tcl.h +++ b/src/tcl/interaction_data_tcl.h @@ -18,8 +18,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifndef IA_DATA_TCL_H -#define IA_DATA_TCL_H +#ifndef _INTERACTION_DATA_TCL_H +#define _INTERACTION_DATA_TCL_H #include "parser.h" #include "forcecap_tcl.h" diff --git a/src/tcl/parser.h b/src/tcl/parser.h index dbeddfb516b..1cfe13952b2 100644 --- a/src/tcl/parser.h +++ b/src/tcl/parser.h @@ -18,8 +18,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifndef PARSER_H -#define PARSER_H +#ifndef _PARSER_H +#define _PARSER_H /** \file parser.h This file contains macros for parsing the parameters to the 'inter' command. diff --git a/src/tcl/particle_data_tcl.c b/src/tcl/particle_data_tcl.c index 17e5288d6f6..54af0c0ef18 100644 --- a/src/tcl/particle_data_tcl.c +++ b/src/tcl/particle_data_tcl.c @@ -257,7 +257,7 @@ void tclcommand_part_print_bond_partners(Particle *part, char *buffer, Tcl_Inter /* setup bond partners and distance list. Since we need to identify particles via their identity, we use a full sized array */ - partners = malloc((max_seen_particle + 1)*sizeof(IntList)); + partners = (IntList*)malloc((max_seen_particle + 1)*sizeof(IntList)); for (p = 0; p <= max_seen_particle; p++) init_intlist(&partners[p]); updatePartCfg(WITH_BONDS); @@ -279,7 +279,7 @@ void tclcommand_part_print_bond_partners(Particle *part, char *buffer, Tcl_Inter /* Create links to particle */ distance++; - links = malloc((distance+1)*sizeof(IntList)); + links = (IntList*)malloc((distance+1)*sizeof(IntList)); for( c = 0; c <= distance; c++) init_intlist(&links[c]); p1 = part->p.identity; @@ -1349,9 +1349,9 @@ int part_parse_gamma(Tcl_Interp *interp, int argc, char **argv, int tclcommand_part_parse_bond(Tcl_Interp *interp, int argc, char **argv, - int part_num, int * change) + int part_num, int *change) { - int delete = 0; + bool deleteIt = false; int type_num; int n_partners; /* Bond type number and the bond partner atoms are stored in this field. */ @@ -1369,7 +1369,7 @@ int tclcommand_part_parse_bond(Tcl_Interp *interp, int argc, char **argv, /* parse away delete eventually */ if (ARG0_IS_S("delete")) { - delete = 1; + deleteIt = true; argc--; argv++; *change += 1; @@ -1431,7 +1431,7 @@ int tclcommand_part_parse_bond(Tcl_Interp *interp, int argc, char **argv, j++; } /* set/delete bond */ - if (change_particle_bond(part_num, bond, delete) != TCL_OK) { + if (change_particle_bond(part_num, bond, deleteIt) != TCL_OK) { Tcl_AppendResult(interp, "bond to delete did not exist", (char *)NULL); free(bond); return TCL_ERROR; @@ -1445,8 +1445,8 @@ int tclcommand_part_parse_bond(Tcl_Interp *interp, int argc, char **argv, return TCL_OK; } /* check for the old, multiple numbers format */ - if (argc == 0) { - if (delete == 0) { + if (argc <= 0) { + if (!deleteIt) { Tcl_AppendResult(interp, "usage: part

bond +\n", (char *) NULL); return TCL_ERROR; } @@ -1501,7 +1501,7 @@ int tclcommand_part_parse_bond(Tcl_Interp *interp, int argc, char **argv, } } /* set/delete bond */ - if (change_particle_bond(part_num, bond, delete) != TCL_OK) { + if (change_particle_bond(part_num, bond, deleteIt) != TCL_OK) { Tcl_AppendResult(interp, "bond to delete did not exist", (char *)NULL); free(bond); return TCL_ERROR; @@ -1517,7 +1517,8 @@ int tclcommand_part_parse_bond(Tcl_Interp *interp, int argc, char **argv, int tclcommand_part_parse_exclusion(Tcl_Interp *interp, int argc, char **argv, int part_num, int * change) { - int delete = 0, partner; + bool deleteIt = false; + int partner; *change = 0; @@ -1530,7 +1531,7 @@ int tclcommand_part_parse_exclusion(Tcl_Interp *interp, int argc, char **argv, /* parse away delete eventually */ if (ARG0_IS_S("delete")) { - delete = 1; + deleteIt = true; argc--; argv++; (*change)++; @@ -1554,8 +1555,8 @@ int tclcommand_part_parse_exclusion(Tcl_Interp *interp, int argc, char **argv, } /* set/delete exclusion */ - if (change_exclusion(part_num, partner, delete) != TCL_OK) { - if (delete) + if (change_exclusion(part_num, partner, deleteIt) != TCL_OK) { + if (deleteIt) Tcl_AppendResult(interp, "exclusion to delete did not exist", (char *)NULL); else Tcl_AppendResult(interp, "particle to exclude from interaction does not exist or is the same", (char *)NULL); diff --git a/src/tcl/polymer_tcl.c b/src/tcl/polymer_tcl.c index a12689feae4..c8b97e9340e 100644 --- a/src/tcl/polymer_tcl.c +++ b/src/tcl/polymer_tcl.c @@ -100,7 +100,7 @@ int tclcommand_polymer (ClientData data, Tcl_Interp *interp, int argc, char **ar /* [pos ] */ else if (ARG_IS_S(i, "pos")) { if (i+3 < argc) { - posed = malloc(3*sizeof(double)); + posed = (double*)malloc(3*sizeof(double)); if (!(ARG_IS_D(i+1, posed[0]) && ARG_IS_D(i+2, posed[1]) && ARG_IS_D(i+3, posed[2]))) { Tcl_ResetResult(interp); Tcl_AppendResult(interp, "The first start monomers position must be double (got: ",argv[i+1],",",argv[i+2],",",argv[i+3],")!", (char *)NULL); @@ -200,7 +200,7 @@ int tclcommand_polymer (ClientData data, Tcl_Interp *interp, int argc, char **ar while(angle2 >= 2.0*PI) angle2 -= 2.0*PI; i++; if (i+3 < argc) { - posed2=malloc(3*sizeof(double)); + posed2=(double*)malloc(3*sizeof(double)); if (ARG_IS_D(i+1, posed2[0]) && ARG_IS_D(i+2, posed2[1]) && ARG_IS_D(i+3, posed2[2])) { i+=3; } else { diff --git a/src/tcl/random_tcl.c b/src/tcl/random_tcl.c index 12467158441..eae9d8a61f1 100644 --- a/src/tcl/random_tcl.c +++ b/src/tcl/random_tcl.c @@ -59,7 +59,7 @@ int tclcommand_t_random (ClientData data, Tcl_Interp *interp, int argc, char **a } } else if (!strncmp(argv[0], "seed", strlen(argv[0]))) { /* 't_random seed [ ... ]' */ - long *seed = malloc(n_nodes*sizeof(long)); + long *seed = (long*)malloc(n_nodes*sizeof(long)); if (argc <= 1) { mpi_random_seed(0,seed); for (i=0; i < n_nodes; i++) { @@ -78,7 +78,7 @@ int tclcommand_t_random (ClientData data, Tcl_Interp *interp, int argc, char **a return(TCL_OK); } else if (!strncmp(argv[0], "stat", strlen(argv[0]))) { /* 't_random stat [status-list]' */ - RandomStatus *stat = malloc(n_nodes*sizeof(RandomStatus)); + RandomStatus *stat = (RandomStatus*)malloc(n_nodes*sizeof(RandomStatus)); if (argc <= 1) { mpi_random_stat(0,stat); for (i=0; i < n_nodes; i++) { @@ -132,7 +132,7 @@ int tclcommand_bit_random (ClientData data, Tcl_Interp *interp, int argc, char * /* argc > 1 */ argc--; argv++; if (!strncmp(argv[0], "seed", strlen(argv[0]))) { /* 'bit_random seed [ ... ]' */ - int *seed = malloc(n_nodes*sizeof(int)); + int *seed = (int*)malloc(n_nodes*sizeof(int)); if (argc <= 1) { mpi_bit_random_seed(0,seed); for (i=0; i < n_nodes; i++) { @@ -151,7 +151,7 @@ int tclcommand_bit_random (ClientData data, Tcl_Interp *interp, int argc, char * return(TCL_OK); } else if (!strncmp(argv[0], "stat", strlen(argv[0]))) { /* 'bit_random stat [status-list]' */ - BitRandomStatus *stat = malloc(n_nodes*sizeof(BitRandomStatus)); + BitRandomStatus *stat = (BitRandomStatus*)malloc(n_nodes*sizeof(BitRandomStatus)); if (argc <= 1) { mpi_bit_random_stat(0,stat); for (i=0; i < n_nodes; i++) { diff --git a/src/tcl/reaction_field_tcl.c b/src/tcl/reaction_field_tcl.c index 1ac4c47f67f..59a8f29e050 100644 --- a/src/tcl/reaction_field_tcl.c +++ b/src/tcl/reaction_field_tcl.c @@ -27,7 +27,7 @@ #ifdef ELECTROSTATICS #include "reaction_field.h" -int tclprint_to_result_rf(Tcl_Interp *interp,char *name) +int tclprint_to_result_rf(Tcl_Interp *interp, const char *name) { char buffer[TCL_DOUBLE_SPACE]; sprintf(buffer,"%s",name); diff --git a/src/tcl/reaction_field_tcl.h b/src/tcl/reaction_field_tcl.h index 00c0b77e4b8..c3873262d3a 100644 --- a/src/tcl/reaction_field_tcl.h +++ b/src/tcl/reaction_field_tcl.h @@ -29,7 +29,7 @@ #ifdef ELECTROSTATICS /// -int tclprint_to_result_rf(Tcl_Interp *interp,char *name); +int tclprint_to_result_rf(Tcl_Interp *interp, const char *name); /// int tclcommand_inter_coulomb_parse_rf(Tcl_Interp * interp, diff --git a/src/tcl/statistics_correlation_tcl.c b/src/tcl/statistics_correlation_tcl.c index 96b137b22fa..e5b0f79b4b7 100644 --- a/src/tcl/statistics_correlation_tcl.c +++ b/src/tcl/statistics_correlation_tcl.c @@ -99,10 +99,9 @@ int correlation_print_parameters(double_correlation* self, Tcl_Interp* interp) { } int correlation_print_parameters_all(Tcl_Interp* interp) { - int i; char buffer[TCL_DOUBLE_SPACE + TCL_INTEGER_SPACE + 4]; Tcl_AppendResult(interp, " { ", (char *)NULL); - for (i=0; i< n_correlations; i++) { + for (unsigned i=0; i< n_correlations; i++) { sprintf(buffer, " %d ", i); Tcl_AppendResult(interp, "\n{ correlation ", buffer, (char *)NULL); if ( correlations+i == NULL ) { @@ -116,7 +115,6 @@ int correlation_print_parameters_all(Tcl_Interp* interp) { } int correlation_print_average1(double_correlation* self, Tcl_Interp* interp, int argc, char** argv) { - int i; char buffer[TCL_DOUBLE_SPACE]; int err; if (self->n_data < 1) { @@ -124,14 +122,14 @@ int correlation_print_average1(double_correlation* self, Tcl_Interp* interp, int return TCL_ERROR; } if (argc == 0) { - for (i=0; i< self->dim_A; i++) { + for (unsigned i=0; i< self->dim_A; i++) { Tcl_PrintDouble(interp, self->A_accumulated_average[i]/self->n_data, buffer); Tcl_AppendResult(interp, buffer, " ", (char *)NULL); } return TCL_OK; } else if (ARG0_IS_S("formatted")) { double* values = (double*) malloc(self->dim_A*sizeof(double)); - for (i=0; i< self->dim_A; i++) { + for (unsigned i=0; i< self->dim_A; i++) { values[i]=self->A_accumulated_average[i]/self->n_data; } int change=0; @@ -145,13 +143,12 @@ int correlation_print_average1(double_correlation* self, Tcl_Interp* interp, int } int correlation_print_variance1(double_correlation* self, Tcl_Interp* interp) { - int i; char buffer[TCL_DOUBLE_SPACE]; if (self->n_data < 1) { Tcl_AppendResult(interp, buffer, "Error in print variance: No input data available", (char *)NULL); return TCL_ERROR; } - for (i=0; i< self->dim_A; i++) { + for (unsigned i=0; i< self->dim_A; i++) { Tcl_PrintDouble(interp, self->A_accumulated_variance[i]/self->n_data - (self->A_accumulated_average[i]/self->n_data)*(self->A_accumulated_average[i]/self->n_data), buffer); @@ -163,7 +160,6 @@ int correlation_print_variance1(double_correlation* self, Tcl_Interp* interp) { int tclcommand_print_correlation_time(double_correlation* self, Tcl_Interp* interp) { char buffer[TCL_DOUBLE_SPACE]; double* correlation_time; - int j; if (self->dim_A != self->dim_corr) { Tcl_AppendResult(interp, buffer, "Error in print correlation_time: Only makes sense when the dimensions of \ the observables and correlation match (Isn't it?) ", (char *)NULL); @@ -176,7 +172,7 @@ int tclcommand_print_correlation_time(double_correlation* self, Tcl_Interp* inte correlation_time = (double*) malloc(self->dim_corr*sizeof(double)); correlation_get_correlation_time(self, correlation_time); - for (j=0; jdim_corr; j++) { + for (unsigned j=0; jdim_corr; j++) { Tcl_PrintDouble(interp, correlation_time[j], buffer); Tcl_AppendResult(interp, buffer, " ",(char *)NULL); } @@ -190,7 +186,6 @@ int tclcommand_print_average_errorbars(double_correlation* self, Tcl_Interp* int double* correlation_time; double variance; double errorbar; - int j; if (self->dim_A != self->dim_corr) { Tcl_AppendResult(interp, buffer, "Error in print average_errorbars: Only makes sense when the dimensions of \ the observables and correlation match (Isn't it?) ", (char *)NULL); @@ -203,7 +198,7 @@ int tclcommand_print_average_errorbars(double_correlation* self, Tcl_Interp* int correlation_time = (double*) malloc(self->dim_corr*sizeof(double)); correlation_get_correlation_time(self, correlation_time); - for (j=0; jdim_corr; j++) { + for (unsigned j=0; jdim_corr; j++) { variance=(self->A_accumulated_variance[j]/self->n_data - self->A_accumulated_average[j]*self->A_accumulated_average[j]/self->n_data/self->n_data); errorbar=sqrt(variance*(correlation_time[j]/self->dt / self->n_data)); Tcl_PrintDouble(interp, errorbar, buffer); @@ -219,7 +214,6 @@ int tclcommand_print_average_errorbars(double_correlation* self, Tcl_Interp* int * identified by their ids. */ int tclcommand_correlation(ClientData data, Tcl_Interp* interp, int argc, char** argv) { - int i; int no; char buffer[TCL_INTEGER_SPACE]; argc-=1; @@ -232,6 +226,7 @@ int tclcommand_correlation(ClientData data, Tcl_Interp* interp, int argc, char** return TCL_OK; } if (ARG0_IS_S("new")) { + unsigned i; for (i=0;i 0 ) { if (ARG0_IS_S("start")) { // if(correlations[no].A_fun==&tcl_input || correlations[no].is_from_file) { @@ -272,7 +266,7 @@ int tclcommand_correlation_parse_autoupdate(Tcl_Interp* interp, int no, int argc } else if (ARG0_IS_S("stop")) { correlations_autoupdate=0; correlations[no].autoupdate=0; - for (i=0; i 0) { if (ARG0_IS_S("print")) { return tclcommand_correlation_parse_print(interp, no, argc-1, argv+1); @@ -427,7 +421,7 @@ int tclcommand_correlation_parse_corr(Tcl_Interp* interp, int no, int argc, char return TCL_ERROR; } - } else if ( no == n_correlations || correlations+no == 0) { + } else if ( (unsigned)no == n_correlations || correlations+no == 0) { //Tcl_AppendResult(interp, "Setting up a new correlation\n", (char *)NULL); // Else we must parse the other arguments and see if we can construct a fully @@ -560,7 +554,7 @@ int tclcommand_correlation_parse_corr(Tcl_Interp* interp, int no, int argc, char error_msg = (char *)init_errors[error]; if ( error == 0 ) { //printf("Set up correlation %d, autoupdate: %d\n",n_correlations,correlations[n_correlations].autoupdate); - if ( no == n_correlations ) n_correlations++; + if ( (unsigned)no == n_correlations ) n_correlations++; sprintf(buffer,"%d",no); Tcl_AppendResult(interp,buffer,(char *)NULL); return TCL_OK; @@ -614,18 +608,17 @@ int parse_corr_operation(Tcl_Interp* interp, int argc, char** argv, int* change, int double_correlation_print_correlation( double_correlation* self, Tcl_Interp* interp) { - int j, k; double dt=self->dt; char buffer[TCL_DOUBLE_SPACE]; // char ibuffer[TCL_INTEGER_SPACE+2]; - for (j=0; jn_result; j++) { + for (unsigned j=0; jn_result; j++) { Tcl_AppendResult(interp, " { ", (char *)NULL); Tcl_PrintDouble(interp, self->tau[j]*dt, buffer); Tcl_AppendResult(interp, buffer, " ",(char *)NULL); sprintf(buffer, "%d ", self->n_sweeps[j]); Tcl_AppendResult(interp, buffer, " ",(char *)NULL); - for (k=0; k< self->dim_corr; k++) { + for (unsigned k=0; k< self->dim_corr; k++) { if (self->n_sweeps[j] == 0 ) { Tcl_PrintDouble(interp, 0., buffer); Tcl_AppendResult(interp, buffer, " ", (char *)NULL); @@ -643,7 +636,6 @@ int double_correlation_print_correlation( double_correlation* self, Tcl_Interp* int double_correlation_print_spherically_averaged_sf(double_correlation* self, Tcl_Interp* interp) { - int j,k; int qi,qj,qk,qn, dim_sf, order2; double dt=self->dt; observable_sf_params* params=(observable_sf_params*)self->A_obs->args; @@ -662,10 +654,10 @@ int double_correlation_print_spherically_averaged_sf(double_correlation* self, T av_sf_Im=(double*)malloc(order2*sizeof(double)); // compute spherically averaged sf - for (j=0; jn_result; j++) { + for (unsigned j=0; jn_result; j++) { // compute the spherically averaged sf for current dt - for(k=0;kresult[j][2*k ]; av_sf_Im[qn-1]+=self->result[j][2*k+1]; } - for(k=0;k0.0) { + for (int k=0;k0.0) { av_sf_Re[k]/=q_density[k]; av_sf_Im[k]/=q_density[k]; } // note: if q_density[k]==0, we did not add anything to av_sf_Xx[k], so it is 0.0 } // now print what we obtained - for(k=0;ktau[j]*dt, buffer); Tcl_AppendResult(interp, buffer, " } { ",(char *)NULL); @@ -709,15 +701,14 @@ int double_correlation_print_spherically_averaged_sf(double_correlation* self, T int double_correlation_write_to_file( double_correlation* self, char* filename) { FILE* file=0; - int j, k; double dt=self->dt; file=fopen(filename, "w"); if (!file) { return 1; } - for (j=0; jn_result; j++) { + for (unsigned j=0; jn_result; j++) { fprintf(file, "%.6g %d ", self->tau[j]*dt, self->n_sweeps[j]); - for (k=0; k< self->dim_corr; k++) { + for (unsigned k=0; k< self->dim_corr; k++) { if (self->n_sweeps[j] == 0 ) fprintf(file, "%.6g ", 0.); else diff --git a/src/tcl/statistics_observable_tcl.c b/src/tcl/statistics_observable_tcl.c index d8b16c7379d..b92ec1e3181 100644 --- a/src/tcl/statistics_observable_tcl.c +++ b/src/tcl/statistics_observable_tcl.c @@ -30,13 +30,14 @@ int tclcommand_observable_print_formatted(Tcl_Interp* interp, int argc, char** a int tclcommand_observable_print(Tcl_Interp* interp, int argc, char** argv, int* change, observable* obs); static int convert_types_to_ids(IntList * type_list, IntList * id_list); +static int observable_tclcommand(void* _container, double* A, unsigned int n_A); int parse_id_list(Tcl_Interp* interp, int argc, char** argv, int* change, IntList** ids ) { int i,ret; // char** temp_argv; int temp_argc; // int temp; - IntList* input=malloc(sizeof(IntList)); - IntList* output=malloc(sizeof(IntList)); + IntList* input=(IntList*)malloc(sizeof(IntList)); + IntList* output=(IntList*)malloc(sizeof(IntList)); init_intlist(input); alloc_intlist(input,1); init_intlist(output); @@ -766,7 +767,7 @@ int tclcommand_observable_interacts_with(Tcl_Interp* interp, int argc, char** ar #define REGISTER_OBSERVABLE(name,parser,id) \ if (ARG_IS_S(2,#name)) { \ - observables[id]=malloc(sizeof(observable)); \ + observables[id]=(observable*)malloc(sizeof(observable)); \ if (parser(interp, argc-2, argv+2, &temp, observables[n_observables]) ==TCL_OK) { \ n_observables++; \ argc-=1+temp; \ @@ -1250,7 +1251,7 @@ int tclcommand_parse_radial_profile(Tcl_Interp* interp, int argc, char** argv, i int tclcommand_observable_print(Tcl_Interp* interp, int argc, char** argv, int* change, observable* obs) { char buffer[TCL_DOUBLE_SPACE]; - double* values=malloc(obs->n*sizeof(double)); + double* values=(double*)malloc(obs->n*sizeof(double)); if ( (*obs->fun)(obs->args, values, obs->n) ) { Tcl_AppendResult(interp, "\nFailed to compute observable tclcommand\n", (char *)NULL ); return TCL_ERROR; @@ -1301,7 +1302,7 @@ int sf_print_usage(Tcl_Interp* interp) { return TCL_ERROR; } -int observable_tclcommand(void* _container, double* A, unsigned int n_A) { +static int observable_tclcommand(void* _container, double* A, unsigned int n_A) { Observable_Tclcommand_Arg_Container* container = (Observable_Tclcommand_Arg_Container*) _container; Tcl_Interp* interp = (Tcl_Interp*) container->interp; int error = Tcl_Eval(interp, container->command); @@ -1310,9 +1311,9 @@ int observable_tclcommand(void* _container, double* A, unsigned int n_A) { } char* result = Tcl_GetStringResult(interp); char* token; - int counter=0; + unsigned counter=0; token = strtok(result, " "); - while ( token != NULL && counter < n_A ) { + while (token != NULL && counter < n_A) { A[counter] = atof(token); token = strtok(NULL, " "); counter++; diff --git a/src/tcl/statistics_observable_tcl.h b/src/tcl/statistics_observable_tcl.h index 9152cac1a3d..338a60ee3c8 100644 --- a/src/tcl/statistics_observable_tcl.h +++ b/src/tcl/statistics_observable_tcl.h @@ -27,7 +27,6 @@ int tclcommand_observable(ClientData data, Tcl_Interp *interp, int argc, char ** int tclcommand_observable_print_formatted(Tcl_Interp* interp, int argc, char** argv, int* change, observable* obs, double* values); int parse_id_list(Tcl_Interp* interp, int argc, char** argv, int* change, IntList** ids ); -int observable_tclcommand(void* _container, double* A, unsigned int n_A); typedef struct { Tcl_Interp* interp; diff --git a/src/tcl/statistics_tcl.c b/src/tcl/statistics_tcl.c index e0757e26f36..a3325108466 100644 --- a/src/tcl/statistics_tcl.c +++ b/src/tcl/statistics_tcl.c @@ -229,7 +229,7 @@ static int tclcommand_analyze_parse_get_folded_positions(Tcl_Interp *interp, int ERROR_SPRINTF(errtxt, "{058 could not sort partCfg, particles have to start at 0 and have consecutive identities} "); return TCL_ERROR; } - coord = malloc(n_total_particles*3*sizeof(float)); + coord = (float*)malloc(n_total_particles*3*sizeof(float)); /* Construct the array coord*/ for (i = 0; i < n_total_particles; i++) { int dummy[3] = {0,0,0}; @@ -1401,7 +1401,7 @@ static int tclcommand_analyze_parse_distribution(Tcl_Interp *interp, int argc, c if(r_max <= r_min) return TCL_ERROR; if(r_bins < 1) return TCL_ERROR; /* calculate distribution */ - distribution = malloc(r_bins*sizeof(double)); + distribution = (double*)malloc(r_bins*sizeof(double)); updatePartCfg(WITHOUT_BONDS); calc_part_distribution(p1.e, p1.max, p2.e, p2.max, r_min, r_max, r_bins, log_flag,&low,distribution); if(int_flag==1) { @@ -1563,7 +1563,7 @@ static int tclcommand_analyze_parse_rdf(Tcl_Interp *interp, int average, int arg } else Tcl_AppendResult(interp, " }", (char *)NULL); - rdf = malloc(r_bins*sizeof(double)); + rdf = (double*)malloc(r_bins*sizeof(double)); if (!sortPartCfg()) { Tcl_AppendResult(interp, "for analyze, store particles consecutively starting with 0.",(char *) NULL); return (TCL_ERROR); } @@ -1676,7 +1676,7 @@ static int tclcommand_analyze_parse_density_profile_av(Tcl_Interp *interp, int a return (TCL_ERROR); } - rho_ave = malloc(n_bin*sizeof(double)); + rho_ave = (double*)malloc(n_bin*sizeof(double)); for(i=0;i Date: Fri, 8 Mar 2013 11:16:31 +0100 Subject: [PATCH 2/7] Fixed some malloc issues for C++ compiler in #MODES feature --- src/modes.c | 18 +++++++++--------- src/pressure.h | 1 + src/tcl/statistics_tcl.c | 10 +++++----- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/modes.c b/src/modes.c index 6f6a42ce10a..62773c081ed 100644 --- a/src/modes.c +++ b/src/modes.c @@ -358,7 +358,7 @@ int get_lipid_orients(IntList* l_orient) { } /* Allocate memory for height grid arrays and initialize these arrays */ - height_grid = malloc((mode_grid_3d[xdir])*sizeof(double)*mode_grid_3d[ydir]); + height_grid = (double*) malloc((mode_grid_3d[xdir])*sizeof(double)*mode_grid_3d[ydir]); /* Calculate physical size of grid mesh */ @@ -440,8 +440,8 @@ int modes2d(fftw_complex* modes, int switch_fluc) { fftw_destroy_plan(mode_analysis_plan); fftw_cleanup(); /* Allocate memory for input and output arrays */ - height_grid = malloc((mode_grid_3d[xdir])*sizeof(double)*mode_grid_3d[ydir]); - result = malloc((mode_grid_3d[ydir]/2+1)*(mode_grid_3d[xdir])*sizeof(fftw_complex)); + height_grid = (double*) malloc((mode_grid_3d[xdir])*sizeof(double)*mode_grid_3d[ydir]); + result = (fftw_complex*) malloc((mode_grid_3d[ydir]/2+1)*(mode_grid_3d[xdir])*sizeof(fftw_complex)); mode_analysis_plan = fftw_plan_dft_r2c_2d(mode_grid_3d[xdir],mode_grid_3d[ydir],height_grid, result,FFTW_ESTIMATE); STAT_TRACE(fprintf(stderr,"%d,created new fftw plan \n",this_node)); @@ -605,7 +605,7 @@ int bilayer_density_profile ( IntList *beadids, double hrange , DoubleList *dens } /* Allocate memory for the grid if we are going to need it */ - tmp_height_grid = malloc((mode_grid_3d[xdir])*sizeof(double)*mode_grid_3d[ydir]); + tmp_height_grid = (double*) malloc((mode_grid_3d[xdir])*sizeof(double)*mode_grid_3d[ydir]); /* Calculate physical size of grid mesh */ grid_size[xdir] = box_l[xdir]/(double)mode_grid_3d[xdir]; grid_size[ydir] = box_l[ydir]/(double)mode_grid_3d[ydir]; @@ -749,11 +749,11 @@ int calc_fluctuations ( double* height_grid, int switch_fluc ) { /* Allocate memory for height grid / thickness arrays and initialize these arrays */ - height_grid_up = malloc((mode_grid_3d[xdir])*sizeof(double)*mode_grid_3d[ydir]); - height_grid_down = malloc((mode_grid_3d[xdir])*sizeof(double)*mode_grid_3d[ydir]); - grid_parts_up = malloc((mode_grid_3d[xdir])*sizeof(int)*mode_grid_3d[ydir]); - grid_parts_down = malloc((mode_grid_3d[xdir])*sizeof(int)*mode_grid_3d[ydir]); - grid_parts = malloc((mode_grid_3d[xdir])*sizeof(int)*mode_grid_3d[ydir]); + height_grid_up = (double*) malloc((mode_grid_3d[xdir])*sizeof(double)*mode_grid_3d[ydir]); + height_grid_down = (double*) malloc((mode_grid_3d[xdir])*sizeof(double)*mode_grid_3d[ydir]); + grid_parts_up = (int*) malloc((mode_grid_3d[xdir])*sizeof(int)*mode_grid_3d[ydir]); + grid_parts_down = (int*) malloc((mode_grid_3d[xdir])*sizeof(int)*mode_grid_3d[ydir]); + grid_parts = (int*) malloc((mode_grid_3d[xdir])*sizeof(int)*mode_grid_3d[ydir]); for ( i = 0 ; i < mode_grid_3d[xdir] ; i++) { for ( j = 0 ; j < mode_grid_3d[ydir] ; j++) { height_grid[j+i*mode_grid_3d[xdir]] = 0; diff --git a/src/pressure.h b/src/pressure.h index ba8529629e2..4232c408bb4 100644 --- a/src/pressure.h +++ b/src/pressure.h @@ -209,6 +209,7 @@ MDINLINE void calc_bonded_force(Particle *p1, Particle *p2, Bonded_ia_parameters #ifdef OVERLAPPED case BONDED_IA_OVERLAPPED: // printf("BONDED OVERLAP, Particle: %d, P2: %d TYPE_OVERLAP: %d\n",p1->p.identity,p2->p.identity,iparams->p.tab.type); + char *errtxt; switch(iaparams->p.overlap.type) { case OVERLAP_BOND_LENGTH: calc_overlap_bond_force(p1, p2, iaparams, dx, force); break; diff --git a/src/tcl/statistics_tcl.c b/src/tcl/statistics_tcl.c index cd8a6a338c9..8fd3476c54e 100644 --- a/src/tcl/statistics_tcl.c +++ b/src/tcl/statistics_tcl.c @@ -322,8 +322,8 @@ static int tclcommand_analyze_parse_modes2d(Tcl_Interp *interp, int argc, char * return (TCL_OK); } - result_ht = malloc((mode_grid_3d[ydir]/2+1)*(mode_grid_3d[xdir])*sizeof(fftw_complex)); - result_th = malloc((mode_grid_3d[ydir]/2+1)*(mode_grid_3d[xdir])*sizeof(fftw_complex)); + result_ht = (fftw_complex*) malloc((mode_grid_3d[ydir]/2+1)*(mode_grid_3d[xdir])*sizeof(fftw_complex)); + result_th = (fftw_complex*) malloc((mode_grid_3d[ydir]/2+1)*(mode_grid_3d[xdir])*sizeof(fftw_complex)); if (!modes2d(result_th, 0) || !modes2d(result_ht,1)) { fprintf(stderr,"%d,mode analysis failed \n",this_node); @@ -478,7 +478,7 @@ static int tclcommand_analyze_parse_radial_density_map(Tcl_Interp *interp, int a /* allocate memory for the profile if necessary */ if (thetabins > 0 ) { - density_profile = malloc(beadtypes.max*sizeof(DoubleList)); + density_profile = (DoubleList*) malloc(beadtypes.max*sizeof(DoubleList)); if (density_profile) { for ( i = 0 ; i < beadtypes.max ; i++ ) { init_doublelist(&density_profile[i]); @@ -494,7 +494,7 @@ static int tclcommand_analyze_parse_radial_density_map(Tcl_Interp *interp, int a } /* Allocate a doublelist of bins for each beadtype so that we can keep track of beads separately */ - density_map = malloc(beadtypes.max*sizeof(DoubleList)); + density_map = (DoubleList*) malloc(beadtypes.max*sizeof(DoubleList)); if ( density_map ) { /* Initialize all the subprofiles in density profile */ for ( i = 0 ; i < beadtypes.max ; i++ ) { @@ -715,7 +715,7 @@ static int tclcommand_analyze_parse_lipid_orient_order(Tcl_Interp *interp, int a return (TCL_OK); } - stored_dirs = malloc(sizeof(double)*n_molecules*3); + stored_dirs = (double*) malloc(sizeof(double)*n_molecules*3); /* Do the calculation */ if ( orient_order(&result,stored_dirs) != TCL_OK ) { Tcl_AppendResult(interp, "Error calculating orientational order ", (char *)NULL); From 25d45443cbecbfcea1e7ec5865bc5364244a0959 Mon Sep 17 00:00:00 2001 From: Tobias Richter Date: Fri, 8 Mar 2013 11:33:52 +0100 Subject: [PATCH 3/7] fix feature DIPOLES --- src/fft-dipolar.c | 24 ++++----- src/molforces.c | 4 +- testsuite/configs/myconfig-maxset.h | 76 ++++++++++++++--------------- 3 files changed, 52 insertions(+), 52 deletions(-) diff --git a/src/fft-dipolar.c b/src/fft-dipolar.c index beb97b201dd..42196cba39a 100644 --- a/src/fft-dipolar.c +++ b/src/fft-dipolar.c @@ -88,8 +88,8 @@ int dfft_init(double **data, dfft.max_comm_size=0; dfft.max_mesh_size=0; for(i=0;i<4;i++) { - n_id[i] = malloc(1*n_nodes*sizeof(int)); - n_pos[i] = malloc(3*n_nodes*sizeof(int)); + n_id[i] = (int *) malloc(1*n_nodes*sizeof(int)); + n_pos[i] = (int *) malloc(3*n_nodes*sizeof(int)); } /* === node grids === */ @@ -245,9 +245,9 @@ int dfft_init(double **data, wisdom_status = fftw_import_wisdom_from_file(wisdom_file); fclose(wisdom_file); } - if(dfft.init_tag==1) fftw_destroy_plan(dfft.plan[i].fftw_plan); + if(dfft.init_tag==1) fftw_destroy_plan(dfft.plan[i].our_fftw_plan); //printf("dfft.plan[%d].n_ffts=%d\n",i,dfft.plan[i].n_ffts); - dfft.plan[i].fftw_plan = + dfft.plan[i].our_fftw_plan = fftw_plan_many_dft(1,&dfft.plan[i].new_mesh[2],dfft.plan[i].n_ffts, c_data,NULL,1,dfft.plan[i].new_mesh[2], c_data,NULL,1,dfft.plan[i].new_mesh[2], @@ -271,8 +271,8 @@ int dfft_init(double **data, wisdom_status = fftw_import_wisdom_from_file(wisdom_file); fclose(wisdom_file); } - if(dfft.init_tag==1) fftw_destroy_plan(dfft.back[i].fftw_plan); - dfft.back[i].fftw_plan = + if(dfft.init_tag==1) fftw_destroy_plan(dfft.back[i].our_fftw_plan); + dfft.back[i].our_fftw_plan = fftw_plan_many_dft(1,&dfft.plan[i].new_mesh[2],dfft.plan[i].n_ffts, c_data,NULL,1,dfft.plan[i].new_mesh[2], c_data,NULL,1,dfft.plan[i].new_mesh[2], @@ -335,19 +335,19 @@ void dfft_perform_forw(double *data) data[(2*i)+1] = 0; /* complex value */ } /* perform FFT (in/out is data)*/ - fftw_execute_dft(dfft.plan[1].fftw_plan,c_data,c_data); + fftw_execute_dft(dfft.plan[1].our_fftw_plan,c_data,c_data); /* ===== second direction ===== */ FFT_TRACE(fprintf(stderr,"%d: dipolar fft_perform_forw: dir 2:\n",this_node)); /* communication to current dir row format (in is data) */ dfft_forw_grid_comm(dfft.plan[2], data, dfft.data_buf); /* perform FFT (in/out is data_buf)*/ - fftw_execute_dft(dfft.plan[2].fftw_plan,c_data_buf,c_data_buf); + fftw_execute_dft(dfft.plan[2].our_fftw_plan,c_data_buf,c_data_buf); /* ===== third direction ===== */ FFT_TRACE(fprintf(stderr,"%d: dipolar fft_perform_forw: dir 3:\n",this_node)); /* communication to current dir row format (in is data_buf) */ dfft_forw_grid_comm(dfft.plan[3], dfft.data_buf, data); /* perform FFT (in/out is data)*/ - fftw_execute_dft(dfft.plan[3].fftw_plan,c_data,c_data); + fftw_execute_dft(dfft.plan[3].our_fftw_plan,c_data,c_data); //fft_print_global_fft_mesh(dfft.plan[3],data,1,0); /* REMARK: Result has to be in data. */ @@ -366,21 +366,21 @@ void dfft_perform_back(double *data) /* perform FFT (in is data) */ - fftw_execute_dft(dfft.back[3].fftw_plan,c_data,c_data); + fftw_execute_dft(dfft.back[3].our_fftw_plan,c_data,c_data); /* communicate (in is data)*/ dfft_back_grid_comm(dfft.plan[3],dfft.back[3],data,dfft.data_buf); /* ===== second direction ===== */ FFT_TRACE(fprintf(stderr,"%d: dipolar fft_perform_back: dir 2:\n",this_node)); /* perform FFT (in is data_buf) */ - fftw_execute_dft(dfft.back[2].fftw_plan,c_data_buf,c_data_buf); + fftw_execute_dft(dfft.back[2].our_fftw_plan,c_data_buf,c_data_buf); /* communicate (in is data_buf) */ dfft_back_grid_comm(dfft.plan[2],dfft.back[2],dfft.data_buf,data); /* ===== first direction ===== */ FFT_TRACE(fprintf(stderr,"%d: fft_perform_back: dir 1:\n",this_node)); /* perform FFT (in is data) */ - fftw_execute_dft(dfft.back[1].fftw_plan,c_data,c_data); + fftw_execute_dft(dfft.back[1].our_fftw_plan,c_data,c_data); /* throw away the (hopefully) empty complex component (in is data)*/ for(i=0;i Date: Fri, 8 Mar 2013 11:51:25 +0100 Subject: [PATCH 4/7] removed "deprecated warnings" when switching on debug in c++ compiler --- src/cells.c | 4 ++-- src/debug.c | 6 +++--- src/debug.h | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/cells.c b/src/cells.c index f5cb94279d2..5fffeddc805 100644 --- a/src/cells.c +++ b/src/cells.c @@ -75,7 +75,7 @@ static void check_cells_consistency() memset(used.e, 0, n_cells*sizeof(int)); for (c = 0; c < local_cells.n; c++) { - index = (void *)local_cells.cell[c] - (void *)cells; + index = (char *)local_cells.cell[c] - (char *)cells; if ((index % sizeof(Cell)) != 0) { fprintf(stderr, "%d: local cell pointer not even aligned, certainly wrong (local_cell[%d], index=%d).\n", this_node, c, index); errexit(); @@ -93,7 +93,7 @@ static void check_cells_consistency() } for (c = 0; c < ghost_cells.n; c++) { - index = (void *)ghost_cells.cell[c] - (void *)cells; + index = (char *)ghost_cells.cell[c] - (char *)cells; if ((index % sizeof(Cell)) != 0) { fprintf(stderr, "%d: ghost cell pointer not even aligned, certainly wrong (ghost_cell[%d], index=%d).\n", this_node, c, index); errexit(); diff --git a/src/debug.c b/src/debug.c index 3514c8985f6..6ed0dfae540 100644 --- a/src/debug.c +++ b/src/debug.c @@ -51,7 +51,7 @@ int check_id = ONEPART_DEBUG_ID ; #undef malloc #undef free -void *__realloc(void *old, unsigned int size, char *where, int line) +void *__realloc(void *old, unsigned int size, const char *where, int line) { void *ret; if (size == 0) { @@ -65,7 +65,7 @@ void *__realloc(void *old, unsigned int size, char *where, int line) return ret; } -void *__malloc(unsigned int size, char *where, int line) +void *__malloc(unsigned int size, const char *where, int line) { void *ret; if (size > 0) @@ -76,7 +76,7 @@ void *__malloc(unsigned int size, char *where, int line) return ret; } -void __free(void *p, char *where, int line) +void __free(void *p, const char *where, int line) { fprintf(stderr, "%d: free %p at %s:%d\n", this_node, p, where, line); free(p); diff --git a/src/debug.h b/src/debug.h index 19781acf50d..620d899ec05 100644 --- a/src/debug.h +++ b/src/debug.h @@ -42,13 +42,13 @@ #endif /** memory allocation test routine */ -void *__realloc(void *old, unsigned int size, char *where, int line); +void *__realloc(void *old, unsigned int size, const char *where, int line); /** memory allocation test routine */ -void *__malloc(unsigned int size, char *where, int line); +void *__malloc(unsigned int size, const char *where, int line); /** memory allocation test routine */ -void __free(void *p, char *where, int line); +void __free(void *p, const char *where, int line); #endif From 7fd3781acd1d4c7e7248dd30191b15c084558cc8 Mon Sep 17 00:00:00 2001 From: Florian Fahrenberger Date: Fri, 8 Mar 2013 13:09:19 +0100 Subject: [PATCH 5/7] Got LB working with C++ compiler --- src/communication.c | 10 +++++----- src/config.h | 3 +++ src/halo.c | 14 +++++++------- src/lb-boundaries.c | 2 +- src/lb.c | 28 ++++++++++++++-------------- src/lb.h | 2 +- src/statistics_fluid.c | 14 +++++++------- src/tcl/lb-boundaries_tcl.c | 2 +- src/tcl/statistics_fluid_tcl.c | 4 ++-- 9 files changed, 41 insertions(+), 38 deletions(-) diff --git a/src/communication.c b/src/communication.c index 089bdeba919..3d7ff1d4c7a 100644 --- a/src/communication.c +++ b/src/communication.c @@ -1894,7 +1894,7 @@ void mpi_bcast_lbboundary(int del_num) else if (del_num == -2) { /* delete all boundaries */ n_lb_boundaries = 0; - lb_boundaries = realloc(lb_boundaries,n_lb_boundaries*sizeof(LB_Boundary)); + lb_boundaries = (LB_Boundary*) realloc(lb_boundaries,n_lb_boundaries*sizeof(LB_Boundary)); } #if defined(LB_BOUNDARIES_GPU) else if (del_num == -3) { @@ -1904,7 +1904,7 @@ void mpi_bcast_lbboundary(int del_num) else { memcpy(&lb_boundaries[del_num],&lb_boundaries[n_lb_boundaries-1],sizeof(LB_Boundary)); n_lb_boundaries--; - lb_boundaries = realloc(lb_boundaries,n_lb_boundaries*sizeof(LB_Boundary)); + lb_boundaries = (LB_Boundary*) realloc(lb_boundaries,n_lb_boundaries*sizeof(LB_Boundary)); } on_lbboundary_change(); @@ -1918,13 +1918,13 @@ void mpi_bcast_lbboundary_slave(int node, int parm) #if defined(LB_BOUNDARIES) if(parm == -1) { n_lb_boundaries++; - lb_boundaries = realloc(lb_boundaries,n_lb_boundaries*sizeof(LB_Boundary)); + lb_boundaries = (LB_Boundary*) realloc(lb_boundaries,n_lb_boundaries*sizeof(LB_Boundary)); MPI_Bcast(&lb_boundaries[n_lb_boundaries-1], sizeof(LB_Boundary), MPI_BYTE, 0, comm_cart); } else if (parm == -2) { /* delete all boundaries */ n_lb_boundaries = 0; - lb_boundaries = realloc(lb_boundaries,n_lb_boundaries*sizeof(LB_Boundary)); + lb_boundaries = (LB_Boundary*) realloc(lb_boundaries,n_lb_boundaries*sizeof(LB_Boundary)); } #if defined(LB_BOUNDARIES_GPU) else if (parm == -3) { @@ -1934,7 +1934,7 @@ void mpi_bcast_lbboundary_slave(int node, int parm) else { memcpy(&lb_boundaries[parm],&lb_boundaries[n_lb_boundaries-1],sizeof(LB_Boundary)); n_lb_boundaries--; - lb_boundaries = realloc(lb_boundaries,n_lb_boundaries*sizeof(LB_Boundary)); + lb_boundaries = (LB_Boundary*) realloc(lb_boundaries,n_lb_boundaries*sizeof(LB_Boundary)); } #endif diff --git a/src/config.h b/src/config.h index 25aedd1234f..10a69849ae6 100644 --- a/src/config.h +++ b/src/config.h @@ -32,6 +32,9 @@ /* Include the defines created by configure. */ #include +/* Prevent C++ bindings in OpenMPI (there is a DataType called LB in there) */ +#define OMPI_SKIP_MPICXX + /* doxyconfig.h is used instead of myconfig when doxygen is run */ /* doxyconfig.h defines all features so that all features are documented */ #ifndef DOXYGEN_RUN diff --git a/src/halo.c b/src/halo.c index 669f6cb5618..3d49bc9f679 100644 --- a/src/halo.c +++ b/src/halo.c @@ -45,7 +45,7 @@ struct _Fieldtype fieldtype_double = { 0, NULL, NULL, sizeof(double), 0, 0, 0, 0 void halo_create_fieldtype(int count, int* lengths, int *disps, int extent, Fieldtype *newtype) { int i; - Fieldtype ntype = *newtype = malloc(sizeof(*ntype)); + Fieldtype ntype = *newtype = (Fieldtype) malloc(sizeof(*ntype)); ntype->subtype = NULL; ntype->vflag = 0; @@ -59,7 +59,7 @@ void halo_create_fieldtype(int count, int* lengths, int *disps, int extent, Fiel if (count>0) { - ntype->lengths = malloc(count*2*sizeof(int)); + ntype->lengths = (int*) malloc(count*2*sizeof(int)); ntype->disps = (int *)((char *)ntype->lengths + count*sizeof(int)); for (i=0;isubtype = oldtype; ntype->vflag = 1; @@ -94,7 +94,7 @@ void halo_create_field_vector(int vblocks, int vstride, int vskip, Fieldtype old ntype->extent = oldtype->extent * ((vblocks-1)*vskip + vstride); int count = ntype->count = oldtype->count; - ntype->lengths = malloc(count*2*sizeof(int)); + ntype->lengths = (int*) malloc(count*2*sizeof(int)); ntype->disps = (int *)((char *)ntype->lengths + count*sizeof(int)); for (i=0;isubtype = oldtype; ntype->vflag = 0; @@ -119,7 +119,7 @@ void halo_create_field_hvector(int vblocks, int vstride, int vskip, Fieldtype ol ntype->extent = oldtype->extent*vstride + (vblocks-1)*vskip; int count = ntype->count = oldtype->count; - ntype->lengths = malloc(count*2*sizeof(int)); + ntype->lengths = (int*) malloc(count*2*sizeof(int)); ntype->disps = (int *)((char *)ntype->lengths + count*sizeof(int)); for (i=0;inum = num ; - hc->halo_info = realloc(hc->halo_info,num*sizeof(HaloInfo)) ; + hc->halo_info = (HaloInfo*) realloc(hc->halo_info,num*sizeof(HaloInfo)) ; int extent = fieldtype->extent; diff --git a/src/lb-boundaries.c b/src/lb-boundaries.c index 306106b77d9..3e0f5b473dc 100644 --- a/src/lb-boundaries.c +++ b/src/lb-boundaries.c @@ -222,7 +222,7 @@ void lb_init_boundaries() { int lbboundary_get_force(int no, double* f) { #ifdef LB_BOUNDARIES - double* forces=malloc(3*n_lb_boundaries*sizeof(double)); + double* forces = (double*) malloc(3*n_lb_boundaries*sizeof(double)); mpi_gather_stats(8, forces, NULL, NULL, NULL); diff --git a/src/lb.c b/src/lb.c index 8b189d51f5e..95197c9a022 100644 --- a/src/lb.c +++ b/src/lb.c @@ -1041,8 +1041,8 @@ static void halo_push_communication() { * X direction * ***************/ count = 5*lblattice.halo_grid[1]*lblattice.halo_grid[2]; - sbuf = malloc(count*sizeof(double)); - rbuf = malloc(count*sizeof(double)); + sbuf = (double*) malloc(count*sizeof(double)); + rbuf = (double*) malloc(count*sizeof(double)); /* send to right, recv from left i = 1, 7, 9, 11, 13 */ snode = node_neighbors[1]; @@ -1136,8 +1136,8 @@ static void halo_push_communication() { * Y direction * ***************/ count = 5*lblattice.halo_grid[0]*lblattice.halo_grid[2]; - sbuf = realloc(sbuf, count*sizeof(double)); - rbuf = realloc(rbuf, count*sizeof(double)); + sbuf = (double*) realloc(sbuf, count*sizeof(double)); + rbuf = (double*) realloc(rbuf, count*sizeof(double)); /* send to right, recv from left i = 3, 7, 10, 15, 17 */ snode = node_neighbors[3]; @@ -1235,8 +1235,8 @@ static void halo_push_communication() { * Z direction * ***************/ count = 5*lblattice.halo_grid[0]*lblattice.halo_grid[1]; - sbuf = realloc(sbuf, count*sizeof(double)); - rbuf = realloc(rbuf, count*sizeof(double)); + sbuf = (double*) realloc(sbuf, count*sizeof(double)); + rbuf = (double*) realloc(rbuf, count*sizeof(double)); /* send to right, recv from left i = 5, 11, 14, 15, 18 */ snode = node_neighbors[5]; @@ -1365,8 +1365,8 @@ int lb_sanity_checks() { /** (Pre-)allocate memory for data structures */ void lb_pre_init() { n_veloc = lbmodel.n_veloc; - lbfluid[0] = malloc(2*lbmodel.n_veloc*sizeof(double *)); - lbfluid[0][0] = malloc(2*lblattice.halo_grid_volume*lbmodel.n_veloc*sizeof(double)); + lbfluid[0] = (double**) malloc(2*lbmodel.n_veloc*sizeof(double *)); + lbfluid[0][0] = (double*) malloc(2*lblattice.halo_grid_volume*lbmodel.n_veloc*sizeof(double)); } /** (Re-)allocate memory for the fluid and initialize pointers. */ @@ -1375,8 +1375,8 @@ static void lb_realloc_fluid() { LB_TRACE(printf("reallocating fluid\n")); - lbfluid[0] = realloc(*lbfluid,2*lbmodel.n_veloc*sizeof(double *)); - lbfluid[0][0] = realloc(**lbfluid,2*lblattice.halo_grid_volume*lbmodel.n_veloc*sizeof(double)); + lbfluid[0] = (double**) realloc(*lbfluid,2*lbmodel.n_veloc*sizeof(double *)); + lbfluid[0][0] = (double*) realloc(**lbfluid,2*lblattice.halo_grid_volume*lbmodel.n_veloc*sizeof(double)); lbfluid[1] = (double **)lbfluid[0] + lbmodel.n_veloc; lbfluid[1][0] = (double *)lbfluid[0][0] + lblattice.halo_grid_volume*lbmodel.n_veloc; @@ -1385,7 +1385,7 @@ static void lb_realloc_fluid() { lbfluid[1][i] = lbfluid[1][0] + i*lblattice.halo_grid_volume; } - lbfields = realloc(lbfields,lblattice.halo_grid_volume*sizeof(*lbfields)); + lbfields = (LB_FluidNode*) realloc(lbfields,lblattice.halo_grid_volume*sizeof(*lbfields)); } @@ -1406,7 +1406,7 @@ static void lb_prepare_communication() { prepare_halo_communication(&comm, &lblattice, FIELDTYPE_DOUBLE, MPI_DOUBLE); update_halo_comm.num = comm.num; - update_halo_comm.halo_info = realloc(update_halo_comm.halo_info,comm.num*sizeof(HaloInfo)); + update_halo_comm.halo_info = (HaloInfo*) realloc(update_halo_comm.halo_info,comm.num*sizeof(HaloInfo)); /* replicate the halo structure */ for (i=0; i Date: Fri, 8 Mar 2013 14:36:43 +0100 Subject: [PATCH 6/7] C++ compiler fixes in lbgpu --- src/endangledist.c | 4 ++-- src/lb-boundaries.c | 2 +- src/lb.c | 8 ++++---- src/lbgpu_cfile.c | 12 ++++++------ 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/endangledist.c b/src/endangledist.c index fbdd1d9c770..a180181efe2 100644 --- a/src/endangledist.c +++ b/src/endangledist.c @@ -228,8 +228,8 @@ int calc_endangledist_pair_force(Particle *p1, Particle *p2, Bonded_ia_parameter } #endif - ONEPART_TRACE(if(p1->p.identity==check_id) fprintf(stderr,"%d: OPT: ENDANGLEDIST f = (%.3e,%.3e,%.3e) with part id=%d at dist %f fac %.3e\n",this_node,p1->f.f[0],p1->f.f[1],p1->f.f[2],p2->p.identity,dist2,fac)); - ONEPART_TRACE(if(p2->p.identity==check_id) fprintf(stderr,"%d: OPT: ENDANGLEDIST f = (%.3e,%.3e,%.3e) with part id=%d at dist %f fac %.3e\n",this_node,p2->f.f[0],p2->f.f[1],p2->f.f[2],p1->p.identity,dist2,fac)); + ONEPART_TRACE(if(p1->p.identity==check_id) fprintf(stderr,"%d: OPT: ENDANGLEDIST f = (%.3e,%.3e,%.3e) with part id=%d at dist %f fac %.3e\n",this_node,p1->f.f[0],p1->f.f[1],p1->f.f[2],p2->p.identity,dist,fac_b)); + ONEPART_TRACE(if(p2->p.identity==check_id) fprintf(stderr,"%d: OPT: ENDANGLEDIST f = (%.3e,%.3e,%.3e) with part id=%d at dist %f fac %.3e\n",this_node,p2->f.f[0],p2->f.f[1],p2->f.f[2],p1->p.identity,dist,fac_b)); return 0; } diff --git a/src/lb-boundaries.c b/src/lb-boundaries.c index 3e0f5b473dc..a24e875f54b 100644 --- a/src/lb-boundaries.c +++ b/src/lb-boundaries.c @@ -134,7 +134,7 @@ void lb_init_boundaries() { if (dist <= 0 && n_lb_boundaries > 0) { size_of_index = (number_of_boundnodes+1)*sizeof(int); - host_boundindex = realloc(host_boundindex, size_of_index); + host_boundindex = (int*) realloc(host_boundindex, size_of_index); host_boundindex[number_of_boundnodes] = x + lbpar_gpu.dim_x*y + lbpar_gpu.dim_x*lbpar_gpu.dim_y*z; //printf("boundindex %i: \n", host_boundindex[number_of_boundnodes]); number_of_boundnodes++; diff --git a/src/lb.c b/src/lb.c index 95197c9a022..d160646ad0c 100644 --- a/src/lb.c +++ b/src/lb.c @@ -417,7 +417,7 @@ int lb_lbfluid_print_vtk_boundary(char* filename) { if (lattice_switch & LATTICE_LB_GPU) { #ifdef LB_GPU unsigned int* bound_array; - bound_array = malloc(lbpar_gpu.number_of_nodes*sizeof(unsigned int)); + bound_array = (unsigned int*) malloc(lbpar_gpu.number_of_nodes*sizeof(unsigned int)); lb_get_boundary_flags_GPU(bound_array); int j; @@ -510,7 +510,7 @@ int lb_lbfluid_print_boundary(char* filename) { if (lattice_switch & LATTICE_LB_GPU) { #ifdef LB_GPU unsigned int* bound_array; - bound_array = malloc(lbpar_gpu.number_of_nodes*sizeof(unsigned int)); + bound_array = (unsigned int*) malloc(lbpar_gpu.number_of_nodes*sizeof(unsigned int)); lb_get_boundary_flags_GPU(bound_array); int xyz[3]; @@ -698,7 +698,7 @@ int lb_lbnode_get_rho(int* ind, double* p_rho){ if (lattice_switch & LATTICE_LB_GPU) { #ifdef LB_GPU LB_values_gpu *host_print_values; - host_print_values = malloc(sizeof(LB_values_gpu)); + host_print_values = (LB_values_gpu*) malloc(sizeof(LB_values_gpu)); double rho; int single_nodeindex = ind[0] + ind[1]*lbpar_gpu.dim_x + ind[2]*lbpar_gpu.dim_x*lbpar_gpu.dim_y; lb_print_node_GPU(single_nodeindex, host_print_values); @@ -729,7 +729,7 @@ int lb_lbnode_get_u(int* ind, double* p_u) { if (lattice_switch & LATTICE_LB_GPU) { #ifdef LB_GPU LB_values_gpu *host_print_values; - host_print_values = malloc(sizeof(LB_values_gpu)); + host_print_values = (LB_values_gpu*) malloc(sizeof(LB_values_gpu)); int single_nodeindex = ind[0] + ind[1]*lbpar_gpu.dim_x + ind[2]*lbpar_gpu.dim_x*lbpar_gpu.dim_y; lb_print_node_GPU(single_nodeindex, host_print_values); diff --git a/src/lbgpu_cfile.c b/src/lbgpu_cfile.c index 57c3c946a03..e71276fe77a 100644 --- a/src/lbgpu_cfile.c +++ b/src/lbgpu_cfile.c @@ -151,7 +151,7 @@ void lb_realloc_particles_gpu(){ /**-----------------------------------------------------*/ /**Allocate struct for particle forces */ size_t size_of_forces = lbpar_gpu.number_of_particles * sizeof(LB_particle_force_gpu); - host_forces = realloc(host_forces, size_of_forces); + host_forces = (LB_particle_force_gpu*) realloc(host_forces, size_of_forces); lbpar_gpu.your_seed = (unsigned int)i_random(max_ran); @@ -260,7 +260,7 @@ static void mpi_get_particles_lb(LB_particle_gpu *host_data) int i; int *sizes; - sizes = malloc(sizeof(int)*n_nodes); + sizes = (int*) malloc(sizeof(int)*n_nodes); n_part = cells_get_n_particles(); @@ -332,7 +332,7 @@ static void mpi_get_particles_slave_lb(){ if (n_part > 0) { /* get (unsorted) particle informations as an array of type 'particle' */ /* then get the particle information */ - host_data_sl = malloc(n_part*sizeof(LB_particle_gpu)); + host_data_sl = (LB_particle_gpu*) malloc(n_part*sizeof(LB_particle_gpu)); g = 0; for (c = 0; c < local_cells.n; c++) { @@ -377,7 +377,7 @@ static void mpi_send_forces_lb(LB_particle_force_gpu *host_forces){ int c; int i; int *sizes; - sizes = malloc(sizeof(int)*n_nodes); + sizes = (int*) malloc(sizeof(int)*n_nodes); n_part = cells_get_n_particles(); /* first collect number of particles on each node */ MPI_Gather(&n_part, 1, MPI_INT, sizes, 1, MPI_INT, 0, comm_cart); @@ -434,7 +434,7 @@ static void mpi_send_forces_slave_lb(){ int g = 0; /* get (unsorted) particle informations as an array of type 'particle' */ /* then get the particle information */ - host_forces_sl = malloc(n_part*sizeof(LB_particle_force_gpu)); + host_forces_sl = (LB_particle_force_gpu*) malloc(n_part*sizeof(LB_particle_force_gpu)); MPI_Recv(host_forces_sl, n_part*sizeof(LB_particle_force_gpu), MPI_BYTE, 0, REQ_GETPARTS, comm_cart, &status); for (c = 0; c < local_cells.n; c++) { @@ -464,7 +464,7 @@ int lb_lbnode_set_extforce_GPU(int ind[3], double f[3]) ind[0] + ind[1]*lbpar_gpu.dim_x + ind[2]*lbpar_gpu.dim_x*lbpar_gpu.dim_y; size_t size_of_extforces = (n_extern_nodeforces+1)*sizeof(LB_extern_nodeforce_gpu); - host_extern_nodeforces = realloc(host_extern_nodeforces, size_of_extforces); + host_extern_nodeforces = (LB_extern_nodeforce_gpu*) realloc(host_extern_nodeforces, size_of_extforces); host_extern_nodeforces[n_extern_nodeforces].force[0] = (float)f[0]; host_extern_nodeforces[n_extern_nodeforces].force[1] = (float)f[1]; From 4b029254197f83053c39ff7fa2f33c1dfc7ebbaa Mon Sep 17 00:00:00 2001 From: Florian Fahrenberger Date: Fri, 8 Mar 2013 15:31:16 +0100 Subject: [PATCH 7/7] fixed CUDA and C++ linking --- src/cuda_init.cu | 4 ---- src/lbgpu.cu | 2 -- src/lbgpu.h | 14 +------------- 3 files changed, 1 insertion(+), 19 deletions(-) diff --git a/src/cuda_init.cu b/src/cuda_init.cu index 7ea65a8b05b..05537b4e90c 100644 --- a/src/cuda_init.cu +++ b/src/cuda_init.cu @@ -18,13 +18,9 @@ */ -// CUDA code is always interpreted as C++, so we need the extern C interface -extern "C" { - #include "utils.h" #include "cuda_init.h" -} #ifdef CUDA diff --git a/src/lbgpu.cu b/src/lbgpu.cu index 655fd767847..f9d742fb8c1 100644 --- a/src/lbgpu.cu +++ b/src/lbgpu.cu @@ -27,10 +27,8 @@ #include #include -extern "C" { #include "lbgpu.h" #include "config.h" -} #ifdef LB_GPU #ifndef GAUSSRANDOM diff --git a/src/lbgpu.h b/src/lbgpu.h index 00ba2fbe0e2..9f652ab4725 100644 --- a/src/lbgpu.h +++ b/src/lbgpu.h @@ -198,9 +198,7 @@ void on_lb_params_change_gpu(int field); /** */ -#ifdef __cplusplus -extern "C" { -#endif + /** Switch indicating momentum exchange between particles and fluid */ extern LB_parameters_gpu lbpar_gpu; extern LB_values_gpu *host_values; @@ -208,9 +206,6 @@ extern int transfer_momentum_gpu; extern LB_extern_nodeforce_gpu *extern_nodeforces_gpu; extern int n_lb_boundaries; -#ifdef __cplusplus -} -#endif /*@}*/ @@ -220,9 +215,6 @@ extern int n_lb_boundaries; /************************************************************/ /*@{*/ -#ifdef __cplusplus -extern "C" { -#endif void lattice_boltzmann_update_gpu(); @@ -277,10 +269,6 @@ void lb_reinit_extern_nodeforce_GPU(LB_parameters_gpu *lbpar_gpu); void lb_reinit_GPU(LB_parameters_gpu *lbpar_gpu); int lb_lbnode_set_extforce_GPU(int ind[3], double f[3]); -#ifdef __cplusplus -} -#endif - /*@{*/ #endif /* LB_GPU */