gvec_to_jorek_writeToFile_ASCII Subroutine

private subroutine gvec_to_jorek_writeToFile_ASCII()

Uses

  • proc~~gvec_to_jorek_writetofile_ascii~~UsesGraph proc~gvec_to_jorek_writetofile_ascii gvec_to_jorek_writeToFile_ASCII module~modgvec_globals MODgvec_Globals proc~gvec_to_jorek_writetofile_ascii->module~modgvec_globals module~modgvec_gvec_to_jorek_vars MODgvec_gvec_to_jorek_Vars proc~gvec_to_jorek_writetofile_ascii->module~modgvec_gvec_to_jorek_vars iso_fortran_env iso_fortran_env module~modgvec_globals->iso_fortran_env module~modgvec_gvec_to_jorek_vars->module~modgvec_globals module~modgvec_base MODgvec_base module~modgvec_gvec_to_jorek_vars->module~modgvec_base module~modgvec_fbase MODgvec_fBase module~modgvec_gvec_to_jorek_vars->module~modgvec_fbase module~modgvec_base->module~modgvec_globals module~modgvec_base->module~modgvec_fbase module~modgvec_sbase MODgvec_sBase module~modgvec_base->module~modgvec_sbase module~modgvec_sgrid MODgvec_sGrid module~modgvec_base->module~modgvec_sgrid module~modgvec_fbase->module~modgvec_globals module~modgvec_sbase->module~modgvec_globals module~modgvec_sbase->module~modgvec_sgrid module~sll_m_bsplines sll_m_bsplines module~modgvec_sbase->module~sll_m_bsplines module~sll_m_spline_interpolator_1d sll_m_spline_interpolator_1d module~modgvec_sbase->module~sll_m_spline_interpolator_1d module~sll_m_spline_matrix sll_m_spline_matrix module~modgvec_sbase->module~sll_m_spline_matrix module~modgvec_sgrid->module~modgvec_globals module~sll_m_bsplines_base sll_m_bsplines_base module~sll_m_bsplines->module~sll_m_bsplines_base module~sll_m_bsplines_non_uniform sll_m_bsplines_non_uniform module~sll_m_bsplines->module~sll_m_bsplines_non_uniform module~sll_m_bsplines_uniform sll_m_bsplines_uniform module~sll_m_bsplines->module~sll_m_bsplines_uniform module~sll_m_working_precision sll_m_working_precision module~sll_m_bsplines->module~sll_m_working_precision module~sll_m_spline_interpolator_1d->module~sll_m_spline_matrix module~sll_m_boundary_condition_descriptors sll_m_boundary_condition_descriptors module~sll_m_spline_interpolator_1d->module~sll_m_boundary_condition_descriptors module~sll_m_spline_interpolator_1d->module~sll_m_bsplines_base module~sll_m_spline_1d sll_m_spline_1d module~sll_m_spline_interpolator_1d->module~sll_m_spline_1d module~sll_m_spline_interpolator_1d->module~sll_m_working_precision module~sll_m_spline_matrix_banded sll_m_spline_matrix_banded module~sll_m_spline_matrix->module~sll_m_spline_matrix_banded module~sll_m_spline_matrix_base sll_m_spline_matrix_base module~sll_m_spline_matrix->module~sll_m_spline_matrix_base module~sll_m_spline_matrix_dense sll_m_spline_matrix_dense module~sll_m_spline_matrix->module~sll_m_spline_matrix_dense module~sll_m_spline_matrix->module~sll_m_working_precision module~sll_m_bsplines_base->module~sll_m_working_precision module~sll_m_bsplines_non_uniform->module~sll_m_bsplines_base module~sll_m_bsplines_non_uniform->module~sll_m_working_precision module~sll_m_bsplines_uniform->module~sll_m_bsplines_base module~sll_m_bsplines_uniform->module~sll_m_working_precision module~sll_m_spline_1d->module~sll_m_bsplines_base module~sll_m_spline_1d->module~sll_m_working_precision module~sll_m_spline_matrix_banded->iso_fortran_env module~sll_m_spline_matrix_banded->module~sll_m_spline_matrix_base module~sll_m_spline_matrix_banded->module~sll_m_working_precision module~sll_m_spline_matrix_base->module~sll_m_working_precision module~sll_m_spline_matrix_dense->iso_fortran_env module~sll_m_spline_matrix_dense->module~sll_m_spline_matrix_base module~sll_m_spline_matrix_dense->module~sll_m_working_precision

