Silverfrost Forums

Welcome to our forums

Import in 7.1

13 Jun 2014 7:36 #14172

In the list of changes for 7.1 there are the following items: The IMPORT statement has been added as part of the Fortran 2003 standard.

The /ISO command line option previously did not generate an error report when a TYPE or PARAMETER within an INTERFACE was inherited from the host. Can you conform whether the IMPORT statement is implemented, or if it is just allowed syntax but ignored?

The fact that an interface would inherit TYPE and PARAMETERS from its host meant that IMPORT was effectively the default in version 7.00. It is possible that you have utilised this and have fully implemented IMPORT. However, there was some discussion here about just accepting the syntax but not do anything.

13 Jun 2014 2:50 #14176

My intention was to implement IMPORT. If there are any deficiencies then please let me know.

13 Jun 2014 4:24 #14187

Thanks Paul.

I will try it out when I have time to do so. It is a useful extension to have I think.

9 Aug 2014 7:30 #14433

Success!

[u:1a418c3b2b]Standard extension[/u:1a418c3b2b] The code below works with the IMPORT statement and /F2K enabled in Version 7.10 😃

[u:1a418c3b2b]Non standard extension[/u:1a418c3b2b] Note that as a non-standard extension you can still omit the import and parameter declaration lines and it does host association (i.e. it seems to import whatever it needs from the host to maintain linkage). It would have been nice to have a NON_STANDARD warning in such cases that could be switched off with /NON_STANDARD but I am happy with it as it is.

Note that using /ISO doesn't seem to produce the error message for this non-standard extension as indicated in the release notes.

David.

module mod

   integer, parameter :: dp = kind(1.0d0)
   
contains

   subroutine test(fnc, x, y)

      ! Interface defining fnc dummay argument
      interface
         function fnc(x)
            ! F2000 extension needs /F2K
            import dp
            ! F95 needs to redeclare dp as it isn't accessible by 'host' association
            ! integer, parameter :: dp = kind(1.0d0)
            real(kind=dp), intent(in) :: x
            real(kind=dp) :: fnc
         end function fnc
      end interface
      
      real(kind=dp), intent(in) :: x
      real(kind=dp), intent(out) :: y
      
      y = fnc(x)
   end subroutine test
   
   function fnc(x)
      real(kind=dp), intent(in) :: x
      real(kind=dp) :: fnc
      fnc = x
   end function fnc
   
end module mod

program anon

   use mod
   real(kind=dp) :: y
   call test(fnc, 1.0d0, y)
   print *, y, '<-- should print 1.0 and is!'
   
end program anon
10 Aug 2014 7:49 #14437

Thanks. I have logged this for further investigation.

Please login to reply.