The JAMS Fortran library is a collection of general Fortran modules offering miscellaneous functions in the categories Computational, Date and Time, Input / Output, Math / Numerics, Screening, Sensitivity Analysis and Optimising / Fitting, and Miscellaneous.
Created November 2011 by Matthias Cuntz and Juliane Mai
while at the Department Computational Hydrosystems, Helmholtz Centre
for Environmental Research - UFZ, Permoserstr. 15, 04318 Leipzig,
Germany, and continued while M Cuntz is at the Institut National de
Recherche pour l’Agriculture, l’Alimentation et l’Environnement
(INRAE), Nancy, France, and J Mai is at the Department of Civil and
Environmental Engineering of the University of Waterloo, ON, Canada.
It is distributed under the MIT License (see LICENSE file and below).
Copyright (c) 2011-2020 Matthias Cuntz and Juliane Mai
Contact Matthias Cuntz - mc (at) macu (dot) de
The library is maintained on a git repository at:
https://github.com/mcuntz/jams_fortran/
To use it, checkout the git repository
git clone https://github.com/mcuntz/jams_fortran.git
Copy the mo_*.f90 file of the chosen utility to your Fortran project. grep -i 'use' mo_*.f90 to check for dependencies. All Fortran modules use at least the kind definitions of mo_kind.f90; quite a few use also the general utilities in mo_utils.f90.
Documentation of the functions is above each function code or above the module procedure interface at the top of the file. There is a very brief introduction to the modules at the beginning of each file.
Some but not all documentation is in doxygen format and can be formatted with the appropriate tools, e.g. using the JAMS Makefile project.
Each module has a test program in the directory test/test_mo_*/. These test programs try to test all functionalities of the modules and provide hence examples of code usage of (almost) all subroutines.
The library is compatible with the Fortran 2003 standard. It was tested with the GNU gfortran, Intel ifort, NAG nagfor, and PGI pgfortran compilers in various revisions.
Interoperability with C is assured by the use of the intrinsic module
iso_c_binding in mo_kind.f90. The use of C functions were tested using
the C-header file cfortran.h, for example with the qhull
library. See
the use of cfortran.h in qhull/qhull_c.c and the corresponding
Fortran call in mo_qhull.f90.
The library uses C preprocessor flags to deal with special compiler
behaviours, i.e. one has to compile with the -cpp or -fpp compiler
flag. For example, gfortran (revisions < 5) did not include an
intrinsic ieee_arithmetic module so that mo_utils has convenience
funtions such as is_nan(x), which uses either the gfortran extension
isnan(x) or the Fortran standard ieee_is_nan(x). The decision is
made during compile time, checking if the variable __GFORTRAN__
is
defined. The following preprocessor variables are currently checked:
__ABSOFT__
, __GFORTRAN__
, __GFORTRAN41__
, __NETCDF3__
,
__pgiFortran__
, __NAG__
, __NAGf90Fortran__
.
Some modules use third-party packages such as LAPack or netCDF.
The libraries MinPack,
QHull, and
netCDF3
are given for convenience with the JAMS library. It is always
recommended to use specific installations for the computer system, for
example for blas and lapack, which are highly optimised. The netcdf3
directory includes only the parts of the netCDF 3.6.3 version that are
necessary for Fortran projects. Read the README in the netcdf3
directory for two system-specific configuration files. The
JAMS Makefile project
handles these kind of special configuration files.
The only other third-party softwares are LAPack and netCDF 4, which have to be installed independently. The latter can be installed by using, for example the installation script install_netcdf of https://github.com/mcuntz/install_netcdf.
Modules are provided in the following categories:
- Computational
- Date and Time
- Input / Output
- Math / Numerics
- Screening, Sensitivity Analysis and Optimising / Fitting
- Miscellaneous
mo_anneal | Simulated Annealing with estimation of initial temperature | |
mo_ansi_colors | Provide colouriser to output coloured text on terminal | |
mo_append | Appends vectors and/or matrixes like *nix cat and paste | |
mo_bootstrapping_sensitivity_analysis.f90 | Bootstrapping for sensitivity analysis | |
mo_boxcox | Box-Cox transformation, inverse transformation & estimating best exponent for transformation | |
mo_combinatorics | Combinatorial algorithms, e.g. binomial coefficient and k-subsets | |
mo_constants | Mathematical and physical constants | |
mo_corr | Correlation function with Fast Fourier Transform, or auto- & cross-correlations via direct calculation | |
mo_dds | Dynamically Dimensioned Search (DDS) and Modified DDS (MDDS) | |
mo_delsa | Distributed Evaluation of Local Sensitivity Analysis (DELSA) | |
mo_distributions.f90 | Continuous distributions density functions such as for the normal distribution | |
mo_elemeffects | Calculation of parameter's Elementary Effect on model/function output | |
mo_errormeasures | Distance or error measures between two datasets, e.g. bias, RMSE, ... | |
mo_file_utils | Utilities for file handling, e.g. search free unit | |
mo_finish | Routine to end program gracefully | |
mo_fit | Linear & polynomial fitting, and general fit with singular value decomposition | |
mo_functional.f90 | Functional programming for modern Fortran | |
mo_functions | Special functions such as the Gamma function | |
mo_histo | Histogram of data (useable also for variogram) | |
mo_integrate | Integration routines | |
mo_interpol | Linear interpolation for irregular grids | |
mo_julian | Converts dates between calendars, e.g. Julian Day into Day, Month and Year, and vice versa; Standard and IMSL convention | |
mo_kernel | Kernel regression and kernel density estimation for PDF and CDF | |
mo_kind | Definition of numerical precisions | |
mo_laplace_inversion.f90 | Numerical Laplace inversion | |
mo_linear_algebra | Wrapper functions for LAPACK's F77 linear algebra routines + some convenience functions such as the diagonal of a matrix | |
mo_linfit | Fit a straight line with model I or model II (geometric mean) regression without error bars on input | |
mo_mad | Median absolute deviation test | |
mo_mcmc | Monte Carlo Markov Chain sampling of parameter distribution around optimum | |
mo_message | Write out message; works with num2str from mo_string_utils | |
mo_minpack | Optimization package minpack (F90 interfaces) | |
mo_moment | 1st to 4th moments, central and mixed central moments | |
mo_mpi_stubs.f90 | Dummy functions for common MPI routines | |
mo_mtclim.f90 | Peter E Thornton's climate generator | |
mo_ncdump.f90 | Quick dumping of variables into netcdf files | |
mo_ncread | Reading nc files using the netcdf4 library | |
mo_ncwrite | Writing nc files using the netcdf4 library | |
mo_nelmin | Minimizes a function using the Nelder-Mead algorithm with the Applied Statistics algorithms No. 047 | |
mo_netcdf | David Schaefer's NetCDF Fortran 90 interface wrapper, with NETCDF3 support | |
mo_nml | Routines to handle namelist files | |
mo_nr | Main numerical recipes module containing the interfaces | |
mo_nrutil | Numerical recipes utilities module | |
mo_ode_generator | Given N reactants, generates and solves all corresponding ODE systems | |
mo_ode_solver | Iterative methods for the approximation of solutions of Ordinary Differential Equations (ODE) | |
mo_opt_functions | Test functions for optimization routines | |
mo_orderpack | Orderpack 2.0 from Michel Olagnon provides order and unconditional, unique, and partial ranking, sorting, and permutation. Provides also convenience routines sort and sort_index | |
mo_percentile | Median, Percentiles | |
mo_pi_index | Parameter importance index PI or alternatively B index calculation | |
mo_poly | Tests if a given 2D point lies inside, outside, or on edge/vertex of a 2D polygon, compute area and center of mass | |
mo_pumpingtests.f90 | Thiem and Theis solutions for groundwater-flow equation, and effektive well-flow solution for the effective coarse-graining conductivity | |
mo_qhull.f90 | Wrapper of C program for convex hull calculation from number of points | |
mo_quicksort | Several different implementations of Quicksort including an OpenMP version | |
mo_random_field.f90 | Generation of random fields with certain statistical properties, e.g. a given correlation length | |
mo_remap | Remaps a grid to another grid | |
mo_sampling | Random and Latin Hypercube Sampling for a set of parameters with Uniform(0,1) or Gaussian(0,1) Distribution | |
mo_sce | Shuffled Complex Evolution optimisation | |
mo_select_distant_entries.f90 | Select elements of matrix with largest distance to each other | |
mo_sobol | Sampling of parameters using Sobol sequences | |
mo_sobol_index | Sobol indexes (main and total effects) | |
mo_sort | Quicksort arrays or indices | |
mo_spatialsimilarity.f90 | Routines for bias insensitive comparison of spatial patterns | |
mo_specan | Spectral analysis using FFT | |
mo_spline | Spline functions to approximate or interpolate data | |
mo_standard_score.f90 | Normalized (anomaly)/standard score/z score and deseasonalized (standard score on monthly basis) values of a time series | |
mo_string_utils | Utilities for strings | |
mo_tee.f90 | Write out concatenated strings on standard out and to a given file or unit | |
mo_template | Module template demonstrating the coding standard of the library | |
mo_timer | CPU time routines, allows setting of multiple CPU timers | |
mo_utils | Provides general utilities such as comparisons of two reals, swapping of two elements in an array, is_nan, etc. | |
mo_var2nc.f90 | Writing variables to netcdf files | |
mo_xor4096 | Generating Uniform or Gaussian Random Numbers using the xor4096 algorithm | |
mo_xor4096_apps | Wrapper functions for random number generator xor4096 (Arrays of RNs, ranged RNs, Multivariate Normal Distribution) |
mo_append | Appends vectors and/or matrixes like *nix cat and paste | |
mo_constants | Mathematical and physical constants | |
mo_functional.f90 | Functional programming for modern Fortran | |
mo_kind | Definition of numerical precisions | |
mo_message | Write out message; works with num2str from mo_string_utils | |
mo_mpi_stubs.f90 | Dummy functions for common MPI routines | |
mo_nml | Routines to handle namelist files | |
mo_nr | Main numerical recipes module containing the interfaces | |
mo_nrutil | Numerical recipes utilities module | |
mo_orderpack | Orderpack 2.0 from Michel Olagnon provides order and unconditional, unique, and partial ranking, sorting, and permutation. Provides also convenience routines sort and sort_index | |
mo_quicksort | Several different implementations of Quicksort including an OpenMP version | |
mo_remap | Remaps a grid to another grid | |
mo_sort | Quicksort arrays or indices | |
mo_string_utils | Utilities for strings | |
mo_template | Module template demonstrating the coding standard of the library | |
mo_timer | CPU time routines, allows setting of multiple CPU timers | |
mo_utils | Provides general utilities such as comparisons of two reals, swapping of two elements in an array, is_nan, etc. | |
mo_finish | Routine to end program gracefully |
mo_julian | Converts dates between calendars, e.g. Julian Day into Day, Month and Year, and vice versa; Standard and IMSL convention |
mo_ansi_colors | Provide colouriser to output coloured text on terminal | |
mo_file_utils | Utilities for file handling, e.g. search free unit | |
mo_ncdump.f90 | Quick dumping of variables into netcdf files | |
mo_ncread | Reading nc files using the netcdf4 library | |
mo_ncwrite | Writing nc files using the netcdf4 library | |
mo_netcdf | David Schaefer's NetCDF Fortran 90 interface wrapper, with NETCDF3 support | |
mo_tee.f90 | Write out concatenated strings on standard out and to a given file or unit | |
mo_var2nc.f90 | Writing variables to netcdf files |
mo_boxcox | Box-Cox transformation, inverse transformation & estimating best exponent for transformation | |
mo_combinatorics | Combinatorial algorithms, e.g. binomial coefficient and k-subsets | |
mo_corr | Correlation function with Fast Fourier Transform, or auto- & cross-correlations via direct calculation | |
mo_distributions.f90 | Continuous distributions density functions such as for the normal distribution | |
mo_errormeasures | Distance or error measures between two datasets, e.g. bias, RMSE, ... | |
mo_functions | Special functions such as the Gamma function | |
mo_histo | Histogram of data (useable also for variogram) | |
mo_integrate | Integration routines | |
mo_interpol | Linear interpolation for irregular grids | |
mo_kernel | Kernel regression and kernel density estimation for PDF and CDF | |
mo_laplace_inversion.f90 | Numerical Laplace inversion | |
mo_linear_algebra | Wrapper functions for LAPACK's F77 linear algebra routines + some convenience functions such as the diagonal of a matrix | |
mo_linfit | Fit a straight line with model I or model II (geometric mean) regression without error bars on input | |
mo_mad | Median absolute deviation test | |
mo_moment | 1st to 4th moments, central and mixed central moments | |
mo_ode_solver | Iterative methods for the approximation of solutions of Ordinary Differential Equations (ODE) | |
mo_percentile | Median, Percentiles | |
mo_poly | Tests if a given 2D point lies inside, outside, or on edge/vertex of a 2D polygon, compute area and center of mass | |
mo_qhull.f90 | Wrapper of C program for convex hull calculation from number of points | |
mo_sampling | Random and Latin Hypercube Sampling for a set of parameters with Uniform(0,1) or Gaussian(0,1) Distribution | |
mo_select_distant_entries.f90 | Select elements of matrix with largest distance to each other | |
mo_sobol | Sampling of parameters using Sobol sequences | |
mo_spatialsimilarity.f90 | Routines for bias insensitive comparison of spatial patterns | |
mo_spline | Spline functions to approximate or interpolate data | |
mo_standard_score.f90 | Normalized (anomaly)/standard score/z score and deseasonalized (standard score on monthly basis) values of a time series | |
mo_xor4096 | Generating Uniform or Gaussian Random Numbers using the xor4096 algorithm | |
mo_xor4096_apps | Wrapper functions for random number generator xor4096 (Arrays of RNs, ranged RNs, Multivariate Normal Distribution) |
Screening, Sensitivity Analysis and Optimising / Fitting
mo_anneal | Simulated Annealing with estimation of initial temperature | |
mo_bootstrapping_sensitivity_analysis.f90 | Bootstrapping for sensitivity analysis | |
mo_dds | Dynamically Dimensioned Search (DDS) and Modified DDS (MDDS) | |
mo_delsa | Distributed Evaluation of Local Sensitivity Analysis (DELSA) | |
mo_elemeffects | Calculation of parameter's Elementary Effect on model/function output | |
mo_fit | Linear & polynomial fitting, and general fit with singular value decomposition | |
mo_mcmc | Monte Carlo Markov Chain sampling of parameter distribution around optimum | |
mo_minpack | Optimization package minpack (F90 interfaces) | |
mo_nelmin | Minimizes a function using the Nelder-Mead algorithm with the Applied Statistics algorithms No. 047 | |
mo_opt_functions | Test functions for optimization routines | |
mo_pi_index | Parameter importance index PI or alternatively B index calculation | |
mo_sce | Shuffled Complex Evolution optimisation | |
mo_sobol_index | Sobol indexes (main and total effects) |
mo_mtclim.f90 | Peter E Thornton's climate generator | |
mo_ode_generator | Given N reactants, generates and solves all corresponding ODE systems | |
mo_pumpingtests.f90 | Thiem and Theis solutions for groundwater-flow equation, and effektive well-flow solution for the effective coarse-graining conductivity | |
mo_random_field.f90 | Generation of random fields with certain statistical properties, e.g. a given correlation length | |
mo_specan | Spectral analysis using FFT |
This file is part of the JAMS Fortran library, distributed under the MIT License.
Copyright (c) 2011-2020 Matthias Cuntz, Juliane Mai, Stephan Thober - mc (at) macu (dot) de
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Be aware that some code is under the Numerical Recipes License 3rd edition http://www.nr.com/aboutNR3license.html. You can identity it by the use of mo_nr or mo_nrutil.
The Numerical Recipes Personal Single-User License lets you personally use Numerical Recipes code ("the code") on any number of computers, but only one computer at a time. You are not permitted to allow anyone else to access or use the code. You may, under this license, transfer precompiled, executable applications incorporating the code to other, unlicensed, persons, providing that (i) the application is noncommercial (i.e., does not involve the selling or licensing of the application for a fee), and (ii) the application was first developed, compiled, and successfully run by you, and (iii) the code is bound into the application in such a manner that it cannot be accessed as individual routines and cannot practicably be unbound and used in other programs. That is, under this license, your application user must not be able to use Numerical Recipes code as part of a program library or "mix and match" workbench.
Businesses and organizations that purchase the disk or code download, and that thus acquire one or more Numerical Recipes Personal Single-User Licenses, may permanently assign those licenses, in the number acquired, to individual employees. Such an assignment must be made before the code is first used and, once made, it is irrevocable and can not be transferred.
If you do not hold a Numerical Recipes License, this code is only for informational and educational purposes but cannot be used.