Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error compiling the master branch with GCC-10 #1250

Closed
syalavarthi opened this issue Jul 10, 2020 · 6 comments · Fixed by #1251 or SJSU-CS-systems-group/WRF-SFIRE#1
Closed

Error compiling the master branch with GCC-10 #1250

syalavarthi opened this issue Jul 10, 2020 · 6 comments · Fixed by #1251 or SJSU-CS-systems-group/WRF-SFIRE#1

Comments

@syalavarthi
Copy link
Contributor

syalavarthi commented Jul 10, 2020

WRF master branch build fails due to two issues which are a result of changes in GCC-10

As Mismatches between actual and dummy argument lists in a single file are now rejected with an error, gfortran would require additional flag "-fallow-argument-mismatch" to build the fortran sources,

`gfortran -fopenmp -O0 -ftree-vectorize -funroll-loops -march=armv8-a -w -ffree-form -ffree-line-length-none -fconvert=big-endian -frecord-marker=4 -o wrf_io.o -I/opt/ubuntu/libraries/glibc-2.31/netcdf-fortran/4.5.2-gcc-10.0.1/include -I../ioapi_share -c wrf_io.f
wrf_io.f:1517:36:

1517 | CALL ext_ncd_open_for_read_begin( DatasetName, Comm1, Comm2, SysDepInfo, DataHandle, Status )
| 1
Error: Dummy argument ‘datasetname’ with INTENT(IN) in variable definition context (actual argument to INTENT = OUT/INOUT) at (1)
wrf_io.f:7543:58:

3196 | stat = NF_PUT_ATT_INT (DH%NCID,NF_GLOBAL,Element,NF_INT,Count,Data)
| 2
......
7543 | stat = NF_PUT_ATT_INT(NCID,VarID,'FieldType',NF_INT,1,FieldType)
| 1
`

Changes were made in GCC-10 , in the way BOZ literal constants are handled. This would require "-fallow-invalid-boz" flag to passed to the fortran sources.

`time mpif90 -o module_ra_cam_support.o -c -O0 -ftree-vectorize -funroll-loops -march=armv8-a -w -ffree-form -ffree-line-length-none -fconvert=big-endian -frecord-marker=4 -fallow-argument-mismatch -fopenmp -I../dyn_em -I../dyn_nmm -I/home/syalavarthi/WRF/external/esmf_time_f90 -I/home/syalavarthi/WRF/main -I/home/syalavarthi/WRF/external/io_netcdf -I/home/syalavarthi/WRF/external/io_int -I/home/syalavarthi/WRF/frame -I/home/syalavarthi/WRF/share -I/home/syalavarthi/WRF/phys -I/home/syalavarthi/WRF/wrftladj -I/home/syalavarthi/WRF/chem -I/home/syalavarthi/WRF/inc -I/opt/ubuntu/libraries/glibc-2.31/netcdf-fortran/4.5.2-gcc-10.0.1/include module_ra_cam_support.f90
module_ra_cam_support.f90:9:35:

9 |       integer, parameter:: bigint = O'17777777777'
  |                                   1

Error: BOZ literal constant at (1) is neither a data-stmt-constant nor an actual argument to INT, REAL, DBLE, or CMPLX intrinsic function [see ‘-fno-allow-invalid-boz’]
`

@syalavarthi syalavarthi changed the title Error Compiling compiling the master branch with GCC-10 Error compiling the master branch with GCC-10 Jul 10, 2020
davegill pushed a commit that referenced this issue Oct 23, 2020
TYPE: bug fix

KEYWORDS: gfortran/10

SOURCE: Srikanth Yalavarthi (Marvell Semiconductor)

DESCRIPTION OF CHANGES: 
Problem:
Due to argument inconsistencies, the WRF code will not compile with gfortran/10. 

Here are some examples of incorrect Fortran argument usages:

