Skip to content

Commit

Permalink
+Style compliance in external/drifters code
Browse files Browse the repository at this point in the history
  Revised the external/drifters code to bring it into closer alignment with the
MOM6 style guide at https://github.com/mom-ocean/MOM6/wiki/Code-style-guide.
This includes using standard syntax to document variable units, the addition of
'implicit none ; private', explicit public statements, and a licensing statement
to the files that were missing one, and modifications to follow the MOM6 2-point
indenting convention.  All answers are bitwise identical.
  • Loading branch information
Hallberg-NOAA authored and marshallward committed May 8, 2022
1 parent 84d78a6 commit 1d8fb50
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 30 deletions.
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

0 comments on commit 1d8fb50

Please sign in to comment.