Commit 93b495f4 authored by Pierre Cazenave's avatar Pierre Cazenave

Merge branch 'dev' of gitlab.ecosystem-modelling.pml.ac.uk:fvcom/fvcom-toolbox into dev

parents 03c52a43 ce0d4e76
function make_model_nml_generic(inputConf,yy,mm)
% script to create the model run namelist
% fname='nador_year2046_automatic.nml';
% fnml=fopen(fname,'wt');
% parameters to change for this run
days2sec=24*60*60;
% inputConf.modelYear= 2006;
% inputConf.casename= 'aqua_v14';
% inputConf.base= '/data/medusa/rito/models/FVCOM/runVigo/';
% inputConf.version= 'ver3.2.1'
% inputConf.SIGMA_LEVELS_FILE = 'sigma_geom.dat';
% inputConf.report= 60 % interval to report to the screen in model minutes
% for mm=8:10;
inputConf.startDate= [yy mm 01 00 00 00 ];
inputConf.endDate=[yy mm+1 01 00 00 00 ];
%% Entries to change
% these cannot be left to the default values
inputConf.EXTSTEP_SECONDS =inputConf.timestep;
inputConf.IRAMP = floor(inputConf.ramp*days2sec./(inputConf.EXTSTEP_SECONDS*inputConf.isplit)); % ramp over one day
inputConf.START_DATE=datestr(inputConf.startDate,'yyyy-mm-dd HH:MM:SS');% '2046-02-01 00:00:00';
inputConf.END_DATE=datestr(inputConf.endDate,'yyyy-mm-dd HH:MM:SS');% '2046-03-01 00:00:00';
inputConf.RST_FIRST_OUT=inputConf.START_DATE;
% Change sigma file
inputConf.IREPORT = floor(inputConf.report*60./(inputConf.timestep*inputConf.isplit));
inputConf.BOTTOM_ROUGHNESS_FILE = [inputConf.casename '_z0=',num2str(inputConf.bed_roughness), '.nc'];
inputConf.INPUT_DIR= inputConf.fvcom_input_nml;
inputConf.OUTPUT_DIR = inputConf.fvcom_output_nml;
inputConf.NC_FIRST_OUT=inputConf.START_DATE;
inputConf.NCAV_FIRST_OUT=inputConf.START_DATE;
inputConf.PROJECTION_REFERENCE=inputConf.projection;
% if isfield(inputConf,'TS_nudge')
% inputConf.OBC_TEMP_NUDGING_TIMESCALE = 1/(inputConf.TS_nudge*3600/inputConf.timestep);
% inputConf.OBC_SALT_NUDGING_TIMESCALE = 1/(inputConf.TS_nudge*3600/inputConf.timestep);
% inputConf.OBC_FABM_NUDGING_TIMESCALE = 1/(inputConf.TS_nudge*3600/inputConf.timestep);
% end
[fmt,nml]=make_default_nml(inputConf);
if isfield(inputConf,lower('OFFLINE_FABM_FILE'))
else
nml.NML_FABM = rmfield(nml.NML_FABM,'OFFLINE_FABM_FILE');
end
% get name of nml blocks
nml_blocks=fieldnames(nml);
nml_vars={};
change_vars=fieldnames(inputConf);
for nn=1:length(nml_blocks)
nml_vars=fieldnames(nml.(nml_blocks{nn}));
for vv=1:length(nml_vars)
var_idx=strcmpi(nml_vars(vv),change_vars);
if any(var_idx)
change_field=upper(change_vars{find(var_idx)});
disp(['Changing variable ',nml_blocks{nn},'.',change_field])
nml.(nml_blocks{nn}).(change_field)=inputConf.(change_vars{find(var_idx)});
end
end
end
% % get name of nml blocks
% nml_blocks=fieldnames(nml);
% nml_vars={};
% change_vars=fieldnames(change);
% for nn=1:length(nml_blocks)
% nml_vars=fieldnames(nml.(nml_blocks{nn}));
% for vv=1:length(nml_vars)
% var_idx=strcmp(nml_vars(vv),change_vars);
% if any(var_idx)
% disp(['Changing variable ',nml_blocks{nn},'.',change_vars{find(var_idx)}])
% nml.(nml_blocks{nn}).(change_vars{find(var_idx)})=change.(change_vars{find(var_idx)});
% end
% end
% end
res = write_model_nml(inputConf,nml,fmt);
assert(res == 0, 'Error writting namelist file %s', ...
fullfile(inputConf.fvcom_model, sprintf('%s.nml', inputConf.casename)))
% end
% fprintf(
% &NML_CASE
% CASE_TITLE = 'Nadoor Production FVCOM3.1.6 code'
% TIMEZONE = 'UTC';%
% DATE_FORMAT = 'YMD'
% DATE_REFERENCE = 'default'
% START_DATE = '2046-02-01 00:00:00'
% END_DATE = '2046-03-01 00:00:00'
% %/
......@@ -10,6 +10,7 @@ function write_admesh_mesh(Mobj,varargin)
% Mobj = needs bathymetry, nodes and triangulation
% table. read_sms_mesh provides everything it needs.
% [optional] output_directory = directory to write mesh.14 file
% [optional] filename = filename to use instead of default mesh(.14). Don't provide extension
% [optional] native_coord = cartesian or spherical. Assumes cartesian if
% omitted.
%
......@@ -48,7 +49,7 @@ out_dir = pwd; % default is to write file to current directory
native_coord = 'cartesian';
have_xy = true;
have_lonlat = false;
filename = 'mesh'
for i = 1:2:length(varargin) - 1
keyword = lower(varargin{i});
......@@ -57,6 +58,8 @@ for i = 1:2:length(varargin) - 1
switch keyword
case 'output_directory'
out_dir = varargin{i + 1};
case 'filename'
filename = varargin{i + 1};
case 'native_coord'
coord = varargin{i + 1};
if strcmpi(coord, 'spherical')
......@@ -79,7 +82,7 @@ end
%--------------------------------------------------------------------------
% Open the output file
%--------------------------------------------------------------------------
gmsh_msh = fullfile(out_dir,'mesh.14');
gmsh_msh = fullfile(out_dir,[filename '.14']);
fid = fopen(gmsh_msh, 'wt');
assert(fid >= 0, sprintf('file: %s could not be created\n', gmsh_msh));
......
% Blend two sources of bathymetry
function [ new_bat ] = merge_bathymetry( dist_OB,coarse_bat,fine_bat,d0,d1 )
%
% [ new_bat ] = merge_bathymetry( dist_OB,coarse_bat,fine_bat,d0,d1 )
%
% DESCRIPTION:
% This script uses a blending function to combine two bathymetry sources
% over a common spatial extent (High-resolution, unstructured meshes for hydrodynamic models of the Great Barrier Reef, Australia,
% Estuarine Coastal and Shelf Science 68:36-46 · June 2006
% DOI: 10.1016/j.ecss.2005.08.017 )
% INPUT [keyword pairs]:
% dist_OB: a length metric used to combine the two sources
% coarse_bat: Bathymetry data to combine at lower distance
% fine_bat: Bathymetry data to combine at longer distances
% d0: is the plateau distance
% d1: is the end distance limiting factor
%
%
% the blending function is a piecewise polynomial function as
% f1d= 3.*( (dist_OB-d0)./(d1-d0) ).^2 - 2.*( (dist_OB-d0)./(d1-d0) ).^3;
% % restric closes points
% f1d(dist_OB<=d0)=0;
% f1d(dist_OB>=d1)=1;
% f1d=abs(f1d-1);
% % % Example
% d0=50;d1=2000;dist_OB = 0:100:12000;
% f1d= 3.*( (dist_OB-d0)./(d1-d0) ).^2 - 2.*( (dist_OB-d0)./(d1-d0) ).^3;
% % restric closes points
% f1d(dist_OB<=d0)=0;
% f1d(dist_OB>=d1)=1;
% plot(dist_OB,abs(f1d-1));
% EXAMPLE USAGE
% Mobj_all.sub.z_merged = merge_bathymetry( Distance_from_nodestring,Mobj_all.z,Mobj_all.z1,100,2000 );
%
% Author(s):
% Ricardo Torres (Plymouth Marine Laboratory)
%
% Revision history
%
%
%==============================================================================
f1d= 3.*( (dist_OB-d0)./(d1-d0) ).^2 - 2.*( (dist_OB-d0)./(d1-d0) ).^3;
% restric closes points
f1d(dist_OB<=d0)=0;
f1d(dist_OB>=d1)=1;
f1d=abs(f1d-1);
new_bat=f1d.*coarse_bat+((1-f1d).*fine_bat);
return
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