From owner-chemistry@ccl.net  Wed Feb 14 16:28:24 1996
Received: from bedrock.ccl.net  for owner-chemistry@ccl.net
	by www.ccl.net (8.6.10/950822.1) id QAA14605; Wed, 14 Feb 1996 16:20:38 -0500
Received: from swan.wcc.wesleyan.edu  for ravishan@wesleyan.edu
	by bedrock.ccl.net (8.7.1/950822.1) id QAA03884; Wed, 14 Feb 1996 16:20:35 -0500 (EST)
Received: from ravishan.its.wesleyan.edu by swan.wcc.wesleyan.edu (AIX 3.2/UCB 5.64/4.03)
          id AA21840; Wed, 14 Feb 1996 16:28:00 -0500
Message-Id: <2.2.32.19960214212021.02e0215c@swan.wcc.wesleyan.edu>
X-Sender: ravishan@swan.wcc.wesleyan.edu
X-Mailer: Windows Eudora Pro Version 2.2 (32)
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Date: Wed, 14 Feb 1996 16:20:21 -0500
To: chemistry@ccl.net
From: "G. Ravishanker" <ravishan@wesleyan.edu>
Subject: Pipes in Fortran



Hi All

        I would like to use pipes in Fortran. Basically, in my C programs, I
open a pipe using popen and it returns a file handle, with which I can do
whatever I do with a file, such as writing a sequence of commands one after
the other. I want to do the same thing in fortran. popen works for a single
command, but I do not know how to access it after that. If I do

        iunit = popen ("/usr/local/bin/wg ")    !open wg program        

        write (iunit,*)'Graph'                  ! I want to ask wg to draw a
graph

iunit is always zero and the subsequent write has no meaning. However,

main ()
{
        FILE *iunit;

        iunit = popen("/usr/local/bin/wg", "w");
        fprintf(iunit,"Graph\n");
        fprintf(iunit,"Curve 1 2\n");
        fprintf(iunit,"Table\n");
        ......
        fclose(iunit);
}

works fine.

        Any help is appreciated.

Ravi


