Code review comment for lp:~fluidity-core/fluidity/gmsh-on-sphere

Revision history for this message
Lawrence Mitchell (wence) wrote :

The fladapt issue is a real one, but it is generally applicable to all branches, rather than just this one I think. The error (with --enable-debugging) is something like:

Fortran runtime error: Actual string length is shorter than the declared one for dummy argument 'input' (-2123626932/7)

Here's a simplified test of the problematic code:

$ cat > foo.cpp <<\EOF
extern "C" {
#define F77_FUNC(name,NAME) name ## _
#define foo F77_FUNC(foo, FOO)
    void foo(const char *in, const int *len);
}

#include <iostream>
#include <stdlib.h>

using namespace std;
int main(int argc, char **argv)
{
    string in = "fladapt";
    int len = in.size();
    foo(in.c_str(), &len);
    return 0;
}
EOF

$ cat > foo.f90 <<\EOF
subroutine foo(input, length)
  integer, intent(in) :: length
  character(len = length), intent(in) :: input

  write(*,*)input
end subroutine foo
EOF

$ g++ -fbounds-check -O0 -g -c -o foo_main.o foo.cpp
$ gfortran -fbounds-check -O0 -g -c -o foo.o foo.f90
$ g++ -o foo -O0 -g foo.o foo_main.o -lgfortran
$ gdb ./foo
(gdb) r
Starting program: /home/lmitche4/tmp/foo
At line 1 of file foo.f90
Fortran runtime error: Actual string length is shorter than the declared one for dummy argument 'input' (-8200/7)

Program exited with code 02.
(gdb)

I think TRTD is either specified fixed length strings, or use iso_c_binding appropriately as is done in petsc_readnsolve. I think this is necessary for the majority of C++ main tools in tools/

« Back to merge proposal