I am quite new to CB. I am facing issues with compiling the following FORTRAN code where I am trying to test passing of an allocatable array to a subroutine
module subst
contains
subroutine test1(a)
implicit none
integer, allocatable :: a(:,:)
print *, 'inside test1', size(a,1)
print *, 'inside test1', size(a,2)
end subroutine test1
end module subst
program test
use subst
implicit none
integer :: row,col,i,j
integer, allocatable :: a(:,:)
character :: junk
open (11,file='test.txt',status = 'old')
read (11,*) row, col
read (11,*) junk
print *, row, col
allocate(a(1:row,1:col))
do i=1,row
read (11,*) a(i,:)
enddo
do j=1,col
do i=1,row
print *, a(i,j)
enddo
enddo
print *, size(a,1)
print *, size(a,2)
call test1(a)
deallocate(a)
end program test
When I run the program for the first time, it compiles and works fine. But if I make some changes in the module, say
change the following line in subroutine test1
integer, allocatable :: a(:,:)
to
integer, allocatable, intent(inout) :: a(:,:)
I am getting the following error while truing to compile the code
||=== Build file: Debug in testcb (compiler: GNU Fortran Compiler) ===|
||Fatal Error: Can't rename module file 'obj\Debug\/subst.mod0' to 'obj\Debug\/subst.mod': File exists|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
If I revert the code back to the original state, then the code compiles and run properly.
The input file test.txt is as follows
2 3
Sally
1 2 3
2 3 4
Can you help me point out what I might be possibly doing wrong?