From 7aface2e184e527132819f17b0fa18a6e1ba4bc3 Mon Sep 17 00:00:00 2001 From: hackbard Date: Tue, 28 Nov 2006 15:37:00 +0000 Subject: [PATCH] well, no more segfaults -> now its getting hard to debug ... --- moldyn.c | 32 ++++++++++++++++++-------------- moldyn.h | 2 +- sic.c | 31 +++++++++++++++++++++++-------- 3 files changed, 42 insertions(+), 23 deletions(-) diff --git a/moldyn.c b/moldyn.c index 509a45d..505f496 100644 --- a/moldyn.c +++ b/moldyn.c @@ -156,7 +156,7 @@ int moldyn_set_log(t_moldyn *moldyn,u8 type,char *fb,int timer) { strncpy(moldyn->sfb,fb,63); break; case VISUAL_STEP: - moldyn->mwrite=timer; + moldyn->vwrite=timer; strncpy(moldyn->vfb,fb,63); visual_init(&(moldyn->vis),fb); break; @@ -234,7 +234,7 @@ int create_lattice(t_moldyn *moldyn,u8 type,double lc,int element,double mass, } int add_atom(t_moldyn *moldyn,int element,double mass,u8 bnum,u8 attr, - t_3dvec r,t_3dvec v) { + t_3dvec *r,t_3dvec *v) { t_atom *atom; void *ptr; @@ -248,10 +248,11 @@ int add_atom(t_moldyn *moldyn,int element,double mass,u8 bnum,u8 attr, perror("[moldyn] realloc (add atom)"); return -1; } - - atom=ptr; - atom->r=r; - atom->v=v; + moldyn->atom=ptr; + + atom=moldyn->atom; + atom->r=*r; + atom->v=*v; atom->element=element; atom->bnum=bnum; atom->attr=attr; @@ -404,6 +405,9 @@ int link_cell_init(t_moldyn *moldyn) { t_linkcell *lc; int i; + int fd; + + fd=open("/dev/null",O_WRONLY); lc=&(moldyn->lc); @@ -418,10 +422,11 @@ int link_cell_init(t_moldyn *moldyn) { lc->cells=lc->nx*lc->ny*lc->nz; lc->subcell=malloc(lc->cells*sizeof(t_list)); - printf("initializing linked cells (%d)\n",lc->cells); + printf("[moldyn] initializing linked cells (%d)\n",lc->cells); for(i=0;icells;i++) - list_init(&(lc->subcell[i]),1); + //list_init(&(lc->subcell[i]),1); + list_init(&(lc->subcell[i]),fd); link_cell_update(moldyn); @@ -541,6 +546,7 @@ int moldyn_add_schedule(t_moldyn *moldyn,int runs,double tau) { perror("[moldyn] realloc (runs)"); return -1; } + moldyn->schedule.runs=ptr; moldyn->schedule.runs[count-1]=runs; ptr=realloc(schedule->tau,count*sizeof(double)); @@ -548,6 +554,7 @@ int moldyn_add_schedule(t_moldyn *moldyn,int runs,double tau) { perror("[moldyn] realloc (tau)"); return -1; } + moldyn->schedule.tau=ptr; moldyn->schedule.tau[count-1]=tau; return 0; @@ -650,12 +657,13 @@ int moldyn_integrate(t_moldyn *moldyn) { } if(v) { if(!(i%v)) { - visual_atoms(moldyn->visual,i*moldyn->tau, + visual_atoms(&(moldyn->vis),moldyn->time, moldyn->atom,moldyn->count); - printf("\rsteps: %d",i); + printf("\rsched: %d, steps: %d",sched,i); fflush(stdout); } } + } /* check for hooks */ @@ -695,15 +703,11 @@ int velocity_verlet(t_moldyn *moldyn) { } /* neighbour list update */ -printf("list update ...\n"); link_cell_update(moldyn); -printf("done\n"); /* forces depending on chosen potential */ -printf("calc potential/force ...\n"); potential_force_calc(moldyn); //moldyn->potential_force_function(moldyn); -printf("done\n"); for(i=0;i