11/*
2- * Copyright (c) 1995-2018 , NVIDIA CORPORATION. All rights reserved.
2+ * Copyright (c) 1995-2019 , NVIDIA CORPORATION. All rights reserved.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -1190,14 +1190,17 @@ ENTF90(PTR_SRC_ALLOC03A, ptr_src_alloc03a)(F90_Desc *sd, __INT_T *nelem,
11901190 src_len = ENTF90 (GET_OBJECT_SIZE , get_object_size )(sd );
11911191 if (sd && sd -> tag == __DESC && sd -> lsize > 1 )
11921192 src_len *= sd -> lsize ;
1193+ else if (nelem && * nelem > 1 ) {
1194+ src_len *= * nelem ;
1195+ }
11931196 max_len = (len && nelem ) ? (* len * * nelem ) : 0 ;
11941197 if (max_len < src_len )
11951198 max_len = src_len ;
11961199
11971200 if (ISPRESENT (stat ) && firsttime && * firsttime )
11981201 * stat = 0 ;
11991202
1200- (void )I8 (__alloc04 )(* nelem , (dtype )* kind , (size_t )max_len , stat , pointer ,
1203+ (void )I8 (__alloc04 )(1 , (dtype )* kind , (size_t )max_len , stat , pointer ,
12011204 offset , 0 , 0 , LOCAL_MODE ? __fort_malloc_without_abort
12021205 : __fort_gmalloc_without_abort ,
12031206 0 , CADR (errmsg ), CLEN (errmsg ));
@@ -1225,16 +1228,19 @@ ENTF90(PTR_SRC_CALLOC03A, ptr_src_calloc03a)(F90_Desc *sd, __INT_T *nelem,
12251228 __INT_T src_len , max_len ;
12261229
12271230 src_len = ENTF90 (GET_OBJECT_SIZE , get_object_size )(sd );
1228- if (sd && sd -> tag == __DESC && sd -> lsize > 1 )
1231+ if (sd && sd -> tag == __DESC && sd -> lsize > 1 ) {
12291232 src_len *= sd -> lsize ;
1233+ } else if (nelem && * nelem > 1 ) {
1234+ src_len *= * nelem ;
1235+ }
12301236 max_len = (len && nelem ) ? (* len * * nelem ) : 0 ;
12311237 if (max_len < src_len )
12321238 max_len = src_len ;
12331239
12341240 if (ISPRESENT (stat ) && firsttime && * firsttime )
12351241 * stat = 0 ;
12361242
1237- (void )I8 (__alloc04 )(* nelem , (dtype )* kind , (size_t )max_len , stat , pointer ,
1243+ (void )I8 (__alloc04 )(1 , (dtype )* kind , (size_t )max_len , stat , pointer ,
12381244 offset , 0 , 0 , LOCAL_MODE ? __fort_calloc_without_abort
12391245 : __fort_gcalloc_without_abort ,
12401246 0 , CADR (errmsg ), CLEN (errmsg ));
@@ -1264,14 +1270,17 @@ ENTF90(PTR_SRC_ALLOC04A, ptr_src_alloc04a)(F90_Desc *sd, __NELEM_T *nelem,
12641270 src_len = ENTF90 (GET_OBJECT_SIZE , get_object_size )(sd );
12651271 if (sd && sd -> tag == __DESC && sd -> lsize > 1 )
12661272 src_len *= sd -> lsize ;
1273+ else if (nelem && * nelem > 1 ) {
1274+ src_len *= * nelem ;
1275+ }
12671276 max_len = (len && nelem ) ? (* len * * nelem ) : 0 ;
12681277 if (max_len < src_len )
12691278 max_len = src_len ;
12701279
12711280 if (ISPRESENT (stat ) && firsttime && * firsttime )
12721281 * stat = 0 ;
12731282
1274- (void )I8 (__alloc04 )(* nelem , (dtype )* kind , (size_t )max_len , stat , pointer ,
1283+ (void )I8 (__alloc04 )(1 , (dtype )* kind , (size_t )max_len , stat , pointer ,
12751284 offset , 0 , 0 , LOCAL_MODE ? __fort_malloc_without_abort
12761285 : __fort_gmalloc_without_abort ,
12771286 * align , CADR (errmsg ), CLEN (errmsg ));
@@ -1309,6 +1318,8 @@ ENTF90(PTR_SRC_CALLOC04A, ptr_src_calloc04a)
13091318 sd -> kind > 0 && sd -> kind <= __NTYPES ) {
13101319 src_len = sd -> len ;
13111320 }
1321+ } else if (nelem && * nelem > 1 ) {
1322+ src_len *= * nelem ;
13121323 }
13131324 max_len = (len && nelem ) ? (* len * * nelem ) : 0 ;
13141325 if (max_len < src_len )
@@ -1317,7 +1328,7 @@ ENTF90(PTR_SRC_CALLOC04A, ptr_src_calloc04a)
13171328 if (ISPRESENT (stat ) && firsttime && * firsttime )
13181329 * stat = 0 ;
13191330
1320- (void )I8 (__alloc04 )(* nelem , (dtype )* kind , (size_t )max_len , stat , pointer ,
1331+ (void )I8 (__alloc04 )(1 , (dtype )* kind , (size_t )max_len , stat , pointer ,
13211332 offset , 0 , 0 , LOCAL_MODE ? __fort_calloc_without_abort
13221333 : __fort_gcalloc_without_abort ,
13231334 * align , CADR (errmsg ), CLEN (errmsg ));
0 commit comments