From: MuxaB on
I have a FORTRAN question.

The problems is:

I want to write several variables, arrays and scalars, out to a file.
I want to store the names of these variables in character strings to
be used in the routine that writes the data out. For example, for the
array called PRESSURE(istart:iend), I would store 'PRESSURE' in a
character variable say CHAROUT of type character*10 (the PRESSURE
array dimensions will be stored elsewhere).

The question is: is there a way to convert that character string back
into the variable name? That is, starting with CHAROUT='PRESSURE',
figure out the variable name PRESSURE and use it to write out the
data.
From: dpb on
MuxaB wrote:
....

> The question is: is there a way to convert that character string back
> into the variable name? That is, starting with CHAROUT='PRESSURE',
> figure out the variable name PRESSURE and use it to write out the
> data.

Short Fortran answer is "no"...

--

From: robin on
"MuxaB" <mike(a)flow3d.com> wrote in message news:5c8f6eb4-e0b7-4344-b3ab-7dc23e5ef539(a)z13g2000prh.googlegroups.com...
|I have a FORTRAN question.
|
| The problems is:
|
| I want to write several variables, arrays and scalars, out to a file.
| I want to store the names of these variables in character strings to
| be used in the routine that writes the data out. For example, for the
| array called PRESSURE(istart:iend), I would store 'PRESSURE' in a
| character variable say CHAROUT of type character*10 (the PRESSURE
| array dimensions will be stored elsewhere).
|
| The question is: is there a way to convert that character string back
| into the variable name? That is, starting with CHAROUT='PRESSURE',
| figure out the variable name PRESSURE and use it to write out the
| data.

Closest would be NAMELIST


From: Jovan Cormac on
MuxaB wrote:
> I have a FORTRAN question.
>
> The problems is:
>
> I want to write several variables, arrays and scalars, out to a file.
> I want to store the names of these variables in character strings to
> be used in the routine that writes the data out. For example, for the
> array called PRESSURE(istart:iend), I would store 'PRESSURE' in a
> character variable say CHAROUT of type character*10 (the PRESSURE
> array dimensions will be stored elsewhere).
>
> The question is: is there a way to convert that character string back
> into the variable name? That is, starting with CHAROUT='PRESSURE',
> figure out the variable name PRESSURE and use it to write out the
> data.


There is no way to *automatically* do that in standard Fortran; however,
you can manually set up a construct like this:

SELECT CASE (CHAROUT)
CASE ('PRESSURE')
output_string = PRESSURE ! You might need to preformat here
CASE ('...')
....
END SELECT

WRITE(*,*) output_string


--
-- jovan
From: analyst41 on
On Jun 10, 8:10 pm, dpb <n...(a)non.net> wrote:
> MuxaB wrote:
>
> ...
>
> > The question is: is there a way to convert that character string back
> > into the variable name? That is, starting with CHAROUT='PRESSURE',
> > figure out the variable name PRESSURE and use it to write out the
> > data.
>
> Short Fortran answer is "no"...
>
> --


I think what we are talking about here is metadata. A database for
example has column names and types along with the data and a select *
would give you all the columns along with their names.