Skip to content

Commit 7f50d02

Browse files
committed
Use integer mask in fabm_sediment
1 parent d056c9c commit 7f50d02

2 files changed

Lines changed: 19 additions & 19 deletions

File tree

src/components/fabm_sediment_component.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
!! MOSSCO sediment component.
55
!
66
! This computer program is part of MOSSCO.
7-
!> @copyright Copyright (C) 2021-2024 Helmholtz-Zentrum Hereon GmbH
7+
!> @copyright Copyright (C) 2021-2025 Helmholtz-Zentrum Hereon GmbH
88
!> @copyright Copyright (C) 2013-2021 Helmholtz-Zentrum Geesthacht GmbH
99
!> @author Carsten Lemmen <carsten.lemmen@hereon.de>
1010
!> @author Richard Hofmeister

src/drivers/fabm_sediment_driver.F90

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
!!
44
!! The driver contains the sediment driver module
55
! This computer program is part of MOSSCO.
6-
!> @copyright Copyright (C) 2021-2024 Helmholtz-Zentrum hereon GmbH
6+
!> @copyright Copyright (C) 2021-2025 Helmholtz-Zentrum hereon GmbH
77
!> @copyright Copyright (C) 2013-2021 Helmholtz-Zentrum Geesthacht
88
!> @author Carsten Lemmen <carsten.lemmen@hereon.de>
99
!> @author Richard Hofmeister
@@ -48,8 +48,8 @@ module fabm_sediment_driver
4848
integer :: knum,inum=-1,jnum=-1
4949
real(rk) :: dzmin
5050
logical :: use_ugrid=.false.
51-
logical, dimension(:,:,:), pointer :: mask => null()
52-
logical, dimension(:,:), pointer :: mask_hz => null()
51+
integer, dimension(:,:,:), pointer :: mask => null()
52+
integer, dimension(:,:), pointer :: mask_hz => null()
5353
integer :: type=LOCAL_GRID
5454
contains
5555
procedure :: init_grid
@@ -249,11 +249,11 @@ subroutine initialize(sed, unit)
249249

250250
if (.not.associated(sed%mask)) then
251251
allocate(sed%mask(sed%grid%inum,sed%grid%jnum,sed%grid%knum))
252-
sed%mask = .false.
252+
sed%mask = 0
253253
end if
254254
if (.not.associated(sed%grid%mask_hz)) then
255255
allocate(sed%grid%mask_hz(sed%grid%inum,sed%grid%jnum))
256-
sed%grid%mask_hz = .false.
256+
sed%grid%mask_hz = 0
257257
end if
258258
! add mask to grid
259259
sed%grid%mask => sed%mask
@@ -428,7 +428,7 @@ subroutine update_porosity(sed, from_surface, reinitialize_concentrations)
428428
end if
429429

430430
! set porosity to 1.0 in the mask to avoid overflows in get_rhs
431-
where(sed%mask) sed%porosity = 1.0d0
431+
where(sed%mask > 0) sed%porosity = 1.0d0
432432

433433
! update interface porosity
434434
sed%intf_porosity(:,:,1) = sed%porosity(:,:,1)
@@ -461,7 +461,7 @@ subroutine init_concentrations(sed)
461461
do j=1,sed%jnum
462462
do i=1,sed%inum
463463
!> @todo: check adaptive solver for -1.d20 or other negative missing values
464-
if (sed%mask(i,j,k)) sed%conc(i,j,k,:)=sed%missing_value
464+
if (sed%mask(i,j,k) > 0) sed%conc(i,j,k,:)=sed%missing_value
465465
end do
466466
end do
467467
end do
@@ -500,45 +500,45 @@ subroutine fabm_sed_check_domain(sed, rc)
500500
write(0,*) 'shape(cond)=',shape(sed%conc),' shape(mask)=', shape(sed%mask)
501501
#endif
502502

503-
if (any(.not.sed%mask.and.sed%porosity<=0)) then
503+
if (any(.not.(sed%mask > 0).and.sed%porosity<=0)) then
504504
write(0,*) 'FATAL sediment porosity <=0 '
505505
stop
506506
endif
507507

508-
if (any(.not.sed%mask.and.sed%porosity > 1)) then
508+
if (any(.not.(sed%mask > 0).and.sed%porosity > 1)) then
509509
write(0,*) 'FATAL sediment porosity > 1 '
510510
stop
511511
endif
512512

