| 1 | = First Steps with PDAF = |
| 2 | |
| 3 | [[PageOutline(2-3,Contents of this page)]] |
| 4 | |
| 5 | When you have downloaded PDAF, a good starting point is to run a |
| 6 | tutorial example. The directory tutorial/ contains files for tutorials |
| 7 | demonstrating the implementation and application of PDAF with a simple 2-dimensional example. |
| 8 | |
| 9 | == First Test Case - A Single Analysis Step == |
| 10 | |
| 11 | In this test case, a data assimilation program is used to read an ensemble of model fields from files and compute an analysis step. This is the so-called offline coupling mode of PDAF. |
| 12 | |
| 13 | === Compiling === |
| 14 | |
| 15 | We recommend to first look at the tutorial offline_2D_serial, which is a |
| 16 | single analysis step acting on an ensemble of 2D model fields without any |
| 17 | parallelization. |
| 18 | |
| 19 | Change to the tutorial directory with |
| 20 | {{{ |
| 21 | cd tutorial/offline_2D_serial |
| 22 | }}} |
| 23 | and run |
| 24 | {{{ |
| 25 | make PDAF_ARCH=linux_gfortran |
| 26 | }}} |
| 27 | This compiles the assimilation program including PDAF. The compilation |
| 28 | should work for computers running Linux. If the compilation fails, please |
| 29 | see below the section [#CompilationProblems Compilation Problems]. |
| 30 | |
| 31 | === Running === |
| 32 | |
| 33 | Having compiled the program, you can just run it by executing |
| 34 | {{{ |
| 35 | ./PDAF_offline |
| 36 | }}} |
| 37 | The program computes a single analysis step of the ensemble Kalman filter ESTKF. It should not take more than a second. The program generates the |
| 38 | output files |
| 39 | `state_ana.txt` (The analysis state) |
| 40 | and |
| 41 | `ens_01_ana.txt` to `ens_09_ana.txt` (the analysis ensemble). |
| 42 | |
| 43 | The screen output shows the progress of the program. For example the ensemble standard deviation before and after the analysis step and final timing and memory information are shown. Lines starting with 'PDAF' are outputs from the code part of PDAF other lines are from the user routines. |
| 44 | |
| 45 | === Plotting === |
| 46 | |
| 47 | To plot, e.g. the analysis field you can use Matlab or Octave and do |
| 48 | {{{ |
| 49 | load state_ana.txt |
| 50 | pcolor(state_ana) |
| 51 | }}} |
| 52 | You can also plot the initial ensemble mean field by |
| 53 | {{{ |
| 54 | cd ../inputs_offline |
| 55 | load state_ini.txt |
| 56 | pcolor(state_ini) |
| 57 | }}} |
| 58 | Analogously you can plot the observations (`obs.txt`) and the true state (`true.txt`) from which the observations have been generated. In the |
| 59 | observation file, only 28 grid points are observed, while non-observed grid points have the value -999.0. To get a meaningful plot, you can specify the limits for the color map by |
| 60 | {{{ |
| 61 | set(gca,'clim',[-2 2]) |
| 62 | }}} |
| 63 | |
| 64 | === Assimilation Options === |
| 65 | |
| 66 | There are various options you can set to modify the assimilation, |
| 67 | For example you can run |
| 68 | {{{ |
| 69 | ./PDAF_offline -filtertype 7 |
| 70 | }}} |
| 71 | With this setting, the localized filter LESTKF instead of the global ESTKF. |
| 72 | Without further settings, the localization radius is set to 0 so that only |
| 73 | the observed grid points are changed by the assimilation. |
| 74 | You can further set the localization radius with |
| 75 | {{{ |
| 76 | ./PDAF_offline -filtertype 7 -local_range 5 |
| 77 | }}} |
| 78 | Now the LESTKF is used with a localization radius of 5 grid points. This |
| 79 | localization still uses a constant weight of the observation. So you will |
| 80 | see steps in the analysis fields around each observation. To add a |
| 81 | tapering so that observations get less influence for increasing distance, |
| 82 | use |
| 83 | {{{ |
| 84 | ./PDAF_offline -filtertype 7 -local_range 5 -locweight 2 |
| 85 | }}} |
| 86 | Now, the filter is applied with the 5th-order polynomial function by |
| 87 | Gaspari and Cohn. As a result you get a smoothly changing analysis field. |
| 88 | You can also change the ensemble size, e.g. running |
| 89 | {{{ |
| 90 | ./PDAF_offline -dim_ens 5 |
| 91 | }}} |
| 92 | to run with an ensemble of 5 model states. (For this test case we only |
| 93 | prepared 9, so only dim_obs<=9 is possible to run here.) |
| 94 | The standard deviation (RMS error) of the observation is set to 0.5 in the program. To change it to, e.g. 2.0, would would run |
| 95 | {{{ |
| 96 | ./PDAF_offline -rms_obs 2.0 |
| 97 | }}} |
| 98 | All the different options can be combined. For a complete list of possible options, see the file `init_pdaf_offline.F90`, which is the source code file in which the default values of options are specified. |
| 99 | |
| 100 | |
| 101 | |
| 102 | == Second Test Case - A Sequence of Analysis Steps == |
| 103 | |
| 104 | As a second test case, we recommend to look at the tutorial online_2D_serialmodel. |
| 105 | This case is again a simple 2D model field, but now coupled to PDAF with |
| 106 | time stepping. This is the so-called online-coupling of PDAF, in which the model code is augmented with data assimilation functionality provided by PDAF. |
| 107 | |
| 108 | === Compiling === |
| 109 | |
| 110 | Change to the tutorial directory with |
| 111 | {{{ |
| 112 | cd ../online_2D_serialmodel |
| 113 | }}} |
| 114 | and run |
| 115 | {{{ |
| 116 | make cleanall |
| 117 | }}} |
| 118 | and then |
| 119 | {{{ |
| 120 | make model_pdaf PDAF_ARCH=linux_gfortran_openmpi |
| 121 | }}} |
| 122 | This compiles the assimilation program including PDAF. The compilation |
| 123 | should work for computers running Linux, but it requires that OpenMPI |
| 124 | is installed on the computer. If it's not installed, please install it |
| 125 | using the Linux package providing it. If the compilation still fails, |
| 126 | please see below the section [#CompilationProblems Compilation Problems]. |
| 127 | |
| 128 | === Running === |
| 129 | |
| 130 | Having compiled the program, you can just run it by executing |
| 131 | {{{ |
| 132 | mpirun -np 9 ./model_pdaf -dim_ens 9 |
| 133 | }}} |
| 134 | The program computes a sequence of 9 analysis steps with two model time |
| 135 | steps in between subsequent analysis steps. The assimilation uses of the |
| 136 | ensemble Kalman filter ESTKF. It should not take more than a few seconds. |
| 137 | The program generates the |
| 138 | output files |
| 139 | `state_stepX_ana.txt` (The analysis state at time step X) |
| 140 | and |
| 141 | `ens_01_stepX_ana.txt` to `ens_09_stepX_ana.txt` (the analysis ensemble at time step X) |
| 142 | `ens_01_stepX_for.txt to `ens_09_stepX_for.txt` (the forecast ensemble at time step X) |
| 143 | |
| 144 | === Plotting === |
| 145 | |
| 146 | You can plot the analysis fields, but also the observations, true fields |
| 147 | and the initial state estimate as described in the first test case. However, |
| 148 | the files for the observations and true fields are stored in the directory |
| 149 | inputs_online/ |
| 150 | |
| 151 | To plot the analysis field at time step 10, you can do |
| 152 | {{{ |
| 153 | load state_step10_ana.txt |
| 154 | pcolor(state_step10_ana) |
| 155 | }}} |
| 156 | You can also plot the initial model field by |
| 157 | {{{ |
| 158 | cd ../inputs_online |
| 159 | load state_ini.txt |
| 160 | pcolor(state_ini) |
| 161 | }}} |
| 162 | The directory `inputs_online/` also contains files for the true state at time steps 1 to 18. |
| 163 | For example, you can plot the true state at time step 15, with |
| 164 | {{{ |
| 165 | load true_step15.txt |
| 166 | pcolor(true_step15) |
| 167 | }}} |
| 168 | Analogously you can plot the observations (`obs_stepX.txt`) with time step X. In the |
| 169 | observation file, observation gaps are indiced by the value -999.0. So |
| 170 | to get a meaningful plot, you can specify the limits for the color map by |
| 171 | {{{ |
| 172 | set(gca,'clim',[-2 2]) |
| 173 | }}} |
| 174 | |
| 175 | |
| 176 | === Assimilation Options === |
| 177 | |
| 178 | The same options as for the first test case can be used here, too. In addition, one can specify the |
| 179 | forecast length (number of time steps between two analysis steps by |
| 180 | {{{ |
| 181 | mpirun -np 9 ./model_pdaf -dim_ens 9 -delt_obs 6 |
| 182 | }}} |
| 183 | To change the ensemble size to 6 states, you can use for example |
| 184 | {{{ |
| 185 | mpirun -np 6 ./model_pdaf -dim_ens 6 -filtertype 5 -local_range 3 |
| 186 | }}} |
| 187 | which chooses to run the LETKF with a localization radius of 3 grid points. |
| 188 | (Please note: The value behind `-np` must always set to be equal to the value given for `-dim_ens`. |
| 189 | For this test case we only |
| 190 | prepared 9 initial ensemble files, so only dim_obs<=9 is possible to run here.) |
| 191 | |
| 192 | |
| 193 | |
| 194 | |
| 195 | |
| 196 | == Compilation Problems == |
| 197 | |
| 198 | For the compilation, you need `make`. This should be installed on any computer running Linux, Unix or OSX. |
| 199 | If it is missing, you cannot compile and should install `make`. |
| 200 | |
| 201 | The compilation might fail with an error mentioning `blas` or `lapack`. |
| 202 | These are libraries for matrix computations, which are used by PDAF for |
| 203 | performance reasons. Both libraries are usually installed on Linux |
| 204 | computers. If these libraries are missing, please install them from the |
| 205 | Linux packages of your Linux distribution. Then compile the tutorial |
| 206 | example again. |
| 207 | |
| 208 | For compilation on computers different from standard Linux or with a |
| 209 | different compiler than gfortran, the directory `make.arch/` provides |
| 210 | include files for the compilation. To check for a suitable include file |
| 211 | koos into the directory `make.arch/`. There are files for |
| 212 | compilation on different computers both with and without parallelization |
| 213 | (MPI). If you don't find a suitable include file, you might also copy |
| 214 | an existing one and edit it for your needs. To specify the include file |
| 215 | for the compilation, you just need to set it when running make as |
| 216 | {{{ |
| 217 | make PDAF_ARCH=FILENAME_WITHOUT_.h |
| 218 | }}} |
| 219 | |
| 220 | |
| 221 | == Next steps == |
| 222 | |
| 223 | Possible next steps from here can be the following: |
| 224 | |
| 225 | |
| 226 | === Implementing PDAF with your model === |
| 227 | |
| 228 | If you plan to couple PDAF with your model, we recommend to study the [wiki:PdafTutorial PDAF implementation tutorials]. The tutorial provides a step-by-step explanation of the implementation steps. Further, please see the description of the [wiki:GeneralImplementationConcept Implementation Concept of PDAF]. |
| 229 | |
| 230 | === Model Bindings === |
| 231 | |
| 232 | With PDAF 1.13, the PDAF package provides a model binding for the MITgcm general circulation model. This code provides an implementation of PDAF with the MITgcm model for a simple test case. Please look into the directory `modelbindings/MITgcm/` of the PDAF package, where a README-file describes the use of the model binding code. |