Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
1 View

read() error with multiple cpus

     

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 ?

Thanks !

0 Kudos
11 Replies
Highlighted
Valued Contributor II
1 View

I do not know how Abaqus

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.

0 Kudos
Highlighted
Beginner
1 View

Thanks Arjen for responding.

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:

0.381,
0.381,
1.0,
1.0e+03,
1.6020e+03,
2.65e+03,
5.0e+02,
9.81000000000000,
0.2

Thanks in advance

0 Kudos
Highlighted
Valued Contributor II
1 View

Sure, but you have to be

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.

0 Kudos
Highlighted
Beginner
1 View

If you don't mind, can you be

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.
 

0 Kudos
Highlighted
Valued Contributor II
1 View

My guess is that you are

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.

 

 

0 Kudos
Highlighted
Beginner
1 View

 

 

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

 

0 Kudos
Highlighted
Beginner
1 View

Hi Arjen,

Hi Arjen,

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.

Thanks

 

 

 

 

 

 

 

 

 

 

 

0 Kudos
Highlighted
Black Belt
1 View

Which compiler version are

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).

--
Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos
Highlighted
Valued Contributor II
1 View

Ah, good to hear that - as it

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.

0 Kudos
Highlighted
Beginner
1 View

Hi Steve,

Hi Steve,

By default Abaqus uses MPI based. Though I can opt for thread based.

I am using XE 2013.

Noted your message Arjen.

 

 

0 Kudos
Highlighted
Black Belt
1 View

Do you get the end-of-file on

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.

--
Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos