From 7b763a2474248da876a205f730cc2cebc9055c25 Mon Sep 17 00:00:00 2001 From: Dusan Jovic Date: Thu, 30 Sep 2021 14:17:23 +0000 Subject: [PATCH 1/4] Add get_nth_domain_info subroutine --- driver/fvGFS/atmosphere.F90 | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/driver/fvGFS/atmosphere.F90 b/driver/fvGFS/atmosphere.F90 index 3fb22c2d6..c1e4e2e57 100644 --- a/driver/fvGFS/atmosphere.F90 +++ b/driver/fvGFS/atmosphere.F90 @@ -225,7 +225,8 @@ module atmosphere_mod atmosphere_get_bottom_layer, & atmosphere_nggps_diag, & get_bottom_mass, get_bottom_wind, & - get_stock_pe, set_atmosphere_pelist + get_stock_pe, set_atmosphere_pelist, & + get_nth_domain_info !--- physics/radiation data exchange routines public :: atmos_phys_driver_statein @@ -924,15 +925,30 @@ subroutine set_atmosphere_pelist () end subroutine set_atmosphere_pelist + subroutine get_nth_domain_info(n, layout, nx, ny, pelist) + integer, intent(in) :: n + integer, intent(out) :: layout(2) + integer, intent(out) :: nx, ny + integer, pointer, intent(out) :: pelist(:) + + layout(1:2) = Atm(n)%layout(1:2) + nx = Atm(n)%npx -1 + ny = Atm(n)%npy -1 + pelist => Atm(n)%pelist + + end subroutine get_nth_domain_info + !>@brief The subroutine 'atmosphere_domain' is an API to return !! the "domain2d" variable associated with the coupling grid and the !! decomposition for the current cubed-sphere tile. !>@detail Coupling is done using the mass/temperature grid with no halos. - subroutine atmosphere_domain ( fv_domain, layout, regional, nested, pelist ) + subroutine atmosphere_domain ( fv_domain, layout, regional, nested, ngrids_atmos, mygrid_atmos, pelist ) type(domain2d), intent(out) :: fv_domain integer, intent(out) :: layout(2) logical, intent(out) :: regional logical, intent(out) :: nested + integer, intent(out) :: ngrids_atmos + integer, intent(out) :: mygrid_atmos integer, pointer, intent(out) :: pelist(:) ! returns the domain2d variable associated with the coupling grid ! note: coupling is done using the mass/temperature grid with no halos @@ -941,6 +957,8 @@ subroutine atmosphere_domain ( fv_domain, layout, regional, nested, pelist ) layout(1:2) = Atm(mygrid)%layout(1:2) regional = Atm(mygrid)%flagstruct%regional nested = ngrids > 1 + ngrids_atmos = ngrids + mygrid_atmos = mygrid call set_atmosphere_pelist() pelist => Atm(mygrid)%pelist From 80ebd27b6afbe1df96960a3d241b928553f480d9 Mon Sep 17 00:00:00 2001 From: Dusan Jovic Date: Wed, 3 Nov 2021 15:27:06 +0000 Subject: [PATCH 2/4] Deallocate local arrays in fv_dyn_bundle_setup --- driver/fvGFS/fv_nggps_diag.F90 | 3 +++ model/fv_regional_bc.F90 | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/driver/fvGFS/fv_nggps_diag.F90 b/driver/fvGFS/fv_nggps_diag.F90 index 8e68b2e44..db5e80414 100644 --- a/driver/fvGFS/fv_nggps_diag.F90 +++ b/driver/fvGFS/fv_nggps_diag.F90 @@ -991,6 +991,7 @@ subroutine fv_dyn_bundle_setup(axes, dyn_bundle, fcst_grid, quilting, rc) line=__LINE__, & file=__FILE__)) & return ! bail out + deallocate(axis_name_vert) endif do id = 1,num_axes @@ -1333,6 +1334,8 @@ subroutine fv_dyn_bundle_setup(axes, dyn_bundle, fcst_grid, quilting, rc) ! name="output_file", value=fld_outfilename, rc=rc) ! print *,'in dyn bundle setup, i=',i,' fieldname=',trim(fieldnamelist(i)),' out filename=',trim(fld_outfilename) ! enddo + deallocate(axis_name) + deallocate(all_axes) end subroutine fv_dyn_bundle_setup diff --git a/model/fv_regional_bc.F90 b/model/fv_regional_bc.F90 index 08f7c6158..395a86183 100644 --- a/model/fv_regional_bc.F90 +++ b/model/fv_regional_bc.F90 @@ -6741,7 +6741,7 @@ subroutine get_data_source(data_source_fv3gfs,regional) logical, intent(out):: data_source_fv3gfs character (len=80) :: source - logical :: lstatus + logical :: lstatus = .false. type(FmsNetcdfFile_t) :: Gfs_data integer, allocatable, dimension(:) :: pes !< Array of the pes in the current pelist ! From 9af3191689ea4245c623b57e42c3eebc65d298c5 Mon Sep 17 00:00:00 2001 From: Dusan Jovic Date: Wed, 5 Jan 2022 20:16:06 +0000 Subject: [PATCH 3/4] Do not print debug messages to stderr --- model/fv_regional_bc.F90 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/model/fv_regional_bc.F90 b/model/fv_regional_bc.F90 index 8d955fbb4..51f4cdc21 100644 --- a/model/fv_regional_bc.F90 +++ b/model/fv_regional_bc.F90 @@ -393,7 +393,7 @@ subroutine setup_regional_BC(Atm & ! call check(nf90_open(file_name,nf90_nowrite,ncid)) !<-- Open the BC file; get the file ID. if (is_master()) then - write(0,*)' opened BC file ',trim(file_name) + write(*,*)' opened BC file ',trim(file_name) endif ! !----------------------------------------------------------------------- @@ -1672,7 +1672,7 @@ subroutine regional_bc_data(Atm,bc_hour & ! call check(nf90_open(file_name,nf90_nowrite,ncid)) !<-- Open the BC file; get the file ID. if (is_master()) then - write(0,*)' opened BC file ',trim(file_name) + write(*,*)' opened BC file ',trim(file_name) endif ! call check(nf90_inq_dimid(ncid,'lev',dimid)) !<-- Get the vertical dimension's NetCDF ID. @@ -3305,7 +3305,7 @@ subroutine read_regional_bc_file(is_input,ie_input & call check(status) endif if (status /= nf90_noerr) then - if (east_bc.and.is_master()) write(0,*)' WARNING: Tracer ',trim(var_name),' not in input file' + if (east_bc.and.is_master()) write(*,*)' WARNING: Tracer ',trim(var_name),' not in input file' array_4d(:,:,:,tlev)=0. !<-- Tracer not in input so set to zero in boundary. ! blend_this_tracer(tlev)=.false. !<-- Tracer not in input so do not apply blending. From 9d1fabcdb6a55cc7f1bc6ae6e78d8e56f0a7a326 Mon Sep 17 00:00:00 2001 From: Dusan Jovic Date: Fri, 11 Feb 2022 15:54:48 +0000 Subject: [PATCH 4/4] Use mpp_error instead of write statements in model/fv_regional_bc.F90 --- model/fv_regional_bc.F90 | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/model/fv_regional_bc.F90 b/model/fv_regional_bc.F90 index 51f4cdc21..ccdba5fbf 100644 --- a/model/fv_regional_bc.F90 +++ b/model/fv_regional_bc.F90 @@ -383,18 +383,12 @@ subroutine setup_regional_BC(Atm & file_name='INPUT/gfs_bndy.tile7.'//int_to_char//'_gsi.nc' !<-- The DA-updated BC file. endif ! - if (is_master()) then - write(*,20011)trim(file_name) -20011 format(' regional_bc_data file_name=',a) - endif !----------------------------------------------------------------------- !*** Open the regional BC file. !----------------------------------------------------------------------- ! call check(nf90_open(file_name,nf90_nowrite,ncid)) !<-- Open the BC file; get the file ID. - if (is_master()) then - write(*,*)' opened BC file ',trim(file_name) - endif + call mpp_error(NOTE, 'Opened BC file: '//trim(file_name)) ! !----------------------------------------------------------------------- !*** Check if the desired number of blending rows are present in @@ -1075,7 +1069,7 @@ subroutine read_regional_lon_lat ! call check(nf90_open(filename,nf90_nowrite,ncid_grid)) !<-- Open the grid data netcdf file; get the file ID. ! - call mpp_error(NOTE,' opened grid file '//trim(filename)) + call mpp_error(NOTE, 'Opened grid file: '//trim(filename)) ! !----------------------------------------------------------------------- !*** The longitude and latitude are on the super grid. We need only @@ -1170,12 +1164,9 @@ subroutine read_regional_filtered_topo ! filename='INPUT/'//trim(oro_data) - if (is_master()) then - write(*,23421)trim(filename) -23421 format(' topo filename=',a) - endif ! call check(nf90_open(filename,nf90_nowrite,ncid_oro)) !<-- Open the netcdf file; get the file ID. + call mpp_error(NOTE, 'Opened topo file: '//trim(filename)) ! !----------------------------------------------------------------------- !*** Read in the data including the extra outer row. @@ -1661,19 +1652,13 @@ subroutine regional_bc_data(Atm,bc_hour & file_name='INPUT/gfs_bndy.tile7.'//int_to_char//'_gsi.nc' !<-- The DA-updated BC file. endif ! - if (is_master()) then - write(*,22211)trim(file_name) -22211 format(' regional_bc_data file_name=',a) - endif !----------------------------------------------------------------------- !*** Open the regional BC file. !*** Find the # of layers (klev_in) in the BC input. !----------------------------------------------------------------------- ! call check(nf90_open(file_name,nf90_nowrite,ncid)) !<-- Open the BC file; get the file ID. - if (is_master()) then - write(*,*)' opened BC file ',trim(file_name) - endif + call mpp_error(NOTE, 'Opened BC file: '//trim(file_name)) ! call check(nf90_inq_dimid(ncid,'lev',dimid)) !<-- Get the vertical dimension's NetCDF ID. call check(nf90_inquire_dimension(ncid,dimid,len=klev_in)) !<-- Get the vertical dimension's value (klev_in). @@ -3305,7 +3290,9 @@ subroutine read_regional_bc_file(is_input,ie_input & call check(status) endif if (status /= nf90_noerr) then - if (east_bc.and.is_master()) write(*,*)' WARNING: Tracer ',trim(var_name),' not in input file' + if (east_bc) then + call mpp_error(NOTE, 'Tracer '//trim(var_name)//' not in input file') + endif array_4d(:,:,:,tlev)=0. !<-- Tracer not in input so set to zero in boundary. ! blend_this_tracer(tlev)=.false. !<-- Tracer not in input so do not apply blending. @@ -3877,7 +3864,6 @@ subroutine remap_scalar_nggps_regional_bc(Atm & enddo ! call pmaxmn('PS_diff (mb)', wk, is, ie, js, je, 1, 0.01, Atm%gridstruct%area_64, Atm%domain) deallocate (pe0,qn1,dp2,pe1,qp) - if (is_master()) write(*,*) 'done remap_scalar_nggps_regional_bc' !--------------------------------------------------------------------- end subroutine remap_scalar_nggps_regional_bc @@ -3997,8 +3983,6 @@ subroutine remap_dwinds_regional_bc(Atm & deallocate(qn1_d) deallocate(qn1_c) - if (is_master()) write(*,*) 'done remap_dwinds' - end subroutine remap_dwinds_regional_bc !--------------------------------------------------------------------- @@ -6764,7 +6748,7 @@ subroutine get_data_source(data_source_fv3gfs,regional) if (mpp_pe() == 0) write(0,*) 'INPUT source not found ',lstatus,' set source=No Source Attribute' source='No Source Attribute' endif - if (mpp_pe()==0) write(*,*) 'INPUT gfs_data source string=',source + call mpp_error(NOTE, 'INPUT gfs_data source string: '//trim(source)) ! Logical flag for fv3gfs nemsio/netcdf/grib2 -------- if ( trim(source)=='FV3GFS GAUSSIAN NEMSIO FILE' .or. & @@ -6774,7 +6758,6 @@ subroutine get_data_source(data_source_fv3gfs,regional) else data_source_fv3gfs = .FALSE. endif - if (mpp_pe()==0) write(*,*) 'data_source_fv3gfs=',data_source_fv3gfs end subroutine get_data_source