Re: [petsc-users] Installation issue of 3.18.* and 3.19.0 on Apple systems

2023-04-06 Thread Satish Balay via petsc-users
Great! I created MR for this change

https://gitlab.com/petsc/petsc/-/merge_requests/6289

Satish

On Thu, 6 Apr 2023, Kaus, Boris wrote:

> Apologies, mistake on my side. Yes this works - thanks a lot for your help!
> 
> Boris
> 
> On 6. Apr 2023, at 00:56, Satish Balay  wrote:
> 
> This is strange. I can trigger the error with:
> 
> -  v = tuple([int(a) for a in platform.mac_ver()[0].split('.')])
> +  v = tuple([int('')])
> 
> and this fix is able to overcome it.
> 
> I pushed this change to `balay/fix-macos-version-check` branch - can you try 
> from it?
> 
> Satish
> 
> On Wed, 5 Apr 2023, Kaus, Boris wrote:
> 
> I don’t understand why this keeps giving the same error (shouldn’t):
> 
> sandbox:${WORKSPACE}/srcdir/petsc-3.18.0 #  ./configure 
> --prefix=/workspace/destdir/lib/petsc/double_real_Int32/
> ***
>TypeError or ValueError possibly related to ERROR in COMMAND LINE ARGUMENT 
> while running ./configure
> ---
> invalid literal for int() with base 10: ''
> ***
> 
> 
>  File "/workspace/srcdir/petsc-3.18.0/config/configure.py", line 457, in 
> petsc_configure
>framework = 
> config.framework.Framework(['--configModules=PETSc.Configure','--optionsModule=config.compilerOptions']+sys.argv[1:],
>  loadArgDB = 0)
>  File 
> "/workspace/srcdir/petsc-3.18.0/config/BuildSystem/config/framework.py", line 
> 101, in __init__
>self.createChildren()
>  File 
> "/workspace/srcdir/petsc-3.18.0/config/BuildSystem/config/framework.py", line 
> 338, in createChildren
>self.getChild(moduleName)
>  File 
> "/workspace/srcdir/petsc-3.18.0/config/BuildSystem/config/framework.py", line 
> 323, in getChild
>config.setupDependencies(self)
>  File "/workspace/srcdir/petsc-3.18.0/config/PETSc/Configure.py", line 89, in 
> setupDependencies
>self.registerPythonFile(utility,'config.utilities')
>  File "/workspace/srcdir/petsc-3.18.0/config/PETSc/Configure.py", line 49, in 
> registerPythonFile
>utilityObj = 
> self.framework.require(directory+utilityName, self)
>  File 
> "/workspace/srcdir/petsc-3.18.0/config/BuildSystem/config/framework.py", line 
> 343, in require
>config = self.getChild(moduleName, keywordArgs)
>  File 
> "/workspace/srcdir/petsc-3.18.0/config/BuildSystem/config/framework.py", line 
> 317, in getChild
>config = type(self, *keywordArgs)
>  File 
> "/workspace/srcdir/petsc-3.18.0/config/BuildSystem/config/utilities/macosFirewall.py",
>  line 12, in __init__
>self.isDarwin = config.setCompilers.Configure.isDarwin(self.log)
>  File 
> "/workspace/srcdir/petsc-3.18.0/config/BuildSystem/config/setCompilers.py", 
> line 676, in isDarwin
>if not isUname_value: config.setCompilers.Configure.isUname(log)
>  File 
> "/workspace/srcdir/petsc-3.18.0/config/BuildSystem/config/setCompilers.py", 
> line 631, in isUname
>v = tuple([int(a) for a in platform.mac_ver()[0].split('.')])
>  File 
> "/workspace/srcdir/petsc-3.18.0/config/BuildSystem/config/setCompilers.py", 
> line 631, in 
>v = tuple([int(a) for a in platform.mac_ver()[0].split('.')])
> 
> 
> On 5. Apr 2023, at 23:58, Satish Balay  wrote:
> 
> Ah - my patch was buggy.
> 
> +except RuntimeError:
> 
> should be: 'except:' i.e:
> 
> diff --git a/config/BuildSystem/config/setCompilers.py 
> b/config/BuildSystem/config/setCompilers.py
> index 57848e736e3..e191c1e1b4d 100644
> --- a/config/BuildSystem/config/setCompilers.py
> +++ b/config/BuildSystem/config/setCompilers.py
> @@ -630,10 +630,14 @@ class Configure(config.base.Configure):
>if log: log.write('Detected Darwin')
>isDarwin_value = True
>import platform
> -v = tuple([int(a) for a in platform.mac_ver()[0].split('.')])
> -if v >= (10,15,0):
> -  if log: log.write('Detected Darwin/MacOSX Catalina OS\n')
> -  isDarwinCatalina_value = True
> +try:
> +  v = tuple([int(a) for a in platform.mac_ver()[0].split('.')])
> +  if v >= (10,15,0):
> +if log: log.write('Detected Darwin/MacOSX Catalina OS\n')
> +isDarwinCatalina_value = True
> +except:
> +  if log: log.write('MacOS version detecton failed!\n')
> +  pass
>  if output.find('freebsd') >= 0:
>if log: log.write('Detected FreeBSD')
>isFreeBSD_value = True
> 
> Satish
> 
> 
> 
> 
> On Wed, 5 Apr 2023, Kaus, Boris wrote:
> 
> Perhaps python is broken, or perhaps this is because it is not a real Mac OS, 
> but an emulated one.
> 
> Seems a similar error now occurs a bit down the line:
> 
> ---
> 
> sandbox:${WORKSPACE}/srcdir/petsc-3.18.0 #  ./configure 
> --prefix=/workspace/destdir/lib/petsc/double_real_Int32/
> ***
>   

