Skip to content

Commit

Permalink
Merge pull request #1 from billsacks/agsys
Browse files Browse the repository at this point in the history
Organize agsys into 3 subdirectories
  • Loading branch information
pengbinpeluo authored Oct 31, 2019
2 parents 0abc4cf + f0766d1 commit 0a88295
Show file tree
Hide file tree
Showing 13 changed files with 139 additions and 71 deletions.
4 changes: 3 additions & 1 deletion cime_config/buildlib
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ def _main_func():
os.path.join(lnd_root,"src","fates","biogeophys"),
os.path.join(lnd_root,"src","fates","biogeochem"),
os.path.join(lnd_root,"src","fates","fire"),
os.path.join(lnd_root,"src","agsys"),
os.path.join(lnd_root,"src","agsys","ctsm_interface"),
os.path.join(lnd_root,"src","agsys","ctsm_wrappers"),
os.path.join(lnd_root,"src","agsys","science"),
os.path.join(lnd_root,"src","utils"),
os.path.join(lnd_root,"src","cpl"),
os.path.join(lnd_root,"src","cpl",driver)]
Expand Down
51 changes: 0 additions & 51 deletions src/agsys/AgSysParams.F90

This file was deleted.

9 changes: 5 additions & 4 deletions src/agsys/AgSys.F90 → src/agsys/ctsm_interface/AgSys.F90
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ module AgSys
#include "shr_assert.h"
use clm_time_manager, only : is_beg_curr_day
use decompMod, only : bounds_type
use AgSysCommon, only : agsys_common_type
use AgSysGeneral, only : agsys_general_type
use AgSysParams, only : agsys_params_type
use AgSysParamReader, only : ReadParams
use AgSysClimate, only : agsys_climate_type
use AgSysPhenology, only : agsys_phenology_type
!
Expand All @@ -22,7 +23,7 @@ module AgSys

type, public :: agsys_type
private
type(agsys_common_type) :: agsys_common_inst
type(agsys_general_type) :: agsys_general_inst
type(agsys_params_type) :: agsys_params_inst
type(agsys_climate_type) :: agsys_climate_inst
type(agsys_phenology_type) :: agsys_phenology_inst
Expand Down Expand Up @@ -86,8 +87,8 @@ subroutine Init(this, bounds)
character(len=*), parameter :: subname = 'Init'
!-----------------------------------------------------------------------

call this%agsys_common_inst%Init(bounds)
call this%agsys_params_inst%Init()
call this%agsys_general_inst%Init(bounds)
call ReadParams(this%agsys_params_inst)
call this%agsys_climate_inst%Init(bounds)
call this%agsys_phenology_inst%Init(bounds)

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module AgSysCommon
module AgSysGeneral

!-----------------------------------------------------------------------
! !DESCRIPTION:
! Class containing data used by multiple other AgSys classes
! Class containing general data used by multiple other AgSys classes
!
! !USES:
#include "shr_assert.h"
Expand All @@ -15,19 +15,15 @@ module AgSysCommon

! !PUBLIC TYPES:

integer, parameter, public :: crop_type_maize = 1
integer, parameter, public :: crop_type_soybean = 2
integer, parameter, public :: crop_type_maxval = 2

type, public :: agsys_common_type
type, public :: agsys_general_type
private

! ------------------------------------------------------------------------
! Public data members, time-constant
! ------------------------------------------------------------------------

! AgSys's crop type: one of the crop_type_* constants defined above; note that these
! may differ from the constants in pftconMod
! AgSys's crop type: one of the crop_type_* constants defined in AgSysConstants; note
! that these may differ from the constants in pftconMod
integer, pointer, public :: crop_type_patch(:)

! Cultivar type. A given value implies a given crop type; for example, cultivar
Expand All @@ -52,7 +48,7 @@ module AgSysCommon
contains
procedure, public :: Init
procedure, private :: InitAllocate
end type agsys_common_type
end type agsys_general_type

