<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""></div> So it actually does not load everything at the call to use but waits until the subroutine definitions and then only loads what you ask to import? <div class=""><br class=""></div><div class=""> Sorry, this is odd, with C include or python import it immediately loads up everything as soon as it sees the include or import, there is no way later to say "wo hoarsy I didn't really mean you should get everything I asked, for please only load up a subset". But then Fortran was always weird, when I saw presentations of the Fortran standards committee members I always felt like they read every third page of some computer science book but never realized they missed many of the pages.</div><div class=""><br class=""></div><div class=""> But, ok, if it works, it works. </div><div class=""><br class=""></div><div class=""> Barry</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Mar 16, 2021, at 6:54 PM, Jacob Faibussowitsch <<a href="mailto:jacob.fai@gmail.com" class="">jacob.fai@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><blockquote type="cite" class=""><span class="" style="display: inline !important;">I am puzzled by the import tXXX, how it can work? How does it know what module file to look in for the import? With use xxx the xxx gets translated directly to a file name. But with import tXXX that is impossible.</span></blockquote><div class=""><br class=""></div>Its similar to nested namespace semantics, you “use" the super-namespace at the module level then import the objects at interface of that module. i.e.:<div class=""><br class=""></div><div class="">Module foo</div><div class=""> Use bar <—— module contains bop</div><div class=""> Interface </div><div class=""> Subroutine baz(x)</div><div class=""> Import bop <—— hoists bop out of bar defined in super-scope</div><div class=""> Bop x</div><div class=""> End subroutine</div><div class=""> End interface</div><div class="">End module</div><div class=""><br class=""><div class="">
<div dir="auto" style="caret-color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class="">Best regards,<br class=""><br class="">Jacob Faibussowitsch<br class="">(Jacob Fai - booss - oh - vitch)<br class="">Cell: (312) 694-3391</div></div>
</div>
<div class=""><br class=""><blockquote type="cite" class=""><div class="">On Mar 16, 2021, at 18:25, Barry Smith <<a href="mailto:bsmith@petsc.dev" class="">bsmith@petsc.dev</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta charset="UTF-8" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">On Mar 16, 2021, at 5:03 PM, Satish Balay <<a href="mailto:balay@mcs.anl.gov" class="">balay@mcs.anl.gov</a>> wrote:<br class=""><br class="">On Tue, 16 Mar 2021, Barry Smith wrote:<br class=""><br class=""><blockquote type="cite" class=""><br class="">Jacob,<br class=""><br class=""> You very well may be right, splitting may not be needed or relevant. I only advocated it since for Mat it did fix a VM gfortran memory issue. How closely the IBM compiler and gfortran issues are I do not know.<span class="Apple-converted-space"> </span><br class=""><br class="">My MR Mat split is read to to go into main.<br class=""><br class=""><a href="https://gitlab.com/petsc/petsc/-/merge_requests/3715" class="">https://gitlab.com/petsc/petsc/-/merge_requests/3715</a> <<a href="https://gitlab.com/petsc/petsc/-/merge_requests/3715" class="">https://gitlab.com/petsc/petsc/-/merge_requests/3715</a>> The MPI one is still needing some babysitting, hopefully it can pass the CI and get into main soon.<br class=""><br class="">Both should be in main before starting to muck with changing the use stuff for the IBM compiler.<br class=""><br class="">Satish, does your Vec file split pass the CI? If so I think we should also get it into main before messing with the use for the IBM compiler.<br class=""></blockquote><br class="">Barry - if the switch from 'use' to 'import' is sufficient [for VM builds] - should we still split the sources? Right now it changes only the auto-fortran stubs, fixing custom stubs should give further improvements.<br class=""></blockquote><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class=""> If the import solves the VM gfortran problem then I see no reason to split the source (it is a little easier to maintain as one file).<span class="Apple-converted-space"> </span></span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class=""> So maybe, for now use the import and later if the VM gfortran problem continues we split the source.</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class=""> Barry</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class=""> I am puzzled by the import tXXX, how it can work? How does it know what module file to look in for the import? With use xxx the xxx gets translated directly to a file name. But with import tXXX that is impossible.</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br class="">If spliting sources is useful - I'll look into pushing the Vec split into this MR.<br class=""><br class="">BTW: Matt - can you test balay/reorg-f90-for-xlf branch against 'gfortran VM'?<br class=""><br class="">Satish<br class=""><br class=""><blockquote type="cite" class=""><br class=""><br class="">Who has access to the wonky IBM compiler? Is there any way to have general access so it can be added to the CI and we can maintain code that works with it? Or does someone need to fix things one at a time, first Vec, then Mat, then ....<span class="Apple-converted-space"> </span><br class=""><br class=""><br class="">Barry<br class=""><br class=""><br class=""><blockquote type="cite" class="">On Mar 16, 2021, at 2:14 PM, Satish Balay via petsc-dev <<a href="mailto:petsc-dev@mcs.anl.gov" class="">petsc-dev@mcs.anl.gov</a>> wrote:<br class=""><br class="">On Tue, 16 Mar 2021, Matthew Knepley wrote:<br class=""><br class=""><blockquote type="cite" class="">On Tue, Mar 16, 2021 at 2:42 PM Jacob Faibussowitsch <<a href="mailto:jacob.fai@gmail.com" class="">jacob.fai@gmail.com</a>><br class="">wrote:<br class=""><br class=""><blockquote type="cite" class="">To me the best solution is to first split the files when possible (it is<br class="">often not or just too painful) and then adding imports if needed.<br class=""><br class=""><br class="">I’m not sure I agree. Bear in mind my familiarity with fortran is very<br class="">limited, but to me the “use” statement is similar to #include <header> in C<br class="">or using namespace xxx in cpp.<br class=""><br class="">Our fortran interface is not optimal code atm, it’s as if we put a<br class="">"#include <petscvec.h>” before every Vec function in the C source<br class="">(assuming include guards are not used). Sure you can fix this by splitting<br class="">the vec src files in two, but at the end of the day that’s a bandaid<br class="">solution. I think I can get the import stuff to work reasonably well (a lot<br class="">of the infrastructure to capture types is already present in the current<br class="">generatefortranstubs).<br class=""><br class=""></blockquote><br class="">If you can get this to work, we should definitely do it. Was there a<br class="">question about getting it to work?<br class=""></blockquote><br class="">Likely these additional changes should be done starting with Barry's split-up of sources.<br class=""><br class="">Satish<br class=""><br class=""><blockquote type="cite" class=""><br class="">Thanks,<br class=""><br class=""> Matt<br class=""><br class=""><br class=""><blockquote type="cite" class="">Best regards,<br class=""><br class="">Jacob Faibussowitsch<br class="">(Jacob Fai - booss - oh - vitch)<br class="">Cell: (312) 694-3391<br class=""><br class="">On Mar 16, 2021, at 12:56, Barry Smith <<a href="mailto:bsmith@petsc.dev" class="">bsmith@petsc.dev</a>> wrote:<br class=""><br class=""><br class="">Jacob,<br class=""><br class=""> I split the mat definitions in the MR<br class=""><a href="https://gitlab.com/petsc/petsc/-/merge_requests/3696" class="">https://gitlab.com/petsc/petsc/-/merge_requests/3696</a> and this reduced<br class="">memory requirements enough to get builds through on some VM that failed<br class="">previously ran out of memory (with gfortran).<br class=""><br class=""> The petsc*mod.F90 files are all handwritten so it is ok to manually<br class="">change them with imports if that helps the IBM compiler. To me the best<br class="">solution is to first split the files when possible (it is often not or just<br class="">too painful) and then adding imports if needed.<br class=""><br class=""> Note also the MR<br class=""><a href="https://gitlab.com/petsc/petsc/-/merge_requests/3715/diffs" class="">https://gitlab.com/petsc/petsc/-/merge_requests/3715/diffs</a> which may help<br class="">a great deal with the IBM compiler or not.<br class=""><br class=""> Thanks<br class=""><br class=""> Barry<br class=""><br class=""><br class=""><br class="">On Mar 16, 2021, at 11:47 AM, Jacob Faibussowitsch <<a href="mailto:jacob.fai@gmail.com" class="">jacob.fai@gmail.com</a>><br class="">wrote:<br class=""><br class="">Ok something I have gotten to work, but only doing things by hand in<br class="">petscvecmod.F90:<br class=""><br class="">diff --git a/src/vec/f90-mod/petscvecmod.F90<br class="">b/src/vec/f90-mod/petscvecmod.F90<br class="">index 0c447156b9..ef3e2e2e55 100644<br class="">--- a/src/vec/f90-mod/petscvecmod.F90<br class="">+++ b/src/vec/f90-mod/petscvecmod.F90<br class="">module petscisdef<br class="">use petscisdefdummy<br class="">interface operator(.ne.)<br class="">function isnotequal(A,B)<br class="">- use petscisdefdummy<br class="">+ import tIS<br class="">logical isnotequal<br class=""><br class="">type(tIS), intent(in) :: A,B<br class="">end function isnotequal<br class=""><br class="">This works for everything wrapped in a module which contains an interface<br class="">block. For dangling functions the following works:<br class=""><br class="">function isnotequal(A,B)<br class="">- use petscisdefdummy<br class="">+ use petscisdef, only: tIs<br class="">logical isnotequal<br class="">type(tIS), intent(in) :: A,B<br class="">isnotequal = (A%v .ne. B%v)<br class="">end function isnotequal<br class=""><br class="">Do our fortran stub generators have any notion of types? Specifically<br class="">types that originate from petsc?<br class=""><br class="">Best regards,<br class=""><br class="">Jacob Faibussowitsch<br class="">(Jacob Fai - booss - oh - vitch)<br class="">Cell: (312) 694-3391<br class=""><br class="">On Mar 16, 2021, at 11:11, Satish Balay <<a href="mailto:balay@mcs.anl.gov" class="">balay@mcs.anl.gov</a>> wrote:<br class=""><br class="">On Tue, 16 Mar 2021, Jacob Faibussowitsch wrote:<br class=""><br class="">My [partial] change is in branch balay/reorg-f90-for-xlf<br class=""><br class=""><br class="">Satish is this branch pushed? I’d like to send it to the ibm folks to see<br class="">if it works for them as well.<br class=""><br class=""><br class="">Sorry - pushed now. From what I remember - it didn't work.<br class=""><br class="">Satish<br class=""><br class=""><br class="">They also added this extra follow up:<br class=""><br class="">The change we did in the source files is to replace all the "use pet*"<br class="">statements in all the Interface blocks with IMPORT statement.<br class=""><br class="">The nature of this workaround is to reduce the number of symbols that the<br class="">compiler have to create, which exceeded the limitation and caused ICE.<br class=""><br class="">Every USE statement in an interface block opens up the module symbol file<br class="">and reads all the symbols from it and creates an entity for each symbol in<br class="">compiler. This is unnecessary when the module already has the same USE<br class="">statement in the module scope. Instead, users can use IMPORT statement to<br class="">make the module symbols accessible inside interface face blocks.<br class=""><br class="">With the change, the compiler would only read the module symbol file once<br class="">and create one set of symbols where the old code reads the module symbol<br class="">files as many times as the number of the USE statements in Interface blocks<br class="">and create that many sets of duplicate symbols. Replacing those USE<br class="">statements with IMPORT statements also shortens the compile time<br class="">significantly.<br class=""><br class="">Best regards,<br class=""><br class="">Jacob Faibussowitsch<br class="">(Jacob Fai - booss - oh - vitch)<br class="">Cell: (312) 694-3391<br class=""><br class="">On Mar 3, 2021, at 13:43, Satish Balay via petsc-dev <<br class=""><a href="mailto:petsc-dev@mcs.anl.gov" class="">petsc-dev@mcs.anl.gov</a>> wrote:<br class=""><br class="">The only change I can get working (i.e avoid compile errors) is to split<br class="">petscvecmod.F90 into 2 source files - but I don't know if this will help<br class="">with xlf..<br class=""><br class="">My [partial] change is in branch balay/reorg-f90-for-xlf<br class=""><br class="">Satish<br class=""><br class="">On Wed, 3 Mar 2021, Satish Balay via petsc-dev wrote:<br class=""><br class="">On Wed, 3 Mar 2021, Satish Balay via petsc-dev wrote:<br class=""><br class="">Sure - once any change works locally [for gcc and xlf]<br class=""><br class="">When I try - I get a bunch of errors.. [yet to digest them.]<br class=""><br class=""><br class="">Can you please give the following source code workaround a try?<br class="">Since there is already "use petscvecdefdummy" at the module scope, one<br class="">workaround might be to remove the unnecessary "use petscvecdefdummy" in<br class="">vecnotequal and vecequals<br class="">and all similar procedures.<br class=""><br class="">For example, the test case has:<br class=""> module petscvecdef<br class=""> use petscvecdefdummy<br class="">...<br class=""> function vecnotequal(A,B)<br class=""> use petscvecdefdummy<br class=""> logical vecnotequal<br class=""> type(tVec), intent(in) :: A,B<br class=""> vecnotequal = (A%v .ne. B%v)<br class=""> end function<br class=""><br class=""><br class=""><br class="">Ok - try this suggestion:<br class=""><br class="">diff --git a/src/vec/f90-mod/petscvecmod.F90<br class="">b/src/vec/f90-mod/petscvecmod.F90<br class="">index 0c447156b9..81968c7ca1 100644<br class="">--- a/src/vec/f90-mod/petscvecmod.F90<br class="">+++ b/src/vec/f90-mod/petscvecmod.F90<br class="">@@ -77,7 +77,6 @@<br class=""> use petscvecdefdummy<br class=""> interface operator(.ne.)<br class=""> function vecnotequal(A,B)<br class="">- use petscvecdefdummy<br class=""> logical vecnotequal<br class=""> type(tVec), intent(in) :: A,B<br class=""> end function<br class=""><br class=""><br class=""><br class=""> FC arch-linux-c-debug/obj/vec/f90-mod/petscvecmod.o<br class="">/home/balay/petsc/src/vec/f90-mod/petscvecmod.F90:81:22:<br class=""><br class="">81 | type(tVec), intent(in) :: A,B<br class=""> | 1<br class="">Error: Derived type ‘tvec’ at (1) is being used before it is defined<br class=""><br class="">/home/balay/petsc/include/../src/vec/f90-mod/ftn-auto-interfaces/petscis.h90:2:10:<br class=""><br class="">2 | use petscvecdef<br class=""> | 1<br class="">Fatal Error: Cannot open module file ‘petscvecdef.mod’ for reading at (1):<br class="">No such file or directory<br class=""><<<<<<<br class=""><br class="">Satish</blockquote></blockquote></blockquote></blockquote></blockquote></div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div></body></html>