Hello,
I have a weird problem with a function returning an instance of a derived type. To make things more simple than my real problem, let say I have a derived type:
type :: A
real :: x
end type A
I have a function :
function genA( x0 ) result( instA)
type(A) :: instA
real :: x0
instA%x = x0
end function genA
and finally a program where I have
type(A) :: mA
mA = genA(4.5)
print *, mA%x
and instead of 4.5 I get 0 or anything mA%x was initialized with before calling genA.
My problem is that I have in my program several derived types that I “construct” like this with no problem, and one where the “constructor” function ( like genA ) does not change anything to the initial value of the data members like for the case just above ( which is not a real case ).
Another point is that the compilation with pgfortran is ok ( but I have this problem when running the program )
Last point : with other compilers ( gfortran and ifort ) , I do not have this problem at all.
I could not write simpler examples than the real one in my program that shows the same behaviour so someone could try to reproduce it. It only happens with one particular derived type in my program.
If my explanation is clear enough and someone has an idea of where I should look at I will be happy !
Thanks in advance.
Marc