title: fortran: Error: Type mismatch between actual argument at (1) and actual argument at (2) (INTEGER(8)/INTEGER(2))
body: <p>I am a beginner of Fortran and running a model written by Fortran. When I tried to compile it, I got an error message like:</p>
  <pre><code>libtool: link: (cd &quot;.libs&quot; &amp;&amp; rm -f &quot;libgrib_api_f77.so&quot; &amp;&amp; ln -s &quot;libgrib_api_f77.so.1.0.0&quot; &quot;libgrib_api_f77.so&quot;)
  libtool: link: ar cru .libs/libgrib_api_f77.a  grib_fortran.o grib_f77.o
  libtool: link: ranlib .libs/libgrib_api_f77.a
  libtool: link: ( cd &quot;.libs&quot; &amp;&amp; rm -f &quot;libgrib_api_f77.la&quot; &amp;&amp; ln -s &quot;../libgrib_api_f77.la&quot; &quot;libgrib_api_f77.la&quot; )
  gfortran   -c -o same_int_long.o same_int_long.f90
  same_int_long.f90:23:18:
   
     17 |   call check_long(x2(1),x2(2),ret)
        |                  2
  ......
     23 |   call check_long(x4(1),x4(2),ret)
        |                  1
  Error: Type mismatch between actual argument at (1) and actual argument at (2) (INTEGER(4)/INTEGER(2)).
  same_int_long.f90:29:18:
   
     17 |   call check_long(x2(1),x2(2),ret)
        |                  2
  ......
     29 |   call check_long(x8(1),x8(2),ret)
        |                  1
  Error: Type mismatch between actual argument at (1) and actual argument at (2) (INTEGER(8)/INTEGER(2)).
  same_int_long.f90:51:17:
   
     45 |   call check_int(x2(1),x2(2),ret)
        |                 2
  ......
     51 |   call check_int(x4(1),x4(2),ret)
        |                 1
  Error: Type mismatch between actual argument at (1) and actual argument at (2) (INTEGER(4)/INTEGER(2)).
  same_int_long.f90:57:17:
   
     45 |   call check_int(x2(1),x2(2),ret)
        |                 2
  ......
     57 |   call check_int(x8(1),x8(2),ret)
        |                 1
  Error: Type mismatch between actual argument at (1) and actual argument at (2) (INTEGER(8)/INTEGER(2)).
  make[2]: *** [Makefile:546: same_int_long.o] Error 1
  make[2]: Leaving directory '/gpfs/home3/eccei339/snellius_surfex/open_SURFEX_V8_1/src/LIB/grib_api-1.17.0-Source/fortran'
  make[1]: *** [Makefile:604: all-recursive] Error 1
  make[1]: Leaving directory '/gpfs/home3/eccei339/snellius_surfex/open_SURFEX_V8_1/src/LIB/grib_api-1.17.0-Source'
  make: *** [Makefile:398: /home/eccei339/snellius_surfex/open_SURFEX_V8_1/src/LIB/grib_api-1.17.0-Source-LXgfortran/include/grib_api.mod] Error 2
  </code></pre>
  <p>What I did is basically following the installation of the model:</p>
  <p>Step1</p>
  <pre><code>(base) [eccei339@int3 ~]$ mkdir snellius_surfex
  (base) [eccei339@int3 ~]$ cp open_surfex_v8_1_20200107.tar-2.gz snellius_surfex/
  (base) [eccei339@int3 ~]$ cd snellius_surfex/
  (base) [eccei339@int3 snellius_surfex]$ tar zxvf open_surfex_v8_1_20200107.tar-2.gz
  </code></pre>
  <p>…(omit the tar zxvf logging information)</p>
  <p>Step 2: some essential env variable</p>
  <pre><code>(base) [eccei339@int3 snellius_surfex]$ export VER_MPI=&quot;NOMPI&quot;
  (base) [eccei339@int3 snellius_surfex]$ export OMP_NUM_THREADS=1
  (base) [eccei339@int3 snellius_surfex]$ module load 2021
  (base) [eccei339@int3 snellius_surfex]$ module load GCC/10.3.0
  (base) [eccei339@int3 snellius_surfex]$ ls
  open_SURFEX_V8_1  open_surfex_v8_1_20200107.tar-2.gz
  </code></pre>
  <p>(here I exported some necessary envi var following the instructions of installation of the software)</p>
  <p>Step 3: configure</p>
  <pre><code>(base) [eccei339@int3 snellius_surfex]$ cd open_SURFEX_V8_1/src/
  (base) [eccei339@int3 src]$ ls
  ASSIM      Makefile            Rules.bullXI15.mk    Rules.MCgfortran.mk  SURFEX
  configure  Makefile.SURFEX.mk  Rules.bullXI16.mk    Rules.SX8.mk
  FORC       OFFLIN              Rules.LXgfortran.mk  Rules.zgfortran.mk
  include    Rules.AIX64.mk      Rules.LXifort.mk     Rules.zifort.mk
  LIB        Rules.bgfortran.mk  Rules.LXpgi.mk       scripts
  (base) [eccei339@int3 src]$ ./configure
  </code></pre>
  <p>(omit the long logging info of the “configure” command)</p>
  <pre><code>(base) [eccei339@int3 src]$ . ../conf/profile_surfex-LXgfortran-SFX-V8-1-1-NOMPI-OMP-O2-X0
  </code></pre>
  <p>(an essential step following the instructions of installation of the software)</p>
  <p>Step 4: make the master</p>
  <pre><code>(base) [eccei339@int3 src]$ make
  find: ‘/home/eccei339/snellius_surfex/open_SURFEX_V8_1/src/dir_obj-LXgfortran-SFX-V8-1-1-NOMPI-OMP-O2-X0/MASTER’: No such file or directory
  cd /home/eccei339/snellius_surfex/open_SURFEX_V8_1/src/LIB/grib_api-1.17.0-Source &amp;&amp; LDFLAGS= FCFLAGS= CPPFLAGS=&quot;&quot; \
   ./configure --disable-jpeg --prefix=/home/eccei339/snellius_surfex/open_SURFEX_V8_1/src/LIB/grib_api-1.17.0-Source-LXgfortran FC=&quot;gfortran&quot; &amp;&amp; \
   make -j 1 clean &amp;&amp; \
   make -j 1 &amp;&amp; \
   make -j 1 install &amp;&amp; \
   make -j 1 clean
  checking build system type... x86_64-unknown-linux-gnu
  checking host system type... x86_64-unknown-linux-gnu
  checking how to print strings... printf
  checking for gcc... gcc
  checking whether the C compiler works... yes
  checking for C compiler default output file name... a.out
  checking for suffix of executables... 
  checking whether we are cross compiling... no
  </code></pre>
  <p>(omit the long logging information, and the final lines are the error message shown in the beginning of this question description.)</p>
  <p>I searched the Internet that this could be due to the GCC 10 is more strict than older GCC (I compiled this model last year with older GCC and made it, but failed this time because our server is transferred to a new system, thus the GCC is upgraded from older version to a new version). Some information from Google said that I could add something like this:</p>
  <pre><code>export FCFLAGS=&quot;-w -fallow-argument-mismatch -O2&quot;
  export FFLAGS=&quot;-w -fallow-argument-mismatch -O2&quot;
  </code></pre>
  <p>But I tried it in the step 2 where I export some essential environmental variables, it still does not work. So I am wondering is there anybody who can help me? Thanks a lot!</p>
  <p>Updates: the source code of <code>grib_api-1.17.0-Source/fortran/same_int_long.f90</code> from <a href="http://distfiles.macports.org/grib_api/" rel="nofollow noreferrer">http://distfiles.macports.org/grib_api/</a> is as following:</p>
  <pre><code>! Copyright 2005-2016 ECMWF.
  !
  ! This software is licensed under the terms of the Apache Licence Version 2.0
  ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
  ! 
  ! In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
  ! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
  
  integer function kind_of_long()
    integer(2), dimension(2) :: x2 = (/1, 2/)
    integer(4), dimension(2) :: x4 = (/1, 2/)
    integer(8), dimension(2) :: x8 = (/1, 2/)
    character(len=1) :: ret
  
    kind_of_long=-1
  
    call check_long(x2(1),x2(2),ret)
    if (ret == 't') then
     kind_of_long=2
     return
    endif
  
    call check_long(x4(1),x4(2),ret)
    if (ret == 't') then
     kind_of_long=4
     return
    endif
  
    call check_long(x8(1),x8(2),ret)
    if (ret == 't') then
     kind_of_long=8
     return
    endif
  
  end function kind_of_long
  
  integer function kind_of_int()
    integer(2), dimension(2) :: x2 = (/1, 2/)
    integer(4), dimension(2) :: x4 = (/1, 2/)
    integer(8), dimension(2) :: x8 = (/1, 2/)
    character(len=1) :: ret
  
    kind_of_int=-1
  
    call check_int(x2(1),x2(2),ret)
    if (ret == 't') then
     kind_of_int=2
     return
    endif
  
    call check_int(x4(1),x4(2),ret)
    if (ret == 't') then
     kind_of_int=4
     return
    endif
  
    call check_int(x8(1),x8(2),ret)
    if (ret == 't') then
     kind_of_int=8
     return
    endif
  
  end function kind_of_int
  
  program same_int_long
    integer ki,kl
  
    ki=kind_of_int()
    kl=kind_of_long()
    if (ki /= kl) then
      write (*,'(i1)') 0
    else
      write (*,'(i1)') 1
    endif
  end program same_int_long
  
  
  </code></pre>
  <p>Here is the full log information of <code>make</code>: <a href="https://drive.google.com/file/d/14rkj2ay39Rv84QBL6UDiSdlIAfhuEt_z/view?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/14rkj2ay39Rv84QBL6UDiSdlIAfhuEt_z/view?usp=sharing</a></p>