Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2394 support char logical in psydata #2509

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8b8d9b6
#2394 Support logical and character for nan and readonly.
hiker Nov 9, 2023
1c54119
Merge remote-tracking branch 'origin/master' into 2394_support_char_l…
hiker Feb 22, 2024
b61f169
Merge remote-tracking branch 'origin/master' into 2394_support_char_l…
hiker May 14, 2024
76f2a28
Merge remote-tracking branch 'origin/master' into 2394_support_char_l…
hiker Dec 8, 2024
92388d6
#2394 Fixed character handling.
hiker Dec 9, 2024
a2f86f7
Merge remote-tracking branch 'origin/master' into 2394_support_char_l…
hiker Dec 10, 2024
1d13b02
Merge remote-tracking branch 'origin/master' into 2394_support_char_l…
hiker Dec 18, 2024
ecb0571
Merge remote-tracking branch 'origin/master' into 2394_support_char_l…
hiker Jan 6, 2025
8debe33
#2394 Removed the bits field from ALL_TYPES.
hiker Jan 7, 2025
69b9938
#2394 Fixed bug (int arrays not checked for value range).
hiker Jan 7, 2025
ae62916
#2394 Added generic read-only verification library, and added example…
hiker Jan 9, 2025
42259f5
Merge remote-tracking branch 'origin/master' into 2394_support_char_l…
hiker Jan 9, 2025
b3f9904
#2394 Fixed coding style.
hiker Jan 9, 2025
fa19a9b
Merge remote-tracking branch 'origin/master' into 2394_support_char_l…
hiker Jan 9, 2025
96d917d
#2394 fix whitespace errors in xdsl makefile
arporter Jan 10, 2025
9533be1
#2394 Fix typo.
hiker Jan 14, 2025
3358e77
#2394 Updated documentation and comments.
hiker Jan 14, 2025
e970ccf
#2394 Fix makefile to avoid running psyclone unnecessary.
hiker Jan 14, 2025
2f1497a
#2394 Added more comments.
hiker Jan 14, 2025
b0003bf
#2394 Updated comments, fixed link.
hiker Jan 14, 2025
761099c
#2394 Fixed incorrect links in READMEs.
hiker Jan 14, 2025
3c80cb8
Merge branch '2394_support_char_logical_in_psydata' of github.com:stf…
hiker Jan 14, 2025
d0562cf
Merge remote-tracking branch 'origin/master' into 2394_support_char_l…
hiker Jan 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/read_only/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ PSYDATA_LIB_DIR ?= ./..

# The read-only verification library is implemented for int, real and
arporter marked this conversation as resolved.
Show resolved Hide resolved
# double scalars and 2-dimension arrays
PROCESS_ARGS = -prefix=read_only_verify_ -types=int,real,double \
-dims=2
PROCESS_ARGS = -prefix=read_only_verify_ -types=char,int,logical,real,double \
-dims=1,2,3,4
PROCESS = $$($(PSYDATA_LIB_DIR)/get_python.sh) $(PSYDATA_LIB_DIR)/process.py

default: read_only_base.o psy_data_base.o
Expand Down
45 changes: 32 additions & 13 deletions lib/read_only/read_only_base.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -284,16 +284,26 @@ contains
character(*), intent(in) :: name
{{type}}, intent(in) :: value

{{type}} :: orig_value
integer(kind=int64) :: checksum, int_64
{% if name == "Char" %}
character, allocatable :: orig_value
integer :: i
{% else %}
{{type}} :: orig_value
{% endif %}
integer(kind=int64) :: checksum, int_64

{% if bits==32 %}
integer(kind=int32) :: int_32
integer(kind=int32) :: int_32
{% endif %}

if (.not. is_enabled) return

{% if bits == 32 %}
{% if name == "Char" %}
checksum = 0
do i=1, len(value)
checksum = checksum + ichar(value(i:i))
enddo
{% elif bits == 32 %}
! `transfer` leaves undefined bits in a 64-bit value
! so assign to 32-bit, then assign to 64-bit to have all bits defined
int_32 = transfer(value, int_32)
Expand All @@ -315,20 +325,22 @@ contains
write(stderr,*) "------------- PSyData -------------------------"
write(stderr,*) "{{type}} variable ", name, " has been modified in ", &
trim(this%module_name)," : ", trim(this%region_name)
! We can recreate the original value which is stored as
! 64-bit integer as the checksum:
{% if bits == 32 %}
{% if name != "Char" %}
! We can recreate the original scalar value which is stored as
! 64-bit integer in the checksum:
{% if bits == 32 %}
int_32 = this%checksums(this%next_var_index)
orig_value = transfer(int_32, orig_value)
{% elif bits == 64 %}
{% elif bits == 64 %}
orig_value = transfer(this%checksums(this%next_var_index), orig_value)
{% elif name == "Logical" %}
{% elif name == "Logical" %}
orig_value = this%checksums(this%next_var_index) .eq. 1
{% else %}
{% else %}
ERROR - UNSUPPORTED BIT SIZE {{bits}}!
{% endif %}
{% endif %}
write(stderr,*) "Original value: ", orig_value
write(stderr,*) "New value: ", value
{% endif %}
write(stderr,*) "------------- PSyData -------------------------"
else if(this%verbosity>1) then
write(stderr,*) "PSyData: checked variable ", trim(name)
Expand Down Expand Up @@ -400,7 +412,9 @@ contains
{{type}}, dimension({{DIMENSION}}) :: field

