Dynlib: Difference between revisions

From gfi
Csp001 (talk | contribs)
No edit summary
Anmar5059 (talk | contribs)
Typesetting
 
(19 intermediate revisions by 2 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 ==
== Quick start to developing with dynlib ==
 
*Before you compile you need to set up an environment where you will install the necessary libraries with the required version (e.g., numpy not newer than 1.26.2)
*:<code>$ python3 -m venv dyn</code>
*:<code>$ pip install numpy==1.26.2</code> 
*:<code>$ pip install scipy python-dateutil</code> 
*:<code>$ pip install xarray pandas netcdf4 h5netcdf</code> 
*:<code>$ pip install python-dateutil</code> 
*:<code>$ pip install basemap==1.3.8 basemap-data-hires</code>
*Then activate the environment
*:<code>$  '''source''' dyn/bin/activate</code>
 
=== Obtaining dynlib ===


# Create a new folder for the project that'll use dynlib, and go into that directory.
#Copying the source code repository
#:<code>$ mkdir <project-name></code>
#:<code>$ git clone /Data/gfi/users/local/src/dynlib.git</code>
#:<code>$ cd <project-name></code>
#:To clone the repository to your laptop or any machine outside the UiB network, use
# Copying the source code repository
#:<code>$ git clone <username>@login.uib.no:/Data/gfi/users/local/src/dynlib.git</code>
#:<code>$ git clone /Data/gfi/users/tsp065/lib/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> Make sure that the current hostname is recognised, if needed add the following lines to compile
# Make sure everything works as expected
#:<code>if [ "${host: -9}" == 'novalocal' ]; then</code><code>    LIBS="-L$(pwd)/ext/spherepack3.2/lib -lopenblas -lscalapack -lspherepack"</code> <code>    RPATH="" #-Wl,-rpath,/Data/gfi/users/local/lib"</code> and change  <code>host=`hostname -f`</code> to <code>host=`hostname`</code>
#:<code>$ ./test</code>
# Finally, you need to link external libraries
# You can now go back to your main project folder and use dynib from there. Dynlib automatically installed a <code>settings.py</code> where you can override the default settings and some examples scripts in that project folder.
#:<code>export LD_LIBRARY_PATH="/cvmfs/software.eessi.io/versions/2023.06/software/linux/x86_64/generic/software/ScaLAPACK/2.2.0-gompi-2023b-fb/lib:/cvmfs/software.eessi.io/versions/2023.06/software/linux/x86_64/generic/software/OpenBLAS/0.3.24-GCC-13.2.0/lib"</code>
#:<code>$ cd ..</code>
# To use your personal development version of dynlib, create a symlink in your scripts folder that points to the development version
#:<code>$ ls</code>
#:<code><in script folder>$ ln -s <path-to-dynlib>/lib dynlib</code>
#:<code>example_ani.py example_diag.py example_netcdf_write.py example_stat.py settings.py</code>
Happy developing!
 
== Quick start to developing with dynlib ==
 
=== Editing the Fortran code ===
=== Editing the Fortran code ===


The fortran code lives in <code>src</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 src/*.f95
<nowiki>$ ls *.f90
:config.f95 const.f95 conv.f95 derivatives.f95 diag.f95 diag_contour_rwb.f95 kind.f95 stat.f95 utils.f95</code>
config.f90            detect_lines.f90      ellipse.f90            stat.f90
The most important are <code>diag.f95</code> which contains subroutines that calculate various diagnostics, and <code>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
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>
:<code>$ ./compile</code>


Line 39: Line 48:
:<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)
Line 49: Line 61:
=== Using the Fortran functions ===
=== Using the Fortran functions ===


An example python script which calculates deformation using the Fortran function is provided with <code>example_diag.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 are classified into different categories.
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].
* [[Dynlib derivatives functions|Dynlib derivatives libary]]
* [[Dynlib diag functions|Dynlib diagnostic functions]]
* [[Dynlib utils functions|Dynlib utility functions]]


[[Category:Dynlib]]
[[Category:Dynlib]]
[[Category:Libraries]]
[[Category:Libraries]]

Latest revision as of 09:42, 17 April 2026

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

Quick start to developing with dynlib

  • Before you compile you need to set up an environment where you will install the necessary libraries with the required version (e.g., numpy not newer than 1.26.2)
    $ python3 -m venv dyn
    $ pip install numpy==1.26.2
    $ pip install scipy python-dateutil
    $ pip install xarray pandas netcdf4 h5netcdf
    $ pip install python-dateutil
    $ pip install basemap==1.3.8 basemap-data-hires
  • Then activate the environment
    $ source dyn/bin/activate

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 Make sure that the current hostname is recognised, if needed add the following lines to compile
    if [ "${host: -9}" == 'novalocal' ]; then    LIBS="-L$(pwd)/ext/spherepack3.2/lib -lopenblas -lscalapack -lspherepack"     RPATH="" #-Wl,-rpath,/Data/gfi/users/local/lib" and change host=`hostname -f` to host=`hostname`
  4. Finally, you need to link external libraries
    export LD_LIBRARY_PATH="/cvmfs/software.eessi.io/versions/2023.06/software/linux/x86_64/generic/software/ScaLAPACK/2.2.0-gompi-2023b-fb/lib:/cvmfs/software.eessi.io/versions/2023.06/software/linux/x86_64/generic/software/OpenBLAS/0.3.24-GCC-13.2.0/lib"
  5. To use your personal development version of dynlib, create a symlink in your scripts folder that points to the development version
    <in script folder>$ ln -s <path-to-dynlib>/lib dynlib

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

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.