Tuesday, April 12, 2022

Read binary Fortran files in Julia

For instance, the matrices G and A22 from blupf90 . Yes, we can, using FortranFiles:

using FortranFiles
Gfile=FortranFile("G")
# read header 
aa,i,val,j=read(Gfile,FString{10},Int32,Float64,Int32)
G=read(Gfile,(Float64,29138,29138))
mean(G)
close(Gfile)