dc-fukuoka / f03_exercise

fortran 2003 exercise, just for my study.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fortran 2003 exercise, just for my study.
like the following can be achieved.

type(matrix) :: a, b, c, d, e, f

a = matrix(size)
b = matrix(size)

call a%set_mat(-1.0d0, 1.0d0, 5555)
call b%set_mat(-2.0d0, 2.0d0, 7777)

c = a*b
d = c+a-b
e = d
f = c/b ! = c*b^-1
if (a == f) write(6, *) "A == F"

looks like python, simply use C++ is enough...?

$ make
ifort -c /opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/include/mkl_vsl.f90
ifort -warn all -g -O3 -mavx -fopenmp test.F90 -mkl
$ ./a.out
 size:           4
 A:
   6.71751E-01  -5.11412E-01   5.03268E-01  -5.15220E-01
  -1.42823E-01  -4.56335E-01   1.01004E-01  -7.82845E-01
  -7.78005E-01   9.79638E-01   7.61025E-01  -6.15416E-01
  -8.88567E-01  -5.99848E-01   3.96229E-01  -8.35100E-01
 B:
   1.26819E+00  -1.32831E-01  -3.12948E-01   1.46513E+00
  -1.44351E+00  -4.38352E-01   1.67454E-01  -1.87368E+00
   1.24615E-01  -1.73444E+00   2.32557E-01   1.59954E-03
  -7.00869E-01  -3.26451E-01   1.82880E+00   1.79528E+00
 C = A*B:
   2.01395E+00  -5.69746E-01  -1.12106E+00   1.01826E+00
   1.03885E+00   2.99381E-01  -1.43989E+00  -7.59494E-01
  -1.87461E+00  -1.44514E+00  -5.40970E-01  -4.07903E+00
   3.73684E-01  -3.36444E-02  -1.25745E+00  -1.67655E+00
 D = C+A-B:
   1.41751E+00  -9.48327E-01  -3.04840E-01  -9.62086E-01
   2.33954E+00   2.81399E-01  -1.50634E+00   3.31337E-01
  -2.77723E+00   1.26895E+00  -1.25025E-02  -4.69605E+00
   1.85987E-01  -3.07041E-01  -2.69002E+00  -4.30693E+00
 E = D
   1.41751E+00  -9.48327E-01  -3.04840E-01  -9.62086E-01
   2.33954E+00   2.81399E-01  -1.50634E+00   3.31337E-01
  -2.77723E+00   1.26895E+00  -1.25025E-02  -4.69605E+00
   1.85987E-01  -3.07041E-01  -2.69002E+00  -4.30693E+00
 F = C/B (=A)
   6.71751E-01  -5.11412E-01   5.03268E-01  -5.15220E-01
  -1.42823E-01  -4.56335E-01   1.01004E-01  -7.82845E-01
  -7.78005E-01   9.79638E-01   7.61025E-01  -6.15416E-01
  -8.88567E-01  -5.99848E-01   3.96229E-01  -8.35100E-01
 maximum error is   3.552713678800501E-015
 A == F

About

fortran 2003 exercise, just for my study.


Languages

Language:Fortran 96.4%Language:Makefile 3.6%