Skip to content

Fix output when fluid2d runs on multiple cores #4

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions core/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def __init__(self, param, grid, diag, flxlist=None):
self.template = self.expdir+'/%s_his_%03i.nc'
if self.nbproc > 1:
self.hisfile = self.template % (self.expname, self.myrank)
self.hisfile_joined = '%s/%s_his.nc' % (self.expdir, self.expname)
else:
self.hisfile = '%s/%s_his.nc' % (self.expdir, self.expname)

Expand All @@ -43,7 +42,6 @@ def __init__(self, param, grid, diag, flxlist=None):
template = self.expdir+'/%s_flx_%03i.nc'
if self.nbproc > 1:
self.flxfile = template % (self.expname, self.myrank)
self.flxfile_joined = '%s/%s_flx.nc' % (self.expdir, self.expname)
else:
self.flxfile = '%s/%s_flx.nc' % (self.expdir, self.expname)

Expand Down Expand Up @@ -154,13 +152,13 @@ def dump_diag(self):
def join(self):
if self.nbproc > 1:
filename = self.hisfile.split('his')[0]+'his'
join(filename)
self.hisfile = join(filename)
if self.diag_fluxes:
filename = self.flxfile.split('flx')[0]+'flx'
join(filename)
self.flxfile = join(filename)



class NcfileIO(object):
"""Allow to create() and write() a Netcdf file of 'history' type,
i.e. a set of model 2D snapshots. Variables were originally the
Expand Down Expand Up @@ -250,7 +248,8 @@ def join(filename):
''' Join history files without having to mpirun

Useful when the run has been broken and one wants to join
things from an interactive session '''
things from an interactive session.
Return the name of the new, joined history file. '''

template = filename+'_%03i.nc'
hisfile_joined = filename+'.nc'
Expand Down Expand Up @@ -390,3 +389,5 @@ def join(filename):
os.remove(ncfile)

print('-'*50)

return hisfile_joined
8 changes: 8 additions & 0 deletions core/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ def __init__(self, param, grid, var, diag):
'generate_mp4', 'myrank', 'modelname']
param.copy(self, self.list_param)

if param.npx * param.npy > 1 and self.generate_mp4:
print(
'Warning: It is not possible to generate an mp4-file when '
'fluid2d runs on multiple cores.\n'
'The parameter generate_mp4 is automatically changed to False.'
)
self.generate_mp4 = False

nh = self.nh
nx = param.nx
ny = param.ny
Expand Down
6 changes: 0 additions & 6 deletions core/restart.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,10 @@ def __init__(self, param, grid, f2d, launch=True):
f2d.output.template = self.expdir +'/%s_%02i_his' % (
self.expname, self.nextrestart)+'_%03i.nc'
f2d.output.hisfile = f2d.output.template % (self.myrank)
f2d.output.hisfile_joined = self.expdir + '/%s_%02i_his.nc' % (
self.expname, self.nextrestart)
if self.diag_fluxes:
f2d.output.template = self.expdir +'/%s_%02i_flx' % (
self.expname, self.nextrestart)+'_%03i.nc'
f2d.output.flxfile = f2d.output.template % (self.myrank)
f2d.output.flxfile_joined = self.expdir + '/%s_%02i_flx.nc' % (
self.expname, self.nextrestart)



# split the integration in 'ninterrestart' intervals and
# save a restart at the end of each
Expand Down