Soil Water Balance (SWB2)
Loading...
Searching...
No Matches
fog__monthly_grid.F90
Go to the documentation of this file.
1!> @file
2!! Contains the module \ref fog__monthly_grid.
3
4!>
5!! Module \ref fog__monthly_grid
6!! provides support for estimating fog drip given a gridded map
7!! of FOG_RATIO and FOG_CAPTURE_EFFICIENCY.
8
10
11 use iso_c_binding
13 use data_catalog
15 use dictionary
16 use exceptions
18 use logfiles, only : logs, log_all
19 use parameters, only : params
21 use fstring
22 use fstring_list
23
24 implicit none
25
26 private
27
29
31 real (c_float), allocatable :: ffog_catch_efficiency(:)
32
33contains
34
35 !> Initialize the fog drip algorithm.
36 !!
37 !! Read in a fog ratio grid.
38 !! Open a NetCDF output file to hold fog variable output.
39 !!
40 !! @param[in] lActive 2-D array of active cells within the model domain.
41 subroutine fog_monthly_grid_initialize( lActive )
42
43 logical (c_bool), intent(in) :: lactive(:,:)
44
45 ! [ LOCALS ]
46 integer (c_int) :: istat
47 type (fstring_list_t) :: slstring
48 integer (c_int) :: iindex
49 integer (c_int), allocatable :: ilandusecodes(:)
50 integer (c_int) :: inumberoflanduses
51 logical (c_bool) :: larelengthsequal
52
53 ! locate the data structure associated with the gridded fog ratio entries
54 pfog_ratio => dat%find("FOG_RATIO")
55 if ( .not. associated(pfog_ratio) ) &
56 call die("A FOG_RATIO grid must be supplied in order to make use of this option.", __file__, __line__)
57
58 !> Determine how many landuse codes are present
59 call slstring%append("LU_Code")
60 call slstring%append("Landuse_Code")
61
62 call params%get_parameters( slkeys=slstring, ivalues=ilandusecodes )
63 inumberoflanduses = count( ilandusecodes > 0 )
64
65 call slstring%clear()
66
67 call slstring%append("Fog_catch_eff")
68 call slstring%append("Fog_catch_efficiency")
69
70 call params%get_parameters( slkeys=slstring , fvalues=ffog_catch_efficiency )
71
72 if ( ffog_catch_efficiency(1) <= ftinyval ) &
73 call warn( "Failed to find a data column containing fog catch efficiency values.", lfatal=true, &
74 iloglevel=log_all )
75
76 larelengthsequal = ( ( ubound(ffog_catch_efficiency,1) == ubound(ilandusecodes,1) ) )
77
78 if ( .not. larelengthsequal ) &
79 call warn( smessage="The number of landuses does not match the number of fog catch efficiency values.", &
80 smodule=__file__, iline=__line__, lfatal=.true._c_bool )
81
82 end subroutine fog_monthly_grid_initialize
83
84!--------------------------------------------------------------------------------------------------
85
86 subroutine fog_monthly_grid_calculate( fRainfall, fFog, iLanduse_Index, lActive, nodata_fill_value )
87
88 real (c_float), intent(in) :: frainfall(:)
89 real (c_float), intent(inout) :: ffog(:)
90 integer (c_int), intent(in) :: ilanduse_index(:)
91 logical (c_bool), intent(in) :: lactive(:,:)
92 real (c_float), intent(in) :: nodata_fill_value(:,:)
93
94 ! [ LOCALS ]
95 integer (c_int) :: iindex
96 real (c_float) :: ffactor
97
98 associate( dt => sim_dt%curr )
99
100 if ( .not. associated(pfog_ratio) ) &
101 call die("INTERNAL PROGRAMMING ERROR: attempted use of NULL pointer", __file__, __line__)
102
103 if ( .not. allocated(pfog_ratio%pGrdBase%rData) ) &
104 call die("INTERNAL PROGRAMMING ERROR: attempted use of unallocated variable", __file__, __line__)
105
106 call pfog_ratio%getvalues( dt )
107
108 ffog = frainfall * pack( pfog_ratio%pGrdBase%rData, lactive ) &
109 * ffog_catch_efficiency( ilanduse_index )
110
111 end associate
112
113 end subroutine fog_monthly_grid_calculate
114
115end module fog__monthly_grid
This module contains physical constants and convenience functions aimed at performing unit conversion...
logical(c_bool), parameter, public true
Defines the DATA_CATALOG_T data type, which contains type-bound procedures to add,...
type(data_catalog_t), public dat
DAT is a global to hold data catalog entries.
subroutine, public warn(smessage, smodule, iline, shints, lfatal, iloglevel, lecho)
subroutine, public die(smessage, smodule, iline, shints, scalledby, icalledbyline)
Module fog__monthly_grid provides support for estimating fog drip given a gridded map of FOG_RATIO an...
real(c_float), dimension(:), allocatable ffog_catch_efficiency
subroutine, public fog_monthly_grid_initialize(lactive)
Initialize the fog drip algorithm.
type(data_catalog_entry_t), pointer, public pfog_ratio
subroutine, public fog_monthly_grid_calculate(frainfall, ffog, ilanduse_index, lactive, nodata_fill_value)
type(logfile_t), public logs
Definition logfiles.F90:62
type(parameters_t), public params
type(date_range_t), public sim_dt