From 57c1ed2fb35446595ab096dc7618e9c108116f2d Mon Sep 17 00:00:00 2001 From: Stephen Neilson <36410751+s-neilson@users.noreply.github.com> Date: Fri, 26 Jun 2026 14:49:17 +1000 Subject: [PATCH 01/13] When writing ascii pixmaps, values requiring exponents with three or more digits are now truncated to values that can be formatted using an exponent of two digits. This prevents invalid values from being written to the file as ascii pixmaps are written with values that have exponents of two digits. The user is given warnings when the truncation happens. --- src/write_pixmap.f90 | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/write_pixmap.f90 b/src/write_pixmap.f90 index 531f1fa1..e00c74b5 100644 --- a/src/write_pixmap.f90 +++ b/src/write_pixmap.f90 @@ -133,11 +133,13 @@ end subroutine writepixmap subroutine write_pixmap_ascii(datpix,npixx,npixy,xmin,ymin,dx,datmin,datmax,label,filename,time) integer, intent(in) :: npixx,npixy real, intent(in), dimension(npixx,npixy) :: datpix + real, dimension(npixx,npixy) :: datpixTruncated real, intent(in) :: xmin,ymin,dx,datmin,datmax,time character(len=*), intent(in) :: label,filename character(len=10) :: stringx,stringy character(len=30) :: fmtstring integer :: ierr,j + integer :: nSmallNegative, nSmallPositive, nLargeNegative, nLargePositive integer, parameter :: iunit = 166 ! !--write ascii file @@ -162,18 +164,42 @@ subroutine write_pixmap_ascii(datpix,npixx,npixy,xmin,ymin,dx,datmin,datmax,labe write(iunit,"(a,1pe14.6)", err=66) '# time = ',time write(iunit,"(a)",err=66) '# '//trim(adjustl(stringx))//' '//trim(adjustl(stringy)) + datpixTruncated=datpix + nSmallNegative = count((datpix > -9.999999E-99) .and. (datpix < 0.0)) + nSmallPositive = count((datpix < 9.999999E-99) .and. (datpix > 0.0)) + nLargeNegative = count(datpix < -9.999999E99) + nLargePositive = count(datpix > 9.999999E99) + where((datpix > -9.999999E-99) .and. (datpix < 0.0)) datpixTruncated = -9.999999E-99 + where((datpix < 9.999999E-99) .and. (datpix > 0.0)) datpixTruncated = 9.999999E-99 + where(datpix < -9.999999E99) datpixTruncated = -9.999999E99 + where(datpix > 9.999999E99) datpixTruncated = 9.999999E99 + write(fmtstring,"(a,i6,a)",iostat=ierr) '(',npixx,'(1pe14.6))' if (ierr /= 0) then do j=1,npixy - write(iunit,*,err=66) datpix(1:npixx,j) + write(iunit,*,err=66) datpixTruncated(1:npixx,j) enddo else do j=1,npixy - write(iunit,fmtstring,err=66) datpix(1:npixx,j) + write(iunit,fmtstring,err=66) datpixTruncated(1:npixx,j) enddo endif close(iunit) print "(a)",'OK' + + if (nSmallNegative > 0) then + print "(a,i9,a)"," WARNING: ",nSmallNegative," pixel values are between -9.999999E-99 and 0, setting them to -9.999999E-99" + endif + if (nSmallPositive > 0) then + print "(a,i9,a)"," WARNING: ",nSmallPositive," pixels values are between 0 and 9.999999E-99, setting them to 9.999999E-99" + endif + if (nLargeNegative > 0) then + print "(a,i9,a)"," WARNING: ",nLargeNegative," pixels values are smaller than -9.999999E99, setting them to -9.999999E99" + endif + if (nLargePositive > 0) then + print "(a,i9,a)"," WARNING: ",nLargePositive," pixels values are larger than 9.999999E99, setting them to 9.999999E99" + endif + return 66 continue From d2bb5c3c2ccd283f6266577ae08fb9f7a08e39b6 Mon Sep 17 00:00:00 2001 From: Stephen Neilson <36410751+s-neilson@users.noreply.github.com> Date: Fri, 26 Jun 2026 15:11:35 +1000 Subject: [PATCH 02/13] For writing ascii pixmaps, fixed the smallest/largest values that can be represented with a negative exponent of two digits. --- src/write_pixmap.f90 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/write_pixmap.f90 b/src/write_pixmap.f90 index e00c74b5..2f88321c 100644 --- a/src/write_pixmap.f90 +++ b/src/write_pixmap.f90 @@ -165,12 +165,12 @@ subroutine write_pixmap_ascii(datpix,npixx,npixy,xmin,ymin,dx,datmin,datmax,labe write(iunit,"(a)",err=66) '# '//trim(adjustl(stringx))//' '//trim(adjustl(stringy)) datpixTruncated=datpix - nSmallNegative = count((datpix > -9.999999E-99) .and. (datpix < 0.0)) - nSmallPositive = count((datpix < 9.999999E-99) .and. (datpix > 0.0)) + nSmallNegative = count((datpix > -1.0E-99) .and. (datpix < 0.0)) + nSmallPositive = count((datpix < 1.0E-99) .and. (datpix > 0.0)) nLargeNegative = count(datpix < -9.999999E99) nLargePositive = count(datpix > 9.999999E99) - where((datpix > -9.999999E-99) .and. (datpix < 0.0)) datpixTruncated = -9.999999E-99 - where((datpix < 9.999999E-99) .and. (datpix > 0.0)) datpixTruncated = 9.999999E-99 + where((datpix > -9.999999E-99) .and. (datpix < 0.0)) datpixTruncated = -1.0E-99 + where((datpix < 9.999999E-99) .and. (datpix > 0.0)) datpixTruncated = 1.0E-99 where(datpix < -9.999999E99) datpixTruncated = -9.999999E99 where(datpix > 9.999999E99) datpixTruncated = 9.999999E99 @@ -188,10 +188,10 @@ subroutine write_pixmap_ascii(datpix,npixx,npixy,xmin,ymin,dx,datmin,datmax,labe print "(a)",'OK' if (nSmallNegative > 0) then - print "(a,i9,a)"," WARNING: ",nSmallNegative," pixel values are between -9.999999E-99 and 0, setting them to -9.999999E-99" + print "(a,i9,a)"," WARNING: ",nSmallNegative," pixel values are between -1.0E-99 and 0, setting them to -1.0E-99" endif if (nSmallPositive > 0) then - print "(a,i9,a)"," WARNING: ",nSmallPositive," pixels values are between 0 and 9.999999E-99, setting them to 9.999999E-99" + print "(a,i9,a)"," WARNING: ",nSmallPositive," pixels values are between 0 and 1.0E-99, setting them to 1.0E-99" endif if (nLargeNegative > 0) then print "(a,i9,a)"," WARNING: ",nLargeNegative," pixels values are smaller than -9.999999E99, setting them to -9.999999E99" From a894ddf10c6357742ddbe602874241bfb8a59aaa Mon Sep 17 00:00:00 2001 From: Stephen Neilson <36410751+s-neilson@users.noreply.github.com> Date: Fri, 26 Jun 2026 15:21:28 +1000 Subject: [PATCH 03/13] For writing ascii pixmaps, fixed some more references to incorrect limits for the largest and smallest values that can be represented with negative expodents of two digits. --- src/write_pixmap.f90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/write_pixmap.f90 b/src/write_pixmap.f90 index 2f88321c..4f0c72f1 100644 --- a/src/write_pixmap.f90 +++ b/src/write_pixmap.f90 @@ -169,8 +169,8 @@ subroutine write_pixmap_ascii(datpix,npixx,npixy,xmin,ymin,dx,datmin,datmax,labe nSmallPositive = count((datpix < 1.0E-99) .and. (datpix > 0.0)) nLargeNegative = count(datpix < -9.999999E99) nLargePositive = count(datpix > 9.999999E99) - where((datpix > -9.999999E-99) .and. (datpix < 0.0)) datpixTruncated = -1.0E-99 - where((datpix < 9.999999E-99) .and. (datpix > 0.0)) datpixTruncated = 1.0E-99 + where((datpix > -1.0E-99) .and. (datpix < 0.0)) datpixTruncated = -1.0E-99 + where((datpix < 1.0E-99) .and. (datpix > 0.0)) datpixTruncated = 1.0E-99 where(datpix < -9.999999E99) datpixTruncated = -9.999999E99 where(datpix > 9.999999E99) datpixTruncated = 9.999999E99 From dd473f1a45b8c68949171baa601260dd7c653e07 Mon Sep 17 00:00:00 2001 From: Stephen Neilson <36410751+s-neilson@users.noreply.github.com> Date: Sat, 27 Jun 2026 01:15:45 +1000 Subject: [PATCH 04/13] In write_pixmap_ascii, ensured that datpixTruncated is allocated to the heap instead of the stack. --- src/write_pixmap.f90 | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/write_pixmap.f90 b/src/write_pixmap.f90 index 4f0c72f1..08275b16 100644 --- a/src/write_pixmap.f90 +++ b/src/write_pixmap.f90 @@ -133,7 +133,7 @@ end subroutine writepixmap subroutine write_pixmap_ascii(datpix,npixx,npixy,xmin,ymin,dx,datmin,datmax,label,filename,time) integer, intent(in) :: npixx,npixy real, intent(in), dimension(npixx,npixy) :: datpix - real, dimension(npixx,npixy) :: datpixTruncated + real, dimension(:,:), allocatable :: datpixTruncated real, intent(in) :: xmin,ymin,dx,datmin,datmax,time character(len=*), intent(in) :: label,filename character(len=10) :: stringx,stringy @@ -149,6 +149,15 @@ subroutine write_pixmap_ascii(datpix,npixx,npixy,xmin,ymin,dx,datmin,datmax,labe print*,'error opening '//trim(filename) return endif + + allocate(datpixTruncated(npixx,npixy),stat=ierr) + if (ierr /= 0) then + print *,"ERROR: Memory allocation of datpixTruncated failed" + close(iunit) + return + endif + datpixTruncated=datpix + write(*,"(a)",ADVANCE='NO') '> writing pixel map to file '//trim(filename)//' ...' write(stringx,"(i10)") npixx @@ -162,9 +171,8 @@ subroutine write_pixmap_ascii(datpix,npixx,npixy,xmin,ymin,dx,datmin,datmax,labe write(iunit,"(a,1pe14.6,a,1pe14.6)",err=66) '# x axis: min = ',xmin,' max = ',xmin+(npixx-1)*dx write(iunit,"(a,1pe14.6,a,1pe14.6)",err=66) '# y axis: min = ',ymin,' max = ',ymin+(npixy-1)*dx write(iunit,"(a,1pe14.6)", err=66) '# time = ',time - write(iunit,"(a)",err=66) '# '//trim(adjustl(stringx))//' '//trim(adjustl(stringy)) - - datpixTruncated=datpix + write(iunit,"(a)",err=66) '# '//trim(adjustl(stringx))//' '//trim(adjustl(stringy)) + nSmallNegative = count((datpix > -1.0E-99) .and. (datpix < 0.0)) nSmallPositive = count((datpix < 1.0E-99) .and. (datpix > 0.0)) nLargeNegative = count(datpix < -9.999999E99) @@ -184,6 +192,7 @@ subroutine write_pixmap_ascii(datpix,npixx,npixy,xmin,ymin,dx,datmin,datmax,labe write(iunit,fmtstring,err=66) datpixTruncated(1:npixx,j) enddo endif + deallocate(datpixTruncated) close(iunit) print "(a)",'OK' From ddaf39a2b4bea4e960ec9e8a5fd8f1b1f78698e4 Mon Sep 17 00:00:00 2001 From: Stephen Neilson <36410751+s-neilson@users.noreply.github.com> Date: Sun, 28 Jun 2026 01:28:39 +1000 Subject: [PATCH 05/13] Rename write_pixmap.f90 to write_pixmap.F90 --- src/{write_pixmap.f90 => write_pixmap.F90} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/{write_pixmap.f90 => write_pixmap.F90} (100%) diff --git a/src/write_pixmap.f90 b/src/write_pixmap.F90 similarity index 100% rename from src/write_pixmap.f90 rename to src/write_pixmap.F90 From b012c38411e44f8af4f03028d046893ac52a0133 Mon Sep 17 00:00:00 2001 From: Stephen Neilson <36410751+s-neilson@users.noreply.github.com> Date: Sun, 28 Jun 2026 01:36:24 +1000 Subject: [PATCH 06/13] Changed the extension of write_pixmap to .F90 in build/Makefile so it can use the preprocessor. --- build/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/Makefile b/build/Makefile index b9aa1a26..05b4f868 100644 --- a/build/Makefile +++ b/build/Makefile @@ -473,7 +473,7 @@ SOURCES= $(PLOTLIB) globaldata.f90 physcon.f90 utils_vectors.f90 \ interpolate3D_proj_geom.f90 \ interpolate3D_opacity.f90 interpolate_vec.f90 interpolate3D.f90 \ units.f90 limits.f90 geomutils.f90 dataread_utils.f90 \ - write_data_gadget.f90 write_data_phantom.f90 write_pfm.f90 write_pixmap.f90 \ + write_data_gadget.f90 write_data_phantom.f90 write_pfm.f90 write_pixmap.F90 \ labels_chem.f90 write_griddata.f90 write_sphdata.f90 read_composition.F90 \ $(SYSTEMFILE) system_utils.f90 \ cubicsolve.f90 discplot.f90 fparser.f90 parsetext.f90 \ From 8556189e4707f2bf508a7ea09ec3f9c21a18a22f Mon Sep 17 00:00:00 2001 From: Stephen Neilson <36410751+s-neilson@users.noreply.github.com> Date: Sun, 28 Jun 2026 01:37:19 +1000 Subject: [PATCH 07/13] Changed the extension of write_pixmap to .F90 in build/.depends so it can use the preprocessor. --- build/.depends | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/.depends b/build/.depends index efe4b84f..ae980be4 100644 --- a/build/.depends +++ b/build/.depends @@ -165,5 +165,5 @@ write_data_phantom.o : write_data_phantom.f90 write_fits.o : write_fits.f90 write_griddata.o : write_griddata.F90 asciiutils.o write_pfm.o : write_pfm.f90 -write_pixmap.o : write_pixmap.f90 asciiutils.o colours.o labels.o write_pfm.o globaldata.o +write_pixmap.o : write_pixmap.F90 asciiutils.o colours.o labels.o write_pfm.o globaldata.o write_sphdata.o : write_sphdata.f90 geomutils.o globaldata.o write_data_gadget.o write_data_phantom.o globaldata.o globaldata.o units.o labels.o asciiutils.o From 98499fd00be86c65e6646883559b71c3c3a912c7 Mon Sep 17 00:00:00 2001 From: Stephen Neilson <36410751+s-neilson@users.noreply.github.com> Date: Sun, 28 Jun 2026 02:15:36 +1000 Subject: [PATCH 08/13] For write_pixmap.F90, made it so that the write_ascii_pixmap value truncation will only occur when SPLASH is compiled in double precision mode as it is unnecessary and creates problems in single precision mode. Also added truncation (only in double precision mode) to the header datmin and datmax values for the ascii and ppm pixmaps as they use the same formatting string as the pixel values. --- src/write_pixmap.F90 | 64 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 5 deletions(-) diff --git a/src/write_pixmap.F90 b/src/write_pixmap.F90 index 08275b16..f7a80092 100644 --- a/src/write_pixmap.F90 +++ b/src/write_pixmap.F90 @@ -38,10 +38,53 @@ module write_pixmap public :: isinputformat,isoutputformat public :: readpixmap + !The limits for numbers that can be written with the formatting string "1pe14.6" +#ifdef DP + real, parameter, private :: sN = -1.0E-99 + real, parameter, private :: sP = 1.0E-99 + real, parameter, private :: lN = -9.999999E99 + real, parameter, private :: lP = 9.999999E99 +#endif + private contains +!----------------------------------------------------------------- +! Truncates the datmin and datmax values for pixmap headers if they are outside the range +! that can be formatted with the formatting string "1pe14.6" +!----------------------------------------------------------------- +subroutine truncateHeaderMinMax(datmin,datmax,datminTruncated,datmaxTruncated) + real, intent(in) :: datmin,datmax + real, intent(out) :: datminTruncated,datmaxTruncated + logical :: datminChanged = .false. + logical :: datmaxChanged = .false. + + datminTruncated=datmin + datmaxTruncated=datmax + +#ifdef DP + if((datmin > sN) .and. (datmin < 0.0)) then; datminTruncated = sN; datminChanged=.true.; endif + if((datmin < sP) .and. (datmin > 0.0)) then; datminTruncated = sP; datminChanged=.true.; endif + if(datmin < lN) then; datminTruncated = lN; datminChanged=.true.; endif + if(datmin > lP) then; datminTruncated = lP; datminChanged=.true.; endif + + if((datmax > sN) .and. (datmax < 0.0)) then; datmaxTruncated = sN; datmaxChanged=.true.; endif + if((datmax < sP) .and. (datmax > 0.0)) then; datmaxTruncated = sP; datmaxChanged=.true.; endif + if(datmax < lN) then; datmaxTruncated = lN; datmaxChanged=.true.; endif + if(datmax > lP) then; datmaxTruncated = lP; datmaxChanged=.true.; endif + + if(datminChanged) then + print "(a,1pe14.6,a)"," WARNING: pixmap header datmin altered to the value",datminTruncated," as it was either "& + //">9.999999E99, <-9.999999E99, (>1.0E-99 and <0), (<1.0E-99 and >0)" + endif + if(datmaxChanged) then + print "(a,1pe14.6,a)"," WARNING: pixmap header datmax altered to the value",datmaxTruncated," as it was either "& + //">9.999999E99, <-9.999999E99, (>1.0E-99 and <0), (<1.0E-99 and >0)" + endif +#endif +end subroutine + !----------------------------------------------------------------- ! utility to check if an output format selection is valid !----------------------------------------------------------------- @@ -135,6 +178,7 @@ subroutine write_pixmap_ascii(datpix,npixx,npixy,xmin,ymin,dx,datmin,datmax,labe real, intent(in), dimension(npixx,npixy) :: datpix real, dimension(:,:), allocatable :: datpixTruncated real, intent(in) :: xmin,ymin,dx,datmin,datmax,time + real :: datminTruncated,datmaxTruncated character(len=*), intent(in) :: label,filename character(len=10) :: stringx,stringy character(len=30) :: fmtstring @@ -157,7 +201,9 @@ subroutine write_pixmap_ascii(datpix,npixx,npixy,xmin,ymin,dx,datmin,datmax,labe return endif datpixTruncated=datpix - + + call truncateHeaderMinMax(datmin,datmax,datminTruncated,datmaxTruncated) + write(*,"(a)",ADVANCE='NO') '> writing pixel map to file '//trim(filename)//' ...' write(stringx,"(i10)") npixx @@ -167,12 +213,13 @@ subroutine write_pixmap_ascii(datpix,npixx,npixy,xmin,ymin,dx,datmin,datmax,labe write(iunit,"(a)",err=66) '# do j=1,'//trim(adjustl(stringy)) write(iunit,"(a)",err=66) '# write(*,*) dat(1:'//trim(adjustl(stringx))//',j)' write(iunit,"(a)",err=66) '# enddo' - write(iunit,"(a,1pe14.6,a,1pe14.6)",err=66) '# '//trim(label)//': min = ',datmin,' max = ',datmax + write(iunit,"(a,1pe14.6,a,1pe14.6)",err=66) '# '//trim(label)//': min = ',datminTruncated,' max = ',datmaxTruncated write(iunit,"(a,1pe14.6,a,1pe14.6)",err=66) '# x axis: min = ',xmin,' max = ',xmin+(npixx-1)*dx write(iunit,"(a,1pe14.6,a,1pe14.6)",err=66) '# y axis: min = ',ymin,' max = ',ymin+(npixy-1)*dx write(iunit,"(a,1pe14.6)", err=66) '# time = ',time write(iunit,"(a)",err=66) '# '//trim(adjustl(stringx))//' '//trim(adjustl(stringy)) - + +#ifdef DP nSmallNegative = count((datpix > -1.0E-99) .and. (datpix < 0.0)) nSmallPositive = count((datpix < 1.0E-99) .and. (datpix > 0.0)) nLargeNegative = count(datpix < -9.999999E99) @@ -181,6 +228,7 @@ subroutine write_pixmap_ascii(datpix,npixx,npixy,xmin,ymin,dx,datmin,datmax,labe where((datpix < 1.0E-99) .and. (datpix > 0.0)) datpixTruncated = 1.0E-99 where(datpix < -9.999999E99) datpixTruncated = -9.999999E99 where(datpix > 9.999999E99) datpixTruncated = 9.999999E99 +#endif write(fmtstring,"(a,i6,a)",iostat=ierr) '(',npixx,'(1pe14.6))' if (ierr /= 0) then @@ -195,7 +243,8 @@ subroutine write_pixmap_ascii(datpix,npixx,npixy,xmin,ymin,dx,datmin,datmax,labe deallocate(datpixTruncated) close(iunit) print "(a)",'OK' - + +#ifdef DP if (nSmallNegative > 0) then print "(a,i9,a)"," WARNING: ",nSmallNegative," pixel values are between -1.0E-99 and 0, setting them to -1.0E-99" endif @@ -208,6 +257,7 @@ subroutine write_pixmap_ascii(datpix,npixx,npixy,xmin,ymin,dx,datmin,datmax,labe if (nLargePositive > 0) then print "(a,i9,a)"," WARNING: ",nLargePositive," pixels values are larger than 9.999999E99, setting them to 9.999999E99" endif +#endif return @@ -227,6 +277,7 @@ subroutine write_pixmap_ppm(datpix,npixx,npixy,xmin,ymin,dx,datmin,datmax,label, real, intent(in), dimension(npixx,npixy) :: datpix real, intent(in), dimension(npixx,npixy), optional :: brightness real, intent(in) :: xmin,ymin,dx,datmin,datmax + real :: datminTruncated,datmaxTruncated character(len=*), intent(in) :: label integer, intent(in) :: istep character(len=120) :: filename @@ -252,6 +303,9 @@ subroutine write_pixmap_ppm(datpix,npixx,npixy,xmin,ymin,dx,datmin,datmax,label, print*,'error opening ppm file' return endif + + call truncateHeaderMinMax(datmin,datmax,datminTruncated,datmaxTruncated) + write(*,"(a)",ADVANCE='NO') '> writing pixel map to file '//trim(filename)//' ...' ! !--PPM header @@ -259,7 +313,7 @@ subroutine write_pixmap_ppm(datpix,npixx,npixy,xmin,ymin,dx,datmin,datmax,label, maxcolour = 255 write(iunit,"(a)",err=66) 'P3' write(iunit,"(a)",err=66) '# '//trim(adjustl(filename))//' created by '//trim(tagline) - write(iunit,"(a,1pe14.6,a,1pe14.6)",err=66) '# '//trim(label)//': min = ',datmin,' max = ',datmax + write(iunit,"(a,1pe14.6,a,1pe14.6)",err=66) '# '//trim(label)//': min = ',datminTruncated,' max = ',datmaxTruncated write(iunit,"(a,1pe14.6,a,1pe14.6)",err=66) '# x axis: min = ',xmin,' max = ',xmin+(npixx-1)*dx write(iunit,"(a,1pe14.6,a,1pe14.6)",err=66) '# y axis: min = ',ymin,' max = ',ymin+(npixy-1)*dx write(iunit,"(i4,1x,i4)",err=66) npixx, npixy From 6fe2ee7ef8b82d9ab7b5ab8d96093cdd6fc7529c Mon Sep 17 00:00:00 2001 From: Stephen Neilson <36410751+s-neilson@users.noreply.github.com> Date: Fri, 10 Jul 2026 15:01:59 +1000 Subject: [PATCH 09/13] Made write_pixmap.F90 no longer use the preprocessor (and changed its name back to write_pixmap.f90). Also fixed missing references to sN,sP,lN and lP in write_pixmap_ascii. --- src/{write_pixmap.F90 => write_pixmap.f90} | 46 ++++++++++------------ 1 file changed, 20 insertions(+), 26 deletions(-) rename src/{write_pixmap.F90 => write_pixmap.f90} (94%) diff --git a/src/write_pixmap.F90 b/src/write_pixmap.f90 similarity index 94% rename from src/write_pixmap.F90 rename to src/write_pixmap.f90 index f7a80092..d138fceb 100644 --- a/src/write_pixmap.F90 +++ b/src/write_pixmap.f90 @@ -39,12 +39,10 @@ module write_pixmap public :: readpixmap !The limits for numbers that can be written with the formatting string "1pe14.6" -#ifdef DP - real, parameter, private :: sN = -1.0E-99 - real, parameter, private :: sP = 1.0E-99 - real, parameter, private :: lN = -9.999999E99 - real, parameter, private :: lP = 9.999999E99 -#endif + real(kind=8), parameter, private :: sN = -1.0E-99 + real(kind=8), parameter, private :: sP = 1.0E-99 + real(kind=8), parameter, private :: lN = -9.999999E99 + real(kind=8), parameter, private :: lP = 9.999999E99 private @@ -55,15 +53,14 @@ module write_pixmap ! that can be formatted with the formatting string "1pe14.6" !----------------------------------------------------------------- subroutine truncateHeaderMinMax(datmin,datmax,datminTruncated,datmaxTruncated) - real, intent(in) :: datmin,datmax - real, intent(out) :: datminTruncated,datmaxTruncated + real(kind=8), intent(in) :: datmin,datmax + real(kind=8), intent(out) :: datminTruncated,datmaxTruncated logical :: datminChanged = .false. logical :: datmaxChanged = .false. datminTruncated=datmin datmaxTruncated=datmax -#ifdef DP if((datmin > sN) .and. (datmin < 0.0)) then; datminTruncated = sN; datminChanged=.true.; endif if((datmin < sP) .and. (datmin > 0.0)) then; datminTruncated = sP; datminChanged=.true.; endif if(datmin < lN) then; datminTruncated = lN; datminChanged=.true.; endif @@ -82,7 +79,6 @@ subroutine truncateHeaderMinMax(datmin,datmax,datminTruncated,datmaxTruncated) print "(a,1pe14.6,a)"," WARNING: pixmap header datmax altered to the value",datmaxTruncated," as it was either "& //">9.999999E99, <-9.999999E99, (>1.0E-99 and <0), (<1.0E-99 and >0)" endif -#endif end subroutine !----------------------------------------------------------------- @@ -176,9 +172,9 @@ end subroutine writepixmap subroutine write_pixmap_ascii(datpix,npixx,npixy,xmin,ymin,dx,datmin,datmax,label,filename,time) integer, intent(in) :: npixx,npixy real, intent(in), dimension(npixx,npixy) :: datpix - real, dimension(:,:), allocatable :: datpixTruncated + real(kind=8), dimension(:,:), allocatable :: datpixTruncated real, intent(in) :: xmin,ymin,dx,datmin,datmax,time - real :: datminTruncated,datmaxTruncated + real(kind=8) :: datminTruncated,datmaxTruncated character(len=*), intent(in) :: label,filename character(len=10) :: stringx,stringy character(len=30) :: fmtstring @@ -200,9 +196,9 @@ subroutine write_pixmap_ascii(datpix,npixx,npixy,xmin,ymin,dx,datmin,datmax,labe close(iunit) return endif - datpixTruncated=datpix + datpixTruncated=real(datpix,kind=8) - call truncateHeaderMinMax(datmin,datmax,datminTruncated,datmaxTruncated) + call truncateHeaderMinMax(real(datmin,kind=8),real(datmax,kind=8),datminTruncated,datmaxTruncated) write(*,"(a)",ADVANCE='NO') '> writing pixel map to file '//trim(filename)//' ...' @@ -219,16 +215,14 @@ subroutine write_pixmap_ascii(datpix,npixx,npixy,xmin,ymin,dx,datmin,datmax,labe write(iunit,"(a,1pe14.6)", err=66) '# time = ',time write(iunit,"(a)",err=66) '# '//trim(adjustl(stringx))//' '//trim(adjustl(stringy)) -#ifdef DP - nSmallNegative = count((datpix > -1.0E-99) .and. (datpix < 0.0)) - nSmallPositive = count((datpix < 1.0E-99) .and. (datpix > 0.0)) - nLargeNegative = count(datpix < -9.999999E99) - nLargePositive = count(datpix > 9.999999E99) - where((datpix > -1.0E-99) .and. (datpix < 0.0)) datpixTruncated = -1.0E-99 - where((datpix < 1.0E-99) .and. (datpix > 0.0)) datpixTruncated = 1.0E-99 - where(datpix < -9.999999E99) datpixTruncated = -9.999999E99 - where(datpix > 9.999999E99) datpixTruncated = 9.999999E99 -#endif + nSmallNegative = count((datpixTruncated > sN) .and. (datpixTruncated < 0.0)) + nSmallPositive = count((datpixTruncated < sP) .and. (datpixTruncated > 0.0)) + nLargeNegative = count(datpixTruncated < lN) + nLargePositive = count(datpixTruncated > lP) + where((datpixTruncated > sN) .and. (datpixTruncated < 0.0)) datpixTruncated = sN + where((datpixTruncated < sP) .and. (datpixTruncated > 0.0)) datpixTruncated = sP + where(datpixTruncated < lN) datpixTruncated = lN + where(datpixTruncated > lP) datpixTruncated = lP write(fmtstring,"(a,i6,a)",iostat=ierr) '(',npixx,'(1pe14.6))' if (ierr /= 0) then @@ -277,7 +271,7 @@ subroutine write_pixmap_ppm(datpix,npixx,npixy,xmin,ymin,dx,datmin,datmax,label, real, intent(in), dimension(npixx,npixy) :: datpix real, intent(in), dimension(npixx,npixy), optional :: brightness real, intent(in) :: xmin,ymin,dx,datmin,datmax - real :: datminTruncated,datmaxTruncated + real(kind=8) :: datminTruncated,datmaxTruncated character(len=*), intent(in) :: label integer, intent(in) :: istep character(len=120) :: filename @@ -304,7 +298,7 @@ subroutine write_pixmap_ppm(datpix,npixx,npixy,xmin,ymin,dx,datmin,datmax,label, return endif - call truncateHeaderMinMax(datmin,datmax,datminTruncated,datmaxTruncated) + call truncateHeaderMinMax(real(datmin,kind=8),real(datmax,kind=8),datminTruncated,datmaxTruncated) write(*,"(a)",ADVANCE='NO') '> writing pixel map to file '//trim(filename)//' ...' ! From 0a3ef8d5759ff751289330ad0b4668d7c4056b2b Mon Sep 17 00:00:00 2001 From: Stephen Neilson <36410751+s-neilson@users.noreply.github.com> Date: Fri, 10 Jul 2026 15:03:43 +1000 Subject: [PATCH 10/13] In Makefile, changed extension of write_pixmap back to .f90. --- build/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/Makefile b/build/Makefile index 05b4f868..b9aa1a26 100644 --- a/build/Makefile +++ b/build/Makefile @@ -473,7 +473,7 @@ SOURCES= $(PLOTLIB) globaldata.f90 physcon.f90 utils_vectors.f90 \ interpolate3D_proj_geom.f90 \ interpolate3D_opacity.f90 interpolate_vec.f90 interpolate3D.f90 \ units.f90 limits.f90 geomutils.f90 dataread_utils.f90 \ - write_data_gadget.f90 write_data_phantom.f90 write_pfm.f90 write_pixmap.F90 \ + write_data_gadget.f90 write_data_phantom.f90 write_pfm.f90 write_pixmap.f90 \ labels_chem.f90 write_griddata.f90 write_sphdata.f90 read_composition.F90 \ $(SYSTEMFILE) system_utils.f90 \ cubicsolve.f90 discplot.f90 fparser.f90 parsetext.f90 \ From f0effd8af1c6f1a05dbf0d27b348171713a08d90 Mon Sep 17 00:00:00 2001 From: Stephen Neilson <36410751+s-neilson@users.noreply.github.com> Date: Fri, 10 Jul 2026 15:05:17 +1000 Subject: [PATCH 11/13] In .depends, changed extension of write_pixmap back to .f90. --- build/.depends | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/.depends b/build/.depends index ae980be4..efe4b84f 100644 --- a/build/.depends +++ b/build/.depends @@ -165,5 +165,5 @@ write_data_phantom.o : write_data_phantom.f90 write_fits.o : write_fits.f90 write_griddata.o : write_griddata.F90 asciiutils.o write_pfm.o : write_pfm.f90 -write_pixmap.o : write_pixmap.F90 asciiutils.o colours.o labels.o write_pfm.o globaldata.o +write_pixmap.o : write_pixmap.f90 asciiutils.o colours.o labels.o write_pfm.o globaldata.o write_sphdata.o : write_sphdata.f90 geomutils.o globaldata.o write_data_gadget.o write_data_phantom.o globaldata.o globaldata.o units.o labels.o asciiutils.o From a70b5f931a76c387d9c25879b8816fddadb1ddd3 Mon Sep 17 00:00:00 2001 From: Stephen Neilson <36410751+s-neilson@users.noreply.github.com> Date: Fri, 10 Jul 2026 15:11:39 +1000 Subject: [PATCH 12/13] Fixed an #ifdef and #endif that I accidentally left in write_pixmap.f90. --- src/write_pixmap.f90 | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/write_pixmap.f90 b/src/write_pixmap.f90 index d138fceb..b9c49131 100644 --- a/src/write_pixmap.f90 +++ b/src/write_pixmap.f90 @@ -238,7 +238,6 @@ subroutine write_pixmap_ascii(datpix,npixx,npixy,xmin,ymin,dx,datmin,datmax,labe close(iunit) print "(a)",'OK' -#ifdef DP if (nSmallNegative > 0) then print "(a,i9,a)"," WARNING: ",nSmallNegative," pixel values are between -1.0E-99 and 0, setting them to -1.0E-99" endif @@ -251,7 +250,6 @@ subroutine write_pixmap_ascii(datpix,npixx,npixy,xmin,ymin,dx,datmin,datmax,labe if (nLargePositive > 0) then print "(a,i9,a)"," WARNING: ",nLargePositive," pixels values are larger than 9.999999E99, setting them to 9.999999E99" endif -#endif return From 97d21390b5a61cca645f964aabf1fc076de79b3d Mon Sep 17 00:00:00 2001 From: Stephen Neilson <36410751+s-neilson@users.noreply.github.com> Date: Fri, 10 Jul 2026 15:24:03 +1000 Subject: [PATCH 13/13] In write_pixmap.f90, changed the values of sN,sP,lN and lP to double precision literals. --- src/write_pixmap.f90 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/write_pixmap.f90 b/src/write_pixmap.f90 index b9c49131..fd9d8588 100644 --- a/src/write_pixmap.f90 +++ b/src/write_pixmap.f90 @@ -39,10 +39,10 @@ module write_pixmap public :: readpixmap !The limits for numbers that can be written with the formatting string "1pe14.6" - real(kind=8), parameter, private :: sN = -1.0E-99 - real(kind=8), parameter, private :: sP = 1.0E-99 - real(kind=8), parameter, private :: lN = -9.999999E99 - real(kind=8), parameter, private :: lP = 9.999999E99 + real(kind=8), parameter, private :: sN = -1.0d-99 + real(kind=8), parameter, private :: sP = 1.0d-99 + real(kind=8), parameter, private :: lN = -9.999999d99 + real(kind=8), parameter, private :: lP = 9.999999d99 private