```
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (rank-1 and scalar)
wrf_io.f:7605:71:

 7605 |                                                    ,i1,i2,j1,j2,k1,k2 )
      |                                                                       1
```
```
Error: Type mismatch in argument ‘field’ at (1); passed INTEGER(4) to REAL(8)
wrf_io.f:7744:49:

 2538 |     stat = NF_GET_ATT_INT (DH%NCID,NF_GLOBAL,Element,Buffer)
      |                                                     2
......
 7744 |     stat = NF_GET_ATT_INT(NCID,VarID,'FieldType',FType)
      |                                                 1
```
```
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (scalar and rank-3)
field_routines.f:158:52:

  110 |     stat = NF_GET_VARA_INT(NCID,VarID,VStart,VCount,Data)
      |                                                    2
......
  158 |     stat = NF_GET_VARA_INT(NCID,VarID,VStart,VCount,Buffer)
      |                                                    1
```
```
Error: Rank mismatch in argument ‘fileindex’ at (1) (scalar and rank-1)
io_grib1.f90:685:27:

  685 |   CALL gr1_fill_eta_levels(fileinfo(DataHandle)%fileindex(:), FileFd(DataHandle), &
      |                           1
```
```
Error: Type mismatch between actual argument at (1) and actual argument at (2) (INTEGER(4)/REAL(4)).
module_internal_header_util.f:1592:39:

 1592 |                            DataHandle, Data, Count, code )
      |                                       1
......
 1654 |                            DataHandle, Data, Count, code )
      |                                       2
```
```
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (rank-1 and scalar)
module_io_int_read.f:129:39:

  129 |     call mpi_file_read_at(ifd, offset, tmp, 1, &
      |                                       1
......
  573 |     call mpi_file_read_at(ifd, offset, tmp, num, &
      |                                       2
```
```
Error: Type mismatch between actual argument at (1) and actual argument at (2) (REAL(8)/COMPLEX(8)).
zmfm1b.f90:74:38:

   72 |       call zmf3kb ( lot, ido, l1, na, c, jump, inc, ch, 1, lot, wa(iw) )
      |                                      2
   73 |     else if ( nbr == 4 ) then
   74 |       call zmf3kb ( lot, ido, l1, na, ch, 1, lot, c, jump, inc, wa(iw) )
      |                                      1
```
The errors in the WRF infrastructure code can be eventually updated. However, the code from the FFTPACK library 
will be left AS-IS. We are going to initially address all of the problems in a temporary fashion.

Temporary solution:
A compiler flag was added for the gfortran compiler to allow mismatched arguments, which enables the WRF system
to build. The new flag is only for versions of gfortran 10 and later. This change was introduced in the configure script,
which modifies all gfortran stanzas.

Permanent fix:
A complete fix requires changes in the Fortran sources for BOZ declarations and to fix mismatches in subroutine 
arguments.

ISSUE: 
Fixes #1250

LIST OF MODIFIED FILES: 
M   Makefile
M   arch/configure.defaults
M   configure

