Skip to content

Commit

Permalink
4.10.5 PATCH
Browse files Browse the repository at this point in the history
NEW Fotran Debug compiler options, including -fsanitize=address
for GNU Fortran compiler to help debug memory issues.

+ small updated to IOTOOLS
  • Loading branch information
aamaricci committed Nov 21, 2022
1 parent befa722 commit 9e1dba4
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 72 deletions.
2 changes: 1 addition & 1 deletion cmake/FortranCompilerConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if(CMAKE_Fortran_COMPILER_ID MATCHES GNU) # this is gfortran
SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-argument-mismatch")
ENDIF()
SET(CMAKE_Fortran_FLAGS_TESTING "-O2 -funroll-loops")
SET(CMAKE_Fortran_FLAGS_DEBUG "-O0 -p -g -Wsurprising -Waliasing -fwhole-file -fcheck=all -fbacktrace -fbounds-check")
SET(CMAKE_Fortran_FLAGS_DEBUG "-O0 -p -g -fbacktrace -fwhole-file -fcheck=all -fbounds-check -fsanitize=address -fdebug-aux-vars -Wall -Waliasing -Wsurprising -Wampersand -Warray-bounds -Wc-binding-type -Wcharacter-truncation -Wconversion -Wdo-subscript -Wfunction-elimination -Wimplicit-interface -Wimplicit-procedure -Wintrinsic-shadow -Wintrinsics-std -Wno-align-commons -Wno-overwrite-recursive -Wno-tabs -Wreal-q-constant -Wunderflow -Wunused-parameter -Wrealloc-lhs -Wrealloc-lhs-all -Wfrontend-loop-interchange -Wtarget-lifetime")
SET(CMAKE_Fortran_FLAGS_RELEASE "-O3 -funroll-loops")
elseif(CMAKE_Fortran_COMPILER_ID MATCHES Intel)
SET(CMAKE_Fortran_MODDIR_FLAG "-module ") #remember the ending white space here
Expand Down
12 changes: 8 additions & 4 deletions src/SF_IOTOOLS/IOFILE.f90
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ module IOFILE
contains




!+-----------------------------------------------------------------+
!PURPOSE :
!+-----------------------------------------------------------------+
Expand All @@ -80,24 +82,26 @@ end function reg_filename

function get_filename(string) result(fname)
character(len=*) :: string
character(len=len_trim(string)) :: fname
! character(len=len_trim(string)) :: fname
character(len=:),allocatable :: fname
integer :: i,slen
slen=len_trim(string)
do i=slen,1,-1
if(string(i:i)== '/')exit
enddo
fname=string(i+1:slen)
fname=trim(adjustl(trim(string(i+1:slen))))
end function get_filename

function get_filepath(string) result(pname)
character(len=*) :: string
character(len=len_trim(string)) :: pname
! character(len=len_trim(string)) :: pname
character(len=:),allocatable :: pname
integer :: i,slen
slen=len_trim(string)
do i=slen,1,-1
if(string(i:i)== '/')exit
enddo
pname=string(1:i)
pname=trim(adjustl(trim(string(1:i))))
end function get_filepath


