| 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-2020 Daniel Price. All rights reserved. |
| 19 |
! Contact: [email protected] |
| 20 |
! |
| 21 |
!----------------------------------------------------------------- |
| 22 |
module set_options_from_dataread |
| 23 |
implicit none |
| 24 |
|
| 25 |
contains |
| 26 |
|
| 27 |
subroutine set_options_dataread() |
| 28 |
use exact, only:read_exactparams |
| 29 |
use settings_part, only:iplotpartoftype,PlotonRenderings |
| 30 |
use particle_data, only:npartoftype |
| 31 |
use settings_data, only:ndim,ncolumns,ncalc,ntypes,iexact,iverbose,UseTypeInRenderings,& |
| 32 |
idefaults_file_read,iCalcQuantities,DataIsBuffered |
| 33 |
use filenames, only:rootname,nsteps,nstepsinfile,ifileopen,fileprefix |
| 34 |
use labels, only:labeltype,irho,ih,get_sink_type |
| 35 |
use asciiutils, only:ucase |
| 36 |
use settings_render, only:icolour_particles |
| 37 |
use settings_xsecrot, only:xsec_nomulti |
| 38 |
use calcquantities, only:print_example_quantities,calc_quantities |
| 39 |
use limits, only:set_limits |
| 40 |
integer :: itype,nplot,ierr,idash |
| 41 |
logical :: iexist |
| 42 |
! |
| 43 |
!--check for errors in data read / print warnings |
| 44 |
! |
| 45 |
if (ndim > 0 .and. ncolumns > 0 .and. nsteps > 0 .and. .not.idefaults_file_read) then |
| 46 |
if (sum(npartoftype(:,1)) > 0 .and. npartoftype(1,1)==0 .and. .not.any(iplotpartoftype(2:))) then |
| 47 |
if (iverbose >= 1) print "(/,a)",' WARNING! DATA APPEARS TO CONTAIN NO '//trim(ucase(labeltype(1)))//' PARTICLES' |
| 48 |
itype = 0 |
| 49 |
nplot = 0 |
| 50 |
do while (nplot==0 .and. itype < ntypes) |
| 51 |
itype = itype + 1 |
| 52 |
if (npartoftype(itype,1) > 0) then |
| 53 |
iplotpartoftype(itype) = .true. |
| 54 |
if (UseTypeInRenderings(itype)) nplot = nplot + npartoftype(itype,1) |
| 55 |
if (iverbose >= 1) print "(a)",' (plotting of '//trim(labeltype(itype))//' particles turned ON)' |
| 56 |
endif |
| 57 |
enddo |
| 58 |
print* |
| 59 |
endif |
| 60 |
! Set particle colouring if it can't render |
| 61 |
if (irho==0 .or. ih==0) then |
| 62 |
icolour_particles = .true. |
| 63 |
endif |
| 64 |
endif |
| 65 |
! |
| 66 |
!--turn sink particles ON by default |
| 67 |
! |
| 68 |
if (ndim > 0 .and. .not.idefaults_file_read) then ! only on first data read |
| 69 |
itype = get_sink_type(ntypes) |
| 70 |
if (itype > 0) then |
| 71 |
if (npartoftype(itype,1) > 0 .and. .not.UseTypeInRenderings(itype)) then |
| 72 |
iplotpartoftype(itype) = .true. |
| 73 |
PlotOnRenderings(itype) = .true. |
| 74 |
endif |
| 75 |
endif |
| 76 |
endif |
| 77 |
|
| 78 |
!--for fits cubes, turn on cross section by default if 3D |
| 79 |
if (ndim >= 3 .and. .not.idefaults_file_read .and. ifileopen > 0) then ! only on first data read |
| 80 |
if (index(rootname(ifileopen),'.fits') > 0) then |
| 81 |
print "(a)",' turning cross section ON for fits cube' |
| 82 |
xsec_nomulti = .true. |
| 83 |
endif |
| 84 |
endif |
| 85 |
! |
| 86 |
!--read exact solution parameters from files if present |
| 87 |
! |
| 88 |
if (iexact /= 0) then |
| 89 |
if (ifileopen > 0) then |
| 90 |
call read_exactparams(iexact,rootname(ifileopen),ierr) |
| 91 |
endif |
| 92 |
elseif (.not.idefaults_file_read .and. ifileopen > 0) then |
| 93 |
! |
| 94 |
! set the exact solution option ON by default if |
| 95 |
! certain files are present |
| 96 |
! |
| 97 |
idash = index(rootname(ifileopen),'_',back=.true.) |
| 98 |
if (idash==0) idash = len_trim(rootname(ifileopen))+1 |
| 99 |
|
| 100 |
! functions if splash.func found |
| 101 |
inquire(file=trim(rootname(ifileopen))//'.func',exist=iexist) |
| 102 |
if (iexist) iexact = 1 |
| 103 |
|
| 104 |
inquire(file=trim(fileprefix)//'.exactfiles',exist=iexist) |
| 105 |
if (iexist) iexact = 2 |
| 106 |
|
| 107 |
! exact from file if stellar profile ascii file found |
| 108 |
inquire(file=trim(rootname(ifileopen)(1:idash-1))//'.profile',exist=iexist) |
| 109 |
if (iexist) then |
| 110 |
iexact = 2 |
| 111 |
call print_example_quantities(.true.,ncalc) |
| 112 |
iCalcQuantities = .true. |
| 113 |
if (DataIsBuffered) then |
| 114 |
call calc_quantities(1,nsteps) |
| 115 |
call set_limits(1,nsteps,ncolumns+1,ncolumns+ncalc) |
| 116 |
else |
| 117 |
if (ifileopen > 0) then |
| 118 |
call calc_quantities(1,nstepsinfile(ifileopen)) |
| 119 |
call set_limits(1,nstepsinfile(ifileopen),ncolumns+1,ncolumns+ncalc) |
| 120 |
endif |
| 121 |
endif |
| 122 |
endif |
| 123 |
|
| 124 |
! spiral arms exact solution if .spirals file present |
| 125 |
inquire(file=trim(rootname(ifileopen))//'.spirals',exist=iexist) |
| 126 |
if (iexist) iexact = 17 |
| 127 |
|
| 128 |
! flyby trajectory if .trajectory file found |
| 129 |
inquire(file=trim(rootname(ifileopen)(1:idash-1))//'.trajectory1',exist=iexist) |
| 130 |
if (iexist .and. iexact==0) iexact = 2 |
| 131 |
|
| 132 |
call read_exactparams(iexact,rootname(ifileopen),ierr) |
| 133 |
|
| 134 |
|
| 135 |
endif |
| 136 |
|
| 137 |
end subroutine set_options_dataread |
| 138 |
|
| 139 |
end module set_options_from_dataread |