info *gmy_info;
int *gi;
unsigned char dc;
+unsigned char shut_down;
int get_data_and_calc(t_event *event,void *allineed);
int nop(t_event *event,void *allineed);
thiz=d3_l->status+x+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y;
conc=d3_l->extra+x+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y;
- p=my_info->b*nel_z;
+ //p=my_info->b*nel_z; // energieuebertrag prop zu nukl. bk
+ p=my_info->b*URAND_MAX; // konstanter energieuebertrag
for(i=-(my_info->range);i<=my_info->range;i++)
{
for(j=-(my_info->range);j<=my_info->range;j++)
}
}
p+=*conc*my_info->c*URAND_MAX;
- if(!(*thiz&AMORPH))
- {
- if(get_rand(URAND_MAX)<=p) MAKE_AMORPH(thiz);
- } else
- {
- /* assume 1-p probability */
- /* also look for neighbours ! */
- q=(URAND_MAX-p)>0?URAND_MAX-p:0;
- j=0;
- j+=(*(d3_l->status+((x+d3_l->max_x+1)%d3_l->max_x)+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y)&AMORPH)?1:0;
- j+=(*(d3_l->status+((x+d3_l->max_x-1)%d3_l->max_x)+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y)&AMORPH)?1:0;
- j+=(*(d3_l->status+x+((y+1+d3_l->max_y)%d3_l->max_y)*d3_l->max_x+z*d3_l->max_x*d3_l->max_y)&AMORPH)?1:0;
- j+=(*(d3_l->status+x+((y-1+d3_l->max_y)%d3_l->max_y)*d3_l->max_x+z*d3_l->max_x*d3_l->max_y)&AMORPH)?1:0;
- j+=(*(d3_l->status+x+y*d3_l->max_x+((z+1+d3_l->max_z)%d3_l->max_z)*d3_l->max_x*d3_l->max_y)&AMORPH)?1:0;
- j+=(*(d3_l->status+x+y*d3_l->max_x+((z-1+d3_l->max_z)%d3_l->max_z)*d3_l->max_x*d3_l->max_y)&AMORPH)?1:0;
-
- p+=((q/6)*j);
- if(get_rand(URAND_MAX)>p) MAKE_CRYST(thiz);
+ if(p>=URAND_MAX) MAKE_AMORPH(thiz);
+ else {
+ if(!(*thiz&AMORPH)) {
+ if(get_rand(URAND_MAX)<=p) MAKE_AMORPH(thiz);
+ }
+ else {
+ /* assume 1-p probability */
+ /* also look for neighbours ! */
+ q=(URAND_MAX-p)>0?URAND_MAX-p:0;
+ j=0;
+ j+=(*(d3_l->status+((x+d3_l->max_x+1)%d3_l->max_x)+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y)&AMORPH)?1:0;
+ j+=(*(d3_l->status+((x+d3_l->max_x-1)%d3_l->max_x)+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y)&AMORPH)?1:0;
+ j+=(*(d3_l->status+x+((y+1+d3_l->max_y)%d3_l->max_y)*d3_l->max_x+z*d3_l->max_x*d3_l->max_y)&AMORPH)?1:0;
+ j+=(*(d3_l->status+x+((y-1+d3_l->max_y)%d3_l->max_y)*d3_l->max_x+z*d3_l->max_x*d3_l->max_y)&AMORPH)?1:0;
+ j+=(*(d3_l->status+x+y*d3_l->max_x+((z+1+d3_l->max_z)%d3_l->max_z)*d3_l->max_x*d3_l->max_y)&AMORPH)?1:0;
+ j+=(*(d3_l->status+x+y*d3_l->max_x+((z-1+d3_l->max_z)%d3_l->max_z)*d3_l->max_x*d3_l->max_y)&AMORPH)?1:0;
+
+ p+=((q/6)*j);
+ if(p<=URAND_MAX) {
+ if(get_rand(URAND_MAX)>p) MAKE_CRYST(thiz);
+ }
+ }
}
return 1;
void send_data(int signum) {
int c;
- unsigned char data;
+ unsigned char ack=DATA_OK;
c=gd3_l->max_x*gd3_l->max_y*gd3_l->max_z;
- printf("%d <-\n",c);
-
- network_send(gnet->connection[0].fd,&dc,1);
- network_receive(gnet->connection[0].fd,&data,sizeof(unsigned char));
- printf("debug: sent dc\n");
-
- network_send(gnet->connection[0].fd,(unsigned char *)gd3_l,
- sizeof(d3_lattice));
- network_receive(gnet->connection[0].fd,&data,sizeof(unsigned char));
- printf("debug: sent d3_lattice\n");
-
- network_send(gnet->connection[0].fd,(unsigned char *)gmy_info,sizeof(info));
- network_receive(gnet->connection[0].fd,&data,sizeof(unsigned char));
- printf("debug: sent info\n");
-
- network_send(gnet->connection[0].fd,gd3_l->status,c*sizeof(unsigned char));
- network_receive(gnet->connection[0].fd,&data,sizeof(unsigned char));
- printf("debug: sent ac\n");
-
- network_send(gnet->connection[0].fd,(unsigned char *)gd3_l->extra,
- c*sizeof(int));
- network_receive(gnet->connection[0].fd,&data,sizeof(unsigned char));
- printf("debug: sent cc\n");
-
- network_send(gnet->connection[0].fd,(unsigned char *)gi,sizeof(int));
- network_receive(gnet->connection[0].fd,&data,sizeof(unsigned char));
- printf("debug: sent steps\n");
+ network_send_chan(gnet,0,&dc,1);
+ network_send_chan(gnet,0,(unsigned char *)gd3_l,sizeof(d3_lattice));
+ network_send_chan(gnet,0,(unsigned char *)gmy_info,sizeof(info));
+ network_send_chan(gnet,0,gd3_l->status,c*sizeof(unsigned char));
+ network_send_chan(gnet,0,(unsigned char *)gd3_l->extra,c*sizeof(int));
+ network_send_chan(gnet,0,(unsigned char *)gi,sizeof(int));
+ network_send_chan(gnet,0,&ack,sizeof(unsigned char));
+ if(dc==DC_QUIT) shut_down=1;
}
gnet=&net;
/* default values */
- strcpy(server_ip,"");
+ strcpy(server_ip,"137.250.82.105");
strcpy(p_file,IMP_PROFILE);
strcpy(n_e_file,NEL_PROFILE);
strcpy(r_file,"");
printf("idle, waiting for jobs ...\n");
event_start(&event,NULL,get_data_and_calc,nop);
+ network_shutdown(&net);
+
return 1;
}
int nop(t_event *event,void *allineed) {
+ printf("\ni did a nop :)\n");
+
return 1;
}
gmy_info=&my_info;
gi=&i;
dc=0;
+ shut_down=0;
printf("got a new job ...\n");
sizeof(int));
network_send(net->connection[0].fd,&data,sizeof(unsigned char));
}
+ if(c_step==0) {
+ printf("important: clear status/conc data!\n");
+ memset(d3_l.status,0,j*sizeof(unsigned char));
+ memset(d3_l.extra,0,j*sizeof(int));
+ }
}
else {
printf("unknown instruction, restarting ...\n");
for(j=0;j<my_info.cpi;j++) {
x_c=get_rand(d3_l.max_x);
y_c=get_rand(d3_l.max_y);
- // z_c=get_rand_reject(d3_l.max_z,ne_max,n_e_loss);
- z_c=get_rand(d3_l.max_z);
+ z_c=get_rand_reject(d3_l.max_z,ne_max,n_e_loss);
+ //z_c=get_rand(d3_l.max_z);
process_cell(&d3_l,x_c,y_c,z_c,&my_info,nel_z[z_c]);
}
distrib_c(&d3_l,&my_info,i,ip_max,c_profile);
dc=DC_QUIT;
}
if(i%my_info.s_rate==0) sputter(&d3_l);
+ if(shut_down) {
+ free(d3_l.status);
+ free(d3_l.extra);
+ free(c_profile);
+ free(n_e_loss);
+ free(nel_z);
+ event_stop(event);
+ }
}
/* finished */
/* shutdown/free/close everything now ... */
free(d3_l.status);
free(d3_l.extra);
+ free(c_profile);
+ free(n_e_loss);
+ free(nel_z);
return 1;
}