9 use fckit_configuration_module,
only: fckit_configuration
12 use fv_arrays_mod,
only: r_grid
13 use fv_grid_utils_mod,
only: mid_pt_sphere, get_unit_vect2, get_latlon_vector, inner_prod
27 integer :: isc, iec, jsc, jec
28 real(kind=
kind_real),
allocatable,
dimension(:,:,:) :: grid
45 type(fckit_configuration),
intent(in) :: conf
47 allocate(self%grid(geom%isd:geom%ied+1,geom%jsd:geom%jed+1,2))
76 character(len=field_clen),
allocatable :: fields_to_do(:)
77 real(kind=
kind_real),
pointer :: field_ptr(:,:,:)
80 logical :: have_d_winds
81 integer :: i, j, k, levp
82 real(kind=
kind_real),
allocatable :: ud_cold(:,:,:)
83 real(kind=
kind_real),
allocatable :: vd_cold(:,:,:)
84 real(kind=
kind_real),
pointer :: u_w_cold(:,:,:)
85 real(kind=
kind_real),
pointer :: v_w_cold(:,:,:)
86 real(kind=
kind_real),
pointer :: u_s_cold(:,:,:)
87 real(kind=
kind_real),
pointer :: v_s_cold(:,:,:)
89 real(kind=r_grid),
dimension(2) :: p1, p2, p3
90 real(kind=r_grid),
dimension(3) :: e1, e2, ex, ey
94 call copy_subset(xin%fields, xout%fields, fields_to_do)
99 if (.not.
allocated(fields_to_do))
return
104 have_d_winds = .false.
105 if ( xin%has_field(
'u_w_cold') .and. xin%has_field(
'v_w_cold') .and. &
106 xin%has_field(
'u_s_cold') .and. xin%has_field(
'v_s_cold') )
then
108 call xin%get_field(
'u_w_cold', u_w_cold)
109 call xin%get_field(
'v_w_cold', v_w_cold)
110 call xin%get_field(
'u_s_cold', u_s_cold)
111 call xin%get_field(
'v_s_cold', v_s_cold)
113 levp =
size(u_w_cold,3)
115 allocate(ud_cold(self%isc:self%iec, self%jsc:self%jec+1,1:levp))
116 allocate(vd_cold(self%isc:self%iec+1,self%jsc:self%jec, 1:levp))
119 do j = self%jsc, self%jec+1
120 do i = self%isc, self%iec
121 p1(:) = self%grid(i, j,1:2)
122 p2(:) = self%grid(i+1,j,1:2)
123 call mid_pt_sphere(p1, p2, p3)
124 call get_unit_vect2(p1, p2, e1)
125 call get_latlon_vector(p3, ex, ey)
126 ud_cold(i,j,k) = u_s_cold(i,j,k)*inner_prod(e1, ex) + v_s_cold(i,j,k)*inner_prod(e1, ey)
129 do j = self%jsc, self%jec
130 do i = self%isc, self%iec+1
131 p1(:) = self%grid(i,j ,1:2)
132 p2(:) = self%grid(i,j+1,1:2)
133 call mid_pt_sphere(p1, p2, p3)
134 call get_unit_vect2(p1, p2, e2)
135 call get_latlon_vector(p3, ex, ey)
136 vd_cold(i,j,k) = u_w_cold(i,j,k)*inner_prod(e2, ex) + v_w_cold(i,j,k)*inner_prod(e2, ey)
141 have_d_winds = .true.
148 do f = 1,
size(fields_to_do)
150 call xout%get_field(trim(fields_to_do(f)), field_ptr)
152 select case (trim(fields_to_do(f)))
156 if (.not. have_d_winds)
call field_fail(fields_to_do(f))
161 if (.not. have_d_winds)
call field_fail(fields_to_do(f))
166 call abor1_ftn(
"fv3jedi_vc_coldstartwinds_mod.changevar unknown field: "//trim(fields_to_do(f))&
167 //
". Not in input field and no transform case specified.")
175 xout%calendar_type = xin%calendar_type
176 xout%date_init = xin%date_init