Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor I
24 Views

if the module has a interface, when i click build solution, it always rebuilds

Jump to solution

recently i suffer the problem of rebuilding everything even when i do nothing with my code

i find the interface is one of reasons, an example like this

module inter
    !interface itf
    !    module procedure:: op
    !end interface
contains
    subroutine op
    end subroutine op
end module inter

program main

end program main

if without the interface, clicking <build solution> throws the message 'up to date'

but once the module has an interface, visual studio always rebuild the file when i click <build solution>

is there any way avoiding this situation?

it takes me too much time when debugging my project!

 

i use psxe2017 updta2 and vs2015

0 Kudos

Accepted Solutions
Highlighted
Black Belt Retired Employee
24 Views

I can reproduce this with your source. A workaround is to remove the "module" keyword from "module procedure" (it is optional in this context.) Looks like a bug in the build system's dependency analyzer.

View solution in original post

0 Kudos
11 Replies
Highlighted
Black Belt Retired Employee
24 Views

I can reproduce this with your source. A workaround is to remove the "module" keyword from "module procedure" (it is optional in this context.) Looks like a bug in the build system's dependency analyzer.

0 Kudos
Highlighted
Black Belt Retired Employee
25 Views

I can reproduce this with your source. A workaround is to remove the "module" keyword from "module procedure" (it is optional in this context.) Looks like a bug in the build system's dependency analyzer.

View solution in original post

0 Kudos
Highlighted
New Contributor I
24 Views

Steve Lionel (Ret.) wrote:

I can reproduce this with your source. A workaround is to remove the "module" keyword from "module procedure" (it is optional in this context.) Looks like a bug in the build system's dependency analyzer.

thanks for your suggestion, it works in this context

but the rebuilding still exists in my project after modification.

i can't find another reason for now

if i find it, i will let you know

0 Kudos
Highlighted
Employee
24 Views

I also can reproduce this and reported it to Development. I informed them the work around Steve found is only helpful within the small reproducer context and requested help with finding any other possible work around. If you wan to post another reproducer for which the work around is not helpful I will gladly pass that along to Development too.  Thank you for the convenient reproducer also.

(Internal tracking id: DPD200419360)

0 Kudos
Highlighted
New Contributor I
24 Views

Kevin D (Intel) wrote:

I also can reproduce this and reported it to Development. I informed them the work around Steve found is only helpful within the small reproducer context and requested help with finding any other possible work around. If you wan to post another reproducer for which the work around is not helpful I will gladly pass that along to Development too.  Thank you for the convenient reproducer also.

(Internal tracking id: DPD200419360)

when i restart vs, the rebuild disappear

0 Kudos
Highlighted
New Contributor I
24 Views

Steve Lionel (Ret.) wrote:

I can reproduce this with your source. A workaround is to remove the "module" keyword from "module procedure" (it is optional in this context.) Looks like a bug in the build system's dependency analyzer.

when i restart vs, the rebuild disappear

 

and i want know what's the difference between the <module procedure> and <procedure>

 

0 Kudos
Highlighted
24 Views

In a module, contained subroutines and functions do not require an interface.

In your example case, your "interface" is simply a redeclaration for a subroutine. In your actual program,  you may have multiple different subroutines (i.e. as for generic interface), or you simply wish to rename the interface.

Try placing into a separate module (and compilation unit) and use the only and => to remap the names. You may also need to specify a dependency in the solution such that the contains module is built first. IOW this may require your solution to have (at least) 3 projects:

1) contains module project (also holding general data)
2) interface module project (dependent upon the contains module)
3) application project (dependent on interface module project)

Jim Dempsey

0 Kudos
Highlighted
Black Belt Retired Employee
24 Views

In Fortran 90, the "module" keyword was required when declaring a module procedure for a generic interface. Fortran 2003 made that keyword optional. There is no difference here.

The "module" keyword is required if you are declaring an interface for a separate module procedure that is supplied in a submodule. 

 

0 Kudos
Highlighted
New Contributor I
24 Views

Steve Lionel (Ret.) wrote:

In Fortran 90, the "module" keyword was required when declaring a module procedure for a generic interface. Fortran 2003 made that keyword optional. There is no difference here.

The "module" keyword is required if you are declaring an interface for a separate module procedure that is supplied in a submodule. 

 

got it! thanks!

0 Kudos
Highlighted
New Contributor I
24 Views

jimdempseyatthecove wrote:

In a module, contained subroutines and functions do not require an interface.

In your example case, your "interface" is simply a redeclaration for a subroutine. In your actual program,  you may have multiple different subroutines (i.e. as for generic interface), or you simply wish to rename the interface.

Try placing into a separate module (and compilation unit) and use the only and => to remap the names. You may also need to specify a dependency in the solution such that the contains module is built first. IOW this may require your solution to have (at least) 3 projects:

1) contains module project (also holding general data)
2) interface module project (dependent upon the contains module)
3) application project (dependent on interface module project)

Jim Dempsey

the description of my title is not accurate

it's not the interface leading to build problem, but the difference of <module procedure> and <procedure>

still thanks for your help

0 Kudos
Highlighted
24 Views

Run a simple experiment:

a) Edit the contains section (this can be as simple as adding a comment)
b) Build

Next, click on Build again. If it rebuilds, then the work around I offered in #8 will prevent the unnecessary build. The suggestion I made was to break the circular dependency (that should not have been there).

If the rebuild did not occur then the removal of the optional "module" keyword is all you have to do (for now).

Jim Dempsey

0 Kudos