This HTML automatically generated with rman for NEMO
Table of Contents

Name

snapidl - tabulate a snapshot for IDL in binary mode

Synopsis

snapidl [parameter=value]

Description

snapidl outputs selected particle variables in binary format (e.g. for IDL or fortran unformatted read’s) The output format is a local host binary format(see snapprint(1NEMO) for an ascii table version), and should only be used on that local host to prevent endianism and floating point format conversion problems. See examples below on how to read the binary data into IDL and fortran.

Note that this program write all variables as float (single precision), including integers.

For an alternative approach, use snappat(1NEMO) to create a Particle-Attribute-Time datacube, convert this to FITS using ccdfits(1NEMO) and read this into IDL. For simulations with a large number of snapshots this can be significantly faster.

Parameters

The following parameters are recognized in any order if the keyword is also given:
in=file
Input file (snapshot). No default.
options=
Things to output [x,y,z,vx,vy,vz]
times=t1,t2,...
Times to select snapshot [all]
out=file
Output file - normally a pipe for IDL. [Default: -]
fortran=t|f
Attempt to format the binary data suitable for a series of FORTRAN unformatted READ’s. [Default: f]
header=0|4|8|
Header size in bytes that unformatted files use. Default: 4

Format

The output format is binary encoded, and only meant to be transported to other machines (e.g. is uses the local host format).
Nb,T1,Nv,v1,v2,v3,....v_Nv,Nb,T2,Nv,v1,v2,v3,....v_Nv,....
where Nb is the number of bodies and Nv the number of vectors of length Nb each.

Examples

Here is an example to dump all positions of the particles at time 1.0 to a pipe, which is then read by IDL into arrays x,y,z.
mkplummer snap000 100
idl
IDL> SPAWN, [’snapidl’,’snap000’,’x,y,z’], UNIT=LUN, /NOSHELL
IDL> nbody=0L
IDL> nvec=0L 
IDL> READU,LUN,nbody,nvec,tsnap
IDL> PRINT,"Found a snapshot with ",nbody," particles at time", tsnap
IDL> x=FLTARR(nbody)
IDL> y=FLTARR(nbody)
IDL> z=FLTARR(nbody)
IDL> READU,LUN,x,y,z
IDL> FREE_LUN, LUN

And here is an example writing the data in a format that can be read with a fortran program:

mkplummer snap111 100 
snapidl snap111 x,y,z out=snap111.dat fortran=t
idl
IDL> OPENR,LUN,’snap111.dat’,/F77_UNFORMATTED,/GET_LUN
IDL> nbody=0L
IDL> nvec=0L 
IDL> READU,LUN,nbody,nvec,tsnap
IDL> PRINT,"Found a snapshot with ",nbody," particles at time", tsnap
IDL> x=FLTARR(nbody)
IDL> y=FLTARR(nbody)
IDL> z=FLTARR(nbody)
IDL> READU,LUN,x
IDL> READU,LUN,y
IDL> READU,LUN,z
IDL> FREE_LUN, LUN
In fortran, without any error control and array overflow checking, snap111.dat can also be read as follows:
    program snapread
    real x(1000),y(1000),z(1000),tsnap
    integer nbody,nvec,i
    open(1,file=’snap111.dat’,form=’unformatted’)
    read(1) nbody,nvec,tsnap
    read(1) (x(i),i=1,nbody)
    read(1) (y(i),i=1,nbody)
    read(1) (z(i),i=1,nbody)
    end

Caveat

Some versions of IDL (e.g. 6.3) do not properly read/write 8 byte headers where needed on 64 bit systems. See also unfio(1NEMO) for a description.

Careful cutting and pasting examples from man pages, hidden characters can slip unseen into your session.

See Also

snapprint(1NEMO) , snappat(1NEMO) , unfio(1NEMO) , snapshot(5NEMO) ,

Files

src/nbody/io    - snapidl.c

Author

Peter Teuben

Update History


26-Nov-02    V1.0 Created    PJT
5-aug-09    it seems IDL now needs /GET_LUN in the 2nd example
6-aug-09    V1.2 added header=    PJT


Table of Contents