diff --git a/README.md b/README.md index c297e41..83dde84 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,8 @@ - # Introduction -`codata` is a Fortran library providing the standard and abridged atomic weights, +`codata` is a Fortran library providing the standard and abridged atomic weights, the isotopic abundance and the isotopes' standard atomic weights. -The data are taken from http://ciaaw.org. +The data are taken from http://ciaaw.org. C API allows usage from C, or can be used as a basis for other wrappers. Python wrapper allows easy usage from Python. @@ -13,15 +12,15 @@ To use `codata` within your [fpm](https://github.com/fortran-lang/fpm) project, add the following to your `fpm.toml` file: ``` -[dependencies] -codata = { git="https://github.com/MilanSkocic/codata.git" } + [dependencies] + codata = { git="https://github.com/MilanSkocic/codata.git" } ``` -**Notes**: +**Notes**: -* The latest codata constants were integrated in the [stdlib](https://github.com/fortran-lang/stdlib/releases/tag/v0.7.0). The constants are implemented as derived type which carries the name, the value, the uncertainty and the unit. This library will be complementary to the constants defined in the stdlib by providing older values for the constants. +* The latest codata constants were integrated in the [stdlib](https://github.com/fortran-lang/stdlib/releases/tag/v0.7.0). The constants are implemented as derived type which carries the name, the value, the uncertainty and the unit. This library will be complementary to the constants defined in the stdlib by providing older values for the constants. -* If you only need sources for the codata constants that you can integrate directly in your sources you may be interested by https://github.com/vmagnin/fundamental_constants. +* If you only need sources for the codata constants that you can integrate directly in your sources you may be interested by https://github.com/vmagnin/fundamental_constants. # Dependencies @@ -38,100 +37,21 @@ fypp>=3.0 A Makefile is provided, which uses [fpm](https://fpm.fortran-lang.org), for building the library. -* On windows, [msys2](https://www.msys2.org) needs to be installed. -Add the msys2 binary (usually C:\msys64\usr\bin) to the path in order to be able to use make. +* On windows, [msys2](https://www.msys2.org) needs to be installed. + Add the msys2 binary (usually C:\\msys64\\usr\\bin) to the path in order to be able to use make. * On Darwin, the [gcc](https://formulae.brew.sh/formula/gcc) toolchain needs to be installed. Build: the configuration file will set all the environment variables necessary for the compilation ``` -chmod +x configure.sh -. ./configure.sh -make -make install -make uninstall + chmod +x configure.sh + . ./configure.sh + make + make install + make uninstall ``` # License MIT - - -# Usage - - -```Fortran -program example_in_f -use iso_fortran_env -use codata -implicit none - -print '(A)', '########## EXAMPLE IN FORTRAN ##########' - -print '(A)', '# VERSION' -print *, "version = ", get_version() - -print '(A)', '# CONSTANTS' -print *, "c = ", SPEED_OF_LIGHT_IN_VACUUM%value - -print '(A)', '# UNCERTAINTY' -print *, "u(c) = ", SPEED_OF_LIGHT_IN_VACUUM%uncertainty - -print '(A)', '# OLDER VALUES' -print '(A, F23.16)', "Mu_2022(latest) = ", MOLAR_MASS_CONSTANT%value -print '(A, F23.16)', "Mu_2018 = ", MOLAR_MASS_CONSTANT_2018%value -print '(A, F23.16)', "Mu_2014 = ", MOLAR_MASS_CONSTANT_2014%value -print '(A, F23.16)', "Mu_2010 = ", MOLAR_MASS_CONSTANT_2010%value - - -end program -``` -```C -#include -#include "codata.h" - -int main(void){ - -printf("########## EXAMPLE IN C ##########n"); - -printf("%sn","# VERSION"); -printf("version = %sn", codata_get_version()); - -printf("%sn","# CONSTANTS"); -printf("c = %fn", SPEED_OF_LIGHT_IN_VACUUM.value); - -printf("%sn","# UNCERTAINTY"); -printf("u(c) = %fn", SPEED_OF_LIGHT_IN_VACUUM.uncertainty); - -printf("%sn","# OLDER VALUES"); -printf("Mu_2022(latest) = %23.16fn", MOLAR_MASS_CONSTANT.value); -printf("Mu_2018 = %23.16fn", MOLAR_MASS_CONSTANT_2018.value); -printf("Mu_2014 = %23.16fn", MOLAR_MASS_CONSTANT_2014.value); -printf("Mu_2010 = %23.16fn", MOLAR_MASS_CONSTANT_2010.value); - -return 0; -} -``` -```Python -r"""Example in python.""" -import sys -sys.path.insert(0, "../src/") -import pycodata - -print("########## EXAMPLE IN PYTHON ##########") -print("# VERSION") -print(f"version = {pycodata.__version__}") - -print("# Constants") -print(f"c =", pycodata.SPEED_OF_LIGHT_IN_VACUUM["value"]) - -print("# UNCERTAINTY") -print(f"u(c) = ", pycodata.SPEED_OF_LIGHT_IN_VACUUM["uncertainty"]) - -print("# OLDER VALUES") -print(f"Mu_2022 = ", pycodata.MOLAR_MASS_CONSTANT["value"]) -print(f"Mu_2018 = ", pycodata.codata_constants_2018.MOLAR_MASS_CONSTANT_2018["value"]) -print(f"Mu_2014 = ", pycodata.codata_constants_2014.MOLAR_MASS_CONSTANT_2014["value"]) -print(f"Mu_2010 = ", pycodata.codata_constants_2010.MOLAR_MASS_CONSTANT_2010["value"]) -``` diff --git a/README_TEMPLATE.txt b/README_TEMPLATE.txt deleted file mode 100644 index 0613887..0000000 --- a/README_TEMPLATE.txt +++ /dev/null @@ -1,62 +0,0 @@ -# Introduction - -`codata` is a Fortran library providing the standard and abridged atomic weights, -the isotopic abundance and the isotopes' standard atomic weights. -The data are taken from http://ciaaw.org. -C API allows usage from C, or can be used as a basis for other wrappers. -Python wrapper allows easy usage from Python. - -The names are quite long and can be aliased with shorter names. - -To use `codata` within your [fpm](https://github.com/fortran-lang/fpm) project, -add the following to your `fpm.toml` file: - -``` - [dependencies] - codata = { git="https://github.com/MilanSkocic/codata.git" } -``` - -**Notes**: - -* The latest codata constants were integrated in the [stdlib](https://github.com/fortran-lang/stdlib/releases/tag/v0.7.0). The constants are implemented as derived type which carries the name, the value, the uncertainty and the unit. This library will be complementary to the constants defined in the stdlib by providing older values for the constants. - -* If you only need sources for the codata constants that you can integrate directly in your sources you may be interested by https://github.com/vmagnin/fundamental_constants. - - -# Dependencies - -``` -gfortran>=10 -fpm>=0.7 -stdlib>=0.5 -fypp>=3.0 -``` - - -# Installation - -A Makefile is provided, which uses [fpm](https://fpm.fortran-lang.org), for building the library. - -* On windows, [msys2](https://www.msys2.org) needs to be installed. - Add the msys2 binary (usually C:\\msys64\\usr\\bin) to the path in order to be able to use make. -* On Darwin, the [gcc](https://formulae.brew.sh/formula/gcc) toolchain needs to be installed. - -Build: the configuration file will set all the environment variables necessary for the compilation - -``` - chmod +x configure.sh - . ./configure.sh - make - make install - make uninstall -``` - - -# License - -MIT - - -# Usage - - diff --git a/configure.sh b/configure.sh index 63b19e0..4f728f4 100644 --- a/configure.sh +++ b/configure.sh @@ -1,43 +1,5 @@ #!/bin/bash -function prepare_readme () { - - local fpath_readme_tpl="$1" - local fpath_readme="$2" - local fpath_example_in_f="$3" - local fpath_example_in_c="$4" - local fpath_example_in_py="$5" - - echo "" > $fpath_readme - while read line - do - set -f - echo $line >> $fpath_readme - set +f - done < $fpath_readme_tpl - - echo "\`\`\`Fortran" >> $fpath_readme - while read line - do - echo $line >> $fpath_readme - done < $fpath_example_in_f - echo "\`\`\`" >> $fpath_readme - - echo "\`\`\`C" >> $fpath_readme - while read line - do - echo $line >> $fpath_readme - done < $fpath_example_in_c - echo "\`\`\`" >> $fpath_readme - - echo "\`\`\`Python" >> $fpath_readme - while read line - do - echo $line >> $fpath_readme - done < $fpath_example_in_py - echo "\`\`\`" >> $fpath_readme -} - NAME="codata" LIBNAME="lib$NAME" PYNAME="py$NAME" @@ -119,14 +81,4 @@ echo "* PY=" $PY echo -n "Copying version and license for python..." cp -f VERSION ./py/VERSION cp -f LICENSE ./py/LICENSE -echo "OK" - -echo -n "Generating examples in README..." -fpath_readme_tpl="./README_TEMPLATE.txt" -fpath_readme="./README.md" -fpath_example_in_f="./example/example.f90" -fpath_example_in_c="./example/example.c" -fpath_example_in_py="./example/example.py" -prepare_readme $fpath_readme_tpl $fpath_readme $fpath_example_in_f $fpath_example_in_c $fpath_example_in_py -echo "OK" - +echo "OK" \ No newline at end of file diff --git a/doc/specs/codata_constants.md b/doc/specs/api.md similarity index 100% rename from doc/specs/codata_constants.md rename to doc/specs/api.md diff --git a/doc/specs/index.md b/doc/specs/index.md index 102088e..3628ffc 100644 --- a/doc/specs/index.md +++ b/doc/specs/index.md @@ -4,4 +4,5 @@ title: Specifications (specs) This is an index/directory of the specifications (specs) for each module. -- [constants](codata_constants.html) +- [API](api.html) +- [C API](api.html) diff --git a/src/codata_api.f90 b/src/codata_api.f90 index 893eb9d..3d4616b 100644 --- a/src/codata_api.f90 +++ b/src/codata_api.f90 @@ -1,5 +1,6 @@ module codata__api - !! Constants module. + !! API + !! See [specs](../page/specs/api.html). !! The latest values (2022) do not have the year as a suffix in their name. !! Older values can be used and they feature the year as a suffix in their name. use codata__version, only: version diff --git a/src/codata_capi.f90 b/src/codata_capi.f90 index 812d5bf..ad9cd84 100644 --- a/src/codata_capi.f90 +++ b/src/codata_capi.f90 @@ -1,7 +1,6 @@ module codata__capi - !! Constants module. - !! The latest values (2022) do not have the year as a suffix in their name. - !! Older values can be used and they feature the year as a suffix in their name. + !! C API + !! See [specs](../page/specs/capi.html). use codata__api, only: get_version use iso_c_binding, only: c_ptr, c_null_char, c_loc implicit none