Skip to content

Commit

Permalink
Fixing starts/counts for pio puts
Browse files Browse the repository at this point in the history
The starts/counts for puts where the vars (1d/2d/3d) had no time
dimensions were wrong, i.e., always had an extra start/count
corresponding to the time dimension. Now we have the starts/counts
for time dimension only when the var is supposed to have
multiple timesteps
  • Loading branch information
jayeshkrishna committed Mar 6, 2019
1 parent 679a1c8 commit 09061d0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 26 deletions.
29 changes: 13 additions & 16 deletions components/clm/src/main/ncdio_pio.F90.in
Original file line number Diff line number Diff line change
Expand Up @@ -1317,37 +1317,34 @@ contains

call ncd_inqvid (ncid, varname, varid, vardesc)

if (present(nt)) then
#if ({DIMS}==0)
start(1) = 1 ; count(1) = 1
if (present(nt)) start(1) = nt ; count(1) = 1
temp(1) = data
status = pio_put_var(ncid, varid, start, count, temp)
start(1) = nt ; count(1) = 1
temp(1) = data
status = pio_put_var(ncid, varid, start, count, temp)
#elif ({DIMS}==1)
start(1) = 1 ; count(1) = size(data)
start(2) = 1 ; count(2) = 1
if (present(nt)) start(2) = nt
status = pio_put_var(ncid, varid, start, count, data)
start(1) = 1 ; count(1) = size(data)
start(2) = nt ; count(2) = 1
status = pio_put_var(ncid, varid, start, count, data)
#elif ({DIMS}==2)
start(1) = 1 ; count(1) = size(data, dim=1)
start(2) = 1 ; count(2) = size(data, dim=2)
start(3) = 1 ; count(3) = 1
if (present(nt)) start(3) = nt
status = pio_put_var(ncid, varid, start, count, data)
start(1) = 1 ; count(1) = size(data, dim=1)
start(2) = 1 ; count(2) = size(data, dim=2)
start(3) = nt ; count(3) = 1
status = pio_put_var(ncid, varid, start, count, data)
#elif ({DIMS}==3)
if (present(nt)) then
start(1) = 1 ; count(1) = size(data,dim=1)
start(2) = 1 ; count(2) = size(data,dim=2)
start(3) = 1 ; count(3) = size(data,dim=3)
start(4) = nt ; count(4) = 1
status = pio_put_var(ncid, varid, start, count, data)
#endif
else
status = pio_put_var(ncid, varid, data)
end if
#endif

endif

end subroutine ncd_io_{DIMS}d_{TYPE}_glob
end subroutine ncd_io_{DIMS}d_{TYPE}_glob

!------------------------------------------------------------------------
!DIMS 0,1,2
Expand Down
20 changes: 10 additions & 10 deletions components/mosart/src/riverroute/RtmIO.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1087,6 +1087,8 @@ subroutine ncd_io_int_var1_nf(varname, data, flag, ncid, readvar, nt)

elseif (flag == 'write') then

start = 0
count = 0
if (present(nt)) then
start(1) = 1
count(1) = size(data)
Expand All @@ -1095,8 +1097,6 @@ subroutine ncd_io_int_var1_nf(varname, data, flag, ncid, readvar, nt)
else
start(1) = 1
count(1) = size(data)
start(2) = 1
count(2) = 1
end if
call ncd_inqvid (ncid, varname, varid, vardesc)
status = pio_put_var(ncid, varid, start, count, data)
Expand Down Expand Up @@ -1148,6 +1148,8 @@ subroutine ncd_io_log_var1_nf(varname, data, flag, ncid, readvar, nt)

elseif (flag == 'write') then

start = 0
count = 0
if (present(nt)) then
start(1) = 1
count(1) = size(data)
Expand All @@ -1156,8 +1158,6 @@ subroutine ncd_io_log_var1_nf(varname, data, flag, ncid, readvar, nt)
else
start(1) = 1
count(1) = size(data)
start(2) = 1
count(2) = 1
end if
call ncd_inqvid (ncid, varname, varid, vardesc)
allocate( idata(size(data)) )
Expand Down Expand Up @@ -1209,16 +1209,16 @@ subroutine ncd_io_real_var1_nf(varname, data, flag, ncid, readvar, nt)

elseif (flag == 'write') then

start = 0
count = 0
if (present(nt)) then
start(1) = 1
start(2) = nt
count(1) = size(data)
count(2) = 1
else
start(1) = 1
start(2) = 1
count(1) = size(data)
count(2) = 1
end if
call ncd_inqvid (ncid, varname, varid, vardesc)
status = pio_put_var(ncid, varid, start, count, data)
Expand Down Expand Up @@ -1325,6 +1325,8 @@ subroutine ncd_io_int_var2_nf(varname, data, flag, ncid, readvar, nt)

elseif (flag == 'write') then

start = 0
count = 0
if (present(nt)) then
start(1) = 1
start(2) = 1
Expand All @@ -1335,10 +1337,8 @@ subroutine ncd_io_int_var2_nf(varname, data, flag, ncid, readvar, nt)
else
start(1) = 1
start(2) = 1
start(3) = 1
count(1) = size(data, dim=1)
count(2) = size(data, dim=2)
count(3) = 1
end if
call ncd_inqvid(ncid, varname, varid, vardesc)
status = pio_put_var(ncid, varid, start, count, data)
Expand Down Expand Up @@ -1384,6 +1384,8 @@ subroutine ncd_io_real_var2_nf(varname, data, flag, ncid, readvar, nt)

elseif (flag == 'write') then

start = 0
count = 0
if (present(nt)) then
start(1) = 1
start(2) = 1
Expand All @@ -1394,10 +1396,8 @@ subroutine ncd_io_real_var2_nf(varname, data, flag, ncid, readvar, nt)
else
start(1) = 1
start(2) = 1
start(3) = 1
count(1) = size(data, dim=1)
count(2) = size(data, dim=2)
count(3) = 1
end if
call ncd_inqvid (ncid, varname, varid, vardesc)
status = pio_put_var(ncid, varid, start, count, data)
Expand Down

0 comments on commit 09061d0

Please sign in to comment.