Skip to content
Snippets Groups Projects
Commit c2adbeb4 authored by Evgeny Mortikov's avatar Evgeny Mortikov
Browse files

adding time slice container

parent 7b120d70
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,7 @@ set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/modules/)
set(SOURCES
obl_grid.f90
obl_tslice.f90
obl_time_and_space.f90
obl_common_phys_parameters.f90
obl_mathematics.f90
......
! obl model macro definitions
!#define OBL_EXCLUDE_NETCDF
!#define USE_CONFIG_PARSER
!#define OBL_USE_GRID_DATATYPE
!#define OBL_USE_TSLICE_OUTPUT
......@@ -10,6 +10,9 @@ program obl_main
! modules used
use obl_grid
#ifdef OBL_USE_TSLICE_OUTPUT
use obl_tslice
#endif
use obl_time_and_space
use obl_initial_conditions
use obl_forcing_and_boundary
......@@ -37,6 +40,11 @@ program obl_main
type(gridDataType) :: grid
#ifdef OBL_USE_TSLICE_OUTPUT
! time slice
type (oblTimeSlice) :: output_Theta, output_Salin
#endif
real :: t !< time, [s]
integer :: nt !< number of time steps
integer :: nf !< number of time steps for forcing
......@@ -105,6 +113,9 @@ program obl_main
! screen output parameters
integer, parameter :: nscreen = 1000
! file output parameters
integer, parameter :: noutput = 60
! arrays for output
real, allocatable :: Theta_write(:,:)
real, allocatable :: Salin_write(:,:)
......@@ -384,6 +395,7 @@ program obl_main
! Theta (k) = Theta(k) + Theta_0
!end do
#ifndef OBL_USE_TSLICE_OUTPUT
Theta_write(:, i) = Theta_dev
Salin_write(:, i) = Salin_dev
U_write(:, i) = U
......@@ -397,6 +409,7 @@ program obl_main
hml_write(i) = hml
maxcellnumber_write(i) = maxcellnumber
lab_hml_write(i) = lab_hml
#endif
!write(199,*) time_current, hml, lab_hml
!write(20,*) time_current, Theta_dev(nz) + Theta_ref
......@@ -412,6 +425,14 @@ program obl_main
(time_current / time_end) * 100.0, '% ]'
write(*, '(a)') '-------------------------------------------------'
endif
! time slice output
#ifdef OBL_USE_TSLICE_OUTPUT
if (mod(i, noutput) == 0) then
call push_profile_to_tslice(output_Theta, Theta_dev, nz)
call push_profile_to_tslice(output_Salin, Salin_dev, nz)
endif
#endif
enddo
Theta_C_write = Theta_write - 273.15
......@@ -419,6 +440,7 @@ program obl_main
Salin_write = Salin_write + Salin_ref
!Rho_write = Rho_write + Rho_ref
#ifndef OBL_USE_TSLICE_OUTPUT
! Writing 2D arrays (variables with depth and time)
call write_2d_real_nc(Theta_write, 'output.nc', meta_theta)
call write_2d_real_nc(Salin_write, 'output.nc', meta_salin)
......@@ -431,6 +453,7 @@ program obl_main
call write_2d_real_nc(Kh_write, 'output.nc', meta_kh)
call write_2d_real_nc(Km_write, 'output.nc', meta_km)
call write_2d_real_nc(Theta_C_write, 'output.nc', meta_theta_C)
#endif
! Writing 1D arrays (scalar variables over time)
call write_1d_real_nc(hml_write, 'output.nc', meta_hml)
......@@ -439,6 +462,7 @@ program obl_main
!call write_1d_real_nc(Tau_y_surf, 'output.nc', meta_tau_v)
call write_1d_real_nc(lab_hml_write, 'output.nc', meta_lab_hml)
#ifndef OBL_USE_TSLICE_OUTPUT
! Writing 2D arrays (variables with depth and time) to ASCII files
call write_2d_real_ascii(Theta_write, 'output_Theta.txt', meta_theta)
call write_2d_real_ascii(Salin_write, 'output_Salin.txt', meta_salin)
......@@ -450,6 +474,7 @@ program obl_main
call write_2d_real_ascii(Ri_grad_write, 'output_Ri_grad.txt', meta_ri_grad)
call write_2d_real_ascii(Kh_write, 'output_Kh.txt', meta_kh)
call write_2d_real_ascii(Km_write, 'output_Km.txt', meta_km)
#endif
! Writing 1D arrays (scalar variables over time) to ASCII files
call write_1d_real_ascii(hml_write, 'output_hml.txt', meta_hml)
......@@ -458,6 +483,12 @@ program obl_main
!call write_1d_real_ascii(Tau_x_surf, 'output_tau_u.txt', meta_tau_u)
!call write_1d_real_ascii(Tau_y_surf, 'output_tau_v.txt', meta_tau_v)
#ifdef OBL_USE_TSLICE_OUTPUT
! time slice output
call write_2d_real_ascii(output_Theta%data(:,1:output_Theta%num), 'Theta_tslice.txt', meta_theta)
call write_2d_real_ascii(output_Salin%data(:,1:output_Salin%num), 'Salin_tslice.txt', meta_salin)
#endif
!close(199)
!close(20)
......
......@@ -53,6 +53,7 @@ module obl_richardson
end subroutine
#ifdef OBL_USE_GRID_DATATYPE
subroutine get_N2_on_grid(N2, Rho, Rho_dyn_surf, Rho_dyn_bot, grid)
!< @brief calculate square of buoyancy frequency
......@@ -87,6 +88,7 @@ module obl_richardson
N2(grid%cz) = - g/Rho_ref * dRho_tmp_surf
end subroutine
#endif
subroutine get_S2(S2, U, V, flux_u_surf, flux_u_bot, flux_v_surf, flux_v_bot, dz, nz)
!< @brief calculate square of shear frequency
......@@ -127,6 +129,7 @@ module obl_richardson
end subroutine
#ifdef OBL_USE_GRID_DATATYPE
subroutine get_S2_on_grid(S2, U, V, flux_u_surf, flux_u_bot, flux_v_surf, flux_v_bot, grid)
!< @brief calculate square of shear frequency
......@@ -165,6 +168,7 @@ module obl_richardson
call limit_min_array(S2, S2_min, grid%cz)
end subroutine
#endif
subroutine get_Rig(Ri_grad, N2, S2, nz)
!< @brief calculate Richardson gradient number
......
module obl_tslice
!< @brief obl time slice def.
! --------------------------------------------------------------------------------
! modules used
! --------------------------------------------------------------------------------
! directives list
implicit none
private
! public interface
! --------------------------------------------------------------------------------
public :: push_profile_to_tslice
public :: deallocate_tslice
! --------------------------------------------------------------------------------
!> @brief time slice datatype
type, public :: oblTimeSlice
integer :: cz
integer :: num = 0
integer :: nalloc = 0
real, allocatable :: data(:, :)
end type
contains
subroutine push_profile_to_tslice(tslice, profile, cz)
!> @brief add profile to time slice
! ----------------------------------------------------------------------------
type (oblTimeSlice), intent(inout) :: tslice
integer, intent(in) :: cz
real, dimension(cz), intent(in) :: profile
real, allocatable :: buf(:, :)
! ----------------------------------------------------------------------------
if (tslice%num == 0) tslice%cz = cz
if (tslice%num == tslice%nalloc) then
tslice%nalloc = tslice%nalloc + 1024
allocate(buf(tslice%cz, tslice%nalloc))
if (tslice%num > 0) then
buf(:, 1:tslice%num) = tslice%data(:,1:tslice%num)
deallocate(tslice%data)
end if
call move_alloc(buf, tslice%data)
endif
tslice%data(:, tslice%num + 1) = profile(:)
tslice%num = tslice%num + 1
end subroutine push_profile_to_tslice
subroutine deallocate_tslice(tslice)
!> @brief free time slice
! ----------------------------------------------------------------------------
type (oblTimeSlice), intent(inout) :: tslice
! ----------------------------------------------------------------------------
if (tslice%num > 0) then
deallocate(tslice%data)
end if
end subroutine deallocate_tslice
end module
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment