Skip to content

Commit

Permalink
Add create_esmf_pet_files to the namelist, fix some issues so the err…
Browse files Browse the repository at this point in the history
…or checking is robust, add more flush statements, change some of the output from write(6 to write(ndiag
  • Loading branch information
ekluzek committed Oct 11, 2023
1 parent 90e9483 commit 83383a2
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 71 deletions.
2 changes: 2 additions & 0 deletions tools/mksurfdata_esmf/src/mkdomainMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ subroutine mkdomain(mesh_o, lon_o, lat_o, rc)
write(ndiag,'(1x,80a1)') ('=',k=1,80)
write(ndiag,*)
write(ndiag,'(a)') 'Attempting to create model lats and lons from model mesh .....'
flush(ndiag)
end if

call ESMF_MeshGet(mesh_o, spatialDim=spatialDim, numOwnedElements=ns_o, rc=rc)
Expand All @@ -62,6 +63,7 @@ subroutine mkdomain(mesh_o, lon_o, lat_o, rc)

if (root_task) then
write (ndiag,'(a)') 'Successfully made model lats and lons'
flush(ndiag)
end if

end subroutine mkdomain
Expand Down
21 changes: 16 additions & 5 deletions tools/mksurfdata_esmf/src/mkinputMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ module mkinputMod
character(CL) , public :: flakname ! generic lake filename

character(CS) , public :: mksrf_grid_name = ' ' ! Name of this grid
integer , public :: grid_size ! Number of columne in the grid

character(CX) , public :: mksrf_fgrid_mesh = ' ' ! land grid file name to use
integer , public :: mksrf_fgrid_mesh_nx = -999
Expand Down Expand Up @@ -112,6 +113,7 @@ module mkinputMod
character(CS) , public :: logname = ' ' ! user name
character(CS) , public :: hostname = ' ' ! machine name

logical , public :: create_esmf_pet_files = .false. ! Always create ESMF PET files (.false. if only on error)
logical , public :: urban_skip_abort_on_invalid_data_check

character(len=*), parameter :: u_FILE_u = &
Expand All @@ -129,7 +131,6 @@ subroutine read_namelist_input()
integer :: ier
integer :: k
integer :: fileunit
integer :: grid_size ! Number of columne in the grid
logical :: lexist
character(len=*), parameter :: subname = 'read_namelist_input'
! ------------------------------------------------------------
Expand Down Expand Up @@ -198,6 +199,7 @@ subroutine read_namelist_input()
fdyndat, &
fsurlog, &
std_elev, &
create_esmf_pet_files, &
urban_skip_abort_on_invalid_data_check

! Set default namelist values - make these the defaults in gen_mksurfdata_namelist.py
Expand All @@ -209,18 +211,18 @@ subroutine read_namelist_input()
urban_skip_abort_on_invalid_data_check = .false. ! default value for bug work around

if (root_task) then
write(6,*) 'Attempting to initialize control settings .....'
write(ndiag,*) 'Attempting to initialize control settings .....'
end if

if (root_task) then
read(5, nml=mksurfdata_input, iostat=ier)
if (ier > 0) then
call shr_sys_abort(subname//' error reading in mksurfdata_input namelist from standard input')
end if
end if
if ( mksrf_grid_name == ' ' )then
grid_size = mksrf_fgrid_mesh_nx * mksrf_fgrid_mesh_ny
write(mksrf_grid_name,'("Grid",I07)') grid_size
if ( mksrf_grid_name == ' ' )then
write(mksrf_grid_name,'("Cols",I7.7)') grid_size
end if
end if

end subroutine read_namelist_input
Expand All @@ -237,6 +239,8 @@ subroutine bcast_namelist_input()
call mpi_bcast (mksrf_fgrid_mesh, len(mksrf_fgrid_mesh), MPI_CHARACTER, 0, mpicom, ier)
call mpi_bcast (mksrf_fgrid_mesh_nx, 1, MPI_INTEGER, 0, mpicom, ier)
call mpi_bcast (mksrf_fgrid_mesh_ny, 1, MPI_INTEGER, 0, mpicom, ier)
call mpi_bcast (grid_size, 1, MPI_INTEGER, 0, mpicom, ier)
call mpi_bcast (mksrf_grid_name, len(mksrf_grid_name), MPI_CHARACTER, 0, mpicom, ier)

call mpi_bcast (mksrf_fvegtyp, len(mksrf_fvegtyp), MPI_CHARACTER, 0, mpicom, ier)
call mpi_bcast (mksrf_fvegtyp_mesh, len(mksrf_fvegtyp_mesh), MPI_CHARACTER, 0, mpicom, ier)
Expand Down Expand Up @@ -313,6 +317,7 @@ subroutine bcast_namelist_input()
call mpi_bcast (outnc_3dglc, 1, MPI_LOGICAL, 0, mpicom, ier)

call mpi_bcast (urban_skip_abort_on_invalid_data_check, 1, MPI_LOGICAL, 0, mpicom, ier)
call mpi_bcast (create_esmf_pet_files, 1, MPI_LOGICAL, 0, mpicom, ier)
call mpi_bcast (numpft, 1, MPI_INTEGER, 0, mpicom, ier)
call mpi_bcast (no_inlandwet, 1, MPI_LOGICAL, 0, mpicom, ier)
call mpi_bcast (std_elev, 1, MPI_REAL, 0, mpicom, ier)
Expand Down Expand Up @@ -428,6 +433,7 @@ subroutine write_namelist_input()
write(ndiag,'(a)')' mksrf_fgrid_mesh = '//trim(mksrf_fgrid_mesh)
write(ndiag,'(a,i8)')' nlon= ',mksrf_fgrid_mesh_nx
write(ndiag,'(a,i8)')' nlat= ',mksrf_fgrid_mesh_ny
write(ndiag,'(a,i8)')'Grid_size: ', grid_size
write(ndiag,*)
write(ndiag,'(1x,80a1)') ('=',k=1,80)
write(ndiag,*)
Expand All @@ -451,6 +457,11 @@ subroutine write_namelist_input()
if ( outnc_3dglc )then
write(ndiag,'(a)')' Output optional 3D glacier fields (mostly used for verification of the glacier model)'
end if
if (create_esmf_pet_files) then
write(ndiag,'(a)')' Always output ESMF PET files'
else
write(ndiag,'(a)')' Only output ESMF PET files if fatal errors happen in ESMF'
end if
if (urban_skip_abort_on_invalid_data_check) then
write(ndiag, '(a)') " WARNING: aborting on invalid data check in urban has been disabled!"
write(ndiag, '(a)') " WARNING: urban data may be invalid!"
Expand Down
Loading

0 comments on commit 83383a2

Please sign in to comment.