- 积分
- 0
- 注册时间
- 2006-11-16
- 仿真币
-
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2013-7-25 04:25:55
|
显示全部楼层
来自 德国
版主说的对,但是我觉得理论的东西都需要看书,论坛里面可以讨论点什么就可以了,没法系统的介绍很多。
博客里有一篇文章,适合放在这里,关于Fortran面向对象的编程,看看有没有人看兴趣
Fortran面向对象编程,节点类,示例
http://blog.sina.com.cn/s/blog_609af0750101c09y.html
一个简化的模块,定义节点类。不做解释,具体功能参考书籍。
使用的话,首先用use,然后通过下面的命令来测试,生成一个节点对象,保存数组里面。
node(1) = create_node(999,(/12.D0,13.D0,14.D0/))
call node(1)%SetCoord((/13.D0,13.D0,13.D0/))
write(88,*) node(1)%GetCoord
定义节点的模块:
******************************************************************************
module ktClassNode
Implicit none
!private
! Object public Methode
public :: newNode
integer :: NumOfNode
! Object Class
type NodeType
integer :: nr=0
real(8),dimension(6) :: x=zero
contains
procedure :: GetCoord
procedure :: SetCoord
end type NodeType
! Object constructor
interface newNode
module procedure create_node
end interface
! Object node
type(NodeType),allocatable,dimension( :: node
contains
! Node Methode
Type(NodeType) function create_node(nr,x,pin)
integer,intent(in) :: nr
real(8),intent(in) :: x(3) ! only Translation
character(len=6),intent(in) ,optional :: pin
create_node%Nr = nr
create_node%x(1:3) = x(1:3)
end function create_node
! Node Methode
function GetCoord(this)
class(NodeType) :: this
real(8) :: GetCoord(3) ! only Translation
GetCoord(1:3) = this%x0(1:3)
return
end function GetCoord
! Node Methode
subroutine SetCoord (this,x0)
class(NodeType) :: this
real(8),intent(in) :: x0(3) ! only Translation
this%x0(1:3) =x0(1:3)
end subroutine SetCoord
end Module |
|