diff --git a/obl_config.f90 b/obl_config.f90 index b5e2808ed9bfa1c3d73c4466b87aba9c535430e6..d774611ec07143731676486acf143d1239bcff67 100644 --- a/obl_config.f90 +++ b/obl_config.f90 @@ -112,6 +112,9 @@ contains call set_uniform_grid(grid, -depth, depth, cz) end block +#else + !> unable to define without config + ierr = 1 #endif end subroutine set_grid @@ -166,6 +169,9 @@ contains end if end block +#else + !> unable to define without config + ierr = 1 #endif end subroutine set_time @@ -232,6 +238,9 @@ contains end if end block +#else + !> unable to define without config + ierr = 1 #endif end subroutine set_phys @@ -265,9 +274,7 @@ contains return endif -#ifdef USE_CONFIG_PARSER block - call set_config_tforcing(tau_x_surf, "atm.tau_x", ierr) if (ierr /= 0) return @@ -333,7 +340,9 @@ contains ! ---------------------------------------------------------------------------- end block -#endif + !> assuming that surface fluxes could be not set + !> *: this will use LW[in] and calculate LW[out] + !> *: probably to better set = 0 in all explicitly end subroutine set_forcing ! -------------------------------------------------------------------------------- @@ -368,13 +377,28 @@ contains return endif -#ifdef USE_CONFIG_PARSER block - !> just a temporaty to set smth - call set_initial_conditions_kato(grid) + call set_config_profile(Theta, "initial_conditions.Theta", grid, ierr) + if (ierr /= 0) then + return + endif + + call set_config_profile(Salin, "initial_conditions.Salin", grid, ierr) + if (ierr /= 0) then + return + endif + + call set_config_profile(U, "initial_conditions.U", grid, ierr) + if (ierr /= 0) then + return + endif + + call set_config_profile(V, "initial_conditions.V", grid, ierr) + if (ierr /= 0) then + return + endif end block -#endif end subroutine set_initial_conditions end module obl_config diff --git a/obl_init.f90 b/obl_init.f90 index 1cd270bc9e8a69b70d344fa20c3365b078bc1d95..4dc16d9f1ea0eca704854b3c266801e5a30a9186 100644 --- a/obl_init.f90 +++ b/obl_init.f90 @@ -4,6 +4,10 @@ module obl_init ! modules used ! -------------------------------------------------------------------------------- +#ifdef USE_CONFIG_PARSER + use iso_c_binding, only: C_NULL_CHAR + use config_parser +#endif use obl_grid use obl_math @@ -15,6 +19,7 @@ module obl_init ! public interface ! -------------------------------------------------------------------------------- public :: set_const_profile, set_linear_profile, set_external_profile + public :: set_config_profile ! -------------------------------------------------------------------------------- contains @@ -111,4 +116,71 @@ module obl_init endif end subroutine + ! -------------------------------------------------------------------------------- + subroutine set_config_profile(F, tag, grid, ierr) + !< @brief set constant profile + ! ---------------------------------------------------------------------------- + type (gridDataType), intent(in) :: grid + + real, dimension(grid%cz), intent(out) :: F + integer, intent(out) :: ierr + + character(len = *), intent(in) :: tag + + character, allocatable :: config_field(:) + integer :: status + + real :: Fsurf, Fgrad + ! -------------------------------------------------------------------------------- + + ierr = 0 ! = OK + +#ifdef USE_CONFIG_PARSER + call c_config_get_string(trim(tag)//".mode"//C_NULL_CHAR, config_field, status) + if (status == 0) then + ierr = 1 ! signal ERROR + return + end if + + if (trim(char_array2str(config_field)) == 'const') then + call c_config_get_float(trim(tag)//".surface_value"//C_NULL_CHAR, Fsurf, status) + if (status == 0) then + ierr = 1 ! signal ERROR + return + end if + + call set_const_profile(F, Fsurf, grid) + else if (trim(char_array2str(config_field)) == 'linear') then + call c_config_get_float(trim(tag)//".surface_value"//C_NULL_CHAR, Fsurf, status) + if (status == 0) then + ierr = 1 ! signal ERROR + return + end if + call c_config_get_float(trim(tag)//".grad_z"//C_NULL_CHAR, Fgrad, status) + if (status == 0) then + ierr = 1 ! signal ERROR + return + end if + + call set_linear_profile(F, Fsurf, Fgrad, grid) + else if (trim(char_array2str(config_field)) == 'ascii') then + call c_config_get_string(trim(tag)//".filename"//C_NULL_CHAR, config_field, status) + if (status == 0) then + ierr = 1 ! signal ERROR + return + end if + + call set_external_profile(F, char_array2str(config_field), grid) + else + write(*, *) ' FAILURE! > unknown initial conditions mode: ', trim(char_array2str(config_field)) + ierr = 1 ! signal ERROR + return + endif +#else + !> unable to define without config + ierr = 1 +#endif + + end subroutine + end module