Author Topic: Fortran Modules with CB, "Cant rename module file, File exists"  (Read 4851 times)

josintom

  • Guest
Fortran Modules with CB, "Cant rename module file, File exists"
« on: February 01, 2016, 08:18:08 pm »
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?


« Last Edit: February 01, 2016, 08:22:36 pm by josintom »

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3352
Re: Fortran Modules with CB, "Cant rename module file, File exists"
« Reply #1 on: February 01, 2016, 09:16:39 pm »
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

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: Fortran Modules with CB, "Cant rename module file, File exists"
« Reply #2 on: February 01, 2016, 09:29:43 pm »
http://stackoverflow.com/questions/27281158/fortran-90-gfortran-fatal-error-cant-rename-module-file-exists
If that is the case, please use the installer that ships with the GFortran compiler, available from the C::B download section (assuming you are using Windows).
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