An error about the pvd_mod

Z6AJ7TWUIQ(~8T8A9XYR8FO
pvd_mod.f (10.0 KB)
When I used TFM to calculate, the calculation stopped after running 0.298 seconds and the console gave an error.

@cgw @jeff.dietiker
Can you give me some advice?

Please attach the input files (“Submit bug report”) from main menu

Here are some files.
files.zip (53.2 KB)
@cgw

@Raymond_Yu - I ran this case with MFiX release 21.3.2 on both Linux and Windows and was not able to reproduce the “file opened for READ” error.

Is this something that happens on every run, or is it occasional? Do you know a way to trigger the bug reproducibly?

– Charles

I run in MFIX 21.3, this error occurs every time I run it, at the same time. I’ll try it in MFIX 21.3.2.
@cgw

I also ran this case with MFiX release 21.3.2 on Windows. At first it works, but after a while this error will occur.

@Raymond_Yu - we do our best to help with all questions posted here. Nobody is assigned to support full-time, we all have other work, but we take problem reports very seriously, especially when they are possible MFiX bugs.

I spent some time on Friday trying to reproduce this error, without success. Nobody else has ever reported this problem, so it’s something very unique to your system.

The error is saying that the PVD file was opened in read-only mode, and the program attempted to write to it. However, examining the source code, there’s no place where the PVD file is opened read-only - in fact, the access mode is not specified at all.

Perusing the GFortran docs, I found this:
https://gcc.gnu.org/onlinedocs/gfortran/Files-opened-without-an-explicit-ACTION_003d-specifier.html

The Fortran standard says that if an OPEN statement is 
executed without an explicit ACTION= specifier, the
default value is processor dependent. GNU Fortran
behaves as follows:

Attempt to open the file with ACTION='READWRITE'
If that fails, try to open with ACTION='READ'
If that fails, try to open with ACTION='WRITE'
If that fails, generate an error 

So what may be happening is that the initial READWRITE open attempt is failing, and it’s falling back to READ. However I have no idea why this would be happening. Something with the filesystem? Can you try it on a different machine?

I think the next step in debugging would be to change the OPEN statements to use explicit READWRITE, that way if this fails, instead of falling back to read-only mode it will generate an error right away, which might give us more info (if there is a decent error message). Since we are not able to reproduce the error, you will have to do this. I’ll work up a patch and post it here today.

@Raymond_Yu - let’s try this. The patch below changes all of the places where the .pvd file is opened to specify READWRITE.
You can use the patch utility to apply this, or else just edit the two files cartesian_grid/pvd_mod.f and des/vtp_mod.f directly to add the ACTION='READWRITE' parameter:

patch.txt (3.6 KB)

After this, rebuild the solver and run your problem case, maybe we’ll get a clue what’s going wrong.

– Charles

Thank you, Charles. Since I started using MFIX, you have helped me solve a lot of doubts, and I am deeply moved by your professionalism. When I encounter problems, I will first try to solve them by myself. If I can’t solve them, I will post here. Next, I will try according to your suggestion and use the"pacth" to reconstruct solver. I’ll let you know if there’s any progress.

Scanning dependencies of target udfs
[ 96%] Building Fortran object CMakeFiles/udfs.dir/C_/Users/DELL/Desktop/11.17/patch.f.obj
[ 97%] Building Fortran object CMakeFiles/udfs.dir/C_/Users/DELL/Desktop/11.17/usr_rates.f.obj
C:\Users\DELL\Desktop\11.17\patch.f:1:0:

 diff --git a/model/cartesian_grid/pvd_mod.f b/model/cartesian_grid/pvd_mod.f
 1
Error: Unclassifiable statement at (1)
C:\Users\DELL\Desktop\11.17\patch.f:2:0:

 index aeb71898e..3cec2dc4a 100644
 1
Error: Unclassifiable statement at (1)
C:\Users\DELL\Desktop\11.17\patch.f:3:0:

 --- a/model/cartesian_grid/pvd_mod.f
 1
Error: Unclassifiable statement at (1)
C:\Users\DELL\Desktop\11.17\patch.f:4:0:

 +++ b/model/cartesian_grid/pvd_mod.f
 1
Error: Unclassifiable statement at (1)
C:\Users\DELL\Desktop\11.17\patch.f:5:1:

 @@ -45,7 +45,7 @@ CONTAINS
 1
Error: Invalid character in name at (1)
C:\Users\DELL\Desktop\11.17\patch.f:9:0:

 -               OPEN(UNIT = UNIT_PVD, FILE = TRIM(PVD_FILENAME))
 1
Error: Unclassifiable statement at (1)
C:\Users\DELL\Desktop\11.17\patch.f:10:0:

 +               OPEN(UNIT = UNIT_PVD, FILE = TRIM(PVD_FILENAME),ACTION='READWRITE')
 1
Error: Unclassifiable statement at (1)
C:\Users\DELL\Desktop\11.17\patch.f:14:1:

 @@ -58,14 +58,14 @@ CONTAINS
 1
Error: Invalid character in name at (1)
C:\Users\DELL\Desktop\11.17\patch.f:18:0:

 -               OPEN(UNIT = UNIT_PVD, FILE = TRIM(PVD_FILENAME))
 1
Error: Unclassifiable statement at (1)
C:\Users\DELL\Desktop\11.17\patch.f:19:0:

 +               OPEN(UNIT = UNIT_PVD, FILE = TRIM(PVD_FILENAME),ACTION='READWRITE')
 1
Error: Unclassifiable statement at (1)
C:\Users\DELL\Desktop\11.17\patch.f:23:55:

                 PVD_FILE_INITIALIZED(VTK_REGION)=.TRUE.
                                                       1
Error: Unexpected STATEMENT FUNCTION statement at (1)
C:\Users\DELL\Desktop\11.17\patch.f:26:0:

 -               OPEN(UNIT=UNIT_PVD,FILE = TRIM(PVD_FILENAME),POSITION="APPEND",STATUS='OLD')
 1
Error: Unclassifiable statement at (1)
C:\Users\DELL\Desktop\11.17\patch.f:27:0:

 +               OPEN(UNIT=UNIT_PVD,FILE = TRIM(PVD_FILENAME),POSITION="APPEND",STATUS='OLD',ACTION='READWRITE')
 1
Error: Unclassifiable statement at (1)
C:\Users\DELL\Desktop\11.17\patch.f:30:55:

                 PVD_FILE_INITIALIZED(VTK_REGION)=.TRUE.
                                                       1
Error: Unexpected STATEMENT FUNCTION statement at (1)
C:\Users\DELL\Desktop\11.17\patch.f:31:1:

 @@ -74,7 +74,7 @@ CONTAINS
 1
Error: Invalid character in name at (1)
C:\Users\DELL\Desktop\11.17\patch.f:32:11:

        ELSE
           1
Error: Duplicate ELSE statements at (1) and (1)
C:\Users\DELL\Desktop\11.17\patch.f:35:0:

 -         OPEN(UNIT=UNIT_PVD,FILE = TRIM(PVD_FILENAME),POSITION="APPEND",STATUS='OLD')
 1
Error: Unclassifiable statement at (1)
C:\Users\DELL\Desktop\11.17\patch.f:36:0:

 +         OPEN(UNIT=UNIT_PVD,FILE = TRIM(PVD_FILENAME),POSITION="APPEND",STATUS='OLD',ACTION='READWRITE')
 1
Error: Unclassifiable statement at (1)
C:\Users\DELL\Desktop\11.17\patch.f:40:0:

 diff --git a/model/des/vtp_mod.f b/model/des/vtp_mod.f
 1
Error: Unclassifiable statement at (1)
C:\Users\DELL\Desktop\11.17\patch.f:41:0:

 index 3f36225b7..51251c48c 100644
 1
Error: Unclassifiable statement at (1)
C:\Users\DELL\Desktop\11.17\patch.f:42:0:

 --- a/model/des/vtp_mod.f
 1
Error: Unclassifiable statement at (1)
C:\Users\DELL\Desktop\11.17\patch.f:43:0:

 +++ b/model/des/vtp_mod.f
 1
Error: Unclassifiable statement at (1)
C:\Users\DELL\Desktop\11.17\patch.f:44:1:

 @@ -462,7 +462,7 @@ CONTAINS
 1
Error: Invalid character in name at (1)
C:\Users\DELL\Desktop\11.17\patch.f:48:0:

 -                  OPEN(UNIT=UNIT_PVD,FILE=FNAME_PVD,STATUS='NEW')
 1
Error: Unclassifiable statement at (1)
C:\Users\DELL\Desktop\11.17\patch.f:49:0:

 +                  OPEN(UNIT=UNIT_PVD,FILE=FNAME_PVD,STATUS='NEW',ACTION='READWRITE')
 1
Error: Unclassifiable statement at (1)
C:\Users\DELL\Desktop\11.17\patch.f:53:1:

 @@ -474,8 +474,7 @@ CONTAINS
 1
Error: Invalid character in name at (1)
C:\Users\DELL\Desktop\11.17\patch.f:54:33:

              ELSE ! a restart run
                                 1
Error: Duplicate ELSE statements at (1) and (1)
C:\Users\DELL\Desktop\11.17\patch.f:57:0:

 -                  OPEN(UNIT=UNIT_PVD,FILE=FNAME_PVD,&
 1
Error: Unclassifiable statement at (1)
C:\Users\DELL\Desktop\11.17\patch.f:59:0:

 +                  OPEN(UNIT=UNIT_PVD,FILE=FNAME_PVD,POSITION="REWIND",STATUS='OLD',IOSTAT=IOS,ACTION='READWRITE')
 1
Error: Unclassifiable statement at (1)
C:\Users\DELL\Desktop\11.17\patch.f:63:1:

 @@ -518,8 +517,7 @@ CONTAINS
 1
Error: Invalid character in name at (1)
C:\Users\DELL\Desktop\11.17\patch.f:66:31:

           ELSE ! not FIRST_PASS
                               1
Error: Duplicate ELSE statements at (1) and (1)
C:\Users\DELL\Desktop\11.17\patch.f:67:0:

 -            OPEN(UNIT=UNIT_PVD,FILE=FNAME_PVD,&
 1
Error: Unclassifiable statement at (1)
C:\Users\DELL\Desktop\11.17\patch.f:69:0:

 +            OPEN(UNIT=UNIT_PVD,FILE=FNAME_PVD,POSITION="APPEND",STATUS='OLD',IOSTAT=IOS,ACTION='READWRITE')
 1
Error: Unclassifiable statement at (1)
f951.exe: Error: Unexpected end of file in 'C:\Users\DELL\Desktop\11.17\patch.f'
CMakeFiles\udfs.dir\build.make:78: recipe for target 'CMakeFiles/udfs.dir/C_/Users/DELL/Desktop/11.17/patch.f.obj' failed
mingw32-make.exe[2]: *** [CMakeFiles/udfs.dir/C_/Users/DELL/Desktop/11.17/patch.f.obj] Error 1
mingw32-make.exe[2]: *** Waiting for unfinished jobs....
CMakeFiles\Makefile2:101: recipe for target 'CMakeFiles/udfs.dir/all' failed
mingw32-make.exe[1]: *** [CMakeFiles/udfs.dir/all] Error 2
Makefile:134: recipe for target 'all' failed
mingw32-make.exe: *** [all] Error 2
==========================================================================

                     BUILD FAILED
==========================================================================

The patch.txt shows the changes you need to make to the files. Replace the lines shown with a - by the lines shown with a +. The files that need to be edited are model/cartesian_grid/pvd_mod.f and model/des/vtp_mod.f. You should not attempt to compile the patch file as is.

Basically you need to add the ACTION='READWRITE' descriptor to the open statements in the above two files.

If you still struggle with this we will attach the entire files.

1 Like