yorick banner

Home

Manual

Packages

Global Index

Keywords

Quick Reference





func Run_Adaptahop (directory,fileroot,start,stop,force=,path_adapt=,rm=,verb=,fileref=,nmpi=)
/* DOCUMENT 
     EXAMPLE Run_Adaptahop("/raid/pichon/simu-ramses-25Mpc","part",1,29)
   SEE ALSO:
 */
{
  gettime();
  if(is_void(path_adapt))
    path_adapt="nice /home1/pichon/Project/flows/f90/compute_neiKDtree_0.3";
  if(is_void(rm)) rm=1;
  if(is_void(nmpi)) nmpi=8;
  if(is_void(force)) force=1;
  
  for(i=start;i<=stop;i++)    
    {
     
      dirout=directory;
      fileconfig=dirout+"/adapt.conf"+swrite(format="_%05d",i)+".out";
      filein=directory+"/"+fileroot+swrite(format="_%05d",i)+".out";
      filedis=dirout+"/adapt.dis"+swrite(format="_%05d",i)+".out";
      fileneinei=dirout+"/adapt.nei"+swrite(format="_%05d",i)+".out";
      filenode=dirout+"/adapt.nod"+swrite(format="_%05d",i)+".out";
      fileneihop=fileneinei;
      for(j=1;j<=3;j++)
        {
          if(((j=1)*(!open(filedis,"r",1)))||(force))
            {
              write_config_file(fileconfig,filein,j,filedis,fileneinei,filenode,fileneihop,fileref=fileref,nmpi=nmpi);
              commande=path_adapt+"/compute_neiKDtree "+fileconfig;
              if(verb) write,commande;
              system,commande;
            }

          if(((j=2)*(!open(fileneinei,"r",1)))||(force))
            {
              
              write_config_file(fileconfig,filein,j,filedis,fileneinei,filenode,fileneihop,fileref=fileref,nmpi=nmpi);
              commande=path_adapt+"/compute_neiKDtree "+fileconfig;
              if(verb) write,commande;
              system,commande;
             
            }

          
          if(((j=3)*(!open(filenode,"r",1)))||(force))
            {
              write_config_file(fileconfig,filein,j,filedis,fileneinei,filenode,fileneihop,fileref=fileref,nmpi=nmpi);
              commande=path_adapt+"/compute_neiKDtree "+fileconfig;
              if(verb) write,commande;
              system,commande;
            }
        }

      if(rm)
        {
          system,"rm -f "+fileneinei;
          system,"rm -f "+filedis;
        }
    }
  
  gettime();
  return 0;
}







func write_config_file (fileconfig,filein,action,filedis,fileneinei,filenode,fileneihop,fileref=,nmpi=)
{
  /* DOCUMENT
      write_config_file(fileconfig,filein,action,filedis,fileneinei,filenode,fileneihop)

      write the configuration file for Compute_neiKDtree

      fileconfig is the config file name to be produced
      filein is the simulation filename
      action =1 distance
             =2 neighbors
             =3 adaptahop

      the other parameters are explained in compute_neiKDtree.f90

     
   */
  
  if(is_void(fileref)) fileref="/home1/pichon/ramses/compute_neiKDtree.config";

  if(action==1) action="distances";
  if(action==2) action="neighbors";
  if(action==3) action="adaptahop";
  
  
  ff=open(fileref,"r");
  gg=open(fileconfig,"w");
  do
    {
      ll=rdline(ff);
      l1 = strtok(ll);
      if (l1(1)=="filein=")  write,gg,l1(1)+"'"+filein+"',";
      else  if (l1(1)=="action=")  write,gg,l1(1)+"'"+action+"',";
      else if (l1(1)=="filedis=") write,gg,l1(1)+"'"+filedis+"',";
      else if (l1(1)=="fileneinei=")  write,gg,l1(1)+"'"+fileneinei+"',";
      else if (l1(1)=="filenode=")  write,gg,l1(1)+"'"+filenode+"',";
      else if (l1(1)=="fileneihop=")  write,gg,l1(1)+"'"+fileneihop+"',";
      else if (l1(1)=="nmpi=")  write,gg,l1(1)+"'"+pr1(nmpi)+"',";
      else  write,gg,ll;
    }
  while (ll);


  close,ff;
  close,gg;

  return 0;
}