Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

gfortran initialized allocated arrays

gfortran initialized allocated arrays

gfortran initialized allocated arrays

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


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


and also used


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


always guaranteed to work no matter how many dimensions up to max 7
assuming the 'kind' etc. agree etc.

RE: gfortran initialized allocated arrays

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.

RE: gfortran initialized allocated arrays

So i would assume the compiler is going to do the same with either form and the .exe file will be exactly the same ?

RE: gfortran initialized allocated arrays

Yes it would be exactly the same: it is just for clarity.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close