From 5863bad719fa0d2154a863058a608a260c1fb684 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 29 Mar 2024 12:20:00 +0000 Subject: [PATCH] docs: update M_intrinsics (#366) Co-authored-by: gnikit <16143716+gnikit@users.noreply.github.com> --- .../internal/intrinsic.procedures.markdown.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fortls/parsers/internal/intrinsic.procedures.markdown.json b/fortls/parsers/internal/intrinsic.procedures.markdown.json index d87d18d9..06f68321 100644 --- a/fortls/parsers/internal/intrinsic.procedures.markdown.json +++ b/fortls/parsers/internal/intrinsic.procedures.markdown.json @@ -2,7 +2,7 @@ "ABS": "## abs\n\n### **Name**\n\n**abs** - \\[NUMERIC\\] Absolute value\n\n### **Synopsis**\n```fortran\n result = abs(a)\n```\n```fortran\n elemental TYPE(kind=KIND) function abs(a)\n\n TYPE(kind=KIND),intent(in) :: a\n```\n### **Characteristics**\n\n- **a** may be any _real_, _integer_, or _complex_ value.\n\n- If **a** is _complex_ the returned value will be a _real_ with the\n same kind as **a**.\n\n Otherwise the returned type and kind is the same as for **a**.\n\n### **Description**\n\n **abs** computes the absolute value of numeric argument **a**.\n\n In mathematics, the absolute value or modulus of a real number **x**,\n denoted **|x|**, is the magnitude of **x** without regard to its sign.\n\n The absolute value of a number may be thought of as its distance from\n zero. So for a complex value the absolute value is a real number\n with magnitude **sqrt(x%re\\*\\*2,x%im\\*\\*2)**, as if the real component\n is the x value and the imaginary value is the y value for the point\n \\.\n\n### **Options**\n\n- **a**\n : The value to compute the absolute value of.\n\n### **Result**\n\n If **a** is of type _integer_ or _real_, the value of the result\n is the absolute value **|a|** and of the same type and kind as the\n input argument.\n\n If **a** is _complex_ with value **(x, y)**, the result is a _real_\n equal to a processor-dependent approximation to\n```fortran\n sqrt(x**2 + y**2)\n```\n computed without undue overflow or underflow (that means the\n computation of the result can overflow the allowed magnitude of the\n real value returned, and that very small values can produce underflows\n if they are squared while calculating the returned value, for example).\n\n That is, if you think of non-complex values as being complex values\n on the x-axis and complex values as being x-y points \n the result of **abs** is the (positive) magnitude of the distance\n of the value from the origin.\n\n### **Examples**\n\nSample program:\n\n```fortran\nprogram demo_abs\nimplicit none\ninteger,parameter :: dp=kind(0.0d0)\n\ninteger :: i = -1\nreal :: x = -1.0\ncomplex :: z = (-3.0,-4.0)\ndoubleprecision :: rr = -45.78_dp\n\ncharacter(len=*),parameter :: &\n ! some formats\n frmt = '(1x,a15,1x,\" In: \",g0, T51,\" Out: \",g0)', &\n frmtc = '(1x,a15,1x,\" In: (\",g0,\",\",g0,\")\",T51,\" Out: \",g0)', &\n g = '(*(g0,1x))'\n\n ! basic usage\n ! any integer, real, or complex type\n write(*, frmt) 'integer ', i, abs(i)\n write(*, frmt) 'real ', x, abs(x)\n write(*, frmt) 'doubleprecision ', rr, abs(rr)\n write(*, frmtc) 'complex ', z, abs(z)\n\n ! You can take the absolute value of any value whose positive value\n ! is representable with the same type and kind.\n write(*, *) 'abs range test : ', abs(huge(0)), abs(-huge(0))\n write(*, *) 'abs range test : ', abs(huge(0.0)), abs(-huge(0.0))\n write(*, *) 'abs range test : ', abs(tiny(0.0)), abs(-tiny(0.0))\n ! A dusty corner is that abs(-huge(0)-1) of an integer would be\n ! a representable negative value on most machines but result in a\n ! positive value out of range.\n\n ! elemental\n write(*, g) ' abs is elemental:', abs([20, 0, -1, -3, 100])\n\n ! COMPLEX input produces REAL output\n write(*, g)' complex input produces real output', &\n & abs(cmplx(30.0_dp,40.0_dp,kind=dp))\n ! dusty corner: \"kind=dp\" is required or the value returned by\n ! CMPLX() is a default real instead of double precision\n\n ! the returned value for complex input can be thought of as the\n ! distance from the origin <0,0>\n write(*, g) ' distance of (', z, ') from zero is', abs( z )\n write(*, g) ' so beware of overflow with complex values'\n !write(*, g) abs(cmplx( huge(0.0), huge(0.0) ))\n write(*, g) ' because the biggest default real is',huge(0.0)\n\nend program demo_abs\n```\nResults:\n```text\n integer In: -1 Out: 1\n real In: -1.000000 Out: 1.000000\n doubleprecision In: -45.78000000000000 Out: 45.78000000000000\n complex In: (-3.000000,-4.000000) Out: 5.000000\n abs range test : 2147483647 2147483647\n abs range test : 3.4028235E+38 3.4028235E+38\n abs range test : 1.1754944E-38 1.1754944E-38\n abs is elemental: 20 0 1 3 100\n complex input produces real output 50.00000000000000\n distance of ( -3.000000 -4.000000 ) from zero is 5.000000\n so beware of overflow with complex values\n Inf\n because the biggest default real is .3402823E+39\n```\n### **Standard**\n\n FORTRAN 77\n\n### **See Also**\n\n[**sign**(3)](#sign)\n\n _fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n", "ACHAR": "## achar\n\n### **Name**\n\n**achar** - \\[CHARACTER:CONVERSION\\] Returns a character in a specified position in the ASCII collating sequence\n\n### **Synopsis**\n```fortran\n result = achar(i [,kind])\n```\n```fortran\n elemental character(len=1,kind=KIND) function achar(i,KIND)\n\n integer(kind=**),intent(in) :: i\n integer(kind=**),intent(in),optional :: KIND\n```\n### **Characteristics**\n\n- a kind designated as ** may be any supported kind for the type\n\n- The _character_ kind returned is the value of **kind** if present.\n otherwise, a single default _character_ is returned.\n\n### **Description**\n\n **achar** returns the character located at position **i** (commonly\n called the _ADE_ or ASCII Decimal Equivalent) in the ASCII collating\n sequence.\n\n The **achar** function is often used for generating in-band escape\n sequences to control terminal attributes, as it makes it easy to print\n unprintable characters such as escape and tab. For example:\n```fortran\n write(*,'(*(a))')achar(27),'[2J'\n```\n will clear the screen on an ANSI-compatible terminal display,\n\n### **Note**\n\nThe ADEs (ASCII Decimal Equivalents) for ASCII are\n```text\n*-------*-------*-------*-------*-------*-------*-------*-------*\n| 00 nul| 01 soh| 02 stx| 03 etx| 04 eot| 05 enq| 06 ack| 07 bel|\n| 08 bs | 09 ht | 10 nl | 11 vt | 12 np | 13 cr | 14 so | 15 si |\n| 16 dle| 17 dc1| 18 dc2| 19 dc3| 20 dc4| 21 nak| 22 syn| 23 etb|\n| 24 can| 25 em | 26 sub| 27 esc| 28 fs | 29 gs | 30 rs | 31 us |\n| 32 sp | 33 ! | 34 \" | 35 # | 36 $ | 37 % | 38 & | 39 ' |\n| 40 ( | 41 ) | 42 * | 43 + | 44 , | 45 - | 46 . | 47 / |\n| 48 0 | 49 1 | 50 2 | 51 3 | 52 4 | 53 5 | 54 6 | 55 7 |\n| 56 8 | 57 9 | 58 : | 59 ; | 60 < | 61 = | 62 > | 63 ? |\n| 64 @ | 65 A | 66 B | 67 C | 68 D | 69 E | 70 F | 71 G |\n| 72 H | 73 I | 74 J | 75 K | 76 L | 77 M | 78 N | 79 O |\n| 80 P | 81 Q | 82 R | 83 S | 84 T | 85 U | 86 V | 87 W |\n| 88 X | 89 Y | 90 Z | 91 [ | 92 \\ | 93 ] | 94 ^ | 95 _ |\n| 96 ` | 97 a | 98 b | 99 c |100 d |101 e |102 f |103 g |\n|104 h |105 i |106 j |107 k |108 l |109 m |110 n |111 o |\n|112 p |113 q |114 r |115 s |116 t |117 u |118 v |119 w |\n|120 x |121 y |122 z |123 { |124 | |125 } |126 ~ |127 del|\n*-------*-------*-------*-------*-------*-------*-------*-------*\n```\n### **Options**\n\n- **i**\n : the _integer_ value to convert to an ASCII character, in the range\n 0 to 127.\n : **achar** shall have the value C for any character\n C capable of representation as a default character.\n\n- **kind**\n : a _integer_ initialization expression indicating the kind\n parameter of the result.\n\n### **Result**\n Assuming **i** has a value in the range 0 <= I <= 127, the result is the\n character in position **i** of the ASCII collating sequence, provided\n the processor is capable of representing that character in the character\n kind of the result; otherwise, the result is processor dependent.\n\n### **Examples**\n\nSample program:\n```fortran\nprogram demo_achar\nuse,intrinsic::iso_fortran_env,only:int8,int16,int32,int64\nimplicit none\ninteger :: i\n i=65\n write(*,'(\"decimal =\",i0)')i\n write(*,'(\"character =\",a1)')achar(i)\n write(*,'(\"binary =\",b0)')achar(i)\n write(*,'(\"octal =\",o0)')achar(i)\n write(*,'(\"hexadecimal =\",z0)')achar(i)\n\n write(*,'(8(i3,1x,a,1x),/)')(i,achar(i), i=32,126)\n\n write(*,'(a)')upper('Mixed Case')\ncontains\n! a classic use of achar(3) is to convert the case of a string\n\npure elemental function upper(str) result (string)\n!\n!$@(#) upper(3f): function to return a trimmed uppercase-only string\n!\n! input string to convert to all uppercase\ncharacter(*), intent(in) :: str\n! output string that contains no miniscule letters\ncharacter(len(str)) :: string\ninteger :: i, iend\ninteger,parameter :: toupper = iachar('A')-iachar('a')\n iend=len_trim(str)\n ! initialize output string to trimmed input string\n string = str(:iend)\n ! process each letter in the string\n do concurrent (i = 1:iend)\n select case (str(i:i))\n ! located miniscule letter\n case ('a':'z')\n ! change miniscule to majuscule letter\n string(i:i) = achar(iachar(str(i:i))+toupper)\n end select\n enddo\nend function upper\nend program demo_achar\n```\nResults:\n```\n decimal =65\n character =A\n binary =1000001\n octal =101\n hexadecimal =41\n 32 33 ! 34 \" 35 # 36 $ 37 % 38 & 39 '\n\n 40 ( 41 ) 42 * 43 + 44 , 45 - 46 . 47 /\n\n 48 0 49 1 50 2 51 3 52 4 53 5 54 6 55 7\n\n 56 8 57 9 58 : 59 ; 60 < 61 = 62 > 63 ?\n\n 64 @ 65 A 66 B 67 C 68 D 69 E 70 F 71 G\n\n 72 H 73 I 74 J 75 K 76 L 77 M 78 N 79 O\n\n 80 P 81 Q 82 R 83 S 84 T 85 U 86 V 87 W\n\n 88 X 89 Y 90 Z 91 [ 92 \\ 93 ] 94 ^ 95 _\n\n 96 ` 97 a 98 b 99 c 100 d 101 e 102 f 103 g\n\n 104 h 105 i 106 j 107 k 108 l 109 m 110 n 111 o\n\n 112 p 113 q 114 r 115 s 116 t 117 u 118 v 119 w\n\n 120 x 121 y 122 z 123 { 124 | 125 } 126 ~\n MIXED CASE\n```\n### **Standard**\n\nFORTRAN 77. KIND argument added Fortran 2003\n\n### **See Also**\n\n[**char**(3)](#char),\n[**iachar**(3)](#iachar),\n[**ichar**(3)](#ichar)\n\n### **Resources**\n\n- [ANSI escape sequences](https://en.wikipedia.org/wiki/ANSI_escape_code)\n- [M_attr module](https://github.com/urbanjost/M_attr) for controlling ANSI-compatible terminals\n\n _fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n", "ACOS": "## acos\n\n### **Name**\n\n**acos** - \\[MATHEMATICS:TRIGONOMETRIC\\] Arccosine (inverse cosine) function\n\n### **Synopsis**\n```fortran\n result = acos(x)\n```\n```fortran\n elemental TYPE(kind=KIND) function acos(x)\n\n TYPE(kind=KIND),intent(in) :: x\n```\n### **Characteristics**\n\n - **TYPE** may be _real_ or _complex_\n - **KIND** may be any kind supported by the associated type.\n - The returned value will be of the same type and kind as the argument.\n\n### **Description**\n\n**acos** computes the arccosine of **x** (inverse of **cos(x)**).\n\n### **Options**\n\n- **x**\n : The value to compute the arctangent of.\n : If the type is _real_, the value must satisfy |**x**| <= 1.\n\n### **Result**\n\nThe return value is of the same type and kind as **x**. The _real_ part of\nthe result is in radians and lies in the range **0 \\<= acos(x%re) \\<= PI** .\n\n### **Examples**\n\nSample program:\n\n```fortran\nprogram demo_acos\nuse, intrinsic :: iso_fortran_env, only : real_kinds,real32,real64,real128\nimplicit none\ncharacter(len=*),parameter :: all='(*(g0,1x))'\nreal(kind=real64) :: x , d2r\n\n ! basics\n x = 0.866_real64\n print all,'acos(',x,') is ', acos(x)\n\n ! acos(-1) should be PI\n print all,'for reference &\n &PI ~= 3.14159265358979323846264338327950288419716939937510'\n write(*,*) acos(-1.0_real64)\n d2r=acos(-1.0_real64)/180.0_real64\n print all,'90 degrees is ', d2r*90.0_real64, ' radians'\n ! elemental\n print all,'elemental',acos([-1.0,-0.5,0.0,0.50,1.0])\n ! complex\n print *,'complex',acos( (-1.0, 0.0) )\n print *,'complex',acos( (-1.0, -1.0) )\n print *,'complex',acos( ( 0.0, -0.0) )\n print *,'complex',acos( ( 1.0, 0.0) )\n\nend program demo_acos\n```\nResults:\n```text\n acos( 0.86599999999999999 ) is 0.52364958093182890\n for reference PI ~= 3.14159265358979323846264338327950288419716939937510\n 3.1415926535897931\n 90 degrees is 1.5707963267948966 radians\n elemental 3.14159274 2.09439516 1.57079637 1.04719758 0.00000000\n complex (3.14159274,-0.00000000)\n complex (2.23703575,1.06127501)\n complex (1.57079637,0.00000000)\n complex (0.00000000,-0.00000000)\n```\n### **Standard**\n\nFORTRAN 77 ; for a _complex_ argument - Fortran 2008\n\n### **See Also**\nInverse function: [**cos**(3)](cos)\n\n### **Resources**\n- [wikipedia: inverse trigonometric functions](https://en.wikipedia.org/wiki/Inverse_trigonometric_functions)\n\n _fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n", - "ACOSH": "## acosh\n\n### **Name**\n\n**acosh** - \\[MATHEMATICS:TRIGONOMETRIC\\] Inverse hyperbolic cosine function\n\n### **Synopsis**\n```fortran\n result = acosh(x)\n```\n```fortran\n elemental TYPE(kind=KIND) function acosh(x)\n\n TYPE(kind=KIND),intent(in) :: x\n```\n### **Characteristics**\n\n - **TYPE** may be _real_ or _complex_\n - **KIND** may be any kind supported by the associated type.\n - The returned value will be of the same type and kind as the argument.\n\n### **Description**\n\n**acosh** computes the inverse hyperbolic cosine of **x** in radians.\n\n### **Options**\n\n- **x**\n : The value to compute the hyperbolic cosine of. A real value should \n be \\>= 1 or the result with be a Nan.\n\n### **Result**\n\nThe result has a value equal to a processor-dependent approximation to\nthe inverse hyperbolic cosine function of X.\n\nIf **x** is _complex_, the imaginary part of the result is in radians\nand lies between\n```fortran\n 0 <= aimag(acosh(x)) <= PI\n```\n### **Examples**\n\nSample program:\n```fortran\nprogram demo_acosh\nuse,intrinsic :: iso_fortran_env, only : dp=>real64,sp=>real32\nimplicit none\nreal(kind=dp), dimension(3) :: x = [ 1.0d0, 2.0d0, 3.0d0 ]\n if( any(x.lt.1) )then\n write (*,*) ' warning: values < 1 are present'\n endif\n write (*,*) acosh(x)\nend program demo_acosh\n```\nResults:\n```text\n 0.000000000000000E+000 1.31695789692482 1.76274717403909\n```\n### **Standard**\n\nFortran 2008\n\n### **See Also**\nInverse function: [**cosh**(3)](#cosh)\n\n### **Resources**\n- [Wikipedia:hyperbolic functions](https://en.wikipedia.org/wiki/Hyperbolic_functions)\n\n _fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n", + "ACOSH": "## acosh\n\n### **Name**\n\n**acosh** - \\[MATHEMATICS:TRIGONOMETRIC\\] Inverse hyperbolic cosine function\n\n### **Synopsis**\n```fortran\n result = acosh(x)\n```\n```fortran\n elemental TYPE(kind=KIND) function acosh(x)\n\n TYPE(kind=KIND),intent(in) :: x\n```\n### **Characteristics**\n\n - **TYPE** may be _real_ or _complex_\n - **KIND** may be any kind supported by the associated type.\n - The returned value will be of the same type and kind as the argument.\n\n### **Description**\n\n**acosh** computes the inverse hyperbolic cosine of **x** in radians.\n\n### **Options**\n\n- **x**\n : The value to compute the hyperbolic cosine of. A real value should\n be \\>= 1 or the result with be a Nan.\n\n### **Result**\n\nThe result has a value equal to a processor-dependent approximation to\nthe inverse hyperbolic cosine function of X.\n\nIf **x** is _complex_, the imaginary part of the result is in radians\nand lies between\n```fortran\n 0 <= aimag(acosh(x)) <= PI\n```\n### **Examples**\n\nSample program:\n```fortran\nprogram demo_acosh\nuse,intrinsic :: iso_fortran_env, only : dp=>real64,sp=>real32\nimplicit none\nreal(kind=dp), dimension(3) :: x = [ 1.0d0, 2.0d0, 3.0d0 ]\n if( any(x.lt.1) )then\n write (*,*) ' warning: values < 1 are present'\n endif\n write (*,*) acosh(x)\nend program demo_acosh\n```\nResults:\n```text\n 0.000000000000000E+000 1.31695789692482 1.76274717403909\n```\n### **Standard**\n\nFortran 2008\n\n### **See Also**\nInverse function: [**cosh**(3)](#cosh)\n\n### **Resources**\n- [Wikipedia:hyperbolic functions](https://en.wikipedia.org/wiki/Hyperbolic_functions)\n\n _fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n", "ADJUSTL": "## adjustl\n\n### **Name**\n\n**adjustl** - \\[CHARACTER:WHITESPACE\\] Left-justified a string\n\n### **Synopsis**\n```fortran\n result = adjustl(string)\n```\n```fortran\n elemental character(len=len(string),kind=KIND) function adjustl(string)\n\n character(len=*,kind=KIND),intent(in) :: string\n```\n### **Characteristics**\n - **string** is a _character_ variable of any supported kind\n - The return value is a _character_ variable of the same kind\n and length as **string**\n\n### **Description**\n\n **adjustl** will left-justify a string by removing leading\n spaces. Spaces are inserted at the end of the string as needed.\n\n### **Options**\n\n- **string**\n : the string to left-justify\n\n### **Result**\n\n A copy of **string** where leading spaces are removed and the same\n number of spaces are inserted on the end of **string**.\n\n### **Examples**\n\nSample program:\n```fortran\nprogram demo_adjustl\nimplicit none\ncharacter(len=20) :: str = ' sample string'\ncharacter(len=:),allocatable :: astr\ninteger :: length\n\n ! basic use\n write(*,'(a,\"[\",a,\"]\")') 'original: ',str\n str=adjustl(str)\n write(*,'(a,\"[\",a,\"]\")') 'adjusted: ',str\n\n ! a fixed-length string can be printed\n ! trimmed using trim(3f) or len_trim(3f)\n write(*,'(a,\"[\",a,\"]\")') 'trimmed: ',trim(str)\n length=len_trim(str)\n write(*,'(a,\"[\",a,\"]\")') 'substring:',str(:length)\n\n ! note an allocatable string stays the same length too\n ! and is not trimmed by just an adjustl(3f) call.\n astr=' allocatable string '\n write(*,'(a,\"[\",a,\"]\")') 'original:',astr\n astr = adjustl(astr)\n write(*,'(a,\"[\",a,\"]\")') 'adjusted:',astr\n ! trim(3f) can be used to change the length\n astr = trim(astr)\n write(*,'(a,\"[\",a,\"]\")') 'trimmed: ',astr\n\nend program demo_adjustl\n```\nResults:\n```text\n original: [ sample string ]\n adjusted: [sample string ]\n trimmed: [sample string]\n substring:[sample string]\n original:[ allocatable string ]\n adjusted:[allocatable string ]\n trimmed: [allocatable string]\n```\n### **Standard**\n\nFortran 95\n\n### **See Also**\n\n[**adjustr**(3)](#adjustr),\n[**trim**(3)](#trim)\n\n _fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n", "ADJUSTR": "## adjustr\n\n### **Name**\n\n**adjustr** - \\[CHARACTER:WHITESPACE\\] Right-justify a string\n\n### **Synopsis**\n```fortran\n result = adjustr(string)\n```\n```fortran\n elemental character(len=len(string),kind=KIND) function adjustr(string)\n\n character(len=*,kind=KIND),intent(in) :: string\n```\n### **Characteristics**\n\n- **string** is a _character_ variable\n- The return value is a _character_ variable of the same kind and\n length as **string**\n\n### **Description**\n\n**adjustr** right-justifies a string by removing trailing spaces. Spaces\nare inserted at the start of the string as needed to retain the original\nlength.\n\n### **Options**\n\n- **string**\n : the string to right-justify\n\n### **Result**\n\nTrailing spaces are removed and the same number of spaces are inserted\nat the start of **string**.\n\n### **Examples**\n\nSample program:\n\n```fortran\nprogram demo_adjustr\nimplicit none\ncharacter(len=20) :: str\n ! print a short number line\n write(*,'(a)')repeat('1234567890',2)\n\n ! basic usage\n str = ' sample string '\n write(*,'(a)') str\n str = adjustr(str)\n write(*,'(a)') str\n\n !\n ! elemental\n !\n write(*,'(a)')repeat('1234567890',5)\n write(*,'(a)')adjustr([character(len=50) :: &\n ' first ', &\n ' second ', &\n ' third ' ])\n write(*,'(a)')repeat('1234567890',5)\n\nend program demo_adjustr\n```\nResults:\n```text\n 12345678901234567890\n sample string\n sample string\n 12345678901234567890123456789012345678901234567890\n first\n second\n third\n 12345678901234567890123456789012345678901234567890\n```\n### **Standard**\n\nFortran 95\n\n### **See Also**\n\n[**adjustl**(3)](#adjustl),\n[**trim**(3)](#trim)\n\n _fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n", "AIMAG": "## aimag\n\n### **Name**\n\n**aimag** - \\[TYPE:NUMERIC\\] Imaginary part of complex number\n\n### **Synopsis**\n```fortran\n result = aimag(z)\n```\n```fortran\n elemental complex(kind=KIND) function aimag(z)\n\n complex(kind=KIND),intent(in) :: z\n```\n### **Characteristics**\n\n- The type of the argument **z** shall be _complex_ and any supported\n _complex_ kind\n\n- The return value is of type _real_ with the kind type parameter of\n the argument.\n\n### **Description**\n\n **aimag** yields the imaginary part of the complex argument **z**.\n\n This is similar to the modern complex-part-designator **%IM** which also\n designates the imaginary part of a value, accept a designator can appear\n on the left-hand side of an assignment as well, as in **val%im=10.0**.\n\n### **Options**\n\n- **z**\n : The _complex_ value to extract the imaginary component of.\n\n### **Result**\n\n The return value is a _real_ value with the magnitude and sign of the\n imaginary component of the argument **z**.\n\n That is, If **z** has the value **(x,y)**, the result has the value\n **y**.\n\n### **Examples**\n\nSample program:\n\n```fortran\nprogram demo_aimag\nuse, intrinsic :: iso_fortran_env, only : real_kinds, &\n & real32, real64, real128\nimplicit none\ncharacter(len=*),parameter :: g='(*(1x,g0))'\ncomplex :: z4\ncomplex(kind=real64) :: z8\n ! basics\n z4 = cmplx(1.e0, 2.e0)\n print *, 'value=',z4\n print g, 'imaginary part=',aimag(z4),'or', z4%im\n\n ! other kinds other than the default may be supported\n z8 = cmplx(3.e0_real64, 4.e0_real64,kind=real64)\n print *, 'value=',z8\n print g, 'imaginary part=',aimag(z8),'or', z8%im\n\n ! an elemental function can be passed an array\n print *\n print *, [z4,z4/2.0,z4+z4,z4**3]\n print *\n print *, aimag([z4,z4/2.0,z4+z4,z4**3])\n\nend program demo_aimag\n```\nResults:\n```text\n value= (1.00000000,2.00000000)\n imaginary part= 2.00000000 or 2.00000000\n value= (3.0000000000000000,4.0000000000000000)\n imaginary part= 4.0000000000000000 or 4.0000000000000000\n\n (1.00000000,2.00000000) (0.500000000,1.00000000) (2.00000000,4.00000000)\n (-11.0000000,-2.00000000)\n\n 2.00000000 1.00000000 4.00000000 -2.00000000\n```\n### **Standard**\n\nFORTRAN 77\n\n### **See Also**\n\n- [**cmplx**(3)](#cmplx) - Complex conversion function\n- [**conjg**(3)](#conjg) - Complex conjugate function\n- [**real**(3)](#real) - Convert to real type\n\nFortran has strong support for _complex_ values, including many intrinsics\nthat take or produce _complex_ values in addition to algebraic and\nlogical expressions:\n\n[**abs**(3)](#abs),\n[**acosh**(3)](#acosh),\n[**acos**(3)](#acos),\n[**asinh**(3)](#asinh),\n[**asin**(3)](#asin),\n[**atan2**(3)](#atan2),\n[**atanh**(3)](#atanh),\n[**atan**(3)](#atan),\n[**cosh**(3)](#cosh),\n[**cos**(3)](#cos),\n[**co_sum**(3)](#co_sum),\n[**dble**(3)](#dble),\n[**dot_product**(3)](#dot_product),\n[**exp**(3)](#exp),\n[**int**(3)](#int),\n[**is_contiguous**(3)](#is_contiguous),\n[**kind**(3)](#kind),\n[**log**(3)](#log),\n[**matmul**(3)](#matmul),\n[**precision**(3)](#precision),\n[**product**(3)](#product),\n[**range**(3)](#range),\n[**rank**(3)](#rank),\n[**sinh**(3)](#sinh),\n[**sin**(3)](#sin),\n[**sqrt**(3)](#sqrt),\n[**storage_size**(3)](#storage_size),\n[**sum**(3)](#sum),\n[**tanh**(3)](#tanh),\n[**tan**(3)](#tan),\n[**unpack**(3)](#unpack),\n\n _fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n", @@ -84,7 +84,7 @@ "FINDLOC": "## findloc\n\n### **Name**\n\n**findloc** - \\[ARRAY:LOCATION\\] Location of first element of ARRAY\nidentified by MASK along dimension DIM matching a target value\n\n### **Synopsis**\n\n```fortran\n result = findloc (array, value, dim [,mask] [,kind] [,back]) |\n findloc (array, value [,mask] [,kind] [,back])\n```\n```fortran\n function findloc (array, value, dim, mask, kind, back)\n\n type(TYPE(kind=KIND)),intent(in) :: array(..)\n type(TYPE(kind=KIND)),intent(in) :: value\n integer(kind=**),intent(in),optional :: dim\n logical(kind=**),intent(in),optional :: mask(..)\n integer(kind=**),intent(in),optional :: kind\n logical(kind=**),intent(in),optional :: back\n```\n### **Characteristics**\n\n- **array** is an array of any intrinsic type.\n- **value** shall be scalar but in type conformance with **array**,\n as specified for the operator == or the operator .EQV..\n- **dim** an _integer_ corresponding to a dimension of **array**.\n The corresponding actual argument shall not be an optional dummy\n argument.\n- **mask** is logical and shall be conformable with **array**.\n- **kind** a scalar integer initialization expression (ie. a constant)\n- **back** a logical scalar.\n- the result is _integer_ of default kind or kind **kind** if the\n **kind** argument is present. If **dim** does not appear, the result\n is an array of rank one and of size equal to the rank of **array**;\n otherwise, the result is an array of the same rank and shape as\n **array** reduced by the dimension **dim**.\n\n**NOTE**: a kind designated as ** may be any supported kind for the type\n\n### **Description**\n\n**findloc** returns the location of the first element of **array**\nidentified by **mask** along dimension **dim** having a value equal\nto **value**.\n\nIf both **array** and **value** are of type logical, the comparison is\nperformed with the **.eqv.** operator; otherwise, the comparison is\nperformed with the == operator. If the value of the comparison is\n_.true._, that element of **array** matches **value**.\n\nIf only one element matches **value**, that element's subscripts are\nreturned. Otherwise, if more than one element matches **value** and\n**back** is absent or present with the value _.false._, the element whose\nsubscripts are returned is the first such element, taken in array\nelement order. If **back** is present with the value _.true._, the element\nwhose subscripts are returned is the last such element, taken in array\nelement order.\n\n### **Options**\n\n- **array**\n : shall be an array of intrinsic type.\n\n- **value**\n : shall be scalar and in type conformance with **array**.\n\n- **dim**\n : shall be an integer scalar with a value in the range 1 <= **DIM** <=\n n, where n is the rank of **array**. The corresponding actual argument\n shall not be an optional dummy argument.\n\n- **mask**\n : (optional) shall be of type logical and shall be conformable with\n **array**.\n\n- **kind**\n : (optional) shall be a scalar integer initialization expression.\n\n- **back**\n : (optional) shall be a logical scalar.\n\n### **Result**\n\n**kind** is present, the kind type\nparameter is that specified by the value of **kind**; otherwise the kind\ntype parameter is that of default integer type. If **dim** does not appear,\nthe result is an array of rank one and of size equal to the rank of\n**array**; otherwise, the result is of rank n - 1 and shape\n```\n [d1, d2, . . ., dDIM-1, dDIM+1, . . ., dn ]\n```\nwhere\n```\n [d1, d2, . . ., dn ]\n```\nis the shape of **array**.\n\n### **Result**\n\n- **Case (i):**\n The result of **findloc (array, value)** is a rank-one array whose\n element values are the values of the subscripts of an element of\n **array** whose value matches **value**. If there is such a value, the\n ith subscript returned lies in the range 1 to ei, where ei is the\n extent of the ith dimension of **array**. If no elements match **value**\n or **array** has size zero, all elements of the result are zero.\n\n- **Case (ii):**\n the result of **findloc (array, value, mask = mask)** is a\n rank-one array whose element values are the values of the subscripts\n of an element of **array**, corresponding to a true element of **mask**,\n whose value matches **value**. If there is such a value, the ith\n subscript returned lies in the range 1 to ei, where ei is the\n extent of the ith dimension of **array**. If no elements match\n **value**, **array** has size zero, or every element of **mask** has the\n value false, all elements of the result are zero.\n\n### **Examples**\n\nSample program:\n\n```fortran\nprogram demo_findloc\nlogical,parameter :: T=.true., F=.false.\ninteger,allocatable :: ibox(:,:)\nlogical,allocatable :: mask(:,:)\n ! basics\n ! the first element matching the value is returned AS AN ARRAY\n call printi('== 6',findloc ([2, 6, 4, 6], value = 6))\n call printi('== 6',findloc ([2, 6, 4, 6], value = 6,back=.true.))\n ! the first element matching the value is returned AS A SCALAR\n call printi('== 6',findloc ([2, 6, 4, 6], value = 6,dim=1))\n call printi('== 6',findloc ([2, 6, 4, 6], value = 6,back=.true.,dim=1))\n\n ibox=reshape([ 0,-5, 7, 7, &\n 3, 4, -1, 2, &\n 1, 5, 6, 7] ,shape=[3,4],order=[2,1])\n\n mask=reshape([ T, T, F, T, &\n T, T, F, T, &\n T, T, F, T] ,shape=[3,4],order=[2,1])\n\n call printi('array is', ibox )\n call printl('mask is', mask )\n print *, 'so for == 7 and back=.false.'\n call printi('so for == 7 the address of the element is', &\n & findloc (ibox, 7, mask = mask) )\n print *, 'so for == 7 and back=.true.'\n call printi('so for == 7 the address of the element is', &\n & findloc (ibox, 7, mask = mask, back=.true.) )\n\n print *,'This is independent of declared lower bounds for the array'\n\n print *, ' using dim=N'\n ibox=reshape([ 1, 2, -9, &\n 2, 2, 6 ] ,shape=[2,3],order=[2,1])\n\n call printi('array is', ibox )\n ! has the value [2, 1, 0] and\n call printi('',findloc (ibox, value = 2, dim = 1) )\n ! has the value [2, 1].\n call printi('',findloc (ibox, value = 2, dim = 2) )\ncontains\n! GENERIC ROUTINES TO PRINT MATRICES\nsubroutine printl(title,a)\nimplicit none\n!@(#) print small 2d logical scalar, vector, matrix in row-column format\ncharacter(len=*),intent(in) :: title\nlogical,intent(in) :: a(..)\n\ncharacter(len=*),parameter :: row='(\" > [ \",*(l1:,\",\"))'\ncharacter(len=*),parameter :: all='(\" \",*(g0,1x))'\nlogical,allocatable :: b(:,:)\ninteger :: i\n write(*,all,advance='no')trim(title)\n ! copy everything to a matrix to keep code simple\n select rank(a)\n rank (0); write(*,'(a)')' (a scalar)'; b=reshape([a],[1,1])\n rank (1); write(*,'(a)')' (a vector)'; b=reshape(a,[size(a),1])\n rank (2); write(*,'(a)')' (a matrix)'; b=a\n rank default; stop '*printl* unexpected rank'\n end select\n do i=1,size(b,dim=1)\n write(*,fmt=row,advance='no')b(i,:)\n write(*,'(\" ]\")')\n enddo\n write(*,all) '>shape=',shape(a),',rank=',rank(a),',size=',size(a)\n write(*,*)\nend subroutine printl\n\nsubroutine printi(title,a)\nimplicit none\n!@(#) print small 2d integer scalar, vector, matrix in row-column format\ncharacter(len=*),intent(in) :: title\ninteger,intent(in) :: a(..)\ncharacter(len=*),parameter :: all='(\" \",*(g0,1x))'\ncharacter(len=20) :: row\ninteger,allocatable :: b(:,:)\ninteger :: i\n write(*,all,advance='no')trim(title)\n ! copy everything to a matrix to keep code simple\n select rank(a)\n rank (0); write(*,'(a)')' (a scalar)'; b=reshape([a],[1,1])\n rank (1); write(*,'(a)')' (a vector)'; b=reshape(a,[size(a),1])\n rank (2); write(*,'(a)')' (a matrix)'; b=a\n rank default; stop '*printi* unexpected rank'\n end select\n ! find how many characters to use for integers\n write(row,'(i0)')ceiling(log10(max(1.0,real(maxval(abs(b))))))+2\n ! use this format to write a row\n row='(\" > [\",*(i'//trim(row)//':,\",\"))'\n do i=1,size(b,dim=1)\n write(*,fmt=row,advance='no')b(i,:)\n write(*,'(\" ]\")')\n enddo\n write(*,all) '>shape=',shape(a),',rank=',rank(a),',size=',size(a)\n write(*,*)\nend subroutine printi\nend program demo_findloc\n```\nResults:\n```text\n > == 6 (a vector)\n > > [ 2 ]\n > >shape= 1 ,rank= 1 ,size= 1\n >\n > == 6 (a vector)\n > > [ 4 ]\n > >shape= 1 ,rank= 1 ,size= 1\n >\n > == 6 (a scalar)\n > > [ 2 ]\n > >shape= ,rank= 0 ,size= 1\n >\n > == 6 (a scalar)\n > > [ 4 ]\n > >shape= ,rank= 0 ,size= 1\n >\n > array is (a matrix)\n > > [ 0, -5, 7, 7 ]\n > > [ 3, 4, -1, 2 ]\n > > [ 1, 5, 6, 7 ]\n > >shape= 3 4 ,rank= 2 ,size= 12\n >\n > mask is (a matrix)\n > > [ T,T,F,T ]\n > > [ T,T,F,T ]\n > > [ T,T,F,T ]\n > >shape= 3 4 ,rank= 2 ,size= 12\n >\n > so for == 7 and back=.false.\n > so for == 7 the address of the element is (a vector)\n > > [ 1 ]\n > > [ 4 ]\n > >shape= 2 ,rank= 1 ,size= 2\n >\n > so for == 7 and back=.true.\n > so for == 7 the address of the element is (a vector)\n > > [ 3 ]\n > > [ 4 ]\n > >shape= 2 ,rank= 1 ,size= 2\n >\n > This is independent of declared lower bounds for the array\n > using dim=N\n > array is (a matrix)\n > > [ 1, 2, -9 ]\n > > [ 2, 2, 6 ]\n > >shape= 2 3 ,rank= 2 ,size= 6\n >\n > (a vector)\n > > [ 2 ]\n > > [ 1 ]\n > > [ 0 ]\n > >shape= 3 ,rank= 1 ,size= 3\n >\n > (a vector)\n > > [ 2 ]\n > > [ 1 ]\n > >shape= 2 ,rank= 1 ,size= 2\n >\n```\n### **Standard**\n\nFortran 95\n\n### **See Also**\n\n - [**maxloc**(3)](#maxloc) - Location of the maximum value within an array\n - [**minloc**(3)](#minloc) - Location of the minimum value within an array\n\n _fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n", "FLOOR": "## floor\n\n### **Name**\n\n**floor** - \\[NUMERIC\\] Function to return largest integral value\nnot greater than argument\n\n### **Synopsis**\n```fortran\n result = floor(a [,kind])\n```\n```fortran\n elemental integer(kind=KIND) function floor( a ,kind )\n\n real(kind=**),intent(in) :: a\n integer(kind=**),intent(in),optional :: KIND\n```\n### **Characteristics**\n\n- a kind designated as ** may be any supported kind for the type\n- **a** is a _real_ of any kind\n- _KIND_ is any valid value for type _integer_.\n- the result is an _integer_ of the specified or default kind\n\n### **Description**\n\n**floor** returns the greatest integer less than or equal to **a**.\n\nIn other words, it picks the whole number at or to the left of the value on\nthe number line.\n\nThis means care has to be taken that the magnitude of the _real_ value **a**\ndoes not exceed the range of the output value, as the range of values supported\nby _real_ values is typically larger than the range for _integers_.\n\n### **Options**\n\n- **a**\n : The value to operate on. Valid values are restricted by the size of\n the returned _integer_ kind to the range **-huge(int(a,kind=KIND))-1**\n to **huge(int(a),kind=KIND)**.\n\n- **kind**\n : A scalar _integer_ constant initialization expression\n indicating the kind parameter of the result.\n\n### **Result**\n\nThe return value is of type _integer(kind)_ if **kind** is present and of\ndefault-kind _integer_ otherwise.\n\nThe result is undefined if it cannot be represented in the specified\ninteger type.\n\nIf in range for the kind of the result the result is the whole number\nat or to the left of the input value on the number line.\n\nIf **a** is positive the result is the value with the fractional part\nremoved.\n\nIf **a** is negative, it is the whole number at or to the left of the\ninput value.\n\n### **Examples**\n\nSample program:\n\n```fortran\nprogram demo_floor\nimplicit none\nreal :: x = 63.29\nreal :: y = -63.59\n print *, x, floor(x)\n print *, y, floor(y)\n ! elemental\n print *,floor([ &\n & -2.7, -2.5, -2.2, -2.0, -1.5, -1.0, -0.5, &\n & 0.0, &\n & +0.5, +1.0, +1.5, +2.0, +2.2, +2.5, +2.7 ])\n\n ! note even a small deviation from the whole number changes the result\n print *, [2.0,2.0-epsilon(0.0),2.0-2*epsilon(0.0)]\n print *,floor([2.0,2.0-epsilon(0.0),2.0-2*epsilon(0.0)])\n\n ! A=Nan, Infinity or huge(0_KIND) is undefined\nend program demo_floor\n```\nResults:\n```text\n > 63.29000 63\n > -63.59000 -64\n > -3 -3 -3 -2 -2 -1\n > -1 0 0 1 1 2\n > 2 2 2\n > 2.000000 2.000000 2.000000\n > 2 1 1\n```\n### **Standard**\n\nFortran 95\n\n### **See Also**\n\n[**ceiling**(3)](#ceiling),\n[**nint**(3)](#nint),\n[**aint**(3)](#aint),\n[**anint**(3)](#anint),\n[**int**(3)](#int),\n[**selected_int_kind**(3)](#selected_int_kind)\n\n _fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n\n", "FRACTION": "## fraction\n\n### **Name**\n\n**fraction** - \\[MODEL_COMPONENTS\\] Fractional part of the model representation\n\n### **Synopsis**\n```fortran\n result = fraction(x)\n```\n```fortran\n elemental real(kind=KIND) function fraction(x)\n\n real(kind=KIND),intent(in) :: fraction\n```\n### **Characteristics**\n\n - **x** is of type _real_\n - The result has the same characteristics as the argument.\n\n### **Description**\n\n **fraction** returns the fractional part of the model representation\n of **x**.\n\n### **Options**\n\n- **x**\n : The value to interrogate\n\n### **Result**\n\nThe fractional part of the model representation of **x** is returned;\nit is **x \\* radix(x)\\*\\*(-exponent(x))**.\n\nIf **x** has the value zero, the result is zero.\n\nIf **x** is an IEEE NaN, the result is that NaN.\n\nIf **x** is an IEEE infinity, the result is an IEEE NaN.\n\n### **Examples**\n\nSample program:\n\n```fortran\nprogram demo_fraction\nimplicit none\nreal :: x\n x = 178.1387e-4\n print *, fraction(x), x * radix(x)**(-exponent(x))\nend program demo_fraction\n```\nResults:\n```text\n 0.5700439 0.5700439\n```\n### **Standard**\n\nFortran 95\n\n### **See Also**\n\n[**digits**(3)](#digits),\n[**epsilon**(3)](#epsilon),\n[**exponent**(3)](#exponent),\n[**huge**(3)](#huge),\n[**maxexponent**(3)](#maxexponent),\n[**minexponent**(3)](#minexponent),\n[**nearest**(3)](#nearest),\n[**precision**(3)](#precision),\n[**radix**(3)](#radix),\n[**range**(3)](#range),\n[**rrspacing**(3)](#rrspacing),\n[**scale**(3)](#scale),\n[**set_exponent**(3)](#set_exponent),\n[**spacing**(3)](#spacing),\n[**tiny**(3)](#tiny)\n\n _fortran-lang intrinsic descriptions_\n", - "GAMMA": "## gamma\n\n### **Name**\n\n**gamma** - \\[MATHEMATICS\\] Gamma function, which yields factorials for positive whole numbers\n\n### **Synopsis**\n```fortran\n result = gamma(x)\n```\n```fortran\n elemental real(kind=KIND) function gamma( x)\n\n type(real,kind=KIND),intent(in) :: x\n```\n### **Characteristics**\n\n - **x** is a _real_ value\n - returns a _real_ value with the kind as **x**.\n\n### **Description**\n\n **gamma(x)** computes Gamma of **x**. For positive whole number values of **n** the\n Gamma function can be used to calculate factorials, as **(n-1)! == gamma(real(n))**.\n That is\n```text\nn! == gamma(real(n+1))\n```\n$$\n\\\\__Gamma__(x) = \\\\int\\_0\\*\\*\\\\infty\nt\\*\\*{x-1}{\\\\mathrm{e}}\\*\\*{__-t__}\\\\,{\\\\mathrm{d}}t\n$$\n\n### **Options**\n\n- **x**\n : Shall be of type _real_ and neither zero nor a negative integer.\n\n### **Result**\n\n The return value is of type _real_ of the same kind as _x_. The result\n has a value equal to a processor-dependent approximation to the gamma\n function of **x**.\n\n### **Examples**\n\nSample program:\n\n```fortran\nprogram demo_gamma\nuse, intrinsic :: iso_fortran_env, only : wp=>real64, int64\nimplicit none\nreal :: x, xa(4)\ninteger :: i, j\n\n ! basic usage\n x = gamma(1.0)\n write(*,*)'gamma(1.0)=',x\n\n ! elemental\n xa=gamma([1.0,2.0,3.0,4.0])\n write(*,*)xa\n write(*,*)\n\n\n ! gamma() is related to the factorial function\n do i = 1, 171\n ! check value is not too big for default integer type\n if (factorial(i) <= huge(0)) then\n write(*,*) i, nint(factorial(i)), 'integer'\n elseif (factorial(i) <= huge(0_int64)) then\n write(*,*) i, nint(factorial(i),kind=int64),'integer(kind=int64)'\n else\n write(*,*) i, factorial(i) , 'user factorial function'\n write(*,*) i, product([(real(j, kind=wp), j=1, i)]), 'product'\n write(*,*) i, gamma(real(i + 1, kind=wp)), 'gamma directly'\n endif\n enddo\n\n\ncontains\nfunction factorial(i) result(f)\n! GAMMA(X) computes Gamma of X. For positive whole number values of N the\n! Gamma function can be used to calculate factorials, as (N-1)! ==\n! GAMMA(REAL(N)). That is\n!\n! n! == gamma(real(n+1))\n!\ninteger, intent(in) :: i\nreal(kind=wp) :: f\n if (i <= 0) then\n write(*,'(*(g0))') ' gamma(3) function value ', i, ' <= 0'\n stop ' bad value in gamma function'\n endif\n f = anint(gamma(real(i + 1,kind=wp)))\nend function factorial\n\nend program demo_gamma\n```\nResults:\n```text\n > gamma(1.0)= 1.00000000 \n > 1.00000000 1.00000000 2.00000000 6.00000000 \n > \n > 1 1 integer\n > 2 2 integer\n > 3 6 integer\n > 4 24 integer\n > 5 120 integer\n > 6 720 integer\n > 7 5040 integer\n > 8 40320 integer\n > 9 362880 integer\n > 10 3628800 integer\n > 11 39916800 integer\n > 12 479001600 integer\n > 13 6227020800 integer(kind=int64)\n > 14 87178291200 integer(kind=int64)\n > 15 1307674368000 integer(kind=int64)\n > 16 20922789888000 integer(kind=int64)\n > 17 355687428096000 integer(kind=int64)\n > 18 6402373705728001 integer(kind=int64)\n > 19 121645100408832000 integer(kind=int64)\n > 20 2432902008176640000 integer(kind=int64)\n > 21 5.1090942171709440E+019 user factorial function\n > 21 5.1090942171709440E+019 product\n > 21 5.1090942171709440E+019 gamma directly\n > :\n > :\n > :\n > 170 7.2574156153079990E+306 user factorial function\n > 170 7.2574156153079940E+306 product\n > 170 7.2574156153079990E+306 gamma directly\n > 171 Infinity user factorial function\n > 171 Infinity product\n > 171 Infinity gamma directly\n```\n\n### **Standard**\n\nFortran 2008\n\n### **See Also**\n\nLogarithm of the Gamma function: [**log_gamma**(3)](#log_gamma)\n\n### **Resources**\n\n[Wikipedia: Gamma_function](https://en.wikipedia.org/wiki/Gamma_function)\n\n _fortran-lang intrinsic descriptions_\n", + "GAMMA": "## gamma\n\n### **Name**\n\n**gamma** - \\[MATHEMATICS\\] Gamma function, which yields factorials for positive whole numbers\n\n### **Synopsis**\n```fortran\n result = gamma(x)\n```\n```fortran\n elemental real(kind=**) function gamma( x)\n\n type(real,kind=**),intent(in) :: x\n```\n### **Characteristics**\n\n - **x** is a _real_ value of any available KIND\n - returns a _real_ value with the same kind as **x**.\n\n### **Description**\n\n **gamma(x)** computes Gamma of **x**. For positive whole number values of **n** the\n Gamma function can be used to calculate factorials, as **(n-1)! == gamma(real(n))**.\n That is\n```text\nn! == gamma(real(n+1))\n```\n$$\n\\\\__Gamma__(x) = \\\\int\\_0\\*\\*\\\\infty\nt\\*\\*{x-1}{\\\\mathrm{e}}\\*\\*{__-t__}\\\\,{\\\\mathrm{d}}t\n$$\n\n### **Options**\n\n- **x**\n : Shall be of type _real_ and neither zero nor a negative integer.\n\n### **Result**\n\n The return value is of type _real_ of the same kind as _x_. The result\n has a value equal to a processor-dependent approximation to the gamma\n function of **x**.\n\n### **Examples**\n\nSample program:\n\n```fortran\nprogram demo_gamma\nuse, intrinsic :: iso_fortran_env, only : wp=>real64, int64\nimplicit none\nreal :: x, xa(4)\ninteger :: i, j\n\n ! basic usage\n x = gamma(1.0)\n write(*,*)'gamma(1.0)=',x\n\n ! elemental\n xa=gamma([1.0,2.0,3.0,4.0])\n write(*,*)xa\n write(*,*)\n\n\n ! gamma() is related to the factorial function\n do i = 1, 171\n ! check value is not too big for default integer type\n if (factorial(i) <= huge(0)) then\n write(*,*) i, nint(factorial(i)), 'integer'\n elseif (factorial(i) <= huge(0_int64)) then\n write(*,*) i, nint(factorial(i),kind=int64),'integer(kind=int64)'\n else\n write(*,*) i, factorial(i) , 'user factorial function'\n write(*,*) i, product([(real(j, kind=wp), j=1, i)]), 'product'\n write(*,*) i, gamma(real(i + 1, kind=wp)), 'gamma directly'\n endif\n enddo\n\n\ncontains\nfunction factorial(i) result(f)\n! GAMMA(X) computes Gamma of X. For positive whole number values of N the\n! Gamma function can be used to calculate factorials, as (N-1)! ==\n! GAMMA(REAL(N)). That is\n!\n! n! == gamma(real(n+1))\n!\ninteger, intent(in) :: i\nreal(kind=wp) :: f\n if (i <= 0) then\n write(*,'(*(g0))') ' gamma(3) function value ', i, ' <= 0'\n stop ' bad value in gamma function'\n endif\n f = anint(gamma(real(i + 1,kind=wp)))\nend function factorial\n\nend program demo_gamma\n```\nResults:\n```text\n > gamma(1.0)= 1.00000000\n > 1.00000000 1.00000000 2.00000000 6.00000000\n >\n > 1 1 integer\n > 2 2 integer\n > 3 6 integer\n > 4 24 integer\n > 5 120 integer\n > 6 720 integer\n > 7 5040 integer\n > 8 40320 integer\n > 9 362880 integer\n > 10 3628800 integer\n > 11 39916800 integer\n > 12 479001600 integer\n > 13 6227020800 integer(kind=int64)\n > 14 87178291200 integer(kind=int64)\n > 15 1307674368000 integer(kind=int64)\n > 16 20922789888000 integer(kind=int64)\n > 17 355687428096000 integer(kind=int64)\n > 18 6402373705728001 integer(kind=int64)\n > 19 121645100408832000 integer(kind=int64)\n > 20 2432902008176640000 integer(kind=int64)\n > 21 5.1090942171709440E+019 user factorial function\n > 21 5.1090942171709440E+019 product\n > 21 5.1090942171709440E+019 gamma directly\n > :\n > :\n > :\n > 170 7.2574156153079990E+306 user factorial function\n > 170 7.2574156153079940E+306 product\n > 170 7.2574156153079990E+306 gamma directly\n > 171 Infinity user factorial function\n > 171 Infinity product\n > 171 Infinity gamma directly\n```\n\n### **Standard**\n\nFortran 2008\n\n### **See Also**\n\nLogarithm of the Gamma function: [**log_gamma**(3)](#log_gamma)\n\n### **Resources**\n\n[Wikipedia: Gamma_function](https://en.wikipedia.org/wiki/Gamma_function)\n\n _fortran-lang intrinsic descriptions_\n", "GET_COMMAND": "## get_command\n\n### **Name**\n\n**get_command** - \\[SYSTEM:COMMAND LINE\\] Get the entire command line invocation\n\n### **Synopsis**\n```fortran\n call get_command([command] [,length] [,status] [,errmsg])\n```\n```fortran\n subroutine get_command( command ,length ,status, errmsg )\n\n character(len=*),intent(out),optional :: command\n integer(kind=**),intent(out),optional :: length\n integer(kind=**),intent(out),optional :: status\n character(len=*),intent(inout),optional :: errmsg\n```\n### **Characteristics**\n\n - a kind designated as ** may be any supported kind for the type\n meeting the conditions described herein.\n - **command** and **errmsg** are scalar _character_ variables of default kind.\n - **length** and **status** are scalar _integer_ with a decimal exponent\n range of at least four.\n\n### **Description**\n\n**get_command** retrieves the entire command line that was used to\ninvoke the program.\n\nNote that what is typed on the command line is often processed by\na shell. The shell typically processes special characters and white\nspace before passing it to the program. The processing can typically be\nturned off by turning off globbing or quoting the command line arguments\nand/or changing the default field separators, but this should rarely\nbe necessary.\n\n### **Result**\n\n- **command**\n : If **command** is present, the entire command line that was used\n to invoke the program is stored into it. If the command cannot be\n determined, **command** is assigned all blanks.\n\n- **length**\n : If **length** is present, it is assigned the length of the command line.\n It is system-dependent as to whether trailing blanks will be counted.\n : If the command length cannot be determined, a length of 0 is assigned.\n\n- **status**\n : If **status** is present, it is assigned 0 upon success of the\n command, **-1** if **command** is too short to store the command line,\n or a positive value in case of an error.\n\n- **errmsg**\n : It is assigned a processor-dependent explanatory message if the\n command retrieval fails. Otherwise, it is unchanged.\n\n### **Examples**\n\nSample program:\n\n```fortran\nprogram demo_get_command\nimplicit none\ninteger :: command_line_length\ncharacter(len=:),allocatable :: command_line\n ! get command line length\n call get_command(length=command_line_length)\n ! allocate string big enough to hold command line\n allocate(character(len=command_line_length) :: command_line)\n ! get command line as a string\n call get_command(command=command_line)\n ! trim leading spaces just in case\n command_line=adjustl(command_line)\n write(*,'(\"OUTPUT:\",a)')command_line\nend program demo_get_command\n```\nResults:\n```bash\n # note that shell expansion removes some of the whitespace\n # without quotes\n ./test_get_command arguments on command line to echo\n\n OUTPUT:./test_get_command arguments on command line to echo\n\n # using the bash shell with single quotes\n ./test_get_command 'arguments *><`~[]!{}?\"\\'| '\n\n OUTPUT:./test_get_command arguments *><`~[]!{}?\"'|\n```\n### **Standard**\n\nFortran 2003\n\n### **See Also**\n\n[**get_command_argument**(3)](#get_command_argument),\n[**command_argument_count**(3)](#command_argument_count)\n\n _fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n#\n", "GET_COMMAND_ARGUMENT": "## get_command_argument\n\n### **Name**\n\n**get_command_argument** - \\[SYSTEM:COMMAND LINE\\] Get command line arguments\n\n### **Synopsis**\n```fortran\n call get_command_argument(number [,value] [,length] &\n & [,status] [,errmsg])\n```\n```fortran\n subroutine get_command_argument( number, value, length, &\n & status ,errmsg)\n\n integer(kind=**),intent(in) :: number\n character(len=*),intent(out),optional :: value\n integer(kind=**),intent(out),optional :: length\n integer(kind=**),intent(out),optional :: status\n character(len=*),intent(inout),optional :: errmsg\n```\n### **Characteristics**\n\n - a kind designated as ** may be any supported kind for the type\n meeting the conditions described herein.\n - **number**, **length**, and **status** are scalar _integer_\n with a decimal exponent range of at least four.\n - **value** and **errmsg** are scalar _character_ variables of default\n kind.\n\n### **Description**\n\n**get_command_argument** retrieves or queries the n-th argument that\nwas passed on the command line to the current program execution.\n\nThere is not anything specifically stated about what an argument is but\nin practice the arguments are strings split on whitespace unless the\narguments are quoted. IFS values (Internal Field Separators) used by\ncommon shells are typically ignored and unquoted whitespace is almost\nalways the separator.\n\nShells have often expanded command arguments and spell characters before\npassing them to the program, so the strings read are often not exactly\nwhat the user typed on the command line.\n\n### **Options**\n\n- **number**\n : is a non-negative number indicating which argument of the current\n program command line is to be retrieved or queried.\n : If **number = 0**, the argument pointed to is set to the name of the\n program (on systems that support this feature).\n : if the processor does not have such a concept as a command name the\n value of command argument 0 is processor dependent.\n : For values from 1 to the number of arguments passed to the program a\n value is returned in an order determined by the processor. Conventionally\n they are returned consecutively as they appear on the command line from\n left to right.\n\n### **Result**\n\n- **value**\n : The **value** argument holds the command line argument.\n If **value** can not hold the argument, it is truncated to fit the\n length of **value**.\n : If there are less than **number** arguments specified at the command\n line or if the argument specified does not exist for other reasons,\n **value** will be filled with blanks.\n\n- **length**\n : The **length** argument contains the length of the n-th command\n line argument. The length of **value** has no effect on this value,\n It is the length required to hold all the significant characters of\n the argument regardless of how much storage is provided by **value**.\n\n- **status**\n : If the argument retrieval fails, **status** is a positive number;\n if **value** contains a truncated command line argument, **status**\n is **-1**; and otherwise the **status** is zero.\n\n### **Examples**\n\nSample program:\n```fortran\nprogram demo_get_command_argument\nimplicit none\ncharacter(len=255) :: progname\ninteger :: count, i, argument_length, istat\ncharacter(len=:),allocatable :: arg\n\n ! command name assuming it is less than 255 characters in length\n call get_command_argument (0, progname, status=istat)\n if (istat == 0) then\n print *, \"The program's name is \" // trim (progname)\n else\n print *, \"Could not get the program's name \" // trim (progname)\n endif\n\n ! get number of arguments\n count = command_argument_count()\n write(*,*)'The number of arguments is ',count\n\n !\n ! allocate string array big enough to hold command line\n ! argument strings and related information\n !\n do i=1,count\n call get_command_argument(number=i,length=argument_length)\n if(allocated(arg))deallocate(arg)\n allocate(character(len=argument_length) :: arg)\n call get_command_argument(i, arg,status=istat)\n ! show the results\n write (*,'(i3.3,1x,i0.5,1x,i0.5,1x,\"[\",a,\"]\")') &\n & i,istat,argument_length,arg\n enddo\n\nend program demo_get_command_argument\n```\nResults:\n```text\n./demo_get_command_argument a test 'of getting arguments ' \" leading\"\n```\n```text\n The program's name is ./demo_get_command_argument\n The number of arguments is 4\n001 00000 00001 [a]\n002 00000 00004 [test]\n003 00000 00022 [of getting arguments ]\n004 00000 00008 [ leading]\n```\n### **Standard**\n\nFortran 2003\n\n### **See Also**\n\n[**get_command**(3)](#get_command),\n[**command_argument_count**(3)](#command_argument_count)\n\n_fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n#\n", "GET_ENVIRONMENT_VARIABLE": "## get_environment_variable\n\n### **Name**\n\n**get_environment_variable** - \\[SYSTEM:ENVIRONMENT\\] Get value of an environment variable\n\n### **Synopsis**\n```fortran\n call get_environment_variable(name [,value] [,length] &\n & [,status] [,trim_name] [,errmsg] )\n```\n```fortran\n subroutine character(len=*) get_environment_variable( &\n & name, value, length, status, trim_name, errmsg )\n\n character(len=*),intent(in) :: name\n character(len=*),intent(out),optional :: value\n integer(kind=**),intent(out),optional :: length\n integer(kind=**),intent(out),optional :: status\n logical,intent(out),optional :: trim_name\n character(len=*),intent(inout),optional :: errmsg\n```\n### **Characteristics**\n\n - a kind designated as ** may be any supported kind for the type\n meeting the conditions described herein.\n - **name**, **value**, and **errmsg** are a scalar _character_ of\n default kind.\n - **length** and **status** are _integer_ scalars with a decimal exponent\n range of at least four.\n - **trim_name** is a scalar of type _logical_ and of default kind.\n\n### **Description**\n\n**get_environment_variable** gets the **value** of the environment\nvariable **name**.\n\nNote that **get_environment_variable** need not be thread-safe. It\nis the responsibility of the user to ensure that the environment is not\nbeing updated concurrently.\n\nIf running in parallel be aware\nIt is processor dependent whether an environment variable that exists\non an image also exists on another image, and if it does exist on both\nimages whether the values are the same or different.\n\n### **Options**\n\n- **name**\n : The name of the environment variable to query.\n The interpretation of case is processor dependent.\n\n### **Result**\n\n- **value**\n : The value of the environment variable being queried. If **value**\n is not large enough to hold the data, it is truncated. If the variable\n **name** is not set or has no value, or the processor does not support\n environment variables **value** will be filled with blanks.\n\n- **length**\n : Argument **length** contains the length needed for storing the\n environment variable **name**. It is zero if the environment variable\n is not set.\n\n- **status**\n : **status** is **-1** if **value** is present but too short for the\n environment variable; it is **1** if the environment variable does\n not exist and **2** if the processor does not support environment\n variables; in all other cases **status** is zero.\n\n- **trim_name**\n : If **trim_name** is present with the value _.false._, the trailing\n blanks in **name** are significant; otherwise they are not part of\n the environment variable name.\n\n### **Examples**\n\nSample program:\n```fortran\nprogram demo_getenv\nimplicit none\ncharacter(len=:),allocatable :: homedir\ncharacter(len=:),allocatable :: var\n\n var='HOME'\n homedir=get_env(var)\n write (*,'(a,\"=\"\"\",a,\"\"\"\")')var,homedir\n\ncontains\n\nfunction get_env(name,default) result(value)\n! a function that makes calling get_environment_variable(3) simple\nimplicit none\ncharacter(len=*),intent(in) :: name\ncharacter(len=*),intent(in),optional :: default\ncharacter(len=:),allocatable :: value\ninteger :: howbig\ninteger :: stat\ninteger :: length\n length=0\n value=''\n if(name.ne.'')then\n call get_environment_variable( name, &\n & length=howbig,status=stat,trim_name=.true.)\n select case (stat)\n case (1)\n print *, name, \" is not defined in the environment. Strange...\"\n value=''\n case (2)\n print *, &\n \"This processor does not support environment variables. Boooh!\"\n value=''\n case default\n ! make string of sufficient size to hold value\n if(allocated(value))deallocate(value)\n allocate(character(len=max(howbig,1)) :: value)\n ! get value\n call get_environment_variable( &\n & name,value,status=stat,trim_name=.true.)\n if(stat.ne.0)value=''\n end select\n endif\n if(value.eq.''.and.present(default))value=default\nend function get_env\n\nend program demo_getenv\n```\nTypical Results:\n```text\n HOME=\"/home/urbanjs\"\n```\n### **Standard**\n\nFortran 2003\n\n### **See also**\n\n[**get_command_argument**(3)](#get_command_argument),\n[**get_command**(3)](#get_command)\n\n _fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n#\n", @@ -130,7 +130,7 @@ "MAXEXPONENT": "## maxexponent\n\n### **Name**\n\n**maxexponent** - \\[NUMERIC MODEL\\] Maximum exponent of a real kind\n\n### **Synopsis**\n```fortran\n result = maxexponent(x)\n```\n```fortran\n elemental integer function maxexponent(x)\n\n real(kind=**),intent(in) :: x\n```\n### **Characteristics**\n\n - **x** is a _real_ scalar or array of any _real_ kind\n - the result is a default _integer_ scalar\n\n### **Description**\n\n **maxexponent** returns the maximum exponent in the model of the\n type of **x**.\n\n### **Options**\n\n- **x**\n : A value used to select the kind of _real_ to return a value for.\n\n### **Result**\n\n The value returned is the maximum exponent for the kind of the value\n queried\n\n### **Examples**\n\nSample program:\n```fortran\nprogram demo_maxexponent\nuse, intrinsic :: iso_fortran_env, only : real32,real64,real128\nimplicit none\ncharacter(len=*),parameter :: g='(*(g0,1x))'\n print g, minexponent(0.0_real32), maxexponent(0.0_real32)\n print g, minexponent(0.0_real64), maxexponent(0.0_real64)\n print g, minexponent(0.0_real128), maxexponent(0.0_real128)\nend program demo_maxexponent\n```\nResults:\n```text\n -125 128\n -1021 1024\n -16381 16384\n```\n### **Standard**\n\nFortran 95\n\n### **See Also**\n\n[**digits**(3)](#digits),\n[**epsilon**(3)](#epsilon),\n[**exponent**(3)](#exponent),\n[**fraction**(3)](#fraction),\n[**huge**(3)](#huge),\n[**minexponent**(3)](#minexponent),\n[**nearest**(3)](#nearest),\n[**precision**(3)](#precision),\n[**radix**(3)](#radix),\n[**range**(3)](#range),\n[**rrspacing**(3)](#rrspacing),\n[**scale**(3)](#scale),\n[**set_exponent**(3)](#set_exponent),\n[**spacing**(3)](#spacing),\n[**tiny**(3)](#tiny)\n\n _fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n", "MAXLOC": "## maxloc\n\n### **Name**\n\n**maxloc** - \\[ARRAY:LOCATION\\] Location of the maximum value within an array\n\n### **Synopsis**\n```fortran\n result = maxloc(array [,mask]) | maxloc(array [,dim] [,mask])\n```\n```fortran\n NUMERIC function maxloc(array, dim, mask)\n\n NUMERIC,intent(in) :: array(..)\n integer(kind=**),intent(in),optional :: dim\n logical(kind=**),intent(in),optional :: mask(..)\n```\n### **Characteristics**\n\n - a kind designated as ** may be any supported kind for the type\n - **NUMERIC** designates any intrinsic numeric type and kind.\n\n### **Description**\n\n**maxloc** determines the location of the element in the array with\nthe maximum value, or, if the **dim** argument is supplied, determines\nthe locations of the maximum element along each row of the array in the\n**dim** direction.\n\nIf **mask** is present, only the elements for which **mask**\nis _.true._ are considered. If more than one element in the array has\nthe maximum value, the location returned is that of the first such element\nin array element order.\n\nIf the array has zero size, or all of the elements\nof **mask** are .false., then the result is an array of zeroes. Similarly,\nif **dim** is supplied and all of the elements of **mask** along a given\nrow are zero, the result value for that row is zero.\n\n### **Options**\n\n- **array**\n : Shall be an array of type _integer_, _real_, or _character_.\n\n- **dim**\n : (Optional) Shall be a scalar of type _integer_, with a value between\n one and the rank of **array**, inclusive. It may not be an optional\n dummy argument.\n\n- **mask**\n : Shall be an array of type _logical_, and conformable with **array**.\n\n### **Result**\n\nIf **dim** is absent, the result is a rank-one array with a length equal\nto the rank of **array**. If **dim** is present, the result is an array\nwith a rank one less than the rank of **array**, and a size corresponding\nto the size of **array** with the **dim** dimension removed. If **dim**\nis present and **array** has a rank of one, the result is a scalar. In\nall cases, the result is of default _integer_ type.\n\nThe value returned is reference to the offset from the beginning of the\narray, not necessarily the subscript value if the array subscripts do\nnot start with one.\n\n### **Examples**\n\nsample program\n\n```fortran\nprogram demo_maxloc\nimplicit none\ninteger :: ii\ninteger,save :: i(-3:3)=[(abs(abs(ii)-50),ii=-3,3)]\ninteger,save :: ints(3,5)= reshape([&\n 1, 2, 3, 4, 5, &\n 10, 20, 30, 40, 50, &\n 11, 22, 33, 44, 55 &\n],shape(ints),order=[2,1])\n\n write(*,*) maxloc(ints)\n write(*,*) maxloc(ints,dim=1)\n write(*,*) maxloc(ints,dim=2)\n ! when array bounds do not start with one remember MAXLOC(3) returns\n ! the offset relative to the lower bound-1 of the location of the\n ! maximum value, not the subscript of the maximum value. When the\n ! lower bound of the array is one, these values are the same. In\n ! other words, MAXLOC(3) returns the subscript of the value assuming\n ! the first subscript of the array is one no matter what the lower\n ! bound of the subscript actually is.\n write(*,'(g0,1x,g0)') (ii,i(ii),ii=lbound(i,dim=1),ubound(i,dim=1))\n write(*,*)maxloc(i)\n\nend program demo_maxloc\n```\n\nResults:\n\n```text\n > 3 5\n > 3 3 3 3 3\n > 5 5 5\n > -3 47\n > -2 48\n > -1 49\n > 0 50\n > 1 49\n > 2 48\n > 3 47\n```\n\n### **Standard**\n\nFortran 95\n\n### **See Also**\n\n - [**findloc**(3)](#findloc) - Location of first element of ARRAY\n identified by MASK along dimension DIM matching a target\n - [**minloc**(3)](#minloc) - Location of the minimum value within an array\n - [**maxval**(3)](#maxval)\n - [**minval**(3)](#minval)\n - [**max**(3)](#max)\n\n _fortran-lang intrinsic descriptions_\n", "MAXVAL": "## maxval\n\n### **Name**\n\n**maxval** - \\[ARRAY:REDUCTION\\] Determines the maximum value in an array or row\n\n### **Synopsis**\n```fortran\n result = maxval(array [,mask]) | maxval(array [,dim] [,mask])\n```\n```fortran\n NUMERIC function maxval(array ,dim, mask)\n\n NUMERIC,intent(in) :: array(..)\n integer(kind=**),intent(in),optional :: dim\n logical(kind=**),intent(in),optional :: mask(..)\n```\n### **Characteristics**\n\n - a kind designated as ** may be any supported kind for the type\n - **NUMERIC** designates any numeric type and kind.\n\n### **Description**\n\n **maxval** determines the maximum value of the elements in an\n array value, or, if the **dim** argument is supplied, determines the\n maximum value along each row of the array in the **dim** direction. If\n **mask** is present, only the elements for which **mask** is _.true._\n are considered. If the array has zero size, or all of the elements of\n **mask** are _.false._, then the result is the most negative number\n of the type and kind of **array** if **array** is numeric, or a string\n of nulls if **array** is of character type.\n\n### **Options**\n\n- **array**\n : Shall be an array of type _integer_, _real_, or _character_.\n\n- **dim**\n : (Optional) Shall be a scalar of type _integer_, with a value between\n one and the rank of **array**, inclusive. It may not be an optional\n dummy argument.\n\n- **mask**\n : (Optional) Shall be an array of type _logical_, and conformable with\n **array**.\n\n### **Result**\n\nIf **dim** is absent, or if **array** has a rank of one, the result is a scalar.\nIf **dim** is present, the result is an array with a rank one less than the\nrank of **array**, and a size corresponding to the size of **array** with the\n**dim** dimension removed. In all cases, the result is of the same type and\nkind as **array**.\n\n### **Examples**\n\nsample program:\n\n```fortran\nprogram demo_maxval\nimplicit none\ninteger,save :: ints(3,5)= reshape([&\n 1, 2, 3, 4, 5, &\n 10, 20, 30, 40, 50, &\n 11, 22, 33, 44, 55 &\n],shape(ints),order=[2,1])\n\n write(*,*) maxval(ints)\n write(*,*) maxval(ints,dim=1)\n write(*,*) maxval(ints,dim=2)\n ! find biggest number less than 30 with mask\n write(*,*) maxval(ints,mask=ints.lt.30)\nend program demo_maxval\n```\nResults:\n```\n > 55\n > 11 22 33 44 55\n > 5 50 55\n > 22\n```\n### **Standard**\n\nFortran 95\n\n### **See Also**\n\n[**maxloc**(3)](#maxloc),\n[**minloc**(3)](#minloc),\n[**minval**(3)](#minval),\n[**max**(3)](#max),\n[**min**(3)](#min)\n\n _fortran-lang intrinsic descriptions_\n", - "MERGE": "## merge\n\n### **Name**\n\n**merge** - \\[ARRAY:CONSTRUCTION\\] Merge variables\n\n### **Synopsis**\n```fortran\n result = merge(tsource, fsource, mask)\n```\n```fortran\n elemental type(TYPE(kind=KIND)) function merge(tsource,fsource,mask)\n\n type(TYPE(kind=KIND)),intent(in) :: tsource\n type(TYPE(kind=KIND)),intent(in) :: fsource\n logical(kind=**),intent(in) :: mask\n mask** : Shall be of type logical.\n```\n### **Characteristics**\n\n - a kind designated as ** may be any supported kind for the type\n - **tsource** May be of any type, including user-defined.\n - **fsource** Shall be of the same type and type parameters as **tsource**.\n - **mask** shall be of type logical.\n - The result will by of the same type and type parameters as **tsource**.\n\n\n### **Description**\n\nThe elemental function **merge** selects values from two arrays or\nscalars according to a logical mask. The result is equal to an element\nof **tsource** where the corresponding element of **mask** is _.true._, or an\nelement of **fsource** when it is _.false._ .\n\nMulti-dimensional arrays are supported.\n\nNote that argument expressions to **merge** are not required to be\nshort-circuited so (as an example) if the array **x** contains zero values\nin the statement below the standard does not prevent floating point\ndivide by zero being generated; as **1.0/x** may be evaluated for all values\nof **x** before the mask is used to select which value to retain:\n\n```fortran\n y = merge( 1.0/x, 0.0, x /= 0.0 )\n```\n\nNote the compiler is also free to short-circuit or to generate an\ninfinity so this may work in many programming environments but is not\nrecommended.\n\nFor cases like this one may instead use masked assignment via the **where**\nconstruct:\n\n```fortran\n where(x .ne. 0.0)\n y = 1.0/x\n elsewhere\n y = 0.0\n endwhere\n```\n\ninstead of the more obscure\n\n```fortran\n merge(1.0/merge(x,1.0,x /= 0.0), 0.0, x /= 0.0)\n```\n### **Options**\n\n- **tsource**\n : May be of any type, including user-defined.\n\n- **fsource**\n : Shall be of the same type and type parameters as **tsource**.\n\n- **mask**\n : Shall be of type _logical_.\n\nNote that (currently) _character_ values must be of the same length.\n\n### **Result**\n The result is built from an element of **tsource** if **mask** is\n _.true._ and from **fsource** otherwise.\n\n Because **tsource** and **fsource** are required to have the same type\n and type parameters (for both the declared and dynamic types), the\n result is polymorphic if and only if both **tsource** and **fsource**\n are polymorphic.\n\n### **Examples**\n\nSample program:\n```fortran\nprogram demo_merge\nimplicit none\ninteger :: tvals(2,3), fvals(2,3), answer(2,3)\nlogical :: mask(2,3)\ninteger :: i\ninteger :: k\nlogical :: chooseleft\n\n ! Works with scalars\n k=5\n write(*,*)merge (1.0, 0.0, k > 0)\n k=-2\n write(*,*)merge (1.0, 0.0, k > 0)\n\n ! set up some simple arrays that all conform to the\n ! same shape\n tvals(1,:)=[ 10, -60, 50 ]\n tvals(2,:)=[ -20, 40, -60 ]\n\n fvals(1,:)=[ 0, 3, 2 ]\n fvals(2,:)=[ 7, 4, 8 ]\n\n mask(1,:)=[ .true., .false., .true. ]\n mask(2,:)=[ .false., .false., .true. ]\n\n ! lets use the mask of specific values\n write(*,*)'mask of logicals'\n answer=merge( tvals, fvals, mask )\n call printme()\n\n ! more typically the mask is an expression\n write(*, *)'highest values'\n answer=merge( tvals, fvals, tvals > fvals )\n call printme()\n\n write(*, *)'lowest values'\n answer=merge( tvals, fvals, tvals < fvals )\n call printme()\n\n write(*, *)'zero out negative values'\n answer=merge( 0, tvals, tvals < 0)\n call printme()\n\n write(*, *)'binary choice'\n chooseleft=.false.\n write(*, '(3i4)')merge([1,2,3],[10,20,30],chooseleft)\n chooseleft=.true.\n write(*, '(3i4)')merge([1,2,3],[10,20,30],chooseleft)\n\ncontains\n\nsubroutine printme()\n write(*, '(3i4)')(answer(i, :), i=1, size(answer, dim=1))\nend subroutine printme\n\nend program demo_merge\n```\nResults:\n```text\n > 1.00000000 \n > 0.00000000 \n > mask of logicals\n > 10 3 50\n > 7 4 -60\n > highest values\n > 10 3 50\n > 7 40 8\n > lowest values\n > 0 -60 2\n > -20 4 -60\n > zero out negative values\n > 10 0 50\n > 0 40 0\n > binary choice\n > 10 20 30\n > 1 2 3\n```\n### **Standard**\n\nFortran 95\n\n### **See Also**\n\n- [**pack**(3)](#pack) packs an array into an array of rank one\n- [**spread**(3)](#spread) is used to add a dimension and replicate data\n- [**unpack**(3)](#unpack) scatters the elements of a vector\n- [**transpose**(3)](#transpose) - Transpose an array of rank two\n\n _fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n", + "MERGE": "## merge\n\n### **Name**\n\n**merge** - \\[ARRAY:CONSTRUCTION\\] Merge variables\n\n### **Synopsis**\n```fortran\n result = merge(tsource, fsource, mask)\n```\n```fortran\n elemental type(TYPE(kind=KIND)) function merge(tsource,fsource,mask)\n\n type(TYPE(kind=KIND)),intent(in) :: tsource\n type(TYPE(kind=KIND)),intent(in) :: fsource\n logical(kind=**),intent(in) :: mask\n mask** : Shall be of type logical.\n```\n### **Characteristics**\n\n - a kind designated as ** may be any supported kind for the type\n - **tsource** May be of any type, including user-defined.\n - **fsource** Shall be of the same type and type parameters as **tsource**.\n - **mask** shall be of type logical.\n - The result will by of the same type and type parameters as **tsource**.\n\n\n### **Description**\n\nThe elemental function **merge** selects values from two arrays or\nscalars according to a logical mask. The result is equal to an element\nof **tsource** where the corresponding element of **mask** is _.true._, or an\nelement of **fsource** when it is _.false._ .\n\nMulti-dimensional arrays are supported.\n\nNote that argument expressions to **merge** are not required to be\nshort-circuited so (as an example) if the array **x** contains zero values\nin the statement below the standard does not prevent floating point\ndivide by zero being generated; as **1.0/x** may be evaluated for all values\nof **x** before the mask is used to select which value to retain:\n\n```fortran\n y = merge( 1.0/x, 0.0, x /= 0.0 )\n```\n\nNote the compiler is also free to short-circuit or to generate an\ninfinity so this may work in many programming environments but is not\nrecommended.\n\nFor cases like this one may instead use masked assignment via the **where**\nconstruct:\n\n```fortran\n where(x .ne. 0.0)\n y = 1.0/x\n elsewhere\n y = 0.0\n endwhere\n```\n\ninstead of the more obscure\n\n```fortran\n merge(1.0/merge(x,1.0,x /= 0.0), 0.0, x /= 0.0)\n```\n### **Options**\n\n- **tsource**\n : May be of any type, including user-defined.\n\n- **fsource**\n : Shall be of the same type and type parameters as **tsource**.\n\n- **mask**\n : Shall be of type _logical_.\n\nNote that (currently) _character_ values must be of the same length.\n\n### **Result**\n The result is built from an element of **tsource** if **mask** is\n _.true._ and from **fsource** otherwise.\n\n Because **tsource** and **fsource** are required to have the same type\n and type parameters (for both the declared and dynamic types), the\n result is polymorphic if and only if both **tsource** and **fsource**\n are polymorphic.\n\n### **Examples**\n\nSample program:\n```fortran\nprogram demo_merge\nimplicit none\ninteger :: tvals(2,3), fvals(2,3), answer(2,3)\nlogical :: mask(2,3)\ninteger :: i\ninteger :: k\nlogical :: chooseleft\n\n ! Works with scalars\n k=5\n write(*,*)merge (1.0, 0.0, k > 0)\n k=-2\n write(*,*)merge (1.0, 0.0, k > 0)\n\n ! set up some simple arrays that all conform to the\n ! same shape\n tvals(1,:)=[ 10, -60, 50 ]\n tvals(2,:)=[ -20, 40, -60 ]\n\n fvals(1,:)=[ 0, 3, 2 ]\n fvals(2,:)=[ 7, 4, 8 ]\n\n mask(1,:)=[ .true., .false., .true. ]\n mask(2,:)=[ .false., .false., .true. ]\n\n ! lets use the mask of specific values\n write(*,*)'mask of logicals'\n answer=merge( tvals, fvals, mask )\n call printme()\n\n ! more typically the mask is an expression\n write(*, *)'highest values'\n answer=merge( tvals, fvals, tvals > fvals )\n call printme()\n\n write(*, *)'lowest values'\n answer=merge( tvals, fvals, tvals < fvals )\n call printme()\n\n write(*, *)'zero out negative values'\n answer=merge( 0, tvals, tvals < 0)\n call printme()\n\n write(*, *)'binary choice'\n chooseleft=.false.\n write(*, '(3i4)')merge([1,2,3],[10,20,30],chooseleft)\n chooseleft=.true.\n write(*, '(3i4)')merge([1,2,3],[10,20,30],chooseleft)\n\ncontains\n\nsubroutine printme()\n write(*, '(3i4)')(answer(i, :), i=1, size(answer, dim=1))\nend subroutine printme\n\nend program demo_merge\n```\nResults:\n```text\n > 1.00000000\n > 0.00000000\n > mask of logicals\n > 10 3 50\n > 7 4 -60\n > highest values\n > 10 3 50\n > 7 40 8\n > lowest values\n > 0 -60 2\n > -20 4 -60\n > zero out negative values\n > 10 0 50\n > 0 40 0\n > binary choice\n > 10 20 30\n > 1 2 3\n```\n### **Standard**\n\nFortran 95\n\n### **See Also**\n\n- [**pack**(3)](#pack) packs an array into an array of rank one\n- [**spread**(3)](#spread) is used to add a dimension and replicate data\n- [**unpack**(3)](#unpack) scatters the elements of a vector\n- [**transpose**(3)](#transpose) - Transpose an array of rank two\n\n _fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n", "MERGE_BITS": "## merge_bits\n\n### **Name**\n\n**merge_bits** - \\[BIT:COPY\\] Merge bits using a mask\n\n### **Synopsis**\n```fortran\n result = merge_bits(i, j, mask)\n```\n```fortran\n elemental integer(kind=KIND) function merge_bits(i,j,mask)\n\n integer(kind=KIND), intent(in) :: i, j, mask\n```\n### **Characteristics**\n\n - the result and all input values have the same _integer_ type and\n KIND with the exception that the mask and either **i** or **j** may be\n a BOZ constant.\n\n### **Description**\n\nA common graphics operation in Ternary Raster Operations is to combine\nbits from two different sources, generally referred to as bit-blending.\n**merge_bits** performs a masked bit-blend of **i** and **j** using\nthe bits of the **mask** value to determine which of the input values\nto copy bits from.\n\nSpecifically, The k-th bit of the result is equal to the k-th bit of\n**i** if the k-th bit of **mask** is **1**; it is equal to the k-th bit\nof **j** otherwise (so all three input values must have the same number\nof bits).\n\nThe resulting value is the same as would result from\n```fortran\n ior (iand (i, mask),iand (j, not (mask)))\n```\nAn exception to all values being of the same _integer_ type is that **i**\nor **j** and/or the mask may be a BOZ constant (A BOZ constant means it is\neither a Binary, Octal, or Hexadecimal literal constant). The BOZ values\nare converted to the _integer_ type of the non-BOZ value(s) as if called\nby the intrinsic function **int()** with the kind of the non-BOZ value(s),\nso the BOZ values must be in the range of the type of the result.\n\n### **Options**\n\n- **i**\n : value to select bits from when the associated bit in the mask is **1**.\n\n- **j**\n : value to select bits from when the associated bit in the mask is **0**.\n\n- **mask**\n : a value whose bits are used as a mask to select bits from **i** and **j**\n\n### **Result**\n\nThe bits blended from **i** and **j** using the mask **mask**.\n\n### **Examples**\n\nSample program:\n```fortran\nprogram demo_merge_bits\nuse,intrinsic :: iso_fortran_env, only : int8, int16, int32, int64\nimplicit none\ninteger(kind=int16) :: if_one,if_zero,msk\ncharacter(len=*),parameter :: fmt='(*(g0, 1X))'\n\n ! basic usage\n print *,'MERGE_BITS( 5,10,41) should be 3.=>',merge_bits(5,10,41)\n print *,'MERGE_BITS(13,18,22) should be 4.=>',merge_bits(13,18,22)\n\n ! use some values in base2 illustratively:\n if_one =int(b'1010101010101010',kind=int16)\n if_zero=int(b'0101010101010101',kind=int16)\n\n msk=int(b'0101010101010101',kind=int16)\n print '(\"should get all zero bits =>\",b16.16)', &\n & merge_bits(if_one,if_zero,msk)\n\n msk=int(b'1010101010101010',kind=int16)\n print '(\"should get all ones bits =>\",b16.16)', &\n & merge_bits(if_one,if_zero,msk)\n\n ! using BOZ values\n print fmt, &\n & merge_bits(32767_int16, o'12345', 32767_int16), &\n & merge_bits(o'12345', 32767_int16, b'0000000000010101'), &\n & merge_bits(32767_int16, o'12345', z'1234')\n\n ! a do-it-yourself equivalent for comparison and validation\n print fmt, &\n & ior(iand(32767_int16, 32767_int16), &\n & iand(o'12345', not(32767_int16))), &\n\n & ior(iand(o'12345', int(o'12345', kind=int16)), &\n & iand(32767_int16, not(int(o'12345', kind=int16)))), &\n\n & ior(iand(32767_int16, z'1234'), &\n & iand(o'12345', not(int( z'1234', kind=int16))))\n\nend program demo_merge_bits\n```\nResults:\n```text\n MERGE_BITS( 5,10,41) should be 3.=> 3\n MERGE_BITS(13,18,22) should be 4.=> 4\n should get all zero bits =>0000000000000000\n should get all ones bits =>1111111111111111\n 32767 32751 5877\n 32767 32767 5877\n```\n### **Standard**\n\nFortran 2008\n\n### **See also**\n\n[****(3)](#)\n\n _fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n", "MIN": "## min\n\n### **Name**\n\n**min** - \\[NUMERIC\\] Minimum value of an argument list\n\n### **Synopsis**\n```fortran\n result = min(a1, a2, a3, ... )\n```\n```fortran\n elemental TYPE(kind=KIND) function min(a1, a2, a3, ... )\n\n TYPE(kind=KIND,intent(in) :: a1\n TYPE(kind=KIND,intent(in) :: a2\n TYPE(kind=KIND,intent(in) :: a3\n :\n :\n :\n```\n### **Characteristics**\n\n- **TYPE** may be _integer_, _real_ or _character_.\n\n### **Description**\n\n**min** returns the argument with the smallest (most negative) value.\n\nSee **max**(3) for an extended example of the behavior of **min** as\nand **max**(3).\n\n### **Options**\n\n- **a1**\n : the first element of the set of values to determine the minimum of.\n\n- **a2, a3, ...**\n : An expression of the same type and kind as **a1** completing the\n set of values to find the minimum of.\n\n### **Result**\n\nThe return value corresponds to the minimum value among the arguments,\nand has the same type and kind as the first argument.\n\n### **Examples**\n\nSample program\n```fortran\nprogram demo_min\nimplicit none\n write(*,*)min(10.0,11.0,30.0,-100.0)\nend program demo_min\n```\nResults:\n```\n -100.0000000\n```\n### **Standard**\n\nFORTRAN 77\n\n### **See Also**\n\n[**maxloc**(3)](#maxloc),\n[**minloc**(3)](#minloc),\n[**minval**(3)](#minval),\n[**max**(3)](#max),\n\n _fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n", "MINEXPONENT": "## minexponent\n\n### **Name**\n\n**minexponent** - \\[NUMERIC MODEL\\] Minimum exponent of a real kind\n\n### **Synopsis**\n```fortran\n result = minexponent(x)\n```\n```fortran\n elemental integer function minexponent(x)\n\n real(kind=**),intent(in) :: x\n```\n### **Characteristics**\n\n - **x** is a _real_ scalar or array of any _real_ kind\n - the result is a default _integer_ scalar\n\n### **Description**\n\n **minexponent** returns the minimum exponent in the model of the\n type of **x**.\n\n### **Options**\n\n- **x**\n : A value used to select the kind of _real_ to return a value for.\n\n### **Result**\n\n The value returned is the maximum exponent for the kind of the value\n queried\n\n### **Examples**\n\nSample program:\n```fortran\nprogram demo_minexponent\nuse, intrinsic :: iso_fortran_env, only : &\n &real_kinds, real32, real64, real128\nimplicit none\nreal(kind=real32) :: x\nreal(kind=real64) :: y\n print *, minexponent(x), maxexponent(x)\n print *, minexponent(y), maxexponent(y)\nend program demo_minexponent\n```\nExpected Results:\n```\n -125 128\n -1021 1024\n```\n### **Standard**\n\nFortran 95\n\n### **See Also**\n\n[**digits**(3)](#digits),\n[**epsilon**(3)](#epsilon),\n[**exponent**(3)](#exponent),\n[**fraction**(3)](#fraction),\n[**huge**(3)](#huge),\n[**maxexponent**(3)](#maxexponent),\n[**nearest**(3)](#nearest),\n[**precision**(3)](#precision),\n[**radix**(3)](#radix),\n[**range**(3)](#range),\n[**rrspacing**(3)](#rrspacing),\n[**scale**(3)](#scale),\n[**set_exponent**(3)](#set_exponent),\n[**spacing**(3)](#spacing),\n[**tiny**(3)](#tiny)\n\n _fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n", @@ -156,9 +156,9 @@ "PRESENT": "## present\n\n### **Name**\n\n**present** - [STATE:INQUIRY\\] Determine whether an optional dummy argument\nis specified\n\n### **Synopsis**\n```fortran\n result = present(a)\n```\n```fortran\n logical function present (a)\n\n type(TYPE(kind=KIND)) :: a(..)\n```\n### **Characteristics**\n\n- **a** May be of any type and may be a pointer, scalar or array value,\n or a dummy procedure.\n\n### **Description**\n\n **present** can be used in a procedure to determine if an optional\n dummy argument was present on the current call to the procedure.\n\n **a** shall be the name of an optional dummy argument that is accessible\n in the subprogram in which the **present** function reference\n appears. There are no other requirements on **a**.\n\n Note when an argument is not present when the current procedure is\n invoked, you may only pass it as an optional argument to another\n procedure or pass it as an argument to **present**.\n\n### **Options**\n\n- **a**\n : the name of an optional dummy argument accessible within the current\n subroutine or function.\n\n### **Result**\n\n Returns _.true._ if the optional argument **a** is present (was passed\n on the call to the procedure) , or _.false._ otherwise.\n\n### **Examples**\n\nSample program:\n```fortran\nprogram demo_present\nimplicit none\ninteger :: answer\n ! argument to func() is not present\n answer=func()\n write(*,*) answer\n ! argument to func() is present\n answer=func(1492)\n write(*,*) answer\ncontains\n!\ninteger function func(x)\n! the optional characteristic on this definition allows this variable\n! to not be specified on a call; and also allows it to subsequently\n! be passed to PRESENT(3):\ninteger, intent(in), optional :: x\ninteger :: x_local\n !\n ! basic\n if(present(x))then\n ! if present, you can use x like any other variable.\n x_local=x\n else\n ! if not, you cannot define or reference x except to\n ! pass it as an optional parameter to another procedure\n ! or in a call to present(3f)\n x_local=0\n endif\n !\n func=x_local**2\n !\n ! passing the argument on to other procedures\n ! so something like this is a bad idea because x is used\n ! as the first argument to merge(3f) when it might not be\n ! present\n ! xlocal=merge(x,0,present(x)) ! NO!!\n !\n ! We can pass it to another procedure if another\n ! procedure declares the argument as optional as well,\n ! or we have tested that X is present\n call tattle('optional argument x',x)\n if(present(x))call not_optional(x)\nend function\n!\nsubroutine tattle(label,arg)\ncharacter(len=*),intent(in) :: label\ninteger,intent(in),optional :: arg\n if(present(arg))then\n write(*,*)label,' is present'\n else\n write(*,*)label,' is not present'\n endif\nend subroutine tattle\n!\nsubroutine not_optional(arg)\ninteger,intent(in) :: arg\n write(*,*)'already tested X is defined',arg\nend subroutine not_optional\n!\nend program demo_present\n```\nResults:\n```text\n optional argument x is not present\n 0\n optional argument x is present\n already tested X is defined 1492\n 2226064\n```\n### **Standard**\n\nFortran 95\n\n _fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n", "PRODUCT": "## product\n\n### **Name**\n\n**product** - \\[ARRAY:REDUCTION\\] Product of array elements\n\n### **Synopsis**\n```fortran\n result = product(array [,dim] [,mask])\n```\n```fortran\n NUMERIC function product(array, dim, mask)\n\n NUMERIC,intent(in) :: array(..)\n integer(kind=**),intent(in),optional :: dim\n logical(kind=**),intent(in),optional :: mask(..)\n```\n### **Characteristics**\n\n - a kind designated as ** may be any supported kind for the type\n - **NUMERIC** is any numeric type and kind.\n\n### **Description**\n\n**product** multiplies together all the selected elements of **array**,\nor along dimension **dim** if the corresponding element in **mask**\nis _.true._.\n\nIf **dim** is absent, a scalar with the product of all elements in **array** is\nreturned. (Note a zero-sized **array** returns **1**).\n\nWhen **dim** is present, If the masked array has a dimension of one\n(ie. is a vector) the result is a scalar. Otherwise, an array of rank\n**n-1**, where **n** equals the rank of **array**, and a shape similar\nto that of **array** with dimension **dim** dropped is returned.\n\n### **Options**\n\n- **array**\n : Shall be an array of type _integer_, _real_ or _complex_.\n\n- **dim**\n : shall be a scalar of type _integer_ with a value in the\n range from **1 to n**, where **n** equals the rank of **array**.\n\n- **mask**\n : shall be of type _logical_ and either be a scalar or an\n array of the same shape as **array**.\n\n### **Result**\n\nThe result is of the same type as **array**.\n\n### **Examples**\n\nSample program:\n```fortran\nprogram demo_product\nimplicit none\ncharacter(len=*),parameter :: all='(*(g0,1x))' ! a handy format\ncharacter(len=1),parameter :: nl=new_line('a')\n\nNO_DIM: block\n! If DIM is not specified, the result is the product of all the\n! selected array elements.\ninteger :: i,n, p1, p2\ninteger,allocatable :: array(:)\n ! all elements are selected by default\n do n=1,10\n print all, 'factorial of ',n,' is ', product([(real(i),i=1,n)])\n enddo\n\n ! using a mask\n array=[10,12,13,15,20,25,30]\n p1=product(array, mask=mod(array, 2)==1) ! only odd elements\n p2=product(array, mask=mod(array, 2)/=1) ! only even elements\n print all, nl,'product of all elements',product(array) ! all elements\n print all, ' odd * even =',nl,p1,'*',p2,'=',p1*p2\n\n ! NOTE: If ARRAY is a zero-sized array, the result is equal to one\n print all\n print all, 'zero-sized array=>',product([integer :: ])\n ! NOTE: If nothing in the mask is true, this also results in a null\n ! array\n print all, 'all elements have a false mask=>', &\n & product(array,mask=.false.)\n\nendblock NO_DIM\n\nWITH_DIM: block\ninteger :: rect(2,3)\ninteger :: box(2,3,4)\n\n! lets fill a few arrays\n rect = reshape([ &\n 1, 2, 3, &\n 4, 5, 6 &\n ],shape(rect),order=[2,1])\n call print_matrix_int('rect',rect)\n\n! Find the product of each column in RECT.\n print all, 'product of columns=',product(rect, dim = 1)\n\n! Find the product of each row in RECT.\n print all, 'product of rows=',product(rect, dim = 2)\n\n! now lets try a box\n box(:,:,1)=rect\n box(:,:,2)=rect*(+10)\n box(:,:,3)=rect*(-10)\n box(:,:,4)=rect*2\n ! lets look at the values\n call print_matrix_int('box 1',box(:,:,1))\n call print_matrix_int('box 2',box(:,:,2))\n call print_matrix_int('box 3',box(:,:,3))\n call print_matrix_int('box 4',box(:,:,4))\n\n ! remember without dim= even a box produces a scalar\n print all, 'no dim gives a scalar',product(real(box))\n\n ! only one plane has negative values, so note all the \"1\" values\n ! for vectors with no elements\n call print_matrix_int('negative values', &\n & product(box,mask=box < 0,dim=1))\n\n! If DIM is specified and ARRAY has rank greater than one, the\n! result is a new array in which dimension DIM has been eliminated.\n\n ! pick a dimension to multiply though\n call print_matrix_int('dim=1',product(box,dim=1))\n\n call print_matrix_int('dim=2',product(box,dim=2))\n\n call print_matrix_int('dim=3',product(box,dim=3))\n\nendblock WITH_DIM\n\ncontains\n\nsubroutine print_matrix_int(title,arr)\nimplicit none\n\n!@(#) print small 2d integer arrays in row-column format\n\ncharacter(len=*),intent(in) :: title\ninteger,intent(in) :: arr(:,:)\ninteger :: i\ncharacter(len=:),allocatable :: biggest\n\n print all\n print all, trim(title),':(',shape(arr),')' ! print title\n biggest=' ' ! make buffer to write integer into\n ! find how many characters to use for integers\n write(biggest,'(i0)')ceiling(log10(max(1.0,real(maxval(abs(arr))))))+2\n ! use this format to write a row\n biggest='(\" > [\",*(i'//trim(biggest)//':,\",\"))'\n ! print one row of array at a time\n do i=1,size(arr,dim=1)\n write(*,fmt=biggest,advance='no')arr(i,:)\n write(*,'(\" ]\")')\n enddo\n\nend subroutine print_matrix_int\n\nend program demo_product\n```\n\nResults:\n\n```text\nfactorial of 1 is 1.000000\nfactorial of 2 is 2.000000\nfactorial of 3 is 6.000000\nfactorial of 4 is 24.00000\nfactorial of 5 is 120.0000\nfactorial of 6 is 720.0000\nfactorial of 7 is 5040.000\nfactorial of 8 is 40320.00\nfactorial of 9 is 362880.0\nfactorial of 10 is 3628800.\n\n product of all elements 351000000\n odd * even =\n 4875 * 72000 = 351000000\n\nzero-sized array=> 1\nall elements have a false mask=> 1\n\nrect :( 2 3 )\n > [ 1, 2, 3 ]\n > [ 4, 5, 6 ]\nproduct of columns= 4 10 18\nproduct of rows= 6 120\n\nbox 1 :( 2 3 )\n > [ 1, 2, 3 ]\n > [ 4, 5, 6 ]\n\nbox 2 :( 2 3 )\n > [ 10, 20, 30 ]\n > [ 40, 50, 60 ]\n\nbox 3 :( 2 3 )\n > [ -10, -20, -30 ]\n > [ -40, -50, -60 ]\n\nbox 4 :( 2 3 )\n > [ 2, 4, 6 ]\n > [ 8, 10, 12 ]\nno dim gives a scalar .1719927E+26\n\nnegative values :( 3 4 )\n > [ 1, 1, 400, 1 ]\n > [ 1, 1, 1000, 1 ]\n > [ 1, 1, 1800, 1 ]\n\ndim=1 :( 3 4 )\n > [ 4, 400, 400, 16 ]\n > [ 10, 1000, 1000, 40 ]\n > [ 18, 1800, 1800, 72 ]\n\ndim=2 :( 2 4 )\n > [ 6, 6000, -6000, 48 ]\n > [ 120, 120000, -120000, 960 ]\n\ndim=3 :( 2 3 )\n > [ -200, -3200, -16200 ]\n > [ -51200, -125000, -259200 ]\n```\n\n### **Standard**\n\nFortran 95\n\n### **See Also**\n\n[**sum**(3)](#sum), note that an element by element multiplication is done\ndirectly using the star character.\n\n _fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n", "RADIX": "## radix\n\n### **Name**\n\n**radix** - \\[NUMERIC MODEL\\] Base of a numeric model\n\n### **Synopsis**\n```fortran\n result = radix(x)\n```\n```fortran\n integer function radix(x)\n\n TYPE(kind=**),intent(in) :: x(..)\n```\n### **Characteristics**\n\n - **x** may be scalar or an array of any _real_ or _integer_ type.\n - the result is a default integer scalar.\n\n### **Description**\n\n **radix** returns the base of the internal model representing the\n numeric entity **x**.\n\n In a positional numeral system, the radix or base is the number of\n unique digits, including the digit zero, used to represent numbers.\n\n This function helps to represent the internal computing model\n generically, but will be 2 (representing a binary machine) for any\n common platform for all the numeric types.\n\n### **Options**\n\n- **x**\n : used to identify the type of number to query.\n\n### **Result**\n\n The returned value indicates what base is internally used to represent\n the type of numeric value **x** represents.\n\n### **Examples**\n\nSample program:\n\n```fortran\nprogram demo_radix\nimplicit none\n print *, \"The radix for the default integer kind is\", radix(0)\n print *, \"The radix for the default real kind is\", radix(0.0)\n print *, \"The radix for the doubleprecision real kind is\", radix(0.0d0)\nend program demo_radix\n```\nResults:\n```text\n > The radix for the default integer kind is 2\n > The radix for the default real kind is 2\n > The radix for the doubleprecision real kind is 2\n```\n### **Standard**\n\nFortran 95\n\n### **See Also**\n\n[**digits**(3)](#digits),\n[**epsilon**(3)](#epsilon),\n[**exponent**(3)](#exponent),\n[**fraction**(3)](#fraction),\n[**huge**(3)](#huge),\n[**maxexponent**(3)](#maxexponent),\n[**minexponent**(3)](#minexponent),\n[**nearest**(3)](#nearest),\n[**precision**(3)](#precision),\n[**range**(3)](#range),\n[**rrspacing**(3)](#rrspacing),\n[**scale**(3)](#scale),\n[**set_exponent**(3)](#set_exponent),\n[**spacing**(3)](#spacing),\n[**tiny**(3)](#tiny)\n\n _fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n", - "RANDOM_INIT": "## random_init\n\n### **Name**\n\n**random_init** - \\[MATHEMATICS:RANDOM\\] Initializes the state of\nthe pseudorandom number generator\n\n### **Synopsis**\n```fortran\n call random_init(repeatable, image_distinct)\n\n logical,intent(in) :: repeatable\n logical,intent(in) :: image_distinct\n```\n### **Characteristics**\n\n- **harvest** and **image_distinct** are logical scalars\n\n### Description\n\nInitializes the state of the pseudorandom number generator used by \n**random_number**.\n\n### **Options**\n\n**repeatable**\n: If it is **.true.**, the seed is set to a processor-dependent\nvalue that is the same each time **random_init** is called from the\nsame image. The term \"same image\" means a single instance of program\nexecution. The sequence of random numbers is different for repeated\nexecution of the program. \n\nIf it is **.false.**, the seed is set to a processor-dependent value.\n\n**image_distinct**\n: If is `.true.`, the seed is set to a processor-dependent value that\nis distinct from the seed set by a call to **random_init**in another\nimage. If it is **.false.**, the seed is set value that does depend\nwhich image called **random_init**.\n\n\n### **Examples**\n\nSample program:\n\n```fortran\n program demo_random_init\n implicit none\n real x(3), y(3)\n call random_init(.true., .true.)\n call random_number(x)\n call random_init(.true., .true.)\n call random_number(y)\n ! x and y should be the same sequence\n if ( any(x /= y) ) stop \"x(:) and y(:) are not all equal\"\n end program demo_random_init\n```\n## **Standard**\n\nFortran 2018\n```\n## **See also**\n\n[random_number](#random_number),\n[random_seed](random_seed)\n\n _fortran-lang intrinsic descriptions\n", + "RANDOM_INIT": "## random_init\n\n### **Name**\n\n**random_init** - \\[MATHEMATICS:RANDOM\\] Initializes the state of\nthe pseudorandom number generator\n\n### **Synopsis**\n```fortran\n call random_init(repeatable, image_distinct)\n\n logical,intent(in) :: repeatable\n logical,intent(in) :: image_distinct\n```\n### **Characteristics**\n\n- **harvest** and **image_distinct** are logical scalars\n\n### Description\n\nInitializes the state of the pseudorandom number generator used by\n**random_number**.\n\n### **Options**\n\n**repeatable**\n: If it is **.true.**, the seed is set to a processor-dependent\nvalue that is the same each time **random_init** is called from the\nsame image. The term \"same image\" means a single instance of program\nexecution. The sequence of random numbers is different for repeated\nexecution of the program.\n\nIf it is **.false.**, the seed is set to a processor-dependent value.\n\n**image_distinct**\n: If is `.true.`, the seed is set to a processor-dependent value that\nis distinct from the seed set by a call to **random_init**in another\nimage. If it is **.false.**, the seed is set value that does depend\nwhich image called **random_init**.\n\n\n### **Examples**\n\nSample program:\n\n```fortran\n program demo_random_init\n implicit none\n real x(3), y(3)\n call random_init(.true., .true.)\n call random_number(x)\n call random_init(.true., .true.)\n call random_number(y)\n ! x and y should be the same sequence\n if ( any(x /= y) ) stop \"x(:) and y(:) are not all equal\"\n end program demo_random_init\n```\n## **Standard**\n\nFortran 2018\n\n## **See also**\n\n[random_number](#random_number),\n[random_seed](random_seed)\n\n _fortran-lang intrinsic descriptions\n", "RANDOM_NUMBER": "## random_number\n\n### **Name**\n\n**random_number** - \\[MATHEMATICS:RANDOM\\] Pseudo-random number\n\n### **Synopsis**\n```fortran\n call random_number(harvest)\n```\n```fortran\n subroutine random_number(harvest)\n\n real,intent(out) :: harvest(..)\n```\n### **Characteristics**\n\n- **harvest** and the result are default _real_ variables\n\n### **Description**\n\n**random_number** returns a single pseudorandom number or an array of\npseudorandom numbers from the uniform distribution over the range\n0 \\<= x \\< 1.\n\n### **Options**\n\n- **harvest**\n : Shall be a scalar or an array of type _real_.\n\n### **Examples**\n\nSample program:\n\n```fortran\nprogram demo_random_number\nuse, intrinsic :: iso_fortran_env, only : dp=>real64\nimplicit none\ninteger, allocatable :: seed(:)\ninteger :: n\ninteger :: first,last\ninteger :: i\ninteger :: rand_int\ninteger,allocatable :: count(:)\nreal(kind=dp) :: rand_val\n call random_seed(size = n)\n allocate(seed(n))\n call random_seed(get=seed)\n first=1\n last=10\n allocate(count(last-first+1))\n ! To have a discrete uniform distribution on the integers\n ! [first, first+1, ..., last-1, last] carve the continuous\n ! distribution up into last+1-first equal sized chunks,\n ! mapping each chunk to an integer.\n !\n ! One way is:\n ! call random_number(rand_val)\n ! choose one from last-first+1 integers\n ! rand_int = first + FLOOR((last+1-first)*rand_val)\n count=0\n ! generate a lot of random integers from 1 to 10 and count them.\n ! with a large number of values you should get about the same\n ! number of each value\n do i=1,100000000\n call random_number(rand_val)\n rand_int=first+floor((last+1-first)*rand_val)\n if(rand_int.ge.first.and.rand_int.le.last)then\n count(rand_int)=count(rand_int)+1\n else\n write(*,*)rand_int,' is out of range'\n endif\n enddo\n write(*,'(i0,1x,i0)')(i,count(i),i=1,size(count))\nend program demo_random_number\n```\nResults:\n```\n 1 10003588\n 2 10000104\n 3 10000169\n 4 9997996\n 5 9995349\n 6 10001304\n 7 10001909\n 8 9999133\n 9 10000252\n 10 10000196\n```\n### **Standard**\n\nFortran 95\n\n### **See Also**\n\n[**random_seed**(3)](#random_seed)\n\n _fortran-lang intrinsic descriptions_\n", - "RANDOM_SEED": "## random_seed\n\n### **Name**\n\n**random_seed** - \\[MATHEMATICS:RANDOM\\] Initialize a pseudo-random number sequence\n\n### **Synopsis**\n```fortran\n call random_seed( [size] [,put] [,get] )\n```\n```fortran\n subroutine random_seed( size, put, get )\n\n integer,intent(out),optional :: size\n integer,intent(in),optional :: put(*)\n integer,intent(out),optional :: get(*)\n```\n### **Characteristics**\n - **size** a scalar default _integer_\n - **put** a rank-one default _integer_ array\n - **get** a rank-one default _integer_ array\n - the result\n\n### **Description**\n\n**random_seed** restarts or queries the state of the pseudorandom\nnumber generator used by random_number.\n\nIf random_seed is called without arguments, it is seeded with random\ndata retrieved from the operating system.\n\n### **Options**\n\n- **size**\n : specifies the minimum size of the arrays used with the **put**\n and **get** arguments.\n\n- **put**\n : the size of the array must be larger than or equal to the number\n returned by the **size** argument.\n\n- **get**\n : It is **intent(out)** and the size of the array must be larger than\n or equal to the number returned by the **size** argument.\n\n### **Examples**\n\nSample program:\n\n```fortran\n program demo_random_seed\n implicit none\n integer, allocatable :: seed(:)\n integer :: n\n \n call random_seed(size = n)\n allocate(seed(n))\n call random_seed(get=seed)\n write (*, *) seed\n \n end program demo_random_seed\n```\nResults:\n```text\n -674862499 -1750483360 -183136071 -317862567 682500039\n 349459 344020729 -1725483289\n```\n### **Standard**\n\nFortran 95\n\n### **See Also**\n\n[**random_number**(3)](#random_number)\n\n _fortran-lang intrinsic descriptions_\n", + "RANDOM_SEED": "## random_seed\n\n### **Name**\n\n**random_seed** - \\[MATHEMATICS:RANDOM\\] Initialize a pseudo-random number sequence\n\n### **Synopsis**\n```fortran\n call random_seed( [size] [,put] [,get] )\n```\n```fortran\n subroutine random_seed( size, put, get )\n\n integer,intent(out),optional :: size\n integer,intent(in),optional :: put(*)\n integer,intent(out),optional :: get(*)\n```\n### **Characteristics**\n - **size** a scalar default _integer_\n - **put** a rank-one default _integer_ array\n - **get** a rank-one default _integer_ array\n - the result\n\n### **Description**\n\n**random_seed** restarts or queries the state of the pseudorandom\nnumber generator used by random_number.\n\nIf random_seed is called without arguments, it is seeded with random\ndata retrieved from the operating system.\n\n### **Options**\n\n- **size**\n : specifies the minimum size of the arrays used with the **put**\n and **get** arguments.\n\n- **put**\n : the size of the array must be larger than or equal to the number\n returned by the **size** argument.\n\n- **get**\n : It is **intent(out)** and the size of the array must be larger than\n or equal to the number returned by the **size** argument.\n\n### **Examples**\n\nSample program:\n\n```fortran\n program demo_random_seed\n implicit none\n integer, allocatable :: seed(:)\n integer :: n\n\n call random_seed(size = n)\n allocate(seed(n))\n call random_seed(get=seed)\n write (*, *) seed\n\n end program demo_random_seed\n```\nResults:\n```text\n -674862499 -1750483360 -183136071 -317862567 682500039\n 349459 344020729 -1725483289\n```\n### **Standard**\n\nFortran 95\n\n### **See Also**\n\n[**random_number**(3)](#random_number)\n\n _fortran-lang intrinsic descriptions_\n", "RANGE": "## range\n\n### **Name**\n\n**range** - \\[NUMERIC MODEL\\] Decimal exponent range of a numeric kind\n\n### **Synopsis**\n```fortran\n result = range(x)\n```\n```fortran\n integer function range (x)\n\n TYPE(kind=KIND),intent(in) :: x\n```\n### **Characteristics**\n\n - **x** may be of type _integer_, _real_, or _complex_. It may be a scalar or an array.\n - **KIND** is any kind supported by the type of **x**\n - the result is a default _integer_ scalar\n\n### **Description**\n\n **range** returns the decimal exponent range in the model of the\n type of **x**.\n\n Since **x** is only used to determine the type and kind being\n interrogated, the value need not be defined.\n\n### **Options**\n\n- **x**\n : the value whose type and kind are used for the query\n\n### **Result**\n\n Case (i)\n : For an integer argument, the result has the value\n```fortran\n int (log10 (huge(x)))\n```\n Case (ii)\n : For a real argument, the result has the value\n```fortran\n int(min (log10 (huge(x)), -log10(tiny(x) )))\n ```\n Case (iii)\n : For a complex argument, the result has the value\n```fortran\n range(real(x))\n```\n### **Examples**\n\nSample program:\n```fortran\nprogram demo_range\nuse,intrinsic :: iso_fortran_env, only : dp=>real64,sp=>real32\nimplicit none\nreal(kind=sp) :: x(2)\ncomplex(kind=dp) :: y\n print *, precision(x), range(x)\n print *, precision(y), range(y)\nend program demo_range\n```\nResults:\n```text\n > 6 37\n > 15 307\n```\n### **Standard**\n\nFortran 95\n\n### **See Also**\n\n[**digits**(3)](#digits),\n[**epsilon**(3)](#epsilon),\n[**exponent**(3)](#exponent),\n[**fraction**(3)](#fraction),\n[**huge**(3)](#huge),\n[**maxexponent**(3)](#maxexponent),\n[**minexponent**(3)](#minexponent),\n[**nearest**(3)](#nearest),\n[**precision**(3)](#precision),\n[**radix**(3)](#radix),\n[**rrspacing**(3)](#rrspacing),\n[**scale**(3)](#scale),\n[**set_exponent**(3)](#set_exponent),\n[**spacing**(3)](#spacing),\n[**tiny**(3)](#tiny)\n\n _fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n", "RANK": "## rank\n\n### **Name**\n\n**rank** - \\[ARRAY:INQUIRY\\] Rank of a data object\n\n### **Synopsis**\n```fortran\n result = rank(a)\n```\n```fortran\n integer function rank(a)\n\n type(TYPE(kind=**)),intent(in) :: a(..)\n```\n### **Characteristics**\n\n - **a** can be of any type **TYPE** and rank.\n - a kind designated as ** may be any supported kind for the type\n\n### **Description**\n\n **rank** returns the rank of a scalar or array data object.\n\n The rank of an array is the number of dimensions it has (zero for a scalar).\n\n### **Options**\n\n- **a** is the data object to query the dimensionality of. The rank returned\n may be from 0 to 16.\n\n The argument **a** may be any data object type, including an assumed-rank\n array.\n\n### **Result**\n\n For arrays, their rank is returned; for scalars zero is returned.\n\n### **Examples**\n\nSample program:\n\n```fortran\nprogram demo_rank\nimplicit none\n\n! a bunch of data objects to query\ninteger :: a\nreal, allocatable :: b(:,:)\nreal, pointer :: c(:)\ncomplex :: d\n\n! make up a type\ntype mytype\n integer :: int\n real :: float\n character :: char\nend type mytype\ntype(mytype) :: any_thing(1,2,3,4,5)\n\n ! basics\n print *, 'rank of scalar a=',rank(a)\n ! you can query this array even though it is not allocated\n print *, 'rank of matrix b=',rank(b)\n print *, 'rank of vector pointer c=',rank(c)\n print *, 'rank of complex scalar d=',rank(d)\n\n ! you can query any type, not just intrinsics\n print *, 'rank of any arbitrary type=',rank(any_thing)\n\n ! an assumed-rank object may be queried\n call query_int(10)\n call query_int([20,30])\n call query_int( reshape([40,50,60,70],[2,2]) )\n\n ! you can even query an unlimited polymorphic entity\n call query_anything(10.0)\n call query_anything([.true.,.false.])\n call query_anything( reshape([40.0,50.0,60.0,70.0],[2,2]) )\n\ncontains\n\nsubroutine query_int(data_object)\n! It is hard to do much with something dimensioned\n! name(..) if not calling C except inside of a\n! SELECT_RANK construct but one thing you can\n! do is call the inquiry functions ...\ninteger,intent(in) :: data_object(..)\ncharacter(len=*),parameter :: all='(*(g0,1x))'\n\n if(rank(data_object).eq.0)then\n print all,&\n & 'passed a scalar to an assumed rank, &\n & rank=',rank(data_object)\n else\n print all,&\n & 'passed an array to an assumed rank, &\n & rank=',rank(data_object)\n endif\n\nend subroutine query_int\n\nsubroutine query_anything(data_object)\nclass(*),intent(in) ::data_object(..)\ncharacter(len=*),parameter :: all='(*(g0,1x))'\n if(rank(data_object).eq.0)then\n print all,&\n &'passed a scalar to an unlimited polymorphic rank=', &\n & rank(data_object)\n else\n print all,&\n & 'passed an array to an unlimited polymorphic, rank=', &\n & rank(data_object)\n endif\nend subroutine query_anything\n\nend program demo_rank\n```\nResults:\n```text\n rank of scalar a= 0\n rank of matrix b= 2\n rank of vector pointer c= 1\n rank of complex scalar d= 0\n rank of any arbitrary type= 5\n passed a scalar to an assumed rank, rank= 0\n passed an array to an assumed rank, rank= 1\n passed an array to an assumed rank, rank= 2\n passed a scalar to an unlimited polymorphic rank= 0\n passed an array to an unlimited polymorphic, rank= 1\n passed an array to an unlimited polymorphic, rank= 2\n```\n### **Standard**\n\n### **See also**\n\n#### Array inquiry:\n\n- [**size**(3)](#size) - Determine the size of an array\n- [**rank**](#rank) - Rank of a data object\n- [**shape**(3)](#shape) - Determine the shape of an array\n- [**ubound**(3)](#ubound) - Upper dimension bounds of an array\n- [**lbound**(3)](#lbound) - Lower dimension bounds of an array\n\n#### State Inquiry:\n\n- [**allocated**(3)](#allocated) - Status of an allocatable entity\n- [**is_contiguous**(3)](#is_contiguous) - Test if object is contiguous\n\n#### Kind Inquiry:\n\n- [**kind**(3)](#kind) - Kind of an entity\n\n#### Bit Inquiry:\n\n- [**storage_size**(3)](#storage_size) - Storage size in bits\n- [**bit_size**(3)](#bit_size) - Bit size inquiry function\n- [**btest**(3)](#btest) - Tests a bit of an _integer_ value.\n\n _fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n#\n", "REAL": "## real\n\n### **Name**\n\n**real** - \\[TYPE:NUMERIC\\] Convert to real type\n\n### **Synopsis**\n```fortran\n result = real(x [,kind])\n```\n```fortran\n elemental real(kind=KIND) function real(x,KIND)\n\n TYPE(kind=**),intent(in) :: x\n integer(kind=**),intent(in),optional :: KIND\n```\n### **Characteristics**\n\n - the type of **x** may be _integer_, _real_, or _complex_; or a BOZ-literal-constant.\n - **kind** is a _integer_ initialization expression (a constant expression)\n + If **kind** is present it defines the kind of the _real_ result\n + if **kind** is not present\n - when **x** is _complex_ the result is a _real_ of the same kind as **x**.\n - when **x** is _real_ or _integer_ the result is a _real_ of default kind\n - a kind designated as ** may be any supported kind for the type\n\n### **Description**\n\n**real** converts its argument **x** to a _real_ type.\n\nThe real part of a complex value is returned. For complex values this\nis similar to the modern complex-part-designator **%RE** which also\ndesignates the real part of a _complex_ value.\n\n```fortran\n z=(3.0,4.0) ! if z is a complex value\n print *, z%re == real(z) ! these expressions are equivalent\n```\n### **Options**\n\n- **x**\n : An _integer_, _real_, or _complex_ value to convert to _real_.\n\n- **kind**\n : When present the value of **kind** defines the kind of the result.\n\n### **Result**\n\n1. **real(x)** converts **x** to a default _real_ type if **x** is an _integer_\n or _real_ variable.\n\n2. **real(x)** converts a _complex_ value to a _real_ type with the\n magnitude of the real component of the input with kind type\n parameter the same as **x**.\n\n3. **real(x, kind)** is converted to a _real_ type with kind type\n parameter **kind** if **x** is a _complex_, _integer_, or _real_ variable.\n\n### **Examples**\n\nSample program:\n```fortran\nprogram demo_real\nuse,intrinsic :: iso_fortran_env, only : dp=>real64\nimplicit none\ncomplex :: zr = (1.0, 2.0)\ndoubleprecision :: xd=huge(3.0d0)\ncomplex(kind=dp) :: zd=cmplx(4.0e0_dp,5.0e0_dp,kind=dp)\n\n print *, real(zr), aimag(zr)\n print *, dble(zd), aimag(zd)\n\n write(*,*)xd,real(xd,kind=kind(0.0d0)),dble(xd)\nend program demo_real\n```\nResults:\n```\n 1.00000000 2.00000000\n 4.0000000000000000 5.0000000000000000\n 1.7976931348623157E+308 1.7976931348623157E+308 1.7976931348623157E+308\n```\n### **Standard**\n\nFORTRAN 77\n\n### **See Also**\n\n- [**aimag**(3)](#aimag) - Imaginary part of complex number\n- [**cmplx**(3)](#cmplx) - Complex conversion function\n- [**conjg**(3)](#conjg) - Complex conjugate function\n\nFortran has strong support for _complex_ values, including many intrinsics\nthat take or produce _complex_ values in addition to algebraic and\nlogical expressions:\n\n[**abs**(3)](#abs),\n[**acosh**(3)](#acosh),\n[**acos**(3)](#acos),\n[**asinh**(3)](#asinh),\n[**asin**(3)](#asin),\n[**atan2**(3)](#atan2),\n[**atanh**(3)](#atanh),\n[**atan**(3)](#atan),\n[**cosh**(3)](#cosh),\n[**cos**(3)](#cos),\n[**co_sum**(3)](#co_sum),\n[**dble**(3)](#dble),\n[**dot_product**(3)](#dot_product),\n[**exp**(3)](#exp),\n[**int**(3)](#int),\n[**is_contiguous**(3)](#is_contiguous),\n[**kind**(3)](#kind),\n[**log**(3)](#log),\n[**matmul**(3)](#matmul),\n[**precision**(3)](#precision),\n[**product**(3)](#product),\n[**range**(3)](#range),\n[**rank**(3)](#rank),\n[**sinh**(3)](#sinh),\n[**sin**(3)](#sin),\n[**sqrt**(3)](#sqrt),\n[**storage_size**(3)](#storage_size),\n[**sum**(3)](#sum),\n[**tanh**(3)](#tanh),\n[**tan**(3)](#tan),\n[**unpack**(3)](#unpack),\n\n _fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n", @@ -167,7 +167,7 @@ "RESHAPE": "\n\n## reshape\n\n### **Name**\n\n**reshape** - \\[ARRAY:RESHAPE\\] Function to reshape an array\n\n### **Synopsis**\n```fortran\n result = reshape( source, shape [,pad] [,order] )\n```\n```fortran\n type(TYPE(kind=KIND)) function reshape\n\n type(TYPE(kind=KIND)),intent(in) :: source(..)\n integer(kind=**),intent(in) :: shape(:)\n type(TYPE(kind=KIND)),intent(in),optional :: pad(..)\n integer(kind=**),intent(in),optional :: order(:)\n```\n### **Characteristics**\n\n - **source** is an array of any type\n - **shape** defines a Fortran shape and therefore an _integer_ vector\n (of rank one) of constant size of up to 16 non-negative values.\n - **pad** is the same type as **source**\n - **order** is the same shape as **shape**\n - The result is an array of shape **shape** with the same type as **source**.\n - a kind designated as ** may be any supported kind for the type\n\n### **Description**\n\n**reshape** constructs an array of arbitrary shape **shape** using the elements\nfrom **source** and possibly **pad** to fill it.\n\nIf necessary, the new array may be padded with elements from **pad**\nor permuted as defined by **order**.\n\nAmong many other uses, **reshape** can be used to reorder a Fortran array\nto match C array ordering before the array is passed from Fortran to a\nC procedure.\n\n### **Options**\n\n- **source**\n : an array containing the elements to be copied to the result.\n there must be enough elements in the source to fill the new shape\n if **pad** is omitted or has size zero. Expressed in Fortran ...\n```fortran\n if(.not.present(pad))then\n if(size(source) < product(shape))then\n stop 'not enough elements in the old array to fill the new one'\n endif\n endif\n```\n- **shape**\n : This is the shape of the new array being generated.\n Being by definition a shape; all elements are either positive integers\n or zero, the size but be 1 or greater, it may have up to 16 elements\n but must be of constant fixed size and rank one.\n\n- **pad**\n : used to fill in extra values if the result array is larger than **source**.\n It will be used repeatedly after all the elements of **source** have been\n placed in the result until the result has all elements assigned.\n : If it is absent or is a zero-sized array, you can only make\n **source** into another array of the same size as **source** or smaller.\n\n- **order**\n : used to insert elements in the result in an order other\n than the normal Fortran array element order, in which the first dimension\n varies fastest.\n : By definition of ranks the values have to be a permutation of the numbers\n from 1 to n, where n is the rank of **shape**.\n : the elements of **source** and pad are placed into the result in order;\n changing the left-most rank most rapidly by default. To change the order by\n which the elements are placed in the result use **order**.\n\n### **Result**\n\nThe result is an array of shape **shape** with the same type and type\nparameters as **source**. It is first filled with the values of elements\nof **source**, with the remainder filled with repeated copies of **pad**\nuntil all elements are filled. The new array may be smaller than\n**source**.\n\n### **Examples**\n\nSample program:\n```fortran\nprogram demo_reshape\nimplicit none\n! notice the use of \"shape(box)\" on the RHS\ninteger :: box(3,4)=reshape([1,2,3,4,5,6,7,8,9,10,11,12],shape(box))\ninteger,allocatable :: v(:,:)\ninteger :: rc(2)\n ! basics0\n ! what is the current shape of the array?\n call printi('shape of box is ',box)\n ! change the shape\n call printi('reshaped ',reshape(box,[2,6]))\n call printi('reshaped ',reshape(box,[4,3]))\n\n ! fill in row column order using order\n v=reshape([1,2,3,4,10,20,30,40,100,200,300,400],[1,12])\n call printi('here is some data to shape',v)\n call printi('normally fills columns first ',reshape([v],[3,4]))\n call printi('fill rows first', reshape([v],[3,4],order=[2,1]))\n\n ! if we take the data and put in back in filling\n ! rows first instead of columns, and flipping the\n ! height and width of the box we not only fill in\n ! a vector using row-column order we actually\n ! transpose it.\n rc(2:1:-1)=shape(box)\n ! copy the data in changing column number fastest\n v=reshape(box,rc,order=[2,1])\n call printi('reshaped and reordered',v)\n ! of course we could have just done a transpose\n call printi('transposed',transpose(box))\n\n ! making the result bigger than source using pad\n v=reshape(box,rc*2,pad=[-1,-2,-3],order=[2,1])\n call printi('bigger and padded and reordered',v)\ncontains\n\nsubroutine printi(title,arr)\nimplicit none\n\n!@(#) print small 2d integer arrays in row-column format\n\ncharacter(len=*),parameter :: all='(*(g0,1x))' ! a handy format\ncharacter(len=*),intent(in) :: title\ninteger,intent(in) :: arr(:,:)\ninteger :: i\ncharacter(len=:),allocatable :: biggest\n\n print all\n print all, trim(title),':(',shape(arr),')' ! print title\n biggest=' ' ! make buffer to write integer into\n ! find how many characters to use for integers\n write(biggest,'(i0)')ceiling(log10(max(1.0,real(maxval(abs(arr))))))+2\n ! use this format to write a row\n biggest='(\" > [\",*(i'//trim(biggest)//':,\",\"))'\n ! print one row of array at a time\n do i=1,size(arr,dim=1)\n write(*,fmt=biggest,advance='no')arr(i,:)\n write(*,'(\" ]\")')\n enddo\n\nend subroutine printi\n\nend program demo_reshape\n```\nResults:\n```text\n shape of box is :( 3 4 )\n > [ 1, 4, 7, 10 ]\n > [ 2, 5, 8, 11 ]\n > [ 3, 6, 9, 12 ]\n\n reshaped :( 2 6 )\n > [ 1, 3, 5, 7, 9, 11 ]\n > [ 2, 4, 6, 8, 10, 12 ]\n\n reshaped :( 4 3 )\n > [ 1, 5, 9 ]\n > [ 2, 6, 10 ]\n > [ 3, 7, 11 ]\n > [ 4, 8, 12 ]\n\n here is some data to shape :( 1 12 )\n > [ 1, 2, 3, 4, 10, 20, 30, 40, 100, 200, 300, 400 ]\n\n normally fills columns first :( 3 4 )\n > [ 1, 4, 30, 200 ]\n > [ 2, 10, 40, 300 ]\n > [ 3, 20, 100, 400 ]\n\n fill rows first :( 3 4 )\n > [ 1, 2, 3, 4 ]\n > [ 10, 20, 30, 40 ]\n > [ 100, 200, 300, 400 ]\n\n reshaped and reordered :( 4 3 )\n > [ 1, 2, 3 ]\n > [ 4, 5, 6 ]\n > [ 7, 8, 9 ]\n > [ 10, 11, 12 ]\n\n transposed :( 4 3 )\n > [ 1, 2, 3 ]\n > [ 4, 5, 6 ]\n > [ 7, 8, 9 ]\n > [ 10, 11, 12 ]\n\n bigger and padded and reordered :( 8 6 )\n > [ 1, 2, 3, 4, 5, 6 ]\n > [ 7, 8, 9, 10, 11, 12 ]\n > [ -1, -2, -3, -1, -2, -3 ]\n > [ -1, -2, -3, -1, -2, -3 ]\n > [ -1, -2, -3, -1, -2, -3 ]\n > [ -1, -2, -3, -1, -2, -3 ]\n > [ -1, -2, -3, -1, -2, -3 ]\n > [ -1, -2, -3, -1, -2, -3 ]\n```\n### **Standard**\n\nFortran 95\n\n### **See Also**\n\n[**shape**(3)](#shape),\n[**pack**(3)](#pack),\n[**transpose**(3)](#transpose)\n\n _fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n\n", "RRSPACING": "## rrspacing\n\n### **Name**\n\n**rrspacing** - \\[MODEL_COMPONENTS\\] Reciprocal of the relative spacing of a numeric type\n\n### **Synopsis**\n```fortran\n result = rrspacing(x)\n```\n```fortran\n elemental real(kind=KIND) function rrspacing(x)\n\n real(kind=KIND),intent(in) :: x\n```\n### **Characteristics**\n\n - **x** is type _real_ an any kind\n - The return value is of the same type and kind as **x**.\n\n### **Description**\n\n**rrspacing** returns the reciprocal of the relative spacing of model\nnumbers near **x**.\n\n\n\n### **Options**\n\n- **x**\n : Shall be of type _real_.\n\n### **Result**\n\n The return value is of the same type and kind as **x**. The value returned\n is equal to **abs(fraction(x)) \\* float(radix(x))\\*\\*digits(x)**.\n\n### **Standard**\n\nFortran 95\n\n### **See Also**\n\n[**digits**(3)](#digits),\n[**epsilon**(3)](#epsilon),\n[**exponent**(3)](#exponent),\n[**fraction**(3)](#fraction),\n[**huge**(3)](#huge),\n[**maxexponent**(3)](#maxexponent),\n[**minexponent**(3)](#minexponent),\n[**nearest**(3)](#nearest),\n[**precision**(3)](#precision),\n[**radix**(3)](#radix),\n[**range**(3)](#range),\n[**scale**(3)](#scale),\n[**set_exponent**(3)](#set_exponent),\n[**spacing**(3)](#spacing),\n[**tiny**(3)](#tiny)\n\n _fortran-lang intrinsic descriptions_\n", "SAME_TYPE_AS": "## same_type_as\n\n### **Name**\n\n**same_type_as** - \\[STATE:INQUIRY\\] Query dynamic types for equality\n\n### **Synopsis**\n```fortran\n result = same_type_as(a, b)\n```\n```fortran\n logical same_type_as(a, b)\n\n type(TYPE(kind=KIND)),intent(in) :: a\n type(TYPE(kind=KIND)),intent(in) :: b\n```\n### **Characteristics**\n\n- **a** shall be an object of extensible declared type or unlimited\n polymorphic. If it is a polymorphic pointer, it shall not have\n an undefined association status.\n\n- **b** shall be an object of extensible declared type or unlimited\n polymorphic. If it is a polymorphic pointer, it shall not have\n an undefined association status.\n\n### **Description**\n\n**same_type_as** queries the dynamic types of objects for equality.\n\n### **Options**\n\n- **a**\n : object to compare to **b** for equality of type\n\n- **b**\n : object to be compared to for equality of type\n\n### **Result**\n\n If the dynamic type of **a** or **b** is extensible, the result is true\n if and only if the dynamic type of **a** is the same as the dynamic\n type of **b**. If neither **a** nor **b** has extensible dynamic type,\n the result is processor dependent.\n\n NOTE1\n\n The dynamic type of a disassociated pointer or unallocated allocatable\n variable is its declared type. An unlimited polymorphic entity has no\n declared type.\n\n NOTE2\n\n The test performed by SAME_TYPE_AS is not the same as the test performed\n by the type guard TYPE IS. The test performed by SAME_TYPE_AS does\n not consider kind type parameters.\n\nSample program:\n```fortran\n ! program demo_same_type_as\n module M_ether\n implicit none\n private\n\n type :: dot\n real :: x=0\n real :: y=0\n end type dot\n\n type, extends(dot) :: point\n real :: z=0\n end type point\n\n type something_else\n end type something_else\n\n public :: dot\n public :: point\n public :: something_else\n\n end module M_ether\n\n program demo_same_type_as\n use M_ether, only : dot, point, something_else\n implicit none\n type(dot) :: dad, mom\n type(point) :: me\n type(something_else) :: alien\n\n write(*,*)same_type_as(me,dad),'I am descended from Dad, but equal?'\n write(*,*)same_type_as(me,me) ,'I am what I am'\n write(*,*)same_type_as(dad,mom) ,'what a pair!'\n\n write(*,*)same_type_as(dad,me),'no paradox here'\n write(*,*)same_type_as(dad,alien),'no relation'\n\n call pointers()\n contains\n subroutine pointers()\n ! Given the declarations and assignments\n type t1\n real c\n end type\n type, extends(t1) :: t2\n end type\n class(t1), pointer :: p, q, r\n allocate (p, q)\n allocate (t2 :: r)\n ! the result of SAME_TYPE_AS (P, Q) will be true, and the result\n ! of SAME_TYPE_AS (P, R) will be false.\n write(*,*)'(P,Q)',same_type_as(p,q),\"mind your P's and Q's\"\n write(*,*)'(P,R)',same_type_as(p,r)\n end subroutine pointers\n\n end program demo_same_type_as\n```\nResults:\n```text\n F I am descended from Dad, but equal?\n T I am what I am\n T what a pair!\n F no paradox here\n F no relation\n (P,Q) T mind your P's and Q's\n (P,R) F\n```\n### **Standard**\n\nFortran 2003\n\n### **See Also**\n\n[**extends_type_of**(3)](#extends_type_of)\n\n _fortran-lang intrinsic descriptions_\n", - "SCALE": "## scale\n\n### **Name**\n\n**scale** - \\[MODEL_COMPONENTS\\] Scale a real value by a whole power of the radix\n\n### **Synopsis**\n```fortran\n result = scale(x, i)\n```\n```fortran\n elemental real(kind=KIND) function scale(x, i)\n\n real(kind=KIND),intent(in) :: x\n integer(kind=**),intent(in) :: i\n```\n### **Characteristics**\n\n - **x** is type _real_ of any kind\n - **i** is type an _integer_ of any kind\n - the result is _real_ of the same kind as **x**\n\n### **Description**\n\n **scale** returns x \\* **radix(x)\\*\\*i**.\n\n It is almost certain the radix(base) of the platform is two, therefore\n **scale** is generally the same as **x*2\\*\\*i**\n\n### **Options**\n\n- **x**\n : the value to multiply by **radix(x)\\*\\*i**. Its type and kind is used\n to determine the radix for values with its characteristics and determines\n the characteristics of the result, so care must be taken the returned\n value is within the range of the characteristics of **x**.\n\n- **i**\n : The power to raise the radix of the machine to\n\n### **Result**\n\nThe return value is **x \\* radix(x)\\*\\*i**, assuming that value can be\nrepresented by a value of the type and kind of **x**.\n\n### **Examples**\n\nSample program:\n```fortran\nprogram demo_scale\nimplicit none\nreal :: x \ncomplex :: c\ninteger :: i\n x = 1.0\n print *, (scale(x,i),i=1,5)\n x = 3.0\n print *, (scale(x,i),i=1,5)\n print *, (scale(log(1.0),i),i=1,5)\n ! on modern machines radix(x) is almost certainly 2\n x = 178.1387e-4\n i = 5\n print *, x, i, scale(x, i), x*radix(x)**i\n ! x*radix(x)**i is the same except roundoff errors are not restricted\n i = 2\n print *, x, i, scale(x, i), x*radix(x)**i\n ! relatively easy to do complex values as well\n c=(3.0,4.0)\n print *, c, i, scale_complex(c, i)!, c*radix(c)**i\ncontains\n function scale_complex(x, n)\n ! example supporting complex value for default kinds\n complex, intent(in) :: x\n integer, intent(in) :: n\n complex :: scale_complex\n scale_complex = cmplx(scale(x%re, n), scale(x%im, n), kind=kind(x%im))\n end function scale_complex\nend program demo_scale\n```\nResults:\n```text\n > 2.00000000 4.00000000 8.00000000 16.0000000 32.0000000 \n > 6.00000000 12.0000000 24.0000000 48.0000000 96.0000000 \n > 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 \n > 1.78138707E-02 5 0.570043862 0.570043862 \n > 1.78138707E-02 2 7.12554827E-02 7.12554827E-02\n > (3.00000000,4.00000000) 2 (12.0000000,16.0000000)\n\n### **Standard**\n\nFortran 95\n\n### **See Also**\n\n[**digits**(3)](#digits),\n[**epsilon**(3)](#epsilon),\n[**exponent**(3)](#exponent),\n[**fraction**(3)](#fraction),\n[**huge**(3)](#huge),\n[**maxexponent**(3)](#maxexponent),\n[**minexponent**(3)](#minexponent),\n[**nearest**(3)](#nearest),\n[**precision**(3)](#precision),\n[**radix**(3)](#radix),\n[**range**(3)](#range),\n[**rrspacing**(3)](#rrspacing),\n[**set_exponent**(3)](#set_exponent),\n[**spacing**(3)](#spacing),\n[**tiny**(3)](#tiny)\n\n _fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n", + "SCALE": "## scale\n\n### **Name**\n\n**scale** - \\[MODEL_COMPONENTS\\] Scale a real value by a whole power of the radix\n\n### **Synopsis**\n```fortran\n result = scale(x, i)\n```\n```fortran\n elemental real(kind=KIND) function scale(x, i)\n\n real(kind=KIND),intent(in) :: x\n integer(kind=**),intent(in) :: i\n```\n### **Characteristics**\n\n - **x** is type _real_ of any kind\n - **i** is type an _integer_ of any kind\n - the result is _real_ of the same kind as **x**\n\n### **Description**\n\n **scale** returns x \\* **radix(x)\\*\\*i**.\n\n It is almost certain the radix(base) of the platform is two, therefore\n **scale** is generally the same as **x*2\\*\\*i**\n\n### **Options**\n\n- **x**\n : the value to multiply by **radix(x)\\*\\*i**. Its type and kind is used\n to determine the radix for values with its characteristics and determines\n the characteristics of the result, so care must be taken the returned\n value is within the range of the characteristics of **x**.\n\n- **i**\n : The power to raise the radix of the machine to\n\n### **Result**\n\nThe return value is **x \\* radix(x)\\*\\*i**, assuming that value can be\nrepresented by a value of the type and kind of **x**.\n\n### **Examples**\n\nSample program:\n```fortran\nprogram demo_scale\nimplicit none\nreal :: x\ncomplex :: c\ninteger :: i\n x = 1.0\n print *, (scale(x,i),i=1,5)\n x = 3.0\n print *, (scale(x,i),i=1,5)\n print *, (scale(log(1.0),i),i=1,5)\n ! on modern machines radix(x) is almost certainly 2\n x = 178.1387e-4\n i = 5\n print *, x, i, scale(x, i), x*radix(x)**i\n ! x*radix(x)**i is the same except roundoff errors are not restricted\n i = 2\n print *, x, i, scale(x, i), x*radix(x)**i\n ! relatively easy to do complex values as well\n c=(3.0,4.0)\n print *, c, i, scale_complex(c, i)!, c*radix(c)**i\ncontains\nfunction scale_complex(x, n)\n! example supporting complex value for default kinds\ncomplex, intent(in) :: x\ninteger, intent(in) :: n\ncomplex :: scale_complex\n scale_complex=cmplx(scale(x%re, n), scale(x%im, n), kind=kind(x%im))\nend function scale_complex\nend program demo_scale\n```\nResults:\n```text\n > 2.00000000 4.00000000 8.00000000 16.0000000 32.0000000\n > 6.00000000 12.0000000 24.0000000 48.0000000 96.0000000\n > 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000\n > 1.78138707E-02 5 0.570043862 0.570043862\n > 1.78138707E-02 2 7.12554827E-02 7.12554827E-02\n > (3.00000000,4.00000000) 2 (12.0000000,16.0000000)\n```\n### **Standard**\n\nFortran 95\n\n### **See Also**\n\n[**digits**(3)](#digits),\n[**epsilon**(3)](#epsilon),\n[**exponent**(3)](#exponent),\n[**fraction**(3)](#fraction),\n[**huge**(3)](#huge),\n[**maxexponent**(3)](#maxexponent),\n[**minexponent**(3)](#minexponent),\n[**nearest**(3)](#nearest),\n[**precision**(3)](#precision),\n[**radix**(3)](#radix),\n[**range**(3)](#range),\n[**rrspacing**(3)](#rrspacing),\n[**set_exponent**(3)](#set_exponent),\n[**spacing**(3)](#spacing),\n[**tiny**(3)](#tiny)\n\n _fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n", "SCAN": "## scan\n\n### **Name**\n\n**scan** - \\[CHARACTER:SEARCH\\] Scan a string for the presence of a set of characters\n\n### **Synopsis**\n```fortran\n result = scan( string, set, [,back] [,kind] )\n```\n```fortran\n elemental integer(kind=KIND) function scan(string,set,back,kind)\n\n character(len=*,kind=**),intent(in) :: string\n character(len=*,kind=**),intent(in) :: set\n logical,intent(in),optional :: back\n integer,intent(in),optional :: kind\n```\n### **Characteristics**\n\n - **string** is a _character_ string of any kind\n - **set** must be a _character_ string with the same kind as **string**\n - **back** is a _logical_\n - **kind** is a scalar _integer_ constant expression\n - the result is an _integer_ with the kind specified by **kind**. If\n **kind** is not present the result is a default _integer_.\n\n### **Description**\n\n **scan** scans a **string** for any of the characters in a **set**\n of characters.\n\n If **back** is either absent or equals _.false._, this function\n returns the position of the leftmost character of **STRING** that is\n in **set**. If **back** equals _.true._, the rightmost position is\n returned. If no character of **set** is found in **string**, the result\n is zero.\n\n### **Options**\n\n- **string**\n : the string to be scanned\n\n- **set**\n : the set of characters which will be matched\n\n- **back**\n : if _.true._ the position of the rightmost character matched is\n returned, instead of the leftmost.\n\n- **kind**\n : the kind of the returned value is the same as **kind** if\n present. Otherwise a default _integer_ kind is returned.\n\n### **Result**\n\n If **back** is absent or is present with the value false and if\n **string** contains at least one character that is in **set**, the value\n of the result is the position of the leftmost character of **string**\n that is in **set**.\n\n If **back** is present with the value true and if **string** contains at\n least one character that is in **set**, the value of the result is the\n position of the rightmost character of **string** that is in **set**.\n\n The value of the result is zero if no character of STRING is in SET\n or if the length of STRING or SET is zero.\n\n### **Examples**\n\nSample program:\n```fortran\nprogram demo_scan\nimplicit none\n write(*,*) scan(\"fortran\", \"ao\") ! 2, found 'o'\n write(*,*) scan(\"fortran\", \"ao\", .true.) ! 6, found 'a'\n write(*,*) scan(\"fortran\", \"c++\") ! 0, found none\nend program demo_scan\n```\nResults:\n```text\n > 2\n > 6\n > 0\n```\n### **Standard**\n\nFortran 95 , with KIND argument - Fortran 2003\n\n### **See Also**\n\nFunctions that perform operations on character strings, return lengths\nof arguments, and search for certain arguments:\n\n- **Elemental:**\n [**adjustl**(3)](#adjustl), [**adjustr**(3)](#adjustr), [**index**(3)](#index),\n [**verify**(3)](#verify)\n\n- **Nonelemental:**\n [**len\\_trim**(3)](#len_trim),\n [**len**(3)](#len),\n [**repeat**(3)](#repeat), [**trim**(3)](#trim)\n\n _fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n", "SELECTED_CHAR_KIND": "## selected_char_kind\n\n### **Name**\n\n**selected_char_kind** - \\[KIND\\] Select character kind such as \"Unicode\"\n\n### **Synopsis**\n```fortran\n result = selected_char_kind(name)\n```\n```fortran\n integer function selected_char_kind(name)\n\n character(len=*),intent(in) :: name\n```\n### **Characteristics**\n\n - **name** is a default _character_ scalar\n - the result is a default _integer_ scalar\n\n### **Description**\n\n **selected_char_kind** returns a kind parameter value for the\n character set named **name**.\n\n If a name is not supported, -1 is returned. Otherwise the result is a\n value equal to that kind type parameter value.\n\n The list of supported names is processor-dependent except for \"DEFAULT\".\n\n + If **name** has the value \"DEFAULT\", then the result has a value equal to\n that of the kind type parameter of default character. This name is\n always supported.\n\n + If **name** has the value \"ASCII\", then the result has a value equal\n to that of the kind type parameter of ASCII character.\n\n + If **name** has the value \"ISO_10646\", then the result has a value equal\n to that of the kind type parameter of the ISO 10646 character kind\n (corresponding to UCS-4 as specified in ISO/IEC 10646).\n\n + If **name** is a processor-defined name of some other character kind\n supported by the processor, then the result has a value equal to that\n kind type parameter value.\n Pre-defined names include \"ASCII\" and \"ISO_10646\".\n\n The NAME is interpreted without respect to case or trailing blanks.\n\n### **Options**\n\n- **name**\n : A name to query the processor-dependent kind value of, and/or to determine\n if supported. **name**, interpreted without respect to case or\n trailing blanks.\n\n Currently, supported character sets include \"ASCII\" and \"DEFAULT\" and\n \"ISO_10646\" (Universal Character Set, UCS-4) which is commonly known as\n \"Unicode\". Supported names other than \"DEFAULT\" are processor dependent.\n\n### **Result**\n\n\n### **Examples**\n\nSample program:\n\n```fortran\nLinux\nprogram demo_selected_char_kind\nuse iso_fortran_env\nimplicit none\n\nintrinsic date_and_time,selected_char_kind\n\n! set some aliases for common character kinds\n! as the numbers can vary from platform to platform\n\ninteger, parameter :: default = selected_char_kind (\"default\")\ninteger, parameter :: ascii = selected_char_kind (\"ascii\")\ninteger, parameter :: ucs4 = selected_char_kind ('ISO_10646')\ninteger, parameter :: utf8 = selected_char_kind ('utf-8')\n\n! assuming ASCII and UCS4 are supported (ie. not equal to -1)\n! define some string variables\ncharacter(len=26, kind=ascii ) :: alphabet\ncharacter(len=30, kind=ucs4 ) :: hello_world\ncharacter(len=30, kind=ucs4 ) :: string\n\n write(*,*)'ASCII ',&\n & merge('Supported ','Not Supported',ascii /= -1)\n write(*,*)'ISO_10646 ',&\n & merge('Supported ','Not Supported',ucs4 /= -1)\n write(*,*)'UTF-8 ',&\n & merge('Supported ','Not Supported',utf8 /= -1)\n\n if(default.eq.ascii)then\n write(*,*)'ASCII is the default on this processor'\n endif\n\n ! for constants the kind precedes the value, somewhat like a\n ! BOZ constant\n alphabet = ascii_\"abcdefghijklmnopqrstuvwxyz\"\n write (*,*) alphabet\n\n hello_world = ucs4_'Hello World and Ni Hao -- ' &\n // char (int (z'4F60'), ucs4) &\n // char (int (z'597D'), ucs4)\n\n ! an encoding option is required on OPEN for non-default I/O\n if(ucs4 /= -1 )then\n open (output_unit, encoding='UTF-8')\n write (*,*) trim (hello_world)\n else\n write (*,*) 'cannot use utf-8'\n endif\n\n call create_date_string(string)\n write (*,*) trim (string)\n\ncontains\n\n! The following produces a Japanese date stamp.\nsubroutine create_date_string(string)\nintrinsic date_and_time,selected_char_kind\ninteger,parameter :: ucs4 = selected_char_kind(\"ISO_10646\")\ncharacter(len=1,kind=ucs4),parameter :: &\n nen = char(int( z'5e74' ),ucs4), & ! year\n gatsu = char(int( z'6708' ),ucs4), & ! month\n nichi = char(int( z'65e5' ),ucs4) ! day\ncharacter(len= *, kind= ucs4) string\ninteger values(8)\n call date_and_time(values=values)\n write(string,101) values(1),nen,values(2),gatsu,values(3),nichi\n 101 format(*(i0,a))\nend subroutine create_date_string\n\nend program demo_selected_char_kind\n```\nResults:\n\nThe results are very processor-dependent\n```text\n > ASCII Supported\n > ISO_10646 Supported\n > UTF-8 Not Supported\n > ASCII is the default on this processor\n > abcdefghijklmnopqrstuvwxyz\n > Hello World and Ni Hao -- \u4f60\u597d\n > 2022\u5e7410\u670815\u65e5\n```\n### **Standard**\n\nFortran 2003\n\n### **See also**\n\n[**selected_int_kind**(3)](#selected_int_kind),\n[**selected_real_kind**(3)](#selected_real_kind)\n\n[**achar**(3)](#achar),\n[**char**(3)](#char),\n[**ichar**(3)](#ichar),\n[**iachar**(3)](#iachar)\n\n _fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n", "SELECTED_INT_KIND": "## selected_int_kind\n\n### **Name**\n\n**selected_int_kind** - \\[KIND\\] Choose integer kind\n\n### **Synopsis**\n```fortran\n result = selected_int_kind(r)\n```\n```fortran\n integer function selected_int_kind(r)\n\n integer(kind=KIND),intent(in) :: r\n```\n### **Characteristics**\n\n - **r** is an _integer_ scalar.\n - the result is an default integer scalar.\n\n### **Description**\n\n **selected_int_kind** return the kind value of the smallest\n integer type that can represent all values ranging from **-10\\*\\*r**\n (exclusive) to **10\\*\\*r** (exclusive). If there is no integer kind\n that accommodates this range, selected_int_kind returns **-1**.\n\n### **Options**\n\n- **r**\n : The value specifies the required range of powers of ten that need\n supported by the kind type being returned.\n\n### **Result**\n\n The result has a value equal to the value of the kind type parameter\n of an integer type that represents all values in the requested range.\n\n if no such kind type parameter is available on the processor, the\n result is -1.\n\n If more than one kind type parameter meets the criterion, the value\n returned is the one with the smallest decimal exponent range, unless\n there are several such values, in which case the smallest of these\n kind values is returned.\n\n### **Examples**\n\nSample program:\n\n```fortran\nprogram demo_selected_int_kind\nimplicit none\ninteger,parameter :: k5 = selected_int_kind(5)\ninteger,parameter :: k15 = selected_int_kind(15)\ninteger(kind=k5) :: i5\ninteger(kind=k15) :: i15\n\n print *, huge(i5), huge(i15)\n\n ! the following inequalities are always true\n print *, huge(i5) >= 10_k5**5-1\n print *, huge(i15) >= 10_k15**15-1\nend program demo_selected_int_kind\n```\nResults:\n```text\n > 2147483647 9223372036854775807\n > T\n > T\n```\n### **Standard**\n\nFortran 95\n\n### **See Also**\n\n[**aint**(3)](#aint),\n[**anint**(3)](#anint),\n[**int**(3)](#int),\n[**nint**(3)](#nint),\n[**ceiling**(3)](#ceiling),\n[**floor**(3)](#floor)\n\n _fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n", @@ -182,7 +182,7 @@ "SINH": "## sinh\n\n### **Name**\n\n**sinh** - \\[MATHEMATICS:TRIGONOMETRIC\\] Hyperbolic sine function\n\n### **Synopsis**\n```fortran\n result = sinh(x)\n```\n```fortran\n elemental TYPE(kind=KIND) function sinh(x)\n\n TYPE(kind=KIND) :: x\n```\n### **Characteristics**\n\n - **TYPE** may be _real_ or _complex_\n - **KIND** may be any kind supported by the associated type.\n - The returned value will be of the same type and kind as the argument.\n\n### **Description**\n\n **sinh** computes the hyperbolic sine of **x**.\n\n The hyperbolic sine of x is defined mathematically as:\n```fortran\n sinh(x) = (exp(x) - exp(-x)) / 2.0\n```\n\n### **Options**\n\n- **x**\n : The value to calculate the hyperbolic sine of\n\n### **Result**\n\n The result has a value equal to a processor-dependent approximation\n to sinh(X). If X is of type complex its imaginary part is regarded\n as a value in radians.\n\n### **Examples**\n\nSample program:\n```fortran\nprogram demo_sinh\nuse, intrinsic :: iso_fortran_env, only : &\n& real_kinds, real32, real64, real128\nimplicit none\nreal(kind=real64) :: x = - 1.0_real64\nreal(kind=real64) :: nan, inf\ncharacter(len=20) :: line\n\n ! basics\n print *, sinh(x)\n print *, (exp(x)-exp(-x))/2.0\n\n ! sinh(3) is elemental and can handle an array\n print *, sinh([x,2.0*x,x/3.0])\n\n ! a NaN input returns NaN\n line='NAN'\n read(line,*) nan\n print *, sinh(nan)\n\n ! a Inf input returns Inf\n line='Infinity'\n read(line,*) inf\n print *, sinh(inf)\n\n ! an overflow returns Inf\n x=huge(0.0d0)\n print *, sinh(x)\n\nend program demo_sinh\n```\nResults:\n```text\n -1.1752011936438014\n -1.1752011936438014\n -1.1752011936438014 -3.6268604078470190 -0.33954055725615012\n NaN\n Infinity\n Infinity\n```\n### **Standard**\n\nFortran 95 , for a complex argument Fortran 2008\n\n### **See Also**\n\n[**asinh**(3)](#asinh)\n\n### **Resources**\n\n- [Wikipedia:hyperbolic functions](https://en.wikipedia.org/wiki/Hyperbolic_functions)\n\n _fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n", "SIZE": "## size\n\n### **Name**\n\n**size** - \\[ARRAY:INQUIRY\\] Determine the size of an array or extent of one dimension\n\n### **Synopsis**\n```fortran\n result = size(array [,dim] [,kind])\n```\n```fortran\n integer(kind=KIND) function size(array,dim,kind)\n\n type(TYPE(kind=KIND)),intent(in) :: array(..)\n integer(kind=**),intent(in),optional :: dim\n integer(kind=**),intent(in),optional :: KIND\n```\n### **Characteristics**\n\n- **array** is an assumed-rank array or array of any type and associated\n kind.\n\n If **array** is a pointer it must be associated and allocatable arrays\n must be allocated.\n- **dim** is an integer scalar\n- **kind** is a scalar integer constant expression.\n- the result is an integer scalar of kind **KIND**. If **KIND** is absent\n a _integer_ of default kind is returned.\n- a kind designated as ** may be any supported kind for the type\n\n\n### **Description**\n\n **size(3)** returns the total number of elements in an array, or\n if **dim** is specified returns the number of elements along that\n dimension.\n\n **size** determines the extent of **array** along a specified\n dimension **dim**, or the total number of elements in **array** if\n **dim** is absent.\n\n### **Options**\n\n- **array**\n : the array to measure the number of elements of.\n If **array* is an assumed-size array, **dim** shall be present with a value less\n than the rank of **array**.\n\n- **dim**\n : a value shall be\n in the range from 1 to n, where n equals the rank of **array**.\n\n If not present the total number of elements of the entire array\n are returned.\n\n- **kind**\n : An _integer_ initialization expression indicating the kind\n parameter of the result.\n\n If absent the kind type parameter of the returned value is that of\n default integer type.\n\n The **kind** must allow for the magnitude returned by **size** or\n results are undefined.\n\n If **kind** is absent, the return value is of default _integer_ kind.\n\n### **Result**\n\n If **dim** is not present **array** is assumed-rank, the result has a\n value equal to **PRODUCT(SHAPE(ARRAY,KIND))**. Otherwise, the result\n has a value equal to the total number of elements of **array**.\n\n If **dim** is present the number of elements along that dimension\n are returned, except that if ARRAY is assumed-rank and associated\n with an assumed-size array and DIM is present with a value equal to\n the rank of **array**, the value is -1.\n\n NOTE1\n\n If **array** is assumed-rank and has rank zero, **dim** cannot be\n present since it cannot satisfy the requirement\n\n 1 <= DIM <= 0.\n\n### **Examples**\n\nSample program:\n\n```fortran\nprogram demo_size\nimplicit none\ninteger :: arr(0:2,-5:5)\n write(*,*)'SIZE of simple two-dimensional array'\n write(*,*)'SIZE(arr) :total count of elements:',size(arr)\n write(*,*)'SIZE(arr,DIM=1) :number of rows :',size(arr,dim=1)\n write(*,*)'SIZE(arr,DIM=2) :number of columns :',size(arr,dim=2)\n\n ! pass the same array to a procedure that passes the value two\n ! different ways\n call interfaced(arr,arr)\ncontains\n\nsubroutine interfaced(arr1,arr2)\n! notice the difference in the array specification\n! for arr1 and arr2.\ninteger,intent(in) :: arr1(:,:)\ninteger,intent(in) :: arr2(2,*)\n !\n write(*,*)'interfaced assumed-shape array'\n write(*,*)'SIZE(arr1) :',size(arr1)\n write(*,*)'SIZE(arr1,DIM=1) :',size(arr1,dim=1)\n write(*,*)'SIZE(arr1,DIM=2) :',size(arr1,dim=2)\n\n! write(*,*)'SIZE(arr2) :',size(arr2)\n write(*,*)'SIZE(arr2,DIM=1) :',size(arr2,dim=1)\n!\n! CANNOT DETERMINE SIZE OF ASSUMED SIZE ARRAY LAST DIMENSION\n! write(*,*)'SIZE(arr2,DIM=2) :',size(arr2,dim=2)\n\nend subroutine interfaced\n\nend program demo_size\n```\nResults:\n```text\n SIZE of simple two-dimensional array\n SIZE(arr) :total count of elements: 33\n SIZE(arr,DIM=1) :number of rows : 3\n SIZE(arr,DIM=2) :number of columns : 11\n interfaced assumed-shape array\n SIZE(arr1) : 33\n SIZE(arr1,DIM=1) : 3\n SIZE(arr1,DIM=2) : 11\n SIZE(arr2,DIM=1) : 2\n```\n### **Standard**\n\nFortran 95 , with **kind** argument - Fortran 2003\n\n### **See Also**\n\n#### Array inquiry:\n\n- [**size**](#size) - Determine the size of an array\n- [**rank**(3)](#rank) - Rank of a data object\n- [**shape**(3)](#shape) - Determine the shape of an array\n- [**ubound**(3)](#ubound) - Upper dimension bounds of an array\n- [**lbound**(3)](#lbound) - Lower dimension bounds of an array\n\n#### State Inquiry:\n\n- [**allocated**(3)](#allocated) - Status of an allocatable entity\n- [**is_contiguous**(3)](#is_contiguous) - Test if object is contiguous\n\n#### Kind Inquiry:\n\n- [**kind**(3)](#kind) - Kind of an entity\n\n#### Bit Inquiry:\n\n- [**storage_size**(3)](#storage_size) - Storage size in bits\n- [**bit_size**(3)](#bit_size) - Bit size inquiry function\n- [**btest**(3)](#btest) - Tests a bit of an _integer_ value.\n\n _fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n", "SPACING": "## spacing\n\n### **Name**\n\n**spacing** - \\[MODEL_COMPONENTS\\] Smallest distance between two numbers of a given type\n\n### **Synopsis**\n```fortran\n result = spacing(x)\n```\n```fortran\n elemental real(kind=KIND) function spacing(x)\n\n real(kind=KIND), intent(in) :: x\n```\n### **Characteristics**\n\n - **x** is type real of any valid kind\n - The result is of the same type as the input argument **x**.\n\n### **Description**\n\n **spacing** determines the distance between the argument **x**\n and the nearest adjacent number of the same type.\n\n### **Options**\n\n- **x**\n : Shall be of type _real_.\n\n### **Result**\n\n If **x** does not have the value zero and is not an IEEE infinity or NaN, the result has the value\n nearest to **x** for values of the same type and kind assuming the value is representable.\n\n Otherwise, the value is the same as **tiny(x)**.\n + zero produces **tiny(x)**\n + IEEE Infinity produces an IEEE Nan\n + if an IEEE NaN, that NaN is returned\n\n If there are two extended model values equally near to **x**, the\n value of greater absolute value is taken.\n\n\n### **Examples**\n\nSample program:\n\n```fortran\nprogram demo_spacing\nimplicit none\ninteger, parameter :: sgl = selected_real_kind(p=6, r=37)\ninteger, parameter :: dbl = selected_real_kind(p=13, r=200)\n\n write(*,*) spacing(1.0_sgl)\n write(*,*) nearest(1.0_sgl,+1.0),nearest(1.0_sgl,+1.0)-1.0\n\n write(*,*) spacing(1.0_dbl)\nend program demo_spacing\n```\nResults:\n\nTypical values ...\n\n```text\n 1.1920929E-07\n 1.000000 1.1920929E-07\n 0.9999999 -5.9604645E-08\n 2.220446049250313E-016\n```\n### **Standard**\n\nFortran 95\n\n### **See Also**\n\n[**digits**(3)](#digits),\n[**epsilon**(3)](#epsilon),\n[**exponent**(3)](#exponent),\n[**fraction**(3)](#fraction),\n[**huge**(3)](#huge),\n[**maxexponent**(3)](#maxexponent),\n[**minexponent**(3)](#minexponent),\n[**nearest**(3)](#nearest),\n[**precision**(3)](#precision),\n[**radix**(3)](#radix),\n[**range**(3)](#range),\n[**rrspacing**(3)](#rrspacing),\n[**scale**(3)](#scale),\n[**set_exponent**(3)](#set_exponent),\n[**tiny**(3)](#tiny)\n\n _fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n", - "SPREAD": "## spread\n\n### **Name**\n\n**spread** - \\[ARRAY:CONSTRUCTION\\] Add a dimension and replicate data\n\n### **Synopsis**\n```fortran\n result = spread(source, dim, ncopies)\n```\n```fortran\n TYPE(kind=KIND) function spread(source, dim, ncopies)\n\n TYPE(kind=KIND) :: source(..)\n integer(kind=**),intent(in) :: dim\n integer(kind=**),intent(in) :: ncopies\n```\n### **Characteristics**\n\n- **source** is a scalar or array of any type and a rank less than fifteen.\n- **dim** is an _integer_ scalar\n- **ncopies** is an integer scalar\n\n### **Description**\n\n**spread** replicates a **source** array along a specified dimension\n**dim**. The copy is repeated **ncopies** times.\n\nSo to add additional rows to a matrix **dim=1** would be used, but to\nadd additional rows **dim=2** would be used, for example.\n\nIf **source** is scalar, the size of the resulting vector is **ncopies**\nand each element of the result has a value equal to **source**.\n\n### **Options**\n\n- **source**\n : the input data to duplicate\n\n- **dim**\n : The additional dimension value in the range from\n **1** to **n+1**, where **n** equals the rank of **source**.\n\n- **ncopies**\n : the number of copies of the original data to generate\n\n### **Result**\n\nThe result is an array of the same type as **source** and has rank **n+1**\nwhere **n** equals the rank of **source**.\n\n### **Examples**\n\nSample program:\n\n```fortran\nprogram demo_spread\nimplicit none\n\ninteger a1(4,3), a2(3,4), v(4), s\n\n write(*,'(a)' ) &\n 'TEST SPREAD(3) ', &\n ' SPREAD(3) is a FORTRAN90 function which replicates', &\n ' an array by adding a dimension. ', &\n ' '\n\n s = 99\n call printi('suppose we have a scalar S',s)\n\n write(*,*) 'to add a new dimension (1) of extent 4 call'\n call printi('spread( s, dim=1, ncopies=4 )',spread ( s, 1, 4 ))\n\n v = [ 1, 2, 3, 4 ]\n call printi(' first we will set V to',v)\n\n write(*,'(a)')' and then do \"spread ( v, dim=2, ncopies=3 )\"'\n a1 = spread ( v, dim=2, ncopies=3 )\n call printi('uses v as a column and makes 3 columns',a1)\n\n a2 = spread ( v, 1, 3 )\n call printi(' spread(v,1,3) uses v as a row and makes 3 rows',a2)\n\ncontains\n! CONVENIENCE ROUTINE; NOT DIRECTLY CONNECTED TO SPREAD(3)\nsubroutine printi(title,a)\nuse, intrinsic :: iso_fortran_env, only : stderr=>ERROR_UNIT,&\n & stdin=>INPUT_UNIT, stdout=>OUTPUT_UNIT\nimplicit none\n\n!@(#) print small 2d integer scalar, vector, matrix in row-column format\n\ncharacter(len=*),parameter :: all='(\" \",*(g0,1x))'\ncharacter(len=*),intent(in) :: title\ncharacter(len=20) :: row\ninteger,intent(in) :: a(..)\ninteger :: i\n\n write(*,all,advance='no')trim(title)\n ! select rank of input\n select rank(a)\n rank (0); write(*,'(a)')' (a scalar)'\n write(*,'(\" > [ \",i0,\" ]\")')a\n rank (1); write(*,'(a)')' (a vector)'\n ! find how many characters to use for integers\n write(row,'(i0)')ceiling(log10(max(1.0,real(maxval(abs(a))))))+2\n ! use this format to write a row\n row='(\" > [\",*(i'//trim(row)//':,\",\"))'\n do i=1,size(a)\n write(*,fmt=row,advance='no')a(i)\n write(*,'(\" ]\")')\n enddo\n rank (2); write(*,'(a)')' (a matrix) '\n ! find how many characters to use for integers\n write(row,'(i0)')ceiling(log10(max(1.0,real(maxval(abs(a))))))+2\n ! use this format to write a row\n row='(\" > [\",*(i'//trim(row)//':,\",\"))'\n do i=1,size(a,dim=1)\n write(*,fmt=row,advance='no')a(i,:)\n write(*,'(\" ]\")')\n enddo\n rank default\n write(stderr,*)'*printi* did not expect rank=', rank(a), &\n & 'shape=', shape(a),'size=',size(a)\n stop '*printi* unexpected rank'\n end select\n write(*,all) '>shape=',shape(a),',rank=',rank(a),',size=',size(a)\n write(*,*)\n\nend subroutine printi\n\nend program demo_spread\n```\nResults:\n```text\n > TEST SPREAD(3) \n > SPREAD(3) is a FORTRAN90 function which replicates\n > an array by adding a dimension. \n > \n > suppose we have a scalar S (a scalar)\n > > [ 99 ]\n > >shape= ,rank= 0 ,size= 1\n > \n > to add a new dimension (1) of extent 4 call\n > spread( s, dim=1, ncopies=4 ) (a vector)\n > > [ 99 ]\n > > [ 99 ]\n > > [ 99 ]\n > > [ 0 ]\n > >shape= 4 ,rank= 1 ,size= 4\n > \n > first we will set V to (a vector)\n > > [ 1 ]\n > > [ 2 ]\n > > [ 3 ]\n > > [ 4 ]\n > >shape= 4 ,rank= 1 ,size= 4\n > \n > and then do \"spread ( v, dim=2, ncopies=3 )\"\n > uses v as a column and makes 3 columns (a matrix) \n > > [ 1, 1, 1 ]\n > > [ 2, 2, 2 ]\n > > [ 3, 3, 3 ]\n > > [ 4, 4, 4 ]\n > >shape= 4 3 ,rank= 2 ,size= 12\n > \n > spread(v,1,3) uses v as a row and makes 3 rows (a matrix) \n > > [ 1, 2, 3, 4 ]\n > > [ 1, 2, 3, 4 ]\n > > [ 1, 2, 3, 4 ]\n > >shape= 3 4 ,rank= 2 ,size= 12\n > \n```\n### **Standard**\n\nFortran 95\n\n### **See Also**\n\n[**merge**(3)](#merge),\n[**pack**(3)](#pack),\n[**unpack**(3)](#unpack)\n\n _fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n\n", + "SPREAD": "## spread\n\n### **Name**\n\n**spread** - \\[ARRAY:CONSTRUCTION\\] Add a dimension and replicate data\n\n### **Synopsis**\n```fortran\n result = spread(source, dim, ncopies)\n```\n```fortran\n TYPE(kind=KIND) function spread(source, dim, ncopies)\n\n TYPE(kind=KIND) :: source(..)\n integer(kind=**),intent(in) :: dim\n integer(kind=**),intent(in) :: ncopies\n```\n### **Characteristics**\n\n- **source** is a scalar or array of any type and a rank less than fifteen.\n- **dim** is an _integer_ scalar\n- **ncopies** is an integer scalar\n\n### **Description**\n\n**spread** replicates a **source** array along a specified dimension\n**dim**. The copy is repeated **ncopies** times.\n\nSo to add additional rows to a matrix **dim=1** would be used, but to\nadd additional rows **dim=2** would be used, for example.\n\nIf **source** is scalar, the size of the resulting vector is **ncopies**\nand each element of the result has a value equal to **source**.\n\n### **Options**\n\n- **source**\n : the input data to duplicate\n\n- **dim**\n : The additional dimension value in the range from\n **1** to **n+1**, where **n** equals the rank of **source**.\n\n- **ncopies**\n : the number of copies of the original data to generate\n\n### **Result**\n\nThe result is an array of the same type as **source** and has rank **n+1**\nwhere **n** equals the rank of **source**.\n\n### **Examples**\n\nSample program:\n\n```fortran\nprogram demo_spread\nimplicit none\n\ninteger a1(4,3), a2(3,4), v(4), s\n\n write(*,'(a)' ) &\n 'TEST SPREAD(3) ', &\n ' SPREAD(3) is a FORTRAN90 function which replicates', &\n ' an array by adding a dimension. ', &\n ' '\n\n s = 99\n call printi('suppose we have a scalar S',s)\n\n write(*,*) 'to add a new dimension (1) of extent 4 call'\n call printi('spread( s, dim=1, ncopies=4 )',spread ( s, 1, 4 ))\n\n v = [ 1, 2, 3, 4 ]\n call printi(' first we will set V to',v)\n\n write(*,'(a)')' and then do \"spread ( v, dim=2, ncopies=3 )\"'\n a1 = spread ( v, dim=2, ncopies=3 )\n call printi('uses v as a column and makes 3 columns',a1)\n\n a2 = spread ( v, 1, 3 )\n call printi(' spread(v,1,3) uses v as a row and makes 3 rows',a2)\n\ncontains\n! CONVENIENCE ROUTINE; NOT DIRECTLY CONNECTED TO SPREAD(3)\nsubroutine printi(title,a)\nuse, intrinsic :: iso_fortran_env, only : stderr=>ERROR_UNIT,&\n & stdin=>INPUT_UNIT, stdout=>OUTPUT_UNIT\nimplicit none\n\n!@(#) print small 2d integer scalar, vector, matrix in row-column format\n\ncharacter(len=*),parameter :: all='(\" \",*(g0,1x))'\ncharacter(len=*),intent(in) :: title\ncharacter(len=20) :: row\ninteger,intent(in) :: a(..)\ninteger :: i\n\n write(*,all,advance='no')trim(title)\n ! select rank of input\n select rank(a)\n rank (0); write(*,'(a)')' (a scalar)'\n write(*,'(\" > [ \",i0,\" ]\")')a\n rank (1); write(*,'(a)')' (a vector)'\n ! find how many characters to use for integers\n write(row,'(i0)')ceiling(log10(max(1.0,real(maxval(abs(a))))))+2\n ! use this format to write a row\n row='(\" > [\",*(i'//trim(row)//':,\",\"))'\n do i=1,size(a)\n write(*,fmt=row,advance='no')a(i)\n write(*,'(\" ]\")')\n enddo\n rank (2); write(*,'(a)')' (a matrix) '\n ! find how many characters to use for integers\n write(row,'(i0)')ceiling(log10(max(1.0,real(maxval(abs(a))))))+2\n ! use this format to write a row\n row='(\" > [\",*(i'//trim(row)//':,\",\"))'\n do i=1,size(a,dim=1)\n write(*,fmt=row,advance='no')a(i,:)\n write(*,'(\" ]\")')\n enddo\n rank default\n write(stderr,*)'*printi* did not expect rank=', rank(a), &\n & 'shape=', shape(a),'size=',size(a)\n stop '*printi* unexpected rank'\n end select\n write(*,all) '>shape=',shape(a),',rank=',rank(a),',size=',size(a)\n write(*,*)\n\nend subroutine printi\n\nend program demo_spread\n```\nResults:\n```text\n > TEST SPREAD(3)\n > SPREAD(3) is a FORTRAN90 function which replicates\n > an array by adding a dimension.\n >\n > suppose we have a scalar S (a scalar)\n > > [ 99 ]\n > >shape= ,rank= 0 ,size= 1\n >\n > to add a new dimension (1) of extent 4 call\n > spread( s, dim=1, ncopies=4 ) (a vector)\n > > [ 99 ]\n > > [ 99 ]\n > > [ 99 ]\n > > [ 0 ]\n > >shape= 4 ,rank= 1 ,size= 4\n >\n > first we will set V to (a vector)\n > > [ 1 ]\n > > [ 2 ]\n > > [ 3 ]\n > > [ 4 ]\n > >shape= 4 ,rank= 1 ,size= 4\n >\n > and then do \"spread ( v, dim=2, ncopies=3 )\"\n > uses v as a column and makes 3 columns (a matrix)\n > > [ 1, 1, 1 ]\n > > [ 2, 2, 2 ]\n > > [ 3, 3, 3 ]\n > > [ 4, 4, 4 ]\n > >shape= 4 3 ,rank= 2 ,size= 12\n >\n > spread(v,1,3) uses v as a row and makes 3 rows (a matrix)\n > > [ 1, 2, 3, 4 ]\n > > [ 1, 2, 3, 4 ]\n > > [ 1, 2, 3, 4 ]\n > >shape= 3 4 ,rank= 2 ,size= 12\n >\n```\n### **Standard**\n\nFortran 95\n\n### **See Also**\n\n[**merge**(3)](#merge),\n[**pack**(3)](#pack),\n[**unpack**(3)](#unpack)\n\n _fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n\n", "SQRT": "## sqrt\n\n### **Name**\n\n**sqrt** - \\[MATHEMATICS\\] Square-root function\n\n### **Synopsis**\n```fortran\n result = sqrt(x)\n```\n```fortran\n elemental TYPE(kind=KIND) function sqrt(x)\n\n TYPE(kind=KIND),intent(in) :: x\n```\n### **Characteristics**\n\n - **TYPE** may be _real_ or _complex_.\n - **KIND** may be any kind valid for the declared type.\n - the result has the same characteristics as **x**.\n\n### **Description**\n\n **sqrt** computes the principal square root of **x**.\n\n The number whose square root is being considered is known as the\n _radicand_.\n\n In mathematics, a square root of a radicand **x** is a number **y**\n such that **y\\*y = x**.\n\n Every nonnegative radicand **x** has two square roots of the same unique\n magnitude, one positive and one negative. The nonnegative square root\n is called the principal square root.\n\n The principal square root of 9 is 3, for example, even though (-3)\\*(-3)\n is also 9.\n\n Square roots of negative numbers are a special case of complex numbers,\n where with **complex** input the components of the _radicand_ need\n not be positive in order to have a valid square root.\n\n### **Options**\n\n- **x**\n : The radicand to find the principal square root of.\n If **x** is _real_ its value must be greater than or equal to zero.\n\n### **Result**\n\n The principal square root of **x** is returned.\n\n For a _complex_ result the real part is greater than or equal to zero.\n\n When the real part of the result is zero, the imaginary part has the\n same sign as the imaginary part of **x**.\n\n### **Examples**\n\nSample program:\n\n```fortran\nprogram demo_sqrt\nuse, intrinsic :: iso_fortran_env, only : real_kinds, &\n & real32, real64, real128\nimplicit none\nreal(kind=real64) :: x, x2\ncomplex :: z, z2\n\n ! basics\n x = 2.0_real64\n ! complex\n z = (1.0, 2.0)\n write(*,*)'input values ',x,z\n\n x2 = sqrt(x)\n z2 = sqrt(z)\n write(*,*)'output values ',x2,z2\n\n ! elemental\n write(*,*)'elemental',sqrt([64.0,121.0,30.0])\n\n ! alternatives\n x2 = x**0.5\n z2 = z**0.5\n write(*,*)'alternatively',x2,z2\n\nend program demo_sqrt\n```\nResults:\n```text\n input values 2.00000000000000 (1.000000,2.000000)\n output values 1.41421356237310 (1.272020,0.7861513)\n elemental 8.000000 11.00000 5.477226\n alternatively 1.41421356237310 (1.272020,0.7861513)\n```\n### **Standard**\n\nFORTRAN 77\n\n### **See also**\n\n[**exp**(3)](#exp),\n[**log**(3)](#log),\n[**log10**(3)](#log10)\n\n _fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n", "STORAGE_SIZE": "\n## storage_size\n\n### **Name**\n\n**storage_size** - \\[BIT:INQUIRY\\] Storage size in bits\n\n### **Synopsis**\n```fortran\n result = storage_size(a [,KIND] )\n```\n```fortran\n integer(kind=KIND) storage_size(a,KIND)\n\n type(TYPE(kind=**)) :: a\n integer,intent(in),optional :: KIND\n```\n### **Characteristics**\n - a kind designated as ** may be any supported kind for the type\n\n - **a** may be of any type and kind. If it is polymorphic it shall not\n be an undefined pointer. If it is unlimited polymorphic or has any\n deferred type parameters, it shall not be an unallocated allocatable\n variable or a disassociated or undefined pointer.\n\n - The kind type parameter of the returned value is that specified by\n the value of **kind**; otherwise, the kind type parameter is that of\n default integer type.\n\n - The result is an _integer_ scalar of default kind unless **kind** is\n specified, in which case it has the kind specified by **kind**.\n\n### **Description**\n\n**storage_size** returns the storage size of argument **a** in bits.\n\n### **Options**\n\n- **a**\n : The entity to determine the storage size of\n\n- **kind**\n : a scalar integer constant expression that defines the kind of the\n output value.\n\n### **Result**\n\n The result value is the size expressed in bits for an element of an\n array that has the dynamic type and type parameters of **a**.\n\n If the type and type parameters are such that storage association\n applies, the result is consistent with the named constants\n defined in the intrinsic module ISO_FORTRAN_ENV.\n\n NOTE1\n\n An array element might take \"type\" more bits to store than an isolated\n scalar, since any hardware-imposed alignment requirements for array\n elements might not apply to a simple scalar variable.\n\n NOTE2\n\n This is intended to be the size in memory that an object takes when it\n is stored; this might differ from the size it takes during expression\n handling (which might be the native register size) or when stored in a\n file. If an object is never stored in memory but only in a register,\n this function nonetheless returns the size it would take if it were\n stored in memory.\n\n### **Examples**\n\nSample program\n```fortran\nprogram demo_storage_size\nimplicit none\n\n ! a default real, integer, and logical are the same storage size\n write(*,*)'size of integer ',storage_size(0)\n write(*,*)'size of real ',storage_size(0.0)\n write(*,*)'size of logical ',storage_size(.true.)\n write(*,*)'size of complex ',storage_size((0.0,0.0))\n\n ! note the size of an element of the array, not the storage size of\n ! the entire array is returned for array arguments\n write(*,*)'size of integer array ',storage_size([0,1,2,3,4,5,6,7,8,9])\n\nend program demo_storage_size\n```\nResults:\n```text\n size of integer 32\n size of real 32\n size of logical 32\n size of complex 64\n size of integer array 32\n```\n### **Standard**\n\nFortran 2008\n\n### **See Also**\n\n[**c_sizeof**(3)](#c_sizeof)\n\n _fortran-lang intrinsic descriptions_\n", "SUM": "## sum\n\n### **Name**\n\n**sum** - \\[ARRAY:REDUCTION\\] Sum the elements of an array\n\n### **Synopsis**\n```fortran\n result = sum(array [,dim[,mask]] | [mask] )\n```\n```fortran\n TYPE(kind=KIND) function sum(array, dim, mask)\n\n TYPE(kind=KIND),intent(in) :: array(..)\n integer(kind=**),intent(in),optional :: dim\n logical(kind=**),intent(in),optional :: mask(..)\n```\n### **Characteristics**\n\n - a kind designated as ** may be any supported kind for the type\n - **array** may be of any numeric type - _integer_, _real_ or _complex_.\n - **dim** is an _integer_\n - **mask** is _logical_ and conformable with **array**.\n - The result is of the same type and kind as **array**. It is scalar\n if **dim** is not present or **array** is a vector, else it is an array.\n\n### **Description**\n\n **sum** adds the elements of **array**.\n\n When only **array** is specified all elements are summed, but groups\n of sums may be returned along the dimension specified by **dim**\n and/or elements to add may be selected by a logical mask.\n\n No method is designated for how the sum is conducted, so whether or not\n accumulated error is compensated for is processor-dependent.\n\n### **Options**\n\n- **array**\n : an array containing the elements to add\n\n- **dim**\n : a value in the range from 1 to n, where n equals the rank (the number\n of dimensions) of **array**. **dim** designates the dimension\n along which to create sums. When absent a scalar sum of the elements\n optionally selected by **mask** is returned.\n\n- **mask**\n : an array of the same shape as **array** that designates\n which elements to add. If absent all elements are used in the sum(s).\n\n### **Result**\n\n If **dim** is absent, a scalar with the sum of all selected elements\n in **array** is returned. Otherwise, an array of rank n-1, where n\n equals the rank of **array**, and a shape similar to that of **array**\n with dimension **dim** dropped is returned. Since a vector has a rank\n of one, the result is a scalar (if n==1, n-1 is zero; and a rank of\n zero means a scalar).\n\n### **Examples**\n\nSample program:\n```fortran\nprogram demo_sum\nimplicit none\ninteger :: vector(5) , matrix(3,4), box(5,6,7)\n\n vector = [ 1, 2, -3, 4, 5 ]\n\n matrix(1,:)=[ -1, 2, -3, 4 ]\n matrix(2,:)=[ 10, -20, 30, -40 ]\n matrix(3,:)=[ 100, 200, -300, 400 ]\n\n box=11\n\n ! basics\n print *, 'sum all elements:',sum(vector)\n print *, 'real :',sum([11.0,-5.0,20.0])\n print *, 'complex :',sum([(1.1,-3.3),(4.0,5.0),(8.0,-6.0)])\n ! with MASK option\n print *, 'sum odd elements:',sum(vector, mask=mod(vector, 2)==1)\n print *, 'sum positive values:', sum(vector, mask=vector>0)\n\n call printi('the input array', matrix )\n call printi('sum of all elements in matrix', sum(matrix) )\n call printi('sum of positive elements', sum(matrix,matrix>=0) )\n ! along dimensions\n call printi('sum along rows', sum(matrix,dim=1) )\n call printi('sum along columns', sum(matrix,dim=2) )\n call printi('sum of a vector is always a scalar', sum(vector,dim=1) )\n call printi('sum of a volume by row', sum(box,dim=1) )\n call printi('sum of a volume by column', sum(box,dim=2) )\n call printi('sum of a volume by depth', sum(box,dim=3) )\n\ncontains\n! CONVENIENCE ROUTINE; NOT DIRECTLY CONNECTED TO SPREAD(3)\nsubroutine printi(title,a)\nuse, intrinsic :: iso_fortran_env, only : stderr=>ERROR_UNIT,&\n & stdin=>INPUT_UNIT, stdout=>OUTPUT_UNIT\nimplicit none\n\n!@(#) print small 2d integer scalar, vector, matrix in row-column format\n\ncharacter(len=*),intent(in) :: title\ninteger,intent(in) :: a(..)\n\ncharacter(len=*),parameter :: all='(\" \",*(g0,1x))'\ncharacter(len=20) :: row\ninteger,allocatable :: b(:,:)\ninteger :: i\n write(*,all,advance='no')trim(title)\n ! copy everything to a matrix to keep code simple\n select rank(a)\n rank (0); write(*,'(a)')' (a scalar)'; b=reshape([a],[1,1])\n rank (1); write(*,'(a)')' (a vector)'; b=reshape(a,[size(a),1])\n rank (2); write(*,'(a)')' (a matrix)'; b=a\n rank default; stop '*printi* unexpected rank'\n end select\n ! find how many characters to use for integers\n write(row,'(i0)')ceiling(log10(max(1.0,real(maxval(abs(b))))))+2\n ! use this format to write a row\n row='(\" > [\",*(i'//trim(row)//':,\",\"))'\n do i=1,size(b,dim=1)\n write(*,fmt=row,advance='no')b(i,:)\n write(*,'(\" ]\")')\n enddo\n write(*,all) '>shape=',shape(a),',rank=',rank(a),',size=',size(a)\n write(*,*)\nend subroutine printi\nend program demo_sum\n```\nResults:\n```text\n sum all elements: 9\n real : 26.00000\n complex : (13.10000,-4.300000)\n sum odd elements: 6\n sum positive values: 12\n the input array (a matrix)\n > [ -1, 2, -3, 4 ]\n > [ 10, -20, 30, -40 ]\n > [ 100, 200, -300, 400 ]\n >shape= 3 4 ,rank= 2 ,size= 12\n\n sum of all elements in matrix (a scalar)\n > [ 382 ]\n >shape= ,rank= 0 ,size= 1\n\n sum of positive elements (a scalar)\n > [ 746 ]\n >shape= ,rank= 0 ,size= 1\n\n sum along rows (a vector)\n > [ 109 ]\n > [ 182 ]\n > [ -273 ]\n > [ 364 ]\n >shape= 4 ,rank= 1 ,size= 4\n\n sum along columns (a vector)\n > [ 2 ]\n > [ -20 ]\n > [ 400 ]\n >shape= 3 ,rank= 1 ,size= 3\n\n sum of a vector is always a scalar (a scalar)\n > [ 9 ]\n >shape= ,rank= 0 ,size= 1\n\n sum of a volume by row (a matrix)\n > [ 55, 55, 55, 55, 55, 55, 55 ]\n > [ 55, 55, 55, 55, 55, 55, 55 ]\n > [ 55, 55, 55, 55, 55, 55, 55 ]\n > [ 55, 55, 55, 55, 55, 55, 55 ]\n > [ 55, 55, 55, 55, 55, 55, 55 ]\n > [ 55, 55, 55, 55, 55, 55, 55 ]\n >shape= 6 7 ,rank= 2 ,size= 42\n\n sum of a volume by column (a matrix)\n > [ 66, 66, 66, 66, 66, 66, 66 ]\n > [ 66, 66, 66, 66, 66, 66, 66 ]\n > [ 66, 66, 66, 66, 66, 66, 66 ]\n > [ 66, 66, 66, 66, 66, 66, 66 ]\n > [ 66, 66, 66, 66, 66, 66, 66 ]\n >shape= 5 7 ,rank= 2 ,size= 35\n\n sum of a volume by depth (a matrix)\n > [ 77, 77, 77, 77, 77, 77 ]\n > [ 77, 77, 77, 77, 77, 77 ]\n > [ 77, 77, 77, 77, 77, 77 ]\n > [ 77, 77, 77, 77, 77, 77 ]\n > [ 77, 77, 77, 77, 77, 77 ]\n >shape= 5 6 ,rank= 2 ,size= 30\n```\n### **Standard**\n\nFortran 95\n\n### **See Also**\n\n - [**all**(3)](#all) - Determines if all the values are true\n - [**any**(3)](#any) - Determines if any of the values in the logical array are true.\n - [**count**(3)](#count) - Count true values in an array\n - [**maxval**(3)](#maxval) - Determines the maximum value in an array\n - [**minval**(3)](#minval) - Minimum value of an array\n - [**product**(3)](#product) - Product of array elements\n - [**merge**(3)](#merge) - Merge variables\n\n _fortran-lang intrinsic descriptions (license: MIT) \\@urbanjost_\n",