Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Re: Running shell commands in a fortran program
Hi,

Is there a way to call shell commands from within fortran? I currently have
a shell script that has to run a series of programs in sequence, but one of
them uses mpi and there is a lengthy initialization each time it is run, so
it would be quicker to only run this program once but call all of the other
programs from within the fortran program. This would require calling shell
commands from within fortran though- I vaguely remember that this might be
possible, but can't remember how it is done!

Thanks for your help,

Martin




Report this thread to moderator Post Follow-up to this message
Old Post
Martin White
09-18-04 01:56 PM


Re: Running shell commands in a fortran program
"Martin White" <mjw63@cam.ac.uk> wrote in message news:<STU2d.670$%g5.541@newsfe5-gui.ntli.
net>...
> Hi,
>
> Is there a way to call shell commands from within fortran? I currently hav
e
> a shell script that has to run a series of programs in sequence, but one o
f
> them uses mpi and there is a lengthy initialization each time it is run, s
o
> it would be quicker to only run this program once but call all of the othe
r
> programs from within the fortran program. This would require calling shell
> commands from within fortran though- I vaguely remember that this might be
> possible, but can't remember how it is done!

There is no standard way, but most compilers have this functionality,
usually through a procedure called 'system' or something similar
('systemqq' for Compaq Visual Fortran on Windows) -- consult your
documentation. To get a more detailed answer, please specify your
compiler and operating system.

Report this thread to moderator Post Follow-up to this message
Old Post
beliavsky@aol.com
09-18-04 08:58 PM


Re: Running shell commands in a fortran program
Martin White wrote:
> Hi,
>
> Is there a way to call shell commands from within fortran? I currently hav
e
> a shell script that has to run a series of programs in sequence, but one o
f
> them uses mpi and there is a lengthy initialization each time it is run, s
o
> it would be quicker to only run this program once but call all of the othe
r
> programs from within the fortran program. This would require calling shell
> commands from within fortran though- I vaguely remember that this might be
> possible, but can't remember how it is done!
>
> Thanks for your help,
>
> Martin

There are two possibilities. From your problem description, it sounds
like it could be accomplished in the makefile. If I got it wrong then
you can use the system command. Works with intel compilers atleast.


program callsystem
implicit none
!to examine the behaviour of the system command
character (len=100)::cmd
cmd="echo Wake up Neo"
!if u are using ifc compiler use -Vaxlib during compilation
call system(cmd//achar(0))
end program callsystem

$ifc -Vaxlib system.f90
program CALLSYSTEM

8 Lines Compiled

$./a.out
Wake up Neo

$ifc -V
Intel(R) Fortran Compiler for 32-bit applications, Version 7.1   Build
20040309Z
Copyright (C) 1985-2004 Intel Corporation.  All rights reserved.
FOR NON-COMMERCIAL USE ONLY

GNU ld version 2.15
Supported emulations:
elf_i386
i386linux
elf_x86_64
/usr/lib/crt1.o(.text+0x18): In function `_start':
../sysdeps/i386/elf/start.S:98: undefined reference to `main'



hth
raju

Report this thread to moderator Post Follow-up to this message
Old Post
kamaraju kusumanchi
09-19-04 01:56 AM


Re: Running shell commands in a fortran program
Hi,

Thank you both for your replies. I'm using  a Sun machine running Solaris 9
(I think!). The compiler is the standard Sun one, but I know little more
than that. I'll give your suggestions a try and see if there is an
equivalent of the system command.

Cheers,

Martin
<beliavsky@aol.com> wrote in message
news:3064b51d.0409181026.a476c48@posting.google.com...
> "Martin White" <mjw63@cam.ac.uk> wrote in message
news:<STU2d.670$%g5.541@newsfe5-gui.ntli.net>... 
have 
of 
so 
other 
shell 
be 
>
> There is no standard way, but most compilers have this functionality,
> usually through a procedure called 'system' or something similar
> ('systemqq' for Compaq Visual Fortran on Windows) -- consult your
> documentation. To get a more detailed answer, please specify your
> compiler and operating system.



Report this thread to moderator Post Follow-up to this message
Old Post
Martin White
09-19-04 02:01 PM


Re: Running shell commands in a fortran program
"Martin White" <mjw63@cam.ac.uk> wrote in message news:<Wde3d.48$ka1.21@newsfe6-win.ntli.ne
t>...
> Hi,
>
> Thank you both for your replies. I'm using  a Sun machine running Solaris 
9
> (I think!). The compiler is the standard Sun one, but I know little more
> than that. I'll give your suggestions a try and see if there is an
> equivalent of the system command.

Sun f95 provides SYSTEM, but for most uses, SH is the better choice.

Sincerely,
Bob Corbett

Report this thread to moderator Post Follow-up to this message
Old Post
Robert Corbett
09-20-04 09:01 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Fortran archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:15 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.