Fortran on Linux (f2c): NARG() and GETARG() 
Author Message
 Fortran on Linux (f2c): NARG() and GETARG()

I'm porting some fortran programs to linux, using f2c
to convert to the fortran sources to C.
My problem is that the fortran sources rely on microsoft
extensions.

Most extensions, like GETDAT() are easily handled
through f2c.h, but NARGS() and GETARG() are
more difficult.

They are used to get command line info.
Unfortunately, argc and argv are not even passed
as arguments to main(), so I cannot get to these
values at all.

My only option is to get the f2c sources and extend
the call to main(), etc, but this takes a lot of time.

Has anybody else solved this one already?

Thanks,
Guus.



Wed, 18 Jun 1902 08:00:00 GMT  
 Fortran on Linux (f2c): NARG() and GETARG()

Quote:

> I'm porting some fortran programs to linux, using f2c
> to convert to the fortran sources to C.
> My problem is that the fortran sources rely on microsoft
> extensions.

> Most extensions, like GETDAT() are easily handled
> through f2c.h, but NARGS() and GETARG() are
> more difficult.

  I was able to compile a fortran program which includes a

call getarg(i,infile)

so, in principle, it should work.

  I know, not much of a help, but I dont do fortran.

  Oliver



Wed, 18 Jun 1902 08:00:00 GMT  
 Fortran on Linux (f2c): NARG() and GETARG()

Quote:
> I'm porting some fortran programs to linux, using f2c
> to convert to the fortran sources to C.
> ...

You could also port them to linux without converting to C.
In any case, you might find some useful links at
http://studbolt.physast.uga.edu/templon/fortran.html

Hans



Wed, 18 Jun 1902 08:00:00 GMT  
 Fortran on Linux (f2c): NARG() and GETARG()

[About porting MS Fortran programs to f2c on Linux:]

Quote:
> Most extensions, like GETDAT() are easily handled
> through f2c.h, but NARGS() and GETARG() are
> more difficult.
> They are used to get command line info.
> Unfortunately, argc and argv are not even passed
> as arguments to main(), so I cannot get to these
> values at all.

Just how old is your version of f2c? For at least the past few years,
f2c has been translating the main program to a C function called
MAIN__, and providing its own main() as a standard function that
calls f_init(), MAIN__(), f_exit() in that order. Certainly that
function accepts (int argc, char *argv[]) as arguments. I believe
it also saves copies in external linkage variables xargc and xargv,
so NARGS() and GETARG() can easily be implemented. In fact, the
version of libf2c I have here already has getarg_() and iargc_(),
hence my question about the vintage of your f2c.

Quote:
> My only option is to get the f2c sources and extend
> the call to main(), etc, but this takes a lot of time.
> Has anybody else solved this one already?

I'd say yes. If you get the latest version of the f2c sources, you'll
see that the feature you want is already in place.


Wed, 18 Jun 1902 08:00:00 GMT  
 Fortran on Linux (f2c): NARG() and GETARG()

Quote:

> I'm porting some fortran programs to linux, using f2c
> to convert to the fortran sources to C.
> My problem is that the fortran sources rely on microsoft
> extensions.

> Most extensions, like GETDAT() are easily handled
> through f2c.h, but NARGS() and GETARG() are
> more difficult.

> They are used to get command line info.
> Unfortunately, argc and argv are not even passed
> as arguments to main(), so I cannot get to these
> values at all.

> My only option is to get the f2c sources and extend
> the call to main(), etc, but this takes a lot of time.

Try the following.  My copies of f2c (and g77) have no problems with:

      character value*32
      integer howmany, which
      howmany = iargc()
      do which = 1, howmany
        call getarg(which, value)
        print *, 'argument ', which, ' = ', value
      enddo
      end

--




Wed, 18 Jun 1902 08:00:00 GMT  
 Fortran on Linux (f2c): NARG() and GETARG()
Thanks guys, you been most helpful!

My problems are solved now.
I was thrown off by a core dump for a bit, but that was
caused by an extra (i.e. superfluous) argument to getarg().
Silly microsoft extension, allowing a variable arg list...

Ciao,
Guus.



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. getenv, getarg, iargc, system etc with intel fortran compiler

2. HP-UX Fortran 90 getarg

3. GETARG & IARGC in Intel Fortran

4. Using GETARG in Absoft Fortran under MPW

5. getarg/sleep/etime for Visual Fortran

6. HP C/Fortran getarg question

7. MS Fortran PowerStation and "getarg" subroutine

8. FORTRAN getarg and iargc (HP-UX8.05)

9. G77 breaks f2c on Linux?

10. Porting problem with g77 or f2c on Linux

11. Linux Slackware f2c trouble

12. f2c,f77 on Linux

 

 
Powered by phpBB® Forum Software