Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
158 changes: 78 additions & 80 deletions config_src/external/ODA_hooks/ocean_da_types.F90
Original file line number Diff line number Diff line change
@@ -1,90 +1,88 @@
!> Dummy aata structures and methods for ocean data assimilation.
module ocean_da_types_mod

use MOM_time_manager, only : time_type
use MOM_time_manager, only : time_type

implicit none
implicit none ; private

private
!> Example type for ocean ensemble DA state
type, public :: OCEAN_CONTROL_STRUCT
integer :: ensemble_size !< ensemble size
real, pointer, dimension(:,:,:) :: SSH => NULL() !< sea surface height across ensembles [m]
real, pointer, dimension(:,:,:,:) :: h => NULL() !< layer thicknesses across ensembles [m or kg m-2]
real, pointer, dimension(:,:,:,:) :: T => NULL() !< layer potential temperature across ensembles [degC]
real, pointer, dimension(:,:,:,:) :: S => NULL() !< layer salinity across ensembles [ppt]
real, pointer, dimension(:,:,:,:) :: U => NULL() !< layer zonal velocity across ensembles [m s-1]
real, pointer, dimension(:,:,:,:) :: V => NULL() !< layer meridional velocity across ensembles [m s-1]
end type OCEAN_CONTROL_STRUCT

!> Example type for ocean ensemble DA state
type, public :: OCEAN_CONTROL_STRUCT
integer :: ensemble_size !< ensemble size
real, pointer, dimension(:,:,:) :: SSH=>NULL() !<sea surface height (m) across ensembles
real, pointer, dimension(:,:,:,:) :: h=>NULL() !<layer thicknesses (m or kg) across ensembles
real, pointer, dimension(:,:,:,:) :: T=>NULL() !<layer potential temperature (degC) across ensembles
real, pointer, dimension(:,:,:,:) :: S=>NULL() !<layer salinity (psu or g kg-1) across ensembles
real, pointer, dimension(:,:,:,:) :: U=>NULL() !<layer zonal velocity (m s-1) across ensembles
real, pointer, dimension(:,:,:,:) :: V=>NULL() !<layer meridional velocity (m s-1) across ensembles
end type OCEAN_CONTROL_STRUCT
!> Example of a profile type
type, public :: ocean_profile_type
integer :: inst_type !< A numeric code indicating the type of instrument (e.g. ARGO drifter, CTD, ...)
logical :: initialized !< a True value indicates that this profile has been allocated for use
logical :: colocated !< a True value indicated that the measurements of (num_variables) data are
!! co-located in space-time
integer :: ensemble_size !< size of the ensemble of model states used in association with this profile
integer :: num_variables !< number of measurement types associated with this profile.
integer, pointer, dimension(:) :: var_id !< variable ids are defined by the ocean_types module
integer :: platform !< platform types are defined by platform class (e.g. MOORING, DROP, etc.)
!! and instrument type (XBT, CDT, etc.)
integer :: levels !< number of levels in the current profile
integer :: basin_mask !< 1:Southern Ocean, 2:Atlantic Ocean, 3:Pacific Ocean,
!! 4:Arctic Ocean, 5:Indian Ocean, 6:Mediterranean Sea, 7:Black Sea,
!! 8:Hudson Bay, 9:Baltic Sea, 10:Red Sea, 11:Persian Gulf
integer :: profile_flag !< an overall flag for the profile
real :: lat !< latitude [degrees_N]
real :: lon !< longitude [degrees_E]
logical :: accepted !< logical flag to disable a profile
type(time_type) :: time_window !< The time window associated with this profile
real, pointer, dimension(:) :: obs_error !< The observation error by variable [various units]
real :: loc_dist !< The impact radius of this observation [m]
type(ocean_profile_type), pointer :: next => NULL() !< all profiles are stored as linked list.
type(ocean_profile_type), pointer :: prev => NULL() !< previous
type(ocean_profile_type), pointer :: cnext => NULL() !< current profiles are stored as linked list.
type(ocean_profile_type), pointer :: cprev => NULL() !< previous
integer :: nbr_xi !< x nearest neighbor model gridpoint for the profile
integer :: nbr_yi !< y nearest neighbor model gridpoint for the profile
real :: nbr_dist !< distance to nearest neighbor model gridpoint [m]
logical :: compute !< profile is within current compute domain
real, dimension(:,:), pointer :: depth => NULL() !< depth of measurement [m]
real, dimension(:,:), pointer :: data => NULL() !< data by variable type [various units]
integer, dimension(:,:), pointer :: flag => NULL() !< flag by depth and variable type
real, dimension(:,:,:), pointer :: forecast => NULL() !< ensemble member first guess
real, dimension(:,:,:), pointer :: analysis => NULL() !< ensemble member analysis
type(forward_operator_type), pointer :: obs_def => NULL() !< observation forward operator
type(time_type) :: time !< profile time type
real :: i_index !< model longitude indices respectively
real :: j_index !< model latitude indices respectively
real, dimension(:,:), pointer :: k_index !< model depth indices
type(time_type) :: tdiff !< difference between model time and observation time
character(len=128) :: filename !< a filename
end type ocean_profile_type

