From 2b1349d7ff17e65cb2d3fbd85a07b857309cd90c Mon Sep 17 00:00:00 2001 From: Evgeny Mortikov <evgeny.mortikov@gmail.com> Date: Sun, 22 Sep 2024 04:04:03 +0300 Subject: [PATCH] adding surface definitions --- srcF/sfx_config.f90 | 14 +++++++++----- srcF/sfx_main.f90 | 1 - srcF/sfx_run.f90 | 4 ++-- srcF/sfx_surface.f90 | 44 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 8 deletions(-) diff --git a/srcF/sfx_config.f90 b/srcF/sfx_config.f90 index 5933c53..99f7b22 100644 --- a/srcF/sfx_config.f90 +++ b/srcF/sfx_config.f90 @@ -17,8 +17,8 @@ module sfx_config !> @brief model enum def. integer, parameter :: model_esm = 0 !< ESM model integer, parameter :: model_log = 1 !< LOG simplified model - integer, parameter :: model_most = 2 !< MOST simplified model - integer, parameter :: model_sheba = 3 !< SHEBA simplified model + integer, parameter :: model_most = 2 !< MOST model + integer, parameter :: model_sheba = 3 !< SHEBA model character(len = 16), parameter :: model_esm_tag = 'esm' character(len = 16), parameter :: model_log_tag = 'log' @@ -47,7 +47,7 @@ module sfx_config character(len = 256) :: filename integer :: nmax - integer :: surface_type + integer :: surface real :: h, z0_m, z0_h end type @@ -139,6 +139,7 @@ contains end function subroutine set_dataset(dataset, id) + use sfx_surface implicit none type(sfxDatasetType), intent(out) :: dataset integer, intent(in) :: id @@ -151,8 +152,8 @@ contains dataset%id = id dataset%filename = get_dataset_filename(id) dataset%nmax = 0 - ! *: temporary surface type & z0(h) def. - dataset%surface_type = 1 + + dataset%surface = surface_land dataset%z0_h = -1.0 if (id == dataset_mosaic) then @@ -167,13 +168,16 @@ contains else if (id == dataset_lake) then ! *: check & fix values dataset%h = 10.0 + dataset%surface = surface_lake dataset%z0_m = -1.0 else if (id == dataset_papa) then dataset%h = 10.0 + dataset%surface = surface_ocean dataset%z0_m = -1.0 else if (id == dataset_toga) then ! *: check & fix values dataset%h = 15.0 + dataset%surface = surface_ocean dataset%z0_m = -1.0 end if diff --git a/srcF/sfx_main.f90 b/srcF/sfx_main.f90 index ac25fec..266de8c 100644 --- a/srcF/sfx_main.f90 +++ b/srcF/sfx_main.f90 @@ -12,7 +12,6 @@ program sfx_main implicit none ! -------------------------------------------------------------------------------- - type(sfxDatasetType) :: dataset integer :: model diff --git a/srcF/sfx_run.f90 b/srcF/sfx_run.f90 index a05706b..531a77b 100644 --- a/srcF/sfx_run.f90 +++ b/srcF/sfx_run.f90 @@ -65,14 +65,14 @@ contains integer :: i integer :: io, status ! -------------------------------------------------------------------------------- - + write(*, *) ' Running SFX:' write(*, '(a,a)') ' model = ', trim(get_model_tag(model)) write(*, '(a,a)') ' dataset = ', trim(get_dataset_tag(dataset%id)) write(*, '(a,a)') ' filename[IN] = ', trim(dataset%filename) write(*, '(a,a)') ' filename[OUT] = ', trim(filename_out) - write(*, '(a,g0)') ' surface type = ', dataset%surface_type + write(*, '(a,g0)') ' surface type = ', dataset%surface write(*, '(a,g0)') ' h = ', dataset%h write(*, '(a,g0)') ' z0(m) = ', dataset%z0_m write(*, '(a,g0)') ' z0(h) = ', dataset%z0_h diff --git a/srcF/sfx_surface.f90 b/srcF/sfx_surface.f90 index 0d8d2cc..d5e3699 100644 --- a/srcF/sfx_surface.f90 +++ b/srcF/sfx_surface.f90 @@ -24,6 +24,12 @@ module sfx_surface integer, public, parameter :: surface_ocean = 0 !< ocean surface integer, public, parameter :: surface_land = 1 !< land surface integer, public, parameter :: surface_lake = 2 !< lake surface + integer, public, parameter :: surface_snow = 3 !< snow covered surface + + character(len = 16), parameter :: surface_ocean_tag = 'ocean' + character(len = 16), parameter :: surface_land_tag = 'land' + character(len = 16), parameter :: surface_lake_tag = 'lake' + character(len = 16), parameter :: surface_snow_tag = 'snow' ! -------------------------------------------------------------------------------- real, parameter, private :: kappa = 0.40 !< von Karman constant [n/d] @@ -60,6 +66,44 @@ module sfx_surface contains + ! surface type definition + ! -------------------------------------------------------------------------------- + function get_surface_id(tag) result(id) + implicit none + character(len=*), intent(in) :: tag + integer :: id + + id = - 1 + if (trim(tag) == trim(surface_ocean_tag)) then + id = surface_ocean + else if (trim(tag) == trim(surface_land_tag)) then + id = surface_land + else if (trim(tag) == trim(surface_lake_tag)) then + id = surface_lake + else if (trim(tag) == trim(surface_snow_tag)) then + id = surface_snow + end if + + end function + + function get_surface_tag(id) result(tag) + implicit none + integer :: id + character(len=:), allocatable :: tag + + tag = 'undefined' + if (id == surface_ocean) then + tag = surface_ocean_tag + else if (id == surface_land) then + tag = surface_land_tag + else if (id == surface_lake) then + tag = surface_lake_tag + else if (id == surface_snow) then + tag = surface_snow_tag + end if + + end function + ! charnock roughness definition ! -------------------------------------------------------------------------------- subroutine get_charnock_roughness(z0_m, u_dyn0, U, h, maxiters) -- GitLab