From 7123831fce7d802149e5e88873d3a13d744a688a Mon Sep 17 00:00:00 2001 From: Dom Heinzeller Date: Thu, 24 Sep 2020 20:11:38 -0600 Subject: [PATCH 1/2] sorc/chgres_cube.fd/model_grid.F90: read grib2 inventory only with task 0, let all other processes wait for it to complete --- sorc/chgres_cube.fd/model_grid.F90 | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/sorc/chgres_cube.fd/model_grid.F90 b/sorc/chgres_cube.fd/model_grid.F90 index 9beb96c3b..1b591941d 100644 --- a/sorc/chgres_cube.fd/model_grid.F90 +++ b/sorc/chgres_cube.fd/model_grid.F90 @@ -609,11 +609,14 @@ subroutine define_input_grid_gfs_grib2(localpet, npets) implicit none + include "mpif.h" + integer, intent(in) :: localpet, npets character(len=250) :: the_file integer :: i, j, rc, clb(2), cub(2) + integer :: ierr real(esmf_kind_r8), allocatable :: latitude(:,:) real(esmf_kind_r8), allocatable :: longitude(:,:) @@ -631,10 +634,14 @@ subroutine define_input_grid_gfs_grib2(localpet, npets) num_tiles_input_grid = 1 the_file = trim(data_dir_input_grid) // "/" // grib2_file_input_grid - print*,'- OPEN AND INVENTORY GRIB2 FILE: ',trim(the_file) - rc=grb2_mk_inv(the_file,inv_file) - if (rc /=0) call error_handler("OPENING GRIB2 FILE",rc) + if(localpet==0) then + print*,'- OPEN AND INVENTORY GRIB2 FILE: ',trim(the_file) + rc=grb2_mk_inv(the_file,inv_file) + if (rc /=0) call error_handler("OPENING GRIB2 FILE",rc) + endif + ! Wait for localpet 0 to create inventory + call mpi_barrier(mpi_comm_world, ierr) rc = grb2_inq(the_file,inv_file,':PRES:',':surface:',nx=i_input, ny=j_input, & lat=lat4, lon=lon4) if (rc /= 1) call error_handler("READING GRIB2 FILE", rc) From 790a7603e2d899c5db2c4e63e22cc0ee62aaaa60 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Fri, 11 Sep 2020 13:52:34 +0000 Subject: [PATCH 2/2] :eature/mpi_abort Fix mpi_abort calls in chgres_cube and sfc_climo_gen. Issue #140. --- sorc/chgres_cube.fd/utils.f90 | 9 +++++++-- sorc/sfc_climo_gen.fd/interp.F90 | 4 ++-- sorc/sfc_climo_gen.fd/model_grid.F90 | 6 ++++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/sorc/chgres_cube.fd/utils.f90 b/sorc/chgres_cube.fd/utils.f90 index ddda0bb90..3a547eede 100644 --- a/sorc/chgres_cube.fd/utils.f90 +++ b/sorc/chgres_cube.fd/utils.f90 @@ -2,13 +2,17 @@ subroutine error_handler(string, rc) implicit none + include 'mpif.h' + character(len=*), intent(in) :: string integer, intent(in) :: rc + integer :: ierr + print*,"- FATAL ERROR: ", string print*,"- IOSTAT IS: ", rc - call mpi_abort + call mpi_abort(mpi_comm_world, 999, ierr) end subroutine error_handler @@ -20,6 +24,7 @@ subroutine netcdf_err( err, string ) integer, intent(in) :: err character(len=*), intent(in) :: string character(len=256) :: errmsg + integer :: iret include "mpif.h" @@ -28,7 +33,7 @@ subroutine netcdf_err( err, string ) print*,'' print*,'FATAL ERROR: ', trim(string), ': ', trim(errmsg) print*,'STOP.' - call mpi_abort(mpi_comm_world, 999) + call mpi_abort(mpi_comm_world, 999, iret) return end subroutine netcdf_err diff --git a/sorc/sfc_climo_gen.fd/interp.F90 b/sorc/sfc_climo_gen.fd/interp.F90 index 5ed80f14d..a2558a2c7 100644 --- a/sorc/sfc_climo_gen.fd/interp.F90 +++ b/sorc/sfc_climo_gen.fd/interp.F90 @@ -292,7 +292,7 @@ subroutine adjust_for_landice(field, vegt, idim, jdim, field_ch) integer, parameter :: landice=15 - integer :: i, j + integer :: i, j, ierr real :: landice_value @@ -348,7 +348,7 @@ subroutine adjust_for_landice(field, vegt, idim, jdim, field_ch) enddo case default print*,'- FATAL ERROR IN ROUTINE ADJUST_FOR_LANDICE. UNIDENTIFIED FIELD : ', field_ch - call mpi_abort(mpi_comm_world, 57) + call mpi_abort(mpi_comm_world, 57, ierr) end select end subroutine adjust_for_landice diff --git a/sorc/sfc_climo_gen.fd/model_grid.F90 b/sorc/sfc_climo_gen.fd/model_grid.F90 index f281b64ea..ae762d831 100644 --- a/sorc/sfc_climo_gen.fd/model_grid.F90 +++ b/sorc/sfc_climo_gen.fd/model_grid.F90 @@ -83,12 +83,14 @@ subroutine define_model_grid(localpet, npets) implicit none + include 'mpif.h' + integer, intent(in) :: localpet, npets character(len=500) :: the_file integer :: error, id_dim, id_tiles, ncid - integer :: id_grid_tiles + integer :: id_grid_tiles, ierr integer :: extra, rc, tile integer, allocatable :: decomptile(:,:) @@ -124,7 +126,7 @@ subroutine define_model_grid(localpet, npets) if (mod(npets,num_tiles) /= 0) then print*,'- FATAL ERROR: MUST RUN THIS PROGRAM WITH A TASK COUNT THAT' print*,'- IS A MULTIPLE OF THE NUMBER OF TILES.' - call mpi_abort + call mpi_abort(mpi_comm_world, 44, ierr) endif !-----------------------------------------------------------------------