Hello,
How can I include a river discharge in my model?
I have found the options TS_PSOURCE and UV_SOURCE, but it is not clear how the format of the input must be.
Thanks!
Including a river discharge
The first thing to do is take a look in the analytical section of the code (now, Functionals/ana_psource.h). All of the variables that are described there need to be set. It will be more clear what each variable does when you see how it is specified in the analytical code.
Perhaps the least clear flag is the 'river_flag', which is explained in Modules/mod_sources thusly:
Of course, you can also specify the river flow in a forcing file. here is an example of an idealized river discharge with eight points. The code is in python, but it should be straightforward to translate it in to MATLAB, or Pascal, or whatever you use...
Perhaps the least clear flag is the 'river_flag', which is explained in Modules/mod_sources thusly:
Code: Select all
! Fsrc Point Source/Sinks identification flag: !
! Fsrc(:) = 0, All Tracer source/sink are off. !
! Fsrc(:) = 1, Only temperature is on. !
! Fsrc(:) = 2, Only salinity is on. !
! Fsrc(:) = 3, Both temperature and salinity are on. !
! Fsrc(:) = 4, Both nitrate and salinity are on. !
! Fsrc(:) = ... And other combinations. !
! (We need a more robust logic here) !
Code: Select all
def make_frc(Qo, rootdir):
# Find where the river enters and create flow
ridx = arange(1,9)
Nsrc = len(ridx)
river_temp = 10.0
t = arange(0, 21.05, 0.05) # river time in days
Qbar = Qo - Qo * exp(-t/0.05) # ramp flow over about 1 hour.
### write river file
nc = netCDF4.Dataset(os.path.join(rootdir, 'near_frc.nc'), 'w', format='NETCDF3_CLASSIC')
nc.Description = 'River forcing for ideal plume'
nc.Author = 'Rob Hetland'
nc.Created = datetime.now().isoformat()
nc.type = 'ROMS FRC file'
nc.createDimension('river', len(ridx))
nc.createDimension('river_time', len(t))
nc.createDimension('xi_rho', 64)
nc.createDimension('eta_rho', 64)
nc.createDimension('s_rho', 10)
def write_nc_var(var, name, dimensions, units=None):
nc.createVariable(name, 'f8', dimensions)
if units is not None:
nc.variables[name].units = units
nc.variables[name][:] = var
write_nc_var(arange(Nsrc)+1, 'river', ('river', ))
write_nc_var(ones(Nsrc), 'river_Xposition', ('river', ))
write_nc_var(ridx.astype('d'), 'river_Eposition', ('river', ))
write_nc_var(zeros(Nsrc), 'river_direction', ('river', ))
Vshape = zeros(10)
Vshape[:] = arange(1,11)
Vshape /= Vshape.sum()
write_nc_var(Vshape[:, newaxis] * ones((10, Nsrc)), 'river_Vshape', ('s_rho', 'river'))
write_nc_var(t, 'river_time', ('river_time', ), 'days')
write_nc_var(Qbar[:, newaxis]*ones((len(t), Nsrc))/float(Nsrc), 'river_transport',
('river_time', 'river'), 'm3 s-1')
write_nc_var(river_temp*ones((len(t), 10, Nsrc)), 'river_temp',
('river_time', 's_rho', 'river'))
write_nc_var(zeros((len(t), 10, Nsrc)), 'river_salt', ('river_time', 's_rho', 'river'))
write_nc_var(3.0*ones(Nsrc), 'river_flag', ('river', ))
nc.close()