sigma_geo.m 1.08 KB
 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 ``````function dist = sigma_geo(nlev, p_sigma) % Generate a geometric sigma coordinate distribution. % % Mobj = sigma_gen(nlev, p_sigma) % % DESCRIPTION: % Generate a geometric vertical sigma coordinate distribution. % % INPUT: % nlev: Number of sigma levels (layers + 1) % p_sigma: 1 for uniform sigma layers, 2 for parabolic function. See % page 308-309 in the FVCOM manual for examples. % % OUTPUT: % dist: Geometric vertical sigma coordinate distribution. % % EXAMPLE USAGE: % Mobj = read_sigma(21, 2.0) % % 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 to `````` Pierre Cazenave committed Apr 23, 2013 26 ``````% remove the FORTRAN in the else block. `````` 27 28 `````` dist = nan(1, nlev); `````` Pierre Cazenave committed Jun 20, 2012 29 30 31 `````` kb = nlev; `````` 32 33 34 35 36 ``````if p_sigma == 1 for k = 1:nlev dist(k) = -((k-1)/(kb-1))^p_sigma; end else `````` Pierre Cazenave committed Nov 28, 2017 37 `````` for k = 1:floor((kb+1)/2) `````` 38 39 `````` dist(k) = -((k-1)/((kb+1)/2-1))^p_sigma/2; end `````` Pierre Cazenave committed Nov 28, 2017 40 `````` for k = floor((kb+1)/2)+1:kb `````` 41 42 43 `````` dist(k) = ((kb-k)/((kb+1)/2-1))^p_sigma/2-1.0; end end``````