[net.lang.f77] strange statements

ebs@mcnc.UUCP (Edward B. Stokes) (02/07/84)

    I am currently trying to implement a data general fortran77
program on a vax750 which is running unix. The program is full of
statements like:

      type"text..."
      encode (variable,statement#) variable1,variable2
      accept"text...",variable

and other strange things that will not compile on our fortran77
compiler (Feldman and Weinberger's "f77"). I would appreciate
any information on this from a knowledgeable fortran person.

    Please mail any pertinent info to

    ...decvax!duke!mcnc!ebs

                           Thanx,
                           Eddie Stokes

phipps@fortune.UUCP (Clay Phipps) (02/11/84)

The statements you cited:

o   ACCEPT
o   TYPE
o   ENCODE
o   DECODE

are common extensions to FORTRAN.  ENCODE and DECODE have been around
since FORTRAN 66 days.  All the above statements are documented
in the DEC VAX FORTRAN manual.  Maybe some VAX/VMS heathen at your site
has a copy.

I am working entirely from volatile memory here,
so be forewarned that this might not be correct to the letter.

ENCODE and DECODE perform conversion between internal representation
of arithmetic data and their external character string denotation.
The order and meaning of the arguments may not be the same
for all FORTRAN compilers supporting these extensions, by the way;
in particular, DEC FORTRAN may not have the same syntax as DG FORTRAN.
Rather than support these intrinsics in FORTRAN 77,
the ANSI committee decided to implement "internal input/output",
which is a more general facility derived (as far as I know)
from PL/I's PUT STRING / GET STRING statements.
Syntactically, internal input/output looks like ordinary READ and WRITE
statements that have a string variable substituted for the unit number.
Conversion to vanilla FORTRAN 77 *ought to* be straightforward.

TYPE and ACCEPT are interactive input/output statements.
I don't know much about them.
I believe that ACCEPT is an interactive READ,
and TYPE is an interactive WRITE.
The strings that are part of the statements are used as prompts, I think.
I don't know if their behavior is so special that they can't be simulated
by READs and WRITEs to whatever FORTRAN unit number is mapped
to UNIX standard input and output.
As the foregoing reveals, I have never used FORTRAN on UNIX,
and I hope things stay that way.

Don't really know why I went into all this detail from fuzzy memory;
I'm sure that Greg "FORTRAN Hacker" Woods probably has really reliable
answers at his fingertips, but what the h*ll....  Good luck.

-- Clay ("I hate FORTRAN") Phipps

-- 
   {allegra,amd70,cbosgd,dsd,floyd,harpo,hpda,ihnp4,
    megatest,nsc,oliveb,sri-unix,twg,varian,VisiA,wdl1}
   !fortune!phipps

woods@hao.UUCP (Greg Woods) (02/13/84)

  I have converted many FORTRAN programs from a hacked-to-run-on-UNIX version
of DEC FORTRAN running on our 11/70 to our VAX 750's running 4.2 and f77.

"ACCEPT" should be changed to "READ(5," , and "TYPE" should be changed to
"WRITE(6," to have the same effect as the original program. ENCODE and
DECODE should be changed to internal file WRITE's or READ's respectively.
This is a tiny bit more complicated than changing ACCEPTs to READs, though,
since only CHARACTER variables are allowed to be internal files in f77.
Examples follow. I am assuming 4 bytes/integer word, but the conversion
is trivial for other word sizes.

    OLD                                |  NEW
    ---                                |  ---
                                       |
    dimension label(4)                 |   character*16 label
                                       |
    .....                              |   ......
                                       |
    encode(16,100,label) var1,var2,..  |   write(label,100) var1,var2,..
                                       |
    .....                              |   ......
                                       |
    decode(16,label,100) var1,var2,..  |   read(label,100) var1,var2,..
                                       |

  Hope someone finds this useful. BTW, I am writing a document on porting
FORTRAN programs from DEC FORTRAN to f77 for our users here. I'd be glad to
post a copy of it to the net when I finish it if there is interest, but I
don't know how long that would be. I'm pretty busy these days and haven't
had much time to work on it.

	       Greg "FORTRAN hacker" Woods
-- 
{ucbvax!hplabs | allegra!nbires | decvax!stcvax | harpo!seismo | ihnp4!stcvax}
       		        !hao!woods