31 use constants_mod,
only : radius
38 public :: gradient_cubic
39 public :: calc_cubic_grid_info
42 #include<file_version.h>
61 subroutine gradient_cubic(pin, dx, dy, area, edge_w, edge_e, edge_s, edge_n, &
62 en_n, en_e, vlon, vlat, grad_x, grad_y, on_west_edge, &
63 on_east_edge, on_south_edge, on_north_edge)
65 real(r8_kind),
dimension(:,: ),
intent(in ) :: pin, dx, dy, area
66 real(r8_kind),
dimension(: ),
intent(in ) :: edge_w, edge_e, edge_s, edge_n
67 real(r8_kind),
dimension(:,:,:),
intent(in ) :: en_n, en_e
68 real(r8_kind),
dimension(:,:,:),
intent(in ) :: vlon, vlat
69 real(r8_kind),
dimension(:,: ),
intent(out) :: grad_x, grad_y
70 logical,
intent(in ) :: on_west_edge, on_east_edge, on_south_edge, on_north_edge
77 if(
size(pin,1) .NE. nx+2 .OR.
size(pin,2) .NE. ny+2)
call mpp_error(fatal, &
78 &
"gradient_mod:size of pin should be (nx+2, ny+2)")
79 if(
size(dx,1) .NE. nx .OR.
size(dx,2) .NE. ny+1 )
call mpp_error(fatal, &
80 &
"gradient_mod: size of dx should be (nx,ny+1)")
81 if(
size(dy,1) .NE. nx+1 .OR.
size(dy,2) .NE. ny )
call mpp_error(fatal, &
82 &
"gradient_mod: size of dy should be (nx+1,ny)")
83 if(
size(area,1) .NE. nx .OR.
size(area,2) .NE. ny )
call mpp_error(fatal, &
84 &
"gradient_mod: size of area should be (nx,ny)")
85 if(
size(vlon,1) .NE. 3 .OR.
size(vlon,2) .NE. nx .OR.
size(vlon,3) .NE. ny) &
86 call mpp_error(fatal,
"gradient_mod: size of vlon should be (3,nx,ny)")
87 if(
size(vlat,1) .NE. 3 .OR.
size(vlat,2) .NE. nx .OR.
size(vlat,3) .NE. ny) &
88 call mpp_error(fatal,
"gradient_mod: size of vlat should be (3,nx,ny)")
89 if(
size(edge_w) .NE. ny+1)
call mpp_error(fatal,
"gradient_mod: size of edge_w should be (ny+1)")
90 if(
size(edge_e) .NE. ny+1)
call mpp_error(fatal,
"gradient_mod: size of edge_e should be (ny+1)")
91 if(
size(edge_s) .NE. nx+1)
call mpp_error(fatal,
"gradient_mod: size of edge_s should be (nx+1)")
92 if(
size(edge_n) .NE. nx+1)
call mpp_error(fatal,
"gradient_mod: size of edge_n should be (nx+1)")
93 if(
size(en_n,1) .NE. 3 .OR.
size(en_n,2) .NE. nx .OR.
size(en_n,3) .NE. ny+1 ) &
94 call mpp_error(fatal,
"gradient_mod:size of en_n should be (3, nx, ny+1)")
95 if(
size(en_e,1) .NE. 3 .OR.
size(en_e,2) .NE. nx+1 .OR.
size(en_e,3) .NE. ny ) &
96 call mpp_error(fatal,
"gradient_mod:size of en_e should be (3, nx+1, ny)")
98 call grad_c2l(nx, ny, pin, dx, dy, area, edge_w, edge_e, edge_s, edge_n, en_n, en_e, vlon, vlat, &
99 grad_x, grad_y, on_west_edge, on_east_edge, on_south_edge, on_north_edge)
103 end subroutine gradient_cubic
106 subroutine calc_cubic_grid_info(xt, yt, xc, yc, dx, dy, area, edge_w, edge_e, edge_s, edge_n, &
107 en_n, en_e, vlon, vlat, on_west_edge, on_east_edge, on_south_edge, on_north_edge )
108 real(r8_kind),
dimension(:,: ),
intent(in ) :: xt, yt, xc, yc
109 real(r8_kind),
dimension(:,: ),
intent(out) :: dx, dy, area
110 real(r8_kind),
dimension(: ),
intent(out) :: edge_w, edge_e, edge_s, edge_n
111 real(r8_kind),
dimension(:,:,:),
intent(out) :: en_n, en_e
112 real(r8_kind),
dimension(:,:,:),
intent(out) :: vlon, vlat
113 logical,
intent(in ) :: on_west_edge, on_east_edge, on_south_edge, on_north_edge
114 integer :: nx, ny, nxp, nyp
122 if(
size(xt,1) .NE. nx+2 .OR.
size(xt,2) .NE. ny+2 )
call mpp_error(fatal, &
123 &
"gradient_mod: size of xt should be (nx+2,ny+2)")
124 if(
size(yt,1) .NE. nx+2 .OR.
size(yt,2) .NE. ny+2 )
call mpp_error(fatal, &
125 &
"gradient_mod: size of yt should be (nx+2,ny+2)")
126 if(
size(xc,1) .NE. nxp .OR.
size(xc,2) .NE. nyp )
call mpp_error(fatal, &
127 &
"gradient_mod: size of xc should be (nx+1,ny+1)")
128 if(
size(yc,1) .NE. nxp .OR.
size(yc,2) .NE. nyp )
call mpp_error(fatal, &
129 &
"gradient_mod: size of yc should be (nx+1,ny+1)")
130 if(
size(dx,1) .NE. nx .OR.
size(dx,2) .NE. nyp )
call mpp_error(fatal, &
131 &
"gradient_mod: size of dx should be (nx,ny+1)")
132 if(
size(dy,1) .NE. nxp .OR.
size(dy,2) .NE. ny )
call mpp_error(fatal, &
133 &
"gradient_mod: size of dy should be (nx+1,ny)")
134 if(
size(area,1) .NE. nx .OR.
size(area,2) .NE. ny )
call mpp_error(fatal, &
135 &
"gradient_mod: size of area should be (nx,ny)")
136 if(
size(vlon,1) .NE. 3 .OR.
size(vlon,2) .NE. nx .OR.
size(vlon,3) .NE. ny) &
137 call mpp_error(fatal,
"gradient_mod: size of vlon should be (3,nx,ny)")
138 if(
size(vlat,1) .NE. 3 .OR.
size(vlat,2) .NE. nx .OR.
size(vlat,3) .NE. ny) &
139 call mpp_error(fatal,
"gradient_mod: size of vlat should be (3,nx,ny)")
140 if(
size(edge_w) .NE. ny+1)
call mpp_error(fatal,
"gradient_mod: size of edge_w should be (ny-1)")
141 if(
size(edge_e) .NE. ny+1)
call mpp_error(fatal,
"gradient_mod: size of edge_e should be (ny-1)")
142 if(
size(edge_s) .NE. nx+1)
call mpp_error(fatal,
"gradient_mod: size of edge_s should be (nx-1)")
143 if(
size(edge_n) .NE. nx+1)
call mpp_error(fatal,
"gradient_mod: size of edge_n should be (nx-1)")
144 if(
size(en_n,1) .NE. 3 .OR.
size(en_n,2) .NE. nx .OR.
size(en_n,3) .NE. nyp ) &
145 call mpp_error(fatal,
"gradient_mod:size of en_n should be (3, nx, ny+1)")
146 if(
size(en_e,1) .NE. 3 .OR.
size(en_e,2) .NE. nxp .OR.
size(en_e,3) .NE. ny ) &
147 call mpp_error(fatal,
"gradient_mod:size of en_e should be (3, nx+1, ny)")
150 call calc_c2l_grid_info(nx, ny, xt, yt, xc, yc, dx, dy, area, edge_w, edge_e, edge_s, edge_n, &
151 en_n, en_e, vlon, vlat, on_west_edge, on_east_edge, on_south_edge, on_north_edge )
156 end subroutine calc_cubic_grid_info
158 end module gradient_mod