diff --git a/gfort2py/gfort2py.py b/gfort2py/gfort2py.py index d8392e4..fc67003 100644 --- a/gfort2py/gfort2py.py +++ b/gfort2py/gfort2py.py @@ -68,13 +68,16 @@ def __dir__(self): return self.keys() def __getattr__(self, key): + k = key + key = key.lower() + if key in self.__dict__: return self.__dict__[key] if "_initialized" in self.__dict__: if self._initialized: if key not in self.keys(): - raise AttributeError(f"{self._mod_file} has no attribute {key}") + raise AttributeError(f"{self._mod_file} has no attribute {k}") if self._module[key].is_variable(): if key not in self._saved: @@ -98,6 +101,9 @@ def __getattr__(self, key): ) def __setattr__(self, key, value): + k = key + key = key.lower() + if key in self.__dict__: self.__dict__[key] = value return diff --git a/tests/basic.f90 b/tests/basic.f90 index 6e73a5c..fde4f1d 100644 --- a/tests/basic.f90 +++ b/tests/basic.f90 @@ -49,6 +49,10 @@ module basic real :: a_real_set=7.0 real(dp) :: a_real_dp_set=8.0_dp + ! Test Mixed Case variables + integer :: a_int_MIXED + integer :: const_int_MIXED = 1 + contains @@ -235,4 +239,10 @@ logical function func_test_bool(x) end function func_test_bool + + integer function func_TEST_CASE() + func_TEST_CASE = 1 + end function func_TEST_CASE + + end module basic diff --git a/tests/basic_test.py b/tests/basic_test.py index afba4b9..551341a 100644 --- a/tests/basic_test.py +++ b/tests/basic_test.py @@ -255,3 +255,21 @@ def test_func_check_mod(self): x.a_real_dp = 5.0 assert x.func_check_mod().result + + def test_mixed_case(self): + + assert x.const_int_MIXED == 1 + assert x.const_int_mixed == 1 + assert x.CONST_INT_MIXED == 1 + + x.a_int_MIXED = 5 + assert x.a_int_MIXED == 5 + + assert x.a_int_mixed == 5 + + x.a_int_mixed = 6 + assert x.A_INT_MIXED == 6 + + assert x.func_TEST_CASE().result + assert x.func_test_case().result + assert x.FUNC_test_case().result