To: J3 J3/24-187 From: Malcolm Cohen Subject: MAX_RANK proposal (part of auto-generic subprograms) Date: 2024-October-30 References: N2217, 23-223r2, 23-244r1, 24-139r2, 24-168, 24-181. 1. Introduction This paper presents specifications and syntax for MAX_RANK, viz a means of discovering the maximum rank supported by a processor. This is part of the auto-generic subprogram feature for Fortran 202y, but is also more generally useful. 2. Constant or function? Most of the papers so far have envisaged a named constant in the intrinsic module ISO_FORTRAN_ENV, but 24-168 points out that the standard limit on rank is actually a limit on rank+corank, and therefore a function might be more appropriate. If the processor limit is, like the standard, on rank+corank, the maximum rank for a coarray would simply be (the constant) MAX_RANK minus the intended corank. However, there is no requirement that a processor's maximum rank be different for a coarray: for example, a processor could permit rank 15 and corank 15 for the same variable. If MAX_RANK were a function, it could take that into account. 3. Specifications and syntax for MAX_RANK as a named constant (MRS-100) That the intrinsic module ISO_FORTRAN_ENV shall contain a named scalar constant MAX_RANK, of type integer with default kind. (MRS-101) The value of MAX_RANK the maximum rank of array that is supported by the processor. 4. Specifications and syntax for MAX_RANK as a function (MRS-200) That the intrinsic module ISO_FORTRAN_ENV shall contain the simple scalar default integer function MAX_RANK. This function has one optional scalar argument CORANK, of type integer. The value of CORANK shall be non-negative. (MRS-201) If the CORANK argument is absent, the result of MAX_RANK is the maximum rank of array that is supported by the processor. (MRS-202) If the CORANK argument is present with a value less or equal to the maximum corank supported by the processor for a scalar, the result of MAX_RANK(CORANK) is the maximum rank supported for a coarray with corank CORANK. If the CORANK argument is present with a greater value, the result of MAX_RANK is equal to -HUGE(0). Example: For a processor whose limits are exactly the minimum required by the standard, MAX_RANK() = 15 MAX_RANK(1) = 14 MAX_RANK(15) = 0 MAX_RANK(16) = -2147483647 if default integer has 32 bits. For a processor whose maximum rank is 24, and whose maximum rank does not depend on the corank, MAX_RANK() = 24 MAX_RANK(1) = 24 MAX_RANK(24) = 24 MAX_RANK(25) = -2147483647 Note: This function version of MAX_RANK thus also enables discovery of the maximum supported corank, as well as the relationship between maximum rank and corank. (MRS-203) A reference to the function MAX_RANK may appear in a constant expression provided CORANK does not appear or is itself a constant expression. Note: We already allow "transformational" functions from IEEE_ARITHMETIC and IEEE_EXCEPTIONS in constant expressions, so this would involve adding ISO_FORTRAN_ENV to the list in item (11) of 10.1.12 (p173). ===END===