×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

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!
  • Students Click Here

*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

Meaning of IMPLICIT REAL*8(A-H,O-Z)

Meaning of IMPLICIT REAL*8(A-H,O-Z)

Meaning of IMPLICIT REAL*8(A-H,O-Z)

(OP)
Dear All,
I have found this notation.
'IMPLICIT REAL*8(A-H,O-Z)'
why we use this instead of
'Implicit none'
Thank you
Niloy

RE: Meaning of IMPLICIT REAL*8(A-H,O-Z)

Well, those are two different things.

Implicit none says that you have to explicitly declare all your variables before using them. If you come up with a new variable in the middle of your source code, the compiler will complain and make you go back and declare it. You can declare variable whatever type and size you want to, but you have to do it yourself.

Implicit REAL*8(A-H,O-Z), on the other hand, allows you to go the implicit route where you can come up with variables along the way, as needed, without having to declare first. Additionally, all those variables would be REAL*8, which is NOT the default size; default is REAL*4, or simply REAL.

RE: Meaning of IMPLICIT REAL*8(A-H,O-Z)

... and this statement means that all variables with names beginning with either letter of 'a' to 'h' and 'o' to 'z' are declared real*8.

But still, this is poor programming style. 'implicit none' is a very powerful means to avoid typos while coding.

Norbert

The optimist believes we live in the best of all possible worlds - the pessimist fears this might be true.

RE: Meaning of IMPLICIT REAL*8(A-H,O-Z)

(OP)
Thank you both for your reply.
say i have a given value say (8/9)^0.5 and it is fixed.
I want to define it this way,
Real,parameter::x1=(8/9)^0.5

But they are showing that i cannot do this..but why? is my value value contain long significant values?

Niloy

RE: Meaning of IMPLICIT REAL*8(A-H,O-Z)

Is the character ' ^ ' the exponentiation operator nowadays? I thought it was double asterisk.

In any case, you cannot perform an exponentiation operation with a non-integer at compilation time...the compiler is not your running program just yet...you want that kind of value as a parameter? Either calculate it as a regular variable later, or calculate the value once with your calculator or a 3-line fortran program and then hard code the value in your program.

it is just that the PARAMETER statement expects a constant expression, so, it handle most operations, but exponentiation with float seems to be a bit to much to figure out.


RE: Meaning of IMPLICIT REAL*8(A-H,O-Z)

Why would you want to make x1 a parameter?
For whatever you want to do in your program

real*8 x1
...
x1 = (8/9)**0.5

will do the same job.
'paramater' means that (1) you cannot edit this variable in your code and (2) variable name and variable value are equivalent to each other. As far as I know, the compiler would include the value into the executable whenever the name is referenced.

The usage - at least the only real sensible usage - is to name paramters to control certain features of your prog.

Example:
Say, the user shall be able to select the language of the message prompts. so You will have a variable iLanguage that may show the values as follows

iLanguage = 1 means English
iLanguage = 2 means French
iLanguage = 3 means German
iLanguage = 4 means Italian
...
...

In your code you will have to do the selection like

CODE

select case (iLanguage)
   case (1)
      output in English
    case (2)
      output in French
    ....
    ....
end select 

but if you use parameters, then you could have it like this

CODE

integer, parameter :: iEnglish = 1
integer, parameter :: iFrench = 2
integer, parameter :: iGerman = 3
...
... (customer to select language)
...
select case (iLanguage)
    case (iEnglish)
         output in English
    case (iFrench)
         output in French
...
...
(end select) 

So while coding or debugging you do not have to memorize which value indicates which language.

I do not know of any other sensible way to use parameters.



Norbert

The optimist believes we live in the best of all possible worlds - the pessimist fears this might be true.

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