TESTS CONDUCTED: 
1. Successfully built the master branch with GCC-10 on RPi4 Ubuntu-20.04 machine
2. Logic tested, where only GNU 10 and above are impacted.
3. Other compilers are not affected.
4. Jenkins testing is OK.
5. The DA variants have been tested also:  I could build WRF / WRFPLUS / 3DVAR / 4DVAR
```
[00:01] [syalavarthi@sparrow WRF]$./configure wrfda && ./compile all_wrfvar && ls var/build/*.exe
var/build/da_advance_time.exe         var/build/da_tune_obs_hollingsworth1.exe  var/build/gen_be_addmean.exe                var/build/gen_be_diags.exe       var/build/gen_be_hist.exe          var/build/gen_be_stage2_1dvar.exe     var/build/gen_mbe_stage2.exe
var/build/da_bias_airmass.exe         var/build/da_tune_obs_hollingsworth2.exe  var/build/gen_be_cov2d.exe                  var/build/gen_be_diags_read.exe  var/build/gen_be_stage0_gsi.exe    var/build/gen_be_stage2_gsi.exe
var/build/da_bias_scan.exe            var/build/da_update_bc.exe                var/build/gen_be_cov2d3d_contrib.exe        var/build/gen_be_ensmean.exe     var/build/gen_be_stage0_wrf.exe    var/build/gen_be_stage2a.exe
var/build/da_bias_sele.exe            var/build/da_update_bc_ad.exe             var/build/gen_be_cov3d.exe                  var/build/gen_be_ensrf.exe       var/build/gen_be_stage1.exe        var/build/gen_be_stage3.exe
var/build/da_bias_verif.exe           var/build/da_verif_grid.exe               var/build/gen_be_cov3d2d_contrib.exe        var/build/gen_be_ep1.exe         var/build/gen_be_stage1_1dvar.exe  var/build/gen_be_stage4_global.exe
var/build/da_rad_diags.exe            var/build/da_verif_obs.exe                var/build/gen_be_cov3d3d_bin3d_contrib.exe  var/build/gen_be_ep2.exe         var/build/gen_be_stage1_gsi.exe    var/build/gen_be_stage4_regional.exe
var/build/da_tune_obs_desroziers.exe  var/build/da_wrfvar.exe                   var/build/gen_be_cov3d3d_contrib.exe        var/build/gen_be_etkf.exe        var/build/gen_be_stage2.exe        var/build/gen_be_vertloc.exe
[00:10] [syalavarthi@sparrow WRF]$

[06:40] [syalavarthi@sparrow WRFPLUS]$./configure wrfplus && ./compile wrfplus && ls main/*.exe
main/wrfplus.exe

[07:16] [syalavarthi@sparrow WRF]$./configure 4dvar && ./compile all_wrfvar && ls var/build/*.exe
var/build/da_advance_time.exe         var/build/da_tune_obs_hollingsworth1.exe  var/build/gen_be_addmean.exe                var/build/gen_be_diags.exe       var/build/gen_be_hist.exe          var/build/gen_be_stage2_1dvar.exe     var/build/gen_mbe_stage2.exe
var/build/da_bias_airmass.exe         var/build/da_tune_obs_hollingsworth2.exe  var/build/gen_be_cov2d.exe                  var/build/gen_be_diags_read.exe  var/build/gen_be_stage0_gsi.exe    var/build/gen_be_stage2_gsi.exe
var/build/da_bias_scan.exe            var/build/da_update_bc.exe                var/build/gen_be_cov2d3d_contrib.exe        var/build/gen_be_ensmean.exe     var/build/gen_be_stage0_wrf.exe    var/build/gen_be_stage2a.exe
var/build/da_bias_sele.exe            var/build/da_update_bc_ad.exe             var/build/gen_be_cov3d.exe                  var/build/gen_be_ensrf.exe       var/build/gen_be_stage1.exe        var/build/gen_be_stage3.exe
var/build/da_bias_verif.exe           var/build/da_verif_grid.exe               var/build/gen_be_cov3d2d_contrib.exe        var/build/gen_be_ep1.exe         var/build/gen_be_stage1_1dvar.exe  var/build/gen_be_stage4_global.exe
var/build/da_rad_diags.exe            var/build/da_verif_obs.exe                var/build/gen_be_cov3d3d_bin3d_contrib.exe  var/build/gen_be_ep2.exe         var/build/gen_be_stage1_gsi.exe    var/build/gen_be_stage4_regional.exe
var/build/da_tune_obs_desroziers.exe  var/build/da_wrfvar.exe                   var/build/gen_be_cov3d3d_contrib.exe        var/build/gen_be_etkf.exe        var/build/gen_be_stage2.exe        var/build/gen_be_vertloc.exe
```

RELEASE NOTE: Due to subroutine and function argument inconsistencies, the WRF code will not compile with gfortran/10.  The fix introduces a new compiler flag for all gfortran stanzas (`-fallow-argument-mismatch -fallow-invalid-boz`).
@syalavarthi
Copy link
Contributor Author

Fixed with PR #1251
Closing the issue

@anikfal
Copy link

anikfal commented Jan 3, 2021

Still cannot be compiled on Fedora-33 with GCC-10.2.1

Some error messages:

ar: creating ../main/libwrflib.a
gfortran: fatal error: Terminated signal terminated program f951
compilation terminated.
Command exited with non-zero status 1
202.82user 8.74system 3:37.60elapsed 97%CPU (0avgtext+0avgdata 5636076maxresident)k
83224inputs+152outputs (69571major+2608669minor)pagefaults 0swaps
make[2]: [../configure.wrf:354: module_first_rk_step_part1.o] Error 1 (ignored)
gfortran: fatal error: Terminated signal terminated program f951
compilation terminated.
Command exited with non-zero status 1
301.83user 7.35system 5:32.30elapsed 93%CPU (0avgtext+0avgdata 5858636maxresident)k
96120inputs+0outputs (239major+3724989minor)pagefaults 0swaps
make[2]: [../configure.wrf:354: solve_em.o] Error 1 (ignored)
ar: module_first_rk_step_part1.o: No such file or directory

