Skip to content

Commit

Permalink
added error message when trying to alter a parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
theabro committed Dec 2, 2024
1 parent 900449f commit fcb2bf3
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion episodes/02-basics.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,28 @@ $ ./a.out
2.00000000
7.00000000
```
However, you can also define constant values that do not change by defining variables using `parameter`, e.g.
However, you can also define constant values that cannot change by defining variables using `parameter`.
We are then unable to modify `parameter` variables, e.g.
```fortran
program example3
implicit none
real, parameter :: pi = 3.14159265
pi = pi + 2.0
print *, pi
end program example3
```
When compiling this program, this will give an error similar to the following from the `gfortran` compiler:
```
example3.f90:6:3:
6 | pi = pi + 2.0
| 1
Error: Named constant 'pi' in variable definition context (assignment) at (1)
```

::::::::::::::::::::::::::::::::::::: challenge

Expand Down

0 comments on commit fcb2bf3

Please sign in to comment.