From 46ed3abd006245c9399a379593475c7b472266d0 Mon Sep 17 00:00:00 2001
From: Mathieu Faverge <mathieu.faverge@inria.fr>
Date: Fri, 21 Feb 2025 11:59:25 +0100
Subject: [PATCH] tools: update generators

---
 tools/wrappers/spm_fortran.py  | 11 +++++++++--
 tools/wrappers/wrap_fortran.py |  2 +-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/tools/wrappers/spm_fortran.py b/tools/wrappers/spm_fortran.py
index eefa8dd2..4fff2927 100644
--- a/tools/wrappers/spm_fortran.py
+++ b/tools/wrappers/spm_fortran.py
@@ -34,8 +34,6 @@ enums = {
     'description' : "SPM fortran 90 wrapper to define enums and datatypes",
     'header'      : """
 
-#include "spm/config.h"
-
   use, intrinsic :: iso_c_binding
 #if defined(SPM_WITH_MPI)
   use :: mpi_f08, only : MPI_Comm, MPI_COMM_WORLD
@@ -108,6 +106,9 @@ function spmGetCptrFromValue(input) result(output)
      output = c_loc( t )
   type is (real(c_float))
      output = c_loc( t )
+  class default
+     write(0,*) "Input pointer is not pointing to one of double complex, single complex, double real or single real"
+     output = c_null_ptr
   end select
 
 end function spmGetCptrFromValue
@@ -128,6 +129,9 @@ function spmGetCptrFrom1dArray(input) result(output)
      output = c_loc( t )
   type is (real(c_float))
      output = c_loc( t )
+  class default
+     write(0,*) "Input pointer is not pointing to one of double complex, single complex, double real or single real"
+     output = c_null_ptr
   end select
 
 end function spmGetCptrFrom1dArray
@@ -148,6 +152,9 @@ function spmGetCptrFrom2dArray(input) result(output)
      output = c_loc( t )
   type is (real(c_float))
      output = c_loc( t )
+  class default
+     write(0,*) "Input pointer is not pointing to one of double complex, single complex, double real or single real"
+     output = c_null_ptr
   end select
 
 end function spmGetCptrFrom2dArray
diff --git a/tools/wrappers/wrap_fortran.py b/tools/wrappers/wrap_fortran.py
index 72e91143..82328c72 100644
--- a/tools/wrappers/wrap_fortran.py
+++ b/tools/wrappers/wrap_fortran.py
@@ -609,7 +609,7 @@ def iso_c_interface_type(arg, return_value, list, instruct=False):
     else:
         f_type = types_dict[arg[0]]['ftype']
         if instruct and f_type == "type(MPI_Comm)":
-            f_type = "integer(kind=SPM_MPI_COMM_SIZE)"
+            f_type = "integer(kind=SPM_MPI_COMM_KIND)"
 
     if (not return_value and arg[1] != "**"):
         f_type += ", "
-- 
GitLab