9 May 2025 9:00:47.436 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.259563 1.30823 0.259563 -0.403938 1.98661 -0.403938 0.876317 0.502634 0.876317 -0.124894 1.69602 -0.124894 0.261402 1.30632 0.261402 -0.544381 2.14645 -0.544381 -0.767864 2.44630 -0.767864 0.719567 0.767618 0.719567 -0.645851 2.27293 -0.645851 0.424017 1.13292 0.424017 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.758353 -0.199481 -0.199481 -0.013984 0.984487 0.984487 0.836316 0.408156 0.408156 0.939231 0.204693 0.204693 -0.839471 -0.155663 -0.155663 -0.785048 -0.101332 -0.101332 0.596362 0.557085 0.557085 0.070416 0.554079 0.554079 -0.375022 -0.607953 -0.607953 -0.784561 0.252979 0.252979 TEST_AINT AINT is a FORTRAN90 function which returns the value of a real number rounded towards zero. X AINT(X) -0.361811 -0.00000 -9.25605 -9.00000 -1.56961 -1.00000 3.36474 3.00000 5.81685 5.00000 -8.26502 -8.00000 7.39497 7.00000 0.177248 0.00000 -6.75540 -6.00000 -6.05530 -6.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) 13 49 97 44 10 49 44 15 50 99 43 23 65 18 19 10 92 7 65 6 ALL ( A_I4 < 100 ) T ALL ( A_I4 < 90 ) F ALL ( A_I4 < 90, 1 ) T F F T F ALL ( A_I4 < 90, 2 ) F F T F 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) -1.77305 -2.00000 7.70654 8.00000 5.20232 5.00000 6.95295 7.00000 9.25312 9.00000 7.06711 7.00000 2.11749 2.00000 -9.03251 -9.00000 5.20352 5.00000 1.52284 2.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) 18 5 38 81 21 46 48 52 49 55 29 31 52 66 76 53 9 73 35 49 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 F F T ANY ( MOD(A_I4,5)==0,1 ) F T F T T ANY ( MOD(A_I4,5)==0,2 ) T T F 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.232120 0.234256 0.232120 -0.660106 -0.720959 -0.660106 -0.880609 -1.07715 -0.880609 0.658250 0.718492 0.658250 0.213102 0.214749 0.213102 -0.295218 -0.299683 -0.295218 0.807489 0.939883 0.807489 0.444461 0.460573 0.444461 -0.892011 -1.10177 -0.892011 -0.156261 -0.156904 -0.156261 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)) 9.52797 1.46623 9.52797 5.95769 1.40450 5.95769 1.25460 0.897848 1.25460 3.59884 1.29977 3.59884 -7.25630 -1.43385 -7.25630 -8.92045 -1.45916 -8.92045 -4.25962 -1.34021 -4.25962 7.67166 1.44118 7.67166 5.12540 1.37811 5.12540 -9.43850 -1.46524 -9.43850 TEST_ATAN2 ATAN2 is a FORTRAN90 function which returns the inverse tangent of a value X Y ATAN2(Y,X) TAN(ATAN2(Y,X)) 9.37889 -2.38613 -0.249130 -0.254415 7.78096 4.47109 0.521549 0.574620 0.260005 9.91447 1.54458 38.1318 -4.91436 3.30031 2.55021 -0.671565 -0.888813 3.38136 1.82784 -3.80436 -4.28742 -2.58432 -2.59914 0.602768 5.45854 5.35341 0.775675 0.980741 -0.968839 7.37697 1.70138 -7.61424 9.95471 -4.93508 -0.460245 -0.495753 -5.01875 -3.81438 -2.49171 0.760025 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) 6.48173 7 -3.19738 -3 -1.74158 -1 3.58274 4 -2.98162 -2 -0.806407 0 -8.70623 -8 9.67834 10 -1.52798 -1 3.82990 4 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.592463 -0.185629 -0.592463 0.185629 -0.447543 0.887105 -0.447543 -0.887105 -0.581368 -0.029978 -0.581368 0.029978 0.592173 0.682146 0.592173 -0.682146 0.164114 0.166705 0.164114 -0.166705 -0.309497 -0.478213 -0.309497 0.478213 0.356435 -0.093435 0.356435 0.093435 -0.241541 -0.712066 -0.241541 0.712066 0.090383 0.878389 0.090383 -0.878389 -0.204548 0.054163 -0.204548 -0.054163 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.912915 0.126513 0.616342 -0.100376 -0.308571 -0.303528 0.996996 -0.936025E-01 0.835021 0.152527 0.678984 -0.113509 0.166127 -0.605297 1.17249 0.106319 0.237825 -0.245703 1.00134 0.584691E-01 -0.807011 0.552863 0.800085 0.419944 -0.540499E-01 -0.102742 1.00381 -0.556025E-02 0.329822 0.554040 1.09506 -0.188761 0.756438 -0.545073 0.838027 0.392904 -0.829789 0.334060 0.713048 0.251076 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) -4.54414 -0.167460 -2.51425 -0.809593 -9.23866 -0.982730 -7.69782 0.155528 8.17521 -0.315731 9.28711 -0.990538 7.94301 -0.889068E-01 0.543873 0.855711 -6.97758 0.768440 -1.21146 0.351649 TEST_COSH COSH is a FORTRAN90 function which returns the hyperbolic cosine of a real number. X COSH(X) -2.55528 6.47627 6.83737 466.019 -8.77900 3248.20 9.79027 8929.58 -4.18569 32.8772 -2.78116 8.09985 0.500230 1.12775 -9.76420 8699.77 -5.62714 138.934 -0.920252 1.45417 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) 16 20 38 21 48 89 73 52 50 44 9 99 97 28 65 50 15 47 47 38 COUNT ( A_I4 < 100 ) 20 COUNT ( A_I4 < 90 ) 18 COUNT ( A_I4 < 90, 1 ) 4 3 3 4 4 COUNT ( A_I4 < 90, 2 ) 5 5 3 5 COUNT ( MOD(A_I4,2)==0,1 ) 2 1 2 2 3 COUNT ( MOD(A_I4,2)==0,2 ) 4 3 1 2 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 = "20250509". TIME = "210047.436". ZONE = "-0400". VALUES(1) = year = 2025 VALUES(2) = month = 5 VALUES(3) = day = 9 VALUES(4) = UTC minute diff = -240 VALUES(5) = hour = 21 VALUES(6) = minute = 0 VALUES(7) = second = 47 VALUES(8) = milliseconds = 436 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) 65 48 17 60 7 53 92 56 36 92 9 83 37 39 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.361179 0.597535 0.138290 0.458507 0.969900 0.422160 0.802443 0.288617 0.247055 0.275963 0.658656 0.661865 0.777204 0.828149 0.987991 0.551340 0.010991 0.486120 0.549882 0.279329 DOT_PRODUCT(X,Y) = 2.935722 -0.648046 Two real vectors: X Y 0.675978 0.206935 0.549358 0.660652 0.152541 0.977729 0.260028 0.297805 0.222421 0.942293 DOT_PRODUCT(X,Y) = 0.938986 Two integer vectors: X Y 6 2 5 6 1 9 2 2 2 9 DOT_PRODUCT(X,Y) = 73 Two logical vectors: X Y T F F T F T F 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) 86.073669 39.728279 3419.558764 60.828354 25.048750 1523.674225 14.872587 22.489702 334.480058 73.398315 46.235889 3393.636397 44.036846 57.082115 2513.716324 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) 7.56154 1922.80 -5.45948 0.425578E-02 -5.83288 0.292964E-02 -8.86236 0.141620E-03 -5.95479 0.259340E-02 -5.71806 0.328610E-02 -8.96319 0.128038E-03 8.92358 7506.95 -0.847388 0.428533 -7.81653 0.403019E-03 TEST_EXPONENT EXPONENT is a FORTRAN90 function which returns the exponent part of a real number. X EXPONENT(X) -4.40639 3 -7.39556 3 -7.31426 3 2.80091 2 -8.86061 4 9.41566 4 6.01591 3 5.12394 3 -4.10509 3 9.77729 4 TEST_FLOOR FLOOR is a FORTRAN90 function which rounds a real number down "towards -infinity". X FLOOR(X) -2.38673 -3 0.949570 0 8.94421 8 9.40793 9 0.426026 0 6.84177 6 -6.96969 -7 4.28744 4 -2.95630 -3 -3.62083 -4 TEST_FRACTION FRACTION is a FORTRAN90 function which returns the fractional part of a real number. X FRACTION(X) -4.26622 -0.533277 3.14660 0.786649 8.06310 0.503944 2.53295 0.633239 -3.32176 -0.830441 -0.507675 -0.507675 1.32846 0.664228 -9.83066 -0.614417 -6.13881 -0.767351 7.26493 0.908116 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) 79 45 13 60 87 20 18 90 18 31 0 0 12 90 8 12 78 12 86 81 80 11 76 8 0 41 0 11 30 10 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) 57 0 0 15 10 10 9 98 0 37 78 4 26 17 16 74 74 74 67 78 66 3 31 3 11 31 11 57 79 9 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) 65 12 77 19 83 64 15 71 72 36 53 17 74 33 107 75 49 122 28 93 65 18 0 18 48 66 114 73 89 16 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) 86 74 28 11 11 0 77 84 25 84 97 53 56 46 22 92 66 30 59 52 15 53 68 113 91 60 103 11 65 74 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) 63 42 63 73 82 91 11 57 59 65 77 77 12 83 95 13 35 47 57 98 123 19 70 87 50 87 119 27 45 63 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) 64 8 72 37 91 127 37 67 103 25 81 89 49 64 113 97 77 109 66 98 98 55 28 63 37 47 47 65 31 95 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)) 4.33687 1.46715 4.33687 1.12602 0.118689 1.12602 0.856034E-01 -2.45803 0.856034E-01 0.188423 -1.66906 0.188423 9.86784 2.28928 9.86784 7.08398 1.95784 7.08398 1.43952 0.364311 1.43952 9.69892 2.27201 9.69892 9.01474 2.19886 9.01474 7.01146 1.94755 7.01146 TEST_LOG10 LOG10 is a FORTRAN90 function which returns the base 10 logarithm of a real number. X LOG10(X) 10**(LOG(X)) 8.66950 0.937994 8.66950 9.03126 0.955748 9.03126 3.27708 0.515488 3.27708 6.63837 0.822062 6.63837 1.31993 0.120551 1.31993 0.682813E-01 -1.16570 0.682813E-01 7.04208 0.847701 7.04208 0.297907 -0.525920 0.297907 4.85726 0.686392 4.85726 0.745568 -0.127513 0.745568 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 5 2 0 3 2 4 1 1 0 3 2 5 0 1 4 3 3 5 2 Matrix B: 0 5 2 2 4 1 3 2 5 4 3 3 5 2 0 Vector C: 5 4 4 5 3 Matrix AB = matmul ( A, B ): 39 34 15 26 22 15 22 33 23 45 32 40 Vector AC = matmul ( A, C ): 37 35 46 75 Vector CB = matmul ( C, B ): 56 43 48 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 2 7 2 9 1 9 3 6 1 6 4 5 0 5 5 6 2 6 6 10 7 10 7 4 5 5 8 9 0 9 9 1 9 9 10 6 5 6 Now try Z(1:N) = max ( 5, Y(1:N) ) I X(I) Y(I) Z(I) 1 5 10 10 2 5 0 5 3 5 3 5 4 5 5 5 5 5 8 8 6 5 5 5 7 5 1 5 8 5 6 6 9 5 10 10 10 5 6 6 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.437608 0.461982 0.335085 0.068753 0.010312 MAXLOC(X) = 2 An integer vector: X 4 4 3 0 0 MAXLOC(X) = 1 TEST_MAXVAL MAXVAL is a FORTRAN90 function which returns the maximum value of the entries of a vector. A real vector: X 0.361727 0.551547 0.341927 0.123282 0.035170 MAXVAL(X) = 0.551547 An integer vector: X 3 5 3 1 0 MAXVAL(X) = 5 TEST_MERGE MERGE is a FORTRAN90 function which copies entries from one array or the other depending on a logical array. Array A: 85 22 35 54 90 54 11 64 82 76 75 7 12 37 61 100 87 52 37 68 Array B: 53 88 67 76 39 4 51 15 76 96 8 40 31 38 4 67 74 45 100 26 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 88 35 76 39 54 11 64 82 76 8 40 12 38 4 100 87 52 37 68 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.113330 0.556560 0.094828 0.970183 0.815298 MINLOC(X) = 3 An integer vector: X 1 5 0 9 8 MINLOC(X) = 3 TEST_MINVAL MINVAL is a FORTRAN90 function which returns the minimum value of the entries of a vector. A real vector: X 0.880434 0.810241 0.119259 0.439318 0.245974 MINVAL(X) = 0.119259 An integer vector: X 8 8 1 4 2 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) 17 2 1 0 10 0 5 6 5 7 0 Undefined -2 -6 -2 18 1 0 -2 11 -2 14 12 2 18 -3 0 16 -9 7 TEST_MOD_R8 MOD is a FORTRAN90 function which returns the remainder after division. Here, the arguments are reals. X Y MOD(X,Y) 13.126869 -3.853973 1.564951 8.288827 -0.226689 0.128025 -3.159846 12.951424 -3.159846 13.093682 5.615663 1.862357 19.188234 15.725682 3.462552 19.921306 4.291206 2.756481 5.964493 6.831564 5.964493 5.074108 15.693009 5.074108 4.010787 7.132589 4.010787 3.736325 16.124022 3.736325 TEST_MODULO_I4 MODULO is a FORTRAN90 function which returns the remainder after division. Here, the arguments are integers. I J MODULO(I,J) 3 12 3 11 4 3 2 7 2 13 6 1 9 7 2 -4 3 2 18 6 0 -1 -1 0 -2 -10 -2 11 6 5 TEST_MODULO_R4 MODULO is a FORTRAN90 function which returns the remainder after division. Here, the arguments are reals. X Y MODULO(X,Y) -9.638159 10.833946 1.195787 8.631521 -7.520684 -6.409847 15.985252 18.991268 15.985252 -4.963255 1.703331 0.146738 -3.156408 19.774239 16.617830 4.213922 12.230108 4.213922 12.276598 -2.375744 -1.977865 7.590206 9.672848 7.590206 -2.372345 16.484703 14.112358 2.806662 17.361778 2.806662 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) -7.67153 -8 -3.11196 -3 3.50074 4 -8.07573 -8 0.514714 1 -0.413050 0 3.07676 3 4.59589 5 -4.64951 -5 -9.09673 -9 IVEC = NINT ( XVEC ): 0.377401 0 0.600934 1 0.216779 0 0.526016 1 0.247832E-01 0 0.870764 1 0.524872 1 0.835062 1 0.411547 0 0.597739 1 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) 61 -62 80 -81 40 -41 89 -90 67 -68 54 -55 94 -95 86 -87 80 -81 53 -54 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) 16 -17 97 -98 87 -88 72 -73 92 -93 44 -45 61 -62 49 -50 87 -88 74 -75 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) 30 24 13 22 80 23 3 57 44 58 48 30 34 91 66 19 58 15 45 60 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 T F T T T T T T 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: 30 44 34 58 24 23 58 15 13 3 48 66 45 22 57 30 19 60 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.023250 0.315140 0.030262 0.528814 0.120675 -0.463205 -0.514709 -0.610269 -0.669157 -0.499279 PRODUCT(X) = -0.052209 -0.011221 A real vector: X -0.023250 0.030262 0.120675 -0.514709 -0.669157 PRODUCT(X) = -0.000029 An integer vector: X 0 0 1 -5 -6 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.148785 0.765115 0.880840 0.305502E-01 0.988181 Call RANDOM_NUMBER once, with a vector argument 0.607501 0.565395 0.440811 0.379420 0.563051 Call RANDOM_NUMBER with an array argument 0.763705 0.597812E-01 0.408371 0.628645 0.253962 0.248315 0.116775E-01 0.201229 0.597728 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: -549674559 1417064892 -741790541 -496290680 -1922310900 928389699 -1723062424 -132249562 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 = 252205152 COUNT_RATE = 1000 COUNT_MAX = 2147483647 The current value of COUNT corresponds to a a time interval of COUNT / COUNT_RATE 252205. 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. 9 May 2025 9:00:47.437 PM