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

Temporary fix for gfortran/10 compiler complaints #1251

Merged
merged 10 commits into from
Oct 23, 2020

Conversation

syalavarthi
Copy link
Contributor

@syalavarthi syalavarthi commented Jul 10, 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 syalavarthi requested a review from a team as a code owner July 10, 2020 17:02
@davegill davegill changed the base branch from master to release-v4.2.1 July 10, 2020 19:22
configure Outdated Show resolved Hide resolved
changed the version check using a test program
@syalavarthi syalavarthi removed the request for review from a team July 11, 2020 17:00
@davegill davegill changed the base branch from release-v4.2.1 to release-v4.2.2 July 23, 2020 23:06
@davegill
Copy link
Contributor

Jenkins status is all PASS

Please find result of the WRF regression test cases in the attachment. This build is for Commit ID: 4986c7a81e028fed03f3a115a578e82e48b2ee72, requested by: syalavarthi for PR: https://github.com/wrf-model/WRF/pull/1251. For any query please send e-mail to David Gill.

    Test Type              | Expected  | Received |  Failed
    = = = = = = = = = = = = = = = = = = = = = = = =  = = = =
    Number of Tests        : 19           18
    Number of Builds       : 48           46
    Number of Simulations  : 166           164        0
    Number of Comparisons  : 105           104        0

    Failed Simulations are: 
    None
    Which comparisons are not bit-for-bit: 
    None

configure Outdated Show resolved Hide resolved
@yriveiro
Copy link
Contributor

yriveiro commented Jul 31, 2020

BTW: this bug is affecting also the compilation of WRFDA, the FCBASEOPTS_NO_G variable seems to not be used in the setup of the makefile.

all_wrfvar : 
	$(MAKE) MODULE_DIRS="$(DA_WRFVAR_MODULES)" ext
	$(MAKE) MODULE_DIRS="$(DA_WRFVAR_MODULES)" toolsdir
	if [ $(CRTM) -ne 0 ] ; then \
	  (cd var/external/crtm_2.3.0; $(MAKE) $(J)) ; \
	fi
	if [ $(BUFR) ] ; then \
	  (cd var/external/bufr;  \
	  $(MAKE) $(J) FC="$(SFC)" CC="$(SCC)" CPP="$(CPP)" CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" FFLAGS="$(FCOPTIM) $(FORMAT_FIXED)" RANLIB="$(RANLIB)" AR="$(AR)" ARFLAGS="$(ARFLAGS)" ) ; \
	fi

@davegill
Copy link
Contributor

@liujake @jjguerrette @yriveiro
Folks,
This PR impacts the builds with GCC 10. We can now fix the WRF-type builds. We need DA involved.

      - moved GFORTRAN_VERSION_CHECK program generation inside conditional
      - remove the temporary files after check
@syalavarthi
Copy link
Contributor Author

@davegill
Made some minor changes. moved the fortran program generation inside the conditional and added steps to remove temporary files.

Build completed successfully.

==========================================================================
build started: Fri Jul 31 08:11:50 IST 2020
build completed: Fri Jul 31 08:15:32 IST 2020

---> Executables successfully built <---

-rwxrwxr-x 1 syalavarthi syalavarthi 36969912 Jul 31 08:15 main/ndown.exe
-rwxrwxr-x 1 syalavarthi syalavarthi 37032016 Jul 31 08:15 main/real.exe
-rwxrwxr-x 1 syalavarthi syalavarthi 36507072 Jul 31 08:15 main/tc.exe
-rwxrwxr-x 1 syalavarthi syalavarthi 43160096 Jul 31 08:12 main/wrf.exe

==========================================================================

[08:15] [syalavarthi@sparrow WRF]$ uname -a
Linux sparrow 5.4.0-1015-raspi #15-Ubuntu SMP Fri Jul 10 05:34:24 UTC 2020 aarch64 aarch64 aarch64 GNU/Linux

`

@syalavarthi syalavarthi reopened this Jul 31, 2020
@davegill
Copy link
Contributor

@syalavarthi @yriveiro
Srikanth,
This looks nice and clean.

Yago,
I have asked the DA team to weigh in on this issue. I would prefer a single PR that fixes all of the WRF system builds, including DA. We will see if that is easily accomplished.

@davegill davegill changed the title fix for gcc 10 Temporary fix for gfortran/10 compiler complaints Jul 31, 2020
@davegill
Copy link
Contributor

@syalavarthi
Srikanth,
Would you please provide your affiliation? We would like to acknowledge your contribution and assistance in our release message.

@davegill
Copy link
Contributor

@wrf-model/da
We need confirmation that WRF DA builds with GNU/10. It does not look like these mods directly assist the DA code.

@syalavarthi
Copy link
Contributor Author

@davegill I work for Marvell Semiconductor.

Copy link
Contributor Author

@syalavarthi syalavarthi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added changes to fix build issues with WRFDA system by introducing new configure variable "FCCOMPAT"

With these new changes, 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

@davegill davegill added the DAVE label Oct 18, 2020
Copy link
Contributor

@davegill davegill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

@davegill davegill merged commit 28c18ee into wrf-model:release-v4.2.2 Oct 23, 2020
@davegill
Copy link
Contributor

@syalavarthi
Srikanth,
Thank you very much for your detailed analysis and contribution. You may be the only person who has ever voluntarily provided a fix for the model, and then all of the DA pieces as well. We look forward to your continued participation with WRF.

@syalavarthi
Copy link
Contributor Author

@davegill

Thank you

breed pushed a commit to SJSU-CS-systems-group/WRF-SFIRE that referenced this pull request 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`).
breed added a commit to SJSU-CS-systems-group/WRF-SFIRE that referenced this pull request Feb 19, 2021
Temporary fix for gfortran/10 compiler argument mismatches (wrf-model#1251)
stephenmsachs added a commit to stephenmsachs/WRF that referenced this pull request Apr 21, 2023
In order to patch GCC arguments when using GCC-10+ a line `^FCCOMPAT` is
necessary in `configure.wrf`. This patch is an extension to
wrf-model#1251.
weiwangncar pushed a commit that referenced this pull request Jul 19, 2023
TYPE: bug-fix

KEYWORDS: GCC

SOURCE: Stephen Sachs (AWS)

DESCRIPTION OF CHANGES:
Problem:
GCC-10 onwards compilation fails on ARM because of missing macro, FCCOMPAT.

Solution:
In order to patch GCC arguments when using GCC-10+ a line FCCOMPAT is necessary in configure.wrf. This patch is an extension to #1251.
vlakshmanan-scala pushed a commit to scala-computing/WRF that referenced this pull request 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`).
vlakshmanan-scala pushed a commit to scala-computing/WRF that referenced this pull request Apr 4, 2024
TYPE: bug-fix

KEYWORDS: GCC

SOURCE: Stephen Sachs (AWS)

DESCRIPTION OF CHANGES:
Problem:
GCC-10 onwards compilation fails on ARM because of missing macro, FCCOMPAT.

Solution:
In order to patch GCC arguments when using GCC-10+ a line FCCOMPAT is necessary in configure.wrf. This patch is an extension to wrf-model#1251.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error compiling the master branch with GCC-10
3 participants