Difference between revisions of "Dynlib"

m (isopv_angle : iso-PV line angle)
m (Obtaining dynlib)
 
(45 intermediate revisions by 3 users not shown)
Line 1: Line 1:
== [[Dynlib Documentation|Documentation]] ==
+
== [http://folk.uib.no/csp001/dynlib_doc/ Documentation] ==
  
The steps necessary to obtain dynlib are described below. A more thorough documentation is compiled in [[Dynlib Documentation|the main documentation page]].
+
The steps necessary to obtain dynlib are described below. A more thorough documentation is compiled in [http://folk.uib.no/csp001/dynlib_doc/ the main documentation website].
  
== Obtaining dynlib ==
+
== Use the centrally installed dynlib ==
 +
 
 +
Dynlib is installed centrally for python 2.7 and python 3.4 in the python environments at <code>/Data/gfi/users/local/share/virtualenv/dynpie2</code> and <code>/Data/gfi/users/local/share/virtualenv/dynpie3</code>. You'll only have to activate one of these python enviroments to start using dynlib:
 +
<pre>source /Data/gfi/users/local/share/virtualenv/dynpieX/bin/activate</pre>
 +
In this command <code>X=2</code> for python 2.7 and <code>X=3</code> for python 3.4. For convenience add this command to your <code>~/.bash_profile</code> to activate the respective python environment automatically at each login.
 +
 
 +
'''Note''': For some types of login <code>.bash_profile</code> is not taken into account. In case you'll experience problems create a symbolic link <code>~/.bashrc</code> to point to the <code>~/.bash_profile</code> and re-login.
 +
 
 +
== Quick start to developing with dynlib ==
 +
 
 +
The following procedure is only necessary if you want to start developing dynlib further, for example if you want to add your own functions to dynlib. If you only want to use dynlib, the procedure in the above section is all you need.
 +
 
 +
=== Obtaining dynlib ===
  
 
# Copying the source code repository
 
# Copying the source code repository
#:<code>git clone /Data/gfi/users/tsp065/lib/dynlib.git</code>
+
#:<code>$ git clone /Data/gfi/users/local/src/dynlib.git</code>
 +
#:To clone the repository to your laptop or any machine outside the UiB network, use
 +
#:<code>$ git clone <username>@login.uib.no:/Data/gfi/users/local/src/dynlib.git</code>
 
# Change into the dynlib folder
 
# Change into the dynlib folder
#:<code>cd dynlib</code>
+
#:<code>$ cd dynlib</code>
 
# Compile the library
 
# Compile the library
#:<code>./compile</code>
+
#:<code>$ ./compile</code>
 
+
# (known broken right now) Make sure everything works as expected
== Quick start to developing with dynlib ==
+
#:<code>$ ./test</code>
 +
# To use your personal development version of dynlib instead of the centrally installed one, create a symlink in your scripts folder that points to the development version
 +
#:<code><in script folder>$ ln -s <path-to-dynlib>/lib dynlib</code>
 +
Happy developing!
  
 
=== Editing the Fortran code ===
 
=== Editing the Fortran code ===
  
The fortran code lives in the main source code directory. At the moment there are six source code files
+
The fortran code lives in <code>lib/fortran</code> directory. At the moment there are 16 source code files<br />
:<code>$ ls *.f95
+
<nowiki>$ ls *.f90
:dynlib_config.f95  dynlib_const.f95  dynlib_conv.f95  dynlib_diag.f95  dynlib_kind.f95  dynlib_stat.f95</code>
+
config.f90            detect_lines.f90      ellipse.f90            stat.f90
The most important are <code>dynlib_diag.f95</code> which contains subroutines that calculate various diagnostics, and <code>dynlib_stat.f95</code> which contains statistical functions. Changed Fortran sources need to be recompiled, again using  
+
const.f90              detect_rwb_contour.f90 interpol.f90          tend.f90
:<code>./compile</code>
+
derivatives.f90        diag.f90              kind.f90              thermodyn.f90
 +
detect.f90            diag_tend.f90          sphere.f90            utils.f90</nowiki>
 +
The most important are <code>diag.f90</code> which contains subroutines that calculate various diagnostics, and <code>detect.f90</code> which contains feature detection algorithms. Changed Fortran sources need to be recompiled, again using  
 +
:<code>$ ./compile</code>
  
 
=== [[git|Version control]] ===
 
=== [[git|Version control]] ===
  
 
The changes you made to the source code files can be listed by
 
The changes you made to the source code files can be listed by
:<code>git status</code>
+
:<code>$ git status</code>
 
or viewed in detailed diff-comparisons by
 
or viewed in detailed diff-comparisons by
:<code>git diff</code>
+
:<code>$ git diff</code>
 
or for one file only
 
or for one file only
:<code>git diff [filename]</code>
+
:<code>$ git diff <filename></code>
 +
 
 +
In case you want to undo your changes, you can revert any file to the last committed version by
 +
:<code>git checkout <filename></code>
  
 
Commit your changes from time to time and give a sensible and brief description of your changes in the editor that is opened (automatically)
 
Commit your changes from time to time and give a sensible and brief description of your changes in the editor that is opened (automatically)
:<code>git commit -a</code>
+
:<code>$ git commit -a</code>
 
The commit is then stored in your copy of the source code repository, but not yet available for others, which allows you to also commit work-in-progress.
 
The commit is then stored in your copy of the source code repository, but not yet available for others, which allows you to also commit work-in-progress.
  
Line 39: Line 62:
 
=== Using the Fortran functions ===
 
=== Using the Fortran functions ===
  
An example python script which calculates deformation using the Fortran function is provided with <code>deformation.py</code>.
+
An example python script which calculates deformation using the Fortran function is provided in the [http://folk.uib.no/csp001/dynlib_doc/examples.html documentation].
  
 
== Dynlib functions ==
 
== Dynlib functions ==
  
The functions generally operate on real arrays with dimension (nz,ny,nx) where nz is number of times or levels, and ny and nx are the number of latitudes and longitudes, respectively. The function descriptions below contain detailed descriptions of arguments and returns where there is any deviation from this pattern; otherwise they may be assumed to be of the form:
+
The functions are classified into different categories. All functions and categories listed in the [http://folk.uib.no/csp001/dynlib_doc/apidoc.html API documentation].
 
 
{| border="1" class="wikitable" style="text-align:center;"
 
|+ style="text-align:left"| Arguments:
 
|-
 
|
 
! width="60" | Type
 
! width="80" | Dim
 
! width="300" | Description
 
|-
 
! width="80" | u
 
| real || (nz,ny,nx) || Zonal velocity
 
|-
 
! width="80" | v
 
| real || (nz,ny,nx) || Meridional velocity
 
|-
 
! width="80" | pv
 
| real || (nz,ny,nx) || Potential vorticity
 
|}
 
 
 
{| border="1" class="wikitable" style="text-align:center;"
 
|+ style="text-align:left"| Returns:
 
|-
 
|
 
! width="60" | Type
 
! width="120" | Dim
 
! width="300" | Description
 
|-
 
! width="80" | res
 
| real || (nz,ny,nx) || output data
 
|}
 
 
 
The ubiquitous inputs ''dx'' and ''dy'' are all of the form
 
{| border="1" class="wikitable" style="text-align:center;"
 
|-
 
|
 
! width="60" | Type
 
! width="80" | Dim
 
! width="300" | Description
 
|-
 
! width="80" | dx
 
| real || (ny,nx) || dx(j,i)=x(j,i+1)-x(j,i-1) (in metres)
 
|-
 
! width="80" | dy
 
| real || (ny,nx) || dy(j,i)=y(j+1,i)-y(j-1,i) (in metres)
 
|}
 
 
 
Typically, the results for each level or time are computed individually in 2-D fashion, though they are returned as a 3-D array or the same size as the input.
 
 
 
=== ''ddx'' : partial x derivative ===
 
 
 
<code>res=ddx(dat,dx,dy)</code>
 
 
 
Calculates the partial x derivative of dat, using centred differences. For a non-EW-cyclic grid, 0 is returned on the edges of the x domain.
 
 
 
=== ''ddy'' : partial y derivative ===
 
 
 
<code>res=ddy(dat,dx,dy)</code>
 
 
 
Calculates the partial y derivative of dat, using centred differences. For a non-EW-cyclic grid, 0 is returned on all edges of the x,y domain. For an EW-cyclic grid, 0 is returned on the first and last latitudes.
 
 
 
=== ''grad'' : 2-D gradient of a scalar ===
 
 
 
<code>(resx,resy)=grad(dat,dx,dy)</code>
 
 
 
Calculates the 2-D gradient of dat, using centred differences in x and y. For a non-EW-cyclic grid, 0 is returned on all edges of the x,y domain. For an EW-cyclic grid, 0 is returned on the first and last latitudes.
 
 
 
=== ''lap2'' : 2-D laplacian of a scalar ===
 
 
 
<code>res=lap2(dat,dx,dy)</code>
 
 
 
Calculates the 2-D laplacian of dat, using centred differences. For a non-EW-cyclic grid, 0 is returned on all edges of the x,y domain. For an EW-cyclic grid, 0 is returned on the first and last latitudes.
 
 
 
=== ''vor'' : 2-D vorticity ===
 
 
 
<code>res=vor(u,v,dx,dy)</code>
 
 
 
Calculates the z component of vorticity of (u,v), using centred differences.
 
 
 
=== ''div'' : 2-D divergence===
 
 
 
<code>res=div(u,v,dx,dy)</code>
 
 
 
Calculates the 2-D divergence of (u,v), using centred differences.
 
 
 
=== ''def_shear'' : shear deformation ===
 
 
 
<code>res=def_shear(u,v,dx,dy)</code>
 
 
 
Calculates the shear (antisymmetric) deformation of (u,v), using centred differences.
 
 
 
=== ''def_stretch'' : stretch deformation ===
 
 
 
<code>res=def_stretch(u,v,dx,dy)</code>
 
 
 
Calculates the stretch (symmetric) deformation of (u,v), using centred differences.
 
 
 
=== ''def_total'' : total deformation ===
 
 
 
<code>res=def_total(u,v,dx,dy)</code>
 
 
 
Calculates the total (rotation-independent) deformation of (u,v), using centred differences.
 
 
 
=== ''def_angle'' : deformation angle ===
 
 
 
<code>res=def_angle(u,v,dx,dy)</code>
 
 
 
Calculates the angle between the x-axis and the dilatation axis of the deformation of (u,v).
 
 
 
=== ''isopv_angle'' : iso-PV contour angle ===
 
 
 
<code>res=isopv_angle(pv,dx,dy)</code>
 
 
 
Calculates the angle between the x-axis and the iso-lines of PV.
 
 
 
=== ''beta'' : angle between dilatation axis and iso-PV lines===
 
 
 
<code>res=beta(u,v,pv,dx,dy)</code>
 
 
 
Calculates the angle between the dilatation axis and the iso-lines of PV.
 
 
 
=== ''stretch_stir'' : fractional stretching rate and angular rotation rate of grad(PV)===
 
 
 
<code>(stretch,stir)=stretch_stir(u,v,pv,dx,dy)</code>
 
 
 
Returns real arrays, dim (nz,ny,nx):
 
 
 
stretch
 
= fractional PV gradient stretching rate
 
= 1/|gradPV| * d/dt(|gradPV|)
 
= gamma, 'stretching rate' (Lapeyre Klein Hua)
 
= -1/|gradPV| * Fn (Keyser Reeder Reed)
 
Fn = 0.5*|gradPV|(D-E*cos(2*beta))
 
    =  1/|gradPV| * F (Markowski Richardson)
 
 
 
stir
 
= angular rotation rate of grad(PV) (aka stirring rate)
 
= d(theta)/dt (Lapeyre Klein Hua)
 
= 1/|gradPV| * Fs  (Keyser Reeder Reed)
 
Fs = 0.5*|gradPV|(vort+E*sin(2*beta))
 
 
 
=== ''geop_from_montgp'' : geopotential ===
 
 
 
<code>res = geop_from_montgp(m,theta,p,dx,dy)</code>
 
 
 
Calculates geopotential (res) from montgomery potential (m), potential temperature (theta) and pressure (p)
 
 
 
=== ''rev'' : PV gradient reversal ===
 
 
 
<code>(resa,resc,resai,resci,resaiy,resciy,tested) = rev(pv,highenough,latitudes,ddythres,dx,dy)</code>
 
 
 
Gradient reversal: At each (i,j,k) grid point, finds the reversals of PV y-gradient and classes them as c (cyclonic) or a (anticyclonic)
 
 
 
{| border="1" class="wikitable" style="text-align:center;"
 
|+ style="text-align:left"| Arguments:
 
|-
 
|
 
! width="60" | Type
 
! width="80" | Dim
 
! width="300" | Description
 
|-
 
! width="80" | pv
 
| real || (nz,ny,nx) || potential vorticity
 
|-
 
! width="80" | highenough
 
| int*1 || (nz,ny,nx) || array of flags denoting whether to test the point for reversal
 
|-
 
! width="80" | latitudes
 
| real || (ny) || vector of latitudes
 
|-
 
! width="80" | ddythres
 
| real || 0 || Cutoff y-gradient for pv
 
|-
 
! width="80" | latitudes
 
| real || (ny) || vector of latitudes
 
|}
 
 
 
''Highenough'' is typically the output of ''highenough'' funtion, which returns 1 where the surface is sufficiently above ground level and 0 elsewhere.
 
 
 
''ddythres'' is the cutoff y-gradient for pv. The magnitude of (negative) d(pv)/dy must be above ddythres for reversal to be detected; this applies to revc, reva, revci,revai. Typical value 4E-12.
 
           
 
{| border="1" class="wikitable" style="text-align:center;"
 
|+ style="text-align:left"| Returns:
 
|-
 
|
 
! width="60" | Type
 
! width="80" | Dim
 
! width="300" | Description
 
|-
 
! width="80" | revc
 
| int*1 || (nz,ny,nx) || Cyclonic reversal flag (threshold test applied)
 
|-
 
! width="80" | reva
 
| int*1 || (nz,ny,nx) || Anticyclonic reversal flag (threshold test applied)
 
|-
 
! width="80" | revci
 
| real  || (nz,ny,nx) || Cyclonic reversal absolute PV gradient (threshold test applied)
 
|-
 
! width="80" | revai
 
| real  || (nz,ny,nx) || Anticyclonic reversal absolute PV gradient (threshold test applied)
 
|-
 
! width="80" | revciy
 
| real  || (nz,ny,nx) || Cyclonic reversal absolute PV y-gradient (no threshold test applied)
 
|-
 
! width="80" | revaiy
 
| real  || (nz,ny,nx) || Anticyclonic reversal absolute PV y-gradient (no threshold test applied)
 
|-
 
! width="80" | tested
 
| int*1 || (nz,ny,nx) || flag to 1 all tested points: where highenough==1 and point not on grid edge
 
|}
 
 
 
=== ''prepare_fft'' : make data periodic in y for FFT ===
 
 
 
<code>res = prepare_fft(thedata,dx,dy)</code>
 
 
 
Returns the data extended along complementary meridians (for fft).
 
For each lon, the reflected (lon+180) is attached below so that data is periodic in x and y.
 
NOTE: Input data must be lats -90 to 90, and nx must be even.
 
 
 
{| border="1" class="wikitable" style="text-align:center;"
 
|+ style="text-align:left"| Arguments:
 
|-
 
|
 
! width="60" | Type
 
! width="80" | Dim
 
! width="300" | Description
 
|-
 
! width="80" | thedata
 
| real || (nz,ny,nx) || input data
 
|}
 
 
 
{| border="1" class="wikitable" style="text-align:center;"
 
|+ style="text-align:left"| Returns:
 
|-
 
|
 
! width="60" | Type
 
! width="120" | Dim
 
! width="300" | Description
 
|-
 
! width="80" | res
 
| real || (nz,2*ny-2,nx) || output data
 
|}
 
 
 
=== ''sum_kix'' : sum along k for flagged k-values ===
 
 
 
<code>(res,nres) = sum_kix(thedata,kix,dx,dy)</code>
 
 
 
Calculates sum along k dimension for k values which are flagged in kix vector (length nz).
 
 
 
{| border="1" class="wikitable" style="text-align:center;"
 
|+ style="text-align:left"| Arguments:
 
|-
 
|
 
! width="60" | Type
 
! width="80" | Dim
 
! width="300" | Description
 
|-
 
! width="80" | thedata
 
| real || (nz,ny,nx) || input data
 
|-
 
! width="80" | kix
 
| int || (nz) || index flag for summation
 
|}
 
 
 
{| border="1" class="wikitable" style="text-align:center;"
 
|+ style="text-align:left"| Returns:
 
|-
 
|
 
! width="60" | Type
 
! width="80" | Dim
 
! width="300" | Description
 
|-
 
! width="80" | res
 
| real || (ny,nx) || (summed) output data
 
|-
 
! width="80" | nres
 
| int || 0 || Number of data summed = sum(kix)
 
|}
 
 
''Sum_kix'' is typically used for calculating seasonal means. To do this, kix is set to 1 for times in the relevant season and 0 elsewhere. After summing res and nres over all years, res/nres gives the mean for the season for all years.
 
 
 
=== ''high_enough'' : flags points which are sufficiently above ground ===
 
 
 
<code>res = high_enough(zdata,ztest,zthres,dx,dy)</code>
 
 
 
{| border="1" class="wikitable" style="text-align:center;"
 
|+ style="text-align:left"| Arguments:
 
|-
 
|
 
! width="60" | Type
 
! width="80" | Dim
 
! width="300" | Description
 
|-
 
! width="80" | zdata
 
| real || (nz,ny,nx) || geopotential of gridpoints
 
|-
 
! width="80" | ztest
 
| real || (1,ny,nx) ||geopotential of topography
 
|-
 
! width="80" | zthres
 
| real || 0 ||threshold geopotential height difference
 
|}
 
 
 
 
 
{|  border="1" class="wikitable" style="text-align:center;"
 
|+ style="text-align:left"| Returns:
 
|-
 
|
 
! width="60" | Type
 
! width="80" | Dim
 
! width="300" | Description
 
|-
 
! width="80" | res
 
| int*1 || (nz,ny,nx) ||
 
{| style="text-align:left;"
 
|-
 
|3-D flag array set to:
 
|-
 
|style="padding-left: 2em" |1 if zdata(t,y,x) > (ztest(1,y,x) + zthres)
 
|-
 
|style="padding-left: 2em" |0 otherwise
 
|}
 
|}
 
 
 
=== ''contour_rwb'' : detects RWB events, Riviere algorithm ===
 
 
 
<code>(beta_a_out,beta_c_out) = contour_rwb(pv_in,lonvalues,latvalues,ncon,lev,dx,dy)</code>
 
 
 
Detects the occurrence of anticyclonic and cyclonic wave-breaking events from a PV field on isentropic coordinates.
 
 
 
Reference: Rivière (2009, hereafter R09): Effect of latitudinal variations in low-level baroclinicity on eddy life cycles and upper-tropospheric wave-breaking processes. J. Atmos. Sci., 66, 1569–1592. See the appendix C.
 
 
 
{| border="1" class="wikitable" style="text-align:center;"
 
|+ style="text-align:left"| Arguments:
 
|-
 
|
 
! width="60" | Type
 
! width="80" | Dim
 
! width="300" | Description
 
|-
 
! width="80" | pv_in
 
| real || (nz,ny,nx) || isentropic pv. Should be on a regular lat-lon grid and 180W must be the first longitude. (If 180W is not the first longitude, the outputs will have 180W as the first, so must be rearranged)
 
|-
 
! width="80" | lonvalues
 
| real || (nx) || vector of longitudes
 
|-
 
! width="80" | latvalues
 
| real || (ny) || vector of latitudes
 
|-
 
! width="80" | ncon
 
| int || 0 || number of contours to test, normally 41 or 21
 
|-
 
! width="80" | lev
 
| real || 0 || potential temperature of the level
 
|}
 
 
 
{| border="1" class="wikitable" style="text-align:center;"
 
|+ style="text-align:left"| Returns:
 
|-
 
|
 
! width="60" | Type
 
! width="80" | Dim
 
! width="300" | Description
 
|-
 
! width="80" | beta_a_out
 
| int || (nz,ny,nx) || flag array, =1 if anticyclonic wave breaking
 
|-
 
! width="80" | beta_c_out
 
| int || (nz,ny,nx) || flag array, =1 if cyclonic wave breaking
 
|}
 
 
 
=== ''v_g'' : geostrophic velocity ===
 
 
 
<code>(resx,resy) = v_g(mont,lat,dx,dy)</code>
 
 
 
Calculates geostrophic velocity. Returns zero on equator.
 
 
 
=== ''okuboweiss'' : Okubo-Weiss criterion===
 
 
 
<code>res = okuboweiss(u,v,dx,dy)</code>
 
 
 
Calculates Okubo-Weiss criterion lambda_0=1/4 * (sigma^2-omega^2)= 1/4 W, where ''sigma'' is total deformation and ''omega'' is vorticity.
 
 
 
This is the square of the eigenvalues in Okubo's paper (assumes divergence is negligible).
 
 
 
=== ''laccel'' : Lagrangian acceleration===
 
 
 
<code>(resx,resy) = laccel(u,v,mont,lat,dx,dy)</code>
 
 
 
Calculates Lagrangian acceleration on the isentropic surface, based on Montgomery potential.
 
 
 
{| border="1" class="wikitable" style="text-align:center;"
 
|+ style="text-align:left"| Arguments:
 
|-
 
|
 
! width="60" | Type
 
! width="80" | Dim
 
! width="300" | Description
 
|-
 
! width="80" | u
 
| real || (nz,ny,nx) || zonal velocity
 
|-
 
! width="80" | v
 
| real || (nz,ny,nx) || meridional velocity
 
|-
 
! width="80" | mont
 
| real || (nz,ny,nx) || Montgomery potential
 
|-
 
! width="80" | lat
 
| real || (ny) || vector of latitudes
 
|}
 
 
 
=== ''accgrad_eigs'' : Lagrangian acceleration gradient tensor eigenvalues ===
 
 
 
<code>(respr,respi,resmr,resmi) = accgrad_eigs(u,v,mont,lat,dx,dy)</code>
 
 
 
Calculates eigenvalues of the lagrangian acceleration gradient tensor.
 
 
 
{| border="1" class="wikitable" style="text-align:center;"
 
|+ style="text-align:left"| Arguments:
 
|-
 
|
 
! width="60" | Type
 
! width="80" | Dim
 
! width="300" | Description
 
|-
 
! width="80" | u
 
| real || (nz,ny,nx) || zonal velocity
 
|-
 
! width="80" | v
 
| real || (nz,ny,nx) || meridional velocity
 
|-
 
! width="80" | mont
 
| real || (nz,ny,nx) || Montgomery potential
 
|-
 
! width="80" | lat
 
| real || (ny) || vector of latitudes
 
|}
 
 
 
{| border="1" class="wikitable" style="text-align:center;"
 
|+ style="text-align:left"| Returns:
 
|-
 
|
 
! width="60" | Type
 
! width="80" | Dim
 
! width="300" | Description
 
|-
 
! width="80" | respr
 
| real || (nz,ny,nx) || Real part of positive eigenvalue
 
|-
 
! width="80" | respi
 
| real || (nz,ny,nx) || Imaginary part of positive eigenvalue
 
|-
 
! width="80" | resmr
 
| real || (nz,ny,nx) || Real part of negative eigenvalue
 
|-
 
! width="80" | resmi
 
| real || (nz,ny,nx) || Imaginary part of negative eigenvalue
 
|-
 
! width="80" | ncon
 
| int || 0 || number of contours to test, normally 41 or 21
 
|-
 
! width="80" | lev
 
| real || 0 || potential temperature of the level
 
|}
 
 
 
=== ''dphidt'' : Lagrangian derivative of compression axis angle ===
 
 
 
<code>res = dphidt(u,v,mont,lat,dx,dy)</code>
 
 
 
Calculates Lagrangian time derivative of compression axis angle: d(phi)/dt (ref Lapeyre et. al 1999), from deformation and Lagrangian acceleration tensor.
 
 
 
{| border="1" class="wikitable" style="text-align:center;"
 
|+ style="text-align:left"| Arguments:
 
|-
 
|
 
! width="60" | Type
 
! width="80" | Dim
 
! width="300" | Description
 
|-
 
! width="80" | u
 
| real || (nz,ny,nx) || zonal velocity
 
|-
 
! width="80" | v
 
| real || (nz,ny,nx) || meridional velocity
 
|-
 
! width="80" | mont
 
| real || (nz,ny,nx) || Montgomery potential
 
|-
 
! width="80" | lat
 
| real || (ny) || vector of latitudes
 
|}
 
  
 
[[Category:Dynlib]]
 
[[Category:Dynlib]]
 
[[Category:Libraries]]
 
[[Category:Libraries]]

Latest revision as of 16:04, 18 September 2017

Documentation

The steps necessary to obtain dynlib are described below. A more thorough documentation is compiled in the main documentation website.

Use the centrally installed dynlib

Dynlib is installed centrally for python 2.7 and python 3.4 in the python environments at /Data/gfi/users/local/share/virtualenv/dynpie2 and /Data/gfi/users/local/share/virtualenv/dynpie3. You'll only have to activate one of these python enviroments to start using dynlib:

source /Data/gfi/users/local/share/virtualenv/dynpieX/bin/activate

In this command X=2 for python 2.7 and X=3 for python 3.4. For convenience add this command to your ~/.bash_profile to activate the respective python environment automatically at each login.

Note: For some types of login .bash_profile is not taken into account. In case you'll experience problems create a symbolic link ~/.bashrc to point to the ~/.bash_profile and re-login.

Quick start to developing with dynlib

The following procedure is only necessary if you want to start developing dynlib further, for example if you want to add your own functions to dynlib. If you only want to use dynlib, the procedure in the above section is all you need.

Obtaining dynlib

  1. Copying the source code repository
    $ git clone /Data/gfi/users/local/src/dynlib.git
    To clone the repository to your laptop or any machine outside the UiB network, use
    $ git clone <username>@login.uib.no:/Data/gfi/users/local/src/dynlib.git
  2. Change into the dynlib folder
    $ cd dynlib
  3. Compile the library
    $ ./compile
  4. (known broken right now) Make sure everything works as expected
    $ ./test
  5. To use your personal development version of dynlib instead of the centrally installed one, create a symlink in your scripts folder that points to the development version
    <in script folder>$ ln -s <path-to-dynlib>/lib dynlib

Happy developing!

Editing the Fortran code

The fortran code lives in lib/fortran directory. At the moment there are 16 source code files

$ ls *.f90
config.f90             detect_lines.f90       ellipse.f90            stat.f90
const.f90              detect_rwb_contour.f90 interpol.f90           tend.f90
derivatives.f90        diag.f90               kind.f90               thermodyn.f90
detect.f90             diag_tend.f90          sphere.f90             utils.f90

The most important are diag.f90 which contains subroutines that calculate various diagnostics, and detect.f90 which contains feature detection algorithms. Changed Fortran sources need to be recompiled, again using

$ ./compile

Version control

The changes you made to the source code files can be listed by

$ git status

or viewed in detailed diff-comparisons by

$ git diff

or for one file only

$ git diff <filename>

In case you want to undo your changes, you can revert any file to the last committed version by

git checkout <filename>

Commit your changes from time to time and give a sensible and brief description of your changes in the editor that is opened (automatically)

$ git commit -a

The commit is then stored in your copy of the source code repository, but not yet available for others, which allows you to also commit work-in-progress.

A more thorough introduction to the version control system is given here or on the official documentation.

Using the Fortran functions

An example python script which calculates deformation using the Fortran function is provided in the documentation.

Dynlib functions

The functions are classified into different categories. All functions and categories listed in the API documentation.