subroutine frantic_input_save(filename,ierr)

  !  save the state of a frantic calcution -- i.e. just before
  !  executing the calculation

  !  saved netcdf file can be used to reproduce the calculation in
  !  the standalone code `frantic_test.f90'.

  use ezcdf
  implicit none

  character(len=*), intent(in) :: filename ! NetCDF filename
  integer, intent(out) :: ierr             ! completion code, 0=OK

  !-----------------------------------------------

  integer :: ncid

  !-----------------------------------------------
  !  create file & write frantic module contents

  call frantic_module_write(filename,ierr)
  if(ierr.ne.0) then
    ierr=1
    return
  end if

  return
end subroutine frantic_input_save