@davegill
Copy link
Contributor

davegill commented Jan 3, 2021

We put in a fix for this problem in the branch release-v4.2.1

If I test the top of the repository with GNU 10.1.0 (what we have access to, it seems to work OK. The original PR verified that WRF, WRFDA, WRFPLUS, and WRF4DVAR all worked.

gfortran --version

GNU Fortran (GCC) 10.1.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
git clone https://github.com/wrf-model/WRF
cd WRF
git checkout release-v4.2.2
./configure -d << EOF
32
1
EOF
./compile em_real -j 4 >& foo ; tail -13 foo

==========================================================================
build started:   Sun Jan  3 09:45:27 MST 2021
build completed: Sun Jan 3 09:49:06 MST 2021
 
--->                  Executables successfully built                  <---
 
-rwxr-xr-x 1 gill p66770001 69866496 Jan  3 09:48 main/ndown.exe
-rwxr-xr-x 1 gill p66770001 69743976 Jan  3 09:49 main/real.exe
-rwxr-xr-x 1 gill p66770001 68938760 Jan  3 09:49 main/tc.exe
-rwxr-xr-x 1 gill p66770001 80215824 Jan  3 09:48 main/wrf.exe
 
==========================================================================
 

Would you verify that you have this hash: 28c18ee

If GNU 10.2 finds other errors (in addition to those found by 10.1), would you be interested in putting together a pull request for this? Is this a bug that we have recently introduced?

@anikfal
Copy link

anikfal commented Jan 7, 2021

Please take a look at the error messages below. The compilation is by WRF_CHEM=0

gfortran: fatal error: Terminated signal terminated program f951
compilation terminated.
Command exited with non-zero status 1
282.79user 16.41system 5:13.06elapsed 95%CPU (0avgtext+0avgdata 6418548maxresident)k
177072inputs+136outputs (527828major+5747772minor)pagefaults 0swaps
make[2]: [../configure.wrf:348: module_first_rk_step_part1.o] Error 1 (ignored)
gfortran: fatal error: Terminated signal terminated program f951
compilation terminated.
Command exited with non-zero status 1
190.04user 6.54system 3:25.15elapsed 95%CPU (0avgtext+0avgdata 6438936maxresident)k
77576inputs+0outputs (148major+3585981minor)pagefaults 0swaps
make[2]: [../configure.wrf:354: solve_em.o] Error 1 (ignored)
ar: module_first_rk_step_part1.o: No such file or directory
make[2]: [Makefile:57: dyn_em] Error 1 (ignored)
1.30user 0.06system 0:19.94elapsed 6%CPU (0avgtext+0avgdata 61784maxresident)k
60832inputs+688outputs (83major+15697minor)pagefaults 0swaps
0.06user 0.01system 0:00.07elapsed 97%CPU (0avgtext+0avgdata 29848maxresident)k
0inputs+8outputs (0major+5875minor)pagefaults 0swaps
/usr/bin/ld: libwrflib.a(module_dm.o): in function feedback_domain_em_part2_': module_dm.f90:(.text+0x1608e1): undefined reference to cd_feedback_mask_'
/usr/bin/ld: module_dm.f90:(.text+0x160b48): undefined reference to cd_feedback_mask_' /usr/bin/ld: module_dm.f90:(.text+0x160df0): undefined reference to cd_feedback_mask_'
/usr/bin/ld: module_dm.f90:(.text+0x161051): undefined reference to cd_feedback_mask_' /usr/bin/ld: module_dm.f90:(.text+0x162607): undefined reference to cd_feedback_mask_'
/usr/bin/ld: libwrflib.a(module_dm.o):module_dm.f90:(.text+0x1651c2): more undefined references to `cd_feedback_mask_' follow

It seems to be different from the bug you introduced recently.

@davegill
Copy link
Contributor

davegill commented Jan 7, 2021

@anikfal
I do not see a convenient way to have you share a file with me Would you send me an email: gill AT ucar DOT edu which has these following outputs?

git branch >& file.git.txt
./clean -a
./configure < EOF >& file.config.txt
32
1
EOF
./compile em_real >& file.compile.txt

@jlbossa
Copy link

jlbossa commented Feb 12, 2021

This error:

gfortran: fatal error: Terminated signal terminated program f951

Seems to be related to OutOfMemory problems during compilation. I am having a similar problem during compilation with the same error, did you solve this?

cheers

breed pushed a commit to SJSU-CS-systems-group/WRF-SFIRE that referenced this issue Feb 19, 2021
…#1251)

TYPE: bug fix

KEYWORDS: gfortran/10

SOURCE: Srikanth Yalavarthi (Marvell Semiconductor)

DESCRIPTION OF CHANGES: 
Problem:
Due to argument inconsistencies, the WRF code will not compile with gfortran/10. 

Here are some examples of incorrect Fortran argument usages:

```
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (rank-1 and scalar)
wrf_io.f:7605:71:

 7605 |                                                    ,i1,i2,j1,j2,k1,k2 )
      |                                                                       1
