yego.me
💡 Stop wasting time. Read Youtube instead of watch. Download Chrome Extension

GNU Fortran | Lesson 1


3m read
·Nov 3, 2024

Processing might take a few minutes. Refresh later.

Hey guys, it's Makin's anon, and today I'm going to be making one of many videos on a very old programming language called Fortran.

Fortran is a language that's been around for over 25 years, and it's gotten upgraded and changed around since it came out. So the first Fortran, I believe, was Fortran 66. The second one, I believe, was Fortran 77, which came out in 1977, and the next one after that was Fortran 90, which came out in '90. There might also be a Fortran 95; I'm not positive about that. There's also something called G Fortran, which is a Fortran for Linux and UNIX systems. This is a new Fortran, and it has the syntax of Fortran 90 but also works in Fortran 77, of course.

It's interesting. So the reason I'm doing a video on Fortran, which is kind of an obsolete language, is because I was using this the other day just because I was bored. So I was learning it, and I realized, hey, if it was 20 years ago, programming would still be fun.

I want to just show you guys a couple of things you can do in Fortran in this tutorial and make it a really nice language. Now, I might not necessarily be showing you the really nice language stuff in this specific tutorial because there's a bunch of ugly stuff you have to get past first.

I'm gonna be using the terminal to, of course, be programming in Fortran. If you find an IDE, which I doubt you will, you can use that as well. If you want to install Fortran, which you should if you want to be on it, follow this tutorial and do it. If they download the G Fortran, I will have a link for that in the description of this video.

So I'm gonna get started and create a hello world application. I'm gonna edit my hello.f90, and here’s how every Fortran program starts out. Every line of code that's a normal line of code has six spaces before it, and the first line has to be PROGRAM. Therefore, hello. The last two lines have to be STOP and END PROGRAM, and you know, that's right for programming.

Now, you can't hit tab here; you have to type six spaces, which gets annoying. I'll explain why that is in a second after I make our hello world application. There we go! So right here, this will write with these parameters, "Hello, World!"

I'll explain the parameters. The first parameter means the place we're writing this text to. If we just put a star, it means the terminal window. The second parameter, which is the second star, is the format that we are printing it out in. If we say star there, it'll be at the default format, which has a space before what we print out and automatically a newline.

So it's actually a pretty nice format, but if you're getting input, it gets kind of annoying. In a later tutorial, I'll be showing you how to use formats to get rid of this little annoyance.

So why do you have to put six spaces before each line of code? I actually realized that the hard way by not doing that, and I figured out what the six spaces are actually for. This is actually pretty bizarre, but once you get used to it, it's a good idea.

They serve four different functions. The first character being a 'C' means it's a comment. The line is a comment; it doesn't count as code. The second to fifth characters, so four digits right here, are the line label. Normally, this is a number; specifically, I like to use multiples of ten, so a thousand, but you can make it whatever you want.

Then, the character before where you normally write code, the fifth space in, is for the continuation of the last line. If a line gets too long, you can continue it on the next line and start out the continuation on the character before the character you normally start out as to tell the compiler that you're continuing the line.

The reason you'd want to do that is because lines also have a limit to their length, and that also gets quite annoying. So I'm just pointing that out.

You can also declare variables, just like in a normal programming language. So if you've done math, a variable is a number, but in programming, it can be a bunch of different types of data. Thinking up names longer than one character, so we can say INTEGER :: and that makes us have an integer variable.

More Articles

View All
Kevin O'Leary's Predictions for 2022: Are we ready for what's coming next year?
[Music] He is the chairman of O’Leary Financial Group. He is a Shark Tank investor. He is a friend of the show. Mr. Wonderful is back to give us his, uh, I guess wrap up on what has been a pretty impressive year to say the least. Kevin will have, uh, you …
Introduction to solubility equilibria | Equilibrium | AP Chemistry | Khan Academy
Let’s say we have a beaker of distilled water at 25 degrees Celsius, and to the beaker, we add some barium sulfate. Barium sulfate is a white solid. A small amount of the barium sulfate dissolves in the water and forms barium 2 plus ions in solution and s…
The US Literally Cannot Repay Its National Debt.
The US national debt currently sits at $34.8 trillion. For context, the population of the US is currently around 333 million people, so that equates to over $100,000 of national debt per person. But the worrying statistic is not the absolute value; rather…
Are GMOs Good or Bad? Genetic Engineering & Our Food
GMOs are one of the most controversial areas of science. Genetic engineering is used in many fields, but even though medical applications like GM insulin are widely accepted, the debate heats up when it comes to food and agriculture. Why is that? Why is t…
Worked example: Using formal charges to evaluate nonequivalent resonance structures | Khan Academy
[Instructor] We’re told that three possible resonance structures for the thiocyanate ion are shown below. All right, there we have them. Based on formal charges, which of the three structures contributes most to the resonance hybrid of thiocyanate? And …
Solving equations by graphing | Algebra 2 | Khan academy
Let’s say you wanted to solve this equation: (2^{x^2 - 3} = \frac{1}{\sqrt[3]{x}}). Pause this video and see if you can solve this. Well, you probably realize that this is not so easy to solve. The way that I would at least attempt to tackle it is to say…