[net.lang] Bet you can't get this problem!

sth@rayssd.UUCP (Stephen T. Hirsch) (07/30/85)

Now that I've got your attention, I'd like to ask if anybody has ever had
any experience with reading a Vax VMS fortran carriage control file with
Vax-11 C.  I want to read in one line at a time, and every line is of a
varying length.  I think this pretty much precludes using fortran i/o routines,
as I haven't figured out how to input varying length strings in fortran (I
could be wrong, of course!).  Currently, when I read the line in in C, the
first column is skipped, which contains vital control data for the program
(the program was originally written in Whitesmith C, and some workaround
succeeded).

I have nothing to offer any assistor except my undying gratitude.  Any sug-
gestions or clues or hints will be greatly appreciated.  Many thanx in ad-
vance.

Steve Hirsch,		{allegra, decvax!brunix, linus, ccieng5}!rayssd!sth
Raytheon Co,		 Submarine Signal Div., Portsmouth, RI

tp@ndm20 (08/02/85)

>Vax-11 C.  I want to read in one line at a time, and every line is of a
>varying length.  I think this pretty much precludes using fortran i/o routines,
>as I haven't figured out how to input varying length strings in fortran (I

You can do it if you know the maximum  length (which  you probably do
if it is a file with carriage control).   Note that  this is standard
Fortran 77, not VMS specific,  though of  course the carriage-control
problem is.  

      SUBROUTINE READREC(STRING,UNIT)
      CHARACTER STRING*80
      INTEGER UNIT
      READ(UNIT,'(A)')STRING
      RETURN
      END

Not knowing anything about vax-11 C, I'm not sure  the proper calling
sequence for this routine from C, but I'm sure it can be done.  

Of course, if you have control over the program writing the files the
simplest thing to do would probably be  to put CARRIAGECONTROL='LIST'
in the open  statement for  the output  file, and  thus avoid FORTRAN
carriage-control altogether.

Terry Poot
Nathan D. Maier Consulting Engineers
(214)739-4741
Usenet: ...!{allegra|ihnp4}!convex!smu!ndm20!tp
CSNET:  ndm20!tp@smu
ARPA:   ndm20!tp%smu@csnet-relay.ARPA

hopp@nbs-amrf.UUCP (Ted Hopp) (08/10/85)

> Now that I've got your attention, I'd like to ask if anybody has ever had
> any experience with reading a Vax VMS fortran carriage control file with
> Vax-11 C.  I want to read in one line at a time, and every line is of a
> varying length. I think this pretty much precludes using fortran i/o routines,
> as I haven't figured out how to input varying length strings in fortran (I
> could be wrong, of course!).  Currently, when I read the line in in C, the
> first column is skipped, which contains vital control data for the program
> (the program was originally written in Whitesmith C, and some workaround
> succeeded).

First of all, there is a simple way of reading variable length records in
DEC Fortran using the 'Q' format indicator.  The following fragment
illustrates the idea:

	character*80 line
	integer i

	read (6,1000) i,line(:min(i,len(line)))
1000	format (Q,A)

A 'Q' field in a format statement transfers a count of the remaining
characters in the line into the next variable, which must be an integer.
I don't remember whether 'Q' is standard Fortran 77 or another DEC-ism.

I can't help you in reading the file in C, not knowing DEC's C compiler.
If you don't mind loosing the carriage control attribute for the file
(I don't mean loosing the first byte of data!), take a look at the
convert utility, especially the /FDL qualifier.  You can create an
FDL description once for vanilla (no carriage control attribute),
variable length, sequential files and then say:

	convert/fdl=<fdlfile>   <data file>

(I think this is how it all goes.  I don't have any manuals here at home.)

Hope this helps.

Ted Hopp	{seismo,umcp-cs}!nbs-amrf!hopp

-- 

Ted Hopp	{seismo,umcp-cs}!nbs-amrf!hopp