```
```
Error: Type mismatch in argument ‘field’ at (1); passed INTEGER(4) to REAL(8)
wrf_io.f:7744:49:

 2538 |     stat = NF_GET_ATT_INT (DH%NCID,NF_GLOBAL,Element,Buffer)
      |                                                     2
......
 7744 |     stat = NF_GET_ATT_INT(NCID,VarID,'FieldType',FType)
      |                                                 1
```
```
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (scalar and rank-3)
field_routines.f:158:52:

  110 |     stat = NF_GET_VARA_INT(NCID,VarID,VStart,VCount,Data)
      |                                                    2
......
  158 |     stat = NF_GET_VARA_INT(NCID,VarID,VStart,VCount,Buffer)
      |                                                    1
```
```
Error: Rank mismatch in argument ‘fileindex’ at (1) (scalar and rank-1)
io_grib1.f90:685:27:

  685 |   CALL gr1_fill_eta_levels(fileinfo(DataHandle)%fileindex(:), FileFd(DataHandle), &
      |                           1
```
```
Error: Type mismatch between actual argument at (1) and actual argument at (2) (INTEGER(4)/REAL(4)).
module_internal_header_util.f:1592:39:

 1592 |                            DataHandle, Data, Count, code )
      |                                       1
......
 1654 |                            DataHandle, Data, Count, code )
      |                                       2