character(len=*), parameter, private :: sourcefile = &
__FILE__
Expand All @@ -63,10 +59,10 @@ module AgSysCommon
subroutine Init(this, bounds)
!
! !DESCRIPTION:
! Initialize this agsys_common_type instance
! Initialize this agsys_general_type instance
!
! !ARGUMENTS:
class(agsys_common_type), intent(inout) :: this
class(agsys_general_type), intent(inout) :: this
type(bounds_type), intent(in) :: bounds
!
! !LOCAL VARIABLES:
Expand All @@ -81,10 +77,10 @@ end subroutine Init
subroutine InitAllocate(this, bounds)
!
! !DESCRIPTION:
! Allocate components of this agsys_common_type instance
! Allocate components of this agsys_general_type instance
!
! !ARGUMENTS:
class(agsys_common_type), intent(inout) :: this
class(agsys_general_type), intent(inout) :: this
type(bounds_type), intent(in) :: bounds
!
! !LOCAL VARIABLES:
Expand All @@ -105,4 +101,4 @@ subroutine InitAllocate(this, bounds)
end associate
end subroutine InitAllocate

end module AgSysCommon
end module AgSysGeneral
40 changes: 40 additions & 0 deletions src/agsys/ctsm_interface/AgSysParamReader.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
module AgSysParamReader

!-----------------------------------------------------------------------
! !DESCRIPTION:
! Routines for reading AgSys's time-constant parameters
!
! !USES:
#include "shr_assert.h"
use shr_kind_mod , only : r8 => shr_kind_r8
use shr_infnan_mod , only : nan => shr_infnan_nan, assignment(=)
use AgSysParams , only : agsys_params_type
!
implicit none
private

! !PUBLIC ROUTINES:
public :: ReadParams

character(len=*), parameter, private :: sourcefile = &
__FILE__

contains

!-----------------------------------------------------------------------
subroutine ReadParams(params)
!
! !DESCRIPTION:
! Read parameters
!
! !ARGUMENTS:
type(agsys_params_type), intent(inout) :: params
!
! !LOCAL VARIABLES:

character(len=*), parameter :: subname = 'ReadParams'
!-----------------------------------------------------------------------

end subroutine ReadParams

end module AgSysParamReader
File renamed without changes.
3 changes: 3 additions & 0 deletions src/agsys/ctsm_interface/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This directory contains modules that are specific to the CTSM
implementation of AgSys. Furthermore, CTSM should only interact with
AgSys via the modules here.
17 changes: 17 additions & 0 deletions src/agsys/ctsm_wrappers/AgSysKinds.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module AgSysKinds

!-----------------------------------------------------------------------
! !DESCRIPTION:
! Kind parameters needed by AgSys
!
! !USES:
use shr_kind_mod , only : r8 => shr_kind_r8
!
implicit none
private

! !PUBLIC DATA:

public :: r8 ! imported from shr_kind_mod

end module AgSysKinds
7 changes: 7 additions & 0 deletions src/agsys/ctsm_wrappers/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
The modules here provide wrappers to constants, variables and low-level
routines in CTSM that are used by the AgSys science code in order to
make it operate consistently with the rest of CTSM. If AgSys were
plugged in to a different land model, the code in this directory would
need to be replaced by alternatives that provided the same interface but
referenced constants, variables and routines that are available in the
given host model.
20 changes: 20 additions & 0 deletions src/agsys/science/AgSysConstants.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module AgSysConstants

!-----------------------------------------------------------------------
! !DESCRIPTION:
! Constants needed throughout AgSys
!
! !USES:

!
implicit none
private

! !PUBLIC DATA:

! Crop types
integer, parameter, public :: crop_type_maize = 1
integer, parameter, public :: crop_type_soybean = 2
integer, parameter, public :: crop_type_maxval = 2

end module AgSysConstants
26 changes: 26 additions & 0 deletions src/agsys/science/AgSysParams.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module AgSysParams

!-----------------------------------------------------------------------
! !DESCRIPTION:
! Derived type holding AgSys's time-constant parameters, defining various crops and
! cultivars
!
! Variables with suffix '_crop' are indexed by crop_type; variables with suffix
! '_cultivar' are indexed by cultivar.
!
! !USES:
use AgSysKinds, only : r8
!
implicit none
private

! !PUBLIC TYPES:
type, public :: agsys_params_type
private

! Public data members
real(r8), allocatable, public :: shoot_lag_cultivar(:)
real(r8), allocatable, public :: shoot_rate_cultivar(:)
end type agsys_params_type

end module AgSysParams
7 changes: 7 additions & 0 deletions src/agsys/science/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
This directory contains the science implementation of AgSys. Modules
here should not depend on CTSM data structures or routines, so that this
directory could be copied in its entirety into another land model. The
only dependencies should be on (1) other modules in this directory, and
(2) modules in the ctsm_wrappers subdirectory. The latter would be
replaced by a different set of wrappers if AgSys were imported into a
different land model.

0 comments on commit 0a88295

Please sign in to comment.