Silverfrost Forums

Welcome to our forums

Minor compiler bug - Warning 298

3 Feb 2017 9:38 #18825

I get the following error during the compile (/CHECKMATE).

Compiling file: main.f95
F:\Temp\main.F95(2) : warning 298 - Variable J has been used without being given an initial value
Compilation completed with no errors.

The code involves a data initialization of a two-dimensional array. I need to to do it this way to keep all the related data together for easier editing later. I do this in a BLOCK DATA, but this will occur in a routine/module. The simplified code is block data cb integer I,J integer zones_83(2),spzon_83_projection(2),spzon_83(2),spcc_83(2,2) common/defg/zones_83,spzon_83_projection,spzon_83,spcc_83 data (zones_83(i),spzon_83_projection(i),spzon_83(i),(spcc_83(i,j),j=1,2),i=1,2)/10*0/

In actuality, it's all working as one might expect, just the warning that's annoying.

3 Feb 2017 10:17 #18826

Bill,

I remember something like this before. If I remember correctly it's that the i and j in the DATA statement are local to the statement, and so aren't I or J - nothing to do with case. A real authority like mecej4 will probably have the definition.

Do you use J later on?

Eddie

4 Feb 2017 1:01 #18827

It definitely is an annoying false warning. I have had other similar cases. I tried 3 alternatives, which confirm this as a false warning. Is it valid to define local variables in a block data sub program ? block data cb0 ! original integer I,J integer zones_83(2),spzon_83_projection(2),spzon_83(2),spcc_83(2,2) common/defg/zones_83,spzon_83_projection,spzon_83,spcc_83 data (zones_83(i),spzon_83_projection(i),spzon_83(i),(spcc_83(i,j),j=1,2),i=1,2) / 10*0 / end

   block data cb1   ! swap i,j > j,i
     integer I,J 
     integer zones_83(2),spzon_83_projection(2),spzon_83(2),spcc_83(2,2) 
     common/defg/zones_83,spzon_83_projection,spzon_83,spcc_83 
     data (zones_83(i),spzon_83_projection(i),spzon_83(i),(spcc_83(j,i),j=1,2),i=1,2) / 10*0 / 
   end

   block data cb2   ! don't use J !!
!     integer I,J 
     integer zones_83(2),spzon_83_projection(2),spzon_83(2),spcc_83(2,2) 
     common/defg/zones_83,spzon_83_projection,spzon_83,spcc_83 
     data zones_83,spzon_83_projection,spzon_83,spcc_83 / 10*0 / 
   end

This statement will never be executed is another common false warning, which has also been reported lately. Hopefully it is not a major problem to eradicate.

John

4 Feb 2017 4:30 #18828

Yes, apparently that is allowed in a BLOCK DATA if used like this. Just ry to set a value, and it reports that you can't do that unless it is in COMMON

Just an FYI, really. I can ignore it (or /IGNORE 298).

4 Feb 2017 9:47 #18829

I will make a note that this needs fixing.

20 Feb 2017 3:02 #18860

This has now been fixed for the next release (after 8.10).

Please login to reply.