Remove the original POLCOMS parsing script and replace it instead with two separate functions, one to get the positions and the other to import the discharge rates. The part of the original function responsible for finding suitable nodes and assigning the discharges has been moved into get_FVCOM_rivers.m. The reason for this separation of duties is to make each part more flexible. This approach means I can load my positions from a separate file whilst still using the POLCOMS discharge data. Once I have loaded those data, the function to find the suitable nodes is called separately. If you had an alternative source of data, then the latter function could still be used to find the nodes as all it needs is position information
This function has had the parts of the code which deal with loading the discharge data and river positions farmed out into separate functions (get_POLCOMS_river_positions.m and get_POLCOMS_river_discharge.m). By removing that code from the function, this function can now focus entirely on finding the appropriate river node. The logic whereby nodes assigned multiple rivers have the discharge from those rivers summed remains (which differs from the now-extinct get_POLCOMS_rivers.m function which simply used the first river it came across and omitted any discharges from subsequent rivers)