Fortran Programming Silverfrost Error 112

In summary, the user is trying to run a program that was copied from an old book, but when they enter the variables it gives them an error. The user has tried to solve the problem by inserting some WRITE statements, but it still does not work.
  • #1
1
0
I'm new to Fortran, trying to run this program but when I enter the variables it gives me an error 112.

Please help me find where is the mistake. I copied the program from an old book.

DIMENSION S(50),V(50) ! Element stress and velocity
DIMENSION U(51) ! Nodal displacement
! Double arrays for tabular or graph representation of stress discontinuity
DIMENSION X(102),SP(102)
INTEGER J,JP
WRITE(*,*) 'Number of elements N<=50' ! Imput data
READ(*,*) N
WRITE(*,*) 'Number of time steps NT'
READ(*,*) NT
NP=2*N
DO 10 J=1,N ! Initial state of the system at T=O.
S(J)=0.
V(J)=0.
10 U(J)=0.
DX=1./N ! Length of element
DT=DX ! Time increment
DO 20 I=1,NT ! Beginning of time loop
T=I*DT ! Current time
S1=-1. ! Boundary conditions at free end, J=1
V1=V(1)-S1+S(1)
U(1)=U(1)+V1*DT ! Displacement at J=1
DO 30 J=2,N ! Beginning of element loop
V2=0.5*(V(J)+V(J-1)+S(J)-S(J-1)) ! V and S at right border
S2=S(J-1)+V2-V(J-1) ! of the element J-1
U(J)=U(J)+V2*DT ! Displacement at node J
V(J-1)=V1+V2-V(J-1) ! New values of V and S
S(J-1)=S1+S2-S(J-1) ! for element J-1
V1=V2 ! V and S at left border
S1=S2 ! of element J
30 CONTINUE ! End of element loop
V2=0. ! Boundary conditions at fixed
S2=S(N)+V2-V(N) ! end, J=N+1
V(N)=V1+V2-V(N) ! New values of V and S
S(N)=S1+S2-S(N) ! for element J=N
20 CONTINUE ! End of time loop
! To output of stress discontinuity along the rod length
X(1)=0.
X(2)=0.
SP(1)=S(1)
DO 40 JP=3,NP+2
X(JP)=X(JP-2)+DX
SP(JP-1)=S(JP/2)
40 CONTINUE
OPEN(5,FILE='STRESS') ! Element stress vs. rod length at I=NT
WRITE(5,*)'Element stress vs. rod length'
WRITE(5,*)' X S(X)'
WRITE(5,50)(X(JP+1),SP(JP),JP=1,NP)
50 FORMAT(2X,2(E12.5,2X))
OPEN(7,FILE='RESULTS') ! Control results for NT=2*N
WRITE(7,*) 'Control results for NT=2*N'
WRITE(7,*) 'Input data: N=',N,' ','NT=',NT
WRITE(7,*) 'Benchmark: T=2, U(1 )=2, S(N)=-2, S2=-2'
WRITE(7,*) 'Calculated: T=',T,' ','U(1)=',U(1)
WRITE(7,*) 'S(N)=',S(N),' ','S2=',S2
STOP
END ! End of Program

Thank you very much.
 
Technology news on Phys.org
  • #2
Enclose programming code in the [\CODE] tags when posting. This helps preserve the original indenting, and Fortran 77 and older versions are sensitive to having statements start in a particular column.

One of your array variables is outside of its dimensioned limits. About the only thing I can suggest is that you insert some WRITE statements inside the loops to determine where the failure is occurring. This particular problem is best solved running the program and not scanning the source.
 
  • #3
WRITE(*,*) 'Number of elements N<=50' ! Imput data

Above line has spelling error. I don't know if it makes any difference.
 
  • #4
The text after the '!' is treated as a comment. It is stripped out by the compiler before any code generation takes place and does not affect the execution of the program. The error lies elsewhere.
 
  • #5
Seemingly F77, the source for sure lost possible indentation; then, again, F77 is a subset of F90. So, I simply copied and pasted the source above and compiled with every line starting in column 1, it compiled and run...I did not see any error message.

Maybe you can paste exactly the entire output when you run it. I don't know anything about Silverfrost and how it runs program...I rather see you starting a DOS terminal of your own, running the program from the command line and seeing all output there.
 
  • #6
  • #7
Well, like I said, the program compiled and run for me...but I don't know what I am doing and simply punched a couple of numbers.

Upon second review, I can see that if you specify the maximum allowed N of 50, NP turns out 100 and the last loop let's JP go to NP+2 = 102...the index JP-1=101 which is o.k. for SP of length 102; but the index JP/2=51 is not o.k. for S of length 50.
 
Last edited:
  • #8
gsal said:
Upon second review, I can see that if you specify the maximum allowed N of 50, NP turns out 100 and the last loop let's JP go to NP+2 = 102...the index JP-1=101 which is o.k. for SP of length 102; but the index JP/2=51 is not o.k. for S of length 50.

I suspect it doesn't work correctly for any even value of N, since the "last" value of S that is used is never calculated.

It might be doing the wrong thing for odd values of N as well, but we don't know what it's supposed to calculate that's just guessing.
 
  • #9
I see what you mean...the last value in the loop being JP=NP+2 and the index of S being JP/2 = (NP+2)/2 = (2N+2)/2 = N + 1 ...and, you are right, it does not look like the value of S(N+1) is ever calculated...heck, either even or odd N
 

What is "Fortran Programming Silverfrost Error 112"?

"Fortran Programming Silverfrost Error 112" refers to a specific error message that can occur while using the Silverfrost Fortran programming language. It indicates that there is an issue with the source code and the compiler is unable to compile it.

What causes "Fortran Programming Silverfrost Error 112"?

This error can be caused by a variety of factors, such as syntax errors in the code, improper use of language features, or incorrect formatting. It can also occur if the compiler is unable to find necessary files or libraries.

How can I fix "Fortran Programming Silverfrost Error 112"?

The first step to fixing this error is to carefully review your code and check for any syntax errors or incorrect usage of language features. Make sure you are using proper formatting and that all necessary files are included. You may also need to refer to the Silverfrost documentation or seek help from other Fortran programmers.

Can I prevent "Fortran Programming Silverfrost Error 112" from occurring?

While some errors are unavoidable, there are steps you can take to reduce the likelihood of encountering this error. These include properly learning the syntax and features of the Fortran language, using good coding practices, and regularly testing and debugging your code.

Is "Fortran Programming Silverfrost Error 112" a common issue?

This error is not uncommon, especially for beginners learning the Fortran language. However, with proper coding practices and attention to detail, it can usually be resolved without too much trouble.

Suggested for: Fortran Programming Silverfrost Error 112

Replies
4
Views
371
Replies
33
Views
2K
Replies
4
Views
1K
Replies
3
Views
1K
Replies
17
Views
4K
Replies
4
Views
1K
Replies
1
Views
695
Replies
2
Views
1K
Replies
1
Views
2K
Back
Top