Skip to content

Instantly share code, notes, and snippets.

@pletnes
Last active April 4, 2016 07:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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

% for fc in gcc intel nag pgi; do echo "---------- Compiler: $fc" ; make $fc; done                                                                          [paul@bender.sintef.no]
---------- Compiler: gcc
gcc --version
gcc (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

gfortran -Wall -Wextra -fcheck=all intertest.f90 -o intertest-gcc
./intertest-gcc
 If this prints 3.14, all is OK:    3.14000010
---------- Compiler: intel
ifort -V
Intel(R) Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 16.0.2.181 Build 20160204
Copyright (C) 1985-2016 Intel Corporation.  All rights reserved.

ifort -warn -check intertest.f90 -o intertest-intel
./intertest-intel
 If this prints 3.14, all is OK:    3.140000
---------- Compiler: nag
nagfor -V
NAG Fortran Compiler Release 6.0(Hibiya) Build 1057
Product NPL6A60NA for x86-64 Linux
Copyright 1990-2015 The Numerical Algorithms Group Ltd., Oxford, U.K.
nagfor intertest.f90 -o intertest-nag
NAG Fortran Compiler Release 6.0(Hibiya) Build 1057
Error: intertest.f90, line 11: Syntax error
       detected at PROCEDURE@::
[NAG Fortran Compiler pass 1 error termination, 1 error]
Makefile:16: recipe for target 'nag' failed
make: *** [nag] Error 2
---------- Compiler: pgi
pgfortran -V

pgfortran 15.7-0 32-bit target on x86-64 Linux -tp sandybridge
The Portland Group - PGI Compilers and Tools
Copyright (c) 2015, NVIDIA CORPORATION.  All rights reserved.
pgfortran -Minform=inform -Mbounds intertest.f90 -o intertest-pgi
PGF90-S-0034-Syntax error at or near :: (intertest.f90: 11)
  0 inform,   0 warnings,   1 severes, 0 fatal for intertest
Makefile:6: recipe for target 'pgi' failed
make: *** [pgi] Error 2

@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