Skip to content

Instantly share code, notes, and snippets.

Avatar

Ivan Pribec ivan-pi

View GitHub Profile
@ivan-pi
ivan-pi / fortran_namelist.xml
Created Dec 27, 2021
Fortran namelist configuration file for Notepad++
View fortran_namelist.xml
<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 / fypp.sublime-build
Created Dec 9, 2021
Sublime build system command for fypp (https://fypp.readthedocs.io)
View fypp.sublime-build
{
"file_patterns": ["*.fypp", "*.fy90"],
"working_dir": "${file_path}",
"cmd": ["fypp", "${file}", "${file_base_name}.f90"]
}
@ivan-pi
ivan-pi / test_optval.fypp
Created Nov 24, 2021
fypp macros for dealing with Fortran optional arguments
View test_optval.fypp
#! Can be used currently
#:def optval(lhs,opt,default)
${lhs}$ = ${default}$
if (present(${opt}$)) ${lhs}$ = ${opt}$
#:enddef
#! This is the F202X conditional expression syntax
#:def optval2(opt,default)
present(${opt}$)) ? ${opt}$ : ${default}$
#:enddef
@ivan-pi
ivan-pi / lapack_interface.f90
Created Nov 24, 2021
Examle of LU factorization using Fortran parameterized derived types
View lapack_interface.f90
module lapack
implicit none
interface
subroutine sgetrf(m,n,a,lda,ipiv,info)
integer, intent(in) :: m, n, lda
real, intent(inout) :: a(lda,*)
integer, intent(out) :: ipiv(*)
integer, intent(out) :: info
@ivan-pi
ivan-pi / template_ideas.md
Last active Sep 30, 2021
Some ideas for documenting Fortran procedures in (GitHub-Flavored) Markdown documents
View template_ideas.md

Ideas for Fortran documentation in Markdown

Version 1 (f90doc-inspired)

Pros:

  • Terse, reuses actual procedure declaration
  • All argument attributes are visible

Cons:

View pad_mod.f90
module pad_mod
implicit none
interface padl
module procedure padl_blank
module procedure padl_char
end interface
interface padr
@ivan-pi
ivan-pi / integer_list_mod.f90
Created Mar 5, 2021
Fortran experiment with a fixed-size integer list
View integer_list_mod.f90
module integer_list_mod
implicit none
private
public :: integer_list
type :: index_t
private
integer :: idx
@ivan-pi
ivan-pi / chkend.f90
Created Feb 16, 2021
Check processor endianess in Fortran
View chkend.f90
!> Check Endianess
!>
!> Inspect the endianess of the platform.
!>
!> Based on a program posted by @urbanjost (urbanjost@comcast.net)
!> posted at https://github.com/fortran-lang/stdlib/issues/323. The original
!> program was based on ideas from the Code Tuning co-guide, 1998 Lahey Fortran
!> Users' Conference.
!>
!> Author: Ivan Pribec (ivan.pribec@gmail.com)
@ivan-pi
ivan-pi / pcg32.f90
Last active Dec 17, 2020
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.
View pcg32.f90
!
! 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>
!
@ivan-pi
ivan-pi / test_spblas.f90
Last active Dec 25, 2020
Intel MKL Sparse BLAS matrix-vector product example
View test_spblas.f90
! Sparse BLAS matrix-vector product example
!
! The following code demonstrates the creation of
! a CSR matrix, and the sparse matrix-vector product
! using the sparse BLAS functions in Intel MKL.
!
! For linking options for your specific platform see
! the Intel MKL link line advisor located at:
! https://software.intel.com/content/www/us/en/develop/tools/oneapi/components/onemkl/link-line-advisor.html
!