Index: /codes/icosagcm/devel/DySL/jinja
===================================================================
--- /codes/icosagcm/devel/DySL/jinja	(revision 1048)
+++ /codes/icosagcm/devel/DySL/jinja	(revision 1049)
@@ -2,4 +2,5 @@
 from sys import argv
 from textwrap import dedent
+import re
 from re import search # regular expressions
 
@@ -10,6 +11,16 @@
     else:
        print (3*indent)*' ' + line
+
+# Jinja2 custom tests
+# https://jinja.palletsprojects.com/en/2.10.x/templates/
+
+def is_keyword(word, txt):
+    pattern=r'\b%s\b'%word
+    match = search(pattern, txt)
+    return True if match else False
     	
 env=Environment(loader=FileSystemLoader('.'))
+env.tests['in'] = is_keyword
+
 tpl=env.get_template(argv[1])
 source = tpl.render()
@@ -41,2 +52,4 @@
     else:
         pretty(line,indent)
+
+# print is_keyword('LE','LE_DE')
Index: /codes/icosagcm/devel/DySL/macros.jin
===================================================================
--- /codes/icosagcm/devel/DySL/macros.jin	(revision 1048)
+++ /codes/icosagcm/devel/DySL/macros.jin	(revision 1049)
@@ -25,10 +25,10 @@
 
 {% macro cdef(code, key,val) %} 
-{{ define(key,val) if key in code }}
+{{ define(key,val) if key is in code }}
 {%- endmacro %}
 
 {% macro cundef(code, keys) %} 
 {% for key in keys %}
-{{ undef(key) if key in code }}
+{{ undef(key) if key is in code }}
 {%- endfor %}
 {%- endmacro %}
Index: /codes/icosagcm/devel/DySL/unstructured/macros.jin
===================================================================
--- /codes/icosagcm/devel/DySL/unstructured/macros.jin	(revision 1048)
+++ /codes/icosagcm/devel/DySL/unstructured/macros.jin	(revision 1049)
@@ -127,17 +127,23 @@
 {% macro get_edges(thecode, mesh,degree) %}
 {% for iedge in range(1,degree+1) %} 
-{{ 'edge%d = %s_edge(%d,ij)'%(iedge,mesh,iedge) if 'EDGE' in thecode }} 
-{% endfor %}
-{% for iedge in range(1,degree+1) %} 
-{{ 'le_de%d = le_de(edge%d)'%(iedge,iedge) if 'LE_DE' in thecode }}      
-{% endfor %}
-{% for iedge in range(1,degree+1) %} 
-{{ 'sign%d = %s_ne(%d,ij)'%(iedge,mesh,iedge) if 'SIGN' in thecode }}   
-{% endfor %}
-{% for iedge in range(1,degree+1) %} 
-{{ 'ij_up%d = up(edge%d)'%(iedge,iedge) if 'VERTEX1' in thecode }}
-{% endfor %}
-{% for iedge in range(1,degree+1) %} 
-{{ 'ij_down%d = down(edge%d)'%(iedge,iedge) if 'VERTEX2' in thecode }}
+{{ 'edge%d = %s_edge(%d,ij)'%(iedge,mesh,iedge) if 'EDGE' is in thecode }} 
+{% endfor %}
+{% for iedge in range(1,degree+1) %} 
+{{ 'le_de%d = le_de(edge%d)'%(iedge,iedge) if 'LE_DE' is in thecode }}      
+{% endfor %}
+{% for iedge in range(1,degree+1) %} 
+{{ 'de%d = de(edge%d)'%(iedge,iedge) if 'DE' is in thecode }}      
+{% endfor %}
+{% for iedge in range(1,degree+1) %} 
+{{ 'le%d = le(edge%d)'%(iedge,iedge) if 'LE' is in thecode }}
+{% endfor %}
+{% for iedge in range(1,degree+1) %} 
+{{ 'sign%d = %s_ne(%d,ij)'%(iedge,mesh,iedge) if 'SIGN' is in(thecode) }}   
+{% endfor %}
+{% for iedge in range(1,degree+1) %} 
+{{ 'ij_up%d = up(edge%d)'%(iedge,iedge) if 'VERTEX1' is in thecode }}
+{% endfor %}
+{% for iedge in range(1,degree+1) %} 
+{{ 'ij_down%d = down(edge%d)'%(iedge,iedge) if 'VERTEX2' is in thecode }}
 {% endfor %}
 {% endmacro %}
@@ -303,5 +309,5 @@
 END DO
 !$OMP END DO
-{{ cundef(thecode, ('EDGE','LE_DE','SIGN','CELL1','CELL2','VERTEX1','VERTEX2') ) }}
+{{ cundef(thecode, ('EDGE','LE_DE','LE','DE','SIGN','CELL1','CELL2','VERTEX1','VERTEX2') ) }}
 {%- endmacro %}
 
@@ -314,4 +320,6 @@
 {{ cdef(thecode, 'SIGN', 'sign%d'%iedge) }}
 {{ cdef(thecode, 'LE_DE', 'le_de%d'%iedge) }}
+{{ cdef(thecode, 'DE', 'de%d'%iedge) }}
+{{ cdef(thecode, 'LE', 'le%d'%iedge) }}
 {{ cdef(thecode, 'VERTEX1', 'l,ij_up%d'%iedge) }}
 {{ cdef(thecode, 'VERTEX2', 'l,ij_down%d'%iedge) }}
@@ -322,4 +330,6 @@
 {{ cdef(thecode, 'SIGN', mesh + '_ne(iedge,ij)') }}
 {{ cdef(thecode, 'LE_DE', 'le_de(edge)') }}
+{{ cdef(thecode, 'DE', 'de(edge)') }}
+{{ cdef(thecode, 'LE', 'le(edge)') }}
 {{ cdef(thecode, 'VERTEX1', 'l,ij_up') }}
 {{ cdef(thecode, 'VERTEX2', 'l,ij_down') }}
@@ -331,5 +341,5 @@
 END DO
 {% endif %}
-{{ cundef(thecode, ('EDGE', 'SIGN', 'LE_DE', 'VERTEX1', 'VERTEX2') ) }}
+{{ cundef(thecode, ('EDGE', 'SIGN', 'LE_DE', 'LE', 'DE', 'VERTEX1', 'VERTEX2') ) }}
 {%- endmacro %}
 
