I have following program which is being used with abaqus software. Following code works fine with 1 cpu. However when I run on 2 cpus, I receive following error: forrtl: severe (24): end-of-file during read, unit 9.
OPEN (UNIT=9, FILE='../inputs', * form="formatted", * status="OLD", * access="sequential", action="read") read (9,*) rRpipe read (9,*) rRelbow read (9,*) rH read (9,*) rRHO_w read (9,*) rRHO_s read (9,*) rRHO_c read (9,*) rRHO_m read (9,*) rg read (9,*) rIDt close(9)
Could someone give the reasons and the cure ?
I do not know how Abaqus arranges for multiprocessing/multithreading, but you should keep in mind that LU-number for files are global to the program/library. So, it seems to me that the file was opened and read in the first thread/image that hit that bit of the code and then the second one came:
- finding the file already opened to that LU-number, so it could skip that part
- finding that the reading position was already at the end of the file, so that it could not continue.
You will have to make sure that only one thread/image at a time can read from the file, using OpenMP statements for instance, if that is what Abaqus is doing or other means if it is not. An alternative is to use different LU-numbers (and possibly copies of the input file) for each thread/image.
Thanks Arjen for responding.
I was thinking that it is the problem with MPP. I dont have much control in dealing with MPP capabilities of Abaqus.
Is it possible to use ACCESS =direct as my input file is really simple and shown below.
contents of "inputs" file is as follows merely 9 lines:
Thanks in advance
Sure, but you have to be careful: direct-access files have fixed record lengths. That is a trifle at odds with ordinary test flles. What you could do is store the data in an unformatted direct-access files via a small preprocessing step.
If you don't mind, can you be little bit elaborate:
I am not able to understand the parameter: recl to be used.
OPEN (UNIT=9, FILE='../inputs', * form="unformatted", * status="OLD", * access="direct", action="read", recl=9) read (9,rec=1) rRpipe read (9,rec=2) rRelbow read (9,rec=3) rH read (9,rec=4) rRHO_w read (9,rec=5) rRHO_s read (9,rec=6) rRHO_c read (9,rec=7) rRHO_m read (9,rec=8) rg read (9,rec=9) rIDt close(9)
This code is giving error: attempt to access non-existent record.
My guess is that you are trying to use the _same_ file as an unformatted file. That will not work. You will need to create a new file, something like:
open( 10, file = '.../inputs' )
open( 11, file = '../inputs_bin', access = 'direct', recl = 4 ) ! Four bytes for single-precision reals, 8 for double-precision
read( 10, * ) rRpipe
write( 11, rec = 1 ) rPipe
And use the new file, with appropriate record length.
Seems I am still missing some thing. I tried to run this on 6 cpus and getting
Following code gives standard.exe (its the abaqus solver name) / rank 0/ thread 2 encounted an EXCEPTION_ACCESS_VOILATION in ntdll.dll.
inquire(file="../inputs_bin", exist=exist) if (exist) then open (unit=21,file='../inputs_bin',access='direct',recl=4, * status="OLD" ) read (21,rec=1) rRpipe ... close(21) else open (unit=9, file='../inputs.txt',status="OLD") read (9,*) rRpipe ..... close(9) open (unit=12,file='../inputs_bin',access='direct',recl=4, * status="NEW" ) write (12,rec=1) rRpipe ... close(12) open (unit=11,file='../inputs_bin',access='direct',recl=4, * status="OLD" ) read (11,rec=1) rRpipe .... close(11) endif
Note: I can have a protector called MutexInit in Abaqus ( mutexes can be used to protect a common block or a common file from being updated by multiple threads at the same time). This solved my issue.
Which compiler version are you using? In some older (pre-17, I think) versions, you needed to build with "-reentrancy threaded" to protect the I/O system from calls in multiple threads. This would not apply if you are using separate processes (such as with MPI).
Ah, good to hear that - as it is an Abaqus-specific solution, I can't offer much (or actually any) advice, but if it works, so much the better. Do note Steve's reply though.
Do you get the end-of-file on the first READ or on a later one? Might it be that ABAQUS is running the program in different paths and thus the file path is invalid for one of the CPUs? I have often seen the problem where programs open a file in the "wrong" location, it creates a new empty file and then a READ gets an EOF, but you say you are using STATUS='OLD' so I would not expect that to be the case here.
I would add some code to display the full path to the opened file (use INQUIRE(NAME=) to get it), and then to see which READ gets the error. Maybe display the values read from the intermediate READs if it isn't the first.