Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

About "if ... then"

brb36641
Beginner
938 Views

Would someone give me instruction about method of "if ... then"?

I wonderwhich codewould be done whenty value will be changed from false to true as follows.

ty = .false.

ty = .true

if (ty) then

write ("true")

else

write("false")

end if

I really want to know which word, true/false, would be out into file.

Please someone help me as soon as possible.

0 Kudos
4 Replies
Les_Neilson
Valued Contributor II
938 Views

I assume the actual code is not what you have written in your original post.

if (ty) then

else

means "if ty is .TRUE. then execute the following statements up to the else."

so ifin the code before the else, you are writing a value "true" to a file then that is the value you should see in the file.

If ty is *not* true then the statements between the else and the endif will be executed.

If you are still having problems then I suggest you post the actual code with a description of the problem.

Les

0 Kudos
hansr
Beginner
938 Views
The code above writes "false", because there is no finalize dot in the line ty = ".true" and ty remains ".false." Hans
0 Kudos
brb36641
Beginner
938 Views

Thank you very much for instructions.

Both instructioins are so helpful for beginer like me.

0 Kudos
Steven_L_Intel1
Employee
938 Views
The code in the original post contains several syntax errors so would not compile (the missing dot is just one of them.) I assume that the actual code looks somewhat different and therefore it's very difficult to know what the actual problem is.
0 Kudos
Reply