Skip to content

Instantly share code, notes, and snippets.

View shahmoradi's full-sized avatar
Stand with the people of Iran and Ukraine

Amir Shahmoradi shahmoradi

Stand with the people of Iran and Ukraine
View GitHub Profile
@SomajitDey
SomajitDey / GitHub_Workflow_CI_Build.md
Last active April 11, 2024 05:19
How to setup Continuous Integration with GitHub Actions
  • Give your Personal Access Token (PAT) access to workflow.
  • Put the accompanying build.yml inside .github/workflows path inside your repository. Edit it as required. You may check the validity of the yaml file online.
  • On top of your repository's README.md, put the following badge:
[![CI Build Status](https://github.com/<OWNER>/<REPO>/actions/workflows/build.yml/badge.svg)](https://github.com/<OWNER>/<REPO>/actions/workflows/build.yml)
  • Add, Commit and Push
  • See results of GitHub Actions @ https://github.com///actions/workflows/build.yml
@ivan-pi
ivan-pi / fortran_namelist.xml
Created December 27, 2021 11:20
Fortran namelist configuration file for Notepad++
<NotepadPlus>
<UserLang name="Fortran Namelist" ext="nml" udlVersion="2.1">
<Settings>
<Global caseIgnored="yes" allowFoldOfComments="no" foldCompact="no" forcePureLC="0" decimalSeparator="0" />
<Prefix Keywords1="no" Keywords2="no" Keywords3="no" Keywords4="no" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" />
</Settings>
<KeywordLists>
<Keywords name="Comments">00! 01 02 03 04</Keywords>
<Keywords name="Numbers, prefix1">.</Keywords>
<Keywords name="Numbers, prefix2"></Keywords>
@ivan-pi
ivan-pi / pcg32.f90
Last active July 12, 2022 10:21
Attempt of porting the PCG random number generator by Melissa O'Neill to Fortran. The code is not tested. Signed integers are used for the state.
!
! PCG Random Number Generation for Fortran
! Ported from the minimal C version by Melissa O'Neill
!
! Copyright 2020 Ivan Pribec <ivan.pribec@gmail.com>
!
!
! Copyright 2014 Melissa O'Neill <oneill@pcg-random.org>
!
@ryandvmartin
ryandvmartin / c_interop.f90
Last active September 28, 2021 03:05
Fortran Character Arrays and Python Ctypes .... the pain is real.
! testing in the ipython notebook with the fortran code in one cell:
! %%file test.f90
! and with the build call in the following cell:
! `!gfortran -shared test.f90 -o test.dll`
! note: some useful stuff found here: https://stackoverflow.com/a/13880611/5545005
module c_interop
use iso_c_binding
implicit none
integer, parameter :: STRLEN = 64
contains

Two schools

There are two schools how to write numerical code, which in this document we will call the IEEE school and the Fortran school.

One end of the spectrum: no changes in floating point by the compiler, the developer must express exact intent. This is the IEEE school.

On the other end of the spectrum: Developer specifies math, the compiler is

@n-s-k
n-s-k / OOP_F2003_Part_2.md
Last active May 10, 2024 13:46
Object-Oriented Programming in Fortran 2003 Part 2: Data Polymorphism

Object-Oriented Programming in Fortran 2003 Part 2: Data Polymorphism

Original article by Mark Leair, PGI Compiler Engineer

Note: This article was revised in March 2015 and again in January 2016 to bring it up-to-date with the production software release and to correct errors in the examples.

This is Part 2 of a series of articles:

@n-s-k
n-s-k / OOP_F2003_Part_1.md
Last active May 10, 2024 13:46
Object-Oriented Programming in Fortran 2003 Part 1: Code Reusability
@ykonishi
ykonishi / mt19937.f90
Last active May 15, 2023 03:43
MT19937, Mersenne Twister Random Number Generator in Fortran90
! MT19937, Mersenne Twister Random Number Generator ([0,1) Real Number)
! in Fortran90
!
! Usage:
! 1) When you use mt19937, add the sentence "use mt19937"
! above the implicit sentence.
! 2) To set an initial seed, call sgrnd(seed). (The "seed" is an integer.)
! If you do not call this, the seed is 4357.
! 3) Use the function grnd().
! (Do not declare "real(8) :: grnd".)
#!/usr/bin/python
"""
Parses Fortran Namelists
based on Fortran Namelist parser for Python prog/scripts by Stephane Chamberland (stephane.chamberland@ec.gc.ca)
http://code.google.com/p/fortran-namelist/
Updated by Volodymyr Vladymyrov (http://stackoverflow.com/users/1296661/vvladymyrov) to parse format presented
in http://stackoverflow.com/questions/14165733/regular-expression-parsing-key-value-pairs-in-namelist-input-file
added support for
1)
$NAMELIST