Re: [petsc-users] How to use PETSc real version and complex version simultaneously?

2023-04-06 Thread gaochenyi14
Thanks for the hint.I did a naive test and managed to use the same function with different typedefs. Basically, it is relied on that C has no name mangling while C++ has name mangling. Could this trick applies to PETSc? The files for the test are attached. The procedure for compilation is in the `main.cpp`Best regards,C.-Y. GAO<>
On Apr 6, 2023, at 02:04, Matthew Knepley  wrote:On Wed, Apr 5, 2023 at 1:59 PM gaochenyi14  wrote:Hi,

I rely on PETSc to deal with real and complex sparse matrices of dimension 1e4 * 1e4 or above. I want to use real version when only real matrices are involved, to achieve better performance, and use complex version only when complex matrices get involved. But in the manual it says different versions can not be used at the same time. Can this restriction be circumvented? If not, where does the restriction come from?It is possible to do this, but it is cumbersome. You would have to compile both versions of the library, dlopen() them, and get the symbols you need. A group at Purdue has done this, but it is involved.We use typedefs to change between real and complex. It would not be difficult to allow storage in several types. However, prescribing how one type interactes with another, particularly when data is passed in or out, is challenging. This difficulty does not go away with templates since it is about type interaction, not polymorphism.  Thanks,     Matt 
All the best,
C.-Y. GAO
-- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.-- Norbert Wienerhttps://www.cse.buffalo.edu/~knepley/


Re: [petsc-users] Question about NASM initialization

2023-04-06 Thread Takahashi, Tadanaga
Ok, thanks for the clarification.

On Thu, Apr 6, 2023 at 10:25 AM Matthew Knepley  wrote:

