Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Still doesn't compile. Replaced 'list' files with 'array', and removed io_write_age and io_write_age_depth as they're not called
  • Loading branch information
Austin Blevins committed Nov 30, 2022
1 parent 902c8da commit 7e24e21
Show file tree
Hide file tree
Showing 13 changed files with 584 additions and 251 deletions.
537 changes: 349 additions & 188 deletions config/depcomp

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ util/util_area_intersection.f90\
util/util_poisson.f90\
util/util_pop_array.f90\
util/util_push_array.f90\
util/util_traverse_pop.f90\
util/util_traverse_pop_array.f90\
util/util_destroy_list.f90\
util/util_init_list.f90\
util/util_init_array.f90\
util/util_perlin_noise.f90\
io/io_read_const.f90\
io/io_get_token.f90\
Expand All @@ -60,9 +60,7 @@ io/io_crater_profile.f90\
io/io_updatePbar.f90\
io/io_resetPbar.f90\
io/io_splash.f90\
io/io_write_age.f90\
io/io_write_pindex_map.f90\
io/io_write_age_depth.f90\
ejecta/ejecta_emplace.f90\
ejecta/ejecta_ray_pattern.f90\
ejecta/ejecta_ray_pattern_func.f90\
Expand Down
17 changes: 10 additions & 7 deletions src/io/io_write_age.f90
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ subroutine io_write_age(user,surf,n_size,icrater,ncrat)
integer(kind=8) :: recsize
real(SP) :: stmp
real(SP) :: agetot, age_weighted
type(regolisttype),pointer :: current => null()
!type(regolisttype),pointer :: current => null()
type(regodatatype),dimension(:),allocatable :: current
real(DP) :: depth, depth_prev
real(SP) :: recyclratio
! Output multiple "comphisto" files
Expand All @@ -55,8 +56,10 @@ subroutine io_write_age(user,surf,n_size,icrater,ncrat)

depth = 0.0
depth_prev = 0.0
current => surf(i,j)%regolayer
age_prev(:) = current%regodata%age(:)
!current => surf(i,j)%regolayer
!current = surf(i,j)%regolayer(:)
allocate(current,source=surf(i,j)%regolayer(:))
age_prev(:) = current%age(:)
agedepthtot = 0.0_SP
do
if (depth > sdepth) then
Expand All @@ -66,10 +69,10 @@ subroutine io_write_age(user,surf,n_size,icrater,ncrat)
exit
end if
depth_prev = depth
depth = depth + current%regodata%thickness
agedepthtot(:) = agedepthtot(:) + current%regodata%age(:)
age_prev(:) = current%regodata%age(:)
current => current%next
depth = depth + current%thickness
agedepthtot(:) = agedepthtot(:) + current%age(:)
age_prev(:) = current%age(:)
!current => current%next
end do

age_weighted = 0.0_SP
Expand Down
8 changes: 4 additions & 4 deletions src/io/io_write_regotrack.f90
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ subroutine io_write_regotrack(user,surf)
! comp(k) = current%regodata%comp
! age(:,k) = current%regodata%age(:)
! current => current%next
meltfrac(k) = current%meltfrac
thickness(k) = current%thickness
comp(k) = current%comp
age(:,k) = current%age(:)
meltfrac(k) = current(k)%meltfrac
thickness(k) = current(k)%thickness
comp(k) = current(k)%comp
age(:,k) = current(k)%age(:)

