CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Main CFD Forum (http://www.cfd-online.com/Forums/main/)
-   -   code for solving block tridiagonal system (http://www.cfd-online.com/Forums/main/3238-code-solving-block-tridiagonal-system.html)

 cfd March 14, 2001 20:04

code for solving block tridiagonal system

I am looking for a code to solve a block tridigonal system. In the book of Anderson "computational Fluid Mechanics and Heat tranfer", there is a code in the appedix, but seems it does not work. If anyone knows any info about any code to solve it, pls post it. Thanks a lot.

 Kang, Seok Koo March 16, 2001 12:59

Re: code for solving block tridiagonal system

I guess the code works. I'm sure.

The problem is whether you are good at coding or not.

 cfd March 16, 2001 19:27

Re: code for solving block tridiagonal system

I just found an obvious error in the code. In the subroutine LUDECO, it should be

integer order dimension A(order,1)

other than

dimension A(order,1) integer order

Can you guess? Don't say anything before testing by yourself.

 John C. Chien March 16, 2001 20:29

Re: code for solving block tridiagonal system

(1). order is integer, so it should be iorder. (2). ordsq is order*order, is also integer, so it should be iordsq. (2). So, you can change order to iorder, ordsq to iordsq, and remove integer order, integer ordsq from the code. (3). When writing Fortran code, try to use the original convention. That is i,j,k,l,m,n are reserved for the first character of a integer name. (4). Let me know whether you can get it to work with these changes. I don't have time to check it out myself.

 Kang, Seok Koo March 17, 2001 23:47

Re: code for solving block tridiagonal system

Hmm~~ You became a little angry right??

First, I'm sorry if I made you angry.

But, it is obvious that no one in this forum are concerned about whether the code you said works or not. This is not a forum for basic FORTRAN lecture.

I know the code may have an error.

If it does not work, then just try to use another code or you correct it.

The fact that the code have an error is not important at all.

Most of people have no problems in solving the problem you stated.

 cfd March 18, 2001 01:21

Re: code for solving block tridiagonal system

pls look the post

one more example.

seems you have some connect with the authors of the book or the code.

 John Calisch March 18, 2001 02:15

Re: code for solving block tridiagonal system

Both of subroutine ludeco and lusolv have the same error. It appears that the code has not been tested in the form as in the book before publication of the book.

 Eric Chang March 18, 2001 02:28

Re: code for solving block tridiagonal system

From your judgement, there is some possibility that the code contains other errors

 Kang, Seok Koo March 18, 2001 06:06

Re: code for solving block tridiagonal system

Hm.. I don't have any connection with the author. As I said before, whether the code have an error or not is not important. Even middle school student can find the error if he is good at FORTRAN. It does not matter. If Anderson's tridiagonal solver contatins an error, use other program. Anderson's is not a FORTRAN book. The book can contain errors.

 andy March 18, 2001 08:52

Re: code for solving block tridiagonal system

Assuming there is a line break in the two statements, both pairs of statements are correct Fortran. From the specification of Fortran:

"The names of variables, arrays, constants, statement functions, intrinsic functions, and dummy procedures have a scope of a program unit."

Note this does not say the rest of the program unit after the declaration statement!

Only a few Fortran complilers will reject the former pair of statements but one widely used one is gnu's Fortran compiler. I have also come across some HP Fortran compilers with the same problem. I suspect there are others. The source is probably a C mindset in the compiler writer (the main author of g77 quite happily admits to not being a Fortran programmer - this is not meant as a slight on the author by the way since the chances of g77 existing at all if the main author programmed principally in Fortran has got to be about zero!).

 andy March 18, 2001 13:30

Re: code for solving block tridiagonal system - PS

If you have a Linux system and want (or need) to avoid this bug you can use the older Fortran compiler based on the f2c program which seems to parse Fortran a bit more accurately. Some systems have this older compiler under the name "fort77"

fort77 fortranfile.f -o prog

or if this is not there then you can use:

f2c fortranfile.f > cfile.c

gcc -lf2c cfile.c -o prog

Note that you need to include the f2c library when linking. Mixing object code from the two compilers does not work. The names "f77" and "g77" will use the newer compiler.

 John C. Chien March 19, 2001 23:25

Re: code for solving block tridiagonal system

(1). The subroutines appeared in the Appendix B of the book has the opening statement: "The subroutine described here for solving block tridiagonal systems of equations were provided by Sukumar R. Chakravarthy of Rockwell International Science Center." (2). It appears that Mr. Chakravarthy is one of the vendor sponsor of the forum. So, it might be easier to get the answer directly from him. In this way, we might be able to get it settled down once for all. (3). So, if Mr. Chakravarthy is reading this forum, we would like to hear from him about the subroutine errors.

 A.M.Yang March 20, 2001 08:59

GOOD NEWS

Hi,

The errors in Anderson's book are two subroutines (lusolv,ludeco).If you change those,you will work well. I have tested it.

 john Calisch March 20, 2001 13:12

Re: GOOD NEWS

Whether those discussed above are the errors you corrected?

 cfd March 20, 2001 13:43

Re: code for solving block tridiagonal system

From this site, it appears that you are a student in Civil Engineering. My advise to you is that you need to learn more about scientific attitudes, rather than civil engineering. You may find that will benifit you a lot.

 cfd March 20, 2001 14:19

Re: GOOD NEWS

same question as John Calisch's

 Kang, Seok Koo March 21, 2001 01:29

Re: code for solving block tridiagonal system

My advice to you is that you need to learn more about CFD and FORTRAN, rather than finding faults with other people's remark.

Regards.

Seok Koo, Kang.

Graduate Student, Civil Engineering, Hanyang University, Seoul, Korea.

 A.M.Yang March 21, 2001 09:48

Re: GOOD NEWS

Yes,only the two subroutines are error

 A. Al-Otaiby March 23, 2001 03:54

Re: code for solving block tridiagonal system

Try the routine listed in the book" Computational Fluid Dynamics for Engineers--Volume I" by Hoffman and Chian...I tried it, it is working...Good luck.

 Mohsen Mahbubi Fard March 26, 2001 02:42

Re: code for solving block tridiagonal system

I have started to work on it too.I wanted to ask you if you can email me the original code for further work.You know it's typing is difficult and boring! I will announce you about my work. Thank's in advance!

All times are GMT -4. The time now is 06:51.