refactor: resolve various code smells in Fortran source files and makefile
All checks were successful
CI Test Suite / run-tests (push) Successful in 1m13s
Deploy Documentation / build-and-deploy (push) Successful in 53s

This commit is contained in:
ignis 2026-06-02 15:59:02 +00:00
parent d1cf59dca2
commit 79fd3d4d5b
6 changed files with 95 additions and 89 deletions

View file

@ -10,13 +10,13 @@
use, intrinsic :: iso_fortran_env, only: real64
IMPLICIT NONE
REAL(KIND=8), DIMENSION(:), ALLOCATABLE :: lxf,lxs,wxf,wxs, & !< x- LU Decomposition
real(real64), DIMENSION(:), ALLOCATABLE :: lxf,lxs,wxf,wxs, & !< x- LU Decomposition
lyf,lys,wyf,wys, & !< y- LU Decomposition
lzf,lzs,wzf,wzs !< z- LU Decomposition
INTEGER :: nxc,nyc,nzc !< (x, y, z)
REAL(KIND=8), PARAMETER :: ezero = 1.0e-14
real(real64), PARAMETER :: ezero = 1.0e-14
CONTAINS
@ -224,8 +224,8 @@
SUBROUTINE test_nonp_lud1(xx, coef)
INTEGER :: xx
REAL(KIND=8), DIMENSION(xx) :: aa
REAL(KIND=8), DIMENSION(xx), INTENT(OUT) :: coef
real(real64), DIMENSION(xx) :: aa
real(real64), DIMENSION(xx), INTENT(OUT) :: coef
aa=3.
aa(1)=0.5 ; aa(2)=4.
aa(xx-1)=4. ; aa(xx)=0.5
@ -236,8 +236,8 @@
SUBROUTINE test_nonp_lud2(xx, coef)
INTEGER :: xx
REAL(KIND=8), DIMENSION(xx) :: aa
REAL(KIND=8), DIMENSION(xx), INTENT(OUT) :: coef
real(real64), DIMENSION(xx) :: aa
real(real64), DIMENSION(xx), INTENT(OUT) :: coef
aa=5.5
aa(1)=2./11. ; aa(2)=10.
aa(xx-1)=10. ; aa(xx)=2./11.
@ -248,8 +248,8 @@
SUBROUTINE test_p_lud1(xx, coef1, coef2)
INTEGER :: xx
REAL(KIND=8) :: a
REAL(KIND=8), DIMENSION(xx), INTENT(OUT) :: coef1, coef2
real(real64) :: a
real(real64), DIMENSION(xx), INTENT(OUT) :: coef1, coef2
a=3. ! first derivative
CALL ptdlu(a,xx,coef1,coef2) ! x-direction
@ -258,8 +258,8 @@
SUBROUTINE test_p_lud2(xx, coef1, coef2)
INTEGER :: xx
REAL(KIND=8) :: a
REAL(KIND=8), DIMENSION(xx), INTENT(OUT) :: coef1, coef2
real(real64) :: a
real(real64), DIMENSION(xx), INTENT(OUT) :: coef1, coef2
a=11./2. ! second derivative
CALL ptdlu(a,xx,coef1,coef2) ! x-direction
@ -268,7 +268,7 @@
SUBROUTINE nonp_lud(xyz,xx)
INTEGER :: i,xyz,xx
REAL(KIND=8), DIMENSION(xx) :: aa
real(real64), DIMENSION(xx) :: aa
aa=3.
aa(1)=0.5 ; aa(2)=4.
aa(xx-1)=4. ; aa(xx)=0.5
@ -288,7 +288,7 @@
SUBROUTINE p_lud(xyz,xx)
INTEGER :: i,xyz,xx
REAL(KIND=8) :: a
real(real64) :: a
a=3. ! first derivative
IF (xyz.eq.1) CALL ptdlu(a,xx,lxf,wxf) ! x-direction
IF (xyz.eq.2) CALL ptdlu(a,xx,lyf,wyf) ! y-direction
@ -301,9 +301,9 @@
SUBROUTINE stdlu(a,n,l)
INTEGER :: n
REAL(KIND=8), INTENT(IN) :: a(n)
REAL(KIND=8), INTENT(OUT) :: l(n)
REAL(KIND=8) :: d
real(real64), INTENT(IN) :: a(n)
real(real64), INTENT(OUT) :: l(n)
real(real64) :: d
INTEGER :: i
l(1)=1.0d0/a(1)
DO i=2,n
@ -314,10 +314,10 @@
SUBROUTINE ptdlu(a,n,l,w)
INTEGER :: n
REAL(KIND=8), INTENT(IN) :: a
REAL(KIND=8), INTENT(OUT) :: l(n),w(n)
real(real64), INTENT(IN) :: a
real(real64), INTENT(OUT) :: l(n),w(n)
INTEGER :: i
REAL(KIND=8) :: aa(n),d
real(real64) :: aa(n),d
DO i=1,n-1
aa(i)=a
@ -342,11 +342,11 @@
SUBROUTINE rhs1np(n,h,x,dx,nd)
INTEGER,INTENT(IN) :: n,nd
REAL(KIND=8),INTENT(IN) :: h
REAL(KIND=8),INTENT(IN),DIMENSION(nd,n) :: x
REAL(KIND=8),INTENT(OUT),DIMENSION(nd,n) :: dx
real(real64),INTENT(IN) :: h
real(real64),INTENT(IN),DIMENSION(nd,n) :: x
real(real64),INTENT(OUT),DIMENSION(nd,n) :: dx
INTEGER :: i,j
REAL(KIND=8) :: r1,r2,r3,a,b,c,h1,t1,t2,t3,t4
real(real64) :: r1,r2,r3,a,b,c,h1,t1,t2,t3,t4
h1=1.d0/h
@ -383,11 +383,11 @@
SUBROUTINE dfnonp(n,h,x,dx,nd,dir)
INTEGER,INTENT(IN) :: n,nd,dir
REAL(KIND=8),INTENT(IN) :: h
REAL(KIND=8),INTENT(IN),DIMENSION(nd,n) :: x
REAL(KIND=8),INTENT(OUT),DIMENSION(nd,n) :: dx
real(real64),INTENT(IN) :: h
real(real64),INTENT(IN),DIMENSION(nd,n) :: x
real(real64),INTENT(OUT),DIMENSION(nd,n) :: dx
INTEGER :: i,j
REAL(KIND=8) :: r1,r2,r3,a,b,c,h1,t1,t2,t3,t4
real(real64) :: r1,r2,r3,a,b,c,h1,t1,t2,t3,t4
CALL rhs1np (n,h,x,dx,nd)
@ -398,11 +398,11 @@
SUBROUTINE dfp(n,h,x,dx,nd,dir)
INTEGER,INTENT(IN) :: n,nd,dir
REAL(KIND=8),INTENT(IN) :: h
REAL(KIND=8),INTENT(IN),DIMENSION(nd,n) :: x
REAL(KIND=8),INTENT(OUT),DIMENSION(nd,n) :: dx
real(real64),INTENT(IN) :: h
real(real64),INTENT(IN),DIMENSION(nd,n) :: x
real(real64),INTENT(OUT),DIMENSION(nd,n) :: dx
INTEGER :: i,j
REAL(KIND=8) :: r1,r2,h1
real(real64) :: r1,r2,h1
! print *, "dfnonp received (nd,n)", nd, n
@ -437,10 +437,10 @@
SUBROUTINE ptdslv(r,n,l,w,nd)
INTEGER,INTENT(IN) :: n,nd
REAL(KIND=8),INTENT(INOUT),DIMENSION(nd,n) :: r
REAL(KIND=8),INTENT(IN),DIMENSION(n) :: l,w
real(real64),INTENT(INOUT),DIMENSION(nd,n) :: r
real(real64),INTENT(IN),DIMENSION(n) :: l,w
INTEGER i,j
REAL(KIND=8), DIMENSION(nd) :: sum
real(real64), DIMENSION(nd) :: sum
DO j=1,nd
sum(j)=w(1)*r(j,1)
r(j,1)=r(j,1)*l(1)
@ -465,11 +465,11 @@
SUBROUTINE d2fp(n,h,x,dx,nd,dir)
INTEGER,INTENT(IN) :: n,nd,dir
REAL(KIND=8),INTENT(IN) :: h
REAL(KIND=8),INTENT(IN),DIMENSION(nd,n) :: x
REAL(KIND=8),INTENT(OUT),DIMENSION(nd,n) :: dx
real(real64),INTENT(IN) :: h
real(real64),INTENT(IN),DIMENSION(nd,n) :: x
real(real64),INTENT(OUT),DIMENSION(nd,n) :: dx
INTEGER :: i,j
REAL(KIND=8) :: h2,r1,r2,t1,t2
real(real64) :: h2,r1,r2,t1,t2
h2=1./(h*h)
@ -530,10 +530,10 @@
SUBROUTINE tdslv(r,n,l,nd)
INTEGER,INTENT(IN) :: n,nd
REAL(KIND=8),INTENT(INOUT),DIMENSION(nd,n) :: r
REAL(KIND=8),INTENT(IN),DIMENSION(n) :: l
real(real64),INTENT(INOUT),DIMENSION(nd,n) :: r
real(real64),INTENT(IN),DIMENSION(n) :: l
INTEGER i,j
REAL(KIND=8) t1
real(real64) t1
DO j=1,nd
r(j,1)=r(j,1)*l(1)
ENDDO
@ -552,11 +552,11 @@
SUBROUTINE d2fnonp(n,h,x,dx,nd,dir)
INTEGER,INTENT(IN) :: n,nd,dir
REAL(KIND=8),INTENT(IN) :: h
REAL(KIND=8),INTENT(IN),DIMENSION(nd,n) :: x
REAL(KIND=8),INTENT(OUT),DIMENSION(nd,n) :: dx
real(real64),INTENT(IN) :: h
real(real64),INTENT(IN),DIMENSION(nd,n) :: x
real(real64),INTENT(OUT),DIMENSION(nd,n) :: dx
INTEGER :: i,j
REAL(KIND=8) :: h2,r1,r2,r3,a,b,c,e,t1,t2
real(real64) :: h2,r1,r2,r3,a,b,c,e,t1,t2
h2=1./(h*h)

