Skip to content

Instantly share code, notes, and snippets.

@pletnes
Last active April 4, 2016 07:57
Show Gist options
  • Save pletnes/ba5178b5e89f92a07ae2d024d5bf456f to your computer and use it in GitHub Desktop.
Save pletnes/ba5178b5e89f92a07ae2d024d5bf456f to your computer and use it in GitHub Desktop.
Makefile and code - illegal fortran syntax?
.PHONY: all pgi intel gcc nag clean
all: gcc intel nag pgi
pgi:
pgfortran -V
pgfortran -Minform=inform -Mbounds intertest.f90 -o intertest-pgi
./intertest-pgi
intel:
ifort -V
ifort -warn -check intertest.f90 -o intertest-intel
./intertest-intel
nag:
nagfor -V
nagfor intertest.f90 -o intertest-nag
./intertest-nag
gcc:
gcc --version
gfortran -Wall -Wextra -fcheck=all intertest.f90 -o intertest-gcc
./intertest-gcc
clean:
rm -f *.mod intertest-pgi intertest-gcc intertest-intel
@pletnes
Copy link
Author

pletnes commented Apr 4, 2016

module intertest
    implicit none

    type beta
        real :: val
    end type beta

    interface beta
        module procedure :: beta_constructor
    end interface beta

contains

    function beta_constructor(val) result(this)
        implicit none
        type(beta) :: this
        real, intent(in) :: val

        this%val = val
    end function beta_constructor

end module intertest


program test_interface
    use intertest
    implicit none

    type(beta) :: b

    b = beta(3.14)
    print *, "If this prints 3.14, all is OK: ", b%val
end program test_interface

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment