0

I'm new in Fortran and I need your help. I'm a space engineering student and I'm used to code in MATLAB.

Right now I'm writing my MSc thesis and I have to deal with a code written in fortran77 (I'm guessing it by its extension ".for"). The code has already been tested and used in other occasions.

I use Windows 10 as an operating system and I know that sometimes an old code could show problems depending on the system in which it is run (for instance I've heard about the need of running old versions of an operating system through emulators to solve some problems).

I hope I can still use Win10 for the purpose.

So, I have done the following steps (based on what I have found on internet) in order to configure my system:

  1. I have installed the last version of Microsoft Visual Studio Community 2019
  2. I have installed Intel OneApi Basic Toolkit and then Intel OneApi HPC Toolkit (the last one is an add-on that contains the fortran compiler).

It seems that both are well configured/integrated and I think they are working properly.

Now, when I try to open the project from Visual Studio, the .for extension isn't apparently recognized. So I've tried to open it as a simple file, and in doing so, I can visualize it on VS. I don't know If It is the right procedure, and I don't know if it works as it should.

How can I prove it?

I try to run it, but nothing seems to happen (no error flag by the way).

I'm totally new in this field, so any "obvious" suggestions will be really appreciated. I'm open to any tips, even If it is better to change compiler (I've heard about gfortran) or use other kinds of softwares. I would be also grateful if someone could suggest me a beginner useful guide.

Thanks to whoever wants to help me out.

sepp2k
  • 363,768
  • 54
  • 674
  • 675
Catarella
  • 111
  • 3
  • Visual Studio doesn't support Fortran. You have to install an extension. Even then, the compiler will probably support recent versions like Fortran 2003, 2008 or 2018. Fortran 77 is a bit .... old – Panagiotis Kanavos Feb 11 '21 at 12:36
  • Thanks for answering. I know what you mean, Fortran 77 is a bit outdated. Unfortunately I have to deal with it, university has provided me with this code for accademic purpose, and I'm looking for the best way to work on it. Any suggestions? – Catarella Feb 11 '21 at 12:47
  • 1
    Welcome, please take the [tour]. I always teach my student to work with the compiler in the command line first. You are just complicating the stuff with Visual Studio and all the stuff that comes with that. It is great for managing large projects but not for compiling a single file. Just open your command line and try to use the compiler you have (`ifort`). – Vladimir F Героям слава Feb 11 '21 at 13:17
  • @PanagiotisKanavos Be aware that the fixed form files (`.for` or `.f`) are perfectly legal even in Fortran 2015 and still legal, even if obsolete, in Fortran 2018. The compilers must support them. They are still widespread in legacy codes. – Vladimir F Героям слава Feb 11 '21 at 13:27
  • @VladimirF Thank you for your advices. As I told you, I'm totally new in fortran, so the first thing I did was searching on internet and one of the suggested combination was Intel compiler + Visual Studio. So I will try to work directly with the command line and hope to figure it out. – Catarella Feb 11 '21 at 15:09
  • How are using the source file? In Visual Studio virtually everything works from a 'solution' which is a collection of 'projects'. Just opening the .for file will not put it into a project. You could try File->New Project. You should then be able to start a new Intel Fortran project into which you can add your source file. – Rob Feb 12 '21 at 15:10
  • @Rob Hi Rob! I finally decided to switch to another solution. I have downloaded Sublime Text 3 as a code editor, I've installed gfortran as a compiler (I read that it has more backward compatibility), and I will try to compile the code through the command line. The code is quite old, a professor suggested to use a Windows XP emulator with a compiler he has, because the majority of today's compilers wouldn't run the code properly in modern OS... but I haven't tried yet, I'm currently working on the code without execute it. Let's see what happens. – Catarella Feb 13 '21 at 12:18
  • FTN95 runs Fortran 77 code (as should gFortran): https://www.silverfrost.com/11/ftn95/ftn95_fortran_95_for_windows.aspx – Rob Feb 13 '21 at 12:41
  • @Rob Thank you very much Rob. I really appreciate your suggestions. Does FTN95 run well on Windows 10? I'm not thrilled about the idea I should use a Windows XP emulator. Apparently some parts of the code are quite old, and how these parts are executed depend on the compiler used. Moreover, a professor told me that put effort into editing all those lines to rearrange the code, it's not woth it. Please let me know, cheers! – Catarella Feb 14 '21 at 17:26
  • FTN95 runs quite happily in Windows 10 – Rob Feb 15 '21 at 15:10
  • Silverfrost/FTN95 runs on W10. There are 2 IDEs. You can use Visual Studio or Plato. It will run F77 up to possibly F95 and bits of F2003. F77 code should run as-is. Extracting command line may have to be changed. It is not the fastest compiler but not too bad for debugging. – cup Feb 24 '21 at 09:30
  • @Catarella is this issue resolved?, Have you got this working in commandline. Also let us know if you are used ifx or ifort? – ArunJose Apr 26 '21 at 06:15

0 Answers0