Skip to content

Problem with zero sized arrays #148

@pmarguinaud

Description

@pmarguinaud

What happened?

A problem appeared between version 0.3.6 and version 0.3.7; the following piece of code :

ALLOCATE (ZDATA0 (10, 11, 0))

CALL FIELD_NEW (YLF, DATA=ZDATA0)

ZDATA => GET_HOST_DATA_RDWR (YLF)

PRINT *, " LBOUND (ZDATA0) = ", LBOUND (ZDATA0)
PRINT *, " UBOUND (ZDATA0) = ", UBOUND (ZDATA0)

PRINT *, " LBOUND (ZDATA) = ", LBOUND (ZDATA)
PRINT *, " UBOUND (ZDATA) = ", UBOUND (ZDATA)

IF (ANY (LBOUND (ZDATA0) /= LBOUND (ZDATA))) THEN
  STOP 1
ENDIF

IF (ANY (UBOUND (ZDATA0) /= UBOUND (ZDATA))) THEN
  STOP 1
ENDIF

works with 0.3.6 and fails with 0.3.7

This is illustrated in the following branches :

https://github.com/pmarguinaud/field_api/tree/v0.3.6-zerodim
https://github.com/pmarguinaud/field_api/tree/v0.3.7-zerodim

where a new test has been added.

The output of the new test case was (0.3.6):

  LBOUND (ZDATA0) =            1           1           1
  UBOUND (ZDATA0) =           10          11           0
  LBOUND (ZDATA) =            1           1           1
  UBOUND (ZDATA) =           10          11           0

and is now (0.3.7):

  LBOUND (ZDATA0) =            1           1           1
  UBOUND (ZDATA0) =           10          11           0
  LBOUND (ZDATA) =            1           1           1
  UBOUND (ZDATA) =            1           1           1

What are the steps to reproduce the bug?

The test case test_zerodim.F90 in :

https://github.com/pmarguinaud/field_api/tree/v0.3.6-zerodim
https://github.com/pmarguinaud/field_api/tree/v0.3.7-zerodim

reproduces the issue

Version

0.3.7

Platform (OS and architecture)

Linux belenoslogin2.belenoshpc.meteo.fr 3.10.0-1160.102.1.el7.x86_64 #1 SMP Mon Sep 25 05:00:52 EDT 2023 x86_64 x86_64 x86_64 GNU/Linux

Relevant log output

Accompanying data

No response

Organisation

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions