ocean_merge  1.13.0
All Files Functions Pages
merge.F90
1 
19  subroutine merge(lon, lat, binary_lake, lat2d, ocn_frac, &
20  lake_frac, lake_depth, land_frac, slmsk)
21 
22  implicit none
23 
24  integer, intent(in) :: lon, lat, binary_lake
25 
26  real, intent(in) :: lat2d(lon,lat)
27  real, intent(in) :: ocn_frac(lon,lat)
28  real, intent(inout) :: lake_frac(lon,lat)
29  real, intent(inout) :: lake_depth(lon,lat)
30  real, intent(out) :: land_frac(lon,lat)
31  real, intent(out) :: slmsk(lon,lat)
32 
33  real, parameter :: min_land=1.e-4, def_lakedp=10.
34 
35  integer :: i, j, nodp_pt, lake_pt
36 
37  nodp_pt=0
38  lake_pt=0
39 
40  do i=1,lon
41  do j=1,lat
42  if (binary_lake.eq.1) lake_frac(i,j)=nint(lake_frac(i,j)) ! using integer lake_frac
43  if (lat2d(i,j).le.-60.) lake_frac(i,j)=0. ! ignore lakes on Antarctica
44  land_frac(i,j)=1.-ocn_frac(i,j)
45  if (land_frac(i,j) < min_land) land_frac(i,j)=0. ! ignore land < min_land
46  if (land_frac(i,j) > 1.-min_land) land_frac(i,j)=1. ! ignore water < min_land
47  if (1.-land_frac(i,j) > 0.) lake_frac(i,j)=0. ! ocn dominates
48 
49  if (lake_frac(i,j) > 0.) then
50  lake_pt=lake_pt+1 ! calculating total lake points
51  if (binary_lake.eq.1) then
52  land_frac(i,j)=0.
53  else
54  land_frac(i,j)=1.-lake_frac(i,j)
55  end if
56  if (lake_depth(i,j) <= 0.) then
57  lake_depth(i,j)=def_lakedp ! set missing lake depth to default value
58  nodp_pt=nodp_pt+1 ! calculating total lake points without depth
59  end if
60  else
61  lake_depth(i,j)=0.
62  end if
63  slmsk(i,j) = nint(land_frac(i,j)) ! nint got the land pts correct
64  end do
65  end do
66 
67  write(*,'(a,i8,a,i8,a)') 'Total lake point ',lake_pt,' where ',nodp_pt,' has no depth'
68 
69  end subroutine merge