RMetS Early Career Conference, Reading
NVIDIA
NYU
2024-06-09
Some applications in geosciences: 1
Replacing physics-based components of larger models (emulation or data-driven).
Mathematical Bridge by cmglee used under CC BY-SA 3.0
Ideally need to:
inference-engine
, neural-fortran
, own solution etc.forpy.mod
file and compilePython
env
Python
runtime
xkcd #1987 by Randall Munroe, used under CC BY-NC 2.5
Ftorch and TF-lib
Ftorch and TF-lib
Ftorch and TF-lib
Ftorch and TF-lib
Neccessary imports:
use, intrinsic :: iso_c_binding, only: c_int64_t, c_float, c_char, &
c_null_char, c_ptr, c_loc
use ftorch
Loading a pytorch model:
Tensor creation from Fortran arrays:
! Fortran variables
real, dimension(:,:), target :: SST, model_output
! C/Torch variables
integer(c_int), parameter :: dims_T = 2
integer(c_int64_t) :: shape_T(dims_T)
integer(c_int), parameter :: n_inputs = 1
type(torch_tensor), dimension(n_inputs), target :: model_inputs
type(torch_tensor) :: model_output_T
shape_T = shape(SST)
model_inputs(1) = torch_tensor_from_blob(c_loc(SST), dims_T, shape_T &
torch_kFloat64, torch_kCPU)
model_output = torch_tensor_from_blob(c_loc(output), dims_T, shape_T, &
torch_kFloat64, torch_kCPU)
Running the model
Cleaning up:
Investigate the coupling between Fortran, and the PyTorch and Tensorflow models.
Time-height sections of zonal-mean zonal wind (m/s) averaged between ±5o longitude
Timings (real seconds) for computing gravity wave drag.1
Forpy | Direct | % Direct/Forpy | |
---|---|---|---|
PyTorch | 94.43 s | 134.81 s | 142.8 % |
TensorFlow | 667.16 s | 170.31 s | 25.5 % |
Libraries can be found at:
Thanks to:
Get in touch:
Jack Atkinson
Slides available at: https://jackatkinson.net/slides/RMetS/RMetS.html