# Use of pointers

## Pattyn, Boceck, Johnson HO Core

This model makes use of pointers to handle the similarities in the way the $u$ and $v$ components of the velocity are treated. Each component results is in a sparse matrix that is solved assuming the other horizontal velocity component is held fixed.

The file where this is done is

```ice3d_lib.F90
```

The code to do this resides in the subroutine

```    subroutine sparse_setup(component, i,j,k,efvs,dzdx,dzdy,ax,ay,bx,by,cxy,&
h, dx, dy, dz, uvel, vvel, dudx_field, dudy_field, dudz_field, &
dvdx_field, dvdy_field, dvdz_field, &
coef, rhs, direction_x, direction_y, STAGGERED, WHICH_SOURCE)```

This code utilizing pointers is on

```line 1302:1388
```

and looks like

```        if (component == "u") then
dpara_dpara => dudx
dpara_dperp => dudy
dpara_dx    => dudx
dpara_dy    => dudy
dpara_dz    => dudz

dpara_dpara2 => dudx2
dpara_dparaz => dudxz
dpara_dz2    => dudz2
dpara_dx2    => dudx2
dpara_dy2    => dudy2
dpara_dperp2 => dudy2
dpara_dperpz => dudyz
dpara_dyz    => dudyz
dpara_dxz    => dudxz```

and much more. In all about 35 fields are set this way.

It seems to me that the work around is to create a new method that accepts each of the above fields as an arguement. This method is then called twice, once for the $u$ velocity, and again for the $v$. 35 or so arguments makes me think that we might consider other options as well.

Comments? We used pointers because at that time they were the only way we could have dynamic arrays inside derived types. This is no longer necessary for newer fortran compilers (if I remember correctly allocatables inside derived types is a fortran95 feature). We are currently working on getting rid of the pointers. Magi 14:33, 2 March 2010 (UTC)