|
|
Up |
|
|
  |
Author: Jan VorbrüggenJan Vorbrüggen Date: Jul 12, 2006 02:55
> Years ago, Sun's Fortran team considered doing exactly that. The
> team did not agree to that implementation, but it was a serious
> proposal.
>
> The team considered three serious proposals for implementing large
> sequential unformatted records, each supported by about an equal
> number of people. As a result, none of the proposals were approved.
> Had there been only two proposals, one would have won on a simple
> majority vote. Committees are wonderful things.
So what do the current Sun compilers _do_ in this regard?
Jan
|
| |
|
| | 16 Comments |
|
  |
Author: MikeMike Date: Jul 30, 2006 22:59
Mike wrote:
> Hi
>
> I know how to define a derived type. It really simplifies the numbers
> of arguments when passing through subroutines/functions. But it is
> usually defined by users' typing the name & attributes.
> Let's say if I have var_name(n) & var_data(n). Actually n is very
> large, over 200. Do I need to type, which I mean through keyboard, 200
> var_names in the derived type? Is it a problem about dynamic derived
> type?
> thank you in advance.
> Mike
Please neglect the previous one.
Allow me to state it clearer:
|
| Show full article (0.84Kb) |
|
| | 2 Comments |
|
  |
Author: Brooks MosesBrooks Moses Date: Jul 30, 2006 23:40
Mike wrote:
> I would like to have the following setting:
> x%myheader(1)=mydata(1)
> x%myheader(2)=mydata(2)
> x%myheader(3)=mydata(3)
> ...
> x%myheader(n)=mydata(n)
> How do I define the derived type? n is usualy over 200. And I've
> already have arrray of myheader(strings of variable lengths) & mydata.
> thank you.
You can use normal array declaractions in the derived type, like so:
type mytype
character(80), allocatable :: myheader(:)
end type
type(mytype) :: x
allocate(x%myheader(n))
I still don't really understand your question, but hopefully that will
answer it....
- Brooks
|
| Show full article (0.69Kb) |
| no comments |
|
  |
Author: Jan VorbrüggenJan Vorbrüggen Date: Jul 31, 2006 01:59
> Please neglect the previous one.
> Allow me to state it clearer:
>
> I would like to have the following setting:
> x%myheader(1)=mydata(1)
> x%myheader(2)=mydata(2)
> x%myheader(3)=mydata(3)
> ...
> x%myheader(n)=mydata(n)
> How do I define the derived type? n is usualy over 200. And I've
> already have arrray of myheader(strings of variable lengths) & mydata.
If you want to have myheader be strings of variable lenghts, I think you
can't do it easily, because Fortran before F03 doesn't have those easily.
But why would that be required? If you declare myheader, as a component of
x, to be a (character) array, all you would need is the array expression
x%myheader = mydata
and that's it.
Jan
|
| |
| no comments |
|
  |
Author: e p chandlere p chandler Date: Jul 31, 2006 05:41
Mike wrote:
> Mike wrote:
>> Hi
>>
>> I know how to define a derived type. It really simplifies the numbers
>> of arguments when passing through subroutines/functions. But it is
>> usually defined by users' typing the name & attributes.
>> Let's say if I have var_name(n) & var_data(n). Actually n is very
>> large, over 200. Do I need to type, which I mean through keyboard, 200
>> var_names in the derived type? Is it a problem about dynamic derived
>> type?
>> thank you in advance.
>> Mike
> Please neglect the previous one.
> Allow me to state it clearer:
>
> I would like to have the following setting:
> x%myheader(1)=mydata(1)
> x%myheader(2)=mydata(2)
> x%myheader(3)=mydata(3) ...
|
| Show full article (1.31Kb) |
| no comments |
|
  |
