Skip to content

Commit

Permalink
fixed interface bug for gcc10
Browse files Browse the repository at this point in the history
While the code tests OK with gcc9, it did
not work properly with gcc10, likely because
the system provided netcdf lib is built with
another compiler.
  • Loading branch information
jinyun1tang committed Mar 10, 2021
1 parent 20cd483 commit eba045e
Showing 1 changed file with 107 additions and 11 deletions.
118 changes: 107 additions & 11 deletions src/betr/betr_math/ODEMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,19 @@ subroutine ode_ebbks1(odefun, extra, y0, nprimeq, neq, t, dt, y, pscal)
real(r8), intent(in) :: dt !time step
real(r8), intent(out) :: y(neq) !return values
real(r8), optional, intent(out) :: pscal !scaling factor
external :: odefun

interface
subroutine odefun(extra, y, dt2, tt, nprimeq, neq, f)
use bshr_kind_mod , only : r8 => shr_kind_r8
use gbetrType , only : gbetr_type
class(gbetr_type), target :: extra
integer, intent(in) :: neq ! number of equations
real(r8), intent(in) :: tt ! time stamp
real(r8), intent(in) :: dt2 ! time stepping
integer, intent(in) :: nprimeq !
real(r8), intent(in) :: y(neq) ! updated state variable
real(r8), intent(out) :: f(neq) ! derivative
end subroutine
end interface
! !LOCAL VARIABLES:
real(r8) :: f(neq)
real(r8) :: pscal_loc
Expand All @@ -77,7 +88,19 @@ subroutine ode_ebbks2(odefun, extra, y0, nprimeq, neq, t, dt, y)
real(r8), intent(in) :: dt !time step
real(r8), intent(out) :: y(neq) !return value

external :: odefun
interface
subroutine odefun(extra, y, dt2, tt, nprimeq, neq, f)
use bshr_kind_mod , only : r8 => shr_kind_r8
use gbetrType , only : gbetr_type
class(gbetr_type), target :: extra
integer, intent(in) :: neq ! number of equations
real(r8), intent(in) :: tt ! time stamp
real(r8), intent(in) :: dt2 ! time stepping
integer, intent(in) :: nprimeq !
real(r8), intent(in) :: y(neq) ! updated state variable
real(r8), intent(out) :: f(neq) ! derivative
end subroutine
end interface
! !LOCAL VARIABLES:
real(r8) :: f(neq)
real(r8) :: f1(neq)
Expand Down Expand Up @@ -109,9 +132,21 @@ subroutine ode_mbbks1(odefun, extra, y0, nprimeq, neq, t, dt, y, pscal, bstatus)
real(r8), intent(in) :: dt
real(r8), intent(out) :: y(neq)
real(r8), optional, intent(out) :: pscal
interface
subroutine odefun(extra, y, dt2, tt, nprimeq, neq, f)
use bshr_kind_mod , only : r8 => shr_kind_r8
use gbetrType , only : gbetr_type
class(gbetr_type), target :: extra
integer, intent(in) :: neq ! number of equations
real(r8), intent(in) :: tt ! time stamp
real(r8), intent(in) :: dt2 ! time stepping
integer, intent(in) :: nprimeq !
real(r8), intent(in) :: y(neq) ! updated state variable
real(r8), intent(out) :: f(neq) ! derivative
end subroutine
end interface
type(betr_status_type), intent(out) :: bstatus

external :: odefun

! !LOCAL VARIABLES:
real(r8) :: f(neq)
Expand Down Expand Up @@ -169,7 +204,19 @@ subroutine ode_mbbks2(odefun, extra, y0, nprimeq, neq, t, dt, y, bstatus)
real(r8), intent(in) :: dt
real(r8), intent(out) :: y(neq)
type(betr_status_type), intent(out) :: bstatus
external :: odefun
interface
subroutine odefun(extra, y, dt2, tt, nprimeq, neq, f)
use bshr_kind_mod , only : r8 => shr_kind_r8
use gbetrType , only : gbetr_type
class(gbetr_type), target :: extra
integer, intent(in) :: neq ! number of equations
real(r8), intent(in) :: tt ! time stamp
real(r8), intent(in) :: dt2 ! time stepping
integer, intent(in) :: nprimeq !
real(r8), intent(in) :: y(neq) ! updated state variable
real(r8), intent(out) :: f(neq) ! derivative
end subroutine
end interface

