Fortran Fixing Fortran DO Command Errors for Visual Fortran (f90)

  • Thread starter Thread starter zandria
  • Start date Start date
  • Tags Tags
    Fortran
AI Thread Summary
The discussion focuses on resolving errors in a Visual Fortran program related to the DO loop statement. The user initially encounters two errors, which they trace back to the lack of variable declaration for "i." It is emphasized that the "implicit none" statement should remain in the code to enforce explicit variable declaration, preventing potential issues with undeclared variables. Removing this statement may lead to misleading compilations and runtime errors due to misspelled variable names. Properly defining all variables from the start is crucial for maintaining code integrity and avoiding future complications.
zandria
Messages
15
Reaction score
0
I am working with visual Fortran (f90 I believe)

I have the following program and it says that I have 2 errors. I have narrowed it down to having something to do with my loop statement in bold. Is there something wrong that I'm not getting?

program exercise1

implicit none

integer :: limit, f1, f2, f3
read*, limit

f1 = 1
if (limit >= 1) then
print*, f1
end if

f2 = 1
if (limit >= 2) print*, f2

do i= 3, limit
f3 = f1 + f2
print*, f3
f1 = f2
f2 = f3
end do



end program exercise1
 
Technology news on Phys.org
nevermind, figured it out. I did not define "i" as a variable in my list of integers
 
Remove (delete) the statement: implicit none
 
DO NOT REMOVE THE IMPLICIT NONE STATEMENT

Having that in forces the user to explicitly define their variables. Removing that statement to get a program to compile will nearly always cause problems later down the line.

Simply put: fix it right the first time.
 
Without the IMPLICIT NONE, if you mis-spell the name of a variable once, the compiler doesn't catch it for you, as an undeclared variable. Instead, it cheerfully allocates a new variable with that name, which has no connection with the variable you meant to use. Your program compiles "successfully," but when you run it, it either produces incorrect results or crashes with a run-time error that can be very difficult to track down.
 
Thread 'Star maps using Blender'
Blender just recently dropped a new version, 4.5(with 5.0 on the horizon), and within it was a new feature for which I immediately thought of a use for. The new feature was a .csv importer for Geometry nodes. Geometry nodes are a method of modelling that uses a node tree to create 3D models which offers more flexibility than straight modeling does. The .csv importer node allows you to bring in a .csv file and use the data in it to control aspects of your model. So for example, if you...
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...

Similar threads

Replies
12
Views
3K
Replies
13
Views
3K
Replies
4
Views
2K
Replies
8
Views
2K
Replies
5
Views
2K
Replies
17
Views
6K
Back
Top