Debian Codegraph @

src/options_limits.f90

raw
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-2013 Daniel Price. All rights reserved.
19 ! Contact: [email protected]
20 !
21 !-----------------------------------------------------------------
22
23 !-------------------------------------------------------------------------
24 ! Module containing settings and options related to the plot limits
25 ! includes default values of these options and submenu for changing them
26 !-------------------------------------------------------------------------
27 module settings_limits
28 implicit none
29 logical :: iadapt, iadaptcoords, adjustlimitstodevice
30 real :: scalemax
31 real, dimension(3) :: xminoffset_track, xmaxoffset_track
32
33 contains
34
35 !---------------------------------------------
36 ! set default values for these options
37 !---------------------------------------------
38 subroutine defaults_set_limits
39 use multiplot, only:itrans
40
41 iadapt = .true. ! adaptive plot limits
42 iadaptcoords = .false.
43 adjustlimitstodevice = .false.
44 scalemax = 1.0 ! for rescaling adaptive limits
45 itrans(:) = 0 ! no transformations (log10 etc)
46 xminoffset_track = 0.5 ! offset of limits from tracked particle
47 xmaxoffset_track = 0.5 !
48
49 end subroutine defaults_set_limits
50
51 !----------------------------------------------------------------------
52 ! submenu with options relating to plot limits
53 !----------------------------------------------------------------------
54 subroutine submenu_limits(ichoose)
55 use filenames, only:nsteps,nstepsinfile,ifileopen
56 use settings_data, only:ndataplots,numplot,ndim,iCalcQuantities, &
57 DataIsBuffered,track_string,ntypes
58 use calcquantities, only:calc_quantities
59 use multiplot, only:itrans
60 use prompting, only:prompt,print_logical
61 use limits, only:lim,range,rangeset,anyrangeset,print_rangeinfo
62 use labels, only:label,ix,irad,is_coord,labeltype
63 use transforms, only:ntrans,transform_label
64 use part_utils, only:is_trackstring,get_itrackpart
65 integer, intent(in) :: ichoose
66 integer :: iaction,ipick,i,index,ierr
67 integer :: itrackoffset,itracktype
68 character(len=120) :: transprompt,fmtstring
69 character(len=12) :: string,string2
70 character(len=len(track_string)) :: track_string_prev
71
72 ! zoom = 1.0
73
74 iaction = ichoose
75 if (iadapt) then
76 string = 'ADAPT'
77 else
78 string = 'FIXED'
79 endif
80 if (iadaptcoords) then
81 string2 = 'ADAPT'
82 else
83 string2 = 'FIXED'
84 endif
85
86 print "(a)",'------------------ limits options ---------------------'
87 10 format( &
88 ' 0) exit ',/, &
89 ' 1) use adaptive/fixed limits ( ',a,', ',a,' ) ',/, &
90 ' 2) set limits manually ',/, &
91 ' 3) set particle tracking ( ',a,' )',/, &
92 ' 4) subset data by parameter range ( ',a,')',/, &
93 ' 5) apply log/other transformations to columns ')
94 if (iaction <= 0 .or. iaction > 5) then
95 print 10,trim(string),trim(string2),trim(track_string),print_logical(anyrangeset())
96 call prompt('enter option ',iaction,0,5)
97 endif
98 !
99 !--limits
100 !
101 select case(iaction)
102 !------------------------------------------------------------------------
103 case(1)
104
105 !+ With limits set to adaptive, plot limits are minimum
106 !+ and maximum of quantities at current timestep.
107 !+ However, the co-ordinate limits are not adapted
108 !+ in the case of rendered plots. With fixed limits, the
109 !+ plot limits retain their default values for all timesteps.
110
111 call prompt('Use adaptive plot limits?',iadapt)
112 call prompt('Use adaptive plot limits on coordinate axes?',iadaptcoords)
113 call prompt('Adjust limits to aspect ratio of device?',adjustlimitstodevice)
114 print "(a)",'adaptive plot limits = '//print_logical(iadapt)// &
115 ' on coords = '//print_logical(iadaptcoords)
116
117 !------------------------------------------------------------------------
118 case(2)
119
120 !+ Manually sets the plot limits for each column of data
121
122 ipick = 1
123 do while (ipick > 0)
124 ipick = 0
125 !write(*,*)
126 if (ndim >= 1) then
127 write(fmtstring,'(a,i3,a)') 'Enter column number to set limits (0=quit;',numplot+1,'=centred cube in xyz)'
128 call prompt(trim(fmtstring),ipick,0,numplot+1)
129 else
130 write(fmtstring,'(a,i3,a)') 'Enter column number to set limits (0=quit)'
131 call prompt(trim(fmtstring),ipick,0,numplot)
132 endif
133 if (ipick==numplot+1 .and. ndim >= 1) then
134 call prompt(trim(label(ix(1)))//' max ',lim(ix(1),2))
135 lim(ix(1),1) = -lim(ix(1),2)
136 print*,'>> '//trim(label(ix(1)))//' limits set (min,max) = ',lim(ix(1),:)
137 if (ndim >= 2) then
138 lim(ix(2:ndim),1) = lim(ix(1),1)
139 lim(ix(2:ndim),2) = lim(ix(1),2)
140 print*,'>> '//trim(label(ix(2)))//' limits set (min,max) = ',lim(ix(2),:)
141 if (ndim >= 3) print*,'>> '//trim(label(ix(3)))//' limits set (min,max) = ',lim(ix(3),:)
142 endif
143 elseif (ipick > 0) then
144 call prompt(trim(label(ipick))//' min ',lim(ipick,1))
145 call prompt(trim(label(ipick))//' max ',lim(ipick,2))
146 print*,'>> '//trim(label(ipick))//' limits set (min,max) = ',lim(ipick,1),lim(ipick,2)
147 if (is_coord(ipick,ndim)) then
148 iadaptcoords = .false.
149 elseif (ipick <= numplot) then
150 iadapt = .false.
151 endif
152 endif
153 enddo
154 !------------------------------------------------------------------------
155 case(3)
156
157 !+ Co-ordinate limits are centred on the selected
158 !+ particle for all timesteps, with offsets as input by the user.
159 !+ This effectively gives the `Lagrangian' perspective.
160
161 track_string_prev = track_string
162 print "(3(a,/))",'To track particle 4923, enter 4923', &
163 'To track the 43rd particle of type 3, enter 3:43',&
164 'To track the maximum density, enter maxdens'
165
166 call prompt('Enter particle to track: ',track_string,noblank=.true.)
167 call get_itrackpart(track_string,itracktype,itrackoffset,ierr)
168 do while (ierr /= 0 .or. itracktype < 0 .or. itracktype > ntypes .or. itrackoffset < 0)
169 if (itracktype < 0 .or. itracktype > ntypes) print "(a)",'invalid particle type'
170 if (itrackoffset < 0) print "(a)",'invalid particle index'
171 if (ierr /= 0) print "(a)",'syntax error in string'
172 track_string = '0'
173 call prompt('Enter particle to track: ',track_string,noblank=.true.)
174 call get_itrackpart(track_string,itracktype,itrackoffset,ierr)
175 enddo
176 if (itracktype > 0) then
177 write(string,"(i12)") itrackoffset
178 string = adjustl(string)
179 print "(a)",'=> tracking '//trim(labeltype(itracktype))//' particle #'//trim(string)
180 elseif (itrackoffset > 0) then
181 write(string,"(i12)") itrackoffset
182 string = adjustl(string)
183 print "(a)",'=> tracking particle '//trim(string)
184 elseif (is_trackstring(track_string)) then
185 print "(a)",'=> tracking particle at '//trim(track_string)
186 else
187 track_string = '0'
188 print "(a)",'=> particle tracking limits OFF'
189 endif
190
191 if (itrackoffset > 0) then
192 do i=1,ndim
193 call prompt('Enter offset for '//trim(label(ix(i)))//'min:', &
194 xminoffset_track(i))
195 call prompt('Enter offset for '//trim(label(ix(i)))//'max :', &
196 xmaxoffset_track(i))
197 enddo
198 if ((trim(track_string) /= trim(track_string_prev)) &
199 .and. iCalcQuantities .and. irad > 0 .and. irad <= numplot) then
200 !--radius calculation is relative to tracked particle
201 print "(a)",' recalculating radius relative to tracked particle '
202 if (DataIsBuffered) then
203 call calc_quantities(1,nsteps)
204 else
205 call calc_quantities(1,nstepsinfile(ifileopen))
206 endif
207 endif
208 endif
209 !------------------------------------------------------------------------
210 case(4)
211
212 !+ Plot subset of data by restricting parameter range
213
214 ipick = 1
215 do while (ipick > 0)
216 ipick = 0
217 call print_rangeinfo()
218
219 call prompt('Enter column to use to restrict data set (-1=none/unset all,0=quit)',ipick,-1,ndataplots)
220 if (ipick > 0) then
221 print*,'current plot limits for '//trim(label(ipick))//': (min,max) = ',lim(ipick,1),lim(ipick,2)
222 call prompt(trim(label(ipick))//' min value ',range(ipick,1))
223 call prompt(trim(label(ipick))//' max value ',range(ipick,2),range(ipick,1))
224 if (.not.rangeset(ipick)) then
225 print*,'>> min=max: no restriction set'
226 endif
227 elseif (ipick==-1) then
228 print "(a)",'>> removing all range restrictions on data set'
229 range(:,:) = 0.
230 endif
231 write(*,*)
232 enddo
233 !------------------------------------------------------------------------
234 case(5)
235
236 !+ Applies log, inverse and other transformations to data columns
237
238 index = 1
239 do i=1,ntrans
240 write(transprompt(index:),"(1x,i1,'=',a,',')") i,trim(transform_label('x',i))
241 index = len_trim(transprompt) + 1
242 enddo
243
244 ipick = 1
245 do while (ipick > 0 .and. ipick <= numplot)
246 ipick = 0
247 call prompt('Enter column to apply transform (0=quit,-1=all) ',ipick)
248 if (ipick <= numplot .and. ipick /= 0) then
249 print "(a)", trim(transprompt)
250 if (ipick < 0) then
251 ipick = 0
252 call prompt('Which transform (or multiple e.g. 321)?',ipick,0)
253 itrans(:) = ipick
254 ipick = -99
255 else
256 call prompt('Which transform (or multiple e.g. 321)?',itrans(ipick),0)
257 endif
258 endif
259 enddo
260
261 end select
262
263 end subroutine submenu_limits
264
265 end module settings_limits