Skip to content

Commit 8d56d67

Browse files
committed
bugfix when l_energy_modes is used in non-magnetic setups
1 parent 4a0c627 commit 8d56d67

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

src/spectra.f90

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,12 @@ subroutine initialize_spectra()
139139
am_mpol_file='am_mag_pol.'//tag
140140
am_mtor_file='am_mag_tor.'//tag
141141

142-
if ( rank == 0 .and. (.not. l_save_out) ) then
143-
if ( l_mag .and. l_energy_modes ) then
144-
open(newunit=n_am_kpol_file,file=am_kpol_file,status='new', &
145-
& form='unformatted')
146-
open(newunit=n_am_ktor_file,file=am_ktor_file,status='new', &
147-
& form='unformatted')
142+
if ( rank == 0 .and. (.not. l_save_out) .and. l_energy_modes ) then
143+
open(newunit=n_am_kpol_file,file=am_kpol_file,status='new', &
144+
& form='unformatted')
145+
open(newunit=n_am_ktor_file,file=am_ktor_file,status='new', &
146+
& form='unformatted')
147+
if ( l_mag ) then
148148
open(newunit=n_am_mpol_file,file=am_mpol_file,status='new', &
149149
& form='unformatted')
150150
open(newunit=n_am_mtor_file,file=am_mtor_file,status='new', &
@@ -225,10 +225,10 @@ subroutine finalize_spectra()
225225
call dT_ICB_m_ave%finalize()
226226
end if
227227

228-
if ( rank == 0 .and. (.not. l_save_out) ) then
229-
if ( l_mag .and. l_energy_modes ) then
230-
close(n_am_kpol_file)
231-
close(n_am_ktor_file)
228+
if ( rank == 0 .and. (.not. l_save_out) .and. l_energy_modes ) then
229+
close(n_am_kpol_file)
230+
close(n_am_ktor_file)
231+
if ( l_mag ) then
232232
close(n_am_mpol_file)
233233
close(n_am_mtor_file)
234234
end if

0 commit comments

Comments
 (0)