```
```
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (rank-1 and scalar)
module_io_int_read.f:129:39:

  129 |     call mpi_file_read_at(ifd, offset, tmp, 1, &
      |                                       1
......
  573 |     call mpi_file_read_at(ifd, offset, tmp, num, &
      |                                       2
```
```
Error: Type mismatch between actual argument at (1) and actual argument at (2) (REAL(8)/COMPLEX(8)).
zmfm1b.f90:74:38:

   72 |       call zmf3kb ( lot, ido, l1, na, c, jump, inc, ch, 1, lot, wa(iw) )
      |                                      2
   73 |     else if ( nbr == 4 ) then
   74 |       call zmf3kb ( lot, ido, l1, na, ch, 1, lot, c, jump, inc, wa(iw) )
      |                                      1
```
The errors in the WRF infrastructure code can be eventually updated. However, the code from the FFTPACK library 
will be left AS-IS. We are going to initially address all of the problems in a temporary fashion.

Temporary solution:
A compiler flag was added for the gfortran compiler to allow mismatched arguments, which enables the WRF system
to build. The new flag is only for versions of gfortran 10 and later. This change was introduced in the configure script,
which modifies all gfortran stanzas.

Permanent fix:
A complete fix requires changes in the Fortran sources for BOZ declarations and to fix mismatches in subroutine 
arguments.

ISSUE: 
Fixes wrf-model#1250

LIST OF MODIFIED FILES: 
M   Makefile
M   arch/configure.defaults
M   configure

TESTS CONDUCTED: 
1. Successfully built the master branch with GCC-10 on RPi4 Ubuntu-20.04 machine
2. Logic tested, where only GNU 10 and above are impacted.
3. Other compilers are not affected.
4. Jenkins testing is OK.
5. The DA variants have been tested also:  I could build WRF / WRFPLUS / 3DVAR / 4DVAR
```
[00:01] [syalavarthi@sparrow WRF]$./configure wrfda && ./compile all_wrfvar && ls var/build/*.exe
var/build/da_advance_time.exe         var/build/da_tune_obs_hollingsworth1.exe  var/build/gen_be_addmean.exe                var/build/gen_be_diags.exe       var/build/gen_be_hist.exe          var/build/gen_be_stage2_1dvar.exe     var/build/gen_mbe_stage2.exe
var/build/da_bias_airmass.exe         var/build/da_tune_obs_hollingsworth2.exe  var/build/gen_be_cov2d.exe                  var/build/gen_be_diags_read.exe  var/build/gen_be_stage0_gsi.exe    var/build/gen_be_stage2_gsi.exe
var/build/da_bias_scan.exe            var/build/da_update_bc.exe                var/build/gen_be_cov2d3d_contrib.exe        var/build/gen_be_ensmean.exe     var/build/gen_be_stage0_wrf.exe    var/build/gen_be_stage2a.exe
var/build/da_bias_sele.exe            var/build/da_update_bc_ad.exe             var/build/gen_be_cov3d.exe                  var/build/gen_be_ensrf.exe       var/build/gen_be_stage1.exe        var/build/gen_be_stage3.exe
var/build/da_bias_verif.exe           var/build/da_verif_grid.exe               var/build/gen_be_cov3d2d_contrib.exe        var/build/gen_be_ep1.exe         var/build/gen_be_stage1_1dvar.exe  var/build/gen_be_stage4_global.exe
var/build/da_rad_diags.exe            var/build/da_verif_obs.exe                var/build/gen_be_cov3d3d_bin3d_contrib.exe  var/build/gen_be_ep2.exe         var/build/gen_be_stage1_gsi.exe    var/build/gen_be_stage4_regional.exe
var/build/da_tune_obs_desroziers.exe  var/build/da_wrfvar.exe                   var/build/gen_be_cov3d3d_contrib.exe        var/build/gen_be_etkf.exe        var/build/gen_be_stage2.exe        var/build/gen_be_vertloc.exe
[00:10] [syalavarthi@sparrow WRF]$

[06:40] [syalavarthi@sparrow WRFPLUS]$./configure wrfplus && ./compile wrfplus && ls main/*.exe
main/wrfplus.exe

[07:16] [syalavarthi@sparrow WRF]$./configure 4dvar && ./compile all_wrfvar && ls var/build/*.exe
var/build/da_advance_time.exe         var/build/da_tune_obs_hollingsworth1.exe  var/build/gen_be_addmean.exe                var/build/gen_be_diags.exe       var/build/gen_be_hist.exe          var/build/gen_be_stage2_1dvar.exe     var/build/gen_mbe_stage2.exe
var/build/da_bias_airmass.exe         var/build/da_tune_obs_hollingsworth2.exe  var/build/gen_be_cov2d.exe                  var/build/gen_be_diags_read.exe  var/build/gen_be_stage0_gsi.exe    var/build/gen_be_stage2_gsi.exe
var/build/da_bias_scan.exe            var/build/da_update_bc.exe                var/build/gen_be_cov2d3d_contrib.exe        var/build/gen_be_ensmean.exe     var/build/gen_be_stage0_wrf.exe    var/build/gen_be_stage2a.exe
var/build/da_bias_sele.exe            var/build/da_update_bc_ad.exe             var/build/gen_be_cov3d.exe                  var/build/gen_be_ensrf.exe       var/build/gen_be_stage1.exe        var/build/gen_be_stage3.exe
var/build/da_bias_verif.exe           var/build/da_verif_grid.exe               var/build/gen_be_cov3d2d_contrib.exe        var/build/gen_be_ep1.exe         var/build/gen_be_stage1_1dvar.exe  var/build/gen_be_stage4_global.exe
var/build/da_rad_diags.exe            var/build/da_verif_obs.exe                var/build/gen_be_cov3d3d_bin3d_contrib.exe  var/build/gen_be_ep2.exe         var/build/gen_be_stage1_gsi.exe    var/build/gen_be_stage4_regional.exe
var/build/da_tune_obs_desroziers.exe  var/build/da_wrfvar.exe                   var/build/gen_be_cov3d3d_contrib.exe        var/build/gen_be_etkf.exe        var/build/gen_be_stage2.exe        var/build/gen_be_vertloc.exe
```

RELEASE NOTE: Due to subroutine and function argument inconsistencies, the WRF code will not compile with gfortran/10.  The fix introduces a new compiler flag for all gfortran stanzas (`-fallow-argument-mismatch -fallow-invalid-boz`).
vlakshmanan-scala pushed a commit to scala-computing/WRF that referenced this issue Apr 4, 2024
…#1251)

TYPE: bug fix

KEYWORDS: gfortran/10

SOURCE: Srikanth Yalavarthi (Marvell Semiconductor)

DESCRIPTION OF CHANGES: 
Problem:
Due to argument inconsistencies, the WRF code will not compile with gfortran/10. 

Here are some examples of incorrect Fortran argument usages:

```
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (rank-1 and scalar)
wrf_io.f:7605:71:

 7605 |                                                    ,i1,i2,j1,j2,k1,k2 )
      |                                                                       1
```
```
Error: Type mismatch in argument ‘field’ at (1); passed INTEGER(4) to REAL(8)
wrf_io.f:7744:49:

 2538 |     stat = NF_GET_ATT_INT (DH%NCID,NF_GLOBAL,Element,Buffer)
      |                                                     2
......
 7744 |     stat = NF_GET_ATT_INT(NCID,VarID,'FieldType',FType)
      |                                                 1
```
```
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (scalar and rank-3)
field_routines.f:158:52:

  110 |     stat = NF_GET_VARA_INT(NCID,VarID,VStart,VCount,Data)
      |                                                    2
......
  158 |     stat = NF_GET_VARA_INT(NCID,VarID,VStart,VCount,Buffer)
      |                                                    1
```
```
Error: Rank mismatch in argument ‘fileindex’ at (1) (scalar and rank-1)
io_grib1.f90:685:27:

  685 |   CALL gr1_fill_eta_levels(fileinfo(DataHandle)%fileindex(:), FileFd(DataHandle), &
      |                           1
```
```
Error: Type mismatch between actual argument at (1) and actual argument at (2) (INTEGER(4)/REAL(4)).
module_internal_header_util.f:1592:39:

 1592 |                            DataHandle, Data, Count, code )
      |                                       1
......
 1654 |                            DataHandle, Data, Count, code )
      |                                       2
```
```
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (rank-1 and scalar)
module_io_int_read.f:129:39:

  129 |     call mpi_file_read_at(ifd, offset, tmp, 1, &
      |                                       1
......
  573 |     call mpi_file_read_at(ifd, offset, tmp, num, &
      |                                       2
```
```
Error: Type mismatch between actual argument at (1) and actual argument at (2) (REAL(8)/COMPLEX(8)).
zmfm1b.f90:74:38:

   72 |       call zmf3kb ( lot, ido, l1, na, c, jump, inc, ch, 1, lot, wa(iw) )
      |                                      2
   73 |     else if ( nbr == 4 ) then
   74 |       call zmf3kb ( lot, ido, l1, na, ch, 1, lot, c, jump, inc, wa(iw) )
      |                                      1
```
The errors in the WRF infrastructure code can be eventually updated. However, the code from the FFTPACK library 
will be left AS-IS. We are going to initially address all of the problems in a temporary fashion.

Temporary solution:
A compiler flag was added for the gfortran compiler to allow mismatched arguments, which enables the WRF system
to build. The new flag is only for versions of gfortran 10 and later. This change was introduced in the configure script,
which modifies all gfortran stanzas.

Permanent fix:
A complete fix requires changes in the Fortran sources for BOZ declarations and to fix mismatches in subroutine 
arguments.

ISSUE: 
Fixes wrf-model#1250

LIST OF MODIFIED FILES: 
M   Makefile
M   arch/configure.defaults
M   configure

TESTS CONDUCTED: 
1. Successfully built the master branch with GCC-10 on RPi4 Ubuntu-20.04 machine
2. Logic tested, where only GNU 10 and above are impacted.
3. Other compilers are not affected.
4. Jenkins testing is OK.
5. The DA variants have been tested also:  I could build WRF / WRFPLUS / 3DVAR / 4DVAR
```
[00:01] [syalavarthi@sparrow WRF]$./configure wrfda && ./compile all_wrfvar && ls var/build/*.exe
var/build/da_advance_time.exe         var/build/da_tune_obs_hollingsworth1.exe  var/build/gen_be_addmean.exe                var/build/gen_be_diags.exe       var/build/gen_be_hist.exe          var/build/gen_be_stage2_1dvar.exe     var/build/gen_mbe_stage2.exe
var/build/da_bias_airmass.exe         var/build/da_tune_obs_hollingsworth2.exe  var/build/gen_be_cov2d.exe                  var/build/gen_be_diags_read.exe  var/build/gen_be_stage0_gsi.exe    var/build/gen_be_stage2_gsi.exe
var/build/da_bias_scan.exe            var/build/da_update_bc.exe                var/build/gen_be_cov2d3d_contrib.exe        var/build/gen_be_ensmean.exe     var/build/gen_be_stage0_wrf.exe    var/build/gen_be_stage2a.exe
var/build/da_bias_sele.exe            var/build/da_update_bc_ad.exe             var/build/gen_be_cov3d.exe                  var/build/gen_be_ensrf.exe       var/build/gen_be_stage1.exe        var/build/gen_be_stage3.exe
var/build/da_bias_verif.exe           var/build/da_verif_grid.exe               var/build/gen_be_cov3d2d_contrib.exe        var/build/gen_be_ep1.exe         var/build/gen_be_stage1_1dvar.exe  var/build/gen_be_stage4_global.exe
var/build/da_rad_diags.exe            var/build/da_verif_obs.exe                var/build/gen_be_cov3d3d_bin3d_contrib.exe  var/build/gen_be_ep2.exe         var/build/gen_be_stage1_gsi.exe    var/build/gen_be_stage4_regional.exe
var/build/da_tune_obs_desroziers.exe  var/build/da_wrfvar.exe                   var/build/gen_be_cov3d3d_contrib.exe        var/build/gen_be_etkf.exe        var/build/gen_be_stage2.exe        var/build/gen_be_vertloc.exe
[00:10] [syalavarthi@sparrow WRF]$

[06:40] [syalavarthi@sparrow WRFPLUS]$./configure wrfplus && ./compile wrfplus && ls main/*.exe
main/wrfplus.exe

[07:16] [syalavarthi@sparrow WRF]$./configure 4dvar && ./compile all_wrfvar && ls var/build/*.exe
var/build/da_advance_time.exe         var/build/da_tune_obs_hollingsworth1.exe  var/build/gen_be_addmean.exe                var/build/gen_be_diags.exe       var/build/gen_be_hist.exe          var/build/gen_be_stage2_1dvar.exe     var/build/gen_mbe_stage2.exe
var/build/da_bias_airmass.exe         var/build/da_tune_obs_hollingsworth2.exe  var/build/gen_be_cov2d.exe                  var/build/gen_be_diags_read.exe  var/build/gen_be_stage0_gsi.exe    var/build/gen_be_stage2_gsi.exe
var/build/da_bias_scan.exe            var/build/da_update_bc.exe                var/build/gen_be_cov2d3d_contrib.exe        var/build/gen_be_ensmean.exe     var/build/gen_be_stage0_wrf.exe    var/build/gen_be_stage2a.exe
var/build/da_bias_sele.exe            var/build/da_update_bc_ad.exe             var/build/gen_be_cov3d.exe                  var/build/gen_be_ensrf.exe       var/build/gen_be_stage1.exe        var/build/gen_be_stage3.exe
var/build/da_bias_verif.exe           var/build/da_verif_grid.exe               var/build/gen_be_cov3d2d_contrib.exe        var/build/gen_be_ep1.exe         var/build/gen_be_stage1_1dvar.exe  var/build/gen_be_stage4_global.exe
var/build/da_rad_diags.exe            var/build/da_verif_obs.exe                var/build/gen_be_cov3d3d_bin3d_contrib.exe  var/build/gen_be_ep2.exe         var/build/gen_be_stage1_gsi.exe    var/build/gen_be_stage4_regional.exe
var/build/da_tune_obs_desroziers.exe  var/build/da_wrfvar.exe                   var/build/gen_be_cov3d3d_contrib.exe        var/build/gen_be_etkf.exe        var/build/gen_be_stage2.exe        var/build/gen_be_vertloc.exe
```

RELEASE NOTE: Due to subroutine and function argument inconsistencies, the WRF code will not compile with gfortran/10.  The fix introduces a new compiler flag for all gfortran stanzas (`-fallow-argument-mismatch -fallow-invalid-boz`).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants