Debian Codegraph @

src/menu.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-2017 Daniel Price. All rights reserved.
19 ! Contact: [email protected]
20 !
21 !-----------------------------------------------------------------
22
23 !--------------------
24 ! SPLASH MAIN MENU
25 !--------------------
26 module mainmenu
27 implicit none
28 public :: menu,allowrendering,set_extracols
29
30 private
31
32 contains
33
34 subroutine menu
35 use filenames, only:defaultsfile,limitsfile,unitsfile,fileprefix,set_filenames
36 use labels, only:label,labelvec,iamvec,isurfdens,itoomre,iomegasq,ipdf,icolpixmap,is_coord,ix
37 use limits, only:write_limits,lim2,lim,reset_lim2,lim2set
38 use options_data, only:submenu_data
39 use settings_data, only:ndim,numplot,ndataplots,nextra,ncalc,ivegotdata, &
40 buffer_data,ncolumns,icoords,icoordsnew,iRescale
41 use settings_limits, only:submenu_limits,iadapt
42 use settings_part, only:submenu_particleplots,mstari
43 use settings_page, only:submenu_page,submenu_legend,interactive,nacross,ndown
44 use settings_render, only:submenu_render,iplotcont_nomulti,icolours,double_rendering
45 use settings_vecplot, only:submenu_vecplot,iplotpartvec
46 use settings_xsecrot, only:submenu_xsecrotate,xsec_nomulti
47 use settings_units, only:write_unitsfile
48 use multiplot
49 use prompting, only:prompt,print_logical
50 use transforms, only:transform_label
51 use defaults, only:defaults_write
52 use getdata, only:get_data
53 use geomutils, only:set_coordlabels
54 use timestepping
55 integer :: i,icol,ihalf,iadjust,indexi,ierr
56 integer :: ipicky,ipickx,irender,ivecplot,icontourplot
57 integer :: iamvecprev, ivecplottemp,ichoose
58 integer :: maxdigits
59 character(len=5) :: ioption
60 character(len=120) :: vecprompt,string
61 character(len=20) :: rprompt
62 character(len=2) :: fmtstrlen
63 character(len=50) :: fmtstr1,fmtstr2,fmtstr3
64 character(len=*), parameter :: sep="(55('-'))"
65 logical :: iAllowRendering
66
67 irender = 0
68 icontourplot = 0
69 ivecplot = 0
70 if (ndim > 1 .and. ix(1) > 0) then
71 ipickx = ix(1)
72 else
73 ipickx = 1
74 endif
75 ipicky = 1
76
77 menuloop: do
78 !---------------------------------------------------------------------------
79 ! preliminaries
80 !---------------------------------------------------------------------------
81 !
82 !--make sure the number of columns is set appropriately
83 ! (nextra can change depending on what options are set)
84 !
85 !
86 !--numplot is the total number of data columns (read + calculated)
87 ! not including the particle co-ordinates
88 ! nextra are extra graphs to plot (e.g. convergence plots, power spectrum)
89 !
90 ! note that numplot and ndataplots should *only* be set here
91 ! this means that even if ncolumns changes during data reads while plotting
92 ! we don't start plotting new quantities
93 !
94 call set_extracols(ncolumns,ncalc,nextra,numplot,ndataplots)
95 !
96 !--set the coordinate and vector labels
97 ! if working in a different coordinate system
98 !
99 call set_coordlabels(numplot)
100
101 !--set contents of the vector plotting prompt
102 vecprompt(1:6) = '0=none'
103 indexi = 7
104 iamvecprev = 0
105 do icol=1,numplot
106 if (iamvec(icol) /= 0 .and. iamvec(icol) /= iamvecprev) then
107 iamvecprev = iamvec(icol)
108 if (iamvec(icol) >= 10) then
109 write(vecprompt(indexi:),"(',',1x,i2,'=',a)",iostat=ierr) &
110 iamvec(icol),trim(labelvec(icol))
111 else
112 write(vecprompt(indexi:),"(',',1x,i1,'=',a)",iostat=ierr) &
113 iamvec(icol),trim(labelvec(icol))
114 endif
115 indexi = len_trim(vecprompt) + 1
116 endif
117 enddo
118
119 ichoose = 0
120
121 !---------------------------------------------------------------------------
122 ! print menu
123 !---------------------------------------------------------------------------
124
125 if (numplot > 0) then
126 !
127 !--data columns
128 !
129 call print_header()
130 print sep
131 ihalf = numplot/2 ! print in two columns
132 iadjust = mod(numplot,2)
133 maxdigits = floor(log10(real(maxplot)))+1
134 write(fmtstrlen,"(A1,I1)") "i",maxdigits
135 fmtstr1 = "(1x,"//trim(adjustl(fmtstrlen))//",')',1x,a20,1x," &
136 //trim(adjustl(fmtstrlen))//",')',1x,a20)"
137 print fmtstr1, &
138 (i,transform_label(label(i),itrans(i)), &
139 ihalf + i + iadjust, transform_label(label(ihalf + i + iadjust), &
140 itrans(ihalf+i+iadjust)),i=1,ihalf)
141 if (iadjust /= 0) then
142 fmtstr2 = "(1x,"//trim(adjustl(fmtstrlen))//",')',1x,a20)"
143 print fmtstr2, &
144 ihalf + iadjust,transform_label(label(ihalf + iadjust), &
145 itrans(ihalf+iadjust))
146 endif
147 !
148 !--multiplot
149 !
150 print sep
151 fmtstr3 = "(1x,' M)',1x,a,'[ '," &
152 //trim(adjustl(fmtstrlen))//",' ]',5x,a2,') ',a)"
153 print fmtstr3,'multiplot ',nyplotmulti,'m','set multiplot '
154 else
155 !
156 !--if no data
157 !
158 maxdigits = 1
159 print "(/a)",' No data: You may choose from the options below '
160 endif
161 !
162 !--options
163 !
164 print sep
165 if (ndim <= 1) then
166 print "(a)",' d(ata) p(age) o(pts) l(imits) le(g)end s(ave) q(uit)'
167 else
168 print "(a)",' d(ata) p(age) o(pts) l(imits) le(g)end h(elp)'
169 print "(a)",' r(ender) v(ector) x(sec/rotate) s(ave) q(uit)'
170 endif
171 print sep
172
173 !
174 !--prompt user for selection
175 !
176 write(*,"(a)",ADVANCE='NO') 'Please enter your selection now (y axis or option):'
177 read(*,"(a)",iostat=ierr) string
178 if (ierr < 0) stop 'reached end of input' ! end of input (e.g. in script)
179 if (ierr > 0) stop !'error reading input'
180 ioption = string(1:maxdigits)
181
182 !------------------------------------------------------------
183 ! if input is an integer and within range, plot data
184 !------------------------------------------------------------
185 read(ioption,*,iostat=ierr) ipicky
186 if (ierr /= 0) ipicky = -1
187
188 !--try to read more integers from the string
189 ! if present, use these to set up an "instant multiplot"
190 if (ipicky > 0 .and. ipicky < numplot+1 .and. len_trim(string) > 2) then
191 call set_instant_multiplot(string,ipicky,ipickx,numplot,nyplotmulti,&
192 multiplotx,multiploty,nacross,ndown)
193 endif
194
195 !--allow capital M to select the multiplot option
196 if (ioption(1:1)=='M' .or. ipicky==0) ipicky = numplot+1
197
198 if (ipicky > 0 .and. ipicky <= numplot+1) then
199
200 if (.not.ivegotdata) then
201 !
202 !--do not allow plotting if no data - instead try to read data
203 !
204 print*,' no data '
205 if (buffer_data) then
206 call get_data(-1,.false.)
207 else
208 call get_data(1,.false.,firsttime=.true.)
209 endif
210 else
211 !
212 !--if needed prompt for x axis selection
213 !
214 if (ipicky <= (numplot-nextra)) then
215 if (ipickx==0) then
216 if (ndim > 1 .and. ix(1) > 0) then
217 ipickx = ix(1)
218 else
219 ipickx = 1 ! do not allow zero as default
220 endif
221 endif
222 if (ipickx==ipicky) then ! do not allow x same as y by default
223 if (ipickx > 1) then
224 ipickx = ipicky-1
225 else
226 ipickx = ipicky+1
227 endif
228 endif
229 call prompt(' (x axis) ',ipickx)
230 !--go back to y prompt if out of range
231 if (ipickx > numplot .or. ipickx <= 0) cycle menuloop
232 !
233 !--work out whether rendering is allowed
234 !
235 iAllowRendering = allowrendering(ipickx,ipicky,xsec_nomulti)
236 !
237 !--prompt for render and vector plots
238 ! -> only allow if in "natural" coord system, otherwise h's would be wrong)
239 ! (a future feature might be to interpolate in icoord then translate the pixels
240 ! to icoordsnew, or alternatively plot non-cartesian pixel shapes)
241 ! -> also do not allow if transformations are applied
242 !
243 if (is_coord(ipicky,ndim) .and. is_coord(ipickx,ndim)) then
244 if (iAllowRendering) then
245 call prompt('(render) (0=none)',irender,0,(numplot-nextra))
246 if (irender > 0 .and. iplotcont_nomulti .and. icolours /= 0) then
247 if (double_rendering) then
248 rprompt = '2nd render'
249 else
250 rprompt = 'contours'
251 endif
252 call prompt('('//trim(rprompt)//') (0=none)',icontourplot,0,(numplot-nextra))
253 if (icontourplot==irender) then
254 if (iadapt) then
255 print "(a)",' limits for '//trim(rprompt)//' are adaptive'
256 else
257 if (.not.lim2set(icontourplot)) lim2(icontourplot,:) = lim(icontourplot,:)
258 call prompt(' enter min for '//trim(rprompt)//':',lim2(icontourplot,1))
259 call prompt(' enter max for '//trim(rprompt)//':',lim2(icontourplot,2))
260 if (all(abs(lim2(icontourplot,:)-lim(icontourplot,:)) < tiny(lim))) then
261 call reset_lim2(icontourplot)
262 endif
263 endif
264 endif
265 endif
266 else
267 irender = 0
268 endif
269 if (any(iamvec(1:numplot) /= 0) .and. (icoordsnew==icoords)) then
270 ivecplottemp = -1
271 ierr = 1
272 do while(ierr /= 0 .and. ivecplottemp /= 0)
273 ivecplottemp = ivecplot
274 ierr = 0
275 call prompt('(vector plot) ('//trim(vecprompt)//')',ivecplottemp,0,maxval(iamvec))
276 if (.not.any(iamvec(1:numplot)==ivecplottemp)) then
277 print "(a)",'Error, value not in list'
278 ierr = 1
279 endif
280 enddo
281 ivecplot = ivecplottemp
282 else
283 ivecplot = 0
284 endif
285 if (ivecplot > 0 .and. irender==0) then
286 call prompt('plot particles?',iplotpartvec)
287 endif
288 else
289 if (iAllowRendering) then
290 call prompt('(render) (0=none)',irender,0,(numplot-nextra))
291 else
292 irender = 0
293 endif
294 ivecplot = 0
295 endif
296 elseif (ipicky > 0 .and. ipicky==itoomre .or. ipicky==isurfdens .or. ipicky==iomegasq) then
297 print "(a)",' setting x axis to r'
298 if (ipicky==itoomre) call prompt('enter central mass for Toomre Q calculation [code units] ',mstari)
299 ipickx = 1
300 irender = 0
301 ivecplot = 0
302 elseif (ipicky > 0 .and. ipicky==ipdf) then
303 call prompt(' enter x axis for PDF calculation ',ipickx,1,ndataplots)
304 irender = 0
305 ivecplot = 0
306 elseif (ipicky > 0 .and. ipicky==icolpixmap) then
307 call prompt(' enter corresponding SPH column for particle data ',irender,0,ndataplots)
308 ipickx = 0
309 ivecplot = 0
310 elseif (ipicky==numplot+1) then
311 !
312 !--for multiplots, check that options are valid. If not, re-prompt for multiplot
313 ! settings
314 !
315 ipickx = 0
316 irender = 0
317 ivecplot = 0
318 if (any(multiploty(1:nyplotmulti) <= 0) .or. &
319 any(multiploty(1:nyplotmulti) > numplot) .or. &
320 any(multiplotx(1:nyplotmulti) <= 0) .or. &
321 any(multiplotx(1:nyplotmulti) > numplot)) then
322 print "(/,a,/)",'ERROR: multiplot settings out of range, please re-enter these'
323 call options_multiplot
324 endif
325 endif
326 !
327 !--call main plotting routine
328 !
329 call timestep_loop(ipicky,ipickx,irender,icontourplot,ivecplot)
330 endif
331 !------------------------------------------------------------------------
332 ! if input is an integer > numplot+1, quit
333 !------------------------------------------------------------------------
334 elseif (ipicky > numplot+1) then
335 return
336 else
337 !------------------------------------------------------------------------
338 ! if input is a string, use menu options
339 !------------------------------------------------------------------------
340 !-- Menu shortcuts; so you can type e.g. o2 and get the o)ptions menu, item 2
341 read(ioption(2:2),*,iostat=ierr) ichoose
342 if (ierr /= 0) ichoose = 0
343
344 select case(ioption(1:1))
345 !------------------------------------------------------------------------
346 !+ Sets up plotting of (m)ultiple quantities per timestep
347 case('m')
348 call options_multiplot
349 !------------------------------------------------------------------------
350 !+ This submenu sets options relating to the (d)ata read
351 case('d','D')
352 call submenu_data(ichoose)
353 !------------------------------------------------------------------------
354 !+ This option turns (i)nteractive mode on/off
355 case('i','I')
356 interactive = .not.interactive
357 print "(a)",' Interactive mode is '//print_logical(interactive)
358 !------------------------------------------------------------------------
359 !+ This submenu sets (p)age setup options
360 case('p','P')
361 call submenu_page(ichoose)
362 !------------------------------------------------------------------------
363 !+ This submenu sets particle plot (o)ptions
364 case('o','O')
365 call submenu_particleplots(ichoose)
366 !------------------------------------------------------------------------
367 !+ This submenu sets le(g)end and title options
368 case('g','G')
369 call submenu_legend(ichoose)
370 !------------------------------------------------------------------------
371 !+ This submenu sets (r)endering options
372 case('r','R')
373 if (ndim <= 1) print "(a)",'WARNING: these options have no effect in < 2D'
374 call submenu_render(ichoose)
375 !------------------------------------------------------------------------
376 !+ This submenu sets (v)ector plotting options
377 case('v','V')
378 if (ndim <= 1) print "(a)",'WARNING: these options have no effect in < 2D'
379 call submenu_vecplot(ichoose)
380 !------------------------------------------------------------------------
381 !+ This submenu sets cross section and rotation options
382 case('x','X')
383 if (ndim <= 1) print "(a)",'WARNING: these options have no effect in < 2D'
384 call submenu_xsecrotate(ichoose)
385 !------------------------------------------------------------------------
386 !+ This submenu sets options relating to the plot limits
387 case('l','L')
388 call submenu_limits(ichoose)
389 !------------------------------------------------------------------------
390 !+ The (s)ave option saves default options to a
391 !+ file called `splash.defaults'' in the current directory which
392 !+ is read automatically upon the next invocation of splash.
393 !+ This file uses namelist formatting and may be edited
394 !+ manually prior to startup if desired.
395 !+ Also save the current plot limits to a file called
396 !+ 'splash.limits' which is read automatically
397 case('s','S')
398 if (ioption(2:2)=='a' .or. ioption(2:2)=='A') then
399 call prompt('enter prefix for filenames: ',fileprefix,noblank=.true.)
400 call set_filenames(trim(fileprefix))
401 endif
402 call defaults_write(defaultsfile)
403 call write_limits(limitsfile)
404 if (iRescale) call write_unitsfile(unitsfile,ncolumns)
405 !------------------------------------------------------------------------
406 !+ Slightly obsolete: prints whatever help may be helpful
407 case('h','H')
408 print "(10(/a))",' Hint: menu items can be shortcut by typing, e.g. o2 for ',&
409 ' the o)ptions menu, item 2.',' ', &
410 ' for detailed help, consult the user guide',' ',&
411 ' (splash/docs/splash.pdf ',&
412 ' or http://users.monash.edu.au/~dprice/splash/userguide/)', &
413 ' ',' and/or the online FAQ. If you''re really stuck, email me! '
414 read*
415 !------------------------------------------------------------------------
416 !+ (q)uit, unsurprisingly, quits. Typing a number greater
417 !+ than the number of data columns also exits the program
418 !+ (e.g. I often simply type 99 to exit).
419 case('q','Q')
420 return
421 !------------------------------------------------------------------------
422 case DEFAULT
423 print "(a)",'unknown option '//trim(ioption)
424 end select
425
426 endif
427
428 enddo menuloop
429
430 return
431
432 contains
433
434 !----------------------------------------------------
435 ! multiplot setup
436 !----------------------------------------------------
437 subroutine options_multiplot
438 use settings_page, only:nacross, ndown
439 use settings_render, only:iplotcont_nomulti
440 use limits, only:lim,lim2,lim2set,reset_lim2
441 use labels, only:is_coord,labeltype
442 use params, only:maxparttypes
443 use settings_data, only:ntypes
444 use particle_data, only:npartoftype
445 integer :: ifac,ierr,itype,nvalues,nt
446 logical :: isamex, isamey, icoordplot, anycoordplot, imultisamepanel
447 integer, dimension(maxparttypes) :: itypelist
448
449 call prompt('Enter number of plots per timestep:',nyplotmulti,1,numplot)
450
451 isamey = all(multiploty(1:nyplotmulti)==multiploty(1))
452 if (ndim >= 2) call prompt('Same y axis for all?',isamey)
453 if (isamey) then
454 call prompt('Enter y axis for all plots',multiploty(1),1,numplot)
455 multiploty(2:nyplotmulti) = multiploty(1)
456 endif
457
458 isamex = all(multiplotx(1:nyplotmulti)==multiplotx(1))
459 call prompt('Same x axis for all?',isamex)
460 if (isamex) then
461 call prompt('Enter x axis for all plots',multiplotx(1),1,numplot)
462 multiplotx(2:nyplotmulti) = multiplotx(1)
463 endif
464
465 ! only count particle types with non-zero numbers of particles
466 nt = 0
467 do i=1,ntypes
468 if (any(npartoftype(i,:) > 0)) nt = nt + 1
469 enddo
470
471 anycoordplot = .false.
472 do i=1,nyplotmulti
473 print*,'-------------- Plot number ',i,' --------------'
474 if (.not.isamey) then
475 call prompt(' y axis ',multiploty(i),1,numplot)
476 endif
477 if (multiploty(i) <= ndataplots .and. .not.isamex) then
478 call prompt(' x axis ',multiplotx(i),1,ndataplots)
479 else
480 if (multiploty(i)==isurfdens) then
481 print "(a)",' setting x axis to r for surface density plot'
482 multiplotx(i) = 1
483 elseif (multiploty(i)==itoomre) then
484 print "(a)",' setting x axis to r for Toomre Q plot'
485 multiplotx(i) = 1
486 elseif (multiploty(i)==ipdf) then
487 call prompt(' enter x axis for PDF calculation ',multiplotx(i),1,ndataplots)
488 elseif (multiploty(i)==icolpixmap) then
489 call prompt(' enter corresponding SPH column for particle data ',irendermulti(i),0,ndataplots)
490 multiplotx(i) = 1
491 elseif (.not.isamex) then
492 multiplotx(i) = multiploty(i)
493 endif
494 endif
495 !
496 !--work out whether rendering is allowed
497 !
498 iAllowRendering = allowrendering(multiplotx(i),multiploty(i))
499
500 icoordplot = (is_coord(multiplotx(i),ndim) .and. is_coord(multiploty(i),ndim))
501 if (icoordplot) anycoordplot = icoordplot
502
503 if (icoordplot) then
504 if (iAllowRendering) then
505 call prompt('(render) (0=none)',irendermulti(i),0,numplot-nextra)
506 if (irendermulti(i) > 0 .and. iplotcont_nomulti .and. icolours /= 0) then
507 if (double_rendering) then
508 rprompt = '2nd render'
509 else
510 rprompt = 'contours'
511 endif
512 call prompt('('//trim(rprompt)//') (0=none)',icontourmulti(i),0,numplot-nextra)
513 if (icontourmulti(i)==irendermulti(i)) then
514 if (iadapt) then
515 print "(a)",' limits for '//trim(rprompt)//' are adaptive '
516 else
517 if (.not.lim2set(icontourmulti(i))) lim2(icontourmulti(i),:) = lim(icontourmulti(i),:)
518 call prompt(' enter min for '//trim(rprompt)//':',lim2(icontourmulti(i),1))
519 call prompt(' enter max for '//trim(rprompt)//':',lim2(icontourmulti(i),2))
520 if (all(abs(lim2(icontourmulti(i),:)-lim(icontourmulti(i),:)) < tiny(lim))) then
521 call reset_lim2(icontourmulti(i))
522 endif
523 endif
524 endif
525 else
526 icontourmulti(i) = 0
527 endif
528 !iplotcontmulti(i) = iplotcont_nomulti
529 endif
530 if (any(iamvec(1:numplot) > 0)) then
531 ivecplottemp = -1
532 ierr = 1
533 do while(ierr /= 0 .and. ivecplottemp /= 0)
534 ivecplottemp = ivecplotmulti(i)
535 ierr = 0
536 call prompt('(vector plot) ('//trim(vecprompt)//')',ivecplottemp,0,maxval(iamvec))
537 if (.not.any(iamvec(1:numplot)==ivecplottemp)) then
538 print "(a)",'Error, value not in list'
539 ierr = 1
540 endif
541 enddo
542 ivecplotmulti(i) = ivecplottemp
543 else
544 ivecplotmulti(i) = 0
545 endif
546 if (ivecplotmulti(i) > 0 .and. irendermulti(i)==0) then
547 call prompt('plot particles?',iplotpartvec)
548 endif
549 else
550 !
551 !--set irender, icontour and ivecplot to zero if no rendering allowed
552 !
553 if (multiploty(i) /= icolpixmap) irendermulti(i) = 0
554 icontourmulti(i) = 0
555 ivecplotmulti(i) = 0
556 endif
557
558 if (icoordplot .and. ndim >= 2) then
559 call prompt(' is this a cross section (no=projection)? ',x_secmulti(i))
560 if (x_secmulti(i)) then
561 call prompt('enter co-ordinate location of cross section slice',xsecposmulti(i))
562 endif
563 endif
564 !
565 !--prompt for selection of different particle types
566 ! if more than one SPH particle type is present
567 !
568 itypelist = 0
569 if (nt >= 2) then
570 call prompt('use all active particle types?',iusealltypesmulti(i))
571
572 if (iusealltypesmulti(i)) then
573 nvalues = 0
574 itypelist(:) = 0
575 else
576 !
577 !--prepare list of types based on current iplotpartoftypemulti
578 !
579 nvalues = 0
580 do itype=1,ntypes
581 if (iplotpartoftypemulti(itype,i)) then
582 nvalues = nvalues + 1
583 itypelist(nvalues) = itype
584 endif
585 enddo
586 if (nvalues==0) then
587 print*,'warning: internal error in type list'
588 itypelist(:) = 0
589 nvalues = 1
590 endif
591 !
592 !--prompt for list of types to use
593 !
594 do itype=1,ntypes
595 if (any(npartoftype(itype,:) > 0)) then
596 print "(i2,':',1x,a)",itype,'use '//trim(labeltype(itype))//' particles'
597 endif
598 enddo
599
600 call prompt('Enter type or list of types to use',itypelist,nvalues,1,ntypes)
601 !
602 !--set which particle types to plot
603 !
604 iplotpartoftypemulti(:,i) = .false.
605 iplotpartoftypemulti(itypelist(1:nvalues),i) = .true.
606
607 endif
608 else
609 !
610 !--if ntypes < 2 always use the (only) particle type
611 !
612 iusealltypesmulti(i) = .true.
613 endif
614 enddo
615
616 if (isamex .and. .not.anycoordplot) then
617 imultisamepanel = .false.
618 !call prompt('plot all plots in same panel? (default is different panels)',imultisamepanel)
619 else
620 imultisamepanel = .false.
621 endif
622
623 if (nyplotmulti==1 .or. imultisamepanel) then
624 nacross = 1
625 ndown = 1
626 print*,'setting nacross,ndown = ',nacross,ndown
627 elseif (mod(nacross*ndown,nyplotmulti) /= 0) then
628 !--guess nacross,ndown based on largest factor
629 ifac = nyplotmulti/2
630 do while (mod(nyplotmulti,ifac) /= 0 .and. ifac > 1)
631 ifac = ifac - 1
632 enddo
633 if (ifac <= 1) then
634 nacross = nyplotmulti/2
635 else
636 nacross = ifac
637 endif
638 if (nacross <= 0) nacross = 1
639 ndown = nyplotmulti/nacross
640 print*,'setting nacross,ndown = ',nacross,ndown
641 else
642 print*,'nacross = ',nacross,' ndown = ',ndown
643 endif
644
645 return
646 end subroutine options_multiplot
647 end subroutine menu
648
649 !----------------------------------------------
650 ! utility function which determines whether
651 ! or not rendering is allowed or not
652 !----------------------------------------------
653 logical function allowrendering(iplotx,iploty,xsec)
654 use labels, only:ih,irho,get_z_coord
655 use multiplot, only:itrans
656 use settings_data, only:ndim,ndataplots,icoords,icoordsnew
657 use settings_render, only:icolour_particles
658 use geometry, only:coord_is_length
659 integer, intent(in) :: iplotx,iploty
660 logical, intent(in), optional :: xsec
661 integer :: itransx,itransy,iz
662 logical :: is_xsec,islengthz
663
664 if (present(xsec)) then
665 is_xsec = xsec
666 else
667 is_xsec = .true.
668 endif
669 itransx = 0
670 itransy = 0
671 if (iplotx > 0) itransx = itrans(iplotx)
672 if (iploty > 0) itransy = itrans(iploty)
673
674 iz = get_z_coord(ndim,iplotx,iploty)
675 islengthz = coord_is_length(iz,icoordsnew)
676 !
677 !--work out whether rendering is allowed based on presence of rho, h & m in data read
678 ! also must be in base coordinate system and no transformations applied
679 !
680 if ((ih > 0 .and. ih <= ndataplots) &
681 .and.(irho > 0 .and. irho <= ndataplots) &
682 .and.(icoords==icoordsnew .or. (.not.is_xsec .or. (is_xsec .and. islengthz))) &
683 .and.(itransx==0 .and. itransy==0)) then
684
685 allowrendering = .true.
686 else
687 allowrendering = .false.
688 if (icolour_particles) allowrendering = .true.
689 endif
690
691 end function allowrendering
692
693 !----------------------------------------------
694 ! utility function which sets up the "extra"
695 ! plot columns and returns the total number
696 ! of allowed columns for plotting
697 !----------------------------------------------
698 subroutine set_extracols(ncolumns,ncalc,nextra,numplot,ndataplots)
699 use params, only:maxplot
700 use labels, only:ipowerspec,iacplane,isurfdens,itoomre,ispsound,&
701 iutherm,ipdf,label,icolpixmap,ivx,iomegasq
702 use settings_data, only:ndim,ndimV,icoordsnew,ivegotdata,debugmode
703 use settings_part, only:iexact
704 use system_utils, only:lenvironment
705 use write_pixmap, only:ireadpixmap
706 integer, intent(in) :: ncolumns
707 integer, intent(inout) :: ncalc
708 integer, intent(out) :: nextra,numplot,ndataplots
709
710 !
711 !-add extra columns (but not if nothing read from file)
712 !
713 if (ncolumns > 0) then
714 nextra = 0
715 ipowerspec = 0
716 iacplane = 0
717 isurfdens = 0
718 itoomre = 0
719 if (ndim==3 .and. icoordsnew==2 .or. icoordsnew==3) then
720 nextra = nextra + 1
721 isurfdens = ncolumns + ncalc + nextra
722 label(isurfdens) = 'Surface density'
723 if (iutherm > 0 .and. iutherm <= ncolumns .or. ispsound > 0 .and. ispsound <= ncolumns) then
724 nextra = nextra + 1
725 itoomre = ncolumns + ncalc + nextra
726 label(itoomre) = 'Toomre Q parameter'
727 endif
728 if (ivx > 0 .and. ndimV >= 2) then
729 nextra = nextra + 1
730 iomegasq = ncolumns + ncalc + nextra
731 label(iomegasq) = '\kappa^2/\Omega^2'
732 endif
733 endif
734 if (ndim==3 .and. lenvironment('SPLASH_TURB')) then !--Probability Density Function
735 nextra = nextra + 1
736 ipdf = ncolumns + ncalc + nextra
737 label(ipdf) = 'PDF'
738 endif
739
740 if (ndim <= 1 .and. lenvironment('SPLASH_TURB')) then !! .or. ndim==3) then ! if 1D or no coord data (then prompts for which x)
741 nextra = nextra + 1 ! one extra plot = power spectrum
742 ipowerspec = ncolumns + ncalc + nextra
743 label(ipowerspec) = '1D power spectrum'
744 else
745 ipowerspec = 0
746 endif
747 if (iexact==6) then ! toy star plot a-c plane
748 nextra = nextra + 1
749 iacplane = ncolumns + ncalc + nextra
750 label(iacplane) = 'a-c plane'
751 else
752 iacplane = 0
753 endif
754 !nextra = nextra + 1
755 !label(ncolumns+ncalc+nextra) = 'gwaves'
756 if (ndim >= 2) then
757 if (ireadpixmap) then
758 nextra = nextra + 1
759 icolpixmap = ncolumns + ncalc + nextra
760 label(icolpixmap) = '2D pixel map'
761 endif
762 endif
763 endif
764 !
765 !--now that we know nextra, set the total number of allowed plots (numplot).
766 !
767 if (ivegotdata) then
768 numplot = ncolumns + ncalc + nextra
769 if (numplot > maxplot) then
770 print "(a,i3,a)",' ERROR: total number of columns = ',numplot,' is greater '
771 print "(a,i3,a)",' than the current allowed maximum (',maxplot,').'
772 print "(a)",' This is set by the parameter "maxplot" in the params module'
773 print "(a)",' in the file globaldata.f90 -- edit this and recompile splash'
774 print "(a)",' (or email me if this happens to increase the default limit)'
775 stop
776 endif
777 ndataplots = ncolumns + ncalc
778 else
779 numplot = 0
780 ndataplots = 0
781 ncalc = 0
782 endif
783
784 if (debugmode) print*,'DEBUG: numplot = ',numplot, ' ncalc = ',ncalc,' ndataplots = ',ndataplots
785
786 return
787 end subroutine set_extracols
788
789 !----------------------------------------
790 ! instant multiplot setup from main menu
791 !----------------------------------------
792 subroutine set_instant_multiplot(string,ipicky,ipickx,numplot,nmulti,multiplotx,multiploty,nx,ny)
793 use params, only:maxplot
794 use prompting, only:prompt
795 character(len=*), intent(in) :: string
796 integer, intent(in) :: numplot
797 integer, intent(inout) :: ipicky,ipickx
798 integer, intent(inout) :: nmulti,nx,ny
799 integer, intent(inout) :: multiplotx(:),multiploty(:)
800 integer :: ipickarr(maxplot),ierr,i
801
802 ipickarr = 0
803 read(string,*,iostat=ierr) ipickarr
804 i = 1
805 do while (i < size(ipickarr) .and. ipickarr(i) /= 0 .and. ipickarr(i) <= numplot)
806 i = i + 1
807 enddo
808 if (i > 2) then
809 nmulti = i-1
810 !--make sure nmulti matches the number of panels on the page
811 if (nmulti /= nx*ny) then
812 nx = 1
813 ny = nmulti
814 endif
815 multiploty(1:nmulti) = ipickarr(1:nmulti)
816 ipicky = numplot + 1
817 if (ipickx==0) ipickx = 1 ! do not allow zero as default
818 call prompt(' (x axis) ',ipickx)
819 multiplotx(1:nmulti) = ipickx
820 endif
821
822 end subroutine set_instant_multiplot
823
824 !--------------------
825 ! print menu header
826 !--------------------
827 subroutine print_header
828 integer :: v(8),i
829 integer, parameter :: m(48) = (/32,68,111,110,39,116,32,102,111,114,103,101,116,32,116,111,&
830 32,115,101,110,100,32,68,97,110,105,101,108,32,97,32,98,&
831 105,114,116,104,100,97,121,32,109,101,115,115,97,103,101,33/)
832 integer, parameter :: c(49) = (/32,120,111,120,111,120,111,120,111,32,77,101,114,114,121,32,&
833 67,104,114,105,115,116,109,97,115,32,102,114,111,109,32,115,&
834 112,108,97,115,104,33,32,120,111,120,111,120,111,120,111,120,111/)
835 integer, parameter :: d(49) = (/32,79,111,79,111,79,111,79,32,83,80,76,65,83,72,32,119, &
836 105,115,104,101,115,32,121,111,117,32,97,32,118,101,114,121,32,104,&
837 97,112,112,121,32,33,32,79,111,79,111,79,111,79/)
838 integer, parameter :: l(45) = (/64,130,64,216,222,220,206,64,232,210,218,202,64,194,&
839 206,222,64,210,220,64,194,64,206,194,216,194,240,242,64,204,194,&
840 228,88,64,204,194,228,64,194,238,194,242,92,92,92/)
841 integer, parameter :: a(49) = (/32,83,101,103,109,101,110,116,97,116,105,111,110,32,&
842 102,97,117,108,116,46,32,80,108,101,97,115,101,32,114,101,98,111,&
843 111,116,32,121,111,117,114,32,99,111,109,112,117,116,101,114,46/)
844 integer, parameter :: s(48)=(/64,138,228,228,222,228,116,64,230,224,216,194,230,208,64,&
845 200,210,202,200,92,64,160,216,202,194,230,202,64,228,202,196,222,&
846 222,232,64,242,222,234,228,64,198,222,218,224,234,232,202,228/)
847 integer, parameter :: p(53)=(/12,7,10,13,10,14,18,11,15,14,12,14,17,18,16,18,12,11,12,&
848 17,13,15,11,15,13,12,12,17,12,11,16,18,14,9,11,17,17,13,10,18,16,10,15,&
849 18,12,18,18,12,16,14,10,9,14/)
850
851 call date_and_time(values=v)
852 if (v(2)==m(1)/4 .and. v(3)==v(2)-2) then
853 print "(/,48(a))",(achar(m(i)),i=1,48)
854 elseif (v(2)==(m(1)-20) .and. v(3)>20) then
855 print "(/,49(a))",(achar(c(i)),i=1,49)
856 elseif (v(2)==nint(0.6) .and. v(3)==d(2)/79) then
857 print "(/,40(a),i4,9(a))",(achar(d(i)),i=1,40),v(1),(achar(d(i)),i=41,49)
858 elseif (v(2)==l(1)-59 .and. v(3)==l(1)/4**2) then
859 print "(/,45(a))",(achar(l(i)/2),i=1,45)
860 elseif (v(2)==a(14)/8 .and. v(3)==int(1.3) .and. v(5) < (l(1)-16)/4) then
861 print "(/,49(a))",(achar(a(i)),i=1,49)
862 elseif (v(2)==(s(5)+78)/100+1 .and. v(3)==nint(sqrt(1.5)) .and. v(5) < s(1)/5.3) then
863 print "(/,48(a))",(achar(s(i)/2),i=1,48)
864 elseif ((v(2)==int(0.25*p(1)) .and. v(3)==p(6)) .or. (abs(v(3)/real(v(2))-4.*atan(1.)) < 1.3e-3)) then
865 print "(/,1x,53(a))",(achar(p(i)+39),i=1,53)
866 else
867 print "(/a)",' You may choose from a delectable sample of plots'
868 endif
869
870 end subroutine print_header
871
872 end module mainmenu