Quantcast
Channel: Intel® Fortran Compiler
Viewing all articles
Browse latest Browse all 3270

change COMMON to MODULE

$
0
0

We are using an old FORTRAN program which I am trying to set up to date.

One of the main change is converting COMMONs to MODULEs.

But most of the COMMONs include STRUCTUREs which are in an INCLUDE file :

File DECLAR.f90

    structure /drap/

      integer*4 art

      integer*4 col

     end structure

 

Subroutine B

    subroutine b   

    include "declar.f90"   

    type (drap) d1,d2   

    common /ddarp/ d1   

    d1=d2

    return

    end

Program A

   program a   

    include "declar.f90"   

    type (drap) d1,d3   

    common /ddarp/ d1   

    call b

    d3=d1

    end

 

I did change it to :

   module structure_drap   

     structure /drap/

      integer*4 art

      integer*4 col

     end structure

    end module structure_drap

   

    module ddrap

     use structure_drap     

     type (drap) d1    

    end module ddrap   

    subroutine b

   

    use structure_drap

    use ddrap   

    type (drap) d2   

    d1=d2   

    return

    end

   

    program a   

    use structure_drap

    use ddrap   

    type (drap) d3   

    d3=d1   

    return

    end

 

The compiler output the following error :

  This type/structure name has been defined more than once. (DRAP)

 

Note that every module, every subroutine and the main programs are different files and I build all the subroutines a static library.

 

I tried to have 2 different STRUCTUREs DRAP1 and DRAP2, but then the compiler refuses d1=d2 and d3=d1.

 

How can I do ?

 

 

 

And other problem using INTERFACE : the compiler outputs and error when compiling a subroutine together with its INTERFACE. It is very complicated to turn around that + it would be a double check if the compiler could verify the compatibility of the subroutine and its INTERFACE.

 

 

 

 


Viewing all articles
Browse latest Browse all 3270

Trending Articles