Results 1 to 3 of 3
Hi all...
I'm programming in Fortran 77 and i call a external program which receive 3 arguments. This arguments are variables of the fortran code. How can i pass this ...
- 10-22-2009 #1Just Joined!
- Join Date
- Oct 2009
- Posts
- 1
Variables as arguments in Fortran 77
Hi all...
I'm programming in Fortran 77 and i call a external program which receive 3 arguments. This arguments are variables of the fortran code. How can i pass this variables as arguments of the external program (or script), using the 'call system()' subroutine?
Thanks all...
- 10-23-2009 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
Usually you have to dynamically build the command line with all the arguments and store that to a buffer which is passed in turn to the system() call. There are C language calls that will allow you to pass the argument list as a variable length argument list (execl) or an array of arguments (execv), but I don't know if you can call them from Fortran or not.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 10-23-2009 #3Linux Engineer
- Join Date
- Apr 2006
- Location
- Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
- Posts
- 1,117
Hi.
In keeping with a Fortran style, you can write to a Fortran character variable, and pass that to system:
Producing:Code:#!/usr/bin/env bash # @(#) s1 Demonstrate composed string to call system, Fortran. echo set +o nounset LC_ALL=C ; LANG=C ; export LC_ALL LANG echo "Environment: LC_ALL = $LC_ALL, LANG = $LANG" echo "(Versions displayed with local utility \"version\")" version >/dev/null 2>&1 && version "=o" $(_eat $0 $1) gfortran set -o nounset echo FILE=${1-t.f} echo " Data file $FILE:" cat $FILE echo echo " Results:" gfortran -Wall -ffree-form $FILE ./a.out exit 0
Best wishes ... cheers, drlCode:% ./s1 Environment: LC_ALL = C, LANG = C (Versions displayed with local utility "version") OS, ker|rel, machine: Linux, 2.6.26-2-amd64, x86_64 Distribution : Debian GNU/Linux 5.0 GNU bash 3.2.39 gfortran GNU Fortran (Debian 4.3.2-1.1) 4.3.2 Data file t.f: program main integer mark character*12 first, second character*50 command ! As a literal string. call system("echo 'Hello, world.'") ! As a string composed with a format to an "internal file". first = " Hello, " second = "world, and: " mark = 99 write(command,'(a," ",a, " ",a," ",i2," ",a)') "echo '",first,second,mark,"'" print*, "command ", command call system(command) end Results: Hello, world. command echo ' Hello, world, and: 99 ' Hello, world, and: 99Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
We look forward to helping you with the challenge of the other 10%.
( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )


Reply With Quote