Constants, Literals & Parameters

iso_fortran_env also provides constants such as output_unit, input_unit, error_unit, iostat_end, iostat_eor, compiler_version(), compiler_options().

iso_fortran_env also provides constants such as output_unit, input_unit, error_unit, iostat_end, iostat_eor, compiler_version(), compiler_options().

real(dp), parameter :: pi = 4.0_dp * atan(1.0_dp)    ! named constant (compile time)
real(dp), parameter :: c = 2.99792458e8_dp
integer, parameter :: n = 100, m = 2 * n
character(len=*), parameter :: version = "1.0.3"     ! assumed length from value
integer, parameter :: primes(5) = [2, 3, 5, 7, 11]    ! constant array

! Literals
integer :: a = 255, b = int(z'FF'), c = int(b'11111111'), d = int(o'377')   ! hex, binary, octal BOZ
real(dp) :: e = 1.5e-3_dp, f = 6.02214076e23_dp
complex(dp) :: z = (1.0_dp, -1.0_dp)
logical :: t = .true.
character :: q = 'It''s'                    ! doubled quote escapes