Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dcon/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ sing.o: fourfit.o
debug.o: ../equil/local_mod.mod
ode_output.o: dcon_mod.o sing.o debug.o
ode.o: ode_output.o free.o
dcon_netcdf.o: dcon_mod.o
dcon_netcdf.o: dcon_mod.o sing.o
free.o: ../equil/global_mod.mod dcon_netcdf.o ode_output.o
resist.o: dcon_mod.o
dcon.o: ../equil/equil_mod.mod ../equil/equil_out_mod.mod \
Expand Down
20 changes: 18 additions & 2 deletions dcon/sing.f
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,16 @@ END SUBROUTINE sing_lim
c declarations.
c-----------------------------------------------------------------------
SUBROUTINE sing_vmat(ising)
USE, INTRINSIC :: ieee_arithmetic

INTEGER, INTENT(IN) :: ising

LOGICAL, PARAMETER :: diagnose=.FALSE.
INTEGER :: ipert0,ipert,k
REAL(r8) :: psifac,di,di0,q,q1,rho,dpsi
REAL(r8), PARAMETER :: half=.5_r8
REAL(r8) :: val

COMPLEX(r8) :: det
TYPE(sing_type), POINTER :: singp
c-----------------------------------------------------------------------
Expand Down Expand Up @@ -309,8 +312,21 @@ SUBROUTINE sing_vmat(ising)
singp%power=0
singp%power(ipert0)=-singp%alpha
singp%power(ipert0+mpert)=singp%alpha
WRITE(out_unit,'(i3,1p,7e11.3)')ising,psifac,rho,q,q1,di0,
$ singp%di,singp%di/di0-1

! Temporary protection to prevent SIGFPE (division by zero or invalid
! WRITE(out_unit,'(i3,1p,7e11.3)')ising,psifac,rho,q,q1,di0,
! singp%di,singp%di/di0-1
! di0)
IF (abs(di0) > 1.0e-12 .AND. ieee_is_finite(di0)) THEN

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really neat! I have been wanting to look into using IEEE checks for things, it greatly helps improve reproducibility across compilers and platforms. Have you tried going through with the gfortran compile flag -ffpe-trap? Using -ffpe-trap='invalid' for example can be very helpful in trying to find these instances of divide by zeros and overflow/underflows.

val = singp%di / di0 - 1
ELSE
val = 0.0_r8
PRINT *, 'WARNING: di0 is zero or invalid at ising = ', ising,
$ ' di0= ', di0
ENDIF

WRITE(out_unit,'(i3,1p,7e11.3)') ising, psifac, rho, q, q1, di0,
$ singp%di, val
c-----------------------------------------------------------------------
c zeroth-order non-resonant solutions.
c-----------------------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion equil/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ local.o: io.o
utils.o: local.o
spline.o: local.o
grid.o: local.o spline.o
bicube.o: spline.o
bicube.o: local.o spline.o
cspline.o: local.o
fft.o: local.o
jacobi.o: local.o
cspline.o: local.o spline.o
fspline.o: local.o spline.o cspline.o utils.o fft.o
global.o: bicube.o cspline.o
inverse.o: global.o utils.o grid.o
Expand Down
19 changes: 17 additions & 2 deletions gpec/gpout.f
Original file line number Diff line number Diff line change
Expand Up @@ -1975,7 +1975,8 @@ SUBROUTINE gpout_singfld(egnum,xspmn,spot,nspot,
aq(ising) = singtype(ising)%q
asingflx(ising) = ABS(singflx_mn(resnum(ising),ising))
ENDDO
ierr=set_harvest_payload_dbl_array(hlog,"q"//nul,aq,msing)
ierr=set_harvest_payload_dbl_array(hlog,"q"//nul,
$ aq,msing)
ierr=set_harvest_payload_dbl_array(hlog,"singcur"//nul,
$ ABS(singcur),msing)
ierr=set_harvest_payload_dbl_array(hlog,"singflx"//nul,
Expand Down Expand Up @@ -5610,6 +5611,7 @@ SUBROUTINE gpout_control_filter(mode,finmn,foutmn,ftypes,fmodes,
c-----------------------------------------------------------------------
c declaration.
c-----------------------------------------------------------------------
USE, INTRINSIC :: ieee_arithmetic
INTEGER, INTENT(IN) :: fmodes,rout,bpout,bout,rcout,tout,mode
CHARACTER(len=*), INTENT(IN) :: ftypes
COMPLEX(r8), DIMENSION(mpert), INTENT(INOUT) :: finmn,foutmn
Expand Down Expand Up @@ -5765,7 +5767,20 @@ SUBROUTINE gpout_control_filter(mode,finmn,foutmn,ftypes,fmodes,
DO i=1,mpert
tempm = wvecs(:,i)
avals(i) = 0.5*REAL(DOT_PRODUCT(tempm,MATMUL(mat,tempm)))
avals(i) = avals(i)/wvals(i)

! Temporary safeguard against division by zero or invalid
! values (may cause SIGFPE)
!avals(i) = avals(i)/wvals(i)
IF (abs(wvals(i)) > 1.0e-12 .AND. ieee_is_finite(wvals(i)))
$ THEN
avals(i) = avals(i) / wvals(i)
ELSE
avals(i) = 0.0_r8
! NOTE: Temporary fix – wvals(i) is zero or NaN/Inf;
! skipping division to prevent crash
PRINT *, 'WARNING: Skipping division by wvals(', i, ') = ',
$ wvals(i)
END IF
ENDDO
aindx = (/(i,i=1,mpert)/)
CALL isbubble(avals,aindx,1,mpert)
Expand Down
22 changes: 21 additions & 1 deletion install/DEFAULTS.inc
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@
#-----------------------------------------------------------------
# general defaults
#-----------------------------------------------------------------
HOST := $(shell hostname)

# The new modules on portal at PPPL now use LAPACK_HOME instead of LAPACKHOME
ifndef LAPACKHOME
Expand Down Expand Up @@ -405,6 +406,10 @@ else
endif
ifneq ($(wildcard $(NETCDFHOME)/lib/.),)
NETCDFDIR = $(NETCDFHOME)/lib
HOST := $(shell hostname)
ifneq (,$(findstring flux,$(HOST)))
NETCDFDIR = $(NETCDFHOME)/lib64
endif
else
NETCDFDIR = $(NETCDFHOME)
endif
Expand All @@ -421,6 +426,12 @@ ifdef NETCDF_C_HOME
NETCDFLIBS = -lnetcdff
NETCDF_C_LIBS = -lnetcdf
NETCDF_C_DIR = $(NETCDF_C_HOME)/lib

HOST := $(shell hostname)
ifneq (,$(findstring flux,$(HOST)))
NETCDF_C_DIR = $(NETCDF_C_HOME)/lib64
endif

NETCDF_EXTRA_LIBS = -L$(NETCDF_C_DIR) $(NETCDF_C_LIBS)
else
ifneq ($(shell ls $(NETCDFDIR) | grep netcdff),)
Expand Down Expand Up @@ -489,4 +500,13 @@ else
OMPFLAG ?= -openmp
RECURSFLAG ?= -recursive
LEGACYFLAG ?= -std=legacy
endif
endif
ifeq ($(findstring icx,$(CC)),icx)
CFLAGS ?= "-Wno-all -Wno-absolute-value -Wno-pointer-sign -Wno-deprecated-non-prototype"
else ifeq ($(findstring icc,$(CC)),icc)
CFLAGS ?= "-Wno-all -Wno-absolute-value -Wno-pointer-sign -Wno-deprecated-non-prototype"
endif




112 changes: 56 additions & 56 deletions install/makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

include DEFAULTS.inc

# extend these variables to sub-makes (?= sets a default if user doesn't specify options)

# extend these variables to sub-$(MAKE)s (?= sets a default if user doesn't specify options)
FFLAGS ?= -g
CFLAGS ?= -g

Expand All @@ -26,65 +26,65 @@ allf: v harvest equil lsode zlange zvode orbit vacuum pentrc dcon match rdcon rm

harvest:
cd ../; git submodule init; git submodule update
cd ../harvest; make FC='$(FC)' CC='$(CC)' GACODE_ROOT= -f Makefile libharvest.a
cd ../harvest; $(MAKE) FC='$(FC)' CC='$(CC)' GACODE_ROOT= -f Makefile libharvest.a
mkdir -p ../lib
cp -f ../harvest/libharvest.a ../lib/

xdraw:
cd ../xdraw; make
cd ../xdraw; $(MAKE)

lsode:
cd ../lsode; make liblsode
lsode: equil
cd ../lsode; $(MAKE) liblsode

zlange:
cd ../zlange; make libzlange
zlange: equil
cd ../zlange; $(MAKE) libzlange

zvode:
cd ../zvode; make libzvode
cd ../zvode; $(MAKE) libzvode

equil:
cd ../equil; make libequil
cd ../equil; $(MAKE) libequil

vacuum:
cd ../vacuum; make libvac
vacuum: equil
cd ../vacuum; $(MAKE) libvac

orbit:
cd ../orbit; make orbit
orbit: equil lsode
cd ../orbit; $(MAKE) orbit

dcon:
cd ../dcon; make dcon
dcon: equil pentrc vacuum
cd ../dcon; $(MAKE) dcon

match:
cd ../match; make match
match: equil
cd ../match; $(MAKE) match

rdcon:
cd ../rdcon; make rdcon
rdcon: equil
cd ../rdcon; $(MAKE) rdcon

rmatch:
cd ../rmatch; make rmatch
rmatch: equil
cd ../rmatch; $(MAKE) rmatch

multi:
cd ../multi; make multi
multi: equil
cd ../multi; $(MAKE) multi

sum:
cd ../sum; make sum
sum: equil
cd ../sum; $(MAKE) sum

slayer:
cd ../slayer; make slayer
slayer: equil
cd ../slayer; $(MAKE) slayer

coil:
cd ../coil; make libcoil
coil: equil
cd ../coil; $(MAKE) libcoil

gpec:
cd ../gpec; make gpec
gpec: equil coil vacuum pentrc
cd ../gpec; $(MAKE) gpec

pentrc:
cd ../pentrc; make pentrc
pentrc: equil
cd ../pentrc; $(MAKE) pentrc

stride:
cd ../stride; make stride
stride: equil vacuum
cd ../stride; $(MAKE) stride

mkbin:
mkbin: orbit dcon match rdcon rmatch xdraw multi sum slayer gpec pentrc stride
mkdir -p ../bin
cp -f ../orbit/orbit ../bin
cp -f ../dcon/dcon ../bin
Expand Down Expand Up @@ -125,25 +125,25 @@ endif
# cleaning

clean:
cd ../harvest; make clean
cd ../zlange; make clean
cd ../zvode; make clean
cd ../xdraw; make clean
cd ../lsode; make clean
cd ../equil; make clean
cd ../orbit; make clean
cd ../vacuum; make clean
cd ../dcon; make clean
cd ../match; make clean
cd ../rdcon; make clean
cd ../rmatch; make clean
cd ../multi; make clean
cd ../sum; make clean
cd ../slayer; make clean
cd ../coil; make clean
cd ../gpec; make clean
cd ../pentrc; make clean
cd ../stride; make clean
cd ../harvest; $(MAKE) clean
cd ../zlange; $(MAKE) clean
cd ../zvode; $(MAKE) clean
cd ../xdraw; $(MAKE) clean
cd ../lsode; $(MAKE) clean
cd ../equil; $(MAKE) clean
cd ../orbit; $(MAKE) clean
cd ../vacuum; $(MAKE) clean
cd ../dcon; $(MAKE) clean
cd ../match; $(MAKE) clean
cd ../rdcon; $(MAKE) clean
cd ../rmatch; $(MAKE) clean
cd ../multi; $(MAKE) clean
cd ../sum; $(MAKE) clean
cd ../slayer; $(MAKE) clean
cd ../coil; $(MAKE) clean
cd ../gpec; $(MAKE) clean
cd ../pentrc; $(MAKE) clean
cd ../stride; $(MAKE) clean

clear:
cd ../docs/examples/run_ideal_example; rm -f *.out *.bin *.nc
Expand Down
2 changes: 1 addition & 1 deletion pentrc/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ utilities.o: params.o
special.o: params.o utilities.o
dcon_interface.o: params.o utilities.o ../equil/spline_mod.mod ../equil/fspline_mod.mod ../equil/cspline_mod.mod ../equil/bicube_mod.mod
inputs.o: params.o utilities.o special.o dcon_interface.o
energy.o: params.o utilities.o lsode2.o
energy.o: params.o utilities.o lsode2.o dcon_interface.o
pitch.o: params.o utilities.o lsode1.o energy.o special.o
torque.o: params.o utilities.o lsode1.o special.o dcon_interface.o inputs.o energy.o pitch.o
diagnostics.o: params.o special.o energy.o pitch.o
Expand Down
3 changes: 2 additions & 1 deletion xdraw/makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# This is the makefile for XDRAW on Linux computers.
include ../install/DEFAULTS.inc

CFLAGS = -DUNIX -O2 $(X11_INC_DIR)
CFLAGS ?=
CFLAGS += -DUNIX -O2 $(X11_INC_DIR)
CC += $(CFLAGS)

.c.o:
Expand Down
Loading