Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary transfer of variable values in call to solve_noahowp_grid #82

Merged
merged 20 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
d3e4f80
Updating transfer subroutines to not use move spatially and temporall…
GreyREvenson Aug 23, 2023
0b8d74b
Updating transfer of spatially and temporally static variable values
GreyREvenson Aug 23, 2023
ba93adb
Cleanup
GreyREvenson Aug 23, 2023
5c7f60f
Adding calls to re-added InitTransfer functions for column model
GreyREvenson Aug 23, 2023
8dc5a99
Adding InitTransfer type-bound procedures back into code for column m…
GreyREvenson Aug 24, 2023
0083bd1
Removing transfer of variables that will be transferred before/outsid…
GreyREvenson Aug 24, 2023
594a39d
Adding calls to column model InitTransfer subroutines to transfer spa…
GreyREvenson Aug 24, 2023
a2b0831
Cleanup
GreyREvenson Aug 25, 2023
e1910ec
Remove unnecessary transferring-out of parameter_type variables
GreyREvenson Aug 25, 2023
fdccb17
Removing unnecessary transfer-outs
GreyREvenson Aug 28, 2023
df81139
Cleanup
GreyREvenson Aug 28, 2023
55b9b7b
Cleanup
GreyREvenson Aug 28, 2023
62d3135
Re-adding variables to transfer-out subroutine
GreyREvenson Aug 28, 2023
95f8cec
Cleanup
GreyREvenson Aug 28, 2023
a251dab
Cleanup
GreyREvenson Aug 29, 2023
e3654d1
Giving namelist_type instance to all init subroutines for sake of con…
GreyREvenson Aug 29, 2023
5641a70
Give namelist_type instance to Init calls
GreyREvenson Aug 29, 2023
4ac6201
InitTransfer now private in all noahowp_type subtypes and is called w…
GreyREvenson Aug 31, 2023
7f29ff4
Revising noahowp_type subtype Init calls
GreyREvenson Aug 31, 2023
ee47505
Cleanup
GreyREvenson Sep 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

domain_type%InitTransfer was re-added to domain_type to transfer values for variables without spatial indices from argument instance of domaingrid_type to this instance of domain_type.


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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing transfer of variables that are now transferred in newly added domain_type%InitTransfer subroutine (see src/DomainType.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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing obsolete comment


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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

engery_type%InitTransfer was in this file prior to this PR but it was empty and not being called anywhere in the code base. I revised the subroutine to take energygrid_type instead of namelist_type in order to be consistent with the other InitTransfer subroutines bound to noahowp_type member derived data types. However, this subroutine still does nothing because no variables need to be transferred here.

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forcing_type%InitTransfer was re-added forcing_type to transfer variable values from forcinggrid_type to this instance of forcing_type -- specifically for variables that do not have spatial indices (i.e., forcinggrid_type%JULIAN and forcinggrid_type%YEARLEN)

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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Transfer-in for these variables has been moved to forcing_type%InitTransfer (see ForcingType.f90)

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-adding levels_type%InitTransfer to move values from argument instance of levelsgrid_type to this instance of levels_type.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These variables do not have spatial indices as defined in levelsgrid_type. Thus, they are now transferred via forcing_type%InitTransfer (see LevelsType.f90).

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make namelist_type a required argument for options_type%Init to be consistent across all Init subroutines bound to the noahowp_type's member derived data types.

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-adding options_type%InitTransfer to move variable values from optionsgrid_type to this instance of options_type for variables that do not have spatial indices as defined in optionsgrid_type.

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