Skip to content

Instantly share code, notes, and snippets.

View zoziha's full-sized avatar
🍭
清风徐来,水波不兴。

ZUO Zhihua zoziha

🍭
清风徐来,水波不兴。
View GitHub Profile
@zoziha
zoziha / RK4-SU.f90
Created October 31, 2025 07:39
大数据集的四阶龙格库塔法
!> 4 阶 Runge-Kutta 法
module runge_kutta_module
use, intrinsic :: iso_fortran_env, only: wp => real32
implicit none
abstract interface
!> `fcn` 计算 ODE 的导数
subroutine fcn(t, y, yp)
import wp
@zoziha
zoziha / RK4-Lite.f90
Last active October 31, 2025 07:18
小数据集的四阶龙格库塔法
!> 4 阶 Runge-Kutta 法
module runge_kutta_module
use, intrinsic :: iso_fortran_env, only: wp => real32
implicit none
abstract interface
!> `fcn` 计算 ODE 的导数
subroutine fcn(t, y, yp)
import wp
@zoziha
zoziha / perf.f90
Created September 5, 2023 16:17
clean Fortran code in JuliaLang/Microbenchmarks
! https://github.com/JuliaLang/Microbenchmarks/blob/master/perf.f90
module types
implicit none
private
public :: dp, i64
integer, parameter :: dp = kind(0.d0) ! double precision
integer, parameter :: i64 = selected_int_kind(18) ! at least 64-bit integer
@zoziha
zoziha / README.md
Created June 11, 2023 05:05
fortran-generics test

Results:

            0
 Time for integer:   0.281250000    
   0.00000000    
 Time for integer(transfer):    2.10937500    
   0.00000000    
 Time for integer(cast by implicit-external):   0.562500000    
 0.00000000 
@zoziha
zoziha / builder.f90
Created October 18, 2021 03:53
Builder Pattern
module builder_module
use, intrinsic :: iso_fortran_env, only: int8
implicit none
private
public :: ibuilder_t, director_t, house_t, get_builder
type, abstract :: ibuilder_t
contains
@zoziha
zoziha / iterator.f90
Last active October 14, 2021 05:39
Iterator Pattern
!> Reference: https://refactoringguru.cn/design-patterns/iterator/go/example
module iterator_module
use, intrinsic :: iso_fortran_env, only: int8
implicit none
private
public :: user_t, user_collection_t, user_iterator_t, iterator_t
!> Abstract types