Have a block import only some entities from host?

You do it in F2018 like this:

program main
  implicit none
  integer :: x, y, z
  block
    import, only: x, y
    print *,x  ! valid
    print *,z  ! not valid due to import
  end block
end program main

ifort accepts the import statement but gfortran does not (per the bug linked by @kargl).

1 Like