Skip to content
Snippets Groups Projects
Commit 44a916e7 authored by 数学の武士's avatar 数学の武士
Browse files

str comparison func fix

parent e9dd977a
No related branches found
No related tags found
No related merge requests found
...@@ -2,20 +2,29 @@ ...@@ -2,20 +2,29 @@
module PARSER_SUB_F module PARSER_SUB_F
contains contains
FUNCTION compare_char_arrays(arr1, arr2, N) RESULT(isEqual) FUNCTION compare_char_arrays(arr1, arr2) RESULT(isEqual)
IMPLICIT NONE IMPLICIT NONE
CHARACTER, intent(in) :: arr1(N) INTEGER :: size1, size2
CHARACTER, intent(in) :: arr2(N) CHARACTER, intent(in) :: arr1(:)
INTEGER, intent(in) :: N CHARACTER(len=*), intent(in) :: arr2
LOGICAL :: isEqual LOGICAL:: isEqual
INTEGER :: i INTEGER :: N, i
size1 = size(arr1)
size2 = len(arr2)
isEqual = .TRUE. isEqual = .TRUE.
IF (size1.NE.size2) THEN
isEqual = .FALSE.
RETURN
END IF
N = size1
DO i = 1, N DO i = 1, N
IF (arr1(i) .NE. arr2(i)) THEN IF (arr1(i) .NE. arr2(i:i)) THEN
isEqual = .FALSE. ! Найдено неравенство isEqual = .FALSE. ! Найдено неравенство
EXIT RETURN
END IF END IF
END DO END DO
END FUNCTION compare_char_arrays END FUNCTION compare_char_arrays
...@@ -30,11 +39,11 @@ module PARSER_SUB_F ...@@ -30,11 +39,11 @@ module PARSER_SUB_F
call get_charf(config_var_name, sfx_type) call get_charf(config_var_name, sfx_type)
if ( compare_char_arrays(sfx_type, "ocean", SIZE(sfx_type)) ) then if ( compare_char_arrays(sfx_type, "ocean") ) then
type = surface_ocean type = surface_ocean
else if ( compare_char_arrays(sfx_type, "lake", SIZE(sfx_type)) ) then else if ( compare_char_arrays(sfx_type, "lake") ) then
type = surface_lake type = surface_lake
else if ( compare_char_arrays(sfx_type, "land", SIZE(sfx_type)) ) then else if ( compare_char_arrays(sfx_type, "land") ) then
type = surface_land type = surface_land
end if end if
...@@ -43,3 +52,4 @@ module PARSER_SUB_F ...@@ -43,3 +52,4 @@ module PARSER_SUB_F
end module PARSER_SUB_F end module PARSER_SUB_F
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment