To: J3 J3/15-172 Subject: MERGE_PTR intrinsic function From: Van Snyder Reference: 15-007r1 Date: 2015 June 07 1. Proposal =========== Provide a MERGE_PTR intrinsic function that returns a pointer associated with the first argument, or its target if it is a pointer and is associated, if the third argument is true, or the second argument, or its target if it is a pointer and is associated, if the third argument is false. 2. Draft Edits ============== [328 Table 13.1] Insert a row in Table 13.1: "MERGE_PTR (TSOURCE, FSOURCE, MASK) T Pointer selection " [381:6+ 13.8.122+] Insert a subclause " 13.8.121a MERGE_PTR (TSOURCE, FSOURCE, MASK) <> Pointer selection. <> Transformational function. <> TSOURCE may be of any type, kind and rank. It shall be a pointer, or have the TARGET attribute. FSOURCE shall be of the same declared type, kind, and rank as TSOURCE. It shall be a pointer, or have the TARGET attribute. MASK shall be a scalar of type logical. <> A pointer of the same declared type, kind, and rank as TSOURCE. The result is polymorphic if and only if either TSOURCE or FSOURCE is polymorphic. <> Case (i): If MASK is true, the result is a pointer of the same dynamic type, kind and rank as TSOURCE. If TSOURCE is not a pointer, the result is associated with TSOURCE and has the same shape. If TSOURCE is a pointer, the result has the same pointer association status as TSOURCE, and if TSOURCE is associated the result is associated with the same target and has the same shape. Case (ii): If MASK is false, the result is a pointer of the same dynamic type, kind and rank as FSOURCE. If FSOURCE is not a pointer, the result is associated with FSOURCE and has the same shape. If FSOURCE is a pointer, the result has the same pointer association status as FSOURCE, and if FSOURCE is associated the result is associated with the same target and has the same shape. <> If X is a pointer and Y is not a pointer, the result of MERGE_PTR ( X, Y, .TRUE. ) is associated with X, and the result of MERGE_PTR ( X, Y, .FALSE. ) is a pointer having the same pointer association status as Y. If MERGE_PTR ( X, NULL(X), COND ) is an actual argument corresponding to an optional nonpointer dummy argument and X is not a pointer, the dummy argument is present and associated with X if COND is true and absent if COND is false. "