View file

@ -76,8 +76,8 @@ contains
subroutine ddx1d(dst, src)
real*8, dimension(1,nxp), intent(in) :: src
real*8, dimension(1,nxp), intent(out) :: dst
real(real64), dimension(1,nxp), intent(in) :: src
real(real64), dimension(1,nxp), intent(out) :: dst
integer :: i, j ,k
integer :: ju
@ -93,8 +93,8 @@ contains
!! @param dst 3D output derivative field (nxp, nyp, nzp).
subroutine ddx(dst, src)
real*8, dimension(nxp,nyp,nzp), intent(in) :: src
real*8, dimension(nxp,nyp,nzp), intent(out) :: dst
real(real64), dimension(nxp,nyp,nzp), intent(in) :: src
real(real64), dimension(nxp,nyp,nzp), intent(out) :: dst
integer :: i, j ,k
integer :: ju
@ -123,8 +123,8 @@ contains
!! @param dst 3D output derivative field (nxp, nyp, nzp).
subroutine ddy(dst, src)
real*8, dimension(nxp,nyp,nzp), intent(in) :: src
real*8, dimension(nxp,nyp,nzp), intent(out) :: dst
real(real64), dimension(nxp,nyp,nzp), intent(in) :: src
real(real64), dimension(nxp,nyp,nzp), intent(out) :: dst
integer :: i, j ,k
@ -144,8 +144,8 @@ contains
!! @param dst 3D output derivative field (nxp, nyp, nzp).
subroutine ddz(dst, src)
real*8, dimension(nxp,nyp,nzp), intent(in) :: src
real*8, dimension(nxp,nyp,nzp), intent(out) :: dst
real(real64), dimension(nxp,nyp,nzp), intent(in) :: src
real(real64), dimension(nxp,nyp,nzp), intent(out) :: dst
integer :: i, j ,k
@ -168,8 +168,8 @@ contains
subroutine d2dx1d(dst, src)
real*8, dimension(nxp), intent(in) :: src
real*8, dimension(nxp), intent(out) :: dst
real(real64), dimension(nxp), intent(in) :: src
real(real64), dimension(nxp), intent(out) :: dst
integer :: i, j ,k
integer :: ju
@ -181,8 +181,8 @@ contains
subroutine d2dx(dst, src)
real*8, dimension(nxp,nyp,nzp), intent(in) :: src
real*8, dimension(nxp,nyp,nzp), intent(out) :: dst
real(real64), dimension(nxp,nyp,nzp), intent(in) :: src
real(real64), dimension(nxp,nyp,nzp), intent(out) :: dst
integer :: i, j ,k
integer :: ju
@ -207,8 +207,8 @@ contains
subroutine d2dy(dst, src)
real*8, dimension(nxp,nyp,nzp), intent(in) :: src
real*8, dimension(nxp,nyp,nzp), intent(out) :: dst
real(real64), dimension(nxp,nyp,nzp), intent(in) :: src
real(real64), dimension(nxp,nyp,nzp), intent(out) :: dst
integer :: i, j ,k
@ -224,8 +224,8 @@ contains
subroutine d2dz(dst, src)
real*8, dimension(nxp,nyp,nzp), intent(in) :: src
real*8, dimension(nxp,nyp,nzp), intent(out) :: dst
real(real64), dimension(nxp,nyp,nzp), intent(in) :: src
real(real64), dimension(nxp,nyp,nzp), intent(out) :: dst
integer :: i, j ,k
@ -251,8 +251,8 @@ contains
integer,intent(in) :: nx
real*8,intent(out) :: a(nb,nx)
real*8,intent(in) :: b(nx,nb)
real(real64),intent(out) :: a(nb,nx)
real(real64),intent(in) :: b(nx,nb)
call tp2(a, b, nb, nx)
@ -264,8 +264,8 @@ contains
implicit none
integer,intent(in) :: n1, n2
real*8,intent(out) :: a(n1,n2)
real*8,intent(in) :: b(n2,n1)
real(real64),intent(out) :: a(n1,n2)
real(real64),intent(in) :: b(n2,n1)
integer :: i,j,ii,jj
DO jj=1,n2,nb

View file

@ -131,7 +131,15 @@ subroutine read_intro
allocate (file_dist(startnum:endnum), stat=ierr)
if (ierr /= 0) then
write(0,*) "Error: allocation of file_dist failed on process", myid
call MPI_ABORT(MPI_COMM_TASK, 1, mpi_err)
end if
allocate (export_offset(startnum:endnum), stat=ierr)
if (ierr /= 0) then
write(0,*) "Error: allocation of export_offset failed on process", myid
call MPI_ABORT(MPI_COMM_TASK, 1, mpi_err)
end if
file_count = 0

View file

@ -1,8 +1,7 @@
#flags = -r8 -i8 -msse3 -O3 -axT -m64 -fPIC -i_dynamic -openmp
#Neuman flags
#flags = -O3 -r8 -i8 -openmp -msse3 -axSSSE3 -m64 -fPIC -i_dynamic
#Cluster_2(16.161) flags
CC?=gcc
FC = mpif90
LD?=ld
PYTHON?=python3
BLOCKSIZE?=32
@ -20,8 +19,6 @@ endif
flags += -cpp -DBLOCKSIZE=$(BLOCKSIZE) -Wall -ffree-line-length-0 -fdefault-integer-8 -fdefault-double-8 -fdefault-real-8 -march=native -fallow-argument-mismatch
compiler = mpif90
# Modules
MODULES += \
@ -42,15 +39,15 @@ ODATA = build_info.odata latex_equations.odata
Post_Cbar_FSD_Incomp : x-edge-cold-bc-uPrime-hybrid
x-edge-cold-bc-uPrime-hybrid : ${MODULES} ${OBJ} print_build_info.o ${ODATA}
${compiler} -o x-edge-cold-bc-uPrime-hybrid ${flags} ${MODULES} ${OBJ} print_build_info.o ${ODATA}
${FC} -o x-edge-cold-bc-uPrime-hybrid ${flags} ${MODULES} ${OBJ} print_build_info.o ${ODATA}
${OBJ} : ${MODULES}
m_terms.f90 : code_gen/code_gen.py ${TERMSPEC} code_gen/resources/m_template.py
python code_gen/code_gen.py ${TERMSPEC} > $@
${PYTHON} code_gen/code_gen.py ${TERMSPEC} > $@
%.o: %.f90
${compiler} -c ${flags} $<
${FC} -c ${flags} $<
cleanAll: clean
rm -f m_terms.f90
@ -62,26 +59,26 @@ test : test_calculate
./test_calculate
test_field : test_field.o m_openmpi.o m_parameters.o Compact.o m_calculate.o m_arrays.o
${compiler} -o test_field ${flags} m_openmpi.o m_parameters.o Compact.o m_calculate.o m_arrays.o test_field.o
${FC} -o test_field ${flags} m_openmpi.o m_parameters.o Compact.o m_calculate.o m_arrays.o test_field.o
test_calculate : test_calculate.o
${compiler} -o test_calculate ${flags} m_openmpi.o m_parameters.o Compact.o m_calculate.o test_calculate.o
${FC} -o test_calculate ${flags} m_openmpi.o m_parameters.o Compact.o m_calculate.o test_calculate.o
test_calculate.o : m_openmpi.o m_parameters.o Compact.o m_calculate.o
test_compact : Compact.o test_compact.o
${compiler} -o test_compact ${flags} Compact.o test_compact.o
${FC} -o test_compact ${flags} Compact.o test_compact.o
test_compact.o : Compact.o
print_build_info.o : print_build_info.c
gcc -c print_build_info.c
${CC} -c print_build_info.c
%.odata : %.txt
ld -r -b binary -o $@ $<
${LD} -r -b binary -o $@ $<
build_info.txt : ${TEMSPEC}
python code_gen/code_gen.py -b ${TERMSPEC} > $@
build_info.txt : ${TERMSPEC}
${PYTHON} code_gen/code_gen.py -b ${TERMSPEC} > $@
latex_equations.txt : ${TEMSPEC}
python code_gen/code_gen.py -x ${TERMSPEC} > $@
latex_equations.txt : ${TERMSPEC}
${PYTHON} code_gen/code_gen.py -x ${TERMSPEC} > $@

View file

@ -269,6 +269,7 @@ MODULE post
IF(omitnum.gt.0) DEALLOCATE(omit_t)
DEALLOCATE(file_dist)
DEALLOCATE(export_offset)
END SUBROUTINE DEALLOCATES_CLOSE

View file

@ -31,7 +31,12 @@
!First, make sure the right number of inputs have been provided
IF(COMMAND_ARGUMENT_COUNT() > 0) THEN
IF(COMMAND_ARGUMENT_COUNT() > 1) THEN
WRITE(*,*) 'ERROR, TOO MANY COMMAND-LINE ARGUMENTS(MORE THAN ONE). STOPPING'
STOP
ELSE IF(COMMAND_ARGUMENT_COUNT() > 0) THEN
CALL GET_COMMAND_ARGUMENT(1,num1char) !first, read in the two values
@ -52,11 +57,6 @@
STOP
ELSE IF(COMMAND_ARGUMENT_COUNT() > 1) THEN
WRITE(*,*) 'ERROR, TOO MANY COMMAND-LINE ARGUMENTS(MORE THAN ONE). STOPPING'
STOP
ELSE
CALL m_openmpi_init