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
Open sidebar
IPSL
LMD
InTro
RoutingPP
Commits
4934a56c
Commit
4934a56c
authored
Jun 15, 2019
by
POLCHER Jan
🚴🏾
Browse files
Added a function to go from local land index to global land index.
parent
02825e89
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
6 deletions
+36
-6
.gitignore
.gitignore
+1
-0
Interface.py
Interface.py
+4
-1
Partition.py
Partition.py
+31
-5
No files found.
.gitignore
View file @
4934a56c
...
...
@@ -23,6 +23,7 @@ xcuserdata/
*.mod
*.pdone
*.bak
*.jnl
# Backup files
*~.nib
...
...
Interface.py
View file @
4934a56c
...
...
@@ -265,7 +265,10 @@ class HydroGraph :
routingarea
=
np
.
zeros
((
1
,
1
,
1
))
routingarea
[:,:,:]
=
part
.
gather
(
rarea
)
#
rgrid
=
procgrid
.
landscatter
(
self
.
route_togrid
[:,:],
order
=
'F'
)
# The field route_togrid is with indices on the local grid. That needs to be converted to the global grid.
#
grgrid
=
part
.
l2glandindex
(
self
.
route_togrid
[:,:])
rgrid
=
procgrid
.
landscatter
(
grgrid
,
order
=
'F'
)
rgrid
=
rgrid
.
astype
(
vtyp
,
copy
=
False
)
rgrid
[
rgrid
>=
RPP
.
IntFillValue
]
=
NCFillValue
if
part
.
rank
==
0
:
...
...
Partition.py
View file @
4934a56c
...
...
@@ -158,17 +158,28 @@ def haloreceivelist(halosource_map, rank) :
#
# Get 1D indices for the land points
#
def
landindexmap
(
land
)
:
nj
,
ni
=
land
.
shape
def
landindexmap
(
istart
,
ni
,
jstart
,
nj
,
land
)
:
gnj
,
gni
=
land
.
shape
gindland
=
np
.
zeros
((
gnj
,
gni
),
dtype
=
np
.
int32
)
gindland
[:,:]
=-
1
n
=
0
for
i
in
range
(
gni
)
:
for
j
in
range
(
gnj
)
:
if
(
land
[
j
,
i
]
>
0
)
:
gindland
[
j
,
i
]
=
n
n
+=
1
#
indland
=
np
.
zeros
((
nj
,
ni
),
dtype
=
np
.
int32
)
indland
[:,:]
=-
1
local2global
=
[]
n
=
0
for
i
in
range
(
ni
)
:
for
j
in
range
(
nj
)
:
if
(
land
[
j
,
i
]
>
0
)
:
if
(
land
[
j
start
+
j
,
istart
+
i
]
>
0
)
:
indland
[
j
,
i
]
=
n
local2global
.
append
(
gindland
[
jstart
+
j
,
istart
+
i
])
n
+=
1
return
indland
return
n
,
indland
,
np
.
array
(
local2global
,
dtype
=
np
.
int32
)
#
# Convert indices to local
#
...
...
@@ -230,7 +241,7 @@ class partition :
self
.
ihstart
=
part
[
rank
][
"ihstart"
]
self
.
jhstart
=
part
[
rank
][
"jhstart"
]
#
landind
map
=
landindexmap
(
land
[
self
.
j
hstart
:
self
.
jhstart
+
self
.
n
j
h
,
self
.
i
hstart
:
self
.
ihstart
+
self
.
nih
]
)
self
.
nbland
,
landindmap
,
self
.
l2g
landind
=
landindexmap
(
self
.
i
hstart
,
self
.
n
i
h
,
self
.
j
hstart
,
self
.
njh
,
land
)
#
if
wunit
!=
"None"
:
wunit
.
write
(
"Offsets with halo (j-i) : "
+
str
(
self
.
jhstart
)
+
"-"
+
str
(
self
.
ihstart
)
+
'
\n
'
)
...
...
@@ -372,3 +383,18 @@ class partition :
xf
=
modelgrid
.
landscatter
(
xl
,
order
=
order
)
xout
=
self
.
gather
(
xf
)
return
xout
#
# Convert local index of land points to global index
#
def
l2glandindex
(
self
,
x
)
:
nl
,
nh
=
x
.
shape
y
=
np
.
zeros
(
x
.
shape
,
dtype
=
x
.
dtype
)
if
nl
==
self
.
nbland
:
for
i
in
range
(
nl
)
:
for
j
in
range
(
nh
)
:
# Land indices are in FORTRAN !!
y
[
i
,
j
]
=
self
.
l2glandind
[
x
[
i
,
j
]
-
1
]
+
1
else
:
ERROR
(
"The first dimension does not have the length of the number of land points"
)
sys
.
exit
()
return
y
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