[Dart-dev] [4753] DART/trunk: Pass down the ensemble number and the state time
nancy at ucar.edu
nancy at ucar.edu
Wed Feb 23 15:03:07 MST 2011
Revision: 4753
Author: nancy
Date: 2011-02-23 15:03:07 -0700 (Wed, 23 Feb 2011)
Log Message:
-----------
Pass down the ensemble number and the state time
to the forward operator code if it wants to use it.
Modified Paths:
--------------
DART/trunk/filter/filter.dopplerfold.f90
DART/trunk/filter/filter.f90
DART/trunk/obs_def/DEFAULT_obs_def_mod.F90
DART/trunk/obs_def/DEFAULT_obs_def_mod.html
DART/trunk/obs_def/obs_def_mod.html
DART/trunk/obs_sequence/obs_sequence_mod.f90
DART/trunk/obs_sequence/obs_sequence_mod.html
DART/trunk/perfect_model_obs/perfect_model_obs.f90
-------------- next part --------------
Modified: DART/trunk/filter/filter.dopplerfold.f90
===================================================================
--- DART/trunk/filter/filter.dopplerfold.f90 2011-02-23 21:14:37 UTC (rev 4752)
+++ DART/trunk/filter/filter.dopplerfold.f90 2011-02-23 22:03:07 UTC (rev 4753)
@@ -542,8 +542,8 @@
call trace_message('Before observation space diagnostics')
! Do prior observation space diagnostics and associated quality control
- call obs_space_diagnostics(obs_ens_handle, forward_op_ens_handle, ens_size, seq, keys, &
- PRIOR_DIAG, num_output_obs_members, in_obs_copy + 1, &
+ call obs_space_diagnostics(obs_ens_handle, forward_op_ens_handle, ens_size, &
+ seq, keys, PRIOR_DIAG, num_output_obs_members, in_obs_copy+1, &
obs_val_index, OBS_KEY_COPY, & ! new
prior_obs_mean_index, prior_obs_spread_index, num_obs_in_set, &
OBS_PRIOR_MEAN_START, OBS_PRIOR_VAR_START, OBS_GLOBAL_QC_COPY, &
@@ -651,8 +651,8 @@
call trace_message('Before posterior obs space diagnostics')
! Do posterior observation space diagnostics
- call obs_space_diagnostics(obs_ens_handle, forward_op_ens_handle, ens_size, seq, keys, &
- POSTERIOR_DIAG, num_output_obs_members, in_obs_copy + 2, &
+ call obs_space_diagnostics(obs_ens_handle, forward_op_ens_handle, ens_size, &
+ seq, keys, POSTERIOR_DIAG, num_output_obs_members, in_obs_copy+2, &
obs_val_index, OBS_KEY_COPY, & ! new
posterior_obs_mean_index, posterior_obs_spread_index, num_obs_in_set, &
OBS_PRIOR_MEAN_START, OBS_PRIOR_VAR_START, OBS_GLOBAL_QC_COPY, &
@@ -1191,7 +1191,8 @@
! obs_ens_handle%vars(j:j, k), istatus, assimilate_this_ob, evaluate_this_ob)
! and keys is intent in only, vars intent out only.
thiskey(1) = keys(j)
- call get_expected_obs(seq, thiskey, ens_handle%vars(:, k), &
+ call get_expected_obs(seq, thiskey, &
+ global_ens_index, ens_handle%vars(:, k), ens_handle%time(1), &
thisvar, istatus, assimilate_this_ob, evaluate_this_ob)
obs_ens_handle%vars(j, k) = thisvar(1)
! If istatus is 0 (successful) then put 0 for assimilate, -1 for evaluate only
Modified: DART/trunk/filter/filter.f90
===================================================================
--- DART/trunk/filter/filter.f90 2011-02-23 21:14:37 UTC (rev 4752)
+++ DART/trunk/filter/filter.f90 2011-02-23 22:03:07 UTC (rev 4753)
@@ -538,8 +538,8 @@
call trace_message('Before observation space diagnostics')
! Do prior observation space diagnostics and associated quality control
- call obs_space_diagnostics(obs_ens_handle, forward_op_ens_handle, &
- ens_size, seq, keys, PRIOR_DIAG, num_output_obs_members, in_obs_copy+1, &
+ call obs_space_diagnostics(obs_ens_handle, forward_op_ens_handle, ens_size, &
+ seq, keys, PRIOR_DIAG, num_output_obs_members, in_obs_copy+1, &
prior_obs_mean_index, prior_obs_spread_index, num_obs_in_set, &
OBS_PRIOR_MEAN_START, OBS_PRIOR_VAR_START, OBS_GLOBAL_QC_COPY, &
OBS_VAL_COPY, OBS_ERR_VAR_COPY, DART_qc_index)
@@ -646,10 +646,9 @@
call trace_message('Before posterior obs space diagnostics')
! Do posterior observation space diagnostics
- call obs_space_diagnostics(obs_ens_handle, forward_op_ens_handle, &
- ens_size, seq, keys, POSTERIOR_DIAG, num_output_obs_members, &
- in_obs_copy + 2, posterior_obs_mean_index, posterior_obs_spread_index, &
- num_obs_in_set, &
+ call obs_space_diagnostics(obs_ens_handle, forward_op_ens_handle, ens_size, &
+ seq, keys, POSTERIOR_DIAG, num_output_obs_members, in_obs_copy+2, &
+ posterior_obs_mean_index, posterior_obs_spread_index, num_obs_in_set, &
OBS_PRIOR_MEAN_START, OBS_PRIOR_VAR_START, OBS_GLOBAL_QC_COPY, &
OBS_VAL_COPY, OBS_ERR_VAR_COPY, DART_qc_index)
@@ -1186,7 +1185,8 @@
! obs_ens_handle%vars(j:j, k), istatus, assimilate_this_ob, evaluate_this_ob)
! and keys is intent in only, vars intent out only.
thiskey(1) = keys(j)
- call get_expected_obs(seq, thiskey, ens_handle%vars(:, k), &
+ call get_expected_obs(seq, thiskey, &
+ global_ens_index, ens_handle%vars(:, k), ens_handle%time(1), &
thisvar, istatus, assimilate_this_ob, evaluate_this_ob)
obs_ens_handle%vars(j, k) = thisvar(1)
! If istatus is 0 (successful) then put 0 for assimilate, -1 for evaluate only
Modified: DART/trunk/obs_def/DEFAULT_obs_def_mod.F90
===================================================================
--- DART/trunk/obs_def/DEFAULT_obs_def_mod.F90 2011-02-23 21:14:37 UTC (rev 4752)
+++ DART/trunk/obs_def/DEFAULT_obs_def_mod.F90 2011-02-23 22:03:07 UTC (rev 4753)
@@ -352,19 +352,23 @@
!----------------------------------------------------------------------------
-subroutine get_expected_obs_from_def(key, obs_def, obs_kind_ind, state, &
- obs_val, istatus, assimilate_this_ob, evaluate_this_ob)
+subroutine get_expected_obs_from_def(key, obs_def, obs_kind_ind, ens_index, &
+ state, state_time, obs_val, istatus, assimilate_this_ob, evaluate_this_ob)
! Compute forward operator for a particular obs_def
-integer, intent(in) :: key
-type(obs_def_type), intent(in) :: obs_def
-integer, intent(in) :: obs_kind_ind
-real(r8), intent(in) :: state(:)
-real(r8), intent(out) :: obs_val
-integer, intent(out) :: istatus
-logical, intent(out) :: assimilate_this_ob, evaluate_this_ob
+integer, intent(in) :: key
+type(obs_def_type), intent(in) :: obs_def
+integer, intent(in) :: obs_kind_ind, ens_index
+real(r8), intent(in) :: state(:)
+type(time_type), intent(in) :: state_time
+real(r8), intent(out) :: obs_val
+integer, intent(out) :: istatus
+logical, intent(out) :: assimilate_this_ob, evaluate_this_ob
type(location_type) :: location
+type(time_type) :: obs_time
+integer :: obs_key
+real(r8) :: error_var
! Load up the assimilate and evaluate status for this observation kind
assimilate_this_ob = assimilate_this_obs_kind(obs_kind_ind)
@@ -372,12 +376,42 @@
! If not being assimilated or evaluated return with missing_r8 and istatus 0
if(assimilate_this_ob .or. evaluate_this_ob) then
- location = get_obs_def_location(obs_def)
- ! Compute the forward operator;
+ ! for speed, access directly instead of using accessor functions
+ location = obs_def%location
+ obs_time = obs_def%time
+ obs_key = obs_def%key
+ error_var = obs_def%error_variance
+
+ ! Compute the forward operator. In spite of the variable name,
+ ! obs_kind_ind is in fact a 'type' index number. use the function
+ ! get_obs_kind_var_type from the obs_kind_mod if you want to map
+ ! from a specific type to a generic kind. the third argument of
+ ! a call to the 'interpolate()' function must be a kind index and
+ ! not a type. normally the preprocess program does this for you.
select case(obs_kind_ind)
+ ! arguments available to an obs_def forward operator code are:
+ ! state -- the entire model state vector
+ ! state_time -- the time of the state vector data
+ ! ens_index -- the ensemble number
+ ! location -- observation location
+ ! obs_kind_ind -- the index of the observation specific type
+ ! obs_time -- the time of the observation
+ ! error_var -- the observation error variance
+ !
+ ! the routine must return values for:
+ ! obs_val -- the computed forward operator value
+ ! istatus -- return code: 0=ok, >0 is error, <0 reserved for system use
+ !
+ ! to call interpolate() directly, the arg list MUST BE:
+ ! interpolate(state, location, KIND_xxx, obs_val, istatus)
+ !
+ ! the preprocess program generates lines like this automatically,
+ ! and this matches the interfaces in each model_mod.f90 file.
+ !
! CASE statements and algorithms for specific observation kinds are
! inserted here by the DART preprocess program.
+
! DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF INSERTED HERE
! If the observation kind is not available, it is an error. The DART
Modified: DART/trunk/obs_def/DEFAULT_obs_def_mod.html
===================================================================
--- DART/trunk/obs_def/DEFAULT_obs_def_mod.html 2011-02-23 21:14:37 UTC (rev 4752)
+++ DART/trunk/obs_def/DEFAULT_obs_def_mod.html 2011-02-23 22:03:07 UTC (rev 4753)
@@ -140,7 +140,7 @@
<H2>Terms of Use</H2>
<P>
-DART software - Copyright © 2004 - 2010 UCAR.<br>
+DART software - Copyright © 2004 - 2010 UCAR.<br>
This open source software is provided by UCAR, "as is",<br>
without charge, subject to all terms of use at<br>
<a href="http://www.image.ucar.edu/DAReS/DART/DART_download">
Modified: DART/trunk/obs_def/obs_def_mod.html
===================================================================
--- DART/trunk/obs_def/obs_def_mod.html 2011-02-23 21:14:37 UTC (rev 4752)
+++ DART/trunk/obs_def/obs_def_mod.html 2011-02-23 22:03:07 UTC (rev 4753)
@@ -169,6 +169,15 @@
Any fortran use statements for public subroutines or
variables from other modules should be placed between
these lines, with comment characters in the first column.
+<br><br>
+For example, if the forward operator code includes a module
+then a use statement like:
+<pre>
+use obs_def_1d_state_mod, only : write_1d_integral, read_1d_integral, &
+ interactive_1d_integral, get_expected_1d_integral
+</pre>
+needs to be added to the obs_def_mod so the listed subroutines
+are available to be called.
</li>
<li><pre>
@@ -181,6 +190,43 @@
of the state vector.
The code must be in comments,
with the comment character in the first column.
+<br><br>
+The variables available to be passed to subroutines or used
+in this section of code are:
+<table>
+<tr><td><em class=code>state</em></td>
+ <td>the entire model state vector</td></tr>
+<tr><td><em class=code>state_time</em></td>
+ <td>the time of the state data</td></tr>
+<tr><td><em class=code>ens_index</em></td>
+ <td>the ensemble member number</td></tr>
+<tr><td><em class=code>location</em></td>
+ <td>the observation location</td></tr>
+<tr><td><em class=code>obs_kind_ind </em></td>
+ <td>the index of the specific observation type</td></tr>
+<tr><td><em class=code>obs_time</em></td>
+ <td>the time of the observation</td></tr>
+<tr><td><em class=code>error_val</em></td>
+ <td>the observation error variance</td></tr>
+</table>
+<br>
+The routine must fill in the values of these variables:
+<table>
+<tr><td><em class=code>obs_val </em></td>
+ <td>the computed forward operator value </td></tr>
+<tr><td><em class=code>istatus</em></td>
+ <td>return code: 0=ok, >0 is error, <0 reserved for system use</td></tr>
+</table>
+<br>
+To call a model_mod interpolate routine directly, the
+argument list must match exactly:
+<pre>
+interpolate(state, location, KIND_xxx, obs_val, istatus)
+</pre>
+This can be useful if the forward operator needs to retrieve values
+for fields which are typically found in a model and then compute
+a derived value from them.
+
</li>
<li><pre>
@@ -196,6 +242,28 @@
<em class="unix">continue</em>.
The code must be in comments,
with the comment character in the first column.
+<br><br>
+The variables available to be passed to subroutines or used
+in this section of code are:
+<table>
+<tr><td><em class=code>ifile</em></td>
+ <td>the open unit number positioned ready to read, read-only</td></tr>
+<tr><td><em class=code>obs_def </em></td>
+ <td>the rest of the obs_def derived type for this obs, read-write</td></tr>
+<tr><td><em class=code>key</em></td>
+ <td>the index observation number in this sequence, read-only</td></tr>
+<tr><td><em class=code>obs_val</em></td>
+ <td>the observation value, if needed. in general should not be changed</td></tr>
+<tr><td><em class=code>is_ascii</em></td>
+ <td>logical to indicate how the file was opened, formatted or unformatted</td></tr>
+</table>
+<br>
+The usual use of this routine is to read in additional metadata
+per observation and to set the private key in the <em class=code>obs_def</em>
+to indicate which index to use for this observation to look up the
+corresponding metadata in arrays or derived types. Do not confuse
+the key in the obs_def with the key argument to this routine; the latter
+is the global observation sequence number for this observation.
</li>
<li><pre>
@@ -211,6 +279,25 @@
<em class="unix">continue</em>.
The code must be in comments,
with the comment character in the first column.
+<br><br>
+The variables available to be passed to subroutines or used
+in this section of code are:
+<table>
+<tr><td><em class=code>ifile</em></td>
+ <td>the open unit number positioned ready to write, read-only</td></tr>
+<tr><td><em class=code>obs_def </em></td>
+ <td>the rest of the obs_def derived type for this obs, read-only</td></tr>
+<tr><td><em class=code>key</em></td>
+ <td>the index observation number in this sequence, read-only</td></tr>
+<tr><td><em class=code>is_ascii</em></td>
+ <td>logical to indicate how the file was opened, formatted or unformatted</td></tr>
+</table>
+<br>
+The usual use of this routine is to write the additional metadata
+for this observation based on the private key
+in the <em class=code>obs_def</em>. Do not confuse this with
+the key in the subroutine call which is the observation number
+relative to the entire observation sequence file.
</li>
<li><pre>
@@ -227,6 +314,22 @@
<em class="unix">continue</em>.
The code must be in comments,
with the comment character in the first column.
+<br><br>
+The variables available to be passed to subroutines or used
+in this section of code are:
+<table>
+<tr><td><em class=code>obs_def </em></td>
+ <td>the rest of the obs_def derived type for this obs, read-write</td></tr>
+<tr><td><em class=code>key</em></td>
+ <td>the index observation number in this sequence, read-only</td></tr>
+</table>
+<br>
+The DART code will prompt for the rest of the obs_def values
+(location, type, value, error) but any additional metadata needed
+by this observation type should be prompted to, and read from,
+the console (e.g. <em class=code>write(*,*)</em>, and
+<em class=code>read(*, *)</em>). The code will generally set the
+<em class=code>obs_def%key</em> value as part of setting the metadata.
</li>
<li><pre>
@@ -239,6 +342,11 @@
other sections, this comment pair is optional, and if
used, the code must not be in comments;
it will be copied verbatim over to the output file.
+<br><br>
+Generally the code for a forward operator should
+be defined inside a module, to keep module variables
+and other private subroutines from colliding with
+unrelated routines and variables in other forward operator files.
</li>
</ol>
@@ -304,9 +412,10 @@
</pre>
<P>
See the <a href="obs_def_1d_state_mod.html">obs_def_1d_state_mod</a>
-documentation for more details and examples of each section.
-<br>
-<br>
+documentation for more details and examples of each section. Also see
+<a href="obs_def_wind_speed_mod.f90">obs_def_wind_speed_mod.f90</a> for
+an example of a 3D geophysical forward operator.
+<br> <br>
In addition to collecting and managing any additional observation
type-specific code, this module provides the definition of the
obs_def_type derived type, and a collection of subroutines for creating,
@@ -815,12 +924,15 @@
<br>
<div class=routine>
<em class=call> call get_expected_obs_from_def(key, obs_def, obs_kind_ind,
- state, obs_val, istatus, assimilate_this_ob, evaluate_this_ob) </em>
+ ens_index, state, state_time, obs_val, istatus,
+ assimilate_this_ob, evaluate_this_ob) </em>
<pre>
integer, intent(in) :: <em class=code>key</em>
type(obs_def_type), intent(in) :: <em class=code>obs_def</em>
integer, intent(in) :: <em class=code>obs_kind_ind</em>
+integer, intent(in) :: <em class=code>ens_index</em>
real(r8), intent(in) :: <em class=code>state(:)</em>
+type(time_type), intent(in) :: <em class=code>state_time</em>
real(r8), intent(out) :: <em class=code>obs_val</em>
integer, intent(out) :: <em class=code>istatus</em>
logical, intent(out) :: <em class=code>assimilate_this_ob</em>
@@ -842,11 +954,15 @@
<TD>The input obs_def</TD></TR>
<TR><TD valign=top><em class=code>obs_kind_ind </em></TD>
<TD>The obs kind</TD></TR>
+<TR><TD valign=top><em class=code>ens_index </em></TD>
+ <TD>The ensemble member number of this state vector</TD></TR>
<TR><TD valign=top><em class=code>state </em></TD>
<TD>Model state vector</TD></TR>
+<TR><TD valign=top><em class=code>state_time </em></TD>
+ <TD>Time of the data in the model state vector</TD></TR>
<TR><TD valign=top><em class=code>istatus </em></TD>
- <TD>Returned integer describing problems with applying
- forward operator (0 means OK).</TD></TR>
+ <TD>Returned integer describing problems with applying forward
+ operator (0 == OK, >0 == error, <0 reserved for sys use).</TD></TR>
<TR><TD valign=top><em class=code>assimilate_this_ob </em></TD>
<TD>Indicates whether to assimilate this obs or not</TD></TR>
<TR><TD valign=top><em class=code>evaluate_this_ob </em></TD>
Modified: DART/trunk/obs_sequence/obs_sequence_mod.f90
===================================================================
--- DART/trunk/obs_sequence/obs_sequence_mod.f90 2011-02-23 21:14:37 UTC (rev 4752)
+++ DART/trunk/obs_sequence/obs_sequence_mod.f90 2011-02-23 22:03:07 UTC (rev 4753)
@@ -322,27 +322,29 @@
!---------------------------------------------------------
-subroutine get_expected_obs(seq, keys, state, obs_vals, istatus, &
- assimilate_this_ob, evaluate_this_ob)
+subroutine get_expected_obs(seq, keys, ens_index, state, state_time, &
+ obs_vals, istatus, assimilate_this_ob, evaluate_this_ob)
! Compute forward operator for set of obs in sequence
type(obs_sequence_type), intent(in) :: seq
integer, intent(in) :: keys(:)
+integer, intent(in) :: ens_index
real(r8), intent(in) :: state(:)
+type(time_type), intent(in) :: state_time
real(r8), intent(out) :: obs_vals(:)
integer, intent(out) :: istatus
logical, intent(out) :: assimilate_this_ob, evaluate_this_ob
-integer :: num_obs, i
+integer :: num_obs, i
!type(location_type) :: location
-type(obs_type) :: obs
-type(obs_def_type) :: obs_def
-integer :: obs_kind_ind
+type(obs_type) :: obs
+type(obs_def_type) :: obs_def
+integer :: obs_kind_ind
num_obs = size(keys)
-! NEED to initialize istatus to okay value
+! NEED to initialize istatus to okay value
istatus = 0
! Initialize the observation type
@@ -364,8 +366,9 @@
assimilate_this_ob = .true.; evaluate_this_ob = .false.
! Otherwise do forward operator for this kind
else
- call get_expected_obs_from_def(keys(i), obs_def, obs_kind_ind, state, obs_vals(i), &
- istatus, assimilate_this_ob, evaluate_this_ob)
+ call get_expected_obs_from_def(keys(i), obs_def, obs_kind_ind, &
+ ens_index, state, state_time, obs_vals(i), istatus, &
+ assimilate_this_ob, evaluate_this_ob)
endif
end do
Modified: DART/trunk/obs_sequence/obs_sequence_mod.html
===================================================================
--- DART/trunk/obs_sequence/obs_sequence_mod.html 2011-02-23 21:14:37 UTC (rev 4752)
+++ DART/trunk/obs_sequence/obs_sequence_mod.html 2011-02-23 22:03:07 UTC (rev 4753)
@@ -2006,12 +2006,14 @@
<A NAME="get_expected_obs"></A>
<br>
<div class=routine>
-<em class=call> call get_expected_obs(seq, keys, state, obs_vals,
- istatus, assimilate_this_ob, evaluate_this_ob) </em>
+<em class=call> call get_expected_obs(seq, keys, ens_index, state,
+ state_time, obs_vals, istatus, assimilate_this_ob, evaluate_this_ob) </em>
<pre>
type(obs_sequence_type), intent(in) :: <em class=code>seq</em>
integer, dimension(:), intent(in) :: <em class=code>keys</em>
+integer, intent(in) :: <em class=code>ens_index</em>
real(r8), dimension(:), intent(in) :: <em class=code>state</em>
+type(time_type), intent(in) :: <em class=code>state_time</em>
real(r8), dimension(:), intent(out) :: <em class=code>obs_vals</em>
integer, intent(out) :: <em class=code>istatus</em>
logical, intent(out) :: <em class=code>assimilate_this_ob</em>
@@ -2035,8 +2037,12 @@
<TD>An observation sequence</TD></TR>
<TR><TD valign=top><em class=code>keys </em></TD>
<TD>List of integer keys that specify observations in seq</TD></TR>
+<TR><TD valign=top><em class=code>ens_index </em></TD>
+ <TD>The ensemble number for this state vector</TD></TR>
<TR><TD valign=top><em class=code>state </em></TD>
<TD>Model state vector</TD></TR>
+<TR><TD valign=top><em class=code>state_time </em></TD>
+ <TD>The time of the state data</TD></TR>
<TR><TD valign=top><em class=code>obs_vals </em></TD>
<TD>Returned expected values of the observations</TD></TR>
<TR><TD valign=top><em class=code>istatus </em></TD>
Modified: DART/trunk/perfect_model_obs/perfect_model_obs.f90
===================================================================
--- DART/trunk/perfect_model_obs/perfect_model_obs.f90 2011-02-23 21:14:37 UTC (rev 4752)
+++ DART/trunk/perfect_model_obs/perfect_model_obs.f90 2011-02-23 22:03:07 UTC (rev 4753)
@@ -343,7 +343,8 @@
endif
! Compute the observations from the state
- call get_expected_obs(seq, keys(j:j), ens_handle%vars(:, 1), &
+ call get_expected_obs(seq, keys(j:j), &
+ 1, ens_handle%vars(:, 1), ens_handle%time(1), &
true_obs(1:1), istatus, assimilate_this_ob, evaluate_this_ob)
! Get the observational error covariance (diagonal at present)
More information about the Dart-dev
mailing list