==mat_wpofa.f90 processed by SPAG 8.01RF 01:46 13 Dec 2024
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real128), | intent(in) | :: | a1(..) | |||
real(kind=real128) | :: | a2(..) |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real64), | intent(in) | :: | a1(..) | |||
real(kind=real64) | :: | a2(..) |
elementcopy(3f) - [M_LA] copy elements from IN to OUT regardless
of rank until hit end of one of them
Subroutine elementcopy (IN, OUT)
${TYPE} (kind=${KIND}), Intent (In) :: IN(..)
${TYPE} (kind=${KIND}) :: OUT(..)
Where ${TYPE}(kind=${KIND}) may be
o Real(kind=real32)
o Real(kind=real64)
o Real(kind=real128)
o Integer(kind=int8)
o Integer(kind=int16)
o Integer(kind=int32)
o Integer(kind=int64)
Copy the elements from scalar or array IN to array or scalar OUT
until either the end of IN or OUT is reached, regardless of rank
of the arguments.
IN input array or scalar
OUT output array or scalar
Sample program:
program demo_elementcopy
use m_la, only : elementcopy
implicit none
character(len=*),parameter :: g='(*(g0:,","))'
real :: b, b1(3), b2(2,3), b3(2,2,2)
real :: c8(8), c6(6), c3(3), c
integer :: ib, ib1(3), ib2(2,3), ib3(2,2,2)
integer :: ic8(8), ic6(6), ic3(3), ic
! default real
call elementcopy(100.0,b)
write(*,g)'b',b
call elementcopy([1.0,2.0,3.0],b1)
write(*,g)'b1',b1
call elementcopy(reshape([1.0,2.0,3.0,4.0,5.0,6.0],[2,3]),b2)
write(*,g)'b2',b2
call elementcopy(reshape([1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0],[2,2,2]),b3)
write(*,g)'b3',b3
call elementcopy(b3,c8) ! pack
write(*,g)'c8',c8
call elementcopy(b3*10,c3) ! smaller
write(*,g)'c3',c3
call elementcopy(pack(b3*111.0,.true.),b) ! to scalar
write(*,g)'b',b
c6=-999.0
call elementcopy(b1*10,c6) ! bigger
write(*,g)'c6',c6
call elementcopy(b3(2:,2,2),c) ! to scalar from vector
write(*,g)'c',c
call elementcopy(b3(2,1,1),c) ! to scalar from element
write(*,g)'c',c
call elementcopy(b3,c) ! to scalar
write(*,g)'c',c
! default integer
call elementcopy(100,ib)
write(*,g)'ib',ib
call elementcopy([1,2,3],ib1)
write(*,g)'ib1',ib1
call elementcopy(reshape([1,2,3,4,5,6],[2,3]),ib2)
write(*,g)'ib2',ib2
call elementcopy(reshape([1,2,3,4,5,6,7,8],[2,2,2]),ib3)
write(*,g)'ib3',ib3
call elementcopy(ib3,ic8) ! pack
write(*,g)'ic8',ic8
call elementcopy(ib3*10,ic3) ! smaller
write(*,g)'ic3',ic3
call elementcopy(pack(ib3*111,.true.),ib) ! to scalar
write(*,g)'ib',ib
ic6=-999
call elementcopy(ib1*10,ic6) ! bigger
write(*,g)'ic6',ic6
call elementcopy(ib3(2:,2,2),ic) ! to scalar from vector
write(*,g)'ic',ic
call elementcopy(ib3(2,1,1),ic) ! to scalar from element
write(*,g)'ic',ic
call elementcopy(ib3,ic) ! to scalar
write(*,g)'ic',ic
!
tesseract: block
integer :: box(2,3,4,5)
integer :: i
call elementcopy([(i,i=1,size(box))],box)
write(*,g)'box',box
endblock tesseract
end program demo_elementcopy
Results:
b,100.0000
b1,1.00000,2.00000,3.00000
b2,1.00000,2.00000,3.00000,4.00000,5.00000,6.00000
b3,1.00000,2.00000,3.00000,4.00000,5.00000,6.00000,7.00000,8.00000
c8,1.00000,2.00000,3.00000,4.00000,5.00000,6.00000,7.00000,8.00000
c3,10.0000,20.0000,30.0000
b,111.0000
c6,10.00000,20.00000,30.00000,-999.0000,-999.0000,-999.0000
c,8.000000
c,2.000000
c,1.000000
ib,100
ib1,1,2,3
ib2,1,2,3,4,5,6
ib3,1,2,3,4,5,6,7,8
ic8,1,2,3,4,5,6,7,8
ic3,10,20,30
ib,111
ic6,10,20,30,-999,-999,-999
ic,8
ic,2
ic,1
box,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,
19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,
36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,
53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,
70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,
87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,
103,104,105,106,107,108,109,110,111,112,113,114,115,116,
117,118,119,120
John S. Urban, 2022.05.07
CC0-1.0
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real32), | intent(in) | :: | a1(..) | |||
real(kind=real32) | :: | a2(..) |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=int64), | intent(in) | :: | a1(..) | |||
integer(kind=int64) | :: | a2(..) |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=int32), | intent(in) | :: | a1(..) | |||
integer(kind=int32) | :: | a2(..) |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=int16), | intent(in) | :: | a1(..) | |||
integer(kind=int16) | :: | a2(..) |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=int8), | intent(in) | :: | a1(..) | |||
integer(kind=int8) | :: | a2(..) |
linspace(3f) - [M_LA] return a vector of linearly spaced values
function linspace(x1,x2,n)
integer,intent(in) :: n
${TYPE}(kind=${KIND}),intent(in) :: x1,x2
${TYPE}(kind=${KIND}) :: linspace
Where ${TYPE} may be real or integer and ${KIND} may be any
supported kind for the corresponding type.
Common usage:
y = linspace(x1,x2)
y = linspace(x1,x2,n)
linspace returns a vector of linearly spaced values from x1 to
x2 inclusive. It gives direct control over the number of points
and always includes the endpoints, the results being the same as
[(x1+i*(x2-x1)/(n-1),i=0,n-1)] if n>1 and [x1,x2] if n<=1.
X1,X2 X1 and X2 are the upper and lower bound of the values
returned. The options can be of type REAL or INTEGER,
but must be of the same type.
N number of values to return
LINSPACE The returned row vector starts with X1 and ends with X2,
returning N evenly spaced values.
Sample program:
program demo_linspace
use M_LA, only : linspace
implicit none
character(len=*), parameter :: gen='(*(g0, 1x))'
write( *, gen ) linspace( 0, 9, 10 )
write( *, gen ) linspace( 10.0, 20.0, 11 )
write( *, gen ) linspace( 11.1d0, 12.1d0, 5 )
write( *, gen ) linspace( 11.1, 12.1, 5 )
end program demo_linspace
Results: 0 1 2 3 4 5 6 7 8 9 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 11.1000000000 11.3500000000 11.6000000000 11.8500000000 12.100000000 11.1000004 11.3500004 11.6000004 11.8500004 12.1000004
Results:
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real128), | intent(in) | :: | x1 | |||
real(kind=real128), | intent(in) | :: | x2 | |||
integer, | intent(in) | :: | n |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real64), | intent(in) | :: | x1 | |||
real(kind=real64), | intent(in) | :: | x2 | |||
integer, | intent(in) | :: | n |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real32), | intent(in) | :: | x1 | |||
real(kind=real32), | intent(in) | :: | x2 | |||
integer, | intent(in) | :: | n |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=int64), | intent(in) | :: | x1 | |||
integer(kind=int64), | intent(in) | :: | x2 | |||
integer, | intent(in) | :: | n |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=int32), | intent(in) | :: | x1 | |||
integer(kind=int32), | intent(in) | :: | x2 | |||
integer, | intent(in) | :: | n |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=int16), | intent(in) | :: | x1 | |||
integer(kind=int16), | intent(in) | :: | x2 | |||
integer, | intent(in) | :: | n |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=int8), | intent(in) | :: | x1 | |||
integer(kind=int8), | intent(in) | :: | x2 | |||
integer, | intent(in) | :: | n |
!GFORTRAN BUG in 8.3 !real,save :: mas(2,14)=reshape([ & ! & real(Z’ffffffff’,kind=kind(0.0)),real(Z’fff0ffff’,kind=kind(0.0)), & ! & real(Z’ffffffff’,kind=kind(0.0)),real(Z’ff00ffff’,kind=kind(0.0)), & ! & real(Z’ffffffff’,kind=kind(0.0)),real(Z’f000ffff’,kind=kind(0.0)), & ! & real(Z’ffffffff’,kind=kind(0.0)),real(Z‘0000ffff’,kind=kind(0.0)), & ! & real(Z’ffffffff’,kind=kind(0.0)),real(Z‘0000fff0’,kind=kind(0.0)), & ! & real(Z’ffffffff’,kind=kind(0.0)),real(Z‘0000ff00’,kind=kind(0.0)), & ! & real(Z’ffffffff’,kind=kind(0.0)),real(Z‘0000f000’,kind=kind(0.0)), & ! & real(Z’ffffffff’,kind=kind(0.0)),real(Z‘00000000’,kind=kind(0.0)), & ! & real(Z’fff0ffff’,kind=kind(0.0)),real(Z‘00000000’,kind=kind(0.0)), & ! & real(Z’ff00ffff’,kind=kind(0.0)),real(Z‘00000000’,kind=kind(0.0)), & ! & real(Z’f000ffff’,kind=kind(0.0)),real(Z‘00000000’,kind=kind(0.0)), & ! & real(Z‘0000ffff’,kind=kind(0.0)),real(Z‘00000000’,kind=kind(0.0)), & ! & real(Z‘0000fff0’,kind=kind(0.0)),real(Z‘00000000’,kind=kind(0.0)), & ! & real(Z‘0000ff80’,kind=kind(0.0)),real(Z‘00000000’,kind=kind(0.0))],shape(mas))
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
doubleprecision, | intent(in) | :: | x |
|
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | n | ||||
doubleprecision | :: | xr(*) | ||||
doubleprecision | :: | xi(*) | ||||
integer | :: | incx |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
doubleprecision | :: | a | ||||
doubleprecision | :: | b |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
doubleprecision | :: | x |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | n | ||||
doubleprecision | :: | xr(*) | ||||
doubleprecision | :: | xi(*) | ||||
integer | :: | incx |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | n | ||||
doubleprecision | :: | xr(*) | ||||
doubleprecision | :: | xi(*) | ||||
integer | :: | incx | ||||
doubleprecision | :: | yr(*) | ||||
doubleprecision | :: | yi(*) | ||||
integer | :: | incy |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | n | ||||
doubleprecision | :: | xr(*) | ||||
doubleprecision | :: | xi(*) | ||||
integer | :: | incx | ||||
doubleprecision | :: | yr(*) | ||||
doubleprecision | :: | yi(*) | ||||
integer | :: | incy |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | n | ||||
doubleprecision | :: | xr(*) | ||||
doubleprecision | :: | xi(*) | ||||
integer | :: | incx | ||||
doubleprecision | :: | yr(*) | ||||
doubleprecision | :: | yi(*) | ||||
integer | :: | incy |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | n | |||
doubleprecision | :: | xr(*) | ||||
doubleprecision | :: | xi(*) | ||||
integer | :: | incx | ||||
doubleprecision | :: | yr(*) | ||||
doubleprecision | :: | yi(*) | ||||
integer | :: | incy |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | n | ||||
doubleprecision | :: | xr(*) | ||||
doubleprecision | :: | xi(*) | ||||
integer | :: | incx |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
doubleprecision, | intent(out) | :: | a(lda,n) | |||
integer, | intent(in) | :: | lda | |||
integer, | intent(in) | :: | n |
mat_magic(3f) - [M_LA] create an N x N magic square array, N>2
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
doubleprecision | :: | a(rows,n) | ||||
integer, | intent(in) | :: | rows | |||
integer, | intent(in) | :: | n |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
doubleprecision | :: | x | ||||
integer | :: | len | ||||
integer | :: | maxd | ||||
doubleprecision | :: | a | ||||
doubleprecision | :: | b | ||||
doubleprecision | :: | d(len) |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
doubleprecision | :: | ar(lda,*) | ||||
doubleprecision | :: | ai(lda,*) | ||||
integer, | intent(in) | :: | lda | |||
integer | :: | m | ||||
integer | :: | n | ||||
doubleprecision | :: | eps |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | n | ||||
doubleprecision | :: | dx(*) | ||||
integer | :: | incx | ||||
doubleprecision | :: | dy(*) | ||||
integer | :: | incy | ||||
doubleprecision | :: | c | ||||
doubleprecision | :: | s |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
doubleprecision | :: | da | ||||
doubleprecision | :: | db | ||||
doubleprecision | :: | c | ||||
doubleprecision | :: | s |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | n | ||||
doubleprecision | :: | dx | ||||
doubleprecision | :: | dy(*) | ||||
integer | :: | incy |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | n | ||||
doubleprecision | :: | x(*) | ||||
integer | :: | incx | ||||
doubleprecision | :: | y(*) | ||||
integer | :: | incy |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
doubleprecision | :: | xr | ||||
doubleprecision | :: | xi | ||||
doubleprecision | :: | yr | ||||
doubleprecision | :: | yi |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | number_of_values | |||
doubleprecision, | intent(in) | :: | xr(*) | |||
doubleprecision, | intent(in) | :: | xi(*) | |||
integer, | intent(in) | :: | incx | |||
doubleprecision, | intent(out) | :: | yr(*) | |||
doubleprecision, | intent(out) | :: | yi(*) | |||
integer, | intent(in) | :: | incy |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
doubleprecision | :: | ar | ||||
doubleprecision | :: | ai | ||||
doubleprecision | :: | br | ||||
doubleprecision | :: | bi | ||||
doubleprecision | :: | cr | ||||
doubleprecision | :: | ci |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
doubleprecision | :: | in_real | ||||
doubleprecision | :: | in_imag | ||||
doubleprecision | :: | out_real | ||||
doubleprecision | :: | out_imag |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
doubleprecision, | intent(in) | :: | ar | |||
doubleprecision, | intent(in) | :: | ai | |||
doubleprecision, | intent(in) | :: | br | |||
doubleprecision, | intent(in) | :: | bi | |||
doubleprecision, | intent(out) | :: | cr | |||
doubleprecision, | intent(out) | :: | ci |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
double precision | :: | ar(lda,*) | ||||
double precision | :: | ai(lda,*) | ||||
integer | :: | lda | ||||
integer | :: | n | ||||
integer | :: | info |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
doubleprecision, | intent(in) | :: | in_real | |||
doubleprecision, | intent(in) | :: | in_imag | |||
doubleprecision, | intent(out) | :: | out_real | |||
doubleprecision, | intent(out) | :: | out_imag | |||
doubleprecision, | intent(in) | :: | power_real | |||
doubleprecision, | intent(in) | :: | power_imag |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | n | ||||
doubleprecision | :: | s | ||||
doubleprecision | :: | xr(*) | ||||
doubleprecision | :: | xi(*) | ||||
integer | :: | incx |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | n | |||
doubleprecision, | intent(in) | :: | sr | |||
doubleprecision, | intent(in) | :: | si | |||
doubleprecision | :: | xr(*) | ||||
doubleprecision | :: | xi(*) | ||||
integer | :: | incx |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | n | |||
doubleprecision, | intent(in) | :: | xr | |||
doubleprecision, | intent(in) | :: | xi | |||
doubleprecision | :: | yr(*) | ||||
doubleprecision | :: | yi(*) | ||||
integer | :: | incy |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
doubleprecision | :: | xr | ||||
doubleprecision | :: | xi | ||||
doubleprecision | :: | yr | ||||
doubleprecision | :: | yi | ||||
doubleprecision | :: | zr | ||||
doubleprecision | :: | zi |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
doubleprecision, | intent(in) | :: | x_real | |||
doubleprecision, | intent(in) | :: | x_imag | |||
doubleprecision, | intent(out) | :: | y_real | |||
doubleprecision, | intent(out) | :: | y_imag |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer | :: | n | ||||
doubleprecision | :: | xr(*) | ||||
doubleprecision | :: | xi(*) | ||||
integer | :: | incx | ||||
doubleprecision | :: | yr(*) | ||||
doubleprecision | :: | yi(*) | ||||
integer | :: | incy |