513-
if (any(.not.sed%mask(:,:,1:sed%knum-1).and..not.sed%mask(:,:,2:sed%knum) &
513+
if (any(.not.(sed%mask(:,:,1:sed%knum-1) > 0).and..not.(sed%mask(:,:,2:sed%knum) > 0) &
514514
.and.sed%grid%dzc <= 0)) then
515515
write(0,*) 'FATAL sediment central layer difference <= 0 '
516516
do k=1,sed%knum-1; do j=1,sed%jnum; do i=1,sed%inum
517-
if (.not.sed%mask(i,j,k).and..not.sed%mask(i,j,k+1).and.sed%grid%dzc(i,j,k) <= 0) &
517+
if (.not.(sed%mask(i,j,k)> 0).and..not.(sed%mask(i,j,k+1)>0).and.sed%grid%dzc(i,j,k) <= 0) &
518518
write(0,*) 'dz(i,j,k) ',i,j,k, sed%grid%dzc(i,j,k)
519519
enddo; enddo; enddo
520520
stop
521521
endif
522522

523-
if (any(.not.sed%mask.and.sed%grid%dz < sed%grid%dzmin)) then
523+
if (any(.not.(sed%mask>0).and.sed%grid%dz < sed%grid%dzmin)) then
524524
write(0,*) 'FATAL sediment layer height < minimum value ', sed%grid%dzmin
525525
do k=1,sed%knum; do j=1,sed%jnum; do i=1,sed%inum
526-
if (.not.sed%mask(i,j,k).and.sed%grid%dz(i,j,k) < sed%grid%dzmin) &
526+
if (.not.(sed%mask(i,j,k)>0).and.sed%grid%dz(i,j,k) < sed%grid%dzmin) &
527527
write(0,*) 'dz(i,j,k) ',i,j,k, sed%grid%dz(i,j,k)
528528
enddo; enddo; enddo
529529
stop
530530
endif
531531

532532
if (associated(sed%conc)) then
533533
do k=1,sed%knum; do j=1,sed%jnum; do i=1,sed%inum
534-
if (sed%mask(i,j,k)) then
534+
if (sed%mask(i,j,k)>0) then
535535
sed%conc(i,j,k,:)=1.d20
536536
endif
537537
enddo; enddo; enddo
538538
end if
539539

540540
! set porosity to 1.0 in the mask to avoid overflows in get_rhs
541-
where(sed%mask) sed%porosity = 1.0d0
541+
where(sed%mask > 0) sed%porosity = 1.0d0
542542

543543
if (present(rc)) rc=rc_
544544

@@ -598,7 +598,7 @@ subroutine get_rhs(rhs_driver, rhs)
598598
endif
599599
!write(0,*) shape(rhs_driver%mask(:,:,k)), shape(rhs_driver%temp3d(:,:,k))
600600
!write(0,*) shape(rhs_driver%bdys(:,:,1)), shape(rhs_driver%par(:,:,k))
601-
where (.not.rhs_driver%mask(:,:,k))
601+
where (.not.rhs_driver%mask(:,:,k) > 0)
602602
rhs_driver%temp3d(:,:,k) = rhs_driver%bdys(:,:,1)
603603
rhs_driver%par(:,:,k) = rhs_driver%par_surface * exp(-cumdepth/rhs_driver%k_par)
604604
end where
@@ -700,7 +700,7 @@ subroutine get_rhs(rhs_driver, rhs)
700700
call fabm_do(rhs_driver%model,1,rhs_driver%inum,j,k,rhs(:,j,k,:))
701701

702702
do i=1,rhs_driver%inum
703-
if (.not.rhs_driver%mask(i,j,k)) then
703+
if (.not.rhs_driver%mask(i,j,k) > 0) then
704704
!call fabm_do(rhs_driver%model,i,j,k,rhs(i,j,k,:))
705705
else
706706
! set transport to 0.0 - evtl. skip calculation of transport completely
@@ -772,7 +772,7 @@ subroutine diff3d (grid, C, Cup, Cdown, fluxup, fluxdown, &
772772
! positive flux is directed downward
773773
do j=1,grid%jnum
774774
do i=1,grid%inum
775-
if (.not.grid%mask(i,j,1)) then
775+
if (.not.grid%mask(i,j,1) > 0) then
776776
do k = 2,grid%knum
777777
Flux(i,j,k) = -D(i,j,k) * (C(i,j,k)-C(i,j,k-1)) /grid%dzc(i,j,k-1)
778778
end do

0 commit comments

Comments
 (0)