[問題]指數的EXP函數問題,請大大幫忙一下!

看板Fortran作者 (小鐵)時間15年前 (2009/03/16 00:01), 編輯推噓0(002)
留言2則, 2人參與, 最新討論串1/1
我跑程式不知道啥會有底下的問題 Warning: Variable EXP is used before its value has been defined x(i)=log(exp(1)-1)+log(r(i)) 我的程式如下,請大大幫我看看是哪裡出錯了,感謝! program work3 implicit none integer i real r(100),x(100),exp(1) CALL init_random_seed() CALL RANDOM_NUMBER(r) write(*,*)r do i=1,100 x(i)=log(exp(1)-1)+log(r(i)) end do write(*,*)x end program work3 SUBROUTINE init_random_seed() INTEGER :: i, n, clock INTEGER, DIMENSION(:), ALLOCATABLE :: seed CALL RANDOM_SEED(size = n) ALLOCATE(seed(n)) CALL SYSTEM_CLOCK(COUNT=clock) seed = clock + 37 * (/ (i - 1, i = 1, n) /) CALL RANDOM_SEED(PUT = seed) DEALLOCATE(seed) END SUBROUTINE -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.131.96.30

03/16 00:36, , 1F
exp不用宣告;exp裡面放1.0形態才對
03/16 00:36, 1F

03/16 14:10, , 2F
嗯嗯,真的太感謝大大了,問題已解決。
03/16 14:10, 2F
文章代碼(AID): #19lIPHgd (Fortran)
文章代碼(AID): #19lIPHgd (Fortran)