!> Example of a profile type
type, public :: ocean_profile_type
integer :: inst_type !< A numeric code indicating the type of instrument (e.g. ARGO drifter, CTD, ...)
logical :: initialized !< a True value indicates that this profile has been allocated for use
logical :: colocated !< a True value indicated that the measurements of (num_variables) data are
!! co-located in space-time
integer :: ensemble_size !< size of the ensemble of model states used in association with this profile
integer :: num_variables !< number of measurement types associated with this profile.
integer, pointer, dimension(:) :: var_id !< variable ids are defined by the ocean_types module
integer :: platform !< platform types are defined by platform class (e.g. MOORING, DROP, etc.)
!! and instrument type (XBT, CDT, etc.)
integer :: levels !< number of levels in the current profile
integer :: basin_mask !< 1:Southern Ocean, 2:Atlantic Ocean, 3:Pacific Ocean,
!! 4:Arctic Ocean, 5:Indian Ocean, 6:Mediterranean Sea, 7:Black Sea,
!! 8:Hudson Bay, 9:Baltic Sea, 10:Red Sea, 11:Persian Gulf
integer :: profile_flag !< an overall flag for the profile
real :: lat !< latitude [degrees_N]
real :: lon !< longitude [degrees_E]
logical :: accepted !< logical flag to disable a profile
type(time_type) :: time_window !< The time window associated with this profile [s]
real, pointer, dimension(:) :: obs_error !< The observation error by variable
real :: loc_dist !< The impact radius of this observation (m)
type(ocean_profile_type), pointer :: next=>NULL() !< all profiles are stored as linked list.
type(ocean_profile_type), pointer :: prev=>NULL() !< previous
type(ocean_profile_type), pointer :: cnext=>NULL() !< current profiles are stored as linked list.
type(ocean_profile_type), pointer :: cprev=>NULL() !< previous
integer :: nbr_xi !< x nearest neighbor model gridpoint for the profile
integer :: nbr_yi !< y nearest neighbor model gridpoint for the profile
real :: nbr_dist !< distance to nearest neighbor model gridpoint
logical :: compute !< profile is within current compute domain
real, dimension(:,:), pointer :: depth => NULL() !< depth of measurement [m]
real, dimension(:,:), pointer :: data => NULL() !< data by variable type
integer, dimension(:,:), pointer :: flag => NULL() !< flag by depth and variable type
real, dimension(:,:,:), pointer :: forecast => NULL() !< ensemble member first guess
real, dimension(:,:,:), pointer :: analysis => NULL() !< ensemble member analysis
type(forward_operator_type), pointer :: obs_def => NULL() !< observation forward operator
type(time_type) :: time !< profile time type
real :: i_index !< model longitude indices respectively
real :: j_index !< model latitude indices respectively
real, dimension(:,:), pointer :: k_index !< model depth indices
type(time_type) :: tdiff !< difference between model time and observation time
character(len=128) :: filename !< a filename
end type ocean_profile_type
!> Example forward operator type.
type, public :: forward_operator_type
integer :: num !< how many?
integer, dimension(2) :: state_size !< for
integer, dimension(:), pointer :: state_var_index !< for flattened data
integer, dimension(:), pointer :: i_index !< i-dimension index
integer, dimension(:), pointer :: j_index !< j-dimension index
real, dimension(:), pointer :: coef !< coefficient
end type forward_operator_type

!> Example forward operator type.
type, public :: forward_operator_type
integer :: num !< how many?
integer, dimension(2) :: state_size !< for
integer, dimension(:), pointer :: state_var_index !< for flattened data
integer, dimension(:), pointer :: i_index !< i-dimension index
integer, dimension(:), pointer :: j_index !< j-dimension index
real, dimension(:), pointer :: coef !< coefficient
end type forward_operator_type

!> Grid type for DA
type, public :: grid_type
real, pointer, dimension(:,:) :: x=>NULL() !< x
real, pointer, dimension(:,:) :: y=>NULL() !< y
real, pointer, dimension(:,:,:) :: z=>NULL() !< z
real, pointer, dimension(:,:,:) :: h=>NULL() !< h
real, pointer, dimension(:,:) :: basin_mask => NULL() !< basin mask
real, pointer, dimension(:,:,:) :: mask => NULL() !< land mask?
real, pointer, dimension(:,:) :: bathyT => NULL() !< bathymetry at T points
logical :: tripolar_N !< True for tripolar grids
integer :: ni !< ni
integer :: nj !< nj
integer :: nk !< nk
end type grid_type
!> Grid type for DA
type, public :: grid_type
real, pointer, dimension(:,:) :: x => NULL() !< x
real, pointer, dimension(:,:) :: y => NULL() !< y
real, pointer, dimension(:,:,:) :: z => NULL() !< z
real, pointer, dimension(:,:,:) :: h => NULL() !< h
real, pointer, dimension(:,:) :: basin_mask => NULL() !< basin mask
real, pointer, dimension(:,:,:) :: mask => NULL() !< land mask?
real, pointer, dimension(:,:) :: bathyT => NULL() !< bathymetry at T points [m]
logical :: tripolar_N !< True for tripolar grids
integer :: ni !< ni
integer :: nj !< nj
integer :: nk !< nk
end type grid_type

end module ocean_da_types_mod
12 changes: 4 additions & 8 deletions config_src/external/ODA_hooks/write_ocean_obs.F90
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
!> Dummy interfaces for writing ODA data
module write_ocean_obs_mod

use ocean_da_types_mod, only : ocean_profile_type
use MOM_time_manager, only : time_type, get_time, set_date

use ocean_da_types_mod, only : ocean_profile_type
use MOM_time_manager, only : time_type, get_time, set_date
implicit none ; private

implicit none

private

public :: open_profile_file, write_profile, close_profile_file, &
write_ocean_obs_init
public :: open_profile_file, write_profile, close_profile_file, write_ocean_obs_init

contains

Expand Down
48 changes: 25 additions & 23 deletions config_src/external/drifters/MOM_particles.F90
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
!> A set of dummy interfaces for compiling the MOM6 drifters code
module MOM_particles_mod

! This file is part of MOM6. See LICENSE.md for the license.

use MOM_grid, only : ocean_grid_type
use MOM_time_manager, only : time_type, get_date, operator(-)
use MOM_variables, only : thermo_var_ptrs
use particles_types_mod, only : particles, particles_gridded

implicit none ; private

use particles_types_mod, only: particles, particles_gridded

public particles_run, particles_init, particles_save_restart, particles_end
public particles, particles_run, particles_init, particles_save_restart, particles_end

contains

!> Initializes particles container "parts"
subroutine particles_init(parts, Grid, Time, dt, u, v)
! Arguments
type(particles), pointer, intent(out) :: parts !< Container for all types and memory
type(ocean_grid_type), target, intent(in) :: Grid !< Grid type from parent model
type(time_type), intent(in) :: Time !< Time type from parent model
real, intent(in) :: dt !< particle timestep in seconds
real, dimension(:,:,:),intent(in) :: u !< Zonal velocity field
real, dimension(:,:,:),intent(in) :: v !< Meridional velocity field
type(particles), pointer, intent(out) :: parts !< Container for all types and memory
type(ocean_grid_type), target, intent(in) :: Grid !< Grid type from parent model
type(time_type), intent(in) :: Time !< Time type from parent model
real, intent(in) :: dt !< particle timestep [s]
real, dimension(:,:,:), intent(in) :: u !< Zonal velocity field [m s-1]
real, dimension(:,:,:), intent(in) :: v !< Meridional velocity field [m s-1]

end subroutine particles_init

Expand All @@ -29,30 +31,30 @@ subroutine particles_run(parts, time, uo, vo, ho, tv, stagger)
! Arguments
type(particles), pointer :: parts !< Container for all types and memory
type(time_type), intent(in) :: time !< Model time
real, dimension(:,:,:),intent(in) :: uo !< Ocean zonal velocity (m/s)
real, dimension(:,:,:),intent(in) :: vo !< Ocean meridional velocity (m/s)
real, dimension(:,:,:),intent(in) :: ho !< Ocean layer thickness [H ~> m or kg m-2]
type(thermo_var_ptrs), intent(in) :: tv !< structure containing pointers to available thermodynamic fields
real, dimension(:,:,:), intent(in) :: uo !< Ocean zonal velocity [m s-1]
real, dimension(:,:,:), intent(in) :: vo !< Ocean meridional velocity [m s-1]
real, dimension(:,:,:), intent(in) :: ho !< Ocean layer thickness [H ~> m or kg m-2]
type(thermo_var_ptrs), intent(in) :: tv !< structure containing pointers to available thermodynamic fields
integer, optional, intent(in) :: stagger !< Flag for whether velocities are staggered

