编辑代码

module header
    implicit none
    
    type ::var
        real :: test1
        real :: test2
    end type var

    type(var) :: test_var

end module header

module nested_type_example
    use header ,only : test_var
    implicit none

contains

    subroutine cal_test(num1,num2)
        real(8),intent(in) :: num1,num2
        test_var%test1 = num1+num2
        test_var%test2 = num1-num2
    end subroutine
  
end module nested_type_example

program main
    use nested_type_example
    use header ,only : test_var
    implicit none
    
    real(8) :: id1,id2

    id1 = 10.5
    id2 = 3.5
    print *, "Hello  JSRUN   -- from gfrotran"
    test_var%test1 = id1
    test_var%test2 = id2
    print*, test_var%test1,test_var%test2
    
    print *, "Hello  JSRUN    - from gfrotran"
    call cal_test(id1,id2)
    print*, test_var%test1,test_var%test2


end program main