File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -123,15 +123,28 @@ $ ./a.out
123123 2.00000000
124124 7.00000000
125125```
126- However, you can also define constant values that do not change by defining variables using ` parameter ` , e.g.
126+ However, you can also define constant values that cannot change by defining variables using ` parameter ` .
127+ We are then unable to modify ` parameter ` variables, e.g.
127128``` fortran
128129program example3
129130 implicit none
130131
131132 real, parameter :: pi = 3.14159265
132133
134+ pi = pi + 2.0
135+
136+ print *, pi
137+
133138end program example3
134139```
140+ When compiling this program, this will give an error similar to the following from the ` gfortran ` compiler:
141+ ```
142+ example3.f90:6:3:
143+
144+ 6 | pi = pi + 2.0
145+ | 1
146+ Error: Named constant 'pi' in variable definition context (assignment) at (1)
147+ ```
135148
136149::::::::::::::::::::::::::::::::::::: challenge
137150
You can’t perform that action at this time.
0 commit comments