Skip to content

Difficulties with enabling fortran interface #5

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

Open
AtticusBeachy opened this issue Sep 18, 2022 · 3 comments
Open

Difficulties with enabling fortran interface #5

AtticusBeachy opened this issue Sep 18, 2022 · 3 comments

Comments

@AtticusBeachy
Copy link

Installation works perfectly when I configure using
./configure --prefix=/usr/local/zoltan

However, when I run

./configure --prefix=/usr/local/zoltan --enable-f90interface
make everything

It crashes with the following series of errors

make[3]: Entering directory '/home/crow/Downloads/Zoltan-3.901/BuildDir/src/fdriver'
/usr/local/bin/mpif90 -I ../ -I . -g -O2  -c -o mpi_h.o `test -f '../../../src/fdriver/mpi_h.f' || echo '../../../src/fdriver/'`../../../src/fdriver/mpi_h.f
/usr/local/bin/mpif90 -I ../ -I . -g -O2  -c -o farg_typical.o `test -f '../../../src/fdriver/farg_typical.f' || echo '../../../src/fdriver/'`../../../src/fdriver/farg_typical.f
/usr/local/bin/mpif90 -I ../ -I . -g -O2  -c -o mmio.o `test -f '../../../src/fdriver/mmio.f' || echo '../../../src/fdriver/'`../../../src/fdriver/mmio.f
/usr/local/bin/mpif90  -I ../ -I . -g -O2 -c -o fdr_sort.o  `test -f '../../../src/fdriver/fdr_sort.f90' || echo '../../../src/fdriver/'`../../../src/fdriver/fdr_sort.f90
/usr/local/bin/mpif90  -I ../ -I . -g -O2 -c -o fdr_const.o  `test -f '../../../src/fdriver/fdr_const.f90' || echo '../../../src/fdriver/'`../../../src/fdriver/fdr_const.f90
/usr/local/bin/mpif90  -I ../ -I . -g -O2 -c -o fdr_input.o  `test -f '../../../src/fdriver/fdr_input.f90' || echo '../../../src/fdriver/'`../../../src/fdriver/fdr_input.f90
../../../src/fdriver/fdr_input.f90:424:17:

  413 |   call MPI_Bcast(Test_Multi_Callbacks, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
      |                 2
......
  424 |   call MPI_Bcast(pio_info%pdsk_root, len(pio_info%pdsk_root), MPI_CHARACTER, &
      |                 1
Error: Type mismatch between actual argument at (1) and actual argument at (2) (CHARACTER(1025)/INTEGER(4)).
../../../src/fdriver/fdr_input.f90:426:17:

  413 |   call MPI_Bcast(Test_Multi_Callbacks, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
      |                 2
......
  426 |   call MPI_Bcast(pio_info%pdsk_subdir, len(pio_info%pdsk_root), MPI_CHARACTER, &
      |                 1
Error: Type mismatch between actual argument at (1) and actual argument at (2) (CHARACTER(1025)/INTEGER(4)).
../../../src/fdriver/fdr_input.f90:428:17:

  413 |   call MPI_Bcast(Test_Multi_Callbacks, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
      |                 2
......
  428 |   call MPI_Bcast(pio_info%pexo_fname, len(pio_info%pdsk_root), MPI_CHARACTER, &
      |                 1
Error: Type mismatch between actual argument at (1) and actual argument at (2) (CHARACTER(1025)/INTEGER(4)).
../../../src/fdriver/fdr_input.f90:436:19:

  413 |   call MPI_Bcast(Test_Multi_Callbacks, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
      |                 2  
......
  436 |     call MPI_Bcast(pio_info%dsk_list, pio_info%dsk_list_cnt, MPI_INTEGER, &
      |                   1
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (scalar and rank-1)
../../../src/fdriver/fdr_input.f90:441:17:

  413 |   call MPI_Bcast(Test_Multi_Callbacks, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
      |                 2
......
  441 |   call MPI_Bcast(prob%ztnPrm_file, len(prob%ztnPrm_file), MPI_CHARACTER, &
      |                 1
Error: Type mismatch between actual argument at (1) and actual argument at (2) (CHARACTER(1024)/INTEGER(4)).
../../../src/fdriver/fdr_input.f90:445:17:

  413 |   call MPI_Bcast(Test_Multi_Callbacks, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
      |                 2
......
  445 |   call MPI_Bcast(prob%method, len(prob%method), MPI_CHARACTER, 0,MPI_COMM_WORLD,ierr)
      |                 1
Error: Type mismatch between actual argument at (1) and actual argument at (2) (CHARACTER(32)/INTEGER(4)).
../../../src/fdriver/fdr_input.f90:453:21:

  413 |   call MPI_Bcast(Test_Multi_Callbacks, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
      |                 2    
......
  453 |       call MPI_Bcast(prob%params(i)%str(0), size, MPI_CHARACTER, 0, &
      |                     1
Error: Type mismatch between actual argument at (1) and actual argument at (2) (CHARACTER(128)/INTEGER(4)).
../../../src/fdriver/fdr_input.f90:455:21:

  413 |   call MPI_Bcast(Test_Multi_Callbacks, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
      |                 2    
......
  455 |       call MPI_Bcast(prob%params(i)%str(1), size, MPI_CHARACTER, 0, &
      |                     1
Error: Type mismatch between actual argument at (1) and actual argument at (2) (CHARACTER(128)/INTEGER(4)).
make[3]: *** [Makefile:403: fdr_input.o] Error 1
make[3]: Leaving directory '/home/crow/Downloads/Zoltan-3.901/BuildDir/src/fdriver'
make[2]: *** [Makefile:3536: all-recursive] Error 1
make[2]: Leaving directory '/home/crow/Downloads/Zoltan-3.901/BuildDir/src'
make[1]: *** [Makefile:534: all-recursive] Error 1
make[1]: Leaving directory '/home/crow/Downloads/Zoltan-3.901/BuildDir'
make: *** [Makefile:1022: everything] Error 2

I am using gfortran, which is not one of the compilers mentioned in the Known_Problems text file.
Operating System: Linux Mint 21

@AtticusBeachy
Copy link
Author

I figured out the problem. The GFortran compiler enforces type matching for version 10 and later, which causes Zoltan to crash. This can be fixed by using version 9 or earlier.

In Linux Mint, the current version of GFortran can be uninstalled and version 9 installed using the following terminal commands:

sudo apt purge gfortran
sudo apt install gfortran-9 

I strongly recommend adding this information to the documentation.

@adigitoleo
Copy link

Using -fallow-argument-mismatch I was able to compile the code with gfortran 12.2, in fact I can't understand where the mismatch comes from because I can only see the arguments passed to MPI_Bcast being declared as integers everywhere, so I don't follow where the CHARACTER type is coming from, taking Test_Multi_Callbacks for example:

src/fdriver/fdr_migrate.f90
170:  if (Test_Multi_Callbacks.eq.1) then

src/fdriver/fdr_loadbal.f90
253:  if (Test_Multi_Callbacks .eq. 1)  then
283:    if (Test_Multi_Callbacks.eq.1) then
298:  if (Test_Multi_Callbacks.eq.1) then
317:    if (Test_Multi_Callbacks .eq. 1)  then
378:  if (Test_Multi_Callbacks .eq. 1) then

src/fdriver/fdr_input.f90
255:        Test_Multi_Callbacks = iachar(trim(inp_line(index(inp_line,"= ")+2:))) - iachar('0')
413:  call MPI_Bcast(Test_Multi_Callbacks, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)

src/fdriver/fdr_const.f90
63:public :: Test_Multi_Callbacks
80:integer(Zoltan_INT) :: Test_Multi_Callbacks = 0

Maybe the iachar can return a CHARACTER somehow? Fortran docs are not super clear to me. Perhaps someone who understands fortran could take a look. There are some related discussions in other projects where people have suggested replacing #include 'mpif.h' statements with use mpi, see e.g. NOAA-GFDL/FMS#561

@AtticusBeachy
Copy link
Author

I eventually figured this out as well. I configured using the command:

./configure --prefix=/usr/local/zoltan --enable-mpi --with-mpi-compilers --enable-f90interface --with-gnumake FCFLAGS="-w -fallow-argument-mismatch -O2" FFLAGS="-w -fallow-argument-mismatch -O2"

The iachar function returns an integer type according to the Fortran documentation:

Description:
IACHAR(C) returns the code for the ASCII character in the first character position of C.
Syntax:
RESULT = IACHAR(C [, KIND])
Return value:
The return value is of type INTEGER and of kind KIND. If KIND is absent, the return value is of default integer kind.

The type mismatch is a very confusing error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants