Fortran FORTRAN 95 Problem - junk error

  • Thread starter Thread starter Diracster
  • Start date Start date
  • Tags Tags
    Error Fortran
AI Thread Summary
The discussion revolves around a FORTRAN 95 coding issue related to a 3D Ising model simulation. The user initially encounters a "junk error" due to incorrect syntax in the ELSE IF statement, which is resolved. However, after modifying the code, they face a new problem where the program writes out coordinates that should not be outputted, despite the expected conditions regarding spin values. The user seeks clarification on both the original error and the logic of the modified code to ensure it functions as intended. The conversation highlights common pitfalls in FORTRAN syntax and logic when handling multidimensional arrays.
Diracster
Messages
3
Reaction score
0
I have a 3D ising model simulation, what i am trying to do is look up each column in the array and if all the values of that column are -1 then i wish to write the i and j coordinates of that column to a file. the section of code I am having problems with is:

OPEN (10, FILE='holes.dat')
DO i=1,x
DO j=1,y
DO k=1,z
IF (s(i,j,k)>0) THEN
EXIT
ELSE IF (k=10) THEN
WRITE (10,*) i, j
END IF
END DO
END DO
END DO
CLOSE (10)

My compiler is giving me the error:

isingmodel8.f95:163.19:

ELSE IF (k=10) THEN
1
Error: Unexpected junk after ELSE statement at (1)

Basically i would like to know why i am getting this error and also if you think that my code will do what i want it to or if there is a better way of doing it. Any help is much appreciated!

Thanks
 
Technology news on Phys.org
ok so i have fixed the junk error and modified the code slightly, but now i am having the problem that it is writing out every coordinate when i know it shouldn't be. I have a layer of up spins (=1) in the middle of two layers of down spins (=-1) so at the start i would expect the code not to write out any i,j coordinates yet it still rights out all but (4,5). The new code is as follows:

OPEN (10, FILE='holes.dat')
DO i=1,x
DO j=1,y
DO k=1,z
IF (s(i,j,k).GT.0) EXIT
IF (k==z) THEN
WRITE (10,*) i, j
END IF
end do
END DO
END DO
CLOSE (10)
 
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
5
Views
5K
Replies
12
Views
2K
Replies
4
Views
2K
Replies
8
Views
1K
Replies
20
Views
4K
Replies
17
Views
6K
Replies
3
Views
2K
Replies
7
Views
3K
Back
Top