text: #include "flexaid.h"
  #include "boinc.h"
  
  void write_sphere(FA_Global* FA,char filename[]){
  
    int i,l,m;
    float locsphere[MAX_SPHERE_POINTS][3];
    char  outfile[MAX_PATH__];
    FILE* outfile_ptr;
    
    strcpy(outfile,filename);
  
    for(l=0;l<FA->tspoints;l++){
      //create sphere point l around atom i
      for(m=0;m<=2;m++){
        locsphere[l][m]=FA->rngrad*FA->sphere[l][m]+FA->rngcen[m];
      }
    }
    
    i=1;
  
    outfile_ptr=NULL;
    if (!OpenFile_B(outfile,"w",&outfile_ptr)){
      Terminate(6);
    }else{
      // write header information
      fprintf(outfile_ptr,"HEADER coordinate file generated by liginc\n");
      //write coordinates
      for (l=0;l<FA->tspoints;l++){
        fprintf(outfile_ptr,"%s%5d %s %s %c 999    %8.3f%8.3f%8.3f  1.00  0.00\n",
  	      "HETATM",i," C  ","SPH",'A',locsphere[l][0],locsphere[l][1],locsphere[l][2]);
        i++;
      }
    }
    
    CloseFile_B(&outfile_ptr,"w");
    
    return;
  }
  