- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
I'm new in Ifort and I have a little problem with a code, maybe it's a simple problem, who knows but I don't know resolve...
I have a vector with nn data. I need to separate the vector in mm smalls vectors depending of one condition (I know how do that!).
I want that if I change the value of mm the code makes the mm vectors automatically, the problem is I can't image how define the vectors without changing the code structure each time.... Thanks a lot for the help!
I'm new in Ifort and I have a little problem with a code, maybe it's a simple problem, who knows but I don't know resolve...
I have a vector with nn data. I need to separate the vector in mm smalls vectors depending of one condition (I know how do that!).
I want that if I change the value of mm the code makes the mm vectors automatically, the problem is I can't image how define the vectors without changing the code structure each time.... Thanks a lot for the help!
Link Copied
7 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You have not yet stated whether mm has a known value, or is to be determined from one or more conditions, and whether or not nn is divisible by mm.
Thus, while I cannot think of a specific answer, I suggest that you look at the WHERE statement and the WHERE construct, which are described in Fortran reference manuals.
Thus, while I cannot think of a specific answer, I suggest that you look at the WHERE statement and the WHERE construct, which are described in Fortran reference manuals.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
For example, I have a vector with 36 values and I have to separate this vector in 5 parts. But the data in the vector and the separated parts (smalls vectors) change depending of the what I need. In Fortran you MUST declare each vector, but I don't want to change the code every time I change the information. So, I need the code itself read the number of parts and generate the vectors related.
Thanks!
For example, I have a vector with 36 values and I have to separate this vector in 5 parts. But the data in the vector and the separated parts (smalls vectors) change depending of the what I need. In Fortran you MUST declare each vector, but I don't want to change the code every time I change the information. So, I need the code itself read the number of parts and generate the vectors related.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
is the Fortran code going to manipulate the parts?
Are the parts polymorphic? (int(1), int(2),...real(8), char(1), char(2),...user defined type)
When the manipulation is other than byte copy (and, or, cat, ...) then it may be difficult to accomplish what you ask without knowing the type.
However, you can pass field start, end for character field mapping (or array population should these vectors contain numeric data).
character(MAX_CHARS_IN_VECTOR) :: Vector ! you choose max size
type FieldPosition
integer :: iFrom, iTo ! 0 == not mapped
end type FieldPosition
...
type(FieldPosition) :: Field(MAX_FIELDS) ! you choose max fields
CALL GetFields(Field, MAX_FIELDS) ! populate array from header in file of data
...
CALL ReadVector(Vector, MAX_CHARS_IN_VECTOR)
do I=1,MAX_FIELDS
if(Field(I)%iFrom == 0) exit
CALL DoSomethingWithField(Vector(Field(I)%iFrom:Field(I)%iTo))
end do
Are the parts polymorphic? (int(1), int(2),...real(8), char(1), char(2),...user defined type)
When the manipulation is other than byte copy (and, or, cat, ...) then it may be difficult to accomplish what you ask without knowing the type.
However, you can pass field start, end for character field mapping (or array population should these vectors contain numeric data).
character(MAX_CHARS_IN_VECTOR) :: Vector ! you choose max size
type FieldPosition
integer :: iFrom, iTo ! 0 == not mapped
end type FieldPosition
...
type(FieldPosition) :: Field(MAX_FIELDS) ! you choose max fields
CALL GetFields(Field, MAX_FIELDS) ! populate array from header in file of data
...
CALL ReadVector(Vector, MAX_CHARS_IN_VECTOR)
do I=1,MAX_FIELDS
if(Field(I)%iFrom == 0) exit
CALL DoSomethingWithField(Vector(Field(I)%iFrom:Field(I)%iTo))
end do
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks!
Fortran IS going to manipulate the parts.
The parts will be real or integer
But the problem still exists! You must wrote the vector and set up the code every time. :(
Fortran IS going to manipulate the parts.
The parts will be real or integer
But the problem still exists! You must wrote the vector and set up the code every time. :(
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So, polymorphism will not suffice. I am afraid that Fortran will not come endowed with the clairvoyance that you desire for many years to come.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I suggest a design a vector consisting of an unknown number and sequence of previously defined types. The types contained within the vector have a type code. You also define the operators for these types. This can be done with F2003 features. What you cannot have is an unknown type (unless that type brings in the operator functions). This potentially can be done with a DLL (shared library). This is similar to having a free formatted file where variable length record (vector) contains {type ID}{type data}{type ID}{type data}...
Jim Dempsey
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Perhaps katrinastone could post a diagram of what is desired and pseudo code of the operations desired.
Jim Dempsey
Jim Dempsey

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page