[MITgcm-devel] global_sum_ad.F

Constantinos Evangelinos ce107 at ocean.mit.edu
Wed Dec 22 13:07:04 EST 2004


On Wednesday 22 December 2004 12:48, mlosch at awi-bremerhaven.de wrote:

> OK, I didn't really think, that this was wrong. We were a little confused
> about myThid in the MPI_Bcast argument and I felt I needed to understand
> everything before I start modifying global_max_ad.F (global_admax_r8/4),
> because that's really not correct. Patrick and I see problems in the
> adjoint at tile corners when this rourinte is used. global_admax is the
> identical copy of global_max (except for the order of the arguments) and
> that can't be right. Chris, the adjoint of max(x,y) is 0.5+sign(0.5,x-y)
> and you are right it is not defined for x=y, but if sign(.5,0.) returns
> something (either 0.5 or -0.5) that should not be a serious problem (but
> it's not exactly correct). For the adjoint of global_max, one probably has
> to compute the global maximum of the input parameter and then find out
> which processor hat this maximum value. For this processor the dervative is
> one, the others it is zero. That's the theory, in pratice I haven't got it
> to work, yet, and I probably won't make it this year ...

Using MPI_AllReduce with the MAXLOC operator should give you what you want. 
Then every process can check whether its own MAXLOC vector and if their 
process id is the same as the one stored as a real number in the vector, then 
set the resulting value to one, otherwise set it to zero.

Constantinos
 
-- 
Dr. Constantinos Evangelinos
Department of Earth, Atmospheric and Planetary Sciences
Massachusetts Institute of Technology




More information about the MITgcm-devel mailing list