Skip to content

Commit b6b3a86

Browse files
authored
Merge pull request #286 from rgknox/rgknox-threadfix
bug fixes to multi-threading
2 parents ec63421 + 4f6a342 commit b6b3a86

File tree

3 files changed

+13
-17
lines changed

3 files changed

+13
-17
lines changed

main/FatesHistoryInterfaceMod.F90

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -870,20 +870,17 @@ subroutine flush_hvars(this,nc,upfreq_in)
870870
class(fates_history_interface_type) :: this
871871
integer,intent(in) :: nc
872872
integer,intent(in) :: upfreq_in
873-
874873
integer :: ivar
875-
type(fates_history_variable_type),pointer :: hvar
876874
integer :: lb1,ub1,lb2,ub2
877875

878876
do ivar=1,ubound(this%hvars,1)
879-
associate( hvar => this%hvars(ivar) )
880-
if (hvar%upfreq == upfreq_in) then ! Only flush variables with update on dynamics step
881-
call hvar%Flush(nc, this%dim_bounds, this%dim_kinds)
882-
end if
883-
end associate
877+
if (this%hvars(ivar)%upfreq == upfreq_in) then ! Only flush variables with update on dynamics step
878+
call this%hvars(ivar)%flush(nc, this%dim_bounds, this%dim_kinds)
879+
880+
end if
884881
end do
885882

886-
end subroutine flush_hvars
883+
end subroutine flush_hvars
887884

888885

889886
! =====================================================================================
@@ -916,7 +913,6 @@ subroutine set_history_var(this, vname, units, long, use_default, avgflag, vtype
916913
! not used
917914

918915
! locals
919-
type(fates_history_variable_type), pointer :: hvar
920916
integer :: ub1, lb1, ub2, lb2 ! Bounds for allocating the var
921917
integer :: ityp
922918

@@ -1111,7 +1107,7 @@ subroutine update_history_dyn(this,nc,nsites,sites)
11111107
use EDTypesMod , only : nlevleaf
11121108

11131109
! Arguments
1114-
class(fates_history_interface_type) :: this
1110+
class(fates_history_interface_type) :: this
11151111
integer , intent(in) :: nc ! clump index
11161112
integer , intent(in) :: nsites
11171113
type(ed_site_type) , intent(inout), target :: sites(nsites)
@@ -1136,7 +1132,6 @@ subroutine update_history_dyn(this,nc,nsites,sites)
11361132
real(r8) :: patch_scaling_scalar ! ratio of canopy to patch area for counteracting patch scaling
11371133
real(r8) :: dbh ! diameter ("at breast height")
11381134

1139-
type(fates_history_variable_type),pointer :: hvar
11401135
type(ed_patch_type),pointer :: cpatch
11411136
type(ed_cohort_type),pointer :: ccohort
11421137

@@ -1895,7 +1890,6 @@ subroutine update_history_prod(this,nc,nsites,sites,dt_tstep)
18951890
real(r8), parameter :: tiny = 1.e-5_r8 ! some small number
18961891
integer :: ipa2 ! patch incrementer
18971892
integer :: cnlfpft_indx, cnlf_indx, ipft, ican, ileaf ! more iterators and indices
1898-
type(fates_history_variable_type),pointer :: hvar
18991893
type(ed_patch_type),pointer :: cpatch
19001894
type(ed_cohort_type),pointer :: ccohort
19011895
real(r8) :: per_dt_tstep ! Time step in frequency units (/s)
@@ -2253,7 +2247,6 @@ subroutine update_history_hydraulics(this,nc,nsites,sites,dt_tstep)
22532247
integer :: ipa2 ! patch incrementer
22542248
integer :: iscpf ! index of the scpf group
22552249

2256-
type(fates_history_variable_type),pointer :: hvar
22572250
type(ed_patch_type),pointer :: cpatch
22582251
type(ed_cohort_type),pointer :: ccohort
22592252
type(ed_cohort_hydr_type), pointer :: ccohort_hydr

main/FatesHistoryVariableType.F90

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ subroutine Init(this, vname, units, long, use_default, &
8989
call dim_kinds(dk_index)%set_active()
9090

9191
call this%GetBounds(0, dim_bounds, dim_kinds, lb1, ub1, lb2, ub2)
92-
92+
9393
! NOTE(rgk, 2016-09) currently, all array spaces are flushed each
9494
! time the update is called. The flush here on the initialization
9595
! may be redundant, but will prevent issues in the future if we
@@ -167,7 +167,7 @@ subroutine Init(this, vname, units, long, use_default, &
167167
end subroutine Init
168168

169169
! =====================================================================================
170-
170+
171171
subroutine GetBounds(this, thread, dim_bounds, dim_kinds, lb1, ub1, lb2, ub2)
172172

173173
use FatesIODimensionsMod, only : fates_io_dimension_type
@@ -176,7 +176,7 @@ subroutine GetBounds(this, thread, dim_bounds, dim_kinds, lb1, ub1, lb2, ub2)
176176

177177
class(fates_history_variable_type), intent(inout) :: this
178178
integer, intent(in) :: thread
179-
class(fates_io_dimension_type), intent(in) :: dim_bounds(:)
179+
type(fates_io_dimension_type), intent(in) :: dim_bounds(:)
180180
type(fates_io_variable_kind_type), intent(in) :: dim_kinds(:)
181181
integer, intent(out) :: lb1
182182
integer, intent(out) :: ub1
@@ -205,14 +205,17 @@ subroutine GetBounds(this, thread, dim_bounds, dim_kinds, lb1, ub1, lb2, ub2)
205205
ub2 = dim_bounds(d_index)%upper_bound
206206
end if
207207
else
208+
208209
d_index = dim_kinds(this%dim_kinds_index)%dim1_index
209210
lb1 = dim_bounds(d_index)%clump_lower_bound(thread)
210211
ub1 = dim_bounds(d_index)%clump_upper_bound(thread)
212+
211213
if(ndims>1)then
212214
d_index = dim_kinds(this%dim_kinds_index)%dim2_index
213215
lb2 = dim_bounds(d_index)%clump_lower_bound(thread)
214216
ub2 = dim_bounds(d_index)%clump_upper_bound(thread)
215217
end if
218+
216219
end if
217220

218221
end subroutine GetBounds

main/FatesRestartVariableType.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ subroutine GetBounds(this, thread, dim_bounds, dim_kinds, lb1, ub1, lb2, ub2)
118118

119119
class(fates_restart_variable_type), intent(inout) :: this
120120
integer, intent(in) :: thread
121-
class(fates_io_dimension_type), intent(in) :: dim_bounds(:)
121+
type(fates_io_dimension_type), intent(in) :: dim_bounds(:)
122122
type(fates_io_variable_kind_type), intent(in) :: dim_kinds(:)
123123
integer, intent(out) :: lb1
124124
integer, intent(out) :: ub1

0 commit comments

Comments
 (0)