|
[Sponsors] |
September 10, 2008, 07:28 |
fortran derived type assignment
|
#1 |
Guest
Posts: n/a
|
Hi, probably this is not the best place for such a question but i think that most of you have the right knowledge of fortran (better than me of course) to help me.
I'm writing a genetic algorithm code which makes use of external modules. The code is like the following (i put between quotes "" the not important stuff): PROGRAM example USE external_module IMPLICIT NONE INTEGER(KIND=my_int_kind) :: "integer stuff" REAL(KIND=my_real_kind) :: "real stuff" TYPE(my_der_type) :: type_one,type_two "Allocation of some components of type_one which have the pointer attribute to have variable dimension" CALL initialize_type(type_one) CALL show_me(type_one) type_two=type_one CALL modify_type(type_two) CALL show_me(type_one) END PROGRAM example What actually happens is that after having modified type_two, type_one also is modified. I know that there could be thousands reasons for this (some of them have already been checked) but, what i would know is that if, from what i wrote of my code, there is something wrong which i'm doing with the derived types and that determines the wrong modification. I'm using Compaq Visual Fortran 6.0. Thanks |
|
September 12, 2008, 05:53 |
Re: fortran derived type assignment
|
#2 |
Guest
Posts: n/a
|
Even if anyone has the answer for my question, maybe some of you could be interested in it (which i found in a manual). Also because i have another question.
The assignment: type_two=type_one when the derived type has an allocatable array of pointers as a component, is actually equivalent to type_two=>type_one so it is equivalent to a target assignment and this is why type_one was changing with type_two. Now, the question is: Because i'm going to modify my whole program to handle this, do you know if assigning my derived type component by component (instead of a single =) is going to produce the same result or what i need for it? Thanks |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
second order schemes | marine | OpenFOAM | 67 | April 11, 2022 19:19 |
boundary conditions for simpleFoam calculation | foam_noob | OpenFOAM Running, Solving & CFD | 8 | July 1, 2015 09:07 |
Need help with boundary conditions: open to atmosphere | Wolle | OpenFOAM | 2 | April 11, 2011 08:32 |
Pressure instability with rhoSimpleFoam | daniel_mills | OpenFOAM Running, Solving & CFD | 44 | February 17, 2011 18:08 |
Problem with compile the setParabolicInlet | ivanyao | OpenFOAM Running, Solving & CFD | 6 | September 5, 2008 21:50 |