program swapmain
implicit none
real :: a, b
! Read in two values
read(*,*) a, b
call swap(a,b)
write(*,*) a,b
contains
subroutine swap(x, y)
real :: x, y, temp
temp = x
x = y
y = temp
end subroutine swap
end program swapmain
program set
implicit none
real :: a, b
! Read in value of a
read(*,*) a
call setval(b)
write(*,*) b
contains
subroutine setval(x)
real :: x
x = a ! value of a is from main program
end subroutine setval
end program set
Uni. Of Cambridge
Dep. Of Physics
Computational Physics
Self-study guide 2
Programming in Fortran 95
Thanks to Dr. Rachael Padman and Michaelmas for allowing the citation.
참고사이트 https://www.mrao.cam.ac.uk/~rachael/compphys/SelfStudyF95.pdf
#fortran #Dr._Rachael_Padman_and_Michaelmas #fortran_tutorial #vfun #NAG_Fortran #FTN95