end subroutine particles_run


!>Save particle locations (and sometimes other vars) to restart file
subroutine particles_save_restart(parts,temp,salt)
! Arguments
type(particles), pointer :: parts !< Container for all types and memory
real,dimension(:,:,:),optional,intent(in) :: temp !< Optional container for temperature
real,dimension(:,:,:),optional,intent(in) :: salt !< Optional container for salinity
subroutine particles_save_restart(parts, temp, salt)
! Arguments
type(particles), pointer :: parts !< Container for all types and memory
real, dimension(:,:,:), optional, intent(in) :: temp !< Optional container for temperature
real, dimension(:,:,:), optional, intent(in) :: salt !< Optional container for salinity

end subroutine particles_save_restart

!> Deallocate all memory and disassociated pointer
subroutine particles_end(parts,temp,salt)
! Arguments
type(particles), pointer :: parts !< Container for all types and memory
real,dimension(:,:,:),optional,intent(in) :: temp !< Optional container for temperature
real,dimension(:,:,:),optional,intent(in) :: salt !< Optional container for salinity
subroutine particles_end(parts, temp, salt)
! Arguments
type(particles), pointer :: parts !< Container for all types and memory
real, dimension(:,:,:), optional, intent(in) :: temp !< Optional container for temperature
real, dimension(:,:,:), optional, intent(in) :: salt !< Optional container for salinity

end subroutine particles_end

Expand Down
17 changes: 10 additions & 7 deletions config_src/external/drifters/MOM_particles_types.F90
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
!> Dummy data structures and methods for drifters package
module particles_types_mod

! This file is part of MOM6. See LICENSE.md for the license.

use MOM_grid, only : ocean_grid_type
use mpp_domains_mod, only: domain2D
use MOM_domains, only: domain2D

implicit none ; private

!> Container for gridded fields
type :: particles_gridded
type, public :: particles_gridded
type(domain2D), pointer :: domain !< MPP parallel domain
integer :: halo !< Nominal halo width
integer :: isc !< Start i-index of computational domain
Expand Down Expand Up @@ -60,7 +63,7 @@ module particles_types_mod


!>xyt is a data structure containing particle position and velocity fields.
type :: xyt
type, public :: xyt
real :: lon !< Longitude of particle (degree N or unit of grid coordinate)
real :: lat !< Latitude of particle (degree N or unit of grid coordinate)
real :: day !< Day of this record (days)
Expand All @@ -77,7 +80,7 @@ module particles_types_mod
end type xyt

!>particle types are data structures describing a tracked particle
type :: particle
type, public :: particle
type(particle), pointer :: prev=>null() !< Previous link in list
type(particle), pointer :: next=>null() !< Next link in list
! State variables (specific to the particles, needed for restarts)
Expand Down Expand Up @@ -109,19 +112,19 @@ module particles_types_mod


!>A buffer structure for message passing
type :: buffer
type, public :: buffer
integer :: size=0 !< Size of buffer
real, dimension(:,:), pointer :: data !< Buffer memory
end type buffer

!> A wrapper for the particle linked list (since an array of pointers is not allowed)
type :: linked_list
type, public :: linked_list
type(particle), pointer :: first=>null() !< Pointer to the beginning of a linked list of parts
end type linked_list


!> A grand data structure for the particles in the local MOM domain
type :: particles !; private
type, public :: particles !; private
type(particles_gridded) :: grd !< Container with all gridded data
type(linked_list), dimension(:,:), allocatable :: list !< Linked list of particles
type(xyt), pointer :: trajectories=>null() !< A linked list for detached segments of trajectories
Expand Down
22 changes: 22 additions & 0 deletions config_src/external/stochastic_physics/get_stochy_pattern.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
! The are stubs for ocean stochastic physics
! the fully functional code is available at
! https://github.com/noaa-psd/stochastic_physics
module get_stochy_pattern_mod

! This file is part of MOM6. See LICENSE.md for the license.

implicit none ; private

public :: write_stoch_restart_ocn

contains

!> Write the restart file for the stochastic physics perturbations.
subroutine write_stoch_restart_ocn(sfile)
character(len=*) :: sfile !< name of restart file

! This stub function does not actually do anything.
return
end subroutine write_stoch_restart_ocn

end module get_stochy_pattern_mod
Loading