# The DATA statement

**URL:** <https://fortran-lang.discourse.group/t/the-data-statement/5954>\
**Category:** Uncategorized\
**Created:** [June 10, 2023, 8:01pm UTC](https://fortran-lang.discourse.group/t/the-data-statement/5954 "2023-06-10T20:01:04Z")\
**Posts on this page:** 1\
**Showing post:** 4

<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:** [June 10, 2023, 8:45pm UTC](https://fortran-lang.discourse.group/t/the-data-statement/5954/4 "2023-06-10T20:45:09Z")

</div>

> [@abach5](#):
>
> … are there best alternatives to do the same?

As to “best alternatives”, consider first the predominant uses of `DATA` statement in codes that you will **not** view as “modern fortran”. Such uses will be:

1. Data initialization of what are otherwise **constants** in code, take the value of the mathematical constant **\pi** for example,
2. Data initialization of arrays that have some “heft” and pattern to them which then need to be reused in code.

For the use case #1 above, consider named constant facility in Fortran with the `PARAMETER` attribute.

For the second use case, consider the use of such data objects as module entities instead.

Note the standard semantics **implicitly** imparts the `SAVE` attribute to objects in `DATA` statements:

- named constants with the `PARAMETER` are both immutable and available in program when a program unit containing its definition becomes active, Thus no issue here.
- module entities are also `SAVE` and working with them can be seen as a modern, safer alternative.

---

_[View the full topic](https://fortran-lang.discourse.group/t/the-data-statement/5954)._