integer :: {{vars}}
{% if bits == 32 %}
{% if name == "Char" %}
integer :: i
{% elif bits == 32 %}
integer(kind=int32) :: int_32
{% endif %}
integer(kind=int64) :: checksum, int_64
Expand All @@ -410,7 +424,12 @@ contains
{% for j in range(dim, 0, -1) %}
{{" "*3*(dim-j)}}do i{{j}}=1, size(field, {{j}})
{% endfor %}
{% if bits == 32 %}
{% if name == "Char" %}
{{indent}}int_64 = 0
{{indent}}do i=1, len(field({{vars}}))
{{indent}} int_64 = int_64 + ichar(field({{vars}})(i:i))
{{indent}}enddo
{% elif bits == 32 %}
{{indent}}! transfer leaves undefined bits in a 64-bit target
{{indent}}! so we transfer to 32-bits and then assign to 64-bit
{{indent}}int_32 = transfer(field({{vars}}), int_32)
Expand Down
4 changes: 2 additions & 2 deletions lib/value_range_check/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ PSYDATA_LIB_DIR ?= ./..

# The nan-test library is implemented for int, real and
# double scalars and 2-dimension arrays
arporter marked this conversation as resolved.
Show resolved Hide resolved
PROCESS_ARGS = -prefix=value_range_check_ -types=int,real,double \
-dims=2
PROCESS_ARGS = -prefix=value_range_check_ -types=char,int,logical,real,double \
-dims=1,2,3,4
PROCESS = $$($(PSYDATA_LIB_DIR)/get_python.sh) $(PSYDATA_LIB_DIR)/process.py


Expand Down
16 changes: 9 additions & 7 deletions lib/value_range_check/value_range_check_base.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@
when mould is larger than value.) #}

{% if ALL_TYPES is not defined %}
{% set ALL_TYPES = [ ("Double", "real(kind=real64)", 64),
("Real", "real(kind=real32)", 32),
("Int", "integer(kind=int32)", 32) ] %}
{% set ALL_TYPES = [ ("Double", "real(kind=real64)", 64),
("Real", "real(kind=real32)", 32),
("Char", "character", 8),
("Logical", "logical", 8),
arporter marked this conversation as resolved.
Show resolved Hide resolved
("Int", "integer(kind=int32)", 32) ] %}
{% endif %}

! -----------------------------------------------------------------------------
Expand Down Expand Up @@ -346,11 +348,11 @@ contains
this%value_ranges(this%next_var_index,:))
endif

{% if name !="Logical" %}
{% if name not in ["Logical", "Char"] %}

if (this%has_checks(this%next_var_index) == has_min) then
{# The spaces take care of proper indentation #}
{{indent}}if (value< this%value_ranges(this%next_var_index,1)) then
{{indent}}if (value < this%value_ranges(this%next_var_index,1)) then
{{indent}} write(stderr, '(11G0)') "PSyData: Variable '", &
{{indent}} name,"' has the value ", &
{{indent}} value, " in module '", trim(this%module_name), &
Expand Down Expand Up @@ -383,7 +385,7 @@ contains
endif
{% endif %}

{% if name not in ["Int", "Logical"] %}
{% if name not in ["Int", "Char", "Logical"] %}
if (IEEE_SUPPORT_DATATYPE(value)) then
if (.not. IEEE_IS_FINITE(value)) then
write(stderr, '(8G0)') "PSyData: Variable '", name,"' has invalid value ", &
Expand Down Expand Up @@ -431,7 +433,7 @@ contains
{{type}}, dimension({{DIMENSION}}), intent(in) :: value

{# IEEE_SUPPORT_DATATYPE does not even compile for int data types #}
arporter marked this conversation as resolved.
Show resolved Hide resolved
{% if name not in ["Int", "Logical"] %}
{% if name not in ["Int", "Char", "Logical"] %}
integer :: {{vars}}

if (.not. is_enabled) return
Expand Down
Loading