本帖最后由 wxy 于 2024-3-27 19:32 编辑
最近想用f2py编译打包一个模型,大部分代码是f77(.for),f2py -c -m solar solar2.for一直报错。用一个简单函数测试了下转化为自由格式(f90)就没问题,看了下.pyf文件没有正确识别代码 undefined symbol: unknown_subroutine_,尝试设置fcompiler和 --f77flags="-ffixed-form"都不管用,需要加什么设定吗
[Fortran] 纯文本查看 复制代码 C=======================================================================
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
|