Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7051349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:15:11+00:00 2026-05-28T03:15:11+00:00

To initialize and assign value to arrays in Fortran we do as the following:

  • 0

To initialize and assign value to arrays in Fortran we do as the following:

Initializing:

real(kind=8):: r(3,4)
...
r(:,:) = 0.0_8

what if we use only

real(kind=8):: r(3,4)
...
r = 0.0_8

and what if we do as:

real(kind=8):: r(3,4)
...
r = 0

also for situation such as:

real(kind=8):: r(3,4), q(3,4), p(30,40)
...
q = 0
r = q
r = p(1:3,21:24)

we prefer to do as:

real(kind=8):: r(3,4), q(3,4), p(30,40)
...
q = 0.0_8
r(:,:) = q(:,:)
r(:,:) = p(1:3,21:24)

we are not sure so hope you provide us some reasons for each one you prefer.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:15:11+00:00Added an answer on May 28, 2026 at 3:15 am

    Do you think that “kind=8” means 8 bytes? That isn’t true for all compilers. The maximum portability is achieved using the selected_real_kind intrinsic to define a kind value:

    integer, parameter :: DRK = selected_real_kind (14)
    

    Of some of the options that you list, I prefer
    r = 0.0_8, or better r=0.0_DRK.
    This defines the entire array. There is no need to designate array sections in this case, since you are calling out the entire array: r (:, :). Steve Lionel has a discussion of why trying to make arrays obvious with “:” isn’t a good idea — there are differences between array and array (:). As an argument, the first has it declared dimensions, while the second always begins at 1 — see http://software.intel.com/en-us/blogs/2008/03/31/doctor-it-hurts-when-i-do-this/

    Since r is real, r=0 implies a conversion. For the value zero this almost certainly doesn’t matter, but it could make an important difference with other values. e.g.,

    r = 3.1415927654
    

    and

    r = 3.141592654_8
    

    will give different values to r because the constants are different, the first being converted to single precision before the assignment.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do I assign a value to another class's initialize parameter in Ruby class
Is it possible to assign a value to an instance variable during an initialize
When initialize an entity framework context. One is to initialize at class level, such
To initialize an int array with all zeros, do I need to use: int
Without initialization how is it possible to assign values to arrays? string[] s={all,in,all}; I
Why the compiler gives me an error when I don't initialize a value to
I am unable to assign a value to a virtual attribute in the after_initialize
I want to initialize JavaScript array value from c# in asp.net application. I have
To initialize variables for a certain computation I have to assign them values from
How can I allocate memory for a struct pointer and assign value to it's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.