end do
write(FMELT) meltfrac(:)
Expand Down
2 changes: 1 addition & 1 deletion src/regolith/module_regolith.f90
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ subroutine regolith_superdomain(user,crater,domain,regolayer,ejdistribution,xpi,
type(usertype),intent(in) :: user
type(cratertype),intent(inout) :: crater
type(domaintype),intent(in) :: domain
type(regolisttype),pointer :: regolayer
type(regodatatype),dimension(:),allocatable,intent(inout) :: regolayer
real(DP),intent(in) :: ejdistribution
integer(I4B),intent(in) :: xpi, ypi
real(DP),intent(in) :: age
Expand Down
33 changes: 18 additions & 15 deletions src/regolith/regolith_streamtube_head.f90
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ subroutine regolith_streamtube_head(user,surfi,deltar,totmare,tots,age_collector
real(SP),dimension(:),intent(inout) :: age_collector

! internal variables
type(regolisttype),pointer :: current
!type(regolisttype),pointer :: current
type(regodatatype),dimension(:),allocatable :: current
real(DP),parameter :: vratio = sqrt(2.0_DP)/2.0_DP ! Unfortunately, the approximate function that is used to get the size of a stream
! tube with a constraint of CTEM's ejecta blanket thickness is slightly different
! from the analytical function that we use here to approximate the stream tube's
Expand All @@ -41,8 +42,10 @@ subroutine regolith_streamtube_head(user,surfi,deltar,totmare,tots,age_collector
! melt collector
real(DP) :: recyratio

current => surfi%regolayer
z = current%regodata%thickness
!current => surfi%regolayer
!current = surfi%regolayer
allocate(current,source=surfi%regolayer)
z = current%thickness
vsgly = vratio * PI * deltar**3
tothead = 0._DP
totmarehead = 0._DP
Expand All @@ -55,29 +58,29 @@ subroutine regolith_streamtube_head(user,surfi,deltar,totmare,tots,age_collector

if (zend >= zmax) then ! Stream tube's head is inside the 1st layer.
tots = tots + vsgly
totmare = totmare + vsgly * current%regodata%comp
recyratio = vsgly / (user%pix**2) /current%regodata%thickness
age_collector(:) = age_collector(:) + current%regodata%age(:) * recyratio
totmare = totmare + vsgly * current%comp
recyratio = vsgly / (user%pix**2) /current%thickness
age_collector(:) = age_collector(:) + current%age(:) * recyratio
else ! head is not intersected with layers.

do
if (.not. associated(current%next)) exit
! if (.not. associated(current%next)) exit

if (zend < zmax) then
vhead = regolith_circle_sector_func(deltar,zstart,zend)
tothead = tothead + vhead * vratio
totmarehead = totmarehead + vhead * vratio * current%regodata%comp
recyratio = vhead * vratio / (user%pix**2) / current%regodata%thickness
age_collector(:) = age_collector(:) + current%regodata%age(:) * recyratio
current => current%next
z = z + current%regodata%thickness
totmarehead = totmarehead + vhead * vratio * current%comp
recyratio = vhead * vratio / (user%pix**2) / current%thickness
age_collector(:) = age_collector(:) + current%age(:) * recyratio
!current => current%next
z = z + current%thickness
zstart = zend
zend = z
else
totmarehead = totmarehead + (vsgly-tothead) * current%regodata%comp
totmarehead = totmarehead + (vsgly-tothead) * current%comp
tothead = vsgly
recyratio = (vsgly - tothead) / (user%pix**2) / current%regodata%thickness
age_collector(:) = age_collector(:) + current%regodata%age(:) * recyratio
recyratio = (vsgly - tothead) / (user%pix**2) / current%thickness
age_collector(:) = age_collector(:) + current%age(:) * recyratio
exit
end if
end do
Expand Down
2 changes: 1 addition & 1 deletion src/regolith/regolith_superdomain.f90
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ subroutine regolith_superdomain(user,crater,domain,regolayer,ejdistribution,xpi,
type(usertype),intent(in) :: user
type(cratertype),intent(inout) :: crater
type(domaintype),intent(in) :: domain
type(regolisttype),pointer :: regolayer
type(regodatatype),dimension(:),allocatable,intent(inout) :: regolayer
real(DP),intent(in) :: ejdistribution
integer(I4B),intent(in) :: xpi, ypi
real(DP),intent(in) :: age
Expand Down
44 changes: 32 additions & 12 deletions src/util/module_util.f90
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ module module_util
subroutine util_push_array(regolayer,newregodata)
use module_globals
implicit none
type(regodatatype),dimension(:),allocatable :: regolayer
type(regodatatype),dimension(:),allocatable,intent(in) :: newregodata
type(regodatatype),dimension(:),allocatable,intent(inout) :: regolayer
type(regodatatype),intent(in) :: newregodata
end subroutine util_push_array
end interface

interface
subroutine util_pop_array(regolayer,oldregodata)
use module_globals
implicit none
type(regodatatype),dimension(:),allocatable :: regolayer
type(regodatatype),dimension(:),allocatable,intent(inout) :: regolayer
type(regodatatype),intent(out) :: oldregodata
end subroutine util_pop_array
end interface
Expand All @@ -70,15 +70,26 @@ end subroutine util_pop_array
! end subroutine util_pop
! end interface

! interface
! subroutine util_traverse_pop(regolayer,traverse_depth,poppedlist)
! use module_globals
! implicit none
! !type(regolisttype),pointer :: regolayer
! type(regodatatype),dimension(:),allocatable,intent(inout) :: regolayer
! real(DP),intent(in) :: traverse_depth
! !type(regolisttype),pointer :: poppedlist
! !type(regodatatype),dimension(:),allocatable,intent(out) :: poppedarray
! end subroutine
! end interface

interface
subroutine util_traverse_pop(regolayer,traverse_depth,poppedlist)
subroutine util_traverse_pop_array(regolayer,traverse_depth,poppedarray)
use module_globals
implicit none
!type(regolisttype),pointer :: regolayer
type(regodatatype),dimension(:),allocatable :: regolayer
real(DP),intent(in) :: traverse_depth
type(regolisttype),pointer :: poppedlist
end subroutine
type(regodatatype),dimension(:),allocatable,intent(inout) :: regolayer
real(DP),intent(in) :: traverse_depth
type(regodatatype),dimension(:),allocatable,intent(out) :: poppedarray
end subroutine
end interface

interface
Expand All @@ -89,13 +100,22 @@ subroutine util_destroy_list(regolayer)
end subroutine util_destroy_list
end interface

! interface
! subroutine util_init_list(regolayer,initstat)
! use module_globals
! implicit none
! type(regolisttype),pointer :: regolayer
! logical, intent(out) :: initstat
! end subroutine util_init_list
! end interface

interface
subroutine util_init_list(regolayer,initstat)
subroutine util_init_array(regolayer,initstat)
use module_globals
implicit none
type(regolisttype),pointer :: regolayer
type(regodatatype),dimension(:),allocatable,intent(inout) :: regolayer
logical, intent(out) :: initstat
end subroutine util_init_list
end subroutine util_init_array
end interface

interface
Expand Down
61 changes: 61 additions & 0 deletions src/util/util_init_array.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
!**********************************************************************************************************************************
!
! Unit Name : util_init_array
! Unit Type : subroutine
! Project : CTEM
! Language : Fortran 2003
!
! Description : Initialize an new allocatable array
!
!
! Input
! Arguments : regolayer :: array
! oldlayer :: old layer to pop off of the top of the stack
!
! Output
! Arguments :
!
!
! Notes :
!
!**********************************************************************************************************************************
subroutine util_init_array(regolayer,initstat)
use module_globals
use module_util, EXCEPT_THIS_ONE => util_init_array
implicit none

! Arguments
type(regodatatype),dimension(:),allocatable,intent(inout) :: regolayer
logical, intent(out) :: initstat

! Internal variables
integer(I4B) :: allocstat

! Executable code
initstat = .false.
! if (.not. associated(regolayer)) then
! allocate(regolayer, STAT=allocstat)
! if (allocstat == 0) then
! initstat = .true.
! nullify(regolayer%next)
! regolayer%regodata%thickness = sqrt(VBIG) ! This generates a buffer layer that the model should never reach if the run is structured properly
! regolayer%regodata%comp = 0.0_DP
! regolayer%regodata%meltfrac = 0.0_DP
! regolayer%regodata%porosity = 0.0_DP
! regolayer%regodata%age(:) = 0.0_SP
if (allocated(regolayer)) deallocate(regolayer)
allocate(regolayer(1))
regolayer(1)%thickness = sqrt(VBIG) ! This generates a buffer layer that the model should never reach if the run is structured properly
regolayer(1)%comp = 0.0_DP
regolayer(1)%meltfrac = 0.0_DP
regolayer(1)%porosity = 0.0_DP
regolayer(1)%age(:) = 0.0_SP
! else
! write(*,*) 'util_init_list: Initialization failed. Exhausted memory.'
! end if
! else
! write(*,*) 'util_init_list: Initialization failed. Regolayer already associated.'
! end if

return
end subroutine util_init_array
8 changes: 4 additions & 4 deletions src/util/util_pop_array.f90
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ subroutine util_pop_array(regolayer,oldregodata)
implicit none

! Arguments
type(regodatatype),dimension(:),allocatable :: regolayer
type(regodatatype),dimension(:),allocatable,intent(inout) :: regolayer
type(regodatatype),intent(out) :: oldregodata

! Internal variables
type(regodatatype), dimension(:), allocatable :: newlayer
integer(I4B) :: allocstat
integer(I4B) :: nold

! Executable code

nold = size(regolayer)

allocate(newlayer(nold-1), stat=allocstat)
newlayer(1:nold-1) = regolayer(1:nold-1) ! could also be 2:nold depending on if top or bottom is popped off
allocate(newlayer(nold-1),source=regolayer(1:nold-1))
!newlayer(1:nold-1) = regolayer(1:nold-1) ! could also be 2:nold depending on if top or bottom is popped off
oldregodata = regolayer(nold)
call move_alloc(newlayer, regolayer)
end subroutine util_pop_array
9 changes: 4 additions & 5 deletions src/util/util_push_array.f90
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,20 @@ subroutine util_push_array(regolayer,newregodata)
implicit none

! Arguments
type(regodatatype),dimension(:),allocatable :: regolayer
type(regodatatype),dimension(:),allocatable :: newregodata
type(regodatatype),dimension(:),allocatable,intent(inout) :: regolayer
type(regodatatype),intent(in) :: newregodata

! Internal variables
type(regodatatype), dimension(:), allocatable :: newlayer
integer(I4B) :: allocstat
integer(I4B) :: nold

! Executable code

nold = size(regolayer)

allocate(newregodata(nold+1), stat=allocstat)
allocate(newlayer(nold+1))
newlayer(1:nold) = regolayer(1:nold)
newlayer(nold+1) = newregodata(:) ! need to see if this adds to the top or bottom of the layer stack
newlayer(nold+1) = newregodata ! need to see if this adds to the top or bottom of the layer stack
call move_alloc(newlayer, regolayer)
end subroutine util_push_array

Expand Down
Loading

0 comments on commit 7e24e21

Please sign in to comment.