Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28446 Discussions

Need urgent help with Programming in FORTRAN

ninizhao
Beginner
334 Views
Hi ladies and gentlemen, I need help with modifying a simulation software. It is a business simulation where people enter decisions as managers at a factory. When you make a wrong decision, you will see a message like "you made a wrong decision at ------". I need to modify this simulation programming a bit so that whenever someone makes a mistake, there is a counter that adds up all the mistakes. Then by the end of the day, I know the number of mistakes one made in each trial of the simulation. I can pay you for your work and I need the work to be done by the middle of November. Please contact me by sending me an e-mail (ninizhao@yahoo.com) if you can help. I would really appreciate it if you can contact me as soon as possible! Thanks!
0 Kudos
6 Replies
Zhanghong_T_
Novice
334 Views

If you have the code of the software, it will be very easy to do this. Just insert some counter after your message.

Good luck!

0 Kudos
ninizhao
Beginner
334 Views
Dear Sir or Madam,
Thanks for your kind response to my message. Yes, I have the code. The problem is, I am a layman to programming. Can you help me with it?If you can help me, PLEASE contact me again. I can call you or e-mail you for further details, whichever way you prefer.
Thanks and I look forward to your reply!
0 Kudos
Intel_C_Intel
Employee
334 Views
Hello,
You need to ensure that the variable that counts the number of faults is saved. Write something like this:
program simulation
integer, save :: faults = 0
...
...
if (error_by_user) then
faults = faults + 1
...
...
write(*,*)'You did ',faults,' mistakes'
end program simulation
This code initializes the number of faults to zero (the first time), and then increments the number of faults as the user is doing mistakes. Before the program is terminated the number of mistakes is displayed at the screen.
Best Regards,
Lars Petter Endresen
0 Kudos
ninizhao
Beginner
334 Views

Thanks for your detailed reply, Lars, I really appreciate it. However, there is still one question: what if I need to save the number of mistakes in the output file but do not want it to display on the screen?

Thanks.

0 Kudos
Intel_C_Intel
Employee
334 Views

Hello,

Then you need to know the file unit number of the output file. This is the number used in the OPEN statement, for example OPEN(10,...), where 10 is the unityouare using.Then you can do WRITE(10,*)'faults = ',faults.

Best Regards,

Lars Petter

0 Kudos
ninizhao
Beginner
334 Views
Got it. Thanks! Really appreciate it.
0 Kudos
Reply