# Confirming understanding of assignments

**URL:** <https://fortran-lang.discourse.group/t/confirming-understanding-of-assignments/2161>\
**Category:** Help\
**Created:** [October 26, 2021, 11:50am UTC](https://fortran-lang.discourse.group/t/confirming-understanding-of-assignments/2161 "2021-10-26T11:50:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![garynewport](https://avatars.discourse-cdn.com/v4/letter/g/898d66/32.png) [@garynewport](https://fortran-lang.discourse.group/u/garynewport)\
**Post date:** [October 26, 2021, 11:50am UTC](https://fortran-lang.discourse.group/t/confirming-understanding-of-assignments/2161/1 "2021-10-26T11:50:10Z")

</div>

Just to confirm my understanding…

```auto
data ifirst /0/

```

would be the equivalent to…

```auto
integer ifirst = 0

```

and not…

```auto
integer ifirst

first = 0

```

Equally…

```auto
DATA DTIMEx, DTMINx, DTMAXx /0.0, 0.0, 0.0/

```

would become

```auto
real dtimex = 0.0
real dtminx = 0.0
real dtmax = 0.0

```

whilst…

```auto
DATA ZH / 1.0081451, 4.003874, 12.0038156, 23., 24.32, &
     & 26.97, 28.06, 32.07, 39.102, 40.08, 55.85, 14.0075257, &
     & 16., 19.99, 6.941/

```

is defining an array with 15 elements, each element assigned the given value; so…

```auto
real zh = (/ 1.0081451, 4.003874, 12.0038156, 23., 24.32, &
     & 26.97, 28.06, 32.07, 39.102, 40.08, 55.85, 14.0075257, &
     & 16., 19.99, 6.941/)

```

Am I correct here?

---

<div class="post-metadata">

**Author:** ![FortranFan](https://avatars.discourse-cdn.com/v4/letter/f/96bed5/32.png) [@FortranFan](https://fortran-lang.discourse.group/u/FortranFan)\
**Post date:** [October 26, 2021, 11:59am UTC](https://fortran-lang.discourse.group/t/confirming-understanding-of-assignments/2161/2 "2021-10-26T11:59:03Z")

</div>

> [@garynewport](#):
>
> ```auto
> data ifirst /0/
> 
> ```
> 
> would be the equivalent to…
> 
> ```auto
> integer ifirst = 0
> 
> ```

Technically your first line is equivalent to the following in that the `SAVE` attribute is implied with `DATA` statements:

```Fortran
integer, save :: ifirst = 0

```

And carry this forward to the rest of your code snippets.

---

<div class="post-metadata">

**Author:** ![garynewport](https://avatars.discourse-cdn.com/v4/letter/g/898d66/32.png) [@garynewport](https://fortran-lang.discourse.group/u/garynewport)\
**Post date:** [October 26, 2021, 12:06pm UTC](https://fortran-lang.discourse.group/t/confirming-understanding-of-assignments/2161/3 "2021-10-26T12:06:05Z")

</div>

Yes, I excluded the `save` in my examples because I always get a comment that it is implied anyway. I will be including the `save`, even if implied, since I agreed with an earlier poster that I should not rely upon implications. 🙂  
Thank you.

---

<div class="post-metadata">

**Author:** ![Arjen](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@Arjen](https://fortran-lang.discourse.group/u/Arjen)\
**Post date:** [October 26, 2021, 12:34pm UTC](https://fortran-lang.discourse.group/t/confirming-understanding-of-assignments/2161/4 "2021-10-26T12:34:50Z")

</div>

In my opinion this is a wise decision: it makes the SAVE attribute explicit. (It is also distinguishes the statement from syntactically but not semantically equivalent statements in C or similar languages)

---

<div class="post-metadata">

**Author:** ![msz59](https://avatars.discourse-cdn.com/v4/letter/m/3d9bf3/32.png) [@msz59](https://fortran-lang.discourse.group/u/msz59)\
**Post date:** [October 27, 2021, 9:28pm UTC](https://fortran-lang.discourse.group/t/confirming-understanding-of-assignments/2161/5 "2021-10-27T21:28:12Z")

</div>

Please note, however, a subtle difference. While the two following lines:

```auto
integer, save :: ifirst = 0
integer :: ifirst = 0

```

do mean exactly the same, the following two:

```auto
integer, save :: ifirst = 0, isec
integer :: ifirst = 0, isec

```

do not. In the first line the `save` attribute is given both to `ifirst` and `isec`. In the second line only `ifirst` is (implicitly) given `save` attribute.
