FV3-JEDI
fv3jedi_vc_model2geovals_mod.f90
Go to the documentation of this file.
1 ! (C) Copyright 2020 UCAR
2 !
3 ! This software is licensed under the terms of the Apache Licence Version 2.0
4 ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5 
7 
8 use iso_c_binding
9 
10 use fckit_configuration_module, only: fckit_configuration
11 use fckit_log_module, only: fckit_log
12 
13 use datetime_mod
14 
21 
22 use height_vt_mod
27 use wind_vt_mod
28 
29 implicit none
30 
31 private
33 
35  integer :: isc, iec, jsc, jec, npz
36  contains
37  procedure, public :: create
38  procedure, public :: delete
39  procedure, public :: changevar
41 
42 ! --------------------------------------------------------------------------------------------------
43 
44 contains
45 
46 ! --------------------------------------------------------------------------------------------------
47 
48 subroutine create(self, geom, dummyconf)
49 
50 class(fv3jedi_vc_model2geovals), intent(inout) :: self
51 type(fv3jedi_geom), intent(in) :: geom
52 type(fckit_configuration), intent(in) :: dummyconf
53 
54 !!! DO NOT USE CONF !!!
55 
56 ! Grid convenience
57 self%isc = geom%isc
58 self%iec = geom%iec
59 self%jsc = geom%jsc
60 self%jec = geom%jec
61 self%npz = geom%npz
62 
63 end subroutine create
64 
65 ! --------------------------------------------------------------------------------------------------
66 
67 subroutine delete(self)
68 
69 class(fv3jedi_vc_model2geovals), intent(inout) :: self
70 
71 end subroutine delete
72 
73 ! --------------------------------------------------------------------------------------------------
74 
75 subroutine changevar(self, geom, xm, xg)
76 
77 class(fv3jedi_vc_model2geovals), intent(inout) :: self
78 type(fv3jedi_geom), intent(inout) :: geom
79 type(fv3jedi_state), intent(in) :: xm
80 type(fv3jedi_state), intent(inout) :: xg
81 
82 integer :: f, jlev, i, j, k
83 character(len=field_clen), allocatable :: fields_to_do(:)
84 real(kind=kind_real), pointer :: field_ptr(:,:,:)
85 
86 ! Specific humidity
87 logical :: have_q
88 real(kind=kind_real), pointer :: q(:,:,:) !Specific humidity
89 
90 ! Relative humidity
91 logical :: have_rh
92 real(kind=kind_real), allocatable :: rh(:,:,:) !Relative humidity
93 real(kind=kind_real), pointer :: qsat(:,:,:) !Saturation specific humidity
94 
95 ! Pressure fields
96 logical :: have_pressures
97 real(kind=kind_real), allocatable :: ps(:,:,:) !Surface pressure
98 real(kind=kind_real), allocatable :: delp(:,:,:) !Pressure thickness
99 real(kind=kind_real), allocatable :: prsi(:,:,:) !Pressure, interfaces
100 real(kind=kind_real), allocatable :: prs(:,:,:) !Pressure, midpoint
101 
102 ! Temperature fields
103 logical :: have_t
104 real(kind=kind_real), allocatable :: t(:,:,:) !Temperature
105 real(kind=kind_real), pointer :: pt(:,:,:) !Potential temperature
106 real(kind=kind_real), allocatable :: pkz(:,:,:) !Pressure to the kapaa
107 
108 ! Vitual temperature
109 logical :: have_tv
110 real(kind=kind_real), allocatable :: tv(:,:,:) !Virtual temperature
111 
112 ! Geopotential heights
113 logical :: have_geoph
114 real(kind=kind_real), allocatable :: geophi(:,:,:) !Geopotential height, interfaces
115 real(kind=kind_real), allocatable :: geoph(:,:,:) !Geopotential height
116 real(kind=kind_real), allocatable :: suralt(:,:,:) !Surface altitude
117 real(kind=kind_real), pointer :: phis(:,:,:) !Surface geopotential height
118 logical, parameter :: use_compress = .true.
119 
120 ! Ozone
121 logical :: have_o3
122 logical :: have_mass
123 real(kind=kind_real), allocatable :: o3(:,:,:) !Ozone mixing ratio
124 ! Winds
125 logical :: have_winds
126 real(kind=kind_real), allocatable :: ua(:,:,:) !Eastward wind
127 real(kind=kind_real), allocatable :: va(:,:,:) !Northward wind
128 real(kind=kind_real), pointer :: ud(:,:,:) !u component D-grid
129 real(kind=kind_real), pointer :: vd(:,:,:) !v component D-grid
130 
131 ! Sea-land mask
132 logical :: have_slmsk
133 real(kind=kind_real), allocatable :: slmsk(:,:,:) !Land-sea mask
134 real(kind=kind_real), pointer :: frocean(:,:,:) !Fraction ocean
135 real(kind=kind_real), pointer :: frlake(:,:,:) !Fraction lake
136 real(kind=kind_real), pointer :: frseaice(:,:,:) !Fraction seaice
137 real(kind=kind_real), pointer :: tsea(:,:,:) !Surface temperature
138 
139 !f10m
140 logical :: have_f10m
141 real(kind=kind_real), allocatable :: f10m(:,:,:) !Land-sea mask
142 real(kind=kind_real), pointer :: u_srf(:,:,:)
143 real(kind=kind_real), pointer :: v_srf(:,:,:)
144 real(kind=kind_real) :: wspd
145 
146 !qiql
147 logical :: have_qiql
148 real(kind=kind_real), allocatable :: qi(:,:,:)
149 real(kind=kind_real), allocatable :: ql(:,:,:)
150 real(kind=kind_real), pointer :: qils(:,:,:)
151 real(kind=kind_real), pointer :: qicn(:,:,:)
152 real(kind=kind_real), pointer :: qlls(:,:,:)
153 real(kind=kind_real), pointer :: qlcn(:,:,:)
154 
155 !CRTM mixing ratio
156 logical :: have_qmr
157 real(kind=kind_real), allocatable :: qmr(:,:,:) !Land-sea mask
158 
159 !CRTM moisture fields
160 logical :: have_crtm_cld
161 real(kind=kind_real), allocatable :: ql_ade(:,:,:)
162 real(kind=kind_real), allocatable :: qi_ade(:,:,:)
163 real(kind=kind_real), allocatable :: ql_efr(:,:,:)
164 real(kind=kind_real), allocatable :: qi_efr(:,:,:)
165 real(kind=kind_real), allocatable :: watercov(:,:)
166 
167 !Salinity
168 logical :: have_sss
169 real(kind=kind_real), allocatable :: sss(:,:,:)
170 
171 !CRTM surface
172 logical :: have_crtm_surface
173 real(kind=kind_real), pointer :: sheleg(:,:,:)
174 real(kind=kind_real), pointer :: vtype(:,:,:)
175 real(kind=kind_real), pointer :: stype(:,:,:)
176 real(kind=kind_real), pointer :: vfrac(:,:,:)
177 real(kind=kind_real), pointer :: stc(:,:,:)
178 real(kind=kind_real), pointer :: smc(:,:,:)
179 real(kind=kind_real), allocatable :: land_type_index(:,:,:)
180 real(kind=kind_real), allocatable :: vegetation_type_index(:,:,:)
181 real(kind=kind_real), allocatable :: soil_type(:,:,:)
182 real(kind=kind_real), allocatable :: water_area_fraction(:,:,:)
183 real(kind=kind_real), allocatable :: land_area_fraction(:,:,:)
184 real(kind=kind_real), allocatable :: ice_area_fraction(:,:,:)
185 real(kind=kind_real), allocatable :: surface_snow_area_fraction(:,:,:)
186 real(kind=kind_real), allocatable :: leaf_area_index(:,:,:)
187 real(kind=kind_real), allocatable :: surface_temperature_where_sea(:,:,:)
188 real(kind=kind_real), allocatable :: surface_temperature_where_land(:,:,:)
189 real(kind=kind_real), allocatable :: surface_temperature_where_ice(:,:,:)
190 real(kind=kind_real), allocatable :: surface_temperature_where_snow(:,:,:)
191 real(kind=kind_real), allocatable :: volume_fraction_of_condensed_water_in_soil(:,:,:)
192 real(kind=kind_real), allocatable :: vegetation_area_fraction(:,:,:)
193 real(kind=kind_real), allocatable :: soil_temperature(:,:,:)
194 real(kind=kind_real), allocatable :: surface_snow_thickness(:,:,:)
195 real(kind=kind_real), allocatable :: surface_wind_speed(:,:,:)
196 real(kind=kind_real), allocatable :: surface_wind_from_direction(:,:,:)
197 real(kind=kind_real), allocatable :: sea_surface_salinity(:,:,:)
198 
199 
200 ! Identity part of the change of fields
201 ! -------------------------------------
202 call copy_subset(xm%fields, xg%fields, fields_to_do)
203 
204 
205 ! if (geom%f_comm%rank()==0) then
206 ! do f = 1, size(xm%fields)
207 ! print*, "Model2GeoVaLs.changeVar, Model fields: ", trim(xm%fields(f)%fv3jedi_name)
208 ! enddo
209 ! do f = 1, size(xg%fields)
210 ! print*, "Model2GeoVaLs.changeVar, GeoVaLs fields: ", trim(xg%fields(f)%fv3jedi_name)
211 ! enddo
212 ! do f = 1, size(fields_to_do)
213 ! print*, "Model2GeoVaLs.changeVar, GeoVaLs needed by transform: ", trim(fields_to_do(f))
214 ! enddo
215 ! endif
216 
217 
218 ! If variable change is the identity early exit
219 ! ---------------------------------------------
220 if (.not.allocated(fields_to_do)) return
221 
222 
223 ! Get pressures at edge, center & log center
224 ! ------------------------------------------
225 have_pressures = .false.
226 
227 if (xm%has_field('delp')) then
228  call xm%get_field('delp', delp)
229  allocate(ps(self%isc:self%iec, self%jsc:self%jec, 1))
230  ps(:,:,1) = sum(delp,3)
231  have_pressures = .true.
232 elseif (xm%has_field('ps')) then
233  call xm%get_field('ps', ps)
234  allocate(delp(self%isc:self%iec, self%jsc:self%jec, self%npz))
235  do jlev = 1,self%npz
236  delp(:,:,jlev) = (geom%ak(jlev+1)-geom%ak(jlev))+(geom%bk(jlev+1)-geom%bk(jlev))*ps(:,:,1)
237  enddo
238  have_pressures = .true.
239 elseif (xm%has_field('pe')) then
240  call xm%get_field('pe', prsi)
241  allocate(ps(self%isc:self%iec, self%jsc:self%jec, 1))
242  ps(:,:,1) = prsi(:,:,self%npz+1)
243  allocate(delp(self%isc:self%iec, self%jsc:self%jec, self%npz))
244  do jlev = 1,self%npz
245  delp(:,:,jlev) = prsi(:,:,jlev+1) - prsi(:,:,jlev)
246  enddo
247  have_pressures = .true.
248 endif
249 
250 if (have_pressures) then
251  if (.not.allocated(prsi)) allocate(prsi(self%isc:self%iec,self%jsc:self%jec,self%npz+1))
252  if (.not.allocated(prs )) allocate(prs(self%isc:self%iec,self%jsc:self%jec,self%npz ))
253  call delp_to_pe_p_logp(geom, delp, prsi, prs)
254 endif
255 
256 
257 ! Temperature
258 ! -----------
259 have_t = .false.
260 
261 if (xm%has_field( 't')) then
262  call xm%get_field('t', t)
263  have_t = .true.
264 elseif (xm%has_field( 'pt')) then
265  if (.not. have_pressures) &
266  call abor1_ftn("fv3jedi_vc_model2geovals_mod.changevar: a state with pt needs pressures")
267  allocate(t(self%isc:self%iec, self%jsc:self%jec, self%npz))
268  allocate(pkz(self%isc:self%iec, self%jsc:self%jec, self%npz))
269  call xm%get_field('pt', pt)
270  call pe_to_pkz(geom, prsi, pkz)
271  call pt_to_t(geom, pkz, pt, t)
272  have_t = .true.
273 endif
274 
275 
276 ! Specific humidity
277 ! -----------------
278 have_q = .false.
279 if (xm%has_field( 'sphum')) then
280  call xm%get_field('sphum', q)
281  have_q = .true.
282 endif
283 
284 
285 ! Relative humidity
286 ! -----------------
287 have_rh = .false.
288 if (xm%has_field('rh')) then
289  call xm%get_field('rh', rh)
290  have_rh = .true.
291 elseif (have_t .and. have_pressures .and. have_q) then
292  allocate(qsat(self%isc:self%iec,self%jsc:self%jec,self%npz))
293  allocate(rh(self%isc:self%iec,self%jsc:self%jec,self%npz))
294  call get_qsat(geom,delp,t,q,qsat)
295  call q_to_rh(geom,qsat,q,rh)
296  deallocate(qsat)
297  have_rh = .true.
298 endif
299 
300 
301 ! Geopotential height
302 ! -------------------
303 have_geoph = .false.
304 if (have_t .and. have_pressures .and. have_q .and. xm%has_field( 'phis')) then
305  call xm%get_field('phis', phis)
306  if (.not.allocated(geophi)) allocate(geophi(self%isc:self%iec,self%jsc:self%jec,self%npz+1))
307  if (.not.allocated(geoph )) allocate(geoph(self%isc:self%iec,self%jsc:self%jec,self%npz ))
308  if (.not.allocated(suralt)) allocate(suralt(self%isc:self%iec,self%jsc:self%jec,self%npz ))
309  call geop_height(geom, prs, prsi, t, q, phis(:,:,1), use_compress, geoph)
310  call geop_height_levels(geom, prs, prsi, t, q, phis(:,:,1), use_compress, geophi)
311  suralt = phis / grav
312  have_geoph = .true.
313 endif
314 
315 
316 ! Virtual temperature
317 ! -------------------
318 have_tv = .false.
319 if (have_t .and. have_q) then
320  allocate(tv(self%isc:self%iec,self%jsc:self%jec,self%npz))
321  call t_to_tv(geom, t, q, tv)
322  have_tv = .true.
323 endif
324 
325 
326 ! Ozone
327 ! -----
328 have_o3 = .false.
329 have_mass = .false.
330 if (xm%has_field( 'o3mr') .or. xm%has_field( 'o3ppmv')) then
331  if (xm%has_field( 'o3mr')) call xm%get_field('o3mr', o3)
332  if (xm%has_field( 'o3ppmv')) call xm%get_field('o3ppmv', o3)
333  have_mass = xm%has_field( 'o3mr')
334  have_o3 = .true.
335  do k = 1, self%npz
336  do j = self%jsc, self%jec
337  do i = self%isc, self%iec
338  if (o3(i,j,k) >= 0.0_kind_real .and. have_mass) then
339  o3(i,j,k) = o3(i,j,k) * constoz
340  else if (o3(i,j,k) < 0.0_kind_real ) then
341  o3(i,j,k) = 0.0_kind_real
342  endif
343  enddo
344  enddo
345  enddo
346 endif
347 
348 
349 ! Wind transforms
350 ! ---------------
351 have_winds = .false.
352 if (xm%has_field('ua')) then
353  call xm%get_field('ua', ua)
354  call xm%get_field('va', va)
355  have_winds = .true.
356 elseif (xm%has_field('ud')) then
357  call xm%get_field('ud', ud)
358  call xm%get_field('vd', vd)
359  allocate(ua(self%isc:self%iec,self%jsc:self%jec,self%npz))
360  allocate(va(self%isc:self%iec,self%jsc:self%jec,self%npz))
361  call d2a(geom, ud, vd, ua, va)
362  have_winds = .true.
363 endif
364 
365 
366 ! Land sea mask
367 ! -------------
368 have_slmsk = .false.
369 if (xm%has_field( 'slmsk')) then
370  call xm%get_field('slmsk', slmsk)
371  have_slmsk = .true.
372 elseif ( xm%has_field('frocean' ) .and. xm%has_field('frlake' ) .and. &
373  xm%has_field('frseaice') .and. xm%has_field('tsea' ) ) then
374  call xm%get_field('frocean' , frocean )
375  call xm%get_field('frlake' , frlake )
376  call xm%get_field('frseaice', frseaice)
377  call xm%get_field('tsea' , tsea )
378 
379  allocate(slmsk(self%isc:self%iec,self%jsc:self%jec,1))
380  slmsk = 1.0_kind_real !Land
381  do j = self%jsc,self%jec
382  do i = self%isc,self%iec
383  if ( frocean(i,j,1) + frlake(i,j,1) >= 0.6_kind_real) then
384  slmsk(i,j,1) = 0.0_kind_real ! Water
385  endif
386  if ( slmsk(i,j,1) == 0.0_kind_real .and. frseaice(i,j,1) > 0.5_kind_real) then
387  slmsk(i,j,1) = 2.0_kind_real ! Ice
388  endif
389  if ( slmsk(i,j,1) == 0.0_kind_real .and. tsea(i,j,1) < 271.4_kind_real ) then
390  slmsk(i,j,1) = 2.0_kind_real ! Ice
391  endif
392  enddo
393  enddo
394  have_slmsk = .true.
395 endif
396 
397 
398 ! f10m
399 ! ----
400 have_f10m = .false.
401 if (xm%has_field('f10m')) then
402  call xm%get_field('f10m', f10m)
403  have_f10m = .true.
404 elseif ( xm%has_field( 'u_srf') .and. xm%has_field( 'v_srf') .and. have_winds ) then
405  call xm%get_field('u_srf' , u_srf)
406  call xm%get_field('v_srf' , v_srf)
407 
408  allocate(f10m(self%isc:self%iec,self%jsc:self%jec,1))
409  f10m = sqrt(u_srf**2 + v_srf**2)
410 
411  do j = self%jsc,self%jec
412  do i = self%isc,self%iec
413  wspd = sqrt(ua(i,j,self%npz)**2 + va(i,j,self%npz)**2)
414  if (f10m(i,j,1) > 0.0_kind_real) then
415  f10m(i,j,1) = f10m(i,j,1)/wspd
416  else
417  f10m(i,j,1) = 1.0_kind_real
418  endif
419  enddo
420  enddo
421  have_f10m = .true.
422 endif
423 
424 
425 ! CRTM mixing ratio
426 ! -----------------
427 have_qmr = .false.
428 if (have_q) then
429  allocate(qmr(self%isc:self%iec,self%jsc:self%jec,self%npz))
430  call crtm_mixratio(geom, q, qmr)
431  have_qmr = .true.
432 endif
433 
434 
435 ! Clouds
436 ! ------
437 have_qiql = .false.
438 if (xm%has_field( 'ice_wat') .and. xm%has_field( 'liq_wat')) then
439  call xm%get_field('ice_wat', qi)
440  call xm%get_field('liq_wat', ql)
441  have_qiql = .true.
442 elseif (xm%has_field( 'qils') .and. xm%has_field( 'qicn') .and. &
443  xm%has_field( 'qlls') .and. xm%has_field( 'qlcn')) then
444  call xm%get_field('qils', qils)
445  call xm%get_field('qicn', qicn)
446  call xm%get_field('qlls', qlls)
447  call xm%get_field('qlcn', qlcn)
448  allocate(qi(self%isc:self%iec,self%jsc:self%jec,self%npz))
449  allocate(ql(self%isc:self%iec,self%jsc:self%jec,self%npz))
450  qi = qils + qicn
451  ql = qlls + qlcn
452  have_qiql = .true.
453 endif
454 
455 
456 ! Get CRTM moisture fields
457 ! ------------------------
458 have_crtm_cld = .false.
459 if (have_slmsk .and. have_t .and. have_pressures .and. have_q .and. have_qiql ) then
460  allocate(ql_ade(self%isc:self%iec,self%jsc:self%jec,self%npz))
461  allocate(qi_ade(self%isc:self%iec,self%jsc:self%jec,self%npz))
462  allocate(ql_efr(self%isc:self%iec,self%jsc:self%jec,self%npz))
463  allocate(qi_efr(self%isc:self%iec,self%jsc:self%jec,self%npz))
464  allocate(watercov(self%isc:self%iec,self%jsc:self%jec))
465  ql_ade = 0.0_kind_real
466  qi_ade = 0.0_kind_real
467  ql_efr = 0.0_kind_real
468  qi_efr = 0.0_kind_real
469 
470  !TODO Is it water_area_fraction or sea_coverage fed in here?
471  watercov = 0.0_kind_real
472  do j = self%jsc,self%jec
473  do i = self%isc,self%iec
474  if (slmsk(i,j,1) == 0) watercov(i,j) = 1.0_kind_real
475  enddo
476  enddo
477  call crtm_ade_efr( geom, prsi, t, delp, watercov, q, ql, qi, &
478  ql_ade, qi_ade, ql_efr, qi_efr )
479  have_crtm_cld = .true.
480 endif
481 
482 
483 ! CRTM moisture fields
484 ! --------------------
485 have_crtm_surface = .false.
486 have_sss = .false.
487 if ( have_slmsk .and. have_f10m .and. xm%has_field( 'sheleg') .and. &
488  xm%has_field( 'tsea' ) .and. xm%has_field( 'vtype' ) .and. &
489  xm%has_field( 'stype' ) .and. xm%has_field( 'vfrac' ) .and. &
490  xm%has_field( 'stc' ) .and. xm%has_field( 'smc' ) .and. &
491  xm%has_field( 'u_srf' ) .and. xm%has_field( 'v_srf' ) ) then
492 
493  call xm%get_field('sheleg', sheleg)
494  call xm%get_field('tsea' , tsea )
495  call xm%get_field('vtype' , vtype )
496  call xm%get_field('stype' , stype )
497  call xm%get_field('vfrac' , vfrac )
498  call xm%get_field('stc' , stc )
499  call xm%get_field('smc' , smc )
500  call xm%get_field('u_srf' , u_srf )
501  call xm%get_field('v_srf' , v_srf )
502 
503  allocate(land_type_index(self%isc:self%iec,self%jsc:self%jec,1))
504  allocate(vegetation_type_index(self%isc:self%iec,self%jsc:self%jec,1))
505  allocate(soil_type(self%isc:self%iec,self%jsc:self%jec,1))
506  allocate(water_area_fraction(self%isc:self%iec,self%jsc:self%jec,1))
507  allocate(land_area_fraction(self%isc:self%iec,self%jsc:self%jec,1))
508  allocate(ice_area_fraction(self%isc:self%iec,self%jsc:self%jec,1))
509  allocate(surface_snow_area_fraction(self%isc:self%iec,self%jsc:self%jec,1))
510  allocate(leaf_area_index(self%isc:self%iec,self%jsc:self%jec,1))
511  allocate(surface_temperature_where_sea(self%isc:self%iec,self%jsc:self%jec,1))
512  allocate(surface_temperature_where_land(self%isc:self%iec,self%jsc:self%jec,1))
513  allocate(surface_temperature_where_ice(self%isc:self%iec,self%jsc:self%jec,1))
514  allocate(surface_temperature_where_snow(self%isc:self%iec,self%jsc:self%jec,1))
515  allocate(volume_fraction_of_condensed_water_in_soil(self%isc:self%iec,self%jsc:self%jec,1))
516  allocate(vegetation_area_fraction(self%isc:self%iec,self%jsc:self%jec,1))
517  allocate(soil_temperature(self%isc:self%iec,self%jsc:self%jec,1))
518  allocate(surface_snow_thickness(self%isc:self%iec,self%jsc:self%jec,1))
519  allocate(surface_wind_speed(self%isc:self%iec,self%jsc:self%jec,1))
520  allocate(surface_wind_from_direction(self%isc:self%iec,self%jsc:self%jec,1))
521  allocate(sea_surface_salinity(self%isc:self%iec,self%jsc:self%jec,1))
522 
523  allocate(sss(self%isc:self%iec,self%jsc:self%jec,1))
524  sss = 0.0_kind_real
525  if (xm%has_field( 'sss')) then
526  call xm%get_field('sss', sss)
527  have_sss = .true.
528  endif
529 
530  call crtm_surface( geom, slmsk, sheleg, tsea, vtype, stype, vfrac, stc, smc, u_srf, v_srf, &
531  f10m, sss, land_type_index, vegetation_type_index, soil_type, &
532  water_area_fraction, land_area_fraction, ice_area_fraction, &
533  surface_snow_area_fraction, leaf_area_index, surface_temperature_where_sea, &
534  surface_temperature_where_land, surface_temperature_where_ice, &
535  surface_temperature_where_snow, volume_fraction_of_condensed_water_in_soil, &
536  vegetation_area_fraction, soil_temperature, surface_snow_thickness, &
537  surface_wind_speed, surface_wind_from_direction, sea_surface_salinity)
538 
539  have_crtm_surface = .true.
540 
541 endif
542 
543 
544 ! Loop over the fields not found in the input state and work through cases
545 ! ------------------------------------------------------------------------
546 do f = 1, size(fields_to_do)
547 
548  call xg%get_field(trim(fields_to_do(f)), field_ptr)
549 
550  select case (trim(fields_to_do(f)))
551 
552  case ("ua")
553 
554  if (.not. have_winds) call field_fail(fields_to_do(f))
555  field_ptr = ua
556 
557  case ("va")
558 
559  if (.not. have_winds) call field_fail(fields_to_do(f))
560  field_ptr = va
561 
562  case ("q")
563 
564  if (.not. have_q) call field_fail(fields_to_do(f))
565  field_ptr = q
566 
567  case ("rh")
568 
569  if (.not. have_rh) call field_fail(fields_to_do(f))
570  field_ptr = rh
571 
572  case ("p")
573 
574  if (.not. have_pressures) call field_fail(fields_to_do(f))
575  field_ptr = prs
576 
577  case ("pe")
578 
579  if (.not. have_pressures) call field_fail(fields_to_do(f))
580  field_ptr = prsi
581 
582  case ("delp")
583 
584  if (.not. have_pressures) call field_fail(fields_to_do(f))
585  field_ptr = delp
586 
587  case ("ps")
588 
589  if (.not. have_pressures) call field_fail(fields_to_do(f))
590  field_ptr = ps
591 
592  case ("t")
593 
594  if (.not. have_t) call field_fail(fields_to_do(f))
595  field_ptr = t
596 
597  case ("tv")
598 
599  if (.not. have_tv) call field_fail(fields_to_do(f))
600  field_ptr = tv
601 
602  case ("mole_fraction_of_ozone_in_air")
603  if (.not. have_o3) call field_fail(fields_to_do(f))
604  field_ptr = o3
605 
606  case ("geopotential_height", "height")
607 
608  if (.not. have_geoph) call field_fail(fields_to_do(f))
609  field_ptr = geoph
610 
611  case ("geopotential_height_levels")
612 
613  if (.not. have_geoph) call field_fail(fields_to_do(f))
614  field_ptr = geophi
615 
616  case ("surface_altitude")
617 
618  if (.not. have_geoph) call field_fail(fields_to_do(f))
619  field_ptr = suralt
620 
621  case ("mole_fraction_of_carbon_dioxide_in_air")
622 
623  field_ptr = 407.0_kind_real
624 
625  case ("humidity_mixing_ratio")
626 
627  if (.not. have_qmr) call field_fail(fields_to_do(f))
628  field_ptr = qmr
629 
630  case ("mass_content_of_cloud_liquid_water_in_atmosphere_layer")
631 
632  if (.not. have_crtm_cld) call field_fail(fields_to_do(f))
633  field_ptr = ql_ade
634 
635  case ("mass_content_of_cloud_ice_in_atmosphere_layer")
636 
637  if (.not. have_crtm_cld) call field_fail(fields_to_do(f))
638  field_ptr = qi_ade
639 
640  case ("effective_radius_of_cloud_liquid_water_particle")
641 
642  if (.not. have_crtm_cld) call field_fail(fields_to_do(f))
643  field_ptr = ql_efr
644 
645  case ("effective_radius_of_cloud_ice_particle")
646 
647  if (.not. have_crtm_cld) call field_fail(fields_to_do(f))
648  field_ptr = qi_efr
649 
650  case ("water_area_fraction")
651 
652  if (.not. have_crtm_surface) call field_fail(fields_to_do(f))
653  field_ptr = water_area_fraction
654 
655  case ("land_area_fraction")
656 
657  if (.not. have_crtm_surface) call field_fail(fields_to_do(f))
658  field_ptr = land_area_fraction
659 
660  case ("ice_area_fraction")
661 
662  if (.not. have_crtm_surface) call field_fail(fields_to_do(f))
663  field_ptr = ice_area_fraction
664 
665  case ("surface_snow_area_fraction")
666 
667  if (.not. have_crtm_surface) call field_fail(fields_to_do(f))
668  field_ptr = surface_snow_area_fraction
669 
670  case ("surface_temperature_where_sea")
671 
672  if (.not. have_crtm_surface) call field_fail(fields_to_do(f))
673  field_ptr = surface_temperature_where_sea
674 
675  case ("sea_surface_salinity")
676 
677  if (.not. have_sss) call field_fail(fields_to_do(f))
678  field_ptr = sea_surface_salinity
679 
680  case ("surface_temperature_where_land")
681 
682  if (.not. have_crtm_surface) call field_fail(fields_to_do(f))
683  field_ptr = surface_temperature_where_land
684 
685  case ("surface_temperature_where_ice")
686 
687  if (.not. have_crtm_surface) call field_fail(fields_to_do(f))
688  field_ptr = surface_temperature_where_ice
689 
690  case ("surface_temperature_where_snow")
691 
692  if (.not. have_crtm_surface) call field_fail(fields_to_do(f))
693  field_ptr = surface_temperature_where_snow
694 
695  case ("surface_snow_thickness")
696 
697  if (.not. have_crtm_surface) call field_fail(fields_to_do(f))
698  field_ptr = surface_snow_thickness
699 
700  case ("vegetation_area_fraction")
701 
702  if (.not. have_crtm_surface) call field_fail(fields_to_do(f))
703  field_ptr = vegetation_area_fraction
704 
705  case ("surface_wind_speed")
706 
707  if (.not. have_crtm_surface) call field_fail(fields_to_do(f))
708  field_ptr = surface_wind_speed
709 
710  case ("surface_wind_from_direction")
711 
712  if (.not. have_crtm_surface) call field_fail(fields_to_do(f))
713  field_ptr = surface_wind_from_direction
714 
715  case ("leaf_area_index")
716 
717  if (.not. have_crtm_surface) call field_fail(fields_to_do(f))
718  field_ptr = leaf_area_index
719 
720  case ("volume_fraction_of_condensed_water_in_soil")
721 
722  if (.not. have_crtm_surface) call field_fail(fields_to_do(f))
723  field_ptr = volume_fraction_of_condensed_water_in_soil
724 
725  case ("soil_temperature")
726 
727  if (.not. have_crtm_surface) call field_fail(fields_to_do(f))
728  field_ptr = soil_temperature
729 
730  case ("land_type_index")
731 
732  if (.not. have_crtm_surface) call field_fail(fields_to_do(f))
733  field_ptr = land_type_index
734 
735  case ("vegetation_type_index")
736 
737  if (.not. have_crtm_surface) call field_fail(fields_to_do(f))
738  field_ptr = vegetation_type_index
739 
740  case ("soil_type")
741 
742  if (.not. have_crtm_surface) call field_fail(fields_to_do(f))
743  field_ptr = soil_type
744 
745  case default
746 
747  call abor1_ftn("fv3jedi_vc_model2geovals_mod.changevar unknown field: "//trim(fields_to_do(f)) &
748  //". Not in input field and no transform case specified.")
749 
750  end select
751 
752 enddo
753 
754 
755 ! Copy calendar infomation
756 ! ------------------------
757 xg%calendar_type = xm%calendar_type
758 xg%date_init = xm%date_init
759 
760 
761 if (associated(sheleg)) nullify(sheleg)
762 if (associated(vtype)) nullify(vtype)
763 if (associated(stype)) nullify(stype)
764 if (associated(vfrac)) nullify(vfrac)
765 if (associated(stc)) nullify(stc)
766 if (associated(smc)) nullify(smc)
767 if (associated(field_ptr)) nullify(field_ptr)
768 if (associated(q)) nullify(q)
769 if (associated(qsat)) nullify(qsat)
770 if (associated(pt)) nullify(pt)
771 if (associated(phis)) nullify(phis)
772 if (associated(ud)) nullify(ud)
773 if (associated(vd)) nullify(vd)
774 if (associated(frocean)) nullify(frocean)
775 if (associated(frlake)) nullify(frlake)
776 if (associated(frseaice)) nullify(frseaice)
777 if (associated(tsea)) nullify(tsea)
778 if (associated(u_srf)) nullify(u_srf)
779 if (associated(v_srf)) nullify(v_srf)
780 if (associated(qils)) nullify(qils)
781 if (associated(qlls)) nullify(qlls)
782 if (associated(qicn)) nullify(qicn)
783 if (associated(qlcn)) nullify(qlcn)
784 
785 if (allocated(fields_to_do)) deallocate(fields_to_do)
786 if (allocated(rh)) deallocate(rh)
787 if (allocated(t)) deallocate(t)
788 if (allocated(tv)) deallocate(tv)
789 if (allocated(ps)) deallocate(ps)
790 if (allocated(delp)) deallocate(delp)
791 if (allocated(prsi)) deallocate(prsi)
792 if (allocated(prs)) deallocate(prs)
793 if (allocated(pkz)) deallocate(pkz)
794 if (allocated(geophi)) deallocate(geophi)
795 if (allocated(geoph)) deallocate(geoph)
796 if (allocated(suralt)) deallocate(suralt)
797 if (allocated(o3)) deallocate(o3)
798 if (allocated(ua)) deallocate(ua)
799 if (allocated(va)) deallocate(va)
800 if (allocated(slmsk)) deallocate(slmsk)
801 if (allocated(f10m)) deallocate(f10m)
802 if (allocated(ql)) deallocate(ql)
803 if (allocated(qi)) deallocate(qi)
804 if (allocated(qmr)) deallocate(qmr)
805 if (allocated(ql_ade)) deallocate(ql_ade)
806 if (allocated(qi_ade)) deallocate(qi_ade)
807 if (allocated(ql_efr)) deallocate(ql_efr)
808 if (allocated(qi_efr)) deallocate(qi_efr)
809 if (allocated(watercov)) deallocate(watercov)
810 if (allocated(sss)) deallocate(sss)
811 if (allocated(land_type_index)) deallocate(land_type_index)
812 if (allocated(vegetation_type_index)) deallocate(vegetation_type_index)
813 if (allocated(soil_type)) deallocate(soil_type)
814 if (allocated(water_area_fraction)) deallocate(water_area_fraction)
815 if (allocated(land_area_fraction)) deallocate(land_area_fraction)
816 if (allocated(ice_area_fraction)) deallocate(ice_area_fraction)
817 if (allocated(surface_snow_area_fraction)) deallocate(surface_snow_area_fraction)
818 if (allocated(leaf_area_index)) deallocate(leaf_area_index)
819 if (allocated(surface_temperature_where_sea)) deallocate(surface_temperature_where_sea)
820 if (allocated(surface_temperature_where_land)) deallocate(surface_temperature_where_land)
821 if (allocated(surface_temperature_where_ice)) deallocate(surface_temperature_where_ice)
822 if (allocated(surface_temperature_where_snow)) deallocate(surface_temperature_where_snow)
823 if (allocated(volume_fraction_of_condensed_water_in_soil)) &
824  deallocate(volume_fraction_of_condensed_water_in_soil)
825 if (allocated(vegetation_area_fraction)) deallocate(vegetation_area_fraction)
826 if (allocated(soil_temperature)) deallocate(soil_temperature)
827 if (allocated(surface_snow_thickness)) deallocate(surface_snow_thickness)
828 if (allocated(surface_wind_speed)) deallocate(surface_wind_speed)
829 if (allocated(surface_wind_from_direction)) deallocate(surface_wind_from_direction)
830 if (allocated(sea_surface_salinity)) deallocate(sea_surface_salinity)
831 
832 end subroutine changevar
833 
834 ! --------------------------------------------------------------------------------------------------
835 
fv3jedi_state_mod::fv3jedi_state
Fortran derived type to hold FV3JEDI state.
Definition: fv3jedi_state_mod.F90:30
fv3jedi_field_mod
Definition: fv3jedi_field_mod.f90:6
moisture_vt_mod
Definition: moisture_variables_mod.f90:6
fv3jedi_fieldfail_mod::field_fail
subroutine, public field_fail(field)
Definition: fv3jedi_fieldfail_mod.f90:14
temperature_vt_mod::t_to_tv
subroutine, public t_to_tv(geom, t, q, tv)
Definition: temperature_variables_mod.f90:27
fv3jedi_vc_model2geovals_mod::changevar
subroutine changevar(self, geom, xm, xg)
Definition: fv3jedi_vc_model2geovals_mod.f90:76
surface_vt_mod
Definition: surface_variables_mod.f90:6
fv3jedi_state_mod
Definition: fv3jedi_state_mod.F90:6
fv3jedi_field_mod::copy_subset
subroutine, public copy_subset(field_in, field_ou, not_copied)
Definition: fv3jedi_field_mod.f90:236
fv3jedi_geom_mod
Fortran module handling geometry for the FV3 model.
Definition: fv3jedi_geom_mod.f90:8
fv3jedi_vc_model2geovals_mod
Definition: fv3jedi_vc_model2geovals_mod.f90:6
height_vt_mod::geop_height_levels
subroutine, public geop_height_levels(geom, prs, prsi, T, q, phis, use_compress, gphi)
Definition: height_variables_mod.f90:133
moisture_vt_mod::crtm_ade_efr
subroutine, public crtm_ade_efr(geom, p, T, delp, sea_frac, q, ql, qi, ql_ade, qi_ade, ql_efr, qi_efr)
Definition: moisture_variables_mod.f90:38
fv3jedi_geom_mod::fv3jedi_geom
Fortran derived type to hold geometry data for the FV3JEDI model.
Definition: fv3jedi_geom_mod.f90:46
fv3jedi_fieldfail_mod
Definition: fv3jedi_fieldfail_mod.f90:1
wind_vt_mod
Definition: wind_variables_mod.f90:6
fv3jedi_vc_model2geovals_mod::create
subroutine create(self, geom, dummyconf)
Definition: fv3jedi_vc_model2geovals_mod.f90:49
fv3jedi_vc_model2geovals_mod::delete
subroutine delete(self)
Definition: fv3jedi_vc_model2geovals_mod.f90:68
temperature_vt_mod
Definition: temperature_variables_mod.f90:6
moisture_vt_mod::q_to_rh
subroutine, public q_to_rh(geom, qsat, q, rh)
Definition: moisture_variables_mod.f90:444
fv3jedi_vc_model2geovals_mod::fv3jedi_vc_model2geovals
Definition: fv3jedi_vc_model2geovals_mod.f90:34
fv3jedi_constants_mod
Definition: fv3jedi_constants_mod.f90:6
moisture_vt_mod::crtm_mixratio
subroutine, public crtm_mixratio(geom, q, qmr)
Definition: moisture_variables_mod.f90:172
surface_vt_mod::crtm_surface
subroutine, public crtm_surface(geom, field_slmsk, field_sheleg, field_tsea, field_vtype, field_stype, field_vfrac, field_stc, field_smc, field_u_srf, field_v_srf, field_f10m, field_sss, land_type, vegetation_type, soil_type, water_coverage, land_coverage, ice_coverage, snow_coverage, lai, water_temperature, land_temperature, ice_temperature, snow_temperature, soil_moisture_content, vegetation_fraction, soil_temperature, snow_depth, wind_speed, wind_direction, sea_surface_salinity)
Definition: surface_variables_mod.f90:34
pressure_vt_mod
Definition: pressure_variables_mod.f90:6
moisture_vt_mod::get_qsat
subroutine, public get_qsat(geom, delp, t, q, qsat)
Definition: moisture_variables_mod.f90:486
pressure_vt_mod::pe_to_pkz
subroutine, public pe_to_pkz(geom, pe, pkz)
Definition: pressure_variables_mod.f90:68
fv3jedi_kinds_mod::kind_real
integer, parameter, public kind_real
Definition: fv3jedi_kinds_mod.f90:14
temperature_vt_mod::pt_to_t
subroutine, public pt_to_t(geom, pkz, pt, t)
Definition: temperature_variables_mod.f90:131
height_vt_mod
Definition: height_variables_mod.f90:6
wind_vt_mod::d2a
subroutine, public d2a(geom, u_comp, v_comp, ua_comp, va_comp)
Definition: wind_variables_mod.f90:1456
height_vt_mod::geop_height
subroutine, public geop_height(geom, prs, prsi, T, q, phis, use_compress, gph)
Definition: height_variables_mod.f90:41
pressure_vt_mod::delp_to_pe_p_logp
subroutine, public delp_to_pe_p_logp(geom, delp, pe, p, logp)
Definition: pressure_variables_mod.f90:33
fv3jedi_kinds_mod
Definition: fv3jedi_kinds_mod.f90:6
fv3jedi_constants_mod::constoz
real(kind=kind_real), parameter, public constoz
Definition: fv3jedi_constants_mod.f90:59
fv3jedi_constants_mod::grav
real(kind=kind_real), parameter, public grav
Definition: fv3jedi_constants_mod.f90:17
fv3jedi_field_mod::field_clen
integer, parameter, public field_clen
Definition: fv3jedi_field_mod.f90:31