- snprintf(dir,128,"%s/s-%07.f.save",
+#ifdef PTHREADS
+ /* check whether thread has not terminated yet */
+ if(!first) {
+ ret=pthread_join(io_thread,NULL);
+ }
+ first=0;
+ /* prepare and start thread */
+ if(moldyn->count!=md_copy.count) {
+ free(atom_copy);
+ change=1;
+ }
+ memcpy(&md_copy,moldyn,sizeof(t_moldyn));
+ if(change) {
+ atom_copy=malloc(moldyn->count*sizeof(t_atom));
+ if(atom_copy==NULL) {
+ perror("[moldyn] malloc atom copy (change)");
+ return -1;
+ }
+ }
+ md_copy.atom=atom_copy;
+ memcpy(atom_copy,moldyn->atom,moldyn->count*sizeof(t_atom));
+ change=0;
+ ret=pthread_create(&io_thread,NULL,write_save_file,&md_copy);
+ if(ret) {
+ perror("[moldyn] create save file thread\n");
+ return -1;
+ }
+#else
+ snprintf(dir,128,"%s/s-%08.f.save",