Languages and Scripting
cancel
Showing results for 
Search instead for 
Did you mean: 

RUNNING A COMMAND IN FOTRAN

 
SOLVED
Go to solution
Highlighted
Henry Chua
Super Advisor

RUNNING A COMMAND IN FOTRAN

Hi guys,


Does anyone know how to run a command in FOTRAN i.e. the same way the statment "system" does in ANSI C. Pls advise.

Thanks!

Best regards
Henry
4 REPLIES 4
Highlighted
Peter Godron
Honored Contributor
Solution

Re: RUNNING A COMMAND IN FOTRAN

Henry,
according to
http://www.docs.hp.com/en/B3908-90003/B3908-90003.pdf
the system(str) command should get you want you need, at least on hp using fortran90.
Highlighted
Arunvijai_4
Honored Contributor

Re: RUNNING A COMMAND IN FOTRAN

Hi Henry,

Here it is,

http://www.codecomments.com/archive271-2005-3-429704.html
System commands only added in Fortran 2003.

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Highlighted
A. Clay Stephenson
Acclaimed Contributor

Re: RUNNING A COMMAND IN FOTRAN

Yes there is a 3F system function in addition to the more common 3C system for C.
Man 3F system for details.
If it ain't broke, I can fix that.
Highlighted
Michael D. Zorn
Regular Advisor

Re: RUNNING A COMMAND IN FOTRAN

We use system(). One way is

character*80 command
....
command = '/usr/local/bin/myprog'
call system(command)

You can also build commands in the program:

command = 'cat ' // someFileName

or even in the argument:

call system('cat ' // someFileName)

The FORTRAN 9000 manual says system() is a libU77 routine. We don't have to invoke a compiler directive, but we do have to link the library (though it may come in automatically). The only linker options I use regularly are

-lfsys -lm