-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiagnosticsMod.F90
68 lines (45 loc) · 1.88 KB
/
diagnosticsMod.F90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
module diagnostics
use global_mod
use types_mod
use utils_mod
implicit none
public
contains
subroutine diag_prodloss( GI, PL, RC )
! Receives a gas_instance object and sums up its P-L into
! a diagnostic pointer
implicit none
type(gas_instance), pointer, intent(in) :: GI(:) ! gas_instance object
real, pointer, intent(inout) :: PL(:,:,:) ! diagnostic pointer
integer, intent(out) :: RC ! return code
integer :: i
RC = 0 ! Assume success
PL = 0.e0
do i=1,size(GI)
PL = PL + (GI(i)%Prod - GI(i)%Loss)
enddo
return
end subroutine diag_prodloss
subroutine diag_sfcflux( SPC, FLX, RC )
implicit none
character(*), intent(in) :: spc
real, pointer, intent(inout) :: flx(:,:)
integer, intent(out) :: RC
integer :: ispc, idx, inst, i
logical :: is_actv, is_spc, has_mask ! Convenience vars
RC = 0 ! Assume success
ispc = ispecies(trim(SPC))
FLX = 0.e0
do i=1,size(sfc_flux)
inst = sfc_flux(i)%index ! Which associated instance?
is_spc = instances(inst)%p%ispecies == ispc ! Is this instance the right species?
if (.not. is_spc) cycle ! if not cycle
if (.not. associated(sfc_flux(i)%flux)) cycle ! The FLUX isn't associated. This is a failsafe
is_actv = instances(inst)%p%active ! Is it an active instance?
has_mask = instances(inst)%p%hasMask
! Currently only summing over active instances.
if ( has_mask .and. is_actv .and. is_spc) FLX = FLX + sfc_flux(i)%flux*instances(inst)%p%mask
if (.not. has_mask .and. is_actv .and. is_spc) FLX = FLX + sfc_flux(i)%flux
enddo
end subroutine diag_sfcflux
end module diagnostics