View Full Version : Fortran: Word input rather than number?
I would like to input a word in the fortran command line rather than a number. For example, if I wanted to exit a program with the word 'exit' how would that be done?
Thanks for the help :D
-Glenn
in the fortran command line
Do you really mean "command line" here, as in "command line parameter". Or are you actually inquiring about reading (and comparing) strings.
I don't think there is a way to access command line parameters in standard fortran (at least up to F95) so I assume you mean the latter.
character(20) name
print "(a$)", 'Enter your name> '
read *, name
if (name == 'uart') print *,'Cool name dude.'
The above works for me in Fortran 95 (the gnu g95 compiler). In earlier Fortran versions you might have to use .EQ. instead of ==
That is exactly what I was looking for. I didn't know how to use words as input for Fortran until now :DDDDDDDDDDDDDD Thank you so much.
-Glenn
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.