Skip to content

Commit

Permalink
Merge pull request #82 from GreyEvenson-NOAA/noah_om_grid_issue76
Browse files Browse the repository at this point in the history
Remove unnecessary transfer of variable values in call to solve_noahowp_grid
  • Loading branch information
GreyREvenson authored Sep 5, 2023
2 parents efbde7d + ee47505 commit c2e44ec
Show file tree
Hide file tree
Showing 13 changed files with 232 additions and 271 deletions.
36 changes: 31 additions & 5 deletions src/DomainType.f90
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module DomainType

use NamelistRead, only: namelist_type

use NamelistRead, only: namelist_type
use DomainGridType, only: domaingrid_type
implicit none
save
private
Expand Down Expand Up @@ -43,18 +43,21 @@ module DomainType
procedure, public :: Init
procedure, private :: InitAllocate
procedure, private :: InitDefault
procedure, private :: InitTransfer

end type domain_type

contains

subroutine Init(this, namelist)
subroutine Init(this, namelist, domaingrid)

class(domain_type) :: this
type(namelist_type) :: namelist
class(domain_type), intent(inout) :: this
type(namelist_type), intent(in) :: namelist
type(domaingrid_type), intent(in) :: domaingrid

call this%InitAllocate(namelist)
call this%InitDefault()
call this%InitTransfer(domaingrid)

end subroutine Init

Expand Down Expand Up @@ -108,6 +111,29 @@ subroutine InitDefault(this)

end subroutine InitDefault

subroutine InitTransfer(this,domaingrid)

class(domain_type), intent(inout) :: this
type(domaingrid_type), intent(in) :: domaingrid

this%DT = domaingrid%DT
this%dx = domaingrid%dx
this%dy = domaingrid%dy
this%n_x = domaingrid%n_x
this%n_y = domaingrid%n_y
this%startdate = domaingrid%startdate
this%enddate = domaingrid%enddate
this%nowdate = domaingrid%nowdate
this%start_datetime = domaingrid%start_datetime
this%end_datetime = domaingrid%end_datetime
this%curr_datetime = domaingrid%sim_datetimes(domaingrid%itime)
this%itime = domaingrid%itime
this%ntime = domaingrid%ntime
this%time_dbl = domaingrid%time_dbl
this%ZREF = domaingrid%ZREF

end subroutine InitTransfer

end module DomainType


17 changes: 1 addition & 16 deletions src/DomainTypeTransfer.f90
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,11 @@ subroutine DomainVarInTransfer(domain, domaingrid, ix, iy)
integer, intent(in) :: ix
integer, intent(in) :: iy

domain%DT = domaingrid%DT
domain%ix = ix
domain%iy = iy
domain%dx = domaingrid%dx
domain%dy = domaingrid%dy
domain%n_x = domaingrid%n_x
domain%n_y = domaingrid%n_y
domain%startdate = domaingrid%startdate
domain%enddate = domaingrid%enddate
domain%nowdate = domaingrid%nowdate
domain%start_datetime = domaingrid%start_datetime
domain%end_datetime = domaingrid%end_datetime
domain%curr_datetime = domaingrid%sim_datetimes(domaingrid%itime)
domain%itime = domaingrid%itime
domain%ntime = domaingrid%ntime
domain%time_dbl = domaingrid%time_dbl
domain%lat = domaingrid%lat(ix,iy)
domain%lon = domaingrid%lon(ix,iy)
domain%ZREF = domaingrid%ZREF
domain%lon = domaingrid%lon(ix,iy)
domain%terrain_slope = domaingrid%terrain_slope(ix,iy)
domain%azimuth = domaingrid%azimuth(ix,iy)
domain%vegtyp = domaingrid%vegtyp(ix,iy)
Expand All @@ -60,7 +46,6 @@ subroutine DomainVarOutTransfer(domain, domaingrid, ix, iy)
domaingrid%zsoil(ix,iy,:) = domain%zsoil(:)
domaingrid%dzsnso(ix,iy,:) = domain%dzsnso(:)
domaingrid%zsnso(ix,iy,:) = domain%zsnso(:)
domaingrid%nowdate = domain%nowdate !this needs to be kept here until nowdate is updated in domaingriddedDriverModule

end subroutine DomainVarOutTransfer

Expand Down
27 changes: 16 additions & 11 deletions src/EnergyType.f90
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module EnergyType

use NamelistRead, only: namelist_type

use NamelistRead, only: namelist_type
use EnergyGridType, only: energygrid_type

implicit none
save
private
Expand Down Expand Up @@ -161,26 +162,28 @@ module EnergyType
procedure, public :: Init
procedure, private :: InitAllocate
procedure, private :: InitDefault
procedure, public :: InitTransfer
procedure, private :: InitTransfer

end type energy_type

contains

subroutine Init(this, namelist)
subroutine Init(this, namelist, energygrid)

class(energy_type) :: this
type(namelist_type) :: namelist
class(energy_type), intent(inout) :: this
type(namelist_type), intent(in) :: namelist
type(energygrid_type), intent(in) :: energygrid

call this%InitAllocate(namelist)
call this%InitDefault()
call this%InitTransfer(energygrid)

end subroutine Init

subroutine InitAllocate(this, namelist)

class(energy_type) :: this
type(namelist_type) :: namelist
class(energy_type), intent(inout) :: this
type(namelist_type), intent(in) :: namelist

associate(nsnow => namelist%nsnow, &
nsoil => namelist%nsoil)
Expand Down Expand Up @@ -361,11 +364,13 @@ subroutine InitDefault(this)

end subroutine InitDefault

subroutine InitTransfer(this, namelist)
subroutine InitTransfer(this, energygrid)

class(energy_type) :: this
type(namelist_type) :: namelist
class(energy_type), intent(inout) :: this
type(energygrid_type), intent(in) :: energygrid

!Nothing to do

end subroutine InitTransfer

end module EnergyType
24 changes: 20 additions & 4 deletions src/ForcingType.f90
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module ForcingType

use NamelistRead, only: namelist_type
use ForcingGridType, only: forcinggrid_type
implicit none
save
private
Expand Down Expand Up @@ -47,23 +49,27 @@ module ForcingType
procedure, public :: Init
procedure, private :: InitAllocate
procedure, private :: InitDefault
procedure, private :: InitTransfer

end type forcing_type

contains

subroutine Init(this)
subroutine Init(this,namelist,forcinggrid)

class(forcing_type) :: this
class(forcing_type), intent(inout) :: this
type(namelist_type), intent(in) :: namelist
type(forcinggrid_type), intent(in) :: forcinggrid

call this%InitAllocate()
call this%InitDefault()
call this%InitTransfer(forcinggrid)

end subroutine Init

subroutine InitAllocate(this)

class(forcing_type) :: this
class(forcing_type), intent(inout) :: this

if(.NOT.allocated(this%SOLAD)) allocate(this%SOLAD (2))
if(.NOT.allocated(this%SOLAI)) allocate(this%SOLAI (2))
Expand All @@ -72,7 +78,7 @@ end subroutine InitAllocate

subroutine InitDefault(this)

class(forcing_type) :: this
class(forcing_type), intent(inout) :: this

this%SFCPRS = huge(1.0)
this%SFCPRS = huge(1.0)
Expand Down Expand Up @@ -119,4 +125,14 @@ subroutine InitDefault(this)

end subroutine InitDefault

subroutine InitTransfer(this,forcinggrid)

class(forcing_type), intent(inout) :: this
type(forcinggrid_type), intent(in) :: forcinggrid

this%JULIAN = forcinggrid%JULIAN
this%YEARLEN = forcinggrid%YEARLEN

end subroutine InitTransfer

end module ForcingType
2 changes: 0 additions & 2 deletions src/ForcingTypeTransfer.f90
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ subroutine ForcingVarInTransfer(forcing, forcinggrid, ix, iy)
forcing%RHOAIR = forcinggrid%RHOAIR(ix,iy)
forcing%FPICE = forcinggrid%FPICE(ix,iy)
forcing%SWDOWN = forcinggrid%SWDOWN(ix,iy)
forcing%JULIAN = forcinggrid%JULIAN
forcing%YEARLEN = forcinggrid%YEARLEN
forcing%SOLAD(:) = forcinggrid%SOLAD(ix,iy,:)
forcing%SOLAI(:) = forcinggrid%SOLAI(ix,iy,:)

