|
|
### Code formating
|
|
|
|
|
|
To unify everyones editor settings we agreed on a ***3 spaces indent*** for all of FLEUR.
|
|
|
|
|
|
### Passing arrays to functions
|
|
|
|
|
|
Fortran offers severals ways to pass arrays to functions. We recommend using either shape-assumed arrays:
|
|
|
|
|
|
```fortran
|
|
|
real, intent(in) :: x(:,:)
|
|
|
```
|
|
|
or allocatable arrays
|
|
|
```fortran
|
|
|
real, intent(in), allocatable :: x(:,:)
|
|
|
```
|
|
|
|
|
|
Due to fortrans legacy you can also often find statements like this(***not recommended***):
|
|
|
```fortran
|
|
|
real, intent(in) :: x(n_x,n_y)
|
|
|
```
|
|
|
This is ***not recommended***, because it can be (and often is) used to change the rank and size of the array during the call. Consider this small example and try to predict the output:
|
|
|
```fortran
|
|
|
program main
|
|
|
implicit none
|
|
|
real :: x(3,4)
|
|
|
integer :: i
|
|
|
|
|
|
x = reshape([(i,i=1,12)], [3,4])
|
|
|
call f(x)
|
|
|
contains
|
|
|
subroutine f(x)
|
|
|
implicit none
|
|
|
real, intent(in) :: x(10)
|
|
|
write (*,*) x
|
|
|
end subroutine f
|
|
|
end program main
|
|
|
```
|
|
|
|
|
|
This style is unintuitive and confusing to everyone who tries to understand your code. |
|
|
\ No newline at end of file |