Its been a long time since I’ve read a novel and I feel that “All the light we cannot see” by Anthony Doerrr is a perfect book to get back through. Its the story of two souls - Marie Laure, an young girl from paris and Werner, a boy born in the german mines.Today, there has been some heavy lifting! User defined types, dynamic memory, pointers and all its associated magics! Definitely will be revisiting soon. Also, want to acknowledge that I’m finding the method of logging everything here in blog to be too daunting. If I try to make it useful, the post needs to be lengthy but that eats up the time on learning itself.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.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) !Today, I’ve forked All Algorithms archive for Fortran and have implemented few algorithms. Today’s highlight has been gauss elimination method!