CFD Online Logo CFD Online URL
Home > Forums > Main CFD Forum

fortran derived type assignment

Register Blogs Members List Search Today's Posts Mark Forums Read

LinkBack Thread Tools Display Modes
Old   September 10, 2008, 06:28
Default fortran derived type assignment
Paolo Lampitella
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


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)


CALL modify_type(type_two)

CALL show_me(type_one)


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.

  Reply With Quote

Old   September 12, 2008, 04:53
Default Re: fortran derived type assignment
Paolo Lampitella
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:


when the derived type has an allocatable array of pointers as a component, is actually equivalent to


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?

  Reply With Quote


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
boundary conditions for simpleFoam calculation foam_noob OpenFOAM Running, Solving & CFD 8 July 1, 2015 08:07
second order schemes marine OpenFOAM 66 October 26, 2014 12:10
Need help with boundary conditions: open to atmosphere Wolle OpenFOAM 2 April 11, 2011 07: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 20:50

All times are GMT -4. The time now is 16:49.