1 SUBROUTINE open_output_files (extension, iseq, lmac, lscreen,
4 USE vparams,
ONLY: nmac, nthreed, nmac0, nthreed0
10 CHARACTER(LEN=*) :: extension
11 LOGICAL :: lmac, lscreen, lfirst, lwrite
15 INTEGER :: iread, inthreed=0, imac0=0
16 CHARACTER(LEN=120) :: mac_file, threed1_file
21 threed1_file =
'threed1.'//extension
22 mac_file =
'mac.'//extension
27 INQUIRE(file=threed1_file, opened=lfirst)
30 IF (.NOT.lfirst)
RETURN
32 IF (lscreen)
WRITE (*,
'(33('' -''))')
34 CALL safe_open(nthreed, iread, threed1_file,
'new',
36 IF (iread .ne. 0)
THEN
37 IF (iseq .eq. 0 .and. lscreen) print *,
38 1
' VMEC OUTPUT FILES ALREADY EXIST: OVERWRITING THEM ...'
39 CALL safe_open(nthreed, inthreed, threed1_file,
40 1
'replace',
'formatted')
43 nmac = max(nmac0, nthreed)
45 CALL safe_open(nmac, imac0, mac_file,
'replace',
48 IF (inthreed.ne.0 .or. imac0.ne.0)
THEN
49 print *,
' nthreed = ', nthreed,
' istat_threed = ',
50 1 inthreed,
' nmac0 = ', nmac,
' istat_mac0 = ', imac0
51 print *,
'Error opening output file in VMEC ',
57 END SUBROUTINE open_output_files