> On Thu, Apr 6, 2023 at 10:21 AM Takahashi, Tadanaga  wrote:
>
>> I am following up from the last inquiry. I read the source code nasm.c
>>  and it looks
>> like sub-snes iteration is being initialized with a scatter call from the
>> previous solution. In other words, if I use Newton's method for the local
>> solver, then in each NASM iteration the Newton's method uses the previous
>> local solution as the initial guess. Can anyone confirm this?
>>
>
> This is the intention. There are not many tests, so it is possible there
> is a bug, but it is supposed to use the existing solution.
>
>   Thanks,
>
> Matt
>
>
>> On Sun, Apr 2, 2023 at 6:14 PM Takahashi, Tadanaga  wrote:
>>
>>> Hello PETSc devs,
>>>
>>> I am using SNES NASM with Newton LS on the sub-SNES. I was wondering how
>>> the sub-SNES chooses the initial guess during each NASM iteration. Is it
>>> using the previously computed solution or is it restarting from zero?
>>>
>>
>
> --
> What most experimenters take for granted before they begin their
> experiments is infinitely more interesting than any results to which their
> experiments lead.
> -- Norbert Wiener
>
> https://www.cse.buffalo.edu/~knepley/
> 
>


Re: [petsc-users] Question about NASM initialization

2023-04-06 Thread Matthew Knepley
On Thu, Apr 6, 2023 at 10:21 AM Takahashi, Tadanaga  wrote:

> I am following up from the last inquiry. I read the source code nasm.c
>  and it looks
> like sub-snes iteration is being initialized with a scatter call from the
> previous solution. In other words, if I use Newton's method for the local
> solver, then in each NASM iteration the Newton's method uses the previous
> local solution as the initial guess. Can anyone confirm this?
>

This is the intention. There are not many tests, so it is possible there is
a bug, but it is supposed to use the existing solution.

  Thanks,

Matt


> On Sun, Apr 2, 2023 at 6:14 PM Takahashi, Tadanaga  wrote:
>
>> Hello PETSc devs,
>>
>> I am using SNES NASM with Newton LS on the sub-SNES. I was wondering how
>> the sub-SNES chooses the initial guess during each NASM iteration. Is it
>> using the previously computed solution or is it restarting from zero?
>>
>

-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/ 


Re: [petsc-users] Question about NASM initialization

2023-04-06 Thread Takahashi, Tadanaga
I am following up from the last inquiry. I read the source code nasm.c
 and it looks
like sub-snes iteration is being initialized with a scatter call from the
previous solution. In other words, if I use Newton's method for the local
solver, then in each NASM iteration the Newton's method uses the previous
local solution as the initial guess. Can anyone confirm this?

On Sun, Apr 2, 2023 at 6:14 PM Takahashi, Tadanaga  wrote:

> Hello PETSc devs,
>
> I am using SNES NASM with Newton LS on the sub-SNES. I was wondering how
> the sub-SNES chooses the initial guess during each NASM iteration. Is it
> using the previously computed solution or is it restarting from zero?
>


Re: [petsc-users] Installation issues based on Petsc-pardiso et metis

2023-04-06 Thread Matthew Knepley
On Thu, Apr 6, 2023 at 5:21 AM ziming xiong 
wrote:

> Hello,
> I want configure Petsc with pardiso and metis , but there is still error,
>

This seems like a fundamental misunderstanding.

There are two ways to run on a Windows machine:

  1) You can use Windows compilers and generate .lib libraries. This is
what you are currently doing.

  2) You can use WSL2 or MSYS, using UNIX compilers, generating .a archives
and .so shared libraries.

When you built Metis, you used strategy 2) since we see

Executing: win32fe cl  -o
/cygdrive/c/Users/XiongZiming/AppData/Local/Temp/petsc-r1s2t4wp/config.libraries/conftest.exe
   -g
/cygdrive/c/Users/XiongZiming/AppData/Local/Temp/petsc-r1s2t4wp/config.libraries/conftest.o
 -L/cygdrive/f/metis-5.1.0/build -L/cygdrive/f/metis-5.1.0/build -lmetis
