Part 2: Creating the necessary modules

The modules must be compiled to generate ‘modulename.mod’ and ‘modulename.o’. Terminal command for compiling modules in Ubuntu:

gfortran -c modulename.f90

Module 1: ‘writing’

The first module we’ll create is called ‘writing’. Its job is to accept data and write them into a file. It can be as versatile as we want it to be. Here, I’m going to create it using two subroutines, which will be enough for now.

The subroutine ‘point_1’ will accept two real numbers ‘x’ and ‘y’, and a 17 lettered sentence ‘c’, and will write down ‘x’ and ‘y’ in a file named ‘c’. The subroutine ‘array_2’ will accept two real number arrays ‘x’ and ‘y’, and a 17 lettered sentence ‘c’, and it will write down all elements of ‘x’ and ‘y’ in a file named ‘c’.

Keep in mind that we will need to change the space allocated in the dummy variable ‘c’ if we want to change the number of letters in the file name.

Download link: writing.f90

Module 2: ‘plotting’

The second module is called ‘plotting’. It will create a file ‘plot.txt’ containing instructions for gnuplot. Once the file is generated, we can use it to make gnuplot generate images for us. The functions of each subroutine in this module is self explanatory. Formatting in the generated file has to be perfect so that gnuplot can understand the instructions.

Download link: plotting.f90

<<Part 1 | Part 3>>


Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s