Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fixed to compile in gfortran
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Oct 9, 2021
1 parent 4053cd2 commit fe9356d
Show file tree
Hide file tree
Showing 14 changed files with 70 additions and 69 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ SWIFTEST_MODULES = swiftest_globals.f90 \

include Makefile.Defines

MKL_ROOT = /apps/spack/bell/apps/intel-parallel-studio/cluster.2019.5-intel-19.0.5-4brgqlf/mkl/lib
IMKL = -I$(MKLROOT)/include
LMKL = -L$(MKLROOT)/lib/intel64 -qopt-matmul
#MKL_ROOT = /apps/spack/bell/apps/intel-parallel-studio/cluster.2019.5-intel-19.0.5-4brgqlf/mkl/lib
#IMKL = -I$(MKLROOT)/include
#LMKL = -L$(MKLROOT)/lib/intel64 -qopt-matmul

MODULES = $(SWIFTEST_MODULES) $(USER_MODULES)

Expand Down
14 changes: 7 additions & 7 deletions Makefile.Defines
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,18 @@ GDEBUG = -g -Og -fbacktrace -fbounds-check -ffree-line-length-none
GPAR = -fopenmp #-ftree-parallelize-loops=4
GMEM = -fsanitize-address-use-after-scope -fstack-check -fsanitize=bounds-strict -fsanitize=undefined -fsanitize=signed-integer-overflow -fsanitize=object-size -fstack-protector-all
GWARNINGS = -Wall -Warray-bounds -Wimplicit-interface -Wextra -Warray-temporaries
GPRODUCTION = -O2 -ffree-line-length-none $(GPAR)
GPRODUCTION = -O3 -ffree-line-length-none $(GPAR)

#FFLAGS = $(IDEBUG) $(SIMDVEC) $(PAR)
#FFASTFLAGS = $(IDEBUG) $(SIMDVEC) $(PAR)
FSTRICTFLAGS = $(IPRODUCTION) $(STRICTREAL) $(OPTREPORT) #$(ADVIXE_FLAGS)
FFLAGS = $(IPRODUCTION) -fp-model=fast $(OPTREPORT) #$(ADVIXE_FLAGS)
FORTRAN = ifort
#FSTRICTFLAGS = $(IPRODUCTION) $(STRICTREAL) $(OPTREPORT) #$(ADVIXE_FLAGS)
#FFLAGS = $(IPRODUCTION) -fp-model=fast $(OPTREPORT) #$(ADVIXE_FLAGS)
#FORTRAN = ifort
AR = xiar

#FORTRAN = gfortran
#FFLAGS = $(GDEBUG) # $(GMEM) $(GPAR)
#FFLAGS = $(GPRODUCTION) -g -fbacktrace #-fcheck=all #-Wall AR = ar # DO NOT include in CFLAGS the "-c" option to compile object only
FORTRAN = gfortran
FFLAGS = $(GDEBUG) # $(GMEM) $(GPAR)
#FFLAGS = $(GPRODUCTION) -g -fbacktrace -fcheck=all #-Wall AR = ar # DO NOT include in CFLAGS the "-c" option to compile object only
# this is done explicitly as needed in the Makefile

CC = icc
Expand Down
20 changes: 10 additions & 10 deletions src/drift/drift.f90
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ end subroutine drift_all


module pure elemental subroutine drift_one(mu, px, py, pz, vx, vy, vz, dt, iflag)
!$omp declare simd(drift_one)
!!$omp declare simd(drift_one)
!! author: The Purdue Swiftest Team - David A. Minton, Carlisle A. Wishard, Jennifer L.L. Pouplin, and Jacob R. Elliott
!!
!! Perform Danby drift for one body, redoing drift with smaller substeps if original accuracy is insufficient
Expand Down Expand Up @@ -119,7 +119,7 @@ end subroutine drift_one


pure subroutine drift_dan(mu, px0, py0, pz0, vx0, vy0, vz0, dt0, iflag)
!$omp declare simd(drift_dan)
!!$omp declare simd(drift_dan)
!! author: David A. Minton
!!
!! Perform Kepler drift, solving Kepler's equation in appropriate variables
Expand Down Expand Up @@ -197,7 +197,7 @@ end subroutine drift_dan


pure subroutine drift_kepmd(dm, es, ec, x, s, c)
!$omp declare simd(drift_kepmd)
!!$omp declare simd(drift_kepmd)
!! author: David A. Minton
!!
!! Solve Kepler's equation in difference form for an ellipse for small input dm and eccentricity
Expand Down Expand Up @@ -243,7 +243,7 @@ end subroutine drift_kepmd


pure subroutine drift_kepu(dt,r0,mu,alpha,u,fp,c1,c2,c3,iflag)
!$omp declare simd(drift_kepu)
!!$omp declare simd(drift_kepu)
!! author: David A. Minton
!!
!! Solve Kepler's equation in universal variables
Expand Down Expand Up @@ -272,7 +272,7 @@ end subroutine drift_kepu


