diff --git a/src/serialbox-fortran/m_ser_ftg.f90 b/src/serialbox-fortran/m_ser_ftg.f90 index 1b410072..ab2e2a24 100644 --- a/src/serialbox-fortran/m_ser_ftg.f90 +++ b/src/serialbox-fortran/m_ser_ftg.f90 @@ -40,162 +40,287 @@ MODULE m_ser_ftg PUBLIC :: ignore_bullshit, ignore_bullshit_max_dim_size, ignore_bullshit_allow_negative_indices, ignore_not_existing, & ftg_set_serializer, ftg_get_serializer, ftg_destroy_serializer, ftg_print_serializer_debuginfo, & ftg_set_savepoint, ftg_get_savepoint, ftg_destroy_savepoint, & - ftg_add_serializer_metainfo, ftg_add_savepoint_metainfo, & - ftg_field_exists, ftg_get_bounds, ftg_register_only, ftg_write, ftg_read, ftg_allocate + ftg_add_serializer_metainfo, ftg_get_serializer_metainfo, ftg_add_field_metainfo, ftg_get_field_metainfo, & + ftg_add_savepoint_metainfo, ftg_get_savepoint_metainfo, & + ftg_field_exists, ftg_get_bounds, ftg_register_only, ftg_write, ftg_read, & + ftg_allocate_pointer, ftg_allocate_allocatable, ftg_allocate_and_read_pointer, ftg_allocate_and_read_allocatable PRIVATE CHARACTER(LEN=*), PARAMETER :: module_name = 'm_ser_ftg' INTERFACE ftg_set_serializer - MODULE PROCEDURE & - ftg_set_serializer_create, & - ftg_set_serializer_existing + MODULE PROCEDURE & + ftg_set_serializer_create, & + ftg_set_serializer_existing END INTERFACE INTERFACE ftg_set_savepoint - MODULE PROCEDURE & - ftg_set_savepoint_create, & - ftg_set_savepoint_existing + MODULE PROCEDURE & + ftg_set_savepoint_create, & + ftg_set_savepoint_existing END INTERFACE INTERFACE ftg_add_serializer_metainfo - MODULE PROCEDURE & - ftg_add_serializer_metainfo_b, & - ftg_add_serializer_metainfo_i, & - ftg_add_serializer_metainfo_f, & - ftg_add_serializer_metainfo_d, & - ftg_add_serializer_metainfo_s + MODULE PROCEDURE & + ftg_add_serializer_metainfo_b, & + ftg_add_serializer_metainfo_i, & + ftg_add_serializer_metainfo_l, & + ftg_add_serializer_metainfo_f, & + ftg_add_serializer_metainfo_d, & + ftg_add_serializer_metainfo_s +END INTERFACE + +INTERFACE ftg_get_serializer_metainfo + MODULE PROCEDURE & + ftg_get_serializer_metainfo_b, & + ftg_get_serializer_metainfo_i, & + ftg_get_serializer_metainfo_l, & + ftg_get_serializer_metainfo_f, & + ftg_get_serializer_metainfo_d +END INTERFACE + +INTERFACE ftg_add_field_metainfo + MODULE PROCEDURE & + ftg_add_field_metainfo_b, & + ftg_add_field_metainfo_i, & + ftg_add_field_metainfo_l, & + ftg_add_field_metainfo_f, & + ftg_add_field_metainfo_d, & + ftg_add_field_metainfo_s +END INTERFACE + +INTERFACE ftg_get_field_metainfo + MODULE PROCEDURE & + ftg_get_field_metainfo_b, & + ftg_get_field_metainfo_i, & + ftg_get_field_metainfo_l, & + ftg_get_field_metainfo_f, & + ftg_get_field_metainfo_d END INTERFACE INTERFACE ftg_add_savepoint_metainfo - MODULE PROCEDURE & - ftg_add_savepoint_metainfo_b, & - ftg_add_savepoint_metainfo_i, & - ftg_add_savepoint_metainfo_f, & - ftg_add_savepoint_metainfo_d, & - ftg_add_savepoint_metainfo_s + MODULE PROCEDURE & + ftg_add_savepoint_metainfo_b, & + ftg_add_savepoint_metainfo_i, & + ftg_add_savepoint_metainfo_l, & + ftg_add_savepoint_metainfo_f, & + ftg_add_savepoint_metainfo_d, & + ftg_add_savepoint_metainfo_s +END INTERFACE + +INTERFACE ftg_get_savepoint_metainfo + MODULE PROCEDURE & + ftg_get_savepoint_metainfo_b, & + ftg_get_savepoint_metainfo_i, & + ftg_get_savepoint_metainfo_l, & + ftg_get_savepoint_metainfo_f, & + ftg_get_savepoint_metainfo_d END INTERFACE INTERFACE ftg_write - MODULE PROCEDURE & - ftg_write_logical_0d, & - ftg_write_logical_1d, & - ftg_write_logical_2d, & - ftg_write_logical_3d, & - ftg_write_logical_4d, & - ftg_write_bool_0d, & - ftg_write_bool_1d, & - ftg_write_bool_2d, & - ftg_write_bool_3d, & - ftg_write_bool_4d, & - ftg_write_int_0d, & - ftg_write_int_1d, & - ftg_write_int_2d, & - ftg_write_int_3d, & - ftg_write_int_4d, & - ftg_write_long_0d, & - ftg_write_long_1d, & - ftg_write_long_2d, & - ftg_write_long_3d, & - ftg_write_long_4d, & - ftg_write_float_0d, & - ftg_write_float_1d, & - ftg_write_float_2d, & - ftg_write_float_3d, & - ftg_write_float_4d, & - ftg_write_double_0d, & - ftg_write_double_1d, & - ftg_write_double_2d, & - ftg_write_double_3d, & - ftg_write_double_4d + MODULE PROCEDURE & + ftg_write_logical_0d, & + ftg_write_logical_1d, & + ftg_write_logical_2d, & + ftg_write_logical_3d, & + ftg_write_logical_4d, & + ftg_write_bool_0d, & + ftg_write_bool_1d, & + ftg_write_bool_2d, & + ftg_write_bool_3d, & + ftg_write_bool_4d, & + ftg_write_int_0d, & + ftg_write_int_1d, & + ftg_write_int_2d, & + ftg_write_int_3d, & + ftg_write_int_4d, & + ftg_write_long_0d, & + ftg_write_long_1d, & + ftg_write_long_2d, & + ftg_write_long_3d, & + ftg_write_long_4d, & + ftg_write_float_0d, & + ftg_write_float_1d, & + ftg_write_float_2d, & + ftg_write_float_3d, & + ftg_write_float_4d, & + ftg_write_double_0d, & + ftg_write_double_1d, & + ftg_write_double_2d, & + ftg_write_double_3d, & + ftg_write_double_4d END INTERFACE INTERFACE ftg_read - MODULE PROCEDURE & - ftg_read_logical_0d, & - ftg_read_logical_1d, & - ftg_read_logical_2d, & - ftg_read_logical_3d, & - ftg_read_logical_4d, & - ftg_read_bool_0d, & - ftg_read_bool_1d, & - ftg_read_bool_2d, & - ftg_read_bool_3d, & - ftg_read_bool_4d, & - ftg_read_int_0d, & - ftg_read_int_1d, & - ftg_read_int_2d, & - ftg_read_int_3d, & - ftg_read_int_4d, & - ftg_read_long_0d, & - ftg_read_long_1d, & - ftg_read_long_2d, & - ftg_read_long_3d, & - ftg_read_long_4d, & - ftg_read_float_0d, & - ftg_read_float_1d, & - ftg_read_float_2d, & - ftg_read_float_3d, & - ftg_read_float_4d, & - ftg_read_double_0d, & - ftg_read_double_1d, & - ftg_read_double_2d, & - ftg_read_double_3d, & - ftg_read_double_4d + MODULE PROCEDURE & + ftg_read_logical_0d, & + ftg_read_logical_1d, & + ftg_read_logical_2d, & + ftg_read_logical_3d, & + ftg_read_logical_4d, & + ftg_read_bool_0d, & + ftg_read_bool_1d, & + ftg_read_bool_2d, & + ftg_read_bool_3d, & + ftg_read_bool_4d, & + ftg_read_int_0d, & + ftg_read_int_1d, & + ftg_read_int_2d, & + ftg_read_int_3d, & + ftg_read_int_4d, & + ftg_read_long_0d, & + ftg_read_long_1d, & + ftg_read_long_2d, & + ftg_read_long_3d, & + ftg_read_long_4d, & + ftg_read_float_0d, & + ftg_read_float_1d, & + ftg_read_float_2d, & + ftg_read_float_3d, & + ftg_read_float_4d, & + ftg_read_double_0d, & + ftg_read_double_1d, & + ftg_read_double_2d, & + ftg_read_double_3d, & + ftg_read_double_4d END INTERFACE -INTERFACE ftg_allocate - MODULE PROCEDURE & - ftg_allocate_pointer_logical_1d, & - ftg_allocate_pointer_logical_2d, & - ftg_allocate_pointer_logical_3d, & - ftg_allocate_pointer_logical_4d, & - ftg_allocate_pointer_bool_1d, & - ftg_allocate_pointer_bool_2d, & - ftg_allocate_pointer_bool_3d, & - ftg_allocate_pointer_bool_4d, & - ftg_allocate_pointer_int_1d, & - ftg_allocate_pointer_int_2d, & - ftg_allocate_pointer_int_3d, & - ftg_allocate_pointer_int_4d, & - ftg_allocate_pointer_long_1d, & - ftg_allocate_pointer_long_2d, & - ftg_allocate_pointer_long_3d, & - ftg_allocate_pointer_long_4d, & - ftg_allocate_pointer_float_1d, & - ftg_allocate_pointer_float_2d, & - ftg_allocate_pointer_float_3d, & - ftg_allocate_pointer_float_4d, & - ftg_allocate_pointer_double_1d, & - ftg_allocate_pointer_double_2d, & - ftg_allocate_pointer_double_3d, & - ftg_allocate_pointer_double_4d, & - ftg_allocate_allocatable_logical_1d, & - ftg_allocate_allocatable_logical_2d, & - ftg_allocate_allocatable_logical_3d, & - ftg_allocate_allocatable_logical_4d, & - ftg_allocate_allocatable_bool_1d, & - ftg_allocate_allocatable_bool_2d, & - ftg_allocate_allocatable_bool_3d, & - ftg_allocate_allocatable_bool_4d, & - ftg_allocate_allocatable_int_1d, & - ftg_allocate_allocatable_int_2d, & - ftg_allocate_allocatable_int_3d, & - ftg_allocate_allocatable_int_4d, & - ftg_allocate_allocatable_long_1d, & - ftg_allocate_allocatable_long_2d, & - ftg_allocate_allocatable_long_3d, & - ftg_allocate_allocatable_long_4d, & - ftg_allocate_allocatable_float_1d, & - ftg_allocate_allocatable_float_2d, & - ftg_allocate_allocatable_float_3d, & - ftg_allocate_allocatable_float_4d, & - ftg_allocate_allocatable_double_1d, & - ftg_allocate_allocatable_double_2d, & - ftg_allocate_allocatable_double_3d, & - ftg_allocate_allocatable_double_4d -END INTERFACE ftg_allocate +INTERFACE ftg_allocate_pointer + MODULE PROCEDURE & + ftg_allocate_pointer_logical_0d, & + ftg_allocate_pointer_logical_1d, & + ftg_allocate_pointer_logical_2d, & + ftg_allocate_pointer_logical_3d, & + ftg_allocate_pointer_logical_4d, & + ftg_allocate_pointer_bool_0d, & + ftg_allocate_pointer_bool_1d, & + ftg_allocate_pointer_bool_2d, & + ftg_allocate_pointer_bool_3d, & + ftg_allocate_pointer_bool_4d, & + ftg_allocate_pointer_int_0d, & + ftg_allocate_pointer_int_1d, & + ftg_allocate_pointer_int_2d, & + ftg_allocate_pointer_int_3d, & + ftg_allocate_pointer_int_4d, & + ftg_allocate_pointer_long_0d, & + ftg_allocate_pointer_long_1d, & + ftg_allocate_pointer_long_2d, & + ftg_allocate_pointer_long_3d, & + ftg_allocate_pointer_long_4d, & + ftg_allocate_pointer_float_0d, & + ftg_allocate_pointer_float_1d, & + ftg_allocate_pointer_float_2d, & + ftg_allocate_pointer_float_3d, & + ftg_allocate_pointer_float_4d, & + ftg_allocate_pointer_double_0d, & + ftg_allocate_pointer_double_1d, & + ftg_allocate_pointer_double_2d, & + ftg_allocate_pointer_double_3d, & + ftg_allocate_pointer_double_4d +END INTERFACE ftg_allocate_pointer + +INTERFACE ftg_allocate_allocatable + MODULE PROCEDURE & + ftg_allocate_allocatable_logical_0d, & + ftg_allocate_allocatable_logical_1d, & + ftg_allocate_allocatable_logical_2d, & + ftg_allocate_allocatable_logical_3d, & + ftg_allocate_allocatable_logical_4d, & + ftg_allocate_allocatable_bool_0d, & + ftg_allocate_allocatable_bool_1d, & + ftg_allocate_allocatable_bool_2d, & + ftg_allocate_allocatable_bool_3d, & + ftg_allocate_allocatable_bool_4d, & + ftg_allocate_allocatable_int_0d, & + ftg_allocate_allocatable_int_1d, & + ftg_allocate_allocatable_int_2d, & + ftg_allocate_allocatable_int_3d, & + ftg_allocate_allocatable_int_4d, & + ftg_allocate_allocatable_long_0d, & + ftg_allocate_allocatable_long_1d, & + ftg_allocate_allocatable_long_2d, & + ftg_allocate_allocatable_long_3d, & + ftg_allocate_allocatable_long_4d, & + ftg_allocate_allocatable_float_0d, & + ftg_allocate_allocatable_float_1d, & + ftg_allocate_allocatable_float_2d, & + ftg_allocate_allocatable_float_3d, & + ftg_allocate_allocatable_float_4d, & + ftg_allocate_allocatable_double_0d, & + ftg_allocate_allocatable_double_1d, & + ftg_allocate_allocatable_double_2d, & + ftg_allocate_allocatable_double_3d, & + ftg_allocate_allocatable_double_4d +END INTERFACE ftg_allocate_allocatable + +INTERFACE ftg_allocate_and_read_pointer + MODULE PROCEDURE & + ftg_allocate_and_read_pointer_logical_0d, & + ftg_allocate_and_read_pointer_logical_1d, & + ftg_allocate_and_read_pointer_logical_2d, & + ftg_allocate_and_read_pointer_logical_3d, & + ftg_allocate_and_read_pointer_logical_4d, & + ftg_allocate_and_read_pointer_bool_0d, & + ftg_allocate_and_read_pointer_bool_1d, & + ftg_allocate_and_read_pointer_bool_2d, & + ftg_allocate_and_read_pointer_bool_3d, & + ftg_allocate_and_read_pointer_bool_4d, & + ftg_allocate_and_read_pointer_int_0d, & + ftg_allocate_and_read_pointer_int_1d, & + ftg_allocate_and_read_pointer_int_2d, & + ftg_allocate_and_read_pointer_int_3d, & + ftg_allocate_and_read_pointer_int_4d, & + ftg_allocate_and_read_pointer_long_0d, & + ftg_allocate_and_read_pointer_long_1d, & + ftg_allocate_and_read_pointer_long_2d, & + ftg_allocate_and_read_pointer_long_3d, & + ftg_allocate_and_read_pointer_long_4d, & + ftg_allocate_and_read_pointer_float_0d, & + ftg_allocate_and_read_pointer_float_1d, & + ftg_allocate_and_read_pointer_float_2d, & + ftg_allocate_and_read_pointer_float_3d, & + ftg_allocate_and_read_pointer_float_4d, & + ftg_allocate_and_read_pointer_double_0d, & + ftg_allocate_and_read_pointer_double_1d, & + ftg_allocate_and_read_pointer_double_2d, & + ftg_allocate_and_read_pointer_double_3d, & + ftg_allocate_and_read_pointer_double_4d +END INTERFACE ftg_allocate_and_read_pointer + +INTERFACE ftg_allocate_and_read_allocatable + MODULE PROCEDURE & + ftg_allocate_and_read_allocatable_logical_0d, & + ftg_allocate_and_read_allocatable_logical_1d, & + ftg_allocate_and_read_allocatable_logical_2d, & + ftg_allocate_and_read_allocatable_logical_3d, & + ftg_allocate_and_read_allocatable_logical_4d, & + ftg_allocate_and_read_allocatable_bool_0d, & + ftg_allocate_and_read_allocatable_bool_1d, & + ftg_allocate_and_read_allocatable_bool_2d, & + ftg_allocate_and_read_allocatable_bool_3d, & + ftg_allocate_and_read_allocatable_bool_4d, & + ftg_allocate_and_read_allocatable_int_0d, & + ftg_allocate_and_read_allocatable_int_1d, & + ftg_allocate_and_read_allocatable_int_2d, & + ftg_allocate_and_read_allocatable_int_3d, & + ftg_allocate_and_read_allocatable_int_4d, & + ftg_allocate_and_read_allocatable_long_0d, & + ftg_allocate_and_read_allocatable_long_1d, & + ftg_allocate_and_read_allocatable_long_2d, & + ftg_allocate_and_read_allocatable_long_3d, & + ftg_allocate_and_read_allocatable_long_4d, & + ftg_allocate_and_read_allocatable_float_0d, & + ftg_allocate_and_read_allocatable_float_1d, & + ftg_allocate_and_read_allocatable_float_2d, & + ftg_allocate_and_read_allocatable_float_3d, & + ftg_allocate_and_read_allocatable_float_4d, & + ftg_allocate_and_read_allocatable_double_0d, & + ftg_allocate_and_read_allocatable_double_1d, & + ftg_allocate_and_read_allocatable_double_2d, & + ftg_allocate_and_read_allocatable_double_3d, & + ftg_allocate_and_read_allocatable_double_4d +END INTERFACE ftg_allocate_and_read_allocatable LOGICAL :: ignore_bullshit = .TRUE. INTEGER :: ignore_bullshit_max_dim_size = 999999999 @@ -205,8 +330,6 @@ MODULE m_ser_ftg TYPE(t_serializer), POINTER :: serializer => NULL() TYPE(t_savepoint), POINTER :: savepoint => NULL() -LOGICAL :: serializer_has_written = .FALSE., serializer_has_registered = .FALSE. - CONTAINS !============================================================================= @@ -214,8 +337,8 @@ MODULE m_ser_ftg SUBROUTINE ftg_set_serializer_create(directory, prefix, mode, opt_archive) - CHARACTER(LEN=*), INTENT(IN) :: directory, prefix - CHARACTER, INTENT(IN) :: mode + CHARACTER(LEN=*), INTENT(IN) :: directory, prefix + CHARACTER, INTENT(IN) :: mode CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: opt_archive TYPE(t_serializer), POINTER :: new_serializer @@ -223,8 +346,6 @@ SUBROUTINE ftg_set_serializer_create(directory, prefix, mode, opt_archive) ALLOCATE(new_serializer) CALL fs_create_serializer(directory, prefix, mode, new_serializer, opt_archive) serializer => new_serializer - serializer_has_written = .FALSE. - serializer_has_registered = .FALSE. END SUBROUTINE ftg_set_serializer_create @@ -234,8 +355,6 @@ SUBROUTINE ftg_set_serializer_existing(new_serializer) TYPE(t_serializer), INTENT(IN), TARGET :: new_serializer serializer => new_serializer - serializer_has_written = .FALSE. - serializer_has_registered = .FALSE. END SUBROUTINE ftg_set_serializer_existing @@ -243,10 +362,6 @@ END SUBROUTINE ftg_set_serializer_existing SUBROUTINE ftg_destroy_serializer() IF (ASSOCIATED(serializer)) THEN - IF (serializer_has_registered .AND. .NOT. serializer_has_written) THEN - CALL ftg_write('ftg_dummy_var', .TRUE.) - END IF - CALL fs_destroy_serializer(serializer) serializer => NULL() END IF @@ -322,7 +437,7 @@ END FUNCTION ftg_get_savepoint LOGICAL FUNCTION ftg_field_exists(fieldname) - CHARACTER(LEN=*), INTENT(IN) :: fieldname + CHARACTER(LEN=*), INTENT(IN) :: fieldname ftg_field_exists = fs_field_exists(serializer, fieldname) @@ -333,8 +448,8 @@ END FUNCTION ftg_field_exists FUNCTION ftg_get_bounds(fieldname) - CHARACTER(LEN=*), INTENT(IN) :: fieldname - INTEGER, DIMENSION(8) :: ftg_get_bounds + CHARACTER(LEN=*), INTENT(IN) :: fieldname + INTEGER, DIMENSION(8) :: ftg_get_bounds ftg_get_bounds = fs_get_halos(serializer, fieldname) @@ -344,77 +459,222 @@ END FUNCTION ftg_get_bounds !============================================================================= SUBROUTINE ftg_add_serializer_metainfo_b(key, val) - CHARACTER(LEN=*) :: key - LOGICAL, VALUE :: val + CHARACTER(LEN=*), INTENT(IN) :: key + LOGICAL, INTENT(IN) :: val CALL fs_add_serializer_metainfo(serializer, key, val) END SUBROUTINE ftg_add_serializer_metainfo_b - SUBROUTINE ftg_add_serializer_metainfo_i(key, val) - CHARACTER(LEN=*) :: key - INTEGER(C_INT) :: val + CHARACTER(LEN=*), INTENT(IN) :: key + INTEGER(KIND=C_INT), INTENT(IN) :: val CALL fs_add_serializer_metainfo(serializer, key, val) END SUBROUTINE ftg_add_serializer_metainfo_i +SUBROUTINE ftg_add_serializer_metainfo_l(key, val) + CHARACTER(LEN=*), INTENT(IN) :: key + INTEGER(KIND=C_LONG), INTENT(IN) :: val + CALL fs_add_serializer_metainfo(serializer, key, val) +END SUBROUTINE ftg_add_serializer_metainfo_l SUBROUTINE ftg_add_serializer_metainfo_f(key, val) - CHARACTER(LEN=*) :: key - REAL(KIND=C_FLOAT) :: val + CHARACTER(LEN=*), INTENT(IN) :: key + REAL(KIND=C_FLOAT), INTENT(IN) :: val CALL fs_add_serializer_metainfo(serializer, key, val) END SUBROUTINE ftg_add_serializer_metainfo_f - SUBROUTINE ftg_add_serializer_metainfo_d(key, val) - CHARACTER(LEN=*) :: key - REAL(KIND=C_DOUBLE) :: val + CHARACTER(LEN=*), INTENT(IN) :: key + REAL(KIND=C_DOUBLE), INTENT(IN) :: val CALL fs_add_serializer_metainfo(serializer, key, val) END SUBROUTINE ftg_add_serializer_metainfo_d - SUBROUTINE ftg_add_serializer_metainfo_s(key, val) - CHARACTER(LEN=*) :: key, val + CHARACTER(LEN=*), INTENT(IN) :: key + CHARACTER(LEN=*), INTENT(IN) :: val CALL fs_add_serializer_metainfo(serializer, key, val) END SUBROUTINE ftg_add_serializer_metainfo_s !============================================================================= !============================================================================= +SUBROUTINE ftg_get_serializer_metainfo_b(key, val) + CHARACTER(LEN=*), INTENT(IN) :: key + LOGICAL, INTENT(OUT) :: val + CALL fs_get_serializer_metainfo(serializer, key, val) +END SUBROUTINE ftg_get_serializer_metainfo_b + +SUBROUTINE ftg_get_serializer_metainfo_i(key, val) + CHARACTER(LEN=*), INTENT(IN) :: key + INTEGER(KIND=C_INT), INTENT(OUT) :: val + CALL fs_get_serializer_metainfo(serializer, key, val) +END SUBROUTINE ftg_get_serializer_metainfo_i + +SUBROUTINE ftg_get_serializer_metainfo_l(key, val) + CHARACTER(LEN=*), INTENT(IN) :: key + INTEGER(KIND=C_LONG), INTENT(OUT) :: val + CALL fs_get_serializer_metainfo(serializer, key, val) +END SUBROUTINE ftg_get_serializer_metainfo_l + +SUBROUTINE ftg_get_serializer_metainfo_f(key, val) + CHARACTER(LEN=*), INTENT(IN) :: key + REAL(KIND=C_FLOAT), INTENT(OUT) :: val + CALL fs_get_serializer_metainfo(serializer, key, val) +END SUBROUTINE ftg_get_serializer_metainfo_f + +SUBROUTINE ftg_get_serializer_metainfo_d(key, val) + CHARACTER(LEN=*), INTENT(IN) :: key + REAL(KIND=C_DOUBLE), INTENT(OUT) :: val + CALL fs_get_serializer_metainfo(serializer, key, val) +END SUBROUTINE ftg_get_serializer_metainfo_d + + +!============================================================================= +!============================================================================= + +SUBROUTINE ftg_add_field_metainfo_b(fieldname, key, val) + CHARACTER(LEN=*), INTENT(IN) :: fieldname, key + LOGICAL, INTENT(IN) :: val + CALL fs_add_field_metainfo(serializer, fieldname, key, val) +END SUBROUTINE ftg_add_field_metainfo_b + +SUBROUTINE ftg_add_field_metainfo_i(fieldname, key, val) + CHARACTER(LEN=*), INTENT(IN) :: fieldname, key + INTEGER(KIND=C_INT), INTENT(IN) :: val + CALL fs_add_field_metainfo(serializer, fieldname, key, val) +END SUBROUTINE ftg_add_field_metainfo_i + +SUBROUTINE ftg_add_field_metainfo_l(fieldname, key, val) + CHARACTER(LEN=*), INTENT(IN) :: fieldname, key + INTEGER(KIND=C_LONG), INTENT(IN) :: val + CALL fs_add_field_metainfo(serializer, fieldname, key, val) +END SUBROUTINE ftg_add_field_metainfo_l + +SUBROUTINE ftg_add_field_metainfo_f(fieldname, key, val) + CHARACTER(LEN=*), INTENT(IN) :: fieldname, key + REAL(KIND=C_FLOAT), INTENT(IN) :: val + CALL fs_add_field_metainfo(serializer, fieldname, key, val) +END SUBROUTINE ftg_add_field_metainfo_f + +SUBROUTINE ftg_add_field_metainfo_d(fieldname, key, val) + CHARACTER(LEN=*), INTENT(IN) :: fieldname, key + REAL(KIND=C_DOUBLE), INTENT(IN) :: val + CALL fs_add_field_metainfo(serializer, fieldname, key, val) +END SUBROUTINE ftg_add_field_metainfo_d + +SUBROUTINE ftg_add_field_metainfo_s(fieldname, key, val) + CHARACTER(LEN=*), INTENT(IN) :: fieldname, key + CHARACTER(LEN=*), INTENT(IN) :: val + CALL fs_add_field_metainfo(serializer, fieldname, key, val) +END SUBROUTINE ftg_add_field_metainfo_s + +!============================================================================= +!============================================================================= + +SUBROUTINE ftg_get_field_metainfo_b(fieldname, key, val) + CHARACTER(LEN=*), INTENT(IN) :: fieldname, key + LOGICAL, INTENT(OUT) :: val + CALL fs_get_field_metainfo(serializer, fieldname, key, val) +END SUBROUTINE ftg_get_field_metainfo_b + +SUBROUTINE ftg_get_field_metainfo_i(fieldname, key, val) + CHARACTER(LEN=*), INTENT(IN) :: fieldname, key + INTEGER(KIND=C_INT), INTENT(OUT) :: val + CALL fs_get_field_metainfo(serializer, fieldname, key, val) +END SUBROUTINE ftg_get_field_metainfo_i + +SUBROUTINE ftg_get_field_metainfo_l(fieldname, key, val) + CHARACTER(LEN=*), INTENT(IN) :: fieldname, key + INTEGER(KIND=C_LONG), INTENT(OUT) :: val + CALL fs_get_field_metainfo(serializer, fieldname, key, val) +END SUBROUTINE ftg_get_field_metainfo_l + +SUBROUTINE ftg_get_field_metainfo_f(fieldname, key, val) + CHARACTER(LEN=*), INTENT(IN) :: fieldname, key + REAL(KIND=C_FLOAT), INTENT(OUT) :: val + CALL fs_get_field_metainfo(serializer, fieldname, key, val) +END SUBROUTINE ftg_get_field_metainfo_f + +SUBROUTINE ftg_get_field_metainfo_d(fieldname, key, val) + CHARACTER(LEN=*), INTENT(IN) :: fieldname, key + REAL(KIND=C_DOUBLE), INTENT(OUT) :: val + CALL fs_get_field_metainfo(serializer, fieldname, key, val) +END SUBROUTINE ftg_get_field_metainfo_d + +!============================================================================= +!============================================================================= + SUBROUTINE ftg_add_savepoint_metainfo_b(key, val) - CHARACTER(LEN=*) :: key - LOGICAL, VALUE :: val + CHARACTER(LEN=*), INTENT(IN) :: key + LOGICAL, INTENT(IN) :: val CALL fs_add_savepoint_metainfo(savepoint, key, val) END SUBROUTINE ftg_add_savepoint_metainfo_b - SUBROUTINE ftg_add_savepoint_metainfo_i(key, val) - CHARACTER(LEN=*) :: key - INTEGER(C_INT) :: val + CHARACTER(LEN=*), INTENT(IN) :: key + INTEGER(KIND=C_INT), INTENT(IN) :: val CALL fs_add_savepoint_metainfo(savepoint, key, val) END SUBROUTINE ftg_add_savepoint_metainfo_i +SUBROUTINE ftg_add_savepoint_metainfo_l(key, val) + CHARACTER(LEN=*), INTENT(IN) :: key + INTEGER(KIND=C_LONG), INTENT(IN) :: val + CALL fs_add_savepoint_metainfo(savepoint, key, val) +END SUBROUTINE ftg_add_savepoint_metainfo_l SUBROUTINE ftg_add_savepoint_metainfo_f(key, val) - CHARACTER(LEN=*) :: key - REAL(KIND=C_FLOAT) :: val + CHARACTER(LEN=*), INTENT(IN) :: key + REAL(KIND=C_FLOAT), INTENT(IN) :: val CALL fs_add_savepoint_metainfo(savepoint, key, val) END SUBROUTINE ftg_add_savepoint_metainfo_f - SUBROUTINE ftg_add_savepoint_metainfo_d(key, val) - CHARACTER(LEN=*) :: key - REAL(KIND=C_DOUBLE) :: val + CHARACTER(LEN=*), INTENT(IN) :: key + REAL(KIND=C_DOUBLE), INTENT(IN) :: val CALL fs_add_savepoint_metainfo(savepoint, key, val) END SUBROUTINE ftg_add_savepoint_metainfo_d - SUBROUTINE ftg_add_savepoint_metainfo_s(key, val) - CHARACTER(LEN=*) :: key, val + CHARACTER(LEN=*), INTENT(IN) :: key + CHARACTER(LEN=*), INTENT(IN) :: val CALL fs_add_savepoint_metainfo(savepoint, key, val) END SUBROUTINE ftg_add_savepoint_metainfo_s !============================================================================= !============================================================================= +SUBROUTINE ftg_get_savepoint_metainfo_b(key, val) + CHARACTER(LEN=*), INTENT(IN) :: key + LOGICAL, INTENT(OUT) :: val + CALL fs_get_savepoint_metainfo(savepoint, key, val) +END SUBROUTINE ftg_get_savepoint_metainfo_b + +SUBROUTINE ftg_get_savepoint_metainfo_i(key, val) + CHARACTER(LEN=*), INTENT(IN) :: key + INTEGER(KIND=C_INT), INTENT(OUT) :: val + CALL fs_get_savepoint_metainfo(savepoint, key, val) +END SUBROUTINE ftg_get_savepoint_metainfo_i + +SUBROUTINE ftg_get_savepoint_metainfo_l(key, val) + CHARACTER(LEN=*), INTENT(IN) :: key + INTEGER(KIND=C_LONG), INTENT(OUT) :: val + CALL fs_get_savepoint_metainfo(savepoint, key, val) +END SUBROUTINE ftg_get_savepoint_metainfo_l + +SUBROUTINE ftg_get_savepoint_metainfo_f(key, val) + CHARACTER(LEN=*), INTENT(IN) :: key + REAL(KIND=C_FLOAT), INTENT(OUT) :: val + CALL fs_get_savepoint_metainfo(savepoint, key, val) +END SUBROUTINE ftg_get_savepoint_metainfo_f + +SUBROUTINE ftg_get_savepoint_metainfo_d(key, val) + CHARACTER(LEN=*), INTENT(IN) :: key + REAL(KIND=C_DOUBLE), INTENT(OUT) :: val + CALL fs_get_savepoint_metainfo(savepoint, key, val) +END SUBROUTINE ftg_get_savepoint_metainfo_d + +!============================================================================= +!============================================================================= + SUBROUTINE ftg_register_only(fieldname, typename, lbounds, ubounds, cptr) CHARACTER(LEN=*), INTENT(IN) :: fieldname CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: typename @@ -450,32 +710,53 @@ SUBROUTINE ftg_register_only(fieldname, typename, lbounds, ubounds, cptr) IF (.NOT. bullshit) THEN CALL fs_register_field(serializer, fieldname, 'int', 4, sizes(1), sizes(2), sizes(3), sizes(4), & bounds(1), bounds(2), bounds(3), bounds(4), bounds(5), bounds(6), bounds(7), bounds(8)) - CALL fs_add_field_metainfo(serializer, TRIM(fieldname), 'registered_only', .TRUE.) + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:registered_only', .TRUE.) IF (PRESENT(typename)) THEN - CALL fs_add_field_metainfo(serializer, TRIM(fieldname), 'type', TRIM(typename)) + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:type', TRIM(typename)) END IF IF (PRESENT(cptr)) THEN - CALL fs_add_field_metainfo(serializer, TRIM(fieldname), 'loc', TRIM(ftg_loc_hex(cptr))) + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:loc', TRIM(ftg_loc_hex(cptr))) END IF - serializer_has_registered = .TRUE. END IF END SUBROUTINE ftg_register_only +SUBROUTINE ftg_register_only_internal(fieldname, data_type, bytes_per_element, lbounds, ubounds) + CHARACTER(LEN=*), INTENT(IN) :: fieldname + CHARACTER(LEN=*), INTENT(IN) :: data_type + INTEGER, INTENT(IN) :: bytes_per_element, lbounds(:), ubounds(:) + + INTEGER :: sizes(4), bounds(8), i + + sizes = (/ 1, 0, 0, 0 /) + bounds = (/ 0, 0, 0, 0, 0, 0, 0, 0 /) + + DO i = 1, SIZE(lbounds) + sizes(i) = ubounds(i) - lbounds(i) + 1 + bounds(i * 2 - 1) = lbounds(i) + bounds(i * 2) = ubounds(i) + END DO + + CALL fs_register_field(serializer, fieldname, data_type, bytes_per_element, sizes(1), sizes(2), sizes(3), sizes(4), & + bounds(1), bounds(2), bounds(3), bounds(4), bounds(5), bounds(6), bounds(7), bounds(8)) + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:registered_only', .TRUE.) + +END SUBROUTINE ftg_register_only_internal + !============================================================================= !============================================================================= FUNCTION ftg_loc(field) - TYPE(C_PTR), INTENT(in) :: field + TYPE(C_PTR), INTENT(in) :: field INTEGER(KIND=C_INTPTR_T) :: ftg_loc INTERFACE SUBROUTINE ftg_loc_(field, loc) & BIND(c, name='serialboxFortranLoc') - USE, INTRINSIC :: iso_c_binding - TYPE(C_PTR), INTENT(IN), VALUE :: field - INTEGER(C_INTPTR_T), INTENT(OUT) :: loc + USE, INTRINSIC :: iso_c_binding + TYPE(C_PTR), INTENT(IN), VALUE :: field + INTEGER(C_INTPTR_T), INTENT(OUT) :: loc END SUBROUTINE ftg_loc_ END INTERFACE @@ -486,7 +767,7 @@ END FUNCTION ftg_loc FUNCTION ftg_loc_hex(field) TYPE(C_PTR), INTENT(in) :: field - CHARACTER(16) :: ftg_loc_hex + CHARACTER(16) :: ftg_loc_hex WRITE (ftg_loc_hex,'(Z16)') ftg_loc(field) @@ -495,7 +776,6 @@ END FUNCTION ftg_loc_hex !============================================================================= !============================================================================= - SUBROUTINE ftg_write_logical_0d(fieldname, field) CHARACTER(LEN=*), INTENT(IN) :: fieldname LOGICAL, INTENT(IN), TARGET :: field @@ -506,13 +786,13 @@ SUBROUTINE ftg_write_logical_0d(fieldname, field) padd => field bullshit = .FALSE. IF (ignore_bullshit) THEN - bullshit = .NOT. ASSOCIATED(padd, field) + bullshit = .NOT. ASSOCIATED(padd) END IF IF (.NOT. bullshit) THEN CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field) - CALL fs_add_field_metainfo(serializer, TRIM(fieldname), 'loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) - serializer_has_written = .TRUE. + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:registered_only', .FALSE.) + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) END IF END SUBROUTINE ftg_write_logical_0d @@ -528,16 +808,20 @@ SUBROUTINE ftg_write_logical_1d(fieldname, field, lbounds, ubounds) padd=>field bullshit = .FALSE. if (ignore_bullshit) THEN - bullshit = .NOT. ASSOCIATED(padd, field) .OR. SIZE(field, 1) > ignore_bullshit_max_dim_size + bullshit = .NOT. ASSOCIATED(padd) .OR. SIZE(field, 1) > ignore_bullshit_max_dim_size IF (.NOT. bullshit .AND. .NOT. ignore_bullshit_allow_negative_indices) THEN bullshit = lbounds(1) < 0 .OR. ubounds(1) < 0 END IF END IF IF (.NOT. bullshit) THEN - CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) - CALL fs_add_field_metainfo(serializer, TRIM(fieldname), 'loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) - serializer_has_written = .TRUE. + IF (SIZE(field) > 0) THEN + CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:registered_only', .FALSE.) + ELSE + CALL ftg_register_only_internal(fieldname, 'bool', fs_boolsize(), lbounds, ubounds) + END IF + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) END IF END SUBROUTINE ftg_write_logical_1d @@ -553,7 +837,7 @@ SUBROUTINE ftg_write_logical_2d(fieldname, field, lbounds, ubounds) padd=>field bullshit = .FALSE. if (ignore_bullshit) THEN - bullshit = .NOT. ASSOCIATED(padd, field) .OR. & + bullshit = .NOT. ASSOCIATED(padd) .OR. & SIZE(field, 1) > ignore_bullshit_max_dim_size .OR. & SIZE(field, 2) > ignore_bullshit_max_dim_size IF (.NOT. bullshit .AND. .NOT. ignore_bullshit_allow_negative_indices) THEN @@ -562,9 +846,13 @@ SUBROUTINE ftg_write_logical_2d(fieldname, field, lbounds, ubounds) END IF IF (.NOT. bullshit) THEN - CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) - CALL fs_add_field_metainfo(serializer, TRIM(fieldname), 'loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) - serializer_has_written = .TRUE. + IF (SIZE(field) > 0) THEN + CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:registered_only', .FALSE.) + ELSE + CALL ftg_register_only_internal(fieldname, 'bool', fs_boolsize(), lbounds, ubounds) + END IF + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) END IF END SUBROUTINE ftg_write_logical_2d @@ -581,7 +869,7 @@ SUBROUTINE ftg_write_logical_3d(fieldname, field, lbounds, ubounds) padd=>field bullshit = .FALSE. if (ignore_bullshit) THEN - bullshit = .NOT. ASSOCIATED(padd, field) .OR. & + bullshit = .NOT. ASSOCIATED(padd) .OR. & SIZE(field, 1) > ignore_bullshit_max_dim_size .OR. & SIZE(field, 2) > ignore_bullshit_max_dim_size .OR. & SIZE(field, 3) > ignore_bullshit_max_dim_size @@ -591,9 +879,13 @@ SUBROUTINE ftg_write_logical_3d(fieldname, field, lbounds, ubounds) END IF IF (.NOT. bullshit) THEN - CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) - CALL fs_add_field_metainfo(serializer, TRIM(fieldname), 'loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) - serializer_has_written = .TRUE. + IF (SIZE(field) > 0) THEN + CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:registered_only', .FALSE.) + ELSE + CALL ftg_register_only_internal(fieldname, 'bool', fs_boolsize(), lbounds, ubounds) + END IF + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) END IF END SUBROUTINE ftg_write_logical_3d @@ -609,7 +901,7 @@ SUBROUTINE ftg_write_logical_4d(fieldname, field, lbounds, ubounds) padd=>field bullshit = .FALSE. if (ignore_bullshit) THEN - bullshit = .NOT. ASSOCIATED(padd, field) .OR. & + bullshit = .NOT. ASSOCIATED(padd) .OR. & SIZE(field, 1) > ignore_bullshit_max_dim_size .OR. & SIZE(field, 2) > ignore_bullshit_max_dim_size .OR. & SIZE(field, 3) > ignore_bullshit_max_dim_size .OR. & @@ -620,16 +912,17 @@ SUBROUTINE ftg_write_logical_4d(fieldname, field, lbounds, ubounds) END IF IF (.NOT. bullshit) THEN - CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) - CALL fs_add_field_metainfo(serializer, TRIM(fieldname), 'loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) - serializer_has_written = .TRUE. + IF (SIZE(field) > 0) THEN + CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:registered_only', .FALSE.) + ELSE + CALL ftg_register_only_internal(fieldname, 'bool', fs_boolsize(), lbounds, ubounds) + END IF + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) END IF END SUBROUTINE ftg_write_logical_4d -!============================================================================= -!============================================================================= - SUBROUTINE ftg_write_bool_0d(fieldname, field) CHARACTER(LEN=*), INTENT(IN) :: fieldname LOGICAL(KIND=C_BOOL), INTENT(IN), TARGET :: field @@ -640,13 +933,13 @@ SUBROUTINE ftg_write_bool_0d(fieldname, field) padd => field bullshit = .FALSE. IF (ignore_bullshit) THEN - bullshit = .NOT. ASSOCIATED(padd, field) + bullshit = .NOT. ASSOCIATED(padd) END IF IF (.NOT. bullshit) THEN CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field) - CALL fs_add_field_metainfo(serializer, TRIM(fieldname), 'loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) - serializer_has_written = .TRUE. + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:registered_only', .FALSE.) + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) END IF END SUBROUTINE ftg_write_bool_0d @@ -662,16 +955,20 @@ SUBROUTINE ftg_write_bool_1d(fieldname, field, lbounds, ubounds) padd=>field bullshit = .FALSE. if (ignore_bullshit) THEN - bullshit = .NOT. ASSOCIATED(padd, field) .OR. SIZE(field, 1) > ignore_bullshit_max_dim_size + bullshit = .NOT. ASSOCIATED(padd) .OR. SIZE(field, 1) > ignore_bullshit_max_dim_size IF (.NOT. bullshit .AND. .NOT. ignore_bullshit_allow_negative_indices) THEN bullshit = lbounds(1) < 0 .OR. ubounds(1) < 0 END IF END IF IF (.NOT. bullshit) THEN - CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) - CALL fs_add_field_metainfo(serializer, TRIM(fieldname), 'loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) - serializer_has_written = .TRUE. + IF (SIZE(field) > 0) THEN + CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:registered_only', .FALSE.) + ELSE + CALL ftg_register_only_internal(fieldname, 'bool', fs_boolsize(), lbounds, ubounds) + END IF + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) END IF END SUBROUTINE ftg_write_bool_1d @@ -687,7 +984,7 @@ SUBROUTINE ftg_write_bool_2d(fieldname, field, lbounds, ubounds) padd=>field bullshit = .FALSE. if (ignore_bullshit) THEN - bullshit = .NOT. ASSOCIATED(padd, field) .OR. & + bullshit = .NOT. ASSOCIATED(padd) .OR. & SIZE(field, 1) > ignore_bullshit_max_dim_size .OR. & SIZE(field, 2) > ignore_bullshit_max_dim_size IF (.NOT. bullshit .AND. .NOT. ignore_bullshit_allow_negative_indices) THEN @@ -696,9 +993,13 @@ SUBROUTINE ftg_write_bool_2d(fieldname, field, lbounds, ubounds) END IF IF (.NOT. bullshit) THEN - CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) - CALL fs_add_field_metainfo(serializer, TRIM(fieldname), 'loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) - serializer_has_written = .TRUE. + IF (SIZE(field) > 0) THEN + CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:registered_only', .FALSE.) + ELSE + CALL ftg_register_only_internal(fieldname, 'bool', fs_boolsize(), lbounds, ubounds) + END IF + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) END IF END SUBROUTINE ftg_write_bool_2d @@ -710,11 +1011,12 @@ SUBROUTINE ftg_write_bool_3d(fieldname, field, lbounds, ubounds) LOGICAL(KIND=C_BOOL), POINTER :: padd(:,:,:) LOGICAL :: bullshit + CHARACTER(16) :: loc padd=>field bullshit = .FALSE. if (ignore_bullshit) THEN - bullshit = .NOT. ASSOCIATED(padd, field) .OR. & + bullshit = .NOT. ASSOCIATED(padd) .OR. & SIZE(field, 1) > ignore_bullshit_max_dim_size .OR. & SIZE(field, 2) > ignore_bullshit_max_dim_size .OR. & SIZE(field, 3) > ignore_bullshit_max_dim_size @@ -724,9 +1026,13 @@ SUBROUTINE ftg_write_bool_3d(fieldname, field, lbounds, ubounds) END IF IF (.NOT. bullshit) THEN - CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) - CALL fs_add_field_metainfo(serializer, TRIM(fieldname), 'loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) - serializer_has_written = .TRUE. + IF (SIZE(field) > 0) THEN + CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:registered_only', .FALSE.) + ELSE + CALL ftg_register_only_internal(fieldname, 'bool', fs_boolsize(), lbounds, ubounds) + END IF + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) END IF END SUBROUTINE ftg_write_bool_3d @@ -742,7 +1048,7 @@ SUBROUTINE ftg_write_bool_4d(fieldname, field, lbounds, ubounds) padd=>field bullshit = .FALSE. if (ignore_bullshit) THEN - bullshit = .NOT. ASSOCIATED(padd, field) .OR. & + bullshit = .NOT. ASSOCIATED(padd) .OR. & SIZE(field, 1) > ignore_bullshit_max_dim_size .OR. & SIZE(field, 2) > ignore_bullshit_max_dim_size .OR. & SIZE(field, 3) > ignore_bullshit_max_dim_size .OR. & @@ -753,16 +1059,17 @@ SUBROUTINE ftg_write_bool_4d(fieldname, field, lbounds, ubounds) END IF IF (.NOT. bullshit) THEN - CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) - CALL fs_add_field_metainfo(serializer, TRIM(fieldname), 'loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) - serializer_has_written = .TRUE. + IF (SIZE(field) > 0) THEN + CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:registered_only', .FALSE.) + ELSE + CALL ftg_register_only_internal(fieldname, 'bool', fs_boolsize(), lbounds, ubounds) + END IF + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) END IF END SUBROUTINE ftg_write_bool_4d -!============================================================================= -!============================================================================= - SUBROUTINE ftg_write_int_0d(fieldname, field) CHARACTER(LEN=*), INTENT(IN) :: fieldname INTEGER, INTENT(IN), TARGET :: field @@ -773,13 +1080,13 @@ SUBROUTINE ftg_write_int_0d(fieldname, field) padd => field bullshit = .FALSE. IF (ignore_bullshit) THEN - bullshit = .NOT. ASSOCIATED(padd, field) + bullshit = .NOT. ASSOCIATED(padd) END IF IF (.NOT. bullshit) THEN CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field) - CALL fs_add_field_metainfo(serializer, TRIM(fieldname), 'loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) - serializer_has_written = .TRUE. + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:registered_only', .FALSE.) + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) END IF END SUBROUTINE ftg_write_int_0d @@ -795,16 +1102,20 @@ SUBROUTINE ftg_write_int_1d(fieldname, field, lbounds, ubounds) padd=>field bullshit = .FALSE. if (ignore_bullshit) THEN - bullshit = .NOT. ASSOCIATED(padd, field) .OR. SIZE(field, 1) > ignore_bullshit_max_dim_size + bullshit = .NOT. ASSOCIATED(padd) .OR. SIZE(field, 1) > ignore_bullshit_max_dim_size IF (.NOT. bullshit .AND. .NOT. ignore_bullshit_allow_negative_indices) THEN bullshit = lbounds(1) < 0 .OR. ubounds(1) < 0 END IF END IF IF (.NOT. bullshit) THEN - CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) - CALL fs_add_field_metainfo(serializer, TRIM(fieldname), 'loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) - serializer_has_written = .TRUE. + IF (SIZE(field) > 0) THEN + CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:registered_only', .FALSE.) + ELSE + CALL ftg_register_only_internal(fieldname, 'int', fs_intsize(), lbounds, ubounds) + END IF + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) END IF END SUBROUTINE ftg_write_int_1d @@ -820,7 +1131,7 @@ SUBROUTINE ftg_write_int_2d(fieldname, field, lbounds, ubounds) padd=>field bullshit = .FALSE. if (ignore_bullshit) THEN - bullshit = .NOT. ASSOCIATED(padd, field) .OR. & + bullshit = .NOT. ASSOCIATED(padd) .OR. & SIZE(field, 1) > ignore_bullshit_max_dim_size .OR. & SIZE(field, 2) > ignore_bullshit_max_dim_size IF (.NOT. bullshit .AND. .NOT. ignore_bullshit_allow_negative_indices) THEN @@ -829,9 +1140,13 @@ SUBROUTINE ftg_write_int_2d(fieldname, field, lbounds, ubounds) END IF IF (.NOT. bullshit) THEN - CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) - CALL fs_add_field_metainfo(serializer, TRIM(fieldname), 'loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) - serializer_has_written = .TRUE. + IF (SIZE(field) > 0) THEN + CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:registered_only', .FALSE.) + ELSE + CALL ftg_register_only_internal(fieldname, 'int', fs_intsize(), lbounds, ubounds) + END IF + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) END IF END SUBROUTINE ftg_write_int_2d @@ -843,11 +1158,12 @@ SUBROUTINE ftg_write_int_3d(fieldname, field, lbounds, ubounds) INTEGER, POINTER :: padd(:,:,:) LOGICAL :: bullshit + CHARACTER(16) :: loc padd=>field bullshit = .FALSE. if (ignore_bullshit) THEN - bullshit = .NOT. ASSOCIATED(padd, field) .OR. & + bullshit = .NOT. ASSOCIATED(padd) .OR. & SIZE(field, 1) > ignore_bullshit_max_dim_size .OR. & SIZE(field, 2) > ignore_bullshit_max_dim_size .OR. & SIZE(field, 3) > ignore_bullshit_max_dim_size @@ -857,9 +1173,13 @@ SUBROUTINE ftg_write_int_3d(fieldname, field, lbounds, ubounds) END IF IF (.NOT. bullshit) THEN - CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) - CALL fs_add_field_metainfo(serializer, TRIM(fieldname), 'loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) - serializer_has_written = .TRUE. + IF (SIZE(field) > 0) THEN + CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:registered_only', .FALSE.) + ELSE + CALL ftg_register_only_internal(fieldname, 'int', fs_intsize(), lbounds, ubounds) + END IF + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) END IF END SUBROUTINE ftg_write_int_3d @@ -875,7 +1195,7 @@ SUBROUTINE ftg_write_int_4d(fieldname, field, lbounds, ubounds) padd=>field bullshit = .FALSE. if (ignore_bullshit) THEN - bullshit = .NOT. ASSOCIATED(padd, field) .OR. & + bullshit = .NOT. ASSOCIATED(padd) .OR. & SIZE(field, 1) > ignore_bullshit_max_dim_size .OR. & SIZE(field, 2) > ignore_bullshit_max_dim_size .OR. & SIZE(field, 3) > ignore_bullshit_max_dim_size .OR. & @@ -886,16 +1206,17 @@ SUBROUTINE ftg_write_int_4d(fieldname, field, lbounds, ubounds) END IF IF (.NOT. bullshit) THEN - CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) - CALL fs_add_field_metainfo(serializer, TRIM(fieldname), 'loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) - serializer_has_written = .TRUE. + IF (SIZE(field) > 0) THEN + CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:registered_only', .FALSE.) + ELSE + CALL ftg_register_only_internal(fieldname, 'int', fs_intsize(), lbounds, ubounds) + END IF + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) END IF END SUBROUTINE ftg_write_int_4d -!============================================================================= -!============================================================================= - SUBROUTINE ftg_write_long_0d(fieldname, field) CHARACTER(LEN=*), INTENT(IN) :: fieldname INTEGER(KIND=C_LONG), INTENT(IN), TARGET :: field @@ -906,13 +1227,13 @@ SUBROUTINE ftg_write_long_0d(fieldname, field) padd => field bullshit = .FALSE. IF (ignore_bullshit) THEN - bullshit = .NOT. ASSOCIATED(padd, field) + bullshit = .NOT. ASSOCIATED(padd) END IF IF (.NOT. bullshit) THEN CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field) - CALL fs_add_field_metainfo(serializer, TRIM(fieldname), 'loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) - serializer_has_written = .TRUE. + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:registered_only', .FALSE.) + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) END IF END SUBROUTINE ftg_write_long_0d @@ -928,16 +1249,20 @@ SUBROUTINE ftg_write_long_1d(fieldname, field, lbounds, ubounds) padd=>field bullshit = .FALSE. if (ignore_bullshit) THEN - bullshit = .NOT. ASSOCIATED(padd, field) .OR. SIZE(field, 1) > ignore_bullshit_max_dim_size + bullshit = .NOT. ASSOCIATED(padd) .OR. SIZE(field, 1) > ignore_bullshit_max_dim_size IF (.NOT. bullshit .AND. .NOT. ignore_bullshit_allow_negative_indices) THEN bullshit = lbounds(1) < 0 .OR. ubounds(1) < 0 END IF END IF IF (.NOT. bullshit) THEN - CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) - CALL fs_add_field_metainfo(serializer, TRIM(fieldname), 'loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) - serializer_has_written = .TRUE. + IF (SIZE(field) > 0) THEN + CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:registered_only', .FALSE.) + ELSE + CALL ftg_register_only_internal(fieldname, 'long', fs_longsize(), lbounds, ubounds) + END IF + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) END IF END SUBROUTINE ftg_write_long_1d @@ -953,7 +1278,7 @@ SUBROUTINE ftg_write_long_2d(fieldname, field, lbounds, ubounds) padd=>field bullshit = .FALSE. if (ignore_bullshit) THEN - bullshit = .NOT. ASSOCIATED(padd, field) .OR. & + bullshit = .NOT. ASSOCIATED(padd) .OR. & SIZE(field, 1) > ignore_bullshit_max_dim_size .OR. & SIZE(field, 2) > ignore_bullshit_max_dim_size IF (.NOT. bullshit .AND. .NOT. ignore_bullshit_allow_negative_indices) THEN @@ -962,9 +1287,13 @@ SUBROUTINE ftg_write_long_2d(fieldname, field, lbounds, ubounds) END IF IF (.NOT. bullshit) THEN - CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) - CALL fs_add_field_metainfo(serializer, TRIM(fieldname), 'loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) - serializer_has_written = .TRUE. + IF (SIZE(field) > 0) THEN + CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:registered_only', .FALSE.) + ELSE + CALL ftg_register_only_internal(fieldname, 'long', fs_longsize(), lbounds, ubounds) + END IF + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) END IF END SUBROUTINE ftg_write_long_2d @@ -976,11 +1305,12 @@ SUBROUTINE ftg_write_long_3d(fieldname, field, lbounds, ubounds) INTEGER(KIND=C_LONG), POINTER :: padd(:,:,:) LOGICAL :: bullshit + CHARACTER(16) :: loc padd=>field bullshit = .FALSE. if (ignore_bullshit) THEN - bullshit = .NOT. ASSOCIATED(padd, field) .OR. & + bullshit = .NOT. ASSOCIATED(padd) .OR. & SIZE(field, 1) > ignore_bullshit_max_dim_size .OR. & SIZE(field, 2) > ignore_bullshit_max_dim_size .OR. & SIZE(field, 3) > ignore_bullshit_max_dim_size @@ -990,9 +1320,13 @@ SUBROUTINE ftg_write_long_3d(fieldname, field, lbounds, ubounds) END IF IF (.NOT. bullshit) THEN - CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) - CALL fs_add_field_metainfo(serializer, TRIM(fieldname), 'loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) - serializer_has_written = .TRUE. + IF (SIZE(field) > 0) THEN + CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:registered_only', .FALSE.) + ELSE + CALL ftg_register_only_internal(fieldname, 'long', fs_longsize(), lbounds, ubounds) + END IF + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) END IF END SUBROUTINE ftg_write_long_3d @@ -1008,7 +1342,7 @@ SUBROUTINE ftg_write_long_4d(fieldname, field, lbounds, ubounds) padd=>field bullshit = .FALSE. if (ignore_bullshit) THEN - bullshit = .NOT. ASSOCIATED(padd, field) .OR. & + bullshit = .NOT. ASSOCIATED(padd) .OR. & SIZE(field, 1) > ignore_bullshit_max_dim_size .OR. & SIZE(field, 2) > ignore_bullshit_max_dim_size .OR. & SIZE(field, 3) > ignore_bullshit_max_dim_size .OR. & @@ -1019,16 +1353,17 @@ SUBROUTINE ftg_write_long_4d(fieldname, field, lbounds, ubounds) END IF IF (.NOT. bullshit) THEN - CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) - CALL fs_add_field_metainfo(serializer, TRIM(fieldname), 'loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) - serializer_has_written = .TRUE. + IF (SIZE(field) > 0) THEN + CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:registered_only', .FALSE.) + ELSE + CALL ftg_register_only_internal(fieldname, 'long', fs_longsize(), lbounds, ubounds) + END IF + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) END IF END SUBROUTINE ftg_write_long_4d -!============================================================================= -!============================================================================= - SUBROUTINE ftg_write_float_0d(fieldname, field) CHARACTER(LEN=*), INTENT(IN) :: fieldname REAL(KIND=C_FLOAT), INTENT(IN), TARGET :: field @@ -1039,13 +1374,13 @@ SUBROUTINE ftg_write_float_0d(fieldname, field) padd => field bullshit = .FALSE. IF (ignore_bullshit) THEN - bullshit = .NOT. ASSOCIATED(padd, field) + bullshit = .NOT. ASSOCIATED(padd) END IF IF (.NOT. bullshit) THEN CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field) - CALL fs_add_field_metainfo(serializer, TRIM(fieldname), 'loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) - serializer_has_written = .TRUE. + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:registered_only', .FALSE.) + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) END IF END SUBROUTINE ftg_write_float_0d @@ -1061,16 +1396,20 @@ SUBROUTINE ftg_write_float_1d(fieldname, field, lbounds, ubounds) padd=>field bullshit = .FALSE. if (ignore_bullshit) THEN - bullshit = .NOT. ASSOCIATED(padd, field) .OR. SIZE(field, 1) > ignore_bullshit_max_dim_size + bullshit = .NOT. ASSOCIATED(padd) .OR. SIZE(field, 1) > ignore_bullshit_max_dim_size IF (.NOT. bullshit .AND. .NOT. ignore_bullshit_allow_negative_indices) THEN bullshit = lbounds(1) < 0 .OR. ubounds(1) < 0 END IF END IF IF (.NOT. bullshit) THEN - CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) - CALL fs_add_field_metainfo(serializer, TRIM(fieldname), 'loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) - serializer_has_written = .TRUE. + IF (SIZE(field) > 0) THEN + CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:registered_only', .FALSE.) + ELSE + CALL ftg_register_only_internal(fieldname, 'float', fs_floatsize(), lbounds, ubounds) + END IF + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) END IF END SUBROUTINE ftg_write_float_1d @@ -1086,7 +1425,7 @@ SUBROUTINE ftg_write_float_2d(fieldname, field, lbounds, ubounds) padd=>field bullshit = .FALSE. if (ignore_bullshit) THEN - bullshit = .NOT. ASSOCIATED(padd, field) .OR. & + bullshit = .NOT. ASSOCIATED(padd) .OR. & SIZE(field, 1) > ignore_bullshit_max_dim_size .OR. & SIZE(field, 2) > ignore_bullshit_max_dim_size IF (.NOT. bullshit .AND. .NOT. ignore_bullshit_allow_negative_indices) THEN @@ -1095,9 +1434,13 @@ SUBROUTINE ftg_write_float_2d(fieldname, field, lbounds, ubounds) END IF IF (.NOT. bullshit) THEN - CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) - CALL fs_add_field_metainfo(serializer, TRIM(fieldname), 'loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) - serializer_has_written = .TRUE. + IF (SIZE(field) > 0) THEN + CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:registered_only', .FALSE.) + ELSE + CALL ftg_register_only_internal(fieldname, 'float', fs_floatsize(), lbounds, ubounds) + END IF + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) END IF END SUBROUTINE ftg_write_float_2d @@ -1109,11 +1452,12 @@ SUBROUTINE ftg_write_float_3d(fieldname, field, lbounds, ubounds) REAL(KIND=C_FLOAT), POINTER :: padd(:,:,:) LOGICAL :: bullshit + CHARACTER(16) :: loc padd=>field bullshit = .FALSE. if (ignore_bullshit) THEN - bullshit = .NOT. ASSOCIATED(padd, field) .OR. & + bullshit = .NOT. ASSOCIATED(padd) .OR. & SIZE(field, 1) > ignore_bullshit_max_dim_size .OR. & SIZE(field, 2) > ignore_bullshit_max_dim_size .OR. & SIZE(field, 3) > ignore_bullshit_max_dim_size @@ -1123,9 +1467,13 @@ SUBROUTINE ftg_write_float_3d(fieldname, field, lbounds, ubounds) END IF IF (.NOT. bullshit) THEN - CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) - CALL fs_add_field_metainfo(serializer, TRIM(fieldname), 'loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) - serializer_has_written = .TRUE. + IF (SIZE(field) > 0) THEN + CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:registered_only', .FALSE.) + ELSE + CALL ftg_register_only_internal(fieldname, 'float', fs_floatsize(), lbounds, ubounds) + END IF + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) END IF END SUBROUTINE ftg_write_float_3d @@ -1141,7 +1489,7 @@ SUBROUTINE ftg_write_float_4d(fieldname, field, lbounds, ubounds) padd=>field bullshit = .FALSE. if (ignore_bullshit) THEN - bullshit = .NOT. ASSOCIATED(padd, field) .OR. & + bullshit = .NOT. ASSOCIATED(padd) .OR. & SIZE(field, 1) > ignore_bullshit_max_dim_size .OR. & SIZE(field, 2) > ignore_bullshit_max_dim_size .OR. & SIZE(field, 3) > ignore_bullshit_max_dim_size .OR. & @@ -1152,16 +1500,17 @@ SUBROUTINE ftg_write_float_4d(fieldname, field, lbounds, ubounds) END IF IF (.NOT. bullshit) THEN - CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) - CALL fs_add_field_metainfo(serializer, TRIM(fieldname), 'loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) - serializer_has_written = .TRUE. + IF (SIZE(field) > 0) THEN + CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:registered_only', .FALSE.) + ELSE + CALL ftg_register_only_internal(fieldname, 'float', fs_floatsize(), lbounds, ubounds) + END IF + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) END IF END SUBROUTINE ftg_write_float_4d -!============================================================================= -!============================================================================= - SUBROUTINE ftg_write_double_0d(fieldname, field) CHARACTER(LEN=*), INTENT(IN) :: fieldname REAL(KIND=C_DOUBLE), INTENT(IN), TARGET :: field @@ -1172,13 +1521,13 @@ SUBROUTINE ftg_write_double_0d(fieldname, field) padd => field bullshit = .FALSE. IF (ignore_bullshit) THEN - bullshit = .NOT. ASSOCIATED(padd, field) + bullshit = .NOT. ASSOCIATED(padd) END IF IF (.NOT. bullshit) THEN CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field) - CALL fs_add_field_metainfo(serializer, TRIM(fieldname), 'loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) - serializer_has_written = .TRUE. + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:registered_only', .FALSE.) + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) END IF END SUBROUTINE ftg_write_double_0d @@ -1186,7 +1535,7 @@ END SUBROUTINE ftg_write_double_0d SUBROUTINE ftg_write_double_1d(fieldname, field, lbounds, ubounds) CHARACTER(LEN=*), INTENT(IN) :: fieldname REAL(KIND=C_DOUBLE), INTENT(IN), TARGET :: field(:) - INTEGER, DIMENSION(1), INTENT(IN) :: lbounds, ubounds + INTEGER, INTENT(IN) :: lbounds(1), ubounds(1) REAL(KIND=C_DOUBLE), POINTER :: padd(:) LOGICAL :: bullshit @@ -1194,16 +1543,20 @@ SUBROUTINE ftg_write_double_1d(fieldname, field, lbounds, ubounds) padd=>field bullshit = .FALSE. if (ignore_bullshit) THEN - bullshit = .NOT. ASSOCIATED(padd, field) .OR. SIZE(field, 1) > ignore_bullshit_max_dim_size + bullshit = .NOT. ASSOCIATED(padd) .OR. SIZE(field, 1) > ignore_bullshit_max_dim_size IF (.NOT. bullshit .AND. .NOT. ignore_bullshit_allow_negative_indices) THEN bullshit = lbounds(1) < 0 .OR. ubounds(1) < 0 END IF END IF IF (.NOT. bullshit) THEN - CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) - CALL fs_add_field_metainfo(serializer, TRIM(fieldname), 'loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) - serializer_has_written = .TRUE. + IF (SIZE(field) > 0) THEN + CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:registered_only', .FALSE.) + ELSE + CALL ftg_register_only_internal(fieldname, 'double', fs_doublesize(), lbounds, ubounds) + END IF + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) END IF END SUBROUTINE ftg_write_double_1d @@ -1211,7 +1564,7 @@ END SUBROUTINE ftg_write_double_1d SUBROUTINE ftg_write_double_2d(fieldname, field, lbounds, ubounds) CHARACTER(LEN=*), INTENT(IN) :: fieldname REAL(KIND=C_DOUBLE), INTENT(IN), TARGET :: field(:,:) - INTEGER, DIMENSION(2), INTENT(IN) :: lbounds, ubounds + INTEGER, INTENT(IN) :: lbounds(2), ubounds(2) REAL(KIND=C_DOUBLE), POINTER :: padd(:,:) LOGICAL :: bullshit @@ -1219,7 +1572,7 @@ SUBROUTINE ftg_write_double_2d(fieldname, field, lbounds, ubounds) padd=>field bullshit = .FALSE. if (ignore_bullshit) THEN - bullshit = .NOT. ASSOCIATED(padd, field) .OR. & + bullshit = .NOT. ASSOCIATED(padd) .OR. & SIZE(field, 1) > ignore_bullshit_max_dim_size .OR. & SIZE(field, 2) > ignore_bullshit_max_dim_size IF (.NOT. bullshit .AND. .NOT. ignore_bullshit_allow_negative_indices) THEN @@ -1228,9 +1581,13 @@ SUBROUTINE ftg_write_double_2d(fieldname, field, lbounds, ubounds) END IF IF (.NOT. bullshit) THEN - CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) - CALL fs_add_field_metainfo(serializer, TRIM(fieldname), 'loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) - serializer_has_written = .TRUE. + IF (SIZE(field) > 0) THEN + CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:registered_only', .FALSE.) + ELSE + CALL ftg_register_only_internal(fieldname, 'double', fs_doublesize(), lbounds, ubounds) + END IF + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) END IF END SUBROUTINE ftg_write_double_2d @@ -1238,15 +1595,16 @@ END SUBROUTINE ftg_write_double_2d SUBROUTINE ftg_write_double_3d(fieldname, field, lbounds, ubounds) CHARACTER(LEN=*), INTENT(IN) :: fieldname REAL(KIND=C_DOUBLE), INTENT(IN), TARGET :: field(:,:,:) - INTEGER, DIMENSION(3), INTENT(IN) :: lbounds, ubounds + INTEGER, INTENT(IN) :: lbounds(3), ubounds(3) REAL(KIND=C_DOUBLE), POINTER :: padd(:,:,:) LOGICAL :: bullshit + CHARACTER(16) :: loc padd=>field bullshit = .FALSE. if (ignore_bullshit) THEN - bullshit = .NOT. ASSOCIATED(padd, field) .OR. & + bullshit = .NOT. ASSOCIATED(padd) .OR. & SIZE(field, 1) > ignore_bullshit_max_dim_size .OR. & SIZE(field, 2) > ignore_bullshit_max_dim_size .OR. & SIZE(field, 3) > ignore_bullshit_max_dim_size @@ -1256,9 +1614,13 @@ SUBROUTINE ftg_write_double_3d(fieldname, field, lbounds, ubounds) END IF IF (.NOT. bullshit) THEN - CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) - CALL fs_add_field_metainfo(serializer, TRIM(fieldname), 'loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) - serializer_has_written = .TRUE. + IF (SIZE(field) > 0) THEN + CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:registered_only', .FALSE.) + ELSE + CALL ftg_register_only_internal(fieldname, 'double', fs_doublesize(), lbounds, ubounds) + END IF + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) END IF END SUBROUTINE ftg_write_double_3d @@ -1266,7 +1628,7 @@ END SUBROUTINE ftg_write_double_3d SUBROUTINE ftg_write_double_4d(fieldname, field, lbounds, ubounds) CHARACTER(LEN=*), INTENT(IN) :: fieldname REAL(KIND=C_DOUBLE), INTENT(IN), TARGET :: field(:,:,:,:) - INTEGER, DIMENSION(4), INTENT(IN) :: lbounds, ubounds + INTEGER, INTENT(IN) :: lbounds(4), ubounds(4) REAL(KIND=C_DOUBLE), POINTER :: padd(:,:,:,:) LOGICAL :: bullshit @@ -1274,7 +1636,7 @@ SUBROUTINE ftg_write_double_4d(fieldname, field, lbounds, ubounds) padd=>field bullshit = .FALSE. if (ignore_bullshit) THEN - bullshit = .NOT. ASSOCIATED(padd, field) .OR. & + bullshit = .NOT. ASSOCIATED(padd) .OR. & SIZE(field, 1) > ignore_bullshit_max_dim_size .OR. & SIZE(field, 2) > ignore_bullshit_max_dim_size .OR. & SIZE(field, 3) > ignore_bullshit_max_dim_size .OR. & @@ -1285,9 +1647,13 @@ SUBROUTINE ftg_write_double_4d(fieldname, field, lbounds, ubounds) END IF IF (.NOT. bullshit) THEN - CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) - CALL fs_add_field_metainfo(serializer, TRIM(fieldname), 'loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) - serializer_has_written = .TRUE. + IF (SIZE(field) > 0) THEN + CALL fs_write_field(ftg_get_serializer(), ftg_get_savepoint(), fieldname, field, lbounds, ubounds) + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:registered_only', .FALSE.) + ELSE + CALL ftg_register_only_internal(fieldname, 'double', fs_doublesize(), lbounds, ubounds) + END IF + CALL ftg_add_field_metainfo(TRIM(fieldname), 'ftg:loc', TRIM(ADJUSTL(ftg_loc_hex(C_LOC(field))))) END IF END SUBROUTINE ftg_write_double_4d @@ -1298,291 +1664,411 @@ END SUBROUTINE ftg_write_double_4d SUBROUTINE ftg_read_logical_0d(fieldname, field) CHARACTER(LEN=*) :: fieldname LOGICAL, INTENT(OUT), TARGET :: field + LOGICAL :: registered_only IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN - CALL fs_read_field(serializer, savepoint, fieldname, field) + CALL ftg_get_field_metainfo(fieldname, 'ftg:registered_only', registered_only) + IF (.NOT. registered_only) THEN + CALL fs_read_field(serializer, savepoint, fieldname, field) + END IF END IF END SUBROUTINE ftg_read_logical_0d SUBROUTINE ftg_read_logical_1d(fieldname, field) CHARACTER(LEN=*) :: fieldname LOGICAL, INTENT(OUT), TARGET :: field(:) + LOGICAL :: registered_only IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN - CALL fs_read_field(serializer, savepoint, fieldname, field) + CALL ftg_get_field_metainfo(fieldname, 'ftg:registered_only', registered_only) + IF (.NOT. registered_only) THEN + CALL fs_read_field(serializer, savepoint, fieldname, field) + END IF END IF END SUBROUTINE ftg_read_logical_1d SUBROUTINE ftg_read_logical_2d(fieldname, field) CHARACTER(LEN=*) :: fieldname LOGICAL, INTENT(OUT), TARGET :: field(:,:) + LOGICAL :: registered_only IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN - CALL fs_read_field(serializer, savepoint, fieldname, field) + CALL ftg_get_field_metainfo(fieldname, 'ftg:registered_only', registered_only) + IF (.NOT. registered_only) THEN + CALL fs_read_field(serializer, savepoint, fieldname, field) + END IF END IF END SUBROUTINE ftg_read_logical_2d SUBROUTINE ftg_read_logical_3d(fieldname, field) CHARACTER(LEN=*) :: fieldname LOGICAL, INTENT(OUT), TARGET :: field(:,:,:) + LOGICAL :: registered_only IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN - CALL fs_read_field(serializer, savepoint, fieldname, field) + CALL ftg_get_field_metainfo(fieldname, 'ftg:registered_only', registered_only) + IF (.NOT. registered_only) THEN + CALL fs_read_field(serializer, savepoint, fieldname, field) + END IF END IF END SUBROUTINE ftg_read_logical_3d SUBROUTINE ftg_read_logical_4d(fieldname, field) CHARACTER(LEN=*) :: fieldname LOGICAL, INTENT(OUT), TARGET :: field(:,:,:,:) + LOGICAL :: registered_only IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN - CALL fs_read_field(serializer, savepoint, fieldname, field) + CALL ftg_get_field_metainfo(fieldname, 'ftg:registered_only', registered_only) + IF (.NOT. registered_only) THEN + CALL fs_read_field(serializer, savepoint, fieldname, field) + END IF END IF END SUBROUTINE ftg_read_logical_4d -!============================================================================= -!============================================================================= - SUBROUTINE ftg_read_bool_0d(fieldname, field) CHARACTER(LEN=*) :: fieldname LOGICAL(KIND=C_BOOL), INTENT(OUT), TARGET :: field + LOGICAL :: registered_only IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN - CALL fs_read_field(serializer, savepoint, fieldname, field) + CALL ftg_get_field_metainfo(fieldname, 'ftg:registered_only', registered_only) + IF (.NOT. registered_only) THEN + CALL fs_read_field(serializer, savepoint, fieldname, field) + END IF END IF END SUBROUTINE ftg_read_bool_0d SUBROUTINE ftg_read_bool_1d(fieldname, field) CHARACTER(LEN=*) :: fieldname LOGICAL(KIND=C_BOOL), INTENT(OUT), TARGET :: field(:) + LOGICAL :: registered_only IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN - CALL fs_read_field(serializer, savepoint, fieldname, field) + CALL ftg_get_field_metainfo(fieldname, 'ftg:registered_only', registered_only) + IF (.NOT. registered_only) THEN + CALL fs_read_field(serializer, savepoint, fieldname, field) + END IF END IF END SUBROUTINE ftg_read_bool_1d SUBROUTINE ftg_read_bool_2d(fieldname, field) CHARACTER(LEN=*) :: fieldname LOGICAL(KIND=C_BOOL), INTENT(OUT), TARGET :: field(:,:) + LOGICAL :: registered_only IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN - CALL fs_read_field(serializer, savepoint, fieldname, field) + CALL ftg_get_field_metainfo(fieldname, 'ftg:registered_only', registered_only) + IF (.NOT. registered_only) THEN + CALL fs_read_field(serializer, savepoint, fieldname, field) + END IF END IF END SUBROUTINE ftg_read_bool_2d SUBROUTINE ftg_read_bool_3d(fieldname, field) CHARACTER(LEN=*) :: fieldname LOGICAL(KIND=C_BOOL), INTENT(OUT), TARGET :: field(:,:,:) + LOGICAL :: registered_only IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN - CALL fs_read_field(serializer, savepoint, fieldname, field) + CALL ftg_get_field_metainfo(fieldname, 'ftg:registered_only', registered_only) + IF (.NOT. registered_only) THEN + CALL fs_read_field(serializer, savepoint, fieldname, field) + END IF END IF END SUBROUTINE ftg_read_bool_3d SUBROUTINE ftg_read_bool_4d(fieldname, field) CHARACTER(LEN=*) :: fieldname LOGICAL(KIND=C_BOOL), INTENT(OUT), TARGET :: field(:,:,:,:) + LOGICAL :: registered_only IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN - CALL fs_read_field(serializer, savepoint, fieldname, field) + CALL ftg_get_field_metainfo(fieldname, 'ftg:registered_only', registered_only) + IF (.NOT. registered_only) THEN + CALL fs_read_field(serializer, savepoint, fieldname, field) + END IF END IF END SUBROUTINE ftg_read_bool_4d -!============================================================================= -!============================================================================= - SUBROUTINE ftg_read_int_0d(fieldname, field) CHARACTER(LEN=*) :: fieldname INTEGER, INTENT(OUT), TARGET :: field + LOGICAL :: registered_only IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN - CALL fs_read_field(serializer, savepoint, fieldname, field) + CALL ftg_get_field_metainfo(fieldname, 'ftg:registered_only', registered_only) + IF (.NOT. registered_only) THEN + CALL fs_read_field(serializer, savepoint, fieldname, field) + END IF END IF END SUBROUTINE ftg_read_int_0d SUBROUTINE ftg_read_int_1d(fieldname, field) CHARACTER(LEN=*) :: fieldname INTEGER, INTENT(OUT), TARGET :: field(:) + LOGICAL :: registered_only IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN - CALL fs_read_field(serializer, savepoint, fieldname, field) + CALL ftg_get_field_metainfo(fieldname, 'ftg:registered_only', registered_only) + IF (.NOT. registered_only) THEN + CALL fs_read_field(serializer, savepoint, fieldname, field) + END IF END IF END SUBROUTINE ftg_read_int_1d SUBROUTINE ftg_read_int_2d(fieldname, field) CHARACTER(LEN=*) :: fieldname INTEGER, INTENT(OUT), TARGET :: field(:,:) + LOGICAL :: registered_only IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN - CALL fs_read_field(serializer, savepoint, fieldname, field) + CALL ftg_get_field_metainfo(fieldname, 'ftg:registered_only', registered_only) + IF (.NOT. registered_only) THEN + CALL fs_read_field(serializer, savepoint, fieldname, field) + END IF END IF END SUBROUTINE ftg_read_int_2d SUBROUTINE ftg_read_int_3d(fieldname, field) CHARACTER(LEN=*) :: fieldname INTEGER, INTENT(OUT), TARGET :: field(:,:,:) + LOGICAL :: registered_only IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN - CALL fs_read_field(serializer, savepoint, fieldname, field) + CALL ftg_get_field_metainfo(fieldname, 'ftg:registered_only', registered_only) + IF (.NOT. registered_only) THEN + CALL fs_read_field(serializer, savepoint, fieldname, field) + END IF END IF END SUBROUTINE ftg_read_int_3d SUBROUTINE ftg_read_int_4d(fieldname, field) CHARACTER(LEN=*) :: fieldname INTEGER, INTENT(OUT), TARGET :: field(:,:,:,:) + LOGICAL :: registered_only IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN - CALL fs_read_field(serializer, savepoint, fieldname, field) + CALL ftg_get_field_metainfo(fieldname, 'ftg:registered_only', registered_only) + IF (.NOT. registered_only) THEN + CALL fs_read_field(serializer, savepoint, fieldname, field) + END IF END IF END SUBROUTINE ftg_read_int_4d -!============================================================================= -!============================================================================= - SUBROUTINE ftg_read_long_0d(fieldname, field) CHARACTER(LEN=*) :: fieldname INTEGER(KIND=C_LONG), INTENT(OUT), TARGET :: field + LOGICAL :: registered_only IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN - CALL fs_read_field(serializer, savepoint, fieldname, field) + CALL ftg_get_field_metainfo(fieldname, 'ftg:registered_only', registered_only) + IF (.NOT. registered_only) THEN + CALL fs_read_field(serializer, savepoint, fieldname, field) + END IF END IF END SUBROUTINE ftg_read_long_0d SUBROUTINE ftg_read_long_1d(fieldname, field) CHARACTER(LEN=*) :: fieldname INTEGER(KIND=C_LONG), INTENT(OUT), TARGET :: field(:) + LOGICAL :: registered_only IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN - CALL fs_read_field(serializer, savepoint, fieldname, field) + CALL ftg_get_field_metainfo(fieldname, 'ftg:registered_only', registered_only) + IF (.NOT. registered_only) THEN + CALL fs_read_field(serializer, savepoint, fieldname, field) + END IF END IF END SUBROUTINE ftg_read_long_1d SUBROUTINE ftg_read_long_2d(fieldname, field) CHARACTER(LEN=*) :: fieldname INTEGER(KIND=C_LONG), INTENT(OUT), TARGET :: field(:,:) + LOGICAL :: registered_only IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN - CALL fs_read_field(serializer, savepoint, fieldname, field) + CALL ftg_get_field_metainfo(fieldname, 'ftg:registered_only', registered_only) + IF (.NOT. registered_only) THEN + CALL fs_read_field(serializer, savepoint, fieldname, field) + END IF END IF END SUBROUTINE ftg_read_long_2d SUBROUTINE ftg_read_long_3d(fieldname, field) CHARACTER(LEN=*) :: fieldname INTEGER(KIND=C_LONG), INTENT(OUT), TARGET :: field(:,:,:) + LOGICAL :: registered_only IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN - CALL fs_read_field(serializer, savepoint, fieldname, field) + CALL ftg_get_field_metainfo(fieldname, 'ftg:registered_only', registered_only) + IF (.NOT. registered_only) THEN + CALL fs_read_field(serializer, savepoint, fieldname, field) + END IF END IF END SUBROUTINE ftg_read_long_3d SUBROUTINE ftg_read_long_4d(fieldname, field) CHARACTER(LEN=*) :: fieldname INTEGER(KIND=C_LONG), INTENT(OUT), TARGET :: field(:,:,:,:) + LOGICAL :: registered_only IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN - CALL fs_read_field(serializer, savepoint, fieldname, field) + CALL ftg_get_field_metainfo(fieldname, 'ftg:registered_only', registered_only) + IF (.NOT. registered_only) THEN + CALL fs_read_field(serializer, savepoint, fieldname, field) + END IF END IF END SUBROUTINE ftg_read_long_4d -!============================================================================= -!============================================================================= - SUBROUTINE ftg_read_float_0d(fieldname, field) CHARACTER(LEN=*) :: fieldname REAL(KIND=C_FLOAT), INTENT(OUT), TARGET :: field + LOGICAL :: registered_only IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN - CALL fs_read_field(serializer, savepoint, fieldname, field) + CALL ftg_get_field_metainfo(fieldname, 'ftg:registered_only', registered_only) + IF (.NOT. registered_only) THEN + CALL fs_read_field(serializer, savepoint, fieldname, field) + END IF END IF END SUBROUTINE ftg_read_float_0d SUBROUTINE ftg_read_float_1d(fieldname, field) CHARACTER(LEN=*) :: fieldname REAL(KIND=C_FLOAT), INTENT(OUT), TARGET :: field(:) + LOGICAL :: registered_only IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN - CALL fs_read_field(serializer, savepoint, fieldname, field) + CALL ftg_get_field_metainfo(fieldname, 'ftg:registered_only', registered_only) + IF (.NOT. registered_only) THEN + CALL fs_read_field(serializer, savepoint, fieldname, field) + END IF END IF END SUBROUTINE ftg_read_float_1d SUBROUTINE ftg_read_float_2d(fieldname, field) CHARACTER(LEN=*) :: fieldname REAL(KIND=C_FLOAT), INTENT(OUT), TARGET :: field(:,:) + LOGICAL :: registered_only IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN - CALL fs_read_field(serializer, savepoint, fieldname, field) + CALL ftg_get_field_metainfo(fieldname, 'ftg:registered_only', registered_only) + IF (.NOT. registered_only) THEN + CALL fs_read_field(serializer, savepoint, fieldname, field) + END IF END IF END SUBROUTINE ftg_read_float_2d SUBROUTINE ftg_read_float_3d(fieldname, field) CHARACTER(LEN=*) :: fieldname REAL(KIND=C_FLOAT), INTENT(OUT), TARGET :: field(:,:,:) + LOGICAL :: registered_only IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN - CALL fs_read_field(serializer, savepoint, fieldname, field) + CALL ftg_get_field_metainfo(fieldname, 'ftg:registered_only', registered_only) + IF (.NOT. registered_only) THEN + CALL fs_read_field(serializer, savepoint, fieldname, field) + END IF END IF END SUBROUTINE ftg_read_float_3d SUBROUTINE ftg_read_float_4d(fieldname, field) CHARACTER(LEN=*) :: fieldname REAL(KIND=C_FLOAT), INTENT(OUT), TARGET :: field(:,:,:,:) + LOGICAL :: registered_only IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN - CALL fs_read_field(serializer, savepoint, fieldname, field) + CALL ftg_get_field_metainfo(fieldname, 'ftg:registered_only', registered_only) + IF (.NOT. registered_only) THEN + CALL fs_read_field(serializer, savepoint, fieldname, field) + END IF END IF END SUBROUTINE ftg_read_float_4d -!============================================================================= -!============================================================================= - SUBROUTINE ftg_read_double_0d(fieldname, field) - CHARACTER(LEN=*) :: fieldname + CHARACTER(LEN=*) :: fieldname REAL(KIND=C_DOUBLE), INTENT(OUT), TARGET :: field + LOGICAL :: registered_only IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN - CALL fs_read_field(serializer, savepoint, fieldname, field) + CALL ftg_get_field_metainfo(fieldname, 'ftg:registered_only', registered_only) + IF (.NOT. registered_only) THEN + CALL fs_read_field(serializer, savepoint, fieldname, field) + END IF END IF END SUBROUTINE ftg_read_double_0d SUBROUTINE ftg_read_double_1d(fieldname, field) CHARACTER(LEN=*) :: fieldname REAL(KIND=C_DOUBLE), INTENT(OUT), TARGET :: field(:) + LOGICAL :: registered_only IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN - CALL fs_read_field(serializer, savepoint, fieldname, field) + CALL ftg_get_field_metainfo(fieldname, 'ftg:registered_only', registered_only) + IF (.NOT. registered_only) THEN + CALL fs_read_field(serializer, savepoint, fieldname, field) + END IF END IF END SUBROUTINE ftg_read_double_1d SUBROUTINE ftg_read_double_2d(fieldname, field) CHARACTER(LEN=*) :: fieldname REAL(KIND=C_DOUBLE), INTENT(OUT), TARGET :: field(:,:) + LOGICAL :: registered_only IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN - CALL fs_read_field(serializer, savepoint, fieldname, field) + CALL ftg_get_field_metainfo(fieldname, 'ftg:registered_only', registered_only) + IF (.NOT. registered_only) THEN + CALL fs_read_field(serializer, savepoint, fieldname, field) + END IF END IF END SUBROUTINE ftg_read_double_2d SUBROUTINE ftg_read_double_3d(fieldname, field) CHARACTER(LEN=*) :: fieldname REAL(KIND=C_DOUBLE), INTENT(OUT), TARGET :: field(:,:,:) + LOGICAL :: registered_only IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN - CALL fs_read_field(serializer, savepoint, fieldname, field) + CALL ftg_get_field_metainfo(fieldname, 'ftg:registered_only', registered_only) + IF (.NOT. registered_only) THEN + CALL fs_read_field(serializer, savepoint, fieldname, field) + END IF END IF END SUBROUTINE ftg_read_double_3d SUBROUTINE ftg_read_double_4d(fieldname, field) CHARACTER(LEN=*) :: fieldname REAL(KIND=C_DOUBLE), INTENT(OUT), TARGET :: field(:,:,:,:) + LOGICAL :: registered_only IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN - CALL fs_read_field(serializer, savepoint, fieldname, field) + CALL ftg_get_field_metainfo(fieldname, 'ftg:registered_only', registered_only) + IF (.NOT. registered_only) THEN + CALL fs_read_field(serializer, savepoint, fieldname, field) + END IF END IF END SUBROUTINE ftg_read_double_4d !============================================================================= !============================================================================= +SUBROUTINE ftg_allocate_pointer_logical_0d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + LOGICAL, INTENT(OUT), POINTER :: field + + INTEGER, DIMENSION(8) :: bounds + + IF (ftg_field_exists(fieldname)) THEN + bounds = ftg_get_bounds(fieldname) + ALLOCATE(field) + ELSE + NULLIFY(field) + END IF + +END SUBROUTINE ftg_allocate_pointer_logical_0d + SUBROUTINE ftg_allocate_pointer_logical_1d(fieldname, field) CHARACTER(LEN=*) :: fieldname LOGICAL, INTENT(OUT), POINTER :: field(:) @@ -1606,7 +2092,7 @@ SUBROUTINE ftg_allocate_pointer_logical_2d(fieldname, field) IF (ftg_field_exists(fieldname)) THEN bounds = ftg_get_bounds(fieldname) - ALLOCATE(field(bounds(1):bounds(2), bounds(3):bounds(4))) + ALLOCATE(field(bounds(1):bounds(2),bounds(3):bounds(4))) ELSE NULLIFY(field) END IF @@ -1621,14 +2107,13 @@ SUBROUTINE ftg_allocate_pointer_logical_3d(fieldname, field) IF (ftg_field_exists(fieldname)) THEN bounds = ftg_get_bounds(fieldname) - ALLOCATE(field(bounds(1):bounds(2), bounds(3):bounds(4), bounds(5):bounds(6))) + ALLOCATE(field(bounds(1):bounds(2),bounds(3):bounds(4),bounds(5):bounds(6))) ELSE NULLIFY(field) END IF END SUBROUTINE ftg_allocate_pointer_logical_3d - SUBROUTINE ftg_allocate_pointer_logical_4d(fieldname, field) CHARACTER(LEN=*) :: fieldname LOGICAL, INTENT(OUT), POINTER :: field(:,:,:,:) @@ -1637,15 +2122,27 @@ SUBROUTINE ftg_allocate_pointer_logical_4d(fieldname, field) IF (ftg_field_exists(fieldname)) THEN bounds = ftg_get_bounds(fieldname) - ALLOCATE(field(bounds(1):bounds(2), bounds(3):bounds(4), bounds(5):bounds(6), bounds(7):bounds(8))) + ALLOCATE(field(bounds(1):bounds(2),bounds(3):bounds(4),bounds(5):bounds(6),bounds(7):bounds(8))) ELSE NULLIFY(field) END IF END SUBROUTINE ftg_allocate_pointer_logical_4d -!============================================================================= -!============================================================================= +SUBROUTINE ftg_allocate_pointer_bool_0d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + LOGICAL(KIND=C_BOOL), INTENT(OUT), POINTER :: field + + INTEGER, DIMENSION(8) :: bounds + + IF (ftg_field_exists(fieldname)) THEN + bounds = ftg_get_bounds(fieldname) + ALLOCATE(field) + ELSE + NULLIFY(field) + END IF + +END SUBROUTINE ftg_allocate_pointer_bool_0d SUBROUTINE ftg_allocate_pointer_bool_1d(fieldname, field) CHARACTER(LEN=*) :: fieldname @@ -1670,7 +2167,7 @@ SUBROUTINE ftg_allocate_pointer_bool_2d(fieldname, field) IF (ftg_field_exists(fieldname)) THEN bounds = ftg_get_bounds(fieldname) - ALLOCATE(field(bounds(1):bounds(2), bounds(3):bounds(4))) + ALLOCATE(field(bounds(1):bounds(2),bounds(3):bounds(4))) ELSE NULLIFY(field) END IF @@ -1685,7 +2182,7 @@ SUBROUTINE ftg_allocate_pointer_bool_3d(fieldname, field) IF (ftg_field_exists(fieldname)) THEN bounds = ftg_get_bounds(fieldname) - ALLOCATE(field(bounds(1):bounds(2), bounds(3):bounds(4), bounds(5):bounds(6))) + ALLOCATE(field(bounds(1):bounds(2),bounds(3):bounds(4),bounds(5):bounds(6))) ELSE NULLIFY(field) END IF @@ -1700,15 +2197,27 @@ SUBROUTINE ftg_allocate_pointer_bool_4d(fieldname, field) IF (ftg_field_exists(fieldname)) THEN bounds = ftg_get_bounds(fieldname) - ALLOCATE(field(bounds(1):bounds(2), bounds(3):bounds(4), bounds(5):bounds(6), bounds(7):bounds(8))) + ALLOCATE(field(bounds(1):bounds(2),bounds(3):bounds(4),bounds(5):bounds(6),bounds(7):bounds(8))) ELSE NULLIFY(field) END IF END SUBROUTINE ftg_allocate_pointer_bool_4d -!============================================================================= -!============================================================================= +SUBROUTINE ftg_allocate_pointer_int_0d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + INTEGER, INTENT(OUT), POINTER :: field + + INTEGER, DIMENSION(8) :: bounds + + IF (ftg_field_exists(fieldname)) THEN + bounds = ftg_get_bounds(fieldname) + ALLOCATE(field) + ELSE + NULLIFY(field) + END IF + +END SUBROUTINE ftg_allocate_pointer_int_0d SUBROUTINE ftg_allocate_pointer_int_1d(fieldname, field) CHARACTER(LEN=*) :: fieldname @@ -1733,7 +2242,7 @@ SUBROUTINE ftg_allocate_pointer_int_2d(fieldname, field) IF (ftg_field_exists(fieldname)) THEN bounds = ftg_get_bounds(fieldname) - ALLOCATE(field(bounds(1):bounds(2), bounds(3):bounds(4))) + ALLOCATE(field(bounds(1):bounds(2),bounds(3):bounds(4))) ELSE NULLIFY(field) END IF @@ -1748,14 +2257,13 @@ SUBROUTINE ftg_allocate_pointer_int_3d(fieldname, field) IF (ftg_field_exists(fieldname)) THEN bounds = ftg_get_bounds(fieldname) - ALLOCATE(field(bounds(1):bounds(2), bounds(3):bounds(4), bounds(5):bounds(6))) + ALLOCATE(field(bounds(1):bounds(2),bounds(3):bounds(4),bounds(5):bounds(6))) ELSE NULLIFY(field) END IF END SUBROUTINE ftg_allocate_pointer_int_3d - SUBROUTINE ftg_allocate_pointer_int_4d(fieldname, field) CHARACTER(LEN=*) :: fieldname INTEGER, INTENT(OUT), POINTER :: field(:,:,:,:) @@ -1764,15 +2272,27 @@ SUBROUTINE ftg_allocate_pointer_int_4d(fieldname, field) IF (ftg_field_exists(fieldname)) THEN bounds = ftg_get_bounds(fieldname) - ALLOCATE(field(bounds(1):bounds(2), bounds(3):bounds(4), bounds(5):bounds(6), bounds(7):bounds(8))) + ALLOCATE(field(bounds(1):bounds(2),bounds(3):bounds(4),bounds(5):bounds(6),bounds(7):bounds(8))) ELSE NULLIFY(field) END IF END SUBROUTINE ftg_allocate_pointer_int_4d -!============================================================================= -!============================================================================= +SUBROUTINE ftg_allocate_pointer_long_0d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + INTEGER(KIND=C_LONG), INTENT(OUT), POINTER :: field + + INTEGER, DIMENSION(8) :: bounds + + IF (ftg_field_exists(fieldname)) THEN + bounds = ftg_get_bounds(fieldname) + ALLOCATE(field) + ELSE + NULLIFY(field) + END IF + +END SUBROUTINE ftg_allocate_pointer_long_0d SUBROUTINE ftg_allocate_pointer_long_1d(fieldname, field) CHARACTER(LEN=*) :: fieldname @@ -1797,7 +2317,7 @@ SUBROUTINE ftg_allocate_pointer_long_2d(fieldname, field) IF (ftg_field_exists(fieldname)) THEN bounds = ftg_get_bounds(fieldname) - ALLOCATE(field(bounds(1):bounds(2), bounds(3):bounds(4))) + ALLOCATE(field(bounds(1):bounds(2),bounds(3):bounds(4))) ELSE NULLIFY(field) END IF @@ -1812,7 +2332,7 @@ SUBROUTINE ftg_allocate_pointer_long_3d(fieldname, field) IF (ftg_field_exists(fieldname)) THEN bounds = ftg_get_bounds(fieldname) - ALLOCATE(field(bounds(1):bounds(2), bounds(3):bounds(4), bounds(5):bounds(6))) + ALLOCATE(field(bounds(1):bounds(2),bounds(3):bounds(4),bounds(5):bounds(6))) ELSE NULLIFY(field) END IF @@ -1827,15 +2347,27 @@ SUBROUTINE ftg_allocate_pointer_long_4d(fieldname, field) IF (ftg_field_exists(fieldname)) THEN bounds = ftg_get_bounds(fieldname) - ALLOCATE(field(bounds(1):bounds(2), bounds(3):bounds(4), bounds(5):bounds(6), bounds(7):bounds(8))) + ALLOCATE(field(bounds(1):bounds(2),bounds(3):bounds(4),bounds(5):bounds(6),bounds(7):bounds(8))) ELSE NULLIFY(field) END IF END SUBROUTINE ftg_allocate_pointer_long_4d -!============================================================================= -!============================================================================= +SUBROUTINE ftg_allocate_pointer_float_0d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + REAL(KIND=C_FLOAT), INTENT(OUT), POINTER :: field + + INTEGER, DIMENSION(8) :: bounds + + IF (ftg_field_exists(fieldname)) THEN + bounds = ftg_get_bounds(fieldname) + ALLOCATE(field) + ELSE + NULLIFY(field) + END IF + +END SUBROUTINE ftg_allocate_pointer_float_0d SUBROUTINE ftg_allocate_pointer_float_1d(fieldname, field) CHARACTER(LEN=*) :: fieldname @@ -1860,7 +2392,7 @@ SUBROUTINE ftg_allocate_pointer_float_2d(fieldname, field) IF (ftg_field_exists(fieldname)) THEN bounds = ftg_get_bounds(fieldname) - ALLOCATE(field(bounds(1):bounds(2), bounds(3):bounds(4))) + ALLOCATE(field(bounds(1):bounds(2),bounds(3):bounds(4))) ELSE NULLIFY(field) END IF @@ -1875,14 +2407,13 @@ SUBROUTINE ftg_allocate_pointer_float_3d(fieldname, field) IF (ftg_field_exists(fieldname)) THEN bounds = ftg_get_bounds(fieldname) - ALLOCATE(field(bounds(1):bounds(2), bounds(3):bounds(4), bounds(5):bounds(6))) + ALLOCATE(field(bounds(1):bounds(2),bounds(3):bounds(4),bounds(5):bounds(6))) ELSE NULLIFY(field) END IF END SUBROUTINE ftg_allocate_pointer_float_3d - SUBROUTINE ftg_allocate_pointer_float_4d(fieldname, field) CHARACTER(LEN=*) :: fieldname REAL(KIND=C_FLOAT), INTENT(OUT), POINTER :: field(:,:,:,:) @@ -1891,15 +2422,27 @@ SUBROUTINE ftg_allocate_pointer_float_4d(fieldname, field) IF (ftg_field_exists(fieldname)) THEN bounds = ftg_get_bounds(fieldname) - ALLOCATE(field(bounds(1):bounds(2), bounds(3):bounds(4), bounds(5):bounds(6), bounds(7):bounds(8))) + ALLOCATE(field(bounds(1):bounds(2),bounds(3):bounds(4),bounds(5):bounds(6),bounds(7):bounds(8))) ELSE NULLIFY(field) END IF END SUBROUTINE ftg_allocate_pointer_float_4d -!============================================================================= -!============================================================================= +SUBROUTINE ftg_allocate_pointer_double_0d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + REAL(KIND=C_DOUBLE), INTENT(OUT), POINTER :: field + + INTEGER, DIMENSION(8) :: bounds + + IF (ftg_field_exists(fieldname)) THEN + bounds = ftg_get_bounds(fieldname) + ALLOCATE(field) + ELSE + NULLIFY(field) + END IF + +END SUBROUTINE ftg_allocate_pointer_double_0d SUBROUTINE ftg_allocate_pointer_double_1d(fieldname, field) CHARACTER(LEN=*) :: fieldname @@ -1924,7 +2467,7 @@ SUBROUTINE ftg_allocate_pointer_double_2d(fieldname, field) IF (ftg_field_exists(fieldname)) THEN bounds = ftg_get_bounds(fieldname) - ALLOCATE(field(bounds(1):bounds(2), bounds(3):bounds(4))) + ALLOCATE(field(bounds(1):bounds(2),bounds(3):bounds(4))) ELSE NULLIFY(field) END IF @@ -1939,7 +2482,7 @@ SUBROUTINE ftg_allocate_pointer_double_3d(fieldname, field) IF (ftg_field_exists(fieldname)) THEN bounds = ftg_get_bounds(fieldname) - ALLOCATE(field(bounds(1):bounds(2), bounds(3):bounds(4), bounds(5):bounds(6))) + ALLOCATE(field(bounds(1):bounds(2),bounds(3):bounds(4),bounds(5):bounds(6))) ELSE NULLIFY(field) END IF @@ -1954,7 +2497,7 @@ SUBROUTINE ftg_allocate_pointer_double_4d(fieldname, field) IF (ftg_field_exists(fieldname)) THEN bounds = ftg_get_bounds(fieldname) - ALLOCATE(field(bounds(1):bounds(2), bounds(3):bounds(4), bounds(5):bounds(6), bounds(7):bounds(8))) + ALLOCATE(field(bounds(1):bounds(2),bounds(3):bounds(4),bounds(5):bounds(6),bounds(7):bounds(8))) ELSE NULLIFY(field) END IF @@ -1964,6 +2507,19 @@ END SUBROUTINE ftg_allocate_pointer_double_4d !============================================================================= !============================================================================= +SUBROUTINE ftg_allocate_allocatable_logical_0d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + LOGICAL, INTENT(OUT), ALLOCATABLE :: field + + INTEGER, DIMENSION(8) :: bounds + + IF (ftg_field_exists(fieldname)) THEN + bounds = ftg_get_bounds(fieldname) + ALLOCATE(field) + END IF + +END SUBROUTINE ftg_allocate_allocatable_logical_0d + SUBROUTINE ftg_allocate_allocatable_logical_1d(fieldname, field) CHARACTER(LEN=*) :: fieldname LOGICAL, INTENT(OUT), ALLOCATABLE :: field(:) @@ -1985,7 +2541,7 @@ SUBROUTINE ftg_allocate_allocatable_logical_2d(fieldname, field) IF (ftg_field_exists(fieldname)) THEN bounds = ftg_get_bounds(fieldname) - ALLOCATE(field(bounds(1):bounds(2), bounds(3):bounds(4))) + ALLOCATE(field(bounds(1):bounds(2),bounds(3):bounds(4))) END IF END SUBROUTINE ftg_allocate_allocatable_logical_2d @@ -1998,12 +2554,11 @@ SUBROUTINE ftg_allocate_allocatable_logical_3d(fieldname, field) IF (ftg_field_exists(fieldname)) THEN bounds = ftg_get_bounds(fieldname) - ALLOCATE(field(bounds(1):bounds(2), bounds(3):bounds(4), bounds(5):bounds(6))) + ALLOCATE(field(bounds(1):bounds(2),bounds(3):bounds(4),bounds(5):bounds(6))) END IF END SUBROUTINE ftg_allocate_allocatable_logical_3d - SUBROUTINE ftg_allocate_allocatable_logical_4d(fieldname, field) CHARACTER(LEN=*) :: fieldname LOGICAL, INTENT(OUT), ALLOCATABLE :: field(:,:,:,:) @@ -2012,13 +2567,23 @@ SUBROUTINE ftg_allocate_allocatable_logical_4d(fieldname, field) IF (ftg_field_exists(fieldname)) THEN bounds = ftg_get_bounds(fieldname) - ALLOCATE(field(bounds(1):bounds(2), bounds(3):bounds(4), bounds(5):bounds(6), bounds(7):bounds(8))) + ALLOCATE(field(bounds(1):bounds(2),bounds(3):bounds(4),bounds(5):bounds(6),bounds(7):bounds(8))) END IF END SUBROUTINE ftg_allocate_allocatable_logical_4d -!============================================================================= -!============================================================================= +SUBROUTINE ftg_allocate_allocatable_bool_0d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + LOGICAL(KIND=C_BOOL), INTENT(OUT), ALLOCATABLE :: field + + INTEGER, DIMENSION(8) :: bounds + + IF (ftg_field_exists(fieldname)) THEN + bounds = ftg_get_bounds(fieldname) + ALLOCATE(field) + END IF + +END SUBROUTINE ftg_allocate_allocatable_bool_0d SUBROUTINE ftg_allocate_allocatable_bool_1d(fieldname, field) CHARACTER(LEN=*) :: fieldname @@ -2041,7 +2606,7 @@ SUBROUTINE ftg_allocate_allocatable_bool_2d(fieldname, field) IF (ftg_field_exists(fieldname)) THEN bounds = ftg_get_bounds(fieldname) - ALLOCATE(field(bounds(1):bounds(2), bounds(3):bounds(4))) + ALLOCATE(field(bounds(1):bounds(2),bounds(3):bounds(4))) END IF END SUBROUTINE ftg_allocate_allocatable_bool_2d @@ -2054,7 +2619,7 @@ SUBROUTINE ftg_allocate_allocatable_bool_3d(fieldname, field) IF (ftg_field_exists(fieldname)) THEN bounds = ftg_get_bounds(fieldname) - ALLOCATE(field(bounds(1):bounds(2), bounds(3):bounds(4), bounds(5):bounds(6))) + ALLOCATE(field(bounds(1):bounds(2),bounds(3):bounds(4),bounds(5):bounds(6))) END IF END SUBROUTINE ftg_allocate_allocatable_bool_3d @@ -2067,28 +2632,38 @@ SUBROUTINE ftg_allocate_allocatable_bool_4d(fieldname, field) IF (ftg_field_exists(fieldname)) THEN bounds = ftg_get_bounds(fieldname) - ALLOCATE(field(bounds(1):bounds(2), bounds(3):bounds(4), bounds(5):bounds(6), bounds(7):bounds(8))) + ALLOCATE(field(bounds(1):bounds(2),bounds(3):bounds(4),bounds(5):bounds(6),bounds(7):bounds(8))) END IF END SUBROUTINE ftg_allocate_allocatable_bool_4d -!============================================================================= -!============================================================================= - -SUBROUTINE ftg_allocate_allocatable_int_1d(fieldname, field) +SUBROUTINE ftg_allocate_allocatable_int_0d(fieldname, field) CHARACTER(LEN=*) :: fieldname - INTEGER, INTENT(OUT), ALLOCATABLE :: field(:) + INTEGER, INTENT(OUT), ALLOCATABLE :: field INTEGER, DIMENSION(8) :: bounds IF (ftg_field_exists(fieldname)) THEN bounds = ftg_get_bounds(fieldname) - ALLOCATE(field(bounds(1):bounds(2))) + ALLOCATE(field) END IF -END SUBROUTINE ftg_allocate_allocatable_int_1d +END SUBROUTINE ftg_allocate_allocatable_int_0d -SUBROUTINE ftg_allocate_allocatable_int_2d(fieldname, field) +SUBROUTINE ftg_allocate_allocatable_int_1d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + INTEGER, INTENT(OUT), ALLOCATABLE :: field(:) + + INTEGER, DIMENSION(8) :: bounds + + IF (ftg_field_exists(fieldname)) THEN + bounds = ftg_get_bounds(fieldname) + ALLOCATE(field(bounds(1):bounds(2))) + END IF + +END SUBROUTINE ftg_allocate_allocatable_int_1d + +SUBROUTINE ftg_allocate_allocatable_int_2d(fieldname, field) CHARACTER(LEN=*) :: fieldname INTEGER, INTENT(OUT), ALLOCATABLE :: field(:,:) @@ -2096,7 +2671,7 @@ SUBROUTINE ftg_allocate_allocatable_int_2d(fieldname, field) IF (ftg_field_exists(fieldname)) THEN bounds = ftg_get_bounds(fieldname) - ALLOCATE(field(bounds(1):bounds(2), bounds(3):bounds(4))) + ALLOCATE(field(bounds(1):bounds(2),bounds(3):bounds(4))) END IF END SUBROUTINE ftg_allocate_allocatable_int_2d @@ -2109,12 +2684,11 @@ SUBROUTINE ftg_allocate_allocatable_int_3d(fieldname, field) IF (ftg_field_exists(fieldname)) THEN bounds = ftg_get_bounds(fieldname) - ALLOCATE(field(bounds(1):bounds(2), bounds(3):bounds(4), bounds(5):bounds(6))) + ALLOCATE(field(bounds(1):bounds(2),bounds(3):bounds(4),bounds(5):bounds(6))) END IF END SUBROUTINE ftg_allocate_allocatable_int_3d - SUBROUTINE ftg_allocate_allocatable_int_4d(fieldname, field) CHARACTER(LEN=*) :: fieldname INTEGER, INTENT(OUT), ALLOCATABLE :: field(:,:,:,:) @@ -2123,13 +2697,23 @@ SUBROUTINE ftg_allocate_allocatable_int_4d(fieldname, field) IF (ftg_field_exists(fieldname)) THEN bounds = ftg_get_bounds(fieldname) - ALLOCATE(field(bounds(1):bounds(2), bounds(3):bounds(4), bounds(5):bounds(6), bounds(7):bounds(8))) + ALLOCATE(field(bounds(1):bounds(2),bounds(3):bounds(4),bounds(5):bounds(6),bounds(7):bounds(8))) END IF END SUBROUTINE ftg_allocate_allocatable_int_4d -!============================================================================= -!============================================================================= +SUBROUTINE ftg_allocate_allocatable_long_0d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + INTEGER(KIND=C_LONG), INTENT(OUT), ALLOCATABLE :: field + + INTEGER, DIMENSION(8) :: bounds + + IF (ftg_field_exists(fieldname)) THEN + bounds = ftg_get_bounds(fieldname) + ALLOCATE(field) + END IF + +END SUBROUTINE ftg_allocate_allocatable_long_0d SUBROUTINE ftg_allocate_allocatable_long_1d(fieldname, field) CHARACTER(LEN=*) :: fieldname @@ -2152,7 +2736,7 @@ SUBROUTINE ftg_allocate_allocatable_long_2d(fieldname, field) IF (ftg_field_exists(fieldname)) THEN bounds = ftg_get_bounds(fieldname) - ALLOCATE(field(bounds(1):bounds(2), bounds(3):bounds(4))) + ALLOCATE(field(bounds(1):bounds(2),bounds(3):bounds(4))) END IF END SUBROUTINE ftg_allocate_allocatable_long_2d @@ -2165,7 +2749,7 @@ SUBROUTINE ftg_allocate_allocatable_long_3d(fieldname, field) IF (ftg_field_exists(fieldname)) THEN bounds = ftg_get_bounds(fieldname) - ALLOCATE(field(bounds(1):bounds(2), bounds(3):bounds(4), bounds(5):bounds(6))) + ALLOCATE(field(bounds(1):bounds(2),bounds(3):bounds(4),bounds(5):bounds(6))) END IF END SUBROUTINE ftg_allocate_allocatable_long_3d @@ -2178,13 +2762,23 @@ SUBROUTINE ftg_allocate_allocatable_long_4d(fieldname, field) IF (ftg_field_exists(fieldname)) THEN bounds = ftg_get_bounds(fieldname) - ALLOCATE(field(bounds(1):bounds(2), bounds(3):bounds(4), bounds(5):bounds(6), bounds(7):bounds(8))) + ALLOCATE(field(bounds(1):bounds(2),bounds(3):bounds(4),bounds(5):bounds(6),bounds(7):bounds(8))) END IF END SUBROUTINE ftg_allocate_allocatable_long_4d -!============================================================================= -!============================================================================= +SUBROUTINE ftg_allocate_allocatable_float_0d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + REAL(KIND=C_FLOAT), INTENT(OUT), ALLOCATABLE :: field + + INTEGER, DIMENSION(8) :: bounds + + IF (ftg_field_exists(fieldname)) THEN + bounds = ftg_get_bounds(fieldname) + ALLOCATE(field) + END IF + +END SUBROUTINE ftg_allocate_allocatable_float_0d SUBROUTINE ftg_allocate_allocatable_float_1d(fieldname, field) CHARACTER(LEN=*) :: fieldname @@ -2207,7 +2801,7 @@ SUBROUTINE ftg_allocate_allocatable_float_2d(fieldname, field) IF (ftg_field_exists(fieldname)) THEN bounds = ftg_get_bounds(fieldname) - ALLOCATE(field(bounds(1):bounds(2), bounds(3):bounds(4))) + ALLOCATE(field(bounds(1):bounds(2),bounds(3):bounds(4))) END IF END SUBROUTINE ftg_allocate_allocatable_float_2d @@ -2220,12 +2814,11 @@ SUBROUTINE ftg_allocate_allocatable_float_3d(fieldname, field) IF (ftg_field_exists(fieldname)) THEN bounds = ftg_get_bounds(fieldname) - ALLOCATE(field(bounds(1):bounds(2), bounds(3):bounds(4), bounds(5):bounds(6))) + ALLOCATE(field(bounds(1):bounds(2),bounds(3):bounds(4),bounds(5):bounds(6))) END IF END SUBROUTINE ftg_allocate_allocatable_float_3d - SUBROUTINE ftg_allocate_allocatable_float_4d(fieldname, field) CHARACTER(LEN=*) :: fieldname REAL(KIND=C_FLOAT), INTENT(OUT), ALLOCATABLE :: field(:,:,:,:) @@ -2234,13 +2827,23 @@ SUBROUTINE ftg_allocate_allocatable_float_4d(fieldname, field) IF (ftg_field_exists(fieldname)) THEN bounds = ftg_get_bounds(fieldname) - ALLOCATE(field(bounds(1):bounds(2), bounds(3):bounds(4), bounds(5):bounds(6), bounds(7):bounds(8))) + ALLOCATE(field(bounds(1):bounds(2),bounds(3):bounds(4),bounds(5):bounds(6),bounds(7):bounds(8))) END IF END SUBROUTINE ftg_allocate_allocatable_float_4d -!============================================================================= -!============================================================================= +SUBROUTINE ftg_allocate_allocatable_double_0d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + REAL(KIND=C_DOUBLE), INTENT(OUT), ALLOCATABLE :: field + + INTEGER, DIMENSION(8) :: bounds + + IF (ftg_field_exists(fieldname)) THEN + bounds = ftg_get_bounds(fieldname) + ALLOCATE(field) + END IF + +END SUBROUTINE ftg_allocate_allocatable_double_0d SUBROUTINE ftg_allocate_allocatable_double_1d(fieldname, field) CHARACTER(LEN=*) :: fieldname @@ -2263,7 +2866,7 @@ SUBROUTINE ftg_allocate_allocatable_double_2d(fieldname, field) IF (ftg_field_exists(fieldname)) THEN bounds = ftg_get_bounds(fieldname) - ALLOCATE(field(bounds(1):bounds(2), bounds(3):bounds(4))) + ALLOCATE(field(bounds(1):bounds(2),bounds(3):bounds(4))) END IF END SUBROUTINE ftg_allocate_allocatable_double_2d @@ -2276,7 +2879,7 @@ SUBROUTINE ftg_allocate_allocatable_double_3d(fieldname, field) IF (ftg_field_exists(fieldname)) THEN bounds = ftg_get_bounds(fieldname) - ALLOCATE(field(bounds(1):bounds(2), bounds(3):bounds(4), bounds(5):bounds(6))) + ALLOCATE(field(bounds(1):bounds(2),bounds(3):bounds(4),bounds(5):bounds(6))) END IF END SUBROUTINE ftg_allocate_allocatable_double_3d @@ -2289,7 +2892,7 @@ SUBROUTINE ftg_allocate_allocatable_double_4d(fieldname, field) IF (ftg_field_exists(fieldname)) THEN bounds = ftg_get_bounds(fieldname) - ALLOCATE(field(bounds(1):bounds(2), bounds(3):bounds(4), bounds(5):bounds(6), bounds(7):bounds(8))) + ALLOCATE(field(bounds(1):bounds(2),bounds(3):bounds(4),bounds(5):bounds(6),bounds(7):bounds(8))) END IF END SUBROUTINE ftg_allocate_allocatable_double_4d @@ -2297,4 +2900,787 @@ END SUBROUTINE ftg_allocate_allocatable_double_4d !============================================================================= !============================================================================= +SUBROUTINE ftg_allocate_and_read_pointer_logical_0d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + LOGICAL, INTENT(OUT), POINTER :: field + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ASSOCIATED(field)) THEN + CALL ftg_allocate_pointer(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_pointer_logical_0d + +SUBROUTINE ftg_allocate_and_read_pointer_logical_1d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + LOGICAL, INTENT(OUT), POINTER :: field(:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ASSOCIATED(field)) THEN + CALL ftg_allocate_pointer(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_pointer_logical_1d + +SUBROUTINE ftg_allocate_and_read_pointer_logical_2d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + LOGICAL, INTENT(OUT), POINTER :: field(:,:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ASSOCIATED(field)) THEN + CALL ftg_allocate_pointer(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_pointer_logical_2d + +SUBROUTINE ftg_allocate_and_read_pointer_logical_3d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + LOGICAL, INTENT(OUT), POINTER :: field(:,:,:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ASSOCIATED(field)) THEN + CALL ftg_allocate_pointer(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_pointer_logical_3d + +SUBROUTINE ftg_allocate_and_read_pointer_logical_4d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + LOGICAL, INTENT(OUT), POINTER :: field(:,:,:,:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ASSOCIATED(field)) THEN + CALL ftg_allocate_pointer(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_pointer_logical_4d + +SUBROUTINE ftg_allocate_and_read_pointer_bool_0d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + LOGICAL(KIND=C_BOOL), INTENT(OUT), POINTER :: field + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ASSOCIATED(field)) THEN + CALL ftg_allocate_pointer(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_pointer_bool_0d + +SUBROUTINE ftg_allocate_and_read_pointer_bool_1d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + LOGICAL(KIND=C_BOOL), INTENT(OUT), POINTER :: field(:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ASSOCIATED(field)) THEN + CALL ftg_allocate_pointer(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_pointer_bool_1d + +SUBROUTINE ftg_allocate_and_read_pointer_bool_2d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + LOGICAL(KIND=C_BOOL), INTENT(OUT), POINTER :: field(:,:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ASSOCIATED(field)) THEN + CALL ftg_allocate_pointer(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_pointer_bool_2d + +SUBROUTINE ftg_allocate_and_read_pointer_bool_3d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + LOGICAL(KIND=C_BOOL), INTENT(OUT), POINTER :: field(:,:,:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ASSOCIATED(field)) THEN + CALL ftg_allocate_pointer(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_pointer_bool_3d + +SUBROUTINE ftg_allocate_and_read_pointer_bool_4d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + LOGICAL(KIND=C_BOOL), INTENT(OUT), POINTER :: field(:,:,:,:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ASSOCIATED(field)) THEN + CALL ftg_allocate_pointer(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_pointer_bool_4d + +SUBROUTINE ftg_allocate_and_read_pointer_int_0d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + INTEGER, INTENT(OUT), POINTER :: field + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ASSOCIATED(field)) THEN + CALL ftg_allocate_pointer(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_pointer_int_0d + +SUBROUTINE ftg_allocate_and_read_pointer_int_1d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + INTEGER, INTENT(OUT), POINTER :: field(:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ASSOCIATED(field)) THEN + CALL ftg_allocate_pointer(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_pointer_int_1d + +SUBROUTINE ftg_allocate_and_read_pointer_int_2d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + INTEGER, INTENT(OUT), POINTER :: field(:,:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ASSOCIATED(field)) THEN + CALL ftg_allocate_pointer(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_pointer_int_2d + +SUBROUTINE ftg_allocate_and_read_pointer_int_3d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + INTEGER, INTENT(OUT), POINTER :: field(:,:,:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ASSOCIATED(field)) THEN + CALL ftg_allocate_pointer(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_pointer_int_3d + +SUBROUTINE ftg_allocate_and_read_pointer_int_4d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + INTEGER, INTENT(OUT), POINTER :: field(:,:,:,:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ASSOCIATED(field)) THEN + CALL ftg_allocate_pointer(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_pointer_int_4d + +SUBROUTINE ftg_allocate_and_read_pointer_long_0d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + INTEGER(KIND=C_LONG), INTENT(OUT), POINTER :: field + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ASSOCIATED(field)) THEN + CALL ftg_allocate_pointer(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_pointer_long_0d + +SUBROUTINE ftg_allocate_and_read_pointer_long_1d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + INTEGER(KIND=C_LONG), INTENT(OUT), POINTER :: field(:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ASSOCIATED(field)) THEN + CALL ftg_allocate_pointer(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_pointer_long_1d + +SUBROUTINE ftg_allocate_and_read_pointer_long_2d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + INTEGER(KIND=C_LONG), INTENT(OUT), POINTER :: field(:,:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ASSOCIATED(field)) THEN + CALL ftg_allocate_pointer(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_pointer_long_2d + +SUBROUTINE ftg_allocate_and_read_pointer_long_3d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + INTEGER(KIND=C_LONG), INTENT(OUT), POINTER :: field(:,:,:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ASSOCIATED(field)) THEN + CALL ftg_allocate_pointer(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_pointer_long_3d + +SUBROUTINE ftg_allocate_and_read_pointer_long_4d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + INTEGER(KIND=C_LONG), INTENT(OUT), POINTER :: field(:,:,:,:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ASSOCIATED(field)) THEN + CALL ftg_allocate_pointer(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_pointer_long_4d + +SUBROUTINE ftg_allocate_and_read_pointer_float_0d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + REAL(KIND=C_FLOAT), INTENT(OUT), POINTER :: field + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ASSOCIATED(field)) THEN + CALL ftg_allocate_pointer(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_pointer_float_0d + +SUBROUTINE ftg_allocate_and_read_pointer_float_1d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + REAL(KIND=C_FLOAT), INTENT(OUT), POINTER :: field(:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ASSOCIATED(field)) THEN + CALL ftg_allocate_pointer(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_pointer_float_1d + +SUBROUTINE ftg_allocate_and_read_pointer_float_2d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + REAL(KIND=C_FLOAT), INTENT(OUT), POINTER :: field(:,:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ASSOCIATED(field)) THEN + CALL ftg_allocate_pointer(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_pointer_float_2d + +SUBROUTINE ftg_allocate_and_read_pointer_float_3d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + REAL(KIND=C_FLOAT), INTENT(OUT), POINTER :: field(:,:,:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ASSOCIATED(field)) THEN + CALL ftg_allocate_pointer(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_pointer_float_3d + +SUBROUTINE ftg_allocate_and_read_pointer_float_4d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + REAL(KIND=C_FLOAT), INTENT(OUT), POINTER :: field(:,:,:,:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ASSOCIATED(field)) THEN + CALL ftg_allocate_pointer(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_pointer_float_4d + +SUBROUTINE ftg_allocate_and_read_pointer_double_0d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + REAL(KIND=C_DOUBLE), INTENT(OUT), POINTER :: field + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ASSOCIATED(field)) THEN + CALL ftg_allocate_pointer(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_pointer_double_0d + +SUBROUTINE ftg_allocate_and_read_pointer_double_1d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + REAL(KIND=C_DOUBLE), INTENT(OUT), POINTER :: field(:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ASSOCIATED(field)) THEN + CALL ftg_allocate_pointer(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_pointer_double_1d + +SUBROUTINE ftg_allocate_and_read_pointer_double_2d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + REAL(KIND=C_DOUBLE), INTENT(OUT), POINTER :: field(:,:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ASSOCIATED(field)) THEN + CALL ftg_allocate_pointer(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_pointer_double_2d + +SUBROUTINE ftg_allocate_and_read_pointer_double_3d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + REAL(KIND=C_DOUBLE), INTENT(OUT), POINTER :: field(:,:,:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ASSOCIATED(field)) THEN + CALL ftg_allocate_pointer(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_pointer_double_3d + +SUBROUTINE ftg_allocate_and_read_pointer_double_4d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + REAL(KIND=C_DOUBLE), INTENT(OUT), POINTER :: field(:,:,:,:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ASSOCIATED(field)) THEN + CALL ftg_allocate_pointer(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_pointer_double_4d + +!============================================================================= +!============================================================================= + +SUBROUTINE ftg_allocate_and_read_allocatable_logical_0d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + LOGICAL, INTENT(OUT), ALLOCATABLE, TARGET :: field + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ALLOCATED(field)) THEN + CALL ftg_allocate_allocatable(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_allocatable_logical_0d + +SUBROUTINE ftg_allocate_and_read_allocatable_logical_1d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + LOGICAL, INTENT(OUT), ALLOCATABLE, TARGET :: field(:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ALLOCATED(field)) THEN + CALL ftg_allocate_allocatable(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_allocatable_logical_1d + +SUBROUTINE ftg_allocate_and_read_allocatable_logical_2d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + LOGICAL, INTENT(OUT), ALLOCATABLE, TARGET :: field(:,:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ALLOCATED(field)) THEN + CALL ftg_allocate_allocatable(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_allocatable_logical_2d + +SUBROUTINE ftg_allocate_and_read_allocatable_logical_3d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + LOGICAL, INTENT(OUT), ALLOCATABLE, TARGET :: field(:,:,:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ALLOCATED(field)) THEN + CALL ftg_allocate_allocatable(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_allocatable_logical_3d + +SUBROUTINE ftg_allocate_and_read_allocatable_logical_4d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + LOGICAL, INTENT(OUT), ALLOCATABLE, TARGET :: field(:,:,:,:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ALLOCATED(field)) THEN + CALL ftg_allocate_allocatable(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_allocatable_logical_4d + +SUBROUTINE ftg_allocate_and_read_allocatable_bool_0d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + LOGICAL(KIND=C_BOOL), INTENT(OUT), ALLOCATABLE, TARGET :: field + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ALLOCATED(field)) THEN + CALL ftg_allocate_allocatable(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_allocatable_bool_0d + +SUBROUTINE ftg_allocate_and_read_allocatable_bool_1d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + LOGICAL(KIND=C_BOOL), INTENT(OUT), ALLOCATABLE, TARGET :: field(:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ALLOCATED(field)) THEN + CALL ftg_allocate_allocatable(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_allocatable_bool_1d + +SUBROUTINE ftg_allocate_and_read_allocatable_bool_2d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + LOGICAL(KIND=C_BOOL), INTENT(OUT), ALLOCATABLE, TARGET :: field(:,:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ALLOCATED(field)) THEN + CALL ftg_allocate_allocatable(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_allocatable_bool_2d + +SUBROUTINE ftg_allocate_and_read_allocatable_bool_3d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + LOGICAL(KIND=C_BOOL), INTENT(OUT), ALLOCATABLE, TARGET :: field(:,:,:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ALLOCATED(field)) THEN + CALL ftg_allocate_allocatable(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_allocatable_bool_3d + +SUBROUTINE ftg_allocate_and_read_allocatable_bool_4d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + LOGICAL(KIND=C_BOOL), INTENT(OUT), ALLOCATABLE, TARGET :: field(:,:,:,:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ALLOCATED(field)) THEN + CALL ftg_allocate_allocatable(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_allocatable_bool_4d + +SUBROUTINE ftg_allocate_and_read_allocatable_int_0d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + INTEGER, INTENT(OUT), ALLOCATABLE, TARGET :: field + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ALLOCATED(field)) THEN + CALL ftg_allocate_allocatable(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_allocatable_int_0d + +SUBROUTINE ftg_allocate_and_read_allocatable_int_1d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + INTEGER, INTENT(OUT), ALLOCATABLE, TARGET :: field(:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ALLOCATED(field)) THEN + CALL ftg_allocate_allocatable(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_allocatable_int_1d + +SUBROUTINE ftg_allocate_and_read_allocatable_int_2d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + INTEGER, INTENT(OUT), ALLOCATABLE, TARGET :: field(:,:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ALLOCATED(field)) THEN + CALL ftg_allocate_allocatable(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_allocatable_int_2d + +SUBROUTINE ftg_allocate_and_read_allocatable_int_3d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + INTEGER, INTENT(OUT), ALLOCATABLE, TARGET :: field(:,:,:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ALLOCATED(field)) THEN + CALL ftg_allocate_allocatable(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_allocatable_int_3d + +SUBROUTINE ftg_allocate_and_read_allocatable_int_4d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + INTEGER, INTENT(OUT), ALLOCATABLE, TARGET :: field(:,:,:,:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ALLOCATED(field)) THEN + CALL ftg_allocate_allocatable(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_allocatable_int_4d + +SUBROUTINE ftg_allocate_and_read_allocatable_long_0d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + INTEGER(KIND=C_LONG), INTENT(OUT), ALLOCATABLE, TARGET :: field + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ALLOCATED(field)) THEN + CALL ftg_allocate_allocatable(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_allocatable_long_0d + +SUBROUTINE ftg_allocate_and_read_allocatable_long_1d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + INTEGER(KIND=C_LONG), INTENT(OUT), ALLOCATABLE, TARGET :: field(:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ALLOCATED(field)) THEN + CALL ftg_allocate_allocatable(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_allocatable_long_1d + +SUBROUTINE ftg_allocate_and_read_allocatable_long_2d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + INTEGER(KIND=C_LONG), INTENT(OUT), ALLOCATABLE, TARGET :: field(:,:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ALLOCATED(field)) THEN + CALL ftg_allocate_allocatable(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_allocatable_long_2d + +SUBROUTINE ftg_allocate_and_read_allocatable_long_3d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + INTEGER(KIND=C_LONG), INTENT(OUT), ALLOCATABLE, TARGET :: field(:,:,:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ALLOCATED(field)) THEN + CALL ftg_allocate_allocatable(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_allocatable_long_3d + +SUBROUTINE ftg_allocate_and_read_allocatable_long_4d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + INTEGER(KIND=C_LONG), INTENT(OUT), ALLOCATABLE, TARGET :: field(:,:,:,:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ALLOCATED(field)) THEN + CALL ftg_allocate_allocatable(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_allocatable_long_4d + +SUBROUTINE ftg_allocate_and_read_allocatable_float_0d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + REAL(KIND=C_FLOAT), INTENT(OUT), ALLOCATABLE, TARGET :: field + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ALLOCATED(field)) THEN + CALL ftg_allocate_allocatable(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_allocatable_float_0d + +SUBROUTINE ftg_allocate_and_read_allocatable_float_1d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + REAL(KIND=C_FLOAT), INTENT(OUT), ALLOCATABLE, TARGET :: field(:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ALLOCATED(field)) THEN + CALL ftg_allocate_allocatable(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_allocatable_float_1d + +SUBROUTINE ftg_allocate_and_read_allocatable_float_2d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + REAL(KIND=C_FLOAT), INTENT(OUT), ALLOCATABLE, TARGET :: field(:,:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ALLOCATED(field)) THEN + CALL ftg_allocate_allocatable(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_allocatable_float_2d + +SUBROUTINE ftg_allocate_and_read_allocatable_float_3d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + REAL(KIND=C_FLOAT), INTENT(OUT), ALLOCATABLE, TARGET :: field(:,:,:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ALLOCATED(field)) THEN + CALL ftg_allocate_allocatable(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_allocatable_float_3d + +SUBROUTINE ftg_allocate_and_read_allocatable_float_4d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + REAL(KIND=C_FLOAT), INTENT(OUT), ALLOCATABLE, TARGET :: field(:,:,:,:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ALLOCATED(field)) THEN + CALL ftg_allocate_allocatable(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_allocatable_float_4d + +SUBROUTINE ftg_allocate_and_read_allocatable_double_0d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + REAL(KIND=C_DOUBLE), INTENT(OUT), ALLOCATABLE, TARGET :: field + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ALLOCATED(field)) THEN + CALL ftg_allocate_allocatable(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_allocatable_double_0d + +SUBROUTINE ftg_allocate_and_read_allocatable_double_1d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + REAL(KIND=C_DOUBLE), INTENT(OUT), ALLOCATABLE, TARGET :: field(:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ALLOCATED(field)) THEN + CALL ftg_allocate_allocatable(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_allocatable_double_1d + +SUBROUTINE ftg_allocate_and_read_allocatable_double_2d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + REAL(KIND=C_DOUBLE), INTENT(OUT), ALLOCATABLE, TARGET :: field(:,:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ALLOCATED(field)) THEN + CALL ftg_allocate_allocatable(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_allocatable_double_2d + +SUBROUTINE ftg_allocate_and_read_allocatable_double_3d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + REAL(KIND=C_DOUBLE), INTENT(OUT), ALLOCATABLE, TARGET :: field(:,:,:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ALLOCATED(field)) THEN + CALL ftg_allocate_allocatable(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_allocatable_double_3d + +SUBROUTINE ftg_allocate_and_read_allocatable_double_4d(fieldname, field) + CHARACTER(LEN=*) :: fieldname + REAL(KIND=C_DOUBLE), INTENT(OUT), ALLOCATABLE, TARGET :: field(:,:,:,:) + LOGICAL :: registered_only + + IF (.NOT. ignore_not_existing .OR. ftg_field_exists(fieldname)) THEN + IF (.NOT. ALLOCATED(field)) THEN + CALL ftg_allocate_allocatable(fieldname, field) + END IF + CALL ftg_read(fieldname, field) + END IF +END SUBROUTINE ftg_allocate_and_read_allocatable_double_4d + END MODULE m_ser_ftg diff --git a/src/serialbox-fortran/m_serialize.f90 b/src/serialbox-fortran/m_serialize.f90 index 942e95ca..2657dcac 100644 --- a/src/serialbox-fortran/m_serialize.f90 +++ b/src/serialbox-fortran/m_serialize.f90 @@ -44,8 +44,8 @@ MODULE m_serialize fs_create_savepoint, fs_destroy_savepoint, fs_add_savepoint_metainfo, fs_get_savepoint_metainfo, & fs_field_exists, fs_register_field, fs_add_field_metainfo, fs_get_field_metainfo, fs_write_field, fs_read_field, & fs_enable_serialization, fs_disable_serialization, fs_print_debuginfo, fs_read_and_perturb_field, & - fs_get_size, fs_get_halos, fs_get_rank, fs_get_total_size - + fs_get_size, fs_get_halos, fs_get_rank, fs_get_total_size, & + fs_boolsize, fs_intsize, fs_longsize, fs_floatsize, fs_doublesize INTEGER, PARAMETER :: MODE_READ = 0 INTEGER, PARAMETER :: MODE_WRITE = 1 INTEGER, PARAMETER :: MODE_APPEND = 2 diff --git a/test/serialbox-fortran/ser_ftg_test.pf b/test/serialbox-fortran/ser_ftg_test.pf index e63f1d1f..e1b0c9cf 100644 --- a/test/serialbox-fortran/ser_ftg_test.pf +++ b/test/serialbox-fortran/ser_ftg_test.pf @@ -514,171 +514,171 @@ CONTAINS CALL ftg_set_serializer(dir, base_name, 'r') - CALL ftg_allocate("logical1", p_logical1) + CALL ftg_allocate_pointer("logical1", p_logical1) @assertEqual((/ -1 /), LBOUND(p_logical1)) @assertEqual((/ 1 /), UBOUND(p_logical1)) - CALL ftg_allocate("logical1", a_logical1) + CALL ftg_allocate_allocatable("logical1", a_logical1) @assertEqual((/ -1 /), LBOUND(a_logical1)) @assertEqual((/ 1 /), UBOUND(a_logical1)) - CALL ftg_allocate("logical2", p_logical2) + CALL ftg_allocate_pointer("logical2", p_logical2) @assertEqual((/ -2, -3 /), LBOUND(p_logical2)) @assertEqual((/ 2, 3 /), UBOUND(p_logical2)) - CALL ftg_allocate("logical2", a_logical2) + CALL ftg_allocate_allocatable("logical2", a_logical2) @assertEqual((/ -2, -3 /), LBOUND(a_logical2)) @assertEqual((/ 2, 3 /), UBOUND(a_logical2)) - CALL ftg_allocate("logical3", p_logical3) + CALL ftg_allocate_pointer("logical3", p_logical3) @assertEqual((/ -4, -5, -6 /), LBOUND(p_logical3)) @assertEqual((/ 4, 5, 6 /), UBOUND(p_logical3)) - CALL ftg_allocate("logical3", a_logical3) + CALL ftg_allocate_allocatable("logical3", a_logical3) @assertEqual((/ -4, -5, -6 /), LBOUND(a_logical3)) @assertEqual((/ 4, 5, 6 /), UBOUND(a_logical3)) - CALL ftg_allocate("logical4", p_logical4) + CALL ftg_allocate_pointer("logical4", p_logical4) @assertEqual((/ 7, 23, -4, 0 /), LBOUND(p_logical4)) @assertEqual((/ 8, 42, -2, 16 /), UBOUND(p_logical4)) - CALL ftg_allocate("logical4", a_logical4) + CALL ftg_allocate_allocatable("logical4", a_logical4) @assertEqual((/ 7, 23, -4, 0 /), LBOUND(a_logical4)) @assertEqual((/ 8, 42, -2, 16 /), UBOUND(a_logical4)) - CALL ftg_allocate("boolean1", p_boolean1) + CALL ftg_allocate_pointer("boolean1", p_boolean1) @assertEqual((/ -1 /), LBOUND(p_boolean1)) @assertEqual((/ 2 /), UBOUND(p_boolean1)) - CALL ftg_allocate("boolean1", a_boolean1) + CALL ftg_allocate_allocatable("boolean1", a_boolean1) @assertEqual((/ -1 /), LBOUND(a_boolean1)) @assertEqual((/ 2 /), UBOUND(a_boolean1)) - CALL ftg_allocate("boolean2", p_boolean2) + CALL ftg_allocate_pointer("boolean2", p_boolean2) @assertEqual((/ -2, -3 /), LBOUND(p_boolean2)) @assertEqual((/ 2, 4 /), UBOUND(p_boolean2)) - CALL ftg_allocate("boolean2", a_boolean2) + CALL ftg_allocate_allocatable("boolean2", a_boolean2) @assertEqual((/ -2, -3 /), LBOUND(a_boolean2)) @assertEqual((/ 2, 4 /), UBOUND(a_boolean2)) - CALL ftg_allocate("boolean3", p_boolean3) + CALL ftg_allocate_pointer("boolean3", p_boolean3) @assertEqual((/ -4, -5, -6 /), LBOUND(p_boolean3)) @assertEqual((/ 4, 5, 7 /), UBOUND(p_boolean3)) - CALL ftg_allocate("boolean3", a_boolean3) + CALL ftg_allocate_allocatable("boolean3", a_boolean3) @assertEqual((/ -4, -5, -6 /), LBOUND(a_boolean3)) @assertEqual((/ 4, 5, 7 /), UBOUND(a_boolean3)) - CALL ftg_allocate("boolean4", p_boolean4) + CALL ftg_allocate_pointer("boolean4", p_boolean4) @assertEqual((/ 7, 23, -4, 0 /), LBOUND(p_boolean4)) @assertEqual((/ 8, 42, -2, 17 /), UBOUND(p_boolean4)) - CALL ftg_allocate("boolean4", a_boolean4) + CALL ftg_allocate_allocatable("boolean4", a_boolean4) @assertEqual((/ 7, 23, -4, 0 /), LBOUND(a_boolean4)) @assertEqual((/ 8, 42, -2, 17 /), UBOUND(a_boolean4)) - CALL ftg_allocate("integer1", p_integer1) + CALL ftg_allocate_pointer("integer1", p_integer1) @assertEqual((/ -1 /), LBOUND(p_integer1)) @assertEqual((/ 3 /), UBOUND(p_integer1)) - CALL ftg_allocate("integer1", a_integer1) + CALL ftg_allocate_allocatable("integer1", a_integer1) @assertEqual((/ -1 /), LBOUND(a_integer1)) @assertEqual((/ 3 /), UBOUND(a_integer1)) - CALL ftg_allocate("integer2", p_integer2) + CALL ftg_allocate_pointer("integer2", p_integer2) @assertEqual((/ -2, -3 /), LBOUND(p_integer2)) @assertEqual((/ 2, 5 /), UBOUND(p_integer2)) - CALL ftg_allocate("integer2", a_integer2) + CALL ftg_allocate_allocatable("integer2", a_integer2) @assertEqual((/ -2, -3 /), LBOUND(a_integer2)) @assertEqual((/ 2, 5 /), UBOUND(a_integer2)) - CALL ftg_allocate("integer3", p_integer3) + CALL ftg_allocate_pointer("integer3", p_integer3) @assertEqual((/ -4, -5, -6 /), LBOUND(p_integer3)) @assertEqual((/ 4, 5, 8 /), UBOUND(p_integer3)) - CALL ftg_allocate("integer3", a_integer3) + CALL ftg_allocate_allocatable("integer3", a_integer3) @assertEqual((/ -4, -5, -6 /), LBOUND(a_integer3)) @assertEqual((/ 4, 5, 8 /), UBOUND(a_integer3)) - CALL ftg_allocate("integer4", p_integer4) + CALL ftg_allocate_pointer("integer4", p_integer4) @assertEqual((/ 7, 23, -4, 0 /), LBOUND(p_integer4)) @assertEqual((/ 8, 42, -2, 18 /), UBOUND(p_integer4)) - CALL ftg_allocate("integer4", a_integer4) + CALL ftg_allocate_allocatable("integer4", a_integer4) @assertEqual((/ 7, 23, -4, 0 /), LBOUND(a_integer4)) @assertEqual((/ 8, 42, -2, 18 /), UBOUND(a_integer4)) - CALL ftg_allocate("longint1", p_longint1) + CALL ftg_allocate_pointer("longint1", p_longint1) @assertEqual((/ -1 /), LBOUND(p_longint1)) @assertEqual((/ 4 /), UBOUND(p_longint1)) - CALL ftg_allocate("longint1", a_longint1) + CALL ftg_allocate_allocatable("longint1", a_longint1) @assertEqual((/ -1 /), LBOUND(a_longint1)) @assertEqual((/ 4 /), UBOUND(a_longint1)) - CALL ftg_allocate("longint2", p_longint2) + CALL ftg_allocate_pointer("longint2", p_longint2) @assertEqual((/ -2, -3 /), LBOUND(p_longint2)) @assertEqual((/ 2, 6 /), UBOUND(p_longint2)) - CALL ftg_allocate("longint2", a_longint2) + CALL ftg_allocate_allocatable("longint2", a_longint2) @assertEqual((/ -2, -3 /), LBOUND(a_longint2)) @assertEqual((/ 2, 6 /), UBOUND(a_longint2)) - CALL ftg_allocate("longint3", p_longint3) + CALL ftg_allocate_pointer("longint3", p_longint3) @assertEqual((/ -4, -5, -6 /), LBOUND(p_longint3)) @assertEqual((/ 4, 5, 9 /), UBOUND(p_longint3)) - CALL ftg_allocate("longint3", a_longint3) + CALL ftg_allocate_allocatable("longint3", a_longint3) @assertEqual((/ -4, -5, -6 /), LBOUND(a_longint3)) @assertEqual((/ 4, 5, 9 /), UBOUND(a_longint3)) - CALL ftg_allocate("longint4", p_longint4) + CALL ftg_allocate_pointer("longint4", p_longint4) @assertEqual((/ 7, 23, -4, 0 /), LBOUND(p_longint4)) @assertEqual((/ 8, 42, -2, 19 /), UBOUND(p_longint4)) - CALL ftg_allocate("longint4", a_longint4) + CALL ftg_allocate_allocatable("longint4", a_longint4) @assertEqual((/ 7, 23, -4, 0 /), LBOUND(a_longint4)) @assertEqual((/ 8, 42, -2, 19 /), UBOUND(a_longint4)) - CALL ftg_allocate("float1", p_float1) + CALL ftg_allocate_pointer("float1", p_float1) @assertEqual((/ -1 /), LBOUND(p_float1)) @assertEqual((/ 5 /), UBOUND(p_float1)) - CALL ftg_allocate("float1", a_float1) + CALL ftg_allocate_allocatable("float1", a_float1) @assertEqual((/ -1 /), LBOUND(a_float1)) @assertEqual((/ 5 /), UBOUND(a_float1)) - CALL ftg_allocate("float2", p_float2) + CALL ftg_allocate_pointer("float2", p_float2) @assertEqual((/ -2, -3 /), LBOUND(p_float2)) @assertEqual((/ 2, 7 /), UBOUND(p_float2)) - CALL ftg_allocate("float2", a_float2) + CALL ftg_allocate_allocatable("float2", a_float2) @assertEqual((/ -2, -3 /), LBOUND(a_float2)) @assertEqual((/ 2, 7 /), UBOUND(a_float2)) - CALL ftg_allocate("float3", p_float3) + CALL ftg_allocate_pointer("float3", p_float3) @assertEqual((/ -4, -5, -6 /), LBOUND(p_float3)) @assertEqual((/ 4, 5, 10 /), UBOUND(p_float3)) - CALL ftg_allocate("float3", a_float3) + CALL ftg_allocate_allocatable("float3", a_float3) @assertEqual((/ -4, -5, -6 /), LBOUND(a_float3)) @assertEqual((/ 4, 5, 10 /), UBOUND(a_float3)) - CALL ftg_allocate("float4", p_float4) + CALL ftg_allocate_pointer("float4", p_float4) @assertEqual((/ 7, 23, -4, 0 /), LBOUND(p_float4)) @assertEqual((/ 8, 42, -2, 20 /), UBOUND(p_float4)) - CALL ftg_allocate("float4", a_float4) + CALL ftg_allocate_allocatable("float4", a_float4) @assertEqual((/ 7, 23, -4, 0 /), LBOUND(a_float4)) @assertEqual((/ 8, 42, -2, 20 /), UBOUND(a_float4)) - CALL ftg_allocate("double1", p_double1) + CALL ftg_allocate_pointer("double1", p_double1) @assertEqual((/ -1 /), LBOUND(p_double1)) @assertEqual((/ 6 /), UBOUND(p_double1)) - CALL ftg_allocate("double1", a_double1) + CALL ftg_allocate_allocatable("double1", a_double1) @assertEqual((/ -1 /), LBOUND(a_double1)) @assertEqual((/ 6 /), UBOUND(a_double1)) - CALL ftg_allocate("double2", p_double2) + CALL ftg_allocate_pointer("double2", p_double2) @assertEqual((/ -2, -3 /), LBOUND(p_double2)) @assertEqual((/ 2, 8 /), UBOUND(p_double2)) - CALL ftg_allocate("double2", a_double2) + CALL ftg_allocate_allocatable("double2", a_double2) @assertEqual((/ -2, -3 /), LBOUND(a_double2)) @assertEqual((/ 2, 8 /), UBOUND(a_double2)) - CALL ftg_allocate("double3", p_double3) + CALL ftg_allocate_pointer("double3", p_double3) @assertEqual((/ -4, -5, -6 /), LBOUND(p_double3)) @assertEqual((/ 4, 5, 11 /), UBOUND(p_double3)) - CALL ftg_allocate("double3", a_double3) + CALL ftg_allocate_allocatable("double3", a_double3) @assertEqual((/ -4, -5, -6 /), LBOUND(a_double3)) @assertEqual((/ 4, 5, 11 /), UBOUND(a_double3)) - CALL ftg_allocate("double4", p_double4) + CALL ftg_allocate_pointer("double4", p_double4) @assertEqual((/ 7, 23, -4, 0 /), LBOUND(p_double4)) @assertEqual((/ 8, 42, -2, 21 /), UBOUND(p_double4)) - CALL ftg_allocate("double4", a_double4) + CALL ftg_allocate_allocatable("double4", a_double4) @assertEqual((/ 7, 23, -4, 0 /), LBOUND(a_double4)) @assertEqual((/ 8, 42, -2, 21 /), UBOUND(a_double4)) @@ -721,4 +721,328 @@ CONTAINS END SUBROUTINE testRegisterOnly +@Test + SUBROUTINE testZeroSize() + + CHARACTER(len=*), PARAMETER :: base_name = 'testZeroSize' + + LOGICAL(KIND=C_BOOL) :: bool1(0), bool2(2,0), bool3(2:4,3:6,1:0), bool4(2:4,3:6,4:8,5:0) + LOGICAL :: logical1(0), logical2(2,0), logical3(2:4,3:6,1:0), logical4(2:4,3:6,4:8,5:0) + INTEGER(KIND=C_INT) :: int1(0), int2(2,0), int3(2:4,3:6,1:0), int4(2:4,3:6,4:8,5:0) + INTEGER(KIND=C_LONG) :: long1(0), long2(2,0), long3(2:4,3:6,1:0), long4(2:4,3:6,4:8,5:0) + REAL(KIND=C_FLOAT) :: float1(0), float2(2,0), float3(2:4,3:6,1:0), float4(2:4,3:6,4:8,5:0) + REAL(KIND=C_DOUBLE) :: double1(0), double2(2,0), double3(2:4,3:6,1:0), double4(2:4,3:6,4:8,5:0) + + CALL ftg_set_serializer(dir, base_name, 'w') + CALL ftg_write("bool1", bool1, LBOUND(bool1), UBOUND(bool1)) + CALL ftg_write("bool2", bool2, LBOUND(bool2), UBOUND(bool2)) + CALL ftg_write("bool3", bool3, LBOUND(bool3), UBOUND(bool3)) + CALL ftg_write("bool4", bool4, LBOUND(bool4), UBOUND(bool4)) + CALL ftg_write("logical1", logical1, LBOUND(logical1), UBOUND(logical1)) + CALL ftg_write("logical2", logical2, LBOUND(logical2), UBOUND(logical2)) + CALL ftg_write("logical3", logical3, LBOUND(logical3), UBOUND(logical3)) + CALL ftg_write("logical4", logical4, LBOUND(logical4), UBOUND(logical4)) + CALL ftg_write("int1", int1, LBOUND(int1), UBOUND(int1)) + CALL ftg_write("int2", int2, LBOUND(int2), UBOUND(int2)) + CALL ftg_write("int3", int3, LBOUND(int3), UBOUND(int3)) + CALL ftg_write("int4", int4, LBOUND(int4), UBOUND(int4)) + CALL ftg_write("long1", long1, LBOUND(long1), UBOUND(long1)) + CALL ftg_write("long2", long2, LBOUND(long2), UBOUND(long2)) + CALL ftg_write("long3", long3, LBOUND(long3), UBOUND(long3)) + CALL ftg_write("long4", long4, LBOUND(long4), UBOUND(long4)) + CALL ftg_write("float1", float1, LBOUND(float1), UBOUND(float1)) + CALL ftg_write("float2", float2, LBOUND(float2), UBOUND(float2)) + CALL ftg_write("float3", float3, LBOUND(float3), UBOUND(float3)) + CALL ftg_write("float4", float4, LBOUND(float4), UBOUND(float4)) + CALL ftg_write("double1", double1, LBOUND(double1), UBOUND(double1)) + CALL ftg_write("double2", double2, LBOUND(double2), UBOUND(double2)) + CALL ftg_write("double3", double3, LBOUND(double3), UBOUND(double3)) + CALL ftg_write("double4", double4, LBOUND(double4), UBOUND(double4)) + CALL ftg_destroy_serializer() + + CALL ftg_set_serializer(dir, base_name, 'r') + + @assertTrue(ftg_field_exists("bool1")) + @assertTrue(ftg_field_exists("bool2")) + @assertTrue(ftg_field_exists("bool3")) + @assertTrue(ftg_field_exists("bool4")) + @assertTrue(ftg_field_exists("logical1")) + @assertTrue(ftg_field_exists("logical2")) + @assertTrue(ftg_field_exists("logical3")) + @assertTrue(ftg_field_exists("logical4")) + @assertTrue(ftg_field_exists("int1")) + @assertTrue(ftg_field_exists("int2")) + @assertTrue(ftg_field_exists("int3")) + @assertTrue(ftg_field_exists("int4")) + @assertTrue(ftg_field_exists("long1")) + @assertTrue(ftg_field_exists("long2")) + @assertTrue(ftg_field_exists("long3")) + @assertTrue(ftg_field_exists("long4")) + @assertTrue(ftg_field_exists("float1")) + @assertTrue(ftg_field_exists("float2")) + @assertTrue(ftg_field_exists("float3")) + @assertTrue(ftg_field_exists("float4")) + @assertTrue(ftg_field_exists("double1")) + @assertTrue(ftg_field_exists("double2")) + @assertTrue(ftg_field_exists("double3")) + @assertTrue(ftg_field_exists("double4")) + + @assertEqual(exp_size(SHAPE(bool1)), fs_get_size(ftg_get_serializer(), "bool1")) + @assertEqual(exp_size(SHAPE(bool2)), fs_get_size(ftg_get_serializer(), "bool2")) + @assertEqual(exp_size(SHAPE(bool3)), fs_get_size(ftg_get_serializer(), "bool3")) + @assertEqual(exp_size(SHAPE(bool4)), fs_get_size(ftg_get_serializer(), "bool4")) + @assertEqual(exp_size(SHAPE(logical1)), fs_get_size(ftg_get_serializer(), "logical1")) + @assertEqual(exp_size(SHAPE(logical2)), fs_get_size(ftg_get_serializer(), "logical2")) + @assertEqual(exp_size(SHAPE(logical3)), fs_get_size(ftg_get_serializer(), "logical3")) + @assertEqual(exp_size(SHAPE(logical4)), fs_get_size(ftg_get_serializer(), "logical4")) + @assertEqual(exp_size(SHAPE(int1)), fs_get_size(ftg_get_serializer(), "int1")) + @assertEqual(exp_size(SHAPE(int2)), fs_get_size(ftg_get_serializer(), "int2")) + @assertEqual(exp_size(SHAPE(int3)), fs_get_size(ftg_get_serializer(), "int3")) + @assertEqual(exp_size(SHAPE(int4)), fs_get_size(ftg_get_serializer(), "int4")) + @assertEqual(exp_size(SHAPE(long1)), fs_get_size(ftg_get_serializer(), "long1")) + @assertEqual(exp_size(SHAPE(long2)), fs_get_size(ftg_get_serializer(), "long2")) + @assertEqual(exp_size(SHAPE(long3)), fs_get_size(ftg_get_serializer(), "long3")) + @assertEqual(exp_size(SHAPE(long4)), fs_get_size(ftg_get_serializer(), "long4")) + @assertEqual(exp_size(SHAPE(float1)), fs_get_size(ftg_get_serializer(), "float1")) + @assertEqual(exp_size(SHAPE(float2)), fs_get_size(ftg_get_serializer(), "float2")) + @assertEqual(exp_size(SHAPE(float3)), fs_get_size(ftg_get_serializer(), "float3")) + @assertEqual(exp_size(SHAPE(float4)), fs_get_size(ftg_get_serializer(), "float4")) + @assertEqual(exp_size(SHAPE(double1)), fs_get_size(ftg_get_serializer(), "double1")) + @assertEqual(exp_size(SHAPE(double2)), fs_get_size(ftg_get_serializer(), "double2")) + @assertEqual(exp_size(SHAPE(double3)), fs_get_size(ftg_get_serializer(), "double3")) + @assertEqual(exp_size(SHAPE(double4)), fs_get_size(ftg_get_serializer(), "double4")) + + @assertEqual((/ 1, 0, 0, 0, 0, 0, 0, 0 /), ftg_get_bounds("bool1")) + @assertEqual((/ 1, 2, 1, 0, 0, 0, 0, 0 /), ftg_get_bounds("bool2")) + @assertEqual((/ 2, 4, 3, 6, 1, 0, 0, 0 /), ftg_get_bounds("bool3")) + @assertEqual((/ 2, 4, 3, 6, 4, 8, 1, 0 /), ftg_get_bounds("bool4")) + @assertEqual((/ 1, 0, 0, 0, 0, 0, 0, 0 /), ftg_get_bounds("logical1")) + @assertEqual((/ 1, 2, 1, 0, 0, 0, 0, 0 /), ftg_get_bounds("logical2")) + @assertEqual((/ 2, 4, 3, 6, 1, 0, 0, 0 /), ftg_get_bounds("logical3")) + @assertEqual((/ 2, 4, 3, 6, 4, 8, 1, 0 /), ftg_get_bounds("logical4")) + @assertEqual((/ 1, 0, 0, 0, 0, 0, 0, 0 /), ftg_get_bounds("int1")) + @assertEqual((/ 1, 2, 1, 0, 0, 0, 0, 0 /), ftg_get_bounds("int2")) + @assertEqual((/ 2, 4, 3, 6, 1, 0, 0, 0 /), ftg_get_bounds("int3")) + @assertEqual((/ 2, 4, 3, 6, 4, 8, 1, 0 /), ftg_get_bounds("int4")) + @assertEqual((/ 1, 0, 0, 0, 0, 0, 0, 0 /), ftg_get_bounds("long1")) + @assertEqual((/ 1, 2, 1, 0, 0, 0, 0, 0 /), ftg_get_bounds("long2")) + @assertEqual((/ 2, 4, 3, 6, 1, 0, 0, 0 /), ftg_get_bounds("long3")) + @assertEqual((/ 2, 4, 3, 6, 4, 8, 1, 0 /), ftg_get_bounds("long4")) + @assertEqual((/ 1, 0, 0, 0, 0, 0, 0, 0 /), ftg_get_bounds("float1")) + @assertEqual((/ 1, 2, 1, 0, 0, 0, 0, 0 /), ftg_get_bounds("float2")) + @assertEqual((/ 2, 4, 3, 6, 1, 0, 0, 0 /), ftg_get_bounds("float3")) + @assertEqual((/ 2, 4, 3, 6, 4, 8, 1, 0 /), ftg_get_bounds("float4")) + @assertEqual((/ 1, 0, 0, 0, 0, 0, 0, 0 /), ftg_get_bounds("double1")) + @assertEqual((/ 1, 2, 1, 0, 0, 0, 0, 0 /), ftg_get_bounds("double2")) + @assertEqual((/ 2, 4, 3, 6, 1, 0, 0, 0 /), ftg_get_bounds("double3")) + @assertEqual((/ 2, 4, 3, 6, 4, 8, 1, 0 /), ftg_get_bounds("double4")) + + CALL ftg_read("bool1", bool1) + CALL ftg_read("bool2", bool2) + CALL ftg_read("bool3", bool3) + CALL ftg_read("bool4", bool4) + CALL ftg_read("logical1", logical1) + CALL ftg_read("logical2", logical2) + CALL ftg_read("logical3", logical3) + CALL ftg_read("logical4", logical4) + CALL ftg_read("int1", int1) + CALL ftg_read("int2", int2) + CALL ftg_read("int3", int3) + CALL ftg_read("int4", int4) + CALL ftg_read("long1", long1) + CALL ftg_read("long2", long2) + CALL ftg_read("long3", long3) + CALL ftg_read("long4", long4) + CALL ftg_read("float1", float1) + CALL ftg_read("float2", float2) + CALL ftg_read("float3", float3) + CALL ftg_read("float4", float4) + CALL ftg_read("double1", double1) + CALL ftg_read("double2", double2) + CALL ftg_read("double3", double3) + CALL ftg_read("double4", double4) + + CALL ftg_destroy_serializer() + + END SUBROUTINE testZeroSize + +@Test + SUBROUTINE testAllocateAndRead() + + CHARACTER(len=*), PARAMETER :: base_name = 'testIntegerArrays' + + INTEGER :: w_testfield_i0, w_testfield_i1(5), w_testfield_i2(4,3), w_testfield_i3(3,2,2), w_testfield_i4(2,2,2,2) + INTEGER, POINTER :: rp_testfield_i0 => NULL(), rp_testfield_i1(:) => NULL(), rp_testfield_i2(:,:) => NULL(), & + rp_testfield_i3(:,:,:) => NULL(), rp_testfield_i4(:,:,:,:) => NULL() + INTEGER, ALLOCATABLE :: ra_testfield_i0, ra_testfield_i1(:), ra_testfield_i2(:,:), & + ra_testfield_i3(:,:,:), ra_testfield_i4(:,:,:,:) + + w_testfield_i0 = 42 + w_testfield_i1 = (/ 0, 1, 2, 3, 4 /) + w_testfield_i2 = RESHAPE((/ 0, 3, 2, 9, 1, 4, 7, 10, 2, 5, 8, 11 /), SHAPE(w_testfield_i2)) + w_testfield_i3 = RESHAPE((/ 0, 4, 8, 2, 6, 10, 1, 5, 9, 3, 7, 11 /), SHAPE(w_testfield_i3)) + w_testfield_i4 = RESHAPE((/ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 /), SHAPE(w_testfield_i4)) + + CALL ftg_set_serializer(dir, base_name, 'w') + CALL ftg_write("testfield_i0", w_testfield_i0) + CALL ftg_write("testfield_i1", w_testfield_i1, LBOUND(w_testfield_i1), UBOUND(w_testfield_i1)) + CALL ftg_write("testfield_i2", w_testfield_i2, LBOUND(w_testfield_i2), UBOUND(w_testfield_i2)) + CALL ftg_write("testfield_i3", w_testfield_i3, LBOUND(w_testfield_i3), UBOUND(w_testfield_i3)) + CALL ftg_write("testfield_i4", w_testfield_i4, LBOUND(w_testfield_i4), UBOUND(w_testfield_i4)) + CALL ftg_destroy_serializer() + + CALL ftg_set_serializer(dir, base_name, 'r') + @assertTrue(ftg_field_exists("testfield_i0")) + @assertTrue(ftg_field_exists("testfield_i1")) + @assertTrue(ftg_field_exists("testfield_i2")) + @assertTrue(ftg_field_exists("testfield_i3")) + @assertTrue(ftg_field_exists("testfield_i4")) + @assertEqual(exp_size_scalar, fs_get_size(ftg_get_serializer(), "testfield_i0")) + @assertEqual(exp_size(SHAPE(w_testfield_i1)), fs_get_size(ftg_get_serializer(), "testfield_i1")) + @assertEqual(exp_size(SHAPE(w_testfield_i2)), fs_get_size(ftg_get_serializer(), "testfield_i2")) + @assertEqual(exp_size(SHAPE(w_testfield_i3)), fs_get_size(ftg_get_serializer(), "testfield_i3")) + @assertEqual(exp_size(SHAPE(w_testfield_i4)), fs_get_size(ftg_get_serializer(), "testfield_i4")) + CALL ftg_allocate_and_read_pointer("testfield_i0", rp_testfield_i0) + CALL ftg_allocate_and_read_pointer("testfield_i1", rp_testfield_i1) + CALL ftg_allocate_and_read_pointer("testfield_i2", rp_testfield_i2) + CALL ftg_allocate_and_read_pointer("testfield_i3", rp_testfield_i3) + CALL ftg_allocate_and_read_pointer("testfield_i4", rp_testfield_i4) + CALL ftg_allocate_and_read_allocatable("testfield_i0", ra_testfield_i0) + CALL ftg_allocate_and_read_allocatable("testfield_i1", ra_testfield_i1) + CALL ftg_allocate_and_read_allocatable("testfield_i2", ra_testfield_i2) + CALL ftg_allocate_and_read_allocatable("testfield_i3", ra_testfield_i3) + CALL ftg_allocate_and_read_allocatable("testfield_i4", ra_testfield_i4) + CALL ftg_destroy_serializer() + + @assertEqual(w_testfield_i0, rp_testfield_i0) + @assertEqual(w_testfield_i1, rp_testfield_i1) + @assertEqual(w_testfield_i2, rp_testfield_i2) + @assertEqual(w_testfield_i3, rp_testfield_i3) + @assertEqual(w_testfield_i4, rp_testfield_i4) + @assertEqual(w_testfield_i0, ra_testfield_i0) + @assertEqual(w_testfield_i1, ra_testfield_i1) + @assertEqual(w_testfield_i2, ra_testfield_i2) + @assertEqual(w_testfield_i3, ra_testfield_i3) + @assertEqual(w_testfield_i4, ra_testfield_i4) + + END SUBROUTINE testAllocateAndRead + + +@Test + SUBROUTINE testGlobalMetainfo() + + CHARACTER(len=*), PARAMETER :: base_name = 'testGlobalMetainfo' + + LOGICAL :: metalog + INTEGER(KIND=C_INT) :: metaint + INTEGER(KIND=C_LONG) :: metalong + REAL(KIND=C_FLOAT) :: metafloat + REAL(KIND=C_DOUBLE) :: metadouble + + CALL ftg_set_serializer(dir, base_name, 'w') + CALL ftg_add_serializer_metainfo('ser-metalog-t', .TRUE.) + CALL ftg_add_serializer_metainfo('ser-metalog-f', .FALSE.) + CALL ftg_add_serializer_metainfo('ser-metaint', 42) + CALL ftg_add_serializer_metainfo('ser-metalong', -109470000042_8) + CALL ftg_add_serializer_metainfo('ser-metafloat', 23.0_4) + CALL ftg_add_serializer_metainfo('ser-metadouble', 109.47_8) + CALL ftg_destroy_serializer() + + CALL ftg_set_serializer(dir, base_name, 'r') + CALL ftg_get_serializer_metainfo('ser-metalog-t', metalog) + @assertEqual(.TRUE., metalog) + CALL ftg_get_serializer_metainfo('ser-metalog-f', metalog) + @assertEqual(.FALSE., metalog) + CALL ftg_get_serializer_metainfo('ser-metaint', metaint) + @assertEqual(42, metaint) + CALL ftg_get_serializer_metainfo('ser-metalong', metalong) + @assertEqual(-109470000042_8, metalong) + CALL ftg_get_serializer_metainfo('ser-metafloat', metafloat) + @assertEqual(23.0_4, metafloat) + CALL ftg_get_serializer_metainfo('ser-metadouble', metadouble) + @assertEqual(109.47_8, metadouble) + CALL ftg_destroy_serializer() + + END SUBROUTINE testGlobalMetainfo + +@Test + SUBROUTINE testFieldMetainfo() + + TYPE(t_serializer) :: serializer + CHARACTER(len=*), PARAMETER :: base_name = 'test_field_metainfo' + INTEGER :: field(2,1,4) + CHARACTER(len=*), PARAMETER :: field_name = 'field' + + LOGICAL :: metalog + INTEGER(KIND=C_INT) :: metaint + INTEGER(KIND=C_LONG) :: metalong + REAL(KIND=C_FLOAT) :: metafloat + REAL(KIND=C_DOUBLE) :: metadouble + + field = RESHAPE((/ 0, 1, 2, 3, 4, 5, 6, 7 /), SHAPE(field)) + + CALL ftg_set_serializer(dir, base_name, 'w') + CALL ftg_write(field_name, field, LBOUND(field), UBOUND(field)) + CALL ftg_add_field_metainfo(field_name, 'field-metalog-t', .TRUE.) + CALL ftg_add_field_metainfo(field_name, 'field-metalog-f', .FALSE.) + CALL ftg_add_field_metainfo(field_name, 'field-metaint', 42) + CALL ftg_add_field_metainfo(field_name, 'field-metalong', -109470000042_8) + CALL ftg_add_field_metainfo(field_name, 'field-metafloat', 23.0_4) + CALL ftg_add_field_metainfo(field_name, 'field-metadouble', 109.47_8) + CALL ftg_destroy_serializer() + + CALL ftg_set_serializer(dir, base_name, 'r') + CALL ftg_get_field_metainfo(field_name, 'field-metalog-t', metalog) + @assertEqual(.TRUE., metalog) + CALL ftg_get_field_metainfo(field_name, 'field-metalog-f', metalog) + @assertEqual(.FALSE., metalog) + CALL ftg_get_field_metainfo(field_name, 'field-metaint', metaint) + @assertEqual(42, metaint) + CALL ftg_get_field_metainfo(field_name, 'field-metalong', metalong) + @assertEqual(-109470000042_8, metalong) + CALL ftg_get_field_metainfo(field_name, 'field-metafloat', metafloat) + @assertEqual(23.0_4, metafloat) + CALL ftg_get_field_metainfo(field_name, 'field-metadouble', metadouble) + @assertEqual(109.47_8, metadouble) + CALL ftg_destroy_serializer() + + END SUBROUTINE testFieldMetainfo + +@Test + SUBROUTINE testSavepointMetainfo() + + TYPE(t_savepoint) :: savepoint + CHARACTER(len=*), PARAMETER :: savepoint_name = 'test_savepoint_metainfo' + + LOGICAL :: metalog + INTEGER(KIND=C_INT) :: metaint + INTEGER(KIND=C_LONG) :: metalong + REAL(KIND=C_FLOAT) :: metafloat + REAL(KIND=C_DOUBLE) :: metadouble + + CALL ftg_set_savepoint(savepoint_name) + + CALL ftg_add_savepoint_metainfo('metalog-t', .TRUE.) + CALL ftg_add_savepoint_metainfo('metalog-f', .FALSE.) + CALL ftg_add_savepoint_metainfo('metaint', 42) + CALL ftg_add_savepoint_metainfo('metalong', -109470000042_8) + CALL ftg_add_savepoint_metainfo('metafloat', 23.0_4) + CALL ftg_add_savepoint_metainfo('metadouble', 109.47_8) + + CALL ftg_get_savepoint_metainfo('metalog-t', metalog) + @assertEqual(.TRUE., metalog) + CALL ftg_get_savepoint_metainfo('metalog-f', metalog) + @assertEqual(.FALSE., metalog) + CALL ftg_get_savepoint_metainfo('metaint', metaint) + @assertEqual(42, metaint) + CALL ftg_get_savepoint_metainfo('metalong', metalong) + @assertEqual(-109470000042_8, metalong) + CALL ftg_get_savepoint_metainfo('metafloat', metafloat) + @assertEqual(23.0_4, metafloat) + CALL ftg_get_savepoint_metainfo('metadouble', metadouble) + @assertEqual(109.47_8, metadouble) + + CALL ftg_destroy_savepoint() + + END SUBROUTINE testSavepointMetainfo END MODULE ser_ftg_test diff --git a/test/serialbox-fortran/serialbox_test.pf b/test/serialbox-fortran/serialbox_test.pf index a28279df..8404bcff 100644 --- a/test/serialbox-fortran/serialbox_test.pf +++ b/test/serialbox-fortran/serialbox_test.pf @@ -799,8 +799,6 @@ CONTAINS @assertEqual(109.47_8, metadouble) CALL fs_destroy_serializer(serializer) - CALL fs_destroy_serializer(serializer) - END SUBROUTINE testFieldMetainfo @Test