# ASCII only identifiers?

**URL:** https://fortran-lang.discourse.group/t/ascii-only-identifiers/7884
**Category:** Uncategorized
**Created:** [April 21, 2024, 1:10am UTC](https://fortran-lang.discourse.group/t/ascii-only-identifiers/7884 "2024-04-21T01:10:28Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![GregB](https://avatars.discourse-cdn.com/v4/letter/g/da6949/32.png) [@GregB](https://fortran-lang.discourse.group/u/GregB)
#### Post date: [April 21, 2024, 1:10am UTC](https://fortran-lang.discourse.group/t/ascii-only-identifiers/7884/1 "2024-04-21T01:10:28Z")

</div>

Is it correct that Fortran only supports ASCII identifiers (for variable / function / module names)? It looks like `gfortran` and `ifx` both complain about “Invalid character” or “Unrecognized token” when compiling something like:

```fortran
program unicode
    implicit none

    real, parameter :: π = 3.14159
    real, parameter :: ß = 1.23
    real, parameter :: µ₀ = 4 * π * 1e-7
    integer :: i

    real :: Δt, ω
    real :: t(4)
    real :: ϕ(4)
    real :: Aₙ(100)

    Δt = 0.1
    ω = 2.0

    t = [(Δt*real(i), i = 1, 4)]
    ϕ = [π/4, π/2, 3*π/4, π]
    print *, µ₀*cos(ω*t + ϕ) - ß 

end program unicode

```

I suppose things could get carried away, and might be hard for maintenance if you don’t have a setup to type these easily (I use vim, and have `imap` mappings from Latex-like modifiers, so `\omega` becomes `ω`, etc… Just making sure I’m not missing some command-line option.

Thanks!

(speaking of getting carried away…)

```fortran
    ℝ :: ω, ℓ, k, E₁
    ℤ :: n

    ω = √(k/ℓ)
    if (n ≥ 4) then
        E₁ = ½·m·v²
        !∇⨉B = µ₀·(J + ε₀·∂E/∂t)
    end if

```

---

<div class="post-metadata">

### Author: ![RonShepard](https://avatars.discourse-cdn.com/v4/letter/r/a3d4f5/32.png) [@RonShepard](https://fortran-lang.discourse.group/u/RonShepard)
#### Post date: [April 21, 2024, 3:31am UTC](https://fortran-lang.discourse.group/t/ascii-only-identifiers/7884/2 "2024-04-21T03:31:28Z")

</div>

The fortran standard defines a fortran character set, and then all of the language is defined in terms of those characters. It does not define the binary representation of those characters, so each compiler is free to map its native characters to the fortran character set however it wants.

---

<div class="post-metadata">

### Author: ![PierU](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/pieru/32/1848_2.png) [@PierU](https://fortran-lang.discourse.group/u/PierU)
#### Post date: [April 21, 2024, 9:51am UTC](https://fortran-lang.discourse.group/t/ascii-only-identifiers/7884/3 "2024-04-21T09:51:53Z")

</div>

From the [2023 draft standard](https://j3-fortran.org/doc/year/23/23-007r1.pdf):

 ![image](https://global.discourse-cdn.com/free1/uploads/fortran_lang/original/2X/4/4e6594ef3a1f83ce067467846c682a8a1e2962f7.png)

…

![image](https://global.discourse-cdn.com/free1/uploads/fortran_lang/original/2X/5/55159c7674e659e0b102392766b05f82fbd061e0.png)

…

 ![image](https://global.discourse-cdn.com/free1/uploads/fortran_lang/original/2X/6/6fa4fa2e2208ae76478a3a4e38565f8aece3a48d.png)

---

<div class="post-metadata">

### Author: ![IanMartinAjzenszmidt](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/ianmartinajzenszmidt/32/1992_2.png) [@IanMartinAjzenszmidt](https://fortran-lang.discourse.group/u/IanMartinAjzenszmidt)
#### Post date: [April 22, 2024, 4:30am UTC](https://fortran-lang.discourse.group/t/ascii-only-identifiers/7884/4 "2024-04-22T04:30:11Z")

</div>

```auto
Here are some working examples of Greek Maths symbols in gfortran

iian@ian-Latitude-E7440:~$ nano mathsy2.f08
ian@ian-Latitude-E7440:~$ gfortran mathsy2.f08
ian@ian-Latitude-E7440:~$ ./a.out
 Omega symbol: Ω
ian@ian-Latitude-E7440:~$ cat mathsy2.f08
program print_omega
  implicit none
  write(*,*) 'Omega symbol: Ω'
end program print_omega
ian@ian-Latitude-E7440:~$ nano mathsy3.f08
ian@ian-Latitude-E7440:~$ gfortran mathsy3.f08
ian@ian-Latitude-E7440:~$ ./a.out
>Hello<
>Hello and 你好<
ian@ian-Latitude-E7440:~$ cat mathsy3.f08
use iso_fortran_env
implicit none
integer, parameter :: wc = selected_char_kind('ISO_10646')
integer, parameter :: ac = selected_char_kind('ASCII')

character(kind=wc,len=20) :: hello4
character(kind=ac,len=20) :: hello1

hello1 = ac_'Hello'
hello4 = wc_'Hello and '//char(int(z'4F60'),wc)//char(int(z'597D'),wc)
open(output_unit,encoding='utf-8')
write(*,'(5a)') '>',trim(hello1),'<'
write(*,'(3a)') '>',trim(hello4),'<'
end
ian@ian-Latitude-E7440:~$ 

```
