Discrete Inverse and State Estimation Problems. With Geophysical Fluid Applications