! !LOCAL VARIABLES:
real(r8) :: f(neq)
Expand Down Expand Up @@ -298,7 +345,19 @@ subroutine ode_adapt_mbbks1(odefun, extra, y0, nprimeq, neq, t, dt, y, bstatus)
integer, intent(in) :: nprimeq !
real(r8), intent(out) :: y(neq) ! updated state variable
type(betr_status_type), intent(out) :: bstatus
external :: odefun
interface
subroutine odefun(extra, y, dt2, tt, nprimeq, neq, f)
use bshr_kind_mod , only : r8 => shr_kind_r8
use gbetrType , only : gbetr_type
class(gbetr_type), target :: extra
integer, intent(in) :: neq ! number of equations
real(r8), intent(in) :: tt ! time stamp
real(r8), intent(in) :: dt2 ! time stepping
integer, intent(in) :: nprimeq !
real(r8), intent(in) :: y(neq) ! updated state variable
real(r8), intent(out) :: f(neq) ! derivative
end subroutine
end interface

! !LOCAL VARIABLES:
real(r8) :: yc(neq) !coarse time stepping solution
Expand Down Expand Up @@ -538,6 +597,19 @@ subroutine ode_rk4(odefun,extra, y0, neq, t, dt, y )
real(r8), intent(in) :: t
real(r8), intent(in) :: dt
real(r8), intent(out) :: y(neq)
interface
subroutine odefun(extra, y, dt2, tt, neq, f)
use bshr_kind_mod , only : r8 => shr_kind_r8
use gbetrType , only : gbetr_type
class(gbetr_type), target :: extra
integer, intent(in) :: neq ! number of equations
real(r8), intent(in) :: tt ! time stamp
real(r8), intent(in) :: dt2 ! time stepping
real(r8), intent(in) :: y(neq) ! updated state variable
real(r8), intent(out) :: f(neq) ! derivative
end subroutine
end interface

! !LOCAL VARIABLES:
real(r8) :: k1(neq)
real(r8) :: k2(neq)
Expand All @@ -546,7 +618,6 @@ subroutine ode_rk4(odefun,extra, y0, neq, t, dt, y )
real(r8) :: kt(neq)
real(r8) :: ti, dt05, a
integer :: n
external :: odefun

ti = t
dt05 = dt * 0.5_r8
Expand Down Expand Up @@ -606,12 +677,25 @@ subroutine ode_rk2(odefun, extra, y0, neq, t, dt, y )
real(r8), intent(in) :: t
real(r8), intent(in) :: dt
real(r8), intent(out) :: y(neq)

interface
subroutine odefun(extra, y, dt2, tt, neq, f)
use bshr_kind_mod , only : r8 => shr_kind_r8
use gbetrType , only : gbetr_type
class(gbetr_type), target :: extra
integer, intent(in) :: neq ! number of equations
real(r8), intent(in) :: tt ! time stamp
real(r8), intent(in) :: dt2 ! time stepping
real(r8), intent(in) :: y(neq) ! updated state variable
real(r8), intent(out) :: f(neq) ! derivative
end subroutine
end interface

! !LOCAL VARIABLES:
real(r8) :: k1(neq)
real(r8) :: k2(neq)
real(r8) :: ti, dt05
integer :: n
external :: odefun

ti = t
dt05 = dt * 0.5_r8
Expand Down Expand Up @@ -646,7 +730,19 @@ subroutine ode_adapt_ebbks1(odefun, extra, y0, nprimeq, neq, t, dt, y)
integer, intent(in) :: nprimeq !
real(r8), intent(out) :: y(neq) ! updated state variable
external :: odefun

interface
subroutine odefun(extra, y, dt2, tt, nprimeq, neq, f)
use bshr_kind_mod , only : r8 => shr_kind_r8
use gbetrType , only : gbetr_type
class(gbetr_type), target :: extra
integer, intent(in) :: neq ! number of equations
real(r8), intent(in) :: tt ! time stamp
real(r8), intent(in) :: dt2 ! time stepping
integer, intent(in) :: nprimeq !
real(r8), intent(in) :: y(neq) ! updated state variable
real(r8), intent(out) :: f(neq) ! derivative
end subroutine
end interface
! !LOCAL VARIABLES:
real(r8) :: yc(neq) !coarse time stepping solution
real(r8) :: yf(neq) !fine time stepping solution
Expand Down Expand Up @@ -676,9 +772,9 @@ subroutine ode_adapt_ebbks1(odefun, extra, y0, nprimeq, neq, t, dt, y)
tt=tt+dt2
y=yc
else
print*,'get coarse grid solution'
! print*,'get coarse grid solution'
call odefun(extra, y, dt2, tt, nprimeq, neq, f)
print*,'ebbks'
! print*,'ebbks'
call ebbks(y, f, nprimeq, neq, dt2, yc, pscal)

!get fine grid solution
Expand Down

0 comments on commit eba045e

Please sign in to comment.