| 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-2014 Daniel Price. All rights reserved. |
| 19 |
! Contact: [email protected] |
| 20 |
! |
| 21 |
!----------------------------------------------------------------- |
| 22 |
|
| 23 |
!------------------------------------------------- |
| 24 |
! |
| 25 |
! Module containing subroutines relating to |
| 26 |
! setting/saving default options |
| 27 |
! |
| 28 |
!------------------------------------------------- |
| 29 |
module defaults |
| 30 |
implicit none |
| 31 |
|
| 32 |
contains |
| 33 |
!! |
| 34 |
!! set initial default options |
| 35 |
!! these are used if no defaults file is found |
| 36 |
!! |
| 37 |
subroutine defaults_set(use_evdefaults) |
| 38 |
use exact, only:defaults_set_exact |
| 39 |
use multiplot |
| 40 |
use settings_limits, only:defaults_set_limits |
| 41 |
use options_data, only:defaults_set_data |
| 42 |
use settings_part, only:defaults_set_part,defaults_set_part_ev |
| 43 |
use settings_page, only:defaults_set_page,defaults_set_page_ev |
| 44 |
use settings_render, only:defaults_set_render |
| 45 |
use settings_vecplot, only:defaults_set_vecplot |
| 46 |
use settings_xsecrot, only:defaults_set_xsecrotate |
| 47 |
use settings_powerspec, only:defaults_set_powerspec |
| 48 |
use settings_units, only:defaults_set_units |
| 49 |
use titles, only:pagetitles,steplegend |
| 50 |
logical, intent(in) :: use_evdefaults |
| 51 |
integer :: i |
| 52 |
! |
| 53 |
!--set defaults for submenu options |
| 54 |
! |
| 55 |
call defaults_set_data |
| 56 |
call defaults_set_limits |
| 57 |
call defaults_set_page |
| 58 |
call defaults_set_part |
| 59 |
call defaults_set_render |
| 60 |
call defaults_set_xsecrotate |
| 61 |
call defaults_set_vecplot |
| 62 |
call defaults_set_exact |
| 63 |
call defaults_set_powerspec |
| 64 |
call defaults_set_units |
| 65 |
! |
| 66 |
!--if using evsplash, override some default options |
| 67 |
! |
| 68 |
if (use_evdefaults) then |
| 69 |
print "(a)",' ** ev mode: using default settings for .ev files **' |
| 70 |
call defaults_set_page_ev |
| 71 |
call defaults_set_part_ev |
| 72 |
endif |
| 73 |
|
| 74 |
itrans(:) = 0 |
| 75 |
! |
| 76 |
!--multiplot |
| 77 |
! |
| 78 |
nyplotmulti = 4 ! number of plots in multiplot |
| 79 |
multiploty(:) = 0 |
| 80 |
do i=1,4 |
| 81 |
multiploty(i) = 1+i ! first plot : y axis |
| 82 |
enddo |
| 83 |
multiplotx(:) = 1 ! first plot : x axis |
| 84 |
irendermulti(:) = 0 ! rendering |
| 85 |
ivecplotmulti(:) = 0 ! vector plot |
| 86 |
x_secmulti(:) = .false. ! take cross section? |
| 87 |
xsecposmulti(:) = 0.0 ! position of cross section |
| 88 |
icontourmulti(:) = 0 ! contour plot |
| 89 |
iplotpartoftypemulti(:,:) = .false. |
| 90 |
do i=1,size(iplotpartoftypemulti(:,1)) |
| 91 |
iplotpartoftypemulti(i,i) = .true. |
| 92 |
enddo |
| 93 |
iusealltypesmulti(:) = .true. |
| 94 |
! |
| 95 |
!--titles |
| 96 |
! |
| 97 |
pagetitles = ' ' |
| 98 |
steplegend = ' ' |
| 99 |
|
| 100 |
return |
| 101 |
end subroutine defaults_set |
| 102 |
|
| 103 |
! |
| 104 |
! set defaults for 360 video mode |
| 105 |
! |
| 106 |
subroutine defaults_set_360() |
| 107 |
use settings_page, only:defaults_set_page_360 |
| 108 |
use settings_render, only:defaults_set_render_360 |
| 109 |
use settings_data, only:icoordsnew |
| 110 |
|
| 111 |
icoordsnew = 3 |
| 112 |
call defaults_set_render_360 |
| 113 |
call defaults_set_page_360() |
| 114 |
|
| 115 |
end subroutine defaults_set_360 |
| 116 |
|
| 117 |
! |
| 118 |
! writes default options to file (should match defaults_read) |
| 119 |
! |
| 120 |
subroutine defaults_write(filename) |
| 121 |
use exact, only:exactopts,exactparams |
| 122 |
use filenames, only:rootname,nfiles |
| 123 |
use settings_data, only:dataopts |
| 124 |
use settings_part, only:plotopts |
| 125 |
use settings_page, only:pageopts |
| 126 |
use settings_render, only:renderopts |
| 127 |
use settings_vecplot, only:vectoropts |
| 128 |
use settings_xsecrot, only:xsecrotopts,animopts |
| 129 |
use settings_powerspec, only:powerspecopts |
| 130 |
use multiplot, only:multi |
| 131 |
use shapes, only:shapeopts |
| 132 |
use calcquantities, only:calcopts |
| 133 |
character(len=*), intent(in) :: filename |
| 134 |
integer :: i,ierr |
| 135 |
integer, parameter :: iunit = 1 |
| 136 |
|
| 137 |
open(unit=iunit,file=trim(adjustl(filename)),status='replace',form='formatted', & |
| 138 |
delim='apostrophe',iostat=ierr) ! without delim namelists may not be readable |
| 139 |
if (ierr /= 0) then |
| 140 |
print*,'ERROR: cannot write file '//trim(filename) |
| 141 |
close(unit=iunit) |
| 142 |
return |
| 143 |
endif |
| 144 |
write(iunit,NML=dataopts) |
| 145 |
write(iunit,NML=plotopts) |
| 146 |
write(iunit,NML=pageopts) |
| 147 |
write(iunit,NML=renderopts) |
| 148 |
write(iunit,NML=vectoropts) |
| 149 |
write(iunit,NML=xsecrotopts) |
| 150 |
write(iunit,NML=powerspecopts) |
| 151 |
write(iunit,NML=exactopts) |
| 152 |
write(iunit,NML=exactparams) |
| 153 |
write(iunit,NML=multi) |
| 154 |
write(iunit,NML=shapeopts) |
| 155 |
write(iunit,NML=calcopts) |
| 156 |
write(iunit,NML=animopts) |
| 157 |
do i=1,nfiles |
| 158 |
write(iunit,"(a)") trim(rootname(i)) |
| 159 |
enddo |
| 160 |
close(unit=iunit) |
| 161 |
print "(a)",'default options saved to file '//trim(filename) |
| 162 |
|
| 163 |
return |
| 164 |
end subroutine defaults_write |
| 165 |
!----------------------------------------------- |
| 166 |
! reads default options from file |
| 167 |
! uses namelist input to group the options |
| 168 |
! these are specified in the modules |
| 169 |
!----------------------------------------------- |
| 170 |
subroutine defaults_read(filename) |
| 171 |
use filenames, only:rootname,maxfile |
| 172 |
use multiplot, only:multi |
| 173 |
use settings_data, only:dataopts,idustfrac_plot,idefaults_file_read |
| 174 |
use settings_part, only:plotopts |
| 175 |
use settings_page, only:pageopts |
| 176 |
use settings_render, only:renderopts |
| 177 |
use settings_vecplot, only:vectoropts |
| 178 |
use settings_xsecrot, only:xsecrotopts,animopts |
| 179 |
use settings_powerspec, only:powerspecopts |
| 180 |
use exact, only:exactopts,exactparams |
| 181 |
use shapes, only:shapeopts |
| 182 |
use calcquantities, only:calcopts |
| 183 |
character(len=*), intent(in) :: filename |
| 184 |
logical :: iexist |
| 185 |
integer :: ierr,i,nerr |
| 186 |
integer, parameter :: iunit = 1 |
| 187 |
|
| 188 |
nerr = 0 |
| 189 |
inquire (exist=iexist, file=filename) |
| 190 |
if (iexist) then |
| 191 |
open(unit=iunit,file=filename,status='old',form='formatted',delim='apostrophe',err=88) |
| 192 |
|
| 193 |
ierr = 0 |
| 194 |
read(iunit,NML=dataopts,iostat=ierr) |
| 195 |
idefaults_file_read = .true. |
| 196 |
if (ierr /= 0) nerr = nerr + 1 |
| 197 |
|
| 198 |
ierr = 0 |
| 199 |
read(iunit,NML=plotopts,iostat=ierr) |
| 200 |
if (ierr /= 0) nerr = nerr + 1 |
| 201 |
|
| 202 |
ierr = 0 |
| 203 |
read(iunit,NML=pageopts,iostat=ierr) |
| 204 |
if (ierr /= 0) nerr = nerr + 1 |
| 205 |
|
| 206 |
ierr = 0 |
| 207 |
read(iunit,NML=renderopts,iostat=ierr) |
| 208 |
if (ierr /= 0) nerr = nerr + 1 |
| 209 |
|
| 210 |
ierr = 0 |
| 211 |
read(iunit,NML=vectoropts,iostat=ierr) |
| 212 |
if (ierr /= 0) nerr = nerr + 1 |
| 213 |
|
| 214 |
ierr = 0 |
| 215 |
read(iunit,NML=xsecrotopts,iostat=ierr) |
| 216 |
if (ierr /= 0) nerr = nerr + 1 |
| 217 |
|
| 218 |
ierr = 0 |
| 219 |
read(iunit,NML=powerspecopts,iostat=ierr) |
| 220 |
if (ierr /= 0) nerr = nerr + 1 |
| 221 |
|
| 222 |
ierr = 0 |
| 223 |
read(iunit,NML=exactopts,iostat=ierr) |
| 224 |
if (ierr /= 0) nerr = nerr + 1 |
| 225 |
|
| 226 |
ierr = 0 |
| 227 |
read(iunit,NML=exactparams,iostat=ierr) |
| 228 |
if (ierr /= 0) nerr = nerr + 1 |
| 229 |
|
| 230 |
ierr = 0 |
| 231 |
read(iunit,NML=multi,iostat=ierr) |
| 232 |
if (ierr /= 0) nerr = nerr + 1 |
| 233 |
|
| 234 |
ierr = 0 |
| 235 |
read(iunit,NML=shapeopts,iostat=ierr) |
| 236 |
if (ierr /= 0) nerr = nerr + 1 |
| 237 |
|
| 238 |
ierr = 0 |
| 239 |
read(iunit,NML=calcopts,iostat=ierr) |
| 240 |
if (ierr /= 0) nerr = nerr + 1 |
| 241 |
|
| 242 |
ierr = 0 |
| 243 |
read(iunit,NML=animopts,iostat=ierr) |
| 244 |
if (ierr /= 0) nerr = nerr + 1 |
| 245 |
|
| 246 |
if (len_trim(rootname(1))==0) then |
| 247 |
do i=1,maxfile |
| 248 |
read(iunit,*,end=66,iostat=ierr) rootname(i) |
| 249 |
enddo |
| 250 |
endif |
| 251 |
66 continue |
| 252 |
|
| 253 |
close(unit=iunit) |
| 254 |
if (nerr > 0) then |
| 255 |
print "(a)",' WARNING: '//trim(filename)//' incomplete (from old code version)' |
| 256 |
else |
| 257 |
print*,'read '//trim(filename) |
| 258 |
endif |
| 259 |
return |
| 260 |
else |
| 261 |
print*,trim(filename)//' not found: using default settings' |
| 262 |
return |
| 263 |
endif |
| 264 |
|
| 265 |
88 continue |
| 266 |
print "(a)",' *** error opening defaults file '//trim(filename)//': using default settings' |
| 267 |
|
| 268 |
return |
| 269 |
end subroutine defaults_read |
| 270 |
|
| 271 |
end module defaults |