Skip to content

Commit

Permalink
Some more changes in MPI commands within initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinswales committed Oct 25, 2019
1 parent 6126278 commit f35effe
Show file tree
Hide file tree
Showing 4 changed files with 254 additions and 147 deletions.
92 changes: 62 additions & 30 deletions physics/rrtmgp_lw_cloud_optics.F90
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ subroutine rrtmgp_lw_cloud_optics_init(Model, mpicomm, mpirank, mpiroot, lw_clou
status = nf90_inquire_dimension(ncid_lw_clds, dimid, len=npairsLWcldy)
status = nf90_close(ncid_lw_clds)
endif
endif

! Check to ensure that number of ice-roughness categories is feasible.
if (Model%rrtmgp_nrghice .gt. nrghice_lw) then
errmsg = 'Number of RRTMGP ice-roughness categories requested in namelist file is not allowed'
! Check to ensure that number of ice-roughness categories is feasible.
if (Model%rrtmgp_nrghice .gt. nrghice_lw) then
errmsg = 'Number of RRTMGP ice-roughness categories requested in namelist file is not allowed'
endif
endif

! Broadcast dimensions to all processors
Expand Down Expand Up @@ -258,34 +258,66 @@ subroutine rrtmgp_lw_cloud_optics_init(Model, mpicomm, mpirank, mpiroot, lw_clou
! Broadcast arrays to all processors
#ifdef MPI
if (Model%rrtmgp_cld_optics .eq. 1) then
call MPI_BCAST(radliq_lwr, 1, kind_phys, mpiroot, mpicomm, ierr)
call MPI_BCAST(radliq_upr, 1, kind_phys, mpiroot, mpicomm, ierr)
call MPI_BCAST(radliq_fac, 1, kind_phys, mpiroot, mpicomm, ierr)
call MPI_BCAST(radice_lwr, 1, kind_phys, mpiroot, mpicomm, ierr)
call MPI_BCAST(radice_upr, 1, kind_phys, mpiroot, mpicomm, ierr)
call MPI_BCAST(radice_fac, 1, kind_phys, mpiroot, mpicomm, ierr)
call MPI_BCAST(lut_extliq, size(lut_extliq), kind_phys, mpiroot, mpicomm, ierr)
call MPI_BCAST(lut_ssaliq, size(lut_ssaliq), kind_phys, mpiroot, mpicomm, ierr)
call MPI_BCAST(lut_asyliq, size(lut_asyliq), kind_phys, mpiroot, mpicomm, ierr)
call MPI_BCAST(lut_extice, size(lut_extice), kind_phys, mpiroot, mpicomm, ierr)
call MPI_BCAST(lut_ssaice, size(lut_ssaice), kind_phys, mpiroot, mpicomm, ierr)
call MPI_BCAST(lut_asyice, size(lut_asyice), kind_phys, mpiroot, mpicomm, ierr)
call MPI_BCAST(band_lims_cldy , size(band_lims_cldy), kind_phys, mpiroot, mpicomm, ierr)
#ifndef SINGLE_PREC
call MPI_BCAST(radliq_lwr, 1, MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
call MPI_BCAST(radliq_upr, 1, MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
call MPI_BCAST(radliq_fac, 1, MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
call MPI_BCAST(radice_lwr, 1, MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
call MPI_BCAST(radice_upr, 1, MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
call MPI_BCAST(radice_fac, 1, MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
call MPI_BCAST(lut_extliq, size(lut_extliq), MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
call MPI_BCAST(lut_ssaliq, size(lut_ssaliq), MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
call MPI_BCAST(lut_asyliq, size(lut_asyliq), MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
call MPI_BCAST(lut_extice, size(lut_extice), MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
call MPI_BCAST(lut_ssaice, size(lut_ssaice), MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
call MPI_BCAST(lut_asyice, size(lut_asyice), MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
call MPI_BCAST(band_lims_cldy , size(band_lims_cldy), MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
#else
call MPI_BCAST(radliq_lwr, 1, MPI_REAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(radliq_upr, 1, MPI_REAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(radliq_fac, 1, MPI_REAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(radice_lwr, 1, MPI_REAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(radice_upr, 1, MPI_REAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(radice_fac, 1, MPI_REAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(lut_extliq, size(lut_extliq), MPI_REAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(lut_ssaliq, size(lut_ssaliq), MPI_REAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(lut_asyliq, size(lut_asyliq), MPI_REAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(lut_extice, size(lut_extice), MPI_REAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(lut_ssaice, size(lut_ssaice), MPI_REAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(lut_asyice, size(lut_asyice), MPI_REAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(band_lims_cldy , size(band_lims_cldy), MPI_REAL, mpiroot, mpicomm, ierr)
#endif
endif
if (Model%rrtmgp_cld_optics .eq. 2) then
call MPI_BCAST(pade_extliq, size(pade_extliq), kind_phys, mpiroot, mpicomm, ierr)
call MPI_BCAST(pade_ssaliq, size(pade_ssaliq), kind_phys, mpiroot, mpicomm, ierr)
call MPI_BCAST(pade_asyliq, size(pade_asyliq), kind_phys, mpiroot, mpicomm, ierr)
call MPI_BCAST(pade_extice, size(pade_extice), kind_phys, mpiroot, mpicomm, ierr)
call MPI_BCAST(pade_ssaice, size(pade_ssaice), kind_phys, mpiroot, mpicomm, ierr)
call MPI_BCAST(pade_asyice, size(pade_asyice), kind_phys, mpiroot, mpicomm, ierr)
call MPI_BCAST(pade_sizereg_extliq, size(pade_sizereg_extliq), kind_phys, mpiroot, mpicomm, ierr)
call MPI_BCAST(pade_sizereg_ssaliq, size(pade_sizereg_ssaliq), kind_phys, mpiroot, mpicomm, ierr)
call MPI_BCAST(pade_sizereg_asyliq, size(pade_sizereg_asyliq), kind_phys, mpiroot, mpicomm, ierr)
call MPI_BCAST(pade_sizereg_extice, size(pade_sizereg_extice), kind_phys, mpiroot, mpicomm, ierr)
call MPI_BCAST(pade_sizereg_ssaice, size(pade_sizereg_ssaice), kind_phys, mpiroot, mpicomm, ierr)
call MPI_BCAST(pade_sizereg_asyice, size(pade_sizereg_asyice), kind_phys, mpiroot, mpicomm, ierr)
call MPI_BCAST(band_lims_cldy, size(band_lims_cldy), kind_phys, mpiroot, mpicomm, ierr)
#ifndef SINGLE_PREC
call MPI_BCAST(pade_extliq, size(pade_extliq), MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
call MPI_BCAST(pade_ssaliq, size(pade_ssaliq), MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
call MPI_BCAST(pade_asyliq, size(pade_asyliq), MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
call MPI_BCAST(pade_extice, size(pade_extice), MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
call MPI_BCAST(pade_ssaice, size(pade_ssaice), MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
call MPI_BCAST(pade_asyice, size(pade_asyice), MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
call MPI_BCAST(pade_sizereg_extliq, size(pade_sizereg_extliq), MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
call MPI_BCAST(pade_sizereg_ssaliq, size(pade_sizereg_ssaliq), MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
call MPI_BCAST(pade_sizereg_asyliq, size(pade_sizereg_asyliq), MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
call MPI_BCAST(pade_sizereg_extice, size(pade_sizereg_extice), MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
call MPI_BCAST(pade_sizereg_ssaice, size(pade_sizereg_ssaice), MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
call MPI_BCAST(pade_sizereg_asyice, size(pade_sizereg_asyice), MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
call MPI_BCAST(band_lims_cldy, size(band_lims_cldy), MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
#else
call MPI_BCAST(pade_extliq, size(pade_extliq), MPI_REAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(pade_ssaliq, size(pade_ssaliq), MPI_REAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(pade_asyliq, size(pade_asyliq), MPI_REAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(pade_extice, size(pade_extice), MPI_REAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(pade_ssaice, size(pade_ssaice), MPI_REAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(pade_asyice, size(pade_asyice), MPI_REAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(pade_sizereg_extliq, size(pade_sizereg_extliq), MPI_REAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(pade_sizereg_ssaliq, size(pade_sizereg_ssaliq), MPI_REAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(pade_sizereg_asyliq, size(pade_sizereg_asyliq), MPI_REAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(pade_sizereg_extice, size(pade_sizereg_extice), MPI_REAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(pade_sizereg_ssaice, size(pade_sizereg_ssaice), MPI_REAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(pade_sizereg_asyice, size(pade_sizereg_asyice), MPI_REAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(band_lims_cldy, size(band_lims_cldy), MPI_REAL, mpiroot, mpicomm, ierr)
#endif
endif
#endif

Expand Down
105 changes: 63 additions & 42 deletions physics/rrtmgp_lw_gas_optics.F90
Original file line number Diff line number Diff line change
Expand Up @@ -325,20 +325,37 @@ subroutine rrtmgp_lw_gas_optics_init(Model, Radtend, mpicomm, mpirank, mpiroot,
call MPI_BCAST(kminor_start_lower, size(kminor_start_lower), MPI_INTEGER, mpiroot, mpicomm, ierr)
call MPI_BCAST(key_species, size(key_species), MPI_INTEGER, mpiroot, mpicomm, ierr)
call MPI_BCAST(band2gpt, size(band2gpt), MPI_INTEGER, mpiroot, mpicomm, ierr)
call MPI_BCAST(band_lims, size(band_lims), kind_phys, mpiroot, mpicomm, ierr)
call MPI_BCAST(press_ref, size(press_ref), kind_phys, mpiroot, mpicomm, ierr)
call MPI_BCAST(temp_ref, size(temp_ref), kind_phys, mpiroot, mpicomm, ierr)
call MPI_BCAST(kminor_lower, size(kminor_lower), kind_phys, mpiroot, mpicomm, ierr)
call MPI_BCAST(kminor_upper, size(kminor_upper), kind_phys, mpiroot, mpicomm, ierr)
call MPI_BCAST(scaling_gas_lower, size(scaling_gas_lower), kind_phys, mpiroot, mpicomm, ierr)
call MPI_BCAST(scaling_gas_upper, size(scaling_gas_upper), kind_phys, mpiroot, mpicomm, ierr)
call MPI_BCAST(vmr_ref, size(vmr_ref), kind_phys, mpiroot, mpicomm, ierr)
call MPI_BCAST(kmajor, size(kmajor), kind_phys, mpiroot, mpicomm, ierr)
call MPI_BCAST(temp_ref_p, 1, kind_phys, mpiroot, mpicomm, ierr)
call MPI_BCAST(temp_ref_t, 1, kind_phys, mpiroot, mpicomm, ierr)
call MPI_BCAST(press_ref_trop, 1, kind_phys, mpiroot, mpicomm, ierr)
call MPI_BCAST(totplnk, size(totplnk), kind_phys, mpiroot, mpicomm, ierr)
call MPI_BCAST(planck_frac, size(planck_frac), kind_phys, mpiroot, mpicomm, ierr)
#ifndef SINGLE_PREC
call MPI_BCAST(band_lims, size(band_lims), MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
call MPI_BCAST(press_ref, size(press_ref), MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
call MPI_BCAST(temp_ref, size(temp_ref), MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
call MPI_BCAST(kminor_lower, size(kminor_lower), MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
call MPI_BCAST(kminor_upper, size(kminor_upper), MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
call MPI_BCAST(scaling_gas_lower, size(scaling_gas_lower), MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
call MPI_BCAST(scaling_gas_upper, size(scaling_gas_upper), MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
call MPI_BCAST(vmr_ref, size(vmr_ref), MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
call MPI_BCAST(kmajor, size(kmajor), MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
call MPI_BCAST(temp_ref_p, 1, MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
call MPI_BCAST(temp_ref_t, 1, MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
call MPI_BCAST(press_ref_trop, 1, MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
call MPI_BCAST(totplnk, size(totplnk), MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
call MPI_BCAST(planck_frac, size(planck_frac), MPI_DOUBLE_PRECISION, mpiroot, mpicomm, ierr)
#else
call MPI_BCAST(band_lims, size(band_lims), MPI_REAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(press_ref, size(press_ref), MPI_REAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(temp_ref, size(temp_ref), MPI_REAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(kminor_lower, size(kminor_lower), MPI_REAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(kminor_upper, size(kminor_upper), MPI_REAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(scaling_gas_lower, size(scaling_gas_lower), MPI_REAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(scaling_gas_upper, size(scaling_gas_upper), MPI_REAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(vmr_ref, size(vmr_ref), MPI_REAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(kmajor, size(kmajor), MPI_REAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(temp_ref_p, 1, MPI_REAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(temp_ref_t, 1, MPI_REAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(press_ref_trop, 1, MPI_REAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(totplnk, size(totplnk), MPI_REAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(planck_frac, size(planck_frac), MPI_REAL, mpiroot, mpicomm, ierr)
#endif
! Character arrays
do ij=1,nabsorbers
call MPI_BCAST(gas_names(ij), 32, MPI_CHAR, mpiroot, mpicomm, ierr)
Expand All @@ -355,37 +372,41 @@ subroutine rrtmgp_lw_gas_optics_init(Model, Radtend, mpicomm, mpirank, mpiroot,
enddo
! Logical arrays (First convert to integer-array, then broadcast)
!
allocate(temp_log_array1(nminor_absorber_intervals_lower))
where(minor_scales_with_density_lower)
temp_log_array1 = 1
elsewhere
temp_log_array1 = 0
end where
call MPI_BCAST(temp_log_array1, size(temp_log_array1), MPI_INTEGER, mpiroot, mpicomm, ierr)
call MPI_BCAST(minor_scales_with_density_lower, nminor_absorber_intervals_lower, MPI_LOGICAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(scale_by_complement_lower, nminor_absorber_intervals_lower, MPI_LOGICAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(minor_scales_with_density_upper, nminor_absorber_intervals_upper, MPI_LOGICAL, mpiroot, mpicomm, ierr)
call MPI_BCAST(scale_by_complement_upper, nminor_absorber_intervals_upper, MPI_LOGICAL, mpiroot, mpicomm, ierr)
!allocate(temp_log_array1(nminor_absorber_intervals_lower))
!where(minor_scales_with_density_lower)
! temp_log_array1 = 1
!elsewhere
! temp_log_array1 = 0
!end where
!call MPI_BCAST(temp_log_array1, size(temp_log_array1), MPI_INTEGER, mpiroot, mpicomm, ierr)
!
allocate(temp_log_array2(nminor_absorber_intervals_lower))
where(scale_by_complement_lower)
temp_log_array2 = 1
elsewhere
temp_log_array2 = 0
end where
call MPI_BCAST(temp_log_array2, size(temp_log_array2), MPI_INTEGER, mpiroot, mpicomm, ierr)
!allocate(temp_log_array2(nminor_absorber_intervals_lower))
!where(scale_by_complement_lower)
! temp_log_array2 = 1
!elsewhere
! temp_log_array2 = 0
!end where
!call MPI_BCAST(temp_log_array2, size(temp_log_array2), MPI_INTEGER, mpiroot, mpicomm, ierr)
!
allocate(temp_log_array3(nminor_absorber_intervals_upper))
where(minor_scales_with_density_upper)
temp_log_array3 = 1
elsewhere
temp_log_array3 = 0
end where
call MPI_BCAST(temp_log_array3, size(temp_log_array3), MPI_INTEGER, mpiroot, mpicomm, ierr)
!allocate(temp_log_array3(nminor_absorber_intervals_upper))
!where(minor_scales_with_density_upper)
! temp_log_array3 = 1
!elsewhere
! temp_log_array3 = 0
!end where
!call MPI_BCAST(temp_log_array3, size(temp_log_array3), MPI_INTEGER, mpiroot, mpicomm, ierr)
!
allocate(temp_log_array4(nminor_absorber_intervals_upper))
where(scale_by_complement_upper)
temp_log_array4 = 1
elsewhere
temp_log_array4 = 0
end where
call MPI_BCAST(temp_log_array4, size(temp_log_array4), MPI_INTEGER, mpiroot, mpicomm, ierr)
!allocate(temp_log_array4(nminor_absorber_intervals_upper))
!where(scale_by_complement_upper)
! temp_log_array4 = 1
!elsewhere
! temp_log_array4 = 0
!end where
!call MPI_BCAST(temp_log_array4, size(temp_log_array4), MPI_INTEGER, mpiroot, mpicomm, ierr)
#endif

! Initialize gas concentrations and gas optics class with data
Expand Down
Loading

0 comments on commit f35effe

Please sign in to comment.