Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically change parameter and return float types #222

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

jagoosw
Copy link
Collaborator

@jagoosw jagoosw commented Oct 14, 2024

This PR removes hard coded float types in function returns, and sets up most (not worth it to do the sugar kelp model because it has a billion parameters) model setup functions to automatically set the correct float type, or at least be able to set in a simple way, e.g.:

grid = RectilinearGrid(Float32; ...)
bgc = PISCES(; grid) # now has the correct FT
cc = CarbonChemistry(Float32)

cc: @ali-ramadhan @glwagner

Closes #218

@jagoosw jagoosw marked this pull request as ready for review October 15, 2024 18:00
@glwagner
Copy link
Collaborator

That looks nice, two comments:

  1. I prefer bgc = PISCES(grid). The interface is a bit split whether grid should be an arg vs kwarg but I think we have been gradually drifting towards grid as positional arg (the big change is for models, which will have to come later).

  2. There's a discussion about making it easier to change number type here: How can we help users change number type more easily? CliMA/Oceananigans.jl#3800

@glwagner
Copy link
Collaborator

(not worth it to do the sugar kelp model because it has a billion parameters)

I don't follow this statement --- what do you mean?

For situations with large numbers of parameters, you can put them in an Array (like TabluatedAlbedo for ClimaOcean):

https://github.com/CliMA/ClimaOcean.jl/blob/fc175f6c6b3e095bd460d10d323e4361006a5008/src/OceanSeaIceModels/CrossRealmFluxes/tabulated_albedo.jl#L90

Another possibility is to convert at runtime, eg with something like

const parameter = 1.23

f(a::FT) = a + convert(FT, parameter)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hard-coded Float64 values
2 participants