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

Fortran atan function.In summary, the conversation is about a program that calculates the acceleration and values at each step in a loop using a given formula. The program also prints the final velocity. However, there are some issues with defining certain variables and functions in the program.
  • #1
jhosamelly
128
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
  • #2
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:
  • #3
atan is an intrinsic function.

atan(1.0) is proper syntax
 

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

1. What is Fortran 90?

Fortran 90 is a high-level programming language commonly used in scientific and engineering applications. It was developed in the 1990s as an updated version of the original Fortran language, and it includes features such as modules, pointers, and free-form source code formatting.

2. What is a machine problem in Fortran 90?

A machine problem in Fortran 90 refers to a programming task or assignment that requires the use of the Fortran 90 language. This could include writing a program to solve a specific mathematical problem, creating a simulation, or implementing a particular algorithm.

3. How do I declare variables in Fortran 90?

In Fortran 90, variables are declared using the INTEGER, REAL, DOUBLE PRECISION, or CHARACTER keywords, followed by the variable name and an optional list of dimensions. For example, INTEGER :: x(3) would declare the variable x as an array of three integers.

4. What is the difference between DO and DO WHILE loops in Fortran 90?

In Fortran 90, DO and DO WHILE loops are both used for repetitive tasks. The main difference is that DO loops have a fixed number of iterations, while DO WHILE loops continue as long as a specified condition is true. For example, DO i=1,10 would execute the loop 10 times, while DO WHILE (x < 100) would continue until the value of x is no longer less than 100.

5. How can I read and write data files in Fortran 90?

Fortran 90 has built-in functions for reading and writing data files, such as READ and WRITE. These functions use formatted I/O to specify the format of the data being read or written. Additionally, Fortran 90 also has the OPEN statement for opening files and the CLOSE statement for closing files after use.

Similar threads

  • Programming and Computer Science
Replies
5
Views
3K
  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
2
Views
2K
  • Advanced Physics Homework Help
Replies
3
Views
2K
  • Programming and Computer Science
Replies
12
Views
2K
  • Programming and Computer Science
Replies
20
Views
2K
  • Programming and Computer Science
Replies
2
Views
3K
Back
Top