100 Days of Code Log R1D15

Randomly Generated plot in Fortran I owe this to one of the participants of matlab contest - Matlab Mini Hack - where this simple but powerful method was shared. Here is my implementation 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 module charchal use, intrinsic :: iso_fortran_env, only : wp=>real64 implicit none private real, parameter :: pi = 4.

100 Days of Code Log R1D14

Sieve of Eratosthenes Here’s the fortran implementation of Sieve of Eratosthenes, an ancient method for finding prime upto n numbers (and one of the efficient method for finding small primes). 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 program sieve_of_eratosthenes use, intrinsic :: iso_fortran_env, only : error_unit implicit none call prime_sieve_eratosthenes(170) contains subroutine prime_sieve_eratosthenes(n) integer, intent(in) :: n logical :: is_prime(2:n) !

Gauss Elimination in Fortran

Gauss Elimination is a well known method for solving system of linear equations. It has time complexity of order $O(n^3)$ and hence, it fares better than cramer’s rule or Gauss-Jordan method. The following is my implementation of Gauss elimination method in fortran. I’ve made use of scaled pivoting in order to reduce round-off errors.

100 Days of Code Log R1D12

It’s been a great experience today, solving the tower of hanoi. Though a simple solution, the implementation was hard especially since I made some mistake in variable which took more than an hour (and resorting to gdb) to debug. So, the victory feels sweet.

100 Days of Code Log R1D11

Today’s venture was rather short. I reimplemented the logistic map with elemental function. Here’s the code. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 program logisticmap use, intrinsic :: iso_fortran_env, only : dp=>real64, error_unit implicit integer(i-k) integer, parameter :: l=2001, b = 2001 real(dp) :: r(l), x0(b), x(l, b) integer :: fileno, istat, n character(len=1024) :: msg print *, "No of iterations: " read *, n x0 = linspace(0.

The World as I See It - Albert Einstein

Albert Einstein is the scientific genius that the world worships whether they understand his works or not. The change in perspective he brought is so mind boggling that it’s difficult to believe that he is actually a human. But, he is truly a human and the book The World as I see it is a proof of that.

100 Days of Code Log R1D10

Today’s learning can be split mainly into the following two sections. I/O Formatting The formatting string in fortran is passed as a string to print or write statements. 1 2 3 4 character(len=10) :: fmt_str fmt_str = '(*(i3))' print fmt_str, 900 write (*, fmt_str) 900 The following formats are available

100 Days of Code Log R1D9

Continuing with the lessons on fortran, the following stuff were covered today. Procedures in detail Intents: A fortran function’s parameters may have three possible intents in out inout 1 2 3 4 5 6 function one(x) result (y) real, intent(inout) :: x(:) logical :: y x = 1.

100 Days of Code Log R1D8

Today has been the beginning of Week 2 in Fortran for scientific Computing course. This had the introduction to arrays, mainly, along with elemental procedures. A word or two were mentioned about “pure functions” but those remain a mystery for now. But, here are some highlights.