24小时热门版块排行榜    

查看: 2489  |  回复: 9
本帖产生 1 个 程序强帖 ,点击这里进行查看
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

snoopyzhao

至尊木虫 (职业作家)

【答案】应助回帖

★ ★ ★ ★ ★ ★ ★ ★
li_clifff(金币+20): 确实是这样,动态数组,学习了,谢谢 2011-08-24 11:36:10
余泽成(金币+3): 辛苦了! 2011-08-24 16:27:14
dubo(金币+5, 程序强帖+1): 多谢应猪 2011-08-27 16:42:39
ben_ladeng: 专家考核存档 2011-09-28 11:40:00
上面错了一点儿,不是用 allocated,而是用 allocate 来分配内存。下面是修改后的程序:
CODE:
      PROGRAM pmesh
c
c-----------------------------------------------------------------
c     purpose : to eliminate the string from existed mesh data
c               warning : the mesh has to be made out of quadrangles only
c     in :c
c     out :
c             x     : array containing node coordinates
c             ia    : nodes reference number
c             ien   : list of element nodes
c             mat   : material ref. numbers for all elements
c             in    : element sides ref. number
cc-----------------------------------------------------------------------
c
      implicit real*8 (a-h,o-z)
      real xreal,yreal
      integer*4 numnp, numel                           
      real, allocatable :: x(:,:)
      integer*4, allocatable :: ien(:,:), ia(:), mat(:), in(:,:)
!     dimension x(2,numnp),ia(numnp)
!     dimension ien(4,numel),mat(numel),in(4,numel)
   
      open(57,file='pmesh1.dat')
      open(58,file='pmesh2.dat')
      
         call sizemesh(numnp, numel)
         allocate(x(2,numnp),ia(numnp),ien(4,numel),mat(numel),
     +             in(4,numel))
         open(21,file='mesh.dat')
          read(21,*)
          do 300 i=1,numnp                  
          read(21,2100)idum,xreal,yreal,ia(i)
              x(1,i) = xreal
              x(2,i) = yreal
          write(57,*)idum,xreal,yreal,ia(i)
300    continue
          do 500 n=1,numel
          read(21,2300)ndum,(ien(i,n),i=1,4),(in(i,n),i=1,4)
          write(58,*)ndum,(ien(i,n),i=1,4),(in(i,n),i=1,4)
500    continue
          close(21)

2100  format(i5,2x,e15.5,2x,e12.5,2x,i2)
2300  format(5(i5,2x),4(i2,2x))
          end
c**************************************************************


      subroutine sizemesh(numnp,numel)

        integer numnp, numel

      open(21,file='mesh.dat')
      read(21,*) numnp,numel
      close(21)
      return
      end

3楼2011-08-24 11:26:59
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

智能机器人

Robot (super robot)

我们都爱小木虫

相关版块跳转 我要订阅楼主 li_clifff 的主题更新
信息提示
请填处理意见