Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
RoutingPP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IPSL
LMD
InTro
RoutingPP
Commits
4934a56c
Commit
4934a56c
authored
5 years ago
by
POLCHER Jan
Browse files
Options
Downloads
Patches
Plain Diff
Added a function to go from local land index to global land index.
parent
02825e89
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
Interface.py
+4
-1
4 additions, 1 deletion
Interface.py
Partition.py
+31
-5
31 additions, 5 deletions
Partition.py
with
36 additions
and
6 deletions
.gitignore
+
1
−
0
View file @
4934a56c
...
...
@@ -23,6 +23,7 @@ xcuserdata/
*.mod
*.pdone
*.bak
*.jnl
# Backup files
*~.nib
...
...
This diff is collapsed.
Click to expand it.
Interface.py
+
4
−
1
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
:
...
...
This diff is collapsed.
Click to expand it.
Partition.py
+
31
−
5
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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment