# Documenting variable declaration and setting

**URL:** <https://fortran-lang.discourse.group/t/documenting-variable-declaration-and-setting/4383>\
**Category:** Uncategorized\
**Created:** [September 22, 2022, 8:59am UTC](https://fortran-lang.discourse.group/t/documenting-variable-declaration-and-setting/4383 "2022-09-22T08:59:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![FLNewbiee](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/flnewbiee/32/2155_2.png) [@FLNewbiee](https://fortran-lang.discourse.group/u/FLNewbiee)\
**Post date:** [September 22, 2022, 8:59am UTC](https://fortran-lang.discourse.group/t/documenting-variable-declaration-and-setting/4383/1 "2022-09-22T08:59:02Z")

</div>

The info found on the current site is a little poor.

It would be very helpful to add a special section about **variable declaration** and **setting** , presenting **all** possible ways to declare and set, for example, a real variable despite of being best practice or not, or with specific compiler support although hints would be added.

One goes through the `Learn` section and has to search to the web for additional info, too.

---

<div class="post-metadata">

**Author:** ![gnikit](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/gnikit/32/1213_2.png) [@gnikit](https://fortran-lang.discourse.group/u/gnikit)\
**Post date:** [September 22, 2022, 9:30am UTC](https://fortran-lang.discourse.group/t/documenting-variable-declaration-and-setting/4383/2 "2022-09-22T09:30:20Z")

</div>

So what would you say is missing from the existing tutorial [Variables — Fortran Programming Language](https://fortran-lang.org/en/learn/quickstart/variables/). Could you be a bit more specific?

As for information that is compiler specific, I am not aware of any differences declaring and setting variables between the major compilers for Modern Fortran, although I will admit that I don’t closely follow all the available compiler extensions to the standard.

Ultimately however, compiler vendors are responsible for maintaining the docs for their compilers.

---

<div class="post-metadata">

**Author:** ![FLNewbiee](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/flnewbiee/32/2155_2.png) [@FLNewbiee](https://fortran-lang.discourse.group/u/FLNewbiee)\
**Post date:** [September 22, 2022, 10:26am UTC](https://fortran-lang.discourse.group/t/documenting-variable-declaration-and-setting/4383/3 "2022-09-22T10:26:54Z")

</div>

Hello Giannis (Γιάννη),

For example:

Some ways through a real number can be declared and initialised are:

```fortran
use, intrinsic :: iso_fortran_env, only: sp=>real32, dp=>real64, qp=>real128

real :: r ! default
real(n) :: rn ! where n: 4|8|10|16
real(kind=n) :: rkn ! where n: 4|8|10|16
real(cc) :: rcc ! where cc: sp|dp|qp

r = 1 ! integer value coerced to real (not suggested)
rn = 1.
rkn = 1._n ! where n: 4|8|10|16
!rkn = 1_10 ! Wrong
rcc = 1._sp

```

This is a very simple example and not completed.

Perhaps, the best way is to academically interpret the Fortran technical specification by integrated practical examples. _Note: Examples should not have semantics not yet taught._

The sections `Setting up your OS` and `Building programs` are **very helpful** although they are simple as required. One has to search on the web for additional info which is totally accepted since both sections are auxiliary to Fortran.

`Quickstart tutorial` should have, at least, links per paragraph to the corresponding chapter of the _Fortran Language Manual_ for more info.

---

<div class="post-metadata">

**Author:** ![gnikit](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/gnikit/32/1213_2.png) [@gnikit](https://fortran-lang.discourse.group/u/gnikit)\
**Post date:** [September 22, 2022, 11:28am UTC](https://fortran-lang.discourse.group/t/documenting-variable-declaration-and-setting/4383/4 "2022-09-22T11:28:38Z")

</div>

The Quickstart Tutorials offered by Fortran-lang, at least at this point, are exactly what’s on the label, short & quick demos to get someone to start using Fortran. I wouldn’t treat them as a complete, academic, learning resource. There are many great books and courses that aim to do just that [Learn — Fortran Programming Language](https://fortran-lang.org/en/learn/#:~:text=the%20Fortran%20Intrinsics-,Other%20Resources,-On%20the%20web).

Now, for the specific demo you posted. I think it is a big hint to the user that `iso_fortran_env` offers named constants with names `INT8`, `INT16`, `INT32`, `INT64`, `REAL32`, `REAL64` and `REAL128`. Just by looking at a single such name it should be clear to the user that these constants are not interchangeable and hence doing `1._real32` and `1._4` are two different things.

Given that understanding kinds in Fortran is not usually an entry level problem, this entire conversation has been deferred for the later section [Floating Point Numbers — Fortran Programming Language](https://fortran-lang.org/en/learn/best_practices/floating_point/). In that section you will also find a link to the great blog post from @sblionel “It Takes All KINDs” that goes into even more details.

> [@FLNewbiee](#):
>
> `Quickstart tutorial` should have, at least, links per paragraph to the corresponding chapter of the _Fortran Language Manual_ for more info.

I don’t think that is realistically possible for a few reasons. There is no available free copy of the Fortran Standard. The standardisation, like many other languages (C,C++) is done via ISO and hence you have to purchase the document from them [ISO/IEC 1539-1:2018 - Information technology — Programming languages — Fortran — Part 1: Base language](https://www.iso.org/standard/72320.html). You can find drafts to the Standard online and that is what most of us use.

Secondly, I would invite you to have a read of the Fortran Standard (or a draft). It is a technical document, it is not meant to be consumed by the average user, much less be part of a quickstart tutorial to the language. Providing references to the Standard would probably cause only confusion to a beginner.
