This subroutine stores the reference profile at h points for the variable whose address is given by filename and fieldname.
591 character(len=*),
intent(in) :: filename
593 character(len=*),
intent(in) :: fieldname
595 type(time_type),
intent(in) :: Time
596 type(ocean_grid_type),
intent(in) :: G
597 type(verticalGrid_type),
intent(in) :: GV
598 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)), &
599 target,
intent(in) :: f_ptr
600 type(ALE_sponge_CS),
pointer :: CS
603 real,
allocatable,
dimension(:,:,:) :: sp_val
604 real,
allocatable,
dimension(:,:,:) :: mask_z
605 real,
allocatable,
dimension(:),
target :: z_in, z_edges_in
606 real :: missing_value
608 integer :: isd,ied,jsd,jed
610 integer,
dimension(4) :: fld_sz
612 character(len=256) :: mesg
615 real,
dimension(:),
allocatable :: hsrc
616 real,
dimension(:),
allocatable :: tmpT1d
617 real :: zTopOfCell, zBottomOfCell
618 type(remapping_CS) :: remapCS
620 if (.not.
associated(cs))
return
623 call time_interp_external_init()
625 isd = g%isd; ied = g%ied; jsd = g%jsd; jed = g%jed
626 cs%fldno = cs%fldno + 1
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)
639 cs%Ref_val(cs%fldno)%id = init_external_field(filename, fieldname)
641 fld_sz = get_external_field_size(cs%Ref_val(cs%fldno)%id)
643 cs%Ref_val(cs%fldno)%nz_data = nz_data
644 cs%Ref_val(cs%fldno)%num_tlevs = fld_sz(4)
646 allocate( sp_val(isd:ied,jsd:jed, nz_data) )
647 allocate( mask_z(isd:ied,jsd:jed, nz_data) )
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
670 allocate( hsrc(nz_data) )
671 allocate( tmpt1d(nz_data) )
675 ztopofcell = 0. ; zbottomofcell = 0. ; npoints = 0; hsrc(:) = 0.0; tmpt1d(:) = -99.9
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)) )
681 zbottomofcell = -g%bathyT(cs%col_i(col),cs%col_j(col))
686 hsrc(k) = ztopofcell - zbottomofcell
687 if (hsrc(k)>0.) npoints = npoints + 1
688 ztopofcell = zbottomofcell
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)
698 cs%var(cs%fldno)%p => f_ptr
702 deallocate(sp_val, mask_z)