Debian Codegraph @

src/splash.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-2025 Daniel Price. All rights reserved.
19 ! Contact: [email protected]
20 !
21 ! The plotting API for SPLASH 2.0 was written by James Wetter
22 ! [email protected]
23 !
24 ! Work on the unified binary for SPLASH 3.0 was by Josh Calcino
25 ! [email protected]
26 !
27 !-----------------------------------------------------------------
28
29 program splash
30 !---------------------------------------------------------------------------------
31 !
32 ! SPLASH - a plotting utility for SPH data in 1, 2 and 3 dimensions
33 ! Copyright (C) 2005-2026 Daniel Price
34 ! [email protected]
35 !
36 ! --------------------------------------------------------------------------
37 !
38 ! This program is free software; you can redistribute it and/or modify
39 ! it under the terms of the GNU General Public License as published by
40 ! the Free Software Foundation; either version 2 of the License, or
41 ! (at your option) any later version.
42 !
43 ! This program is distributed in the hope that it will be useful,
44 ! but WITHOUT ANY WARRANTY; without even the implied warranty of
45 ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
46 ! GNU General Public License for more details.
47 !
48 ! You should have received a copy of the GNU General Public License
49 ! along with this program; if not, write to the Free Software
50 ! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
51 !
52 ! -------------------------------------------------------------------------
53 ! Version history/ Changelog:
54 ! 3.12.0 : (16/03/26)
55 ! sub-pixel interpolation in splash to grid for non-Cartesian geometries;
56 ! added --fcol flag in splash calc lightcurve for spectral hardening factor;
57 ! seg fault in splash to grid fixed;
58 ! automatically read visual extinction from AV_ files alongside phantom dumps;
59 ! splash can now be compiled in parallel with make -j flag;
60 ! added a column for kappa^2/omega^2 when plotting in cylindrical coordinates
61 ! 3.11.7 : (15/12/25)
62 ! option for nonlinear corrections to Rafikov planet wake exact solution;
63 ! automated plotting of .trajectory files from phantom orbit reconstructor^TM
64 ! Shamrock native .sham data reader implemented;
65 ! --shift=x,y,z flag to centre on sink but shift it to a different position;
66 ! issues with template and license files fixed (thanks to Phil Wyett)
67 ! 3.11.6 : (30/10/25)
68 ! bug fix causing seg fault in interactive mode if pixel number changes between window refreshes;
69 ! bug fix with transparency in multistep multiple panels (thanks to Yann Bernard);
70 ! bug fix reading velocity of sink particles from Phantom when extra arrays present after density in file;
71 ! recognise velocity array in shamrock data
72 ! 3.11.5 : (02/09/25)
73 ! --sortpad flag to sort files while pausing panels where sequence has finished;
74 ! vtk reader works with structured grid format from Idefix code;
75 ! fix seg fault in gadget-hdf5 read with SWIFT data;
76 ! correctly identify dust growth columns + units from phantom dumps
77 ! 3.11.4 : (25/06/25)
78 ! can print time as date and time with offset e.g. 2025-06-25 12:35 in legend;
79 ! plot minimum size point when using scalable markers so sink particles are always visible (thanks to Yann Bernard);
80 ! issue reading .comp files fixed; fixed issue reading column labels if fewer labels than columns;
81 ! experimental --get_h flag to override smoothing lengths;
82 ! fix bug with truncated name in copyright string (thanks to George Blaylock-Squibbs)
83 ! 3.11.3 : (23/04/25)
84 ! bug fix with automatic choice of columns with -360, also render density automatically in 360 mode;
85 ! --origin=1,1,1 can be used to set the origin to a fixed coordinate;
86 ! --omegar=x flag can be used to specify radius from sink particle of Keplerian corotating frame velocity;
87 ! bug fix with accidental log of all columns in interactive mode with only one dust species;
88 ! SYSTEM=gfortran is now the default if no SYSTEM is specified when compiling
89 ! 3.11.2 : (04/04/25)
90 ! automated plotting of star profiles from phantom relax.profile file if present;
91 ! better automated unit guessing when comparing to exact solution from file;
92 ! can plot two shock tube exact solutions with different gammas on top of each other;
93 ! improved behaviour with nstepsperpage = 0;
94 ! bug fix with labels + limits in double rendering when using auto choice of density weighted rendering;
95 ! plotting library api updated to giza v1.5; fix hardwiring of decimal labels on y axis;
96 ! bug fix with multiplot and multiple steps per page not printing axes correctly;
97 ! bug fix reading sink particle data in GADGET HDF5 format;
98 ! bug fix with vector labelling in GADGET HDF5 read;
99 ! bug fix reading density from phantom small dumps if not rendering;
100 ! 3.11.1 : (06/12/24)
101 ! bug fix with type recognition in sphNG data read, better wrong endian error
102 ! message (thanks to Matthew Bate); recognise sphNG format correctly even
103 ! if the dump is big endian; use kappa in opacity rendering if
104 ! present in the dump file (thanks to Mike Lau)
105 ! 3.11.0 : (25/11/24)
106 ! opacity rendering done in parallel;
107 ! compute bad pixel fraction in splash calc lightcurve;
108 ! option to write fits cube in splash calc lightcurve (thanks to Fitz Hu);
109 ! --kappatot option computes opacities using formula from Matsumoto & Metzger (2022);
110 ! read grad(E) as a vector in phantom snapshots (thanks to Mike Lau);
111 ! add SYSTEM=ifx for new intel compiler (thanks to Lionel Siess);
112 ! splash calc tdiffuse option for photon diffusion time along each axis;
113 ! improved label recognition and read all header quantities in GIZMO HDF5 data read;
114 ! plot cross-sections by default if plotting fits data cube;
115 ! bug fix reading phantom snapshots with APR;
116 ! better docs on making movies (thanks to Alison Young);
117 ! bug fix in vtk data read;
118 ! bug fix in follow-the-label column recognition in non-cartesian coordinates (thanks to Lionel Siess)
119 ! 3.10.3 : (04/03/24)
120 ! bug fix reading type information from phantom dumps introduced in 3.10.2
121 ! 3.10.2 : (01/03/24)
122 ! reads phantom dumps with adaptive particle refinement;
123 ! improved splash to phantom conversion;
124 ! better documentation of splash calc lightcurve (thanks to Chunliang Mu);
125 ! saving dust density limits now applies to all dust species;
126 ! 3.10.1 : (4/12/23)
127 ! bug fix with accreted particles appearing in smoothed particle plots;
128 ! automated Trad/Tgas in extra quantities from phantom dumps with radiation
129 ! 3.10.0 : (30/11/23)
130 ! --sort flag to sort filenames for comparison plots;
131 ! --movie flag to automatically make movie from sequence of files;
132 ! giza backend now supports direct output of mp4 movies
133 ! 3.9.0 : (06/11/23)
134 ! follow-the-label column choice, where if a label is selected for plotting
135 ! from the first file, it will automagically shift to find the matching label
136 ! in subsequent files, even if the column containing the quantity has changed;
137 ! implemented vtk reader capable of reading snapshots from Shamrock code;
138 ! apply transparency to smoothed particle plot only if adaptive smoothing used;
139 ! plot colour bar by default when particle colouring by quantity is used;
140 ! can read velocity array from fits header for position-position-velocity cubes;
141 ! bug fix with first page being white with smoothed particle plots on black background;
142 ! bug fix finding .comp file if underscore in the directory name
143 ! 3.8.5 : (23/10/23)
144 ! implemented smoothed particle plots with multiple steps per page;
145 ! allow for .cols and .comp file in current directory even if the filepath is not the current dir;
146 ! sphmoments utility added; added routine to extract velocity dimension from fits files;
147 ! bug fix with repeated string replacements giving endless backslashes in labels;
148 ! bug fix reading long filenames in denoise
149 ! 3.8.4 : (18/08/23)
150 ! various bugs fixed in GADGET data reader; auto-recognise GADGET block format;
151 ! improved conservation checks in splash to grid (thanks to Avi Chen);
152 ! better handling of AREPO data; bug fix with timestep not advancing;
153 ! no longer ask about particle types in multiplot if only one type present
154 ! 3.8.3 : (05/07/23)
155 ! flip option (f/F in interactive mode) now persists across
156 ! timesteps and works in snapshots other than the first;
157 ! bugs fixed in Tipsy data read (thanks to Alex Pettitt);
158 ! auto-recognition of Tipsy binary formats implemented;
159 ! show units labels in calculated quantities list
160 ! 3.8.2 : (12/05/23)
161 ! phantom data read looks for .comp file containing additional composition data;
162 ! also looks for .cols file containing any extra columns with one row per particle;
163 ! recognise opacity if extra quantity called "kappa" calculated
164 ! 3.8.1 : (01/05/23)
165 ! seg faults in auto-magic exact solution mapping fixed; longer line limit in determining
166 ! number of columns in ascii/exact solution files;
167 ! automatically handle log in exact solution labels (e.g. logR, logT)
168 ! 3.8.0 : (26/04/23)
169 ! plots multiple renderings with transparent background if more than one timestep per page selected;
170 ! auto-magically map exact solution columns onto splash columns;
171 ! added --exact=file1,file2 to switch on plotting of exact solution from file(s);
172 ! added --track=maxdens and --origin=maxdens to track/recentre on maximum density;
173 ! pressing backspace over legends deletes them;
174 ! use density weighted and normalised rendering by default in projection plots of vector fields
175 ! 3.7.2 : (21/02/23)
176 ! bug fix recognising labels like v_{phi} on command line, can now use -r vphi
177 ! 3.7.1 : (09/02/23)
178 ! libexact build failure fixed
179 ! 3.7.0 : (09/02/23)
180 ! splash calc extinction computes column density to all sink particles in the simulation;
181 ! bug fix with rendering vector components (e.g. vr) in non-cartesian coordinate systems;
182 ! bug fix with both quantities appearing in black and white when double rendering
183 ! 3.6.0 : (31/10/22)
184 ! skip particles with zero weight in interpolation, large speedup in some cases (thanks to T. Bending);
185 ! splash calc plus and splash calc minus for adding/subtracting snapshots;
186 ! added --origin=6245 flag to centre the origin on particle 6245;
187 ! added --hdu=1 flag to read from a particular hdu in a fits file;
188 ! use wcs coordinates / arcseconds for fits images if present in header;
189 ! option --dense to reset to densest clump in phantom/sphNG data read (thanks to J. Wurster)
190 ! 3.5.1 : (20/06/22)
191 ! bug fix with autolog limits; build failures in libexact and libread fixed and now tested;
192 ! recognise labels on command line e.g. -r density;
193 ! limits option for centred cube (thanks to J. Wurster)
194 ! 3.5.0 : (17/06/22)
195 ! bug fix with blank lines in splash.titles; bug fix with large line lengths in csv files;
196 ! allow blank labels in csv headers; bug fix with display of column labels from ascii/csv files;
197 ! log colour bar by default when using -r flag if more than 3 orders of magnitude range
198 ! 3.4.0 : (24/03/22)
199 ! density weighted interpolation now applied automatically to projection
200 ! plots of quantities that are not densities;
201 ! added flags --codeunits or --code to enforce code units from command line;
202 ! successfully parse csv files where some of the fields are character strings
203 ! 3.3.5 : (01/03/22)
204 ! bug fix with disappearing sinks in phantom MPI dumps
205 ! 3.3.4 : (21/01/22)
206 ! improved visual appearance of normalised renderings with free boundaries;
207 ! automatically read planet-wake parameters from phantom file headers;
208 ! added --wake=1,3 flag to plot wake from sink particle 3 around star 1;
209 ! bug fix with disappearing sinks in phantom MPI dumps; fixed seg fault in fits reader
210 ! 3.3.3 : (19/11/21)
211 ! "splash to csv" exports to comma separated variable (.csv) format;
212 ! automatically apply -ev flag for filenames ending in .ev, .mdot or .out;
213 ! improved label recognition from ascii file headers;
214 ! additional divergent colour schemes (thanks to Sahl Rowther);
215 ! deal with merged sink particles from phantom (thanks to James Wurster);
216 ! bug fix with units resetting to 1; skip blank and comment lines in splash.filenames
217 ! 3.3.2 : (20/07/21)
218 ! bug fix with -dev flag; silenced unnecessary dust warnings in sphNG read;
219 ! change-of-limits animation sequence works for vector plots;
220 ! automatic recognition of ndspmhd format;
221 ! 3.3.1 : (19/07/21)
222 ! f/F in interactive mode flips y axis on 2D plots to next column;
223 ! gradual transparency in double rendering rather than sharp cutoff;
224 ! removed S from main menu as now redundant; allow longer paths with -dev flag;
225 ! added --xmin,--xmax,--ymin,--ymax flags for manual margin adjustment;
226 ! bug fix with relativistic corrections in splash calc lightcurve
227 ! 3.3.0 : (20/05/21)
228 ! bug fix with surface density plot with physical units on;
229 ! splash calc lightcurve computes spectra from local blackbody emission if T and kappa given;
230 ! lightcurve now performs frequency-dependent ray tracing;
231 ! added "--anglex","--angley","--anglez" flags;
232 ! can add labelled arrows by typing ^ in interactive mode, also delete/edit;
233 ! capital M, 0 or ncols+1 from main menu gives multiplot;
234 ! added -multi flag for multiplot from command line
235 ! 3.2.1 : (26/04/21)
236 ! added --xsec=1.0 and --kappa=1.0 flags to specify cross section position
237 ! and opacity, respectively; specifying --xsec automatically switches from projection
238 ! to cross section; specifying --kappa turns on opacity rendering;
239 ! bug fix in splash calc tracks; can use --track=1,2,3 to specify list of particles
240 ! 3.2.0 : (20/04/21)
241 ! disable ALL prompts if any command line flags set;
242 ! all environment variables can now be given as command line flags using lower case string
243 ! after last underscore e.g. SPLASH_CENTRE_ON_SINK=1 becomes --sink=1 on command line;
244 ! useful options include --corotate, --sink=1, --debug and more;
245 ! splash to grid recognises flags including --periodic, --npix=100,100,100 and --convert=1,4;
246 ! added -gandalf and -f gandalf as shortcut for seren data read;
247 ! assume default xw device and disable device prompt if any command line flags set;
248 ! s/S options now do the same thing
249 ! 3.1.1 : (31/03/21)
250 ! automatically plot y vs x given a two-column data file;
251 ! planet wake coordinate system added; bug fix with SPLASH_COROTATE; bug fix reading
252 ! phantom dumps when number of particles of each type does not match itype array;
253 ! bug fixes in grid2pdf
254 ! 3.1.0 : (16/02/21)
255 ! splash calc lightcurve implemented; sink particles ON by default;
256 ! changing units rescales plot limits correctly;
257 ! further improvements to ray tracing / opacity rendering with physical opacity;
258 ! can change units temporarily without writing .units file;
259 ! auto-select closest velocity and mass unit and better default time unit
260 ! in phantom/sphNG read; error message if Inf or NaN read from .units file;
261 ! bug fix with units prompt; floating colour bars are white not black;
262 ! automatically write copyright in Hollywood mode; auto-render fits files;
263 ! read softening length from phantom sinks if accretion radius is zero;
264 ! 3.0.2 : (20/01/21)
265 ! opacity rendering uses physical value of kappa, can also
266 ! use opacity defined on particles; can track multiple particles with
267 ! 'splash calc tracks' by specifying ids in splash.tracks file;
268 ! support for SWIFT code in gadget_hdf5; auto-recognise format for .csv files;
269 ! improved starsmasher data read; improved physical unit selection;
270 ! exact solution lines can be plotted in background colour;
271 ! bug fix for dead particles in phantom dumps; seg fault in fits reader fixed;
272 ! seg fault in gadget data read fixed; bug fix in x-menu options
273 ! 3.0.0 : (26/08/20)
274 ! Unified splash binary with -f flag to specify format;
275 ! automated format recognition for phantom, gadget (and hdf5 variants) and fits;
276 ! cleaner d) menu; splash is compiled in double precision by default;
277 ! rotation settings used in splash to grid to rotate particles;
278 ! bug fix in mbatesph data read; pysplash utility for reading SPH
279 ! data formats into python; libsplash.so, libexact.so and libread.so libraries
280 ! 2.10.1 : (24/06/20)
281 ! exact solution can appear in legend; can also plot under data;
282 ! fits reader and denoise utility can read/write spectral cubes; text shapes can
283 ! print header variables using %(var); can shift cross section by precise amounts
284 ! in interactive mode using number followed by u/d; fits reader includes header
285 ! quantities; reduced verbosity for non-interactive plots; use of fake dust particles
286 ! is now via menu option, not environment variable; max particle types = 24;
287 ! userguide in readthedocs format; bug fix with save limits with particle tracking;
288 ! support for .pfm pixelmap format as output; physical units are ON by default;
289 ! prompts only for particle types present in data
290 ! 2.10.0 : (14/02/20)
291 ! much improved splash to grid - bug fixes with pixel number and roundoff error;
292 ! use Petkova (2018) method for sub-pixel rendering to 3D grid and 3D projections;
293 ! added bytestream output formats for splash to grid and splash to ascii;
294 ! can press number and -/+ to zoom out/in by that factor in interactive mode;
295 ! use SPLASH_COROTATE=1,3 to corotate with arbitrary pair of sink particles;
296 ! SPLASH_COROTATE also gives velocity field in corotating frame;
297 ! splash to ascii can write particular columns by setting SPLASH_CONVERT=1,4;
298 ! plasma beta correct in both code and physical units;
299 ! working fits reader and splash-denoise utility
300 ! 2.9.1 : (08/11/19)
301 ! cleaner menu options for units and calculated quantities;
302 ! surface rendering allowed with 3D perspective turned off;
303 ! automatic labelling of grain sizes in density and column density plots;
304 ! adaptive limits on log colour bars show 3 dex range by default;
305 ! auto-adjust limits to device aspect ratio works with multiple panels;
306 ! bug fixes with r-z rendering; Toomre Q prompts for mass
307 ! 2.9.0 : (05/04/19)
308 ! general header quantities are read and available in function parser;
309 ! more robust label detection and parsing during ascii data read;
310 ! splash to grid works in non-cartesian geometries; added flared and
311 ! log-flared coordinate systems; Doppler shift colour bar; can customise
312 ! line style and colour when plotting multiple exact solutions; seg faults fixed;
313 ! better plot tiling decisions; disappearing arrows bug fix; Rafikov disc-
314 ! planet exact solution added; atan2 implemented in function parser;
315 ! various multigrain phantom read fixes (incl. seg faults); exact rendering
316 ! implemented in 2D; libsplash implemented for use as Python splash backend
317 ! 2.8.0 : (06/04/18)
318 ! 360/4pi video mode added; automatically read labels from ascii file headers;
319 ! nearest sensible unit (e.g. au or pc) used by default; cactus hdf5 data read;
320 ! kernel-smoothed particle plots of arbitrary quantities;
321 ! Viridis, Ocean and Inferno colour schemes; can customise line colours;
322 ! Bondi flow exact solution; option for ticks but no labels;
323 ! correct units in surface density plots; colour bar on top or left;
324 ! support for multi-grain dust in Phantom; bug fix with NaNs in ascii files
325 ! 2.7.0 : (03/05/17)
326 ! Hollywood mode added (ctrl-m in interactive mode); better handling of dust/gas
327 ! phantom data; added rotated cartesian geometry; rendering implemented in r-phi
328 ! coordinates; added Fortran 2008 intrinsics to function parser; better rectangle
329 ! plotting; better falcON data read; Ogilvie-Lubow exact solution for planet-disc
330 ! interaction; tipsy read now works when splash compiled in double precision;
331 ! splash to gridascii2 implemented; bugs with r-phi rendering fixed
332 ! 2.6.0 : (22/10/15)
333 ! SILO, falcON and .pbob data reads implemented; bug fixes in gadget-hdf5 reader;
334 ! can recognise particle types in ascii read; more robust sphNG read;
335 ! dust fraction recognised in phantom data read; Toomre Q works in physical units;
336 ! bug fix with disappearing units labels; bug fix in shock tube exact solution;
337 ! added splash calc delta; splash to ascii keeps precision; better power spectra
338 ! 2.5.1 : (29/01/15)
339 ! error bar style options; support for 5K displays; can plot vectors
340 ! and render with colours if h not read; range restrictions apply during splash to grid;
341 ! improved line-style legend; now up to 6 line styles; fixes to amuse-hdf5 read;
342 ! phantom read handles star/dm particles; various bugs fixed
343 ! 2.5.0 : (22/08/14)
344 ! instant multiplots by giving multiple columns as y axis;
345 ! ability to plot multiple exact solution files on same plot;
346 ! compiles in parallel by default; support for tagged sphNG/Phantom format;
347 ! AMUSE hdf5 format reader added; various bug fixes
348 ! 2.4.1 : (01/04/14)
349 ! Roche-lobe plotting vastly improved; newunit= issue fixed;
350 ! bug fix with reading sink velocities from Phantom; other minor bug fixes.
351 ! 2.4.0 : (21/02/14)
352 ! time formatting in legend can include general functions like %(t + 1000);
353 ! option to include sinks in opacity rendering;
354 ! supports one-fluid dust visualisation;
355 ! C-shock exact solution; better polytrope solution
356 ! 2.3.1 : (11/11/13)
357 ! SPLASH_COROTATE option to plot in frame corotating with sinks;
358 ! bug fixes with handling of dead/accreted/boundary particles in sphNG/phantom;
359 ! various other bugs fixed.
360 ! 2.3.0 : (09/08/13)
361 ! can customise time formatting in legend; improvements to legends;
362 ! less verboseness; splash can read and plot pixel maps produced with -o ascii;
363 ! 3D vector field plotting improved; bug fix with gfortran 4.8
364 ! 2.2.2 : (10/05/13)
365 ! particle tracking by type implemented;
366 ! can interpolate specific columns in splash to grid;
367 ! SPLASH_CENTRE_ON_SINK option generic to all data reads;
368 ! Aly Reheam format added; option for 2nd y axis on plots;
369 ! bug fix with X11 linking on Ubuntu; can read gadget ICs files
370 ! 2.2.1 : (21/02/13)
371 ! minor bug with axes plotting fixed;
372 ! Wendland kernels added; bugs with exact solution plotting fixed;
373 ! bug fix with tracking of dark matter particles
374 ! 2.2.0 : (16/11/12)
375 ! option to use different kernels for interpolation;
376 ! floating/inset colour bars added;
377 ! splash to gadget conversion implemented;
378 ! splash to grid works in 2D;
379 ! improved interfaces to shapes and animation sequences;
380 ! automatically turns on dark matter particle plotting if no gas;
381 ! interactive mode help displayed automatically
382 ! 2.1.1 : (31/08/12)
383 ! irregular/circular particle selection using shift-left/middle click;
384 ! improved h5part and GADGET HDF5 data reads;
385 ! splash can be compiled in double precision;
386 ! bug fixes with calculated quantities + change of coordinate systems;
387 ! improved vector plot legend; option for box+numbers but no labels added
388 ! 2.1.0 : (16/05/12)
389 ! 3D vector field visualisation added;
390 ! GADGET HDF5 read implemented;
391 ! page sizes can be specified in pixels;
392 ! limits can auto-adapt to device aspect ratio;
393 ! more general exact solution from file option;
394 ! tiling works with one colour bar per row;
395 ! splash calc handles different particle types
396 ! 2.0.0 : (29/08/11)
397 ! new giza backend - antialiased lines; real fonts; pdf, eps and svg drivers;
398 ! fewer build dependencies (only cairo, X11);
399 ! support for semi-transparent text;
400 ! Double rendering (with transparent background) implemented.
401 ! 1.15.0 : (29/08/11)
402 ! Multiplot with different particle types implemented; calculated quantities
403 ! list is now pre-filled automatically; preliminary support for r-phi and r-z
404 ! rendering; outlined solid markers implemented; better handling of multiple types;
405 ! manual contour levels can be specified in splash.contours; parallel splash to grid;
406 ! better support for non-square pixels; clipping of numbers at edge of viewport fixed
407 ! 1.14.1 : (17/03/11)
408 ! SEREN data read added; dragon read updated; build follows Gnu conventions
409 ! on DEST and DESTDIR (needed for macports build); can have up to 12 particle types;
410 ! exact solutions re-ordered; dusty wave exact solution added
411 ! 1.14.0 : (06/12/10)
412 ! Can flip between rendered quantities in interactive mode using 'f/F';
413 ! SPLASH_DEFAULTS variable can be set for system-wide defaults;
414 ! can plot arbitrary functions of x,t as exact solution; asplash better
415 ! handles blank lines in header and can specify time, gamma location with
416 ! env. variables; added data read for the H5PART format; GADGET read
417 ! across multiple files implemented; VINE read works with particle injection;
418 ! error bars can be plotted for both x and y axis simultaneously;
419 ! default rotation angles are set if 3D perspective turned on;
420 ! new directory layout and more helpful error messages during build;
421 ! PGPLOT linking is easier to get right.
422 ! 1.13.1 : (26/02/10)
423 ! bugs with new calc_quantities module fixed; generic library interface
424 ! implemented so backend can be changed easily; bug fix with auto pixel selection;
425 ! simpler foreground/background colour setting; added subgrid interpolation warning
426 ! 1.13.0 : (25/02/10)
427 ! function parser incorporated; calculated quantities can now be specified
428 ! at runtime, arbitrary function plotting implemented as an exact
429 ! solution; command-line SPH->grid conversion ("splash to grid")
430 ! implemented; ctrl-t in interactive mode adds arbitrary text box;
431 ! better line style/colour changing; bug fix with tiling and y-axis labels;
432 ! various other bug fixes.
433 ! 1.12.2 : (15/07/09)
434 ! Variable marker sizes added, can plot particles as circles with
435 ! size proportional to h; dark matter rendering with block-labelled
436 ! GADGET format fixed; VINE read handles star particles; TIPSY read
437 ! with ifort10.0.0 works; snsph read added; splash to phantom added;
438 ! does not override labels for coords, vectors by default; bug fixes
439 ! with contouring options; stability bug fixes with older compilers;
440 ! more robust memory handling; bug fix with automatic pixel selection
441 ! causing seg fault.
442 ! 1.12.1 : (20/04/09)
443 ! Can edit/delete text shapes interactively, also the colour bar label; can customise
444 ! the label on projection plots; contour levels better defined; SPLASH_HMIN_CODEUNITS added;
445 ! option for numeric labelling of contours; contour limits can be set separately
446 ! to render limits for same quantity; minor bug fixes.
447 ! 1.12.0 : (22/12/08)
448 ! Command-line plotting implemented; ln transform added; bug fixes in GADGET read;
449 ! Backspace over annotation (legends,titles,axes,colour bar) in interactive mode
450 ! removes it; "splash calc" command line utility calculates time sequences of
451 ! global quantities from a sequence of dump files; bug fix causing seg fault.
452 ! 1.11.1 : (13/10/08)
453 ! automatic number of pixels and exact pixel boundaries implemented;
454 ! mass does not have to be read from dump file; frame changes are per-page
455 ! not per-dump file for animation sequences; lower stacksize footprint;
456 ! bug fix with circles of interaction; bug fixes with block-labelled GADGET read;
457 ! Steve Foulkes data read added.
458 ! 1.11.0 : (15/08/08)
459 ! ability to use subset of particles in restricted parameter range(s);
460 ! probability density function plot option; plot-hugging colour bars added;
461 ! ability to annotate plot with a range of shapes; v,V,w and H implemented
462 ! in interactive mode for >1 panel; various bug fixes (including one with vphi).
463 ! 1.10.2 : (08/05/08)
464 ! disc surface density / toomre q parameter plotting added; flash colour
465 ! schemes added; splash to binary convert option; can change order in
466 ! which particle types are plotted; splash.columns file overrides
467 ! column label settings; vanaverbeke format read; various bug fixes.
468 ! 1.10.1 : (11/03/08)
469 ! "splash to" command line option converts binary dumps to ascii format;
470 ! vector plots + rotation now implemented; block labelled GADGET format read;
471 ! ring-spreading exact solution added.
472 ! 1.10.0 : (28/11/07)
473 ! horizontal colour bars implemented; -p, -o command line options;
474 ! can have mixed types in data reads; TIPSY and DRAGON data reads;
475 ! density weighted rendering; normalisation applies to column
476 ! density plots; improved particle tracking; save as option; various bug fixes
477 ! 1.9.2 : (12/09/07)
478 ! improvements to ascii read including asplash -e option;
479 ! smarter foreground/background colour changing for titles;
480 ! min=max problem fixed (caught by splash not pgplot);
481 ! fixed vector arrow length option; other minor changes and bug fixes
482 ! 1.9.1 : (11/07/07)
483 ! environment variables + improvements to gadget data read; better
484 ! prompting; 3 new colour schemes; improved legend/title options;
485 ! other minor changes
486 ! 1.9.0 : (21/05/07)
487 ! animation sequences implemented; origin settings now affect radius
488 ! calculation and are relative to tracked particle; automatic line
489 ! width choice for postscript devices; w key adapts vector arrows;
490 ! vastly improved userguide
491 ! 1.8.1 : (28/03/07)
492 ! option to hide vector arrows where there are no particles added;
493 ! smoother 3D plotting at low pixel numbers;
494 ! smoother vector plots; bug fixes with a); issues with
495 ! round-off error with z integration of vectors fixed.
496 ! 1.8.0 : (14/03/07)
497 ! hidden particles not used in rendering; units for z integration added;
498 ! a) & g) implemented in interactive mode for multiple-plots-per-page;
499 ! improved cross section using x in interactive mode
500 ! 1.7.2 : (19/02/07)
501 ! Menu shortcuts implemented; bug fix/ more sensible transformation
502 ! of angular vector components in different co-ordinate systems;
503 ! improvements to interactive zoom and origin recentreing;
504 ! improved colour-by-type option; restrictions on page size removed;
505 ! minor bug fixes
506 ! 1.7.1 : (04/01/07)
507 ! command line options for defaults and limits files added;
508 ! minor bug fixes
509 ! 1.7.0 : (13/12/06)
510 ! renamed SPLASH instead of SUPERSPHPLOT; much faster data read
511 ! for gadget and sphNG reads (only required columns read);
512 ! physical units can be saved to file; new menu formats; various
513 ! other bug fixes
514 ! 1.6.2 : (24/10/06)
515 ! fast particle plotting and streamline plotting implemented;
516 ! more bug fixes with interactive mode on multiplots; various other bug fixes
517 ! 1.6.1 : (24/8/06)
518 ! bug fixes to 1.6.0, further improvements to interactive mode on multiplots
519 ! 1.6.0 : (10/8/06)
520 ! Interactive mode on multiple plots per page; highly optimised interpolation
521 ! + parallel version; new Makefile; various bug fixes
522 ! 1.5.4 : (06/7/06)
523 ! Handles multiple SPH/non-SPH particle types; axes redrawn after rendering;
524 ! minor bug fixes
525 ! 1.5.3 : (27/6/06)
526 ! minor bug fixes/improvements to multiple plots per page; colour bar labelling
527 ! tiled plots; legend; Accelerated rendering option for projections.
528 ! 1.5.2 : (11/5/06)
529 ! "S)" option for saving limits and defaults; MUCH faster interactive
530 ! replotting (no unnecessary re-rendering); a few other minor things
531 ! 1.5.1 : (26/4/06)
532 ! docs updated for v1.5, other minor changes
533 ! 1.5.0 : (17/3/06)
534 ! 3D perspective added; 3D opacity rendering; improved rotation,
535 ! colour schemes; adjustable vector arrows (+legend); improved timestepping
536 ! behaviour; speed enhancements; physical unit rescaling
537 ! 1.0.5 : (28/9/05)
538 ! error calculation for exact solutions; legend for plot markers;
539 ! exact_densityprofiles added; more colour schemes;
540 ! unit rescaling improved; other minor changes + bug fixes
541 ! 1.0.4 : (17/8/05)
542 ! better colour schemes; interactive colour scheme changing;
543 ! various minor changes and bug fixes
544 ! 1.0.3 : (5/7/05)
545 ! rescale data option; better page setup; improved zooming;
546 ! interactive particle tracking; various minor changes and bug fixes
547 ! 1.0.2 :
548 ! much improved ascii data read; better line plotting; zoom on
549 ! powerspectrum plots + various bug fixes
550 ! 1.0.1 :
551 ! bug fixes relating to colour bars on multiplots
552 ! 1.0.0 :
553 ! first official release; version given to many people at IPAM
554 ! meeting and put on web
555 !
556 ! -------------------------------------------------------------------------
557 !
558 ! Modules/subroutines as follows (in alphabetical order):
559 !
560 ! allocate : allocates memory for main arrays
561 ! calc_quantities : calculates additional quantities from particle data
562 ! colours : colour schemes for rendering
563 ! colourparts : colours particles
564 ! defaults : writes/reads default options to/from file
565 ! exact : module handling exact solution settings
566 ! exact_fromfile : reads an exact solution tabulated in a file
567 ! exact_mhdshock : some tabulated solutions for mhd shocks
568 ! exact_polytrope : exact solution for a polytrope
569 ! exact_rhoh : exact relation between density and smoothing length
570 ! exact_sedov : exact solution for sedov blast wave
571 ! exact_shock : exact solution for hydrodynamic shocks
572 ! exact_wave : exact solution for a propagating sine wave
573 ! exact_toystar1D : exact solution for the 1D toy star problem
574 ! exact_toystar2D : exact solution for the 2D toy star problem
575 ! fieldlines : module handling streamline plotting
576 ! get_data : wrapper for main data read
577 ! geometry : module handling different coordinate systems
578 ! globaldata : various modules containing "global" variables
579 ! interactive : drives interactive mode
580 ! interpolate1D : interpolation of 1D SPH data to grid using kernel
581 ! interpolate2D : interpolation of 2D SPH data to grid
582 ! interpolate3D_xsec : 3D cross section interpolations
583 ! interpolate3D_projection : 3D interpolation integrated through domain
584 ! legends : plots (time) legend on plot
585 ! limits : sets initial plot limits and writes to/reads from limits file
586 ! menu : main menu
587 ! options_data : sets options relating to current data
588 ! options_limits : sets options relating to plot limits
589 ! options_page : sets options relating to page setup
590 ! options_particleplots : sets options relating to particle plots
591 ! options_powerspec : sets options for power spectrum plotting
592 ! options_render : sets options for render plots
593 ! options_vector : sets options for vector plots
594 ! options_xsecrotate : sets options for cross sections and rotation
595 ! particleplot : subroutines for particle plotting
596 ! plotstep : main subroutines which drive plotting of a single timestep
597 ! powerspectrums : calculates power spectrum of 1D data (2 methods)
598 ! read_data_dansph : reads data from my format of data files
599 ! read_data_mbate : reads data from matthew bate's format of data files
600 ! render : takes array of pixels and plots render map/contours etc
601 ! rotate : subroutines controlling rotation of particles
602 ! setpage : sets up the PGPLOT page (replaces call to PGENV/PGLAB)
603 ! splash : main program, drives menu loop
604 ! timestepping : controls stepping through timesteps
605 ! titles : reads a list of titles to be used to label each timestep
606 ! transform : applies various transformations to data (log10, 1/x, etc)
607 !
608 ! File format is specified in the subroutine read_data
609 !
610 ! See the svn logs for a full ChangeLog
611 !
612 ! Plots can be of two types: co-ordinate plots or not
613 !
614 ! 1) Co-ordinate plots have co-ordinates as x and y axis
615 ! these plots can be rendered with any scalar or vector array.
616 !
617 ! The rendering routines interpolate from the particles to either
618 ! a 2D or 3D grid. In 3D you can either render to a 3D grid and take
619 ! cross sections, or render to a 2D grid using a table of the integrated
620 ! SPH kernel. This 2D rendering results in a map of the quantity
621 ! integrated through the third co-ordinate.
622 ! Rendering to a full 3D grid can be quite slow - it is used only
623 ! if many cross sections are taken all at once from the same data.
624 !
625 ! 2) other plots have a variety of options, with lines joining the particles
626 ! and various exact solutions. Plot limits can be fixed or adaptive.
627 !
628 ! multiplot enables you to set up multiple plots per page, mixing from any type.
629 !
630 !----------------------------------------------------------------------------------
631 use filenames, only:rootname,nfiles,maxfile,defaultsfile,limitsfile, &
632 fileprefix,set_filenames
633 use getdata, only:get_data
634 use geomutils, only:set_coordlabels
635 use defaults, only:defaults_set,defaults_read,defaults_set_360
636 use initialise,only:defaults_set_initial
637 use limits, only:read_limits,lim,set_limits
638 use kernels, only:ikernel,select_kernel_by_name,select_kernel
639 use mainmenu, only:menu,allowrendering,set_extracols
640 use mem_allocation, only:deallocate_all
641 use projections3D, only:setup_integratedkernel
642 use settings_data, only:buffer_data,lowmemorymode,debugmode,ndim,ncolumns,iexact,&
643 ncalc,nextra,numplot,ndataplots,device,ivegotdata,iautorender,&
644 track_string,iRescale,enforce_code_units,UseTypeinRenderings
645 use system_commands, only:get_number_arguments,get_argument
646 use system_utils, only:lenvironment,renvironment,envlist, &
647 get_environment_or_flag,get_command_option,get_command_flag
648 use asciiutils, only:read_asciifile,basename,match_column,&
649 sort_filenames_for_comparison,split,extension
650 use write_pixmap, only:isoutputformat,iwritepixmap,pixmapformat,isinputformat,ireadpixmap,readpixformat
651 use convert, only:convert_all
652 use write_sphdata, only:issphformat
653 use readwrite_griddata, only:isgridformat,print_gridformats
654 use analysis, only:isanalysis
655 use timestepping, only:timestep_loop
656 use settings_page, only:interactive,nomenu,xminpagemargin,xmaxpagemargin,yminpagemargin,ymaxpagemargin
657 use settings_part, only:initialise_coord_transforms
658 use settings_render, only:icolours,rgbfile,npix
659 use settings_xsecrot, only:xsec_nomulti,xsecpos_nomulti,taupartdepth,use3Dopacityrendering,&
660 irotate,anglex,angley,anglez
661 use colours, only:rgbtable,ncoltable,icustom
662 use readdata, only:select_data_format,guess_format,print_available_formats
663 use set_options_from_dataread, only:set_options_dataread
664 use exact, only:ispiral,nfiles_exact=>nfiles,filename_exact
665 use multiplot, only:itrans
666 use labels, only:lenlabel,label,unitslabel,shortlabel,irho
667 use interactive_routines, only:set_movie_mode
668 implicit none
669 integer :: i,ierr,nargs,ipickx,ipicky,irender,icontour,ivecplot,il
670 logical :: ihavereadfilenames,evsplash,doconvert,useall,iexist,use_360,got_format,do_multiplot
671 logical :: using_default_options,got_exact,sort,sort_pad
672 character(len=120) :: string,exactfile
673 character(len=12) :: convertformat
674 character(len=lenlabel) :: stringx,stringy,stringr,stringc,stringv
675 character(len=*), parameter :: version = 'v3.12.0 [16th Mar 2026]'
676
677 !
678 ! initialise some basic code variables
679 !
680 call defaults_set_initial
681 !
682 ! make default format ascii
683 !
684 call select_data_format('ascii',ierr)
685 !
686 ! default names for defaults file and limits file
687 !
688 fileprefix = 'splash'
689 call set_filenames(trim(fileprefix))
690
691 evsplash = .false.
692 lowmemorymode = lenvironment('SPLASH_LOW_MEM') .or. lenvironment('SPLASH_LOWMEM')
693 debugmode = lenvironment('SPLASH_DEBUG')
694 !
695 ! read all arguments off command line
696 !
697 call get_number_arguments(nargs)
698 !
699 ! extract command line arguments and filenames
700 !
701 i = 0
702 nfiles = 0
703 iwritepixmap = .false.
704 ireadpixmap = .false.
705 doconvert = .false.
706 useall = .false.
707 nomenu = .false.
708 got_format = .false.
709 got_exact = .false.
710 ipickx = 0
711 ipicky = 0
712 irender = 0
713 icontour = 0
714 ivecplot = 0
715 use_360 = .false.
716 do_multiplot = .false.
717 device = ''
718 stringx = ''
719 stringy = ''
720 stringr = ''
721 stringc = ''
722 stringv = ''
723
724 do while (i < nargs)
725 i = i + 1
726 call get_argument(i,string)
727
728 if (string(1:1)=='-') then
729 select case(trim(string(2:)))
730 case('x')
731 i = i + 1
732 call get_argument(i,stringx)
733 if (len_trim(stringx)==0) call print_usage(quit=.true.)
734 nomenu = .true.
735 case('y')
736 i = i + 1
737 call get_argument(i,stringy)
738 if (len_trim(stringy)==0) call print_usage(quit=.true.)
739 nomenu = .true.
740 case('multi','-multiplot','-multi')
741 do_multiplot = .true.
742 nomenu = .true.
743 case('render','r','ren')
744 i = i + 1
745 call get_argument(i,stringr)
746 if (len_trim(stringr)==0) call print_usage(quit=.true.)
747 nomenu = .true.
748 case('contour','c','cont','con')
749 i = i + 1
750 call get_argument(i,stringc)
751 if (len_trim(stringc)==0) call print_usage(quit=.true.)
752 case('vec','vecplot')
753 i = i + 1
754 call get_argument(i,stringv)
755 if (len_trim(stringv)==0) call print_usage(quit=.true.)
756 nomenu = .true.
757 case('dev','device')
758 i = i + 1
759 call get_argument(i,device)
760 case('movie','-movie')
761 device = '/mp4'
762 case('l')
763 i = i + 1
764 call get_argument(i,limitsfile)
765 case('d')
766 i = i + 1
767 call get_argument(i,defaultsfile)
768 case('p')
769 i = i + 1
770 call get_argument(i,string)
771 if (len_trim(string) > 0) then
772 fileprefix = trim(string)
773 call set_filenames(trim(fileprefix))
774 endif
775 case('o','writepix','wpix')
776 i = i + 1
777 call get_argument(i,string)
778 if (isoutputformat(string)) then
779 iwritepixmap = .true.
780 pixmapformat = trim(string)
781 else
782 stop
783 endif
784 case('readpix','rpix')
785 i = i + 1
786 call get_argument(i,string)
787 if (isinputformat(string)) then
788 ireadpixmap = .true.
789 readpixformat = trim(string)
790 else
791 stop
792 endif
793 case('e','ev')
794 evsplash = .true.
795 fileprefix = 'evsplash'
796 call set_filenames(trim(fileprefix))
797 got_format = .true.
798 case('360','-360','4pi','fourpi')
799 use_360 = .true.
800 ipickx = 2
801 ipicky = 3
802 if (len_trim(stringr)==0) stringr = 'density'
803 nomenu = .true.
804 case('exact')
805 i = i + 1
806 call get_argument(i,string)
807 if (len_trim(string) > 0) then
808 exactfile = string
809 got_exact = .true.
810 else
811 stop 'error in -exact flag'
812 endif
813 case('lowmem','lm')
814 lowmemorymode = .true.
815 case('nolowmem','nlm')
816 lowmemorymode = .false.
817 case('-buffer','b','buffer')
818 buffer_data = .true.
819 case('f','-format')
820 i = i + 1
821 call get_argument(i,string)
822 call select_data_format(string,ierr)
823 if (ierr/=0) then
824 if (len_trim(string) > 0) then
825 print "(a)",' *** file format '''//trim(string)//''' not found ***'
826 endif
827 call print_available_formats
828 stop
829 endif
830 got_format = .true.
831 case('-formats')
832 call print_available_formats
833 stop
834 case('-help')
835 call print_usage
836 print "(/,a,/)",'Userguide: https://splash-viz.readthedocs.io'
837 stop
838 case default
839 if (.not. got_format) call select_data_format(string(2:),ierr)
840 if (ierr /= 0 .and. string(2:2) /= '-') then
841 call print_usage
842 print "(a)",'unknown command line argument '''//trim(string)//''''
843 stop
844 endif
845 end select
846 elseif (trim(string)=='to' .or. trim(string)=='allto') then
847 !
848 !--for converting SPH formats
849 !
850 if (trim(string)=='allto') useall = .true.
851 i = i + 1
852 call get_argument(i,string)
853 if (isgridformat(string)) then
854 doconvert = .true.
855 convertformat = trim(string)
856 elseif (issphformat(string)) then
857 doconvert = .true.
858 convertformat = trim(string)
859 else
860 call print_gridformats('all')
861 stop
862 endif
863 elseif (trim(string)=='calc') then
864 !
865 !--for performing analysis on a sequence of dump files
866 !
867 i = i + 1
868 call get_argument(i,string)
869 if (isanalysis(string)) then
870 doconvert = .true.
871 convertformat = trim(string)
872 else
873 stop
874 endif
875 elseif (len_trim(string) > 0) then
876 nfiles = nfiles + 1
877 if (nfiles <= maxfile) then
878 rootname(nfiles) = trim(string)
879 endif
880 endif
881 enddo
882
883 !
884 ! select -ev mode automatically if filename ends in .ev, .mdot or .out
885 !
886 if (nfiles > 0) then
887 il = len_trim(rootname(1))
888 if (extension(rootname(1))=='.ev' .or. &
889 extension(rootname(1))=='.mdot' .or. &
890 extension(rootname(1))=='.out') then
891 evsplash = .true.
892 fileprefix = 'evsplash'
893 call set_filenames(trim(fileprefix))
894 endif
895 endif
896 !
897 ! print header
898 !
899 call print_header
900 !
901 ! set default options (used if defaults file does not exist)
902 !
903 call defaults_set(evsplash)
904 if (use_360) call defaults_set_360()
905
906 !
907 ! read default options from file if it exists
908 !
909 call defaults_read(defaultsfile)
910 !
911 ! look for a system-wide defaults file if the environment
912 ! variable SPLASH_DEFAULTS is set, no local file is present
913 ! and no alternative prefix has been set.
914 !
915 using_default_options = .true.
916 inquire(file=defaultsfile,exist=iexist)
917 if (iexist) then
918 using_default_options = .false.
919 elseif (trim(fileprefix)=='splash') then
920 call get_environment_or_flag('SPLASH_DEFAULTS',string)
921 if (len_trim(string) /= 0) then
922 i = index(string,'.defaults')
923 if (i > 0) then
924 defaultsfile = trim(string)
925 else
926 defaultsfile = trim(string)//'.defaults'
927 endif
928 print "(a)",' Using SPLASH_DEFAULTS='//trim(defaultsfile)
929 call defaults_read(defaultsfile)
930 call set_filenames(trim(fileprefix))
931 using_default_options = .false.
932 endif
933 endif
934
935 !
936 ! set options based on command line flags that OVERRIDE settings in the defaults file
937 !
938 if (get_command_flag('kappa')) then ! e.g. --kappa=10.0
939 taupartdepth = get_command_option('kappa',default=taupartdepth)
940 use3Dopacityrendering = .true.
941 endif
942 if (get_command_flag('xsec')) then ! e.g. --xsec=1.0
943 xsecpos_nomulti = get_command_option('xsec',default=xsecpos_nomulti)
944 xsec_nomulti = .true. ! set cross section to true if --xsec was set
945 endif
946 if (get_command_flag('anglex')) then ! e.g. --anglex=1.0
947 anglex = get_command_option('anglex',default=anglex)
948 irotate = .true.
949 endif
950 if (get_command_flag('angley')) then ! e.g. --angley=1.0
951 angley = get_command_option('angley',default=angley)
952 irotate = .true.
953 endif
954 if (get_command_flag('anglez')) then ! e.g. --anglez=1.0
955 anglez = get_command_option('anglez',default=anglez)
956 irotate = .true.
957 endif
958 if (get_command_flag('npix')) then ! e.g. --npix=128
959 npix = get_command_option('npix',default=real(npix))
960 endif
961 if (get_command_flag('track')) then ! e.g. --track=508264
962 call get_environment_or_flag('SPLASH_TRACK',track_string)
963 endif
964 if (get_command_flag('wake')) then
965 iexact = 17
966 ispiral = 1
967 endif
968 if (.not.got_exact .and. get_command_flag('exact')) then ! e.g. --exact=myfile.dat
969 iexact = 2
970 call envlist('exact',nfiles_exact,filename_exact)
971 if (len_trim(filename_exact(1))==0) then
972 print "(a)",'error command line argument --exact=file requires filename'
973 stop
974 endif
975 elseif (got_exact) then
976 iexact = 2 ! override setting in defaults file
977 call split(exactfile,',',filename_exact,nfiles_exact)
978 endif
979 if (get_command_flag('codeunits') .or. get_command_flag('code')) then
980 iRescale = .false.
981 enforce_code_units = .true.
982 endif
983 xminpagemargin = renvironment('SPLASH_MARGIN_XMIN',errval=0.)
984 xmaxpagemargin = renvironment('SPLASH_MARGIN_XMAX',errval=0.)
985 yminpagemargin = renvironment('SPLASH_MARGIN_YMIN',errval=0.)
986 ymaxpagemargin = renvironment('SPLASH_MARGIN_YMAX',errval=0.)
987 !
988 ! check that we have got filenames
989 !
990 if (nfiles > 0) then
991 if (nfiles > maxfile) then
992 print*,' WARNING: number of files >= array size: setting nfiles = ',maxfile
993 nfiles = maxfile
994 endif
995 endif
996 if (nfiles >= 1 .and. rootname(1)(1:1) /= ' ') then
997 ihavereadfilenames = .true.
998 if (nfiles > 1) print*,nfiles,' filenames read from command line'
999 else
1000 ihavereadfilenames = .false.
1001 !print "(a)",' no filenames read from command line'
1002 call read_asciifile(trim(fileprefix)//'.filenames',nfiles,rootname,skip=.true.)
1003 !print*,nfiles,' filenames read from '//trim(fileprefix)//'.filenames file'
1004 if (nfiles > 0) then
1005 ihavereadfilenames = .true.
1006 else
1007 call get_argument(0,string)
1008 print "(/,a/,/,5x,a)",' Usage: ',trim(basename(string))//' snap_0* (or use '&
1009 //trim(fileprefix)//'.filenames to list files)'
1010 print "(5x,a,/)",trim(basename(string))//' --help (for all command line options)'
1011 stop
1012 endif
1013 endif
1014 if (lowmemorymode) print "(a)",' << running in low memory mode >>'
1015
1016 !
1017 ! Guess format if not already set
1018 !
1019 if (.not. got_format .and. ihavereadfilenames) then
1020 call guess_format(nfiles,rootname,ierr)
1021 endif
1022
1023 ! options to sort filenames
1024 sort = get_command_flag('sort')
1025 sort_pad = get_command_flag('sortpad')
1026 if (ihavereadfilenames .and. (sort .or. sort_pad)) then
1027 call sort_filenames_for_comparison(nfiles,rootname,pad=sort_pad)
1028 endif
1029
1030 if (ikernel==0) then
1031 !--if no kernel has been set
1032 call get_environment_or_flag('SPLASH_KERNEL',string)
1033 if (len_trim(string) > 0) then
1034 call select_kernel_by_name(string)
1035 else
1036 call select_kernel(0)
1037 endif
1038 else
1039 call select_kernel(ikernel)
1040 endif
1041
1042 ! set geometry defaults
1043 call initialise_coord_transforms
1044
1045 if (doconvert) then
1046
1047 !
1048 ! batch convert all dump files into the output format
1049 !
1050 call convert_all(convertformat,ihavereadfilenames,useall)
1051
1052 else
1053 !
1054 ! read data from file
1055 !
1056 if (buffer_data) then
1057 call get_data(-1,ihavereadfilenames)
1058 else
1059 call get_data(1,ihavereadfilenames,firsttime=.true.)
1060 endif
1061 !
1062 ! override some options based on specifics of the data
1063 ! (e.g. switch on sink particles if there is no gas)
1064 !
1065 call set_options_dataread()
1066 !
1067 ! translate from string to column id
1068 !
1069 if (nomenu) then
1070 if (ipickx==0) ipickx = match_column(shortlabel(label(1:numplot),unitslabel(1:numplot),lc=.true.),stringx)
1071 if (ipicky==0) ipicky = match_column(shortlabel(label(1:numplot),unitslabel(1:numplot),lc=.true.),stringy)
1072 irender = match_column(shortlabel(label(1:numplot),unitslabel(1:numplot),lc=.true.),stringr)
1073 icontour = match_column(shortlabel(label(1:numplot),unitslabel(1:numplot),lc=.true.),stringc)
1074 ivecplot = match_column(shortlabel(label(1:numplot),unitslabel(1:numplot),lc=.true.),stringv)
1075 endif
1076 !
1077 ! for some data reads we can automatically plot a particular column
1078 !
1079 if (irender == 0 .and. iautorender > 0) then
1080 irender = iautorender
1081 nomenu = .true.
1082 elseif (ncolumns==2) then
1083 nomenu = .true.
1084 if (ipicky==0) ipicky = 2
1085 if (ipickx==0) ipickx = 1
1086 endif
1087
1088 ! set default device to /xw if command line flags set
1089 if (nomenu .and. len_trim(device)==0) device = '/xw'
1090
1091 ! read tabulated colour table, if necessary
1092 if (abs(icolours)==icustom) then
1093 call read_asciifile(rgbfile,ncoltable,rgbtable,ierr)
1094 if (ierr /= 0 .or. ncoltable <= 0) then
1095 print "(a)",'ERROR: could not read colours from '//trim(rgbfile)
1096 else
1097 print "(a,i3,a)",'read ',ncoltable,' colours from '//trim(rgbfile)
1098 endif
1099 endif
1100 !
1101 ! setup kernel table for fast column density plots in 3D
1102 !
1103 call setup_integratedkernel
1104
1105 !
1106 ! read plot limits from file (overrides get_data limits settings)
1107 !
1108 if (ivegotdata) call read_limits(trim(limitsfile),ierr)
1109 !
1110 ! if device is mp4 auto-render column density in Hollywood mode if nothing is set
1111 !
1112 if (device == '/mp4' .and. irender == 0) then
1113 irender = irho
1114 nomenu = .true.
1115 if (using_default_options) call set_movie_mode(.false.)
1116 endif
1117 !
1118 ! use log colour bar by default if more than 3 orders of magnitude range
1119 ! (and no limits file and using default options)
1120 !
1121 if (ivegotdata .and. ierr /= 0 .and. irender > 0 .and. using_default_options) then
1122 ! get masked limits to avoid dead particles giving 0 as lower bound
1123 call set_limits(1,1,irender,irender,UseTypeinRenderings)
1124 if (all(lim(irender,:) > 0.)) then
1125 if (log10(lim(irender,2)/lim(irender,1)) > 3) itrans(irender) = 1
1126 endif
1127 endif
1128
1129 if (nomenu) then
1130 !
1131 ! initialise the things we would need if we called menu directly
1132 !
1133 call set_extracols(ncolumns,ncalc,nextra,numplot,ndataplots)
1134 call set_coordlabels(numplot)
1135 interactive = .false.
1136 !
1137 ! check command line plot invocation
1138 !
1139 if (do_multiplot) then
1140 if (ipicky > 0) print "(a)",' WARNING: ignoring -y option with -multi flag'
1141 ipicky = numplot+1
1142 endif
1143 if (ipicky > 0 .and. ipicky <= numplot+1) then
1144 if (ipicky <= numplot .and. (ipickx==0 .or. ipickx > numplot)) then
1145 print "(a)",' ERROR: x plot not set or out of bounds (use -x col)'
1146 stop
1147 endif
1148 if (irender > 0) then
1149 if (.not.allowrendering(ipicky,ipickx,xsec_nomulti)) then
1150 print "(a)",' ERROR: cannot render with x, y choice (must be coords)'
1151 stop
1152 endif
1153 if (icontour > numplot .or. icontour < 0) then
1154 print "(a)",' ERROR: contour plot choice out of bounds'
1155 stop
1156 endif
1157 elseif (icontour > 0) then
1158 print "(a)",' ERROR: -cont also requires -render setting'
1159 stop
1160 elseif (use_360) then
1161 print "(a)",' ERROR -360 also requires -render setting (e.g. -r 6)'
1162 stop
1163 endif
1164 else
1165 if (irender > 0 .and. ndim >= 2 .and. .not. (ipicky > 0 .or. ipickx > 0)) then
1166 ipicky = 2
1167 ipickx = 1
1168 if (.not.allowrendering(ipicky,ipickx)) then
1169 print "(a,i2,i2)",' ERROR: cannot render',ipicky,ipickx
1170 stop
1171 endif
1172 if (icontour > numplot .or. icontour < 0) then
1173 print "(a)",' ERROR: contour plot choice out of bounds'
1174 stop
1175 endif
1176 else
1177 print "(a)",' ERROR: y plot not set or out of bounds (use -y col)'
1178 stop
1179 endif
1180 endif
1181 if (irender > numplot .or. irender < 0) then
1182 print "(/,a)",' ERROR: render plot choice out of bounds'
1183 stop
1184 endif
1185
1186 call timestep_loop(ipicky,ipickx,irender,icontour,ivecplot)
1187 !
1188 ! if we invoked an interactive device, enter the menu as usual, otherwise finish
1189 !
1190 if (interactive) call menu
1191 else
1192 !
1193 ! enter main menu
1194 !
1195 call menu
1196 endif
1197 endif
1198
1199 !
1200 ! deallocate all memory (not strictly necessary)
1201 !
1202 call deallocate_all
1203
1204 contains
1205
1206 !------------------------------------------------------
1207 ! this subroutine prints the splash screen on startup
1208 !------------------------------------------------------
1209 subroutine print_header
1210
1211 print 10
1212 10 format( &
1213 " _ _ _ _ _ ",/, &
1214 " _(_) ___ _ __ | | __ _ ___| |__ (_) _ (_)",/, &
1215 " _ (_) _ / __| '_ \| |/ _` / __| '_ \ _ (_) ",/, &
1216 " (_) _ (_) \__ \ |_) | | (_| \__ \ | | | _ (_) _ ",/, &
1217 " (_) _ |___/ .__/|_|\__,_|___/_| |_| (_) _ (_) ",/, &
1218 " (_) (_)|_| (_) (_) (_)(_) (_)(_) (_)(_) ")
1219 print 20
1220 20 format(/, &
1221 ' ( B | y ) ( D | a | n | i | e | l ) ( P | r | i | c | e )',/)
1222
1223 print "(a)",' ( '//trim(version)//' Copyright (C) 2005-2025 )'
1224 print 30
1225 30 format(/, &
1226 ' * SPLASH comes with ABSOLUTELY NO WARRANTY. This is ',/, &
1227 ' free software; can redistribute w/conditions (see LICENSE) *',/,/, &
1228 ' https://splash-viz.readthedocs.io',/,/, &
1229 ' Please cite Price (2007), PASA 24, 159 if you use SPLASH in print',/)
1230
1231 end subroutine print_header
1232
1233 subroutine print_usage(quit)
1234 use filenames, only:tagline
1235 logical, intent(in), optional :: quit
1236 logical :: ltemp
1237
1238 print "(a)",trim(tagline)
1239 print "(a,/)",trim(version)
1240 print "(a,/)",'Usage: splash file1 file2 file3...'
1241 print "(a,/,a,/)",'Usage with flags: splash [-f format] [-p fileprefix] [-ev] ', &
1242 ' [-x col] [-y col] [-r col] [-cont col] file1 file2 ...'
1243
1244 print "(a,/)",'Command line options:'
1245 print "(a)",' -f format : input file format to be read (default is ascii, --formats for full list)'
1246 print "(a)",' -p fileprefix : change prefix to ALL settings files read/written by splash '
1247 !print "(a)",' -d defaultsfile : change name of defaults file read/written by splash'
1248 !print "(a)",' -l limitsfile : change name of limits file read/written by splash'
1249 print "(a)",' -e, -ev : use default options best suited for line plotting (.ev files)'
1250 print "(a)",' -360 : set default options suited to 360 video'
1251 print "(a)",' -b, --buffer : buffer all data files into memory'
1252 !print "(a)",' -lm, -lowmem : use low memory mode [applies only to sphNG data read at present]'
1253 print "(a)",' -o pixformat : dump pixel map in specified format (use just -o for list of formats)'
1254 print "(/,a,/)",'Command line plotting mode:'
1255 print "(a)",' -x column : x axis'
1256 print "(a)",' -y column : y axis'
1257 print "(a)",' -r[ender] column : column to render (will use 1 and 2 as x,y if -x,-y not specified)'
1258 print "(a)",' -vec[tor] column : vector quantity to plot with arrows'
1259 print "(a)",' -c[ontour] column : contoured quantity'
1260 print "(a)",' -multi : multiplot'
1261 print "(a)",' -dev device : specify plotting device on command line (e.g. -dev /xw)'
1262 print "(a)",' --movie : shortcut for -dev /mp4 to make a movie from plot sequence'
1263 print "(a)",' --xsec=1.0 : specify location of cross section slice'
1264 print "(a)",' --kappa=1.0 : specify opacity, and turn on opacity rendering'
1265 print "(a)",' --anglex=30 : rotate around x axis (similarly --angley, --anglez)'
1266 print "(a)",' --code : enforce code units (also --codeunits)'
1267 print "(a)",' --sink=1 : centre on sink particle number 1'
1268 print "(a)",' --origin=1,0,0 : centre on specified x,y,z coordinates'
1269 print "(a)",' --origin=666 : set coordinate system origin to particle number 666'
1270 print "(a)",' --origin=maxdens : set coordinate system origin to particle at maximum density'
1271 print "(a)",' --track=666 : track particle number 666'
1272 print "(a)",' --track=maxdens : track particle at maximum density'
1273 print "(a)",' --exact=file1,f2 : read and plot exact solution from ascii files file1 and f2'
1274 print "(a)",' --sort : sort filenames for comparison (e.g. snap_000 snap1_000 snap2_000)'
1275 print "(a)",' --sortpad : sort filenames and pad all sequences to same length'
1276 call print_available_formats('short')
1277 print "(a)"
1278 ltemp = issphformat('none')
1279 call print_gridformats('short')
1280 print "(a)"
1281 ltemp = isanalysis('none')
1282
1283 if (present(quit)) then
1284 if (quit) stop
1285 endif
1286
1287 end subroutine print_usage
1288
1289 end program splash