Skip to content

Instantly share code, notes, and snippets.

View szaghi's full-sized avatar

Stefano Zaghi szaghi

View GitHub Profile
@szaghi
szaghi / hanoi_towers.f90
Created May 15, 2017 09:25
Hanoi's Towers exercise in (poor, not checked) OOP Fortran
module module_vector
use, intrinsic :: iso_fortran_env, only : I32=>int32
implicit none
private
public :: size
public :: vector
type vector
@szaghi
szaghi / Fortran_Stack_Bias.md
Created November 6, 2016 07:31
Test the Stack memory bias for Fortran allocatable/pointer variables

Test Fortran Satck Memory Bias

A testbased on Gary Scott's issue described here.

This test reproduction is devoted to Paul Rich & Co. for GNU gfortran users

The test code

program test
@szaghi
szaghi / bench_select_if_goto.md
Last active October 16, 2016 19:41
Fortran benchmark: select case/if elseif/goto comparison

Aims

Compare the performance of select case, if elseif and goto branching flows.

Benchmark program

program bench_select_if_goto
  use iso_fortran_env
  implicit none
@szaghi
szaghi / README.md
Created May 11, 2016 08:09
Directed Graph Traverse (for entropy)

Discussion on API design of a D(A)G Traverse algorithm

Baseline classes

Plant, the DG

The main DG class built on top of component one.

type, public :: plant 
@szaghi
szaghi / modules_examples.md
Last active April 13, 2016 10:03
Example of modules for Alessandro

A gist for Alessandro

Source files baseline status

Let us assume you have the following situation (for the sake of brevity let us have only 2 source files):

  • file_1.f: it contains procedures sub_1 and sub_2;
  • file_2.f: it contains procedure sub_3 that uses sub_2 of file_1.f90.

Refactoring by modules

@szaghi
szaghi / abstraction_overhead.md
Last active April 14, 2016 13:36
Abstraction overhead

Simple test on Fortran abstraction overhead

This test is a tentative to investigate the abstraction overhead in modern Fortran: it could be not well-posed and not interesting at all, it is just a replay of a question on a Google Group CLF thread

Proposed code for testing

The overhead.f90 test porgram contains

@szaghi
szaghi / load_cvs_in_fortran.md
Last active February 1, 2016 09:41
Loading a formatted CVS in Fortran

A small snippet to load a formatted cvs

I assume that the date string is always 10 characters length.

The number of file records is assumed known at compile time: generalize it as you need.

program cvs_read
  implicit none
@szaghi
szaghi / foo_adt_test_failing.f90
Created January 7, 2016 15:06
A (hopefully) simple test of mismatched abstract/concrete interfaces of Fortran abstract type. This should not compile at all
module adt_foo_class
implicit none
private
type, abstract, public :: adt_foo
private
contains
private
procedure(sym_operator), pass(lhs), deferred :: foo_multiply_foo
procedure(assignment), pass(lhs), deferred :: assign_foo
generic, public :: operator(*) => foo_multiply_foo
@szaghi
szaghi / foo_adt_test.f90
Created January 7, 2016 11:59
A (hopefully) simple test of mismatched abstract/concrete interfaces of Fortran abstract type
module adt_foo_class
implicit none
private
type, abstract, public :: adt_foo
private
contains
private
procedure(sym_operator), pass(lhs), deferred :: foo_multiply_foo
procedure(assignment), pass(lhs), deferred :: assign_foo
generic, public :: operator(*) => foo_multiply_foo