Difference between revisions of "Dynlib"

(Quick start to developing with dynlib)
(Updated instructions for using the shared dynlib)
Line 5: Line 5:
 
== Use the centrally installed dynlib ==
 
== Use the centrally installed dynlib ==
  
Dynlib is installed centrally in <code>/Data/gfi/users/local/lib/python2.7/site-packages</code>. You'll only have to adapt some paths in your <code>~/.bash_profile</code> to start using it! Add the following to your <code>~/.bash_profile</code>:
+
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 these python enviroments to start using dynlib.
 
+
<pre>source /Data/gfi/users/local/share/virtualenv/dynpieX/bin/activate</pre>
<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.
export SHARED='/Data/gfi/users/local'
 
export PATH="$PATH:$SHARED/bin"
 
export PYTHONPATH="$PYTHONPATH:$SHARED/lib/python2.7/site-packages"
 
</pre>
 
 
 
To take into account your changes use <code>source ~/.bash_profile</code>. You can then create a project folder with the default settings file and some example scripts with the command  
 
<code>dynlib_init.py <project-name></code>.
 
  
 
'''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.
 
'''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.

Revision as of 15:20, 11 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 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

Obtaining dynlib

  1. Create a new folder for the project that'll use dynlib, and go into that directory.
    $ mkdir <project-name>
    $ cd <project-name>
  2. Copying the source code repository
    $ git clone $SHARED/src/dynlib.git
    To clone the repository to your laptop or any machine outside the UiB network, use
    $ git clone <username>@login.uib.no:$SHARED/src/dynlib.git
  3. Change into the dynlib folder
    $ cd dynlib
  4. Compile the library
    $ ./compile
  5. (known broken right now) Make sure everything works as expected
    $ ./test

Happy developing!

Editing the Fortran code

The fortran code lives in src directory. At the moment there are 12 source code files

$ ls src/*.f95
src/config.f95 src/derivatives.f95 src/detect_fronts.f95 src/diag.f95 src/humidity.f95 src/stat.f95
src/const.f95 src/detect.f95 src/detect_rwb_contour.f95 src/ellipse.f95 src/kind.f95 src/utils.f95
The most important are diag.f95 which contains subroutines that calculate various diagnostics, and stat.f95 which contains statistical functions. 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 with example_diag.py.

Dynlib functions

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