From: hackbard Date: Tue, 14 Sep 2004 14:06:01 +0000 (+0000) Subject: added trim collision file parser X-Git-Url: https://hackdaworld.org/gitweb/?a=commitdiff_plain;h=3cf265bb194147846ad6be9f7b870802185e5bbc;p=physik%2Fnlsop.git added trim collision file parser --- diff --git a/.cvsignore b/.cvsignore index 0d8585c..209faf8 100644 --- a/.cvsignore +++ b/.cvsignore @@ -5,3 +5,5 @@ nlsop.* conv_fg_tif Makefile nlsop-* +parse_trim_collision +ft diff --git a/parse_trim_collision.c b/parse_trim_collision.c new file mode 100644 index 0000000..ea59d6b --- /dev/null +++ b/parse_trim_collision.c @@ -0,0 +1,131 @@ +/* + * parse srim 2003.26 collision data + * + * author: hackbard@hackdaworld.dyndns.org + * + * this may just work with srim 2003.26 and 180keV c+ -> si, + * not quite sure though! :) + * + */ + +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include + +#define MAXION 5000 +#define MAXZ 233 + +typedef struct s_z { + int cell_hits_from_ions; + int total_hits; + double energy; +} t_z; + +int main(int argc,char **argv) { + + int fd,ion,i,j; + int z,skipped; + float en; + t_z Z[MAXZ]; + unsigned char hit[MAXZ]; + char buf[256],*p,value[6],value2[10]; + + i=0; + + if(argc!=2) return 0; + + printf("opening file %s ...\n",argv[1]); + if((fd=open(argv[1],O_RDONLY))<0) { + printf("unable to open file %s\n",argv[1]); + return 0; + } + + ion=1; + skipped=0; + for(i=0;i232) skipped+=1; + else { + Z[z].energy+=en; + Z[z].total_hits+=1; + hit[z]=1; + } + if(ion!=atoi(value)) { + /* new ion */ + for(i=0;i