Opened 6 years ago
Closed 6 years ago
#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)
Changeset | Author | Time | ChangeLog |
---|---|---|---|
10521 | smasson | 2019-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 6 years ago by rblod
- Description modified (diff)
comment:2 Changed 6 years 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 6 years 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?
comment:4 Changed 6 years ago by nicolasmartin
- Description modified (diff)
comment:5 Changed 6 years 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
comment:6 Changed 6 years 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 6 years ago by smasson
In 10521:
comment:8 Changed 6 years ago by smasson
- Resolution set to fixed
- Status changed from new to closed
Replying to rblod: