OceanBioME / OceanBioME.jl

🌊 🦠 🌿 A fast and flexible modelling environment written in Julia for modelling the coupled interactions between ocean biogeochemistry, carbonate chemistry, and physics
https://oceanbiome.github.io/OceanBioME.jl/
MIT License
40 stars 19 forks source link

Hard-coded `Float64` values #218

Open glwagner opened 4 days ago

glwagner commented 4 days ago

I suspect there will be people cropping up (👀 @ali-ramadhan) want to use Float32. This will thwart them:

https://github.com/OceanBioME/OceanBioME.jl/blob/3c287d625aa7135c8297fa36b94347979344c235/src/Models/AdvectedPopulations/NPZD.jl#L320

All that's needed is

@inline redfield(::Union{Val{:P}, Val{:Z}, Val{:D}}, bgc::NPZD{FT}) where FT = convert(FT, 6.56)

The key is to never write decimals in source code without convert.

johnryantaylor commented 3 days ago

Thanks for the tip @glwagner!