wiki:readwrite_obs

readwrite_obs

The page documents the template routines in readwrite_obs.F90: init_file_syn_obs, write_syn_obs, and read_syn_obs.

This routine can be used when one uses PDAF's functionality for generating synthetic observations with PDAF_generate_obs or PDAF_put_state_generate_obs. The routines are not called directly by PDAF, but in the user code.

The routines are provided as a template in the PDAF package. Usually, they can be used directly without modifications. Their purpose is to write synthetic observations generated by PDAF into a file holdig these synthetic observation, and to read them from this file in a twin data assimilation experiment. The routines use netCDF as the file format, because it allows for structured and efficient file writing and reading. However, one could also modify this cuntionality to e.g. use Fortran binary files.

The routines are the following

init_file_syn_obs

This routine initializes the file(s) holding the synthetic observations. It is usually called at the initialization stage in init_pdaf.

The interface is the following:

SUBROUTINE init_file_syn_obs(dim_obs_max, file_obs, screen)

with

  • dim_obs_max : integer, intent(in)
    Maximum dimension of an observation vector
  • file_obs : character(len=*), intent(in)
    Name of the file
  • screen : integer, intent(in)
    Flag whether the routine should write screen output: (>0) for output

Hints:

  • If the full vector of synthetic observations is identical for each process in a parallel configuration, only a single process (e.g. rank=0) should call this routine. With parallelization each process might hold a different vector of full synthetic observations. In this case each process should call this routine with a distinct file name.

write_syn_obs

This routine writes the full vector of synthetic observations into the file. It is usually called in get_obs_f_pdaf when observations are generated with PDAF.

The interface is the following:

SUBROUTINE write_syn_obs(step, file_obs, dim_obs_f, observation_f, screen)

with

  • step : integer, intent(in)
    Current time step
  • file_obs : character(len=*), intent(in)
    Name of the file
  • dim_obs_f : integer, intent(in)
    Dimension of full observation vector
  • observation_f : real, intent(in), dimsion(dim_obs_f)
    Full vector of synthetic observations to be writting into file
  • screen : integer, intent(in)
    Flag whether the routine should write screen output: (>0) for output

Hints:

  • If the full vector of synthetic observations is identical for each process in a parallel configuration, only a single process (e.g. rank=0) should call this routine. With parallelization each process might hold a different vector of full synthetic observations. In this case each process should call this routine with a distinct file name and observation vector
  • The routine has an internal counter for the index at which a vector is written into the file. This counter is independent for each process and is incremented each time the routine is called.
  • if dim_obs_f > dim_obs_obs, where dim_obs_max was defined in the call to init_file_syn_obs, only the first dim_obs_max elements of the observation vector are written into the file.

read_syn_obs

This routine reads the full vector of synthetic observations from the file. It is usually called in init_dim_obs_f_pdaf when a twin experiment is computed.

The interface is the following:

SUBROUTINE read_syn_obs(file_obs, dim_obs_f, observation_f, offset, screen)

with

  • step : integer, intent(in)
    Current time step
  • file_obs : character(len=*), intent(in)
    Name of the file
  • dim_obs_f : integer, intent(in)
    Dimension of full observation vector
  • observation_f : real, intent(out), dimsion(dim_obs_f)
    Full vector of synthetic observations to be writting into file
  • offset : integer, intent(in)
    Offset in the file index at which the observation vector sould be read
  • screen : integer, intent(in)
    Flag whether the routine should write screen output: (>0) for output

Hints:

  • If the full vector of synthetic observations is identical for each process in a parallel configuration, only a single process (e.g. rank=0) should call this routine. With parallelization each process might hold a different vector of full synthetic observations. In this case each process should call this routine with a distinct file name and observation vector
  • The routine has an internal counter for the index at which a vector from the file is read. Thus at the first call, the vector at the index offset+1 is read. Accordingly, offset should be 0 if the observations are read from file index 1 (i.e. the beginning of the file). If one wants to use the observations with an offset, as for example in the example of the Lorenz-96 model, one sets offset to the value of this offset.
Last modified 6 years ago Last modified on Feb 9, 2019, 1:17:53 PM