回 帖 发 新 帖 刷新版面

主题:为什么我的计算结果全是星号?

我将三个小程序连在一起后,编译连接都没有错,可是输出结果都是星号,我还没见过这种问题,如果单独执行三个小程序,都是没有错的。输出的三个应力都可以正常显示,可是连接完之后就出现问题了。到底是怎么回事啊???!!
program ddn
    implicit none
c
    integer:: num_node,num_elem,inode,t,ii,tt,num_element,enode
    integer::znode,dn
    integer,parameter::N=20
    integer::nn(35683)
    integer::ne(7888)
    integer::dne(7888)
    integer::s(7888,20)
    real::ucr(35683,3)
    integer::den(7888,20)
    integer::ds(330,20)
    integer::dds(330,4)
    integer::ddne(330)
    real::A(N)
    real::B(N)
    real::C(N)
    real::D(N)
    integer I,J
    real TEMP,TE
    integer::e_num(7888)
    integer::nee(330)
    real::ndsp(7888,2)
    num_element=7888
c
    open(11,file='lashen.txt',status='old',action='read')
c
    read(11,*) num_node,num_elem
c
    do inode=1,num_node
      read(11,*) nn(inode),ucr(inode,1),ucr(inode,2),ucr(inode,3)       
    enddo
c
    do t=1,num_elem
      read(11,*) ne(t),s(t,1),s(t,2),s(t,3),s(t,4),s(t,5),s(t,6),
     &  s(t,7),s(t,8),s(t,9),s(t,10),s(t,11),s(t,12),s(t,13),s(t,14),
     &  s(t,15),s(t,16),s(t,17),s(t,18),s(t,19),s(t,20)
    enddo
c
    dn=0
    do t=1,num_elem
      do ii=1,20
        A(ii)=ucr(s(t,ii),2)
        B(ii)=ucr(s(t,ii),1)
        C(ii)=ucr(s(t,ii),3)
        D(ii)=A(ii)*A(ii)+B(ii)*B(ii)
      enddo
c
     do I=N-1,1,-1
       do J=1,I
         if(C(J)>C(J+1)) then
           TEMP=C(J)
           C(J)=C(J+1)
           C(J+1)=TEMP
           TE=s(t,J)
           s(t,J)=s(t,J+1)
           s(t,J+1)=TE
         endif

         if(B(J)>B(J+1)) then
           TEMP=B(J)
           B(J)=B(J+1)
           B(J+1)=TEMP
         endif
       enddo
     enddo
c
        if (C(1)>=39.98.AND.C(20)<=40.10 )
     &  then
     
    if ( D(1)>16.1.AND.D(2)>16.1.AND.D(3)>16.1.AND.D(4)>16.1.AND.
     &    D(5)>16.1.AND.D(6)>16.1.AND.D(7)>16.1.AND.D(8)>16.1.AND.
     &    D(9)>16.1.AND.D(10)>16.1.AND.D(11)>16.1.AND.D(12)>16.1.AND.
     &    D(13)>16.1.AND.D(14)>16.1.AND.D(15)>16.1.AND.D(16)>16.1.AND.
     &    D(17)>16.1.AND.D(18)>16.1.AND.D(19)>16.1.AND.D(20)>16.1 ) then
               dn=dn+1            
    endif
        endif                
c
     if (D(1)>=16.1) then
      if ( C(1)>=39.98 .AND. C(1)<=40.14.AND. C(20)>=39.98 
     & .AND. C(20)<=40.14) then
        dne(t)=ne(t)
        do ii=1,20
          den(t,ii)=s(t,ii)
               enddo
      endif
      else 
        dne(t)=0
        do ii=1,20
          den(t,ii)=0    
        enddo
C
     endif
    enddo                
c
    open(10,file='dn.txt',status='new',action='write')
c
    write(10,400) dn
400       format(I6)
    close(10)
c
    open(11,file='lashen2.txt',status='new',action='write')    
    do t=1,num_elem
      if (dne(t)/=0.0) then
    write(11,100) dne(t),den(t,1),den(t,2),den(t,3),den(t,4),
     &   den(t,5),den(t,6),den(t,7),den(t,8),den(t,9),den(t,10),
     &   den(t,11),den(t,12),den(t,13),den(t,14),den(t,15),
     &   den(t,16),den(t,17),den(t,18),den(t,19),den(t,20)
      end if
    enddo
c
100    format(I6,2X,I6,2X,I6,2X,I6,2X,I6,2X,I6,2X,I6,2X,I6,2X,
     &   I6,2X,I6,2X,I6,2X,I6,2X,I6,2X,I6,2X,I6,2X,I6,2X,I6,
     &    2X,I6,2X,I6,2X,I6,2X,I6,2X)

200   format(I6)
      close(11)
c
    open(12,file='lashen2.txt',status='old',action='read')  
    do tt=1,dn
      read(12,*) ddne(tt),ds(tt,1),ds(tt,2),ds(tt,3),ds(tt,4),
     &   ds(tt,5),ds(tt,6),ds(tt,7),ds(tt,8),ds(tt,9),ds(tt,10),
     &   ds(tt,11),ds(tt,12),ds(tt,13),ds(tt,14),ds(tt,15),ds(tt,16),
     &   ds(tt,17),ds(tt,18),ds(tt,19),ds(tt,20)
    
    enddo
c
    do tt=1,dn
c
     do ii=1,20
        C(ii)=ucr(ds(tt,ii),3)
     enddo
c
     do I=N-1,1,-1
       do J=1,I
         if(C(J)>C(J+1)) then
           TEMP=C(J)
           C(J)=C(J+1)
           C(J+1)=TEMP
           TE=ds(tt,J)
           ds(tt,J)=ds(tt,J+1)
           ds(tt,J+1)=TE
         endif
       enddo
     enddo
    enddo
c
    open(11,file='ne.txt',status='new',action='write')  
    do tt=1,dn
      write(11,300) ddne(tt)
    enddo
    close(11)
c
300   format(I6,2X,I6,2X,I6,2X,I6,2X,I6)
    
c      *** step1 *** !这里总共有20个计算步,程序基本相同,我只贴出来了第一个计算步骤
    open(11,file='elementvolume01.rpt',status='old',action='read')

    do enode=1,num_element
      read(11,*) e_num(enode),ndsp(e_num(enode),1)
    enddo

      open(11,file='ne.txt',status='old',action='read')
    do znode=1,dn
      read(11,*) nee(znode)
    enddo

    open(22,file='deform_lashen01',status='new',action='write')
    do znode=1,dn
        do enode=1,num_element
        if (e_num(enode)==nee(znode)) then
        write(22,200) ndsp(e_num(enode),1)
          end if
       enddo
    enddo


*** step2 ***
*** step3 ***
.......
.......
*** step20 ***
c
500   format(3X,E13.6E2)

      end

回复列表 (共4个回复)

沙发

应该是某处计算有误,如果是三个程序合一起建议是改成三个Subroutine,然后新增加一个Subroutine调用,否则简单合并因变量名重复地不合理利用就容易导致计算错误 :)

板凳

恩,谢谢cgl_lgs! 我试试

3 楼

你把输出不限定格式试试看。即WRITE(22,*)……
没仔细看,只是觉得处理输出星号问题,这样可能有用。

4 楼

[quote]你把输出不限定格式试试看。即WRITE(22,*)……
没仔细看,只是觉得处理输出星号问题,这样可能有用。[/quote]
楼主的程序在分开时没事儿合并后出事儿所以不能简单地这样改:)

我来回复

您尚未登录,请登录后再回复。点此登录或注册