From 692f45ed7fbe3265c15179dd0fe7539522ef6d68 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Sat, 8 May 2021 00:35:53 +0200 Subject: [PATCH] Correct rank in Fortran interface --- configure.ac | 6 ++++++ src/templates_front/templator_front.org | 14 ++++++++------ tools/generator.py | 6 ++++++ trex.json | 2 +- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index ffc8572..266dfdd 100644 --- a/configure.ac +++ b/configure.ac @@ -22,7 +22,13 @@ PKG_LIBS="" PKG_CFLAGS="" # Checks for programs. AC_PROG_CC +AC_PROG_CC_C_O + AC_PROG_FC +AC_FC_FREEFORM +AC_FC_SRCEXT([f90]) + +AC_PROG_FC_C_O AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_CC_C99 diff --git a/src/templates_front/templator_front.org b/src/templates_front/templator_front.org index dd8d503..bd292c1 100644 --- a/src/templates_front/templator_front.org +++ b/src/templates_front/templator_front.org @@ -723,6 +723,8 @@ end interface | ~$group_dset_dtype_double$~ | Double precision type of the dataset [C] | ~double~ | | ~$group_dset_f_dtype_single$~ | Single precision type of the dataset [Fortran] | ~real(4)~ | | ~$group_dset_f_dtype_double$~ | Double precision type of the dataset [Fortran] | ~real(8)~ | + | ~$group_dset_f_dims$~ | Dimensions in Fortran | ~(:,:)~ | + Note: parent group name is always added to the child objects upon construction of TREXIO (e.g. ~num~ of ~nucleus~ group becomes @@ -1301,7 +1303,7 @@ interface integer function trexio_write_$group$_$group_dset$_64 (trex_file, dset) bind(C) use, intrinsic :: iso_c_binding integer(8), intent(in), value :: trex_file - $group_dset_f_dtype_double$, intent(in) :: dset(*) + $group_dset_f_dtype_double$, intent(in) :: dset$group_dset_f_dims$ end function trexio_write_$group$_$group_dset$_64 end interface #+end_src @@ -1311,7 +1313,7 @@ interface integer function trexio_read_$group$_$group_dset$_64 (trex_file, dset) bind(C) use, intrinsic :: iso_c_binding integer(8), intent(in), value :: trex_file - $group_dset_f_dtype_double$, intent(out) :: dset(*) + $group_dset_f_dtype_double$, intent(out) :: dset$group_dset_f_dims$ end function trexio_read_$group$_$group_dset$_64 end interface #+end_src @@ -1321,7 +1323,7 @@ interface integer function trexio_write_$group$_$group_dset$_32 (trex_file, dset) bind(C) use, intrinsic :: iso_c_binding integer(8), intent(in), value :: trex_file - $group_dset_f_dtype_single$, intent(in) :: dset(*) + $group_dset_f_dtype_single$, intent(in) :: dset$group_dset_f_dims$ end function trexio_write_$group$_$group_dset$_32 end interface #+end_src @@ -1331,7 +1333,7 @@ interface integer function trexio_read_$group$_$group_dset$_32 (trex_file, dset) bind(C) use, intrinsic :: iso_c_binding integer(8), intent(in), value :: trex_file - $group_dset_f_dtype_single$, intent(out) :: dset(*) + $group_dset_f_dtype_single$, intent(out) :: dset$group_dset_f_dims$ end function trexio_read_$group$_$group_dset$_32 end interface #+end_src @@ -1341,7 +1343,7 @@ interface integer function trexio_write_$group$_$group_dset$ (trex_file, dset) bind(C) use, intrinsic :: iso_c_binding integer(8), intent(in), value :: trex_file - $group_dset_f_dtype_double$, intent(in) :: dset(*) + $group_dset_f_dtype_double$, intent(in) :: dset$group_dset_f_dims$ end function trexio_write_$group$_$group_dset$ end interface #+end_src @@ -1351,7 +1353,7 @@ interface integer function trexio_read_$group$_$group_dset$ (trex_file, dset) bind(C) use, intrinsic :: iso_c_binding integer(8), intent(in), value :: trex_file - $group_dset_f_dtype_double$, intent(out) :: dset(*) + $group_dset_f_dtype_double$, intent(out) :: dset$group_dset_f_dims$ end function trexio_read_$group$_$group_dset$ end interface #+end_src diff --git a/tools/generator.py b/tools/generator.py index 1e004e3..8fe740a 100644 --- a/tools/generator.py +++ b/tools/generator.py @@ -312,6 +312,12 @@ for fname in files_funcs_dsets: templine1 = templine2.replace('$group$', grname) templine2 = templine1.replace('$GROUP$', grname.upper()) + if "$group_dset_f_dims$" in templine2: + dims = "(" + ",".join([":" for _ in range(params['rank'])]) + ")" + if dims == "()": dims = "" + templine1 = templine2.replace("$group_dset_f_dims$", dims) + templine2 = templine1 + f_out.write(templine2) else: f_out.write(line) diff --git a/trex.json b/trex.json index a2448b8..5c2f8f8 100644 --- a/trex.json +++ b/trex.json @@ -23,7 +23,7 @@ "ecp": { "lmax_plus_1" : [ "int" , [ "nucleus.num" ] ] - , "z_core" : [ "int" , [ "nucleus.num" ] ] + , "z_core" : [ "float", [ "nucleus.num" ] ] , "local_n" : [ "int" , [ "nucleus.num" ] ] , "local_num_n_max" : [ "int" , [ ] ] , "local_exponent" : [ "float", [ "nucleus.num", "ecp.local_num_n_max" ] ]