diff --git a/.gitignore b/.gitignore index 8aa7c1f..4c50efb 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ *.mod *.log *.out +*__genmod.f90 # Compiler python objects *.pyc diff --git a/src/Makefile b/src/Makefile index bab47d2..92f3228 100644 --- a/src/Makefile +++ b/src/Makefile @@ -43,6 +43,7 @@ GIT_SHA1 = $(shell git log -1 2>/dev/null | head -n 1 | awk '{print $$2}') #=============================================================================== ifeq ($(COMPILER),gnu) + CC = gcc F90 = gfortran F90FLAGS := -cpp -fbacktrace -DNO_F2008 LDFLAGS = @@ -71,6 +72,7 @@ endif #=============================================================================== ifeq ($(COMPILER),intel) + CC = icc F90 = ifort F90FLAGS := -cpp -warn -assume byterecl -traceback LDFLAGS = @@ -98,6 +100,7 @@ endif #=============================================================================== ifeq ($(COMPILER),pgi) + CC = pgcc F90 = pgf90 F90FLAGS := -Mpreprocess -DNO_F2008 -Minform=inform -traceback LDFLAGS = @@ -125,6 +128,7 @@ endif #=============================================================================== ifeq ($(COMPILER),ibm) + CC = xlc F90 = xlf2003 F90FLAGS := -WF,-DNO_F2008 -O2 @@ -235,7 +239,7 @@ distclean: clean cd xml-fortran; make clean cd templates; make clean clean: - @rm -f *.o *.mod $(program) + @rm -f *.o *.mod *__genmod.f90 $(program) neat: @rm -f *.o *.mod @@ -249,6 +253,9 @@ neat: %.o: %.F90 $(F90) $(F90FLAGS) -DGIT_SHA1="\"$(GIT_SHA1)\"" -Ixml-fortran -Itemplates -c $< +csignal.o: csignal.c + $(CC) -c $< + #=============================================================================== # Dependencies #=============================================================================== diff --git a/src/OBJECTS b/src/OBJECTS index d53f0a5..b2a7f52 100644 --- a/src/OBJECTS +++ b/src/OBJECTS @@ -15,6 +15,7 @@ cmfd_prod_operator.o \ cmfd_snes_solver.o \ constants.o \ cross_section.o \ +csignal.o \ dict_header.o \ doppler.o \ eigenvalue.o \ @@ -28,6 +29,7 @@ fixed_source.o \ geometry.o \ geometry_header.o \ global.o \ +handle_sigint.o \ hdf5_interface.o \ initialize.o \ interpolation.o \ diff --git a/src/csignal.c b/src/csignal.c new file mode 100644 index 0000000..96bfdb5 --- /dev/null +++ b/src/csignal.c @@ -0,0 +1,7 @@ +#include + +typedef void (*sighandler_t)(int); +void signal_(int* signum, sighandler_t handler) +{ + signal(*signum, handler); +} diff --git a/src/handle_sigint.F90 b/src/handle_sigint.F90 new file mode 100644 index 0000000..b2f7d1b --- /dev/null +++ b/src/handle_sigint.F90 @@ -0,0 +1,27 @@ +!=============================================================================== +! HANDLE_SIGINT +!=============================================================================== + +subroutine handle_sigint() + + use, intrinsic :: ISO_FORTRAN_ENV + + integer :: option ! selected user option + + ! Display interrupt options + write(OUTPUT_UNIT,*) 'Run interrupted. Select one of the options below:' + write(OUTPUT_UNIT,*) ' 1. Continue simulation' + write(OUTPUT_UNIT,*) ' 2. Kill simulation' + + ! Read input from user + read(INPUT_UNIT,*) option + + ! Handle selected option + select case (option) + case (1) + return + case (2) + stop + end select + +end subroutine handle_sigint diff --git a/src/initialize.F90 b/src/initialize.F90 index ff3a209..fd2e222 100644 --- a/src/initialize.F90 +++ b/src/initialize.F90 @@ -42,6 +42,10 @@ contains subroutine initialize_run() + ! Set up signal handler for SIGINT + external handle_sigint + call signal(2, handle_sigint) + ! Start total and initialization timer call time_total % start() call time_initialize % start()