Skip to content

Commit 8a48414

Browse files
committed
enh: removed all realloc-lhs assignments
Signed-off-by: Nick Papior <[email protected]>
1 parent f69d27b commit 8a48414

File tree

5 files changed

+43
-41
lines changed

5 files changed

+43
-41
lines changed

src/ncdf.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ for v in ${vars[@]} ; do
8383
if [ $d -eq 0 ]; then
8484
_psnl "#define DIMS"
8585
else
86-
_psnl "#define DIMS , dimension$(dim_to_size $d)"
86+
_psnl "#define DIMS $(dim_to_size $d)"
8787
fi
8888
_psnl "#define VAR $v$d"
8989
_psnl "#define DIM $d"

src/netcdf_ncdf_att_inc.inc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
subroutine ROUTINE2(put_gatt,VAR)(this, name, att)
44
type(hNCDF), intent(inout) :: this
55
character(len=*), intent(in) :: name
6-
VAR_TYPE, intent(in)DIMS :: att
6+
VAR_TYPE, intent(in) :: att DIMS
77
if ( .not. ncdf_participate(this) ) return
88
if (this%define > -1 ) call ncdf_redef(this)
99
call ncdf_err(nf90_put_att(this%id, NF90_GLOBAL, name, att), &
@@ -13,7 +13,7 @@ end subroutine ROUTINE2(put_gatt,VAR)
1313
subroutine ROUTINE2(put_att,VAR)(this, var, name, att)
1414
type(hNCDF), intent(inout) :: this
1515
character(len=*), intent(in) :: var, name
16-
VAR_TYPE, intent(in)DIMS :: att
16+
VAR_TYPE, intent(in) :: att DIMS
1717
integer :: id
1818
if ( .not. ncdf_participate(this) ) return
1919
if (this%define > -1 ) call ncdf_redef(this)
@@ -26,7 +26,7 @@ end subroutine ROUTINE2(put_att,VAR)
2626
subroutine ROUTINE2(get_att,VAR)(this, var, name, att)
2727
type(hNCDF), intent(inout) :: this
2828
character(len=*), intent(in) :: var, name
29-
VAR_TYPE, intent(out)DIMS :: att
29+
VAR_TYPE, intent(out) :: att DIMS
3030
integer :: id
3131
if ( .not. ncdf_participate(this) ) return
3232
call ncdf_err(nf90_inq_varid(this%id, trim(var), id), &
@@ -38,7 +38,7 @@ end subroutine ROUTINE2(get_att,VAR)
3838
subroutine ROUTINE2(get_gatt,VAR)(this, name, att)
3939
type(hNCDF), intent(inout) :: this
4040
character(len=*), intent(in) :: name
41-
VAR_TYPE, intent(out)DIMS :: att
41+
VAR_TYPE, intent(out) :: att DIMS
4242
if ( .not. ncdf_participate(this) ) return
4343
call ncdf_err(nf90_get_att(this%id, NF90_GLOBAL, name, att), &
4444
'Saving global (VAR) attribute: '/ /trim(name)/ /' in file: '/ /this)

src/netcdf_ncdf_pp.F90

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ recursive subroutine ncdf_crt(this,dic)
436436
type(var) :: v
437437
character(len=DICT_KEY_LENGTH) :: key
438438
character(len=NF90_MAX_NAME) :: name, char
439-
character(len=50), allocatable :: dims(:)
439+
character(len=64), allocatable :: dims(:)
440440
integer, pointer :: chunks(:) => null()
441441
integer :: d_n, type, i, n_d, j
442442
! Type declarations
@@ -2016,34 +2016,36 @@ subroutine ncdf_print(this)
20162016
else if ( this%define == 1 ) then
20172017
write(*,"(a20,a)") "In define-mode: ","False"
20182018
end if
2019-
call ncdf_inq(this, dims=ndims, vars=nvars, atts=ngatts, &
2020-
grps=ngrps, format=file_format)
2021-
select case ( file_format )
2022-
case ( NF90_FORMAT_CLASSIC )
2023-
write(*,"(a20,a)") "File format: ","Classic"
2024-
case ( NF90_FORMAT_64BIT )
2025-
write(*,"(a20,a)") "File format: ","Classic 64Bit"
2026-
case ( NF90_FORMAT_NETCDF4 )
2027-
write(*,"(a20,a)") "File format: ","NetCDF4"
2028-
write(*,"(a20,i7)")"Default compression:",this%comp_lvl
2029-
case ( NF90_FORMAT_NETCDF4_CLASSIC )
2030-
write(*,"(a20,a)") "File format: ","NetCDF4 Classic format"
2031-
write(*,"(a22,i7)")"Default compression: ",this%comp_lvl
2032-
case default
2033-
write(*,"(a20,a)") "File format: ","Could not be determined"
2034-
end select
2035-
write(*,"(a20,i7)") "Number of dimensions: ",ndims
2036-
write(*,"(a20,i7)") "Number of variables: ",nvars
2037-
write(*,"(a20,i7)") "Number of attributes: ",ngatts
2038-
if ( ngrps >= 0 ) then
2039-
write(*,"(a20,i7)") "Number of groups: ",ngrps
2019+
if ( this%f_id >= 0 ) then
2020+
call ncdf_inq(this, dims=ndims, vars=nvars, atts=ngatts, &
2021+
grps=ngrps, format=file_format)
2022+
select case ( file_format )
2023+
case ( NF90_FORMAT_CLASSIC )
2024+
write(*,"(a20,a)") "File format: ","Classic"
2025+
case ( NF90_FORMAT_64BIT )
2026+
write(*,"(a20,a)") "File format: ","Classic 64Bit"
2027+
case ( NF90_FORMAT_NETCDF4 )
2028+
write(*,"(a20,a)") "File format: ","NetCDF4"
2029+
write(*,"(a20,i7)")"Default compression:",this%comp_lvl
2030+
case ( NF90_FORMAT_NETCDF4_CLASSIC )
2031+
write(*,"(a20,a)") "File format: ","NetCDF4 Classic format"
2032+
write(*,"(a22,i7)")"Default compression: ",this%comp_lvl
2033+
case default
2034+
write(*,"(a20,a)") "File format: ","Could not be determined"
2035+
end select
2036+
write(*,"(a20,i7)") "Number of dimensions: ",ndims
2037+
write(*,"(a20,i7)") "Number of variables: ",nvars
2038+
write(*,"(a20,i7)") "Number of attributes: ",ngatts
2039+
if ( ngrps >= 0 ) then
2040+
write(*,"(a20,i7)") "Number of groups: ",ngrps
2041+
end if
20402042
end if
2041-
if ( iand(NF90_WRITE,this%mode) == NF90_WRITE ) &
2042-
write(*,"(a20,a)") "NetCDF mode: ","NF90_WRITE"
2043-
if ( iand(NF90_NOCLOBBER,this%mode) == NF90_NOCLOBBER ) then
2044-
write(*,"(a20,a)") "NetCDF mode: ","NF90_NOCLOBBER"
2045-
else
2046-
write(*,"(a20,a)") "NetCDF mode: ","NF90_CLOBBER"
2043+
if ( iand(NF90_WRITE,this%mode) == NF90_WRITE ) &
2044+
write(*,"(a20,a)") "NetCDF mode: ","NF90_WRITE"
2045+
if ( iand(NF90_NOCLOBBER,this%mode) == NF90_NOCLOBBER ) then
2046+
write(*,"(a20,a)") "NetCDF mode: ","NF90_NOCLOBBER"
2047+
else
2048+
write(*,"(a20,a)") "NetCDF mode: ","NF90_CLOBBER"
20472049
end if
20482050
if ( iand(NF90_NOFILL,this%mode) == NF90_NOFILL ) &
20492051
write(*,"(a20,a)") "NetCDF mode: ","NF90_NOFILL"

src/netcdf_ncdf_var_inc.inc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
subroutine ROUTINE3(put_var,VAR,name)(this,name,var,start,count)
33
type(hNCDF), intent(inout) :: this
44
character(len=*), intent(in) :: name
5-
VAR_TYPE, intent(in)DIMS :: var
5+
VAR_TYPE, intent(in) :: var DIMS
66
integer, intent(in), optional :: start(:)
77
integer, intent(in), optional :: count(:)
88
integer :: id
99
#ifdef IS_COMPLEX
10-
REAL_TYPE, allocatable DIMS :: r
10+
REAL_TYPE, allocatable :: r DIMS
1111
#endif
1212

1313
#if DIM == 0
@@ -18,12 +18,12 @@ subroutine ROUTINE3(put_var,VAR,name)(this,name,var,start,count)
1818
if ( this%define > -1 ) call ncdf_enddef(this)
1919
#ifdef IS_COMPLEX
2020
ALLOC(r,var)
21-
r = real(var)
21+
r DIMS = real(var)
2222
call ncdf_inq_var(this,'Re'/ /name,id=id)
2323
call ncdf_err(nf90_put_var(this%id, id, r,start=start,count=count), &
2424
"Saving variable (VAR) Re"/ /trim(name)/ /' in file: '/ /this)
2525
call ncdf_inq_var(this,'Im'/ /name,id=id)
26-
r = aimag(var)
26+
r DIMS = aimag(var)
2727
call ncdf_err(nf90_put_var(this%id, id, r,start=start,count=count), &
2828
'Saving variable (VAR) Im'/ /trim(name)/ /' in file: '/ /this)
2929
deallocate(r)
@@ -39,14 +39,14 @@ end subroutine ROUTINE3(put_var,VAR,name)
3939
subroutine ROUTINE3(get_var,VAR,name)(this, name, var, start, count, stride)
4040
type(hNCDF), intent(inout) :: this
4141
character(len=*), intent(in) :: name
42-
VAR_TYPE, intent(out)DIMS :: var
42+
VAR_TYPE, intent(out) :: var DIMS
4343
integer, intent(in), optional :: start(:)
4444
integer, intent(in), optional :: count(:)
4545
integer, intent(in), optional :: stride(:)
4646
#if DIM > 0
4747
integer :: id
4848
#ifdef IS_COMPLEX
49-
REAL_TYPE, allocatable DIMS :: r,i
49+
REAL_TYPE, allocatable :: r DIMS , i DIMS
5050
#endif
5151
#endif
5252
#if DIM == 0
@@ -65,7 +65,7 @@ subroutine ROUTINE3(get_var,VAR,name)(this, name, var, start, count, stride)
6565
call ncdf_inq_var(this,'Im'/ /name,id=id)
6666
call ncdf_err(nf90_get_var(this%id, id, i,start=start,count=count,stride=stride), &
6767
'Retrieving variable (VAR) Im'/ /trim(name)/ /' in file: '/ /this)
68-
var = cmplx(r,i)
68+
var DIMS = cmplx(r,i)
6969
deallocate(r,i)
7070
#else
7171
call ncdf_inq_var(this,name,id=id)

0 commit comments

Comments
 (0)