FV3 Bundle
ufo_variables_mod.F90
Go to the documentation of this file.
1 !
2 ! (C) Copyright 2017-2018 UCAR
3 !
4 ! This software is licensed under the terms of the Apache Licence Version 2.0
5 ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6 !
7 
9 
10 implicit none
11 private
14 
15 integer, parameter, public :: naerosols_gocart_esrl=15
16 
17 integer, parameter, public :: maxvarlen=56
18 character(len=MAXVARLEN), public :: var_tv = "virtual_temperature"
19 character(len=MAXVARLEN), public :: var_prsl = "atmosphere_ln_pressure_coordinate"
20 character(len=MAXVARLEN), public :: var_mixr = "humidity_mixing_ratio"
21 character(len=MAXVARLEN), public :: var_q = "specific_humidity"
22 character(len=MAXVARLEN), public :: var_prs = "air_pressure"
23 character(len=MAXVARLEN), public :: var_prsi = "air_pressure_levels"
24 character(len=MAXVARLEN), public :: var_z = "geopotential_height"
25 character(len=MAXVARLEN), public :: var_zi = "geopotential_height_levels"
26 character(len=MAXVARLEN), public :: var_sfc_z= "sfc_geopotential_height"
27 character(len=MAXVARLEN), public :: var_oz = "mass_concentration_of_ozone_in_air"
28 character(len=MAXVARLEN), public :: var_co2 = "mass_concentration_of_carbon_dioxide_in_air"
29 character(len=MAXVARLEN), public :: var_clw = "atmosphere_mass_content_of_cloud_liquid_water"
30 character(len=MAXVARLEN), public :: var_cli = "atmosphere_mass_content_of_cloud_ice"
31 character(len=MAXVARLEN), public :: var_clwefr = "effective_radius_of_cloud_liquid_water_particle"
32 character(len=MAXVARLEN), public :: var_cliefr = "effective_radius_of_cloud_ice_particle"
33 character(len=MAXVARLEN), public :: var_sfc_wfrac = "Water_Fraction"
34 character(len=MAXVARLEN), public :: var_sfc_lfrac = "Land_Fraction"
35 character(len=MAXVARLEN), public :: var_sfc_ifrac = "Ice_Fraction"
36 character(len=MAXVARLEN), public :: var_sfc_sfrac = "Snow_Fraction"
37 character(len=MAXVARLEN), public :: var_sfc_wtmp = "Water_Temperature"
38 character(len=MAXVARLEN), public :: var_sfc_ltmp = "Land_Temperature"
39 character(len=MAXVARLEN), public :: var_sfc_itmp = "Ice_Temperature"
40 character(len=MAXVARLEN), public :: var_sfc_stmp = "Snow_Temperature"
41 character(len=MAXVARLEN), public :: var_sfc_sdepth = "Snow_Depth"
42 character(len=MAXVARLEN), public :: var_sfc_vegfrac = "Vegetation_Fraction"
43 character(len=MAXVARLEN), public :: var_sfc_wspeed = "Sfc_Wind_Speed"
44 character(len=MAXVARLEN), public :: var_sfc_wdir = "Sfc_Wind_Direction"
45 character(len=MAXVARLEN), public :: var_sfc_lai = "Lai"
46 character(len=MAXVARLEN), public :: var_sfc_soilm = "Soil_Moisture"
47 character(len=MAXVARLEN), public :: var_sfc_soilt = "Soil_Temperature"
48 character(len=MAXVARLEN), public :: var_sfc_landtyp = "Land_Type_Index"
49 character(len=MAXVARLEN), public :: var_sfc_vegtyp = "Vegetation_Type"
50 character(len=MAXVARLEN), public :: var_sfc_soiltyp = "Soil_Type"
51 
52 !@mzp strings have to be same MAXVARLEN length for array constructor
53 CHARACTER(len=MAXVARLEN), DIMENSION(naerosols_gocart_esrl), PUBLIC :: var_aerosols =[&
54  &"sulf ",&
55  &"bc1 ",&
56  &"bc2 ",&
57  &"oc1 ",&
58  &"oc2 ",&
59  &"dust1 ",&
60  &"dust2 ",&
61  &"dust3 ",&
62  &"dust4 ",&
63  &"dust5 ",&
64  &"seas1 ",&
65  &"seas2 ",&
66  &"seas3 ",&
67  &"seas4 ",&
68  &"p25 "]
69 
70 CHARACTER(len=MAXVARLEN), PUBLIC :: var_t="temperature"
71 
72 character(len=MAXVARLEN), public :: var_seaicefrac = "ice_concentration"
73 character(len=MAXVARLEN), public :: var_stericheight = "steric_height"
74 character(len=MAXVARLEN), public :: var_seaicethick = "ice_thickness"
75 character(len=MAXVARLEN), public :: var_abs_topo = "sea_surface_height_above_geoid"
76 character(len=MAXVARLEN), public :: var_ocn_pot_temp = "ocean_potential_temperature"
77 character(len=MAXVARLEN), public :: var_ocn_con_temp = "ocean_conservative_temperature"
78 character(len=MAXVARLEN), public :: var_ocn_abs_salt = "ocean_absolute_salinity"
79 character(len=MAXVARLEN), public :: var_ocn_salt = "ocean_salinity"
80 character(len=MAXVARLEN), public :: var_ocn_lay_thick = "ocean_layer_thickness"
81 character(len=MAXVARLEN), public :: var_ocn_sst = "ocean_upper_level_temperature"
82 
83 ! ------------------------------------------------------------------------------
84 
85 !> Fortran derived type to represent model variables
86 type :: ufo_vars
87  integer :: nv
88  character(len=MAXVARLEN), allocatable :: fldnames(:) !< Variable identifiers
89 end type ufo_vars
90 
91 ! ------------------------------------------------------------------------------
92 contains
93 ! ------------------------------------------------------------------------------
94 
95 subroutine ufo_vars_setup(self, c_vars)
96 use iso_c_binding
97 use config_mod
98 implicit none
99 type(ufo_vars), intent(inout) :: self
100 type(c_ptr), intent(in) :: c_vars
101 character(len=30*MAXVARLEN) :: svars
102 
103 self%nv = config_get_int(c_vars, "nvars")
104 
105 allocate(self%fldnames(self%nv))
106 svars = config_get_string(c_vars,len(svars),"variables")
107 read(svars,*) self%fldnames
108 
109 ! TODO: a check on whether this var is in the list of defined vars
110 
111 end subroutine ufo_vars_setup
112 
113 ! ------------------------------------------------------------------------------
114 
115 subroutine ufo_vars_clone(self, other)
116 implicit none
117 type(ufo_vars), intent(in) :: self
118 type(ufo_vars), intent(inout) :: other
119 
120 call ufo_vars_delete(other)
121 other%nv = self%nv
122 allocate(other%fldnames(other%nv))
123 other%fldnames(:) = self%fldnames(:)
124 
125 end subroutine ufo_vars_clone
126 
127 ! ------------------------------------------------------------------------------
128 
129 subroutine ufo_vars_delete(self)
130 implicit none
131 type(ufo_vars), intent(inout) :: self
132 
133 if (allocated(self%fldnames)) deallocate(self%fldnames)
134 self%nv = 0
135 
136 end subroutine ufo_vars_delete
137 
138 ! ------------------------------------------------------------------------------
139 
140 integer function ufo_vars_getindex(self, varname)
141 implicit none
142 type(ufo_vars), intent(in) :: self
143 character(MAXVARLEN), intent(in) :: varname
144 
145 integer :: ivar
146 
148 
149 do ivar = 1, self%nv
150  if (self%fldnames(ivar) == varname) then
151  ufo_vars_getindex = ivar
152  exit
153  endif
154 enddo
155 
156 end function ufo_vars_getindex
157 
158 ! ------------------------------------------------------------------------------
159 
160 integer function ufo_vars_nvars(self)
161 implicit none
162 type(ufo_vars), intent(in) :: self
163 
164 ufo_vars_nvars = self%nv
165 
166 end function ufo_vars_nvars
167 
168 ! ------------------------------------------------------------------------------
169 
170 end module ufo_vars_mod
character(len=maxvarlen), public var_ocn_sst
character(len=maxvarlen), public var_seaicethick
integer function, public ufo_vars_nvars(self)
character(len=maxvarlen), public var_sfc_wspeed
character(len=maxvarlen), public var_mixr
integer, parameter, public naerosols_gocart_esrl
character(len=maxvarlen), dimension(naerosols_gocart_esrl), public var_aerosols
character(len=maxvarlen), public var_prsi
integer function, public ufo_vars_getindex(self, varname)
character(len=maxvarlen), public var_sfc_vegfrac
integer, parameter, public maxvarlen
character(len=maxvarlen), public var_co2
character(len=maxvarlen), public var_sfc_lfrac
subroutine, public ufo_vars_delete(self)
character(len=maxvarlen), public var_sfc_soilt
character(len=maxvarlen), public var_clw
character(len=maxvarlen), public var_ocn_lay_thick
character(len=maxvarlen), public var_sfc_sfrac
character(len=maxvarlen), public var_ocn_abs_salt
character(len=maxvarlen), public var_stericheight
character(len=maxvarlen), public var_sfc_wdir
Fortran derived type to represent model variables.
character(len=maxvarlen), public var_cli
character(len=maxvarlen), public var_sfc_stmp
character(len=maxvarlen), public var_sfc_lai
character(len=maxvarlen), public var_z
character(len=maxvarlen), public var_oz
character(len=maxvarlen), public var_ocn_salt
character(len=maxvarlen), public var_q
character(len=maxvarlen), public var_prsl
character(len=maxvarlen), public var_prs
character(len=maxvarlen), public var_ocn_pot_temp
character(len=maxvarlen), public var_sfc_wfrac
character(len=maxvarlen), public var_sfc_soiltyp
character(len=maxvarlen), public var_clwefr
character(len=maxvarlen), public var_abs_topo
character(len=maxvarlen), public var_sfc_itmp
character(len=maxvarlen), public var_sfc_soilm
character(len=maxvarlen), public var_cliefr
character(len=maxvarlen), public var_sfc_vegtyp
character(len=maxvarlen), public var_sfc_ifrac
character(len=maxvarlen), public var_sfc_sdepth
character(len=maxvarlen), public var_sfc_ltmp
character(len=maxvarlen), public var_sfc_landtyp
character(len=maxvarlen), public var_zi
character(len=maxvarlen), public var_t
character(len=maxvarlen), public var_sfc_wtmp
character(len=maxvarlen), public var_tv
character(len=maxvarlen), public var_sfc_z
character(len=maxvarlen), public var_ocn_con_temp
character(len=maxvarlen), public var_seaicefrac
subroutine, public ufo_vars_setup(self, c_vars)
subroutine, public ufo_vars_clone(self, other)