Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/MilanSkocic/codata
Browse files Browse the repository at this point in the history
  • Loading branch information
MilanSkocic committed Dec 10, 2024
2 parents 154125f + ca72883 commit d8388b7
Show file tree
Hide file tree
Showing 57 changed files with 471 additions and 169 deletions.
7 changes: 0 additions & 7 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,5 @@

doc/** linguist-documentation
docs/** linguist-documentation
example/** linguist-vendored
include/** linguist-vendored
capi/** linguist-vendored
media/** linguist-vendored
pywrapper/** linguist-vendored
py/** linguist-vendored
C/** linguist-vendored
scripts/** linguist-vendored

56 changes: 39 additions & 17 deletions C/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@

# Introduction

`codata` is a C library providing the latest codata constants (2022) and
older values (2018, 2014 and 2010).
`codata` is a C library providing the latest codata constants (2022) and
older values (2018, 2014 and 2010).
The raw codata are taken from http://physics.nist.gov/constants.
The constants (values and uncertainties) are implemented as double precision reals.

Expand All @@ -15,34 +16,55 @@ gcc>=10

# Installation

A Makefile is provided, which uses [fpm](https://fpm.fortran-lang.org), for building the library.
A Makefile is provided 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

```
. ../configure.sh
make
cd ..
. configure.sh
cd C
make
make install
make uninstall
```


Install
# License

```
make install
```
MIT

Uninstall

```
make uninstall
```
# Usage


```C
#include <stdio.h>
#include "codata.h"

# License
int main(void){

MIT
printf("########## EXAMPLE IN C ##########n");

printf("%sn","########## VERSION ##########");
printf("version = %sn", 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;
}
```
43 changes: 43 additions & 0 deletions C/README_TEMPLATE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Introduction

`codata` is a C library providing the latest codata constants (2022) and
older values (2018, 2014 and 2010).
The raw codata are taken from http://physics.nist.gov/constants.
The constants (values and uncertainties) are implemented as double precision reals.


# Dependencies

```
gcc>=10
```


# Installation

A Makefile is provided 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

```
cd ..
. configure.sh
cd C
make
make install
make uninstall
```


# License

MIT


# Usage


2 changes: 1 addition & 1 deletion C/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.0
2.0.1
6 changes: 1 addition & 5 deletions C/include/codata.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,5 @@
#define ADD_IMPORT
#endif
#include "codata_version.h"
#include "codata_constants_type.h"
#include "codata_constants_2010.h"
#include "codata_constants_2014.h"
#include "codata_constants_2018.h"
#include "codata_constants_2022.h"
#include "codata_constants.h"
#endif
13 changes: 13 additions & 0 deletions C/include/codata_constants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#ifndef CODATA_CONSTANTS_H
#define CODATA_CONSTANTS_H
#if _MSC_VER
#define ADD_IMPORT __declspec(dllimport)
#else
#define ADD_IMPORT
#endif
#include "codata_constants_type.h"
#include "codata_constants_2010.h"
#include "codata_constants_2014.h"
#include "codata_constants_2018.h"
#include "codata_constants_2022.h"
#endif
2 changes: 1 addition & 1 deletion C/src/codata_version.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#include "codata_version.h"
const char version[32] = "2.0.0";
const char version[32] = "2.0.1";
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# 2.0.1

* Fix bug in version for Fortran code.

Full changelog available at [github](https://github.com/milanskocic/codata/releases)


# 2.0.0

* Drop compiled extensions for Python.
Expand Down
81 changes: 52 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,40 @@

# Introduction

`codata` is a Fortran library providing the latest codata constants (2022) and
older values (2018, 2014 and 2010).
The raw codata are taken from http://physics.nist.gov/constants.
The constants (values and uncertainties) are implemented as double precision reals.
`codata` is a Fortran library providing the latest codata constants (2022) and
older values (2018, 2014 and 2010).
The constants (values and uncertainties) are implemented as double precision reals
in derived types.
The sources are automatically generated from the raw codata values taken
from http://physics.nist.gov/constants.

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" }
[dependencies]
codata = { git="https://github.com/MilanSkocic/codata.git" }
```

**Notes**:
**Important**:

* 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.
**Extra: C and Python**

**Extra:**
`codata` is primarily a Fortran library but sources for C and Python are also
generated:

* Pure python code is provided in the `py` folder. See `py/README.md`.
A python package is available [pypi](https://pypi.org/project/pycodata).
* Pure C code is provided in the `C` folder. See `C/README.md`
A Makefile is provided for building the C library.


# Dependencies
Expand All @@ -41,39 +51,52 @@ 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
chmod +x configure.sh
. ./configure.sh
make
make install
make uninstall
```

Run tests

```
make test
```
# License

MIT

Install

```
make install
```
# Usage

Uninstall

```
make uninstall
```
```Fortran
program example_in_f
use iso_fortran_env
use codata
implicit none
print '(A)', '########## EXAMPLE IN FORTRAN ##########'
print '(A)', '########## VERSION ##########'
print *, "version = ", version
# License
print '(A)', '########## CONSTANTS ##########'
print *, "c = ", SPEED_OF_LIGHT_IN_VACUUM%value
MIT
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
```
66 changes: 66 additions & 0 deletions README_TEMPLATE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Introduction

`codata` is a Fortran library providing the latest codata constants (2022) and
older values (2018, 2014 and 2010).
The raw codata are taken from http://physics.nist.gov/constants.
The constants (values and uncertainties) are implemented as double precision reals.

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.

**Extra:**

* Pure python code is provided in the `py` folder. See `py/README.md`.
* Pure C code is provided in the `C` folder. See `C/README.md`


# 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


2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.0
2.0.1
Loading

0 comments on commit d8388b7

Please sign in to comment.