Thanks for using Compiler Explorer
Sponsors
Jakt
C++
Ada
Algol68
Analysis
Android Java
Android Kotlin
Assembly
C
C3
Carbon
C with Coccinelle
C++ with Coccinelle
C++ (Circle)
CIRCT
Clean
CMake
CMakeScript
COBOL
C++ for OpenCL
MLIR
Cppx
Cppx-Blue
Cppx-Gold
Cpp2-cppfront
Crystal
C#
CUDA C++
D
Dart
Elixir
Erlang
Fortran
F#
GLSL
Go
Haskell
HLSL
Hook
Hylo
IL
ispc
Java
Julia
Kotlin
LLVM IR
LLVM MIR
Modula-2
Mojo
Nim
Numba
Nix
Objective-C
Objective-C++
OCaml
Odin
OpenCL C
Pascal
Pony
PTX
Python
Racket
Raku
Ruby
Rust
Sail
Snowball
Scala
Slang
Solidity
Spice
SPIR-V
Swift
LLVM TableGen
Toit
Triton
TypeScript Native
V
Vala
Visual Basic
Vyper
WASM
Zig
Javascript
GIMPLE
Ygen
sway
fortran source #1
Output
Compile to binary object
Link to binary
Execute the code
Intel asm syntax
Demangle identifiers
Verbose demangling
Filters
Unused labels
Library functions
Directives
Comments
Horizontal whitespace
Debug intrinsics
Compiler
AARCH64 gfortran 10.5.0
AARCH64 gfortran 11.4.0
AARCH64 gfortran 12.1.0
AARCH64 gfortran 12.2.0
AARCH64 gfortran 12.3.0
AARCH64 gfortran 12.4.0
AARCH64 gfortran 12.5.0
AARCH64 gfortran 13.1.0
AARCH64 gfortran 13.2.0
AARCH64 gfortran 13.3.0
AARCH64 gfortran 13.4.0
AARCH64 gfortran 14.1.0
AARCH64 gfortran 14.2.0
AARCH64 gfortran 14.3.0
AARCH64 gfortran 15.1.0
AARCH64 gfortran 15.2.0
AARCH64 gfortran 4.9.4
AARCH64 gfortran 5.5.0
AARCH64 gfortran 6.4
AARCH64 gfortran 7.3
AARCH64 gfortran 8.2
ARM (32bit) gfortran 10.5.0
ARM (32bit) gfortran 11.4.0
ARM (32bit) gfortran 12.1.0
ARM (32bit) gfortran 12.2.0
ARM (32bit) gfortran 12.3.0
ARM (32bit) gfortran 12.4.0
ARM (32bit) gfortran 12.5.0
ARM (32bit) gfortran 13.1.0
ARM (32bit) gfortran 13.2.0
ARM (32bit) gfortran 13.3.0
ARM (32bit) gfortran 13.4.0
ARM (32bit) gfortran 14.1.0
ARM (32bit) gfortran 14.2.0
ARM (32bit) gfortran 14.3.0
ARM (32bit) gfortran 15.1.0
ARM (32bit) gfortran 15.2.0
ARM (32bit) gfortran 6.4
ARM (32bit) gfortran 7.3
ARM (32bit) gfortran 8.2
HPPA gfortran 14.2.0
HPPA gfortran 14.3.0
HPPA gfortran 15.1.0
HPPA gfortran 15.2.0
LFortran 0.42.0
LFortran 0.43.0
LFortran 0.44.0
LFortran 0.45.0
LFortran 0.46.0
LFortran 0.47.0
LFortran 0.48.0
LFortran 0.49.0
LFortran 0.50.0
LFortran 0.51.0
LFortran 0.52.0
LOONGARCH64 gfortran 12.2.0
LOONGARCH64 gfortran 12.3.0
LOONGARCH64 gfortran 12.4.0
LOONGARCH64 gfortran 12.5.0
LOONGARCH64 gfortran 13.1.0
LOONGARCH64 gfortran 13.2.0
LOONGARCH64 gfortran 13.3.0
LOONGARCH64 gfortran 13.4.0
LOONGARCH64 gfortran 14.1.0
LOONGARCH64 gfortran 14.2.0
LOONGARCH64 gfortran 14.3.0
LOONGARCH64 gfortran 15.1.0
LOONGARCH64 gfortran 15.2.0
MIPS gfortran 12.1.0
MIPS gfortran 12.2.0
MIPS gfortran 12.3.0
MIPS gfortran 12.4.0
MIPS gfortran 12.5.0
MIPS gfortran 13.1.0
MIPS gfortran 13.2.0
MIPS gfortran 13.3.0
MIPS gfortran 13.4.0
MIPS gfortran 14.1.0
MIPS gfortran 14.2.0
MIPS gfortran 14.3.0
MIPS gfortran 15.1.0
MIPS gfortran 15.2.0
MIPS gfortran 4.9.4
MIPS gfortran 5.5.0
MIPS gfortran 9.5.0
MIPS64 gfortran 12.1.0
MIPS64 gfortran 12.2.0
MIPS64 gfortran 12.3.0
MIPS64 gfortran 12.4.0
MIPS64 gfortran 12.5.0
MIPS64 gfortran 13.1.0
MIPS64 gfortran 13.2.0
MIPS64 gfortran 13.3.0
MIPS64 gfortran 13.4.0
MIPS64 gfortran 14.1.0
MIPS64 gfortran 14.2.0
MIPS64 gfortran 14.3.0
MIPS64 gfortran 15.1.0
MIPS64 gfortran 15.2.0
MIPS64 gfortran 4.9.4
MIPS64 gfortran 5.5.0
MIPS64 gfortran 9.5.0
MIPS64el gfortran 12.1.0
MIPS64el gfortran 12.2.0
MIPS64el gfortran 12.3.0
MIPS64el gfortran 12.4.0
MIPS64el gfortran 12.5.0
MIPS64el gfortran 13.1.0
MIPS64el gfortran 13.2.0
MIPS64el gfortran 13.3.0
MIPS64el gfortran 13.4.0
MIPS64el gfortran 14.1.0
MIPS64el gfortran 14.2.0
MIPS64el gfortran 14.3.0
MIPS64el gfortran 15.1.0
MIPS64el gfortran 15.2.0
MIPS64el gfortran 4.9.4
MIPS64el gfortran 5.5.0
MIPS64el gfortran 9.5.0
MIPSel gfortran 12.1.0
MIPSel gfortran 12.2.0
MIPSel gfortran 12.3.0
MIPSel gfortran 12.4.0
MIPSel gfortran 12.5.0
MIPSel gfortran 13.1.0
MIPSel gfortran 13.2.0
MIPSel gfortran 13.3.0
MIPSel gfortran 13.4.0
MIPSel gfortran 14.1.0
MIPSel gfortran 14.2.0
MIPSel gfortran 14.3.0
MIPSel gfortran 15.1.0
MIPSel gfortran 15.2.0
MIPSel gfortran 4.9.4
MIPSel gfortran 5.5.0
MIPSel gfortran 9.5.0
POWER gfortran 12.1.0
POWER gfortran 12.2.0
POWER gfortran 12.3.0
POWER gfortran 12.4.0
POWER gfortran 12.5.0
POWER gfortran 13.1.0
POWER gfortran 13.2.0
POWER gfortran 13.3.0
POWER gfortran 13.4.0
POWER gfortran 14.1.0
POWER gfortran 14.2.0
POWER gfortran 14.3.0
POWER gfortran 15.1.0
POWER gfortran 15.2.0
POWER64 gfortran 12.1.0
POWER64 gfortran 12.2.0
POWER64 gfortran 12.3.0
POWER64 gfortran 12.4.0
POWER64 gfortran 12.5.0
POWER64 gfortran 13.1.0
POWER64 gfortran 13.2.0
POWER64 gfortran 13.3.0
POWER64 gfortran 13.4.0
POWER64 gfortran 14.1.0
POWER64 gfortran 14.2.0
POWER64 gfortran 14.3.0
POWER64 gfortran 15.1.0
POWER64 gfortran 15.2.0
POWER64 gfortran trunk
POWER64le gfortran 12.1.0
POWER64le gfortran 12.2.0
POWER64le gfortran 12.3.0
POWER64le gfortran 12.4.0
POWER64le gfortran 12.5.0
POWER64le gfortran 13.1.0
POWER64le gfortran 13.2.0
POWER64le gfortran 13.3.0
POWER64le gfortran 13.4.0
POWER64le gfortran 14.1.0
POWER64le gfortran 14.2.0
POWER64le gfortran 14.3.0
POWER64le gfortran 15.1.0
POWER64le gfortran 15.2.0
POWER64le gfortran trunk
RISC-V 32-bits gfortran (trunk)
RISC-V 32-bits gfortran 12.1.0
RISC-V 64-bits gfortran (trunk)
RISC-V 64-bits gfortran 12.1.0
RISCV (32bit) gfortran 11.4.0
RISCV (32bit) gfortran 12.2.0
RISCV (32bit) gfortran 12.3.0
RISCV (32bit) gfortran 12.4.0
RISCV (32bit) gfortran 12.5.0
RISCV (32bit) gfortran 13.1.0
RISCV (32bit) gfortran 13.2.0
RISCV (32bit) gfortran 13.3.0
RISCV (32bit) gfortran 13.4.0
RISCV (32bit) gfortran 14.1.0
RISCV (32bit) gfortran 14.2.0
RISCV (32bit) gfortran 14.3.0
RISCV (32bit) gfortran 15.1.0
RISCV (32bit) gfortran 15.2.0
RISCV64 gfortran 11.4.0
RISCV64 gfortran 12.2.0
RISCV64 gfortran 12.3.0
RISCV64 gfortran 12.4.0
RISCV64 gfortran 12.5.0
RISCV64 gfortran 13.1.0
RISCV64 gfortran 13.2.0
RISCV64 gfortran 13.3.0
RISCV64 gfortran 13.4.0
RISCV64 gfortran 14.1.0
RISCV64 gfortran 14.2.0
RISCV64 gfortran 14.3.0
RISCV64 gfortran 15.1.0
RISCV64 gfortran 15.2.0
SPARC LEON gfortran 12.2.0
SPARC LEON gfortran 12.3.0
SPARC LEON gfortran 12.4.0
SPARC LEON gfortran 12.5.0
SPARC LEON gfortran 13.1.0
SPARC LEON gfortran 13.2.0
SPARC LEON gfortran 13.3.0
SPARC LEON gfortran 13.4.0
SPARC LEON gfortran 14.1.0
SPARC LEON gfortran 14.2.0
SPARC LEON gfortran 14.3.0
SPARC LEON gfortran 15.1.0
SPARC LEON gfortran 15.2.0
SPARC gfortran 12.2.0
SPARC gfortran 12.3.0
SPARC gfortran 12.4.0
SPARC gfortran 12.5.0
SPARC gfortran 13.1.0
SPARC gfortran 13.2.0
SPARC gfortran 13.3.0
SPARC gfortran 13.4.0
SPARC gfortran 14.1.0
SPARC gfortran 14.2.0
SPARC gfortran 14.3.0
SPARC gfortran 15.1.0
SPARC gfortran 15.2.0
SPARC64 gfortran 12.2.0
SPARC64 gfortran 12.3.0
SPARC64 gfortran 12.4.0
SPARC64 gfortran 12.5.0
SPARC64 gfortran 13.1.0
SPARC64 gfortran 13.2.0
SPARC64 gfortran 13.3.0
SPARC64 gfortran 13.4.0
SPARC64 gfortran 14.1.0
SPARC64 gfortran 14.2.0
SPARC64 gfortran 14.3.0
SPARC64 gfortran 15.1.0
SPARC64 gfortran 15.2.0
Tricore gfortran 11.3.0 (EEESlab)
flang-trunk
flang-trunk-fc1
power64 AT12.0
power64 AT13.0
power64le AT12.0
power64le AT13.0
s390x gfortran 12.1.0
s390x gfortran 12.2.0
s390x gfortran 12.3.0
s390x gfortran 12.4.0
s390x gfortran 12.5.0
s390x gfortran 13.1.0
s390x gfortran 13.2.0
s390x gfortran 13.3.0
s390x gfortran 13.4.0
s390x gfortran 14.1.0
s390x gfortran 14.2.0
s390x gfortran 14.3.0
s390x gfortran 15.1.0
s390x gfortran 15.2.0
x86 nvfortran 24.11
x86 nvfortran 24.9
x86 nvfortran 25.1
x86 nvfortran 25.3
x86 nvfortran 25.5
x86 nvfortran 25.7
x86-64 gfortran (trunk)
x86-64 gfortran 10.1
x86-64 gfortran 10.2
x86-64 gfortran 10.3
x86-64 gfortran 10.3 (assertions)
x86-64 gfortran 10.4
x86-64 gfortran 10.4 (assertions)
x86-64 gfortran 10.5
x86-64 gfortran 10.5 (assertions)
x86-64 gfortran 11.1
x86-64 gfortran 11.1 (assertions)
x86-64 gfortran 11.2
x86-64 gfortran 11.2 (assertions)
x86-64 gfortran 11.3
x86-64 gfortran 11.3 (assertions)
x86-64 gfortran 11.4
x86-64 gfortran 11.4 (assertions)
x86-64 gfortran 12.1
x86-64 gfortran 12.1 (assertions)
x86-64 gfortran 12.2
x86-64 gfortran 12.2 (assertions)
x86-64 gfortran 12.3
x86-64 gfortran 12.3 (assertions)
x86-64 gfortran 12.4
x86-64 gfortran 12.4 (assertions)
x86-64 gfortran 12.5
x86-64 gfortran 12.5 (assertions)
x86-64 gfortran 13.1
x86-64 gfortran 13.1 (assertions)
x86-64 gfortran 13.2
x86-64 gfortran 13.2 (assertions)
x86-64 gfortran 13.3
x86-64 gfortran 13.3 (assertions)
x86-64 gfortran 13.4
x86-64 gfortran 13.4 (assertions)
x86-64 gfortran 14.1
x86-64 gfortran 14.1 (assertions)
x86-64 gfortran 14.2
x86-64 gfortran 14.2 (assertions)
x86-64 gfortran 14.3
x86-64 gfortran 14.3 (assertions)
x86-64 gfortran 15.1
x86-64 gfortran 15.1 (assertions)
x86-64 gfortran 15.2
x86-64 gfortran 15.2 (assertions)
x86-64 gfortran 4.9.4
x86-64 gfortran 5.5
x86-64 gfortran 6.3
x86-64 gfortran 7.1
x86-64 gfortran 7.2
x86-64 gfortran 7.3
x86-64 gfortran 8.1
x86-64 gfortran 8.2
x86-64 gfortran 8.3
x86-64 gfortran 8.4
x86-64 gfortran 8.5
x86-64 gfortran 9.1
x86-64 gfortran 9.2
x86-64 gfortran 9.3
x86-64 gfortran 9.4
x86-64 ifort 19.0.0
x86-64 ifort 2021.1.2
x86-64 ifort 2021.10.0
x86-64 ifort 2021.11.0
x86-64 ifort 2021.2.0
x86-64 ifort 2021.3.0
x86-64 ifort 2021.4.0
x86-64 ifort 2021.5.0
x86-64 ifort 2021.6.0
x86-64 ifort 2021.7.0
x86-64 ifort 2021.7.1
x86-64 ifort 2021.8.0
x86-64 ifort 2021.9.0
x86-64 ifx (latest)
x86-64 ifx 2021.1.2
x86-64 ifx 2021.2.0
x86-64 ifx 2021.3.0
x86-64 ifx 2021.4.0
x86-64 ifx 2022.0.0
x86-64 ifx 2022.1.0
x86-64 ifx 2022.2.0
x86-64 ifx 2022.2.1
x86-64 ifx 2023.0.0
x86-64 ifx 2023.1.0
x86-64 ifx 2023.2.1
x86-64 ifx 2024.0.0
Options
Source code
module mf_datatypes use iso_fortran_env implicit none integer, parameter :: dp = real64 integer, parameter :: sp = real32 end module mf_datatypes module mf_utils use mf_datatypes interface print_matrix module procedure print_matrix_d, print_matrix_s end interface interface print_vector module procedure print_vector_d, print_vector_s end interface interface rand_mat module procedure rand_mat_d, rand_mat_s end interface interface rand_vec module procedure rand_vec_d, rand_vec_s end interface integer, private :: field_width = 10 integer, private :: field_decimals = 4 character :: field_code(1) = 'G' contains subroutine set_print_format(width, decimals, code) integer, optional :: width integer, optional :: decimals character, optional :: code(1) if (present(width)) then field_width = width end if if (present(decimals)) then field_decimals = decimals end if if (present(code)) then field_code = code end if end subroutine set_print_format subroutine print_matrix_d(A, name) real(dp), intent(in) :: A(:,:) character(*), intent(in), optional :: name integer :: rows, cols, slen integer :: i, j character(255) :: fmt character(255) :: sfmt rows = size(A,1) cols = size(A,2) slen = len_trim(name) if (slen<10) then write(sfmt, '(A,I1,A)') '(TL1,A,A',slen,',A,I3,A,I3,A)' else if (slen<100) then write(sfmt, '(A,I2,A)') '(TL1,A,A',slen,',A,I3,A,I3,A)' else write(sfmt, '(A,I3,A)') '(TL1,A,A',slen,',A,I3,A,I3,A)' end if if (cols<10) then if (field_width<10) then write(fmt, '(A,I1,A,I1,A,I1,A)') '(', cols, field_code, field_width, '.', field_decimals, ')' else write(fmt, '(A,I1,A,I2,A,I1,A)') '(', cols, field_code, field_width, '.', field_decimals, ')' end if else if (cols<100) then if (field_width<10) then write(fmt, '(A,I2,A,I1,A,I1,A)') '(', cols, field_code, field_width, '.', field_decimals, ')' else write(fmt, '(A,I2,A,I2,A,I1,A)') '(', cols, field_code, field_width, '.', field_decimals, ')' end if else if (field_width<10) then write(fmt, '(A,I3,A,I1,A,I1,A)') '(', cols, field_code, field_width, '.', field_decimals, ')' else write(fmt, '(A,I3,A,I2,A,I1,A)') '(', cols, field_code, field_width, '.', field_decimals, ')' end if end if !write(*,'(TL1,A)') repeat('-', cols*field_width) print*,'' if (present(name)) then write(*,sfmt) 'Matrix ',trim(name),' (',rows, ' x ', cols, ') DP' else write(*,'(TL1,A,I3,A,I3,A)') 'Matrix (',rows, ' x ', cols, ') DP' end if write(*,'(TL1,A)') repeat('-', cols*field_width) do i=1,rows write(*,fmt) (A(i,j), j=1,cols) end do write(*,'(TL1,A)') repeat('-', cols*field_width) end subroutine print_matrix_d subroutine print_matrix_s(A, name) real(sp), intent(in) :: A(:,:) character(*), intent(in), optional :: name integer :: rows, cols, slen integer :: i, j character(255) :: fmt character(255) :: sfmt rows = size(A,1) cols = size(A,2) slen = len_trim(name) if (slen<10) then write(sfmt, '(A,I1,A)') '(TL1,A,A',slen,',A,I3,A,I3,A)' else if (slen<100) then write(sfmt, '(A,I2,A)') '(TL1,A,A',slen,',A,I3,A,I3,A)' else write(sfmt, '(A,I3,A)') '(TL1,A,A',slen,',A,I3,A,I3,A)' end if if (cols<10) then if (field_width<10) then write(fmt, '(A,I1,A,I1,A,I1,A)') '(', cols, field_code, field_width, '.', field_decimals, ')' else write(fmt, '(A,I1,A,I2,A,I1,A)') '(', cols, field_code, field_width, '.', field_decimals, ')' end if else if (cols<100) then if (field_width<10) then write(fmt, '(A,I2,A,I1,A,I1,A)') '(', cols, field_code, field_width, '.', field_decimals, ')' else write(fmt, '(A,I2,A,I2,A,I1,A)') '(', cols, field_code, field_width, '.', field_decimals, ')' end if else if (field_width<10) then write(fmt, '(A,I3,A,I1,A,I1,A)') '(', cols, field_code, field_width, '.', field_decimals, ')' else write(fmt, '(A,I3,A,I2,A,I1,A)') '(', cols, field_code, field_width, '.', field_decimals, ')' end if end if print*,'' if (present(name)) then write(*,sfmt) 'Matrix ',trim(name),' (',rows, ' x ', cols, ') SP' else write(*,'(TL1,A,I3,A,I3,A)') 'Matrix (',rows, ' x ', cols, ') SP' end if write(*,'(TL1,A)') repeat('-', cols*field_width) do i=1,rows write(*,fmt) (A(i,j), j=1,cols) end do write(*,'(TL1,A)') repeat('-', cols*field_width) end subroutine print_matrix_s subroutine print_vector_d(A, name) real(dp), intent(in) :: a(:) character(*), intent(in), optional :: name integer :: cols, slen integer :: i character(255) :: fmt character(255) :: sfmt cols = size(A,1) slen = len_trim(name) if (slen<10) then write(sfmt, '(A,I1,A)') '(TL1,A,A',slen,',A,I3,A,I3,A)' else if (slen<100) then write(sfmt, '(A,I2,A)') '(TL1,A,A',slen,',A,I3,A,I3,A)' else write(sfmt, '(A,I3,A)') '(TL1,A,A',slen,',A,I3,A,I3,A)' end if if (cols<10) then if (field_width<10) then write(fmt, '(A,I1,A,I1,A,I1,A)') '(', cols, field_code, field_width, '.', field_decimals, ')' else write(fmt, '(A,I1,A,I2,A,I1,A)') '(', cols, field_code, field_width, '.', field_decimals, ')' end if else if (cols<100) then if (field_width<10) then write(fmt, '(A,I2,A,I1,A,I1,A)') '(', cols, field_code, field_width, '.', field_decimals, ')' else write(fmt, '(A,I2,A,I2,A,I1,A)') '(', cols, field_code, field_width, '.', field_decimals, ')' end if else if (field_width<10) then write(fmt, '(A,I3,A,I1,A,I1,A)') '(', cols, field_code, field_width, '.', field_decimals, ')' else write(fmt, '(A,I3,A,I2,A,I1,A)') '(', cols, field_code, field_width, '.', field_decimals, ')' end if end if print*, '' if (present(name)) then write(*,sfmt) 'Vector ',trim(name),' (',cols,') DP' else write(*,'(TL1,A,I3,A)') 'Vector (',cols,')' end if write(*,'(TL1,A)') repeat('-', cols*field_width) write(*,fmt) (a(i), i=1,cols) write(*,'(TL1,A)') repeat('-', cols*field_width) end subroutine print_vector_d subroutine print_vector_s(A, name) real(sp), intent(in) :: a(:) character(*), intent(in), optional :: name integer :: cols, slen integer :: i character(255) :: fmt character(255) :: sfmt cols = size(A,1) slen = len_trim(name) if (slen<10) then write(sfmt, '(A,I1,A)') '(TL1,A,A',slen,',A,I3,A,I3,A)' else if (slen<100) then write(sfmt, '(A,I2,A)') '(TL1,A,A',slen,',A,I3,A,I3,A)' else write(sfmt, '(A,I3,A)') '(TL1,A,A',slen,',A,I3,A,I3,A)' end if if (cols<10) then if (field_width<10) then write(fmt, '(A,I1,A,I1,A,I1,A)') '(', cols, field_code, field_width, '.', field_decimals, ')' else write(fmt, '(A,I1,A,I2,A,I1,A)') '(', cols, field_code, field_width, '.', field_decimals, ')' end if else if (cols<100) then if (field_width<10) then write(fmt, '(A,I2,A,I1,A,I1,A)') '(', cols, field_code, field_width, '.', field_decimals, ')' else write(fmt, '(A,I2,A,I2,A,I1,A)') '(', cols, field_code, field_width, '.', field_decimals, ')' end if else if (field_width<10) then write(fmt, '(A,I3,A,I1,A,I1,A)') '(', cols, field_code, field_width, '.', field_decimals, ')' else write(fmt, '(A,I3,A,I2,A,I1,A)') '(', cols, field_code, field_width, '.', field_decimals, ')' end if end if print*, '' if (present(name)) then write(*,sfmt) 'Vector ',trim(name),' (',cols,') SP' else write(*,'(TL1,A,I3,A)') 'Vector (',cols,')' end if write(*,'(TL1,A)') repeat('-', cols*field_width) write(*,fmt) (a(i), i=1,cols) write(*,'(TL1,A)') repeat('-', cols*field_width) end subroutine print_vector_s subroutine rand_mat_d(A, randMin, randMax) real(dp), intent(inout) :: A(:,:) real(dp), intent(in) :: randMin, randMax call random_number(A) ! min ---- max A = randMin + (randMax-randMin) * A end subroutine rand_mat_d subroutine rand_mat_s(A, randMin, randMax) real(sp), intent(inout) :: A(:,:) real(sp), intent(in) :: randMin, randMax call random_number(A) ! min ---- max A = randMin + (randMax-randMin) * A end subroutine rand_mat_s subroutine rand_vec_d(a, randMin, randMax) real(dp), intent(inout) :: a(:) real(dp), intent(in) :: randMin, randMax call random_number(a) ! min ---- max a = randMin + (randMax-randMin) * a end subroutine rand_vec_d subroutine rand_vec_s(a, randMin, randMax) real(sp), intent(inout) :: a(:) real(sp), intent(in) :: randMin, randMax call random_number(a) ! min ---- max a = randMin + (randMax-randMin) * a end subroutine rand_vec_s subroutine init_rand() integer :: values(1:8), k integer, dimension(:), allocatable :: seed real(real64) :: r call date_and_time(values=values) call random_seed(size=k) allocate(seed(1:k)) seed(:) = values(8) call random_seed(put=seed) end subroutine end module mf_utils program arr_expr1 use mf_utils real(sp) :: a(10,20), b(10,20), c(10,20) real(sp) :: u(5), v(5) call init_rand() call set_print_format(10, 4, 'F') call rand_mat(a, 0.0_sp, 1.0_sp) call rand_mat(b, 1.0_sp, 10.0_sp) call rand_vec(v, 0.0_sp, 1.0_sp) c = a/b call print_matrix(a, 'a') call print_matrix(b, 'b') call print_matrix(c, 'c') u = v + 1.0_sp call print_vector(v, 'v') call print_vector(u, 'u') u = 5.0_sp/v + a(1:5,5) call print_vector(u, 'u') end program arr_expr1
Become a Patron
Sponsor on GitHub
Donate via PayPal
Compiler Explorer Shop
Source on GitHub
Mailing list
Installed libraries
Wiki
Report an issue
How it works
Contact the author
CE on Mastodon
CE on Bluesky
Statistics
Changelog
Version tree