Quantcast
Channel: Intel® Fortran Compiler
Viewing all articles
Browse latest Browse all 3270

error #8339: dummy argument of a final subroutine cannot be...

$
0
0

Hello all.

Trying to learn how to do OOP with Fortran, and receiving " error #8339: The dummy argument of a final subroutine must be a variable of the derived type being defined and cannot be optional, pointer, allocatable, or polymorphic.   [THIS]  " when trying to run a modified example of S.C.Chapman "Fortran 95/2003 for Scientists and Engineers" (3rd edition), about how to use finalizers (in page 790). I was trying to change the real vector class in that example by a character string class (same error with the real vector in the book), to add some methods afterwards, and to see if I was able to emulate the behavior of string classes in other languages. The book warns the code in the example might not work in the Fortran compilers available by that time. Code is attached. I am using Intel Compiler XE v14 SP1.

Any advice?

Thanks and regards.

   module class_string
   implicit none
   type, public :: string
      character, dimension(:), pointer :: text
      logical :: is_allocated = .false.
   contains
      final :: clean_text
   end type
   contains
      subroutine clean_text(this)
         class(string) :: this
         integer :: istat
         if (this%is_allocated) then
            deallocate(this%text, stat=istat)
         end if
      end subroutine
   end module

Viewing all articles
Browse latest Browse all 3270

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>