| 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-2022 Daniel Price. All rights reserved. |
| 19 |
! Contact: [email protected] |
| 20 |
! |
| 21 |
!----------------------------------------------------------------- |
| 22 |
|
| 23 |
!------------------------------------------------------------------------- |
| 24 |
! Module containing settings and options related to the data read |
| 25 |
! includes default values of these options and submenu for changing them |
| 26 |
!------------------------------------------------------------------------- |
| 27 |
module options_data |
| 28 |
implicit none |
| 29 |
public :: submenu_data,defaults_set_data |
| 30 |
private |
| 31 |
|
| 32 |
contains |
| 33 |
|
| 34 |
!--------------------------------------------- |
| 35 |
! set default values for these options |
| 36 |
! (most should be set upon call to read_data) |
| 37 |
!--------------------------------------------- |
| 38 |
subroutine defaults_set_data |
| 39 |
use settings_data |
| 40 |
use params, only:maxplot |
| 41 |
integer :: i |
| 42 |
|
| 43 |
numplot=maxplot ! reset if read from file |
| 44 |
ncalc = 0 ! number of columns to calculate(e.g. radius) |
| 45 |
nextra = 0 ! extra plots aside from particle data |
| 46 |
ncolumns=maxplot-ncalc ! number of columns in data file |
| 47 |
ndataplots = ncolumns |
| 48 |
ndim = 0 ! number of coordinate dimensions |
| 49 |
ndimV = ndim ! default velocity same dim as coords |
| 50 |
istartatstep = 1 ! timestep to start from |
| 51 |
iendatstep = 1000 ! timestep to finish on |
| 52 |
nfreq = 1 ! frequency of timesteps to read |
| 53 |
icoords = 1 ! coordinate system of simulation |
| 54 |
iformat = 0 ! file format |
| 55 |
buffer_data = .false. |
| 56 |
buffer_steps_in_file = .false. |
| 57 |
iUseStepList = .false. |
| 58 |
do i=1,size(isteplist) |
| 59 |
isteplist(i) = i |
| 60 |
enddo |
| 61 |
iCalcQuantities = .false. |
| 62 |
DataIsBuffered = .false. |
| 63 |
iRescale = .false. |
| 64 |
enforce_code_units = .false. |
| 65 |
idefaults_file_read = .false. |
| 66 |
ivegotdata = .false. |
| 67 |
ntypes = 1 |
| 68 |
xorigin = 0. |
| 69 |
track_string = '0' ! particle tracking limits (none) |
| 70 |
ipartialread = .false. ! strictly unnecessary as set in get_data |
| 71 |
iverbose = 1 |
| 72 |
UseFakeDustParticles = .false. |
| 73 |
iautorender = 0 |
| 74 |
|
| 75 |
end subroutine defaults_set_data |
| 76 |
|
| 77 |
!---------------------------------------------------------------------- |
| 78 |
! sets options relating to current data |
| 79 |
! (read new data or change timesteps plotted) |
| 80 |
!---------------------------------------------------------------------- |
| 81 |
subroutine submenu_data(ichoose) |
| 82 |
use filenames, only:nsteps,nstepsinfile,ifileopen |
| 83 |
use prompting, only:prompt,print_logical |
| 84 |
use getdata, only:get_data |
| 85 |
use settings_data, only:buffer_data,iCalcQuantities,iRescale, & |
| 86 |
DataIsBuffered,numplot,ncalc,ncolumns,UseFakeDustParticles |
| 87 |
use calcquantities, only:calc_quantities,setup_calculated_quantities |
| 88 |
use limits, only:set_limits,rescale_limits |
| 89 |
use labels, only:label,unitslabel,labelzintegration,lenlabel,strip_units,idustfrac |
| 90 |
use settings_units, only:units,units_old,set_units,write_unitsfile,unitzintegration |
| 91 |
use fparser, only:rn,mu0 |
| 92 |
integer, intent(in) :: ichoose |
| 93 |
integer :: ians,i,ncalcwas,maxopt,len_max |
| 94 |
character(len=1) :: charp |
| 95 |
character(len=lenlabel) :: labeli,labelui |
| 96 |
logical :: UnitsHaveChanged,iRescaleprev,oldval |
| 97 |
|
| 98 |
ians = ichoose |
| 99 |
|
| 100 |
print "(a)",'----------------- data read options -------------------' |
| 101 |
|
| 102 |
if (ians <= 0 .or. ians > 3) then |
| 103 |
print 10, print_logical(iCalcQuantities), print_logical(iRescale) |
| 104 |
10 format( & |
| 105 |
' 0) exit ',/, & |
| 106 |
' 1) calculate extra quantities ( ',a,' )',/, & |
| 107 |
' 2) physical units on/off/edit ( ',a,' )') |
| 108 |
if (idustfrac > 0) then |
| 109 |
print & |
| 110 |
"(' 3) use fake dust particles ( ',a,' )')",print_logical(UseFakeDustParticles) |
| 111 |
maxopt = 3 |
| 112 |
else |
| 113 |
maxopt = 2 |
| 114 |
endif |
| 115 |
call prompt('enter option',ians,0,maxopt) |
| 116 |
endif |
| 117 |
! |
| 118 |
!--options |
| 119 |
! |
| 120 |
select case(ians) |
| 121 |
! case(2) |
| 122 |
! iUseStepList = .false. |
| 123 |
! call prompt('Start at timestep ',istartatstep,1,nsteps) |
| 124 |
! call prompt('End at timestep ',iendatstep,istartatstep,nsteps) |
| 125 |
! call prompt(' Frequency of steps to read',nfreq,1,nsteps) |
| 126 |
! print *,' Steps = ',(iendatstep-istartatstep+1)/nfreq |
| 127 |
! !------------------------------------------------------------------------ |
| 128 |
! case(3) |
| 129 |
! iUseStepList = .true. |
| 130 |
! istartatstep = 1 |
| 131 |
! nfreq = 1 |
| 132 |
! iendatstep = min(iendatstep,size(isteplist),nsteps) |
| 133 |
! call prompt('Enter number of steps to plot ', & |
| 134 |
! iendatstep,1,size(isteplist)) |
| 135 |
! do i=1,iendatstep |
| 136 |
! if (isteplist(i) <= 0 .or. isteplist(i) > nsteps) isteplist(i) = i |
| 137 |
! write(fmtstring,"(a,i2)") 'Enter step ',i |
| 138 |
! call prompt(fmtstring,isteplist(i),1,nsteps) |
| 139 |
! enddo |
| 140 |
case(1) |
| 141 |
ncalcwas = ncalc |
| 142 |
call setup_calculated_quantities(ncalc) |
| 143 |
|
| 144 |
iCalcQuantities = (ncalc > 0) |
| 145 |
if (iCalcQuantities) then |
| 146 |
if (DataIsBuffered) then |
| 147 |
call calc_quantities(1,nsteps) |
| 148 |
call set_limits(1,nsteps,ncolumns+ncalcwas+1,ncolumns+ncalc) |
| 149 |
else |
| 150 |
if (ifileopen > 0) then |
| 151 |
call calc_quantities(1,nstepsinfile(ifileopen)) |
| 152 |
call set_limits(1,nstepsinfile(ifileopen),ncolumns+ncalcwas+1,ncolumns+ncalc) |
| 153 |
endif |
| 154 |
endif |
| 155 |
else |
| 156 |
print "(/a)",' Calculation of extra quantities is '//print_logical(iCalcQuantities) |
| 157 |
endif |
| 158 |
!------------------------------------------------------------------------ |
| 159 |
case(2) |
| 160 |
print "(/,a,/)",' Current settings for physical units:' |
| 161 |
len_max = min(maxval(len_trim(label(:))),20) |
| 162 |
labeli = 'dz '//trim(labelzintegration) |
| 163 |
print "(2x,a,es10.3,a)",labeli(1:len_max+3)//' = ',unitzintegration,' x dz' |
| 164 |
labeli = 'time'//trim(unitslabel(0)) |
| 165 |
print "(' 0) ',a,es10.3,a)",labeli(1:len_max)//' = ',units(0),' x time' |
| 166 |
do i=1,ncolumns |
| 167 |
labeli = strip_units(label(i),unitslabel(i)) |
| 168 |
labelui = trim(labeli)//trim(unitslabel(i)) |
| 169 |
print "(i3,') ',a,es10.3,a)",i,labelui(1:len_max)//' = ',units(i),' x '//trim(labeli) |
| 170 |
enddo |
| 171 |
print "(a)" |
| 172 |
|
| 173 |
UnitsHaveChanged = .false. |
| 174 |
iRescaleprev = iRescale |
| 175 |
units_old = 1.d0 |
| 176 |
if (iRescale) units_old = units |
| 177 |
charp='y' |
| 178 |
if (iRescale) charp = 'n' |
| 179 |
call prompt('Use physical units? y)es, n)o, e)dit',charp,& |
| 180 |
list=(/'y','Y','n','N','e','E'/),noblank=.true.) |
| 181 |
select case(charp(1:1)) |
| 182 |
case('y','Y') |
| 183 |
iRescale = .true. |
| 184 |
case('e','E') |
| 185 |
call set_units(ncolumns,numplot,UnitsHaveChanged) |
| 186 |
if (.not.iRescale .and. UnitsHaveChanged) iRescale = .true. |
| 187 |
case default |
| 188 |
iRescale = .false. |
| 189 |
end select |
| 190 |
|
| 191 |
if ((iRescale .and..not. iRescaleprev) .or. (iRescaleprev .and..not.iRescale) & |
| 192 |
.or. UnitsHaveChanged) then |
| 193 |
if (iRescale) then |
| 194 |
mu0 = 12.566370614359_rn |
| 195 |
else |
| 196 |
mu0 = 1.0_rn |
| 197 |
endif |
| 198 |
if (buffer_data) then |
| 199 |
call get_data(-1,.true.) |
| 200 |
else |
| 201 |
call get_data(1,.true.,firsttime=.false.) |
| 202 |
endif |
| 203 |
if (iRescale) then |
| 204 |
call rescale_limits(fac=units(1:)/units_old(1:)) |
| 205 |
else ! switching from physical back to code units |
| 206 |
units_old = 1.d0 |
| 207 |
call rescale_limits(fac=units_old(1:)/units(1:)) |
| 208 |
endif |
| 209 |
endif |
| 210 |
case(3) |
| 211 |
oldval = UseFakeDustParticles |
| 212 |
call prompt( 'Use fake dust particles?',UseFakeDustParticles) |
| 213 |
! re-read data if option has changed |
| 214 |
if (UseFakeDustParticles .neqv. oldval) then |
| 215 |
if (buffer_data) then |
| 216 |
call get_data(-1,.true.) |
| 217 |
else |
| 218 |
call get_data(1,.true.,firsttime=.true.) |
| 219 |
endif |
| 220 |
endif |
| 221 |
end select |
| 222 |
|
| 223 |
end subroutine submenu_data |
| 224 |
|
| 225 |
end module options_data |