Skip to content

Commit aaae085

Browse files
committed
Merge branch 'master' of github.com:fabm-model/fabm into part_of_state
2 parents ad15b30 + e3b0f05 commit aaae085

File tree

5 files changed

+63
-21
lines changed

5 files changed

+63
-21
lines changed

.github/workflows/add-release-assets.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Set up Python
12-
uses: actions/setup-python@v5
12+
uses: actions/setup-python@v6
1313
- name: Python dependencies
1414
run: python -m pip install git-archive-all
1515
- name: Clone fabm-plus

.github/workflows/fabm.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
FFLAGS: -fcheck=all
3636
steps:
3737
- name: Set up Python
38-
uses: actions/setup-python@v5
38+
uses: actions/setup-python@v6
3939
with:
4040
python-version: ">=3.7"
4141
- name: Install Python dependencies
@@ -103,7 +103,7 @@ jobs:
103103
FFLAGS: -check all
104104
steps:
105105
- name: Set up Python
106-
uses: actions/setup-python@v5
106+
uses: actions/setup-python@v6
107107
with:
108108
python-version: ">=3.7"
109109
- name: Install Python dependencies
@@ -151,7 +151,7 @@ jobs:
151151
runs-on: ubuntu-latest
152152
steps:
153153
- name: Set up Python
154-
uses: actions/setup-python@v5
154+
uses: actions/setup-python@v6
155155
with:
156156
python-version: ">=3.7"
157157
- name: Install Python dependencies
@@ -200,7 +200,7 @@ jobs:
200200
FFLAGS: -Mbounds -Mchkptr
201201
steps:
202202
- name: Set up Python
203-
uses: actions/setup-python@v5
203+
uses: actions/setup-python@v6
204204
with:
205205
python-version: ">=3.7"
206206
- name: Install Python dependencies
@@ -251,7 +251,7 @@ jobs:
251251
runs-on: ubuntu-latest
252252
steps:
253253
- name: Set up Python
254-
uses: actions/setup-python@v5
254+
uses: actions/setup-python@v6
255255
with:
256256
python-version: ">=3.7"
257257
- name: Install Python dependencies
@@ -446,3 +446,13 @@ jobs:
446446
run: .binder/postBuild
447447
env:
448448
REPO_DIR: .
449+
single_prec:
450+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
451+
runs-on: ubuntu-latest
452+
steps:
453+
- name: Clone FABM
454+
uses: actions/checkout@v5
455+
- name: Build
456+
run: |
457+
cmake -S . -B build -DFABM_REAL_KIND='SELECTED_REAL_KIND(6)'
458+
cmake --build build --target install

src/fabm_config.F90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module fabm_config
77
use fabm_schedule
88

99
use yaml_settings
10+
use yaml_types, only: yaml_rk => real_kind
1011

1112
implicit none
1213

@@ -133,7 +134,7 @@ recursive subroutine create_instance(self, pair)
133134
do while (associated(link))
134135
if (index(link%name, '/') == 0 .and. link%target%source == source_state .and. link%target%presence == presence_internal) then
135136
realvalue = subsettings%get_real(trim(link%name), trim(link%target%long_name), trim(link%target%units), &
136-
default=link%target%background_values%value, display=display_advanced)
137+
default=real(link%target%background_values%value, yaml_rk), display=display_advanced)
137138
call link%target%background_values%set_value(realvalue)
138139
end if
139140
link => link%next

src/fabm_coupling.F90

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ module fabm_coupling
22
use fabm_types
33
use fabm_builtin_sum
44
use fabm_driver
5-
use yaml_settings, only: default_minimum_real, default_maximum_real
5+
6+
use yaml_settings, only: yaml_default_minimum_real=>default_minimum_real, yaml_default_maximum_real=>default_maximum_real
7+
use yaml_types, only: yaml_rk => real_kind
68

79
implicit none
810

@@ -111,24 +113,24 @@ recursive subroutine get_initial_state(self, require_initialization)
111113
logical, intent(in) :: require_initialization
112114

113115
type (type_link), pointer :: link
114-
real(rk) :: minimum
115-
real(rk) :: maximum
116+
real(yaml_rk) :: minimum
117+
real(yaml_rk) :: maximum
116118
type (type_model_list_node), pointer :: node
117119