Expand Down
25 changes: 21 additions & 4 deletions src/LevelsType.f90
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module LevelsType

use NamelistRead, only: namelist_type
use LevelsGridType, only: levelsgrid_type
implicit none
save
private
Expand All @@ -13,28 +15,43 @@ module LevelsType
contains

procedure, public :: Init
procedure, private :: InitDefault
procedure, private :: InitDefault
procedure, private :: InitTransfer

end type levels_type

contains

subroutine Init(this)
subroutine Init(this,namelist,levelsgrid)

class(levels_type) :: this
class(levels_type), intent(inout) :: this
type(namelist_type), intent(in) :: namelist
type(levelsgrid_type), intent(in) :: levelsgrid

call this%InitDefault()
call this%InitTransfer(levelsgrid)

end subroutine Init

subroutine InitDefault(this)

class(levels_type) :: this
class(levels_type), intent(inout) :: this

this%nsoil = huge(1)
this%nsnow = huge(1)
this%nveg = huge(1)

end subroutine InitDefault

subroutine InitTransfer(this,levelsgrid)

class(levels_type), intent(inout) :: this
type(levelsgrid_type), intent(in) :: levelsgrid

this%nsoil = levelsgrid%nsoil
this%nsnow = levelsgrid%nsnow
this%nveg = levelsgrid%nveg

end subroutine InitTransfer

end module LevelsType
4 changes: 1 addition & 3 deletions src/LevelsTypeTransfer.f90
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ subroutine LevelsVarInTransfer(levels, levelsgrid, ix, iy)
integer, intent(in) :: ix
integer, intent(in) :: iy

levels%nsoil = levelsgrid%nsoil
levels%nsnow = levelsgrid%nsnow
levels%nveg = levelsgrid%nveg
! Nothing to do

end subroutine LevelsVarInTransfer

Expand Down
39 changes: 35 additions & 4 deletions src/OptionsType.f90
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module OptionsType

use NamelistRead, only: namelist_type
use OptionsGridType, only: optionsgrid_type
implicit none
save
private
Expand Down Expand Up @@ -107,23 +109,27 @@ module OptionsType
contains

procedure, public :: Init
procedure, private :: InitDefault
procedure, private :: InitDefault
procedure, private :: InitTransfer

end type options_type

contains

subroutine Init(this)
subroutine Init(this,namelist,optionsgrid)

class(options_type), intent(out) :: this
class(options_type), intent(inout) :: this
type(namelist_type), intent(in) :: namelist
type(optionsgrid_type), intent(in) :: optionsgrid

call this%InitDefault()
call this%InitTransfer(optionsgrid)

end subroutine Init

subroutine InitDefault(this)

class(options_type), intent(out) :: this
class(options_type), intent(inout) :: this

this%opt_snf = huge(1)
this%opt_run = huge(1)
Expand All @@ -145,4 +151,29 @@ subroutine InitDefault(this)

end subroutine InitDefault

subroutine InitTransfer(this,optionsgrid)

class(options_type), intent(inout) :: this
type(optionsgrid_type), intent(in) :: optionsgrid

this%opt_snf = optionsgrid%opt_snf
this%opt_run = optionsgrid%opt_run
this%opt_drn = optionsgrid%opt_drn
this%opt_inf = optionsgrid%opt_inf
this%opt_infdv = optionsgrid%opt_infdv
this%dveg = optionsgrid%dveg
this%opt_alb = optionsgrid%opt_alb
this%opt_rad = optionsgrid%opt_rad
this%opt_sfc = optionsgrid%opt_sfc
this%opt_crs = optionsgrid%opt_crs
this%opt_crop = optionsgrid%opt_crop
this%opt_stc = optionsgrid%opt_stc
this%opt_tbot = optionsgrid%opt_tbot
this%opt_frz = optionsgrid%opt_frz
this%opt_btr = optionsgrid%opt_btr
this%opt_rsf = optionsgrid%opt_rsf
this%opt_sub = optionsgrid%opt_sub

end subroutine InitTransfer

end module OptionsType
Loading

0 comments on commit c2e44ec

Please sign in to comment.