-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_imas.f90
160 lines (131 loc) · 6.06 KB
/
test_imas.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
!-----------------------------------------------------------------------
! Module: TEST_IMAS_MODULE
! Authors: S. Lazerson ([email protected])
! Date: 09/22/2021
! Description: Provides IMAS interfaces for running VMEC from
! IMAS. Currently we assume the code runs
! standalone.
!-----------------------------------------------------------------------
MODULE TEST_IMAS_MODULE
CONTAINS
!-----------------------------------------------------------------------
! SUBROUTINE: VMEC_IMAS_INIT
! PURPOSE: Handles Initialization of VMEC
!-----------------------------------------------------------------------
SUBROUTINE TEST_IMAS_INIT(INDATA_XML, status_code, status_message)
!---------------------------------------------------------------------
! Libraries
!---------------------------------------------------------------------
USE ids_schemas
!---------------------------------------------------------------------
! INPUT/OUTPUT VARIABLES
! INDATA_XML : VMEC INDATA namelist AS XML
! STATUS_CODE : STATUS Flag
! STATUS_MESSAGE : Text Message
!---------------------------------------------------------------------
IMPLICIT NONE
TYPE(ids_parameters_input), INTENT(IN) :: INDATA_XML
INTEGER, INTENT(OUT) :: status_code
CHARACTER(LEN=:), POINTER, INTENT(OUT) :: status_message
!---------------------------------------------------------------------
! BEGIN EXECUTION
!---------------------------------------------------------------------
status_code = 0
!status_message = 'OK'
END SUBROUTINE TEST_IMAS_INIT
!-----------------------------------------------------------------------
! SUBROUTINE: TEST_IMAS
! PURPOSE: RUNS VMEC ASSUMING XML DEFINES RUN LIKE THE
! NAMELIST
!-----------------------------------------------------------------------
SUBROUTINE TEST_IMAS(IDS_EQ_IN, IDS_EQ_OUT, INDATA_XML, status_code, status_message)
!---------------------------------------------------------------------
! Libraries
!---------------------------------------------------------------------
USE ids_schemas
USE mpi
!---------------------------------------------------------------------
! INPUT/OUTPUT VARIABLES
! IDS_EQ_OUT : Equilibrium output
! INDATA_XML : VMEC INDATA namelist AS XML
! STATUS_CODE : STATUS Flag
! STATUS_MESSAGE : Text Message
!---------------------------------------------------------------------
IMPLICIT NONE
TYPE(ids_equilibrium), INTENT(IN) :: IDS_EQ_IN
TYPE(ids_equilibrium), INTENT(OUT) :: IDS_EQ_OUT
TYPE(ids_parameters_input), INTENT(IN) :: INDATA_XML
INTEGER, INTENT(OUT) :: status_code
CHARACTER(LEN=:), POINTER, INTENT(OUT) :: status_message
!---------------------------------------------------------------------
! SUBROUTINE VARIABLES
!---------------------------------------------------------------------
LOGICAL :: lmpi_flag, lscreen
INTEGER :: impi_flag, ivmec_flag, RVC_COMM, grank, gnranks
INTEGER :: ictrl(5), myseq
CHARACTER(len = 128) :: reset_string, filename
!---------------------------------------------------------------------
! BEGIN EXECUTION
!---------------------------------------------------------------------
!---- Default outputs
status_code = 0
!status_message = 'OK'
!---- MPI initialisation ----
! CALL MPI_initialized(lmpi_flag, impi_flag)
! if (.not. lmpi_flag) call MPI_INIT(impi_flag)
!---- MIMIC CALL InitializeParallel
CALL MPI_Comm_rank(MPI_COMM_WORLD,grank,impi_flag)
CALL MPI_Comm_size(MPI_COMM_WORLD,gnranks,impi_flag)
!---- Duplicate the communicator
CALL MPI_COMM_DUP(MPI_COMM_WORLD,RVC_COMM,impi_flag)
!---- Interface with Equilibirum IDS
CALL TEST_EQIN_IMAS(IDS_EQ_IN,status_code,status_message)
!---- Write out EQUILIBRIUM
!---------------------------------------------------------------------
! END EXECUTION - Don't touch below here
!---------------------------------------------------------------------
!---- MPI Finalisation ----
! call MPI_finalized(lmpi_flag, impi_flag)
! IF (.NOT. lmpi_flag) CALL MPI_Finalize(impi_flag)
END SUBROUTINE TEST_IMAS
!-----------------------------------------------------------------------
! SUBROUTINE: VMEC_EQIN_IMAS
! PURPOSE: Handles setting up the indata variables
!-----------------------------------------------------------------------
SUBROUTINE TEST_EQIN_IMAS(IDS_EQ_IN, status_code, status_message)
!---------------------------------------------------------------------
! Libraries
!---------------------------------------------------------------------
USE ids_schemas
!---------------------------------------------------------------------
! INPUT/OUTPUT VARIABLES
! INDATA_XML : VMEC INDATA namelist AS XML
! STATUS_CODE : STATUS Flag
! STATUS_MESSAGE : Text Message
!---------------------------------------------------------------------
IMPLICIT NONE
TYPE(ids_equilibrium), INTENT(IN) :: IDS_EQ_IN
INTEGER, INTENT(OUT) :: status_code
CHARACTER(LEN=:), POINTER, INTENT(OUT) :: status_message
!---------------------------------------------------------------------
! SUBROUTINE VARIABLES
!---------------------------------------------------------------------
INTEGER :: cocos_index, npts_imas, u, mn, itime
REAL*8 :: B0
REAL*8, ALLOCATABLE, DIMENSION(:) :: R_BND, Z_BND, radius, theta
!---------------------------------------------------------------------
! BEGIN EXECUTION
!---------------------------------------------------------------------
status_code = 0
itime = 1 ! This ia a hack
!---- Check the IDS for timeslices
IF (.not. ASSOCIATED(IDS_EQ_IN%time_slice)) THEN
WRITE(*,*) 'No time slices in this equilibrium'
! STOP
END IF
!---- Check Cocos Index
cocos_index = IDS_EQ_IN%time_slice(itime)%profiles_2d(1)%grid_type%index
WRITE(*,*) ' IDS COCOS Convention: ',cocos_index
RETURN
END SUBROUTINE TEST_EQIN_IMAS
END MODULE TEST_IMAS_MODULE