Re: Most elegant way to read to allocatable array?
- From: Gary Scott <garylscott@xxxxxxxxxxxxx>
- Date: Sun, 21 Jan 2007 18:47:06 GMT
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
.
- Follow-Ups:
- Re: Most elegant way to read to allocatable array?
- From: glen herrmannsfeldt
- Re: Most elegant way to read to allocatable array?
- References:
- Most elegant way to read to allocatable array?
- From: yair999@xxxxxxxxx
- Re: Most elegant way to read to allocatable array?
- From: Beliavsky
- Re: Most elegant way to read to allocatable array?
- From: Richard Maine
- Re: Most elegant way to read to allocatable array?
- From: yair999@xxxxxxxxx
- Re: Most elegant way to read to allocatable array?
- From: Richard Maine
- Re: Most elegant way to read to allocatable array?
- From: Michael Prager
- Re: Most elegant way to read to allocatable array?
- From: Richard Maine
- Re: Most elegant way to read to allocatable array?
- From: Dan Nagle
- Re: Most elegant way to read to allocatable array?
- From: Richard Maine
- Re: Most elegant way to read to allocatable array?
- From: Dan Nagle
- Re: Most elegant way to read to allocatable array?
- From: Richard Maine
- Re: Most elegant way to read to allocatable array?
- From: Dan Nagle
- Re: Most elegant way to read to allocatable array?
- From: Richard Maine
- Re: Most elegant way to read to allocatable array?
- From: Dan Nagle
- Re: Most elegant way to read to allocatable array?
- From: glen herrmannsfeldt
- Most elegant way to read to allocatable array?
- Prev by Date: Re: pointer association with empty targets
- Next by Date: IMSL
- Previous by thread: Re: Most elegant way to read to allocatable array?
- Next by thread: Re: Most elegant way to read to allocatable array?
- Index(es):
Relevant Pages
|