[gmx-users] trajectory file problem
Bert de Groot
bgroot at gwdg.de
Mon Jan 27 14:08:25 CET 2003
Anton Feenstra wrote:
>
> David van der Spoel wrote:
> > If you feel like making a repair tool, you'd have to make something that
> > reads a binary file and looks for integers with value 1995. In contrast
> > to what Anton said, the possibility of finding a number like that by
> > accident is 1/2^32, or one in a billion.
>
> That's a Gigabyte, should still be good enough. I know someone in Groningen
> who successfully recovered (part of) his trajectory that way. His one got
> maimed by nfs dropping a packet somewere. The tool was lost, however, before
> we could add it to the Gromacs source...
>
I found the following source code with the promising name 'gmx_rescue.c'. Don't
remember how I got it or if it works though....
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
void main(int argc, char *argv[]) {
int f, out;
int value;
int res;
char buf[1024*32];
if (argc!=3) {
fprintf(stderr, "usage: %s <filename> <rescue file>\n", argv[0]);
}
f = open(argv[1], O_RDONLY);
if (f == -1) {
perror("couldn't open file");
}
lseek(f, 2287*66000, SEEK_SET);
while (read(f, &value, 4) == 4 && value != 1995) {
;
}
printf("postion %ld \n", (long)tell(f)-4);
out=open(argv[2], O_WRONLY | O_CREAT, 0666);
write(out, &value, 4);
while ((res = read(f, buf, 1024*32)) > 0) {
write(out, buf, res);
}
}
--
Bert
____________________________________________________________________________
Dr. Bert de Groot
Max Planck Institute for Biophysical Chemistry
Theoretical molecular biophysics group
Am Fassberg 11
37077 Goettingen, Germany
tel: +49-551-2011306, fax: +49-551-2011089
email: bgroot at gwdg.de
http://www.mpibpc.gwdg.de/abteilungen/071/bgroot
____________________________________________________________________________
More information about the gromacs.org_gmx-users
mailing list