You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While investigating flopy's t052 that demonstrates using an unformatted (a.k.a. BINARY) open/close file for the WEL package, I found a Fortran bug in ULSTRD.
When compiled without optimisation, there is often no bug as all variables (e.g. JAUX) are initialised as zero, and the two well stress rates are correctly listed as -1000. and -500.0.
Gfortran has a silent form of this bug, where all stress rates are printed as -0.0, and well budget terms are also printed as zero. It seems that all stress rates were multiplied by zero on line 378 of util7.f, as SFAC=1. (at top of subroutine).
Intel with "-g -O0 -traceback -check all" compiler flags is a bit more explicit:
$ mf2005 t1.nam
MODFLOW-2005
U.S. GEOLOGICAL SURVEY MODULAR FINITE-DIFFERENCE GROUND-WATER FLOW MODEL
Version 1.12.00 2/3/2017
Using NAME file: t1.nam
Run start date and time (yyyy/mm/dd hh:mm:ss): 2018/08/30 14:48:59
forrtl: severe (194): Run-Time Check Failure. The variable 'ulstrd_$JAUX' is being used in 'utl7.f(378,18)' without being defined
Image PC Routine Line Source
mf2005 0000000001D876DD ulstrd_ 378 utl7.f
mf2005 00000000019BA3EC gwf2wel7rp_ 177 gwf2wel7.f
mf2005 0000000001B28FCC MAIN__ 156 mf2005.f
mf2005 000000000040569E Unknown Unknown Unknown
libc-2.12.so 0000003A2401ED1D __libc_start_main Unknown Unknown
mf2005 00000000004055A9 Unknown Unknown Unknown
Indeed JAUX is only initialised for the formatted read. One suggestion is to move this initialization at the top and/or only scale the fields for the ascii file. I've done both in this patch:
--- utl7.f.orig
+++ utl7.f.mod
@@ -222,6 +222,7 @@
IN=INPACK
ICLOSE=0
IBINARY=0
+ JAUX=0
READ(IN,'(A)') LINE
SFAC=1.
LLOC=1
@@ -323,7 +324,6 @@
C
C5------CHECK FOR AUXILIARY VARIABLE "AUXSFAC" AND STORE LOCATION
C5------READ AN ASCII LIST
- JAUX = 0
DO 230 JJ=1,NAUX
IF(CAUX(JJ) .EQ. "AUXSFAC") THEN
JAUX=JJ+NREAD1
@@ -373,10 +373,12 @@
J=RLIST(3,II)
C
C6A------Scale fields ISCLOC1-ISCLOC2 by SFAC and AUXSFAC (if present)
+ IF (IBINARY.NE.1) THEN
DO 204 ILOC=ISCLOC1,ISCLOC2
RLIST(ILOC,II)=RLIST(ILOC,II)*SFAC
IF (JAUX .NE. 0) RLIST(ILOC,II)=RLIST(ILOC,II)*RLIST(JAUX,II)
204 CONTINUE
+ END IF
C
C6C-----Write the values that were read if IPRFLG is 1.
NN=II-LSTBEG+1
Cheers,
The text was updated successfully, but these errors were encountered:
From Mike Toews:
Hi Christian,
While investigating flopy's t052 that demonstrates using an unformatted (a.k.a. BINARY) open/close file for the WEL package, I found a Fortran bug in ULSTRD.
When compiled without optimisation, there is often no bug as all variables (e.g. JAUX) are initialised as zero, and the two well stress rates are correctly listed as -1000. and -500.0.
Gfortran has a silent form of this bug, where all stress rates are printed as -0.0, and well budget terms are also printed as zero. It seems that all stress rates were multiplied by zero on line 378 of util7.f, as SFAC=1. (at top of subroutine).
Intel with "-g -O0 -traceback -check all" compiler flags is a bit more explicit:
Indeed JAUX is only initialised for the formatted read. One suggestion is to move this initialization at the top and/or only scale the fields for the ascii file. I've done both in this patch:
Cheers,
The text was updated successfully, but these errors were encountered: