Commit 2d73dd8d by Pierre Cazenave

### Fix some remaining FORTRAN code (do loop and float function) to MATLAB. Also...

`Fix some remaining FORTRAN code (do loop and float function) to MATLAB. Also add a function description to match the format of the other tools in the toolbox. Also reformat the code to MATLAB standard format (indentation etc.).`
parent a16b380e
 function dist = sigma_geo(nlev,p_sigma) 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 % remove to FORTRAN in the else block. dist = nan(1, nlev); kb = nlev; if(p_sigma ==1) for k=1:nlev dist(k) = -((k-1)/float(kb-1))^p_sigma; end; else for k=1:(kb+1)/2 dist(k) = -((k-1)/float((kb+1)/2-1))^p_sigma/2; end; do k=(kb+1)/2+1:kb dist(k) = ((kb-k)/float((kb+1)/2-1))^p_sigma/2-1.0; end; end; if p_sigma == 1 for k = 1:nlev dist(k) = -((k-1)/(kb-1))^p_sigma; end else for k = 1:(kb+1)/2 dist(k) = -((k-1)/((kb+1)/2-1))^p_sigma/2; end for k = (kb+1)/2+1:kb dist(k) = ((kb-k)/((kb+1)/2-1))^p_sigma/2-1.0; end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!