#2201 closed Defect (fixed)

Compilation failure (lib_mpp, iom etc)

Reported by: rblod Owned by: systeam
Priority: normal Milestone: Unscheduled
Component: LBC Version: trunk
Severity: major Keywords: compilation
Cc:

Description (last modified by nicolasmartin)

Context

Compilation fails with gfortran 4.8 and key_mpp_mpi activated with message:

CHARACTER(len=*), DIMENSION(nbdelay), PUBLIC ::   c_delaylist = (/ 'cflice', 'fwb'/)
                                                                           1
Error: Different CHARACTER lengths (6/3) in array constructor at (1) 

Same error in iom_nf90.f90 and may other places with same initialisation using character array constructor

Analysis

my guess, It's not allowed by fortran standard (just an intel extension)

Recommendation

Not sure, this syntax makes it but is f2003:

CHARACTER(len=*), DIMENSION(nbdelay), PUBLIC ::   c_delaylist = (/ character(32):: 'cflice', 'fwb'/)

Commit History (1)

ChangesetAuthorTimeChangeLog
10521smasson2019-01-16T08:58:14+01:00

trunk: bugfix for compilation with (at least) gcc, see #2201

Change History (8)

comment:1 in reply to: ↑ description Changed 15 months ago by rblod

  • Description modified (diff)

Replying to rblod:

Context

Compilation fails with gfortran 4.8 and key_mpp_mpi activated with message:
CHARACTER(len=*), DIMENSION(nbdelay), PUBLIC :: c_delaylist = (/ 'cflice', 'fwb'/)

1

Error: Different CHARACTER lengths (6/3) in array constructor at (1)

Same error in iom_nf90.f90 and may other places with same initialisation using character array constructor

Analysis

my guess, It's not allowed by fortran standard (just an intel extension)

Recommendation

Not sure, this syntax makes it but is f2003

CHARACTER(len=32), DIMENSION(nbdelay), PUBLIC
c_delaylist = (/character(32):: 'cflice', 'fwb' /)

comment:2 Changed 15 months ago by rblod

Forgot to say that obviously a quick fix is just to add spaces in order to have the same length for all the text chains in the same array line 167 for lib_mpp and 571 for iom.F90

comment:3 Changed 15 months ago by smasson

The original line in the code in the F90 file is :

CHARACTER(len=32), DIMENSION(nbdelay), PUBLIC ::   c_delaylist = (/ 'cflice', 'fwb' /)

How did you get this line in the f90 file? Why did the cpp changed this line?
do you use AGRIF?

Last edited 15 months ago by nemo (previous) (diff)

comment:4 Changed 15 months ago by nicolasmartin

  • Description modified (diff)

comment:5 Changed 15 months ago by rblod

Sorry , wrong copypaste. I have the same original and preprocessed ones (same as yours)

CHARACTER(len=32), DIMENSION(nbdelay), PUBLIC ::   c_delaylist = (/ 'cflice', 'fwb' /)

I'm saying you're not allowed to initialize (using an array constructor) at declaration an array of characters with characters of different length. So

CHARACTER(len=32), DIMENSION(nbdelay), PUBLIC ::   c_delaylist = (/ 'cflice', 'fwb   ' /) 

works, as well as

CHARACTER(len=32), DIMENSION(nbdelay), PUBLIC ::   c_delaylist = (/ character(32):: 'cflice', 'fwb'/)

the last one being potentially only f2003

Last edited 15 months ago by nemo (previous) (diff)

comment:6 Changed 15 months ago by smasson

Ok I see…
I am afraid the nice solution with the fancy syntaxe may create problems with other compilers…
So I will use the robust solution with the "space tailing" and add a comment to explain the chosen syntaxe…

comment:7 Changed 15 months ago by smasson

In 10521:

trunk: bugfix for compilation with (at least) gcc, see #2201

comment:8 Changed 15 months ago by smasson

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.