sigma_tanh.m 1.06 KB
 Pierre Cazenave committed Jun 20, 2012 1 ``````function dist = sigma_tanh(nlev,dl,du) `````` Pierre Cazenave committed Apr 23, 2013 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 ``````% Generate a tanh sigma coordinate distribution. % % Mobj = sigma_tanh(nlev, dl, du) % % DESCRIPTION: % Generate a tanh vertical sigma coordinate distribution. % % INPUT: % nlev: Number of sigma levels (layers + 1) % dl: The lower depth boundary from the bottom, down to which the % coordinates are parallel with uniform thickness. % du: The upper depth boundary from the surface, up to which the % coordinates are parallel with uniform thickness. % % OUTPUT: % dist: Tanh vertical sigma coordinate distribution. % % EXAMPLE USAGE: % Mobj = read_sigma(nlev, dl, du) % % Author(s): % Geoff Cowles (University of Massachusetts Dartmouth) % Pierre Cazenave (Plymouth Marine Laboratory) % % Revision history % 2013-04-23 Added help on the function and reformatted the code. `````` Pierre Cazenave committed Jun 20, 2012 28 `````` `````` Pierre Cazenave committed Apr 23, 2013 29 ``````dist = nan(1, nlev); `````` Pierre Cazenave committed Jun 20, 2012 30 `````` `````` Pierre Cazenave committed Apr 23, 2013 31 32 33 34 35 36 37 38 39 ``````for k = 1:nlev x1 = dl+du; x1 = x1*(nlev-1-k)/(nlev-1); x1 = x1-dl; x1 = tanh(x1); x2 = tanh(dl); x3 = x2+tanh(du); dist(k+1) = (x1+x2)/x3-1.0; end``````