Description: For this test case the gfortran compiler is demanding that a threadprivate variable declared and initialized in a main program must have the SAVE attribute. However, the variable already has a default SAVE attribute by virtue of its declaration & initialization in the main program.
The error message is incorrect, since SAVE is on by F95 default in this test case. The following statement comes from p. 86 of the OpenMP API Version 2.5 May 2005 in the last bullet found in lines 27-28: " * A variable that appears in a threadprivate directive and is not declared in the scope of a module must have the SAVE attribute" However, the FORTRAN95 HANDBOOK states on p. 138: Paragraph 3: "Any object that is data initialized (in a DATA statement or a type declaration statement) has the SAVE attribute by default." Rules & Restrictions: 2. If SAVE appears in a main program as an attribute or a statement, it has no effect. > gfortran -v Using built-in specs. Target: x86_64-suse-linux Configured with: ../xt-gcc-4.2.0/configure --prefix=/opt/gcc/4.2.0/snos --disable-nls --libdir=/opt/gcc/4.2.0/snos/lib --enable-languages=c,c++,fortran --with-gxx-include-dir=/opt/gcc/4.2.0/snos/include/g++ --with-slibdir=/opt/gcc/4.2.0/snos/lib --with-system-zlib --enable-shared --enable-__cxa_atexit x86_64-suse-linux Thread model: posix gcc version 4.2.0 20070514 (rpm:4) > cat bug2827.f90 ! Derived from OpenMP test omp1/F2_6_2_8_5i.f90 use omp_lib implicit none integer, parameter :: NT = 4 integer :: a = 1 !$omp threadprivate(a) !$ call omp_set_num_threads(NT) !$omp parallel print *, omp_get_thread_num(), a !$omp end parallel END > ftn -O3 -fopenmp -c bug2827.f90 /opt/xt-pe/2.1/bin/snos64/ftn: INFO: linux target is being used bug2827.f90:5.18: integer :: a = 1 1 Error: Threadprivate at (1) isn't SAVEd ------ Note: ftn is an alias for: /opt/gcc/4.2.0/bin/../snos/bin/gfortran -static -v -I/opt/xt-mpt/2.1/mpich2-64/GP/include -I/opt/xt-mpt/2.1/mpich2-64/GP/include -L/opt/xt-mpt/2.1/mpich2-64/GP/lib -I/opt/acml/3.6.1/gnu64/include -I/opt/xt-libsci/10.1.0/gnu/snos64/include -I/opt/xt-libsci/10.1.0/gnu/snos64/include/superlu -I/opt/xt-mpt/2.1/sma/P/include -L/opt/acml/3.6.1/gnu64/lib -L/opt/xt-libsci/10.1.0/gnu/snos64/lib -L/opt/xt-mpt/2.1/sma/P/lib -lmpichf90 -lsci -lacml -lsma -lmpichf90 -lmpich -lrt -D__CRAYXT_COMPUTE_LINUX_TARGET -D__TARGET_LINUX__ -fno-second-underscore -I/notbackedup/users/rsrel/rs64.DEV.070604.Mon/install/include -I/opt/xt-catamount/2.1/catamount/linux/include -I/opt/xt-service/2.1/include -L/notbackedup/users/rsrel/rs64.DEV.070604.Mon/install/lib/snos64 -L/opt/xt-pe/2.1/cnos/linux/64/lib -L/opt/xt-mpt/2.1/lib/snos64 -L/opt/xt-service/2.1/lib/snos64 -Wl,--start -lpct -lalpslli -lalpsutil -lportals -lpthread -Wl,--end -lgfortranbegin -lgfortran -lm -- Summary: GFORTRAN MSG "ERROR: THREADPRIVATE AT (1) ISN'T SAVED" INCORRECT IN MAIN PGM Product: gcc Version: 4.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: longb at cray dot com GCC build triplet: x86_64-suse-linux GCC host triplet: x86_64-suse-linux GCC target triplet: x86_64-suse-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32359