diff --git a/include/standard_variable_assignments.h b/include/standard_variable_assignments.h index 1d44267a..e9140e4b 100644 --- a/include/standard_variable_assignments.h +++ b/include/standard_variable_assignments.h @@ -209,6 +209,14 @@ self%longitude%units = 'degree_east' self%longitude%cf_names = 'longitude' call add(self%longitude) +self%maximum_time_step%name = 'maximum_time_step' +self%maximum_time_step%units = 's' +call add(self%maximum_time_step) + +self%number_of_days_in_year%name = 'number_of_days_in_year' +self%number_of_days_in_year%units = 'd' +call add(self%number_of_days_in_year) + self%number_of_days_since_start_of_the_year%name = 'number_of_days_since_start_of_the_year' self%number_of_days_since_start_of_the_year%units = 'd' call add(self%number_of_days_since_start_of_the_year) diff --git a/include/standard_variables.h b/include/standard_variables.h index 3bddcd68..084bf54f 100644 --- a/include/standard_variables.h +++ b/include/standard_variables.h @@ -52,6 +52,8 @@ type (type_horizontal_standard_variable) :: latitude type (type_horizontal_standard_variable) :: longitude ! Global variables +type (type_global_standard_variable) :: maximum_time_step +type (type_global_standard_variable) :: number_of_days_in_year type (type_global_standard_variable) :: number_of_days_since_start_of_the_year ! Universal variables diff --git a/src/builtin/constant.F90 b/src/builtin/constant.F90 index 9b6105fc..e6e77de2 100644 --- a/src/builtin/constant.F90 +++ b/src/builtin/constant.F90 @@ -31,6 +31,11 @@ module fabm_builtin_constant procedure :: initialize => bottom_constant_initialize end type + type, extends(type_base_model), public :: type_global_constant + contains + procedure :: initialize => global_constant_initialize + end type + contains subroutine interior_constant_initialize(self, configunit) @@ -117,4 +122,25 @@ subroutine bottom_constant_initialize(self, configunit) end if end subroutine bottom_constant_initialize + subroutine global_constant_initialize(self, configunit) + class (type_global_constant), intent(inout), target :: self + integer, intent(in) :: configunit + + real(rk) :: value + type (type_global_standard_variable) :: standard_variable + + call self%register_implemented_routines() + call self%get_parameter(standard_variable%name, 'standard_name', '', 'standard name', default='') + call self%get_parameter(value, 'value', '', 'value') + if (standard_variable%name /= '') then + ! Note: for Cray 8.3.7, standard_variable needs to be declared separately. + ! It cannot be constructed on the fly within the function call + call self%add_scalar_variable('data', '', 'data', fill_value=value, & + output=output_none, source=source_constant, standard_variable=standard_variable) + else + call self%add_scalar_variable('data', '', 'data', fill_value=value, & + output=output_none, source=source_constant) + end if + end subroutine global_constant_initialize + end module diff --git a/src/builtin/model_library.F90 b/src/builtin/model_library.F90 index 2b53d456..2c548a57 100644 --- a/src/builtin/model_library.F90 +++ b/src/builtin/model_library.F90 @@ -67,6 +67,7 @@ subroutine create(self,name,model) case ('horizontal_constant'); allocate(type_horizontal_constant::model) case ('bottom_constant'); allocate(type_bottom_constant::model) case ('surface_constant'); allocate(type_surface_constant::model) + case ('global_constant'); allocate(type_global_constant::model) case ('surface_flux'); allocate(type_constant_surface_flux::model) case ('constant_surface_flux'); allocate(type_constant_surface_flux::model) case ('external_surface_flux'); allocate(type_external_surface_flux::model) diff --git a/src/fabm_job.F90 b/src/fabm_job.F90 index 4f4a1406..f5cd026a 100644 --- a/src/fabm_job.F90 +++ b/src/fabm_job.F90 @@ -1478,7 +1478,7 @@ subroutine job_manager_initialize(self, variable_register, schedules, log_unit, node => node%next end do - ! If we have unfulfilled dependneices, stop here and let the host/user deal with them. + ! If we have unfulfilled dependencies, stop here and let the host/user deal with them. if (associated(variable_register%unfulfilled_dependencies%first)) return variable_register%read_cache%frozen = .true. diff --git a/src/fabm_types.F90 b/src/fabm_types.F90 index 42cbc3da..bb56fe1c 100644 --- a/src/fabm_types.F90 +++ b/src/fabm_types.F90 @@ -2037,7 +2037,7 @@ subroutine add_horizontal_variable(self, name, units, long_name, missing_value, end subroutine add_horizontal_variable subroutine add_scalar_variable(self, name, units, long_name, missing_value, minimum, maximum, initial_value, & - background_value, fill_value, standard_variable, presence, output, & + background_value, fill_value, standard_variable, presence, output, source, & read_index, state_index, write_index, sms_index, background, link) class (type_base_model),target, intent(inout) :: self character(len=*), intent(in) :: name @@ -2045,7 +2045,7 @@ subroutine add_scalar_variable(self, name, units, long_name, missing_value, mini real(rk), intent(in), optional :: minimum, maximum, missing_value real(rk), intent(in), optional :: initial_value, background_value, fill_value class (type_base_standard_variable), intent(in), optional :: standard_variable - integer, intent(in), optional :: presence, output + integer, intent(in), optional :: presence, output, source integer, target, optional :: read_index, state_index, write_index, sms_index real(rk), target, optional :: background type (type_link), pointer, optional :: link @@ -2057,7 +2057,7 @@ subroutine add_scalar_variable(self, name, units, long_name, missing_value, mini ! Process remainder of fields and creation of link generically (i.e., irrespective of variable domain). call add_variable(self, variable, name, units, long_name, missing_value, minimum, maximum, & - initial_value, background_value, fill_value, standard_variable, presence, output, source_unknown, & + initial_value, background_value, fill_value, standard_variable, presence, output, source, & .false., read_index, state_index, write_index, background, link) end subroutine add_scalar_variable diff --git a/util/standard_variables/variables.yaml b/util/standard_variables/variables.yaml index 5ac6b57d..3119e12e 100644 --- a/util/standard_variables/variables.yaml +++ b/util/standard_variables/variables.yaml @@ -100,6 +100,10 @@ horizontal: global: - name: number_of_days_since_start_of_the_year units: d + - name: number_of_days_in_year + units: d + - name: maximum_time_step + units: s universal: - name: total_carbon units: mmol m-3