MOM6
mom_ale_sponge::set_up_ale_sponge_field Interface Reference

Detailed Description

Store the reference profile at h points for a variable.

Definition at line 34 of file MOM_ALE_sponge.F90.

Private functions

subroutine set_up_ale_sponge_field_fixed (sp_val, G, f_ptr, CS)
 This subroutine stores the reference profile at h points for the variable whose address is given by f_ptr. More...
 
subroutine set_up_ale_sponge_field_varying (filename, fieldname, Time, G, GV, f_ptr, CS)
 This subroutine stores the reference profile at h points for the variable whose address is given by filename and fieldname. More...
 

Functions and subroutines

◆ set_up_ale_sponge_field_fixed()

subroutine mom_ale_sponge::set_up_ale_sponge_field::set_up_ale_sponge_field_fixed ( real, dimension( g %isd: g %ied, g %jsd: g %jed,cs%nz_data), intent(in)  sp_val,
type(ocean_grid_type), intent(in)  G,
real, dimension( g %isd: g %ied, g %jsd: g %jed, g %ke), intent(in), target  f_ptr,
type(ale_sponge_cs), pointer  CS 
)
private

This subroutine stores the reference profile at h points for the variable whose address is given by f_ptr.

Parameters
[in]gGrid structure
csALE sponge control structure (in/out).
[in]sp_valField to be used in the sponge, it has arbritary number of layers.
[in]f_ptrPointer to the field to be damped

Definition at line 554 of file MOM_ALE_sponge.F90.

554  type(ocean_grid_type), intent(in) :: G !< Grid structure
555  type(ALE_sponge_CS), pointer :: CS !< ALE sponge control structure (in/out).
556  real, dimension(SZI_(G),SZJ_(G),CS%nz_data), &
557  intent(in) :: sp_val !< Field to be used in the sponge, it has arbritary number of layers.
558  real, dimension(SZI_(G),SZJ_(G),SZK_(G)), &
559  target, intent(in) :: f_ptr !< Pointer to the field to be damped
560 
561  integer :: j, k, col
562  character(len=256) :: mesg ! String for error messages
563 
564  if (.not.associated(cs)) return
565 
566  cs%fldno = cs%fldno + 1
567 
568  if (cs%fldno > max_fields_) then
569  write(mesg,'("Increase MAX_FIELDS_ to at least ",I3," in MOM_memory.h or decrease &
570  &the number of fields to be damped in the call to &
571  &initialize_sponge." )') cs%fldno
572  call mom_error(fatal,"set_up_ALE_sponge_field: "//mesg)
573  endif
574 
575  ! stores the reference profile
576  allocate(cs%Ref_val(cs%fldno)%p(cs%nz_data,cs%num_col))
577  cs%Ref_val(cs%fldno)%p(:,:) = 0.0
578  do col=1,cs%num_col
579  do k=1,cs%nz_data
580  cs%Ref_val(cs%fldno)%p(k,col) = sp_val(cs%col_i(col),cs%col_j(col),k)
581  enddo
582  enddo
583 
584  cs%var(cs%fldno)%p => f_ptr
585 

◆ set_up_ale_sponge_field_varying()

subroutine mom_ale_sponge::set_up_ale_sponge_field::set_up_ale_sponge_field_varying ( character(len=*), intent(in)  filename,
character(len=*), intent(in)  fieldname,
type(time_type), intent(in)  Time,
type(ocean_grid_type), intent(in)  G,
type(verticalgrid_type), intent(in)  GV,
real, dimension( g %isd: g %ied, g %jsd: g %jed, g %ke), intent(in), target  f_ptr,
type(ale_sponge_cs), pointer  CS 
)
private

This subroutine stores the reference profile at h points for the variable whose address is given by filename and fieldname.

Parameters
[in]filenameThe name of the file with the time varying field data
[in]fieldnameThe name of the field in the file with the time varying field data
[in]timeThe current model time
[in]gGrid structure (in).
[in]gvocean vertical grid structure
[in]f_ptrPointer to the field to be damped (in).
csSponge control structure (in/out).

Definition at line 591 of file MOM_ALE_sponge.F90.

591  character(len=*), intent(in) :: filename !< The name of the file with the
592  !! time varying field data
593  character(len=*), intent(in) :: fieldname !< The name of the field in the file
594  !! with the time varying field data
595  type(time_type), intent(in) :: Time !< The current model time
596  type(ocean_grid_type), intent(in) :: G !< Grid structure (in).
597  type(verticalGrid_type), intent(in) :: GV !< ocean vertical grid structure
598  real, dimension(SZI_(G),SZJ_(G),SZK_(G)), &
599  target, intent(in) :: f_ptr !< Pointer to the field to be damped (in).
600  type(ALE_sponge_CS), pointer :: CS !< Sponge control structure (in/out).
601 
602  ! Local variables
603  real, allocatable, dimension(:,:,:) :: sp_val !< Field to be used in the sponge
604  real, allocatable, dimension(:,:,:) :: mask_z !< Field mask for the sponge data
605  real, allocatable, dimension(:), target :: z_in, z_edges_in ! Heights [Z ~> m].
606  real :: missing_value
607  integer :: j, k, col
608  integer :: isd,ied,jsd,jed
609  integer :: nPoints
610  integer, dimension(4) :: fld_sz
611  integer :: nz_data !< the number of vertical levels in this input field
612  character(len=256) :: mesg ! String for error messages
613 
614  ! Local variables for ALE remapping
615  real, dimension(:), allocatable :: hsrc ! Source thicknesses [Z ~> m].
616  real, dimension(:), allocatable :: tmpT1d
617  real :: zTopOfCell, zBottomOfCell ! Heights [Z ~> m].
618  type(remapping_CS) :: remapCS ! Remapping parameters and work arrays
619 
620  if (.not.associated(cs)) return
621 
622  ! Call this in case it was not previously done.
623  call time_interp_external_init()
624 
625  isd = g%isd; ied = g%ied; jsd = g%jsd; jed = g%jed
626  cs%fldno = cs%fldno + 1
627 
628  if (cs%fldno > max_fields_) then
629  write(mesg,'("Increase MAX_FIELDS_ to at least ",I3," in MOM_memory.h or decrease &
630  &the number of fields to be damped in the call to &
631  &initialize_sponge." )') cs%fldno
632  call mom_error(fatal,"set_up_ALE_sponge_field: "//mesg)
633  endif
634 
635  ! get a unique id for this field which will allow us to return an array
636  ! containing time-interpolated values from an external file corresponding
637  ! to the current model date.
638 
639  cs%Ref_val(cs%fldno)%id = init_external_field(filename, fieldname)
640  fld_sz(1:4)=-1
641  fld_sz = get_external_field_size(cs%Ref_val(cs%fldno)%id)
642  nz_data = fld_sz(3)
643  cs%Ref_val(cs%fldno)%nz_data = nz_data !< each individual sponge field is assumed to reside on a different grid
644  cs%Ref_val(cs%fldno)%num_tlevs = fld_sz(4)
645 
646  allocate( sp_val(isd:ied,jsd:jed, nz_data) )
647  allocate( mask_z(isd:ied,jsd:jed, nz_data) )
648 
649  ! initializes the current reference profile array
650  allocate(cs%Ref_val(cs%fldno)%p(nz_data,cs%num_col))
651  cs%Ref_val(cs%fldno)%p(:,:) = 0.0
652  allocate( cs%Ref_val(cs%fldno)%h(nz_data,cs%num_col) )
653  cs%Ref_val(cs%fldno)%h(:,:) = 0.0
654 
655  ! Interpolate external file data to the model grid
656  ! I am hard-wiring this call to assume that the input grid is zonally re-entrant
657  ! In the future, this should be generalized using an interface to return the
658  ! modulo attribute of the zonal axis (mjh).
659 
660  ! call horiz_interp_and_extrap_tracer(CS%Ref_val(CS%fldno)%id,Time, 1.0,G,sp_val,mask_z,z_in,z_edges_in, &
661  ! missing_value, .true., .false., .false., m_to_Z=US%m_to_Z)
662 
663 ! Do not think halo updates are needed (mjh)
664 ! call pass_var(sp_val,G%Domain)
665 ! call pass_var(mask_z,G%Domain)
666 
667 ! Done with horizontal interpolation.
668 ! Now remap to model coordinates
669 ! First we reserve a work space for reconstructions of the source data
670  allocate( hsrc(nz_data) )
671  allocate( tmpt1d(nz_data) )
672 
673  do col=1,cs%num_col
674  ! Build the source grid
675  ztopofcell = 0. ; zbottomofcell = 0. ; npoints = 0; hsrc(:) = 0.0; tmpt1d(:) = -99.9
676  do k=1,nz_data
677  if (mask_z(cs%col_i(col),cs%col_j(col),k) == 1.0) then
678  zbottomofcell = -min( z_edges_in(k+1), g%bathyT(cs%col_i(col),cs%col_j(col)) )
679 ! tmpT1d(k) = sp_val(CS%col_i(col),CS%col_j(col),k)
680  elseif (k>1) then
681  zbottomofcell = -g%bathyT(cs%col_i(col),cs%col_j(col))
682 ! tmpT1d(k) = tmpT1d(k-1)
683 ! else ! This next block should only ever be reached over land
684 ! tmpT1d(k) = -99.9
685  endif
686  hsrc(k) = ztopofcell - zbottomofcell
687  if (hsrc(k)>0.) npoints = npoints + 1
688  ztopofcell = zbottomofcell ! Bottom becomes top for next value of k
689  enddo
690  ! In case data is deeper than model
691  hsrc(nz_data) = hsrc(nz_data) + ( ztopofcell + g%bathyT(cs%col_i(col),cs%col_j(col)) )
692  cs%Ref_val(cs%fldno)%h(1:nz_data,col) = 0.
693  cs%Ref_val(cs%fldno)%p(1:nz_data,col) = -1.e24
694  cs%Ref_val(cs%fldno)%h(1:nz_data,col) = gv%Z_to_H*hsrc(1:nz_data)
695 ! CS%Ref_val(CS%fldno)%p(1:nz_data,col) = tmpT1d(1:nz_data)
696  enddo
697 
698  cs%var(cs%fldno)%p => f_ptr
699 
700  deallocate( hsrc )
701  deallocate( tmpt1d )
702  deallocate(sp_val, mask_z)
703 

The documentation for this interface was generated from the following file: