added -g (continue from file at certain step feature) good for power interrupts ;)
authorhackbard <hackbard>
Mon, 20 Oct 2003 11:48:17 +0000 (11:48 +0000)
committerhackbard <hackbard>
Mon, 20 Oct 2003 11:48:17 +0000 (11:48 +0000)
nlsop.c

diff --git a/nlsop.c b/nlsop.c
index edbc860..5b160bc 100644 (file)
--- a/nlsop.c
+++ b/nlsop.c
@@ -55,6 +55,7 @@ int usage(void)
  printf("-D <value> \t diffusion rate from cryst to amorph cells (default %f)\n",DR_AC);
  printf("-c <value> \t diffusion rate in cryst cells (default %f)\n",DR_CC);
  printf("-e <value> \t do diffusion every <value> steps (default %d)\n",DIFF_RATE);
+ puts("-g <file> <step> \t continue simulation from file and step (step > 0)!");
  printf("-W <value> \t write every <value> steps to save file (default %d)\n",RESAVE);
  puts("-C <file> \t convert file to gnuplot format");
  puts("-L <file> \t load from file");
@@ -612,6 +613,7 @@ int main(int argc,char **argv)
  u32 x,y,z,x_c,y_c,z_c;
  int i,quit,escape,switchmode,nowait,bmp;
  int refresh,resave;
+ int c_step;
  char s_file[MAX_CHARS];
  char s_file_tmp[MAX_CHARS];
  char l_file[MAX_CHARS];
@@ -671,6 +673,7 @@ int main(int argc,char **argv)
  quit=0;
  escape=0;
  switchmode=0;
+ c_step=0;
  strcpy(s_file,"");
  strcpy(l_file,"");
  strcpy(c_file,"");
@@ -765,6 +768,10 @@ int main(int argc,char **argv)
     case 'P':
      strcpy(p_file,argv[++i]);
      break;
+    case 'g':
+     strcpy(l_file,argv[++i]);
+     if(i<argc-1) if(argv[i+1][0]!='-') c_step=atoi(argv[++i]);
+     break;
     default:
      usage();
      return -1;
@@ -817,7 +824,7 @@ int main(int argc,char **argv)
    return 1;
   } 
 #ifdef USE_DFB_API
-    else d3_lattice_init(&argc,argv,&d3_l);
+  else d3_lattice_init(&argc,argv,&d3_l);
 #endif
  }
 
@@ -866,14 +873,14 @@ int main(int argc,char **argv)
  arg_v[25]=dr_cc_txt;
 #endif
 
- if(!strcmp(l_file,""))
+ if((!strcmp(l_file,""))||(c_step))
  {
   if(get_c_ratio(&c_ratio,p_file,&my_info,&d3_l)!=1)
   {
    puts("failed calculating ratio");
    return -1;
   }
-  i=0;
+  i=(c_step?c_step:0);
   while((i<my_info.steps) && (quit==0) && (escape==0))
   {
    x_c=get_rand(d3_l.max_x);