#include "network.h"
#include "event.h"
+#include "nlsop_general.h"
+
#define MAKE_AMORPH(N) *(N)|=AMORPH
#define MAKE_CRYST(N) *(N)&=~AMORPH
-#define NLSOP_CLIENT 'c'
-#define NLSOP_NJOB 'N'
-#define NLSOP_CJOB 'C'
-
/* globals */
char p_file[MAX_CHARS];
int usage(char *prog)
{
puts("usage:");
- printf("%s <server ip>\n",prog);
+ printf("%s -i ip -p port -r/P/n random/profile/neloss file\n",prog);
return 1;
}
}
}
}
- if(my_info->z_diff)
+ /* diff in z direction */
+ if(k!=0)
{
- if(k!=0)
+ off=i+j*d3_l->max_x+(k-1)*d3_l->max_x*d3_l->max_y;
+ carry=0;
+ if(!*(d3_l->status+off)&AMORPH) carry=(int)(my_info->dr_ac*(*(d3_l->extra+off)));
+ if(carry!=0)
{
- off=i+j*d3_l->max_x+(k-1)*d3_l->max_x*d3_l->max_y;
- carry=0;
- if(!*(d3_l->status+off)&AMORPH) carry=(int)(my_info->dr_ac*(*(d3_l->extra+off)));
- if(carry!=0)
- {
- *(d3_l->extra+off)-=carry;
- *(d3_l->extra+offset)+=carry;
- }
+ *(d3_l->extra+off)-=carry;
+ *(d3_l->extra+offset)+=carry;
}
- if(k!=d3_l->max_z-1)
+ }
+ if(k!=d3_l->max_z-1)
+ {
+ off=i+j*d3_l->max_x+(k+1)*d3_l->max_x*d3_l->max_y;
+ carry=0;
+ if(!*(d3_l->status+off)&AMORPH) carry=(int)(my_info->dr_ac*(*(d3_l->extra+off)));
+ if(carry!=0)
{
- off=i+j*d3_l->max_x+(k+1)*d3_l->max_x*d3_l->max_y;
- carry=0;
- if(!*(d3_l->status+off)&AMORPH) carry=(int)(my_info->dr_ac*(*(d3_l->extra+off)));
- if(carry!=0)
- {
- *(d3_l->extra+off)-=carry;
- *(d3_l->extra+offset)+=carry;
- }
+ *(d3_l->extra+off)-=carry;
+ *(d3_l->extra+offset)+=carry;
}
- }
+ }
}
} /* for z */
} /* for y */
return 1;
}
-/* save to file --> send to server :) --> T O D O <-- */
-void send_data(int signum) {
-
- int c;
-
- c=gd3_l->max_x*gd3_l->max_y*gd3_l->max_z;
-
- network_send(gnet->connection[0].fd,&dc,1);
- network_send(gnet->connection[0].fd,(unsigned char *)gd3_l,
- sizeof(d3_lattice));
- network_send(gnet->connection[0].fd,(unsigned char *)gmy_info,sizeof(info));
- network_send(gnet->connection[0].fd,gd3_l->status,c*sizeof(unsigned char));
- network_send(gnet->connection[0].fd,(unsigned char *)gd3_l->extra,
- c*sizeof(int));
- network_send(gnet->connection[0].fd,(unsigned char *)gi,sizeof(int));
-
-}
-
-int save_to_file(char *sf,d3_lattice *d3_l,info *my_inf)
-{
- int sf_fd,c;
-
- if((sf_fd=open(sf,O_WRONLY|O_CREAT))<0)
- {
- puts("cannot open save file");
- return -1;
- }
- if(write(sf_fd,d3_l,sizeof(d3_lattice))<sizeof(d3_lattice))
- {
- puts("failed saving d3 lattice struct");
- return -1;
- }
- if(write(sf_fd,my_inf,sizeof(info))<sizeof(info))
- {
- puts("failed saving info struct");
- return-1;
- }
- c=d3_l->max_x*d3_l->max_y*d3_l->max_z;
- if(write(sf_fd,d3_l->status,c*sizeof(unsigned char))<c*sizeof(unsigned char))
- {
- puts("failed saving status of d3 lattice sites");
- return -1;
- }
- if(write(sf_fd,d3_l->extra,c*sizeof(int))<c*sizeof(int))
- {
- puts("failed saving sites concentration");
- return -1;
- }
- close(sf_fd);
-
- return 1;
-}
-
u32 get_reject_graph(info *my_info,d3_lattice *d3_l,char *file,u32 *graph) {
double a,b;
int i,j,k;
return max;
}
+void send_data(int signum) {
+
+ int c;
+
+ c=gd3_l->max_x*gd3_l->max_y*gd3_l->max_z;
+
+ network_send(gnet->connection[0].fd,&dc,1);
+ /*
+ network_send(gnet->connection[0].fd,(unsigned char *)gd3_l,
+ sizeof(d3_lattice));
+ network_send(gnet->connection[0].fd,(unsigned char *)gmy_info,sizeof(info));
+ */
+ network_send(gnet->connection[0].fd,gd3_l->status,c*sizeof(unsigned char));
+ network_send(gnet->connection[0].fd,(unsigned char *)gd3_l->extra,
+ c*sizeof(int));
+ network_send(gnet->connection[0].fd,(unsigned char *)gi,sizeof(int));
+
+}
/*
/* wait for job */
event_math(net.connection[0].fd,&event,READ,ADD);
+ printf("idle, waiting for jobs ...\n");
event_start(&event,NULL,get_data_and_calc,NULL);
return 1;
u32 *nel_z;
u32 x_c,y_c,z_c;
int i,j;
- int resave;
int c_step;
-#define DC_QUIT (1<<0)
-#define DC_OK (1<<1)
-#define DC_END (1<<2)
unsigned char data[256];
t_net *net;
- resave=RESAVE;
c_step=0;
ne_max=0;
ip_max=0;
gmy_info=&my_info;
gi=&i;
dc=0;
+
+ printf("got a new job ...\n");
/* get info (+data) */
network_receive(net->connection[0].fd,data,1);
}
}
+ printf("starting simulation with following parameters:\n");
+ printf("b = %f | c = %f | s = %f\n",my_info.b,my_info.c,my_info.s);
+ printf("diff every %d steps | diff rate = %f\n",my_info.diff_rate,
+ my_info.dr_ac);
+ printf("current step: %d | total steps: %d\n",c_step,my_info.steps);
+ printf("...\n");
+
/* care for signals */
dc=DC_QUIT;
signal(SIGTERM,send_data);
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);
- if(i%resave==0 && i!=0) {
+ i++;
+ if(i%my_info.save_rate==0) {
dc=DC_OK;
send_data(0);
dc=DC_QUIT;
}
- i++;
if(i%my_info.s_rate==0) sputter(&d3_l);
}