DaniJonesOcean/ECCO_v4_r2_config

Cost funtion

Closed this issue · 2 comments

Hi, Dr.Dan Jones, Thank you so much for providing this great example of adjoint modeling! It is really helpful to understand adjoint sensitivity studies, especially for the real practice on MITgcm. I was checking how did you write the cost function but didn't find it under /code_ad, I suppose it should be in COST_OPTIONS.h, as referred from the MITgcm manual. But it might be different since you used the ECCO setup. I was just wondering could you please explain where and how you coded the cost function in this example? Thanks in advance!

Hi @oceanography-rookie. I'm glad that you've found the example to be helpful!

As you've deduced, in this example, I've used the "ECCO" setup for the cost function. You can see that in the code_ad/ECCO_OPTIONS.h, in the following lines:

C allow for generic cost function and integral terms
#define ALLOW_GENCOST_CONTRIBUTION
C allow for 3 dimensional generic terms
#define ALLOW_GENCOST3D

This allows for the "generic cost function" to be defined at run time. You define the cost function at run time in the file input/data.ecco. In the case of this example, the cost function is an integral, where the control volume is defined using a mask.

You can read more about this approach here:
https://mitgcm.readthedocs.io/en/latest/ocean_state_est/ocean_state_est.html#generic-cost-function

Please do let me know if you have further questions. : )

Hi @DanJonesOcean Thanks for pointing out and kind explaining! I eventually worked it out by simply modifying cost/cost_accumulate_mean.F and cost/cost_atlantic_heat.F. But I am indeed interested in your approach, cuz my cost function is similar with yours. I might give it another try with ecco general cost fucntion. I'll let you know if I have further question. Thanks again! 👍