2015-05-30 41 views
0

我開始使用代碼塊在Fortan中進行編程。 我創建了一個控制檯應用程序,用GNU C++編譯器編譯,當我與編譯開始我得到這個mesage:Fortran在代碼塊-Linux Mint

/media/aleksandar/HD_2/Programiranje/Code Blocks/Fortran/Aleksandar/main.f95|15|/media/aleksandar/HD_2/Programiranje/Code Blocks/Fortran/Aleksandar/main.f95 15 .1:|
||Warning: Nonconforming tab character |
/media/aleksandar/HD_2/Programiranje/Code Blocks/Fortran/Aleksandar/main.f95|15|/media/aleksandar/HD_2/Programiranje/Code Blocks/Fortran/Aleksandar/main.f95 15 .25:|
||Error: Unexpected end of format string in format string |
||=== Build failed: 1 error(s), 7 warning(s) (0 minute(s), 0 second(s)) ===|

什麼我的代碼是什麼問題?

這是我的代碼:

Program KTO 
!Program za sortiranje niza (rastuce i opadajuce vrijednosti) 
Implicit none 
Integer::i,n,Odabir 
Real,dimension(24)::Ppot 
Logical::Max 
!Otvaranje datoteke sa podacima o potrosnji 
!Kad se ucitava kolona na ovaj nacin uvijek ide n+1 broj ucitavanja 
!Strogo paziti na ovo 
Open(8,File='Ulaz',Status='OLD') 

    Read(8,'(i3,/,25(f5.1,/)')n,(Ppot(i),i=1,n) 

Close(8) 
Write(*,'(2x,"Kakvo sortiranje zelite?",//,& 
2x,"1 - Opadajuce vrijednosti?",/,& 
2x,"2 - Rastuce vrijednost?")') 
Read(*,'(i2)') Odabir 
If (Odabir.eq.1) then 
    Max=.true. 
Else 
    Max=.false. 
End if 
Call Sort(n,Ppot,Max) 

! Ispis podataka u datoteku 
Open(10,File='Izlaz',Status='Unknown') 
    Write(10,'(1x,14hSortirani niz:,24(/,f5.1))') (Ppot(i),i=1,n) 
Close(10) 
Stop 
End program KTO 
!Potprogram za sortiranje 
Subroutine Sort(n,Ppot,Max) 
Implicit none 
Integer::i,j 
Integer,intent(in)::n 
Real,dimension(n),intent(inout)::Ppot 
Logical,intent(in)::Max 
Real::Pom 
If (Max.eqv..true.) then 
    Do i=1,n-1 
     Do j=i+1,n 
      If (Ppot(i).lt.Ppot(j)) then 
       Pom=Ppot(i) 
       Ppot(i)=Ppot(j) 
       Ppot(j)=Pom 
      End if 
     End do 
    End do 
Else 
    Do i=1,n-1 
     Do j=i+1,n 
     If (Ppot(i).gt.Ppot(j)) then 
       Pom=Ppot(i) 
       Ppot(i)=Ppot(j) 
       Ppot(j)=Pom 
     End if 
     End do 
    End do 

End if 
Return 
End subroutine Sort 
+0

在我看來像一個失蹤)後1或之後)1. – albert

+0

謝謝薩米。 完全是問題。 :-) –

回答

0

我已經編譯gfortran4.7.2的代碼。然後,隨着@albert建議,以下行竟然是錯誤:如果這是固定

Read(8,'(i3,/,25(f5.1,/))')n,(Ppot(i),i=1,n) 
         ^--- added this 

Read(8,'(i3,/,25(f5.1),/)')n,(Ppot(i),i=1,n) 
        ^--- added this 

代碼開始運行

Read(8,'(i3,/,25(f5.1,/)')n,(Ppot(i),i=1,n) 

,但它很快就中止了,因爲我沒有文件「Ulaz」。

+0

順便說一句,霍勒里斯常數'14hSortirani niz:'可能已經過時了http://en.wikipedia.org/wiki/Hollerith_constant – roygvib