Skip to content

Commit

Permalink
Fast: update setup.scons
Browse files Browse the repository at this point in the history
  • Loading branch information
benoit128 committed Nov 28, 2024
1 parent 2009bc8 commit 3b46ba9
Show file tree
Hide file tree
Showing 26 changed files with 179 additions and 374 deletions.
92 changes: 24 additions & 68 deletions Fast/Fast/setup.scons
Original file line number Diff line number Diff line change
Expand Up @@ -72,91 +72,47 @@ else:

if mpi: libraries += mpiLibs

# Builder fortran
#==============================================================================
# Essai emitter
def addSourceScannerToTargets(target, source, env):
#import SCons.Scanner
#scanner = SCons.Scanner.C.CScanner()
#scanner.skeys = ['.for', '.h']
#for q in zip(source, target):
# f = q[0]
# includes = scanner(f, env, scanner.path_function(env))
# print f,'=='
# for i in includes:
# print " + %s" % (str(i))
# Depends(q[1], str(i))
return (target, source)

PP = Dist.getPP() # preprocessing des fortrans
f77CppArgs = '-D_NOOPENMP4 -DE_SCALAR_COMPUTER -DE_OMP_SOUS_DOMAIN'+" -I'"+fastcIncDir+"'"
#f77CppArgs = '-D_OPENMP4 -DE_SCALAR_COMPUTER -DE_OMP_SOUS_DOMAIN'+" -I'"+fastcIncDir+"'"
cacheLine = Dist.getCacheLine()
if cacheLine == 1: f77CppArgs += ' -DCACHELINE=16'
else: f77CppArgs += ' -DCACHELINE=%d'%cacheLine
nbsocket = Dist.getNbSocket()
if nbsocket == 1: f77CppArgs += ' -DNB_SOCKET=1'
else: f77CppArgs += ' -DNB_SOCKET=%d'%nbsocket

corePerSock = Dist.getCorePerSocket()
if corePerSock== 1: f77CppArgs += ' -DCORE_PER_SOCK=1'
else: f77CppArgs += ' -DCORE_PER_SOCK=%d'%corePerSock

action = PP+'\"'+kcoreIncDir+'\" -I. '+f77CppArgs+' $SOURCES $TARGETS'
bld = Builder(action=action, suffix='.f', src_suffix='.for')
#emitter=addSourceScannerToTargets)

# Env =========================================================================
import srcs
if Dist.getSystem()[0] == 'mingw': tools = ['mingw']
else: tools = None
AR = Dist.getAR()
env = Environment(tools=tools, CC=cc, CXX=cxx, AR=AR, CFLAGS=[], CXXFLAGS=[],
BUILDERS={'FPROC': bld}, FORTRAN=f77compiler,
env = Environment(tools=tools, CC=cc, CXX=cxx, AR=AR, CPPFLAGS=[],
FORTRAN=f77compiler,
LIBPATH=additionalLibPaths+libraryDirs,
LIBS=libraries+additionalLibs,
SHLIBSUFFIX=so_ext, SHLIBPREFIX='',
LINKFLAGS=Dist.getLinkArgs(),
ENV=Dist.getEnvForScons())
env.Replace(CPPPATH=[".","Fast"]+additionalIncludePaths+includeDirs)

ELSAPROD = os.environ.get('ELSAPROD', 'x86_r8')
env.SConsignFile('build/'+ELSAPROD+'/.sconsign.dblite')
env.Replace(CPPPATH=[".", "Fast"]+additionalIncludePaths+includeDirs)
env.Replace(CXXFLAGS=Dist.getCppArgs()+ADDITIONALCPPFLAGS)
env.Replace(CFLAGS=Dist.getCArgs()+ADDITIONALCPPFLAGS)

env = Dist.createFortranScanner(env)

# Pre processing du C
cppArgs = Dist.getCppArgs()+['-g']+["-DE_SCALAR_COMPUTER -DE_OMP_SOUS_DOMAIN"]
if Dist.getCacheLine() == 1: cppArgs += ['-DCACHELINE=16']
env.Replace(CPPFLAGS=cppArgs+ADDITIONALCPPFLAGS)
#=============================================================================================

### voir installBase de KCore pour option de compil par defaut
if f90compiler == 'ifort':
FFLAGS = Dist.getForArgs()
env.Replace(FORTRANFLAGS=FFLAGS)
else:
env.Replace(FORTRANFLAGS=Dist.getForArgs())

if f77compiler == 'ifort':
version = Dist.getForVersion() # A utiliser version=(13,4)
floatType = '-r8' if Dist.EDOUBLEINT else '-r8 -i4'
f77Args = floatType+' -g -fno-alias -fno-fnalias -ip'
cacheLine = Dist.getCacheLine()

simd = Dist.getSimd()
if cacheLine != 1: f77Args += ' -align array%dbyte '%cacheLine

if version[0] >= 17:
env.Replace(FORTRANCOM = '$FORTRAN $FORTRANFLAGS '+f77Args+' -qopt-report5 -qopt-report-phase=loop,vec,cg -qopt-report-embed -unroll0 -c -o $TARGET $SOURCE')
else:
env.Replace(FORTRANCOM = '$FORTRAN $FORTRANFLAGS '+f77Args+' -unroll0 -c -o $TARGET $SOURCE')

env.Replace(FORTRANSUFFIXES=['.f', '.F', '.f90', '.F90'])
fortran_builder = Builder(action='$FORTRANCOM',
suffix='.o', src_suffix='.f')
# additional fortran preprocessing args
addFPPArgs = '-D_OPENMP4 -D_OPENMP -DE_SCALAR_COMPUTER -DE_OMP_SOUS_DOMAIN'
# additional fortran compiler flags
addFFlags = []
cacheLine = Dist.getCacheLine()
if cacheLine == 1: addFPPArgs += ' -DCACHELINE=16'
else: addFPPArgs += ' -DCACHELINE=%d'%cacheLine
nbsocket = Dist.getNbSocket()
if nbsocket == 1: addFPPArgs += ' -DNB_SOCKET=1'
else: addFPPArgs += ' -DNB_SOCKET=%d'%nbsocket
if Dist.DEBUG: addFPPArgs += ' -D__DEBUG__'
corePerSock = Dist.getCorePerSocket()
if corePerSock== 1: addFPPArgs += ' -DCORE_PER_SOCK=1'
else: addFPPArgs += ' -DCORE_PER_SOCK=%d'%corePerSock

if f77compiler == 'gfortran' or f77compiler == 'x86_64-w64-mingw32-gfortran':
addFFlags += ['-fdefault-real-8', '-fdefault-double-8']

env.Append(BUILDERS={'Fortran' : fortran_builder})
env = Dist.createFortranBuilder(env, dirs=["."],
additionalPPArgs=addFPPArgs, additionalFortranArgs=addFFlags)

# Scan fortran files and store dependencies
parentFolder = os.path.dirname(os.path.dirname(os.getcwd()))
Expand Down
7 changes: 1 addition & 6 deletions Fast/FastC/FastC/HPC_LAYER/verrou.for
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ c***********************************************************************
INTEGER_E lok, ival
integer*8 compteur

#include "parallelF.h"

C var loc
INTEGER_E lok_tmp

Expand Down Expand Up @@ -88,12 +86,9 @@ c***********************************************************************

INTEGER_E lok(1), ival

#include "parallelF.h"

C var loc
INTEGER_E lok_tmp
integer*8 compteur


IF(ival.eq.1) then !! verrou go

100 continue
Expand Down
110 changes: 27 additions & 83 deletions Fast/FastC/setup.scons
Original file line number Diff line number Diff line change
Expand Up @@ -55,103 +55,47 @@ else:

if mpi: libraries += mpiLibs

# Builder fortran
#==============================================================================
# Essai emitter
def addSourceScannerToTargets(target, source, env):
#import SCons.Scanner
#scanner = SCons.Scanner.C.CScanner()
#scanner.skeys = ['.for', '.h']
#for q in zip(source, target):
# f = q[0]
# includes = scanner(f, env, scanner.path_function(env))
# print f,'=='
# for i in includes:
# print " + %s" % (str(i))
# Depends(q[1], str(i))
return (target, source)

PP = Dist.getPP() # preprocessing des fortrans
#f77CppArgs = '-D_NOOPENMP4 -DE_SCALAR_COMPUTER -DE_OMP_SOUS_DOMAIN'
f77CppArgs = '-D_OPENMP4 -DE_SCALAR_COMPUTER -DE_OMP_SOUS_DOMAIN'
cacheLine = Dist.getCacheLine()
if cacheLine == 1: f77CppArgs += ' -DCACHELINE=16'
else: f77CppArgs += ' -DCACHELINE=%d'%cacheLine
nbsocket = Dist.getNbSocket()
if nbsocket == 1: f77CppArgs += ' -DNB_SOCKET=1'
else: f77CppArgs += ' -DNB_SOCKET=%d'%nbsocket

if Dist.DEBUG: f77CppArgs += ' -D__DEBUG__'

corePerSock = Dist.getCorePerSocket()
if corePerSock== 1: f77CppArgs += ' -DCORE_PER_SOCK=1'
else: f77CppArgs += ' -DCORE_PER_SOCK=%d'%corePerSock

action = PP+'\"'+kcoreIncDir+'\" -I. '+f77CppArgs+' $SOURCES $TARGETS'
bld = Builder(action=action, suffix='.f', src_suffix='.for')
#emitter=addSourceScannerToTargets)
#
# Env =========================================================================
import srcs
if Dist.getSystem()[0] == 'mingw': tools = ['mingw']
else: tools = None
AR = Dist.getAR()
env = Environment(tools=tools, CC=cc, CXX=cxx, AR=AR, CFLAGS=[], CXXFLAGS=[],
BUILDERS={'FPROC': bld},FORTRAN=f77compiler,
env = Environment(tools=tools, CC=cc, CXX=cxx, AR=AR, CPPFLAGS=[],
FORTRAN=f77compiler,
LIBPATH=additionalLibPaths+libraryDirs,
LIBS=libraries+additionalLibs,
SHLIBSUFFIX=so_ext, SHLIBPREFIX='',
LINKFLAGS=Dist.getLinkArgs(),
ENV=Dist.getEnvForScons())
env.Replace(CPPPATH=[".","FastC"]+additionalIncludePaths+includeDirs)

ELSAPROD = os.environ.get('ELSAPROD', 'x86_r8')
env.SConsignFile('build/'+ELSAPROD+'/.sconsign.dblite')
env.Replace(CPPPATH=[".", "FastC"]+additionalIncludePaths+includeDirs)
env.Replace(CXXFLAGS=Dist.getCppArgs()+ADDITIONALCPPFLAGS)
env.Replace(CFLAGS=Dist.getCArgs()+ADDITIONALCPPFLAGS)

#=============================================================================================

# additional fortran preprocessing args
addFPPArgs = '-D_OPENMP4 -D_OPENMP -DE_SCALAR_COMPUTER -DE_OMP_SOUS_DOMAIN'
# additional fortran compiler flags
addFFlags = []
cacheLine = Dist.getCacheLine()
if cacheLine == 1: addFPPArgs += ' -DCACHELINE=16'
else: addFPPArgs += ' -DCACHELINE=%d'%cacheLine
nbsocket = Dist.getNbSocket()
if nbsocket == 1: addFPPArgs += ' -DNB_SOCKET=1'
else: addFPPArgs += ' -DNB_SOCKET=%d'%nbsocket
if Dist.DEBUG: addFPPArgs += ' -D__DEBUG__'
corePerSock = Dist.getCorePerSocket()
if corePerSock== 1: addFPPArgs += ' -DCORE_PER_SOCK=1'
else: addFPPArgs += ' -DCORE_PER_SOCK=%d'%corePerSock

if f77compiler == 'gfortran' or f77compiler == 'x86_64-w64-mingw32-gfortran':
addFFlags += ['-fdefault-real-8', '-fdefault-double-8']

# Pre processing du C
cppArgs = Dist.getCppArgs()+['-g']+["-DE_SCALAR_COMPUTER -DE_OMP_SOUS_DOMAIN"]
if Dist.getCacheLine() == 1: cppArgs += ['-DCACHELINE=16']
env.Replace(CPPFLAGS=cppArgs+ADDITIONALCPPFLAGS)


### voir installBase de KCore pour option de compil par defaut
if f90compiler == 'ifort':
#env.Replace(FORTRANFLAGS=Dist.getForArgs() +["-I/usr/include/openmpi-x86_64"] )
env.Replace(FORTRANFLAGS=Dist.getForArgs())
else:
env.Replace(FORTRANFLAGS=Dist.getForArgs())

if f77compiler == 'ifort':
version = Dist.getForVersion() # A utiliser version=(13,4)
floatType = '-r8' if Dist.EDOUBLEINT else '-r8 -i4'
f77Args = floatType+' -g -fno-alias -fno-fnalias -ip'
cacheLine = Dist.getCacheLine()
simd = Dist.getSimd()

if cacheLine != 1: f77Args += ' -align array%dbyte '%cacheLine

if version[0] >= 17:
#env.Replace(FORTRANCOM = '$FORTRAN $FORTRANFLAGS -O0 '+floatType+' -traceback -fpe-all=0 -fp-stack-check -ftrapuv -g -c -o $TARGET $SOURCE')
env.Replace(FORTRANCOM = '$FORTRAN $FORTRANFLAGS '+f77Args+' -qopt-report5 -qopt-report-phase=loop,vec,cg -qopt-report-embed -unroll0 -c -o $TARGET $SOURCE')
if Dist.DEBUG:
env.Replace(FORTRANCOM = '$FORTRAN $FORTRANFLAGS -O0 '+floatType+' -traceback -fpe-all=0 -fp-stack-check -ftrapuv -g -c -o $TARGET $SOURCE')
elif version[0] >= 15:
env.Replace(FORTRANCOM = '$FORTRAN $FORTRANFLAGS '+f77Args+' -qopt-report5 -qopt-report-phase=vec,loop -unroll0 -c -o $TARGET $SOURCE')
if Dist.DEBUG:
env.Replace(FORTRANCOM = '$FORTRAN $FORTRANFLAGS -O0 '+floatType+' -traceback -fpe-all=0 -fp-stack-check -ftrapuv -g -c -o $TARGET $SOURCE')
else:
env.Replace(FORTRANCOM = '$FORTRAN $FORTRANFLAGS '+f77Args+' -unroll0 -c -o $TARGET $SOURCE')

elif f77compiler == 'gfortran' or f90compiler == 'x86_64-w64-mingw32-gfortran':
env.Replace(FORTRANCOM = '$FORTRAN $FORTRANFLAGS -fdefault-real-8 -fdefault-double-8 -c -o $TARGET $SOURCE')
else:
env.Replace(FORTRANCOM = '$FORTRAN $FORTRANFLAGS -c -o $TARGET $SOURCE')

env.Replace(FORTRANSUFFIXES=['.f', '.F', '.f90', '.F90'])
fortran_builder = Builder(action='$FORTRANCOM',
suffix='.o', src_suffix='.f')

env.Append(BUILDERS={'Fortran' : fortran_builder})
env = Dist.createFortranBuilder(env, dirs=["."],
additionalPPArgs=addFPPArgs, additionalFortranArgs=addFFlags)

# Scan fortran files and store dependencies
parentFolder = os.path.dirname(os.path.dirname(os.getcwd()))
Expand Down
2 changes: 1 addition & 1 deletion Fast/FastS/FastS/Compute/ALE/move_domx.for
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ c***********************************************************************
C var loc
INTEGER_E l,inck,k,i,j,incmax,i2save,j2save,k2save
INTEGER_E translation_pur
INTEGER_E translation_pur, ndimt_xyz
REAL_E rot(4,3), vtrans(3)
#include "FastS/formule_xyz_param.h"
Expand Down
2 changes: 1 addition & 1 deletion Fast/FastS/FastS/Compute/DTLOC/copy_rk3locallist.for
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ c***********************************************************************
c $Date: 2010-01-28 16:22:02 +0100 (Thu, 28 Jan 2010)
c $ $Revision: 56 $
c $Author: IvanMary $
c*****a*****************************************************************
c***********************************************************************
subroutine copy_rk3locallist(param_int, rop, stock, listDnr,
& nbpts)
c***********************************************************************
Expand Down
2 changes: 1 addition & 1 deletion Fast/FastS/FastS/Compute/DTLOC/copy_rk3localpara.for
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ c***********************************************************************
c $Date: 2010-01-28 16:22:02 +0100 (Thu, 28 Jan 2010)
c $ $Revision: 56 $
c $Author: IvanMary $
c*****a*****************************************************************
c***********************************************************************
subroutine copy_rk3localpara(param_int, ind_loop,ind_loop_,rop,
& stock,ind,taille)
c***********************************************************************
Expand Down
2 changes: 0 additions & 2 deletions Fast/FastS/FastS/Compute/DTLOC/copyflux.for
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ c
c COM
c***********************************************************************

!#include "parallelF.h"
implicit none


#include "FastS/param_solver.h"

INTEGER_E idir, ind_loop(6), param_int(0:*),ind,nzone
Expand Down
4 changes: 1 addition & 3 deletions Fast/FastS/FastS/Compute/DTLOC/copyflux_rk3local.for
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ c***********************************************************************
c $Date: 2010-01-28 16:22:02 +0100 (Thu, 28 Jan 2010)
c $ $Revision: 56 $
c $Author: IvanMary $
c*****a*****************************************************************
c***********************************************************************
subroutine copyflux_rk3local(param_int,ind_loop,drodm,
& stock,ind,taille)

Expand All @@ -18,10 +18,8 @@ c
c COM
c***********************************************************************

!#include "parallelF.h"
implicit none


#include "FastS/param_solver.h"

INTEGER_E ind_loop(6),param_int(0:*),ind,taille
Expand Down
3 changes: 1 addition & 2 deletions Fast/FastS/FastS/Compute/DTLOC/copyflux_rk3local2.for
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ c***********************************************************************
c $Date: 2010-01-28 16:22:02 +0100 (Thu, 28 Jan 2010)
c $ $Revision: 56 $
c $Author: IvanMary $
c*****a*****************************************************************
c***********************************************************************
subroutine copyflux_rk3local2(param_int,ind_loop,drodm,stock,
& ind,taille)

Expand All @@ -18,7 +18,6 @@ c
c COM
c***********************************************************************

!#include "parallelF.h"
implicit none


Expand Down
4 changes: 1 addition & 3 deletions Fast/FastS/FastS/Compute/DTLOC/copyflux_rk3local2para.for
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ c***********************************************************************
c $Date: 2010-01-28 16:22:02 +0100 (Thu, 28 Jan 2010)
c $ $Revision: 56 $
c $Author: IvanMary $
c*****a*****************************************************************
c***********************************************************************
subroutine copyflux_rk3local2para(param_int,ind_loop,ind_loop_,
& drodm,stock,ind,taille)

Expand All @@ -18,10 +18,8 @@ c
c COM
c***********************************************************************

!#include "parallelF.h"
implicit none


#include "FastS/param_solver.h"

INTEGER_E ind_loop(6),ind_loop_(6),param_int(0:*),ind,taille
Expand Down
3 changes: 1 addition & 2 deletions Fast/FastS/FastS/Compute/DTLOC/copyflux_rk3locallist.for
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ c***********************************************************************
c $Date: 2010-01-28 16:22:02 +0100 (Thu, 28 Jan 2010)
c $ $Revision: 56 $
c $Author: IvanMary $
c*****a*****************************************************************
c***********************************************************************
subroutine copyflux_rk3locallist(param_int, drodm, stock, listDnr,
& nbpts, ind)

Expand All @@ -18,7 +18,6 @@ c
c COM
c***********************************************************************

!#include "parallelF.h"
implicit none


Expand Down
Loading

0 comments on commit 3b46ba9

Please sign in to comment.