Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fortran read statement

Status
Not open for further replies.

Travis260

Programmer
Joined
Oct 4, 2004
Messages
5
Location
US
How can I write a read statment that if the user hits enter without entering a new value it will use a defalt value. Here is basically what I think it should be but it does not work. I know it can be done because my Prof. is requiring it on a project.

default = 5.

WRITE(*,*)"enter angle of attack"
READ(*,*) attack
IF(attack ==" ")THEN
AOA == defalt
ELSE
AOA = attack
END IF

Thanks in advance
Travis
 
Change AOA = attack to
Code:
read (attack,*) AOA
 
Try this:

Program test

character*20 attack

default = 5.

write(*,*) 'Enter angle of attack: '
read(*,'(a)') attack
if(attack .eq. ' ') then
aoa = default
else
read(attack,'(f10.2)') aoa
endif

write(*,'(1x,a,f10.2)') 'Result:',aoa

end

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top