Fortran What Should Be the Values of Ax and Ay in This Fortran 90 Code?

  • Thread starter Thread starter jhosamelly
  • Start date Start date
  • Tags Tags
    Fortran Machine
AI Thread Summary
The discussion revolves around a Fortran program designed to simulate motion under gravitational acceleration. The main focus is on defining the acceleration components, Ax and Ay, using the formula a = -r/r^3 in component form. Participants note the necessity of initializing variables such as Nsteps and n, which are currently undefined in the code. Additionally, there are concerns about the syntax used for defining pi, with a suggestion to use atan(1.0) for proper implementation. The conversation highlights the importance of correctly setting initial x and y values for the simulation to function effectively.
jhosamelly
Messages
125
Reaction score
0
5by0hs.jpg


I have the code.
Code:
program star
implicit none
real (kind=8) :: x
integer :: i

dt=0.001
pi=4*(atan1.0)

do i=1, Nsteps
     t = n*dt
     !calculate acceleration
     ax= 
     ay=...
     !calculate values at next step
     vy=vy+ay*dt
     vx=vx+ax*dt
     x=x+vx*dt
     y=y+vy*dt
end do

print *, "vx= ", vx
     
end program star
What should I put as Ax and Ay??
 
Last edited:
Technology news on Phys.org
like the question says, use a = -r/r^3 in component form... you'll need to start the program with some initial x and y value.

I don't know fortran very well, but it looks like you haven't defined Nsteps or n. Also the syntax for defining pi looks dodgy.
 
Last edited:
atan is an intrinsic function.

atan(1.0) is proper syntax
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...

Similar threads

Replies
2
Views
2K
Replies
1
Views
14K
Replies
8
Views
2K
Replies
4
Views
2K
Replies
2
Views
3K
Back
Top