9#include <PB3D_macros.h>
29 real(dp),
allocatable :: dum_1D(:)
30 real(dp),
allocatable :: dum_2D(:,:)
31 real(dp),
allocatable :: dum_3D(:,:,:)
32 real(dp),
allocatable :: dum_4D(:,:,:,:)
33 real(dp),
allocatable :: dum_6D(:,:,:,:,:,:)
34 real(dp),
allocatable :: dum_7D(:,:,:,:,:,:,:)
57 use vmec_vars,
only: is_freeb_v, mnmax_v, mpol_v, ntor_v, is_asym_v, &
66 character(*),
parameter :: rout_name =
'reconstruct_PB3D_in'
69 character(len=*),
intent(in) :: data_name
72 character(len=max_str_ln) :: err_msg
74 real(dp),
parameter :: tol_version = 1.e-4_dp
75 real(dp) :: pb3d_version
76 logical :: debug_version_pb3d
77 character(len=max_str_ln) :: use_debug_str(2)
83 call writo(
'Reconstructing input variables from PB3D output')
90 pb3d_version = dum_1d(1)
112 debug_version_pb3d = .false.
113 if (dum_1d(20).gt.0) debug_version_pb3d = .true.
121 call writo(
'Run tests')
124 call writo(
'PB3D version '//trim(
r2strt(pb3d_version)))
127 err_msg =
'Need at least PB3D version '//&
132 if (debug_version_pb3d)
call writo(
'debug version')
136 if (debug_version_pb3d)
then
137 use_debug_str(1) =
'uses debug version'
139 use_debug_str(1) =
'uses release version'
142 use_debug_str(2) =
'uses debug version'
144 use_debug_str(2) =
'uses release version'
146 call writo(
'The PB3D output '//trim(use_debug_str(1))//&
147 &
' but POST '//trim(use_debug_str(2)))
148 err_msg =
'Need to use debug version for both, or not for &
166 if (dum_1d(1).gt.0) is_asym_v = .true.
167 if (dum_1d(2).gt.0) is_freeb_v = .true.
168 mnmax_v = nint(dum_1d(3))
169 mpol_v = nint(dum_1d(4))
170 ntor_v = nint(dum_1d(5))
171 nfp_v = nint(dum_1d(6))
221 allocate(
mn_v(mnmax_v,2))
235 r_v_c = dum_4d(:,:,:,1)
236 r_v_s = dum_4d(:,:,:,2)
237 z_v_c = dum_4d(:,:,:,3)
238 z_v_s = dum_4d(:,:,:,4)
239 l_v_c = dum_4d(:,:,:,5)
240 l_v_s = dum_4d(:,:,:,6)
270 b_v_c = dum_3d(:,:,1)
271 b_v_s = dum_3d(:,:,2)
289 ias = nint(dum_1d(1))
290 nchi= nint(dum_1d(2))
418 call writo(
'Input variables from PB3D output reconstructed')
441 &lim_pos,grid_limits)
result(ierr)
447 character(*),
parameter :: rout_name =
'reconstruct_PB3D_grid'
450 type(grid_type),
intent(inout) :: grid
451 character(len=*),
intent(in) :: data_name
452 integer,
intent(in),
optional :: rich_lvl
453 logical,
intent(in),
optional :: tot_rich
454 integer,
intent(in),
optional :: lim_pos(3,2)
455 integer,
intent(in),
optional :: grid_limits(2)
459 integer :: lim_mem(3,2)
462 integer :: rich_lvl_loc
464 integer :: par_id_mem(2)
465 integer :: par_lim(2)
466 integer :: rich_id(2)
473 if (
present(rich_lvl)) rich_lvl_loc = rich_lvl
483 if (
present(lim_pos))
then
484 if (lim_pos(1,1).ge.0 .and. lim_pos(1,2).ge.0) n(1) = &
485 &lim_pos(1,2)-lim_pos(1,1)+1
486 if (lim_pos(2,1).ge.0 .and. lim_pos(2,2).ge.0) n(2) = &
487 &lim_pos(2,2)-lim_pos(2,1)+1
488 if (lim_pos(3,1).ge.0 .and. lim_pos(3,2).ge.0) n(3) = &
489 &lim_pos(3,2)-lim_pos(3,1)+1
490 where (lim_pos(:,1).eq.lim_pos(:,2) .and. lim_pos(:,1).eq.[0,0,0]) &
496 if (
present(lim_pos))
then
497 where (lim_pos(1,:).ge.0) par_lim = lim_pos(1,:)
501 ierr = grid%init(n,i_lim=grid_limits)
505 do id = rich_id(2),rich_id(1),-1
507 par_id =
setup_par_id(grid,rich_lvl_loc,id,tot_rich=tot_rich,&
508 &par_lim=par_lim,par_id_mem=par_id_mem)
511 lim_mem(1,:) = par_id_mem
512 lim_mem(2,:) = [1,grid%n(2)]
513 lim_mem(3,:) = [1,grid%n(3)]
514 if (
present(lim_pos))
then
515 lim_mem(2,:) = lim_pos(2,:)
516 lim_mem(3,:) = lim_pos(3,:)
521 &trim(data_name),
'r_F',rich_lvl=id,lim_loc=lim_mem(3:3,:))
529 &trim(data_name),
'r_E',rich_lvl=id,lim_loc=lim_mem(3:3,:))
536 grid%loc_r_F = grid%r_F(grid%i_min:grid%i_max)
539 grid%loc_r_E = grid%r_E(grid%i_min:grid%i_max)
542 lim_mem(1,:) = par_id_mem
543 lim_mem(2,:) = [1,grid%n(2)]
544 lim_mem(3,:) = [grid%i_min,grid%i_max]
545 if (
present(lim_pos))
then
546 lim_mem(2,:) = lim_pos(2,:)
547 lim_mem(3,:) = lim_mem(3,:) + lim_pos(3,1) - 1
551 if (product(grid%n(1:2)).ne.0)
then
554 &trim(data_name),
'theta_F',rich_lvl=id,lim_loc=lim_mem)
557 grid%theta_F(par_id(1):par_id(2):par_id(3),:,:) = dum_3d
562 &trim(data_name),
'theta_E',rich_lvl=id,lim_loc=lim_mem)
565 grid%theta_E(par_id(1):par_id(2):par_id(3),:,:) = dum_3d
570 &trim(data_name),
'zeta_F',rich_lvl=id,lim_loc=lim_mem)
573 grid%zeta_F(par_id(1):par_id(2):par_id(3),:,:) = dum_3d
578 &trim(data_name),
'zeta_E',rich_lvl=id,lim_loc=lim_mem)
581 grid%zeta_E(par_id(1):par_id(2):par_id(3),:,:) = dum_3d
601 character(*),
parameter :: rout_name =
'reconstruct_PB3D_eq_1'
604 type(grid_type),
intent(in) :: grid_eq
605 type(eq_1_type),
intent(inout),
optional :: eq
606 character(len=*),
intent(in) :: data_name
607 integer,
intent(in),
optional :: lim_pos(1,2)
611 integer :: lim_mem(2,2)
619 call eq%init(grid_eq,setup_e=.false.,setup_f=.true.)
622 lim_mem(1,:) = [grid_eq%i_min,grid_eq%i_max]
623 lim_mem(2,:) = [0,-1]
624 if (
present(lim_pos))
then
625 lim_mem(1,:) = lim_mem(1,:) + lim_pos(1,1) - 1
659 eq%flux_p_FD = dum_2d
667 eq%flux_t_FD = dum_2d
672 &lim_loc=lim_mem(1:1,:))
694 &tot_rich,lim_pos)
result(ierr)
699 character(*),
parameter :: rout_name =
'reconstruct_PB3D_eq_2'
702 type(grid_type),
intent(in) :: grid_eq
703 type(eq_2_type),
intent(inout) :: eq
704 character(len=*),
intent(in) :: data_name
705 integer,
intent(in),
optional :: rich_lvl
706 logical,
intent(in),
optional :: tot_rich
707 integer,
intent(in),
optional :: lim_pos(3,2)
711 integer :: lim_mem(7,2)
713 integer :: rich_lvl_loc
715 integer :: par_id_mem(2)
716 integer :: par_lim(2)
717 integer :: rich_id(2)
724 if (
present(rich_lvl)) rich_lvl_loc = rich_lvl
730 par_lim = [1,grid_eq%n(1)]
731 if (
present(lim_pos))
then
732 where (lim_pos(1,:).ge.0) par_lim = lim_pos(1,:)
736 call eq%init(grid_eq,setup_e=.false.,setup_f=.true.)
739 do id = rich_id(2),rich_id(1),-1
741 par_id =
setup_par_id(grid_eq,rich_lvl_loc,id,tot_rich=tot_rich,&
742 &par_lim=par_lim,par_id_mem=par_id_mem)
745 lim_mem(1,:) = par_id_mem
746 lim_mem(2,:) = [1,grid_eq%n(2)]
747 lim_mem(3,:) = [grid_eq%i_min,grid_eq%i_max]
748 lim_mem(4,:) = [-1,-1]
749 lim_mem(5,:) = [-1,-1]
750 lim_mem(6,:) = [-1,-1]
751 lim_mem(7,:) = [-1,-1]
752 if (
present(lim_pos))
then
753 lim_mem(2,:) = lim_pos(2,:)
754 lim_mem(3,:) = lim_mem(3,:) + lim_pos(3,1) - 1
759 &rich_lvl=id,lim_loc=lim_mem)
762 eq%g_FD(par_id(1):par_id(2):par_id(3),:,:,:,:,:,:) = dum_7d
767 &rich_lvl=id,lim_loc=lim_mem)
770 eq%h_FD(par_id(1):par_id(2):par_id(3),:,:,:,:,:,:) = dum_7d
775 &rich_lvl=id,lim_loc=lim_mem(1:6,:))
778 eq%jac_FD(par_id(1):par_id(2):par_id(3),:,:,:,:,:) = dum_6d
783 &rich_lvl=id,lim_loc=lim_mem(1:3,:))
786 eq%S(par_id(1):par_id(2):par_id(3),:,:) = dum_3d
791 &
'kappa_n',rich_lvl=id,lim_loc=lim_mem(1:3,:))
794 eq%kappa_n(par_id(1):par_id(2):par_id(3),:,:) = dum_3d
799 &
'kappa_g',rich_lvl=id,lim_loc=lim_mem(1:3,:))
802 eq%kappa_g(par_id(1):par_id(2):par_id(3),:,:) = dum_3d
807 &rich_lvl=id,lim_loc=lim_mem(1:3,:))
810 eq%sigma(par_id(1):par_id(2):par_id(3),:,:) = dum_3d
832 &tot_rich,lim_sec_X,lim_pos)
result(ierr)
838 character(*),
parameter :: rout_name =
'reconstruct_PB3D_X_1'
842 type(grid_type),
intent(in) :: grid_x
844 character(len=*),
intent(in) :: data_name
845 integer,
intent(in),
optional :: rich_lvl
846 logical,
intent(in),
optional :: tot_rich
847 integer,
intent(in),
optional :: lim_sec_x(2)
848 integer,
intent(in),
optional :: lim_pos(3,2)
852 integer :: lim_sec_x_loc(2)
853 integer :: lim_mem(4,2)
855 integer :: rich_lvl_loc
857 integer :: par_id_mem(2)
858 integer :: par_lim(2)
859 integer :: rich_id(2)
866 if (
present(rich_lvl)) rich_lvl_loc = rich_lvl
873 if (
present(lim_sec_x)) lim_sec_x_loc = lim_sec_x
876 par_lim = [1,grid_x%n(1)]
877 if (
present(lim_pos))
then
878 where (lim_pos(1,:).ge.0) par_lim = lim_pos(1,:)
882 call x%init(mds,grid_x,lim_sec_x)
885 do id = rich_id(2),rich_id(1),-1
887 par_id =
setup_par_id(grid_x,rich_lvl_loc,id,tot_rich=tot_rich,&
888 &par_lim=par_lim,par_id_mem=par_id_mem)
891 lim_mem(1,:) = par_id_mem
892 lim_mem(2,:) = [1,grid_x%n(2)]
893 lim_mem(3,:) = [grid_x%i_min,grid_x%i_max]
894 lim_mem(4,:) = lim_sec_x_loc
895 if (
present(lim_pos))
then
896 lim_mem(2,:) = lim_pos(2,:)
897 lim_mem(3,:) = lim_mem(3,:) + lim_pos(3,1) - 1
902 &
'RE_U_0',rich_lvl=id,lim_loc=lim_mem)
905 x%U_0(par_id(1):par_id(2):par_id(3),:,:,:) = dum_4d
910 &
'IM_U_0',rich_lvl=id,lim_loc=lim_mem)
913 x%U_0(par_id(1):par_id(2):par_id(3),:,:,:) = &
914 x%U_0(par_id(1):par_id(2):par_id(3),:,:,:) +
iu*dum_4d
919 &
'RE_U_1',rich_lvl=id,lim_loc=lim_mem)
922 x%U_1(par_id(1):par_id(2):par_id(3),:,:,:) = dum_4d
927 &
'IM_U_1',rich_lvl=id,lim_loc=lim_mem)
930 x%U_1(par_id(1):par_id(2):par_id(3),:,:,:) = &
931 x%U_1(par_id(1):par_id(2):par_id(3),:,:,:) +
iu*dum_4d
936 &
'RE_DU_0',rich_lvl=id,lim_loc=lim_mem)
939 x%DU_0(par_id(1):par_id(2):par_id(3),:,:,:) = dum_4d
944 &
'IM_DU_0',rich_lvl=id,lim_loc=lim_mem)
947 x%DU_0(par_id(1):par_id(2):par_id(3),:,:,:) = &
948 x%DU_0(par_id(1):par_id(2):par_id(3),:,:,:) +
iu*dum_4d
953 &
'RE_DU_1',rich_lvl=id,lim_loc=lim_mem)
956 x%DU_1(par_id(1):par_id(2):par_id(3),:,:,:) = dum_4d
961 &
'IM_DU_1',rich_lvl=id,lim_loc=lim_mem)
964 x%DU_1(par_id(1):par_id(2):par_id(3),:,:,:) = &
965 x%DU_1(par_id(1):par_id(2):par_id(3),:,:,:) +
iu*dum_4d
991 &tot_rich,lim_sec_X,lim_pos,is_field_averaged)
result(ierr)
997 character(*),
parameter :: rout_name =
'reconstruct_PB3D_X_2'
1000 type(modes_type),
intent(in) :: mds
1001 type(grid_type),
intent(in) :: grid_x
1002 type(x_2_type),
intent(inout) :: x
1003 character(len=*),
intent(in) :: data_name
1004 integer,
intent(in),
optional :: rich_lvl
1005 logical,
intent(in),
optional :: tot_rich
1006 integer,
intent(in),
optional :: lim_sec_x(2,2)
1007 integer,
intent(in),
optional :: lim_pos(3,2)
1008 logical,
intent(in),
optional :: is_field_averaged
1012 logical :: is_field_averaged_loc
1015 integer :: sxr_loc(2,2)
1016 integer :: sxr_tot(2,2)
1017 integer :: nn_mod_loc(2)
1018 integer :: lim_mem(4,2,2)
1019 integer :: rich_lvl_loc
1020 integer :: par_id(3)
1021 integer :: par_id_mem(2)
1022 integer :: par_lim(2)
1023 integer :: rich_id(2)
1024 logical :: read_this(2)
1031 if (
present(rich_lvl)) rich_lvl_loc = rich_lvl
1034 is_field_averaged_loc = .false.
1035 if (
present(is_field_averaged)) is_field_averaged_loc = &
1042 par_lim = [1,grid_x%n(1)]
1043 if (
present(lim_pos))
then
1044 where (lim_pos(1,:).ge.0) par_lim = lim_pos(1,:)
1048 call x%init(mds,grid_x,lim_sec_x,is_field_averaged)
1051 do id = rich_id(2),rich_id(1),-1
1053 if (is_field_averaged_loc)
then
1057 par_id =
setup_par_id(grid_x,rich_lvl_loc,id,tot_rich=tot_rich,&
1058 &par_lim=par_lim,par_id_mem=par_id_mem)
1068 nn_mod_loc = sxr_loc(2,:)-sxr_loc(1,:)+1
1071 if (sxr_loc(1,k).le.sxr_loc(2,k)) read_this(k) = .true.
1079 lim_mem(1,:,1) = par_id_mem
1080 lim_mem(2,:,1) = [1,grid_x%n(2)]
1081 lim_mem(3,:,1) = [grid_x%i_min,grid_x%i_max]
1082 lim_mem(4,:,1) = [sxr_tot(1,1),sxr_tot(2,1)]
1083 lim_mem(1,:,2) = par_id_mem
1084 lim_mem(2,:,2) = [1,grid_x%n(2)]
1085 lim_mem(3,:,2) = [grid_x%i_min,grid_x%i_max]
1086 lim_mem(4,:,2) = [sxr_tot(1,2),sxr_tot(2,2)]
1087 if (
present(lim_pos))
then
1088 lim_mem(2,:,1) = lim_pos(2,:)
1089 lim_mem(3,:,1) = lim_mem(3,:,1) + lim_pos(3,1) - 1
1090 lim_mem(2,:,2) = lim_pos(2,:)
1091 lim_mem(3,:,2) = lim_mem(3,:,2) + lim_pos(3,1) - 1
1094 if (read_this(1))
then
1097 &
'RE_PV_0',rich_lvl=id,lim_loc=lim_mem(:,:,1))
1100 x%PV_0(par_id(1):par_id(2):par_id(3),:,:,&
1101 &sxr_loc(1,1):sxr_loc(2,1)) = dum_4d
1106 &
'IM_PV_0',rich_lvl=id,lim_loc=lim_mem(:,:,1))
1109 x%PV_0(par_id(1):par_id(2):par_id(3),:,:,&
1110 &sxr_loc(1,1):sxr_loc(2,1)) = &
1111 &x%PV_0(par_id(1):par_id(2):par_id(3),:,:,&
1112 &sxr_loc(1,1):sxr_loc(2,1)) +
iu*dum_4d
1117 &
'RE_PV_2',rich_lvl=id,lim_loc=lim_mem(:,:,1))
1120 x%PV_2(par_id(1):par_id(2):par_id(3),:,:,&
1121 &sxr_loc(1,1):sxr_loc(2,1)) = dum_4d
1126 &
'IM_PV_2',rich_lvl=id,lim_loc=lim_mem(:,:,1))
1129 x%PV_2(par_id(1):par_id(2):par_id(3),:,:,&
1130 &sxr_loc(1,1):sxr_loc(2,1)) = &
1131 &x%PV_2(par_id(1):par_id(2):par_id(3),:,:,&
1132 &sxr_loc(1,1):sxr_loc(2,1)) +
iu*dum_4d
1137 &
'RE_KV_0',rich_lvl=id,lim_loc=lim_mem(:,:,1))
1140 x%KV_0(par_id(1):par_id(2):par_id(3),:,:,&
1141 &sxr_loc(1,1):sxr_loc(2,1)) = dum_4d
1146 &
'IM_KV_0',rich_lvl=id,lim_loc=lim_mem(:,:,1))
1149 x%KV_0(par_id(1):par_id(2):par_id(3),:,:,&
1150 &sxr_loc(1,1):sxr_loc(2,1)) = &
1151 &x%KV_0(par_id(1):par_id(2):par_id(3),:,:,&
1152 &sxr_loc(1,1):sxr_loc(2,1)) +
iu*dum_4d
1157 &
'RE_KV_2',rich_lvl=id,lim_loc=lim_mem(:,:,1))
1160 x%KV_2(par_id(1):par_id(2):par_id(3),:,:,&
1161 &sxr_loc(1,1):sxr_loc(2,1)) = dum_4d
1166 &
'IM_KV_2',rich_lvl=id,lim_loc=lim_mem(:,:,1))
1169 x%KV_2(par_id(1):par_id(2):par_id(3),:,:,&
1170 &sxr_loc(1,1):sxr_loc(2,1)) = &
1171 &x%KV_2(par_id(1):par_id(2):par_id(3),:,:,&
1172 &sxr_loc(1,1):sxr_loc(2,1)) +
iu*dum_4d
1176 if (read_this(2))
then
1179 &
'RE_PV_1',rich_lvl=id,lim_loc=lim_mem(:,:,2))
1182 x%PV_1(par_id(1):par_id(2):par_id(3),:,:,&
1183 &sxr_loc(1,2):sxr_loc(2,2)) = dum_4d
1188 &
'IM_PV_1',rich_lvl=id,lim_loc=lim_mem(:,:,2))
1191 x%PV_1(par_id(1):par_id(2):par_id(3),:,:,&
1192 &sxr_loc(1,2):sxr_loc(2,2)) = &
1193 &x%PV_1(par_id(1):par_id(2):par_id(3),:,:,&
1194 &sxr_loc(1,2):sxr_loc(2,2)) +
iu*dum_4d
1199 &
'RE_KV_1',rich_lvl=id,lim_loc=lim_mem(:,:,2))
1202 x%KV_1(par_id(1):par_id(2):par_id(3),:,:,&
1203 &sxr_loc(1,2):sxr_loc(2,2)) = dum_4d
1208 &
'IM_KV_1',rich_lvl=id,lim_loc=lim_mem(:,:,2))
1211 x%KV_1(par_id(1):par_id(2):par_id(3),:,:,&
1212 &sxr_loc(1,2):sxr_loc(2,2)) = &
1213 &x%KV_1(par_id(1):par_id(2):par_id(3),:,:,&
1214 &sxr_loc(1,2):sxr_loc(2,2)) +
iu*dum_4d
1233 character(*),
parameter :: rout_name =
'reconstruct_PB3D_vac'
1236 type(
vac_type),
intent(inout) :: vac
1237 character(len=*),
intent(in) :: data_name
1238 integer,
intent(in),
optional :: rich_lvl
1242 integer :: rich_lvl_loc
1254 if (
present(rich_lvl)) rich_lvl_loc = rich_lvl
1258 &rich_lvl=rich_lvl_loc)
1261 style = nint(dum_1d(1))
1262 n_bnd = nint(dum_1d(2))
1263 prim_x = nint(dum_1d(3))
1264 n_ang = nint(dum_1d(4:5))
1269 ierr = vac%init(style,n_bnd,prim_x,n_ang,jq)
1274 &
'sec_X',rich_lvl=rich_lvl_loc)
1277 vac%sec_X = nint(dum_1d)
1283 &
'norm',rich_lvl=rich_lvl_loc)
1291 &
'x_vec',rich_lvl=rich_lvl_loc)
1298 select case (vac%style)
1302 &
'h_fac',rich_lvl=rich_lvl_loc)
1310 &
'ang',rich_lvl=rich_lvl_loc)
1318 &
'dnorm',rich_lvl=rich_lvl_loc)
1328 &
'RE_res',rich_lvl=rich_lvl_loc)
1336 &
'IM_res',rich_lvl=rich_lvl_loc)
1339 vac%res = vac%res +
iu*dum_2d
1358 &lim_sec_sol,lim_pos)
result(ierr)
1364 character(*),
parameter :: rout_name =
'reconstruct_PB3D_sol'
1368 type(grid_type),
intent(in) :: grid_sol
1369 type(
sol_type),
intent(inout) :: sol
1370 character(len=*),
intent(in) :: data_name
1371 integer,
intent(in),
optional :: rich_lvl
1372 integer,
intent(in),
optional :: lim_sec_sol(2)
1373 integer,
intent(in),
optional :: lim_pos(1,2)
1377 integer :: lim_sec_sol_loc(2)
1378 integer :: lim_mem(3,2)
1390 n_ev = var_1d%tot_i_max(3)-var_1d%tot_i_min(3)+1
1395 if (
present(lim_sec_sol)) lim_sec_sol_loc = lim_sec_sol
1398 call sol%init(mds,grid_sol,n_ev,lim_sec_sol)
1401 lim_mem(1,:) = lim_sec_sol_loc
1402 lim_mem(2,:) = [grid_sol%i_min,grid_sol%i_max]
1403 lim_mem(3,:) = [-1,-1]
1404 if (
present(lim_pos))
then
1405 lim_mem(2,:) = lim_mem(2,:) + lim_pos(1,1) - 1
1424 sol%val = sol%val +
iu*dum_1d
1430 &rich_lvl=rich_lvl,lim_loc=lim_mem)
1439 &rich_lvl=rich_lvl,lim_loc=lim_mem)
1442 sol%vec = sol%vec +
iu*dum_3d
1458 character(*),
parameter :: rout_name =
'get_PB3D_grid_size'
1461 integer,
intent(inout) :: n(3)
1462 character(len=*),
intent(in) :: grid_name
1463 integer,
intent(in),
optional :: rich_lvl
1464 logical,
intent(in),
optional :: tot_rich
1468 real(dp),
allocatable :: dum_1d(:)
1476 &
'n',rich_lvl=rich_lvl)
1484 if (
present(tot_rich) .and.
present(rich_lvl))
then
1485 if (tot_rich .and. rich_lvl.gt.1) n(1) = n(1)*2+1
Converts 1-D to n-D variables.
Variables that have to do with equilibrium quantities and the grid used in the calculations:
real(dp), public r_0
independent normalization constant for nondimensionalization
real(dp), public psi_0
derived normalization constant for nondimensionalization
real(dp), public max_flux_f
max. flux in Flux coordinates, set in calc_norm_range_PB3D_in
real(dp), public t_0
derived normalization constant for nondimensionalization
real(dp), public max_flux_e
max. flux in Equilibrium coordinates, set in calc_norm_range_PB3D_in
real(dp), public rho_0
independent normalization constant for nondimensionalization
real(dp), public pres_0
independent normalization constant for nondimensionalization
real(dp), public vac_perm
either usual mu_0 (default) or normalized
real(dp), public b_0
derived normalization constant for nondimensionalization
Variables pertaining to the different grids used.
integer, public n_alpha
nr. of field-lines
integer, public n_r_eq
nr. of normal points in equilibrium grid
integer, public n_r_in
nr. of normal points in input grid
real(dp), public max_alpha
max. of field-line label [ ] in field-aligned grid
real(dp), public min_alpha
min. of field-line label [ ] in field-aligned grid
integer, public n_r_sol
nr. of normal points in solution grid
Operations on HDF5 and XDMF variables.
integer function, public read_hdf5_arr(var, pb3d_name, head_name, var_name, rich_lvl, disp_info, lim_loc)
Reads a PB3D output file in HDF5 format.
Variables pertaining to HDF5 and XDMF.
Variables that have to do with HELENA quantities.
integer, public ias
0 if top-bottom symmetric, 1 if not
integer, public nchi
nr. of poloidal points
real(dp), dimension(:,:), allocatable, public r_h
major radius (xout)
real(dp), dimension(:,:), allocatable, public h_h_33
upper metric factor (1 / gem12)
real(dp), dimension(:,:), allocatable, public rbphi_h
real(dp), dimension(:,:), allocatable, public pres_h
pressure profile
real(dp), dimension(:,:), allocatable, public z_h
height (yout)
real(dp), dimension(:,:), allocatable, public q_saf_h
safety factor
real(dp), dimension(:), allocatable, public chi_h
poloidal angle
real(dp), dimension(:,:), allocatable, public h_h_12
upper metric factor (gem12)
real(dp), dimension(:,:), allocatable, public flux_p_h
poloidal flux
real(dp), dimension(:,:), allocatable, public h_h_11
upper metric factor (gem11)
real(dp), dimension(:,:), allocatable, public rot_t_h
rotational transform
real(dp), dimension(:,:), allocatable, public flux_t_h
toroidal flux
Numerical utilities related to giving output.
subroutine, public lvl_ud(inc)
Increases/decreases lvl of output.
subroutine, public writo(input_str, persistent, error, warning, alert)
Write output to file identified by output_i.
Numerical variables used by most other modules.
integer, parameter, public dp
double precision
integer, public norm_disc_prec_sol
precision for normal discretization for solution
integer, parameter, public max_name_ln
maximum length of filenames
real(dp), parameter, public pi
real(dp), public max_njq_change
maximum change of prim. mode number times saf. fac. / rot. transf. when using X_style 2 (fast)
integer, public n_procs
nr. of MPI processes
complex(dp), parameter, public iu
complex unit
integer, parameter, public max_str_ln
maximum length of strings
real(dp), public ev_bc
value of artificial Eigenvalue for boundary condition
integer, public prog_style
program style (1: PB3D, 2: PB3D_POST)
logical, public use_normalization
whether to use normalization or not
integer, public norm_disc_style_sol
style for normal discretization for solution (1: central fin. diff., 2: left fin. diff....
integer, public u_style
style for calculation of U (1: ord.2, 2: ord.1, 1: ord.0)
logical, public debug_version
debug version used
real(dp), parameter, public min_pb3d_version
minimum PB3D version for POST
integer, public x_grid_style
style for normal component of X grid (1: eq, 2: sol, 3: enriched)
integer, public rho_style
style for equilibrium density profile
integer, parameter, public max_deriv
highest derivatives for metric factors in Flux coords.
integer, public eq_style
either 1 (VMEC) or 2 (HELENA)
character(len=max_str_ln), public pb3d_name
name of PB3D output file
integer, public norm_disc_prec_eq
precision for normal discretization for equilibrium
integer, public alpha_style
style for alpha (1: one field line, many turns, 2: many field lines, one turn)
integer, dimension(2), public bc_style
style for BC left and right
integer, public ev_style
determines the method used for solving an EV problem
integer, public rank
MPI rank.
integer, public k_style
style for kinetic energy
integer, public norm_disc_prec_x
precision for normal discretization for perturbation
integer, public norm_style
style for normalization
integer, public x_style
style for secondary mode numbers (1: prescribed, 2: fast)
integer, public matrix_slepc_style
style for matrix storage (1: sparse, 2: shell)
logical, public use_pol_flux_e
whether poloidal flux is used in E coords.
logical, public use_pol_flux_f
whether poloidal flux is used in F coords.
integer, public magn_int_style
style for magnetic integrals (1: trapezoidal, 2: Simpson 3/8)
Operations concerning giving output, on the screen as well as in output files.
Operations on PB3D output.
integer function, public reconstruct_pb3d_vac(vac, data_name, rich_lvl)
Reconstructs the vacuum variables from PB3D HDF5 output.
integer function, public reconstruct_pb3d_eq_1(grid_eq, eq, data_name, lim_pos)
Reconstructs the equilibrium variables from PB3D HDF5 output.
integer function, public reconstruct_pb3d_x_2(mds, grid_x, x, data_name, rich_lvl, tot_rich, lim_sec_x, lim_pos, is_field_averaged)
Reconstructs the tensorial perturbation variables from PB3D HDF5 output.
integer function, public reconstruct_pb3d_grid(grid, data_name, rich_lvl, tot_rich, lim_pos, grid_limits)
Reconstructs grid variables from PB3D HDF5 output.
integer function, public get_pb3d_grid_size(n, grid_name, rich_lvl, tot_rich)
get grid size
integer function, public reconstruct_pb3d_x_1(mds, grid_x, x, data_name, rich_lvl, tot_rich, lim_sec_x, lim_pos)
Reconstructs the vectorial perturbation variables from PB3D HDF5 output.
integer function, public reconstruct_pb3d_eq_2(grid_eq, eq, data_name, rich_lvl, tot_rich, lim_pos)
Reconstructs the equilibrium variables from PB3D HDF5 output.
integer function, public reconstruct_pb3d_in(data_name)
Reconstructs the input variables from PB3D HDF5 output.
integer function, public reconstruct_pb3d_sol(mds, grid_sol, sol, data_name, rich_lvl, lim_sec_sol, lim_pos)
Reconstructs the solution variables from PB3D HDF5 output.
Numerical utilities related to PB3D operations.
integer function, dimension(2), public setup_rich_id(rich_lvl_max, tot_rich)
Returns richardson id.
integer function, dimension(3), public setup_par_id(grid, rich_lvl_max, rich_lvl_loc, tot_rich, par_lim, par_id_mem)
Setup parallel id.
Variables pertaining to the solution quantities.
elemental character(len=max_str_ln) function, public r2strt(k)
Convert a real (double) to string.
Variables pertaining to the vacuum quantities.
Variables that concern the output of VMEC.
real(dp), dimension(:,:), allocatable, public q_saf_v
safety factor
real(dp), dimension(:,:,:), allocatable, public jac_v_c
Coeff. of in sine series (HM and FM) and norm. deriv.
real(dp), dimension(:,:,:), allocatable, public b_v_sub_c
Coeff. of B_i in sine series (r,theta,phi) (FM).
integer, dimension(:,:), allocatable, public mn_v
m and n of modes
real(dp), dimension(:,:,:), allocatable, public l_v_s
Coeff. of in cosine series (HM) and norm. deriv.
real(dp), dimension(:,:,:), allocatable, public z_v_c
Coeff. of in sine series (FM) and norm. deriv.
real(dp), dimension(:,:), allocatable, public rot_t_v
rotational transform
real(dp), dimension(:,:,:), allocatable, public jac_v_s
Coeff. of in cosine series (HM and FM) and norm. deriv.
real(dp), dimension(:,:,:), allocatable, public r_v_c
Coeff. of in sine series (FM) and norm. deriv.
real(dp), dimension(:,:), allocatable, public pres_v
pressure
real(dp), dimension(:,:), allocatable, public j_v_sup_int
Integrated poloidal and toroidal current (FM).
real(dp), dimension(:,:,:), allocatable, public b_v_sub_s
Coeff. of B_i in cosine series (r,theta,phi) (FM).
real(dp), dimension(:,:), allocatable, public b_v_s
Coeff. of magnitude of B in cosine series (HM and FM).
real(dp), dimension(:,:), allocatable, public flux_t_v
toroidal flux
real(dp), dimension(:,:,:), allocatable, public z_v_s
Coeff. of in cosine series (FM) and norm. deriv.
real(dp), dimension(:,:,:), allocatable, public r_v_s
Coeff. of in cosine series (FM) and norm. deriv.
real(dp), dimension(:,:,:), allocatable, public l_v_c
Coeff. of in sine series (HM) and norm. deriv.
real(dp), dimension(:,:), allocatable, public b_v_c
Coeff. of magnitude of B in sine series (HM and FM).
real(dp), dimension(:,:), allocatable, public flux_p_v
poloidal flux
Numerical utilities related to perturbation operations.
subroutine, public get_sec_x_range(sec_x_range_loc, sec_x_range_tot, m, sym, lim_sec_x)
Gets one of the the local ranges of contiguous tensorial perturbation variables to be printed or read...
Variables pertaining to the perturbation quantities.
integer, public min_sec_x
m_X (pol. flux) or n_X (tor. flux) (only for X style 1)
real(dp), public max_r_sol
max. normal range for pert.
integer, public n_mod_x
size of m_X (pol. flux) or n_X (tor. flux)
real(dp), public min_r_sol
min. normal range for pert.
integer, public max_sec_x
m_X (pol. flux) or n_X (tor. flux) (only for\ c X style 1)
integer, public prim_x
n_X (pol. flux) or m_X (tor. flux)
1D equivalent of multidimensional variables, used for internal HDF5 storage.
vectorial perturbation type
tensorial perturbation type