Dynlib: Difference between revisions

From gfi
No edit summary
No edit summary
Line 6: Line 6:


# Create a new folder for the project that'll use dynlib, and go into that directory.
# Create a new folder for the project that'll use dynlib, and go into that directory.
#:<code>mkdir <project-name>
#:<code>$ mkdir <project-name></code>
#:<code>cd <project-name>
#:<code>$ cd <project-name></code>
# 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/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 everything works as expected
# Make sure everything works as expected
#:<code>./test</code>
#:<code>$ ./test</code>
# 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.
# 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>cd ..</code>
#:<code>$ cd ..</code>
#:<code>ls -l</code>
#:<code>$ ls</code>
#:<code>example_ani.py example_diag.py example_netcdf_write.py example_stat.py settings.py</code>
Happy developing!
Happy developing!


Line 29: Line 30:
:config.f95 const.f95 conv.f95 derivatives.f95 diag.f95 diag_contour_rwb.f95 kind.f95 stat.f95 utils.f95</code>
:config.f95 const.f95 conv.f95 derivatives.f95 diag.f95 diag_contour_rwb.f95 kind.f95 stat.f95 utils.f95</code>
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  
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  
:<code>./compile</code>
:<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>


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 48: Line 49:
=== 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.f95</code>.
An example python script which calculates deformation using the Fortran function is provided with <code>example_diag.py</code>.


== Dynlib functions ==
== Dynlib functions ==

Revision as of 17:13, 29 January 2013

Documentation

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

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 /Data/gfi/users/tsp065/lib/dynlib.git
  3. Change into the dynlib folder
    $ cd dynlib
  4. Compile the library
    $ ./compile
  5. Make sure everything works as expected
    $ ./test
  6. You can now go back to your main project folder and use dynib from there. Dynlib automatically installed a settings.py where you can override the default settings and some examples scripts in that project folder.
    $ cd ..
    $ ls
    example_ani.py example_diag.py example_netcdf_write.py example_stat.py settings.py

Happy developing!

Quick start to developing with dynlib

Editing the Fortran code

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

$ ls src/*.f95
config.f95 const.f95 conv.f95 derivatives.f95 diag.f95 diag_contour_rwb.f95 kind.f95 stat.f95 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]

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 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:

Dynlib diagnostic functions