mechanism to act upon options supplied to the library input is parsed and interpreted (any errors are identified) and the library data structure (variable common_data) is populated ready for use
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(lib_common_type), | intent(inout) | :: | common_data |
instance of library data object, modified here |
||
| character(len=*), | intent(in) | :: | seedname | |||
| integer, | intent(in) | :: | istdout | |||
| integer, | intent(in) | :: | istderr | |||
| integer, | intent(out) | :: | ierr |
subroutine w90_input_setopt(common_data, seedname, istdout, istderr, ierr) !! mechanism to act upon options supplied to the library !! input is parsed and interpreted (any errors are identified) and !! the library data structure (variable common_data) is populated ready for use ! w90_input_setopt() processes options stored in common_data%settings ! w90_input_reader() processes options stored in common_data%in_data (from .win file, should be empty here) #ifdef W90_MPI08 use mpi_f08 #endif #ifdef W90_MPI90 use mpi #endif use w90_error_base, only: w90_error_type use w90_error, only: set_error_alloc, set_error_fatal, code_mpi use w90_comms, only: w90_comm_type, valid_communicator, mpisize, mpirank use w90_readwrite, only: w90_readwrite_write_win use w90_wannier90_readwrite, only: w90_wannier90_readwrite_read, & w90_wannier90_readwrite_read_special use w90_overlap, only: overlap_write implicit none #ifdef W90_MPIH include 'mpif.h' #endif ! arguments character(len=*), intent(in) :: seedname integer, intent(in) :: istdout, istderr integer, intent(out) :: ierr type(lib_common_type), intent(inout) :: common_data !! instance of library data object, modified here ! local variables type(w90_error_type), allocatable :: error logical :: cp_pp ierr = 0 if (.not. valid_communicator(common_data%comm)) then ! when MPI is not defined, valid_communicator returns true (see comms.F90) ! this is a problem: how do we exit using the parallel error handler when the communicator is unknown? write (istderr, *) ' Error: parallel Wannier90 library invoked with invalid communicator, exiting. Use w90_set_comm()!' ierr = code_mpi return end if if (allocated(common_data%settings%in_data)) then call set_error_fatal(error, & ' Error: w90_read_input() and w90_set_option() clash at w90_input_setopt() call', common_data%comm) call prterr(error, ierr, istdout, istderr, common_data%comm) return else if (.not. allocated(common_data%settings%entries)) then call set_error_fatal(error, ' Error: w90_input_setopt() called with no input set', common_data%comm) call prterr(error, ierr, istdout, istderr, common_data%comm) return !else if (.not. allocated(common_data%dist_kpoints)) then ! call set_error_fatal(error, ' input_setopt called but distk unallocated', common_data%comm) ! call prterr(error, ierr, istdout, istderr, common_data%comm) ! return end if common_data%seedname = seedname ! set seedname for input/output files ! read_special can only be executed once per library object ! it sets key variables (eg, number of k-points sizing allocations, etc) call w90_wannier90_readwrite_read_special(common_data%settings, common_data%atom_data, & common_data%kmesh_input, common_data%kmesh_info, & common_data%kpt_latt, common_data%wann_control, & common_data%proj, common_data%proj_input, & common_data%select_proj, common_data%w90_system, & common_data%w90_calculation, & common_data%real_lattice, common_data%physics%bohr, & common_data%mp_grid, common_data%num_bands, & common_data%exclude_bands, & common_data%num_kpts, common_data%num_proj, & common_data%num_wann, common_data%gamma_only, & common_data%lhasproj, & common_data%use_bloch_phases, & common_data%dist_kpoints, istdout, error, & common_data%comm) if (allocated(error)) then call prterr(error, ierr, istdout, istderr, common_data%comm) return end if ! condition for disentanglement is number of bands > number of WF if (common_data%num_bands > common_data%num_wann) then allocate (common_data%dis_manifold%ndimwin(common_data%num_kpts), stat=ierr) if (ierr /= 0) then call set_error_alloc(error, 'Error allocating ndimwin in w90_input_setopt() library call', common_data%comm) call prterr(error, ierr, istdout, istderr, common_data%comm) return end if allocate (common_data%dis_manifold%nfirstwin(common_data%num_kpts), stat=ierr) if (ierr /= 0) then call set_error_alloc(error, 'Error allocating nfirstwin in w90_input_setopt() library call', common_data%comm) call prterr(error, ierr, istdout, istderr, common_data%comm) return end if allocate (common_data%dis_manifold%lwindow(common_data%num_bands, common_data%num_kpts), stat=ierr) if (ierr /= 0) then call set_error_alloc(error, 'Error allocating lwindow in w90_input_setopt() library call', common_data%comm) call prterr(error, ierr, istdout, istderr, common_data%comm) return end if end if allocate (common_data%wannier_data%centres(3, common_data%num_wann), stat=ierr) if (ierr /= 0) then call set_error_alloc(error, 'Error allocating wannier_centres in w90_input_setopt() library call', common_data%comm) call prterr(error, ierr, istdout, istderr, common_data%comm) return end if common_data%wannier_data%centres = 0.0_dp allocate (common_data%wannier_data%spreads(common_data%num_wann), stat=ierr) if (ierr /= 0) then call set_error_alloc(error, 'Error in allocating wannier_spreads in w90_input_setopt() library call', common_data%comm) call prterr(error, ierr, istdout, istderr, common_data%comm) return end if common_data%wannier_data%spreads = 0.0_dp ! read all other variables; mostly simple variables can be set and/or reset call w90_wannier90_readwrite_read(common_data%settings, common_data%band_plot, & common_data%dis_control, common_data%dis_spheres, & common_data%dis_manifold, common_data%fermi_energy_list, & common_data%fermi_surface_data, common_data%output_file, & common_data%wvfn_read, common_data%wann_control, & common_data%real_space_ham, common_data%kpoint_path, & common_data%w90_system, common_data%tran, & common_data%print_output, common_data%wann_plot, & common_data%ws_region, common_data%real_lattice, & common_data%w90_calculation, common_data%physics%bohr, & common_data%sitesym%symmetrize_eps, common_data%num_bands, & common_data%num_kpts, common_data%num_wann, & common_data%optimisation, common_data%calc_only_A, cp_pp, & common_data%gamma_only, common_data%lsitesymmetry, & common_data%use_bloch_phases, common_data%seedname, istdout, & error, common_data%comm) if (allocated(error)) then call prterr(error, ierr, istdout, istderr, common_data%comm) return end if if (common_data%output_file%write_win_ammats) then if (mpirank(common_data%comm) == 0) then call w90_readwrite_write_win(common_data%settings, seedname, error, common_data%comm) end if if (allocated(error)) then call prterr(error, ierr, istdout, istderr, common_data%comm) return end if end if ! clear settings container (from settings interface not .win file) deallocate (common_data%settings%entries, stat=ierr) if (ierr /= 0) then call set_error_alloc(error, 'Error in deallocating entries data in w90_input_setopt() library call', common_data%comm) call prterr(error, ierr, istdout, istderr, common_data%comm) return end if end subroutine w90_input_setopt