Crank-Nicolsan scheme to solve heat equation in fortran programming

Crank-Nicolsan scheme to solve heat equation in fortran programming

I am trying to solve the 1d heat equation using crank-nicolson scheme. And for that i have used the thomas algorithm in the subroutine. Can you please check my subroutine too, did i missed some codes?? Im trying to connect the subroutine into main program and link it together to generate the value of u(n+1,j) and open the output and graphics into the matlab files.

There were no complier errors. So after i complie and run the program, i got run-time error.
Run-time Error:
Error 112, Reference to undefined variable,array element or function result[/UNDEF]

CRANK_NICOLSON ~THOMAS_ALGORITHM- in file crank_nicolsonf.95 at line : q = a(j)/b(j-1)

main - in file crank_nicolson.f95 at line : call thomas_algorithm(a,b,c,d,JI+1,u_new)

 

AttachmentSize
Downloadtext/plain fortrancode.txt2.12 KB
4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

The code posted compiles/runs correctly using the Intel Fortran compiler for Windows and Linux.

The code posted does not match the error. I guess the error originates from matlab which I do not have so I could not produce the error. The code posted calls the thomas_algorithm() routine with the argument “JI” but the error shows when it was compiled/run and the error occurred that the call was made with the argument “JI+1”. The latter argument (JI+1) references beyond the end of the arrays in the “do j=2,JI” inside the thomas_algorithm() routine. It appears that may be what was detected.

I have some tips for you! I recomend that you initialize all your variables in order to avoid problems. I recomend that you initialize your arrays with 1 not zero.

I notice that you posted this at least twice, probably to different forums.

Unless you have a real issue relevant to the forums, please do not post here. We are a special resource for those very difficult technical issues having to do with Intel tools and products. If you abuse the forums now, you may be ignored later even if you have a very relevant issue we can help you with.

Regards
--
Taylor

Leave a Comment

Please sign in to add a comment. Not a member? Join today