Skip to content

Commit

Permalink
Adds special c!omp for single-source build
Browse files Browse the repository at this point in the history
c!omp lines are removed in BASIS builds, which do not support OMP
  • Loading branch information
holm10 committed Jan 11, 2025
1 parent 7d89786 commit dde6c7d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
18 changes: 9 additions & 9 deletions bbb/oderhs.m
Original file line number Diff line number Diff line change
Expand Up @@ -12323,13 +12323,13 @@ integer ia(neq+1) # pointers to beginning of each row in jac,ja
Use(ParallelEval) # ParallelJac

write(*,*) "jc_interf, ParallelJac = ", ParallelJac
if (ParallelJac.eq.1) then
call jac_calc_parallel (neq, t, yl, yldot00, ml, mu, wk,
. nnzmx, jac, ja, ia)
else
c!omp if (ParallelJac.eq.1) then
c!omp call jac_calc_parallel (neq, t, yl, yldot00, ml, mu, wk,
c!omp. nnzmx, jac, ja, ia)
c!omp else
call jac_calc (neq, t, yl, yldot00, ml, mu, wk,
. nnzmx, jac, ja, ia)
endif
c!omp endif
end subroutine jac_calc_interface

subroutine Pandf1rhs_interface(neq, time, yl, yldot)
Expand All @@ -12340,11 +12340,11 @@ subroutine Pandf1rhs_interface(neq, time, yl, yldot)
integer neq
real time, yl(neqmx),yldot(neq)

if (ParallelPandf1.gt.0) then
call OMPPandf1Rhs(neq, time, yl, yldot)
else
c!omp if (ParallelPandf1.gt.0) then
c!omp call OMPPandf1Rhs(neq, time, yl, yldot)
c!omp else
call pandf1(-1, -1, 0, neq, time, yl, yldot)
endif
c!omp endif

end subroutine Pandf1rhs_interface

Expand Down
9 changes: 7 additions & 2 deletions localrules.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,16 @@ def Petsc(s):
s=s.replace("cpetsc","")
return s
def Omp(s):
if getenv("ENV_VAR", 'False').lower() in ('true', '1', 't')
if isomp['status']:
if s.startswith("c!omp"):
s=s.replace("c!omp"," ")
return s

# Check whether to include or exlude c!omp-lines
try:
with open("builder/omp.flag", "r") as f:
isomp = {'status': bool(int(f.readline()))}
except:
isomp = {'status': False}
saved_dec=0
in_uses=0
savedlines=[]
Expand Down
13 changes: 13 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
import os
import os.path
from os import remove
import string
import site
from Forthon.compilers import FCompiler
Expand Down Expand Up @@ -167,6 +168,11 @@ def run(self):
FLAGS['OMPargs'].remove('--omp')
FLAGS['FARGS'].remove('-fopenmp')
FLAGS['CARGS'].remove('-fopenmp')
# Flag for localrules
set_basis_omp(False)
else:
# Flag for localrules
set_basis_omp(True)
# Add boundary checking to non-debug build
if arglist['checkbounds']:
FLAGS['FARGSOPT'] = FLAGS['FARGSOPT'] + [
Expand All @@ -193,6 +199,7 @@ def run(self):
if call(['make',COMPILEFLAGS,OMPFLAGS,'-f','Makefile.Forthon']) != 0:
raise SystemExit("UEDGE build failure")
build.run(self)
remove('builder/omp.flag')

# Modify clean to use make clean
class uedgeClean(build):
Expand All @@ -201,6 +208,12 @@ def run(self):
if call(['make', '-f', 'Makefile.Forthon', 'clean']) != 0:
raise SystemExit("Clean failure")

def set_basis_omp(isomp):
print(isomp, str(int(isomp)))
with open("builder/omp.flag", "w") as f:
f.write(str(int(isomp)))
f.write("\nPassing information on OMP build to localrules.py")


setup( name="uedge",
ext_modules= [
Expand Down

0 comments on commit dde6c7d

Please sign in to comment.