Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Docker-in-Docker (DinD) capabilities of public runners deactivated.
More info
Open sidebar
IPSL
LMD
InTro
RoutingPP
Commits
3b33680f
Commit
3b33680f
authored
Jan 16, 2021
by
POLCHER Jan
🚴🏾
Browse files
Clean-up of compilation and loading of resulting module. The toolbox for that was refined.
parent
881174c8
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
45 deletions
+33
-45
F90subroutines/Makefile
F90subroutines/Makefile
+6
-2
F90tools.py
F90tools.py
+12
-19
GraphHydro.py
GraphHydro.py
+4
-5
Interface.py
Interface.py
+3
-12
Truncate.py
Truncate.py
+8
-7
No files found.
F90subroutines/Makefile
View file @
3b33680f
...
...
@@ -9,16 +9,20 @@ FFLAG = -fPIC
FPY
=
f2py
#PDBG = --debug
#
EXT_SUFFIX
:=
$(
shell
python3-config
--extension-suffix
)
#
all
:
routing_interface.so diagst.so
routing_interface
:
routing_interface$(EXT_SUFFIX)
diagst
:
diagst$(EXT_SUFFIX)
clean
:
rm
-f
compilation.log
*
.o
*
.so
*
.mod routing_interface.so diagst.so
*
~
routing_interface
.so
:
$(obj) routing_interface.f90
routing_interface
$(EXT_SUFFIX)
:
$(obj) routing_interface.f90
rm
-f
compilation.log
$(FPY)
-c
routing_interface.f90
$(PDBG)
--fcompiler
=
gfortran
-m
routing_interface
$(obj)
>
compilation.log
diagst
.so
:
diagst.f90
diagst
$(EXT_SUFFIX)
:
diagst.f90
$(FPY)
-c
diagst.f90
$(PDBG)
--fcompiler
=
gfortran
-m
diagst
>
compilation.log
defprec.o
:
defprec.f90
...
...
F90tools.py
View file @
3b33680f
...
...
@@ -12,32 +12,25 @@ def localdir(follow_symlinks=True):
path
=
os
.
path
.
realpath
(
path
)
return
os
.
path
.
dirname
(
path
)
def
adddirtopath
(
dir
)
:
sys
.
path
.
append
(
localdir
()
+
'/'
+
dir
)
def
adddirtopath
(
sdir
)
:
if
not
sdir
in
sys
.
path
:
sys
.
path
.
append
(
localdir
()
+
'/'
+
sdir
)
return
def
compilef90
(
mod
)
:
def
compilef90
(
mod
,
mpi
=
None
)
:
adddirtopath
(
localdir
()
+
"/F90subroutines"
)
try
:
MPI
except
:
err
=
os
.
system
(
"cd "
+
localdir
()
+
"/F90subroutines ; make all"
)
if
not
"mpi4py"
in
sys
.
modules
:
err
=
os
.
system
(
"cd "
+
localdir
()
+
"/F90subroutines ; make "
+
mod
)
if
err
!=
0
:
print
(
"Compilation error in the FORTRAN interface"
)
sys
.
exit
()
else
:
if
MPI
==
sys
.
modules
[
'mpi4py'
].
MPI
:
if
MPI
.
COMM_WORLD
.
Get_rank
()
==
0
:
err
=
os
.
system
(
"cd "
+
localdir
()
+
"/F90subroutines ; make all"
)
if
err
!=
0
:
print
(
"Compilation error in the FORTRAN interface"
)
sys
.
exit
()
else
:
print
(
"Not compiling on other cores"
)
MPI
.
COMM_WORLD
.
Barrier
()
else
:
print
(
"MPI exists but is not from mpi4py module"
)
mpimod
=
sys
.
modules
[
"mpi4py"
].
MPI
if
mpimod
.
COMM_WORLD
.
Get_rank
()
==
0
:
err
=
os
.
system
(
"cd "
+
localdir
()
+
"/F90subroutines ; make "
+
mod
)
if
err
!=
0
:
print
(
"Compilation error in the FORTRAN interface"
)
sys
.
exit
()
mpimod
.
COMM_WORLD
.
Barrier
()
return
GraphHydro.py
View file @
3b33680f
#
import
os
import
sys
from
inspect
import
currentframe
,
getframeinfo
localdir
=
os
.
path
.
dirname
(
getframeinfo
(
currentframe
()).
filename
)
sys
.
path
.
append
(
localdir
+
'/F90subroutines'
)
#
import
numpy
as
np
from
netCDF4
import
Dataset
import
datetime
...
...
@@ -20,6 +15,10 @@ log_master, log_world = getargs.getLogger(__name__)
INFO
,
DEBUG
,
ERROR
=
log_master
.
info
,
log_master
.
debug
,
log_world
.
error
INFO_ALL
,
DEBUG_ALL
=
log_world
.
info
,
log_world
.
debug
#
import
F90tools
as
F90T
#
F90T
.
adddirtopath
(
"F90subroutines"
)
F90T
.
compilef90
(
"routing_interface"
)
import
routing_interface
import
NcHelp
as
NH
import
RPPtools
as
RPP
...
...
Interface.py
View file @
3b33680f
...
...
@@ -8,20 +8,11 @@ from mpi4py import MPI
import
gc
#
import
sys
from
inspect
import
currentframe
,
getframeinfo
#
localdir
=
os
.
path
.
dirname
(
getframeinfo
(
currentframe
()).
filename
)
sys
.
path
.
append
(
localdir
+
'/F90subroutines'
)
F90
=
localdir
+
'/F90subroutines'
if
MPI
.
COMM_WORLD
.
Get_rank
()
==
0
:
err
=
os
.
system
(
"cd "
+
F90
+
"; make all"
)
if
err
!=
0
:
print
(
"Compilation error in the FORTRAN interface"
)
sys
.
exit
()
else
:
print
(
"Not compiling on other cores"
)
MPI
.
COMM_WORLD
.
Barrier
()
import
F90tools
as
F90T
#
F90T
.
adddirtopath
(
"F90subroutines"
)
F90T
.
compilef90
(
"routing_interface"
)
import
routing_interface
import
NcHelp
as
NH
#
...
...
Truncate.py
View file @
3b33680f
...
...
@@ -11,19 +11,20 @@ import numpy as np
import
numpy.ma
as
ma
import
time
import
sys
import
os
from
inspect
import
currentframe
,
getframeinfo
localdir
=
os
.
path
.
dirname
(
getframeinfo
(
currentframe
()).
filename
)
sys
.
path
.
append
(
localdir
+
'/F90subroutines'
)
import
routing_interface
#
import
getargs
config
=
getargs
.
SetupConfig
()
frac_lim
=
config
.
getfloat
(
"OverAll"
,
"frac_lim"
,
fallback
=
0.3
)
limit_step5
=
config
.
getfloat
(
"OverAll"
,
"limit_step5"
,
fallback
=
5
)
log_master
,
log_world
=
getargs
.
getLogger
(
__name__
)
INFO
,
DEBUG
,
ERROR
=
log_master
.
info
,
log_master
.
debug
,
log_world
.
error
#
import
F90tools
as
F90T
#
F90T
.
adddirtopath
(
"F90subroutines"
)
F90T
.
compilef90
(
"routing_interface"
)
import
routing_interface
#
######################
class
trunc
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment