Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: f2py Fortran77 comments "!" parsing error for subroutine #26148

Open
xiangyi-wang opened this issue Mar 28, 2024 · 0 comments
Open

BUG: f2py Fortran77 comments "!" parsing error for subroutine #26148

xiangyi-wang opened this issue Mar 28, 2024 · 0 comments

Comments

@xiangyi-wang
Copy link

Describe the issue:

When removing “! Input” and "! Output" everything is normal.
f2py -c -m solar SOLAR.for --fcompiler=intelem --f77flags="-ffixed-form"
I think it may be caused by the appearance of & and ! on the same line?
doy =1 - 365;
xlat =-90 - 90;

Reproduce the code example:

SUBROUTINE DAYLEN(
     &    DOY, XLAT,                                      !Input
     &    DAYL, DEC, SNDN, SNUP)                          !Output

!-----------------------------------------------------------------------
      IMPLICIT NONE
Cf2py intent(in) doy, xlat
Cf2py intent(out) dayl, dec, sndn, snup
      INTEGER DOY
      REAL DEC,DAYL,PI,RAD,SOC,SNDN,SNUP,XLAT
      PARAMETER (PI=3.14159, RAD=PI/180.0)

!-----------------------------------------------------------------------
C     Calculation of declination of sun (Eqn. 16). Amplitude= +/-23.45
C     deg. Minimum = DOY 355 (DEC 21), maximum = DOY 172.5 (JUN 21/22).
      DEC = -23.45 * COS(2.0*PI*(DOY+10.0)/365.0)

C     Sun angles.  SOC limited for latitudes above polar circles.
      SOC = TAN(RAD*DEC) * TAN(RAD*XLAT)
      SOC = MIN(MAX(SOC,-1.0),1.0)

C     Calculate daylength, sunrise and sunset (Eqn. 17)
      DAYL = 12.0 + 24.0*ASIN(SOC)/PI
C FO 06/05/2022 Added protection to avoid day length less than 0.0
C               and greater than 24.0 hours.      
      DAYL = MIN(MAX(DAYL,0.0),24.0)
      SNUP = 12.0 - DAYL/2.0
      SNDN = 12.0 + DAYL/2.0

      RETURN
      END SUBROUTINE DAYLEN


### Error message:

```shell
Python 3.11.5 (main, Sep 11 2023, 13:54:46) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import solar1
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: /home/wxy/dssat-4.8/Weather/solar1.cpython-311-x86_64-linux-gnu.so: undefined symbol: unknown_subroutine_
>>>

Python and NumPy Versions:

import sys, numpy; print(numpy.version); print(sys.version)
1.26.4
3.11.5 (main, Sep 11 2023, 13:54:46) [GCC 11.2.0]

Runtime Environment:

WSL Ubuntu 22.4

Context for the issue:

A model is mostly based on Fortran77 and uses this style of writing. I need to make it part of python

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants