Commit 88bcd93a authored by Pierre Cazenave's avatar Pierre Cazenave

Bail out of the river stuff if we have no rivers in the model domain.

parent b7d33143
......@@ -35,6 +35,7 @@ function Mobj = fix_river_nodes(Mobj, max_discharge, dist_thresh)
% lon, lat - nodal positions in spherical coordinates
% tri - unstructured grid triangulation table
% read_obc_nodes - open boundary node IDs
% nRivers - number of rivers in the model domain
% river_nodes - currently identified river nodes
% river_names - currently identified river names
% river_flux - river discharge time series
......@@ -62,6 +63,8 @@ function Mobj = fix_river_nodes(Mobj, max_discharge, dist_thresh)
% one river exceeded that threshold. Also add better exclusion of
% candidate river nodes (those with two land boundaries only are now
% excluded, as well as open ocean nodes and existing river nodes).
% 2015-09-24 Add check for whether we actually have any rivers to
% process.
%
%==========================================================================
......@@ -72,6 +75,16 @@ if ftbverbose
fprintf('\nbegin : %s\n', subname)
end
% Check we actually have some rivers to process.
if Mobj.nRivers < 1
warning('No rivers specified in the domain.')
if ftbverbose
fprintf('end : %s\n', subname)
end
return
end
% Remove nodes close to the open boundary joint with the coastline.
% Identifying the coastline/open boundary joining nodes is simply a case of
% taking the first and last node ID for each open boundary. Using that
......
......@@ -36,14 +36,26 @@ function Mobj = get_EA_river_climatology(Mobj, ea, dist_thresh)
% 2014-07-08 Think I've fixed the issue with leap years and incorrectly
% sized output temperature arrays with multiple years.
% 2014-09-02 Nope, I hadn't fixed leap years, but I might have now.
% 2015-09-24 Add check for whether we actually have any rivers to
% process.
subname = 'get_EA_river_climatology';
global ftbverbose;
global ftbverbose
if ftbverbose
fprintf('\nbegin : %s \n', subname)
end
if isempty(Mobj.river_nodes)
warning('No rivers specified in the domain.')
Mobj.river_temp = [];
if ftbverbose
fprintf('end : %s\n', subname)
end
return
end
% Load the position (lon/lat), time, climatology and SiteType variables
% only. Not really bothered about the other variables.
nc = netcdf.open(ea, 'NOWRITE');
......
......@@ -73,6 +73,8 @@ function Mobj = get_EHYPE_rivers(Mobj, dist_thresh, varargin)
% of rivers to the relevant field.
% 2014-05-29 - Fix issues with the climatology vs. timeseries allocation
% of the output arrays.
% 2015-09-24 Add check for whether we actually have any rivers to
% process.
%
%==========================================================================
......@@ -290,6 +292,22 @@ ehype_nt = size(fv_flow, 1);
% larger of the two discharge values assigned to those nodes and ditch the
% smaller one. The output is stored in a new fv_uniq_flow array (names and
% nodes are similarly stored in their unique format).
if any(isnan(fv_obc))
% We don't actually have any rivers, so return all the relevant fields
% in Mobj as empty arrays.
Mobj.river_flux = [];
Mobj.river_nodes = [];
Mobj.river_names = [];
Mobj.have_rivers = false;
Mobj.nRivers = 0;
if ftbverbose
fprintf('end : %s \n', subname)
end
return
end
fv_uniq_obc = unique(fv_obc);
fv_uniq_flow = nan(ehype_nt, length(fv_uniq_obc));
fv_uniq_names = cell(length(fv_uniq_obc), 1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment