Previous Page Next Page Contents

generate::Macrofort::setIOSettings -- sets I/O settings

Introduction

Mac::setIOSettings (where Mac:=generate::Macrofort) sets the unit or channel numbers for the input and output of the FORTRAN code generated by Mac::genFor.

Call(s)

generate::Macrofort::setIOSettings(inputf,outputf)

Parameters

inputf,outputf - integers for I/O specifications.

Returns

the void object of domain type DOM_NULL

Side Effects

Resets the I/O settings for the FORTRAN code generated by generate::Macrofort::genFor.

Related Functions

generate::Macrofort::init, generate::Macrofort::genFor

Details

Example 1

Example of "openm" Macrofort Statement.

This example illustrates that one can use the Macrofort global variable for the FORTRAN input unit number or some other choice. The resulting FORTRAN code can read data from different files.

First initialize Macrofort and open the ascii file "test.f":

>> Mac:=generate::Macrofort:
   Mac::init():
   Mac::openOutputFile("test.f"):

Set global FORTRAN I/O settings at 5 and 6 respectively:

>> inputf := 5:  outputf := 6:
   Mac::SetIOSettings(inputf, outputf):

Generate Open statement with input setting at 10 and then at inputf:

>> Mac::genFor(["openm", 10, "toto.data", old,
                ["readm", 10, ["i10"], [j]]]):
   Mac::genFor(["openm", inputf, "toto2.data", old,
                ["readm", inputf, ["i10"], [j]]]):
   Mac::closeOutputFile():
   delete j, old, inputf, outputf:

The output file test.f is:

            open(unit=10,file='toto.data',status='old')
            read(10,2000) j
       2000 format(i10)
            close(10)
            open(unit=5,file='toto2.data',status='old')
            read(5,2001) j
       2001 format(i10)
            close(5)

Example 2

Example of Macro "whilem" Macrofort Statement.

This example uses the Macrofort internal global variable for the FORTRAN output instructions needed in the while-do loop made by the FORTRAN write instruction (via the macro "writem") inside the "whilem" Macrofort instruction.

>> Mac::openOutputFile("test2.f"):
   Mac::genFor(["whilem", abs(a) > eps, ["equal", a, big],
                [["equal", a, a/2.0], ["equal", b,2 ]], 1000]):
   Mac::closeOutputFile():
   delete a, b, big, eps:

The output file test2.f is:

      c
      c     WHILE  (eps < abs(a)) DO <WHILE_LIST> (1)
      c
      c     WHILE LOOP INITIALIZATION
                maxwhile1 = 1000
                nwhile1 = 0
              a = big
      c
      c     WHILE LOOP BEGINNING
       1000 continue
      c
      c     WHILE LOOP TERMINATION TESTS
            if (eps.lt.abs(a)) then
              if (nwhile1.le.maxwhile1) then
      c
      c         NEW LOOP ITERATION
                nwhile1 = nwhile1+1
      c
      c         <WHILE_LIST>
                a = 0.5E0*a
                b = 2
              goto 1000
              else
      c
      c         WHILE LOOP TERMINATION :
      c         BYPASSING THE MAXIMUM ITERATION NUMBER
                write(6,2002)
       2002     format(' maxwhile1 ')
              endif
      c
      c     NORMAL WHILE LOOP TERMINATION
            endif
      c     WHILE LOOP END (1)

See the help-file for Mac::genFor for a more comprehensive list of examples.




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000