-
-
Save AndreasKuhn-ak/0fbba22c28e57ccef5eadded382a48ba to your computer and use it in GitHub Desktop.
Fortran logistic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
subroutine f(u, r) | |
implicit none | |
real(kind(0.d0)), intent(out) :: r | |
real(kind(0.d0)), intent(in) :: u | |
r = u*(1.d0-u) | |
end subroutine f | |
subroutine fortran_logistic(N, dt, u) | |
integer, intent(in) :: N | |
real(kind(0.d0)), intent(in) :: dt | |
real(kind(0.d0)), intent(out) :: u(N) | |
integer :: i | |
real(kind(0.d0)) :: temp | |
u(1) = 1.d-5 | |
do i=1, N-1 | |
call f(u(i), temp) | |
u(i+1) = u(i) + dt*temp | |
end do | |
end subroutine fortran_logistic |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would recommend to use functions instead of subroutines: