To: J3 J3/14-147r1 From: John Reid & Bill Long Subject: Collectives Date: 2014 June 23 References: N2007, N2013 Discussion ---------- In N2013, Malcolm Cohen says "the collectives CO MAX, CO MIN, CO REDUCE, CO SUM, should be split into two forms, one with RESULT, one without. The one with RESULT should have SOURCE as INTENT(IN), the one without should have SOURCE as INTENT(INOUT). RESULT must not be optional. The SOURCE INTENT(IN) form should have no coarray restrictions on SOURCE." and Nick Maclaren says "This TS introduces a conflict with Fortran 2008's concept and specification of variable definition context. This is definitely fixable, but may need significant changes to the collectives." and he suggests the remedy of splitting the collectives as in this example 7.4.7 CO_MAX (SOURCE [, RESULT, RESULT_IMAGE, STAT, ERRMSG]) or CO_MAX_IN_PLACE (OBJECT [, RESULT_IMAGE, STAT, ERRMSG]) Malcolm suggests moving RESULT to the end of the argument list: 7.4.7 CO_MAX (SOURCE [, RESULT_IMAGE, STAT, ERRMSG, RESULT]) or CO_MAX (SOURCE [, RESULT_IMAGE, STAT, ERRMSG]) and has other suggestions that seem to me to be less attractive. A simpler solution is to remove the argument RESULT and give the argument SOURCE intent(inout). It does not involve a loss of functionality since the call CALL CO_MAX (SOURCE,RESULT) may be replaced by RESULT = SOURCE CALL CO_MAX (RESULT) and the call CALL CO_MAX (SOURCE,RESULT,RESULT_IMAGE) may be replaced by RESULT = SOURCE CALL CO_MAX (RESULT,RESULT_IMAGE) The simple scheme might lead to a slight loss of performance because of the copy, but the copy could be optimized away (if the compiler can do non-inplace collectives efficiently), and in any case this should be small since no communication is involved. Furthermore, the names SOURCE and RESULT are potentially confusing when the input argument is overwritten as the output. Instead, the argument name A is used. This paper contains edits for this change. Edits to N2007: --------------- [17:29] Replace "SOURCE or RESULT" by "A". [17:38-39] Change "the RESULT argument becomes undefined ... otherwise" to "the A argument becomes undefined". [18:10+] In NOTE 7.1, replace the first "SOURCE" by "The argument A", delete "with RESULT not present", and replace the second "SOURCE" by "A". [18:10+] Add new note: All the collectives have an argument A with INTENT(INOUT) that holds the original data on entry and the result on return. If it is desired to retain the original data, this is readily obtained by making a copy before entry. Here is an example: REDUCTION = ORIGINAL CALL CO_MIN(REDUCTION) [20:15-21] Replace "SOURCE" by "A", but do not change "SOURCE_IMAGE". [20:19, 20:35, 21:21, 22:7, and 23:1] After "current team." add to "It is an INTENT(INOUT) argument.". In 7.4.7 CO_MAX, 7.4.8 CO_MIN, 7.4.9 CO_REDUCE, and 7.4.10 CO_SUM replace "SOURCE" by "A". [20:30, 21:16, 22:1, and 22:40] Delete "RESULT, ". [20:39-40, 21:25-26, 22:16-18, and 23:6-7] Delete "RESULT ... current team.". [21:5, 21:32, 22:24, and 23:13] Change "If RESULT and RESULT_IMAGE are not present," to "If RESULT_IMAGE is not present,". [21:6, 21:33, 22:25, and 23:14] Change "If RESULT is not present and" to "If". [21:8-11, 21:35-38, 22:27-30, and 23:16-19] Delete "If RESULT is present and ... not modified.". [21:14-15, 21:41-42, 22:38, and 23:22-23] Change "RESULT" to "A" and delete ", RESULT". [34:14+] In the entries for CO_MAX, CO_MIN, CO_REDUCE and CO_SUM, replace "SOURCE [, RESULT," by "[, ".