5. Formats

Thanks to the interpreted facilities of python, pNbody may read any file format. You simply have to decribe it in a python file placed in your  /.Nbody/formats directory. This python file declares a new class that inherit all atributes of the default pNbody class.

As an example, we will describe here after, how to write a file that reads the format written by the following Fortan instructions :

  INTEGER	  NBODY,NGAS,NSTARS
  REAL*4	  TNOW
  REAL*4	  POS(3,MXBODY),VEL(3,MXBODY),MAS(MXBOFY), MET(MXBOFY)
  INTEGER	  K,P	  

  OPEN (UNIT=1,FILE='simpleformat.dat',FORM='UNFORMATTED', STATUS='UNKNOWN')
  WRITE (1) TNOW,NGAS,NSTAR
  WRITE (1) ((POS(K,P), K=1,3),P=1,NBODY)
  WRITE (1) ((VEL(K,P), K=1,3),P=1,NBODY)
  WRITE (1) (MAS(P),	       P=1,NBODY)
  WRITE (1) (MET(P),	       P=1,NGAS)
  CLOSE(UNIT=1)

The file consists of a header block (TNOW,NGAS,NSTAR), a position block of size 3 NBODY, a velocity block of size 3 NBODY, a mass block of size NBODY and a metallicity block of size NGAS.



Subsections
See About this document... for information on suggesting changes.