17374496333_54c62d9372_k.jpg

Legacy Fortran modernization

Posts in Working versions
First working version of FEM-1D and basic gfortran usage

Over the past week or so, I've been able to put together a translation of the original FEM-1D.FOR file into Fortran 2008, FEM-1D.f08, along with several modules in the "common modules" folder. The program runs, but I still need to verify that the results are correct. 

The commit containing this first working version can be found here.

The modules do need to be compiled, which can be done with the following command from the terminal (on a Mac or Linux system) using assemb_mod.f08 as an example:

gfortran -c assemb_mod.f08

This particular command uses the GNU Fortran compiler, but there are several out there that would work. However, these will potentially have different compiler flags, so these commands may not work. Also, this command will only work if the current directory for the terminal is the common modules folder.

With all the modules compiled, we then have to compile the main program from the fem-1d folder. This can be done with the following command:

gfortran -I../common\ modules ../common\ modules/assemb_mod.o ../common\ modules/init_mod.o ../common\ modules/gauss_mod.o -o FEM-1D.o FEM-1D.f08 

What this is saying, piece by piece is that:

-I indicates that there are compiled modules to find in the common modules folder. The phrasing here says to go up a directory level, and the common modules will be under that parent folder, a so called relative path.

The list of *.o files after that are the compiled modules, which have to be given with a path since they're not present in the fem-1d folder.

-o specifies the name of the output file, in this case FEM-1D.o

Finally, FEM-1D.f08 is the file containing the main program.

The program can be run from the terminal with a command:

./FEM-1D.o

I believe in Windows, the leading "./" is not necessary. The program in its current form will ask for an input and output file name. The input files can be found in the "Original code/fem-1d" folder, as the *.DAT files. The output can be named anything except for an existing file name, and the program will throw an error if such a name is used. Otherwise, let me know if there are any issues, I'd like to make the code as robust, stable, and accurate as possible.