+int get_c_ratio(double *c_ratio,char *pfile,info *my_info,d3_lattice *d3_l)
+{
+ double all,a,b,d;
+ int i,k;
+ int p_fd;
+ unsigned char buf[32];
+ char *p;
+ unsigned char c;
+
+ if((p_fd=open(pfile,O_RDONLY))<0)
+ {
+ puts("cannot open profile file");
+ return -1;
+ }
+ k=1;
+ d=0;
+ all=0;
+ while(k)
+ {
+ for(i=0;i<32;i++)
+ {
+ k=read(p_fd,&c,1);
+ buf[i]=c;
+ if(c=='\n') break;
+ }
+ if(k)
+ {
+ p=strtok(buf," ");
+ a=atof(p)/10; /* nm */
+ p=strtok(NULL," ");
+ b=atof(p);
+ if(a>my_info->b_cd*CELL_LENGTH && a<(my_info->b_cd+d3_l->max_z)*CELL_LENGTH) d+=b;
+ all+=b;
+ }
+ }
+ *c_ratio=d/all;
+
+ return 1;
+}
+