Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
COMPLEX a(10,10)
a(1,1) = CMPLX(123,456)
print *,'left part=',REAL(a(1,1))
print *,'right part=',AIMAG(a(1,1))
module ModPair
implicit none
! Pair of values
type::Pair
integer::mVal1
integer::mVal2
end type Pair
! Limits of array
integer, parameter:: &
ROWMAX = 100, &
COLMAX = 100
! Declare an array of Pair
type (Pair), dimension(ROWMAX,COLMAX)::a
contains
! Set values
subroutine PairSet (r, c, v1, v2)
integer, intent(in):: r, c, v1, v2
a(r,c)%mVal1 = v1
a(r,c)%mVal2 = v2
return
end subroutine PairSet
! Get Value
function PairGetV1 (r,c)
integer::PairGetV1
integer, intent(in):: r, c
PairGetV1 = a(r,c)%mVal1
return
end function PairGetV1
! Get Value
function PairGetV2 (r,c)
integer::PairGetV2
integer, intent(in)::r, c
PairGetV2 = a(r,c)%mVal2
return
end function PairGetV2
end module ModPair
program PrgPair
use ModPair
implicit none
! Set some values
call PairSet (1, 1, 123, 456)
call PairSet (1, 2, 789, 124)
! Retrieve the values
write(*,*) PairGetV1(1,1)
write(*,*) PairGetV2(1,2)
stop
end program PrgPair