Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

running a program using a data file

Status
Not open for further replies.

therukus

Technical User
Mar 31, 2003
1
US
I am using Linux, and after I compile my program, which is supposed to read information from a data file, I don't know what the command is to include the file. What do I type after a.out to include the file?
 
You have to get the filename first. There is an intrinsic called getarg. eg

Code:
      program main
      character*40 arg
      integer i
      intrinsic getarg
      do 10 i = 1, 10, 1
          call getarg (i, arg)
!         check for the last parameter
          if (arg(1:1) .eq. ' ') goto 20
          print *, 'Arg ', i, ' = ', arg
10    continue
20    continue
      stop
      end
Basically use getarg to get the filename and then feed it into the open command to access your datafile.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top