two pointers

Hi everyone,

In my program (a big model) there are two pointers profiles%p(:), and coef%rfp_p(:), both are defined in the derived type data.

In one subroutine coef%rfp_p(:) = pres (which is read from the input file),

In the main program, after the allocate(profiles%p), there is
profiles%p(:) = coef%rfp_p(:)
but profiles%p can not get the data from coef%rfp_p, I printed out both sides, left is always 0.0, while the right side has correct value.

as pointers, I thought I could do these things:
a: profiles%p = coef%rfp_p
b: profiles%p => coef%rfp_p
c: profiles%p(:) =coef%rfp_p(:)
d: profiles%p(1:nlevels) = coef%rfp_p(1:nlevels)
e:
do ii = 1, nlevels
profiles%p(ii)=coef%rfp_p(ii)
end do

I tried these a,b,c,d,and e cases, and printed out the both side values. Then I found in a and c cases, profiles%p are always 0.0; For b case the model crashed because of signal 11. For d, the values of profiles%p for all of the dimenstion is equal to the last value of coef%rfp_p. Only in e case I got what I should have: the real value from coef%rfp_p.

As our computer adviser said only in e the compiler does not make any mistake. While in my model there are many places using the profiles%p, so I don’t want to modify everywhere. Is there simple way to make this done? I doubt there is some thing can be done with the compiler, so any ideas? thanks you all in advance.

Efortin

Hi,

We need a little more information. Which version of the compiler are you using? We’d like to see also the actual way coef and profiles are declared and allocated. If you could put together a little working code snippet, that would be great.

Hi Efortin,

Can you post or send to PGI Customer Support (trs@pgroup.com) a reproducing example. We’re not positive what’s wrong but given your information if sounds like a compiler issue, but we’ll need a full example to make sure.

Thanks,
Mat

Hi Mat and brentl,

thank you very much for reply, which is very supportive. I will try to make the complicated things simple and easily understandable.

the compiler I am using is Version 11.7, and I run this model in a Linux cluster. Also the same model is running in another IBM machine, from where we moved the model.

coef’s declaration:(I put the part for the rfp_p)
type (rttov_coef), allocatable :: coef(:)
allocate (coef(nsensors) ,stat= alloc_status(6)) (nsensors is the dimenstion)
here is some information about type rttov_coef
Type rttov_coef


Real(Kind=jprb), Pointer :: rfp_p(:)


End Type rttov_coef


Similarly for profiles, here it is
type( profile_type ), allocatable :: profiles(:)
allocate(profiles(NOBTOV) , stat= alloc_status( 9)) (NOBTOV is the dimension for profiles)
do jo = 1, NOBTOV
allocate( profiles(jo) % p ( coef(no_id) % nlevels ) ,stat= alloc_status(14)) (here coef(no_id)%nlevels is the dimension of profiles%p
end do
for type profile_type, here it goes:
Type profile_type

Real(Kind=jprb), Pointer :: p(:)

End Type profile_type

I don’t know if this information is enough for you.

Your suggestion is highly appreciated,

thanks,

Efortin

Again,

for a reproducing example, in fact I made some simple example just using profiles%p and coef%rfp_p, it is normal. Also for coef$rfp_p it is from a RTTOV package, which have more than 50 subroutines. I don’t know how to make an example for you?
While once in my model the problem is there. I really have no idea what to do with this problem. Any ideas?

thanks,

Efortin

Hi Efortin,

I wonder if it’s as simple as needing to add the flag “-Mallocatable=03” to use F2003 allocatable semantics? Can you give it a try?

Thanks,
Mat

Hi Mat,

I tried “-Mallocatable=03”, it did not improve. By the way, for profiles%p it is allocated in one subroutine, while for assignment it is in another subroutine, will it make any problem?

Thanks,

Efortin

Hi Efortin,

By the way, for profiles%p it is allocated in one subroutine, while for assignment it is in another subroutine, will it make any problem?

If profiles is a module variable or passed in to each routine, then, no, this shouldn’t matter.

As for the cause of this issue, we’re not sure and unfortunately need a reproducing example to tell. Can you send the full source to PGI Customer Support (trs@pgroup.com)?

Thanks,
Mat

Hi Mat,

For the reproducing example it is quite difficult to make it, and my computer adviser and me made different examples: they all work nomarlly, only in my model there is problem. Also I can not give you the whole model because it is big and there are two packages with licence involved.

My computer adviser asked me to rebuild the code, and I probably will do this, when I find the real problem I will let you know, I guess it will take a while since I need to finish something else also.

thanks a lot,

Efortin