Skip to content

Commit

Permalink
Update doc and configure.
Browse files Browse the repository at this point in the history
No more concatenation of READMEs.
  • Loading branch information
MilanSkocic committed Dec 11, 2024
1 parent 86dee2c commit d1491f7
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 210 deletions.
108 changes: 14 additions & 94 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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
Expand All @@ -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 <stdio.h>
#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"])
```
62 changes: 0 additions & 62 deletions README_TEMPLATE.txt

This file was deleted.

50 changes: 1 addition & 49 deletions configure.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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"
File renamed without changes.
3 changes: 2 additions & 1 deletion doc/specs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
3 changes: 2 additions & 1 deletion src/codata_api.f90
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 2 additions & 3 deletions src/codata_capi.f90
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit d1491f7

Please sign in to comment.