[MITgcm-devel] Makefile for adjoint

Martin Losch Martin.Losch at awi.de
Mon Dec 15 04:37:52 EST 2014


Hi Jean-Michel,

On Dec 15, 2014, at 5:53 AM, Jean-Michel Campin <jmc at ocean.mit.edu> wrote:

> Just to clarify: 
> In case I change one of the src file that TAF has to see,
> the changes you propose do not save the staf stage and recompilation 
> of all AD routines, right ?

You are right: If you change one input source file, you’ll still have to go through the entire procedure of calling taf and compiling ***everything*** (the AD_FILES). For each file my_routine.f you send to taf, you get back a file my_routine_ad.f (or _tl.f) that contains both the adjoint ***and*** the forward routines. The files my_routine.f (in the Makefile $(AD_FILES)) are not compiled, or rather, not linked into mitgcmuv_ad, instead the my_routine_ad.f files ($(AD_FILES:.f=_ad.f) are compiled and linked. This also means that your suggestion:
> Anyway, I think it would be interesting to have this option:
>  sending directly many src files to TAF 
> + compiling separately the FWD routines (as it used to be before the switch 
>  to TAF version 2)
> + compiling separately the AD routines.
cannot work, because the fwd and the ad routines are always in one file and you’ll have to compile them together in one step. The only real advantage of “my” genmake2 is that I can now use make -j and compile many *_ad.f simultaneously instead of just one ad_taf_output.f (which can take very long on some systems, e.g. SX8 (>1hour), and already takes very long on my linux box (many minutes)), and personally, I prefer having multiple files when I want to look at the source code. Having fwd and adj code for one routine in one file is quite convenient for reading the code.
> did not have time to check the list of issues that you listed in README file.
> Also, I don't know what would happen if we had a mistake in forward src file name
> with 2 src files named my_routine.F and my_routine_ad.F ?
see above: the $(AD_FILES) cannot be linked together with $(AD_FILES:.f=_ad.f) because both contain subroutines with the same names. I don’t think that this is a problem. As long as the list of AD_FILES is there, it’s easy to differentiate (via suffix substitution) between these duplicate subroutines.
> 
> But I would suggest to add an option to genmake2 (off by default for now) to 
> generate the new Makefile (multiple src files sent to TAF) and keep the current
> Makefile (single src file sent to TAF) otherwise.
> The list of diff lines (from the patch) does not seem too bad to me (at least 
> much less that the OpenAD specific feature) and could be added to genmake2
> so that we would have both options available.
> 
> What do others think ?
I would like this option (I just didn’t dare to do that myself, because I find genmake2 frightening). It would make it possible to use this capability, and at the same you can avoid the issues that break portability (e.g. sed -i is not POSIX standard), by using the (slower) default. But first I would suggest, that the svd-targets are tested (I don’t know how), and for that we should maybe wait for Patrick or someone elso who knows.

Martin





More information about the MITgcm-devel mailing list