For Programmers: Free Programming Magazines  


Home > Archive > Fortran > October 2006 > How to use syscall in Fortran90/95?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How to use syscall in Fortran90/95?
crazyFritz

2006-10-24, 8:01 am

Ciao,

does anybody know how to use syscall() in Fortran90/95?

Best regards,
crazyFritz

Elijah Cardon

2006-10-30, 7:15 pm


"crazyFritz" <crazyFritz@gmail.com> wrote in message
news:1161697795.901543.223270@h48g2000cwc.googlegroups.com...
> Ciao,
>
> does anybody know how to use syscall() in Fortran90/95?
>
> Best regards,
> crazyFritz

I created an executable tja1 in the same directory as the caller:
program caller
syscall(tja1)
end program caller

This doesn't compile, and I think the reason is that my f95 compiler has no
idea what 'syscall' is. How does one make a system call in fortran? EC


meek@skyway.usask.ca

2006-10-30, 7:15 pm

In a previous article, "Elijah Cardon" <invalid@invalid.net> wrote:
>
>"crazyFritz" <crazyFritz@gmail.com> wrote in message
>news:1161697795.901543.223270@h48g2000cwc.googlegroups.com...
>I created an executable tja1 in the same directory as the caller:
>program caller
> syscall(tja1)
>end program caller
>
>This doesn't compile, and I think the reason is that my f95 compiler has no
>idea what 'syscall' is. How does one make a system call in fortran? EC
>
>

It used to depend on the fortran - maybe it still does.
You could look into the manual for a start.
Chris
AeroSpace Ed

2006-10-30, 7:15 pm

Elijah Cardon wrote:

>
> "crazyFritz" <crazyFritz@gmail.com> wrote in message
> news:1161697795.901543.223270@h48g2000cwc.googlegroups.com...
> I created an executable tja1 in the same directory as the caller:
> program caller
> syscall(tja1)
> end program caller
>
> This doesn't compile, and I think the reason is that my f95 compiler has
> no
> idea what 'syscall' is. How does one make a system call in fortran? EC



Elijah, do you have documentation for your compiler? Questions that fall
outside of the Fortran language are going to be handled, rather
specifically, if at all by the individual compiler. A common external
procedure, by the name of 'system' can be found on a number of compilers.
Sometimes its a function call, other times its a subroutine call, sometimes
it can be both. It all depends on your compiler.

Ed

Richard Maine

2006-10-30, 7:15 pm

Elijah Cardon <invalid@invalid.net> wrote:

> program caller
> syscall(tja1)
> end program caller
>
> This doesn't compile, and I think the reason is that my f95 compiler has no
> idea what 'syscall' is. How does one make a system call in fortran? EC


It is not a standard part of the language, but almost all compilers have
something for it, although the exact details vary from compiler to
compiler. It is most commonly called something like system, but even
among compilers that call it that, the details vary. Sometimes it is a
function; sometimes a subroutine; the number of arguments varies.
Because it is compiler-dependent, you'll need to consult the docs for
your particular compiler.

But in any case

syscall(tja1)

isn't going to work even if it does happen to be called syscall. That's
not Fortran syntax. You are probably thinking in C. If it is a
subroutine, you need to use a CALL statement; the "call" is not
optional. If it is a function, you have to evaluate it as part of an
expression - and unlike C, an expression by itself is not a complete
statement.

--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
Elijah Cardon

2006-10-30, 7:15 pm


"AeroSpace Ed" <mimihoohoo@sbcglobal.net> wrote in message
news:6Mx%g.17338$vJ2.9083@newssvr12.news.prodigy.com...
> Elijah Cardon wrote:
>
[looking for a system call][color=darkred]
> Elijah, do you have documentation for your compiler? Questions that fall
> outside of the Fortran language are going to be handled, rather
> specifically, if at all by the individual compiler. A common external
> procedure, by the name of 'system' can be found on a number of compilers.
> Sometimes its a function call, other times its a subroutine call,
> sometimes
> it can be both. It all depends on your compiler.


http://www.billfordx.net/screendumps/fortran2.htm

I substituted 'system' where there was 'syscall' before and my compiler told
me no comprendo. Could a vendor view this as a callback function? EC


crazyFritz

2006-10-30, 7:15 pm

> do you have documentation for your compiler? Questions that fall
> outside of the Fortran language are going to be handled, rather
> specifically, if at all by the individual compiler. A common external
> procedure, by the name of 'system' can be found on a number of compilers.
> Sometimes its a function call, other times its a subroutine call, sometimes
> it can be both. It all depends on your compiler.


Yes I do have a docu, but beside that syscall() is supported nothing is
written.
The problem is that SYSTEM is not working, therefore I'm coming to ask
about syscall().

Best regards,
Thomas

AeroSpace Ed

2006-10-30, 7:15 pm

crazyFritz wrote:

>
> Yes I do have a docu, but beside that syscall() is supported nothing is
> written.
> The problem is that SYSTEM is not working, therefore I'm coming to ask
> about syscall().
>
> Best regards,
> Thomas


Then see Richard's post about using proper Fortran syntax and use a 'call'
statement.

Ed
Richard E Maine

2006-10-30, 7:15 pm

Elijah Cardon <invalid@invalid.net> wrote:

> I substituted 'system' where there was 'syscall' before and my compiler told
> me no comprendo. Could a vendor view this as a callback function? EC


You are making this *FAR* too complicated. The actual issue is, I'm
sure, completely trivial. See my other post. There is nothing
particularly special about system(). It is just like any other function
or subroutine (whichever it is for your compiler). You seem to be trying
to use a special syntax for it. Don't. Use normal Fortran syntax...
which includes the keyword "CALL" for calling a subroutine (if that's
what it is).

Just forget about the syscall thing. Does your compiler document such a
thing? If you are trying to call a random C function that your compiler
hasn't made special provisions for, there are ways to do that, but

1. In any case, C function or not, you have to use Fortran syntax in a
Fortran compiler. You can't drop random C code into it. Or Ada if you or
calling an Ada proceduire. Or anything else. Fortran syntax does not
allow a function invocation as a statement by itself. Really. I cannot
emphasize this enough.

2. There are several extra tricks involved in calling C functions. Yes,
it can be done, but it involves more that I feel like going into here.
It isn't even horribly complicated in this case, but it is at least 10
times harder than what is needed here (particularly as we have a
character argument involved), so I'm rather reluctant to go into that.
When we haven't yet got the syntax of a normal Fortran call statement
down, "retreating" to something 10 times more complicated seems like the
wrong direction.

--
Richard Maine | Good judgment comes from experience;
email: my first.last at org.domain| experience comes from bad judgment.
org: nasa, domain: gov | -- Mark Twain
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com