X-Git-Url: https://hackdaworld.org/gitweb/?p=physik%2Fnlsop.git;a=blobdiff_plain;f=nlsop_client.c;h=9718270fcfa7a7a67c2e53eb5c612052faeea288;hp=be24dc97bfaa22c5c0bd56d31cee6493df7e4e48;hb=dd664a3acbc39be7bc2f75e2a9378f989c75baa8;hpb=f615574d57f1d57dd4169ddd4f552d5c000c6dc8 diff --git a/nlsop_client.c b/nlsop_client.c index be24dc9..9718270 100644 --- a/nlsop_client.c +++ b/nlsop_client.c @@ -66,6 +66,7 @@ int *gi; unsigned char dc; int get_data_and_calc(t_event *event,void *allineed); +int nop(t_event *event,void *allineed); int usage(char *prog) { @@ -307,17 +308,12 @@ void send_data(int signum) { 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)); - + 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)); } @@ -338,7 +334,7 @@ int main(int argc,char **argv) 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,""); @@ -397,7 +393,14 @@ int main(int argc,char **argv) /* 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); + event_start(&event,NULL,get_data_and_calc,nop); + + return 1; +} + +int nop(t_event *event,void *allineed) { + + printf("\ni did a nop :)\n"); return 1; } @@ -413,7 +416,7 @@ int get_data_and_calc(t_event *event,void *allineed) { u32 x_c,y_c,z_c; int i,j; int c_step; - unsigned char data[256]; + unsigned char data; t_net *net; @@ -430,8 +433,8 @@ int get_data_and_calc(t_event *event,void *allineed) { printf("got a new job ...\n"); /* get info (+data) */ - network_receive(net->connection[0].fd,data,1); - if(data[0]==NLSOP_NJOB || data[0]==NLSOP_CJOB) { + network_receive(net->connection[0].fd,&data,sizeof(unsigned char)); + if(data==NLSOP_NJOB || data==NLSOP_CJOB) { network_receive(net->connection[0].fd,(unsigned char *)&d3_l, sizeof(d3_lattice)); network_receive(net->connection[0].fd,(unsigned char *)&my_info, @@ -448,15 +451,30 @@ int get_data_and_calc(t_event *event,void *allineed) { printf("extra malloc failed\n"); return -1; } - if(data[0]==NLSOP_CJOB) { + if(data==NLSOP_CJOB) { + data=DATA_OK; network_receive(net->connection[0].fd,d3_l.status, j*sizeof(unsigned char)); + network_send(net->connection[0].fd,&data,sizeof(unsigned char)); network_receive(net->connection[0].fd,(unsigned char *)d3_l.extra, j*sizeof(int)); + network_send(net->connection[0].fd,&data,sizeof(unsigned char)); network_receive(net->connection[0].fd,(unsigned char *)&c_step, sizeof(int)); + network_send(net->connection[0].fd,&data,sizeof(unsigned char)); } } + else { + printf("unknown instruction, restarting ...\n"); + return -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; @@ -526,6 +544,11 @@ int get_data_and_calc(t_event *event,void *allineed) { dc=DC_QUIT; /* 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; }