~albertog/siesta/4.1-xc

« back to all changes in this revision

Viewing changes to Src/ncdf/src/netcdf_ncdf_var_inc.inc

  • Committer: Nick Papior
  • Date: 2018-12-06 14:20:30 UTC
  • Revision ID: nickpapior@gmail.com-20181206142030-m12ony85o87264aw
Updated fdict and ncdf to latest released versions

Now retrieving dcmplx also works as expected!

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
subroutine ROUTINE3(put_var,VAR,name)(this,name,var,start,count)
3
3
  type(hNCDF), intent(inout) :: this
4
4
  character(len=*), intent(in) :: name
5
 
  VAR_TYPE, intent(in)DIMS :: var
 
5
  VAR_TYPE, intent(in) :: var DIMS
6
6
  integer, intent(in), optional :: start(:)
7
7
  integer, intent(in), optional :: count(:)
8
8
  integer :: id
9
 
#ifdef IS_COMPLEX
10
 
  REAL_TYPE, allocatable DIMS :: r
 
9
#ifdef COMPLEX_DTYPE
 
10
  REAL_TYPE, allocatable :: r DIMS
11
11
#endif
12
12
 
13
13
#if DIM == 0
16
16
 
17
17
  if ( .not. ncdf_participate(this) ) return
18
18
  if ( this%define > -1 ) call ncdf_enddef(this)
19
 
#ifdef IS_COMPLEX
 
19
#ifdef COMPLEX_DTYPE
20
20
  ALLOC(r,var)
21
 
  r = real(var)
 
21
  r DIMS = real(var, COMPLEX_DTYPE)
22
22
  call ncdf_inq_var(this,'Re'/ /name,id=id)
23
23
  call ncdf_err(nf90_put_var(this%id, id, r,start=start,count=count), &
24
24
     "Saving variable (VAR) Re"/ /trim(name)/ /' in file: '/ /this)
25
25
  call ncdf_inq_var(this,'Im'/ /name,id=id)
26
 
  r = aimag(var)
 
26
  r DIMS = aimag(var)
27
27
  call ncdf_err(nf90_put_var(this%id, id, r,start=start,count=count), &
28
28
       'Saving variable (VAR) Im'/ /trim(name)/ /' in file: '/ /this)
29
29
  deallocate(r)
39
39
subroutine ROUTINE3(get_var,VAR,name)(this, name, var, start, count, stride)
40
40
  type(hNCDF), intent(inout) :: this
41
41
  character(len=*), intent(in) :: name
42
 
  VAR_TYPE, intent(out)DIMS :: var
 
42
  VAR_TYPE, intent(out) :: var DIMS
43
43
  integer, intent(in), optional :: start(:)
44
44
  integer, intent(in), optional :: count(:)
45
45
  integer, intent(in), optional :: stride(:)
46
46
#if DIM > 0 
47
47
  integer :: id
48
 
#ifdef IS_COMPLEX
49
 
  REAL_TYPE, allocatable DIMS :: r,i
 
48
#ifdef COMPLEX_DTYPE
 
49
  REAL_TYPE, allocatable :: r DIMS , i DIMS
50
50
#endif
51
51
#endif
52
52
#if DIM == 0
56
56
#else
57
57
  if ( .not. ncdf_participate(this) ) return
58
58
  if ( this%define > -1 ) call ncdf_enddef(this)
59
 
#ifdef IS_COMPLEX
 
59
#ifdef COMPLEX_DTYPE
60
60
  ALLOC(r,var)
61
61
  ALLOC(i,var)
62
62
  call ncdf_inq_var(this,'Re'/ /name,id=id)
65
65
  call ncdf_inq_var(this,'Im'/ /name,id=id)
66
66
  call ncdf_err(nf90_get_var(this%id, id, i,start=start,count=count,stride=stride), &
67
67
       'Retrieving variable (VAR) Im'/ /trim(name)/ /' in file: '/ /this)
68
 
  var = cmplx(r,i)
 
68
  var DIMS = cmplx(r,i, COMPLEX_DTYPE)
69
69
  deallocate(r,i)
70
70
#else
71
71
  call ncdf_inq_var(this,name,id=id)
89
89
  integer :: lfill
90
90
  VAR_TYPE :: lfill_val 
91
91
  integer :: tmp_lr
92
 
#ifdef IS_COMPLEX
 
92
#ifdef COMPLEX_DTYPE
93
93
  REAL_TYPE :: lr
94
94
  integer :: id(2)
95
95
#else
104
104
  if ( present(fill) ) lfill = fill
105
105
  lfill_val = fill_val
106
106
 
107
 
#ifdef IS_COMPLEX
108
 
  lr = real(lfill_val)
 
107
#ifdef COMPLEX_DTYPE
 
108
  lr = real(lfill_val, COMPLEX_DTYPE)
109
109
  call ncdf_err(nf90_def_var_fill(this%id, id(1), lfill, tmp_lr), &
110
110
       'Setting fill (VAR) Re'/ /trim(name)/ /' in file: '/ /this)
111
111
  lr = aimag(lfill_val)
123
123
  character(len=*), intent(in) :: name
124
124
  VAR_TYPE, intent(out) :: fill_val ! non-optional to allow interfacing
125
125
  logical, intent(out), optional  :: exist
126
 
#ifdef IS_COMPLEX
 
126
#ifdef COMPLEX_DTYPE
127
127
  integer, intent(out), optional  :: id(2)
128
128
#else
129
129
  integer, intent(out), optional  :: id
133
133
  integer, intent(out), optional :: fill
134
134
  integer :: lid, lfill
135
135
  integer :: tmp_lr
136
 
#ifdef IS_COMPLEX
 
136
#ifdef COMPLEX_DTYPE
137
137
  REAL_TYPE :: lfill_valr,lfill_valc
138
138
#else
139
139
  REAL_TYPE :: lfill_val
140
140
#endif
141
141
  if ( .not. ncdf_participate(this) ) return
142
 
#ifdef IS_COMPLEX
 
142
#ifdef COMPLEX_DTYPE
143
143
  call ncdf_inq_var_def(this,'Re'/ /name,id=lid,exist=exist,size=size,atts=atts)
144
144
  if ( present(exist) ) then
145
145
     if ( .not. exist ) return
159
159
     end if
160
160
  end if
161
161
!  if ( present(fill_val) ) then
162
 
     !fill_val = cmplx(lfill_valr,lfill_valc)
163
 
     fill_val = cmplx(0.,0.)
 
162
     !fill_val = cmplx(lfill_valr,lfill_valc, COMPLEX_DTYPE)
 
163
     fill_val = cmplx(0,0, COMPLEX_DTYPE)
164
164
!  end if
165
165
#else
166
166
  call ncdf_inq_var_def(this,name,id=lid,exist=exist,size=size,atts=atts)