V3FIT
packafile.f
1 !*******************************************************************************
2 ! File packafile.f
3 ! Module for use in program v3post
4 ! Packs the responses into a single binary file as NETCDF files
5 ! for the coil responses and the plasma responses are read.
6 ! packed file format: (intgerer*4 and real(rprec) logicals and strings)
7 ! n_diagn_c n_field_cg
8 ! cl_response(1:n_diagn_c,1:n_field_cg)
9 ! ir jz kp kp_store,
10 ! rmin,rmax,zmin,zmax
11 ! n_field_periods
12 ! lstell_sym
13 ! REPEAT n_diagn_c TIMES:
14 ! diag# shortname
15 ! component#, array(ir,jz,kp_store)
16 ! THIS PRODUCES A FILES SIZE OF ABOUT 7.9 Mb / DIAGNOSTIC
17 !-------------------------------------------------------------------------------
18 ! DEPENDENCIES
19 !-------------------------------------------------------------------------------
20 !
21 ! This module uses the following modules:
22 ! stel_kinds
23 ! stel_constants
24 !
25 !-------------------------------------------------------------------------------
26 ! CHANGE HISTORY
27 !-------------------------------------------------------------------------------
28 !
29 ! Initial Coding - Ed Lazarus 03.31.2005
30 !-------------------------------------------------------------------------------
31 ! USAGE : Called within read_response if pack=T in V3POST namelist
32 !-------------------------------------------------------------------------------
33 !
34 !-------------------------------------------------------------------------------
35 ! COMMENTS I A response to the failure to successfully read prfun files when
36 ! many parallel proccesses are active
37 !-------------------------------------------------------------------------------
38 !
39 !
40 !*******************************************************************************
41 ! MODULE read_response
42 !
43 ! SECTION I. VARIABLE DECLARATIONS
44 ! SECTION II. INTERFACE BLOCKS
45 ! SECTION III. COIL PACKING
46 ! SECTION IV. PLASMA PACKING
47 !*******************************************************************************
48 
49 !*******************************************************************************
50 ! SECTION I. VARIABLE DECLARATIONS
51 !*******************************************************************************
52 
53  MODULE packafile
54 
55 ! work_arrays avoids premature size definition of arrays
56  USE stel_kinds
57  USE stel_constants
58 
59 
60 ! Other variables
61  INTEGER :: npack = 0, nhere=1
62  INTEGER :: one1 = 1, two2 = 2, three3 = 3
63  LOGICAL :: pack_in_read = .false.
64  ChARACTER(len=80) :: packafilename
65 !*******************************************************************************
66 ! SECTION II. INTERFACE BLOCKS
67 !*******************************************************************************
68 !-------------------------------------------------------------------------------
69 !
70 !-------------------------------------------------------------------------------
71 
72  CONTAINS
73 
74 !*******************************************************************************
75 ! SECTION III. COIL RESPONSE FUNCTION READ
76 !*******************************************************************************
77 !-------------------------------------------------------------------------------
78 !
79 !-------------------------------------------------------------------------------
80  SUBROUTINE open_packafile (filename)
81  USE safe_open_mod
82  IMPLICIT NONE
83 
84 !-----------------------------------------------
85 ! D u m m y A r g u m e n t s
86 !-----------------------------------------------
87  CHARACTER(len=*) :: filename
88 !-----------------------------------------------
89 ! L o c a l V a r i a b l e s
90 !-----------------------------------------------
91  INTEGER :: istat
92 
93 
94  CALL safe_open(npack, istat, filename,
95  1 'unknown', 'unformatted')
96  IF (istat .ne. 0) stop
97  1 'safe_open iostat != 0 in open_packafile'
98 ! closed on exit from V3POST
99 
100  END SUBROUTINE open_packafile
101 
102  SUBROUTINE read_packafile (filename)
103  USE safe_open_mod
104  IMPLICIT NONE
105 
106 !-----------------------------------------------
107 ! D u m m y A r g u m e n t s
108 !-----------------------------------------------
109  CHARACTER(len=*) :: filename
110 !-----------------------------------------------
111 ! L o c a l V a r i a b l e s
112 !-----------------------------------------------
113  INTEGER :: istat
114 
115 
116  CALL safe_open(npack, istat, filename,
117  1 'old', 'unformatted')
118  IF (istat .ne. 0) stop
119  1 'safe_open iostat != 0 in read_packafile'
120 ! closed on exit from V3POST
121 
122  END SUBROUTINE read_packafile
123 
124 
125  END MODULE packafile
126