# FreeFem - PETSc compilation error - libblas.a/liblapack.a cannot be used

**URL:** <https://community.freefem.org/t/freefem-petsc-compilation-error-libblas-a-liblapack-a-cannot-be-used/2771>\
**Category:** FreeFEM installation\
**Created:** [November 1, 2023, 7:12pm UTC](https://community.freefem.org/t/freefem-petsc-compilation-error-libblas-a-liblapack-a-cannot-be-used/2771 "2023-11-01T19:12:39Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![kulcsarm](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/kulcsarm/32/1530_2.png) [@kulcsarm](https://community.freefem.org/u/kulcsarm)\
**Post date:** [November 1, 2023, 7:12pm UTC](https://community.freefem.org/t/freefem-petsc-compilation-error-libblas-a-liblapack-a-cannot-be-used/2771/1 "2023-11-01T19:12:39Z")

</div>

Hello,

I’m trying to compile FreeFem on a cray based hpc without any luck so far. I have compiled FreeFem multiple times already using [this](https://joliv.et/FreeFem-tutorial/main.pdf) guide, but I have no experience in doing it on cray based systems.

The problem I’m running into is that PETSc can’t use libblas.a/liblapack.a no matter what I do. The main configure line I’m trying to run:

```auto
./configure --with-mpi-dir=/opt/cray/pe/mpich/8.1.27/ofi/cray/16.0/ --download-mumps --download-parmetis --download-metis --download-hypre --download-superlu --download-slepc --download-hpddm --download-ptscotch --download-suitesparse --download-scalapack --download-tetgen --download-mmg --download-parmmg --with-fortran-bindings=no --with-scalar-type=real --with-debugging=no --download-bison --download-make --with-packages-download-dir=${PETSCBUILDETC_DIR}

```

The libraries are not present on the hpc I’m working on so at first I tried adding the `--download-fblaslapack` option to the configure line, but got an error at the end stating that the library cannot be used (attached [configure.log](https://gist.github.com/kulcsarm/9ed95f8406309d0b2bdfc899223deff4) file).

I tried looking for similar errors and found that the fortran compiler might be different for the libraries and PETSc so I tried compiling blas and lapack (tried both the netlib and openblas packeges) myself and added the cmake option `-DCMAKE_Fortran_COMPILER=/opt/cray/pe/mpich/8.1.27/ofi/cray/16.0/bin/mpif90` so that the libraries would be compiled with the same fortran compiler as PETSc is and added the configure options `--with-blas-lib=/home/p_mvgkm/p_mvgopt02/FreeFem/lapack/lib64/libblas.a` (tried it with `--with-blas-lib=/home/p_mvgkm/p_mvgopt02/FreeFem/blas/lib/libblas.a` as well) and `--with-lapack-lib=/home/p_mvgkm/p_mvgopt02/FreeFem/lapack/lib64/liblapack.a` but got a similar error, stating the libraries cannot be used. (attached [configure.log](https://gist.github.com/kulcsarm/745fe269d77c7aab34d773aca9aef62b) file)

I also had to remove `--download-parmmg` from the config line, because it makes the configure process freeze, it gives no error it is just stuck. (attached [configure.log](https://gist.github.com/kulcsarm/a33c594eb1a4f091bf248b20b4bd2955) file)

Did somebody run into a similar issue, or does someone have any solution ideas in mind?

Another question I would like to ask, is that on cray based systems there are no `mpirun` or `mpiexec` commands, instead running things with `srun` does the same. Is there going to be someting I will have to change to use `srun` or does linking the cray-mpich compiler solve this issue.

Any help would be appriciated, thank you in advance!

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [November 2, 2023, 12:16pm UTC](https://community.freefem.org/t/freefem-petsc-compilation-error-libblas-a-liblapack-a-cannot-be-used/2771/2 "2023-11-02T12:16:58Z")

</div>

Could you try `--download-f2cblaslapack` instead of `--download-fblaslapack`?

---

<div class="post-metadata">

**Author:** ![kulcsarm](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/kulcsarm/32/1530_2.png) [@kulcsarm](https://community.freefem.org/u/kulcsarm)\
**Post date:** [November 2, 2023, 2:43pm UTC](https://community.freefem.org/t/freefem-petsc-compilation-error-libblas-a-liblapack-a-cannot-be-used/2771/3 "2023-11-02T14:43:05Z")

</div>

Thank you for your reply! I tried changing that option and the compiler went further, but stopped with an error when compiling ScaLAPACK ([configure.log](https://gist.github.com/kulcsarm/bbc0137ef7ce4bc70d007cfa5bef3cba)).  
On a sidenote, I also saw this option but assumed, that it only works with `--with-fc=0` as suggested on the PETSc site and when I ran the configure it didn’t start stating, that scalapack needs a fortran compiler. This new issue might be related to this.

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [November 2, 2023, 2:52pm UTC](https://community.freefem.org/t/freefem-petsc-compilation-error-libblas-a-liblapack-a-cannot-be-used/2771/4 "2023-11-02T14:52:54Z")

</div>

It appears there is something not right with your Fortran compiler, or at least it is making PETSc configure fail, so I would just reconfigure `--with-fc=0 --download-superlu_dist` and without `--download-scalapack --download-mumps`.

---

<div class="post-metadata">

**Author:** ![kulcsarm](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/kulcsarm/32/1530_2.png) [@kulcsarm](https://community.freefem.org/u/kulcsarm)\
**Post date:** [November 2, 2023, 4:21pm UTC](https://community.freefem.org/t/freefem-petsc-compilation-error-libblas-a-liblapack-a-cannot-be-used/2771/5 "2023-11-02T16:21:25Z")

</div>

I can configure PETSc with the options you suggested, thank you!

I will try talking with the support of the hpc, see if they can do something about the Fortran compiler and report back if the root of the issue is found.

---

<div class="post-metadata">

**Author:** ![kulcsarm](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/kulcsarm/32/1530_2.png) [@kulcsarm](https://community.freefem.org/u/kulcsarm)\
**Post date:** [November 6, 2023, 5:40pm UTC](https://community.freefem.org/t/freefem-petsc-compilation-error-libblas-a-liblapack-a-cannot-be-used/2771/6 "2023-11-06T17:40:29Z")

</div>

I managed to configure and make the real part of PETSc, however I run into a issue while compiling the complex part of PETSc with the error: `/home/p_mvgkm/p_mvgopt02/FreeFem/petsc/include/petscmath.h:429:45: error: unknown type name ' __complex128' PETSC_EXTERN MPI_Datatype MPIU___ COMPLEX128 MPIU___COMPLEX128_ATTR_TAG;`.  
[configure.log](https://gist.github.com/kulcsarm/3d3a9076c7375bd5c2ea067728d78fad)  
[make.log](https://gist.github.com/kulcsarm/e0c59e30892f79c9c3194698dc3dc453)

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [November 6, 2023, 7:00pm UTC](https://community.freefem.org/t/freefem-petsc-compilation-error-libblas-a-liblapack-a-cannot-be-used/2771/7 "2023-11-06T19:00:10Z")

</div>

Configure with the additional `COPTFLAGS` `-DPETSC_SKIP_REAL___FLOAT128` and let me know if this fix the issue, please.

---

<div class="post-metadata">

**Author:** ![kulcsarm](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/kulcsarm/32/1530_2.png) [@kulcsarm](https://community.freefem.org/u/kulcsarm)\
**Post date:** [November 7, 2023, 11:30am UTC](https://community.freefem.org/t/freefem-petsc-compilation-error-libblas-a-liblapack-a-cannot-be-used/2771/8 "2023-11-07T11:30:35Z")

</div>

I tried configuring the complex part again with the added option, but got an error while running the make command.  
[configure.log](https://gist.github.com/kulcsarm/9348d0f9c80c276e20e77c8dfba4afe8)  
[make.log](https://gist.github.com/kulcsarm/5114b3ea7554378fa3d9c342a6fb9ac6)  
I also tried reconfiguring the real part with the same option as well, but it could not be made with this option either.  
[configure.log](https://gist.github.com/kulcsarm/ef0c6c522e4c607a986a144d537b1e7f)  
[make.log](https://gist.github.com/kulcsarm/535f3054ece8b26526a995396704e422)

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [November 7, 2023, 5:20pm UTC](https://community.freefem.org/t/freefem-petsc-compilation-error-libblas-a-liblapack-a-cannot-be-used/2771/9 "2023-11-07T17:20:51Z")

</div>

Hm, could you try to remove manually `#define PETSC_HAVE_REAL___FLOAT128 1` from `petscconf.h` and give a last shot?

---

<div class="post-metadata">

**Author:** ![kulcsarm](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/kulcsarm/32/1530_2.png) [@kulcsarm](https://community.freefem.org/u/kulcsarm)\
**Post date:** [November 7, 2023, 8:02pm UTC](https://community.freefem.org/t/freefem-petsc-compilation-error-libblas-a-liblapack-a-cannot-be-used/2771/10 "2023-11-07T20:02:08Z")

</div>

This seems to have solved my issues, I could compile the complex part after deleting the line you suggested, and could also configure and make FreeFem. Thank you for your help!

---

<div class="post-metadata">

**Author:** ![kulcsarm](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/kulcsarm/32/1530_2.png) [@kulcsarm](https://community.freefem.org/u/kulcsarm)\
**Post date:** [November 20, 2023, 7:15pm UTC](https://community.freefem.org/t/freefem-petsc-compilation-error-libblas-a-liblapack-a-cannot-be-used/2771/11 "2023-11-20T19:15:19Z")

</div>

I managed to compile the original version with the Fortran compiler, so if anybody would run into this issue in the future, the fix was using the `--with-cc`, `--with-cxx` and `--with-fc` options and giving them the absolute path of the `cc`, `CC` and `ftn` wrappers as on Cray systems these are already mpi ready wrappers. The fix deleting that line from the` petscconf.h` was still required.
