+int get_amorphous_layer_info(d3_lattice *d3_l,int *sai,int *sacl,int *eacl) {
+ int i,j,a,oend,nend,count;
+ unsigned char sacl_is_set=0;
+ unsigned char eacl_is_set=0;
+ unsigned char sai_is_set=0;
+
+ a=d3_l->max_x*d3_l->max_y;
+ nend=a;
+ oend=0;
+
+ for(i=0;i<d3_l->max_z;i++) {
+ count=0;
+ for(j=oend;j<nend;j++) if(*(d3_l->status+j)&AMORPH) count++;
+ oend=nend;
+ nend+=a;
+ if((count>=A_START*a)&&(!sai_is_set)) {
+ *sai=i;
+ sai_is_set=1;
+ }
+ if((count>=AC_START*a)&&(!sacl_is_set)) {
+ *sacl=i;
+ sacl_is_set=1;
+ }
+ if((count<=A_END*a)&&(sacl_is_set)&&(!eacl_is_set)) {
+ *eacl=i;
+ eacl_is_set=1;
+ }
+ if((eacl_is_set)&&(count>=A_END*a)) eacl_is_set=0;
+ }
+ return 1;
+}
+