This paper deals with a problem of identification and suboptimal control of a counterflow heat exchanger. From the point of view of control theory the heat exchanger is a nonlinear, multidimensional, distributed parameter, dynamical system, and due to its complexity it is difficult to identify it as a black box. In this paper a hybrid model containing neural networks is identified. Its complicated structure makes the analytical calculation of the gradient of performance index with respect to neural network weights very difficult. This problem is solved using a special, structural formulation of sensitivity analysis called generalized back propagation through time (GBPTT). This method is universal, can be used for searching suboptimal parameters (weights) or suboptimal control signals in continuous or discrete time, nonlinear, dynamical systems. Moreover, the presented method is fully mnemonic. The obtained model of the heat exchanger and the same methodology is used during the gradient calculation of the suboptimal control signal of the heat exchanger. Numerical examples are presented.