| 1 |
!----------------------------------------------------------------- |
| 2 |
! |
| 3 |
! This file is (or was) part of SPLASH, a visualisation tool |
| 4 |
! for Smoothed Particle Hydrodynamics written by Daniel Price: |
| 5 |
! |
| 6 |
! http://users.monash.edu.au/~dprice/splash |
| 7 |
! |
| 8 |
! SPLASH comes with ABSOLUTELY NO WARRANTY. |
| 9 |
! This is free software; and you are welcome to redistribute |
| 10 |
! it under the terms of the GNU General Public License |
| 11 |
! (see LICENSE file for details) and the provision that |
| 12 |
! this notice remains intact. If you modify this file, please |
| 13 |
! note section 2a) of the GPLv2 states that: |
| 14 |
! |
| 15 |
! a) You must cause the modified files to carry prominent notices |
| 16 |
! stating that you changed the files and the date of any change. |
| 17 |
! |
| 18 |
! Copyright (C) 2005-2012 Daniel Price. All rights reserved. |
| 19 |
! Contact: [email protected] |
| 20 |
! |
| 21 |
!----------------------------------------------------------------- |
| 22 |
|
| 23 |
!------------------------------------------------------------------------- |
| 24 |
! this subroutine reads from the data file(s) |
| 25 |
! change this to change the format of data input |
| 26 |
! |
| 27 |
! THIS VERSION IS FOR READING UNFORMATTED OUTPUT FROM THE VINE CODE |
| 28 |
! (ie. STRAIGHT FROM THE DATA DUMP) |
| 29 |
! |
| 30 |
! *** CONVERTS TO SINGLE PRECISION *** |
| 31 |
! |
| 32 |
! SOME CHOICES FOR THIS FORMAT CAN BE SET USING THE FOLLOWING |
| 33 |
! COMMAND-LINE FLAGS: |
| 34 |
! |
| 35 |
! --mhd if set, reads MHD dump files |
| 36 |
! --hfac if set, multiplies the |
| 37 |
! smoothing lengths read from the file by a factor of 2.8 for |
| 38 |
! compatibility with older VINE dump files. |
| 39 |
! |
| 40 |
! the data is stored in the global array dat |
| 41 |
! |
| 42 |
! >> this subroutine must return values for the following: << |
| 43 |
! |
| 44 |
! ncolumns : number of data columns |
| 45 |
! ndim, ndimV : number of spatial, velocity dimensions |
| 46 |
! nstepsread : number of steps read from this file |
| 47 |
! |
| 48 |
! maxplot,maxpart,maxstep : dimensions of main data array |
| 49 |
! dat(maxplot,maxpart,maxstep) : main data array |
| 50 |
! |
| 51 |
! npartoftype(1:6,maxstep) : number of particles of each type in each timestep |
| 52 |
! |
| 53 |
! time(maxstep) : time at each step |
| 54 |
! gamma(maxstep) : gamma at each step |
| 55 |
! |
| 56 |
! most of these values are stored in global arrays |
| 57 |
! in the module 'particle_data' |
| 58 |
!------------------------------------------------------------------------- |
| 59 |
module vineread |
| 60 |
implicit none |
| 61 |
! |
| 62 |
! These are the indices of various values saved in |
| 63 |
! the header part of the dump file. |
| 64 |
! |
| 65 |
! SHOULD BE IDENTICAL TO THOSE DEFINED IN THE VINE io.F FILE... |
| 66 |
! |
| 67 |
integer,parameter::id_iheadlen= 1, id_npart = 2, id_npart_sph = 3 |
| 68 |
integer,parameter::id_nstep = 4, id_idump = 5, id_makechkpnt= 6 |
| 69 |
integer,parameter::id_idbg = 7, id_itme = 8, id_ibctype = 9 |
| 70 |
integer,parameter::id_indts =10, id_iusebin=11, id_ipres =12 |
| 71 |
integer,parameter::id_ipdv =13, id_ieos =14, id_icool =15 |
| 72 |
integer,parameter::id_iheat =16, id_ivisc =17, id_ivtime =18 |
| 73 |
integer,parameter::id_ibals =19, id_ishok =20, id_igrav =21 |
| 74 |
integer,parameter::id_isoft =22, id_imac =23, id_ihts =24 |
| 75 |
integer,parameter::id_iexpand =25, id_ncdumps=26, id_maxclumpsize=27 |
| 76 |
integer,parameter::id_intgrtr =28, id_ishift =29, id_ndim =30 |
| 77 |
integer,parameter::id_io_fmt =31, id_iunits =32, id_maxbunchsize=33 |
| 78 |
integer,parameter::id_npoim =34, id_ndt_ana=35, id_maxbuild =36 |
| 79 |
integer,parameter::id_fullextrap=37,id_revise=38, id_n_dtmax =39 |
| 80 |
integer,parameter::id_n_ana =40 |
| 81 |
integer,parameter::id_lastint1=41 !1 after last id for integers |
| 82 |
|
| 83 |
integer, parameter::id_t = 1,id_dtmax = 2,id_deltnew = 3 |
| 84 |
integer, parameter::id_gamma = 4,id_ekin = 5,id_egrav = 6 |
| 85 |
integer, parameter::id_etherm = 7,id_ascale = 8,id_cosbox = 9 |
| 86 |
integer, parameter::id_vlength =10,id_alfstar =11,id_betastar =12 |
| 87 |
integer, parameter::id_tol =13,id_cfl =14,id_dhmax =15 |
| 88 |
integer, parameter::id_treeacc =16,id_sepmax =17,id_hmin =18 |
| 89 |
integer, parameter::id_eps =19,id_dtinit =20,id_tstop =21 |
| 90 |
integer, parameter::id_dt_out =22,id_uconst =23,id_xmas =24 |
| 91 |
integer, parameter::id_ylen =25,id_umin =26,id_rcore =27 |
| 92 |
integer, parameter::id_h_0 =28,id_omegam =29,id_gmasslim =30 |
| 93 |
integer, parameter::id_hmax =31,id_uexpon =32,id_ftol =33 |
| 94 |
integer, parameter::id_clhfrac =34,id_xmin =35,id_xmax =36 |
| 95 |
integer, parameter::id_ymin =37,id_ymax =38,id_zmin =39 |
| 96 |
integer, parameter::id_zmax =40 |
| 97 |
integer, parameter::id_eosK =41,id_rhozero =42,id_ftolpm =43 |
| 98 |
integer, parameter::id_tolpm =44,id_tnextout=45,id_alfmax =46 |
| 99 |
integer, parameter::id_vtol =47,id_vtolpm =48,id_dtmin =49 |
| 100 |
integer, parameter::id_tlastout=50,id_dt_ana =51,id_bsepmax =52 |
| 101 |
integer, parameter::id_taucool =53 |
| 102 |
integer, parameter::id_lastreal1=54 !1 after last id for real numbers |
| 103 |
|
| 104 |
end module vineread |
| 105 |
|
| 106 |
module readdata_VINE |
| 107 |
implicit none |
| 108 |
|
| 109 |
public :: read_data_VINE, set_labels_VINE |
| 110 |
|
| 111 |
private |
| 112 |
contains |
| 113 |
|
| 114 |
|
| 115 |
subroutine read_data_VINE(rootname,indexstart,ipos,nstepsread) |
| 116 |
use particle_data, only:npartoftype,dat,time,gamma,maxcol,maxpart,maxstep |
| 117 |
use params, only:doub_prec |
| 118 |
use settings_data, only:ndim,ndimV,ncolumns,ncalc |
| 119 |
use labels, only:ivx, iBfirst,ih,ipmass |
| 120 |
use mem_allocation, only:alloc |
| 121 |
use system_utils, only:lenvironment |
| 122 |
use vineread, only:id_gamma,id_iheadlen,id_ndim,id_npart,id_npart_sph,& |
| 123 |
id_npoim,id_t |
| 124 |
integer, intent(in) :: indexstart,ipos |
| 125 |
integer, intent(out) :: nstepsread |
| 126 |
character(len=*), intent(in) :: rootname |
| 127 |
integer :: iheadlength |
| 128 |
integer :: i,j,ierr,nparti,ntoti,i1,icol |
| 129 |
integer :: npart_max,nstep_max,ncolstep,nptmass |
| 130 |
logical :: iexist,mhdread,useipindx |
| 131 |
character(len=len(rootname)+10) :: dumpfile |
| 132 |
integer, parameter :: maxheadlength = 1000 |
| 133 |
integer, dimension(maxheadlength) :: iheader |
| 134 |
integer, dimension(:), allocatable :: ipindx,itstepbin |
| 135 |
|
| 136 |
!--we are assuming dump is double precision |
| 137 |
real(doub_prec), dimension(maxheadlength) :: dheader |
| 138 |
real(doub_prec), dimension(:,:), allocatable :: dattemp, dattempvec |
| 139 |
real :: dum |
| 140 |
|
| 141 |
real :: hfactor |
| 142 |
|
| 143 |
nstepsread = 0 |
| 144 |
npart_max = maxpart |
| 145 |
!--this is the default header length |
| 146 |
iheadlength = maxheadlength |
| 147 |
|
| 148 |
dumpfile = trim(rootname) |
| 149 |
! |
| 150 |
!--check if first data file exists |
| 151 |
! |
| 152 |
inquire(file=dumpfile,exist=iexist) |
| 153 |
if (.not.iexist) then |
| 154 |
print "(a)",' *** error: '//trim(dumpfile)//': file not found ***' |
| 155 |
return |
| 156 |
endif |
| 157 |
! |
| 158 |
!--fix number of spatial dimensions |
| 159 |
! |
| 160 |
ndim = 3 |
| 161 |
ndimV = 3 |
| 162 |
mhdread = .false. |
| 163 |
if (lenvironment('VSPLASH_MHD') .or. lenvironment('VINE_MHD')) then |
| 164 |
mhdread = .true. |
| 165 |
endif |
| 166 |
if (lenvironment('VSPLASH_HFAC') .or. lenvironment('VINE_HFAC')) then |
| 167 |
hfactor = 2.8 |
| 168 |
else |
| 169 |
hfactor = 1.0 |
| 170 |
endif |
| 171 |
nstep_max = max(indexstart,1) |
| 172 |
|
| 173 |
j = indexstart |
| 174 |
nstepsread = 0 |
| 175 |
nparti = 0 |
| 176 |
ncolstep = 0 |
| 177 |
|
| 178 |
write(*,"(26('>'),1x,a,1x,26('<'))") trim(dumpfile) |
| 179 |
if (mhdread) then |
| 180 |
print "(a)",' reading VINE MHD format' |
| 181 |
else |
| 182 |
print "(a)",' reading default VINE format (set --mhd for MHD)' |
| 183 |
endif |
| 184 |
! |
| 185 |
!--open the (unformatted) binary file and read the number of particles |
| 186 |
! |
| 187 |
open(unit=15,iostat=ierr,file=dumpfile,status='old',form='unformatted') |
| 188 |
if (ierr /= 0) then |
| 189 |
print "(a)",'*** ERROR OPENING '//trim(dumpfile)//' ***' |
| 190 |
else |
| 191 |
! |
| 192 |
!--read timestep header (integers only) |
| 193 |
! |
| 194 |
read(15,iostat=ierr) (iheader(i),i=1,iheadlength) |
| 195 |
! |
| 196 |
!--get number of particles from header and allocate memory |
| 197 |
! |
| 198 |
iheadlength = iheader(id_iheadlen) |
| 199 |
if (iheadlength > maxheadlength) print "(a)",' ERROR: header length too big!' |
| 200 |
ntoti = iheader(id_npart ) |
| 201 |
nparti = iheader(id_npart_sph) |
| 202 |
nptmass = iheader(id_npoim ) |
| 203 |
ndim = iheader(id_ndim ) |
| 204 |
if (ntoti < nparti) then |
| 205 |
print*,' *** WARNING: ntotal < npart_sph in header, setting n_total=n_sph' |
| 206 |
ntoti = nparti |
| 207 |
endif |
| 208 |
if (nptmass < 0) then |
| 209 |
print*,' *** WARNING: error in nptmass read from header, nptmass = ',nptmass,' setting to 0' |
| 210 |
nptmass = 0 |
| 211 |
endif |
| 212 |
if (nparti <= 0) then |
| 213 |
print*,' *** WARNING: error in npart read from header, npart = ',nparti |
| 214 |
ierr = 2 |
| 215 |
endif |
| 216 |
if (ndim <= 0 .or. ndim > 3) then |
| 217 |
print*,' *** WARNING: error in ndim read from header, ndim = ',ndim |
| 218 |
ierr = 1 |
| 219 |
endif |
| 220 |
|
| 221 |
ndimV = ndim |
| 222 |
if (ndim /= 3) print "(a,i1)",' number of dimensions = ',ndim |
| 223 |
if (mhdread) then |
| 224 |
ncolstep = 2*ndim + 6 + ndim |
| 225 |
else |
| 226 |
ncolstep = 2*ndim + 6 |
| 227 |
endif |
| 228 |
ncolumns = ncolstep |
| 229 |
if ((.not.allocated(dat) .or. ntoti+nptmass > npart_max) .and. ierr==0) then |
| 230 |
if (.not.allocated(dat)) then |
| 231 |
npart_max = ntoti + nptmass |
| 232 |
else |
| 233 |
npart_max = max(npart_max,INT(1.1*(ntoti+nptmass))) |
| 234 |
endif |
| 235 |
call alloc(npart_max,nstep_max,ncolstep+ncalc) |
| 236 |
endif |
| 237 |
! |
| 238 |
!--rewind file |
| 239 |
! |
| 240 |
rewind(15) |
| 241 |
endif |
| 242 |
if (ierr /= 0) then |
| 243 |
print "(/,a)", ' *** ERROR READING TIMESTEP HEADER: wrong endian? ***' |
| 244 |
print "(/,a)", ' (see splash userguide for compiler-dependent' |
| 245 |
print "(a)", ' ways to change endianness on the command line)' |
| 246 |
print "(/,a,/)", ' (set --mhd if you are trying to read MHD format)' |
| 247 |
else |
| 248 |
|
| 249 |
npart_max = max(npart_max,ntoti) |
| 250 |
! |
| 251 |
!--allocate/reallocate memory if j > maxstep |
| 252 |
! |
| 253 |
if (j > maxstep) then |
| 254 |
call alloc(maxpart,j+2*nstepsread,maxcol) |
| 255 |
endif |
| 256 |
! |
| 257 |
!--allocate a temporary array for double precision variables |
| 258 |
! |
| 259 |
if (allocated(dattemp)) deallocate(dattemp) |
| 260 |
allocate(dattemp(npart_max,ncolstep),stat=ierr) |
| 261 |
dattemp = 0. |
| 262 |
if (ierr /= 0) print*,'not enough memory in read_data_VINE (dattemp)' |
| 263 |
! |
| 264 |
!--allocate a temporary array for vectors |
| 265 |
! |
| 266 |
if (allocated(dattempvec)) deallocate(dattempvec) |
| 267 |
if (mhdread) then |
| 268 |
allocate(dattempvec(3*ndim+1,npart_max),stat=ierr) |
| 269 |
else |
| 270 |
allocate(dattempvec(2*ndim+1,npart_max),stat=ierr) |
| 271 |
endif |
| 272 |
dattempvec = 0. |
| 273 |
if (ierr /= 0) print*,'not enough memory in read_data_VINE (dattempvec)' |
| 274 |
! |
| 275 |
!--allocate a temporary array for particle index |
| 276 |
! |
| 277 |
if (allocated(ipindx)) deallocate(ipindx) |
| 278 |
allocate(ipindx(npart_max),stat=ierr) |
| 279 |
!ipindx = 0 |
| 280 |
if (ierr /= 0) print*,'not enough memory in read_data_VINE (ipindx)' |
| 281 |
! |
| 282 |
!--allocate a temporary array for itstepbin (MHD or point masses only) |
| 283 |
! |
| 284 |
if (mhdread .or. nptmass > 0) then |
| 285 |
if (allocated(itstepbin)) deallocate(itstepbin) |
| 286 |
allocate(itstepbin(npart_max),stat=ierr) |
| 287 |
!itstepbin = 0 |
| 288 |
if (ierr /= 0) print*,'not enough memory in read_data_VINE (itstepbin)' |
| 289 |
endif |
| 290 |
! |
| 291 |
!--now read the timestep data in the dumpfile |
| 292 |
! |
| 293 |
write(*,"(a,i5,a)",advance="no") '| step ',j,': ' |
| 294 |
|
| 295 |
ivx = ndim + 2 ! location of vx in 'columns' |
| 296 |
! starting point for non position and velocity columns |
| 297 |
icol = ndim + 1 + ndimV + 1 |
| 298 |
|
| 299 |
if (mhdread) then |
| 300 |
if (nptmass > 0) then |
| 301 |
print "(a)",' WARNING: MHD format but point masses are present' |
| 302 |
print "(a)",' and reading of point masses is not implemented' |
| 303 |
print "(a)",' *** Please email a copy of io.F so I can fix this *** ' |
| 304 |
endif |
| 305 |
iBfirst = icol+5 |
| 306 |
read(15,iostat=ierr) & |
| 307 |
(iheader(i),i=1,iheadlength), & |
| 308 |
(dheader(i),i=1,iheadlength), & |
| 309 |
(dattempvec(1:ndim+1,i),i=1,ntoti), & |
| 310 |
(dattempvec(ivx:ivx+ndimV-1,i),i=1,ntoti), & |
| 311 |
(dattemp(i,icol), i=1,ntoti), & |
| 312 |
(dattemp(i,icol+1), i=1,nparti), & |
| 313 |
(dattemp(i,icol+2), i=1,nparti), & |
| 314 |
(dattemp(i,icol+3), i=1,nparti), & |
| 315 |
(dattemp(i,icol+4), i=1,ntoti), & |
| 316 |
(ipindx(i), i=1,ntoti), & |
| 317 |
(itstepbin(i),i=1,ntoti), & |
| 318 |
(dattempvec(ivx+ndimV:ivx+2*ndimV-1,i),i=1,nparti) |
| 319 |
else |
| 320 |
if (nptmass > 0) then |
| 321 |
! |
| 322 |
!--read point mass information at the end of the dump file |
| 323 |
! |
| 324 |
read(15,iostat=ierr) & |
| 325 |
(iheader(i),i=1,iheadlength), & |
| 326 |
(dheader(i),i=1,iheadlength), & |
| 327 |
(dattempvec(1:ndim+1,i),i=1,ntoti), & |
| 328 |
(dattempvec(ivx:ivx+ndimV-1,i),i=1,ntoti), & |
| 329 |
(dattemp(i,icol), i=1,ntoti), & |
| 330 |
(dattemp(i,icol+1), i=1,nparti), & |
| 331 |
(dattemp(i,icol+2), i=1,nparti), & |
| 332 |
(dattemp(i,icol+3), i=1,nparti), & |
| 333 |
(dattemp(i,icol+4), i=1,ntoti), & |
| 334 |
(ipindx(i), i=1,ntoti), & |
| 335 |
(dum, i=1,nparti), & |
| 336 |
(itstepbin(i), i=1,ntoti), & |
| 337 |
(dattempvec(1:ndim+1,i),i=ntoti+1,ntoti+nptmass), & |
| 338 |
(dattempvec(ivx:ivx+ndimV-1,i),i=ntoti+1,ntoti+nptmass), & |
| 339 |
((dum, i1=1,3),i=1,nptmass), & |
| 340 |
(dattemp(i,icol), i=ntoti+1,ntoti+nptmass) |
| 341 |
else |
| 342 |
! |
| 343 |
!--no point masses, so shorter read |
| 344 |
! |
| 345 |
read(15,iostat=ierr) & |
| 346 |
(iheader(i),i=1,iheadlength), & |
| 347 |
(dheader(i),i=1,iheadlength), & |
| 348 |
(dattempvec(1:ndim+1,i),i=1,ntoti), & |
| 349 |
(dattempvec(ivx:ivx+ndimV-1,i),i=1,ntoti), & |
| 350 |
(dattemp(i,icol), i=1,ntoti), & |
| 351 |
(dattemp(i,icol+1), i=1,nparti), & |
| 352 |
(dattemp(i,icol+2), i=1,nparti), & |
| 353 |
(dattemp(i,icol+3), i=1,nparti), & |
| 354 |
(dattemp(i,icol+4), i=1,ntoti), & |
| 355 |
(ipindx(i), i=1,ntoti) |
| 356 |
endif |
| 357 |
endif |
| 358 |
|
| 359 |
if (ierr < 0) then |
| 360 |
print "(a)",'*** END OF FILE IN READ DATA ***' |
| 361 |
elseif (ierr /= 0) then |
| 362 |
if (mhdread) then |
| 363 |
print "(a)",'*** ERROR READING DATA: MAYBE NOT AN MHD FILE?? ***' |
| 364 |
else |
| 365 |
print "(a)",'*** ERROR READING DATA ***' |
| 366 |
print "(/,a,/)", ' (set --mhd if you are trying to read MHD format)' |
| 367 |
endif |
| 368 |
endif |
| 369 |
nstepsread = nstepsread + 1 |
| 370 |
! |
| 371 |
!--spit out time |
| 372 |
! |
| 373 |
time(j) = real(dheader(id_t )) |
| 374 |
gamma(j) = real(dheader(id_gamma)) |
| 375 |
print "(a,es10.3,3(a,i8))",'t = ',time(j),' n(SPH) = ',ntoti,' n(Nbody) = ',ntoti-nparti,' n(star) = ',nptmass |
| 376 |
! |
| 377 |
!--check sanity of ipindx array: do not sort particles if values not sensible |
| 378 |
! |
| 379 |
useipindx = .true. |
| 380 |
if (any(ipindx(1:ntoti) <= 0 .or. ipindx(1:ntoti) > ntoti)) then |
| 381 |
print*,'WARNING: ipindx array has values < 0 or > ntot: particles not sorted' |
| 382 |
useipindx = .false. |
| 383 |
endif |
| 384 |
! |
| 385 |
!--convert posm and velocity vectors to columns and double to single precision |
| 386 |
! |
| 387 |
do i=1,2*ndim+1 |
| 388 |
if (useipindx) then |
| 389 |
dat(ipindx(1:ntoti),i,j) = real(dattempvec(i,1:ntoti)) |
| 390 |
else |
| 391 |
dat(1:ntoti,i,j) = real(dattempvec(i,1:ntoti)) |
| 392 |
endif |
| 393 |
enddo |
| 394 |
if (nptmass > 0) then |
| 395 |
do i=1,2*ndim+1 |
| 396 |
dat(ntoti+1:ntoti+nptmass,i,j) = real(dattempvec(i,ntoti+1:ntoti+nptmass)) |
| 397 |
enddo |
| 398 |
endif |
| 399 |
! |
| 400 |
!--convert B vectors to columns and double to single precision |
| 401 |
! |
| 402 |
if (mhdread) then |
| 403 |
i1 = iBfirst - 1 |
| 404 |
do i=ivx+ndimV,ivx+2*ndimV-1 |
| 405 |
i1 = i1 + 1 |
| 406 |
if (useipindx) then |
| 407 |
dat(ipindx(1:nparti),i1,j) = real(dattempvec(i,1:nparti)) |
| 408 |
else |
| 409 |
dat(1:nparti,i1,j) = real(dattempvec(i,1:nparti)) |
| 410 |
endif |
| 411 |
enddo |
| 412 |
endif |
| 413 |
! |
| 414 |
!--now convert scalars |
| 415 |
! |
| 416 |
if (useipindx) then |
| 417 |
dat(ipindx(1:ntoti),icol:ncolstep,j) = real(dattemp(1:ntoti,icol:ncolstep)) |
| 418 |
else |
| 419 |
dat(1:ntoti,icol:ncolstep,j) = real(dattemp(1:ntoti,icol:ncolstep)) |
| 420 |
endif |
| 421 |
if (nptmass > 0) then |
| 422 |
dat(ntoti+1:ntoti+nptmass,icol,j) = real(dattemp(ntoti+1:ntoti+nptmass,icol)) |
| 423 |
endif |
| 424 |
|
| 425 |
call set_labels_VINE |
| 426 |
if (ih > 0 .and. hfactor > 1.0) then |
| 427 |
dat(1:ntoti+nptmass,ih,j) = hfactor*dat(1:ntoti+nptmass,ih,j) |
| 428 |
endif |
| 429 |
|
| 430 |
if (nptmass < 10) then |
| 431 |
do i=1,nptmass |
| 432 |
if (ndim==2) then |
| 433 |
print "('| point mass ',i1,': pos = (',es10.2,',',es10.2,'), mass = ',es10.2)", & |
| 434 |
i,dat(ntoti+i,1:ndim,j),dat(ntoti+i,ipmass,j) |
| 435 |
else |
| 436 |
print "('| point mass ',i1,': pos = (',2(es10.2,','),es10.2,'), mass = ',es10.2)", & |
| 437 |
i,dat(ntoti+i,1:ndim,j),dat(ntoti+i,ipmass,j) |
| 438 |
endif |
| 439 |
enddo |
| 440 |
endif |
| 441 |
|
| 442 |
! |
| 443 |
!--set particle numbers |
| 444 |
! |
| 445 |
npartoftype(1,j) = nparti |
| 446 |
npartoftype(2,j) = ntoti - nparti |
| 447 |
npartoftype(3,j) = nptmass |
| 448 |
! |
| 449 |
!--clean up |
| 450 |
! |
| 451 |
if (allocated(dattemp)) deallocate(dattemp) |
| 452 |
if (allocated(dattempvec)) deallocate(dattempvec) |
| 453 |
if (allocated(ipindx)) deallocate(ipindx) |
| 454 |
if (allocated(itstepbin)) deallocate(itstepbin) |
| 455 |
|
| 456 |
endif |
| 457 |
|
| 458 |
! |
| 459 |
!--reached end of file |
| 460 |
! |
| 461 |
close(15) |
| 462 |
if (nstepsread > 0) then |
| 463 |
print*,'>> end of dump file: ntotal = ',sum(npartoftype(:,j)) |
| 464 |
endif |
| 465 |
|
| 466 |
|
| 467 |
return |
| 468 |
|
| 469 |
end subroutine read_data_VINE |
| 470 |
|
| 471 |
!!------------------------------------------------------------ |
| 472 |
!! set labels for each column of data |
| 473 |
!!------------------------------------------------------------ |
| 474 |
|
| 475 |
subroutine set_labels_VINE |
| 476 |
use labels, only:label,ih,ipmass,ivx,iutherm,irho,ix,iBfirst, & |
| 477 |
labelvec,iamvec,labeltype |
| 478 |
use params |
| 479 |
use settings_data, only:ndim,ndimV,UseTypeInRenderings,ntypes |
| 480 |
use geometry, only:labelcoord |
| 481 |
integer :: i |
| 482 |
|
| 483 |
if (ndim <= 0 .or. ndim > 3) then |
| 484 |
print*,'*** ERROR: ndim = ',ndim,' in set_labels_VINE ***' |
| 485 |
return |
| 486 |
endif |
| 487 |
if (ndimV <= 0 .or. ndimV > 3) then |
| 488 |
print*,'*** ERROR: ndimV = ',ndimV,' in set_labels_VINE ***' |
| 489 |
return |
| 490 |
endif |
| 491 |
|
| 492 |
do i=1,ndim |
| 493 |
ix(i) = i |
| 494 |
enddo |
| 495 |
ipmass = ndim+1 ! particle mass |
| 496 |
ivx = ndim+2 |
| 497 |
|
| 498 |
ih = ndim + 1 + ndimV + 1 ! smoothing length |
| 499 |
iutherm = ih+1 ! thermal energy |
| 500 |
irho = iutherm+1 ! location of rho in data array |
| 501 |
|
| 502 |
label(ix(1:ndim)) = labelcoord(1:ndim,1) |
| 503 |
label(irho) = 'density' |
| 504 |
label(iutherm) = 'u' |
| 505 |
label(ih) = 'h' |
| 506 |
label(ipmass) = 'particle mass' |
| 507 |
label(irho+1) = 'alpha' |
| 508 |
label(irho+2) = 'potential energy' |
| 509 |
! |
| 510 |
!--set labels for vector quantities |
| 511 |
! |
| 512 |
iamvec(ivx:ivx+ndimV-1) = ivx |
| 513 |
labelvec(ivx:ivx+ndimV-1) = 'v' |
| 514 |
do i=1,ndimV |
| 515 |
label(ivx+i-1) = trim(labelvec(ivx))//'\d'//labelcoord(i,1) |
| 516 |
enddo |
| 517 |
if (iBfirst > 0) then |
| 518 |
iamvec(iBfirst:iBfirst+ndimV-1) = iBfirst |
| 519 |
labelvec(iBfirst:iBfirst+ndimV-1) = 'B' |
| 520 |
do i=1,ndimV |
| 521 |
label(iBfirst+i-1) = trim(labelvec(iBfirst))//'\d'//labelcoord(i,1) |
| 522 |
enddo |
| 523 |
endif |
| 524 |
! |
| 525 |
!--set labels for each particle type |
| 526 |
! |
| 527 |
ntypes = 3 |
| 528 |
labeltype(1) = 'gas' |
| 529 |
labeltype(2) = 'Nbody' |
| 530 |
labeltype(3) = 'point mass' |
| 531 |
UseTypeInRenderings(1) = .true. |
| 532 |
UseTypeInRenderings(2) = .false. |
| 533 |
UseTypeInRenderings(3) = .false. |
| 534 |
|
| 535 |
!----------------------------------------------------------- |
| 536 |
|
| 537 |
return |
| 538 |
end subroutine set_labels_VINE |
| 539 |
end module readdata_VINE |