主题:[讨论]大量子程序文件的接口,怎么缩减?
subroutine文件较多时怎样写接口比较好一点?用interface还是module?
比如这一段程序
Program main implicit none interface head !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! subroutine CreateNode(ModelLenth,ModelHeight, & ModelCelLenth,ModelCelHeight, & CrackLenth,CrackHeight, & CrackCelLenth,CrackCelHeight, & XNodeNum,YNodeNum,NodeNum, & CrackNodeNum,CrackRightNodeNum, & BodyNode,CrackNode,ModelNode) implicit none real*8,intent(in):: ModelLenth,ModelHeight, & !模型半长和半高 ModelCelLenth,ModelCelHeight, & !Y方向正中间两个节点距离的半高 CrackLenth,CrackHeight, & !初始裂纹半长和裂纹宽 CrackCelLenth,CrackCelHeight !裂纹单元尺寸 integer,intent(in):: XNodeNum,YNodeNum,NodeNum, & !X方向节点数,Y方向节点数,总结点数 CrackNodeNum,CrackRightNodeNum !裂纹从x=0到裂尖的总结点数,裂纹右侧节点数 real*8,intent(out),dimension(:,:):: BodyNode, & !基体节点和坐标 CrackNode, & !裂纹节点和坐标 ModelNode !整体模型节点和坐标 end subroutine CreateNode !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! subroutine WriteNode(node) implicit none real*8,intent(in),dimension(:,:):: node end subroutine WriteNode !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! end interface head real*8:: ModelLenth,ModelHeight, & !模型半长和半高 ModelCelLenth,ModelCelHeight, & !Y方向正中间两个节点距离的半高 CrackLenth,CrackHeight, & !初始裂纹半长和裂纹宽 CrackCelLenth,CrackCelHeight !裂纹单元尺寸 integer:: XNodeNum,YNodeNum,NodeNum, & !X方向节点数,Y方向节点数,总结点数 CrackNodeNum,CrackRightNodeNum, & !裂纹从x=0到裂尖的总结点数,裂纹右侧节点数 i,j,k,l,m,n !循环参数 real*8,allocatable:: BodyNode(:,:), & !基体节点和坐标 CrackNode(:,:), & !裂纹节点和坐标 ModelNode(:,:) !整体模型节点和坐标 CrackLenth=40.0e-6 CrackHeight=1.0e-6 ModelLenth=4.5e-2 ModelHeight=4.5e-2/2.0 XNodeNum=20 YNodeNum=15 CrackNodeNum=5 ModelCelHeight=ModelHeight/YNodeNum ModelCelLenth=ModelLenth/(XNodeNum-1) CrackCelHeight=CrackHeight/(CrackNodeNum-1) CrackCelLenth=CrackLenth/(CrackNodeNum-1) CrackRightNodeNum=int((ModelLenth-CrackLenth)/ModelCelLenth)+1 NodeNum=2*YNodeNum*XNodeNum+CrackNodeNum*2-1+CrackRightNodeNum allocate( BodyNode(YNodeNum*XNodeNum,3), & CrackNode(CrackNodeNum*2-1+CrackRightNodeNum,3),& ModelNode(NodeNum,3)) call CreateNode(ModelLenth,ModelHeight, & ModelCelLenth,ModelCelHeight, & CrackLenth,CrackHeight, & CrackCelLenth,CrackCelHeight, & XNodeNum,YNodeNum,NodeNum, & CrackNodeNum,CrackRightNodeNum, & BodyNode,CrackNode,ModelNode) call WriteNode(ModelNode) !Read(*,*) end Program main
两个subroutine文件就不列出了。
本意是不想把一个文件写的太长。但subroutine多了之后main文件的interface的篇幅也很可观,严重影响可读性。
那段interface能写在另一个文件中么?