{"action":"closed","issue":{"url":"https://api.github.com/repos/NCAR/KGen/issues/2","repository_url":"https://api.github.com/repos/NCAR/KGen","labels_url":"https://api.github.com/repos/NCAR/KGen/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/NCAR/KGen/issues/2/comments","events_url":"https://api.github.com/repos/NCAR/KGen/issues/2/events","html_url":"https://github.com/NCAR/KGen/issues/2","id":123182111,"number":2,"title":"partial array allocation","user":{"login":"grnydawn","id":11076687,"avatar_url":"https://avatars.githubusercontent.com/u/11076687?v=3","gravatar_id":"","url":"https://api.github.com/users/grnydawn","html_url":"https://github.com/grnydawn","followers_url":"https://api.github.com/users/grnydawn/followers","following_url":"https://api.github.com/users/grnydawn/following{/other_user}","gists_url":"https://api.github.com/users/grnydawn/gists{/gist_id}","starred_url":"https://api.github.com/users/grnydawn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grnydawn/subscriptions","organizations_url":"https://api.github.com/users/grnydawn/orgs","repos_url":"https://api.github.com/users/grnydawn/repos","events_url":"https://api.github.com/users/grnydawn/events{/privacy}","received_events_url":"https://api.github.com/users/grnydawn/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/NCAR/KGen/labels/major","name":"major","color":"ededed"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-12-20T20:49:30Z","updated_at":"2016-04-01T16:29:51Z","closed_at":"2016-04-01T16:29:50Z","body":"_From @grnydawn on December 1, 2015 4:49_\n\nA kernel I am trying to generate with KGEN is crashing with a segfault when I run. It's happening in this bit of code:\r\n\r\nSUBROUTINE kgen_read_element_t_dim1(var, kgen_unit, printvar)\r\n   INTEGER, INTENT(IN) :: kgen_unit\r\n   CHARACTER(*), INTENT(IN), OPTIONAL :: printvar\r\n   TYPE(element_t), INTENT(OUT), ALLOCATABLE, DIMENSION(:) :: var\r\n   LOGICAL :: is_true\r\n   INTEGER :: idx1\r\n   INTEGER, DIMENSION(2,1) :: kgen_bound\r\n   READ(UNIT = kgen_unit) is_true\r\n   IF ( is_true ) THEN\r\n      READ(UNIT = kgen_unit) kgen_bound(1, 1)\r\n      READ(UNIT = kgen_unit) kgen_bound(2, 1)\r\n      ALLOCATE(var(kgen_bound(2, 1) - kgen_bound(1, 1) + 1))\r\n      DO idx1=kgen_bound(1,1), kgen_bound(2, 1)\r\n         IF ( PRESENT(printvar) ) THEN\r\n            CALL kgen_read_mod6(var(idx1), kgen_unit, printvar=printvar)\r\n         ELSE\r\n            CALL kgen_read_mod6(var(idx1), kgen_unit)\r\n         END IF\r\n      END DO\r\n   ELSE\r\n      IF ( PRESENT(printvar) ) THEN\r\n         PRINT *, \"** KGEN DEBUG: \" // printvar // \" ** is NOT present\"\r\n      END IF\r\n   END IF\r\nEND SUBROUTINE kgen_read_element_t_dim1\r\n\r\nIt looks like kgen_bound(1,1), and kgen_bound(2,1) both have value 6. So the allocation of var is:\r\n\r\nALLOCATE(var(1))\r\n\r\nbut then the loop is:\r\n\r\nDO idx1=6, 6\r\n   IF ( PRESENT(printvar) ) THEN\r\n      CALL kgen_read_mod6(var(idx1), kgen_unit, printvar=printvar)\r\n   ELSE\r\n      CALL kgen_read_mod6(var(idx1), kgen_unit)\r\n   END IF\r\nEND DO\r\n\r\nwhich is causing an out-of-bounds access to var(6). Do you know what is going wrong during the kernel generation? If you want to take a look, the kernel is at:\r\n\r\n/glade/u/home/rory/kgen_sf/kernel\n\n_Copied from original issue: NCAR-CISL-ASAP/KGen#121_"}}