@@ -1396,15 +1396,15 @@ subroutine rectgrid
13961396 ! original rectgrid defines latlon first
13971397 call rectgrid_scale_dxdy
13981398 else
1399- ! rectgrid no grid spacing.
1399+ ! rectgrid no grid spacing.
14001400 ! original method with addition to use namelist lat/lon reference
1401-
1401+
14021402 if (my_task == master_task) then
14031403 work_g1 = c0
14041404 length = dxrect* cm_to_m/ radius* rad_to_deg
1405-
1405+
14061406 work_g1(1 ,:) = lonrefrect ! reference lon from namelist
1407-
1407+
14081408 do j = 1 , ny_global
14091409 do i = 2 , nx_global
14101410 work_g1(i,j) = work_g1(i-1 ,j) + length ! ULON
@@ -1416,13 +1416,13 @@ subroutine rectgrid
14161416 field_loc_NEcorner, field_type_scalar)
14171417 call ice_HaloExtrapolate(ULON, distrb_info, &
14181418 ew_boundary_type, ns_boundary_type)
1419-
1419+
14201420 if (my_task == master_task) then
14211421 work_g1 = c0
14221422 length = dyrect* cm_to_m/ radius* rad_to_deg
1423-
1423+
14241424 work_g1(:,1 ) = latrefrect ! reference latitude from namelist
1425-
1425+
14261426 do i = 1 , nx_global
14271427 do j = 2 , ny_global
14281428 work_g1(i,j) = work_g1(i,j-1 ) + length ! ULAT
@@ -1535,84 +1535,84 @@ subroutine rectgrid
15351535 end subroutine rectgrid
15361536
15371537! =======================================================================
1538-
1538+
15391539 subroutine rectgrid_scale_dxdy
1540-
1540+
15411541 ! generate a variable spaced rectangluar grid.
15421542 ! extend spacing from center of grid outward.
15431543 use ice_constants, only: c0, c1, c2, radius, cm_to_m, &
15441544 field_loc_center, field_loc_NEcorner, field_type_scalar
1545-
1545+
15461546 integer (kind= int_kind) :: &
15471547 i, j, iblk, &
15481548 imid, jmid, &
15491549 center1, center2 ! array centers for expanding dx, dy
1550-
1550+
15511551 real (kind= dbl_kind) :: &
15521552 length, &
15531553 rad_to_deg
15541554
15551555 real (kind= dbl_kind), dimension (:,:), allocatable :: &
15561556 work_g1
1557-
1557+
15581558 character (len=* ), parameter :: subname = ' (rectgrid_scale_dxdy)'
1559-
1559+
15601560 call icepack_query_parameters(rad_to_deg_out= rad_to_deg)
15611561
15621562 allocate (work_g1(nx_global,ny_global))
1563-
1563+
15641564 ! determine dx spacing
15651565 ! strategy: initialize with dxrect.
15661566 ! if want to scale the grid, work from center outwards,
15671567 ! multplying neighbor cell by scale factor.
15681568 ! this assumes dx varies in x direction only.
15691569 ! (i.e, dx is the same across same y location)
15701570 if (my_task == master_task) then
1571-
1571+
15721572 ! initialize with initial dxrect
15731573 work_g1(:,:) = dxrect
1574-
1574+
15751575 ! check if nx is even or odd
15761576 ! if even, middle 2 columns are center
15771577 ! of odd, middle 1 column is center
15781578 if (mod (nx_global,2 ) == 0 ) then ! nx_global is even
1579-
1579+
15801580 ! with even number of x locatons,
15811581 ! the center two y columns are center
15821582 center1 = nx_global/ 2 ! integer math
15831583 center2 = center1 + 1 ! integer math
1584-
1584+
15851585 else ! nx_global = odd
15861586 ! only one center index. set center2=center1
15871587 center1 = ceiling (real (nx_global/ 2 ),int_kind)
15881588 center2 = center1
15891589 endif
1590-
1590+
15911591 ! note loop over only half the x grid points (center1)-1
15921592 ! working from the center outward.
15931593 do j = 1 , ny_global
15941594 do i = 1 , center1-1
15951595 ! work from center1 to left
15961596 work_g1(center1- i,j) = dxscale* work_g1(center1- i+1 ,j)
1597-
1597+
15981598 ! work from center2 to right
15991599 work_g1(center2+ i,j) = dxscale* work_g1(center2+ i-1 ,j)
16001600 enddo ! i
16011601 enddo ! j
1602-
1602+
16031603 endif ! my_task == master_task
1604-
1605-
1604+
1605+
16061606 ! note work_g1 is converted to meters in primary_grid_lengths_HTN
16071607 call primary_grid_lengths_HTN(work_g1) ! dxU, dxT, dxN, dxE
1608-
1608+
16091609 ! make ULON array
16101610 if (my_task == master_task) then
1611-
1611+
16121612 ! make first column reference lon in radians.
16131613 ! the remaining work_g1 is still dx in meters
16141614 work_g1(1 ,:) = lonrefrect/ rad_to_deg ! radians
1615-
1615+
16161616 ! loop over remaining points and add spacing to successive
16171617 ! x locations
16181618 do j = 1 , ny_global
@@ -1626,57 +1626,57 @@ subroutine rectgrid_scale_dxdy
16261626 field_loc_NEcorner, field_type_scalar)
16271627 call ice_HaloExtrapolate(ULON, distrb_info, &
16281628 ew_boundary_type, ns_boundary_type)
1629-
1629+
16301630 ! determine dy spacing
16311631 ! strategy: initialize with dyrect.
16321632 ! if want to scale the grid, work from center outwards,
16331633 ! multplying neighbor cell by scale factor.
16341634 ! this assumes dy varies in y direction only.
16351635 ! (i.e, dy is the same across same x location)
16361636 if (my_task == master_task) then
1637-
1637+
16381638 ! initialize with initial dxrect
16391639 work_g1(:,:) = dyrect
16401640
16411641 ! check if ny is even or odd
16421642 ! if even, middle 2 rows are center
16431643 ! of odd, middle 1 row is center
16441644 if (mod (ny_global,2 ) == 0 ) then ! ny_global is even
1645-
1645+
16461646 ! with even number of x locatons,
16471647 ! the center two y columns are center
16481648 center1 = ny_global/ 2 ! integer math
16491649 center2 = center1 + 1 ! integer math
1650-
1650+
16511651 else ! ny_global = odd
16521652 ! only one center index. set center2=center1
16531653 center1 = ceiling (real (ny_global/ 2 ),int_kind)
16541654 center2 = center1
16551655 endif
1656-
1656+
16571657 ! note loop over only half the y grid points (center1)-1
16581658 ! working from the center outward.
16591659 do i = 1 , nx_global
16601660 do j = 1 , center1-1
16611661 ! work from center1 to bottom
16621662 work_g1(i,center1- j) = dyscale* work_g1(i,center1- j+1 )
1663-
1663+
16641664 ! work from center2 to top
16651665 work_g1(i,center2+ j) = dyscale* work_g1(i,center2+ j-1 )
16661666 enddo ! i
16671667 enddo ! j
16681668 endif ! mytask == master_task
16691669 ! note work_g1 is converted to meters primary_grid_lengths_HTE
16701670 call primary_grid_lengths_HTE(work_g1) ! dyU, dyT, dyN, dyE
1671-
1671+
16721672 ! make ULAT array
16731673 if (my_task == master_task) then
1674-
1674+
16751675 ! make first row reference lat in radians.
16761676 ! the remaining work_g1 is still dy in meters
16771677 work_g1(:,1 ) = latrefrect/ rad_to_deg ! radians
1678-
1679-
1678+
1679+
16801680 ! loop over remaining points and add spacing to successive
16811681 ! x locations
16821682 do j = 2 , ny_global ! start from j=2. j=1 is latrefrect
@@ -1690,10 +1690,10 @@ subroutine rectgrid_scale_dxdy
16901690 field_loc_NEcorner, field_type_scalar)
16911691 call ice_HaloExtrapolate(ULAT, distrb_info, &
16921692 ew_boundary_type, ns_boundary_type)
1693-
1693+
16941694
16951695 deallocate (work_g1)
1696-
1696+
16971697 end subroutine rectgrid_scale_dxdy
16981698
16991699! =======================================================================
0 commit comments