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

forrtl: severe (30): / process cannot access file because it is being used by another process.

Kunal_Rao
Novice
3,189 Views
Hi
I am getting the following error when I execute with 2 processes.
--------------
forrtl: The process cannot access the file because it is being used by another process.
forrtl: severe (30): open failure, unit 35, file amr_runtime_parameters.dump
---------------
It works with 1 process but when I execute with 2 process using mpiexec -np 2 ./myapp.exe then it fails with the above message. I could track down using the -traceback option which portion of the code is doing this.
That part of the code is as follows:
----------------
#include "paramesh_preprocessor.fh"
subroutine gr_amr_dump_runtime_parameters()
use paramesh_dimensions
use physicaldata
use tree
use timings
use io
use Grid_data, ONLY : gr_myPE, gr_numProcs
implicit none
! If there are "many" processors and this is not the master processor,
! do not write to file at all but return immediately.

if (gr_myPE .NE. 0 .AND. gr_numProcs .GT. 8) return

open (unit=35, &

& file='amr_runtime_parameters.dump', &

& status='UNKNOWN', &

& action='WRITE', &

& form='formatted')

write (35,*) maxblocks ,', maxblocks'

-----------------

Looking at the numproc condition for 8, I executed with mpiexec -np 10 myapp.exe and that worked. So basically, what happens when I execute with 2 process ? Why does it give me that error ?

The compiler options used while compiling the code are:

ifort -c -traceback -real_size:64 -MD -assume:underscore -names:lowercase -fpp

I am using MSMPI and working in the cygwin environment.

Is this issue with the code or msmpi or intel compiler ?

Thanks & Regards,

Kunal

4 Replies
jimdempseyatthecove
Honored Contributor III
3,192 Views
You are opening a sequential file for exclusive use (writing).

What do you want to happend when say 2 applications write to the same file?
a) 2nd app errors out
b) writes ofone app overwriting writes ofother app?
c) writes are interleaved?
d) writes write to different files? (same name, different folder)
e) other?

When multiple applications write to same file you need to use direct access file modes (shared record I/O)
(using SHARED or SHARE='DENYNONE')

When you want multiple applications to append tothe file, you will have synchronization issues. These issues can be overcome with additional programming, by interpreting error status, or by other programming techniques (e.g. predefined records for use per process).
Lorri_M_Intel
Employee
3,192 Views
By default, OPEN creates files that are not shared on Windows.

If you add SHARED, to your list of open keywords and you should be able to share the files between the two processes.

-- Lorri
Kevin_McGrattan
3,192 Views

SHARED is no longer accepted in the Fortran 2003 standard. Is there something that replaces it? I would like to have another program read my Fortran output files while the Fortran program is running. The other application should have read-only access.

0 Kudos
Steven_L_Intel1
Employee
3,192 Views

SHARED was never standard - it is an extension. You can continue to use it in Intel Fortran.

Reply