Dear Tobias, I have a couple of follow up questions:
1. Do we need to create the global variables __gfortran_called_proc, __gfortran_called_interface during compilation? If yes, how would these global variables be initialized, the module containing the caller’s source code or the module containing the callee’s source code? 2. Do we plan to do the instrumentation for runtime check inline in the IR itself (inline monitoring)? Or can we write a runtime library that does the checking, and we just insert calls to the runtime library routine at compile time? 3. Do we need to handle multithreaded programs? How will we handle the race condition in which two different threads call an external procedure at the same time? 4. How will we identify the procedures which require the run-time check? I mean, do we need to write a static analysis to figure out which functions are called externally? Regards, Krishna Kariya On Tue, Apr 6, 2021 at 2:38 PM Tobias Burnus <tobias_bur...@mentor.com> wrote: > Hi Krishna, > > On 03.04.21 13:52, Krishna Kariya wrote: > > I am Krishna, a final-year undergraduate student from India. I am > > interested in the project “Fortran – run-time argument checking” for > > GSoC 2021. Please share some resources about the project. Please point > > to some issues or programming tasks that I can try out to understand > > the project better. > > In older Fortran program, no modules were used and, hence, no argument > checking was possible. Think of: > > subroutine caller() > external callee > integer :: A(5), b(4) > call callee(A, B, 5.0, "Hello") > end > > Here, the compiler only knows that 'callee' is a subroutine but has no > idea about the actual arguments. Alternatively, in semi-modern code, it > could use: > > subroutine caller() > integer :: A(5), b(4) > interface > subroutine callee(w,x,y,z) > integer :: w(*), x(*) > real :: y > character(*) :: z > end > end interface > call callee(A, B, 5.0, "Hello") > end > > The idea is that the caller now fills global variables: > __gfortran_called_proc = callee ! function pointer > __gfortran_called_interface = ... pointer to a struct/derived type > and afterwards, it would set both to null. > > The latter contains then: > - a version number (to be able to add more data later on) > - file name, function name and line number of the caller > - information about the arguments: > - 4 arguments > - first: integer array of size 4 > - ... > > And in > subroutine callee(....) > it would check: > if (__gfortran_called_proc == callee) > and then fill a similar struct with similar data > (version number, filename, proc name, line number, arguments) > and then call the library function > __libgfortran_check_args( > __gfortran_called_interface, > callee_interface); > which then checks whether the arguments match. > > Internal procedures and module procedures can be excluded as > those can not be access from the outside. > > Minimal check would be: > - number of arguments > - data type > - array + array size > - caller/callee is a function – and expected return values (type, array) > but that can be extended especially in the context of an interface block > (with a zoo of attributes, additional array types etc.) and with intent > handling (intent(out) in caller but constant or intent(in) as argument, > intent(out) argument to intent(in) etc.) > > Tobias > > ----------------- > Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München > Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank > Thürauf >