-
Notifications
You must be signed in to change notification settings - Fork 45
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
Adjoint models #107
Comments
I don't know much about adjoints, but if calculating an adjoint can be done by computing the outputs of sympl components with slight perturbations to the inputs about some reference state, then I would say there should be an easy way to do it, but there isn't an existing way to do it. I don't know that anyone has done this before, maybe @JoyMonteiro has some insight. I think the result would make a neat Python package! |
@RPrudden you are correct that this is a non-trivial task. A lot of code in climt is in Fortran, and Even if we did get our hands on code like this, ADs have a hard time dealing with model physics because of strong nonlinearities present in the atmosphere in the presence of clouds and water vapour. See this paper for example. While it would certainly be interesting to see adjoint models for climt components, it is not on my priority list currently. If you are interested, I think the dynamical core would be a good target to develop an adjoint for. |
Many thanks, both! I think computing the adjoint of the dynamical core would be enough to cover the kind of work I have in mind, so I may be able to avoid the difficulties involved in differentiating the physics components. In terms of the dynamical core, it looks like this directory would be the place to start. I guess you were thinking to use autograd to compute the gradients, is that right? |
That directory only contains the wrapper. The actual algorithmic part is written in Fortran and resides The easiest way I would think is to translate the relevant parts to python code and then run autograd on it. There are only two core functions:
which does the actual time stepping and
which calculates the tendencies used by the timestepper. Each will need some helper functions, There is a subtle issue to keep in mind -- There are parts of the code which do differentiation themselves, calling the shtns library. These will have to be translated by hand to calls to differentiation by shtns (there is a python wrapper to shtns, so not a big issue there). I think it is doable, but requires some grunt work! |
Ok, I understand better now. As you say, it looks fairly intensive to translate.. but I am quite interested, so I might try to carve out some time. |
Great!! We can keep this issue open in case you need any other input. While I can't contribute to the coding effort itself, I can certainly take a look at any code or help you to navigate the fortran code. |
A bit of googling around yielded a AD package for Fortran: They seem to have used it for an ocean model (NEMO). |
Has anyone given any thought to calculating the adjoints of CliMT models? As far as I can tell there is no easy way to do this, but I'd be delighted to be wrong.
The text was updated successfully, but these errors were encountered: