Query about function result having allocatable component of derived type

Sudesh Chandna, Noida sudeshc@hcl.in
Wed Sep 20 07:01:00 GMT 2006


Hi,

I have a query about function result having allocatable component of
derived type. 
For allocatable function result standard says that "Function result
should be allocated and have defined value on return". Consider
following example:

Function fun
Integer,allocatable::fun(:)
End 

In above example as function result is NOT allocated an error should e
generated by compiler.

Now my question is Does above rule applies to function result of derived
type having allocatable component. Consider following example

Type drv
 Integer::i
 Integer,allocatble::arr(:)
End type drv

Function fun1
 Type(drv)::fun1
 Fun1%i=10
end

Now in above as am assigning 'I' component and status of allocatable
component is NOT allocated. So should compiler generate error for this
as well. 

Kindly revert back asap.

Thanks & Regards,
Sudesh Bhateja

DISCLAIMER:
-----------------------------------------------------------------------------------------------------------------------
The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only. 
It shall not attach any liability on the originator or HCL or its affiliates. Any views or opinions presented in 
this email are solely those of the author and may not necessarily reflect the opinions of HCL or its affiliates. 
Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of 
this message without the prior written consent of the author of this e-mail is strictly prohibited. If you have 
received this email in error please delete it and notify the sender immediately. Before opening any mail and 
attachments please check them for viruses and defect.
-----------------------------------------------------------------------------------------------------------------------



More information about the Fortran mailing list