Re: Most elegant way to read to allocatable array?



glen herrmannsfeldt wrote:
Dan Nagle wrote:

(snip about replacements for UNIT numbers in I/O statements)

I had to stop a repetitious discussion at a recent meeting
about what a newly proposed intrinsic type would be.
Precedent, or the desirability of the lack thereof, got
out of control.


I hadn't thought of it that way before.

C has the FILE type, though normally a FILE* pointer is used.

It is not intrinsic in the way you mean. It is declared in stdio.h
just like any user defined type. FILE is usually a typedef
to a struct, but I believe even that is implementation dependent.

Typedef allows one to give a name to a type, either a new name for
a standard type, or for a struct, union, or enum, that can be used
in the same way as any other type name. In Fortran terms, a struct
typedef would be similar to a defined type without the need to say
TYPE everywhere. The value of a FILE* variable can be passed to
other functions in the usual ways.

I despise the proliferation of types with identical internal representation that this typically generates in C code. It may be object oriented, but it drastically complicates analysis and especially interlanguage operability (not that a typical C programmer cares about that)


----------------------------------------------------------

In PL/I, the equivalent of unit numbers are FILE constants. They are
declared similar to variables, but are constants in the same way that
Fortran unit number are. They can be INTERNAL (local) or EXTERNAL
(global), with the latter being the default. (The name is not necessarily related to the file name, though might be the default
if no other name is specified.) One can, for example,

OPEN FILE(XYZ) OUTPUT STREAM SEQUENTIAL UNBUFFERED TITLE('THIS.OUT');

In another procedure

PUT FILE(XYZ) LIST(X,Y,Z);

FILE variables can be used in the same way that INTEGER variables are
used for unit numbers in Fortran, to pass FILE constants around.

-- glen



--

Gary Scott
mailto:garylscott@sbcglobal dot net

***** 5 Jan: Back from 7 days in Cozumel! *****

Fortran Library: http://www.fortranlib.com

Support the Original G95 Project: http://www.g95.org
-OR-
Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html

If you want to do the impossible, don't hire an expert because he knows it can't be done.

-- Henry Ford
.



Relevant Pages

  • Re: Most elegant way to read to allocatable array?
    ... FILE is usually a typedef ... to a struct, but I believe even that is implementation dependent. ... the equivalent of unit numbers are FILE constants. ... Fortran unit number are. ...
    (comp.lang.fortran)
  • Fortran derived type and C struct passing character
    ... I'm attempting to call a C function from Fortran where the argument is ... a derived type in the Fortran and a GNU defined struct (struct tm in ... and I have it defined as a CHARACTER, ... CALL LOCALTIME(TIME_T, LOCTIME) ...
    (comp.lang.fortran)
  • RE: command for measuring computing time in milli sec.
    ... In a previous article, glen herrmannsfeldt wrote: ... command for calculating the computing time in fortran. ... way to get all the assembler declaration statements in place.) ...
    (comp.lang.fortran)
  • Re: Fortran derived type and C struct passing character
    ... a derived type in the Fortran and a GNU defined struct in the C program. ... I am able to get all variables who's values are obtained in the C passed back to Fortran via the struct/derived type, however, I'm unable to get Fortran to find the length of the character pointer passed back, I'm only getting the single first character. ...
    (comp.lang.fortran)
  • F Edit Descriptor & Blank Interpretation Mode (Was: Parsing TLE data)
    ... "glen herrmannsfeldt" wrote in message ... "The numeric field descriptor Fw.d indicates that the external field ... If the blank interpretation mode is changed during data transfer, it reverts to its previous value whent he data transfer statement terminates. ... The blank interpretation mode is one of several connection modes defined by Fortran 2003. ...
    (comp.lang.fortran)