max533 发表于 2015-11-16 17:22:45

Operand incompatible with opcode Compilation failed.

如標題,我用ftn95在win7底下進行編譯。
出現了這個error message:Operand incompatible with opcode Compilation failed.
不知道這個訊息到底指示了什麼意思,所以沒辦法找出錯誤的地方。
還請論壇上的各位高手給予協助,感激不盡。
program filter_radiosonde
implicit none

integer :: stat,time_array_size,stat2,array_size,i,yr,doy,hr,stat3,array_pointer,stat4,stat5,RH,height
integer, allocatable :: RH_array(:),yr_array(:),doy_array(:),hr_array(:)
character :: filename*50,filename_correct*50,time_error*50,file_error*50
real*8 :: last_timeall,pressure,temp,timeall
real*8, allocatable :: time_array(:),timeall_array(:),height_array(:),pressure_array(:),temp_array(:)
logical :: array_logical

open (11,file='list.txt')
close (11,status='delete')
call system ('dir /b *.radio1 > list.txt')
open (11,file='list.txt')

stat=0
do while (stat==0)
read (11,*,iostat=stat) filename
if (stat/=0) exit
open (22,file=trim(filename))
filename_correct=filename(1:6)//'_c.radio1'
time_error=filename(1:6)//'_e.time'
file_error=filename(1:6)//'_e.radio1'
open (33,file=trim(filename_correct))
open (44,file=trim(time_error))
open (55,file=trim(file_error))

time_array_size=0
last_timeall=0.0
stat2=0
do while (stat2==0)
    read (22,*,iostat=stat2)
    if (stat2/=0) then
      time_array_size=time_array_size+1
      last_timeall=timeall
    end if
    if (stat2/=0) exit
    if (timeall - last_timeall < 1.0d-7) then
      time_array_size=time_array_size+1
      last_timeall=timeall
    end if
end do
rewind (22)

if (.not. allocated(time_array)) then
    allocate (time_array(time_array_size))
end if

time_array_size=0
last_timeall=0.0
stat3=0
do while (stat3==0)
    read (22,*,iostat=stat3)
    if (stat3/=0) then
      time_array_size=time_array_size+1
      time_array(time_array_size)=timeall
      last_timeall=timeall
    end if
    if (stat3/=0) exit
    if (timeall-last_timeall<1d-7) then
      time_array_size=time_array_size+1
      time_array(time_array_size)=timeall
      last_timeall=timeall
    end if
end do
rewind (22)

array_size=0
do i=1,time_array_size
    if ( allocated(timeall_array) .or. array_size/=0 ) then
      deallocate (timeall_array(array_size))
      deallocate (height_array(array_size))
      deallocate (pressure_array(array_size))
      deallocate (temp_array(array_size))
      deallocate (RH_array(array_size))
      deallocate (yr_array(array_size))
      deallocate (doy_array(array_size))
      deallocate (hr_array(array_size))
    end if

    stat4=0
    do while (stat4==0)
      read (22,*,iostat=stat4) timeall,height,pressure,temp,RH,yr,doy,hr
      if (stat4/=0) exit
      if (time_array(i)-timeall<1d-7) then
      array_size=array_size+1
      end if
      if (timeall - time_array(i)>0) exit
    end do
    rewind (22)
   
    if (.not. allocated (timeall_array)) then
      allocate (timeall_array(array_size))
      allocate (height_array(array_size))
      allocate (pressure_array(array_size))
      allocate (temp_array(array_size))
      allocate (RH_array(array_size))
      allocate (yr_array(array_size))
      allocate (doy_array(array_size))
      allocate (hr_array(array_size))
    end if
   
    array_pointer=0
    stat5=0
    do while (stat5==0)
      read (22,*,iostat=stat5) timeall,height,pressure,temp,RH,yr,doy,hr
      if (stat5/=0) exit
      if (time_array(i)-timeall<1d-7) then
      array_pointer=array_pointer+1
      timeall_array(array_pointer)= timeall
      height_array(array_pointer)= height
      pressure_array(array_pointer)= pressure
      temp_array(array_pointer)= temp
      RH_array(array_pointer) = RH
      yr_array(array_pointer) = yr
      doy_array(array_pointer) = doy
      hr_array(array_pointer) = hr
      end if
      if (timeall - time_array(i)>0) exit
    end do
    rewind (22)
   
    array_logical=.true.
   
    if ( height_array(1) - 300.0 > 1d-7 .or. pressure_array(array_size) - 300.0 < 1d-7 ) then
      array_logical=.false.
    end if
   
    do array_pointer=1,array_size-1
      if (pressure(array_pointer+1)-pressure(array_pointer) > 200.0 ) then
      array_logical=.false.
      end if
    end do
   
    if (array_logical) then
      write (44,30) timeall_array(1),yr_array(1),doy_array(1),hr_array(1)
30    format (f12.7,1x,i4.4,1x,i3.3,1x,i2.2)
    end if

    do array_pointer=1,array_size
      if (array_logical) then
      write (33,50) timeall_array(array_pointer),height_array(array_pointer),pressure_array(array_pointer)&
      &,temp_array(array_pointer),RH_array(array_pointer),yr_array(array_pointer)&
      &,doy_array(array_pointer),hr_array(array_pointer)
50      format (f12.7,1x,i5.5,1x,f6.1,1x,f5.1,1x,i3.3,1x,i4.4,1x,i3.3,1x,i2.2)
      else if (.not. array_logical) then
      write (55,50) timeall_array(array_pointer),height_array(array_pointer),pressure_array(array_pointer)&
      &,temp_array(array_pointer),RH_array(array_pointer),yr_array(array_pointer)&
      &,doy_array(array_pointer),hr_array(array_pointer)
      end if
    end do
   
end do

close (22)
close (33)
close (44)
close (55)

end do

end program

楚香饭 发表于 2015-11-16 18:20:32

71-78行,请不要在deallocate语句中指定数组大小。

130行,
if (pressure(array_pointer+1)-pressure(array_pointer) > 200.0 ) then
是否应该为
if ((pressure_array(array_pointer+1)-pressure_array(array_pointer)) > 200.0 ) then

max533 发表于 2015-11-17 11:18:40

楚香饭 发表于 2015-11-16 18:20
71-78行,请不要在deallocate语句中指定数组大小。

130行,


感謝,楚大的提醒與指教。
小弟受益良多。問題已解決^ ^
所以Operand incompatible with opcode Compilation failed
此錯誤訊息是指示說,我的語法上有錯誤嗎?!

楚香饭 发表于 2015-11-17 11:26:46

Operand incompatible with opcode 的意思是 操作数与操作码不匹配。
这两个概念都是汇编的概念。
比如 mov eax , 1
mov 是操作码(opcode) , eax 是操作数(Operand)

我也不清楚 Ftn95 为何用这种方式来提示。我猜应该是130行导致的。要对数组进行操作(操作码),但是操作数却是单变量
页: [1]
查看完整版本: Operand incompatible with opcode Compilation failed.