paravt icon indicating copy to clipboard operation
paravt copied to clipboard

Gadget 2 Incorrect Header format

Open DCunnama opened this issue 8 years ago • 6 comments

Hi there,

I've been trying to run paravt on a gadget snapshot but have been getting an error with the header format. I have tried a few different snapshots from different simulations. All Gadget2 binary format and am getting the same error.

Filename=/home/daniel/work/2016/data/cluster_00019/simulation/GadgetOWLS/FP_Aligned/snap_161 fileformat=2 BOX enabled. PERIODIC disabled. MULTIMASS disabled. WRITEASCII enabled. indices = 1 1 1 Reading Gadget file with particle type 0 ... incorrect header format Stop code...

Any ideas?

DCunnama avatar Sep 27 '16 13:09 DCunnama

Hi , i think there are 3 possible causes:

1- As far as i know OWLS used a modified gadget III format, probably the header structure is different, the header structure i use is from the standard gadget2 io routines:

https://github.com/regonzar/paravt/blob/master/vars.h#L60

2- The endianess of the OWLS file is big or little endian ordering? probably a byte swap is required.

3- Another cause may be OWLS use long ids, (for 1024+ ^3 particles), in the code is hardcoded 32bit integers, and some int should be replaced by longs.

regonzar avatar Sep 27 '16 13:09 regonzar

In this line the code check header consistency. https://github.com/regonzar/paravt/blob/master/iovt.c#L156

if (blk != 256 || blk2 != 256) { printf ("incorrect header format\n"); stopcode (); }

it would be more easy to understand the problem if you print blk and blk2 integers by replacing that line and show results.

printf ("incorrect header format blk=%d blk2=%d\n", blk, blk2);

regonzar avatar Sep 27 '16 14:09 regonzar

Here is the output for that:

incorrect header format blk=8 blk2=0

DCunnama avatar Sep 27 '16 14:09 DCunnama

it look like the file use long integers 64bit rather than 32bit integers.

can you replace L156 and157 to read long to check if that is the reason: https://github.com/regonzar/paravt/blob/master/iovt.c#L156

i.e long long blk,blk2; #define SKIP {fread(&blk,sizeof(long long),1,filein);} #define SKIP2 {fread(&blk2,sizeof(long long),1,filein);}

printf ("incorrect header format blk=%ld blk2=%ld\n", blk, blk2);

sorry i didnt implement the code for long gadget3 files, if you send me a sample of the file i can implement that, or you can try yourseft above modifications in block read size and probably some values in the header which are long long rather than int. Also the particles ID are probably long long aswell

regonzar avatar Sep 27 '16 15:09 regonzar

Hi,

Thanks it sounds like that is the most likely problem, I changed those lines but to no avail:

This code is intended for parallel run, using 1 processor may run slower than any other voronoi tessellation code due MPI overhead. Filename=/home/daniel/work/2016/data/cluster_00019/simulation/GadgetOWLS/FP_Aligned/snap_161 fileformat=2 BOX enabled. PERIODIC disabled. MULTIMASS disabled. WRITEASCII enabled. indices = 1 1 1 Reading Gadget file with particle type 0 ... incorrect header format blk=4918288443605254152 blk2=0 Stop code...

I have an example snapshot here if you wouldn't mind taking a look, it's quite big unfortunately. Sorry about this.

https://www.dropbox.com/s/m1muix04wn3qwsv/snap_161?dl=0

Thanks, Daniel

DCunnama avatar Sep 28 '16 11:09 DCunnama

Hi Daniel, i check your file and it is not a standard gadget file, it does not begin with the block size of the header. I checked byte ordering is ok and no long ids.

if you read the file you have the following before the header:

value type 8 4 bytes integer HEAD 4 bytes char 264 4 bytes integer 8 4 bytes integer 256 4 bytes integer >>> here the header of a typical gadget file begin .. .. .

if you skip the first 16 bytes of data, (by adding SKIP function 4 times before line 151) and cross fingers probably the rest of the file is a standard gadget file. If not, i recommend you to look for the specif format of your file which is clearly non standard gadget.

regonzar avatar Sep 28 '16 16:09 regonzar