- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Members,
I am completely new to the Fortran. I have a very simple program for the Identity matrix. I want to know if Fortran is case insensitive?
The "N" in the subroutine is the same "n" used in the DO loop?
SUBROUTINE IDENTITY(Mat, N)
IMPLICIT NONE
INTEGER, INTENT(IN) :: N
REAL*8, INTENT(OUT), DIMENSION(N,N) :: Mat
INTEGER :: i, j
! Creates and Identity Matrix
DO i=1,n
DO j=1,n
IF (i .EQ. j) THEN
Mat(i,j) = 1.0D0
ELSE
Mat(i,j) = 0.0D0
END IF
END DO
END DO
Thanks!
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
May I suggest you obtain--and read--a basic textbook or guidebook on the Fortran language. The question you ask is a very basic one, and if you continue to rely on this (or other) source for all such basic questions, you will be spending much more time than if you get it all in one document.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
To answer your immediate question, though - Fortran is not a case-sensitive language, so, yes, N and n identify the same variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you dboggs for your suggestion. I will definitely refer books for the basics.
Thank You Steve. Much appreciated.
Regards,
Geetanjali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Geetanjali,
FORTRAN is one of the oldest compiler languages. It dates back to when source code was written on 80 column punched cards. The cards only used upper case letters, numbers, and a few special characters. When lower case letters were introduced with the ASCII character set, FORTRAN kept the tradition of interpreting all alpha characters as their upper case variant. So, "a" and "A" are interpreted as "A" by a FORTRAN compiler. I personally like this much better than languages like C that are case sensitive. I like it that I don't have to worry whether "caps lock" is on or off while writing code. There are more than enough variable names available without making the names case sensitive. One hint I will pass on as good coding practice. Always include the line " IMPLICIT NONE" at the beginning of a FORTRAN program before you declare variables. This requires you to declare all your variables, prevents getting INTEGER and REAL variables from being declared based on their initial letter, and helps the compiler find any variable misspellings.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Books which i definetly recommend are:
Fortran 95/2003 for Scientists & Engineers, J. Chapman
Guide to Fortran 2008 Programming, S. Brainerd
because if it comes to Fortran the internet (except this forum) is not the best ressource, because there is a lot of legacy code floating around.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A free concise introduction to Fortran 90 is available here:
https://www.uv.es/dogarcar/man/IntrFortran90.pdf
It is rather well written and easy to follow. Although it is still relevant, it is way behind modern Fortran (2003, 2008, 2018) features (notably object-oriented programming, submodules, and Coarray parallel programming). A a definitive reference on modern Fortran (2008) would be the book by Metcalf et al. "Modern Fortran Explained".
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page