GFortran is the name of the GNU Fortran project. The main wiki page offers many helpful links about GFortran, as well as Fortran in general. In this guide, the installation process for GFortran on Windows, Linux, macOS and OpenBSD is presented in a beginner-friendly format based on the information from GFortranBinaries.
Windows Subsystem for Linux (WSL): An official compatibility layer for running Linux binary executables on Windows. With Windows Subsystem for Linux GUI one can run text editors and other graphical programs.
Finally, you can switch between different versions or set the default one with the update-alternatives (see manpage). There are many online tutorials on how to use this feature. A well structured one using as an example C and C++ can be found here, you can apply the same logic by replacing either gcc or g++ with gfortran.
OpenCoarrays is an open-source software project that produces an application binary interface (ABI) used by the GNU Compiler Collection (GCC) Fortran front-end to build executable programs that leverage the parallel programming features of Fortran 2018. Since OpenCoarrays is not a separate compiler, we include it here, under gfortran.
While with gfortran you can compile perfectly valid code using coarrays, the generated binaries will only run in a single image (image is a Fortran term for a parallel process), that is, in serial mode. OpenCoarrays allows running code in parallel on shared- and distributed-memory machines, similar to MPI:
Conda-forge has GFortran/MinGW, I think it is based on an early attempt to distribute MSYS2 via conda. What you get is GCC 5.3.0 and can be somewhat shaky depending on the features you want to use in modern Fortran.
Nobody decided to do it yet, simple as that. It is not a nice task, you will have to patch the compiler until it passes its test suite, than you have to rebuild all existing packages using this compiler (only in case of an ABI change), if something fails probably patch the package build and/or the compiler build.
Another choice may be using Docker. You can install and configure whatever you want in the Docker image. People just need to load that image and bingo.
Or, I think you can also create a WSL image with GUI configured, and people can load that WSL image, and visit it using Windows Remote Desktop via the port you defined in that image (such as port 3389, 3390, etc).
But of course, in the above two cases, users are still using Linux actually. But Gfortran performs the best in Linux.
If you make the students use Visual Studio Code it should be able to integrate natively with the WSL environment, no virtualization from within WSL. BTW The same is true for docker images, although you might need the remote extension pack from Microsoft
I always recommend MSYS2 (winget install msys2.msys2), because in addition to the GCC suite, we may also need other tools, such as lapack/openblas, hdf5, git, python, etc., which can be easily obtained in MSYS2. After installing MSYS2, we only need to set the the environment path of the execution program can be: C:\msys64\ucrt64\bin, that you can access the MSYS2 environment in cmd and pwsh.
Other than that, Cygwin (winget install Cygwin.Cygwin) is also possible, but as far as I know, MSYS2 seems to be based on Cygwin under the hood, so I think there may be no essential difference between MSYS2 and Cygwin, but MSYS2 is more convenient.
Cygwin has a much more complete *nix environment easily available with hundreds (thousands?) of additional packages and X11 Windows; but with the other options available and depending on whether you also do/do not want them to have a Unix-like interface and X11 windows it might not be what you want. I adore it, but there are a lot of other options, as mentioned. Works great with fpm(1) too, but so do some of the others.
The rebuilding after such an update is mostly automated, the problem are the 5% of packages which might fail, those can be mostly fixed in the respective package recipe. Since we are talking about 17k packages on conda-forge and an update affecting the fraction which uses GCC for C, C++ and/or GFortran and Windows, it is best to coordinate such effort with the conda-forge core team.
Conda environments provide enough isolation to make this work. You can have completely different and conflicting runtimes for some programs if you have them in different environments, then you can just stack them on top of each other and things should usually work. Cross-linking or cross-loading libraries between such environments will be a bit more tricky as you try to break the environment isolation.
At GFortran - GCC Wiki several options to download gfortran binaries are discussed. I have not tested these downloads (on Windows I use MSYS2). Note that for these solutions OpenCoarrays usually is not included, so the use of Coarrys may be be limited to a single image.
As a followup from this, in the short term what I need is to build a statically-linked binary of the latest version of my package. In linux it is just about installing gfortran and cmake, and doing make.
I have just spent one hour trying to install some fortran compiler on Windows, without success. I have no real experience with doing anything on Windows, so probably this is just my lack of knowledge.
I can recommend MSYS2, it gives you a bash shell with a Cygwin-like runtime as base and (several) MinGW native toolchains on top, which allows linking static binaries for distribution outside of MSYS2. From my experience this is the closest Unix experience one can get on Windows, while still being able to create native binaries. However, it might appear a bit complex due to the different available environments on the first glance.
After installation there will be several terminals available (msys2, mingw64, mingw32, ucrt64, clang64, clang32). The msys2 terminal is a pure Cywgin-like environment, software from this environment is available in all environments. mingw64, mingw32 and ucrt64 are based on GCC/MinGW, here you get gfortran as Fortran compiler. In clang64 and clang32 you can instead rely on flang as Fortran compiler.
On Windows, if you need as comprehensive a Linux tool experience as possible, and the latest packages (its gfortran will always keep the latest version), MSYS2 is very good, which I have been using.
I managed to document creating Windows executables on Linux by cross-compiling. My experience is detailed here. If you need access to Windows DLLs it becomes more complicated, but if you stick to straight Fortran, it is nice to have one shell script that compiles both executables. Now if I could only cross-compile to OSX.
The program reads problem data from the standard input stream, using Unit 5. This, by itself, is fine, but the program attempts to read the input twice, with a REWIND(5) in between. Depending on the operating system and the Fortran compiler being used, this may fail if the standard input is obtained by redirection from a file.
In various places, there are WRITE statements in which the output list contains references to the character function i5hex. However, the function i5hex itself contains WRITE statements to an internal file, and such recursive I/O statements may not work or may not work correctly.
If I was to read it once I would need at least to know the number of lines, to preallocate a vector of strings with proper size. Is there any way to do that? Or a push? At the same time that has not been an issue in the many years Packmol is out there.
The Fortran standard has a section on Internal Files. In Fortran 2018, for example, the section is 12.4. Recursive I/O can be avoided by using a temporary character variable which is set to the function value, and placing that temporary character variable in the I/O list. For example, instead of
There is also a separate distribution of mingw-w64 that can be installed without MSYS2, but I don't recommend it, as the last files there have gcc-8.1.0, from 2018 (apart from a recent build by Ray Linn that includes the Ada, but not the Fortran compiler).
Another compiler that is now free is Intel Fortran : you have to install Microsoft Visual Studio Community, Intel oneAPI Base Toolkit and Intel oneAPI HPC Toolkit. More information here. Available on Linux, macOS and Windows (of course, Visual Studio is needed only on Windows). Intel oneAPI is at least partly open source, not sure about the Fortran compiler.
MSYS2 is a much smaller package (in terms of disk pace needed), and is used by several other free projects: R (Rtools), Octave and Strawberry Perl all include parts of it, including the gcc compilers.
To compile Fortran code for Windows you need a Fortran compiler for Windows. Microsoft neither provides a built-in one nor offers one for sale. Third-party compilers are available, including gfortran, but you'll need to install one yourself. If you want to use gfortran in particular, or if you like it simply because you don't have to spend money to get it, then I would recommend obtaining it as part of mingw-w64. Alternatives are available from multiple vendors, some free of charge, but most for sale.
Fortran is one of the earliest imperative computer programming languages around. It is often used for scientificand numeric programs. This page lists free Fortran compilers for various operating systems. Note that the differentsoftware listed are compliant with different Fortran standards, eg, ANSI Fortran 77, Fortran 95, Fortran 2003,Fortran 2008, Fortran 2018, and so on, so be sure to get the appropriate one for your purpose. Some of them may alsocome complete with debuggers,editors and anintegrated development environment (IDE).
The MinGW-w64 project provides the libraries, headers and runtime needed for the GNU compilers, among whichis their Fortran compiler, to run on a Windows system. They allow you to create both32 bit and 64 bit programs with the compilers. The project also provides cross compilers, so that you cancompile (say) a Windows program from a Linux system if you choose. Precompiled binaries can be obtained froma variety of sources, includingthe official MinGW-w64 binaries site,and third-party sites such as the MSYS2 project.
3a8082e126