Skip to content

muxwan/fortrite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Fortrite

Read the repo name again.

Anyways, this repository serves as a kind of "dropbox" where I drop Fortran programs and modules. Feel free to use them as you wish.

Quick guide to Fortran90


Compiling a program directly

gfortran NAMEOFPROGRAM.f90 -o NAMEOFOUTPUT

Example :

gfortran circle_test.f90 -o circle.out

Compiling a program by linking

First, generate the object files

gfortran -c NAMEOFPROGRAM.f90

Example :

gfortran -c main.f90

Repeat for all necessary files.

Lastly, mention all the required object files and create the executable.

gfortran PROGRAM-01.o PROGRAM-02.o ... PROGRAM-N.o -o OUTPUTPROGRAM

Example :

gfortran rectangle.o square.o -o shapes.out

Creating dynamic libraries

In Linux (.so files):

gfortran -shared -fPIC -o NAMEOFLIBRARY.so NAMEOFPROGRAM-01.f90 NAMEOFPROGRAM-02.f90 ... NAMEOFPROGRAM-N.f90

Example :

gfortran -shared -fPIC -o libgeometry.so squares.f90 triangles.f90

In Windows (.dll files): Example :

gfortran -shared -o libgeometry.dll squares.f90 triangles.f90

In MacOS (.dylib files): Example :

gfortran -dynamiclib -o libgeometry.dylib squares.f90 triangles.f90