PrincetonUniversity / SPEC

The Stepped-Pressure Equilibrium Code, an advanced MRxMHD equilibrium solver.
https://princetonuniversity.github.io/SPEC/
GNU General Public License v3.0
24 stars 4 forks source link

Wrapper will not compile (reserved python words?) #155

Closed smiet closed 3 years ago

smiet commented 3 years ago

I am trying to compile the python wrapper for SPEC, but run into a compilation error:

    /mnt/c/Users/rf_ds/Workspace/codes/SPEC2/_skbuild/linux-x86_64-3.8/cmake-build/Utilities/python_wrapper/f90wrap_global_m_fpp.f90:3203:24:

     3203 |     use allglobal, only: allglobal_in_ => in_
          |                        1
    Error: Symbol ‘in_’ referenced at (1) not found in module ‘allglobal’
    /mnt/c/Users/rf_ds/Workspace/codes/SPEC2/_skbuild/linux-x86_64-3.8/cmake-build/Utilities/python_wrapper/f90wrap_global_m_fpp.f90:3213:30:

     3213 |     if (allocated(allglobal_in)) then
          |                              1
    Error: Symbol ‘allglobal_in’ at (1) has no IMPLICIT type

If I look at the file _skbuild/linux-x86_64-3.8/cmake-build/Utilities/python_wrapper/f90wrap_global_m_fpp.f90:3203:24: I see that the wrapper has added an underscore _ to the end of the name allglobal_in_ in the wrapping funciton for the array in (together with im used for looping over arrays). This is possibly because in is a reserved python keyword? Error-throwing code below:

subroutine f90wrap_allglobal__array__in(dummy_this, nd, dtype, dshape, dloc)
    use constants
    use typedefns
    use allglobal, only: allglobal_in_ => in_
    implicit none
    integer, intent(in) :: dummy_this(2)
    integer, intent(out) :: nd
    integer, intent(out) :: dtype
    integer, dimension(10), intent(out) :: dshape
    integer*8, intent(out) :: dloc

    nd = 1
    dtype = 7
    if (allocated(allglobal_in)) then
        dshape(1:1) = shape(allglobal_in)
        dloc = loc(allglobal_in)
    else
        dloc = 0
    end if
end subroutine f90wrap_allglobal__array__in

(Compare to the wrapping function generated for the array 'im':

subroutine f90wrap_allglobal__array__im(dummy_this, nd, dtype, dshape, dloc)
    use constants
    use typedefns
    use allglobal, only: allglobal_im => im
    implicit none
    integer, intent(in) :: dummy_this(2)
    integer, intent(out) :: nd
    integer, intent(out) :: dtype
    integer, dimension(10), intent(out) :: dshape
    integer*8, intent(out) :: dloc

    nd = 1
    dtype = 7
    if (allocated(allglobal_im)) then
        dshape(1:1) = shape(allglobal_im)
        dloc = loc(allglobal_im)
    else
        dloc = 0
    end if
end subroutine f90wrap_allglobal__array__im

which does not contain the underscore.

I have tried with f90wrap==0.2.7, and also reverted to 0.2.5, but the error persists. Has anyone else encountered these errors in compiling the wrapper, or does anyone know a workaround, or a flag I need to set?

I am using the gfortran compiler and gcc 9.3.0

zhucaoxiang commented 3 years ago

Are you installing f90wrap using pip install -U git+https://github.com/zhucaoxiang/f90wrap?

smiet commented 3 years ago

Thanks @zhucaoxiang, that was the problem! I had forgotten that you had forked this repo. Maybe this could be added to the readme. I could prepare a few lines to add to help future users.

Will the fix be included in future versions of f90wrap?

Warmest regards, Chris

zhucaoxiang commented 3 years ago

It is in the readme, but not in a clear location. I should find some time to push the forked version back to the official repo.