Index: codes/icosagcm/devel/src/kernels_unst/coriolis.k90
===================================================================
--- codes/icosagcm/devel/src/kernels_unst/coriolis.k90	(revision 683)
+++ codes/icosagcm/devel/src/kernels_unst/coriolis.k90	(revision 940)
@@ -176,75 +176,150 @@
    !$OMP END DO
    !
-   !$OMP DO SCHEDULE(STATIC)
-   DO edge = 1, edge_num
-      ! this VLOOP iterates over the TRISK stencil
-      SELECT CASE(trisk_deg(edge))
-      CASE(4)
-         !DIR$ SIMD
-         DO l = 1, llm
-            du_trisk=0.
-            itrisk = 1
-            edge_trisk = trisk(1,edge)
-            du_trisk = du_trisk + wee(itrisk,edge)*hflux(l,edge_trisk)*(qu(l,edge)+qu(l,edge_trisk))
-            itrisk = 2
-            edge_trisk = trisk(2,edge)
-            du_trisk = du_trisk + wee(itrisk,edge)*hflux(l,edge_trisk)*(qu(l,edge)+qu(l,edge_trisk))
-            itrisk = 3
-            edge_trisk = trisk(3,edge)
-            du_trisk = du_trisk + wee(itrisk,edge)*hflux(l,edge_trisk)*(qu(l,edge)+qu(l,edge_trisk))
-            itrisk = 4
-            edge_trisk = trisk(4,edge)
-            du_trisk = du_trisk + wee(itrisk,edge)*hflux(l,edge_trisk)*(qu(l,edge)+qu(l,edge_trisk))
-            du(l,edge) = du(l,edge) + .5*du_trisk
-         END DO
-      CASE(10)
-         !DIR$ SIMD
-         DO l = 1, llm
-            du_trisk=0.
-            itrisk = 1
-            edge_trisk = trisk(1,edge)
-            du_trisk = du_trisk + wee(itrisk,edge)*hflux(l,edge_trisk)*(qu(l,edge)+qu(l,edge_trisk))
-            itrisk = 2
-            edge_trisk = trisk(2,edge)
-            du_trisk = du_trisk + wee(itrisk,edge)*hflux(l,edge_trisk)*(qu(l,edge)+qu(l,edge_trisk))
-            itrisk = 3
-            edge_trisk = trisk(3,edge)
-            du_trisk = du_trisk + wee(itrisk,edge)*hflux(l,edge_trisk)*(qu(l,edge)+qu(l,edge_trisk))
-            itrisk = 4
-            edge_trisk = trisk(4,edge)
-            du_trisk = du_trisk + wee(itrisk,edge)*hflux(l,edge_trisk)*(qu(l,edge)+qu(l,edge_trisk))
-            itrisk = 5
-            edge_trisk = trisk(5,edge)
-            du_trisk = du_trisk + wee(itrisk,edge)*hflux(l,edge_trisk)*(qu(l,edge)+qu(l,edge_trisk))
-            itrisk = 6
-            edge_trisk = trisk(6,edge)
-            du_trisk = du_trisk + wee(itrisk,edge)*hflux(l,edge_trisk)*(qu(l,edge)+qu(l,edge_trisk))
-            itrisk = 7
-            edge_trisk = trisk(7,edge)
-            du_trisk = du_trisk + wee(itrisk,edge)*hflux(l,edge_trisk)*(qu(l,edge)+qu(l,edge_trisk))
-            itrisk = 8
-            edge_trisk = trisk(8,edge)
-            du_trisk = du_trisk + wee(itrisk,edge)*hflux(l,edge_trisk)*(qu(l,edge)+qu(l,edge_trisk))
-            itrisk = 9
-            edge_trisk = trisk(9,edge)
-            du_trisk = du_trisk + wee(itrisk,edge)*hflux(l,edge_trisk)*(qu(l,edge)+qu(l,edge_trisk))
-            itrisk = 10
-            edge_trisk = trisk(10,edge)
-            du_trisk = du_trisk + wee(itrisk,edge)*hflux(l,edge_trisk)*(qu(l,edge)+qu(l,edge_trisk))
-            du(l,edge) = du(l,edge) + .5*du_trisk
-         END DO
-      CASE DEFAULT
-         !DIR$ SIMD
-         DO l = 1, llm
-            du_trisk=0.
-            DO itrisk = 1, trisk_deg(edge)
-               edge_trisk = trisk(itrisk,edge)
-               du_trisk = du_trisk + wee(itrisk,edge)*hflux(l,edge_trisk)*(qu(l,edge)+qu(l,edge_trisk))
-            END DO
-            du(l,edge) = du(l,edge) + .5*du_trisk
-         END DO
-      END SELECT
-   END DO
-   !$OMP END DO
+   SELECT CASE(caldyn_conserv)
+   CASE(conserv_energy) ! energy-conserving TRiSK
+      !$OMP DO SCHEDULE(STATIC)
+      DO edge = 1, edge_num
+         ! this VLOOP iterates over the TRISK stencil
+         SELECT CASE(trisk_deg(edge))
+         CASE(4)
+            !DIR$ SIMD
+            DO l = 1, llm
+               du_trisk=0.
+               itrisk = 1
+               edge_trisk = trisk(1,edge)
+               du_trisk = du_trisk + wee(itrisk,edge,1)*hflux(l,edge_trisk)*(qu(l,edge)+qu(l,edge_trisk))
+               itrisk = 2
+               edge_trisk = trisk(2,edge)
+               du_trisk = du_trisk + wee(itrisk,edge,1)*hflux(l,edge_trisk)*(qu(l,edge)+qu(l,edge_trisk))
+               itrisk = 3
+               edge_trisk = trisk(3,edge)
+               du_trisk = du_trisk + wee(itrisk,edge,1)*hflux(l,edge_trisk)*(qu(l,edge)+qu(l,edge_trisk))
+               itrisk = 4
+               edge_trisk = trisk(4,edge)
+               du_trisk = du_trisk + wee(itrisk,edge,1)*hflux(l,edge_trisk)*(qu(l,edge)+qu(l,edge_trisk))
+               du(l,edge) = du(l,edge) + .5*du_trisk
+            END DO
+         CASE(10)
+            !DIR$ SIMD
+            DO l = 1, llm
+               du_trisk=0.
+               itrisk = 1
+               edge_trisk = trisk(1,edge)
+               du_trisk = du_trisk + wee(itrisk,edge,1)*hflux(l,edge_trisk)*(qu(l,edge)+qu(l,edge_trisk))
+               itrisk = 2
+               edge_trisk = trisk(2,edge)
+               du_trisk = du_trisk + wee(itrisk,edge,1)*hflux(l,edge_trisk)*(qu(l,edge)+qu(l,edge_trisk))
+               itrisk = 3
+               edge_trisk = trisk(3,edge)
+               du_trisk = du_trisk + wee(itrisk,edge,1)*hflux(l,edge_trisk)*(qu(l,edge)+qu(l,edge_trisk))
+               itrisk = 4
+               edge_trisk = trisk(4,edge)
+               du_trisk = du_trisk + wee(itrisk,edge,1)*hflux(l,edge_trisk)*(qu(l,edge)+qu(l,edge_trisk))
+               itrisk = 5
+               edge_trisk = trisk(5,edge)
+               du_trisk = du_trisk + wee(itrisk,edge,1)*hflux(l,edge_trisk)*(qu(l,edge)+qu(l,edge_trisk))
+               itrisk = 6
+               edge_trisk = trisk(6,edge)
+               du_trisk = du_trisk + wee(itrisk,edge,1)*hflux(l,edge_trisk)*(qu(l,edge)+qu(l,edge_trisk))
+               itrisk = 7
+               edge_trisk = trisk(7,edge)
+               du_trisk = du_trisk + wee(itrisk,edge,1)*hflux(l,edge_trisk)*(qu(l,edge)+qu(l,edge_trisk))
+               itrisk = 8
+               edge_trisk = trisk(8,edge)
+               du_trisk = du_trisk + wee(itrisk,edge,1)*hflux(l,edge_trisk)*(qu(l,edge)+qu(l,edge_trisk))
+               itrisk = 9
+               edge_trisk = trisk(9,edge)
+               du_trisk = du_trisk + wee(itrisk,edge,1)*hflux(l,edge_trisk)*(qu(l,edge)+qu(l,edge_trisk))
+               itrisk = 10
+               edge_trisk = trisk(10,edge)
+               du_trisk = du_trisk + wee(itrisk,edge,1)*hflux(l,edge_trisk)*(qu(l,edge)+qu(l,edge_trisk))
+               du(l,edge) = du(l,edge) + .5*du_trisk
+            END DO
+         CASE DEFAULT
+            !DIR$ SIMD
+            DO l = 1, llm
+               du_trisk=0.
+               DO itrisk = 1, trisk_deg(edge)
+                  edge_trisk = trisk(itrisk,edge)
+                  du_trisk = du_trisk + wee(itrisk,edge,1)*hflux(l,edge_trisk)*(qu(l,edge)+qu(l,edge_trisk))
+               END DO
+               du(l,edge) = du(l,edge) + .5*du_trisk
+            END DO
+         END SELECT
+      END DO
+      !$OMP END DO
+   CASE(conserv_enstrophy) ! enstrophy-conserving TRiSK
+      !$OMP DO SCHEDULE(STATIC)
+      DO edge = 1, edge_num
+         ! this VLOOP iterates over the TRISK stencil
+         SELECT CASE(trisk_deg(edge))
+         CASE(4)
+            !DIR$ SIMD
+            DO l = 1, llm
+               du_trisk=0.
+               itrisk = 1
+               edge_trisk = trisk(1,edge)
+               du_trisk = du_trisk + wee(itrisk,edge,1)*hflux(l,edge_trisk)
+               itrisk = 2
+               edge_trisk = trisk(2,edge)
+               du_trisk = du_trisk + wee(itrisk,edge,1)*hflux(l,edge_trisk)
+               itrisk = 3
+               edge_trisk = trisk(3,edge)
+               du_trisk = du_trisk + wee(itrisk,edge,1)*hflux(l,edge_trisk)
+               itrisk = 4
+               edge_trisk = trisk(4,edge)
+               du_trisk = du_trisk + wee(itrisk,edge,1)*hflux(l,edge_trisk)
+               du(l,edge) = du(l,edge) + du_trisk*qu(l,edge)
+            END DO
+         CASE(10)
+            !DIR$ SIMD
+            DO l = 1, llm
+               du_trisk=0.
+               itrisk = 1
+               edge_trisk = trisk(1,edge)
+               du_trisk = du_trisk + wee(itrisk,edge,1)*hflux(l,edge_trisk)
+               itrisk = 2
+               edge_trisk = trisk(2,edge)
+               du_trisk = du_trisk + wee(itrisk,edge,1)*hflux(l,edge_trisk)
+               itrisk = 3
+               edge_trisk = trisk(3,edge)
+               du_trisk = du_trisk + wee(itrisk,edge,1)*hflux(l,edge_trisk)
+               itrisk = 4
+               edge_trisk = trisk(4,edge)
+               du_trisk = du_trisk + wee(itrisk,edge,1)*hflux(l,edge_trisk)
+               itrisk = 5
+               edge_trisk = trisk(5,edge)
+               du_trisk = du_trisk + wee(itrisk,edge,1)*hflux(l,edge_trisk)
+               itrisk = 6
+               edge_trisk = trisk(6,edge)
+               du_trisk = du_trisk + wee(itrisk,edge,1)*hflux(l,edge_trisk)
+               itrisk = 7
+               edge_trisk = trisk(7,edge)
+               du_trisk = du_trisk + wee(itrisk,edge,1)*hflux(l,edge_trisk)
+               itrisk = 8
+               edge_trisk = trisk(8,edge)
+               du_trisk = du_trisk + wee(itrisk,edge,1)*hflux(l,edge_trisk)
+               itrisk = 9
+               edge_trisk = trisk(9,edge)
+               du_trisk = du_trisk + wee(itrisk,edge,1)*hflux(l,edge_trisk)
+               itrisk = 10
+               edge_trisk = trisk(10,edge)
+               du_trisk = du_trisk + wee(itrisk,edge,1)*hflux(l,edge_trisk)
+               du(l,edge) = du(l,edge) + du_trisk*qu(l,edge)
+            END DO
+         CASE DEFAULT
+            !DIR$ SIMD
+            DO l = 1, llm
+               du_trisk=0.
+               DO itrisk = 1, trisk_deg(edge)
+                  edge_trisk = trisk(itrisk,edge)
+                  du_trisk = du_trisk + wee(itrisk,edge,1)*hflux(l,edge_trisk)
+               END DO
+               du(l,edge) = du(l,edge) + du_trisk*qu(l,edge)
+            END DO
+         END SELECT
+      END DO
+      !$OMP END DO
+   END SELECT
    !---------------------------- coriolis ----------------------------------
    !--------------------------------------------------------------------------
