rniswon / mfnwt

MODFLOW-NWT - Version: 1.1.0 Newton Formulation for MODFLOW-2005 For more information go to http://water.usgs.gov/ogw/modflow-nwt
4 stars 7 forks source link

Bugs in LMT8 #6

Closed langevin-usgs closed 7 years ago

langevin-usgs commented 7 years ago

Guys, I found a couple problems with the following code in lmt8.f. I am fixing it in mf2005, but I have not fixed it in mfnwt.

C--MANIPULATE IUZFRCH
      IF(NUZTOP.EQ.1.OR.NUZTOP.EQ.2) THEN ! No need to loop through layers with these options
        DO I=1,NROW
          DO J=1,NCOL
            IF(IBOUND(J,I,K).GT.0) THEN
              IF(NUZTOP.EQ.1) THEN ! Recharge to and discharge from only the top layer
                IUZFRCH(J,I)=1
              ELSEIF(NUZTOP.EQ.2) THEN ! Recharge to and discharge from the layer specified in IUZFBND
                IUZFRCH(J,I)=IUZFBND(J,I)
                BUFF(J,I,1)=BUFF(J,I,IUZFBND(J,I))
              ENDIF
            ENDIF
          ENDDO
        ENDDO
      ELSEIF(NUZTOP.EQ.3) THEN
        DO I=1,NROW
          DO J=1,NCOL
            DO K=1,NLAY  
              IF(IBOUND(J,I,K).GT.0) THEN
                IF(J.EQ.169) THEN
                  CONTINUE
                ENDIF
                IF(HNEW(J,I,K).GT.BOTM(J,I,0)) THEN ! water table above land surface
                  IUZFRCH(J,I)=1
                  EXIT
                ELSEIF(HNEW(J,I,K).GT.BOTM(J,I,K)) THEN ! water table in the first layer
                  IUZFRCH(J,I)=K
                  EXIT
                ENDIF
              ENDIF
            ENDDO
          ENDDO
        ENDDO
      ENDIF

This is how I changed it. Note there are two places: (1) in setting K before accessing ibound(j,i,k), and (2) commenting out the rogue "if j.eq.169" conditional.

C--MANIPULATE IUZFRCH
      IF(NUZTOP.EQ.1.OR.NUZTOP.EQ.2) THEN ! No need to loop through layers with these options
        DO I=1,NROW
          DO J=1,NCOL
            K=1
            IF(NUZTOP.EQ.2) K=IUZFBND(J,I)
            IF(IBOUND(J,I,K).GT.0) THEN
              IF(NUZTOP.EQ.1) THEN ! Recharge to and discharge from only the top layer
                IUZFRCH(J,I)=1
              ELSEIF(NUZTOP.EQ.2) THEN ! Recharge to and discharge from the layer specified in IUZFBND
                IUZFRCH(J,I)=IUZFBND(J,I)
                BUFF(J,I,1)=BUFF(J,I,IUZFBND(J,I))
              ENDIF
            ENDIF
          ENDDO
        ENDDO
      ELSEIF(NUZTOP.EQ.3) THEN
        DO I=1,NROW
          DO J=1,NCOL
            DO K=1,NLAY  
              IF(IBOUND(J,I,K).GT.0) THEN
                !IF(J.EQ.169) THEN
                !  CONTINUE
                !ENDIF
                IF(HNEW(J,I,K).GT.BOTM(J,I,0)) THEN ! water table above land surface
                  IUZFRCH(J,I)=1
                  EXIT
                ELSEIF(HNEW(J,I,K).GT.BOTM(J,I,K)) THEN ! water table in the first layer
                  IUZFRCH(J,I)=K
                  EXIT
                ENDIF
              ENDIF
            ENDDO
          ENDDO
        ENDDO
      ENDIF