gfortran编译问题:`_gfortran_set_options'的多重定义

问题描述 投票:0回答:0

我的gfortran版本是8.1.0,我用cmake搭建了一个fortran工程。 当我将所有源代码保存在一个文件夹中并将它们编译成 exe 时,它就可以工作了。但是如果我把它们分成两部分,一个用于编译dll,另一个用于编译exe,然后我将这个exe链接到dll,它就会出现这样的问题:enter image description here

我正在使用这样的源代码:

PROGRAM BELLHOP

  ! Beam tracing in cylindrical coordinates
  ! Michael B. Porter and Homer P. Bucker

  USE bellMod
  USE RefCoMod
  USE bdryMod
  USE angleMod
  USE SdRdRMod
  USE ArrMod
  USE BeamPatternMod

  ! note ArrivalsStorage of 2000000 is about the max g95 could take in the allocate statement
  INTEGER, PARAMETER    :: SHDFIL = 25, RAYFIL = 21, ArrivalsStorage = 20000000
  REAL,    PARAMETER    :: DegRad = pi / 180.0
  INTEGER   IBPvec( 1 )
  REAL      xs( 2 ), gradc( 2 )
  COMPLEX,  ALLOCATABLE ::   U( :, : )
  COMPLEX   EPS, PICKEPS
  CHARACTER TITLE*80, BotOpt*3, RunType*4, BeamType*3

  CALL CPU_TIME( Tstart )

  ! Read in control data ***

  CALL READIN( TITLE, freq, ISINGL, &
       NIMAGE, IBWIN, deltas, MaxN, zBox, rBox, EPMULT, RLOOP,  &
       TopOpt, DepthT, CPT, RHOT, BotOpt, DepthB, CPB, RHOB, RunType, BeamType )

  CALL READATI(  TopOpt(5:5), DepthT, rBox, PRTFil )    ! READ AlTImetry
  CALL READBTY(  BotOpt(2:2), DepthB, rBox, PRTFil )      ! READ BaThYmetrY
  CALL READRC(   BotOpt(1:1), TopOpt(2:2),  PRTFil )    ! READ Reflection Coefficients (top and bottom)
  CALL READPAT( RunType(3:3),               PRTFil )      ! Read Source Beam Pattern
...
...
...
END PROGRAM BELLHOP

SUBROUTINE func_name(arglist)
    ...
END SUBROUTINE func_name
...
...

这样的dll源代码:


SUBROUTINE SHIFTIN( X, T, I1, I2 )

  ! Shift values (I1, I2) one position to the right
  !  and insert T at position I1

SUBROUTINE SORT( X, N )

  ! Does an insertion sort on a vector of real numbers

  ! At the Ith step, the first I-1 positions contain a sorted
  ! vector.  We shall insert the Ith value into its place in that
  ! vector shifting up to produce a new vector of length I.

  REAL X( * )

  IF ( N == 1 ) RETURN

  DO I = 2, N

     T = X( I )

     IF ( T < X( 1 ) ) THEN
        ! Goes in the first position
        CALL SHIFTIN( X, T, 1, I - 1 )

     ELSE IF ( T < X( I - 1 ) ) THEN

        ! *** Binary search for its place ***

        IRIGHT = I - 1
        ILEFT  = 1

        DO WHILE ( IRIGHT > ILEFT + 1 )
           IMID = ( ILEFT + IRIGHT ) / 2
           IF ( T < X(IMID) ) THEN
              IRIGHT = IMID
           ELSE
              ILEFT  = IMID
           ENDIF
        END DO

        ! Shift and insert
        CALL SHIFTIN( X, T, IRIGHT, I - 1 )

     ENDIF

  END DO

  RETURN
END SUBROUTINE SORT
  REAL X( * )

  DO  K = I2, I1, -1
     X( K + 1 ) = X( K )
  END DO

  X( I1 ) = T

  RETURN
END SUBROUTINE SHIFTIN

请帮忙。 谢谢。

compiler-errors fortran gfortran
© www.soinside.com 2019 - 2024. All rights reserved.