"system" extension on Windows
- From: relaxmike <michael.baudin@xxxxxxxxx>
- Date: Thu, 3 Jul 2008 03:10:37 -0700 (PDT)
Hi all,
I work on a Monte-Carlo simulation tool, which is based on the
fortran extension "system". At the core of the simulation, there is
a loop which calls an external program which simulates one
particular randomized set of parameters :
do i=1,100000
sysres = system("externaltool.exe")
enddo
The problem is that the simulation fails at a random number of of
iterations,
sometimes 32 000, sometimes less. A message appears in the console,
which depends on the run, for example :
forrtl: severe (9): permission to access file denied, unit 32,
file ....
forrtl: severe (29): file not found, unit 7, file ...
etc...
I cannot write here the full source code because it is quite
complicated.
The problem appears on Windows XP, with Intel Fortran 8.1.
Strangely, it does not appear on Windows with either gfortran or g95,
and I have no explanation for that fact.
The bug may be a bug in our source code, a bug in the compilers, or
a bug in the OS.
I suspect that the "system" extension is based directly on native
windows API with Intel and that the gfortran and g95 are using a
gnu windows interface to the native system : that would explain the
difference in the behaviour.
On Linux, with either gfortran or g95, the same problems does not
appear.
I tried several methods, including a dynamic computing of the fortran
logical units, but the problem seems to be elsewhere.
To further inquire, I tried to reproduce the problem with a smaller
set of source code. Unfortunately, I was not able to reproduce the
bug,
but, and I experienced strange behaviours.
It appears that the performances between Linux and Windows with
respect
to the "system" extension are really different.
This is the sample source code.
The external tool is replaced by the following source code :
program toto
implicit none
write(33,*) 'toto'
end program toto
which is compiled in optimized mode (called Release in Intel Fortran).
The Monte-Carlo simulation tool is replaced by the following source
code :
program appel
use ifport
implicit none
integer i , sysres
integer :: timestart, timestop, count,countrate,countmax
real :: timer_elapse
call system_clock(timestart)
do i=1,100
write(32,*) i
sysres = system("toto.exe")
write(32,*) "result:", sysres
enddo
call system_clock(timestop)
call system_clock(count,countrate,countmax)
timer_elapse = real(timestop - timestart)/countrate
write(32,*) "elapsed : ", timer_elapse
end program appel
Notice that in Intel Fortran, the system extension is provided as a
function.
The following table contains the elapsed times measured on my
"average"
Pentium D dual core PC, by experimenting several values of the number
of
iterations :
PC: Dell Optiplex GX520
OS: Windows
Compiler: IVF8
10 iterations : 0.531
100 iterations : 4.890
1000 iterations : 51.187
I compiled the same source code with g95 and the following set
of commands :
g95 -O2 -c toto.f90
g95 -O2 -o toto.exe toto.o
g95 -O2 -c appel.f90
g95 -O2 -o appel.exe appel.o
Of course, one must remove the "use ifport" line.
PC: Dell Optiplex GX520
OS: Windows
Compiler: g95
10 iterations : 0.6406
100 iterations : 4.9844
1000 iterations : 51.2034
I then made the same tests under Linux.
One only have to change the call to the executable so that it can be
found in the current directory :
sysres = system("./toto.exe")
PC: Dell Precision 380
OS: Linux
Compiler: g95
10 iterations : 0.025 (=time win32 / 25)
100 iterations : 0.3027 (=time win32 / 16)
1000 iterations : 2.5327 (=time win32 / 20)
With the same compiler, the difference of performances between
Linux and Windows is approximately 20x !
Of course, the machine is different but I think that the main
difference comes from the OS.
Any help will be appreciated.
Regards,
Michaël
.
- Follow-Ups:
- Re: "system" extension on Windows
- From: Jugoslav Dujic
- Re: "system" extension on Windows
- From: Michel Olagnon
- Re: "system" extension on Windows
- From: Arjen Markus
- Re: "system" extension on Windows
- Prev by Date: Re: Native Fortran 77 - CGI interface howto
- Next by Date: ftcl
- Previous by thread: FYI/OT: [Fwd: ANN: Units of measurement for Ada v2.7]
- Next by thread: Re: "system" extension on Windows
- Index(es):
Relevant Pages
|
|