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)
INTEGER, INTENT(IN) :: N
REAL*8, INTENT(OUT), DIMENSION(N,N) :: Mat
INTEGER :: i, j
! Creates and Identity Matrix
IF (i .EQ. j) THEN
Mat(i,j) = 1.0D0
Mat(i,j) = 0.0D0
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.
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.
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.
A free concise introduction to Fortran 90 is available here:
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".