Routine to write the response matrix for this supercell to netcdf file.
Only the head processor actually writes to file. However, in current use we only call this routine on processors which have this supercell local and which don't consider it empty. This is usually ok, but for box runs the mode with ky=kx=0 (super)cell is forced to be considered empty which means that, as it stands, this supercell won't be dumped here (although it is for the fields_implicit approach). This could cause issues for restoring these response matrices as we end up recalculating these if we can't load any expected file. As such we have to be careful how we deal with this matrix.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(supercell_type), | intent(inout) | :: | self |
The instance of the supercell class |
||
character(len=*), | intent(in), | optional | :: | suffix |
If passed then use as part of file suffix |
subroutine sc_dump_to_file(self, suffix)
use gs2_save, only: gs2_save_response
use fields_arrays, only: get_specific_response_file_name, time_dump_response
use gs2_time, only: code_dt
use job_manage, only: time_message
implicit none
!> The instance of the supercell class
class(supercell_type), intent(in out) :: self
!> If passed then use as part of file suffix
character(len=*), optional, intent(in) :: suffix
complex, dimension(:,:), allocatable :: tmp_arr
! Exit early if we're not involved in this supercell
if(.not.self%is_local) return
call time_message(.false.,time_dump_response,' Field Dump')
!Allocate array -- for big problems this might be an issue
allocate(tmp_arr(self%nrow,self%ncol))
!First have to pull all row level data
call self%pull_rows_to_arr(tmp_arr)
!Now save if on head proc -- could probably only allocate tmp_arr and call
!pull_rows_to_arr on this head proc as well, at least for now.
if(self%is_head)then
call gs2_save_response(tmp_arr, get_specific_response_file_name(self%ik_ind, self%is_ind, code_dt, suffix), code_dt, self%condition_number)
endif
deallocate(tmp_arr)
call time_message(.false.,time_dump_response,' Field Dump')
end subroutine sc_dump_to_file