Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nemo2cmor doesn't find bathymetry/subbasins in linked directories #715

Open
uwefladrich opened this issue Sep 7, 2021 · 0 comments
Open

Comments

@uwefladrich
Copy link

ece2cmor constructs the paths for the bathymetry and subbasins files (if not given as env vars) as follows:

expdir = os.path.abspath(os.path.join(os.path.realpath(path), "..", "..", ".."))
# [...]
bathy_file_ = os.environ.get("ECE2CMOR3_NEMO_BATHY_METER", os.path.join(expdir, "bathy_meter.nc"))
# [...]
basin_file_ = os.environ.get("ECE2CMOR3_NEMO_SUBBASINS", os.path.join(expdir, "subbasins.nc"))

The problem is that this does not necessarily works if symbolic links are involved. Consider the following structure:

> tree .
.
├── bar
└── foo
    ├── bar -> ../bar
    └── file
3 directories, 1 file

So ./foo/bar is a symbolic link to ./bar. Then we have

> ls foo/file 
foo/file

but

> ls foo/bar/../file
ls: cannot access 'foo/bar/../file': No such file or directory

I had a corresponding situation in our linked-up rundirs and cmorisation dropped some Ofx variables as a consequence.

It might be a better implementation to use the Python pathlib to construct the paths with something like this (not tested!):

from pathlib import Path
expdir = Path(path).parents[3]
bathy_file_ = expdir / 'bathy_meter.nc'
basin_file_ = expdir / 'subbasins.nc'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant