OpenCDSS / cdss-app-statecu-fortran

Colorado's Decision Support Systems (CDSS) StateCU consumptive use model code, documentation, tests
GNU General Public License v3.0
1 stars 1 forks source link

Update code for latest gfortran to eliminate warnings #15

Closed smalers closed 3 years ago

smalers commented 3 years ago

The StateCU code needs to be recompiled with the latest gfortran similar to StateMod and update code in response to compiler warnings. Here are some instructions that I previously provided to Erin Wilson in an email for how to use the new compiler. I've added links.

  1. Install the latest gfortran compiler using the MSys2/MinGW environment using documentation that I created for StateMod.
  2. Open the appropriate MSys2/MinGW window (64-bit or 32-bit).
  3. Change to the source code folder.
  4. Run make help to see compile options.
  5. Run make veryclean to clean out old object files and executable
  6. Run make statecu to compile.

Fix the code problems and repeat step 6 as necessary. I suspect that there will be some specific things that I need to help you with. I may need to get you an updated makefile and that will be obvious once you get going because things will either work or not work when compiling.

Most of the changes seem to be adding CONTINUE or END DO to loops rather than relying on calculation lines with label number. Arithmetic IF statements can be replaced with logic like:

Old:

IF ( a ) 100, 110, 120

New:

IF ( a < 0 ) THEN
   GOTO 100
ELSE IF ( a == 0 )
   GOTO 110
ELSE
  GOTO 120
END IF
smalers commented 3 years ago

I received a zip file from Erin with her code changes to address compiler warnings. I am using kdiff3 to visually compare the files one by one and copy into the current code. In general, the changes she made are:

Change Type Comment
Replace tabs in code with spaces. Ensures consistent formatting across text editors.
Add explicit continue statements for end of loops. Responds to compiler warnings.
Add int to cast numbers to integer where appropriate rather than relying on compiler to auto-cast. Responds to compiler warning about loss in precision when auto-casting.
Remove unused variables. Responds to compiler warnings.
Initialize all variables. Good, because Fortran does not by default initialize to zero and don't want to rely on global compiler option.
Remove or comment out unused FORMAT statements. Respond to compiler warnings.
Logic changes. I assume related to new features, code cleanup, and follow up to previous Jim Brannon work.
Remove old code that was commented out. Code cleanup.
Additional code comments. Always a good thing.
New code merged. Work that was done for ArkDSS? is included, with some files having significant changes.

Notes below are any additional changes made during this process.

File Comment
General Seems like code from around 5/31/2019 was merged and other changes? I assume that this is new functionality for Arkansas? Most of the compiler warning changes seem trivial but I cannot comment on the level of effort needed for these other changes. Hopefully a dataset is available to execute the new features.
General Seem to be using substring to deal with some string issues but maybe don't need to use substring? This limits the potential for future updates to allow longer identifiers. Using the substring may be unneeded.
All Need to change the copyright notice at the top to have ending year of 2021. I did not change this because want to have a clean comparison with the latest files.
All Doing a check for -999 and -998 on real numbers could return false if internal precision results in difference, especially values read from files. I typically use a function like isMissing() that checks for a range on either side. This has apparently been working for years so maybe it is not an issue.
calpcrop.for Not sure why cropid needs to be set to characters 1:12 rather than the full string.
etrrref.for Empty file provided by Erin. Assume this is an editing mistake and that changes are correctly made to etrref.for. Not including the file in the compile.
fall.for Line continuation uses exclamation in column 6. This is also used for inline comments and could result in confusion. I recommend using another character like ampersand or colon that can't be confused with actual code. This is a tricky thing because using a plus sign, asterisk, or number could be an issue if accidentally moved outside of column 6 since an equation line. In general, want to use a character that will cause the compiler to complain if it is accidentally put in the wrong column.
flyfill.for Empty file provided by Erin. Assume this is an editing mistake and that changes are correctly made to other flyfill* file. Not including the file in the compile.
gcommon.inc There are many changes that are difficult for me to comment on. Needs to have RDATE set to the release date corresponding to the version. I also recommend changing the version to Semantic versioning such as 13.11.0 where the first is major release, second is minor release, and third is bug fix release. It is good to see use of parameter and more could be done, although this can be a keyword on a variable rather than separate parameter statement (Fortran reference recommends this more modern syntax).
makefile Was not provided. Assume it has been modified for new files.
pmcommon.inc Question about KCDAY being an integer. Keep an eye on this related to remaining warning.
proto.for Not sure why substring is needed for some strings. Note that built-in trim function might be useful. There are some continue statements that don't have statement numbers, which may lead to some confusion.
readcrc.for Empty file provided by Erin. Assume this is an editing mistake and that changes are correctly made to readrcr.for file. Not including the file in the compile.
readrcr.for Not sure why substring is needed. See previous comments.
readepr.for New file. Add to makefile.
satecu.for Empty file provided by Erin. Assume this is an editing mistake and that changes are correctly made to statecu.for file or the next file below. Not including the file in the compile.
statecu_7-2-21.for Renamed to statecu.for for comparison. Not sure why it was necessary to change the filename and this could lead to confusion if there is an old statecu.for in the folder that is being used by the makefile. Since the makefile was not provided, I can't check.
sb_init.for Should not be necessary to initialize strings to all blanks? Old code should be fine. See use of trim if necessary.
slimit.for Change from flag to flags could have been confusing before. Not sure why substrings used. See previous comments.
spring.for Noticed 30.5. I never have understood why using a non-actual number of days is OK. It is simple enough to figure out the actual number of days in a month considering leap years.
statecu.for Was not provided. See above comments. Hopefully there is no confusion with what main program is being compiled into the executable by the makefile.
summary.for Not sure why substring is needed. See previous comments.
table.for Noticed in changed code that some IF statements don't have an ELSE. I generally always try to have an ELSE if there is potential for bad input. Not sure if this is the case here but previous code had other values for ITIME near line 135.
wsuply.for Empty file provided by Erin. Assume this is an editing mistake and that changes are correctly made to wsupply.for file. Not including the file in the compile.
wsupsum.for Not sure why substring is needed for twdid and some other strings. See previous comments.
smalers commented 3 years ago

After copying all the changed/new files, I used the latest makefile to run make state_curelease. I also updated the makefile to have -Wall for the optimized version (leaving out was an oversight). This compiles both the optimized _o3 version and the check _check version executables. There are quite a few warnings printed for statecu.for code. See my review comments above about possible confusion. The warnings are shown at the bottom of this issue.

I copied the statecu-13.12-gfortran-win-64bit-check.exe file to StateCU folder that I have with cm2015 dataset used with StateMod testing. I ran with:

statecu-13.11-gfortran-win-64bit-check.exe cm2015
StateCU Version 13.11      DUMB
 Reading Response File: cm2015.rcu                                                                                                                                                            
 Reading Control File:  cm2015.ccu                                                                                                                                                            
 Reading Climate Station File:  COclim2015.cli                                                                                                                                                
 Reading Monthly Temperature File: COclim2015.tem                                                                                                                                             
 Reading Monthly Precipitation File:  COclim2015.prc                                                                                                                                          
 Reading Structure File:  cm2015.str                                                                                                                                                          
 Reading Crop Characteristics File:  CDSS.cch                                                                                                                                                 
 Reading Water Supply File:  cm2015_cu.ddh                                                                                                                                                    
 Reading in historic diversion file
 Reading Crop Acreage File:  cm2015.cds                                                                                                                                                       
 Reading Frost Date File:  COclim2015.fd                                                                                                                                                      
 Summarizing input to file *.sum and processing
 Starting Blaney Criddle Process
 Reading Crop Coefficient File
 Calculating consumptive use:
   processed through structure #          25
   processed through structure #          50
   processed through structure #          75
   processed through structure #         100
   processed through structure #         125
   processed through structure #         150
   processed through structure #         175
   processed through structure #         200
   processed through structure #         225
   processed through structure #         250
   processed through structure #         275
   processed through structure #         300
   processed through structure #         325
   processed through structure #         350
   processed through structure #         375
   finished
 Preparing Water Budget:
   processed through structure #          25
   processed through structure #          75
   processed through structure #         100
   processed through structure #         125
   processed through structure #         150
   processed through structure #         175
   processed through structure #         200
   processed through structure #         225
   processed through structure #         250
   processed through structure #         300
   processed through structure #         325
   processed through structure #         350
   processed through structure #          50
   processed through structure #         275
   processed through structure #         375
 Writing water budget output:
   processed through structure #          25
   processed through structure #          50
   processed through structure #          75
   processed through structure #         100
   processed through structure #         125
   processed through structure #         150
   processed through structure #         175
   processed through structure #         200
   processed through structure #         225
   processed through structure #         250
   processed through structure #         275
   processed through structure #         300
   processed through structure #         325
   processed through structure #         350
   processed through structure #         375
   finished
 Writing consumptive use summary:
 Creating *.ddc file (statemod formatted results)
Note: The following floating-point exceptions are signalling: IEEE_INVALID_FLAG

The first question I have is where exactly is the warning being generated? See: Options for debugging your program or GNU Fortran. Based on this documentation, I added the following to compile the check version (note -ffpe). Then I did a full clean compile.

FFLAGS_CHECK = -g -O1 -Wall -cpp -DCOMPILER=$(COMPILER_ENUM) -fno-align-commons -ffpe-trap=invalid,zero,overflow -static $(FFLAGS_ARCH) $(FFLAGS_EXTRA_CHECKS) -I/usr/include

Using an MSys2 64 window, run again:

./statecu-13.11-gfortran-win-64bit-check.exe cm2015
StateCU Version 13.11      DUMB
 Reading Response File: cm2015.rcu                                                                                                                                                                    
 Reading Control File:  cm2015.ccu                                                                                                                                                                    
 Reading Climate Station File:  COclim2015.cli                                                                                                                                                        
 Reading Monthly Temperature File: COclim2015.tem                                                                                                                                                     
 Reading Monthly Precipitation File:  COclim2015.prc                                                                                                                                                  
 Reading Structure File:  cm2015.str                                                                                                                                                                  
 Reading Crop Characteristics File:  CDSS.cch                                                                                                                                                         
 Reading Water Supply File:  cm2015_cu.ddh                                                                                                                                                            
 Reading in historic diversion file
 Reading Crop Acreage File:  cm2015.cds                                                                                                                                                               
 Reading Frost Date File:  COclim2015.fd                                                                                                                                                              
 Summarizing input to file *.sum and processing
 Starting Blaney Criddle Process
 Reading Crop Coefficient File
 Calculating consumptive use:
   processed through structure #          25
   processed through structure #          50
   processed through structure #          75
   processed through structure #         100
   processed through structure #         125
   processed through structure #         150
   processed through structure #         175
   processed through structure #         200
   processed through structure #         225
   processed through structure #         250
   processed through structure #         275
   processed through structure #         300
   processed through structure #         325
   processed through structure #         350
   processed through structure #         375
   finished
 Preparing Water Budget:
   processed through structure #          25
   processed through structure #          75
   processed through structure #         100
   processed through structure #         125
   processed through structure #         150
   processed through structure #         175
   processed through structure #         200
   processed through structure #         225
   processed through structure #         250
   processed through structure #         300
   processed through structure #         325
   processed through structure #         350
   processed through structure #          50
   processed through structure #         275
   processed through structure #         375
 Writing water budget output:
   processed through structure #          25
   processed through structure #          50
   processed through structure #          75
   processed through structure #         100
   processed through structure #         125
   processed through structure #         150
   processed through structure #         175
   processed through structure #         200
   processed through structure #         225
   processed through structure #         250
   processed through structure #         275
   processed through structure #         300
   processed through structure #         325
   processed through structure #         350
   processed through structure #         375
   finished
 Writing consumptive use summary:

Program received signal SIGFPE: Floating-point exception - erroneous arithmetic operation.

Backtrace for this error:
#0  0x2975fb
#1  0x28f904
#2  0x270b21
#3  0xa1f37ff7
#4  0xa2cf217e
#5  0xa2ca1453
#6  0xa2cf0cad
#7  0x265b2f
#8  0x1b8ea6
#9  0x19dcbd
#10  0x19ffb4
#11  0x1913c0
#12  0x1914f5
#13  0xa20f7033
#14  0xa2ca2650
#15  0xffffffff

Debug with:

gdb statecu-13.11-gfortran-win-64bit-check.exe

run cm2015

...
 Writing water budget output:
   processed through structure #          25
   processed through structure #          50
   processed through structure #          75
   processed through structure #         100
   processed through structure #         125
   processed through structure #         150
   processed through structure #         175
   processed through structure #         200
   processed through structure #         225
   processed through structure #         250
   processed through structure #         275
   processed through structure #         300
   processed through structure #         325
   processed through structure #         350
   processed through structure #         375
   finished
 Writing consumptive use summary:
 Creating *.ddc file (statemod formatted results)
[Thread 17064.0xbb00 exited with code 0]
[Inferior 1 (process 17064) exited normally]

So that is pretty irritating because the error does not show up in the debugger. It must be occurring in the Writing consumptive use summary code. I added some write statements to try to narrow it down. I'm confused why the program opens unit 999 for the log file but after running the cm2015.log file only has one line showing the version. The fort.6 file contains the message I added. I'm wondering if Erin is seeing some weird behavior with the log file.

I did find that unit 6 is being closed in wsupsum.for and should not be since this is the console output. Unit 1 is standard error, unit 5 is standard input (user command line input), and unit 6 is standard output (console output). The wsupsum.for program is opening and closing unit 5 and 6 and should not be. I changed the open(5,... to open(599,... and similar for 6 to 699. I changed the write and close statements similarly, making sure that the statements don't go past column 72. I removed the fort.6 file and reran. Now I don't get that file but the log file still only has the one line. Any write statement that I added that is WRITE(*,.. does not output to standard output. Switching to WRITE(0,... does write to the console using standard error. I'm confused why the log file does not work. Anyhow, the problem is in PROJ or code that it calls.

Reading the compiler docs some more, I added -fbacktrace to see if that forces a core file to be dumped. Nope. Pretty frustrating not to be able to use the debugger on a core file.

Finally, I resorted to putting in write statements and the culprit is pointed out as IPTOT=:0 which leads to division by zero. Erin needs to comment on the root cause.

 TABLE Processing IY=          62  of           64
 TABLE Processing IY=          63  of           64
 TABLE Processing IY=          64  of           64
 TABLE before calculating AR_AVG
 TABLE before calculating UDEPTH
 IPTOT=           0  AR_AVG=   1662.91956

Below are compile warnings from the original compile step (before all the troubleshooting above).

gfortran -g -O1 -Wall -cpp -DCOMPILER=1 -fno-align-commons -static -Wl,--default-image-base-low -fcheck=bits,bounds,do,mem,pointer,recursion -I/usr/include -c statecu.for
statecu.for:2038:3:

 2038 | 999   FORMAT(1x,'program is running...')
      |   1
Warning: Label 999 at (1) defined but not used [-Wunused-label]
statecu.for:2032:3:

 2032 | 942   format(5x,a30,f10.0)
      |   1
Warning: Label 942 at (1) defined but not used [-Wunused-label]
statecu.for:2021:3:

 2021 | 936   format(a20,1x,i2,2x,i2,1x,i2,2x,i2,2x,i2,2x,i4,1x,i4,1x,f3.0,1x,
      |   1
Warning: Label 936 at (1) defined but not used [-Wunused-label]
statecu.for:2020:3:

 2020 | 935   format(i4,1x,a12,8x,F10.0,i10)
      |   1
Warning: Label 935 at (1) defined but not used [-Wunused-label]
statecu.for:2019:3:

 2019 | 934   format(4x,A20,F10.0)
      |   1
Warning: Label 934 at (1) defined but not used [-Wunused-label]
statecu.for:2018:3:

 2018 | 933   format(a12)
      |   1
Warning: Label 933 at (1) defined but not used [-Wunused-label]
statecu.for:2017:3:

 2017 | 932   format(12x,12f8.0)
      |   1
Warning: Label 932 at (1) defined but not used [-Wunused-label]
statecu.for:2016:3:

 2016 | 931   format(i8,i4)
      |   1
Warning: Label 931 at (1) defined but not used [-Wunused-label]
statecu.for:2015:3:

 2015 | 929   format(a20)
      |   1
Warning: Label 929 at (1) defined but not used [-Wunused-label]
statecu.for:2014:3:

 2014 | 928   format('No default crop mix found for structure ',a12)
      |   1
Warning: Label 928 at (1) defined but not used [-Wunused-label]
statecu.for:2013:3:

 2013 | 927   format('warning: Default crop types used for structure ',a12)
      |   1
Warning: Label 927 at (1) defined but not used [-Wunused-label]
statecu.for:2010:3:

 2010 | 925   FORMAT(1X,'warning- Structure ', A12,' has a demsrc of '
      |   1
Warning: Label 925 at (1) defined but not used [-Wunused-label]
statecu.for:2005:3:

 2005 | 923   FORMAT(A12, A24)
      |   1
Warning: Label 923 at (1) defined but not used [-Wunused-label]
statecu.for:2004:3:

 2004 | 922   format(1x,i8,1x,a12,1x,i2,10(1x,a20,f6.0))
      |   1
Warning: Label 922 at (1) defined but not used [-Wunused-label]
statecu.for:2003:3:

 2003 | 921   format(a12,1x,i5)
      |   1
Warning: Label 921 at (1) defined but not used [-Wunused-label]
statecu.for:2002:3:

 2002 | 920   format(48x,f8.0,i8)
      |   1
Warning: Label 920 at (1) defined but not used [-Wunused-label]
statecu.for:2001:3:

 2001 | 919   format(a12,4x,i2)
      |   1
Warning: Label 919 at (1) defined but not used [-Wunused-label]
statecu.for:1999:3:

 1999 | 917   format(a12,1x,f7.0,16x,a10,i8,1x,f5.0,2x,f5.0)
      |   1
Warning: Label 917 at (1) defined but not used [-Wunused-label]
statecu.for:1998:3:

 1998 | 916   format(a12,f6.0,f9.0,2x,a20,a8,2x,a20)
      |   1
Warning: Label 916 at (1) defined but not used [-Wunused-label]
statecu.for:1997:3:

 1997 | 915   format(i2,6x,f5.3,18x,a10,1x,i8)
      |   1
Warning: Label 915 at (1) defined but not used [-Wunused-label]
statecu.for:1996:3:

 1996 | 914   CALL MYEXIT(20)
      |   1
Warning: Label 914 at (1) defined but not used [-Wunused-label]
statecu.for:1988:3:

 1988 | 905   format (a40)
      |   1
Warning: Label 905 at (1) defined but not used [-Wunused-label]
statecu.for:1987:3:

 1987 | 903   FORMAT(I3,A20,A15)
      |   1
Warning: Label 903 at (1) defined but not used [-Wunused-label]
statecu.for:1986:3:

 1986 | 902   FORMAT(I2,A20)
      |   1
Warning: Label 902 at (1) defined but not used [-Wunused-label]
statecu.for:1985:3:

 1985 | 901   FORMAT(A40)
      |   1
Warning: Label 901 at (1) defined but not used [-Wunused-label]
statecu.for:1562:3:

 1562 | 555          do 560 j2=1,tncrop
      |   1
Warning: Label 555 at (1) defined but not used [-Wunused-label]
statecu.for:1411:3:

 1411 | 510    if(isuply .gt. 0) then
      |   1
Warning: Label 510 at (1) defined but not used [-Wunused-label]
statecu.for:1516:72:

 1516 |          twdid=bas_id(j1)
      |                                                                        1
Warning: CHARACTER expression will be truncated in assignment (12/40) at (1) [-Wcharacter-truncation]
statecu.for:1579:72:

 1579 |           twdid=bas_id(j1)
      |                                                                        1
Warning: CHARACTER expression will be truncated in assignment (12/40) at (1) [-Wcharacter-truncation]
statecu.for:78:33:

   78 |       CHARACTER*200 dfile1,argmet,prfile,ddcfile,croprep,setout
      |                                 1
Warning: Unused variable 'argmet' declared at (1) [-Wunused-variable]
statecu.for:101:23:

  101 |       character*9 celev
      |                       1
Warning: Unused variable 'celev' declared at (1) [-Wunused-variable]
statecu.for:92:25:

   92 |       character*20 chtest
      |                         1
Warning: Unused variable 'chtest' declared at (1) [-Wunused-variable]
statecu.for:78:56:

   78 |       CHARACTER*200 dfile1,argmet,prfile,ddcfile,croprep,setout
      |                                                        1
Warning: Unused variable 'croprep' declared at (1) [-Wunused-variable]
statecu.for:78:26:

   78 |       CHARACTER*200 dfile1,argmet,prfile,ddcfile,croprep,setout
      |                          1
Warning: Unused variable 'dfile1' declared at (1) [-Wunused-variable]
statecu.for:107:41:

  107 |       integer pyr1,pyr2,i1(DIM_NA,DIM_NY),i2(DIM_NA,DIM_NY)
      |                                         1
Warning: Array 'i1' at (1) is larger than limit set by '-fmax-stack-var-size=', moved from stack to static storage. This makes the procedure unsafe when called recursively, or concurrently from multiple threads. Consider using '-frecursive', or increase the '-fmax-stack-var-size=' limit, or change the code to use an ALLOCATABLE array. [-Wsurprising]
statecu.for:107:59:

  107 |       integer pyr1,pyr2,i1(DIM_NA,DIM_NY),i2(DIM_NA,DIM_NY)
      |                                                           1
Warning: Array 'i2' at (1) is larger than limit set by '-fmax-stack-var-size=', moved from stack to static storage. This makes the procedure unsafe when called recursively, or concurrently from multiple threads. Consider using '-frecursive', or increase the '-fmax-stack-var-size=' limit, or change the code to use an ALLOCATABLE array. [-Wsurprising]
statecu.for:108:31:

  108 |       integer i3(DIM_NA,DIM_NY), i4(DIM_NA,DIM_NY)
      |                               1
Warning: Array 'i3' at (1) is larger than limit set by '-fmax-stack-var-size=', moved from stack to static storage. This makes the procedure unsafe when called recursively, or concurrently from multiple threads. Consider using '-frecursive', or increase the '-fmax-stack-var-size=' limit, or change the code to use an ALLOCATABLE array. [-Wsurprising]
statecu.for:108:50:

  108 |       integer i3(DIM_NA,DIM_NY), i4(DIM_NA,DIM_NY)
      |                                                  1
Warning: Array 'i4' at (1) is larger than limit set by '-fmax-stack-var-size=', moved from stack to static storage. This makes the procedure unsafe when called recursively, or concurrently from multiple threads. Consider using '-frecursive', or increase the '-fmax-stack-var-size=' limit, or change the code to use an ALLOCATABLE array. [-Wsurprising]
statecu.for:103:39:

  103 |       integer thuc,tyr,tyr1,ptyr,ifound,if1,ttyr
      |                                       1
Warning: Unused variable 'ifound' declared at (1) [-Wunused-variable]
statecu.for:105:46:

  105 |       integer t1,t2,t3,t4,t5,t6,t7,t8,iloca(7),rept2,rept6
      |                                              1
Warning: Unused variable 'iloca' declared at (1) [-Wunused-variable]
statecu.for:104:33:

  104 |       integer tread,ttcrop,istart,tncrop,tnparce
      |                                 1
Warning: Unused variable 'istart' declared at (1) [-Wunused-variable]
statecu.for:76:26:

   76 |       INTEGER I, J, K, IYR
      |                          1
Warning: Unused variable 'iyr' declared at (1) [-Wunused-variable]
statecu.for:97:30:

   97 |       character*40 tbasin,line,fstring
      |                              1
Warning: Unused variable 'line' declared at (1) [-Wunused-variable]
statecu.for:80:35:

   80 |       integer(2) nbuff,statln,ndlyt
      |                                   1
Warning: Unused variable 'ndlyt' declared at (1) [-Wunused-variable]
statecu.for:113:19:

  113 |       integer numch
      |                   1
Warning: Unused variable 'numch' declared at (1) [-Wunused-variable]
statecu.for:78:40:

   78 |       CHARACTER*200 dfile1,argmet,prfile,ddcfile,croprep,setout
      |                                        1
Warning: Unused variable 'prfile' declared at (1) [-Wunused-variable]
statecu.for:96:32:

   96 |       character*10 tcounty,rept1,rept3,tid2
      |                                1
Warning: Unused variable 'rept1' declared at (1) [-Wunused-variable]
statecu.for:105:52:

  105 |       integer t1,t2,t3,t4,t5,t6,t7,t8,iloca(7),rept2,rept6
      |                                                    1
Warning: Unused variable 'rept2' declared at (1) [-Wunused-variable]
statecu.for:96:38:

   96 |       character*10 tcounty,rept1,rept3,tid2
      |                                      1
Warning: Unused variable 'rept3' declared at (1) [-Wunused-variable]
statecu.for:82:35:

   82 |       REAL tlat,tttwws,tttwrs,rept4,rept5
      |                                   1
Warning: Unused variable 'rept4' declared at (1) [-Wunused-variable]
statecu.for:82:41:

   82 |       REAL tlat,tttwws,tttwrs,rept4,rept5
      |                                         1
Warning: Unused variable 'rept5' declared at (1) [-Wunused-variable]
statecu.for:105:58:

  105 |       integer t1,t2,t3,t4,t5,t6,t7,t8,iloca(7),rept2,rept6
      |                                                          1
Warning: Unused variable 'rept6' declared at (1) [-Wunused-variable]
statecu.for:78:63:

   78 |       CHARACTER*200 dfile1,argmet,prfile,ddcfile,croprep,setout
      |                                                               1
Warning: Unused variable 'setout' declared at (1) [-Wunused-variable]
statecu.for:80:29:

   80 |       integer(2) nbuff,statln,ndlyt
      |                             1
Warning: Unused variable 'statln' declared at (1) [-Wunused-variable]
statecu.for:84:14:

   84 |       real t21,t22,t33(12),tpct1
      |              1
Warning: Unused variable 't21' declared at (1) [-Wunused-variable]
statecu.for:84:18:

   84 |       real t21,t22,t33(12),tpct1
      |                  1
Warning: Unused variable 't22' declared at (1) [-Wunused-variable]
statecu.for:84:26:

   84 |       real t21,t22,t33(12),tpct1
      |                          1
Warning: Unused variable 't33' declared at (1) [-Wunused-variable]
statecu.for:81:33:

   81 |       character*127 command,tchar,tdesc
      |                                 1
Warning: Unused variable 'tchar' declared at (1) [-Wunused-variable]
statecu.for:81:39:

   81 |       character*127 command,tchar,tdesc
      |                                       1
Warning: Unused variable 'tdesc' declared at (1) [-Wunused-variable]
statecu.for:85:31:

   85 |       real rlat(dim_na),tlo,tel,trlatd,relev(dim_na)
      |                               1
Warning: Unused variable 'tel' declared at (1) [-Wunused-variable]
statecu.for:96:43:

   96 |       character*10 tcounty,rept1,rept3,tid2
      |                                           1
Warning: Unused variable 'tid2' declared at (1) [-Wunused-variable]
statecu.for:85:27:

   85 |       real rlat(dim_na),tlo,tel,trlatd,relev(dim_na)
      |                           1
Warning: Unused variable 'tlo' declared at (1) [-Wunused-variable]
statecu.for:104:48:

  104 |       integer tread,ttcrop,istart,tncrop,tnparce
      |                                                1
Warning: Unused variable 'tnparce' declared at (1) [-Wunused-variable]
statecu.for:104:19:

  104 |       integer tread,ttcrop,istart,tncrop,tnparce
      |                   1
Warning: Unused variable 'tread' declared at (1) [-Wunused-variable]
statecu.for:85:38:

   85 |       real rlat(dim_na),tlo,tel,trlatd,relev(dim_na)
      |                                      1
Warning: Unused variable 'trlatd' declared at (1) [-Wunused-variable]
statecu.for:104:26:

  104 |       integer tread,ttcrop,istart,tncrop,tnparce
      |                          1
Warning: Unused variable 'ttcrop' declared at (1) [-Wunused-variable]
statecu.for:82:29:

   82 |       REAL tlat,tttwws,tttwrs,rept4,rept5
      |                             1
Warning: Unused variable 'tttwrs' declared at (1) [-Wunused-variable]
statecu.for:82:22:

   82 |       REAL tlat,tttwws,tttwrs,rept4,rept5
      |                      1
smalers commented 3 years ago

The updated makefile is attached here. Rename to remove the .txt extension that was necessary to upload. Similar for the other files. My write statements are still in the files but are easy to find given the messages that print. The code could really be improved with some checks to prevent division by zero, and the log file issues are still a mystery but I don't have time to figure out right now. I wonder if using a large unit number like 999 is a problem. The unit numbers in write statements really should be a variable so that the unit number is set once. StateMod uses nlog=99. It would not take much effort to change that. To be clear, StateCU appears to run through but is crashing writing the output. This needs to be fixed and I need to be able to read full output from the binary files. I will try that in the next couple of days.

makefile.txt proj.for.txt statecu.for.txt table.for.txt wsupsum.for.txt

smalers commented 3 years ago

Erin provided another code update today: StateCU_Fortran_8-14-2021.zip. I'll do my normal comparison using kdiff3 and see if there are any further issues to consider.

First, I committed the initial work that Erin provided that is described above. This allows for an incremental commit and to make it easier to see what has changed in the latest iteration. I would normally set the version in gcommon.inc to something like 14.0.0.dev1 to indicate a development version for this commit leading up to the full 14.0.0 release. However, the version is still a floating point number and therefore only 2 parts are allowed. Therefore, I set the version to 13.12 and added a comment indicating that it is a transitional version not intended for release.

The following are comments on Erin's most recent changes. Outstanding issues have been added to the repository issues.

I did have to convert the files to linux line endings for comparison using the dos2unix command line tool in the MinGW shell. I'm not sure why this was not an issue in the previous iteration but it is a common thing to deal with. Working files created with MinGW shell programs typically use Linux file endings. The repository always uses Linux file endings for text files. Upon review, some of my working files had Windows line endings so I converted all to linux endings for comparison.

File Comment
calpcrop.for I added calcrop name on the first line, consistent with other files. Each file should have a one sentence summary at the top like StateMod and other program code but I'm not going to do that.
fall.for Copy as is.
gcommon.inc I changed the following for the version version date: PARAMETER (RDATE = '06/22/09 11:11AM') changed to PARAMETER (RDATE = '08/14/21'). The time is not needed and the date did not make sense. I'm not a fan of Americanized dates because of ambiguity. I prefer ISO 8601 standard dates. However, I'm leaving the traditional date format so as to not rock the boat here.
mainxc.for Copy as is.
proj.for Copy as is.
proto.for Copy as is.
statecu.for Copy as is.
summary.for Copy as is.
table.for Added GPL notice at top.
wsupsum.for I changed unit number 5 back to 599 and unit number 6 back to 699. 5 is the default unit number for stdin and 6 for stdout and should not be repurposed.

Next I'll run the cm2015 dataset to make sure it runs through and then will move on to integrating the executable with full testing framework.

smalers commented 3 years ago

The model ran OK. I am going to close this issue. Other issues can be opened if necessary for more specific issues.