I am a Fortran newbie. I attempted to write fortran code for matrix operations, where I was stuck in designing the prototype(interface) of my functions.
My C/C++ programming experience tells me that to write a code that may apply to matrices of all dimensions one needs to pass the array and dimensions separately to the function. Example(probably not the best) :
int * matx_op(int *mat_a, int arows, int acols, int *mat_b, int brows, int bcols);
But it seems that in fortran matmul() function does this automatically. Want to understand hows that done.
print *, 'Enter 16 elements of matrix A'
do i=1,4
do j=1,4
read *, ma(i,j)
end do
end do
print *, 'Enter 16 elements of matrix B'
do i=1,4
do j=1,4
read *, mb(i,j)
end do
end do
mr = matmul(ma,mb)
size()to get size in a single dimension. You can also uselbound(),ubound()andshape(). Be sure to study your Fortran manual gcc.gnu.org/onlinedocs/gfortran/SIZE.html#SIZE.size(..,dim=..)gives size along one dimension rather than the overall size. My motivation for suggesting the duplicate was the discussion around assumed shape (etc.). It's this latter facility that is the visible aspect of the passing. It may also be worth noting for other things that intrinsics needn't have a Fortran implementation.