File: example_constants.f90

package info (click to toggle)
fortran-stdlib 0.8.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 34,008 kB
  • sloc: f90: 24,178; ansic: 1,244; cpp: 623; python: 119; makefile: 13
file content (25 lines) | stat: -rw-r--r-- 1,064 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
program example_constants
    use stdlib_constants, only: c, pi=>PI_dp
    use stdlib_codata, only: alpha=>ALPHA_PARTICLE_ELECTRON_MASS_RATIO
    use stdlib_codata_type, only : to_real
    use stdlib_kinds, only: dp, sp

    ! Use most common physical constants defined as double precision reals
    print *, "speed of light in vacuum= ", c

    ! Use of mathematical constants such as PI
    print *, "PI as double precision real= ", pi

    ! Use codata_constant type for evaluating the value to the desired precision
    print *, "Value of alpha... evaluated to double precision=", alpha%to_real(1.0_dp)
    print *, "Uncertainty of alpha... evaluated to double precision=", alpha%to_real(1.0_sp, .true.)
    print *, "Value of alpha... evaluated to single precision=", alpha%to_real(1.0_sp)

    ! Convert a codata constant to a real
    print *, "Value of the alpha... evaluated to double precision=", to_real(alpha, 1.0_dp)


    ! Print out codata constant attributes: name, value, uncertainty and unit
    call alpha%print()

end program example_constants