News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Fortran Modules with CB, "Cant rename module file, File exists"

Started by josintom, February 01, 2016, 08:18:08 PM

Previous topic - Next topic

josintom

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?



BlueHazzard

I don't know fortran, but googeling your problem:
http://stackoverflow.com/questions/27281158/fortran-90-gfortran-fatal-error-cant-rename-module-file-exists

For the next post please use the code tags (the # symbol in the topic editor) for logs and code

greetings

MortenMacFly

Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]