Skip to content

READ 2d array #588

Closed
Closed
@tardini

Description

@tardini

In a json file I have a 2d array

    "myarr": [
	[2.240000e+04, 0.000000e+00],
	[1.250000e+02, 1.361000e+02]
  ],

the trailing comma is because I have other entries afterwards - and anyway my problem occurs at ccompilation time, NOT runtime, so it should not be a json-syntax problem.
I compile with ifort and I get the following error

error #8486: There is no matching specific subroutine for this type bound generic subroutine call.   [GET]
call config%get('myarr', myarr, found)

"config" is a perfectly valid json_file object, and reading all the 1D arrays works perfectly. "found" is a LOGICAL.
In my fortran code I declare
real, allocatable, dimension(:, :) :: myarr

I tried also double precision, same error. Is my Intel compiler too old? It reads 2023.1.0.x, it is quite new in fact. It's difficult for me to change the compiler because that's part of a larger code which takes advantage of the intel compiler features. ChatGPT is not helpful, stackoverflow neither. What am I doing wrong?

Note that if I declare
real, allocatable, dimension(:) :: myarr
the compilation error vanishes, but a simple
write(*, *) myarr(1)
gives a segmentation fault.

write(*, *) SHAPE(myarr)
outputs
0
If instead I declare
double precision, allocatable, dimension(:) :: myarr
then the SHAPE is 2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions