@@ -488,6 +488,7 @@ ${loop_variables_end(rank-1," "*12)}$
488488 call parse_norm_type(order,norm_request,err_)
489489 call lange_task_request(norm_request,lange_task,err_)
490490 if (err_%error()) then
491+ allocate(nrm${emptyranksuffix(rank-2)}$)
491492 call linalg_error_handling(err_,err)
492493 return
493494 endif
@@ -496,7 +497,7 @@ ${loop_variables_end(rank-1," "*12)}$
496497 s = shape(a,kind=ilp)
497498
498499 ! Check if input column data is contiguous
499- contiguous_data = dims(1)==1
500+ contiguous_data = all(dims==[1,2])
500501
501502 ! Matrix norm size
502503 m = s(dims(1))
@@ -505,20 +506,17 @@ ${loop_variables_end(rank-1," "*12)}$
505506 ! Get packed data with norm dimensions as 1:2
506507 if (contiguous_data) then
507508
508- ! Collapse everything before the 1st dimension as apack's dim #1
509- ! Set size==1 for all unused trailing dimensions
510- spack = [product(s(1:dims(2)-1)),s(dims(2):),(1_ilp,j=1,dims(2)-2)]
511-
512509 ! Reshape without moving data
513- apack${shape_from_array_data('spack',rank)}$ => a
510+ spack = s
511+ apack => a
514512
515513 else
516514
517515 ! Dimension permutations to map dims(1),dims(2) => 1:2
518516 perm = [dims,pack(dim_range, dim_range/=dims(1) .and. dim_range/=dims(2))]
519517 iperm(perm) = dim_range
520518 spack = s(perm)
521- apack = reshape(a, shape=spack, order=iperm)
519+ allocate( apack,source= reshape(a, shape=spack, order=iperm))
522520
523521 endif
524522
0 commit comments