Skip to content

Commit

Permalink
Merge pull request #7 from CMCC-Foundation/dims_logic_fix
Browse files Browse the repository at this point in the history
Revision of dimensions identification logic
  • Loading branch information
pgf authored Jan 24, 2025
2 parents 9c396ba + 058fda0 commit 054bf60
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/py_nemo_rebuild/nemo_rebuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@

# SemVer version
_major_version = 0
_minor_version = 5
_minor_version = 6
_patch = 0

#_release = 'beta'
_release = ''

_date = '24-11-2023'
_date = '24-01-2025'

_version = '{:d}.{:d}'.format(_major_version, _minor_version)
if (_patch>0):
Expand Down Expand Up @@ -254,24 +254,25 @@ def nemo_rebuild(in_file=None,
####################################################################
#
# Define dimensions & get global dims to be rebuilt
gdimids = incid.DOMAIN_dimensions_ids
gdimszs = incid.DOMAIN_size_global
ldimszs = incid.DOMAIN_size_local
gdims = ['', '']
for name, dim in incid.dimensions.items():
for dim in incid.dimensions.values():
if (verbose):
print(dim)
if ((dim._dimid + 1) == gdimids[0]):
oncid.createDimension(name, gnx)
gdims[0] = name
elif ((dim._dimid + 1) == gdimids[1]):
oncid.createDimension(name, gny)
gdims[1] = name
if dim.isunlimited():
oncid.createDimension(dim.name, None)
elif (dim.size in ldimszs):
idx = 0 if ldimszs[0]==dim.size else 1
oncid.createDimension(dim.name, gdimszs[idx])
gdims[idx] = dim.name
else:
oncid.createDimension(name, len(dim) if not dim.isunlimited() else None)
oncid.createDimension(dim.name, dim.size)
#
if (verbose):
print('Global dimensions to be rebuilt: ', gdims)
del dim
del gdimids
del gdimszs, ldimszs
#
####################################################################
#
Expand Down

0 comments on commit 054bf60

Please sign in to comment.