If you run into troubles, it is always a good habit to report the following information:
  • the way build.mrcc was invoked
  • the output of build.mrcc
  • compiler version (for example: ifort -V, gfortran -v)
  • blas/lapack versions
  • as well as gcc and glibc versions

as well as the value of the relevant environmental variables, such OMP_NUM_THREADS, etc.

This information helps us a lot when figuring out what is going on with your compilation :)

GNU compilers cannot compile xmrcc.f and mrcc.f due to mismatched array sizes

  • TiborGY
  • Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 2 months ago - 3 years 2 months ago #1043 by TiborGY
Dear developers,

I have found it impossible to compile MRCC using the GNU compilers (version 9.3.0), due to what seems to be a problem in the source code of xmrcc.f and mrcc.f, related to the size of the arrays being passed to the "rospc" and "wiadd" subroutines. My understanding of Fortran 77 is very limited but this is what I think the cause of the issue is:

For example:
  1. In xmrcc.f, at line 3911, a 2 element array named iaddo is defined
  2. The next time iaddo occurs (line 3954), it is used as the first argument for rospc
  3. The first argument of rospc is defined (line 4069) as a 13 element array
  4. I assume it is illegal in Fortran 77 to pass a 2 element array where the called subroutine requires a 13 element array, therefore the compilation is aborted.
I do not know what the code does or which array size would be correct, but hopefully someone who has worked on these files would know.
But at first glance, based on what rospc seems to be doing neither 2 or 13 is correct, since the do loop would access elements beyond index 12 if j ever becomes larger than 0. Alternatively, if j can never become larger than 0, then the entire do loop seems to be pointless.
I have managed to placate the compiler by increasing the size of a number of arrays in xmrcc and mrcc to 13 elements, but I have made these changes blindly and I do not know if they are problematic or not. I have attached the "fixed" source files to this post.

Please find the error messages from the compiler below:

xmrcc.f:
Code:
xmrcc.f:3954:23: 3954 | call rospc(iaddo,iaddn,nvirtoldact,noccoldact,wsmax) | 1 Error: Actual argument contains too few elements for dummy argument ‘iadd’ (2/13) at (1) xmrcc.f:3955:23: 3955 | call rospc(wspc2,wspc3,nvirtoldact,noccoldact,wsmax) | 1 Error: Actual argument contains too few elements for dummy argument ‘iadd’ (2/13) at (1) xmrcc.f:3285:25: 3285 | call wiadd(iadd,0,0,i3,i4,0,0,0,0,i9,i10,ile1) | 1 Error: Actual argument contains too few elements for dummy argument ‘iadd’ (2/13) at (1) xmrcc.f:3309:25: 3309 | call wiadd(iadd,i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,ile1) | 1 Error: Actual argument contains too few elements for dummy argument ‘iadd’ (2/13) at (1)

mrcc.f:
Code:
mrcc.f:7583:25: 7583 | call wiadd(iadd,0,0,i3,i4,0,0,0,0,i9,i10,ile1) | 1 Error: Actual argument contains too few elements for dummy argument ‘iadd’ (2/13) at (1) mrcc.f:7615:25: 7615 | call wiadd(iadd,i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,ile1) | 1 Error: Actual argument contains too few elements for dummy argument ‘iadd’ (2/13) at (1) mrcc.f:9959:23: 9959 | call rospc(iaddo,iaddn,nvirtoldact,noccoldact,wsmax) | 1 Error: Actual argument contains too few elements for dummy argument ‘iadd’ (2/13) at (1) mrcc.f:9960:23: 9960 | call rospc(wspc2,wspc3,nvirtoldact,noccoldact,wsmax) | 1 Error: Actual argument contains too few elements for dummy argument ‘iadd’ (2/13) at (1)
Last edit: 3 years 2 months ago by TiborGY.

Please Log in to join the conversation.

More
2 years 7 months ago #1136 by hokru
GNU's gfortran become recently (I think v9 onwards) very strict in that regard.
It was common practice to mismatch the array sizes (not 100% sure what the official standards dictate).
Many were not happy in the Fortran community about this new strictness.

Anyway, "-fallow-argument-mismatch" is the argument to add.
The following user(s) said Thank You: TiborGY

Please Log in to join the conversation.

  • TiborGY
  • Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 7 months ago #1137 by TiborGY
Thanks for the tip.
I am not sure why it was common practice to mismatch array sizes, especially the way I described it above (passing an array that is too small). To me that sounds like putting landmines in your code for no good reason.

Not sure how Fortran handles the underlying storage for arrays, but in C/C++ accessing elements beyond the end of an array is definitely something to be guarded against, so my gut feeling tells me that allowing such mismatches is just hiding the landmines.

Please Log in to join the conversation.

Time to create page: 0.041 seconds
Powered by Kunena Forum