pure subroutine drift_kepu_fchk(dt, r0, mu, alpha, u, s, f)
!$omp declare simd(drift_kepu_fchk)
!!$omp declare simd(drift_kepu_fchk)
!! author: David A. Minton
!!
!! Computes the value of f, the function whose root we are trying to find in universal variables
Expand Down Expand Up @@ -303,7 +303,7 @@ end subroutine drift_kepu_fchk


pure subroutine drift_kepu_guess(dt, r0, mu, alpha, u, s)
!$omp declare simd(drift_kepu_guess)
!!$omp declare simd(drift_kepu_guess)
!! author: David A. Minton
!!
!! Compute initial guess for solving Kepler's equation using universal variables
Expand Down Expand Up @@ -348,7 +348,7 @@ end subroutine drift_kepu_guess


pure subroutine drift_kepu_lag(s, dt, r0, mu, alpha, u, fp, c1, c2, c3, iflag)
!$omp declare simd(drift_kepu_lag)
!!$omp declare simd(drift_kepu_lag)
!! author: David A. Minton
!!
!! Solve Kepler's equation in universal variables using Laguerre's method
Expand Down Expand Up @@ -403,7 +403,7 @@ end subroutine drift_kepu_lag


pure subroutine drift_kepu_new(s, dt, r0, mu, alpha, u, fp, c1, c2, c3, iflag)
!$omp declare simd(drift_kepu_new)
!!$omp declare simd(drift_kepu_new)
!! author: David A. Minton
!!
!! Solve Kepler's equation in universal variables using Newton's method
Expand Down Expand Up @@ -455,7 +455,7 @@ end subroutine drift_kepu_new


pure subroutine drift_kepu_p3solve(dt, r0, mu, alpha, u, s, iflag)
!$omp declare simd(drift_kepu_p3solve)
!!$omp declare simd(drift_kepu_p3solve)
!! author: David A. Minton
!!
!! Computes real root of cubic involved in setting initial guess for solving Kepler's equation in universal variables
Expand Down Expand Up @@ -506,7 +506,7 @@ end subroutine drift_kepu_p3solve


pure subroutine drift_kepu_stumpff(x, c0, c1, c2, c3)
!$omp declare simd(drift_kepu_stumpff)
!!$omp declare simd(drift_kepu_stumpff)
!! author: David A. Minton
!!
!! Compute Stumpff functions needed for Kepler drift in universal variables
Expand Down
6 changes: 3 additions & 3 deletions src/encounter/encounter_check.f90
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ end subroutine encounter_check_all_triangular_pltp


module pure subroutine encounter_check_one(xr, yr, zr, vxr, vyr, vzr, renc, dt, lencounter, lvdotr)
!$omp declare simd(encounter_check_one)
!!$omp declare simd(encounter_check_one)
!! author: David A. Minton
!!
!! Determine whether a test particle and planet are having or will have an encounter within the next time step
Expand Down Expand Up @@ -1068,7 +1068,7 @@ end subroutine encounter_check_sweep_aabb_all_single_list


pure subroutine encounter_check_sweep_aabb_one_double_list(i, n1, n2, ntot, ext_ind, ibegxi, iendxi, ibegyi, iendyi, ibegx, iendx, ibegy, iendy, lencounteri)
!$omp declare simd(encounter_check_sweep_aabb_one_double_list)
!!$omp declare simd(encounter_check_sweep_aabb_one_double_list)
!! author: David A. Minton
!!
!! Performs a sweep operation on a single body. Encounters from the same lists not allowed (e.g. pl-tp encounters only)
Expand Down Expand Up @@ -1101,7 +1101,7 @@ end subroutine encounter_check_sweep_aabb_one_double_list


pure subroutine encounter_check_sweep_aabb_one_single_list(n, ext_ind, ibegxi, iendxi, ibegyi, iendyi, ibegx, iendx, ibegy, iendy, lencounteri)
!$omp declare simd(encounter_check_sweep_aabb_one_single_list)
!!$omp declare simd(encounter_check_sweep_aabb_one_single_list)
!! author: David A. Minton
!!
!! Performs a sweep operation on a single body. Mutual encounters allowed (e.g. pl-pl)
Expand Down
28 changes: 13 additions & 15 deletions src/fraggle/fraggle_generate.f90
Original file line number Diff line number Diff line change
Expand Up @@ -547,21 +547,19 @@ function radial_objective_function(v_r_mag_input) result(fval)
real(DP), dimension(frag%nbody) :: kearr
real(DP) :: keo, ke_radial, rotmag2, vmag2

associate(nfrag => frag%nbody)
allocate(v_shift, mold=frag%vb)
v_shift(:,:) = fraggle_util_vmag_to_vb(v_r_mag_input, frag%v_r_unit, frag%v_t_mag, frag%v_t_unit, frag%mass, frag%vbcom)
!$omp do simd firstprivate(nfrag) lastprivate(rotmag2, vmag2)
do i = 1,nfrag
rotmag2 = frag%rot(1,i)**2 + frag%rot(2,i)**2 + frag%rot(3,i)**2
vmag2 = v_shift(1,i)**2 + v_shift(2,i)**2 + v_shift(3,i)**2
kearr(i) = frag%mass(i) * (frag%Ip(3, i) * frag%radius(i)**2 * rotmag2 + vmag2)
end do
!$omp end do simd
keo = 2 * frag%ke_budget - sum(kearr(:))
ke_radial = frag%ke_budget - frag%ke_orbit - frag%ke_spin
! The following ensures that fval = 0 is a local minimum, which is what the BFGS method is searching for
fval = (keo / (2 * ke_radial))**2
end associate
allocate(v_shift, mold=frag%vb)
v_shift(:,:) = fraggle_util_vmag_to_vb(v_r_mag_input, frag%v_r_unit, frag%v_t_mag, frag%v_t_unit, frag%mass, frag%vbcom)
!$omp do simd firstprivate(frag)
do i = 1,frag%nbody
rotmag2 = frag%rot(1,i)**2 + frag%rot(2,i)**2 + frag%rot(3,i)**2
vmag2 = v_shift(1,i)**2 + v_shift(2,i)**2 + v_shift(3,i)**2
kearr(i) = frag%mass(i) * (frag%Ip(3, i) * frag%radius(i)**2 * rotmag2 + vmag2)
end do
!$omp end do simd
keo = 2 * frag%ke_budget - sum(kearr(:))
ke_radial = frag%ke_budget - frag%ke_orbit - frag%ke_spin
! The following ensures that fval = 0 is a local minimum, which is what the BFGS method is searching for
fval = (keo / (2 * ke_radial))**2

return
end function radial_objective_function
Expand Down
2 changes: 1 addition & 1 deletion src/helio/helio_drift.f90
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ end subroutine helio_drift_tp


