Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Fixed issue that was causing all varibles to be converted to Float64
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Sep 15, 2021
1 parent 20af4a1 commit 10f3616
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion python/swiftest/swiftest/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ def swiftest2xr(param):

elif ((param['OUT_TYPE'] == 'NETCDF_DOUBLE') or (param['OUT_TYPE'] == 'NETCDF_FLOAT')):
print('\nCreating Dataset')
ds = xr.open_dataset(param['BIN_OUT'], mask_and_scale=True)
ds = xr.open_dataset(param['BIN_OUT'], mask_and_scale=False)
ds = clean_string_values(param, ds)
else:
print(f"Error encountered. OUT_TYPE {param['OUT_TYPE']} not recognized.")
Expand Down
18 changes: 15 additions & 3 deletions src/netcdf/netcdf.f90
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ module subroutine netcdf_initialize_output(self, param)
! Internals
logical :: fileExists
integer(I4B) :: old_mode, nvar, varid, vartype
real(DP) :: nan
real(DP) :: dfill
real(SP) :: sfill

nan = ieee_value(nan, IEEE_QUIET_NAN)
dfill = ieee_value(dfill, IEEE_QUIET_NAN)
sfill = ieee_value(sfill, IEEE_QUIET_NAN)

!! Create the new output file, deleting any previously existing output file of the same name
call check( nf90_create(param%outfile, NF90_NETCDF4, self%ncid) )
Expand Down Expand Up @@ -144,7 +146,17 @@ module subroutine netcdf_initialize_output(self, param)
! Set fill mode to NaN for all variables
call check( nf90_inquire(self%ncid, nVariables=nvar) )
do varid = 1, nvar
call check( nf90_def_var_fill(self%ncid, varid, 0, nan) )
call check( nf90_inquire_variable(self%ncid, varid, xtype=vartype) )
select case(vartype)
case(NF90_INT)
call check( nf90_def_var_fill(self%ncid, varid, 0, NF90_FILL_INT) )
case(NF90_FLOAT)
call check( nf90_def_var_fill(self%ncid, varid, 0, sfill) )
case(NF90_DOUBLE)
call check( nf90_def_var_fill(self%ncid, varid, 0, dfill) )
case(NF90_CHAR)
call check( nf90_def_var_fill(self%ncid, varid, 0, 0) )
end select
end do

return
Expand Down

0 comments on commit 10f3616

Please sign in to comment.