add_eigenpair_to_file Subroutine

public subroutine add_eigenpair_to_file(eval, fphi, fapar, fbpar, IDs, my_conv)

Add an eigenpairs data to file

Arguments

Type IntentOptional AttributesName
complex, intent(in) :: eval
real, intent(in) :: fphi
real, intent(in) :: fapar
real, intent(in) :: fbpar
type(EigNetcdfID), intent(inout) :: IDs
real, intent(in), optional :: my_conv

Contents

Source Code


Source Code

  subroutine add_eigenpair_to_file(eval,fphi,fapar,fbpar,IDs,my_conv)
    use fields_arrays, only: phinew, aparnew, bparnew
    use convert, only: c2r
    use theta_grid, only: ntgrid
    complex, intent(in) :: eval !Note just use fields to get eigenvectors
    real, intent(in), optional :: my_conv
    type(EigNetcdfID), intent(inout) :: IDs
    real, intent(in) :: fphi, fapar, fbpar
#ifdef NETCDF
    real, dimension(2) :: ri_omega
    real, dimension(:,:), allocatable :: ri_field
    integer, dimension(3) :: start_field, count_field
    integer, dimension(2) :: start_omega
    integer :: ierr
    real :: local_conv
#endif

    !First increment counter
    IDs%nconv_count=IDs%nconv_count+1

#ifdef NETCDF
    !Now we make start values
    start_field(1)=1 ; start_field(2)=1 ; start_field(3)=IDs%nconv_count
    count_field(1)=2 ; count_field(2)=2*ntgrid+1 ; count_field(3)=1
    start_omega(1)=1 ; start_omega(2)=IDs%nconv_count

    !Set the conv value
    if(present(my_conv))then
       local_conv=my_conv
    else
       local_conv=IDs%nconv_count*1.0
    endif

    !Now we can write data
    !/Conv
    ierr=nf90_put_var(IDs%ncid,IDs%conv_var_id,local_conv, start=(/IDs%nconv_count/))!,count=(/1/))
    if(ierr/=NF90_NOERR) call netcdf_error (ierr, IDs%ncid, IDs%conv_var_id)

    !/Omega
    ri_omega(1)=real(eval)
    ri_omega(2)=aimag(eval)
    ierr=nf90_put_var(IDs%ncid,IDs%omega_var_id,ri_omega, start=start_omega,count=(/2,1/))
    if(ierr/=NF90_NOERR) call netcdf_error (ierr, IDs%ncid, IDs%omega_var_id)

    !/Fields
    allocate(ri_field(2,2*ntgrid+1))
    if(fphi.gt.epsilon(0.0))then
       call c2r(phinew(:,1,1),ri_field)
       ierr=nf90_put_var(IDs%ncid,IDs%phi_var_id,ri_field, start=start_field,count=count_field)
       if(ierr/=NF90_NOERR) call netcdf_error (ierr, IDs%ncid, IDs%phi_var_id)
    endif
    if(fapar.gt.epsilon(0.0))then
       call c2r(aparnew(:,1,1),ri_field)
       ierr=nf90_put_var(IDs%ncid,IDs%apar_var_id,ri_field, start=start_field,count=count_field)
       if(ierr/=NF90_NOERR) call netcdf_error (ierr, IDs%ncid, IDs%apar_var_id)
    endif
    if(fbpar.gt.epsilon(0.0))then
       call c2r(bparnew(:,1,1),ri_field)
       ierr=nf90_put_var(IDs%ncid,IDs%bpar_var_id,ri_field, start=start_field,count=count_field)
       if(ierr/=NF90_NOERR) call netcdf_error (ierr, IDs%ncid, IDs%bpar_var_id)
    endif
    deallocate(ri_field)       
#endif
  end subroutine add_eigenpair_to_file