Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

-check uninit

Gabriele_B_
Beginner
1,598 Views

Hi,

I'm trying to use -check uninit to find uninitialized variables in my code:

+ mpif90 -I/usr/local/other/SLES11.3/ncl/gcc-4.3.4/6.3.0-static/include -I/usr/local/other/SLES11.3/silo/4.10.2/include -extend-source -r8 -c -O2 -g -traceback -check uninit -warn noalign 3dpic_full_mpi.f
+ mpif90 -o 3dpic_full_mpi.exe 3dpic_full_mpi.o -L/usr/local/other/SLES11.3/ncl/gcc-4.3.4/6.3.0-static/lib -L/usr/local/other/SLES11.3/silo/4.10.2/lib -lsiloh5 -lhdf5_hl -lhdf5 -lsz -lz -lm -lrt -ldl -lstdc++ -O2 -g -traceback -check uninit -mcmodel medium

But it doesn't work.

Can you tell me what should I do?

Thanks

GB

0 Kudos
1 Solution
Lorri_M_Intel
Employee
1,598 Views

Please note, the command line switches -check uninit and -init snan change *runtime* behavior, they do not trigger any sort of message at compile time.

           Is that, perhaps, the confusion?

                          --Lorri

View solution in original post

0 Kudos
13 Replies
TimP
Honored Contributor III
1,598 Views
Is your mpif90 built against ifort? For example show us mpif90 -V and mpif90 -V -fc =ifort Doesn't work is far too vague for us to guess your meaning. I filed an ips issue several years ago on check uninit which was never answered so it may not be fully supported.
0 Kudos
Steven_L_Intel1
Employee
1,598 Views

-check uninit has some significant restrictions. It works on local routine scalar variables only You might find -init=snan (requires version 16) to be useful.

0 Kudos
Gabriele_B_
Beginner
1,598 Views

Hi Steve,

My routines are local: they are called in the main. I'll try the version 16.

Tim, here they are, for the second I get an error:

Intel(R) Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 14.0.2.144 Build 20140120 Copyright (C) 1985-2014 Intel Corporation.  All rights reserved.

GNU ld (GNU Binutils; SUSE Linux Enterprise 11) 2.23.1
/usr/local/intel/Composer/composer_xe_2013_sp1.2.144/compiler/lib/intel64/for_main.o: In function `main':
/export/users/nbtester/efi2linux_nightly/branch-14_0/20140121_010000/libdev/frtl/src/libfor/for_main.c:(.text+0x42): undefined reference to `MAIN__'

GB

 

0 Kudos
TimP
Honored Contributor III
1,598 Views

If the compile step failed to put the main program in .o there should be an earlier error message.  -check uninit should have no effect in the link step which produced the quoted message.  Adding -# option would provide more detail in link step.  You might try comparing result of nm *.o with and without -check to see if that option is responsible for missing MAIN

0 Kudos
Gabriele_B_
Beginner
1,598 Views

Hi Tim,

probably you have misunderstood me.

I obtain the message above once I type the command you told me to try: mpif90 -V -fc =ifort

Thanks

GB

0 Kudos
Gabriele_B_
Beginner
1,598 Views

Steve Lionel (Intel) wrote:

-check uninit has some significant restrictions. It works on local routine scalar variables only You might find -init=snan (requires version 16) to be useful.

Hi Steve,

I explicitly inserted an uninitialized variable in the main (as write(*,*) gurdulu, where gurdulu is the not init. variable, never defined before)

I did the commands I report below and nothing was displayed.

cluster05 121% mpif90 -I/usr/local/other/SLES11.3/ncl/gcc-4.3.4/6.3.0-static/include -I/usr/local/other/SLES11.3/silo/4.10.2/include -extend-source -r8 -c -O2 -g -traceback -init=snan -warn noalign 3dpic_full_mpi.f
cluster05 122% mpif90 -o 3dpic_full_mpi.exe 3dpic_full_mpi.o -L/usr/local/other/SLES11.3/ncl/gcc-4.3.4/6.3.0-static/lib -L/usr/local/other/SLES11.3/silo/4.10.2/lib -lsiloh5 -lhdf5_hl -lhdf5 -lsz -lz -lm -lrt -ldl -lstdc++ -O2 -g -init=snan -traceback -mcmodel medium

I'm using these modules (I work on a cluster):

cluster05 113% module load comp/intel-16.0.2.181
cluster05 114% module load mpi/sgi-mpt-2.13

Thanks

GB

 

0 Kudos
Lorri_M_Intel
Employee
1,599 Views

Please note, the command line switches -check uninit and -init snan change *runtime* behavior, they do not trigger any sort of message at compile time.

           Is that, perhaps, the confusion?

                          --Lorri

0 Kudos
Gabriele_B_
Beginner
1,598 Views

Lorri Menard (Intel) wrote:

Please note, the command line switches -check uninit and -init snan change *runtime* behavior, they do not trigger any sort of message at compile time.

           Is that, perhaps, the confusion?

                          --Lorri

Yes, I didn't get that. Thanks!

Is there a way to receive a message when a variable is not defined? I'm losing a lot of time for typos in the variable names!

When I was using gcc for compiling C++ I wasn't able to compile if there was an undefined variable!

GB

0 Kudos
mecej4
Honored Contributor III
1,598 Views

Add IMPLICIT NONE to the beginning of the declarations section of every Fortran subprogram. Be prepared to receive a large number of "undeclared variable XYZ" warnings after you have made this change.

An alternative is to ask the compiler to give you a cross-reference listing of variables. You can then look at this listing to spot misspelled variable names.

0 Kudos
Gabriele_B_
Beginner
1,598 Views

mecej4 wrote:

Add IMPLICIT NONE to the beginning of the declarations section of every Fortran subprogram. Be prepared to receive a large number of "undeclared variable XYZ" warnings after you have made this change.

An alternative is to ask the compiler to give you a cross-reference listing of variables. You can then look at this listing to spot misspelled variable names.

Thanks! but this last one would work only for misspelled names, right?

GB

0 Kudos
mecej4
Honored Contributor III
1,598 Views

GB wrote:

Thanks! but this last one would work only for misspelled names, right?

Yes. You can catch such errors using /warn:unused, and some of the others by using the various sub-options of the /warn compiler option.

There exist third party tools for generating complete variable declarations from Fortran source containing the ubiquitous

IMPLICIT REAL*8 (A-H,O-Z)

that one finds in old F77 code.

 

 

 

 

 

0 Kudos
Gabriele_B_
Beginner
1,598 Views

mecej4 wrote:

Add IMPLICIT NONE to the beginning of the declarations section of every Fortran subprogram. Be prepared to receive a large number of "undeclared variable XYZ" warnings after you have made this change.

An alternative is to ask the compiler to give you a cross-reference listing of variables. You can then look at this listing to spot misspelled variable names.

Hi, implicit none would work very well for undeclared variables. Is there something for UNDEFINED variables?

Thanks

GB

0 Kudos
mecej4
Honored Contributor III
1,598 Views

Catching undefined variables is quite difficult. Some can be caught at compile time, but mostly they occur at run time. The hardest to catch are those related to components of user-defined types, arguments to subroutines, errors and misconceptions about what INTENT(IN), INTENT(OUT) imply.

Intel Fortran can, with the appropriate options, help catch some, but its emphasis is on producing fast code. There are other compilers that are more helpful in debugging code containing undefined variables.

0 Kudos
Reply