AgriculturalModelExchangeInitiative / PyCrop2ML

CropML Python library
Other
17 stars 17 forks source link

Translation issue for handling brackets which behinds "/“ or "-" #77

Closed MengZhang closed 4 years ago

MengZhang commented 5 years ago

I got translation result which improperly removed brackets used in the calculation as below.

pyx code: RLINIT = WTNEW FRRT PLTPOP RFAC1 DEP / ( RTDEP * 10000 )

generated f90 code RLINIT = WTNEW FRRT PLTPOP RFAC1 DEP / RTDEP * 10000

the brackets should be kept if it appears after divided or minus operation.

cyrillemidingoyi commented 4 years ago

Thanks @MengZhang. I correct it

def main():
    cdef float RLINIT,WTNEW, FRRT, PLTPOP, RFAC1, DEP, RTDEP
    RLINIT = WTNEW * FRRT * PLTPOP * RFAC1 * DEP / ( RTDEP * 10000 )
    return RLINIT

SUBROUTINE main(RLINIT)
    REAL, INTENT(OUT) :: RLINIT
    REAL:: WTNEW
    REAL:: FRRT
    REAL:: PLTPOP
    REAL:: RFAC1
    REAL:: DEP
    REAL:: RTDEP
    RLINIT = WTNEW * FRRT * PLTPOP * RFAC1 * DEP / (RTDEP * 10000)
END SUBROUTINE main