Skip to content

ambiguousname/fortran-format-web-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Building

Pre-compiled binaries are included for convenience's sake. If you want to re-create these, you should follow this tutorial.

Major differences between that tutorial and this one are that I'm using LLVM 20.x, so some things will be accordingly changed.

Compiling

Feel free to skip to Part Four if you have no intention of changing the binary .wasm code.

Part One: Setup the LLVM Repo

  1. Clone LLVM on Github.
  2. Apply the Git patch under llvm/llvm-wasm.diff.

Part Two: Build libFortranRuntime for WebAssembly

The FORMAT statement is actually a bunch of disguised calls to libFortranRuntime, so we need to compile these calls to WebAssembly:

  1. Install and activate the emscripten SDK.
  2. Build libFortranRuntime and libFortranDecimal. You can configure with:
    • emcmake cmake -S flang/runtime -B flang/runtime
    • emcmake cmake -S flang/lib/Decimal -B flang/lib/Decimal
    • Then make with emcmake cmake --build <DIRECTORY> for each.
  3. Copy the built libraries to the binaries/libFortran folder of the git project.

Part Three: Building the Program

emcmake cmake -B build
cmake --build build --target=fortran_wasm

Possible Errors

Missing variable is: CMAKE_Fortran_PREPROCESS_SOURCE

I believe this is something specific to Ninja, so you can just re-run emcmake cmake -B build and it should be fixed.

Part Four: Running the Web Demo

npm -C web ci
npm -C web run start --mode development

About

FORMAT statements in WebAssembly

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published