This part of the programme specifies the data types of variables that will be used by the main programme. The specification, or declaration, section is placed immediately after the implicit statement. You can’t write anything in any order and expect it to work – just as main() must be at the end of a C file. FORTRAN programs do have a specific order, though. The rest of the code for the programme follows these statements. Everything after the ! on that line is ignored by the compiler, except when it is used in a character string. Only the USE keyword may be placed before it, but we will come to that later. This statement comes straight after PROGRAM. It is included in almost all code to prevent issues with mistaken type declarations. This is because, if this is not set, FORTRAN will attempt to define any variables with the names i, j, k, l, m and n as integers, and all other variables as real. This tells the compiler that no implicit types are used by this programme. Most modern FORTRAN programs follow this with IMPLICIT none. PROGRAM is optional, but it is almost always included as it informs the compiler where the main routine of the programme begins. The initial programme templateĪll FORTRAN programs start with the following basic template: PROGRAM programme_nameĮvery FORTRAN programme starts with the keyword PROGRAM followed by the name of the programme and ends with END PROGRAM followed by the name of the programme. I will be following the convention of writing all keywords in capitals, though this is completely optional. If you’re working with legacy code or compilers, a lot of this may not apply to you. This post and any future posts regarding FORTRAN will not deal with language elements that are specific to fixed-form FORTRAN. That probably won’t go down well with your boss. That being said, I wouldn’t recommend using FORTRAN if the rest of your company only understands Objective-C. At the end of the day, the tools used are unimportant only the ability of the final product to meet requirements matters. There’s no reason not to use FORTRAN, provided you enjoy working with the language and you can use it within your environment. It’s designed for people who already know a little about programming, but haven’t worked with FORTRAN in the past. This post will walk you through the basic structure of a FORTRAN programme. Modern FORTRAN – which is now just spelt Fortran, although I prefer the former – supports generics and modularisation, object-oriented programming, concurrent programming, and is even interoperable with C. It’s thoroughly up to date, with the previous stable standard being released in 2018 (5779), and the previous in 2010 (5771). FORTRAN is often viewed as an outdated and archaic language, but it is just as capable of doing any job that other compiled languages can.
0 Comments
Leave a Reply. |