[Dart-dev] DART/branches Revision: 12364

dart at ucar.edu dart at ucar.edu
Thu Jan 18 11:04:20 MST 2018


nancy at ucar.edu
2018-01-18 11:04:20 -0700 (Thu, 18 Jan 2018)
77
make sure the table is initialized with all entries
having a factor of 1.0.




Modified: DART/branches/recam/models/cam-fv/chem_tables_mod.f90
===================================================================
--- DART/branches/recam/models/cam-fv/chem_tables_mod.f90	2018-01-18 18:03:43 UTC (rev 12363)
+++ DART/branches/recam/models/cam-fv/chem_tables_mod.f90	2018-01-18 18:04:20 UTC (rev 12364)
@@ -59,6 +59,8 @@
 ! to add more quantities, add entries here following the pattern.
 ! there can be only one entry per 'QTY_xxx'
 
+integer :: i
+
 if (module_initialized) return
 
 num_qtys = get_num_quantities()
@@ -65,11 +67,12 @@
 
 allocate(chem_conv_table(0:num_qtys))
 
-! the default factor is unity. then you can always multiply
-! by this factor for any quantity.
- 
-chem_conv_table(:) = 1.0_r8
+! initialize all entries to an empty name and a factor of 1.0
+do i=0, num_qtys
+   call set_entry('', 1.0_r8, i)
+enddo
 
+! and now add entries for real items
 call add_entry('O3',   47.9982_r8, 'QTY_O3')
 call add_entry('O',    15.9994_r8, 'QTY_O')
 call add_entry('O1D',  15.9994_r8, 'QTY_O1D')
@@ -242,6 +245,30 @@
 !--------------------------------------------------------------------
 !>
 
+subroutine set_entry(netcdf_varname, convert_factor, quantity_index)
+
+character(len=*), intent(in) :: netcdf_varname
+real(r8),         intent(in) :: convert_factor
+integer,          intent(in) :: quantity_index
+
+character(len=32) :: quantity_name
+
+quantity_name = get_name_for_quantity(quantity_index)
+if (quantity_name == '') then
+   write(string1,'(3A)') 'quantity index "', quantity_index, &
+                         '" not found in known quantities list'
+   write(string2, *) 'check obs_kind_mod.f90 for valid quantities; defined by preprocess namelist'
+   call error_handler(E_ERR, 'chem_convert_factor', string1, &
+                      source, revision, revdate, text2=string2)
+endif
+
+chem_conv_table(quantity_index) = chem_convert(netcdf_varname, convert_factor, quantity_name)
+
+end subroutine set_entry
+
+!--------------------------------------------------------------------
+!>
+
 function chem_convert_factor(qty)
 
 integer, intent(in) :: qty


More information about the Dart-dev mailing list