Ws2_32.lib
stdout: LINK : fatal error LNK1104: cannot open file 'libmetis.lib'
Possible ERROR while running linker: exit code 2
stdout:
LINK : fatal error LNK1104: cannot open file 'libmetis.lib'
Linker output before filtering:
LINK : fatal error LNK1104: cannot open file 'libmetis.lib'
Linker output after filtering:
LINK : fatal error LNK1104: cannot open file 'libmetis.lib'

Personally, I find strategy 2) easier to deal with, especially for external
libraries.

  Thanks,

 Matt


> I work with the following code for pardiso:
>  ./configure
>  --with-cc="win32fe cl"
> --with-fc=0
>  --with-cxx="win32fe cl"
> --with-shared-libraries=0
> --with-mpi-dir="/cygdrive/c/PROGRA~2/Intel/MPI"
> --with-mpiexec="/cygdrive/c/PROGRA~1/Microsoft_MPI/Bin/mpiexec"
> --with-blaslapack-dir="/cygdrive/c/PROGRA~2/Intel/oneAPI/mkl/latest"
> --with-mkl_pardiso-dir="/cygdrive/c/PROGRA~2/Intel/oneAPI/mkl/latest"
>
> the configure_error_with_pardiso.log is the configure log file.
>
> For metis, i used code:
>  ./configure
> --with-metis-lib=/cygdrive/f/metis-5.1.0/build/libmetis
>  --with-metis-include=/cygdrive/f/metis-5.1.0/include
> --with-cc="win32fe cl"
>  --with-fc=0
>  --with-cxx="win32fe cl"
>  --with-shared-libraries=0
>  --with-mpi-dir="/cygdrive/c/PROGRA~2/Intel/MPI"
>  --with-mpiexec="/cygdrive/c/PROGRA~1/Microsoft_MPI/Bin/mpiexec"
>  
> --with-blaslapack-lib="-L/cygdrive/c/PROGRA~2/Intel/oneAPI/mkl/latest/lib/intel64
> mkl_intel_lp64_dll.lib mkl_sequential_dll.lib mkl_core_dll.lib"
>
> But there is the error as follow:
>   --with-metis-lib=['/cygdrive/f/metis-5.1.0/build/libmetis'] and
>   --with-metis-include=['/cygdrive/f/metis-5.1.0/include'] did not work
>
> which the configure_error_with_metis is the configure file for metis.
>
> I also try to use --download-metis for configure with metis, but there is
> the Error configuring METIS with CMake. If u want I can send the
> configure.log file
>
> Please help me to configure with these external packages. I've been stuck
> in this stage for a long time
>
> Best regards,
> Ziming XIONG
>
>

-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/ 


Re: [petsc-users] Installation issue of 3.18.* and 3.19.0 on Apple systems

2023-04-06 Thread Kaus, Boris
Apologies, mistake on my side. Yes this works - thanks a lot for your help!

Boris

On 6. Apr 2023, at 00:56, Satish Balay  wrote:

This is strange. I can trigger the error with:

-  v = tuple([int(a) for a in platform.mac_ver()[0].split('.')])
+  v = tuple([int('')])

and this fix is able to overcome it.

I pushed this change to `balay/fix-macos-version-check` branch - can you try 
from it?

Satish

On Wed, 5 Apr 2023, Kaus, Boris wrote:

I don’t understand why this keeps giving the same error (shouldn’t):

sandbox:${WORKSPACE}/srcdir/petsc-3.18.0 #  ./configure 
--prefix=/workspace/destdir/lib/petsc/double_real_Int32/
***
   TypeError or ValueError possibly related to ERROR in COMMAND LINE ARGUMENT 
while running ./configure
---
invalid literal for int() with base 10: ''
***


 File "/workspace/srcdir/petsc-3.18.0/config/configure.py", line 457, in 
petsc_configure
   framework = 
config.framework.Framework(['--configModules=PETSc.Configure','--optionsModule=config.compilerOptions']+sys.argv[1:],
 loadArgDB = 0)
 File "/workspace/srcdir/petsc-3.18.0/config/BuildSystem/config/framework.py", 
