Fortran Coder

查看: 24003|回复: 12
打印 上一主题 下一主题

[求助] 一个变量我初值赋0了可是输出却是1.0737E+08

[复制链接]

55

帖子

17

主题

0

精华

熟手

F 币
261 元
贡献
169 点
跳转到指定楼层
楼主
发表于 2014-10-9 10:17:18 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
[Fortran] 纯文本查看 复制代码
C     check for water balance error
      BALERD = STORD - (INTR + INTS + INTRMS + SNOW + SWAT + GWAT) + 
     *   PRECD - EVAPD - FLOWD - SEEPD
      IF (ABS(BALERD) .GT. .003) THEN
         PRINT*, 'Serious water balance error (BALERD .GT. 0.003 mm)'
         PRINT*, 'Must be a programming error'
         write(*,*)'intrms=',INTRMS
         WRITE(*,*)'EVAPD=',EVAPD
         WRITE(*,*)'IRVPMS=',IRVPMSD,IRVPMS
         CALL INTERMS (RNETMS, GIVP, MAI, FRINTLMS, CINTRLMS, 
     *   DTP, INTRMS, RINTMS, IRVPMS)
         STOP
      END IF

我改了程序后这个水量平衡的等式就不成立了,然后逐个输出值找错误最后确定就是IRVPMS值出错,而他的出错主要是子程序EVP我新加的CATCHMS初始值不对,可是我后来给他附了初值可是也不太管用
附件里B90v3是原版程序,B90v4是我改过的
哪位高手大神老师在北京啊?我想现场找你们问问,正好你们省的看程序了。
以下是我改的EVP  子程序
[Fortran] 纯文本查看 复制代码
C     *************************************************************************
      SUBROUTINE INTER (RFAL, PINT, LAI, SAI, FRINTL, FRINTS, CINTRL, 
     *   CINTRS, DTP, INTR, RINT, IRVP)
C     rain interception, used when NPINT > 1
C     same routine is used for snow interception, with different calling 
C        variables
      IMPLICIT NONE
C     input
        REAL   RFAL     ! rainfall rate, mm/d
        REAL   PINT     ! potential interception rate, mm/d
        REAL   LAI      ! projected leaf area index, m2/m2
        REAL   SAI      ! projected stem area index, m2/m2
        REAL   FRINTL   ! intercepted fraction of RFAL per unit LAI
        REAL   FRINTS   ! intercepted fraction of RFAL per unit SAI
        REAL   CINTRL   ! maximum interception storage of rain per unit LAI, mm
        REAL   CINTRS   ! maximum interception storage of rain per unit SAI, mm
        REAL   DTP      ! precipitation interval time step, d
        REAL   INTR     ! intercepted rain, mm
C     output
        REAL   RINT     ! rain catch rate, mm/d
        REAL   IRVP     ! evaporation rate of intercepted rain, mm/d
C     local
        REAL   INTRMX   ! maximum canopy storage for rain, mm
        REAL   CATCH    ! maximum RINT, mm/d
        REAL   NEWINT   ! first approximation to new canopy storage (INTR)
C
      CATCH = (FRINTL * LAI + FRINTS * SAI) * RFAL
      INTRMX = CINTRL * LAI + CINTRS * SAI
      NEWINT = INTR + (CATCH - PINT) * DTP
      IF (NEWINT .GT. 0.) THEN
C        canopy is wet throughout DTP
         IRVP = PINT
         IF (NEWINT .GT. INTRMX) THEN
C           canopy capacity is reached
            RINT = PINT + (INTRMX - INTR) / DTP
C           RINT can be negative if INTR exists and LAI or SAI is 
C              decreasing over time
         ELSE
C           canopy capacity is not reached
            RINT = CATCH
         END IF
      ELSE
C        canopy dries during interval or stays dry
         RINT = CATCH
         IRVP = (INTR / DTP) + CATCH
C        IRVP is < PINT
      END IF
      END

C     *************************************************************************
      SUBROUTINE INTER24 (RFAL, PINT, LAI, SAI, FRINTL, FRINTS, CINTRL, 
     *   CINTRS, DURATN, INTR, RINT, IRVP)
C     rain interception with duration in hours, used when NPINT = 1
C     same routine is used for snow interception, with different calling 
C        variables
      IMPLICIT NONE
C     input
        REAL   RFAL     ! 24-hour average rainfall rate, mm/d
        REAL   PINT     ! potential interception rate, mm/d
        REAL   LAI      ! projected leaf area index, m2/m2
        REAL   SAI      ! projected stem area index, m2/m2
        REAL   FRINTL   ! intercepted fraction of RFAL per unit LAI
        REAL   FRINTS   ! intercepted fraction of RFAL per unit SAI
        REAL   CINTRL   ! maximum interception storage of rain per unit LAI, mm
        REAL   CINTRS   ! maximum interception storage of rain per unit SAI, mm
        REAL   DURATN   ! average storm duration, hr
        REAL   INTR     ! intercepted rain storage, mm,
C     output
        REAL   RINT     ! rain catch rate, mm/d
        REAL   IRVP     ! evaporation rate of intercepted rain, mm/d
C     local
        REAL   INTRMX   ! maximum canopy storage for rain, mm
        REAL   INTRNU   ! canopy storage at end of hour, mm
        REAL   NEWINT   ! first approximation to INTRNU, mm
        REAL   RINTHR   ! rain catch rate for hour, mm/hr
        REAL   CATCH    ! maximum RINTHR, mm/hr
        REAL   IRVPHR   ! evaporation rate for hour, mm/hr
        REAL   SMINT    ! daily accumulated actual catch, mm
        REAL   SMVP     ! daily accumulated actual evaporation, mm
        INTEGER IHD     ! half DURATN in truncated integer hours
        INTEGER I       ! hour, 0 to 23
        REAL   DTH      ! time step, = 1 hr
C     intrinsic
C       REAL, INT
C
      IHD = INT((DURATN + .1) / 2)
      INTRMX = CINTRL * LAI + CINTRS * SAI
      INTRNU = INTR
      SMINT = 0.
      SMVP = 0.
      DTH = 1.
      DO 100 I = 0, 23
         IF (I .LT. (12 - IHD) .OR. I .GE. (12 + IHD)) THEN
C           before or after rain
            CATCH = 0.
         ELSE
C           during rain, mm/hr is rate in mm/d divided by hr of rain/d
            CATCH = (FRINTL * LAI + FRINTS * SAI) * RFAL / REAL(2 * IHD)
         ENDIF
         NEWINT = INTRNU + (CATCH - PINT / 24.) * DTH
         IF (NEWINT .GT. .0001) THEN
C           canopy is wet throughout hour, evap rate is PINT
            IRVPHR = PINT / 24.
            IF (NEWINT .GT. INTRMX) THEN
C              canopy capacity is reached
               RINTHR = IRVPHR + (INTRMX - INTRNU) / DTH
C              INTRMX - INTRNU can be negative if LAI or SAI is decreasing 
C                 over time
            ELSE
C              canopy capacity is not reached
               RINTHR = CATCH
            END IF
         ELSE
C           canopy dries during hour or stays dry
            RINTHR = CATCH
            IRVPHR = INTRNU / DTH + CATCH
C           IRVPHR for hour is < PI/24
         END IF
         INTRNU = INTRNU + (RINTHR - IRVPHR) * DTH
         SMVP = SMVP + IRVPHR * DTH
         SMINT = SMINT + RINTHR * DTH
  100 CONTINUE
      IRVP = SMVP
C                 / 1 d
      RINT = SMINT
C                 / 1 d
      END
    
C     *************************************************************************
      SUBROUTINE INTERMS (RNETMS, GIVP, MAI , FRINTLMS, CINTRLMS, 
     *   DTP, INTRMS, RINTMS, IRVPMS)
C     moss rain interception, used when NPINT > 1
C     same routine is used for snow interception, with different calling 
C        variables
      IMPLICIT NONE
C     input
        REAL   RNETMS    ! throughfall  minus  RSNO, mm/d
        REAL   GIVP      ! ground evaporation with interception, mm/d
        REAL   MAI       ! projected moss area index, m2/m2
        REAL   FRINTLMS  ! intercepted fraction of RNETMS per unit MAI
        REAL   CINTRLMS  ! maximum interception storage of rain per unit MAI, mm
        REAL   DTP       ! precipitation interval time step, d
        REAL   INTRMS    ! moss intercepted rain, mm
