init testing
[physik/posic.git] / visual / visual.c
index 6ad527a..ce4ceaf 100644 (file)
@@ -25,7 +25,7 @@ int visual_init(t_visual *v,char *filebase) {
        memset(file,0,128+8);
        sprintf(file,"%s.scr",v->fb);
 
-       v->fd=open(file,O_WRONLY);
+       v->fd=open(file,O_WRONLY|O_CREAT|O_TRUNC);
        if(v->fd<0) {
                perror("open visual fd");
                return -1;
@@ -69,7 +69,7 @@ int visual_atoms(t_visual *v,double time,t_atom *atom,int n) {
        };
 
        sprintf(file,"%s-%.15f.xyz",v->fb,time);
-       fd=open(file,O_WRONLY);
+       fd=open(file,O_WRONLY|O_CREAT|O_TRUNC);
        if(fd<0) {
                perror("open visual save file fd");
                return -1;
@@ -87,8 +87,8 @@ int visual_atoms(t_visual *v,double time,t_atom *atom,int n) {
        dprintf(v->fd,"zap\n");
 
        /* write the actual data file */
-       dprintf(fd,"Atoms at time %.15f\n",time);
        dprintf(fd,"%d\n",n);
+       dprintf(fd,"atoms at time %.15f\n",time);
        for(i=0;i<n;i++)
                dprintf(fd,"%s %f %f %f\n",pse[atom[i].element],
                                           atom[i].r.x,atom[i].r.y,atom[i].r.z);