c read_gadget_header.f c c read a gadget header with lenght unit Mpc c integer npart(6), !c1(6) + SF,Fb,Cool,nFiles,npartot1(6) !c3(10) double precision masses(6),aexpn,z, !c2(8) + box_dp, h,Lambda,Om !c4(4) integer*8 n32bit parameter ( n32bit=4294967296 ) integer*8 npartot(6) integer iflag_star, iflag_met, nallhigh(6) integer n_o_b ! number of bytes CHARACTER*120 snapshot write(*,*) 'which file' read(*,*) snapshot open (2, file =snapshot, + form = 'unformatted', STATUS = 'OLD') Read (2) npart, !c1 + masses,aexpn,z, !c2 + SF,Fb, npartot1, !c3 + Cool,nFiles,box_dp,Om,Lambda,h, !c4 + iflag_star, iflag_met, nallhigh ! print header informations write (*,'(a,f7.3,a,f6.1,a)') 'z =',z,' Box=', + box_dp,' h^-1 Mpc (GADGET unit is Mpc)' write(*,'(a,f7.4)') 'h = ',h write(*,'(a,f7.4)') 'aexpn = ',aexpn write(*,'(a,f6.3,a,f8.3)') 'Omega = ',OM,' Lambda = ',Lambda Do i = 1,6 masses(i) = masses(i)*1.E10 ENDDO if(npartot1(2).lt.0) then npartot(2) = (npartot1(3)+1)*n32bit + npartot1(2) else npartot(2) = npartot1(3)*n32bit + npartot1(2) endif write (*,'(a,e12.4,a)') 'm =',masses(2),' h^-1 M_sun' write(*,*) ' ' nn2 = INT( (FLOAT(npartot(2)))**0.333333 + 0.5 ) write(*,1234) npartot(2),nn2 1234 FORMAT('total number of particles =',I16,' = ',I5,'^3') IF(nFiles .gt. 1) THEN write(*,*) ' ' write(*,'(a,I6,a)') 'Output is divided into ',nFiles,' files.' write(*,'(a,I11,a)') 'this file contains ',npart(2),' particles' endif END