pure elemental subroutine helio_drift_linear_one(xhx, xhy, xhz, ptx, pty, ptz, dt)
!$omp declare simd(helio_drift_linear_one)
!!$omp declare simd(helio_drift_linear_one)
implicit none
real(DP), intent(inout) :: xhx, xhy, xhz
real(DP), intent(in) :: ptx, pty, ptz, dt
Expand Down
10 changes: 6 additions & 4 deletions src/kick/kick.f90
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ module subroutine kick_getacch_int_all_flat_pl(npl, nplpl, k_plpl, x, Gmass, rad
zr = x(3, j) - x(3, i)
rji2 = xr**2 + yr**2 + zr**2
rlim2 = (radius(i) + radius(j))**2
if (rji2 > rlim2) call kick_getacch_int_one_pl(rji2, xr, yr, zr, Gmass(i), Gmass(j), ahi(1,i), ahi(2,i), ahi(3,i), ahj(1,j), ahj(2,j), ahj(3,j))
if (rji2 > rlim2) call kick_getacch_int_one_pl(rji2, xr, yr, zr, Gmass(i), Gmass(j), &
ahi(1,i), ahi(2,i), ahi(3,i), ahj(1,j), ahj(2,j), ahj(3,j))
end do
!$omp end parallel do

Expand Down Expand Up @@ -156,7 +157,8 @@ module subroutine kick_getacch_int_all_triangular_pl(npl, nplm, x, Gmass, radius
zr = x(3, j) - x(3, i)
rji2 = xr**2 + yr**2 + zr**2
rlim2 = (radius(i) + radius(j))**2
if (rji2 > rlim2) call kick_getacch_int_one_pl(rji2, xr, yr, zr, Gmass(i), Gmass(j), ahi(1,i), ahi(2,i), ahi(3,i), ahj(1,j), ahj(2,j), ahj(3,j))
if (rji2 > rlim2) call kick_getacch_int_one_pl(rji2, xr, yr, zr, Gmass(i), Gmass(j), &
ahi(1,i), ahi(2,i), ahi(3,i), ahj(1,j), ahj(2,j), ahj(3,j))
end do
end do
!$omp end parallel do
Expand Down Expand Up @@ -210,7 +212,7 @@ end subroutine kick_getacch_int_all_tp


module pure subroutine kick_getacch_int_one_pl(rji2, xr, yr, zr, Gmi, Gmj, axi, ayi, azi, axj, ayj, azj)
!$omp declare simd(kick_getacch_int_one_pl)
!!$omp declare simd(kick_getacch_int_one_pl)
!! author: David A. Minton
!!
!! Compute direct cross (third) term heliocentric accelerations for a single pair of massive bodies
Expand Down Expand Up @@ -242,7 +244,7 @@ end subroutine kick_getacch_int_one_pl


module pure subroutine kick_getacch_int_one_tp(rji2, xr, yr, zr, GMpl, ax, ay, az)
!$omp declare simd(kick_getacch_int_one_tp)
!!$omp declare simd(kick_getacch_int_one_tp)
!! author: David A. Minton
!!
!! Compute direct cross (third) term heliocentric accelerations of a single test particle massive body pair.
Expand Down
2 changes: 1 addition & 1 deletion src/modules/encounter_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ module subroutine encounter_check_collapse_ragged_list(ragged_list, n1, nenc, in
logical, dimension(:), allocatable, intent(out), optional :: lvdotr !! Array indicating which bodies are approaching
end subroutine encounter_check_collapse_ragged_list

module subroutine encounter_check_sort_aabb_1D(self, n, extent_arr)
module pure subroutine encounter_check_sort_aabb_1D(self, n, extent_arr)
implicit none
class(encounter_bounding_box_1D), intent(inout) :: self !! Bounding box structure along a single dimension
integer(I4B), intent(in) :: n !! Number of bodies with extents
Expand Down
14 changes: 7 additions & 7 deletions src/operators/operator_cross.f90
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
contains

module pure function operator_cross_sp(A, B) result(C)
!$omp declare simd(operator_cross_sp)
!!$omp declare simd(operator_cross_sp)
implicit none
real(SP), dimension(:), intent(in) :: A, B
real(SP), dimension(3) :: C
Expand All @@ -19,7 +19,7 @@ module pure function operator_cross_sp(A, B) result(C)
end function operator_cross_sp

module pure function operator_cross_dp(A, B) result(C)
!$omp declare simd(operator_cross_dp)
!!$omp declare simd(operator_cross_dp)
implicit none
real(DP), dimension(:), intent(in) :: A, B
real(DP), dimension(3) :: C
Expand All @@ -30,7 +30,7 @@ module pure function operator_cross_dp(A, B) result(C)
end function operator_cross_dp

module pure function operator_cross_qp(A, B) result(C)
!$omp declare simd(operator_cross_qp)
!!$omp declare simd(operator_cross_qp)
implicit none
real(QP), dimension(:), intent(in) :: A, B
real(QP), dimension(3) :: C
Expand All @@ -41,7 +41,7 @@ module pure function operator_cross_qp(A, B) result(C)
end function operator_cross_qp

module pure function operator_cross_i1b(A, B) result(C)
!$omp declare simd(operator_cross_i1b)
!!$omp declare simd(operator_cross_i1b)
implicit none
integer(I1B), dimension(:), intent(in) :: A, B
integer(I1B), dimension(3) :: C
Expand All @@ -52,7 +52,7 @@ module pure function operator_cross_i1b(A, B) result(C)
end function operator_cross_i1b

module pure function operator_cross_i2b(A, B) result(C)
!$omp declare simd(operator_cross_i2b)
!!$omp declare simd(operator_cross_i2b)
implicit none
integer(I2B), dimension(:), intent(in) :: A, B
integer(I2B), dimension(3) :: C
Expand All @@ -63,7 +63,7 @@ module pure function operator_cross_i2b(A, B) result(C)
end function operator_cross_i2b

module pure function operator_cross_i4b(A, B) result(C)
!$omp declare simd(operator_cross_i4b)
!!$omp declare simd(operator_cross_i4b)
implicit none
integer(I4B), dimension(:), intent(in) :: A, B
integer(I4B), dimension(3) :: C
Expand All @@ -74,7 +74,7 @@ module pure function operator_cross_i4b(A, B) result(C)
end function operator_cross_i4b

module pure function operator_cross_i8b(A, B) result(C)
!$omp declare simd(operator_cross_i8b)
!!$omp declare simd(operator_cross_i8b)
implicit none
integer(I8B), dimension(:), intent(in) :: A, B
integer(I8B), dimension(3) :: C
Expand Down
4 changes: 2 additions & 2 deletions src/operators/operator_mag.f90
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
contains

module pure function operator_mag_sp(A) result(B)
!$omp declare simd(operator_mag_sp)
!!$omp declare simd(operator_mag_sp)
implicit none
real(SP), dimension(:), intent(in) :: A
real(SP) :: B
Expand All @@ -16,7 +16,7 @@ module pure function operator_mag_sp(A) result(B)
end function operator_mag_sp

module pure function operator_mag_dp(A) result(B)
!$omp declare simd(operator_mag_dp)
!!$omp declare simd(operator_mag_dp)
implicit none
real(DP), dimension(:), intent(in) :: A
real(DP) :: B
Expand Down
Loading

0 comments on commit fe9356d

Please sign in to comment.