Author: MikeMike Date: Jul 31, 2006 18:25
Jan Vorbrüggen wrote:
>> Please neglect the previous one.
>> Allow me to state it clearer:
>>
>> I would like to have the following setting:
>> x%myheader(1)=mydata(1)
>> x%myheader(2)=mydata(2)
>> x%myheader(3)=mydata(3)
>> ...
>> x%myheader(n)=mydata(n)
>> How do I define the derived type? n is usualy over 200. And I've
>> already have arrray of myheader(strings of variable lengths) & mydata.
>
> If you want to have myheader be strings of variable lenghts, I think you
> can't do it easily, because Fortran before F03 doesn't have those easily.
> But why would that be required? If you declare myheader, as a component of
> x, to be a (character) array, all you would need is the array expression
>
> x%myheader = mydata
> ...
|
| Show full article (1.82Kb) |
| 1 Comment |
|
  |
Author: e p chandlere p chandler Date: Jul 31, 2006 20:28
Mike wrote:
> Jan Vorbrüggen wrote:
>>> Please neglect the previous one.
>>> Allow me to state it clearer:
>>>
>>> I would like to have the following setting:
>>> x%myheader(1)=mydata(1)
>>> x%myheader(2)=mydata(2)
>>> x%myheader(3)=mydata(3)
>>> ...
>>> x%myheader(n)=mydata(n)
>>> How do I define the derived type? n is usualy over 200. And I've
>>> already have arrray of myheader(strings of variable lengths) & mydata.
>>
>> If you want to have myheader be strings of variable lenghts, I think you
>> can't do it easily, because Fortran before F03 doesn't have those easily.
>> But why would that be required? If you declare myheader, as a component of
>> x, to be a (character) array, all you would need is the array expression
>>
>> x%myheader = mydata ...
|
| Show full article (2.56Kb) |
| no comments |
|
  |
Author: Jan VorbrüggenJan Vorbrüggen Date: Aug 1, 2006 00:55
What you're trying to do is a form of object-oriented programming, but you're
still unclear about the actual data structures at each level. Building such
data structures is possible with F95, but it's a bit of a pain because you
can't have the same item point at differently structured data (= derived
types), as you would need in order to have a list of owned items for each
persons. In F03, there is support for such data structures in a natural way.
Given that, you need to be more detailed what you really want to do before
one can recommend a data structure for implementation. For instance, you
could have an array or linked list for each type of item, and the references
(e.g., in the owned item list for a person) would be a type indicator and
an index into the array or list. With such a structure, processing would
contain a lot of CASE statement in order to select the right array or list
based on the type indicator.
Jan
|
| |
| no comments |
|
  |
Author: ArnoArno Date: Aug 1, 2006 01:07
I think that what you want is, is to cast the arrays myheader and
mydata into types, and then get rid of the arrays. However, what the
exact definitions of the types are, depend on the (abstract) data
structures of your prolem, as Elliot allready pointed out. Could you
provide this?
> Let's say I have a car, bicycle etc.. Each of them has attributes:
> width,length etc (all of them area REAL*4). So are many persons. So
> it looks like this:
> John%car%width, John%car%length; ... and also bicycle....
> Paul%car%width, Paul%car%length;... and also bicycle....
First, do all the possible things have identical attributes? So, does
bicycle also have a width and a length? If so, you could think of
defining a thing-type:
type thing
real(4) :: length,width
end type
If you know all the possible things a person *might* own on beforehand,
you may want to define a person type like:
|
| Show full article (2.04Kb) |
| no comments |
|
  |
|
|
  |
Author: MikeMike Date: Aug 1, 2006 17:45
Arno wrote:
> I think that what you want is, is to cast the arrays myheader and
> mydata into types, and then get rid of the arrays. However, what the
> exact definitions of the types are, depend on the (abstract) data
> structures of your prolem, as Elliot allready pointed out. Could you
> provide this?
That's the question. After these discussions by you and all the folks
here, I am afraid I still cannot figure out.
>
>> Let's say I have a car, bicycle etc.. Each of them has attributes:
>> width,length etc (all of them area REAL*4). So are many persons. So
>> it looks like this:
>> John%car%width, John%car%length; ... and also bicycle....
>> Paul%car%width, Paul%car%length;... and also bicycle....
>
> First, do all the possible things have identical attributes? So, does
> bicycle also have a width and a length? If so, you could think of
> defining a thing-type:
>
> type thing ...
|
| Show full article (1.70Kb) |
| 1 Comment |
|
RELATED THREADS |
  |
|
|
|
|
|