From 8debe338b7d35f09c078c23a07114db40dc3179b Mon Sep 17 00:00:00 2001 From: Joerg Henrichs Date: Tue, 7 Jan 2025 16:18:24 +1100 Subject: [PATCH] #2394 Removed the bits field from ALL_TYPES. --- lib/Makefile | 6 ++++ lib/extract/compare_variables_mod.jinja | 22 ++++++------- lib/extract/netcdf/extract_netcdf_base.jinja | 22 ++++++------- lib/extract/netcdf/read_kernel_data_mod.jinja | 22 ++++++------- .../standalone/extract_standalone_base.jinja | 22 ++++++------- .../standalone/read_kernel_data_mod.jinja | 22 ++++++------- lib/process.py | 12 +++---- lib/psy_data_base.jinja | 16 ++++------ lib/read_only/Makefile | 4 +-- lib/read_only/read_only_base.jinja | 32 ++++++++++++------- lib/value_range_check/Makefile | 4 +-- .../value_range_check_base.jinja | 20 +++++------- 12 files changed, 96 insertions(+), 108 deletions(-) diff --git a/lib/Makefile b/lib/Makefile index 95496615bb..593828bb00 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -61,6 +61,12 @@ all: $(MAKE) -C read_only all $(MAKE) -C value_range_check all +allclean: + $(MAKE) -C extract clean + $(MAKE) -C profiling clean + $(MAKE) -C read_only clean + $(MAKE) -C value_range_check clean + %.f90: %.jinja process.py $$($(PSYDATA_LIB_DIR)/get_python.sh) $(PSYDATA_LIB_DIR)/process.py $< > $*.f90 diff --git a/lib/extract/compare_variables_mod.jinja b/lib/extract/compare_variables_mod.jinja index d3d6865f37..bd2f416c3a 100644 --- a/lib/extract/compare_variables_mod.jinja +++ b/lib/extract/compare_variables_mod.jinja @@ -23,18 +23,14 @@ {# The types that are supported. The first entry of each tuple is the name used when naming subroutines and in user messages. - The second entry is the Fortran declaration. The third entry - is the number of bits. There is slightly different code - required for 32 and 64 bit values (due to the fact that the - Fortran transfer(value, mould) function leaves undefined bits - when mould is larger than value.) #} + The second entry is the Fortran declaration. #} {% if ALL_TYPES is not defined -%} - {% set ALL_TYPES = [ ("Double", "real(kind=real64)", 64), - ("Real", "real(kind=real32)", 32), - ("Character", "character(*)", 8), - ("Long", "real(kind=int64)", 64), - ("Int", "integer(kind=int32)", 32) ] %} + {% set ALL_TYPES = [ ("Double", "real(kind=real64)" ), + ("Real", "real(kind=real32)" ), + ("Character", "character(*)" ), + ("Long", "real(kind=int64)" ), + ("Int", "integer(kind=int32)") ] %} {% endif -%} @@ -99,7 +95,7 @@ module compare_variables_mod {# ------------------------------------------------------------------------- #} interface compare {% set all_compares=[] -%} - {% for name, type, bits in ALL_TYPES %} + {% for name, type in ALL_TYPES %} module procedure compare_scalar_{{name}} {% for dim in ALL_DIMS %} module procedure compare_array_{{dim}}d{{name}} @@ -158,7 +154,7 @@ contains end subroutine compare_summary ! ------------------------------------------------------------------------- -{% for name, type, bits in ALL_TYPES %} +{% for name, type in ALL_TYPES %} {# Logical needs EQV for its tests #} {% if name == "Logical" %} {% set EQUAL = ".EQV." -%} @@ -311,6 +307,6 @@ contains end subroutine Compare_array_{{dim}}d{{name}} {% endfor -%} {# for dim in ALL_DIMS #} -{%- endfor -%} {# for name, type, bits in ALL_TYPES #} +{%- endfor -%} {# for name, type in ALL_TYPES #} end module compare_variables_mod diff --git a/lib/extract/netcdf/extract_netcdf_base.jinja b/lib/extract/netcdf/extract_netcdf_base.jinja index ffff5830c5..e39d1747e4 100644 --- a/lib/extract/netcdf/extract_netcdf_base.jinja +++ b/lib/extract/netcdf/extract_netcdf_base.jinja @@ -26,18 +26,14 @@ {# The types that are supported. The first entry of each tuple is the name used when naming subroutines and in user messages. - The second entry is the Fortran declaration. The third entry - is the number of bits. There is slightly different code - required for 32 and 64 bit values (due to the fact that the - Fortran transfer(value, mould) function leaves undefined bits - when mould is larger than value.) #} + The second entry is the Fortran declaration. #} {% if ALL_TYPES is not defined -%} - {% set ALL_TYPES = [ ("Double", "real(kind=real64)", 64), - ("Real", "real(kind=real32)", 32), - ("Character", "character(*)", 32), - ("Long", "real(kind=int64)", 64), - ("Int", "integer(kind=int32)", 32) ] %} + {% set ALL_TYPES = [ ("Double", "real(kind=real64)" ), + ("Real", "real(kind=real32)" ), + ("Character", "character(*)" ), + ("Long", "real(kind=int64)" ), + ("Int", "integer(kind=int32)") ] %} {% endif -%} @@ -119,7 +115,7 @@ module extract_netcdf_base_mod {# ------------------------------------------------------------------------- -#} {% set all_declares=[] -%} {% set all_provides=[] -%} - {% for name, type, bits in ALL_TYPES %} + {% for name, type in ALL_TYPES %} procedure :: DeclareScalar{{name}} procedure :: WriteScalar{{name}} {{- all_declares.append("DeclareScalar"~name) or "" -}} @@ -318,7 +314,7 @@ contains "Int": "NF90_INT"} -%} {% set indent=" " %} -{% for name, type, bits in ALL_TYPES %} +{% for name, type in ALL_TYPES %} {% set NETCDF_TYPE = NCDF_TYPE_MAPPING[name] %} ! ------------------------------------------------------------------------- !> @brief This subroutine declares a scalar {{type}} value. @@ -506,6 +502,6 @@ contains {% endfor -%} {# for dim in ALL_DIMS #} -{%- endfor -%} {# for name, type, bits in ALL_TYPES #} +{%- endfor -%} {# for name, type in ALL_TYPES #} end module extract_netcdf_base_mod diff --git a/lib/extract/netcdf/read_kernel_data_mod.jinja b/lib/extract/netcdf/read_kernel_data_mod.jinja index 315906304e..f799b0c9a2 100644 --- a/lib/extract/netcdf/read_kernel_data_mod.jinja +++ b/lib/extract/netcdf/read_kernel_data_mod.jinja @@ -19,18 +19,14 @@ {# The types that are supported. The first entry of each tuple is the name used when naming subroutines and in user messages. - The second entry is the Fortran declaration. The third entry - is the number of bits. There is slightly different code - required for 32 and 64 bit values (due to the fact that the - Fortran transfer(value, mould) function leaves undefined bits - when mould is larger than value.) #} + The second entry is the Fortran declaration. #} {% if ALL_TYPES is not defined -%} - {% set ALL_TYPES = [ ("Double", "real(kind=real64)", 64), - ("Real", "real(kind=real32)", 32), - ("Char", "character(*)", 8), - ("Logical","integer(kind=real32)",32), - ("Int", "integer(kind=int32)", 32) ] %} + {% set ALL_TYPES = [ ("Double", "real(kind=real64)" ), + ("Real", "real(kind=real32)" ), + ("Char", "character(*)" ), + ("Logical","integer(kind=real32)"), + ("Int", "integer(kind=int32)" ) ] %} {% endif -%} @@ -99,7 +95,7 @@ module read_kernel_data_mod {# Collect and declare the various procedures for the same generic interface -#} {# ------------------------------------------------------------------------- -#} {% set all_reads=[] -%} - {% for name, type, bits in ALL_TYPES %} + {% for name, type in ALL_TYPES %} procedure :: ReadScalar{{name}} {{- all_reads.append("ReadScalar"~name) or "" }} {% for dim in ALL_DIMS %} @@ -197,7 +193,7 @@ contains "Logical":"NF90_INT", "Int": "NF90_INT"} -%} -{% for name, type, bits in ALL_TYPES %} +{% for name, type in ALL_TYPES %} {% set NETCDF_TYPE = NCDF_TYPE_MAPPING[name] %} ! ------------------------------------------------------------------------- @@ -329,6 +325,6 @@ contains {% endfor -%} {# for dim in ALL_DIMS #} -{%- endfor -%} {# for name, type, bits in ALL_TYPES #} +{%- endfor -%} {# for name, type in ALL_TYPES #} end module read_kernel_data_mod diff --git a/lib/extract/standalone/extract_standalone_base.jinja b/lib/extract/standalone/extract_standalone_base.jinja index da6c2d95de..0f15059cea 100644 --- a/lib/extract/standalone/extract_standalone_base.jinja +++ b/lib/extract/standalone/extract_standalone_base.jinja @@ -26,18 +26,14 @@ {# The types that are supported. The first entry of each tuple is the name used when naming subroutines and in user messages. - The second entry is the Fortran declaration. The third entry - is the number of bits. There is slightly different code - required for 32 and 64 bit values (due to the fact that the - Fortran transfer(value, mould) function leaves undefined bits - when mould is larger than value.) #} + The second entry is the Fortran declaration. #} {% if ALL_TYPES is not defined -%} - {% set ALL_TYPES = [ ("Double", "real(kind=real64)", 64), - ("Real", "real(kind=real32)", 32), - ("Character", "character(*)", 8), - ("Long", "real(kind=int64)", 64), - ("Int", "integer(kind=int32)", 32) ] %} + {% set ALL_TYPES = [ ("Double", "real(kind=real64)" ), + ("Real", "real(kind=real32)" ), + ("Character", "character(*)" ), + ("Long", "real(kind=int64)" ), + ("Int", "integer(kind=int32)") ] %} {% endif -%} @@ -112,7 +108,7 @@ module extract_standalone_base_mod {# ------------------------------------------------------------------------- -#} {% set all_declares=[] -%} {% set all_provides=[] -%} - {% for name, type, bits in ALL_TYPES %} + {% for name, type in ALL_TYPES %} procedure :: WriteScalar{{name}} {{- all_provides.append("WriteScalar"~name) or "" }} {% for dim in ALL_DIMS %} @@ -215,7 +211,7 @@ contains end subroutine PostEnd -{% for name, type, bits in ALL_TYPES %} +{% for name, type in ALL_TYPES %} ! ------------------------------------------------------------------------- !> @brief This subroutine writes the value of a scalar {{type}} !! variable to the file. It takes the variable id from the @@ -275,6 +271,6 @@ contains {% endfor -%} {# for dim in ALL_DIMS #} -{%- endfor -%} {# for name, type, bits in ALL_TYPES #} +{%- endfor -%} {# for name, type in ALL_TYPES #} end module extract_standalone_base_mod diff --git a/lib/extract/standalone/read_kernel_data_mod.jinja b/lib/extract/standalone/read_kernel_data_mod.jinja index 29584c8473..00210a7114 100644 --- a/lib/extract/standalone/read_kernel_data_mod.jinja +++ b/lib/extract/standalone/read_kernel_data_mod.jinja @@ -19,18 +19,14 @@ {# The types that are supported. The first entry of each tuple is the name used when naming subroutines and in user messages. - The second entry is the Fortran declaration. The third entry - is the number of bits. There is slightly different code - required for 32 and 64 bit values (due to the fact that the - Fortran transfer(value, mould) function leaves undefined bits - when mould is larger than value.) #} + The second entry is the Fortran declaration. #} {% if ALL_TYPES is not defined -%} - {% set ALL_TYPES = [ ("Double", "real(kind=real64)", 64), - ("Real", "real(kind=real32)", 32), - ("Char", "character(*)", 8), - ("Logical","integer(kind=real32)",32), - ("Int", "integer(kind=int32)", 32) ] %} + {% set ALL_TYPES = [ ("Double", "real(kind=real64)" ), + ("Real", "real(kind=real32)" ), + ("Char", "character(*)" ), + ("Logical","integer(kind=real32)"), + ("Int", "integer(kind=int32)" ) ] %} {% endif -%} @@ -102,7 +98,7 @@ module read_kernel_data_mod {# Collect and declare the various procedures for the same generic interface -#} {# ------------------------------------------------------------------------- -#} {% set all_reads=[] -%} - {% for name, type, bits in ALL_TYPES %} + {% for name, type in ALL_TYPES %} procedure :: ReadScalar{{name}} {{- all_reads.append("ReadScalar"~name) or "" }} {% for dim in ALL_DIMS %} @@ -168,7 +164,7 @@ contains end subroutine OpenReadFileName -{% for name, type, bits in ALL_TYPES %} +{% for name, type in ALL_TYPES %} ! ------------------------------------------------------------------------- !> @brief This subroutine reads the value of a scalar {{type}} @@ -264,6 +260,6 @@ contains {% endfor -%} {# for dim in ALL_DIMS #} -{%- endfor -%} {# for name, type, bits in ALL_TYPES #} +{%- endfor -%} {# for name, type in ALL_TYPES #} end module read_kernel_data_mod diff --git a/lib/process.py b/lib/process.py index d7d094fdfb..b568ce011e 100755 --- a/lib/process.py +++ b/lib/process.py @@ -102,12 +102,12 @@ # --------------------------------------------------------- # This is a mapping from the command line option name # to the tuple that is required for the jinja templates: -TYPE_DATA = {"real": ("Real", "real(kind=real32)", 32), - "double": ("Double", "real(kind=real64)", 64), - "int": ("Int", "integer(kind=int32)", 32), - "char": ("Char", "character(*)", 8), - "logical": ("Logical", "Logical(kind=4)", 4), - "long": ("Long", "integer(kind=int64)", 64)} +TYPE_DATA = {"real": ("Real", "real(kind=real32)"), + "double": ("Double", "real(kind=real64)"), + "int": ("Int", "integer(kind=int32)"), + "char": ("Char", "character(*)"), + "logical": ("Logical", "Logical(kind=4)"), + "long": ("Long", "integer(kind=int64)")} # --------------------------------------------------------- # Check type information: diff --git a/lib/psy_data_base.jinja b/lib/psy_data_base.jinja index d154a2c2b3..61148aafb1 100644 --- a/lib/psy_data_base.jinja +++ b/lib/psy_data_base.jinja @@ -12,16 +12,12 @@ {# The types that are supported. The first entry of each tuple is the name used when naming subroutines and in user messages. - The second entry is the Fortran declaration. The third entry - is the number of bits. There is slightly different code - required for 32 and 64 bit values (due to the fact that the - Fortran transfer(value, mould) function leaves undefined bits - when mould is larger than value.) #} + The second entry is the Fortran declaration. #} {% 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)" ), + ("Real", "real(kind=real32)" ), + ("Int", "integer(kind=int32)") ] %} {% endif %} ! ----------------------------------------------------------------------------- @@ -110,7 +106,7 @@ module psy_data_base_mod {# ------------------------------------------------------------- -#} {% set all_declares=[] -%} {% set all_provides=[] -%} - {% for name, type, bits in ALL_TYPES %} + {% for name, type in ALL_TYPES %} procedure :: DeclareScalar{{name}} procedure :: ProvideScalar{{name}} {{- all_declares.append("DeclareScalar"~name) or "" -}} @@ -316,7 +312,7 @@ contains ! ========================================================================= ! Jinja created code: ! ========================================================================= - {% for name, type, bits in ALL_TYPES %} + {% for name, type in ALL_TYPES %} ! ------------------------------------------------------------------------- !> @brief This subroutine declares a scalar {{type}} value. This !! implementation only increases the next index, and prints diff --git a/lib/read_only/Makefile b/lib/read_only/Makefile index cded52cc2e..5d17c88808 100644 --- a/lib/read_only/Makefile +++ b/lib/read_only/Makefile @@ -48,8 +48,8 @@ F90FLAGS ?= PSYDATA_LIB_DIR ?= ./.. # ----------------------------------------------------------------------------- -# The read-only verification library is implemented for int, real and -# double scalars and 2-dimension arrays +# The read-only verification library is implemented for int, logical, +# characters, real, and double precision scalars and 1 to 4 dimensional arrays 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 diff --git a/lib/read_only/read_only_base.jinja b/lib/read_only/read_only_base.jinja index f81399c232..b9e5ee5568 100644 --- a/lib/read_only/read_only_base.jinja +++ b/lib/read_only/read_only_base.jinja @@ -29,16 +29,12 @@ {# The types that are supported. The first entry of each tuple is the name used when naming subroutines and in user messages. - The second entry is the Fortran declaration. The third entry - is the number of bits. There is slightly different code - required for 32 and 64 bit values (due to the fact that the - Fortran transfer(value, mould) function leaves undefined bits - when mould is larger than value.) #} + The second entry is the Fortran declaration. #} {% 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)" ), + ("Real", "real(kind=real32)" ), + ("Int", "integer(kind=int32)") ] %} {% endif %} ! ----------------------------------------------------------------------------- @@ -117,7 +113,7 @@ module read_only_base_mod {# Collect the various procedures for the same generic interface -#} {# ------------------------------------------------------------- -#} {% set all_provides=[] -%} - {%- for name, type, bits in ALL_TYPES %} + {%- for name, type in ALL_TYPES %} procedure :: ProvideScalar{{name}} {{- all_provides.append("ProvideScalar"~name) or "" }} {% for dim in ALL_DIMS %} @@ -145,7 +141,7 @@ module read_only_base_mod {# Create a generic interface for all ComputeChecksum functions #} {# ------------------------------------------------------------ #} {% set all_compute = [] -%} - {% for name, type, bits in ALL_TYPES %} + {% for name, type in ALL_TYPES %} {% for dim in ALL_DIMS %} {{- all_compute.append("ComputeChecksum"~dim~"d"~name) or "" -}} {% endfor %} @@ -265,7 +261,21 @@ contains LFRic which uses ComputeChecksum1dDouble) #} -{% for name, type, bits in ALL_TYPES %} +{% for name, type in ALL_TYPES %} + {# We need the number of bits since there is slightly different code + required for 32 and 64 bit values (due to the fact that the + Fortran transfer(value, mold) function leaves undefined bits + when mold is larger than value. #} + {% if name in ["Real", "Int", "Logical"] %} + {% set bits = 32 %} + {% elif name in ["Double", "Long"] %} + {% set bits = 64 %} + {% elif name in ["Char"] %} + {% set bits = 8 %} + {% else %} + ERROR - UNSUPPORTED BIT SIZE for {{name}}! + {% endif %} + ! ========================================================================= ! Implementation for all {{type}} types diff --git a/lib/value_range_check/Makefile b/lib/value_range_check/Makefile index c2e61854e2..10d4dbf94d 100644 --- a/lib/value_range_check/Makefile +++ b/lib/value_range_check/Makefile @@ -48,8 +48,8 @@ F90FLAGS ?= PSYDATA_LIB_DIR ?= ./.. # ----------------------------------------------------------------------------- -# The nan-test library is implemented for int, real and -# double scalars and 2-dimension arrays +# The value-range check library is implemented for int, logical, characters, +# real, and double precision scalars and 1 to 4 dimensional arrays 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 diff --git a/lib/value_range_check/value_range_check_base.jinja b/lib/value_range_check/value_range_check_base.jinja index 35a5daa843..7485fb50e2 100644 --- a/lib/value_range_check/value_range_check_base.jinja +++ b/lib/value_range_check/value_range_check_base.jinja @@ -26,18 +26,14 @@ {# The types that are supported. The first entry of each tuple is the name used when naming subroutines and in user messages. - The second entry is the Fortran declaration. The third entry - is the number of bits. There is slightly different code - required for 32 and 64 bit values (due to the fact that the - Fortran transfer(value, mould) function leaves undefined bits - when mould is larger than value.) #} + The second entry is the Fortran declaration. #} {% if ALL_TYPES is not defined %} - {% set ALL_TYPES = [ ("Double", "real(kind=real64)", 64), - ("Real", "real(kind=real32)", 32), - ("Char", "character", 8), - ("Logical", "logical", 8), - ("Int", "integer(kind=int32)", 32) ] %} + {% set ALL_TYPES = [ ("Double", "real(kind=real64)" ), + ("Real", "real(kind=real32)" ), + ("Char", "character", ), + ("Logical", "logical", ), + ("Int", "integer(kind=int32)") ] %} {% endif %} ! ----------------------------------------------------------------------------- @@ -128,7 +124,7 @@ module value_range_check_base_mod {# ------------------------------------------------------------------------- -#} {% set all_declares=[] -%} {% set all_provides=[] -%} - {% for name, type, bits in ALL_TYPES %} + {% for name, type in ALL_TYPES %} procedure :: ProvideScalar{{name}} {{- all_provides.append("ProvideScalar"~name) or "" }} {% for dim in ALL_DIMS %} @@ -317,7 +313,7 @@ contains ! Jinja created code. ! ========================================================================= -{% for name, type, bits in ALL_TYPES %} +{% for name, type in ALL_TYPES %} ! ========================================================================= ! Implementation for all {{type}} types