mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
Added patch for interrupt handling if we want to add it at some point.
This commit is contained in:
parent
8f93de1ee4
commit
0b19909dec
1 changed files with 148 additions and 0 deletions
148
signal.patch
Normal file
148
signal.patch
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
diff --git a/.gitignore b/.gitignore
|
||||
index 99ecbed..6e86cf7 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 a5c9237..d6c1bba 100644
|
||||
--- a/src/Makefile
|
||||
+++ b/src/Makefile
|
||||
@@ -33,6 +33,7 @@ GIT_SHA1 = $(shell git log -1 | head -n 1 | awk '{print $$2}')
|
||||
#===============================================================================
|
||||
|
||||
ifeq ($(COMPILER),gnu)
|
||||
+ CC = gcc
|
||||
F90 = gfortran
|
||||
F90FLAGS := -cpp -fbacktrace -DNO_F2008
|
||||
LDFLAGS =
|
||||
@@ -61,6 +62,7 @@ endif
|
||||
#===============================================================================
|
||||
|
||||
ifeq ($(COMPILER),intel)
|
||||
+ CC = icc
|
||||
F90 = ifort
|
||||
F90FLAGS := -cpp -warn -assume byterecl -traceback
|
||||
LDFLAGS =
|
||||
@@ -88,6 +90,7 @@ endif
|
||||
#===============================================================================
|
||||
|
||||
ifeq ($(COMPILER),pgi)
|
||||
+ CC = pgcc
|
||||
F90 = pgf90
|
||||
F90FLAGS := -Mpreprocess -DNO_F2008 -Minform=inform -traceback
|
||||
LDFLAGS =
|
||||
@@ -115,6 +118,7 @@ endif
|
||||
#===============================================================================
|
||||
|
||||
ifeq ($(COMPILER),ibm)
|
||||
+ CC = xlc
|
||||
F90 = xlf2003
|
||||
F90FLAGS := -WF,-DNO_F2008 -O2
|
||||
|
||||
@@ -206,7 +210,7 @@ distclean: clean
|
||||
cd xml-fortran; make clean
|
||||
cd xml-fortran/templates; make clean
|
||||
clean:
|
||||
- @rm -f *.o *.mod $(program)
|
||||
+ @rm -f *.o *.mod *__genmod.f90 $(program)
|
||||
neat:
|
||||
@rm -f *.o *.mod
|
||||
|
||||
@@ -220,6 +224,9 @@ neat:
|
||||
%.o: %.F90
|
||||
$(F90) $(F90FLAGS) -DGIT_SHA1="\"$(GIT_SHA1)\"" -Ixml-fortran -Ixml-fortran/templates -c $<
|
||||
|
||||
+csignal.o: csignal.c
|
||||
+ $(CC) -c $<
|
||||
+
|
||||
#===============================================================================
|
||||
# Dependencies
|
||||
#===============================================================================
|
||||
diff --git a/src/OBJECTS b/src/OBJECTS
|
||||
index 0daf0f1..a476eb6 100644
|
||||
--- a/src/OBJECTS
|
||||
+++ b/src/OBJECTS
|
||||
@@ -4,6 +4,7 @@ ace_header.o \
|
||||
bank_header.o \
|
||||
cross_section.o \
|
||||
criticality.o \
|
||||
+csignal.o \
|
||||
datatypes.o \
|
||||
datatypes_header.o \
|
||||
doppler.o \
|
||||
@@ -17,6 +18,7 @@ fixed_source.o \
|
||||
geometry.o \
|
||||
geometry_header.o \
|
||||
global.o \
|
||||
+handle_sigint.o \
|
||||
hdf5_interface.o \
|
||||
initialize.o \
|
||||
intercycle.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 <signal.h>
|
||||
+
|
||||
+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 60c0806..8cac6a5 100644
|
||||
--- a/src/initialize.F90
|
||||
+++ b/src/initialize.F90
|
||||
@@ -46,6 +46,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 timer_start(time_total)
|
||||
call timer_start(time_initialize)
|
||||
Loading…
Add table
Add a link
Reference in a new issue