+
+int visual_bonds_process(t_moldyn *moldyn,t_atom *itom,t_atom *jtom,
+ void *data,u8 bc) {
+
+ t_vb *vb;
+
+ vb=data;
+
+ if(itom->tag>=jtom->tag)
+ return 0;
+
+ if(moldyn->check_2b_bond(moldyn,itom,jtom,bc)==FALSE)
+ return 0;
+
+ if((itom->attr&ATOM_ATTR_VB)|(jtom->attr&ATOM_ATTR_VB))
+ dprintf(vb->fd,"# [B] %f %f %f %f %f %f\n",
+ itom->r.x,itom->r.y,itom->r.z,
+ jtom->r.x,jtom->r.y,jtom->r.z);
+
+ return 0;
+}
+
+#ifdef VISUAL_THREAD
+void *visual_atoms(void *ptr) {
+#else
+int visual_atoms(t_moldyn *moldyn) {
+#endif
+
+ int i;
+ char file[128+64];
+ t_3dvec dim;
+ double help;
+ t_visual *v;
+ t_atom *atom;
+ t_vb vb;
+ t_3dvec strain;
+#ifdef VISUAL_THREAD
+ t_moldyn *moldyn;
+
+ moldyn=ptr;
+#endif
+
+ v=&(moldyn->vis);
+ dim.x=v->dim.x;
+ dim.y=v->dim.y;
+ dim.z=v->dim.z;
+ atom=moldyn->atom;
+
+ help=(dim.x+dim.y);
+
+ sprintf(file,"%s/atomic_conf_%08.f.xyz",v->fb,moldyn->time);
+ vb.fd=open(file,O_WRONLY|O_CREAT|O_TRUNC,S_IRUSR|S_IWUSR);
+ if(vb.fd<0) {
+ perror("open visual save file fd");
+#ifndef VISUAL_THREAD
+ return -1;
+#endif
+ }
+
+ /* write the actual data file */
+
+ // povray header
+ dprintf(vb.fd,"# [P] %d %08.f <%f,%f,%f>\n",
+ moldyn->count,moldyn->time,help/40.0,help/40.0,-0.8*help);
+
+ // atomic configuration
+ for(i=0;i<moldyn->count;i++) {
+ v3_sub(&strain,&(atom[i].r),&(atom[i].r_0));
+ check_per_bound(moldyn,&strain);
+ // atom type, positions, color and kinetic energy
+ dprintf(vb.fd,"%s %f %f %f %s %f\n",pse_name[atom[i].element],
+ atom[i].r.x,
+ atom[i].r.y,
+ atom[i].r.z,
+ pse_col[atom[i].element],
+ //atom[i].ekin);
+ sqrt(v3_absolute_square(&strain)));
+ }
+
+ // bonds between atoms
+#ifndef VISUAL_THREAD
+ process_2b_bonds(moldyn,&vb,visual_bonds_process);
+#endif
+
+ // boundaries
+ if(dim.x) {
+ dprintf(vb.fd,"# [D] %f %f %f %f %f %f\n",
+ -dim.x/2,-dim.y/2,-dim.z/2,
+ dim.x/2,-dim.y/2,-dim.z/2);
+ dprintf(vb.fd,"# [D] %f %f %f %f %f %f\n",
+ -dim.x/2,-dim.y/2,-dim.z/2,
+ -dim.x/2,dim.y/2,-dim.z/2);
+ dprintf(vb.fd,"# [D] %f %f %f %f %f %f\n",
+ dim.x/2,dim.y/2,-dim.z/2,
+ dim.x/2,-dim.y/2,-dim.z/2);
+ dprintf(vb.fd,"# [D] %f %f %f %f %f %f\n",
+ -dim.x/2,dim.y/2,-dim.z/2,
+ dim.x/2,dim.y/2,-dim.z/2);
+
+ dprintf(vb.fd,"# [D] %f %f %f %f %f %f\n",
+ -dim.x/2,-dim.y/2,dim.z/2,
+ dim.x/2,-dim.y/2,dim.z/2);
+ dprintf(vb.fd,"# [D] %f %f %f %f %f %f\n",
+ -dim.x/2,-dim.y/2,dim.z/2,
+ -dim.x/2,dim.y/2,dim.z/2);
+ dprintf(vb.fd,"# [D] %f %f %f %f %f %f\n",
+ dim.x/2,dim.y/2,dim.z/2,
+ dim.x/2,-dim.y/2,dim.z/2);
+ dprintf(vb.fd,"# [D] %f %f %f %f %f %f\n",
+ -dim.x/2,dim.y/2,dim.z/2,
+ dim.x/2,dim.y/2,dim.z/2);
+
+ dprintf(vb.fd,"# [D] %f %f %f %f %f %f\n",
+ -dim.x/2,-dim.y/2,dim.z/2,
+ -dim.x/2,-dim.y/2,-dim.z/2);
+ dprintf(vb.fd,"# [D] %f %f %f %f %f %f\n",
+ -dim.x/2,dim.y/2,dim.z/2,
+ -dim.x/2,dim.y/2,-dim.z/2);
+ dprintf(vb.fd,"# [D] %f %f %f %f %f %f\n",
+ dim.x/2,-dim.y/2,dim.z/2,
+ dim.x/2,-dim.y/2,-dim.z/2);
+ dprintf(vb.fd,"# [D] %f %f %f %f %f %f\n",
+ dim.x/2,dim.y/2,dim.z/2,
+ dim.x/2,dim.y/2,-dim.z/2);
+ }
+
+ close(vb.fd);
+
+#ifdef VISUAL_THREAD
+ pthread_exit(NULL);
+
+}
+#else
+
+ return 0;
+}
+#endif
+
+/*
+ * fpu cntrol functions
+ */
+
+// set rounding to double (eliminates -ffloat-store!)
+int fpu_set_rtd(void) {
+
+ fpu_control_t ctrl;
+
+ _FPU_GETCW(ctrl);
+
+ ctrl&=~_FPU_EXTENDED;
+ ctrl|=_FPU_DOUBLE;
+
+ _FPU_SETCW(ctrl);
+
+ return 0;
+}
+