From 881fb9d06aaee0af4b143db91ae982162447dab5 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Wed, 5 Jun 2024 17:46:34 -0600 Subject: [PATCH 1/7] Fixed test category for betsy versus izumi in one test --- cime_config/testdefs/testlist_mosart.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cime_config/testdefs/testlist_mosart.xml b/cime_config/testdefs/testlist_mosart.xml index 8030578..9e79cbd 100644 --- a/cime_config/testdefs/testlist_mosart.xml +++ b/cime_config/testdefs/testlist_mosart.xml @@ -62,8 +62,8 @@ - - + + From 8fd94746591f5ff5abd1f751da2ff7067a7902a5 Mon Sep 17 00:00:00 2001 From: mvertens Date: Thu, 6 Jun 2024 04:38:05 -0600 Subject: [PATCH 2/7] fixed compilation problems with nag --- src/riverroute/mosart_control_type.F90 | 13 ++++++------- src/riverroute/mosart_driver.F90 | 3 +-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/riverroute/mosart_control_type.F90 b/src/riverroute/mosart_control_type.F90 index 9d98de3..1245545 100644 --- a/src/riverroute/mosart_control_type.F90 +++ b/src/riverroute/mosart_control_type.F90 @@ -1,9 +1,9 @@ module mosart_control_type - use shr_kind_mod, only : r8 => shr_kind_r8, CL => SHR_KIND_CL + use shr_kind_mod, only : r8 => shr_kind_r8 use shr_sys_mod, only : shr_sys_abort use shr_const_mod, only : shr_const_pi, shr_const_rearth - use shr_mpi_mod, only : shr_mpi_sum, shr_mpi_max + use shr_mpi_mod, only : shr_mpi_sum use mosart_io, only : ncd_io, ncd_pio_openfile, ncd_pio_closefile use mosart_vars, only : mainproc, iam, npes, mpicom_rof, iulog, spval, re use pio, only : file_desc_t, PIO_BCAST_ERROR, pio_seterrorhandling @@ -423,7 +423,6 @@ subroutine init_decomp(this, locfn, decomp_option, use_halo_option, & integer, pointer :: halo_list(:) integer, pointer :: seqlist(:) integer, allocatable :: store_halo_index(:) - integer :: nglob character(len=*),parameter :: subname = '(mosart_control_type: init_decomp) ' !----------------------------------------------------------------------- @@ -1110,10 +1109,10 @@ subroutine calc_gradient(this, fld, fld_halo_array, dfld_dx, dfld_dy, rc) integer :: i, n, nr ! local indices real(r8) :: deg2rad real(r8) :: mean_dx, mean_dy, dlon, dlat - real(r8) :: ax_indices(4) ! x indices to add - real(r8) :: sx_indices(4) ! x indices to subtract - real(r8) :: ay_indices(4) ! y indices to add - real(r8) :: sy_indices(4) ! y indices to subtract + integer :: ax_indices(4) ! x indices to add + integer :: sx_indices(4) ! x indices to subtract + integer :: ay_indices(4) ! y indices to add + integer :: sy_indices(4) ! y indices to subtract real(r8) :: fld_surrounding(max_num_halo) real(r8) :: dx(max_num_halo) real(r8) :: dy(max_num_halo) diff --git a/src/riverroute/mosart_driver.F90 b/src/riverroute/mosart_driver.F90 index eacfe25..83fc1ee 100644 --- a/src/riverroute/mosart_driver.F90 +++ b/src/riverroute/mosart_driver.F90 @@ -6,7 +6,6 @@ module mosart_driver use shr_kind_mod , only : r8 => shr_kind_r8, CS => shr_kind_cs, CL => shr_kind_CL use shr_sys_mod , only : shr_sys_abort - use shr_mpi_mod , only : shr_mpi_sum, shr_mpi_max use shr_const_mod , only : SHR_CONST_PI, SHR_CONST_CDAY use shr_string_mod , only : shr_string_listGetNum, shr_string_listGetName use mosart_vars , only : re, spval, iulog, ice_runoff, & @@ -167,7 +166,7 @@ subroutine mosart_read_namelist() write(iulog,'(a,i8)') ' coupling_period = ',coupling_period write(iulog,'(a,i8)') ' delt_mosart = ',delt_mosart write(iulog,'(a)' ) ' decomp option = '//trim(decomp_option) - write(iulog,'(a,l)' ) ' use_halo_option = ',use_halo_option + write(iulog,'(a,l1)') ' use_halo_option = ',use_halo_option write(iulog,'(a)' ) ' bypass_routing option = '//trim(bypass_routing_option) write(iulog,'(a)' ) ' qgwl runoff option = '//trim(qgwl_runoff_option) write(iulog,'(a)' ) ' mosart tracers = '//trim(mosart_tracers) From 5ef52061f9668015430bf5cf9f204607e01a64a3 Mon Sep 17 00:00:00 2001 From: mvertens Date: Thu, 6 Jun 2024 04:48:47 -0600 Subject: [PATCH 3/7] addressed https://github.com/ESCOMP/MOSART/issues/93 --- src/riverroute/mosart_io.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/riverroute/mosart_io.F90 b/src/riverroute/mosart_io.F90 index 15ae9f9..98d6e77 100644 --- a/src/riverroute/mosart_io.F90 +++ b/src/riverroute/mosart_io.F90 @@ -200,8 +200,8 @@ subroutine ncd_pio_openfile(file, fname, mode) character(len=*),parameter :: subname='ncd_pio_openfile' ! subroutine name !----------------------------------------------------------------------- + call pio_seterrorhandling(file, PIO_BCAST_ERROR) ierr = pio_openfile(pio_subsystem, file, io_type, fname, mode) - if(ierr/= PIO_NOERR) then call shr_sys_abort(subname//'ERROR: Failed to open file') else if(pio_iotask_rank(pio_subsystem)==0 .and. mainproc) then @@ -247,8 +247,8 @@ subroutine ncd_pio_createfile(file, fname) if(io_type == PIO_IOTYPE_NETCDF .or. io_type == PIO_IOTYPE_PNETCDF) then iomode = ior(iomode, io_format) endif + call pio_seterrorhandling(file, PIO_BCAST_ERROR) ierr = pio_createfile(pio_subsystem, file, io_type, fname, iomode) - if(ierr/= PIO_NOERR) then call shr_sys_abort( subname//' ERROR: Failed to open file to write: '//trim(fname)) else if(pio_iotask_rank(pio_subsystem)==0 .and. mainproc) then From 377d6ca94fd9fb554dd8f032f6987c656c680892 Mon Sep 17 00:00:00 2001 From: mvertens Date: Thu, 6 Jun 2024 07:06:51 -0600 Subject: [PATCH 4/7] reverted changes in mosart_io.F90 since they caused the model to crash with a segmentation error --- src/riverroute/mosart_io.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/riverroute/mosart_io.F90 b/src/riverroute/mosart_io.F90 index 98d6e77..15ae9f9 100644 --- a/src/riverroute/mosart_io.F90 +++ b/src/riverroute/mosart_io.F90 @@ -200,8 +200,8 @@ subroutine ncd_pio_openfile(file, fname, mode) character(len=*),parameter :: subname='ncd_pio_openfile' ! subroutine name !----------------------------------------------------------------------- - call pio_seterrorhandling(file, PIO_BCAST_ERROR) ierr = pio_openfile(pio_subsystem, file, io_type, fname, mode) + if(ierr/= PIO_NOERR) then call shr_sys_abort(subname//'ERROR: Failed to open file') else if(pio_iotask_rank(pio_subsystem)==0 .and. mainproc) then @@ -247,8 +247,8 @@ subroutine ncd_pio_createfile(file, fname) if(io_type == PIO_IOTYPE_NETCDF .or. io_type == PIO_IOTYPE_PNETCDF) then iomode = ior(iomode, io_format) endif - call pio_seterrorhandling(file, PIO_BCAST_ERROR) ierr = pio_createfile(pio_subsystem, file, io_type, fname, iomode) + if(ierr/= PIO_NOERR) then call shr_sys_abort( subname//' ERROR: Failed to open file to write: '//trim(fname)) else if(pio_iotask_rank(pio_subsystem)==0 .and. mainproc) then From 3c7b9d188c120c72f0a1b981129db86ac824b395 Mon Sep 17 00:00:00 2001 From: Mariana Vertenstein Date: Thu, 6 Jun 2024 11:00:18 -0600 Subject: [PATCH 5/7] updates to fix pio error checking in mosart_io.F90 --- src/riverroute/mosart_io.F90 | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/riverroute/mosart_io.F90 b/src/riverroute/mosart_io.F90 index 15ae9f9..06945ea 100644 --- a/src/riverroute/mosart_io.F90 +++ b/src/riverroute/mosart_io.F90 @@ -196,17 +196,19 @@ subroutine ncd_pio_openfile(file, fname, mode) integer , intent(in) :: mode ! file mode ! Local variables + integer :: oldmethod integer :: ierr character(len=*),parameter :: subname='ncd_pio_openfile' ! subroutine name !----------------------------------------------------------------------- + call pio_seterrorhandling(pio_subsystem, PIO_BCAST_ERROR, oldmethod) ierr = pio_openfile(pio_subsystem, file, io_type, fname, mode) - if(ierr/= PIO_NOERR) then call shr_sys_abort(subname//'ERROR: Failed to open file') else if(pio_iotask_rank(pio_subsystem)==0 .and. mainproc) then write(iulog,*) 'Opened existing file ', trim(fname), file%fh end if + call pio_seterrorhandling(pio_subsystem, oldmethod) end subroutine ncd_pio_openfile @@ -237,6 +239,7 @@ subroutine ncd_pio_createfile(file, fname) character(len=*), intent(in) :: fname ! File name to create ! Local variables + integer :: oldmethod integer :: ierr integer :: iomode character(len=*),parameter :: subname='ncd_pio_createfile' ! subroutine name @@ -247,13 +250,14 @@ subroutine ncd_pio_createfile(file, fname) if(io_type == PIO_IOTYPE_NETCDF .or. io_type == PIO_IOTYPE_PNETCDF) then iomode = ior(iomode, io_format) endif + call pio_seterrorhandling(pio_subsystem, PIO_BCAST_ERROR, oldmethod) ierr = pio_createfile(pio_subsystem, file, io_type, fname, iomode) - if(ierr/= PIO_NOERR) then call shr_sys_abort( subname//' ERROR: Failed to open file to write: '//trim(fname)) else if(pio_iotask_rank(pio_subsystem)==0 .and. mainproc) then write(iulog,*) 'Opened file ', trim(fname), ' to write', file%fh end if + call pio_seterrorhandling(pio_subsystem, oldmethod) end subroutine ncd_pio_createfile @@ -272,6 +276,7 @@ subroutine check_var(ncid, varname, vardesc, readvar, print_err ) logical, optional, intent(in) :: print_err ! If should print about error ! Local variables + integer :: oldmethod integer :: ret ! return value logical :: log_err ! if should log error character(len=*),parameter :: subname='check_var' ! subroutine name @@ -284,14 +289,15 @@ subroutine check_var(ncid, varname, vardesc, readvar, print_err ) log_err = .true. end if readvar = .true. - call pio_seterrorhandling(ncid, PIO_BCAST_ERROR) + call pio_seterrorhandling(ncid, PIO_BCAST_ERROR, oldmethod) ret = pio_inq_varid (ncid, varname, vardesc) if (ret /= PIO_NOERR) then readvar = .false. - if (mainproc .and. log_err) & - write(iulog,*) subname//': variable ',trim(varname),' is not on dataset' + if (mainproc .and. log_err) then + write(iulog,*) subname//': variable ',trim(varname),' is not on dataset' + end if end if - call pio_seterrorhandling(ncid, PIO_INTERNAL_ERROR) + call pio_seterrorhandling(ncid, oldmethod) end subroutine check_var @@ -355,11 +361,12 @@ subroutine ncd_inqdid(ncid,name,dimid,dimexist) logical,optional, intent(out):: dimexist ! if this dimension exists or not ! Local variables + integer :: oldmethod integer :: status !----------------------------------------------------------------------- if ( present(dimexist) )then - call pio_seterrorhandling(ncid, PIO_BCAST_ERROR) + call pio_seterrorhandling(ncid, PIO_BCAST_ERROR, oldmethod) end if status = PIO_inq_dimid(ncid,name,dimid) if ( present(dimexist) )then @@ -368,7 +375,7 @@ subroutine ncd_inqdid(ncid,name,dimid,dimexist) else dimexist = .false. end if - call pio_seterrorhandling(ncid, PIO_INTERNAL_ERROR) + call pio_seterrorhandling(ncid, oldmethod) end if end subroutine ncd_inqdid @@ -430,6 +437,7 @@ subroutine ncd_inqfdims(ncid, isgrid2d, ni, nj, ns) integer , intent(out) :: nj integer , intent(out) :: ns ! Local variables + integer :: oldmethod integer :: dimid ! netCDF id integer :: ier ! error status character(len=CS) :: subname = 'surfrd_filedims' ! subroutine name @@ -438,7 +446,7 @@ subroutine ncd_inqfdims(ncid, isgrid2d, ni, nj, ns) ni = 0 nj = 0 - call pio_seterrorhandling(ncid, PIO_BCAST_ERROR) + call pio_seterrorhandling(ncid, PIO_BCAST_ERROR, oldmethod) ier = pio_inq_dimid (ncid, 'lon', dimid) if (ier == PIO_NOERR) ier = pio_inq_dimlen(ncid, dimid, ni) ier = pio_inq_dimid (ncid, 'lat', dimid) @@ -460,7 +468,7 @@ subroutine ncd_inqfdims(ncid, isgrid2d, ni, nj, ns) if (ier == PIO_NOERR) nj = 1 end if - call pio_seterrorhandling(ncid, PIO_INTERNAL_ERROR) + call pio_seterrorhandling(ncid, oldmethod) if (ni == 0 .or. nj == 0) then write(iulog,*) trim(subname),' ERROR: ni,nj = ',ni,nj,' cannot be zero ' @@ -492,13 +500,14 @@ subroutine ncd_inqvid(ncid,name,varid,vardesc,readvar) logical, optional, intent(out) :: readvar ! does variable exist ! Local variables + integer :: oldmethod integer :: ret ! return code character(len=*),parameter :: subname='ncd_inqvid' ! subroutine name !----------------------------------------------------------------------- if (present(readvar)) then readvar = .false. - call pio_seterrorhandling(ncid, PIO_BCAST_ERROR) + call pio_seterrorhandling(pio_subsystem, PIO_BCAST_ERROR, oldmethod) ret = pio_inq_varid(ncid,name,vardesc) if (ret /= PIO_NOERR) then if (mainproc) write(iulog,*) subname//': variable ',trim(name),' is not on dataset' @@ -506,7 +515,7 @@ subroutine ncd_inqvid(ncid,name,varid,vardesc,readvar) else readvar = .true. end if - call pio_seterrorhandling(ncid, PIO_INTERNAL_ERROR) + call pio_seterrorhandling(ncid, oldmethod) else ret = pio_inq_varid(ncid,name,vardesc) endif From 641414c296367895fe9cb2a0e51de925118f4a3c Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Thu, 6 Jun 2024 15:20:17 -0600 Subject: [PATCH 6/7] Update a user_nl_mosart comment --- cime_config/user_nl_mosart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cime_config/user_nl_mosart b/cime_config/user_nl_mosart index e8f3087..e7c8865 100644 --- a/cime_config/user_nl_mosart +++ b/cime_config/user_nl_mosart @@ -1,7 +1,7 @@ !---------------------------------------------------------------------------------- ! Users should add all user specific namelist changes below in the form of ! namelist_var = new_namelist_value -! NOTE: namelist variable rtm_tstep CAN ONLY be changed by modifying the value +! NOTE: namelist variable delt_mosart (the time-step) CAN ONLY be changed by modifying the value ! of the xml variable ROF_NCPL in env_run.xml !---------------------------------------------------------------------------------- From 2695f36fc405d6741773f439724cfd5af3204ca8 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Thu, 6 Jun 2024 15:41:03 -0600 Subject: [PATCH 7/7] Updated ChangeLog --- docs/ChangeLog | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/docs/ChangeLog b/docs/ChangeLog index 670f9b2..de7e2da 100644 --- a/docs/ChangeLog +++ b/docs/ChangeLog @@ -1,3 +1,51 @@ +=============================================================== +Tag name: mosart1_1_01 +Originator(s): mvertens +Date: Jun 06, 2024 +One-line Summary: major mosart refactor including addition of new halo capability + +Removed all references to rtm + +files have been renamed and namelists no longer contain rtm in the name + +New modularity: + +introduced new modules with new derived types and methods +mosart_control_type.F90 +mosart_tctl_type.F90 +mosart_tparameter_type.F90 +mosart_tspatialunit_type.F90 +mosart_tstatusflux_type.F90 + +the new modules modularize a lot of the complexity and variables that were previously found in RunOffMod.F90 and permit decomposition initialization to be more flexible and transparent. + +New halo capability + +Ability to have halo regions and communication using ESMF. This is needed for computing derivatives in upcoming new additions to MOSART. +New halo namelist - use_halo_option. When this is set to true halos can be activated. See the test_halo subroutine in mosart_control_type.F90 module. +Verified that the results for the halos are bfb identical regardless of the number of processors that are used. +-To set the values for the exclusive region that will be used in halo operations - you need to access the pointer as is done in the test_halo routine in mosart_control_type.F90: + n = 0 + do nr = this%begr,this%endr + n = n + 1 + this%halo_arrayptr(n) = this%latc(nr)*10. + this%lonc(nr)/100. + end do + + call ESMF_ArrayHalo(this%haloArray, routehandle=this%haloHandle, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + +Issues addressed: +Fixes #93 "if (ierr /= PIO_NOERR)" will not be invoked unless PIO_BCAST_ERROR is explicitly set +Fixes #98 Change namelist items to remove "rtm" in the names of namelist variables +Fixes #97 Remove RTM in more of the MOSART code (filenames, subroutines, variables etc.) +Fixes #99 Add a new mosart_noresm testlist + +Testing: standard testing + izumi -- OK + cheyenne -- OK + +See https://github.com/ESCOMP/MOSART/pull/76 for more details + =============================================================== Tag name: mosart1_0_49 Originator(s): mvertens