Expand Down
137 changes: 70 additions & 67 deletions src/SF_IOTOOLS/ioplot_splot3d.f90
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ subroutine d_splot3D(pname,X1,X2,Y,xmin,xmax,ymin,ymax,nosurface,wlines,nlines)
real(8),optional :: xmin,xmax,ymin,ymax
integer,optional :: nlines
logical,optional :: wlines,nosurface
logical :: nosurface_
real(8) :: X1min,X1max
real(8) :: X2min,X2max
character(len=12) :: minx,miny,maxx,maxy
character(len=256) :: fname,dname
fname=get_filename(pname)
dname=get_filepath(pname)
character(len=:),allocatable :: fname,dname
fname=get_filename(reg(pname))
dname=get_filepath(reg(pname))
nosurface_=.false.;if(present(nosurface))nosurface_=nosurface
Nx1=size(X1) ; Nx2=size(X2)
Nl=5; if(present(nlines))Nl=nlines
open(719,file=adjustl(trim(pname)))
if(present(wlines))open(720,file=adjustl(trim(pname))//"_withlines")
open(719,file=str(pname))
if(present(wlines))open(720,file=str(pname)//"_withlines")
do i=1,Nx1
count=mod(i,Nl)
do j=1,Nx2
Expand All @@ -38,30 +40,30 @@ subroutine d_splot3D(pname,X1,X2,Y,xmin,xmax,ymin,ymax,nosurface,wlines,nlines)
write(maxy,"(f12.4)")X2max
if(present(wlines))close(720)

open(10,file=adjustl(trim(pname))//"_map.gp")
write(10,*)"set title '"//trim(fname)//"'"
open(10,file=reg(pname)//"_map.gp")

write(10,*)"set title '"//fname//"'"
write(10,*)"set pm3d map"
write(10,*)"set size square"
write(10,*)"set xrange ["//trim(adjustl(trim(minx)))//":"//trim(adjustl(trim(maxx)))//"]"
write(10,*)"set yrange ["//trim(adjustl(trim(miny)))//":"//trim(adjustl(trim(maxy)))//"]"
write(10,*)"set xrange ["//minx//":"//maxx//"]"
write(10,*)"set yrange ["//miny//":"//maxy//"]"
write(10,*)"splot '"//trim(fname)//"'"
write(10,*)"#set term png size 1920,1280"
write(10,*)"#set out '"//adjustl(trim(fname))//".png'"
write(10,*)"#set out '"//fname//".png'"
write(10,*)"#rep"
!
close(10)
if(present(nosurface).AND.nosurface)return
open(10,file=adjustl(trim(pname))//"_surface.gp")

write(10,*)"set title '"//trim(fname)//"'"
!
if(nosurface_)return
!
open(10,file=reg(pname)//"_surface.gp")
write(10,*)"set title '"//fname//"'"
write(10,*)"unset key"
write(10,*)"unset grid"
write(10,*)"set view 50,10,1,1"
write(10,*)"splot '"//trim(fname)//"' with pm3d"
if(present(wlines))write(10,*)"rep '"//trim(pname)//"_withlines' with lines"
write(10,*)"splot '"//fname//"' with pm3d"
if(present(wlines))write(10,*)"rep '"//reg(pname)//"_withlines' with lines"
write(10,*)"#set term png size 1920,1280"
write(10,*)"#set out '"//adjustl(trim(fname))//".png'"
write(10,*)"#set out '"//fname//".png'"
write(10,*)"#rep"
close(10)
end subroutine d_splot3D
Expand All @@ -76,28 +78,29 @@ subroutine c_splot3D(pname,X1,X2,Y,xmin,xmax,ymin,ymax,nosurface,wlines,nlines)
real(8),optional :: xmin,xmax,ymin,ymax
integer,optional :: nlines
logical,optional :: wlines,nosurface
logical :: nosurface_
real(8) :: X1min,X1max
real(8) :: X2min,X2max
character(len=12) :: minx,miny,maxx,maxy
character(len=256) :: fname,dname
fname=get_filename(pname)
dname=get_filepath(pname)
character(len=12) :: minx,miny,maxx,maxy
character(len=:),allocatable :: fname,dname
fname=get_filename(reg(pname))
dname=get_filepath(reg(pname))
nosurface_=.false.;if(present(nosurface))nosurface_=nosurface
Nx1=size(X1) ; Nx2=size(X2)
Nl=5; if(present(nlines))Nl=nlines

open(619,file=adjustl(trim(dname))//"re_"//adjustl(trim(fname)))
open(719,file=adjustl(trim(dname))//"im_"//adjustl(trim(fname)))
open(619,file=dname//"re_"//fname)
open(719,file=dname//"im_"//fname)
if(present(wlines))then
open(620,file=adjustl(trim(dname))//"re_"//adjustl(trim(fname))//"_withlines")
open(720,file=adjustl(trim(dname))//"im_"//adjustl(trim(fname))//"_withlines")
open(620,file=dname//"re_"//fname//"_withlines")
open(720,file=dname//"im_"//fname//"_withlines")
endif
do i=1,Nx1
count=mod(i,Nl)
do j=1,Nx2
write(619,*)X1(i),X2(j),dreal(Y(i,j))
write(719,*)X1(i),X2(j),dimag(Y(i,j))
if(present(wlines).AND.count==0)write(620,*)X1(i),X2(j),real(Y(i,j),8)
if(present(wlines).AND.count==0)write(720,*)X1(i),X2(j),aimag(Y(i,j))
if(present(wlines).AND.count==0)write(620,*)X1(i),X2(j),dreal(Y(i,j))
if(present(wlines).AND.count==0)write(720,*)X1(i),X2(j),dimag(Y(i,j))
enddo
write(619,*)""
write(719,*)""
Expand Down Expand Up @@ -125,56 +128,56 @@ subroutine c_splot3D(pname,X1,X2,Y,xmin,xmax,ymin,ymax,nosurface,wlines,nlines)


!Re:
open(10,file=adjustl(trim(pname))//"_re_map.gp")

write(10,*)"set title 'Re_"//trim(fname)//"'"
open(10,file=pname//"_re_map.gp")
write(10,*)"set title 'Re_"//fname//"'"
write(10,*)"set pm3d map"
write(10,*)"set size square"
write(10,*)"set xrange ["//trim(adjustl(trim(minx)))//":"//trim(adjustl(trim(maxx)))//"]"
write(10,*)"set yrange ["//trim(adjustl(trim(miny)))//":"//trim(adjustl(trim(maxy)))//"]"
write(10,*)"set xrange ["//minx//":"//maxx//"]"
write(10,*)"set yrange ["//miny//":"//maxy//"]"
write(10,*)"splot 're_"//trim(fname)//"'"
write(10,*)"#set term png size 1920,1280"
write(10,*)"#set out 're_"//adjustl(trim(fname))//".png'"
write(10,*)"#set out 're_"//fname//".png'"
write(10,*)"#rep"
close(10)
!Im
open(10,file=adjustl(trim(pname))//"_im_map.gp")
write(10,*)"set title 'Im_"//trim(fname)//"'"
open(10,file=pname//"_im_map.gp")

write(10,*)"set title 'Im_"//fname//"'"
write(10,*)"set pm3d map"
write(10,*)"set size square"
write(10,*)"set xrange ["//trim(adjustl(trim(minx)))//":"//trim(adjustl(trim(maxx)))//"]"
write(10,*)"set yrange ["//trim(adjustl(trim(miny)))//":"//trim(adjustl(trim(maxy)))//"]"
write(10,*)"splot 'im_"//trim(fname)//"'"
write(10,*)"set xrange ["//minx//":"//maxx//"]"
write(10,*)"set yrange ["//miny//":"//maxy//"]"
write(10,*)"splot 'im_"//fname//"'"
write(10,*)"#set term png size 1920,1280"
write(10,*)"#set out 'im_"//adjustl(trim(fname))//".png'"
write(10,*)"#set out 'im_"//fname//".png'"
write(10,*)"#rep"
close(10)
if(present(nosurface).AND.nosurface)return
!
if(nosurface_)return
!Re
open(10,file=adjustl(trim(pname))//"_re_surface.gp")
write(10,*)"set title 'Re_"//trim(fname)//"'"
open(10,file=pname//"_re_surface.gp")

write(10,*)"set title 'Re_"//(fname)//"'"
write(10,*)"unset key"
write(10,*)"unset grid"
write(10,*)"set view 50,10,1,1"
write(10,*)"splot 're_"//trim(fname)//"' with pm3d"
if(present(wlines))write(10,*)"rep 're_"//trim(pname)//"_withlines' with lines"
write(10,*)"splot 're_"//(fname)//"' with pm3d"
if(present(wlines))write(10,*)"rep 're_"//str(pname)//"_withlines' with lines"
write(10,*)"#set term png size 1920,1280"
write(10,*)"#set out 're_"//adjustl(trim(fname))//".png'"
write(10,*)"#set out 're_"//(fname)//".png'"
write(10,*)"#rep"
close(10)
!Im
open(10,file=adjustl(trim(pname))//"_im_surface.gp")
write(10,*)"set title 'Im_"//trim(fname)//"'"
open(10,file=pname//"_im_surface.gp")

write(10,*)"set title 'Im_"//(fname)//"'"
write(10,*)"set nokey"
write(10,*)"set grid"
write(10,*)"set view 50,10,1,1"
write(10,*)"splot 'im_"//trim(fname)//"' with pm3d"
if(present(wlines))write(10,*)"rep 'im_"//trim(pname)//"_withlines' with lines"
write(10,*)"splot 'im_"//(fname)//"' with pm3d"
if(present(wlines))write(10,*)"rep 'im_"//str(pname)//"_withlines' with lines"
write(10,*)"#set term png size 1920,1280"
write(10,*)"#set out 'im_"//adjustl(trim(fname))//".png'"
write(10,*)"#set out 'im_"//(fname)//".png'"
write(10,*)"#rep"
close(10)
end subroutine c_splot3D
Expand All @@ -192,14 +195,14 @@ subroutine d_splot3d_animate(pname,X1,X2,Y,xmin,xmax,ymin,ymax)
real(8),optional :: xmin,xmax,ymin,ymax
real(8) :: Rmin(3),Rmax(3),Zmin,Zmax
Character(len=256) :: fname,dname
fname=get_filename(pname)
dname=get_filepath(pname)
fname=get_filename(reg(pname))
dname=get_filepath(reg(pname))
Nx1=size(X1) ; Nx2=size(X2)
if(size(Y,1)/=Nx1) stop "Error Nx1"
if(size(Y,2)/=Nx2) stop "Error Nx2"
Nt=size(Y,3)
write(*,*) "splot3d_animate "//str(fname)//" ("//str(Nx1)//","//str(Nx2)//","//str(Nt)//")"
open(719,file=adjustl(trim(pname)))
open(719,file=reg(pname))
do m=1,Nt
do i=1,Nx1
do j=1,Nx2
Expand All @@ -215,12 +218,12 @@ subroutine d_splot3d_animate(pname,X1,X2,Y,xmin,xmax,ymin,ymax)
X2max=maxval(X2);if(present(ymax))X2max=ymax
Rmin=minval(Y);Rmax=maxval(Y)
Zmin=minval(Rmin);Zmax=maxval(Rmax)
open(10,file=adjustl(trim(pname))//"_map.gp")
open(10,file=reg(pname)//"_map.gp")
! write(10,*)"gnuplot -persist << EOF"
write(10,*)"reset"
write(10,*)"#set term gif animate"
write(10,*)"#set output '"//trim(fname)//".gif'"

write(10,*)"set pm3d map"
write(10,*)"set size square"
write(10,*)"set xrange ["//trim(adjustl(trim(txtfy(X1min))))//":"//trim(adjustl(trim(txtfy(X1max))))//"]"
Expand All @@ -235,7 +238,7 @@ subroutine d_splot3d_animate(pname,X1,X2,Y,xmin,xmax,ymin,ymax)
write(10,*)"#set output"
! write(10,"(A)")"EOF"
close(10)
! call system("chmod +x "//adjustl(trim(pname))//"_map.gp")
! call system("chmod +x "//reg(pname)//"_map.gp")
end subroutine d_splot3D_animate


Expand All @@ -251,8 +254,8 @@ subroutine c_splot3d_animate(pname,X1,X2,Y,xmin,xmax,ymin,ymax)
real(8),optional :: xmin,xmax,ymin,ymax
real(8) :: Rmin(3),Rmax(3),Zmin,Zmax
character(len=256) :: fname,dname
fname=get_filename(pname)
dname=get_filepath(pname)
fname=get_filename(reg(pname))
dname=get_filepath(reg(pname))
Nx1=size(X1) ; Nx2=size(X2)
if(size(Y,1)/=Nx1) stop "Error Nx1"
if(size(Y,2)/=Nx2) stop "Error Nx2"
Expand All @@ -278,7 +281,7 @@ subroutine c_splot3d_animate(pname,X1,X2,Y,xmin,xmax,ymin,ymax)
X2max=maxval(X2);if(present(ymax))X2max=ymax
Rmin=minval(dreal(Y));Rmax=maxval(dreal(Y))
Zmin=minval(Rmin);Zmax=maxval(Rmax)
open(10,file=adjustl(trim(pname))//"_re_map.gp")
open(10,file=reg(pname)//"_re_map.gp")
! write(10,*)"gnuplot -persist << EOF"
write(10,*)"reset"
write(10,*)"#set term gif animate"
Expand All @@ -301,7 +304,7 @@ subroutine c_splot3d_animate(pname,X1,X2,Y,xmin,xmax,ymin,ymax)

Rmin=minval(dimag(Y));Rmax=maxval(dimag(Y))
Zmin=minval(Rmin);Zmax=maxval(Rmax)
open(10,file=adjustl(trim(pname))//"_im_map.gp")
open(10,file=reg(pname)//"_im_map.gp")
! write(10,*)"gnuplot -persist << EOF"
write(10,*)"reset"
write(10,*)"#set term gif animate"
Expand All @@ -321,7 +324,7 @@ subroutine c_splot3d_animate(pname,X1,X2,Y,xmin,xmax,ymin,ymax)
write(10,*)"#set output"
! write(10,"(A)")"EOF"
close(10)
! call system("chmod +x "//adjustl(trim(pname))//".gp")
! call system("chmod +x "//reg(pname)//".gp")
end subroutine c_splot3d_animate


Expand Down

0 comments on commit 9e1dba4

Please sign in to comment.