Fortran Coder

标题: abaqusfilm子程序我想输入温度变化数据,并赋值到数组中。 [打印本页]

作者: arrowzero    时间: 2023-7-3 13:31
标题: abaqusfilm子程序我想输入温度变化数据,并赋值到数组中。
在film子程序编写下列代码,并print数组a和sink。但最后在.log文件中看到的输出结果全是0.有没有大神帮我看看代码有问题吗?
here is my program:
[Fortran] 纯文本查看 复制代码
real a(2,240)
integer i,j
if (TIME(2).EQ.0) then
!读入温度数据
open(12,file='temperature.txt')
do i=1,240
read(12,*) a(:,i)
print*, a(:,i)
end do
close(12)
end if
! 对应时间步长
do j = 1,240
if (TIME(2).EQ.a(1,j)) then
SINK = a(2,j)
exit
else
SINK = 0
end if
end do

but in the job.log i find the result of print is all zero. why!?
here is my txt:
0 28.7100000000000
0.500000000000000 28.3600000000000
1 28.0300000000000
1.50000000000000 27.6100000000000
2 27.4900000000000
2.50000000000000 27.0800000000000
3 26.7400000000000
3.50000000000000 26.7200000000000
....
119.500000000000 24.3700000000000
120 24.3300000000000


作者: arrowzero    时间: 2023-7-3 15:56
[Fortran] 纯文本查看 复制代码
 SUBROUTINE FILM(H,SINK,TEMP,KSTEP,KINC,TIME,NOEL,NPT,
     1 COORDS,JLTYP,FIELD,NFIELD,SNAME,NODE,AREA)
C
      INCLUDE 'ABA_PARAM.INC'
C
      DIMENSION H(2),TIME(2),COORDS(3), FIELD(NFIELD)
      CHARACTER*80 SNAME
      real a(2,241)
      integer i,j
      
      data iread /1/
      save iread
      save a
      
      if(iread.eq.1) then
      !读入温度数据
          iread = 2
          open(12,file='D:\abaqusworks\abaqus\temperature.txt')
          do i=1,241
              read(12,*) a(1,i),a(2,i)
              print*, a(1,i),a(2,i)
          end do
      end if
      
          close(12)
      ! 对应时间步长
      do j = 1,241
          if (TIME(2).EQ.a(1,j)) then
              SINK = a(2,j)
              exit
          end if
      end do

我看了别的帖子,加了iread 和 save 就成功了, 虽然不知道iread是什么意思




欢迎光临 Fortran Coder (http://bbs.fcode.cn/) Powered by Discuz! X3.2