import4.f90
来自「用于进行gcc测试」· F90 代码 · 共 100 行
F90
100 行
! { dg-do run }! Test for import in modules! PR fortran/29601subroutine bar(r) implicit none integer(8) :: r if(r /= 42) call abort() r = 13end subroutine barsubroutine foo(a) implicit none type myT sequence character(len=3) :: c end type myT type(myT) :: a if(a%c /= "xyz") call abort() a%c = "abc"end subroutinesubroutine new(a,b) implicit none type gType sequence integer(8) :: c end type gType real(8) :: a type(gType) :: b if(a /= 99.0 .or. b%c /= 11) call abort() a = -123.0 b%c = -44end subroutine newmodule general implicit none integer,parameter :: ikind = 8 type gType sequence integer(ikind) :: c end type gTypeend module generalmodule modtest use general implicit none type myT sequence character(len=3) :: c end type myT integer, parameter :: dp = 8 interface subroutine bar(x) import :: dp integer(dp) :: x end subroutine bar subroutine foo(c) import :: myT type(myT) :: c end subroutine foo subroutine new(x,y) import :: ikind,gType real(ikind) :: x type(gType) :: y end subroutine new end interface contains subroutine test integer(dp) :: y y = 42 call bar(y) if(y /= 13) call abort() end subroutine test subroutine test2() type(myT) :: z z%c = "xyz" call foo(z) if(z%c /= "abc") call abort() end subroutine test2end module modtestprogram all use modtest implicit none call test() call test2() call test3()contains subroutine test3() real(ikind) :: r type(gType) :: t r = 99.0 t%c = 11 call new(r,t) if(r /= -123.0 .or. t%c /= -44) call abort() end subroutine test3end program all! { dg-final { cleanup-modules "modtest general" } }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?