C     output
        REAL   RINTMS    ! moss catch rain rate, mm/d        
        REAL   IRVPMS    ! evaporation rate of  moss  intercepted rain, mm/d
C     local
        REAL   INTRMSMX  ! maximum moss storage for rain, mm
        REAL   CATCHMS   ! maximum RINTMS, mm/d
        REAL   NEWINTMS  ! first approximation to new moss storage (INTR)
C
         WRITE(*,*)"1CATCHMS=",CATCHMS
      CATCHMS = FRINTLMS* MAI* RNETMS
         WRITE(*,*)"2CATCHMS=",CATCHMS
      INTRMSMX = CINTRLMS* MAI
      NEWINTMS = INTRMS + (CATCHMS - GIVP) * DTP
      IF (NEWINTMS .GT. 0.) THEN
C        moss is wet throughout DTP
         IRVPMS = GIVP
         IF (NEWINTMS .GT. INTRMSMX) THEN
C           moss capacity is reached
            RINTMS = GIVP + (INTRMSMX - INTRMS) / DTP
C           RINTMS can be negative if INTRMS exists and MAI is 
C              decreasing over time
            ELSE
C           moss capacity is not reached
            WRITE(*,*)"3CATCHMS=",CATCHMS
            RINTMS = CATCHMS
            WRITE(*,*)"1RINTMS=",RINTMS
         END IF
      ELSE
C        canopy dries during interval or stays dry
          WRITE(*,*)"4CATCHMS=",CATCHMS
         RINTMS = CATCHMS
         WRITE(*,*)"2RINTMS=",RINTMS
         IRVPMS = (INTRMS / DTP) + CATCHMS
         WRITE(*,*)"IRVPMS=",IRVPMS
C        IRVPMSis < GIVP
      END IF
      END

123.zip

865.69 KB, 下载次数: 9

分享到:  微信微信
收藏收藏 点赞点赞 点踩点踩

55

帖子

17

主题

0

精华

熟手

F 币
261 元
贡献
169 点
沙发
 楼主| 发表于 2014-10-9 10:18:00 | 只看该作者
补充下,我用是win7的ivf2013

736

帖子

4

主题

0

精华

大师

农村外出务工人员

F 币
700 元
贡献
359 点

新人勋章爱心勋章水王勋章元老勋章热心勋章

板凳
发表于 2014-10-9 10:33:52 | 只看该作者
哪个变量的值是 1.0737E+08 ?你对他赋初值的代码在什么源代码里,第几行?

CATCHMS 的值不对,应该是多少?实际是多少?

55

帖子

17

主题

0

精华

熟手

F 币
261 元
贡献
169 点
地板
 楼主| 发表于 2014-10-9 10:48:40 | 只看该作者
楚香饭 发表于 2014-10-9 10:33
哪个变量的值是 1.0737E+08 ?你对他赋初值的代码在什么源代码里,第几行?

CATCHMS 的值不对,应该是多少 ...

在pfile这个txt里面,赋值是一,catchms应该是0,计算后输出也是0,可是第一天就是一个很大的数字

736

帖子

4

主题

0

精华

大师

农村外出务工人员

F 币
700 元
贡献
359 点

新人勋章爱心勋章水王勋章元老勋章热心勋章

5#
发表于 2014-10-9 11:02:43 | 只看该作者
[Fortran] 纯文本查看 复制代码
      SUBROUTINE INTERMS (RNETMS, GIVP, MAI , FRINTLMS, CINTRLMS, 
     *   DTP, INTRMS, RINTMS, IRVPMS)
C     moss rain interception, used when NPINT > 1
C     same routine is used for snow interception, with different calling 
C        variables
      IMPLICIT NONE
C     input
        REAL   RNETMS    ! throughfall  minus  RSNO, mm/d
        REAL   GIVP      ! ground evaporation with interception, mm/d
        REAL   MAI       ! projected moss area index, m2/m2
        REAL   FRINTLMS  ! intercepted fraction of RNETMS per unit MAI
        REAL   CINTRLMS  ! maximum interception storage of rain per unit MAI, mm
        REAL   DTP       ! precipitation interval time step, d
        REAL   INTRMS    ! moss intercepted rain, mm
C     output
        REAL   RINTMS    ! moss catch rain rate, mm/d        
        REAL   IRVPMS    ! evaporation rate of  moss  intercepted rain, mm/d
C     local
        REAL   INTRMSMX  ! maximum moss storage for rain, mm
        REAL   CATCHMS   ! maximum RINTMS, mm/d
        REAL   NEWINTMS  ! first approximation to new moss storage (INTR)
C
         WRITE(*,*)"1CATCHMS=",CATCHMS !// 此时你没赋值,其值不确定,是很大的数字也很正常。
      CATCHMS = FRINTLMS* MAI* RNETMS!// 执行这一步后,其值为 0

55

帖子

17

主题

0

精华

熟手

F 币
261 元
贡献
169 点
6#
 楼主| 发表于 2014-10-9 11:59:53 | 只看该作者
楚香饭 发表于 2014-10-9 11:02
[mw_shl_code=fortran,true]      SUBROUTINE INTERMS (RNETMS, GIVP, MAI , FRINTLMS, CINTRLMS,
     *  ...

那我怎么解决呢?

736

帖子

4

主题

0

精华

大师

农村外出务工人员

F 币
700 元
贡献
359 点

新人勋章爱心勋章水王勋章元老勋章热心勋章

7#
发表于 2014-10-9 12:12:57 | 只看该作者
本帖最后由 楚香饭 于 2014-10-9 12:14 编辑

Serious water balance error (BALERD .GT. 0.003 mm)
Must be a programming error
intrms=  0.0000000E+00
EVAPD= -1.0737418E+08
IRVPMS= -1.0737418E+08  0.0000000E+00
1CATCHMS= -1.0737418E+08
2CATCHMS=  0.0000000E+00
4CATCHMS=  0.0000000E+00
2RINTMS=  0.0000000E+00
IRVPMS=  0.0000000E+00
请按任意键继续. . .


以上是我的执行结果。

你不是说 CATCHMS 应该是 0 么?
CATCHMS = FRINTLMS* MAI* RNETMS!// 执行这一步后,其值为 0

已经符合你的想法了,你还需要怎么解决?


55

帖子

17

主题

0

精华

熟手

F 币
261 元
贡献
169 点
8#
 楼主| 发表于 2014-10-9 12:35:46 | 只看该作者
楚香饭 发表于 2014-10-9 12:12
以上是我的执行结果。

你不是说 CATCHMS 应该是 0 么?

关键是因为这个事软件不运行不出结果了
我的让他计算啊

736

帖子

4

主题

0

精华

大师

农村外出务工人员

F 币
700 元
贡献
359 点

新人勋章爱心勋章水王勋章元老勋章热心勋章

9#
发表于 2014-10-9 12:48:42 | 只看该作者
你的代码太长,看懂并理解它需要太多的时间,且需要你专业的知识。我无法代劳。

你提到的赋值为 0 ,很大的数,我已给你做出解答。

看起来问题既不是 IRVPMS 也不是 CATCHMS ,恐怕需要你自己去寻求原因,或者向代码作者寻求帮助了。

55

帖子

17

主题

0

精华

熟手

F 币
261 元
贡献
169 点
10#
 楼主| 发表于 2014-10-9 13:15:49 | 只看该作者
楚香饭 发表于 2014-10-9 12:48
你的代码太长,看懂并理解它需要太多的时间,且需要你专业的知识。我无法代劳。

你提到的赋值为 0 ,很大 ...

我想知道如何让catchms一开始不计算的时候就=0
您需要登录后才可以回帖 登录 | 极速注册

本版积分规则

捐赠本站|Archiver|关于我们 About Us|小黑屋|Fcode ( 京ICP备18005632-2号 )

GMT+8, 2024-12-24 01:00

Powered by Tencent X3.4

© 2013-2024 Tencent

快速回复 返回顶部 返回列表