added general header file
[physik/nlsop.git] / nlsop_client.c
index c635892..6467827 100644 (file)
@@ -49,6 +49,8 @@
 #include "network.h"
 #include "event.h"
 
+#include "nlsop_general.h"
+
 #define MAKE_AMORPH(N) *(N)|=AMORPH
 #define MAKE_CRYST(N) *(N)&=~AMORPH
 
@@ -72,7 +74,7 @@ int get_data_and_calc(t_event *event,void *allineed);
 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;
 }
 
@@ -238,59 +240,6 @@ int distrib_c(d3_lattice *d3_l,info *my_info,int step,u32 rj_m,u32 *rj_g)
  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;
@@ -358,6 +307,24 @@ u32 get_reject_graph(info *my_info,d3_lattice *d3_l,char *file,u32 *graph) {
  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));
+
+}
 
 
 /*
@@ -452,9 +419,6 @@ int get_data_and_calc(t_event *event,void *allineed) {
   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;