line 101, in __init__
   self.createChildren()
 File "/workspace/srcdir/petsc-3.18.0/config/BuildSystem/config/framework.py", 
line 338, in createChildren
   self.getChild(moduleName)
 File "/workspace/srcdir/petsc-3.18.0/config/BuildSystem/config/framework.py", 
line 323, in getChild
   config.setupDependencies(self)
 File "/workspace/srcdir/petsc-3.18.0/config/PETSc/Configure.py", line 89, in 
setupDependencies
   self.registerPythonFile(utility,'config.utilities')
 File "/workspace/srcdir/petsc-3.18.0/config/PETSc/Configure.py", line 49, in 
registerPythonFile
   utilityObj = 
self.framework.require(directory+utilityName, self)
 File "/workspace/srcdir/petsc-3.18.0/config/BuildSystem/config/framework.py", 
line 343, in require
   config = self.getChild(moduleName, keywordArgs)
 File "/workspace/srcdir/petsc-3.18.0/config/BuildSystem/config/framework.py", 
line 317, in getChild
   config = type(self, *keywordArgs)
 File 
"/workspace/srcdir/petsc-3.18.0/config/BuildSystem/config/utilities/macosFirewall.py",
 line 12, in __init__
   self.isDarwin = config.setCompilers.Configure.isDarwin(self.log)
 File 
"/workspace/srcdir/petsc-3.18.0/config/BuildSystem/config/setCompilers.py", 
line 676, in isDarwin
   if not isUname_value: config.setCompilers.Configure.isUname(log)
 File 
"/workspace/srcdir/petsc-3.18.0/config/BuildSystem/config/setCompilers.py", 
line 631, in isUname
   v = tuple([int(a) for a in platform.mac_ver()[0].split('.')])
 File 
"/workspace/srcdir/petsc-3.18.0/config/BuildSystem/config/setCompilers.py", 
line 631, in 
   v = tuple([int(a) for a in platform.mac_ver()[0].split('.')])


On 5. Apr 2023, at 23:58, Satish Balay  wrote:

Ah - my patch was buggy.

+except RuntimeError:

should be: 'except:' i.e:

diff --git a/config/BuildSystem/config/setCompilers.py 
b/config/BuildSystem/config/setCompilers.py
index 57848e736e3..e191c1e1b4d 100644
--- a/config/BuildSystem/config/setCompilers.py
+++ b/config/BuildSystem/config/setCompilers.py
@@ -630,10 +630,14 @@ class Configure(config.base.Configure):
   if log: log.write('Detected Darwin')
   isDarwin_value = True
   import platform
-v = tuple([int(a) for a in platform.mac_ver()[0].split('.')])
-if v >= (10,15,0):
-  if log: log.write('Detected Darwin/MacOSX Catalina OS\n')
-  isDarwinCatalina_value = True
+try:
+  v = tuple([int(a) for a in platform.mac_ver()[0].split('.')])
+  if v >= (10,15,0):
+if log: log.write('Detected Darwin/MacOSX Catalina OS\n')
+isDarwinCatalina_value = True
+except:
+  if log: log.write('MacOS version detecton failed!\n')
+  pass
 if output.find('freebsd') >= 0:
   if log: log.write('Detected FreeBSD')
   isFreeBSD_value = True

Satish




On Wed, 5 Apr 2023, Kaus, Boris wrote:

Perhaps python is broken, or perhaps this is because it is not a real Mac OS, 
but an emulated one.

Seems a similar error now occurs a bit down the line:

---

sandbox:${WORKSPACE}/srcdir/petsc-3.18.0 #  ./configure 
--prefix=/workspace/destdir/lib/petsc/double_real_Int32/
***
  TypeError or ValueError possibly related to ERROR in COMMAND LINE ARGUMENT 
while running ./configure
---
invalid literal for int() with base 10: ''
***


File "/workspace/srcdir/petsc-3.18.0/config/configure.py", line 457, in 
petsc_configure
  framework =