Thread Closed

Fortran 95!!!!

 
Share Thread Thread Tools
Feb3-09, 05:44 PM   #1
 

Fortran 95!!!!


Does anyone know how to program with Fortan 95? I need some help!
PhysOrg.com
PhysOrg
science news on PhysOrg.com

>> King Richard III found in 'untidy lozenge-shaped grave'
>> Google Drive sports new view and scan enhancements
>> Researcher admits mistakes in stem cell study
Feb3-09, 05:54 PM   #2
 
Recognitions:
Homework Helper Homework Help
Science Advisor Science Advisor
Something specific to F95 or a general intro to Fortran 90?

http://www.cisl.ucar.edu/tcg/consweb.../tutorial.html
Feb3-09, 05:59 PM   #3
 
Something specific:
I'm trying to write a program in Fortan 95. I need to find the distance between 2 points (x1,y1) and (x2,y2) on a Cartesian coordinate plane given by the equation:
d=sqrt[(x1-x2)^2+(y1-y2)^2].
I want to use the points (-1,1) and (6,2).

This is the copy of what I am doing:
program distance
!kathryn, Assignment 2-21, calculate distance between two points.
implicit none
real::x1 !This is the x from the first ordered pair.
real::y1 !This is the y from the first ordered pair.
real::x2 !This is the x from the second ordered pair.
real::y2 !This is the y from the second ordered pair.
real:: d !This is the distance we are trying to find.
write(*,*) 'This program calculates the distance between two points
+ on a Cartesian coordinate plane.'
read(*,*) d
d=sqrt((x1-x2)^2+(y1-y2)^2) !Calculation
read(*,*) 'The distance between any two points ,'(x1,y1)', and ,'(x2,y2)', is ,'d
end


My problem is that when I compile, I get errors. Where am I going wrong?
Feb3-09, 06:03 PM   #4
 
Recognitions:
Homework Helper Homework Help
Science Advisor Science Advisor

Fortran 95!!!!


I don't know f90 but what are the error messages ?
Feb3-09, 06:06 PM   #5
 
Quote by mgb_phys View Post
I don't know f90 but what are the error messages ?
i don't know right off hand, but it's f95.
Feb3-09, 06:10 PM   #6
 
Recognitions:
Homework Helper Homework Help
Science Advisor Science Advisor
Quote by kathrynag View Post
i don't know right off hand, but it's f95.
Theres no real difference, between Fortran90 and Fortran95,
The compiler error should at least tell you which line the problem is on.

Is ^ a new operator in f95 It used to be '**' in f77 ?
Feb3-09, 06:12 PM   #7
 
Ok, well I could try it again. I can't run it on my comp. I'll have to try a different one.
Feb4-09, 12:29 AM   #8
 
Recognitions:
Gold Membership Gold Member
I think there are two bugs:

(1) The exponentiation operator is (**) in F95, not (^)
(2)The read statement before end program should be write instead
Feb4-09, 11:35 AM   #9
 
Quote by Useful nucleus View Post
I think there are two bugs:

(1) The exponentiation operator is (**) in F95, not (^)
(2)The read statement before end program should be write instead
Ok, I'll try those, but I still got errors. Is the last read statement fine other than the write?
Feb4-09, 12:59 PM   #10
 
Recognitions:
Gold Membership Gold Member
Hi kathrynag

It looks like that there are some synatax errors and a logical one actually.

(1) In your code you wrote

Code:
write(*,*) 'This program calculates the distance between two points
+ on a Cartesian coordinate plane.'
The continuation operator in Fortran is "&" not "+", so a valid statement is
Code:
write(*,*) 'This program calculates the distance between two points &
 & on a Cartesian coordinate plane.'
(2) A logical error in this statement:

Code:
read(*,*) d
You are supposed to ask the user to enter the coordinates x1,x2,y1,y2 , not the distance . After all your code should calculate the distance when the user enters the coordinates. So a valid statement should be

Code:
read(*,*) x1, y1, x2,y2

(3) This statment has some syntax erros:
Code:
read(*,*) 'The distance between any two points ,'(x1,y1)', and ,'(x2,y2)', is ,'d
A better one is :
Code:
write(*,*)'The distance between any two points ,',x1,y1,', and ,',x2,y2,', is ,',d
Compare them.

(4) Finally, if you are using fixed format file, make sure that none of the lines is longer than 80 columns. If any is longer, use the continuation operator "&"

Hope that works for you
Feb4-09, 02:44 PM   #11
 
Ok, I'll try those and let you know what happens.
should I do read(*,*) x1,x2,y1,y2 or seperate lines for each variable?
Feb4-09, 05:23 PM   #12
 
Recognitions:
Gold Membership Gold Member
Quote by kathrynag View Post
Ok, I'll try those and let you know what happens.
should I do read(*,*) x1,x2,y1,y2 or seperate lines for each variable?
It is fine as you wrote it.
Feb4-09, 09:04 PM   #13
 
I got it all figured out except for the extension of a line. It works fine if I don't extend a line.
Thread Closed
Thread Tools


Similar Threads for: Fortran 95!!!!
Thread Forum Replies
Help in fortran 77 Programming & Comp Sci 1
Accessing Fortran Modules within a Fortran library from Fortran Programming & Comp Sci 0
Fortran v.s. Visual Fortran Programming & Comp Sci 0
trying to look for a fortran compiler for my windows XP Academic Guidance 6
Fortran Academic Guidance 5