Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Fortran subModule for OOP methods

Masrul
Beginner
869 Views
 

Dear All:
I am trying subModule for OOP methods in Fortran as test case. Followings are code snippets:

Module:

Module declarations
    type::Car
        character(len=10)::Name
        character(len=10)::Make
        contains
          procedure::print=>Print_CarInfo
    end type Car

    interface
        module subroutine Print_CarInfo(self)
            class(Car)::self
        end subroutine
    end interface
End Module declarations

subModule:

subModule (declarations) definitions
  contains
    module subroutine Print_CarInfo(self)
        class(Car)::self
        print*,self%Name
        print*,self%Make
    end subroutine Print_CarInfo
end subModule definitions

mainProgram:

program testOOP
    use declarations
    type(Car)::MyFirstCar

    MyFirstCar%Name='MyCar'
    MyFirstCar%Make='Hyundai'
    call MyFirstCar%print()
end program testOOP

Compile Note: ifort module.f90 submodule.f90 main.f90

Error:

Undefined symbols for architecture x86_64:
  "_declarations_mp_print_", referenced from:
      _MAIN__ in iforteEEioN.o
     (maybe you meant: _declarations_mp_print_carinfo_)
ld: symbol(s) not found for architecture x86_64

But same things compiled correctly with gfortran-6 and output as expected. By the way i am using ifort-18

Thanks in Advance,

Masrul

 

 

0 Kudos
1 Reply
Lorri_M_Intel
Employee
869 Views

There's a known bug in 18.0 provoked by this line in your first program:

procedure::print=>Print_CarInfo

Unfortunately, the compiler was creating an external reference to a routine with the name "print".

This has been fixed for a future update.

          Sorry for the inconvenience --

                         --Lorri

0 Kudos
Reply