public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Toon Moene <toon@moene.org>
To: Jakub Jelinek <jakub@redhat.com>, fortran@gcc.gnu.org
Subject: A gfortran silent "wrong code" bug in the transition from 4.9.0 -> 4.9.1, using OpenMP.
Date: Thu, 30 Jun 2016 17:34:00 -0000	[thread overview]
Message-ID: <45f3c5ba-af62-a02f-bd37-633ebb7f7f56@moene.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 940 bytes --]

Jakub,

A colleague of mine at Meteo France, Toulouse, managed to reduce a 
problem he had with our common weather forecasting code when using 
OpenMP down to the attached code and the transition from 4.9.0 -> 4.9.1.

In 4.9.1 OpenMP 4.0 was introduced. That is of course a big hammer to 
start looking for the culprit, but you are the best person to go to on 
this code.

The attached code produces with 4.9.1, 5.4 and 6.1:

    99999.0000       99999.0000       99999.0000       99999.0000

whereas it should produce four zeros.

Compile with gfortran -fopenmp elkhatib.f90.

Thanks for any help - kind regards,

PS: I will make a Bugzilla report if it doesn't ring a bell immediately.

-- 
Toon Moene - e-mail: toon@moene.org - phone: +31 346 214290
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
At home: http://moene.org/~toon/; weather: http://moene.org/~hirlam/
Progress of GNU Fortran: http://gcc.gnu.org/wiki/GFortran#news

[-- Attachment #2: elkhatib.f90 --]
[-- Type: text/x-fortran, Size: 1178 bytes --]

MODULE MYFIELDS_MOD

! The definition of a derived type containing an allocatable array

IMPLICIT NONE
SAVE

TYPE :: MYFIELDS
  REAL, ALLOCATABLE :: GMVT1S(:)
END TYPE MYFIELDS

END MODULE MYFIELDS_MOD

PROGRAM GP_MODEL

! A program to allocate then use a structure containing a allocatable array

USE MYFIELDS_MOD , ONLY : MYFIELDS

IMPLICIT NONE

TYPE(MYFIELDS) :: YRFIELDS

ALLOCATE(YRFIELDS%GMVT1S(4))

YRFIELDS%GMVT1S=99999.

CALL GP_TEST(YRFIELDS)

END PROGRAM GP_MODEL

SUBROUTINE GP_TEST(YDFIELDS)

! A subroutine to initialize the component of a structure, which is an
! allocatable array, via an association

! DOES NOT WORK SINCE GFORTRAN 4.9.2 (4.9.1 ?), UNLESS ONE OF THE FOLLOWING CONDITIONS IS RESPECTED :
! - Open-mp is disabled
! - the attribute is POINTER instead of ALLOCATABLE
! - the association is not used
! COULD BE AN ISSUE WITH Version 4.0 of the OpenMP specification

USE MYFIELDS_MOD , ONLY : MYFIELDS

IMPLICIT NONE

TYPE(MYFIELDS), INTENT(INOUT)      :: YDFIELDS

INTEGER :: J

ASSOCIATE(YDGMV=>YDFIELDS)

!$OMP PARALLEL DO
DO J=1,4
  YDGMV%GMVT1S(J)=0.
ENDDO
!$OMP END PARALLEL DO

print*,YDFIELDS%GMVT1S(:)

END ASSOCIATE

END SUBROUTINE GP_TEST

             reply	other threads:[~2016-06-30 17:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-30 17:34 Toon Moene [this message]
2016-06-30 18:44 ` Jakub Jelinek
2016-06-30 20:00   ` Toon Moene
2016-07-01 15:17     ` [committed] Re: A gfortran silent "wrong code" bug in the transition from 4.9.0 -> 4.9.1, using OpenMP. (PR fortran/71717) Jakub Jelinek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=45f3c5ba-af62-a02f-bd37-633ebb7f7f56@moene.org \
    --to=toon@moene.org \
    --cc=fortran@gcc.gnu.org \
    --cc=jakub@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).