118120
! Transfer user-specified initial state to the model.
119121
link => self%links%first
120122
do while (associated(link))
121-
minimum = default_minimum_real
122-
maximum = default_maximum_real
123+
minimum = yaml_default_minimum_real
124+
maximum = yaml_default_maximum_real
123125
if (link%target%minimum /= -1.e20_rk) minimum = link%target%minimum
124126
if (link%target%maximum /= 1.e20_rk) maximum = link%target%maximum
125127
if (index(link%name, '/') == 0 .and. link%target%source == source_state .and. link%target%presence == presence_internal) then
126128
if (require_initialization) then
127-
call self%initialization%get(link%target%initial_value, trim(link%name), trim(link%target%long_name), &
129+
link%target%initial_value = self%initialization%get_real(trim(link%name), trim(link%target%long_name), &
128130
trim(link%target%units), minimum=minimum, maximum=maximum)
129131
else
130-
call self%initialization%get(link%target%initial_value, trim(link%name), trim(link%target%long_name), &
131-
trim(link%target%units), minimum=minimum, maximum=maximum, default=link%target%initial_value)
132+
link%target%initial_value = self%initialization%get_real(trim(link%name), trim(link%target%long_name), &
133+
trim(link%target%units), minimum=minimum, maximum=maximum, default=real(link%target%initial_value, yaml_rk))
132134
end if
133135
end if
134136
link => link%next

src/fabm_types.F90

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ module fabm_types
1717
type_universal_standard_variable => type_universal_standard_variable
1818
use fabm_properties
1919
use fabm_driver, only: driver
20-
use yaml_settings
20+
21+
use yaml_settings, yaml_default_minimum_real => default_minimum_real, yaml_default_maximum_real => default_maximum_real
22+
use yaml_types, only: yaml_rk => real_kind
2123

2224
implicit none
2325

@@ -516,10 +518,11 @@ module fabm_types
516518

517519
! Procedures that may be used to query parameter values during initialization.
518520
procedure :: get_real_parameter
521+
procedure :: get_double_parameter
519522
procedure :: get_integer_parameter
520523
procedure :: get_logical_parameter
521524
procedure :: get_string_parameter
522-
generic :: get_parameter => get_real_parameter, get_integer_parameter, get_logical_parameter, get_string_parameter
525+
generic :: get_parameter => get_real_parameter,get_double_parameter,get_integer_parameter,get_logical_parameter,get_string_parameter
523526

524527
procedure :: set_variable_property_real
525528
procedure :: set_variable_property_integer
@@ -2611,10 +2614,36 @@ function get_effective_display(display, user_created) result(display_)
26112614

26122615
subroutine get_real_parameter(self, value, name, units, long_name, default, scale_factor, minimum, maximum, display)
26132616
class (type_base_model), intent(inout), target :: self
2614-
real(rk), intent(inout), target :: value
2617+
real(kind(1.0e0)), intent(inout), target :: value
26152618
character(len=*), intent(in) :: name
26162619
character(len=*), intent(in), optional :: units, long_name
2617-
real(rk), intent(in), optional :: default, scale_factor, minimum, maximum
2620+
real(kind(1.0e0)), intent(in), optional :: default, scale_factor, minimum, maximum
2621+
integer, intent(in), optional :: display
2622+
2623+
real(yaml_rk) :: scale_factor_, minimum_, maximum_
2624+
2625+
minimum_ = yaml_default_minimum_real
2626+
maximum_ = yaml_default_maximum_real
2627+
scale_factor_ = 1.0_yaml_rk
2628+
if (present(minimum)) minimum_ = minimum
2629+
if (present(maximum)) maximum_ = maximum
2630+
if (present(scale_factor)) scale_factor_ = scale_factor
2631+
2632+
if (present(default)) then
2633+
value = self%parameters%get_real(name, get_effective_string(long_name, name), get_effective_string(units, ''), &
2634+
default=real(default, yaml_rk), minimum=minimum_, maximum=maximum_, scale_factor=scale_factor_, display=get_effective_display(display, self%user_created))
2635+
else
2636+
value = self%parameters%get_real(name, get_effective_string(long_name, name), get_effective_string(units, ''), &
2637+
minimum=minimum_, maximum=maximum_, scale_factor=scale_factor_, display=get_effective_display(display, self%user_created))
2638+
end if
2639+
end subroutine get_real_parameter
2640+
2641+
subroutine get_double_parameter(self, value, name, units, long_name, default, scale_factor, minimum, maximum, display)
2642+
class (type_base_model), intent(inout), target :: self
2643+
real(kind(1.0d0)), intent(inout), target :: value
2644+
character(len=*), intent(in) :: name
2645+
character(len=*), intent(in), optional :: units, long_name
2646+
real(kind(1.0d0)), intent(in), optional :: default, scale_factor, minimum, maximum
26182647
integer, intent(in), optional :: display
26192648

26202649
if (fabm_parameter_pointers) then
@@ -2624,7 +2653,7 @@ subroutine get_real_parameter(self, value, name, units, long_name, default, scal
26242653
value = self%parameters%get_real(name, get_effective_string(long_name, name), get_effective_string(units, ''), &
26252654
default, minimum, maximum, scale_factor, display=get_effective_display(display, self%user_created))
26262655
end if
2627-
end subroutine get_real_parameter
2656+
end subroutine get_double_parameter
26282657

26292658
subroutine get_integer_parameter(self, value, name, units, long_name, default, minimum, maximum, options, display)
26302659
class (type_base_model), intent(inout), target :: self
@@ -3260,7 +3289,7 @@ subroutine settings_set_real(self, key, value)
32603289

32613290
real(rk) :: final_value
32623291

3263-
final_value = self%get_real(key, key, '', default=value)
3292+
final_value = self%get_real(key, key, '', default=real(value, yaml_rk))
32643293
end subroutine settings_set_real
32653294

32663295
subroutine settings_set_integer(self, key, value)

0 commit comments

Comments
 (0)