I start with using Code Blocks for programing in Fortan.
I created a console app, compiling with gnu fortran compiler and when i start with compiling i got this mesage:
/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)) ===|
What is problem with my code?
This is my code:
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
I have compiled the code with gfortran4.7.2. Then as #albert suggested, the following line turned out to be error:
Read(8,'(i3,/,25(f5.1,/)')n,(Ppot(i),i=1,n)
If this is fixed to
Read(8,'(i3,/,25(f5.1,/))')n,(Ppot(i),i=1,n)
^--- added this
or
Read(8,'(i3,/,25(f5.1),/)')n,(Ppot(i),i=1,n)
^--- added this
the code started to run, but it soon aborted because I have no file "Ulaz".
Related
I am having a problem with calling Lua built-in functions using Scribunto.
I created basic module Module:Item
local p = {};
function p.test(frame)
print("Hello World!")
end
return p
Which I call in different page as {{#invoke: Item | test}}
and I receive a following error:
Lua error in Module:Item at line 3: attempt to call global 'print' (a nil value).
Backtrace:
1. (tail call): ?
2. Module:Item:3: in function "chunk"
3. mw.lua:511: ?
4. (tail call): ?
5. [C]: in function "xpcall"
6. MWServer.lua:99: in function "handleCall"
7. MWServer.lua:313: in function "dispatch"
8. MWServer.lua:52: in function "execute"
9. mw_main.lua:7: in main chunk
10. [C]: ?
Since print is Lua built-in function I have the feeling the problem will be somewhere in setting on the pc.
However, when I imported wiki Infoboxes, they are working OK.
Versions:
Linux Mint Tara - Cinnamon based on ubuntu 18
MediaWiki 1.31.7
Scribunto (106fbf4) 17:24, 15 May 2018
Lua 5.1.5
Any help pointing where the problem can be is highly appreciated.
Scribunto intentionally doesn't include print. The "Removed functions and packages" section in its manual says this about it:
This was discussed on wikitech-l and it was decided that it should be omitted in favour of return values, to improve code quality. If necessary, mw.log() may be used to output information to the debug console.
I have a problem with gfortran 4.9.2
I don't have this problem with gfortran 8.2
I don't have this problem under ifort 17.0.6
Unfortunately, I absolutely have to make my work work in gfortran 4.9.2.
I get the following error message :
mpif90 -O0 -g -Wall -fbacktrace -finit-local-zero -ffpe-trap=invalid,zero,overflow -fbounds-check -cpp -fcheck='all' -c main.f
gfortran: internal compiler error: Segmentation error (program f951)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:////usr/share/doc/gcc-4.9/README.Bugs> for instructions.
Makefile:160: recipe for target "main.o' failed
make: ***[main.o] Error 4
In particular the use of the modules lead me to the problem:
My failure is absolutely inexplicable.
I managed to get around it by doing the following:
This first code doesn't work
MODULE MOD_1
USE MOD_2
CONTAINS
SUBROUTINE SUB_1
END SUBROUTINE SUB_1
SUBROUTINE SUB_2
END SUBROUTINE SUB_2
END MODULE MOD_1
This seconde code works fine
MODULE MOD_1
CONTAINS
SUBROUTINE SUB_1
USE MOD_2
END SUBROUTINE SUB_1
SUBROUTINE SUB_2
USE MOD_2
END SUBROUTINE SUB_2
END MODULE MOD_1
I simply moved the USE MOD_2 inside the two subroutines
For me it really doesn't make sense. I still have many similar mistakes.
Could someone tell me where to find a description of this problem?
If I knew him more precisely, I might avoid falling back into it!
I hope to have a link to the problem description and possibly the version of the gfortran patch
Sincerely
I'm a beginner at LUA so I'm having some trouble with it. I'm using the code for a Minecraft mod called Computercraft, but to me it's a great introduction to programming.
I've been searching the web to find out why my code of not even 26 lines is failing, but I couldn't find it sadly.
Here's the code:
monitor = peripheral.wrap("right")
monitor.clear()
monitor.setCursorPos(1,1)
monitor.setTextScale(1)
monitor.print("Current mode:")
monitor.setCursorPos(1,3)
monitor.print("Dust gaat naar furnace")
redstone.setOutput(back,false)
print("Dust gaat automatisch naar de furnace toe")
print("Wil je dat de dust naar de chest gaat in plaats van de furnace?")
write()
while input == ja
do
print("Oke :)")
redstone.setOutput(back,true)
monitor.clear()
monitor.setCursorPos(1,1)
monitor.print("Current mode:")
monitor.setCursorPos(1,3)
monitor.print("Dust gaat naar chest")
end
else
print("Okeuu dan niet jongee")
end
I know that I have used 'end' 2 times. This is because I get an error when I remove one.
The error I get when I run the program is:
bios:14: [string ".temp"]:22: '<eof>' expected.
The error I get when I remove the first 'end'.
The error I get when I remove the second 'end'.
EDIT
Okay well after some advice i managed to get rid of the error.
Thanks to all the people that responded! c:
Now i got an other error though lol.
As suggested i made a new post about it: Basic LUA problems
The :22: is telling you that the error has occurred around line 22 of the script, which is the else. If you have a look at the Lua reference guide you will see that else belongs with an if statement, not a while statement.
Your code should probably be as follows, as a while doesn't make sense here
if input == ja
then
... code ...
else
... other code ...
end
This error came with this script, can anyone find the error?
function checkPing(thePlayer)
ping = getPlayerPing(thePlayer)
if ( ping > 500 ) then
kickPlayer (thePlayer ,ToohighPing)
outputChatBox (getPlayerName(thePlayer).."Has been kicked due to High ping",255,255,0)
end
addEventHandler ("OnResourceStart")
You need to have two ends: one to close the if statement and one to close function. You are probably missing end between lines 5 and 6.
I'm using these files in my gaming server, and every time I add a new player model, I get
[ERROR] lua/autorun/server/fastdlskins.lua:938: '<eof>' expected near 'end'
1. unknown - lua/autorun/server/fastdlskins.lua:0
I also get a similar error when I add an add-on to a different file
[ERROR] lua/autorun/server/workshopitems.lua:55: '<eof>' expected near 'end'
1. unknown - lua/autorun/server/workshopitems.lua:0
I usually just have to put an 'end' after the code, but I don't see what else I'm required to do. I don't have any loops running (I think), so I'm not closing any of those out. Not sure what to do.
As Egor said, remove the extra end at the end of the files.
end is only used to close blocks for functions and loops, like } in C-like languages. The end at the file is not closing anything, and is thus invalid syntax.