Skip to content

Instantly share code, notes, and snippets.

@cbcoutinho
Created February 6, 2017 20:44
Show Gist options
  • Save cbcoutinho/cf22a60c971d4d4fa9330c064121ba18 to your computer and use it in GitHub Desktop.
Save cbcoutinho/cf22a60c971d4d4fa9330c064121ba18 to your computer and use it in GitHub Desktop.
module mod
use iso_fortran_env, only: wp=>real64
implicit none
private
public :: myfun
interface myfun
module function fun1(n, x) result(y)
integer, intent(in) :: n
real(wp), intent(in) :: x
real(wp), dimension(n) :: y
end function fun1
end interface myfun
end module mod
submodule (mod) submod
use iso_fortran_env, only: wp=>real64
implicit none
contains
module function fun1(n, x) result(y)
integer, intent(in) :: n
real(wp), intent(in) :: x
real(wp), dimension(n) :: y
y = x * 2.d0
end function fun1
! module procedure fun1
!
! y = x * 2.d0
!
! end procedure fun1
end submodule submod
program main
use mod, only: myfun
use iso_fortran_env, only: wp=>real64
implicit none
integer :: n = 2
print*, myfun(n, 1.d0)
end program main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment