6 October 2025 6:06:03.065 PM f90_intrinsics_test(): Fortran90 version Test Fortran90 intrinsic library. test_abs(): abs() returns the absolute value of a numeric quantity Type VALUE ABS(VALUE) integer -88 88 Integer ( kind = 8 ) -88 88 Real 45.7800 45.7800 Real ( kind = rk8 ) 45.7800 45.7800 Complex 1.0000 -2.0000 2.2361 Complex ( kind = ck8 ) 1.0000 -2.0000 2.2361 TEST_ACHAR ACHAR is a Fortran90 function which returns the character of given ASCII index. I ACHAR(I) 32 33 ! 34 " 35 # 36 $ 37 % 38 & 39 ' 40 ( 41 ) 42 * 43 + 44 , 45 - 46 . 47 / 48 0 49 1 50 2 51 3 52 4 53 5 54 6 55 7 56 8 57 9 58 : 59 ; 60 < 61 = 62 > 63 ? 64 @ 65 A 66 B 67 C 68 D 69 E 70 F 71 G 72 H 73 I 74 J 75 K 76 L 77 M 78 N 79 O 80 P 81 Q 82 R 83 S 84 T 85 U 86 V 87 W 88 X 89 Y 90 Z 91 [ 92 \ 93 ] 94 ^ 95 _ 96 ` 97 a 98 b 99 c 100 d 101 e 102 f 103 g 104 h 105 i 106 j 107 k 108 l 109 m 110 n 111 o 112 p 113 q 114 r 115 s 116 t 117 u 118 v 119 w 120 x 121 y 122 z 123 { 124 | 125 } 126 ~ TEST_ACOS ACOS is a Fortran90 function which returns the inverse cosine of a value between -1 and 1 X ACOS(X) COS(ACOS(X)) 0.945611 0.331328 0.945611 0.345452 1.21808 0.345452 0.684284 0.817175 0.684284 0.695593 0.801551 0.695593 -0.923421 2.74770 -0.923421 -0.200184 1.77234 -0.200184 0.492754 1.05554 0.492754 0.586611E-01 1.51210 0.586611E-01 -0.926819 2.75665 -0.926819 -0.932999 2.77346 -0.932999 TEST_ADJUSTL ADJUSTL is a Fortran90 function which returns the left-adjusted copy of a string. S ADJUSTL(S) ---------- ---------- 1234567890 1234567890 12345 12345 67890 67890 34 678 34 678 5 5 TEST_ADJUSTR ADJUSTR is a Fortran90 function which returns the right-adjusted copy of a string. S ADJUSTR(S) ---------- ---------- 1234567890 1234567890 12345 12345 67890 67890 34 678 34 678 5 5 TEST_AIMAG AIMAG is a Fortran90 function which returns the imaginary part of a complex number. X AIMAG(X) -0.357129 0.798542 0.798542 0.973236 0.203064 0.203064 0.795595 -0.389878 -0.389878 -0.695330 -0.576954 -0.576954 0.170539 -0.983466 -0.983466 0.628275 -0.455452 -0.455452 -0.896159 0.292513 0.292513 -0.555103 0.797655 0.797655 0.390525 0.400284 0.400284 -0.856376 -0.100693 -0.100693 TEST_AINT AINT is a Fortran90 function which returns the value of a real number rounded towards zero. X AINT(X) 7.77768 7.00000 -2.40020 -2.00000 -4.61752 -4.00000 -6.88033 -6.00000 4.54501 4.00000 -0.230214 -0.00000 4.42442 4.00000 -2.58387 -2.00000 7.60833 7.00000 -1.91680 -1.00000 TEST_ALL ALL(MASK) is a Fortran90 function which returns TRUE if every entry of MASK is true. ALL(MASK,DIM) is a Fortran90 function which returns an array of values which are TRUE where every entry in dimension DIM is true. integer a_i4(4,5) 83 53 39 86 80 92 2 89 25 68 43 76 41 31 92 67 51 89 55 21 ALL ( A_I4 < 100 ) T ALL ( A_I4 < 90 ) F ALL ( A_I4 < 90, 1 ) F T T T F ALL ( A_I4 < 90, 2 ) T F F T ALL ( MOD(A_I4,2)==0,1 ) F F F F F ALL ( MOD(A_I4,2)==0,2 ) F F F F TEST_ALLOCATED ALLOCATED(ARRAY) is a Fortran90 function which is TRUE if the allocatable array ARRAY has actually been allocated. Initial status: A_C4 <- Not allocated. A_I4 <- Not allocated. A_R8 <- Not allocated. Call ALLOCATED: ALLOCATED(A_C4) = F ALLOCATED(A_I4) = F ALLOCATED(A_R8) = F Allocate A_C4 and A_I4: ALLOCATED(A_C4) = T ALLOCATED(A_I4) = T ALLOCATED(A_R8) = F Deallocate A_C4, allocate A_R8: ALLOCATED(A_C4) = F ALLOCATED(A_I4) = T ALLOCATED(A_R8) = T TEST_ANINT ANINT is a Fortran90 function which returns, as a real value, the nearest integer to a given real number. X ANINT(X) -3.09453 -3.00000 7.42805 7.00000 -3.07101 -3.00000 -9.09375 -9.00000 2.02589 2.00000 7.35721 7.00000 5.38586 5.00000 -1.04148 -1.00000 -7.60296 -8.00000 -2.90156 -3.00000 TEST_ANY ANY(MASK) is a Fortran90 function which returns TRUE if any entry of MASK is true. ANY(MASK,DIM) is a Fortran90 function which returns an array of values which are TRUE where any entry in dimension DIM is true. integer a_i4(4,5) 66 8 89 69 13 41 2 19 23 43 53 99 28 75 19 90 79 93 68 80 ANY ( A_I4 < 10 ) T ANY ( A_I4 < 0 ) F ANY ( A_I4 < 10, 1 ) F T F F F ANY ( A_I4 < 10, 2 ) T T F F ANY ( MOD(A_I4,5)==0,1 ) T F F T T ANY ( MOD(A_I4,5)==0,2 ) F F T T TEST_ASIN ASIN is a Fortran90 function which returns the inverse sine of a value between -1 and 1 X ASIN(X) SIN(ASIN(X)) 0.902857 1.12637 0.902857 -0.556520 -0.590192 -0.556520 -0.718602 -0.801789 -0.718602 0.315920 0.321426 0.315920 0.659156E-01 0.659634E-01 0.659156E-01 -0.617019 -0.664949 -0.617019 0.334829 0.341424 0.334829 0.238373 0.240690 0.238373 0.370011 0.379021 0.370011 0.242913 0.245368 0.242913 TEST_ASSOCIATED ASSOCIATED(POINTER,TARGET) is a Fortran90 function which returns the association status of a pointer, or indicates the pointer is associated with the target. Initial status: P_C4 <- Not associated. P_I4 <- Not associated. P_R8 <- Not associated. Call ASSOCIATED: ASSOCIATED(P_C4,A_C4) = F ASSOCIATED(P_I4,A_I4) = F ASSOCIATED(P_R8,A_R8) = F Point to A_C4 and A_I4: ASSOCIATED(P_C4,A_C4) = T ASSOCIATED(P_I4,A_I4) = T ASSOCIATED(P_R8,A_R8) = F Nullify A_C4, point to A_R8: ASSOCIATED(P_C4,A_C4) = F ASSOCIATED(P_I4,A_I4) = T ASSOCIATED(P_R8,A_R8) = T test_atan(): atan() is a Fortran90 function which returns the inverse tangent of a value X ATAN(X) TAN(ATAN(X)) 6.40169 1.41584 6.40169 -2.86951 -1.23547 -2.86951 0.874239 0.718399 0.874239 6.19686 1.41080 6.19686 -8.49730 -1.45365 -8.49730 -4.99011 -1.37302 -4.99011 -0.696635 -0.608464 -0.696635 -5.98775 -1.40532 -5.98775 -8.80832 -1.45775 -8.80832 8.04570 1.44714 8.04570 TEST_ATAN2 ATAN2 is a Fortran90 function which returns the inverse tangent of a value X Y ATAN2(Y,X) TAN(ATAN2(Y,X)) 2.20389 -1.38592 -0.561364 -0.628852 0.430347 6.99232 1.50933 16.2481 -4.19665 5.04176 2.26497 -1.20138 -5.78239 -8.84499 -2.14980 1.52964 -7.31302 -3.43354 -2.70263 0.469511 2.69639 -5.14300 -1.08791 -1.90737 2.85393 -5.52857 -1.09426 -1.93717 6.05803 9.40285 0.998456 1.55213 4.76821 -2.95063 -0.554137 -0.618812 8.77392 -6.96162 -0.670731 -0.793445 TEST_BIT_SIZE BIT_SIZE is a Fortran90 function which returns the size of an integer in bits. Type(X) BIT_SIZE(X) INTEGER 32 integer 32 INTEGER ( KIND = 8 ) 64 TEST_BTEST BTEST(I,POS) is a Fortran90 function which is TRUE if bit POS of I is 1. Here, we are only going to check the lowest 32 bits. I POS BTEST(I,POS) 213456 0 F 213456 1 F 213456 2 F 213456 3 F 213456 4 T 213456 5 F 213456 6 T 213456 7 T 213456 8 T 213456 9 F 213456 10 F 213456 11 F 213456 12 F 213456 13 F 213456 14 T 213456 15 F 213456 16 T 213456 17 T 213456 18 F 213456 19 F 213456 20 F 213456 21 F 213456 22 F 213456 23 F 213456 24 F 213456 25 F 213456 26 F 213456 27 F 213456 28 F 213456 29 F 213456 30 F 213456 31 F The binary representation of 213456 is: "00000000000000110100000111010000". I POS BTEST(I,POS) -28 0 F -28 1 F -28 2 T -28 3 F -28 4 F -28 5 T -28 6 T -28 7 T -28 8 T -28 9 T -28 10 T -28 11 T -28 12 T -28 13 T -28 14 T -28 15 T -28 16 T -28 17 T -28 18 T -28 19 T -28 20 T -28 21 T -28 22 T -28 23 T -28 24 T -28 25 T -28 26 T -28 27 T -28 28 T -28 29 T -28 30 T -28 31 T The binary representation of -28 is: "11111111111111111111111111100100". test_ceiling(): ceiling() is a Fortran90 function which rounds a real number up "towards infinity". X CEILING(X) 8.76620 9 -6.95818 -6 5.78240 6 -1.89682 -1 8.78585 9 -2.96038 -2 3.93452 4 4.88839 5 -0.785396 0 -8.18621 -8 TEST_CHAR CHAR is a Fortran90 function which returns the character of given character index. I CHAR(I) 32 33 ! 34 " 35 # 36 $ 37 % 38 & 39 ' 40 ( 41 ) 42 * 43 + 44 , 45 - 46 . 47 / 48 0 49 1 50 2 51 3 52 4 53 5 54 6 55 7 56 8 57 9 58 : 59 ; 60 < 61 = 62 > 63 ? 64 @ 65 A 66 B 67 C 68 D 69 E 70 F 71 G 72 H 73 I 74 J 75 K 76 L 77 M 78 N 79 O 80 P 81 Q 82 R 83 S 84 T 85 U 86 V 87 W 88 X 89 Y 90 Z 91 [ 92 \ 93 ] 94 ^ 95 _ 96 ` 97 a 98 b 99 c 100 d 101 e 102 f 103 g 104 h 105 i 106 j 107 k 108 l 109 m 110 n 111 o 112 p 113 q 114 r 115 s 116 t 117 u 118 v 119 w 120 x 121 y 122 z 123 { 124 | 125 } 126 ~ TEST_CMPLX CMPLX is a Fortran90 function which returns the complex number formed by real and imaginary parts. CMPLX(1) 1.000000 0.000000 CMPLX(2,3) 2.000000 3.000000 CMPLX(4.5) 4.500000 0.000000 CMPLX(6.7, 8.9 ) 6.700000 8.900000 TEST_CONJG CONJG is a Fortran90 function which returns the conjugate of a complex number. X CONJG(X) -------------------------- ---------------------------- 0.732449 -0.214031 0.732449 0.214031 -0.599224 -0.426429 -0.599224 0.426429 -0.381117 -0.365297 -0.381117 0.365297 0.672325 0.670529 0.672325 -0.670529 -0.304818 -0.479297 -0.304818 0.479297 0.158235 -0.836683 0.158235 0.836683 -0.111869 0.703844 -0.111869 -0.703844 0.684539 0.472513 0.684539 -0.472513 -0.036210 0.894266 -0.036210 -0.894266 -0.957301 0.179908 -0.957301 -0.179908 TEST_COS_C4 COS is a Fortran90 function which returns the cosine of a real or complex number. Here we use complex arguments. X COS(X) -------------------------- ---------------------------- 0.577323 0.301827 0.876385 -0.167244 -0.212327 0.328409 1.03073 0.704580E-01 0.152997 0.827956 1.34687 -0.141100 0.261497 -0.414226 1.05007 0.110177 0.427995 0.570380 1.06185 -0.249781 0.599877 0.588857 0.972694 -0.351982 -0.833920 -0.242147 0.691775 -0.181085 -0.274582 -0.330649E-01 0.963065 -0.896699E-02 0.331680 -0.664606 1.16211 0.232704 -0.893822E-01 0.413109E-01 0.996858 0.368859E-02 TEST_COS_R8 COS is a Fortran90 function which returns the cosine of a real or complex number. Here we use real ( kind = rk8 ) arguments. X COS(X) -7.26047 0.559278 -9.25391 -0.985437 -1.19587 0.366208 0.476769 0.888482 6.43810 0.988025 -2.49665 -0.799133 -9.94715 -0.866639 8.71461 -0.758250 -5.67975 0.823390 -7.72442 0.129201 TEST_COSH COSH is a Fortran90 function which returns the hyperbolic cosine of a real number. X COSH(X) 5.52945 126.005 -3.42489 15.3759 -7.57359 973.060 3.83714 23.2070 -9.18783 4888.69 7.22974 689.931 3.29762 13.5426 -8.18651 1796.09 3.84812 23.4629 8.15604 1742.18 TEST_COUNT COUNT(MASK) is a Fortran90 function which returns the number of TRUE entries in MASK. COUNT(MASK,DIM) is a Fortran90 function which returns an array of values which are count the number of TRUE entries in MASK in dimension DIM. integer a_i4(4,5) 24 70 70 3 41 96 21 38 49 81 6 39 51 27 28 14 85 42 90 18 COUNT ( A_I4 < 100 ) 20 COUNT ( A_I4 < 90 ) 18 COUNT ( A_I4 < 90, 1 ) 3 4 4 3 4 COUNT ( A_I4 < 90, 2 ) 5 4 5 4 COUNT ( MOD(A_I4,2)==0,1 ) 4 1 3 1 2 COUNT ( MOD(A_I4,2)==0,2 ) 3 2 2 4 TEST_CSHIFT CSHIFT is a Fortran90 function which applies a circular shift to a vector or array. integer v1_i4(10): 1 2 3 4 5 6 7 8 9 10 v2_i4 = cshift ( v1_i4, 3 ): 4 5 6 7 8 9 10 1 2 3 v2_i4 = cshift ( v1_i4, -2 ): 9 10 1 2 3 4 5 6 7 8 integer a1_i4(4,5): 11 12 13 14 15 21 22 23 24 25 31 32 33 34 35 41 42 43 44 45 a2_i4 = cshift ( a1_i4, (/ 1, 2, 3, 4 /), dim = 2 ): 12 13 14 15 11 23 24 25 21 22 34 35 31 32 33 45 41 42 43 44 a2_i4 = cshift ( a1_i4, 2, 1 ): 31 32 33 34 35 41 42 43 44 45 11 12 13 14 15 21 22 23 24 25 TEST_DATE_AND_TIME DATE_AND_TIME is a Fortran90 subroutine which returns date and time information. call date_and_time ( date, time, zone, values ) DATE = "20251006". TIME = "180603.065". ZONE = "-0400". VALUES(1) = year = 2025 VALUES(2) = month = 10 VALUES(3) = day = 6 VALUES(4) = UTC minute diff = -240 VALUES(5) = hour = 18 VALUES(6) = minute = 6 VALUES(7) = second = 3 VALUES(8) = milliseconds = 65 TEST_DBLE DBLE is a Fortran90 function which converts a complex, integer or real value to double precision real Type X DBLE(X) complex 1.1000 2.2000 1.1000 complex ( kind = ck8 ) 3.3000 4.4000 3.3000 integer 5 5.0000 integer ( kind = 8 ) 6 6.0000 real 7.7000 7.7000 real ( kind = rk8 ) 8.8000 8.8000 TEST_DIGITS DIGITS is a Fortran90 function which returns the number of significant digits for numbers of the same kind as X. Type DIGITS(X) integer 31 integer 31 integer ( kind = 8 ) 63 real 24 real ( kind = rk8 ) 53 TEST_DIM DIM is a Fortran90 function which returns the maximum of X-Y or 0. Arithmetic type: integer X, Y X Y DIM(X,Y) 69 49 20 56 73 0 19 96 0 36 88 0 8 75 0 TEST_DOT_PRODUCT DOT_PRODUCT is a Fortran90 function which returns the dot product of two vectors. If the arguments are COMPLEX, then the first vector will be conjugated to produce the result. Two complex vectors: X Y 0.855426 0.513407 0.630980 0.893182 0.067868 0.688550 0.653288 0.688681 0.805246 0.271789 0.095858 0.496922 0.347020 0.075121 0.681515 0.769271 0.029612 0.147003 0.683861 0.660755 DOT_PRODUCT(X,Y) = 2.140770 0.545904 Two real vectors: X Y 0.446985 0.490293 0.333928 0.125558 0.853278 0.473517 0.615446 0.128594 0.310583 0.902312 DOT_PRODUCT(X,Y) = 1.024508 Two integer vectors: X Y 4 4 3 1 8 4 6 1 3 9 DOT_PRODUCT(X,Y) = 84 Two logical vectors: X Y F F F F T F T F F T DOT_PRODUCT(X,Y) = F TEST_DPROD DPROD is a Fortran90 function which returns the product of real values X and Y, using double precision. real x, y X Y DPROD(X,Y) 36.003994 57.538677 2071.622189 80.151840 86.238083 6912.141039 87.754860 20.894695 1833.611058 34.167946 60.262566 2059.048079 14.113628 43.142216 608.893201 TEST_EOSHIFT EOSHIFT is a Fortran90 function which applies an "end off" shift to a vector or array. integer v1_i4(10): 1 2 3 4 5 6 7 8 9 10 v2_i4 = eoshift ( v1_i4, 3, 99 ): 4 5 6 7 8 9 10 99 99 99 v2_i4 = eoshift ( v1_i4, -2, 88 ): 88 88 1 2 3 4 5 6 7 8 integer a1_i4(4,5): 11 12 13 14 15 21 22 23 24 25 31 32 33 34 35 41 42 43 44 45 a2_i4 = eoshift ( a1_i4, (/ 1, 2, 3, 4 /), 77, dim = 2 ): 12 13 14 15 77 23 24 25 77 77 34 35 77 77 77 45 77 77 77 77 a2_i4 = eoshift ( a1_i4, 2, 66, 1 ): 31 32 33 34 35 41 42 43 44 45 66 66 66 66 66 66 66 66 66 66 TEST_EPSILON EPSILON is a Fortran90 function which returns the "machine epsilon" associated with a real number. First, some "default precision" reals: X EPSILON(X) 1.00000 0.119209E-06 0.00000 0.119209E-06 0.100000E+07 0.119209E-06 Now, some "double precision" reals: X EPSILON(X) 1.00000 0.222045E-15 0.00000 0.222045E-15 0.100000E+07 0.222045E-15 TEST_EXP EXP is a Fortran90 function which returns the exponential of a real number. X EXP(X) -2.50783 0.814448E-01 0.557327E-01 1.05732 7.70262 2214.15 -6.87558 0.103270E-02 0.159284 1.17267 -7.39600 0.613701E-03 -5.59374 0.372108E-02 4.87732 131.279 9.62164 15087.8 4.80918 122.631 TEST_EXPONENT EXPONENT is a Fortran90 function which returns the exponent part of a real number. X EXPONENT(X) -2.85113 2 -9.34767 4 5.35095 3 4.65269 3 -3.56664 2 5.73994 3 2.35983 2 -1.16500 1 -5.49166 3 6.65690 3 TEST_FLOOR FLOOR is a Fortran90 function which rounds a real number down "towards -infinity". X FLOOR(X) -5.31508 -6 -3.27086 -4 3.08290 3 -6.63792 -7 0.416162 0 -4.70279 -5 6.74510 6 -0.594209 -1 2.00306 2 2.42170 2 TEST_FRACTION FRACTION is a Fortran90 function which returns the fractional part of a real number. X FRACTION(X) 9.55510 0.597194 -2.41939 -0.604848 0.166283E-01 0.532104 -2.72752 -0.681880 2.92335 0.730838 -4.81611 -0.602014 -0.219088 -0.876350 -6.49165 -0.811456 4.64727 0.580909 4.98208 0.622760 TEST_HUGE HUGE is a Fortran90 function which returns a "huge value" associated with a real or integer. First, some "default precision" reals: X HUGE(X) 1.00000 0.340282E+39 0.00000 0.340282E+39 0.100000E+07 0.340282E+39 Now, some "double precision" reals: X HUGE(X) 1.00000 0.179769+309 0.00000 0.179769+309 0.100000E+07 0.179769+309 Now, some integers: X HUGE(X) 1 2147483647 0 2147483647 1000000 2147483647 TEST_IACHAR IACHAR is a Fortran90 function which returns the ASCII index of a given character C IACHAR(C) ACHAR(IACHAR(C)) T 84 T h 104 h i 105 i s 115 s 32 i 105 i s 115 s 32 a 97 a 32 s 115 s t 116 t r 114 r i 105 i n 110 n g 103 g 32 o 111 o f 102 f 32 t 116 t e 101 e x 120 x t 116 t ! 33 ! TEST_IAND_I4 IAND is a Fortran90 function which returns the bitwise AND of two integers. Here, I and J are integers of KIND = 4. I J IAND(I,J) 70 17 0 64 74 64 41 46 40 32 29 0 65 32 0 23 37 5 1 95 1 61 100 36 41 65 1 82 61 16 TEST_IAND_I8 IAND is a Fortran90 function which returns the bitwise AND of two integers. Here, I and J are integers of KIND = 8. I J IAND(I,J) 76 21 4 34 77 0 80 75 64 92 63 28 73 34 0 96 64 64 25 93 25 80 43 0 69 10 0 62 88 24 TEST_IBCLR IBCLR is a Fortran90 function which sets a given bit to zero in an integer word. I POS IBCLR(I,POS) 2047 0 2046 2047 1 2045 2047 2 2043 2047 3 2039 2047 4 2031 2047 5 2015 2047 6 1983 2047 7 1919 2047 8 1791 2047 9 1535 2047 10 1023 TEST_IBITS IBITS is a Fortran90 function which extracts LEN bits from word I start at position POS. I POS LEN IBITS(I,POS,LEN) 1396 0 3 4 1396 1 3 2 1396 2 3 5 1396 3 3 6 1396 4 3 7 1396 5 3 3 1396 6 3 5 1396 7 3 2 1396 8 3 5 1396 9 3 2 1396 10 3 1 1396 2 1 1 1396 2 2 1 1396 2 3 5 1396 2 4 13 1396 2 5 29 1396 2 6 29 1396 2 7 93 1396 2 8 93 1396 2 9 349 1396 2 10 349 Use IBITS to extract the 4 bytes that make up an integer word. I4 = 1040503311 Byte 0 = 15 Byte 1 = 210 Byte 2 = 4 Byte 3 = 62 TEST_IBSET IBSET is a Fortran90 function which sets a given bit to one in an integer word. I POS IBSET(I,POS) 0 0 1 1 1 3 3 2 7 7 3 15 15 4 31 31 5 63 63 6 127 127 7 255 255 8 511 511 9 1023 1023 10 2047 TEST_ICHAR ICHAR is a Fortran90 function which returns the character index of a given character C ICHAR(C) CHAR(ICHAR(C)) T 84 T h 104 h i 105 i s 115 s 32 i 105 i s 115 s 32 a 97 a 32 s 115 s t 116 t r 114 r i 105 i n 110 n g 103 g 32 o 111 o f 102 f 32 t 116 t e 101 e x 120 x t 116 t ! 33 ! TEST_IEOR_I4 IEOR is a Fortran90 function which returns the bitwise exclusive OR of two integers. Here, I and J are integers of KIND = 4. I J IEOR(I,J) 42 70 108 71 62 121 29 76 81 55 87 96 50 6 52 91 5 94 0 64 64 28 93 65 78 17 95 17 12 29 TEST_IEOR_I8 IEOR is a Fortran90 function which returns the bitwise exclusive OR of two integers. Here, I and J are integers of KIND = 8. I J IEOR(I,J) 11 59 48 44 27 55 50 43 25 53 13 56 3 34 33 32 20 52 18 61 47 43 55 28 34 15 45 54 27 45 TEST_INDEX INDEX(S,SUB) is a Fortran90 function which returns the location of the first occurrence of substring SUB in string S. INDEX(S,SUB,.TRUE.) returns the location of the LAST occurrence. index ( 'THE CATATONIC CAT', 'CAT' ) 5 index ( 'THE CATATONIC CAT', 'cat' ) 0 index ( 'THE CATATONIC CAT', 'CAT', .TRUE. ) 15 TEST_INT INT is a Fortran90 function which converts a complex, integer or real value to integer. Type X INT(X) complex 1.1000 2.2000 1 complex ( kind = ck8 ) 3.3000 4.4000 3 integer 5 5 integer ( kind = 8 ) 6 6 real 7.7000 7 real ( kind = rk8 ) 8.8000 8 TEST_IOR_I4 IOR is a Fortran90 function which returns the bitwise inclusive OR of two integers. Here, I and J are integers of KIND = 4. I J IOR(I,J) 56 36 60 64 77 77 48 77 125 89 27 91 65 96 97 66 90 90 76 27 95 61 42 63 92 66 94 65 84 85 TEST_IOR_I8 IOR is a Fortran90 function which returns the bitwise inclusive OR of two integers. Here, I and J are integers of KIND = 8. I J IOR(I,J) 66 61 127 63 25 63 53 81 117 11 88 91 93 17 93 29 45 61 92 19 95 78 79 79 42 66 106 98 61 127 TEST_ISHFT ISHFT is a Fortran90 function which shifts the bits in an integer word. I SHIFT ISHFT(I,SHIFT) 89 -5 2 89 -4 5 89 -3 11 89 -2 22 89 -1 44 89 0 89 89 1 178 89 2 356 89 3 712 89 4 1424 89 5 2848 TEST_ISHFTC ISHFTC is a Fortran90 function which circular-shifts the bits in an integer word. I SHIFT ISHFTC(I,SHIFT) 89 -5 -939524094 89 -4 -1879048187 89 -3 536870923 89 -2 1073741846 89 -1 -2147483604 89 0 89 89 1 178 89 2 356 89 3 712 89 4 1424 89 5 2848 TEST_KIND KIND is a Fortran90 function which returns the kind associated with a given variable Declaration KIND(X) character 1 complex 4 complex 4 complex ( kind = ck8 ) 8 integer 4 integer ( kind = 8 ) 8 logical 4 real 4 real ( kind = rk8 ) 8 TEST_LBOUND LBOUND(ARRAY) is a Fortran90 function which returns the lower array bounds in all dimensions; LBOUND(ARRAY,DIM) returns the lower bound in dimension DIM. real a(5,10,17) lbound(a) = 1 1 1 lbound(a,1) = 1 lbound(a,2) = 1 lbound(a,3) = 1 integer b(4:6,-5:-1,10:20) lbound(b) = 4 -5 10 lbound(b,1) = 4 lbound(b,2) = -5 lbound(b,3) = 10 TEST_LEN LEN is a Fortran90 function which returns the declared length of a string variable, or the length of a string constant S LEN(S) ---------- ----- character ( len = 1 ) 1 character ( len = 2 ) 2 character ( len = 4 ) 4 character ( len = 8 ) 8 character ( len = 16 ) 16 "A STRING" 8 TEST_LEN_TRIM LEN_TRIM is a Fortran90 function which returns the "used" length of a string variable up to the last nonblank. S LEN_TRIM(S) ---------- ---------- "1234567890" 10 "12345 " 5 " 67890" 10 " 5 " 5 "1 3 5 7 9 " 9 TEST_LGE LGE is a Fortran90 function which returns the value of "S1 >= S2" where S1 and S2 are strings. S1 S2 LGE(S1,S2) --- --- ---------- "boy" "boy" T "boy" "cat" F "cat" "boy" T "cat" "dog" F "cat" "CAT" T "cat" "cats" F TEST_LGT LGT is a Fortran90 function which returns the value of "S1 > S2" where S1 and S2 are strings. S1 S2 LGT(S1,S2) --- --- ---------- "boy" "boy" F "boy" "cat" F "cat" "boy" T "cat" "dog" F "cat" "CAT" T "cat" "cats" F TEST_LLE LLE is a Fortran90 function which returns the value of "S1 <= S2" where S1 and S2 are strings. S1 S2 LLE(S1,S2) --- --- ---------- "boy" "boy" T "boy" "cat" T "cat" "boy" F "cat" "dog" T "cat" "CAT" F "cat" "cats" T TEST_LGT LLT is a Fortran90 function which returns the value of "S1 < S2" where S1 and S2 are strings. S1 S2 LLT(S1,S2) --- --- ---------- "boy" "boy" F "boy" "cat" T "cat" "boy" F "cat" "dog" T "cat" "CAT" F "cat" "cats" T TEST_LOG LOG is a Fortran90 function which returns the natural logarithm of a real number. X LOG(X) EXP(LOG(X)) 6.26035 1.83424 6.26035 4.55137 1.51543 4.55137 2.35403 0.856127 2.35403 7.71660 2.04337 7.71660 9.31721 2.23186 9.31721 2.52073 0.924549 2.52073 4.42548 1.48738 4.42548 2.72821 1.00365 2.72821 9.11214 2.20961 9.11214 8.12775 2.09528 8.12775 TEST_LOG10 LOG10 is a Fortran90 function which returns the base 10 logarithm of a real number. X LOG10(X) 10**(LOG(X)) 0.778822 -0.108562 0.778822 0.789317 -0.102748 0.789317 2.67536 0.427382 2.67536 7.84967 0.894851 7.84967 1.52254 0.182570 1.52254 7.34118 0.865766 7.34118 9.92391 0.996683 9.92391 9.92745 0.996838 9.92745 7.63865 0.883017 7.63865 7.23515 0.859448 7.23515 TEST_LOGICAL LOGICAL is a Fortran90 function which can convert between logical kinds logical x_l4 = T logical ( kind = 1 ) x_lb x_lb = logical ( x_l4, kind = 1 ) = T x_lb = .not. x_lb = F x_l4 = logical ( x_lb ) = F TEST_MATMUL MATMUL is a Fortran90 function which returns the product of two matrices or a matrix and vector. Matrix A: 0 2 5 2 0 3 4 1 2 4 3 3 3 2 3 3 3 2 4 0 Matrix B: 0 2 5 3 4 1 3 3 3 3 3 2 2 5 2 Vector C: 0 2 1 1 5 Matrix AB = matmul ( A, B ): 30 35 19 41 46 42 42 50 38 29 41 36 Vector AC = matmul ( A, C ): 11 31 26 12 Vector CB = matmul ( C, B ): 36 24 26 TEST_MAX MAX is a Fortran90 function which returns the maximum value in a list. max(2,1) = 2 max(1,3,2) = 3 max(3,2,4,1) = 4 max(2.1, 1.2) = 2.1 max(1.1, 3.2, 2.3) = 3.2 max(3.1, 2.2, 4.3, 1.4) = 4.3 TEST_MAX_VECTOR MAX is a Fortran90 function which returns the maximum value in a list. We consider a vector version: I X(I) Y(I) Z(I) 1 7 1 7 2 10 8 10 3 2 4 4 4 0 8 8 5 9 9 9 6 8 4 8 7 2 3 3 8 0 5 5 9 3 1 3 10 2 10 10 Now try Z(1:N) = max ( 5, Y(1:N) ) I X(I) Y(I) Z(I) 1 5 5 5 2 5 0 5 3 5 4 5 4 5 9 9 5 5 7 7 6 5 6 6 7 5 10 10 8 5 6 6 9 5 0 5 10 5 8 8 TEST_MAXEXPONENT MAXEXPONENT is a Fortran90 function which returns the maximum exponent associated with real numbers of the same kind as X. Type MAXEXPONENT(X) real 128 real ( kind = rk8 ) 1024 TEST_MAXLOC MAXLOC is a Fortran90 function which returns the index of the maximum value of the entries of a vector. A real vector: X 0.362047 0.629062 0.823399 0.258241 0.347560 MAXLOC(X) = 3 An integer vector: X 3 6 8 2 3 MAXLOC(X) = 3 TEST_MAXVAL MAXVAL is a Fortran90 function which returns the maximum value of the entries of a vector. A real vector: X 0.487902 0.054102 0.843722 0.610472 0.097256 MAXVAL(X) = 0.843722 An integer vector: X 4 0 8 6 0 MAXVAL(X) = 8 TEST_MERGE MERGE is a Fortran90 function which copies entries from one array or the other depending on a logical array. Array A: 63 85 99 42 76 80 77 84 15 1 89 95 80 17 32 99 93 32 92 87 Array B: 53 54 78 31 17 80 63 36 80 13 22 47 29 45 92 90 40 7 92 42 Array C: F F T F F T T T T T F F T F F T T T T T Array D = MERGE(A,B,C): 53 54 99 31 17 80 77 84 15 1 22 47 80 45 92 99 93 32 92 87 TEST_MIN MIN is a Fortran90 function which returns the minimum value in a list. min(3, 4) = 3 min(4, 2, 3) = 2 min(2, 3, 1, 4) = 1 min(3.1, 4.2) = 3.1 min(4.1. 2.2, 3.3) = 2.2 min(2.1, 3.2, 1.3, 4.4) = 1.3 TEST_MINEXPONENT MINEXPONENT is a Fortran90 function which returns the minimum exponent associated with real numbers of the same kind as X. Type MINEXPONENT(X) real -125 real ( kind = rk8 ) -1021 TEST_MINLOC MINLOC is a Fortran90 function which returns the index of the minimum value of the entries of a vector. A real vector: X 0.606842 0.331825 0.863594 0.559247 0.007191 MINLOC(X) = 5 An integer vector: X 6 3 8 5 0 MINLOC(X) = 5 TEST_MINVAL MINVAL is a Fortran90 function which returns the minimum value of the entries of a vector. A real vector: X 0.657952 0.243372 0.716650 0.276898 0.109034 MINVAL(X) = 0.109034 An integer vector: X 6 2 7 2 1 MINVAL(X) = 1 TEST_MOD_I4 MOD is a Fortran90 function which returns the remainder after division. Here, the arguments are integers. I J MOD(I,J) -1 14 -1 18 10 8 7 17 7 9 -3 0 2 10 2 -10 11 -10 11 18 11 -1 -9 -1 13 5 3 13 -6 1 TEST_MOD_R8 MOD is a Fortran90 function which returns the remainder after division. Here, the arguments are reals. X Y MOD(X,Y) 0.255618 -4.647600 0.255618 -7.240395 10.689834 -7.240395 16.362476 17.124885 16.362476 8.150007 -8.366510 8.150007 -8.425997 5.025418 -3.400579 7.508392 -6.270540 1.237852 15.586459 -4.066919 3.385702 8.259998 -1.427157 1.124212 3.953216 10.209605 3.953216 -1.718088 19.234909 -1.718088 TEST_MODULO_I4 MODULO is a Fortran90 function which returns the remainder after division. Here, the arguments are integers. I J MODULO(I,J) 17 -9 -1 12 3 0 4 13 4 -9 1 0 6 -3 0 2 16 2 16 1 0 20 9 2 0 -4 0 -2 2 0 TEST_MODULO_R4 MODULO is a Fortran90 function which returns the remainder after division. Here, the arguments are reals. X Y MODULO(X,Y) 17.719212 8.587111 0.544991 7.535545 3.919168 3.616377 9.631294 -9.341904 -9.052513 9.711126 7.933332 1.777794 4.873929 10.207062 4.873929 8.717424 10.673473 8.717424 7.295776 -9.643549 -2.347773 -1.296868 6.582800 5.285932 12.235701 19.563995 12.235701 14.154858 17.112656 14.154858 TEST_MVBITS MVBITS is a Fortran90 function which extracts bits from one place and copies them elsewhere. CALL MVBITS(FROM,FROMPOS,LEN,TO,TOPOS) We will always use I1 = 1396 We will always start with I2 = 0 CALL MVBITS(I1,0, 5,I2,0): I2 = 20 CALL MVBITS(I1,0,32,I2,0): I2 = 1396 CALL MVBITS(I1,5, 5,I2,0): I2 = 11 CALL MVBITS(I1,5, 5,I2,5): I2 = 352 TEST_NEAREST NEAREST is a Fortran90 function which returns the nearest real number to a given real number, in a given direction. X NEAREST(X,+1.0) NEAREST(X,-1.0) 1.00000000 1.00000012 0.99999994 test_nint(): nint() is a Fortran90 function which returns, as an integer, the nearest integer to a given real number. X NINT(X) 4.76688 5 -1.27920 -1 9.68572 10 8.42723 8 -0.896751 -1 2.50618 3 -1.48462 -1 6.27967 6 -2.19932 -2 -1.09492 -1 IVEC = NINT ( XVEC ): 0.267276 0 0.920023 1 0.182771 0 0.168895 0 0.856875 1 0.421941 0 0.110755 0 0.261996 0 0.952858 1 0.259664 0 TEST_NOT_I4 NOT is a Fortran90 function which returns the bitwise NOT of an integer. Here, I is an integer of KIND = 4. I NOT(I) 14 -15 68 -69 17 -18 12 -13 96 -97 63 -64 84 -85 55 -56 16 -17 74 -75 TEST_NOT_I8 NOT is a Fortran90 function which returns the bitwise NOT of an integer. Here, I is an integer of KIND = 8. I NOT(I) 51 -52 4 -5 76 -77 94 -95 29 -30 56 -57 26 -27 6 -7 78 -79 98 -99 TEST_PACK PACK is a Fortran90 function which packs the entries of an array into a vector subject to a logical mask. Here is integer array a(5,4) 23 4 20 78 92 5 78 30 38 15 66 9 89 92 58 51 42 13 74 82 Here is the logical array mask(5,4), which we will use to choose our entries of A: T T T T F T T T T T T T F F T T T T T F We can count the number of entries to be copied into V by: N = COUNT ( MASK ) Now set V = pack ( a, mask ) Here are the entries copied into vector V: 23 38 42 4 5 15 13 20 78 66 58 74 78 30 9 51 TEST_PRECISION PRECISION is a Fortran90 function which returns the number of decimal places available for real numbers. Declaration PRECISION(X) real 6 double precision 15 real ( kind = rk8 ) 15 TEST_PRESENT PRESENT is a Fortran90 function which reports whether optional arguments have been supplied. This routine has optional arguments ETHEL, FRED, GEORGE. present ( ethel ) = F present ( fred ) = F present ( george ) = F sum A+B=**** TEST_PRESENT PRESENT is a Fortran90 function which reports whether optional arguments have been supplied. This routine has optional arguments ETHEL, FRED, GEORGE. present ( ethel ) = F present ( fred ) = T present ( george ) = F sum A+B=**** TEST_PRESENT PRESENT is a Fortran90 function which reports whether optional arguments have been supplied. This routine has optional arguments ETHEL, FRED, GEORGE. present ( ethel ) = F present ( fred ) = T present ( george ) = T sum A+B=**** TEST_PRESENT PRESENT is a Fortran90 function which reports whether optional arguments have been supplied. This routine has optional arguments ETHEL, FRED, GEORGE. present ( ethel ) = T present ( fred ) = T present ( george ) = T sum A+B=**** TEST_PRODUCT PRODUCT is a Fortran90 function which returns the product of the entries of a vector. A complex vector: X 0.193270 -0.762382 0.277044 -0.318285 -0.440386 -0.650865 -0.008035 -0.255937 -0.933395 -0.201394 PRODUCT(X) = -0.054339 -0.033374 A real vector: X 0.193270 0.277044 -0.440386 -0.008035 -0.933395 PRODUCT(X) = -0.000177 An integer vector: X 1 2 -4 0 -9 PRODUCT(X,Y) = 0 TEST_RADIX RADIX is a Fortran90 function which returns the radix or base exponent associated with the representation of numbers of a given type and kind. integer 2 integer ( kind = 8 ) 2 real 2 real ( kind = rk8 ) 2 TEST_RANDOM_NUMBER RANDOM_NUMBER is a Fortran90 function which returns uniformly distributed pseudorandom values. Call RANDOM_NUMBER 5 times in a row: 0.297166 0.124773 0.960606 0.492765 0.843708 Call RANDOM_NUMBER once, with a vector argument 0.152576 0.409331 0.928831E-02 0.464479 0.792165 Call RANDOM_NUMBER with an array argument 0.588347 0.282485 0.280520 0.255731 0.502812 0.485296 0.969921 0.611592 0.239209E-01 TEST_RANDOM_SEED RANDOM_SEED is a Fortran90 function which allows the user to read or set the random number seed. CALL RANDOM_SEED ( SIZE = seed_size ) returns the dimension of the random number seed. SIZE = 8 Call RANDOM_SEED ( GET = SEED ) to get current contents of the SEED array: 1225453821 1250339355 1295389653 -921537970 2118176107 1528414356 -1225694096 -1458023170 Set the SEED array to a simple value. 1 2 3 4 5 6 7 8 Call RANDOM_SEED ( PUT = SEED ) to reset current contents of the SEED array: Call RANDOM_NUMBER 5 times. 0.471071 0.117345 0.357548 0.318135 0.696754 Call RANDOM_SEED ( GET = SEED ) to get current contents of the SEED array. Notice that the seed has changed! -159671239 -450880304 -431290970 630396222 -725784985 -10493970 1358261573 283296611 Call RANDOM_SEED ( PUT = SEED ) to reset the SEED array: Call RANDOM_NUMBER 5 times. Because the SEED array is the same, the values should be repeated. 0.471071 0.117345 0.357548 0.318135 0.696754 TEST_RANGE RANGE is a Fortran90 function which returns the base 10 logarithm of the largest magnitude objects of a given type and kind. integer 9 Integer ( kind = 8 ) 18 Real 37 Real ( kind = rk8 ) 307 Complex 37 Complex ( kind = ck8 ) 307 TEST_REAL_C4 REAL is a Fortran90 function which can return the real part of a complex number. X REAL(X) ------------------------ ---------------- 0.397598 -0.518050 0.397598 -0.189609 -0.554326 -0.189609 -0.514963 0.552916 -0.514963 0.011255 0.604745 0.011255 -0.900924 0.083034 -0.900924 -0.226205 -0.026149 -0.226205 -0.713858 0.540119 -0.713858 0.542917 0.640804 0.542917 0.461489 0.844837 0.461489 0.953216 0.170975 0.953216 TEST_REPEAT REPEAT(S,N) creates a new character string by repeating a given string S N times. S N REPEAT(S,N) "a" 5 "aaaaa" "Ab" 4 "AbAbAbAb" "Abc " 3 "Abc Abc Abc " TEST_RESHAPE RESHAPE can "reshape" an array. A is a 3 x 4 matrix, and we reshape it to a vector: 11 12 13 14 21 22 23 24 31 32 33 34 We reshape A to a vector: B = RESHAPE ( A, (/ 12 /) ) 11 21 31 12 22 32 13 23 33 14 24 34 We reshape B to a matrix C: C = RESHAPE ( B, (/ 2, 6 /) ) 11 31 22 13 33 24 21 12 32 23 14 34 We reshape B to a 3D matrix D: D = RESHAPE ( B, (/ 2, 3, 2 /) ) 11 13 31 33 22 24 21 23 12 14 32 34 TEST_RRSPACING RRSPACING is a Fortran90 function which returns the reciprocal relative spacing associated with a real number. First, some "default precision" reals: X RRSPACING(X) 1.00000 0.838861E+07 0.00000 0.00000 0.100000E+07 0.160000E+08 Now, some "double precision" reals: X RRSPACING(X) 1.00000 0.450360E+16 0.00000 0.00000 0.100000E+07 0.858993E+16 TEST_SCALE SCALE(X,I) is a Fortran90 function which returns the value of X * RADIX**I, where RADIX is the base for real number arithmetic. X I SCALE(X,I) 5.00000 -5 0.156250 5.00000 -4 0.312500 5.00000 -3 0.625000 5.00000 -2 1.25000 5.00000 -1 2.50000 5.00000 0 5.00000 5.00000 1 10.0000 5.00000 2 20.0000 5.00000 3 40.0000 5.00000 4 80.0000 5.00000 5 160.000 TEST_SCAN SCAN(S,SET) is a Fortran90 function which returns the location of the first occurrence of any character from SET in string S. SCAN(S,SET,.TRUE.) returns the location of the LAST occurrence. scan ( 'THE CATATONIC CAT', 'CAT' ) 1 scan ( 'THE CATATONIC CAT', 'DOG' ) 10 scan ( 'THE CATATONIC CAT', 'cat' ) 0 scan ( 'THE CATATONIC CAT', 'ABC' ) 5 scan ( 'THE CATATONIC CAT', 'ABC', .TRUE. ) 16 TEST_SELECTED_INT_KIND SELECTED_INT_KIND(R) is a Fortran90 function which returns a value of the KIND parameter for integers up to 10**R. R SELECTED_INT_KIND(R) 1 1 2 1 3 2 4 2 5 4 6 4 7 4 8 4 9 4 10 8 11 8 12 8 13 8 14 8 15 8 16 8 17 8 18 8 19 16 20 16 TEST_SELECTED_REAL_KIND SELECTED_INT_KIND(R) is a Fortran90 function which returns a value of the KIND parameter for integers up to 10**R. P R SELECTED_REAL_KIND(P,R) 5 1 4 5 2 4 5 3 4 5 4 4 5 5 4 5 6 4 5 7 4 5 8 4 5 9 4 5 10 4 5 11 4 5 12 4 5 13 4 5 14 4 5 15 4 5 16 4 5 17 4 5 18 4 5 19 4 5 20 4 1 10 4 2 10 4 3 10 4 4 10 4 5 10 4 6 10 4 7 10 8 8 10 8 9 10 8 10 10 8 11 10 8 12 10 8 13 10 8 14 10 8 15 10 8 16 10 10 17 10 10 18 10 10 19 10 16 20 10 16 TEST_SET_EXPONENT SET_EXPONENT(X,I) is a Fortran90 function which returns the FRACTION(X)*RADIX**I, where FRACTION(X) is the fractional part of X, and RADIX is the base for real number arithmetic. X I SET_EXPONENT(X,I) 100.000 -5 0.244141E-01 100.000 -4 0.488281E-01 100.000 -3 0.976562E-01 100.000 -2 0.195312 100.000 -1 0.390625 100.000 0 0.781250 100.000 1 1.56250 100.000 2 3.12500 100.000 3 6.25000 100.000 4 12.5000 100.000 5 25.0000 TEST_SHAPE SHAPE(ARRAY) is a Fortran90 function which returns the "shape" of the array. real a(5,10,17) shape(a) = 5 10 17 integer b(4:6,-5:-1,10:20) shape(b) = 3 5 11 TEST_SIGN SIGN is a Fortran90 function which returns the sign of Y times the magnitude of X. X Y SIGN(X,Y) 8.68042 -4.65229 -8.68042 -3.22248 -7.45676 -3.22248 -3.73982 -4.81357 -3.73982 7.95635 -1.13841 -7.95635 -3.92853 -0.588557 -3.92853 8.37774 -7.26517 -8.37774 -5.82040 6.62662 5.82040 6.38617 0.152309 6.38617 9.26334 4.65308 9.26334 6.05645 -6.43198 -6.05645 TEST_SIN_R8 SIN is a Fortran90 function which returns the sine of a real or complex number. Here we use real ( kind = rk8 ) arguments. X SIN(X) -8.25196 -0.921847 0.429567E-02 0.429566E-02 3.81619 -0.624585 -2.70769 -0.420418 -4.38413 0.946604 2.91239 0.227203 -5.97134 0.306811 4.45648 -0.967434 -1.43928 -0.991364 9.75825 -0.327328 TEST_SINH SINH is a Fortran90 function which returns the hyperbolic sine of a real number. X SINH(X) -9.97870 -10781.1 -5.74663 -156.565 -0.549058 -0.577064 3.59205 18.1404 -4.92761 -69.0206 6.60458 369.235 -9.21392 -5017.92 -0.742449 -0.812563 -0.236330 -0.238536 0.843507 0.947153 TEST_SIZE SIZE(ARRAY) is a Fortran90 function which returns the size in all dimensions; SIZE(ARRAY,DIM) returns the size in dimension DIM. real a(5,10,17) size(a) = 850 size(a,1) = 5 size(a,2) = 10 size(a,3) = 17 integer b(4:6,-5:-1,10:20) size(b) = 165 size(b,1) = 3 size(b,2) = 5 size(b,3) = 11 TEST_SPACING SPACING is a Fortran90 function which returns the absolute spacing associated with a real number. First, some "default precision" reals: X SPACING(X) 1.00000 0.119209E-06 0.00000 0.117549E-37 0.100000E+07 0.625000E-01 Now, some "double precision" reals: X SPACING(X) 1.00000 0.222045E-15 0.00000 0.222507-307 0.100000E+07 0.116415E-09 TEST_SPREAD SPREAD is a Fortran90 function which replicates an array by adding a dimension. Suppose we have a scalar S = 99 V = spread ( s, 1, 4 ) adds a new dimension (1) of extent 4 99 99 99 99 Now first reset V to (1,2,3,4) A1 = spread ( v, 2, 3 ) adds a new dimension (2) of extent 3 1 1 1 2 2 2 3 3 3 4 4 4 A2 = spread ( v, 1, 3 ) adds a new dimension (1) of extent 3 1 2 3 4 1 2 3 4 1 2 3 4 TEST_SQRT SQRT is a Fortran90 function which returns the square root of a real number. X SQRT(X) (SQRT(X))**2 9.25156 3.04164 9.25156 0.567769E-01 0.238279 0.567769E-01 8.51433 2.91793 8.51433 8.49165 2.91404 8.49165 2.68037 1.63718 2.68037 0.386198 0.621449 0.386198 0.416452 0.645331 0.416452 4.70768 2.16972 4.70768 3.74006 1.93392 3.74006 0.659037 0.811811 0.659037 TEST_SUM SUM is a Fortran90 function which returns the sum of the entries of a vector. A complex vector: X -0.158877 -0.824544 -0.865410 0.298088 -0.330904 0.652513 -0.122888 0.509554 0.128221 0.119966 SUM(X) = -1.349857 0.755577 A real vector: X -0.158877 -0.865410 -0.330904 -0.122888 0.128221 SUM(X) = -1.349857 An integer vector: X -1 -8 -3 -1 1 SUM(X) = -12 A 4 x 5 integer array A containing 1 through 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 SUM(A) = 210 TEST_SUM_ARAY SUM(A) is a Fortran90 function which returns the sum of the entries of a vector or array. SUM(A,1) or SUM(A,DIM=1) returns an array of one lower rank containing sums over index 1, and so on. A 4 x 5 integer array A containing 1 through 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 SUM(A) = 210 SUM(A,1) = SUM(A,DIM=1) will give sums across rows: 34 38 42 46 50 SUM(A,2) = SUM(A,DIM=2) will give sums across columns: 15 40 65 90 TEST_SYSTEM_CLOCK SYSTEM_CLOCK is a Fortran90 subroutine which returns information from a system clock. COUNT = 58131956 COUNT_RATE = 1000 COUNT_MAX = 2147483647 The current value of COUNT corresponds to a a time interval of COUNT / COUNT_RATE 58132.0 seconds, TEST_TAN TAN is a Fortran90 function which returns the tangent of a real number. X TAN(X) 9.77508 0.365373 -2.23338 1.28163 3.09871 -0.429126E-01 -0.266084 -0.272547 -3.89262 -0.933522 -6.90936 -0.723268 -1.59792 36.8554 -3.07830 0.633733E-01 1.17275 2.37817 -3.67474 -0.590148 TEST_TANH TANH is a Fortran90 function which returns the hyperbolic tangent of a real number. X TANH(X) 7.90714 1.00000 -4.54098 -0.999773 3.15228 0.996351 9.95554 1.00000 1.49664 0.904539 4.58779 0.999793 -6.20488 -0.999992 8.04357 1.00000 8.47021 1.00000 -4.70177 -0.999835 TEST_TINY TINY is a Fortran90 function which returns the "tiniest number" associated with a real number. First, some "default precision" reals: X TINY(X) 1.00000 0.117549E-37 0.00000 0.117549E-37 0.100000E+07 0.117549E-37 Now, some "double precision" reals: X TINY(X) 1.00000 0.222507-307 0.00000 0.222507-307 0.100000E+07 0.222507-307 TEST_TRANSFER TRANSFER is a Fortran90 function which allows the "physical" data of a variable to be interpreted as though it were another type or kind of variable. Examine REAL data as though it were an INTEGER. I = TRANSFER ( R, I ) R = 1.00000 I = 1065353216 Examine COMPLEX data as though it were two REALS. R2 = TRANSFER ( C, R2 ) C = 1.20000 3.40000 R2 = 1.20000 3.40000 Examine LOGICAL data as though it were an INTEGER. I = TRANSFER ( L, I ) L = T I = 1 Examine CHARACTER data as though it were an INTEGER. I = TRANSFER ( CH, I ) CH = "a" I = 1067030938 TEST_TRANSPOSE TRANSPOSE is a Fortran90 function which returns the transpose of a complex, integer or real two dimensional array. integer x_i4(4,4) 16 86 37 34 20 93 57 21 50 25 88 6 93 35 4 43 y_i4 = transpose ( x_i4 ) 16 20 50 93 86 93 25 35 37 57 88 4 34 21 6 43 real x_r4(2,3) 0.056775 0.006901 0.037163 0.423944 0.625663 0.541553 y_r4 = transpose ( x_r4 ) 0.056775 0.423944 0.006901 0.625663 0.037163 0.541553 TEST_TRIM TRIM is a Fortran90 function which returns a copy of a string from which the trailing blanks have been dropped. S TRIM(S) ---------- ---------- "1234567890" "1234567890" "12345 " "12345" " 67890" " 67890" " 34 678 " " 34 678" " 5 " " 5" " " "" TEST_UBOUND UBOUND(ARRAY) is a Fortran90 function which returns the upper array bounds in all dimensions; UBOUND(ARRAY,DIM) returns the upper bound in dimension DIM. real a(5,10,17) ubound(a) = 5 10 17 ubound(a,1) = 5 ubound(a,2) = 10 ubound(a,3) = 17 integer b(4:6,-5:-1,10:20) ubound(b) = 6 -1 20 ubound(b,1) = 6 ubound(b,2) = -1 ubound(b,3) = 20 TEST_UNPACK UNPACK is a Fortran90 function which unpacks the entries of a vector into an array subject to a logical mask. integer v(20) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 logical mask(5,4) F T F T T F T F F T F T T F T F F T F T integer a(5,4) = unpack ( v, mask, field ) -99 3 -99 8 1 -99 6 -99 -99 4 -99 9 2 -99 7 -99 -99 5 -99 10 TEST_VERIFY VERIFY(S1,S2) is a Fortran90 function which returns the location of the first character in S1 not in S2, or else 0. S1 S2 VERIFY(S1,S2) 1001010001 01 0 1002010091 01 4 CAPS lower CAPS LOWER 6 Blanks count! aBcklnstu! 7 The optional parameter BACK, set to TRUE, makes the check start at the END of S1. S1 S2 VERIFY(S1,S2,BACK) 1001010001 01 0 1002010091 01 9 CAPS lower CAPS LOWER 10 Blanks count! aBcklnstu! 14 f90_intrinsics_test(): Normal end of execution. 6 October 2025 6:06:03.067 PM