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