Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

gfortran initialized allocated arrays

Status
Not open for further replies.

zmth

Technical User
Aug 5, 2015
57
PH
if for example array is allocatable say of one dimension and
already allocated then is it automatically set all elements to 0?
I had always been doing

array=0

which i have also seen in the literature of other people doing
In fact i have been doing so for all arrays of any dimensions real or integer
Also to set all values equal to an arbitrary value or number
other than 0 I used

array=value

and also used

array:))=value

and both seemed to work. Are both 'officially' acceptable ? More simply
is

array=value

always guaranteed to work no matter how many dimensions up to max 7
assuming the 'kind' etc. agree etc.
 
Yes, they are both officially accepted; though, it is recommended to go the "array:),:,...)" route for clarity, for you and others reading your code.

To quote a couple of items from "The Zen of Python":
- Explicit is better than implicit.
- Readability counts.
 
So i would assume the compiler is going to do the same with either form and the .exe file will be exactly the same ?
 
Yes it would be exactly the same: it is just for clarity.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top