0

I make this code to solve Runge-Kutta, my compiler does not show anything wrong, but does not give me anything to check if is really correct.

I not sure if the code is OK, but, I use the Debug option and it does not show me anything. It only told me

The program '[1328] Console2.exe' has exited with code 0 (0x0).
Program Runge-Kutta

    INTEGER i, n
    PARAMETER  (n=101,m=101)
    REAL (kind=8) eta(i), psi(i), teta(i)
    REAL (kind=8) k1(i), k2(i), k3(i), k4(i), l1(i), l2(i), l3(i), l4(i)
    REAL (kind=8) f(i), g(i)
    REAL (kind=8) h
-----------------definition of parameters--------------------
PARAMETER (h=0.01)
------------------ initial conditions---------------------
eta(1)= 0.d0
teta(1)= 0.d0
eta(n)= 1
teta(n)= 1
psi(1)= 0.d0

declaración función a evaluar

FUNCTION f(eta(i), psi(i), teta(i))
DO i=1, n
  f= psi(i)
ENDDO
ENDFUNCTION 

FUNCTION g(eta(i), psi(i), teta(i))
DO i=1, n
  g=-(1/2) eta(i) psi(i)
ENDDO
ENDFUNCTION 

obtain values of K

DO i=1, n

    k1(i)= h * f
    l1(i)= h * g

    !k2(n)= h * f(eta(i) + (h/2), psi(i) + (l1(i)/2), teta(i) + (k1(i)/2))
    !l2(n)= h * g(eta(i) + (h/2), psi(i) + (l1(i)/2), teta(i) + (k1(i)/2))

    !k3(n)= h * f(eta(i) + (h/2), psi(i) + (l2(i)/2), teta(i) + (k2(i)/2))
    !l3(n)= h * g(eta(i) + (h/2), psi(i) + (l2(i)/2), teta(i) + (k2(i)/2))

    !k4(n)= h * f(eta(i) + h, psi(i) + l3(i), teta(i) + k3(i))
    !l4(n)= h * g(eta(i) + h, psi(i) + l3(i), teta(i) + k3(i))


teta(i+1)= teta(i) + (1/6)*(k1(i)) !+ 2 * k2(i)+2* k3(i) +k4(i))

psi(i+1)= psi(i) + (1/6)*(l1(i))  !+ 2* l2(i)+2* l3(i) +l4(i))

ENDDO

If(n==100)then
----------------------------------------- archivos DATOS ------------------------------
OPEN(unit=12,file='datos RK.dat')
WRITE(12,*)'TITLE     = "Grid" '
WRITE(12,*)'VARIABLES = "x"'
WRITE(12,*)'"RK"'         ! variable
WRITE(12,*)'ZONE T= "Matrix"'
---------------------------------------- ESCRITURA DE LAS VARIABLES ----------------------------------
DO i=1,n
    WRITE(12,*) teta(i), psi(i) 
END DO
CLOSE(unit=12) 

End Program Runge-Kutta

Conan
  • 11
  • 2
  • Please confirm, you do do not see any output when you run the code? How exactly do you run it? What are you clicking at or which command are you using? – Vladimir F Героям слава Mar 27 '19 at 18:31
  • 1
    What kind of output do you expect? Your program writes everything in a file, not on screen. You got a message telling you it exited without error, now go get your file. –  Mar 27 '19 at 20:30
  • BTW, do not learn `real(8)`, it is [ugly](https://stackoverflow.com/questions/838310/fortran-90-kind-parameter). – Vladimir F Героям слава Mar 27 '19 at 22:03
  • Really apreciate your coments, i'm clicking in a comand say attach, the program don't tell me about any error, but I have more errors, thank I'll ask when I study more how to programing. I think i need more theory. – Conan Mar 29 '19 at 16:52
  • Can you recommended any page, books, site anything to study Fortran? – Conan Mar 29 '19 at 16:57
  • If you want to know the language, the primary resource is the standard: [Here](https://j3-fortran.org/doc/year/18/18-007r1.pdf) is the last free draft of the 2018 revision. Invaluable, if a bit obscure at times. Note, however, that this won't teach you how to *program*. For this you don't want a Fortran book, but a book on computer science, or maybe numerical analysis. –  Mar 30 '19 at 08:42

0 Answers0