/* This OpenCL kernel implements part of the Forward Backward Linear numerical scheme for the shallow water equations, described in L. P. Røed, "Documentation of simple ocean models for use in ensemble predictions", Met no report 2012/3 and 2012/5 . Copyright (C) 2016 SINTEF ICT This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ /** * Kernel that evolves eta one step in time. */ __kernel void computeEtaKernel( //Discretization parameters int nx_, int ny_, float dx_, float dy_, float dt_, //Physical parameters float g_, //< Gravitational constant float f_, //< Coriolis coefficient float r_, //< Bottom friction coefficient //Data __global float* H_ptr_, int H_pitch_, __global float* U_ptr_, int U_pitch_, __global float* V_ptr_, int V_pitch_, __global float* eta_ptr_, int eta_pitch_) { //Index of thread within block const int tx = get_local_id(0); const int ty = get_local_id(1); //Index of block within domain const int bx = get_local_size(0) * get_group_id(0); const int by = get_local_size(1) * get_group_id(1); //Index of cell within domain const int ti = get_global_id(0); const int tj = get_global_id(1); __local float U_shared[block_height][block_width+1]; __local float V_shared[block_height+1][block_width]; //Compute pointer to current row in the U array __global float* const eta_row = (__global float*) ((__global char*) eta_ptr_ + eta_pitch_*tj); //Read current eta float eta_current = 0.0f; if (ti < nx_ && tj < ny_) { eta_current = eta_row[ti]; } //Read U into shared memory for (int j=ty; j