Skip to content

Commit

Permalink
adjust logic of equal interval grid spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
mattldawson committed Oct 27, 2023
1 parent bb0939d commit 5a40db5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/grids/equal_delta.F90
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,16 @@ function constructor( config ) result ( this )
call config%get( 'units', this%units_, Iam )

this%ncells_ = ( Upper_val - Lower_val ) / Delta_val
if( mod( ( Upper_val - Lower_val ), Delta_val ) /= 0._dk ) then
if( Upper_val - ( Lower_val + this%ncells_ * Delta_val ) &
> spacing( Lower_val + this%ncells_ * Delta_val ) ) then
this%ncells_ = this%ncells_ + 1
endif
allocate( this%mid_( this%ncells_ ) )
allocate( this%delta_( this%ncells_ ) )
allocate( this%edge_( this%ncells_ + 1 ) )
do n = 1, this%ncells_ + 1
this%edge_( n ) = &
min( real( ( n - 1 ), kind = dk ) * Delta_val + Lower_val, Upper_val )
min( Lower_val + ( n - 1 ) * Delta_val, Upper_val )
enddo
this%mid_(:) = .5_dk * &
( this%edge_( 1 : this%ncells_ ) + this%edge_( 2 : this%ncells_ + 1 ) )
Expand Down

0 comments on commit 5a40db5

Please sign in to comment.