Skip to content

Instantly share code, notes, and snippets.

@Leowbattle
Created September 9, 2023 11:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Leowbattle/7ac27c971f2b9c982b10cbf1ebb87ab7 to your computer and use it in GitHub Desktop.
Save Leowbattle/7ac27c971f2b9c982b10cbf1ebb87ab7 to your computer and use it in GitHub Desktop.
Simulation of a simple pendulum in Fortran using the semi-implicit Euler method
program pendulum
implicit none
real :: time, dt, g, l, y, v
integer :: n, i
read (*,*) time, dt, g, l, y, v
n = ceiling(time / dt)
do i=2,n
v = v - (g/l * sin(y)) * dt
y = y + v * dt
print *, y
end do
end program pendulum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment