From chemistry-request@ccl.net Wed Dec 11 14:18:15 1991 Date: Wed, 11 Dec 91 14:10:14 EST From: G. Ravishanker To: chemistry@ccl.net Subject: F90 -> C Status: R Hi I have seen a sudden increase in activity in this group related to Fortran vs C. It is indeed interesting and I thought I will voice my opinion on this too. I have been programming in both Fortran '77 and C for the past several years. I try to keep all my scientific code in Fortran and others, such as networking, input/output, parsing using lex and yacc in C. I personally feel that this kind of separation builds on the strengths of each language. Given that what we are trying to accomplish is a readable and modular code, it is hard to justify writing a piece of well readable scientific code in C. Since several of the users of that code are likely to be Fortran programmers, what is readable in C may not be well readable for a Fortran programmer. Regarding portability, I have found that several of the well written C programs are indeed system dependent, however small the system dependency may be. Same can be argued for Fortran too. One can always write Fortran programs with minimal system dependency. Fortran '77 gives enough flexibility to organize your program to look like a "structured program", if you wish to do that. You can write top-down programs, go-to less programs and all that. Someone needs to explain this to me clearly that structured programs are easier written in C than in Fortran '77. The only major disadvantage is you cannot have recursive subroutines in Fortran (some Unix machines even allow that), but how many have we all written in our lifetime! (factorial, Tower of Hanoi and Eight Queen problem....) What has gotten us much more than anything else in Fortran code (other than old spaghetti code) is the lack of bounds checking for arrays. Some of the old Fortran programs used this to their advantage in manipulating some scratch commons differently in different subroutines. But it stinks. You run an MD simulation and burn 5 hrs of Cray time only to see that your temperature in the common block got overwritten by the next to last member of the previous array in the common block. C of course would not allow you to do it (sometimes you can, in case of strings...) Though I do not have many things in support of C in the above paragraphs, I do a fair amount of code development in C, but I feel that it is more appropriate for doing things other than developing scientific code. Once you have put in all the strengths of C to develop a very good piece of code, you have lost a fair amount of your scientific users. Thanks for your attention. Ravi