write data to file

Arguments

None

Calls

proc~~gvec_to_jorek_writetofile_ascii~~CallsGraph proc~gvec_to_jorek_writetofile_ascii gvec_to_jorek_writeToFile_ASCII interface~getfreeunit GETFREEUNIT proc~gvec_to_jorek_writetofile_ascii->interface~getfreeunit interface~getfreeunit->interface~getfreeunit

Called by

proc~~gvec_to_jorek_writetofile_ascii~~CalledByGraph proc~gvec_to_jorek_writetofile_ascii gvec_to_jorek_writeToFile_ASCII interface~gvec_to_jorek_writetofile gvec_to_jorek_writeToFile interface~gvec_to_jorek_writetofile->proc~gvec_to_jorek_writetofile_ascii program~convert_gvec_to_jorek CONVERT_GVEC_TO_JOREK program~convert_gvec_to_jorek->interface~gvec_to_jorek_writetofile

Source Code

SUBROUTINE gvec_to_jorek_writeToFile_ASCII()
! MODULES
USE MODgvec_Globals,ONLY:Unit_stdOut,GETFREEUNIT
USE MODgvec_gvec_to_jorek_Vars
IMPLICIT NONE
!-----------------------------------------------------------------------------------------------------------------------------------
! INPUT VARIABLES
!-----------------------------------------------------------------------------------------------------------------------------------
! OUTPUT VARIABLES
!-----------------------------------------------------------------------------------------------------------------------------------
! LOCAL VARIABLES
INTEGER       :: ioUnit,iVar
INTEGER       :: date_time_values(8)
CHARACTER(LEN=30) :: curr_date_time
!===================================================================================================================================
  CALL DATE_AND_TIME(VALUES=date_time_values)
  WRITE(curr_date_time,'(1X,I4.4,"-",I2.2,"-",I2.2,2X,I2.2,":",I2.2,":",I2.2)') date_time_values(1:3),date_time_values(5:7)

  WRITE(UNIT_stdOut,'(A)')'WRITING NEW JOREK FILE    "'//TRIM(FileNameOut)//'" , date: '//TRIM(curr_date_time)//' ... '
  ioUnit=GETFREEUNIT()
  OPEN(UNIT     = ioUnit       ,&
     FILE     = TRIM(FileNameOut) ,&
     STATUS   = 'REPLACE'   ,&
     ACCESS   = 'SEQUENTIAL' )

!HEADER
  WRITE(ioUnit,'(A100)')'## -------------------------------------------------------------------------------------------------'
  WRITE(ioUnit,'(A100)')'## GVEC-TO-JOREK file, VERSION: 1.0                                                                 '
  WRITE(ioUnit,'(A100)')'## -------------------------------------------------------------------------------------------------'
  WRITE(ioUnit,'(A100)')'## data is written on equidistant points in s,theta,zeta coordinates,                               '
  WRITE(ioUnit,'(A100)')'## * radially outward coordinate s=sqrt(phi_tor/phi_tor_edge) in [0,1]                              '
  WRITE(ioUnit,'(A100)')'##   s(1:Ns) , with  s(1)=0, s(Ns)=1                                                                '
  WRITE(ioUnit,'(A100)')'## * poloidal angle theta in [0,2pi] , sign: theta ~ atan(z/sqrt(x^2+y^2))                          '
  WRITE(ioUnit,'(A100)')'##   theta(1:Ntheta)  with theta(1)=0, theta(Ntheta)=2pi*(Ntheta-1)*/Ntheta                         '
  WRITE(ioUnit,'(A100)')'## * toroidal angle zeta in [0,2pi/nfp], sign: zeta ~ atan(y/x)  (opposite to GVEC definition!)     '
  WRITE(ioUnit,'(A100)')'##   zeta(1:Nzeta)  with zeta(1)=0, zeta(Nzeta)=2pi/nfp*(Nzeta-1)*/Nzeta                            '
  WRITE(ioUnit,'(A100)')'## * Angular coordinates can represent GVEC coordinates, which are not SFL (straight-field line)    '
  WRITE(ioUnit,'(A100)')'##   coordinates or can be SFL coordinates, either PEST or BOOZER. See global parameter "SFLcoord"  '
  WRITE(ioUnit,'(A100)')'##                                                                                                  '
  WRITE(ioUnit,'(A100)')'## 2D arrays containing toroidal Fourier coefficients for GVEC fields are used for the import       '
  WRITE(ioUnit,'(A100)')'## 3D test data can be generated instead if the -g option has been used                                                                                                 '
  WRITE(ioUnit,'(A100)')'##                                                                                                  '
  WRITE(ioUnit,'(A100)')'##   WARNING: Note that the change in the coordinate system is important!                           '
  WRITE(ioUnit,'(A100)')'##            GVEC and JOREK both use left handed coodinate systems so:                             '
  WRITE(ioUnit,'(A100)')'##                                                                                                  '
  WRITE(ioUnit,'(A100)')'##                          (x,y,z)=(Rcos(zeta),-Rsin(zeta),Z)                                      '
  WRITE(ioUnit,'(A100)')'## -------------------------------------------------------------------------------------------------'
  WRITE(ioUnit,'(A100)')'## Global variables:                                                                                '
  WRITE(ioUnit,'(A100)')'## * SFLcoord    : =0: GVEC coords (not SFL), =1: PEST SFL coords. , =2: BOOZER SFL coords.         '
  WRITE(ioUnit,'(A100)')'## * nfp         : number of toroidal field periods (toroidal angle [0,2pi/nfp])                    '
  WRITE(ioUnit,'(A100)')'## * asym        :  =0: symmetric cofiguration (R~cos,Z~sin), 1: asymmetric                         '
  WRITE(ioUnit,'(A100)')'## * m_max       : maximum number of poloidal modes in R,Z,lambda variables                         '
  WRITE(ioUnit,'(A100)')'## * n_max       : maximum number of toroidal modes in R,Z,lambda variables                         '
  WRITE(ioUnit,'(A100)')'## -------------------------------------------------------------------------------------------------'
  WRITE(ioUnit,'(A100)')'## 2D arrays of scalar fourier coefficients (1:Ntheta,1:Ns)                                         '
  WRITE(ioUnit,'(A100)')'## * R              : major radius                                                                  '
  WRITE(ioUnit,'(A100)')'## * R_s            : radial derivative of major radius                                             '
  WRITE(ioUnit,'(A100)')'## * R_t            : poloidal derivative of major radius                                           '
  WRITE(ioUnit,'(A100)')'## * R_st           : cross derivative of major radius                                              '
  WRITE(ioUnit,'(A100)')'## * Z              : vertical position                                                             '
  WRITE(ioUnit,'(A100)')'## * Z_s            : radial derivative of vertical position                                        '
  WRITE(ioUnit,'(A100)')'## * Z_t            : poloidal derivative of vertical position                                      '
  WRITE(ioUnit,'(A100)')'## * Z_st           : cross derivative of vertical position                                         '
  WRITE(ioUnit,'(A100)')'## * P              : pressure                                                                      '
  WRITE(ioUnit,'(A100)')'## * P_s            : radial derivative of pressure                                                 '
  WRITE(ioUnit,'(A100)')'## * P_t            : poloidal derivative of pressure                                               '
  WRITE(ioUnit,'(A100)')'## * P_st           : cross derivative of pressure                                                  '
  WRITE(ioUnit,'(A100)')'## * A_R            : X component of  vector potential                                              '
  WRITE(ioUnit,'(A100)')'## * A_R_s          : radial derivative of X component of  vector potential                         '
  WRITE(ioUnit,'(A100)')'## * A_R_t          : poloidal derivative of X component of  vector potential                       '
  WRITE(ioUnit,'(A100)')'## * A_R_st         : cross derivative of X component of  vector potential                          '
  WRITE(ioUnit,'(A100)')'## * A_Z            : Y Component vector potential                                                  '
  WRITE(ioUnit,'(A100)')'## * A_Z_s          : radial derivative of Y component of  vector potential                         '
  WRITE(ioUnit,'(A100)')'## * A_Z_t          : poloidal derivative of Y component of  vector potential                       '
  WRITE(ioUnit,'(A100)')'## * A_Z_st         : cross derivative of Y component of  vector potential                          '
  WRITE(ioUnit,'(A100)')'## * A_phi          : Vertical vector potential                                                     '
  WRITE(ioUnit,'(A100)')'## * A_phi_s        : radial derivative of Vertical vector potential                                '
  WRITE(ioUnit,'(A100)')'## * A_phi_t        : poloidal derivative of Vertical vector potential                              '
  WRITE(ioUnit,'(A100)')'## * A_phi_st       : cross derivative of Vertical vector potential                                 '
  WRITE(ioUnit,'(A100)')'## * B_R            : X component of  magnetic field                                                '
  WRITE(ioUnit,'(A100)')'## * B_R_s          : radial derivative of X component of  magnetic field                           '
  WRITE(ioUnit,'(A100)')'## * B_R_t          : poloidal derivative of X component of  magnetic field                         '
  WRITE(ioUnit,'(A100)')'## * B_R_st         : cross derivative of X component of  magnetic field                            '
  WRITE(ioUnit,'(A100)')'## * B_Z            : Y Component magnetic field                                                    '
  WRITE(ioUnit,'(A100)')'## * B_Z_s          : radial derivative of Y component of  magnetic field                           '
  WRITE(ioUnit,'(A100)')'## * B_Z_t          : poloidal derivative of Y component of  magnetic field                         '
  WRITE(ioUnit,'(A100)')'## * B_Z_st         : cross derivative of Y component of  magnetic field                            '
  WRITE(ioUnit,'(A100)')'## * B_phi          : Vertical magnetic field                                                       '
  WRITE(ioUnit,'(A100)')'## * B_phi_s        : radial derivative of Vertical magnetic field                                  '
  WRITE(ioUnit,'(A100)')'## * B_phi_t        : poloidal derivative of Vertical magnetic field                                '
  WRITE(ioUnit,'(A100)')'## * B_phi_st       : cross derivative of Vertical magnetic field                                   '
  WRITE(ioUnit,'(A100)')'## * J_R            : X component of  current density                                               '
  WRITE(ioUnit,'(A100)')'## * J_R_s          : radial derivative of X component of  current density                          '
  WRITE(ioUnit,'(A100)')'## * J_R_t          : poloidal derivative of X component of  current density                        '
  WRITE(ioUnit,'(A100)')'## * J_R_st         : cross derivative of X component of  current density                           '
  WRITE(ioUnit,'(A100)')'## * J_Z            : Y Component current density                                                   '
  WRITE(ioUnit,'(A100)')'## * J_Z_s          : radial derivative of Y component of  current density                          '
  WRITE(ioUnit,'(A100)')'## * J_Z_t          : poloidal derivative of Y component of  current density                        '
  WRITE(ioUnit,'(A100)')'## * J_Z_st         : cross derivative of Y component of  current density                           '
  WRITE(ioUnit,'(A100)')'## * J_phi          : Vertical current density                                                      '
  WRITE(ioUnit,'(A100)')'## * J_phi_s        : radial derivative of Vertical current density                                 '
  WRITE(ioUnit,'(A100)')'## * J_phi_t        : poloidal derivative of Vertical current density                               '
  WRITE(ioUnit,'(A100)')'## * J_phi_st       : cross derivative of Vertical current density                                  '
  WRITE(ioUnit,'(A100)')'## -------------------------------------------------------------------------------------------------'
  WRITE(ioUnit,'(A100)')'## 3D arrays of scalars (1:Ntheta,1:Nzeta,1:Ns)                                                     '
  WRITE(ioUnit,'(A100)')'## * s              : radial coordinate                                                             '
  WRITE(ioUnit,'(A100)')'## * t              : poloidal coordinate                                                           '
  WRITE(ioUnit,'(A100)')'## * p              : toroidal coordinate                                                           '
  WRITE(ioUnit,'(A100)')'## * X1 (R)         : coordinate R=sqrt(x^2+y^2) ( called X1 in GVEC, only=R for hmap=1)            '
  WRITE(ioUnit,'(A100)')'## * X1_s (R)       : radial derivative of X1                                                       '
  WRITE(ioUnit,'(A100)')'## * X1_t (R)       : poloidal derivative of X1                                                     '
  WRITE(ioUnit,'(A100)')'## * X1_st (R)      : cross derivative of X1                                                        '
  WRITE(ioUnit,'(A100)')'## * X2 (Z)         : coordinate Z=z ( called X2 in GVEC, only=Z for hmap=1)                        '
  WRITE(ioUnit,'(A100)')'## * X2_s (Z)       : radial derivative of X2                                                       '
  WRITE(ioUnit,'(A100)')'## * X2_t (Z)       : poloidal derivative of X2                                                     '
  WRITE(ioUnit,'(A100)')'## * X2_st (Z)      : cross derivative of X2                                                        '
  WRITE(ioUnit,'(A100)')'## * P              : pressure                                                                      '
  WRITE(ioUnit,'(A100)')'## * P_s            : radial derivative of pressure                                                 '
  WRITE(ioUnit,'(A100)')'## * A_R            : X component of  vector potential                                              '
  WRITE(ioUnit,'(A100)')'## * A_R_s          : radial derivative of X component of  vector potential                         '
  WRITE(ioUnit,'(A100)')'## * A_R_t          : poloidal derivative of X component of  vector potential                       '
  WRITE(ioUnit,'(A100)')'## * A_R_st         : cross derivative of X component of  vector potential                          '
  WRITE(ioUnit,'(A100)')'## * A_Z            : Y Component vector potential                                                  '
  WRITE(ioUnit,'(A100)')'## * A_Z_s          : radial derivative of Y component of  vector potential                         '
  WRITE(ioUnit,'(A100)')'## * A_Z_t          : poloidal derivative of Y component of  vector potential                       '
  WRITE(ioUnit,'(A100)')'## * A_Z_st         : cross derivative of Y component of  vector potential                          '
  WRITE(ioUnit,'(A100)')'## * A_phi          : Vertical vector potential                                                     '
  WRITE(ioUnit,'(A100)')'## * A_phi_s        : radial derivative of Vertical vector potential                                '
  WRITE(ioUnit,'(A100)')'## * A_phi_t        : poloidal derivative of Vertical vector potential                              '
  WRITE(ioUnit,'(A100)')'## * A_phi_st       : cross derivative of Vertical vector potential                                 '
  WRITE(ioUnit,'(A100)')'## * B_R            : X component of  magnetic field                                                '
  WRITE(ioUnit,'(A100)')'## * B_R_s          : radial derivative of X component of  magnetic field                           '
  WRITE(ioUnit,'(A100)')'## * B_R_t          : poloidal derivative of X component of  magnetic field                         '
  WRITE(ioUnit,'(A100)')'## * B_R_st         : cross derivative of X component of  magnetic field                            '
  WRITE(ioUnit,'(A100)')'## * B_Z            : Y Component magnetic field                                                    '
  WRITE(ioUnit,'(A100)')'## * B_Z_s          : radial derivative of Y component of  magnetic field                           '
  WRITE(ioUnit,'(A100)')'## * B_Z_t          : poloidal derivative of Y component of  magnetic field                         '
  WRITE(ioUnit,'(A100)')'## * B_Z_st         : cross derivative of Y component of  magnetic field                            '
  WRITE(ioUnit,'(A100)')'## * B_phi          : Vertical magnetic field                                                       '
  WRITE(ioUnit,'(A100)')'## * B_phi_s        : radial derivative of Vertical magnetic field                                  '
  WRITE(ioUnit,'(A100)')'## * B_phi_t        : poloidal derivative of Vertical magnetic field                                '
  WRITE(ioUnit,'(A100)')'## * B_phi_st       : cross derivative of Vertical magnetic field                                   '
  WRITE(ioUnit,'(A100)')'## * J_R            : X component of  current density                                               '
  WRITE(ioUnit,'(A100)')'## * J_R_s          : radial derivative of X component of  current density                          '
  WRITE(ioUnit,'(A100)')'## * J_R_t          : poloidal derivative of X component of  current density                        '
  WRITE(ioUnit,'(A100)')'## * J_R_st         : cross derivative of X component of  current density                           '
  WRITE(ioUnit,'(A100)')'## * J_Z            : Y Component current density                                                   '
  WRITE(ioUnit,'(A100)')'## * J_Z_s          : radial derivative of Y component of  current density                          '
  WRITE(ioUnit,'(A100)')'## * J_Z_t          : poloidal derivative of Y component of  current density                        '
  WRITE(ioUnit,'(A100)')'## * J_Z_st         : cross derivative of Y component of  current density                           '
  WRITE(ioUnit,'(A100)')'## * J_phi          : Vertical current density                                                      '
  WRITE(ioUnit,'(A100)')'## * J_phi_s        : radial derivative of Vertical current density                                 '
  WRITE(ioUnit,'(A100)')'## * J_phi_t        : poloidal derivative of Vertical current density                               '
  WRITE(ioUnit,'(A100)')'## * J_phi_st       : cross derivative of Vertical current density                                  '
  WRITE(ioUnit,'(A100)')'## -------------------------------------------------------------------------------------------------'
  WRITE(ioUnit,'(2A)')  '## CALLED AS: ',TRIM(cmdline)
  WRITE(ioUnit,'(2A)')  '## CALLED ON: ',TRIM(curr_date_time)
  WRITE(ioUnit,'(A100)')'####################################################################################################'
  WRITE(ioUnit,'(A)')'##<< number of grid points: 1:Ns (radial), 1:Ntheta (poloidal),1:Nzeta (toroidal) '
  WRITE(ioUnit,'(*(I8,:,1X))')Ns_out,Nthet_out,Nzeta_out
  WRITE(ioUnit,'(A)')'##<< global: SFLcoord,nfp,  asym, m_max, n_max, n_modes, sin_min, sin_max, cos_min, cos_max'
  WRITE(ioUnit,'(12X,*(I6,:,1X))')SFLcoord,nfp_out,asym_out,mn_max_out(1:2), n_modes,sin_range(1:2),cos_range(1:2)
  IF (generate_test_data) THEN
    ! Write 3D data only
    DO iVar=1,nVarScalar3D
      WRITE(ioUnit,'(A)',ADVANCE='NO')'##<< 3D scalar variable (1:Ntheta,1:Nzeta,1:Ns), Variable name: '
      WRITE(ioUNIT,'(A)')' "'//TRIM(StrVarNamesScalar3D(iVar))//'"'
      WRITE(ioUnit,'(*(6(e23.15,:,1X),/))') data_scalar3D(1:Nthet_out,1:Nzeta_out,1:Ns_out,iVar)
    END DO !iVar=1,nVarScalar3D
  ELSE
    ! Write 2D data only
    DO iVar=1,nVarScalar2D
      WRITE(ioUnit,'(A)',ADVANCE='NO')'##<< 2D scalar variable fourier modes (1:Ntheta,1:Ns), Variable name: '
      WRITE(ioUNIT,'(A)')' "'//TRIM(StrVarNamesScalar2D(iVar))//'"'
      WRITE(ioUnit,'(*(6(e23.15,:,1X),/))') data_scalar2D(1:Nthet_out,1:Ns_out,1:n_modes,iVar)
    END DO !iVar=1,nVarScalar2D
  END IF

  CLOSE(ioUnit)

  WRITE(UNIT_stdOut,'(A)')'...DONE.'
END SUBROUTINE gvec_to_jorek_writeToFile_ASCII