To: J3 J3/14-147 From: John Reid Subject: Collectives Date: 2014 May 11 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 optimised away (if the compiler can do non-inplace collectives efficiently), and in any case this should be small since no communication is involved. This paper contains edits for this change. They are written without any changes of names, but it has been suggested that "SOURCE" be changed to "A". This name change is included as a global edit at the end. Edits to N2007: --------------- [17:29] Delete "or RESULT". [17:38-39] Change "the RESULT argument becomes undefined ... otherwise" to "the SOURCE argument becomes undefined". [18:10+] In NOTE 7.1, delete "with RESULT not present". [18:10+] Add new note: All the collectives have an argument SOURCE 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:19, 20:35, 21:21, 22:7, and 23:1] After "current team." add to "It is an INTENT(INOUT) argument.". [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 "SOURCE" and delete ", RESULT". [34:14+] In the entries for CO_MAX, CO_MIN, CO_REDUCE and CO_SUM, delete ", RESULT". [Global]. Change "SOURCE" (but not in "SOURCE=") to "A".