New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SCons does not handle fortran submodules and type bound procedures correctly. #3135
Comments
This is the link to the User thread. |
The Fortran scanner needs to ignore this:
The scanner seems to be processing the module function and expecting a function.mod to be generated. |
I looked at the fortran scanner and found the regex that it uses to find module definitions (in src/engine/SCons/Scanner/Fortran.py). The regex is:
and so is designed to not match
as a valid module name should not be a fortran keyword anyway. However SCons still fails for my example after this change. In order to ensure that the scanner had been updated in my build, I first changed my example to comment out any reference to the It therefore seems to me that there is something else in SCons that triggers the error even before the Fortran scanner is called. Any ideas, where this might be? |
@pdiener Can you fork the repo, branch, and push a pull request with your work in progress? Then we can take a look at your work so far and help to resolve any remaining issues. |
Done. I hope I followed the instructions correctly. |
I finally got time to take another look at this and I figured out that the same regex was used in the emitter in FortranCommon.py. Fixing the regex there allowed me to compile my project with scons. As a lot of time had passed, I deleted my fork of scons and created a new one. I have created a pull request based on a checkout of scons from today. |
Upss! Using the previous example I have modified a little and I added two additional fortran files (test_21.f90 and test_22.f90). Both should be ok in fortran sense Javier |
@jglezplatas - Can you add a small snippet of fortran code to your comment showing this additional syntax you have in your zip file? |
The left picture is the file test_21.f90. The module procedure takes the information given in the interface block as you can see on the message of bdbaddog (31/may/2018) and scons works for this case. |
I tried this example out and found that it is indeed the pure attribute does mess scons up so that it thinks there are multiple definitions of a module named pure. I suspect a simple fix is to edit the regexes to also ignore 'module' followed by 'pure'. I can't think of any case where those two keywords would follow each other, except for this case. Unless the programmer really intends to declare a module named 'pure', which would be incredibly stupid. I haven't tried the fix out though. While we're at it we probably also need to include 'elemental' in the regex as this is another keyword that can be used in front of 'subroutine' of 'subroutine'. And then of course there is the Fortran 2008 keyword |
Pictures are not the preferred way to share code in here. |
Understood!
Javier González Platas
Departamento de Física
Avda. Astrofísico Fco. Sánchez s/n
Apartado 456
38200 La Laguna. S/C de Tenerife
T. 922 318 251
M. 629 080 140
ull.es <https://www.ull.es/>
------------------------------
Aviso de confidencialidad
<https://www.ull.es/informacion-sobre-web-institucional/#aviso-confidencialidad>
El mar., 23 abr. 2019 a las 0:07, William Deegan (<notifications@github.com>)
escribió:
… The left picture is the file test_21.f90. The module procedure takes the
information given in the interface block as you can see on the message of
bdbaddog (31/may/2018) and scons works for this case.
While the right picture is the file test_22.f90 that give the problem with
scons in the current version.
In this case the definition of the procedure (subroutine in this case) is
given again (equal that in the interface block). Word "pure" is irrelevant
in this case (or I think it).
[image: submodules_fortran]
<https://user-images.githubusercontent.com/8006859/56525847-db6fca80-654b-11e9-8b96-6cb2c1b014ce.png>
Pictures are not the preferred way to share code in here.
Please just paste the text and then use the right markup to mark it as
code. (surround with triple single back quotes).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3135 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AB5CZSY4TUCCUAGCV4RQUM3PRYZINANCNFSM4FCWPJGA>
.
|
…ly processing interface module declarations
Can you try the code in #3359 to see if
addresses your issue?
…On Mon, Apr 22, 2019 at 6:32 PM jglezplatas ***@***.***> wrote:
Understood!
Javier González Platas
Departamento de Física
Avda. Astrofísico Fco. Sánchez s/n
Apartado 456
38200 La Laguna. S/C de Tenerife
T. 922 318 251
M. 629 080 140
ull.es <https://www.ull.es/>
------------------------------
Aviso de confidencialidad
<
https://www.ull.es/informacion-sobre-web-institucional/#aviso-confidencialidad
>
El mar., 23 abr. 2019 a las 0:07, William Deegan (<
***@***.***>)
escribió:
> The left picture is the file test_21.f90. The module procedure takes the
> information given in the interface block as you can see on the message of
> bdbaddog (31/may/2018) and scons works for this case.
> While the right picture is the file test_22.f90 that give the problem
with
> scons in the current version.
> In this case the definition of the procedure (subroutine in this case) is
> given again (equal that in the interface block). Word "pure" is
irrelevant
> in this case (or I think it).
>
> [image: submodules_fortran]
> <
https://user-images.githubusercontent.com/8006859/56525847-db6fca80-654b-11e9-8b96-6cb2c1b014ce.png
>
>
> Pictures are not the preferred way to share code in here.
> Please just paste the text and then use the right markup to mark it as
> code. (surround with triple single back quotes).
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#3135 (comment)>, or
mute
> the thread
> <
https://github.com/notifications/unsubscribe-auth/AB5CZSY4TUCCUAGCV4RQUM3PRYZINANCNFSM4FCWPJGA
>
> .
>
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#3135 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAAUCNAJLZN7TT2YPHRXVWTPRY4GFANCNFSM4FCWPJGA>
.
|
In order to solve the issue with declaring a type bound procedure as being pure in the module and then repeating that declaration in the submodule, you would have to add PURE to the regex in both the scanner and emitter. I personally prefer to not have to repeat the declaration in the submodule (i.e. by using the "module procedure' syntax instead), but it is not illegal to do so, so it will probably be best Since making this comment 3 days ago, I have been able to confirm (using Javier's example) that adding PURE to the regex fixes the issue. |
Any chance you can fork my branch and update the regex and the tests to
cover this case as well?
…On Thu, Apr 25, 2019 at 6:24 PM pdiener ***@***.***> wrote:
In order to solve the issue with declaring a type bound procedure as being
pure in the module and then repeating that declaration in the submodule,
you would have to add PURE to the regex in both the scanner and emitter. I
personally prefer to not have to repeat the declaration in the submodule
(i.e. by using the "module procedure' syntax instead), but it is not
illegal to do so, so it will probably be best
to expand the regex. The same issue can occur for the declaration of
elemental type bound procedures, so it would probably be prudent to expand
the regex with both PURE and ELEMENTAL.
Since making this comment 3 days ago, I have been able to confirm (using
Javier's example) that adding PURE to the regex fixes the issue.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#3135 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAAUCNB7QHWTSRQPBFWD3ULPSIVTVANCNFSM4FCWPJGA>
.
|
Then you can send me a pull request against my branch, when I merge that
it'll update into this pull request.
On Thu, Apr 25, 2019 at 10:10 PM Bill Deegan <bill@baddogconsulting.com>
wrote:
… Any chance you can fork my branch and update the regex and the tests to
cover this case as well?
On Thu, Apr 25, 2019 at 6:24 PM pdiener ***@***.***> wrote:
> In order to solve the issue with declaring a type bound procedure as
> being pure in the module and then repeating that declaration in the
> submodule, you would have to add PURE to the regex in both the scanner and
> emitter. I personally prefer to not have to repeat the declaration in the
> submodule (i.e. by using the "module procedure' syntax instead), but it is
> not illegal to do so, so it will probably be best
> to expand the regex. The same issue can occur for the declaration of
> elemental type bound procedures, so it would probably be prudent to expand
> the regex with both PURE and ELEMENTAL.
>
> Since making this comment 3 days ago, I have been able to confirm (using
> Javier's example) that adding PURE to the regex fixes the issue.
>
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub
> <#3135 (comment)>, or mute
> the thread
> <https://github.com/notifications/unsubscribe-auth/AAAUCNB7QHWTSRQPBFWD3ULPSIVTVANCNFSM4FCWPJGA>
> .
>
|
Hi!
Happy to do test but the problem is that I don't know how apply your
changes.
Where I find the instructions to follow?
Javier González Platas
Departamento de Física
Avda. Astrofísico Fco. Sánchez s/n
Apartado 456
38200 La Laguna. S/C de Tenerife
T. 922 318 251
M. 629 080 140
ull.es <https://www.ull.es/>
------------------------------
Aviso de confidencialidad
<https://www.ull.es/informacion-sobre-web-institucional/#aviso-confidencialidad>
El vie., 26 abr. 2019 a las 4:11, William Deegan (<notifications@github.com>)
escribió:
… Then you can send me a pull request against my branch, when I merge that
it'll update into this pull request.
On Thu, Apr 25, 2019 at 10:10 PM Bill Deegan ***@***.***>
wrote:
> Any chance you can fork my branch and update the regex and the tests to
> cover this case as well?
>
> On Thu, Apr 25, 2019 at 6:24 PM pdiener ***@***.***>
wrote:
>
>> In order to solve the issue with declaring a type bound procedure as
>> being pure in the module and then repeating that declaration in the
>> submodule, you would have to add PURE to the regex in both the scanner
and
>> emitter. I personally prefer to not have to repeat the declaration in
the
>> submodule (i.e. by using the "module procedure' syntax instead), but it
is
>> not illegal to do so, so it will probably be best
>> to expand the regex. The same issue can occur for the declaration of
>> elemental type bound procedures, so it would probably be prudent to
expand
>> the regex with both PURE and ELEMENTAL.
>>
>> Since making this comment 3 days ago, I have been able to confirm (using
>> Javier's example) that adding PURE to the regex fixes the issue.
>>
>> —
>> You are receiving this because you commented.
>> Reply to this email directly, view it on GitHub
>> <#3135 (comment)>,
or mute
>> the thread
>> <
https://github.com/notifications/unsubscribe-auth/AAAUCNB7QHWTSRQPBFWD3ULPSIVTVANCNFSM4FCWPJGA
>
>> .
>>
>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3135 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AB5CZS2XVQFQJJ4A36ADP3LPSJQELANCNFSM4FCWPJGA>
.
|
I have never used git. I only use svn for my projects.
You are asking me something that I don't know how do....Sorry.
At the same time, I have done a copy of files modified and I'm trying to
replace for the original that I have in order to see if it works.
Javier González Platas
Departamento de Física
Avda. Astrofísico Fco. Sánchez s/n
Apartado 456
38200 La Laguna. S/C de Tenerife
T. 922 318 251
M. 629 080 140
ull.es <https://www.ull.es/>
------------------------------
Aviso de confidencialidad
<https://www.ull.es/informacion-sobre-web-institucional/#aviso-confidencialidad>
El vie., 26 abr. 2019 a las 8:27, Javier GONZALEZ PLATAS (<
jplatas@ull.edu.es>) escribió:
… Hi!
Happy to do test but the problem is that I don't know how apply your
changes.
Where I find the instructions to follow?
Javier González Platas
Departamento de Física
Avda. Astrofísico Fco. Sánchez s/n
Apartado 456
38200 La Laguna. S/C de Tenerife
T. 922 318 251
M. 629 080 140
ull.es <https://www.ull.es/>
------------------------------
Aviso de confidencialidad
<https://www.ull.es/informacion-sobre-web-institucional/#aviso-confidencialidad>
El vie., 26 abr. 2019 a las 4:11, William Deegan (<
***@***.***>) escribió:
> Then you can send me a pull request against my branch, when I merge that
> it'll update into this pull request.
>
> On Thu, Apr 25, 2019 at 10:10 PM Bill Deegan ***@***.***>
> wrote:
>
> > Any chance you can fork my branch and update the regex and the tests to
> > cover this case as well?
> >
> > On Thu, Apr 25, 2019 at 6:24 PM pdiener ***@***.***>
> wrote:
> >
> >> In order to solve the issue with declaring a type bound procedure as
> >> being pure in the module and then repeating that declaration in the
> >> submodule, you would have to add PURE to the regex in both the scanner
> and
> >> emitter. I personally prefer to not have to repeat the declaration in
> the
> >> submodule (i.e. by using the "module procedure' syntax instead), but
> it is
> >> not illegal to do so, so it will probably be best
> >> to expand the regex. The same issue can occur for the declaration of
> >> elemental type bound procedures, so it would probably be prudent to
> expand
> >> the regex with both PURE and ELEMENTAL.
> >>
> >> Since making this comment 3 days ago, I have been able to confirm
> (using
> >> Javier's example) that adding PURE to the regex fixes the issue.
> >>
> >> —
> >> You are receiving this because you commented.
> >> Reply to this email directly, view it on GitHub
> >> <#3135 (comment)>,
> or mute
> >> the thread
> >> <
> https://github.com/notifications/unsubscribe-auth/AAAUCNB7QHWTSRQPBFWD3ULPSIVTVANCNFSM4FCWPJGA
> >
> >> .
> >>
> >
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#3135 (comment)>, or mute
> the thread
> <https://github.com/notifications/unsubscribe-auth/AB5CZS2XVQFQJJ4A36ADP3LPSJQELANCNFSM4FCWPJGA>
> .
>
|
Hello William
I have done the next
1.- I have tried to add PURE and ELEMENTAL using this
def_regex =
"""(?i)^\s*MODULE\s+(?!PROCEDURE|PURE|ELEMENTAL|SUBROUTINE|FUNCTION)(\w+)"""
in both files but I have the same error. Probably is my fault and this line
must be written in other form.
2.- So, I deleted the words Pure and elemental on my interfaces
declarations and also on the definitions of the procedures.
It seems works
But now I have other problem. Scons is trying to compile fortran files
before others.
I have modules and submodules in different files. For any reason Scons try
to compile submodule files before than their parent module fortran file.
Is possible define the order of compilation using Scons?
I have tried define a list with modules files before and other list
containing the submodules. Maybe this is the error...
Javier
Javier González Platas
Departamento de Física
Avda. Astrofísico Fco. Sánchez s/n
Apartado 456
38200 La Laguna. S/C de Tenerife
T. 922 318 251
M. 629 080 140
ull.es <https://www.ull.es/>
------------------------------
Aviso de confidencialidad
<https://www.ull.es/informacion-sobre-web-institucional/#aviso-confidencialidad>
El vie., 26 abr. 2019 a las 9:28, Javier GONZALEZ PLATAS (<
jplatas@ull.edu.es>) escribió:
… I have never used git. I only use svn for my projects.
You are asking me something that I don't know how do....Sorry.
At the same time, I have done a copy of files modified and I'm trying to
replace for the original that I have in order to see if it works.
Javier González Platas
Departamento de Física
Avda. Astrofísico Fco. Sánchez s/n
Apartado 456
38200 La Laguna. S/C de Tenerife
T. 922 318 251
M. 629 080 140
ull.es <https://www.ull.es/>
------------------------------
Aviso de confidencialidad
<https://www.ull.es/informacion-sobre-web-institucional/#aviso-confidencialidad>
El vie., 26 abr. 2019 a las 8:27, Javier GONZALEZ PLATAS (<
***@***.***>) escribió:
> Hi!
> Happy to do test but the problem is that I don't know how apply your
> changes.
> Where I find the instructions to follow?
>
> Javier González Platas
>
>
>
> Departamento de Física
> Avda. Astrofísico Fco. Sánchez s/n
> Apartado 456
> 38200 La Laguna. S/C de Tenerife
>
> T. 922 318 251
> M. 629 080 140
>
> ull.es <https://www.ull.es/>
> ------------------------------
> Aviso de confidencialidad
> <https://www.ull.es/informacion-sobre-web-institucional/#aviso-confidencialidad>
>
>
> El vie., 26 abr. 2019 a las 4:11, William Deegan (<
> ***@***.***>) escribió:
>
>> Then you can send me a pull request against my branch, when I merge that
>> it'll update into this pull request.
>>
>> On Thu, Apr 25, 2019 at 10:10 PM Bill Deegan ***@***.***>
>> wrote:
>>
>> > Any chance you can fork my branch and update the regex and the tests to
>> > cover this case as well?
>> >
>> > On Thu, Apr 25, 2019 at 6:24 PM pdiener ***@***.***>
>> wrote:
>> >
>> >> In order to solve the issue with declaring a type bound procedure as
>> >> being pure in the module and then repeating that declaration in the
>> >> submodule, you would have to add PURE to the regex in both the
>> scanner and
>> >> emitter. I personally prefer to not have to repeat the declaration in
>> the
>> >> submodule (i.e. by using the "module procedure' syntax instead), but
>> it is
>> >> not illegal to do so, so it will probably be best
>> >> to expand the regex. The same issue can occur for the declaration of
>> >> elemental type bound procedures, so it would probably be prudent to
>> expand
>> >> the regex with both PURE and ELEMENTAL.
>> >>
>> >> Since making this comment 3 days ago, I have been able to confirm
>> (using
>> >> Javier's example) that adding PURE to the regex fixes the issue.
>> >>
>> >> —
>> >> You are receiving this because you commented.
>> >> Reply to this email directly, view it on GitHub
>> >> <#3135 (comment)>,
>> or mute
>> >> the thread
>> >> <
>> https://github.com/notifications/unsubscribe-auth/AAAUCNB7QHWTSRQPBFWD3ULPSIVTVANCNFSM4FCWPJGA
>> >
>> >> .
>> >>
>> >
>>
>> —
>> You are receiving this because you were mentioned.
>> Reply to this email directly, view it on GitHub
>> <#3135 (comment)>, or mute
>> the thread
>> <https://github.com/notifications/unsubscribe-auth/AB5CZS2XVQFQJJ4A36ADP3LPSJQELANCNFSM4FCWPJGA>
>> .
>>
>
|
Just FYI, here's one approach. If you have the link to a github Pull Request (PR), you can use that same link and append
|
It'd be easier to just do the following: https://github.com/SCons/scons/wiki/GitWorkflows Clearly you already have a github account. Do you use IRC, if so jump over to #scons and I'll help you through it. For scons/scons on github. |
Also please update src/CHANGES to have your name instead of your Github username if you like. |
@bdbaddog. I'll try to fork your branch and update the regex and test. I have not looked at how tests are done before, so have to figure that out first. |
@bdbaddog. I have added PURE and ELEMENTAL to the regex and updated the tests accordingly. I have created a pull request. |
@pdiener - Thanks! That wasn't too tough was it? They make the process reasonable. I've merged and once the testing is complete baring issues I'll merge to master and it will make it into the next release! |
Fix Issue #3135 - Type Bound procedures in Fortran submodules
Merged #3359 - It will show up in next release. |
@bdbaddog. No it wasn't too tough. I'm just not very experienced with the git workflow used here, so I had to take it slow and make sure I did everything correct. I also had not used the scons testing infrastructure before, so I had to spend some time figuring out where things were. Happy to contribute and looking forward to check out the next release. Is there a plan for when the next release will happen? |
@pdiener - No hard schedule at this point. Hopefully not too long. A couple bugs I'd like to knock out first. |
SCons seems to think that the declaration of the interface of type bound procedures in a module declares a module named function. This happens when the definition of the procedures are in submodules.
Version of SCons
I have tried both SCons 3.0.1 and the latest development version SCons 3.1.0.alpha.
Version of Python
Python 2.7.12
Which python distribution if applicable (python.org, cygwin, anaconda, macports, brew,etc)
OpenSuse
How you installed SCons
For version SCons 3.0.1:
Downloaded and unpacked the tar ball from SourceForge cd'ed into the scons-3.0.1 directory and did 'python setup.py install' as root.
For Version SCons 3.1.0.alpha:
Cloned the git repository (git clone https://github.com/SCons/scons.git) cd'ed into the scons directory and did 'python bootstrap.py', 'cd build/scons' and finally 'python setup.py install' as root.
What Platform are you on? (Linux/Windows and which version)
Linux OpenSuse 42.1
How to reproduce your issue? Please include a small self contained reproducer. Likely a SConstruct should do for most issues.
In the following zip-file, there are 3 fortran source files and an SConstruct file that shows the issue.
scons-submodule.zip
When I run scons I get:
scons: *** Multiple ways to build the same target were specified for: function.mod (from ['test_1.f90'] and from ['test_2.f90'])
File "/home/diener/TMP/SCons_Test/SConstruct", line 28, in <module>
Link to SCons Users thread discussing your issue.
https://pairlist4.pair.net/pipermail/scons-users/2018-April/006893.html
The text was updated successfully, but these errors were encountered: