From e88f40c03cf5a3b9d531baba08de5b99d33f82f3 Mon Sep 17 00:00:00 2001 From: Mariana Vertenstein Date: Sat, 30 Mar 2024 10:06:55 -0600 Subject: [PATCH] updates for dglc features required --- dglc/cime_config/buildnml | 4 +- dglc/cime_config/config_component.xml | 13 +-- dglc/cime_config/namelist_definition_dglc.xml | 37 +++---- dglc/dglc_datamode_noevolve_mod.F90 | 96 +++++++++---------- dglc/glc_comp_nuopc.F90 | 37 ++++--- 5 files changed, 75 insertions(+), 112 deletions(-) diff --git a/dglc/cime_config/buildnml b/dglc/cime_config/buildnml index a18295e6e..b68516429 100755 --- a/dglc/cime_config/buildnml +++ b/dglc/cime_config/buildnml @@ -60,7 +60,7 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path scol_lat = float(case.get_value('PTS_LAT')) else: scol_lat = -999. - if (scol_lon > -999. and scol_lat > 999.): + if (scol_lon > -999. or scol_lat > -999.): expect(False, "single column mode for DGLC is not currently allowed") @@ -80,7 +80,7 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path nmlgen.write_output_file(namelist_file, data_list_path, groups=['dglc_nml']) # Generate dglc.streams.xml - print("dglc_mode is {}".format(dglc_mode)) + logger.debug("dglc_mode is {}".format(dglc_mode)) if 'noevolve' in dglc_mode: generate_stream_file = False diff --git a/dglc/cime_config/config_component.xml b/dglc/cime_config/config_component.xml index d8ef6469f..15271a5b8 100644 --- a/dglc/cime_config/config_component.xml +++ b/dglc/cime_config/config_component.xml @@ -34,7 +34,7 @@ run_component_dglc env_run.xml - + NOEVOLVE mode is used in CESM as follows. In typical runs, CISM is not evolving; CLM computes the surface mass balance (SMB) and sends it to CISM, but CISM’s ice sheet geometry @@ -43,17 +43,6 @@ - - logical - FALSE - run_component_dglc - env_run.xml - - If true, have the mediator calculate import values that are sent back to - GLC even in GLC is in NOEVOLVE mode - - - logical FALSE diff --git a/dglc/cime_config/namelist_definition_dglc.xml b/dglc/cime_config/namelist_definition_dglc.xml index 20dd0bde1..8bc4e0c0e 100644 --- a/dglc/cime_config/namelist_definition_dglc.xml +++ b/dglc/cime_config/namelist_definition_dglc.xml @@ -42,7 +42,6 @@ dglc_nml $DIN_LOC_ROOT/glc/cism/Antarctica/ISMIP6_Antarctica_8km.init.c210908.nc:$DIN_LOC_ROOT/glc/cism/Greenland/greenland_4km_epsg3413_c171126.nc - $DIN_LOC_ROOT/glc/cism/Greenland/gland20.input_c150415.nc $DIN_LOC_ROOT/glc/cism/Greenland/greenland_4km_epsg3413_c171126.nc $DIN_LOC_ROOT/glc/cism/Antarctica/ISMIP6_Antarctica_8km.init.c210908.nc @@ -65,18 +64,19 @@ - + real(20) streams dglc_nml - 3.94162024004361e-07,1.57664809601744e-06 - 1. - 3.94162024004361e-07 - 1.57664809601744e-06 + 8000,4000 + 4000 + 8000 - colon deliminted string of inputdata files + model internal grid size(s) in m which is used to compute the internal model + model area in radians**2 using the formula (model_internal_gridsize/shr_const_rearth)**2 - + for more than one ice sheet this will contain an array of model_internal_gridsize values. @@ -91,8 +91,8 @@ 76 - global size(s) of nx - for more than one ice sheets this will contain an array of nx values + global size(s) of nx where for more than one ice sheet this + will contain an array of nx values @@ -107,8 +107,8 @@ 141 - global size(s) of ny - for more than one ice sheets this will contain an array of ny values + global size(s) of ny where for more than one ice sheet this + will contain an array of ny values @@ -124,21 +124,6 @@ - - logical - dglc - dglc_nml - - If set to true, than dglc will advertise and realize import - fields even if it does not do anything with them. This - capability is used, for example, in generating coupler history - data for GLC spinup runs. - - - $DGLC_GET_IMPORT_DATA - - - logical dglc diff --git a/dglc/dglc_datamode_noevolve_mod.F90 b/dglc/dglc_datamode_noevolve_mod.F90 index 8e681b34e..9a5431e62 100644 --- a/dglc/dglc_datamode_noevolve_mod.F90 +++ b/dglc/dglc_datamode_noevolve_mod.F90 @@ -7,7 +7,7 @@ module dglc_datamode_noevolve_mod use NUOPC , only : NUOPC_Advertise, NUOPC_IsConnected use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs use shr_sys_mod , only : shr_sys_abort - use shr_const_mod , only : SHR_CONST_RHOICE, SHR_CONST_RHOSW + use shr_const_mod , only : SHR_CONST_RHOICE, SHR_CONST_RHOSW, SHR_CONST_REARTH use dshr_methods_mod , only : dshr_state_getfldptr, dshr_fldbun_getfldptr, chkerr use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add use dshr_strdata_mod , only : shr_strdata_type @@ -27,7 +27,6 @@ module dglc_datamode_noevolve_mod logical :: initialized_noevolve = .false. integer :: num_icesheets real(r8) :: thk0 = 1._r8 - logical :: get_import_data ! Data structure to enable multiple ice sheets type icesheet_ptr_t @@ -65,13 +64,12 @@ module dglc_datamode_noevolve_mod !=============================================================================== subroutine dglc_datamode_noevolve_advertise(NStateExp, fldsexport, NStateImp, fldsimport, & - get_import_data_in, flds_scalar_name, rc) + flds_scalar_name, rc) ! input/output variables type(ESMF_State) , intent(inout) :: NStateExp(:) type(fldlist_type), pointer :: fldsexport type(ESMF_State) , intent(inout) :: NStateImp(:) - logical , intent(in) :: get_import_data_in type(fldlist_type), pointer :: fldsimport character(len=*) , intent(in) :: flds_scalar_name integer , intent(out) :: rc @@ -84,9 +82,6 @@ subroutine dglc_datamode_noevolve_advertise(NStateExp, fldsexport, NStateImp, fl rc = ESMF_SUCCESS - ! Set module vraiable - get_import_data = get_import_data_in - !-------------------------------- ! Create nested state for active ice sheets only !-------------------------------- @@ -114,22 +109,20 @@ subroutine dglc_datamode_noevolve_advertise(NStateExp, fldsexport, NStateImp, fl enddo ! Advertise import fields if appropriate - if (get_import_data) then - call dshr_fldList_add(fldsImport, trim(flds_scalar_name)) - call dshr_fldList_add(fldsImport, field_in_tsrf) - call dshr_fldList_add(fldsImport, field_in_qice) - - do ns = 1,num_icesheets - write(cnum,'(i0)') ns - fldlist => fldsImport ! the head of the linked list - do while (associated(fldlist)) - call NUOPC_Advertise(NStateImp(ns), standardName=fldlist%stdname, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call ESMF_LogWrite('(dglc_comp_advertise): To_glc'//trim(cnum)//"_"//trim(fldList%stdname), ESMF_LOGMSG_INFO) - fldList => fldList%next - end do - enddo - end if + call dshr_fldList_add(fldsImport, trim(flds_scalar_name)) + call dshr_fldList_add(fldsImport, field_in_tsrf) + call dshr_fldList_add(fldsImport, field_in_qice) + + do ns = 1,num_icesheets + write(cnum,'(i0)') ns + fldlist => fldsImport ! the head of the linked list + do while (associated(fldlist)) + call NUOPC_Advertise(NStateImp(ns), standardName=fldlist%stdname, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call ESMF_LogWrite('(dglc_comp_advertise): To_glc'//trim(cnum)//"_"//trim(fldList%stdname), ESMF_LOGMSG_INFO) + fldList => fldList%next + end do + enddo end subroutine dglc_datamode_noevolve_advertise @@ -172,39 +165,37 @@ subroutine dglc_datamode_noevolve_init_pointers(NStateExp, NstateImp, rc) end do ! initialize pointers to import fields if appropriate - if (get_import_data) then - allocate(Sl_tsrf(num_icesheets)) - allocate(Flgl_qice(num_icesheets)) - - do ns = 1,num_icesheets - ! NOTE: the field is connected ONLY if the MED->GLC entry is in the nuopc.runconfig file - ! This restriction occurs even if the field was advertised - if (NUOPC_IsConnected(NStateImp(ns), fieldName=field_in_tsrf)) then - call dshr_state_getfldptr(NStateImp(ns), field_in_tsrf, fldptr1=Sl_tsrf(ns)%ptr, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - end if - if (NUOPC_IsConnected(NStateImp(ns), fieldName=field_in_qice)) then - call dshr_state_getfldptr(NStateImp(ns), field_in_qice, fldptr1=Flgl_qice(ns)%ptr, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - end if - end do - end if + allocate(Sl_tsrf(num_icesheets)) + allocate(Flgl_qice(num_icesheets)) + + do ns = 1,num_icesheets + ! NOTE: the field is connected ONLY if the MED->GLC entry is in the nuopc.runconfig file + ! This restriction occurs even if the field was advertised + if (NUOPC_IsConnected(NStateImp(ns), fieldName=field_in_tsrf)) then + call dshr_state_getfldptr(NStateImp(ns), field_in_tsrf, fldptr1=Sl_tsrf(ns)%ptr, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end if + if (NUOPC_IsConnected(NStateImp(ns), fieldName=field_in_qice)) then + call dshr_state_getfldptr(NStateImp(ns), field_in_qice, fldptr1=Flgl_qice(ns)%ptr, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end if + end do end subroutine dglc_datamode_noevolve_init_pointers !=============================================================================== subroutine dglc_datamode_noevolve_advance(pio_subsystem, io_type, io_format, & - model_meshes, model_areas, input_files, rc) + model_meshes, model_internal_gridsize, model_datafiles, rc) ! Assume that the model mesh is the same as the input data mesh ! input/output variables - type(iosystem_desc_t) , pointer :: pio_subsystem ! pio info - integer , intent(in) :: io_type ! pio info - integer , intent(in) :: io_format ! pio info - type(ESMF_Mesh) , intent(in) :: model_meshes(:) ! ice sheets meshes - real(r8) , intent(in) :: model_areas(:) ! internal model ice sheets areas (radians**2) - character(len=*) , intent(in) :: input_files(:) ! input file names + type(iosystem_desc_t) , pointer :: pio_subsystem ! pio info + integer , intent(in) :: io_type ! pio info + integer , intent(in) :: io_format ! pio info + type(ESMF_Mesh) , intent(in) :: model_meshes(:) ! ice sheets meshes + real(r8) , intent(in) :: model_internal_gridsize(:) ! internal model gridsizes (m) + character(len=*) , intent(in) :: model_datafiles(:) ! input file names integer , intent(out) :: rc ! local variables @@ -251,8 +242,11 @@ subroutine dglc_datamode_noevolve_advance(pio_subsystem, io_type, io_format, & if (ChkErr(rc,__LINE__,u_FILE_u)) return ! Determine "glc_area" ; + ! Sg_areas is in radians + ! SHR_CONST_REARTH is the radius of earth in m + ! model_internal_gridsize is the internal model gridsize in m do ng = 1,lsize - Sg_area(ns)%ptr(ng) = model_areas(ns) + Sg_area(ns)%ptr(ng) = (model_internal_gridsize(ns)/SHR_CONST_REARTH)**2 end do ! Create module level field bundle @@ -271,12 +265,12 @@ subroutine dglc_datamode_noevolve_advance(pio_subsystem, io_type, io_format, & if (chkerr(rc,__LINE__,u_FILE_u)) return ! Create pioid and pio_iodesc at the module level - inquire(file=trim(input_files(ns)), exist=exists) + inquire(file=trim(model_datafiles(ns)), exist=exists) if (.not.exists) then - write(6,'(a)')' ERROR: model input file '//trim(input_files(ns))//' does not exist' + write(6,'(a)')' ERROR: model input file '//trim(model_datafiles(ns))//' does not exist' call shr_sys_abort() end if - rcode = pio_openfile(pio_subsystem, pioid, io_type, trim(input_files(ns)), pio_nowrite) + rcode = pio_openfile(pio_subsystem, pioid, io_type, trim(model_datafiles(ns)), pio_nowrite) call pio_seterrorhandling(pioid, PIO_BCAST_ERROR) rcode = pio_inq_varid(pioid, 'thk', varid) rcode = pio_inq_varndims(pioid, varid, ndims) diff --git a/dglc/glc_comp_nuopc.F90 b/dglc/glc_comp_nuopc.F90 index ad521bf9b..233794fd3 100644 --- a/dglc/glc_comp_nuopc.F90 +++ b/dglc/glc_comp_nuopc.F90 @@ -63,14 +63,13 @@ module cdeps_dglc_comp character(*) , parameter :: nullstr = 'null' integer , parameter :: max_icesheets = 10 ! maximum number of ice sheets for namelist input integer :: num_icesheets ! actual number of ice sheets - logical :: get_import_data = .false. ! namelist input character(CL) :: model_meshfiles(max_icesheets) = nullstr character(CL) :: model_datafiles(max_icesheets) = nullstr integer :: nx_global(max_icesheets) = 0 integer :: ny_global(max_icesheets) = 0 - real(r8) :: model_areas(max_icesheets) = 1.e36 + real(r8) :: model_internal_gridsize(max_icesheets) = 1.e36 ! module variables for multiple ice sheets type(shr_strdata_type) , allocatable :: sdat(:) @@ -184,7 +183,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) integer :: inst_index ! number of current instance (ie. 1) integer :: nu ! unit number integer :: ierr ! error code - integer :: bcasttmp(3) + integer :: bcasttmp(2) integer :: ns character(len=CS) :: cnum character(len=ESMF_MAXSTR) :: model_datafiles_list ! colon separated string containing input datafiles @@ -194,8 +193,8 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! Note that the suffix '-list' refers to a colon delimited string of names namelist / dglc_nml / datamode, & - model_meshfiles_list, model_datafiles_list, model_areas, nx_global, ny_global, & - get_import_data, restfilm, skip_restart_read + model_meshfiles_list, model_datafiles_list, model_internal_gridsize, nx_global, ny_global, & + restfilm, skip_restart_read rc = ESMF_SUCCESS @@ -238,22 +237,19 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) write(logunit,'(a,a)')' case_name = ',trim(case_name) write(logunit,'(a,a)')' datamode = ',trim(datamode) do ns = 1,num_icesheets - write(logunit,'(a,i4 )') ' ice_sheet index = ',ns - write(logunit,'(a,a )') ' model_meshfile = ',trim(model_meshfiles(ns)) - write(logunit,'(a,a )') ' model_datafile = ',trim(model_datafiles(ns)) - write(logunit,'(a,i10)') ' nx_global = ',nx_global(ns) - write(logunit,'(a,i10)') ' ny_global = ',ny_global(ns) - write(logunit,'(a,d13.5)')' model_areas = ',model_areas(ns) + write(logunit,'(a,i4 )') ' ice_sheet index = ',ns + write(logunit,'(a,a )') ' model_meshfile = ',trim(model_meshfiles(ns)) + write(logunit,'(a,a )') ' model_datafile = ',trim(model_datafiles(ns)) + write(logunit,'(a,d13.5)')' model_internal_gridsize = ',model_internal_gridsize(ns) + write(logunit,'(a,i10)') ' nx_global = ',nx_global(ns) + write(logunit,'(a,i10)') ' ny_global = ',ny_global(ns) end do write(logunit,'(a,a )')' restfilm = ',trim(restfilm) - write(logunit,'(a,l6)')' get_import_data = ',get_import_data write(logunit,'(a,l6)')' skip_restart_read = ',skip_restart_read bcasttmp(1) = 0 if(skip_restart_read) bcasttmp(1) = 1 - bcasttmp(2) = 0 - if(get_import_data) bcasttmp(2) = 1 - bcasttmp(3) = num_icesheets + bcasttmp(2) = num_icesheets endif ! Broadcast namelist input @@ -267,17 +263,16 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call ESMF_VMBroadcast(vm, model_datafiles, CL*max_icesheets, main_task, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return + call ESMF_VMBroadcast(vm, model_internal_gridsize, max_icesheets, main_task, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return call ESMF_VMBroadcast(vm, nx_global, max_icesheets, main_task, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call ESMF_VMBroadcast(vm, ny_global, max_icesheets, main_task, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call ESMF_VMBroadcast(vm, model_areas, max_icesheets, main_task, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return call ESMF_VMBroadcast(vm, bcasttmp, 3, main_task, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return skip_restart_read = (bcasttmp(1) == 1) - get_import_data = (bcasttmp(2) == 1) - num_icesheets = bcasttmp(3) + num_icesheets = bcasttmp(2) ! Validate datamode if ( trim(datamode) == 'noevolve') then ! read stream, no import data @@ -304,7 +299,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! Advertise dglc fields if (trim(datamode)=='noevolve') then call dglc_datamode_noevolve_advertise(NStateExp, fldsexport, NStateImp, fldsimport, & - get_import_data, flds_scalar_name, rc) + flds_scalar_name, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return end if @@ -571,7 +566,7 @@ subroutine dglc_comp_run(clock, target_ymd, target_tod, restart_write, rc) select case (trim(datamode)) case('noevolve') call dglc_datamode_noevolve_advance(sdat(1)%pio_subsystem, sdat(1)%io_type, sdat(1)%io_format, & - model_meshes, model_areas, model_datafiles, rc) + model_meshes, model_internal_gridsize, model_datafiles, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return end select