3.4 Modules in Fortran 87
SUBROUTINE allocate_sp_array(this_array,n)
TYPE (single_particle_descript), INTENT(INOUT) :: this_array
INTEGER , INTENT(IN) :: n
IF (ASSOCIATED (this_array%nn) ) &
DEALLOCATE(this_array%nn)
ALLOCATE(this_array%nn(n))
IF (ASSOCIATED (this_array%ll) ) &
DEALLOCATE(this_array%ll)
ALLOCATE(this_array%ll(n))
IF (ASSOCIATED (this_array%jj) ) &
DEALLOCATE(this_array%jj)
ALLOCATE(this_array%jj(n))
IF (ASSOCIATED (this_array%spin) ) &
DEALLOCATE(this_array%spin)
ALLOCATE(this_array%spin(n))
IF (ASSOCIATED (this_array%e) ) &
DEALLOCATE(this_array%e)
ALLOCATE(this_array%e(n))
IF (ASSOCIATED (this_array%orbit_status) ) &
DEALLOCATE(this_array%orbit_status)
ALLOCATE(this_array%orbit_status(n))
IF (ASSOCIATED (this_array%model_space) ) &
DEALLOCATE(this_array%model_space)
ALLOCATE(this_array%model_space(n))
! blank all charactersandzero all other values
DO i= 1, n
this_array%model_space(i)=' '
this_array%orbit_status(i)=' '
this_array%e(i)=0.
this_array%nn(i)=0
this_array%ll(i)=0
this_array%jj(i)=0
this_array%nshell(i)=0
this_array%itzp(i)=0
ENDDO
SUBROUTINE deallocate_sp_array(this_array)
TYPE (single_particle_descript), INTENT(INOUT) :: this_array
DEALLOCATE(this_array%nn)
DEALLOCATE(this_array%ll)
DEALLOCATE(this_array%jj)
DEALLOCATE(this_array%spin)
DEALLOCATE(this_array%e)
DEALLOCATE(this_array%orbit_status); &
DEALLOCATE(this_array%model_space)
END SUBROUTINE deallocate_sp_array
!
! Read in all relevant single-particle data
!
SUBROUTINE single_particle_data
IMPLICIT NONE
CHARACTER100 :: particle_species
READ(5,) particle_species
WRITE(6,)' Particle species: '
WRITE(6,) particle_species
SELECT CASE (particle_species)
CASE ('electron')
CALL read_electron_sp_data