diff --git a/CMakeLists.txt b/CMakeLists.txt index 1996e8525..733855ab2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ if (DEFINED CIMEROOT) set(CMAKE_Fortran_COMPILER ${MPIFC}) set(CMAKE_CXX_COMPILER ${MPICXX}) endif() - set(CMAKE_Fortran_FLAGS "${FFLAGS} -I${LIBROOT}/include -I${LIBROOT}/finclude -I${LIBROOT}/nuopc/esmf/${NINST_VALUE}/include") + set(CMAKE_Fortran_FLAGS "${FFLAGS} ${CPPDEFS} -I${LIBROOT}/include -I${LIBROOT}/finclude -I${LIBROOT}/nuopc/esmf/${NINST_VALUE}/include") else() set(BLD_STANDALONE TRUE) endif() diff --git a/cime_config/testdefs/testlist_cdeps.xml b/cime_config/testdefs/testlist_cdeps.xml index e49889d71..72f019c6c 100644 --- a/cime_config/testdefs/testlist_cdeps.xml +++ b/cime_config/testdefs/testlist_cdeps.xml @@ -1,7 +1,7 @@ - + @@ -9,7 +9,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -25,7 +25,7 @@ - + @@ -33,7 +33,7 @@ - + @@ -41,7 +41,7 @@ - + @@ -49,7 +49,7 @@ - + diff --git a/datm/atm_comp_nuopc.F90 b/datm/atm_comp_nuopc.F90 index d14964a3d..d10e83c27 100644 --- a/datm/atm_comp_nuopc.F90 +++ b/datm/atm_comp_nuopc.F90 @@ -217,7 +217,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! Obtain flds_scalar values, mpi values, multi-instance values and ! set logunit and set shr logging to my log file - call dshr_init(gcomp, mpicom, my_task, inst_index, inst_suffix, & + call dshr_init(gcomp, 'ATM', sdat, mpicom, my_task, inst_index, inst_suffix, & flds_scalar_name, flds_scalar_num, flds_scalar_index_nx, flds_scalar_index_ny, & logunit, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -366,7 +366,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) ! Initialize mesh, restart flag, compid, and logunit call ESMF_TraceRegionEnter('datm_strdata_init') - call dshr_mesh_init(gcomp, nullstr, logunit, 'ATM', nx_global, ny_global, & + call dshr_mesh_init(gcomp, sdat, nullstr, logunit, 'ATM', nx_global, ny_global, & model_meshfile, model_maskfile, model_createmesh_fromfile, model_mesh, & model_mask, model_frac, restart_read, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return diff --git a/datm/cime_config/buildnml b/datm/cime_config/buildnml index ebfde5be8..265274521 100755 --- a/datm/cime_config/buildnml +++ b/datm/cime_config/buildnml @@ -74,8 +74,10 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path config['datm_co2_tseries'] = datm_co2_tseries config['datm_presaero'] = datm_presaero config['cime_model'] = get_model() - config['scol_mode'] = 'true' if case.get_value('PTS_MODE') else 'false' - config['create_mesh'] = 'true' if case.get_value("ATM_DOMAIN_MESH") == 'create_mesh' else 'false' + if case.get_value('PTS_MODE'): + config['mode'] = 'single_column' + else: + config['mode'] = case.get_value("ATM_DOMAIN_MESH") nmlgen.init_defaults(infile, config) diff --git a/datm/cime_config/config_component.xml b/datm/cime_config/config_component.xml index 59f5aef4b..d5639c3fb 100644 --- a/datm/cime_config/config_component.xml +++ b/datm/cime_config/config_component.xml @@ -159,46 +159,7 @@ case name used to determine stream filenames when DATM_MODE is CPLHIST - - integer - - -999 - run_component_datm - env_run.xml - - Simulation year corresponding to DATM_CPLHIST_YR_START (only used - when DATM_MODE is CPLHIST). A common usage is to set this to - RUN_STARTDATE. With this setting, the forcing in the first year of - the run will be the forcing of year DATM_CPLHIST_YR_START. Another - use case is to align the calendar of transient forcing with the - model calendar. For example, setting - DATM_CPLHIST_YR_ALIGN=DATM_CPLHIST_YR_START will lead to the - forcing calendar being the same as the model calendar. The forcing - for a given model year would be the forcing of the same year. This - would be appropriate in transient runs where the model calendar is - setup to span the same year range as the forcing data. - - - - - integer - - -999 - run_component_datm - env_run.xml - starting year to loop data over (only used when DATM_MODE is CPLHIST) - - - - integer - - -999 - run_component_datm - env_run.xml - ending year to loop data over (only used when DATM_MODE is CPLHIST) - - - + integer 1 @@ -209,26 +170,38 @@ 1895 1901 1901 - $DATM_CLMNCEP_YR_START + $DATM_YR_START 1895 1901 1901 - $DATM_CLMNCEP_YR_START - $DATM_CLMNCEP_YR_START - $DATM_CLMNCEP_YR_START + $DATM_YR_START + $DATM_YR_START + $DATM_YR_START 1 1 - $DATM_CLMNCEP_YR_START - $DATM_CLMNCEP_YR_START - $DATM_CLMNCEP_YR_START - $DATM_CLMNCEP_YR_START + $DATM_YR_START + $DATM_YR_START + $DATM_YR_START + $DATM_YR_START run_component_datm env_run.xml - year align + + Simulation year corresponding to DATM_YR_START. A common usage + is to set this to RUN_STARTDATE. With this setting, the forcing + in the first year of the run will be the forcing of year + DATM_YR_START. Another use case is to align the calendar + of transient forcing with the model calendar. For example, + setting DATM_YR_ALIGN=DATM_YR_START will lead to + the forcing calendar being the same as the model calendar. The + forcing for a given model year would be the forcing of the same + year. This would be appropriate in transient runs where the + model calendar is setup to span the same year range as the + forcing data. + - + integer 2004 @@ -270,7 +243,7 @@ starting year to loop data over - + integer 2004 diff --git a/datm/cime_config/namelist_definition_datm.xml b/datm/cime_config/namelist_definition_datm.xml index a8c420889..eaaf9290d 100644 --- a/datm/cime_config/namelist_definition_datm.xml +++ b/datm/cime_config/namelist_definition_datm.xml @@ -133,8 +133,8 @@ $ATM_DOMAIN_MESH - null - null + null + null @@ -148,8 +148,8 @@ $ATM_DOMAIN_MESH - $ATM_DOMAIN_PATH/$ATM_DOMAIN_FILE - $ATM_DOMAIN_PATH/$ATM_DOMAIN_FILE + $ATM_DOMAIN_PATH/$ATM_DOMAIN_FILE + $ATM_DOMAIN_PATH/$ATM_DOMAIN_FILE @@ -163,8 +163,8 @@ null - $ATM_DOMAIN_PATH/$ATM_DOMAIN_FILE - $ATM_DOMAIN_PATH/$ATM_DOMAIN_FILE + $ATM_DOMAIN_PATH/$ATM_DOMAIN_FILE + $ATM_DOMAIN_PATH/$ATM_DOMAIN_FILE diff --git a/datm/cime_config/stream_definition_datm.xml b/datm/cime_config/stream_definition_datm.xml index d7a957bc3..24af2bacd 100644 --- a/datm/cime_config/stream_definition_datm.xml +++ b/datm/cime_config/stream_definition_datm.xml @@ -214,9 +214,9 @@ nn null - $DATM_CLMNCEP_YR_ALIGN - $DATM_CLMNCEP_YR_START - $DATM_CLMNCEP_YR_END + $DATM_YR_ALIGN + $DATM_YR_START + $DATM_YR_END 0 coszen @@ -246,9 +246,9 @@ nn null - $DATM_CLMNCEP_YR_ALIGN - $DATM_CLMNCEP_YR_START - $DATM_CLMNCEP_YR_END + $DATM_YR_ALIGN + $DATM_YR_START + $DATM_YR_END 0 nearest @@ -282,9 +282,9 @@ nn null - $DATM_CLMNCEP_YR_ALIGN - $DATM_CLMNCEP_YR_START - $DATM_CLMNCEP_YR_END + $DATM_YR_ALIGN + $DATM_YR_START + $DATM_YR_END 0 linear @@ -317,9 +317,9 @@ bilinear null - $DATM_CLMNCEP_YR_ALIGN - $DATM_CLMNCEP_YR_START - $DATM_CLMNCEP_YR_END + $DATM_YR_ALIGN + $DATM_YR_START + $DATM_YR_END 0 coszen @@ -348,9 +348,9 @@ bilinear null - $DATM_CLMNCEP_YR_ALIGN - $DATM_CLMNCEP_YR_START - $DATM_CLMNCEP_YR_END + $DATM_YR_ALIGN + $DATM_YR_START + $DATM_YR_END 0 nearest @@ -383,9 +383,9 @@ nn null - $DATM_CLMNCEP_YR_ALIGN - $DATM_CLMNCEP_YR_START - $DATM_CLMNCEP_YR_END + $DATM_YR_ALIGN + $DATM_YR_START + $DATM_YR_END 0 linear @@ -419,9 +419,9 @@ nn null - $DATM_CLMNCEP_YR_ALIGN - $DATM_CLMNCEP_YR_START - $DATM_CLMNCEP_YR_END + $DATM_YR_ALIGN + $DATM_YR_START + $DATM_YR_END 0 coszen @@ -451,9 +451,9 @@ nn null - $DATM_CLMNCEP_YR_ALIGN - $DATM_CLMNCEP_YR_START - $DATM_CLMNCEP_YR_END + $DATM_YR_ALIGN + $DATM_YR_START + $DATM_YR_END 0 nearest @@ -486,9 +486,9 @@ nn null - $DATM_CLMNCEP_YR_ALIGN - $DATM_CLMNCEP_YR_START - $DATM_CLMNCEP_YR_END + $DATM_YR_ALIGN + $DATM_YR_START + $DATM_YR_END 0 linear @@ -522,7 +522,7 @@ nn null - $DATM_CLMNCEP_YR_ALIGN + $DATM_YR_ALIGN 2000 2004 0 @@ -554,7 +554,7 @@ nn null - $DATM_CLMNCEP_YR_ALIGN + $DATM_YR_ALIGN 2000 2004 0 @@ -589,7 +589,7 @@ nn null - $DATM_CLMNCEP_YR_ALIGN + $DATM_YR_ALIGN 2000 2004 0 @@ -624,9 +624,9 @@ redist null - $DATM_CLMNCEP_YR_ALIGN - $DATM_CLMNCEP_YR_START - $DATM_CLMNCEP_YR_END + $DATM_YR_ALIGN + $DATM_YR_START + $DATM_YR_END 0 coszen @@ -655,9 +655,9 @@ redist null - $DATM_CLMNCEP_YR_ALIGN - $DATM_CLMNCEP_YR_START - $DATM_CLMNCEP_YR_END + $DATM_YR_ALIGN + $DATM_YR_START + $DATM_YR_END 0 nearest @@ -690,9 +690,9 @@ redist null - $DATM_CLMNCEP_YR_ALIGN - $DATM_CLMNCEP_YR_START - $DATM_CLMNCEP_YR_END + $DATM_YR_ALIGN + $DATM_YR_START + $DATM_YR_END 0 linear @@ -734,7 +734,7 @@ none null - $DATM_CLMNCEP_YR_ALIGN + $DATM_YR_ALIGN 1993 1993 0 @@ -774,7 +774,7 @@ none null - $DATM_CLMNCEP_YR_ALIGN + $DATM_YR_ALIGN 1992 1992 0 @@ -829,7 +829,7 @@ none null - $DATM_CLMNCEP_YR_ALIGN + $DATM_YR_ALIGN 0001 0002 0 @@ -3427,7 +3427,7 @@ $ATM_DOMAIN_MESH - $DATM_CPLHIST_DIR/$DATM_CPLHIST_CASE.cpl.ha2x3h.%ym.nc + $DATM_CPLHIST_DIR/$DATM_CPLHIST_CASE.cpl.ha2x3h.%ym.nc a2x3h_Sa_topo Sa_topo @@ -3438,9 +3438,9 @@ nn null - $DATM_CPLHIST_YR_ALIGN - $DATM_CPLHIST_YR_START - $DATM_CPLHIST_YR_END + $DATM_YR_ALIGN + $DATM_YR_START + $DATM_YR_END 0 nearest @@ -3458,7 +3458,7 @@ $ATM_DOMAIN_MESH - $DATM_CPLHIST_DIR/$DATM_CPLHIST_CASE.cpl.ha2x1d.%ym.nc + $DATM_CPLHIST_DIR/$DATM_CPLHIST_CASE.cpl.ha2x1d.%ym.nc a2x1d_Faxa_bcphiwet Faxa_bcphiwet @@ -3482,9 +3482,9 @@ nn null - $DATM_CPLHIST_YR_ALIGN - $DATM_CPLHIST_YR_START - $DATM_CPLHIST_YR_END + $DATM_YR_ALIGN + $DATM_YR_START + $DATM_YR_END 0 nearest @@ -3503,7 +3503,7 @@ $ATM_DOMAIN_MESH - $DATM_CPLHIST_DIR/$DATM_CPLHIST_CASE.cpl.ha2x1hi.%ym.nc + $DATM_CPLHIST_DIR/$DATM_CPLHIST_CASE.cpl.ha2x1hi.%ym.nc a2x1hi_Faxa_swndr Faxa_swndr @@ -3517,9 +3517,9 @@ nn null - $DATM_CPLHIST_YR_ALIGN - $DATM_CPLHIST_YR_START - $DATM_CPLHIST_YR_END + $DATM_YR_ALIGN + $DATM_YR_START + $DATM_YR_END 2700 nearest @@ -3538,7 +3538,7 @@ $ATM_DOMAIN_MESH - $DATM_CPLHIST_DIR/$DATM_CPLHIST_CASE.cpl.ha2x3h.%ym.nc + $DATM_CPLHIST_DIR/$DATM_CPLHIST_CASE.cpl.ha2x3h.%ym.nc a2x3h_Faxa_rainc Faxa_rainc @@ -3553,9 +3553,9 @@ nn null - $DATM_CPLHIST_YR_ALIGN - $DATM_CPLHIST_YR_START - $DATM_CPLHIST_YR_END + $DATM_YR_ALIGN + $DATM_YR_START + $DATM_YR_END 900 nearest @@ -3574,7 +3574,7 @@ $ATM_DOMAIN_MESH - $DATM_CPLHIST_DIR/$DATM_CPLHIST_CASE.cpl.ha2x3h.%ym.nc + $DATM_CPLHIST_DIR/$DATM_CPLHIST_CASE.cpl.ha2x3h.%ym.nc a2x3h_Sa_z Sa_z @@ -3593,9 +3593,9 @@ nn null - $DATM_CPLHIST_YR_ALIGN - $DATM_CPLHIST_YR_START - $DATM_CPLHIST_YR_END + $DATM_YR_ALIGN + $DATM_YR_START + $DATM_YR_END 900 linear @@ -3614,7 +3614,7 @@ $ATM_DOMAIN_MESH - $DATM_CPLHIST_DIR/$DATM_CPLHIST_CASE.cpl.ha2x1h.%ym.nc + $DATM_CPLHIST_DIR/$DATM_CPLHIST_CASE.cpl.ha2x1h.%ym.nc a2x1h_Sa_u Sa_u @@ -3626,9 +3626,9 @@ nn null - $DATM_CPLHIST_YR_ALIGN - $DATM_CPLHIST_YR_START - $DATM_CPLHIST_YR_END + $DATM_YR_ALIGN + $DATM_YR_START + $DATM_YR_END 900 linear diff --git a/dice/cime_config/buildnml b/dice/cime_config/buildnml index 7b925d5b4..aca70e45e 100755 --- a/dice/cime_config/buildnml +++ b/dice/cime_config/buildnml @@ -63,10 +63,15 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path config = {} config['ice_grid'] = ice_grid config['dice_mode'] = dice_mode - config['scol_mode'] = 'true' if case.get_value('PTS_MODE') else 'false' - config['create_mesh'] = 'true' if case.get_value("ICE_DOMAIN_MESH") == 'create_mesh' else 'false' - scol_mode = True if case.get_value('PTS_MODE') else False - config['set_model_maskfile'] = 'true' if scol_mode or (ice_nx==atm_nx and ice_ny==atm_ny) else 'false' + config['set_model_maskfile'] = 'false' + if case.get_value('PTS_MODE'): + config['mode'] = 'single_column' + config['set_model_maskfile'] = 'true' + else: + config['mode'] = case.get_value("ICE_DOMAIN_MESH") + + if (ice_nx==atm_nx and ice_ny==atm_ny): + config['set_model_maskfile'] = 'true' # Initialize nmlgen nmlgen.init_defaults(infile, config) diff --git a/dice/cime_config/namelist_definition_dice.xml b/dice/cime_config/namelist_definition_dice.xml index fe18d508a..7f375bfc1 100644 --- a/dice/cime_config/namelist_definition_dice.xml +++ b/dice/cime_config/namelist_definition_dice.xml @@ -54,8 +54,8 @@ file specifying model mesh $ICE_DOMAIN_MESH - null - null + null + null @@ -68,10 +68,7 @@ file specifying model mask if not obtained from input model mesh - $ICE_DOMAIN_MESH - $ICE_DOMAIN_PATH/$ICE_DOMAIN_FILE - $ICE_DOMAIN_PATH/$ICE_DOMAIN_FILE - $ICE_DOMAIN_PATH/$ICE_DOMAIN_FILE + $MASK_MESH @@ -83,8 +80,8 @@ file specifying if model mesh is to be created at runtime null - $ICE_DOMAIN_PATH/$ICE_DOMAIN_FILE - $ICE_DOMAIN_PATH/$ICE_DOMAIN_FILE + $ICE_DOMAIN_PATH/$ICE_DOMAIN_FILE + $ICE_DOMAIN_PATH/$ICE_DOMAIN_FILE diff --git a/dice/ice_comp_nuopc.F90 b/dice/ice_comp_nuopc.F90 index de243e597..4fd0fa5f9 100644 --- a/dice/ice_comp_nuopc.F90 +++ b/dice/ice_comp_nuopc.F90 @@ -180,7 +180,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! Obtain flds_scalar values, mpi values, multi-instance values and ! set logunit and set shr logging to my log file - call dshr_init(gcomp, mpicom, my_task, inst_index, inst_suffix, & + call dshr_init(gcomp, 'ICE', sdat, mpicom, my_task, inst_index, inst_suffix, & flds_scalar_name, flds_scalar_num, flds_scalar_index_nx, flds_scalar_index_ny, & logunit, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -301,7 +301,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) ! Initialize mesh, restart flag, logunit call ESMF_TraceRegionEnter('dice_strdata_init') - call dshr_mesh_init(gcomp, nullstr, logunit, 'ICE', nx_global, ny_global, & + call dshr_mesh_init(gcomp, sdat, nullstr, logunit, 'ICE', nx_global, ny_global, & model_meshfile, model_maskfile, model_createmesh_fromfile, model_mesh, & model_mask, model_frac, restart_read, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return diff --git a/dlnd/cime_config/buildnml b/dlnd/cime_config/buildnml index e6176e3bd..667657784 100755 --- a/dlnd/cime_config/buildnml +++ b/dlnd/cime_config/buildnml @@ -62,9 +62,8 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path config['dlnd_mode'] = dlnd_mode config['create_mesh'] = 'true' if case.get_value("LND_DOMAIN_MESH") == 'create_mesh' else 'false' - # Do not allow single column mode for drof - scol_mode = True if case.get_value('PTS_MODE') else False - expect(not scol_mode, + # Do not allow single column mode for dlnd + expect(not case.get_value('PTS_MODE'), "for DLND, single column mode is not allowed") # Initialize nmlgen diff --git a/dlnd/lnd_comp_nuopc.F90 b/dlnd/lnd_comp_nuopc.F90 index 566b80441..5e0cc6c92 100644 --- a/dlnd/lnd_comp_nuopc.F90 +++ b/dlnd/lnd_comp_nuopc.F90 @@ -175,7 +175,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! Obtain flds_scalar values, mpi values, multi-instance values and ! set logunit and set shr logging to my log file - call dshr_init(gcomp, mpicom, my_task, inst_index, inst_suffix, & + call dshr_init(gcomp, 'LND', sdat, mpicom, my_task, inst_index, inst_suffix, & flds_scalar_name, flds_scalar_num, flds_scalar_index_nx, flds_scalar_index_ny, & logunit, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -282,7 +282,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) ! Initialize sdat call ESMF_TraceRegionEnter('dlnd_strdata_init') - call dshr_mesh_init(gcomp, nullstr, logunit, 'LND', nx_global, ny_global, & + call dshr_mesh_init(gcomp, sdat, nullstr, logunit, 'LND', nx_global, ny_global, & model_meshfile, model_maskfile, model_createmesh_fromfile, model_mesh, & model_mask, model_frac, restart_read, rc=rc) diff --git a/doc/source/streams.rst b/doc/source/streams.rst index c2f7d9073..743f31b65 100644 --- a/doc/source/streams.rst +++ b/doc/source/streams.rst @@ -219,15 +219,15 @@ where: over the forcing data for 1901-1920, and then run the model for years 1901-2010 using the forcing data from 1901-2010. To do this, initially set:: - ./xmlchange DATM_CLMNCEP_YR_ALIGN=1901 - ./xmlchange DATM_CLMNCEP_YR_START=1901 - ./xmlchange DATM_CLMNCEP_YR_END=1920 + ./xmlchange DATM_YR_ALIGN=1901 + ./xmlchange DATM_YR_START=1901 + ./xmlchange DATM_YR_END=1920 When the model has completed year 1900, set:: - ./xmlchange DATM_CLMNCEP_YR_ALIGN=1901 - ./xmlchange DATM_CLMNCEP_YR_START=1901 - ./xmlchange DATM_CLMNCEP_YR_END=2010 + ./xmlchange DATM_YR_ALIGN=1901 + ./xmlchange DATM_YR_START=1901 + ./xmlchange DATM_YR_END=2010 With this setup, the correlation between model run year and forcing year looks like this:: @@ -235,7 +235,7 @@ where: RUN Year : 1850 ... 1860 1861 ... 1870 ... 1880 1881 ... 1890 ... 1900 1901 ... 2010 FORCE Year : 1910 ... 1920 1901 ... 1910 ... 1920 1901 ... 1910 ... 1920 1901 ... 2010 - Setting ``DATM_CLMNCEP_YR_ALIGN`` to 1901 tells the code that you want + Setting ``DATM_YR_ALIGN`` to 1901 tells the code that you want to align model year 1901 with forcing data year 1901, and then it calculates what the forcing year should be if the model starts in year 1850. diff --git a/docn/cime_config/buildnml b/docn/cime_config/buildnml index e76b8d0c1..16066f7a3 100755 --- a/docn/cime_config/buildnml +++ b/docn/cime_config/buildnml @@ -69,7 +69,6 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path config['docn_mode'] = docn_mode config['create_mesh'] = 'true' if case.get_value("OCN_DOMAIN_MESH") == 'create_mesh' else 'false' config['aqua_planet'] = 'true' if 'aquap' in docn_mode else 'false' - scol_mode = True if case.get_value('PTS_MODE') else False nmlgen.init_defaults(infile, config) diff --git a/docn/cime_config/namelist_definition_docn.xml b/docn/cime_config/namelist_definition_docn.xml index cd7af94c0..aa5a050f5 100644 --- a/docn/cime_config/namelist_definition_docn.xml +++ b/docn/cime_config/namelist_definition_docn.xml @@ -119,8 +119,8 @@ $OCN_DOMAIN_MESH - null - null + null + null @@ -148,8 +148,8 @@ null - $OCN_DOMAIN_PATH/$OCN_DOMAIN_FILE - $OCN_DOMAIN_PATH/$OCN_DOMAIN_FILE + $OCN_DOMAIN_PATH/$OCN_DOMAIN_FILE + $OCN_DOMAIN_PATH/$OCN_DOMAIN_FILE diff --git a/docn/ocn_comp_nuopc.F90 b/docn/ocn_comp_nuopc.F90 index 6a73b1043..b6c3b15e7 100644 --- a/docn/ocn_comp_nuopc.F90 +++ b/docn/ocn_comp_nuopc.F90 @@ -191,7 +191,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! Obtain flds_scalar values, mpi values, multi-instance values and ! set logunit and set shr logging to my log file - call dshr_init(gcomp, mpicom, my_task, inst_index, inst_suffix, & + call dshr_init(gcomp, 'OCN', sdat, mpicom, my_task, inst_index, inst_suffix, & flds_scalar_name, flds_scalar_num, flds_scalar_index_nx, flds_scalar_index_ny, logunit, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -322,7 +322,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) ! Initialize model mesh, restart flag, logunit, model_mask and model_frac call ESMF_TraceRegionEnter('docn_strdata_init') - call dshr_mesh_init(gcomp, nullstr, logunit, 'OCN', nx_global, ny_global, & + call dshr_mesh_init(gcomp, sdat, nullstr, logunit, 'OCN', nx_global, ny_global, & model_meshfile, model_maskfile, model_createmesh_fromfile, model_mesh, & model_mask, model_frac, restart_read, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return diff --git a/drof/cime_config/buildnml b/drof/cime_config/buildnml index 316b46906..f7d567504 100755 --- a/drof/cime_config/buildnml +++ b/drof/cime_config/buildnml @@ -63,8 +63,7 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path config['create_mesh'] = 'true' if case.get_value("ROF_DOMAIN_MESH") == 'create_mesh' else 'false' # Do not allow single column mode for drof - scol_mode = True if case.get_value('PTS_MODE') else False - expect(not scol_mode, + expect(not case.get_value('PTS_MODE'), "for, DROF single column mode is not allowed") # Initialize nmlgen diff --git a/drof/rof_comp_nuopc.F90 b/drof/rof_comp_nuopc.F90 index aef47ee01..27c0139d1 100644 --- a/drof/rof_comp_nuopc.F90 +++ b/drof/rof_comp_nuopc.F90 @@ -171,7 +171,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! Obtain flds_scalar values, mpi values, multi-instance values and ! set logunit and set shr logging to my log file - call dshr_init(gcomp, mpicom, my_task, inst_index, inst_suffix, & + call dshr_init(gcomp, 'ROF', sdat, mpicom, my_task, inst_index, inst_suffix, & flds_scalar_name, flds_scalar_num, flds_scalar_index_nx, flds_scalar_index_ny, & logunit, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -279,7 +279,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) ! Initialize mesh, restart flag, logunit call ESMF_TraceRegionEnter('drof_strdata_init') - call dshr_mesh_init(gcomp, nullstr, logunit, 'ROF', nx_global, ny_global, & + call dshr_mesh_init(gcomp, sdat, nullstr, logunit, 'ROF', nx_global, ny_global, & model_meshfile, model_maskfile, model_createmesh_fromfile, model_mesh, & model_mask, model_frac, restart_read, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return diff --git a/dshr/dshr_mod.F90 b/dshr/dshr_mod.F90 index eec384601..0ad235a1e 100644 --- a/dshr/dshr_mod.F90 +++ b/dshr/dshr_mod.F90 @@ -30,6 +30,7 @@ module dshr_mod use ESMF , only : ESMF_RouteHandle, ESMF_FieldRegrid use ESMF , only : ESMF_TERMORDER_SRCSEQ, ESMF_FieldRegridStore, ESMF_SparseMatrixWrite use ESMF , only : ESMF_Region_Flag, ESMF_REGION_TOTAL, ESMF_MAXSTR, ESMF_RC_NOT_VALID + use ESMF , only : ESMF_UtilStringUpperCase use shr_kind_mod , only : r8=>shr_kind_r8, cs=>shr_kind_cs, cl=>shr_kind_cl, cxx=>shr_kind_cxx, i8=>shr_kind_i8 use shr_sys_mod , only : shr_sys_abort use shr_mpi_mod , only : shr_mpi_bcast @@ -37,7 +38,9 @@ module dshr_mod use shr_cal_mod , only : shr_cal_datetod2string, shr_cal_date2julian use shr_const_mod , only : shr_const_spval, shr_const_cday use shr_orb_mod , only : shr_orb_params, SHR_ORB_UNDEF_INT, SHR_ORB_UNDEF_REAL +#ifdef CESMCOUPLED use shr_pio_mod , only : shr_pio_getiosys, shr_pio_getiotype, shr_pio_getioformat +#endif use dshr_strdata_mod , only : shr_strdata_type, shr_strdata_init_from_xml, SHR_STRDATA_GET_STREAM_COUNT use dshr_methods_mod , only : chkerr use pio @@ -100,21 +103,23 @@ subroutine dshr_model_initphase(gcomp, importState, exportState, clock, rc) end subroutine dshr_model_initphase !=============================================================================== - subroutine dshr_init(gcomp, mpicom, my_task, inst_index, inst_suffix, & + subroutine dshr_init(gcomp, compname, sdat, mpicom, my_task, inst_index, inst_suffix, & flds_scalar_name, flds_scalar_num, flds_scalar_index_nx, flds_scalar_index_ny, logunit, rc) ! input/output variables - type(ESMF_GridComp) :: gcomp - integer , intent(inout) :: mpicom - integer , intent(out) :: my_task - integer , intent(out) :: inst_index - character(len=*) , intent(out) :: inst_suffix - character(len=*) , intent(out) :: flds_scalar_name - integer , intent(out) :: flds_scalar_num - integer , intent(out) :: flds_scalar_index_nx - integer , intent(out) :: flds_scalar_index_ny - integer , intent(out) :: logunit - integer , intent(out) :: rc + type(ESMF_GridComp) :: gcomp + character(len=*) , intent(in) :: compname !e.g. ATM, OCN, ... + type(shr_strdata_type), intent(inout) :: sdat + integer , intent(inout) :: mpicom + integer , intent(out) :: my_task + integer , intent(out) :: inst_index + character(len=*) , intent(out) :: inst_suffix + character(len=*) , intent(out) :: flds_scalar_name + integer , intent(out) :: flds_scalar_num + integer , intent(out) :: flds_scalar_index_nx + integer , intent(out) :: flds_scalar_index_ny + integer , intent(out) :: logunit + integer , intent(out) :: rc ! local variables type(ESMF_VM) :: vm @@ -195,10 +200,18 @@ subroutine dshr_init(gcomp, mpicom, my_task, inst_index, inst_suffix, & inst_index=1 endif +#ifdef CESMCOUPLED + sdat%pio_subsystem => shr_pio_getiosys(trim(compname)) + sdat%io_type = shr_pio_getiotype(trim(compname)) + sdat%io_format = shr_pio_getioformat(trim(compname)) +#else + call dshr_pio_init(gcomp, sdat, logunit, rc) +#endif + end subroutine dshr_init !=============================================================================== - subroutine dshr_mesh_init(gcomp, nullstr, logunit, compname, model_nxg, model_nyg, & + subroutine dshr_mesh_init(gcomp, sdat, nullstr, logunit, compname, model_nxg, model_nyg, & model_meshfile, model_maskfile, model_createmesh_fromfile, model_mesh, & model_mask, model_frac, read_restart, rc) @@ -207,7 +220,8 @@ subroutine dshr_mesh_init(gcomp, nullstr, logunit, compname, model_nxg, model_ny ! ---------------------------------------------- ! input/output variables - type(ESMF_GridComp), intent(inout) :: gcomp + type(ESMF_GridComp) , intent(inout) :: gcomp + type(shr_strdata_type) , intent(in) :: sdat integer , intent(in) :: logunit character(len=*) , intent(in) :: compname !e.g. ATM, OCN, ... character(len=*) , intent(in) :: nullstr @@ -238,10 +252,6 @@ subroutine dshr_mesh_init(gcomp, nullstr, logunit, compname, model_nxg, model_ny type(ESMF_Array) :: elemMaskArray type(file_desc_t) :: pioid type(var_desc_t) :: varid - type(io_desc_t) :: pio_iodesc - type(iosystem_desc_t), pointer :: pio_subsystem => null() ! pio info - integer :: io_type ! pio info - integer :: io_format ! pio info integer :: rcode logical :: isPresent, isSet logical :: masterproc @@ -322,7 +332,7 @@ subroutine dshr_mesh_init(gcomp, nullstr, logunit, compname, model_nxg, model_ny ! Now create the model meshfile call dshr_mesh_create(trim(model_createmesh_fromfile), scol_mode, scol_lon, scol_lat, & - trim(compname), my_task, logunit, model_mesh, model_mask, model_frac, rc=rc) + trim(compname), sdat, my_task, logunit, model_mesh, model_mask, model_frac, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return else @@ -379,28 +389,26 @@ end subroutine dshr_mesh_init !=============================================================================== subroutine dshr_mesh_create(filename, scol_mode, scol_lon, scol_lat, & - compname, my_task, logunit, model_mesh, model_mask, model_frac, rc) + compname, sdat, my_task, logunit, model_mesh, model_mask, model_frac, rc) ! Create the model mesh from the domain file - for either single column mode ! or for a regional grid ! input/output variables - character(len=*) , intent(in) :: filename - logical , intent(in) :: scol_mode - real(r8) , intent(inout) :: scol_lon - real(r8) , intent(inout) :: scol_lat - character(len=*) , intent(in) :: compname - integer , intent(in) :: my_task - integer , intent(in) :: logunit - type(ESMF_Mesh) , intent(out) :: model_mesh - integer , pointer , intent(out) :: model_mask(:) - real(r8), pointer , intent(out) :: model_frac(:) - integer , intent(out) :: rc + character(len=*) , intent(in) :: filename + logical , intent(in) :: scol_mode + real(r8) , intent(inout) :: scol_lon + real(r8) , intent(inout) :: scol_lat + character(len=*) , intent(in) :: compname + type(shr_strdata_type), intent(in) :: sdat + integer , intent(in) :: my_task + integer , intent(in) :: logunit + type(ESMF_Mesh) , intent(out) :: model_mesh + integer , pointer , intent(out) :: model_mask(:) + real(r8), pointer , intent(out) :: model_frac(:) + integer , intent(out) :: rc ! local variables - type(iosystem_desc_t), pointer :: pio_subsystem => null() ! pio info - integer :: io_type ! pio info - integer :: io_format ! pio info type(file_desc_t) :: pioid integer :: rcode ! error code type(var_desc_t) :: varid ! variable id @@ -431,15 +439,11 @@ subroutine dshr_mesh_create(filename, scol_mode, scol_lon, scol_lat, & rc = ESMF_SUCCESS - pio_subsystem => shr_pio_getiosys(trim(compname)) - io_type = shr_pio_getiotype(trim(compname)) - io_format = shr_pio_getioformat(trim(compname)) - !------------------------------------- ! open domain file and get dimensions !------------------------------------- - rcode = pio_openfile(pio_subsystem, pioid, io_type, trim(filename), pio_nowrite) + rcode = pio_openfile(sdat%pio_subsystem, pioid, sdat%io_type, trim(filename), pio_nowrite) call pio_check_err(rcode, 'error opening file '//trim(filename)) call PIO_seterrorhandling(pioid, PIO_BCAST_ERROR) @@ -1691,4 +1695,414 @@ subroutine dshr_set_modelmask(mesh_dst, meshfile_mask, compname, mask_dst, frac_ end subroutine dshr_set_modelmask + subroutine dshr_pio_init(gcomp, sdat, logunit, rc) + + ! ---------------------------------------------- + ! Initialize PIO + ! ---------------------------------------------- + + ! input/output variables + type(ESMF_GridComp) , intent(in) :: gcomp + type(shr_strdata_type), intent(inout) :: sdat + integer , intent(in) :: logunit + integer , intent(out) :: rc + + ! local variables: + type(ESMF_VM) :: vm + integer :: mpicom, my_task, petCount + integer :: pio_numiotasks + integer :: pio_stride + integer :: pio_rearranger + integer :: pio_root + integer :: pio_debug_level + integer :: pio_rearr_comm_type + integer :: pio_rearr_comm_fcd + logical :: pio_rearr_comm_enable_hs_comp2io + logical :: pio_rearr_comm_enable_isend_comp2io + integer :: pio_rearr_comm_max_pend_req_comp2io + logical :: pio_rearr_comm_enable_hs_io2comp + logical :: pio_rearr_comm_enable_isend_io2comp + integer :: pio_rearr_comm_max_pend_req_io2comp + logical :: isPresent, isSet, ret + character(len=CL) :: cvalue + character(len=CS) :: cname + character(len=CL) :: logmsg + character(len=CL) :: diro + character(len=CL) :: logfile + character(len=*),parameter :: subname='(dshr_pio_init)' + !------------------------------------------------------------------------------- + + rc = ESMF_SUCCESS + + ! generate local mpi comm + call ESMF_GridCompGet(gcomp, vm=vm, name=cname, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + call ESMF_VMGet(vm, mpiCommunicator=mpicom, localPet=my_task, & + petCount=petCount, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + ! query component specific PIO attributes + ! pio_netcdf_format + call NUOPC_CompAttributeGet(gcomp, name='pio_netcdf_format', value=cvalue, & + isPresent=isPresent, isSet=isSet, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + if (isPresent .and. isSet) then + cvalue = ESMF_UtilStringUpperCase(cvalue) + if (trim(cvalue) .eq. 'CLASSIC') then + sdat%io_format = 0 + else if (trim(cvalue) .eq. '64BIT_OFFSET') then + sdat%io_format = PIO_64BIT_OFFSET + else if (trim(cvalue) .eq. '64BIT_DATA') then + sdat%io_format = PIO_64BIT_DATA + else + call ESMF_LogWrite(trim(subname)//'-'//trim(cname)// & + ' : need to provide valid option for pio_ioformat & + (CLASSIC|64BIT_OFFSET|64BIT_DATA)', ESMF_LOGMSG_INFO) + rc = ESMF_FAILURE + return + end if + else + cvalue = '64BIT_OFFSET' + sdat%io_format = PIO_64BIT_OFFSET + end if + if (my_task == master_task) write(logunit,*) trim(subname)//' : pio_netcdf_format = ', & + trim(cvalue), sdat%io_format + + ! pio_typename + call NUOPC_CompAttributeGet(gcomp, name='pio_typename', value=cvalue, & + isPresent=isPresent, isSet=isSet, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + if (isPresent .and. isSet) then + cvalue = ESMF_UtilStringUpperCase(cvalue) + if (trim(cvalue) .eq. 'NETCDF') then + sdat%io_type = PIO_IOTYPE_NETCDF + else if (trim(cvalue) .eq. 'PNETCDF') then + sdat%io_type = PIO_IOTYPE_PNETCDF + else if (trim(cvalue) .eq. 'NETCDF4C') then + sdat%io_type = PIO_IOTYPE_NETCDF4C + else if (trim(cvalue) .eq. 'NETCDF4P') then + sdat%io_type = PIO_IOTYPE_NETCDF4P + else + call ESMF_LogWrite(trim(subname)//'-'//trim(cname)// & + ' : need to provide valid option for pio_typename & + (NETCDF|PNETCDF|NETCDF4C|NETCDF4P)', ESMF_LOGMSG_INFO) + rc = ESMF_FAILURE + return + end if + else + cvalue = 'NETCDF' + sdat%io_type = PIO_IOTYPE_NETCDF + end if + if (my_task == master_task) write(logunit,*) trim(subname)//' : pio_typename = ', & + trim(cvalue), sdat%io_type + + ! pio_root + call NUOPC_CompAttributeGet(gcomp, name='pio_root', value=cvalue, & + isPresent=isPresent, isSet=isSet, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + if (isPresent .and. isSet) then + read(cvalue,*) pio_root + if (pio_root < 0) then + pio_root = 1 + endif + pio_root = min(pio_root, petCount-1) + else + pio_root = 1 + end if + if (my_task == master_task) write(logunit,*) trim(subname)//' : pio_root = ', & + pio_root + + ! pio_stride + call NUOPC_CompAttributeGet(gcomp, name='pio_stride', value=cvalue, & + isPresent=isPresent, isSet=isSet, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + if (isPresent .and. isSet) then + read(cvalue,*) pio_stride + else + pio_stride = -99 + end if + if (my_task == master_task) write(logunit,*) trim(subname)//' : pio_stride = ', & + pio_stride + + ! pio_numiotasks + call NUOPC_CompAttributeGet(gcomp, name='pio_numiotasks', value=cvalue, & + isPresent=isPresent, isSet=isSet, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + if (isPresent .and. isSet) then + read(cvalue,*) pio_numiotasks + else + pio_numiotasks = -99 + end if + if (my_task == master_task) write(logunit,*) trim(subname)//' : pio_numiotasks = ', & + pio_numiotasks + + ! check for parallel IO, it requires at least two io pes + if (petCount > 1 .and. pio_numiotasks == 1 .and. & + (sdat%io_type .eq. PIO_IOTYPE_PNETCDF .or. & + sdat%io_type .eq. PIO_IOTYPE_NETCDF4P)) then + pio_numiotasks = 2 + pio_stride = min(pio_stride, petCount/2) + if (my_task == master_task) then + write(logunit,*) ' parallel io requires at least two io pes - following parameters are updated:' + write(logunit,*) trim(subname)//' : pio_stride = ', pio_stride + write(logunit,*) trim(subname)//' : pio_numiotasks = ', pio_numiotasks + end if + endif + + ! check/set/correct io pio parameters + if (pio_stride > 0 .and. pio_numiotasks < 0) then + pio_numiotasks = max(1, petCount/pio_stride) + if (my_task == master_task) write(logunit,*) trim(subname)//' : update pio_numiotasks = ', pio_numiotasks + else if(pio_numiotasks > 0 .and. pio_stride < 0) then + pio_stride = max(1, petCount/pio_numiotasks) + if (my_task == master_task) write(logunit,*) trim(subname)//' : update pio_stride = ', pio_stride + else if(pio_numiotasks < 0 .and. pio_stride < 0) then + pio_stride = max(1,petCount/4) + pio_numiotasks = max(1,petCount/pio_stride) + if (my_task == master_task) write(logunit,*) trim(subname)//' : update pio_numiotasks = ', pio_numiotasks + if (my_task == master_task) write(logunit,*) trim(subname)//' : update pio_stride = ', pio_stride + end if + if (pio_stride == 1) then + pio_root = 0 + endif + + if (pio_root + (pio_stride)*(pio_numiotasks-1) >= petCount .or. & + pio_stride <= 0 .or. pio_numiotasks <= 0 .or. & + pio_root < 0 .or. pio_root > petCount-1) then + if (petCount < 100) then + pio_stride = max(1, petCount/4) + else if(petCount < 1000) then + pio_stride = max(1, petCount/8) + else + pio_stride = max(1, petCount/16) + end if + if(pio_stride > 1) then + pio_numiotasks = petCount/pio_stride + pio_root = min(1, petCount-1) + else + pio_numiotasks = petCount + pio_root = 0 + end if + if (my_task == master_task) then + write(logunit,*) 'pio_stride, iotasks or root out of bounds - resetting to defaults:' + write(logunit,*) trim(subname)//' : pio_root = ', pio_root + write(logunit,*) trim(subname)//' : pio_stride = ', pio_stride + write(logunit,*) trim(subname)//' : pio_numiotasks = ', pio_numiotasks + end if + end if + + ! init PIO + allocate(sdat%pio_subsystem) + if (my_task == master_task) write(logunit,*) trim(subname)//' : calling pio init' + call pio_init(my_task, mpicom, pio_numiotasks, 0, pio_stride, & + pio_rearranger, sdat%pio_subsystem, base=pio_root) + + ! PIO debug related options + ! pio_debug_level + call NUOPC_CompAttributeGet(gcomp, name='pio_debug_level', value=cvalue, & + isPresent=isPresent, isSet=isSet, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + if (isPresent .and. isSet) then + read(cvalue,*) pio_debug_level + if (pio_debug_level < 0 .or. pio_debug_level > 6) then + call ESMF_LogWrite(trim(subname)//': need to provide valid option for & + pio_debug_level (0-6)', ESMF_LOGMSG_INFO) + rc = ESMF_FAILURE + return + end if + else + pio_debug_level = 0 + end if + if (my_task == master_task) write(logunit,*) trim(subname), & + ' : pio_debug_level = ',pio_debug_level + + ! set PIO debug level + call pio_setdebuglevel(pio_debug_level) + + ! pio_rearranger + call NUOPC_CompAttributeGet(gcomp, name='pio_rearranger', value=cvalue, & + isPresent=isPresent, isSet=isSet, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + if (isPresent .and. isSet) then + cvalue = ESMF_UtilStringUpperCase(cvalue) + if (trim(cvalue) .eq. 'BOX') then + pio_rearranger = PIO_REARR_BOX + else if (trim(cvalue) .eq. 'SUBSET') then + pio_rearranger = PIO_REARR_SUBSET + else + call ESMF_LogWrite(trim(subname)//'-'//trim(cname)// & + ' : need to provide valid option for pio_rearranger & + (BOX|SUBSET)', ESMF_LOGMSG_INFO) + rc = ESMF_FAILURE + return + end if + else + cvalue = 'BOX' + pio_rearranger = PIO_REARR_BOX + end if + if (my_task == master_task) write(logunit,*) trim(subname)//' : pio_rearranger = ', & + trim(cvalue), pio_rearranger + + ! init PIO + allocate(sdat%pio_subsystem) + if (my_task == master_task) write(logunit,*) trim(subname)//' : calling pio init' + call pio_init(my_task, mpicom, pio_numiotasks, 0, pio_stride, & + pio_rearranger, sdat%pio_subsystem, base=pio_root) + + ! query shared PIO rearranger attributes + ! pio_rearr_comm_type + call NUOPC_CompAttributeGet(gcomp, name='pio_rearr_comm_type', value=cvalue, & + isPresent=isPresent, isSet=isSet, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + if (isPresent .and. isSet) then + cvalue = ESMF_UtilStringUpperCase(cvalue) + if (trim(cvalue) .eq. 'P2P') then + pio_rearr_comm_type = PIO_REARR_COMM_P2P + else if (trim(cvalue) .eq. 'COLL') then + pio_rearr_comm_type = PIO_REARR_COMM_COLL + else + call ESMF_LogWrite(trim(subname)//' : need to provide valid option for & + pio_rearr_comm_type (P2P|COLL)', ESMF_LOGMSG_INFO) + rc = ESMF_FAILURE + return + end if + else + cvalue = 'P2P' + pio_rearr_comm_type = PIO_REARR_COMM_P2P + end if + if (my_task == master_task) write(logunit,*) trim(subname)// & + ' : pio_rearr_comm_type = ', trim(cvalue), pio_rearr_comm_type + + ! pio_rearr_comm_fcd + call NUOPC_CompAttributeGet(gcomp, name='pio_rearr_comm_fcd', value=cvalue, & + isPresent=isPresent, isSet=isSet, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + if (isPresent .and. isSet) then + cvalue = ESMF_UtilStringUpperCase(cvalue) + if (trim(cvalue) .eq. '2DENABLE') then + pio_rearr_comm_fcd = PIO_REARR_COMM_FC_2D_ENABLE + else if (trim(cvalue) .eq. 'IO2COMP') then + pio_rearr_comm_fcd = PIO_REARR_COMM_FC_1D_IO2COMP + else if (trim(cvalue) .eq. 'COMP2IO') then + pio_rearr_comm_fcd = PIO_REARR_COMM_FC_1D_COMP2IO + else if (trim(cvalue) .eq. '2DDISABLE') then + pio_rearr_comm_fcd = PIO_REARR_COMM_FC_2D_DISABLE + else + call ESMF_LogWrite(trim(subname)//' : need to provide valid option for & + pio_rearr_comm_fcd (2DENABLE|IO2COMP|COMP2IO|2DDISABLE)', ESMF_LOGMSG_INFO) + rc = ESMF_FAILURE + return + end if + else + cvalue = '2DENABLE' + pio_rearr_comm_fcd = PIO_REARR_COMM_FC_2D_ENABLE + end if + if (my_task == master_task) write(logunit,*) trim(subname)// & + ' : pio_rearr_comm_fcd = ', trim(cvalue), pio_rearr_comm_fcd + + ! pio_rearr_comm_enable_hs_comp2io + call NUOPC_CompAttributeGet(gcomp, name='pio_rearr_comm_enable_hs_comp2io', & + value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + if (isPresent .and. isSet) then + read(cvalue,*) pio_rearr_comm_enable_hs_comp2io + else + pio_rearr_comm_enable_hs_comp2io = .true. + end if + + ! pio_rearr_comm_enable_isend_comp2io + call NUOPC_CompAttributeGet(gcomp, name='pio_rearr_comm_enable_isend_comp2io', & + value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + if (isPresent .and. isSet) then + read(cvalue,*) pio_rearr_comm_enable_isend_comp2io + else + pio_rearr_comm_enable_isend_comp2io = .false. + end if + + ! pio_rearr_comm_max_pend_req_comp2io + call NUOPC_CompAttributeGet(gcomp, name='pio_rearr_comm_max_pend_req_comp2io', & + value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + if (isPresent .and. isSet) then + read(cvalue,*) pio_rearr_comm_max_pend_req_comp2io + else + pio_rearr_comm_max_pend_req_comp2io = 0 + end if + + ! pio_rearr_comm_enable_hs_io2comp + call NUOPC_CompAttributeGet(gcomp, name='pio_rearr_comm_enable_hs_io2comp', & + value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + if (isPresent .and. isSet) then + read(cvalue,*) pio_rearr_comm_enable_hs_io2comp + else + pio_rearr_comm_enable_hs_io2comp = .false. + end if + + ! pio_rearr_comm_enable_isend_io2comp + call NUOPC_CompAttributeGet(gcomp, name='pio_rearr_comm_enable_isend_io2comp', & + value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + if (isPresent .and. isSet) then + read(cvalue,*) pio_rearr_comm_enable_isend_io2comp + else + pio_rearr_comm_enable_isend_io2comp = .true. + end if + + ! pio_rearr_comm_max_pend_req_io2comp + call NUOPC_CompAttributeGet(gcomp, name='pio_rearr_comm_max_pend_req_io2comp', & + value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + if (isPresent .and. isSet) then + read(cvalue,*) pio_rearr_comm_max_pend_req_io2comp + else + pio_rearr_comm_max_pend_req_io2comp = 64 + end if + + ! print out PIO rearranger parameters + if (my_task == master_task) then + write(logunit,*) trim(subname)//' : pio_rearr_comm_enable_hs_comp2io = ', & + pio_rearr_comm_enable_hs_comp2io + write(logunit,*) trim(subname)//' : pio_rearr_comm_enable_isend_comp2io = ', & + pio_rearr_comm_enable_isend_comp2io + write(logunit,*) trim(subname)//' : pio_rearr_comm_max_pend_req_comp2io = ', & + pio_rearr_comm_max_pend_req_comp2io + write(logunit,*) trim(subname)//' : pio_rearr_comm_enable_hs_io2comp = ', & + pio_rearr_comm_enable_hs_io2comp + write(logunit,*) trim(subname)//' : pio_rearr_comm_enable_isend_io2comp = ', & + pio_rearr_comm_enable_isend_io2comp + write(logunit,*) trim(subname)//' : pio_rearr_comm_max_pend_req_io2comp = ', & + pio_rearr_comm_max_pend_req_io2comp + end if + + ! set PIO rearranger options + if (my_task == master_task) write(logunit,*) trim(subname)// & + ' calling pio_set_rearr_opts' + ret = pio_set_rearr_opts(sdat%pio_subsystem, pio_rearr_comm_type, & + pio_rearr_comm_fcd, & + pio_rearr_comm_enable_hs_comp2io, & + pio_rearr_comm_enable_isend_comp2io, & + pio_rearr_comm_max_pend_req_comp2io, & + pio_rearr_comm_enable_hs_io2comp, & + pio_rearr_comm_enable_isend_io2comp, & + pio_rearr_comm_max_pend_req_io2comp) + + end subroutine dshr_pio_init + end module dshr_mod diff --git a/dwav/cime_config/buildnml b/dwav/cime_config/buildnml index 88e4b19cd..5f9f508c8 100755 --- a/dwav/cime_config/buildnml +++ b/dwav/cime_config/buildnml @@ -61,8 +61,7 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path config['dwav_mode'] = dwav_mode # do not allow single column mode for dwav - scol_mode = True if case.get_value('PTS_MODE') else False - expect(not scol_mode, + expect(not case.get_value('PTS_MODE'), "for, DWAV single column mode is not allowed") # Initialize nmlgen diff --git a/dwav/wav_comp_nuopc.F90 b/dwav/wav_comp_nuopc.F90 index a6aa72243..70f360d45 100644 --- a/dwav/wav_comp_nuopc.F90 +++ b/dwav/wav_comp_nuopc.F90 @@ -170,7 +170,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! Obtain flds_scalar values, mpi values, multi-instance values and ! set logunit and set shr logging to my log file - call dshr_init(gcomp, mpicom, my_task, inst_index, inst_suffix, & + call dshr_init(gcomp, 'WAV', sdat, mpicom, my_task, inst_index, inst_suffix, & flds_scalar_name, flds_scalar_num, flds_scalar_index_nx, flds_scalar_index_ny, & logunit, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -267,7 +267,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) ! Initialize sdat - create the model domain mesh and intialize the sdat clock call ESMF_TraceRegionEnter('dwav_strdata_init') - call dshr_mesh_init(gcomp, nullstr, logunit, 'WAV', nx_global, ny_global, & + call dshr_mesh_init(gcomp, sdat, nullstr, logunit, 'WAV', nx_global, ny_global, & model_meshfile, model_maskfile, model_createmesh_fromfile, model_mesh, & model_mask, model_frac, restart_read, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return diff --git a/share/CMakeLists.txt b/share/CMakeLists.txt index cc71a4217..d24e8f93c 100644 --- a/share/CMakeLists.txt +++ b/share/CMakeLists.txt @@ -9,7 +9,6 @@ add_library(cdeps_share ${GenF90_SRCS} shr_timer_mod.F90 shr_cal_mod.F90 shr_kind_mod.F90 - shr_pio_mod.F90 shr_sys_mod.F90 shr_abort_mod.F90 shr_const_mod.F90 diff --git a/share/shr_pio_mod.F90 b/share/shr_pio_mod.F90 deleted file mode 100644 index 73ee46b2f..000000000 --- a/share/shr_pio_mod.F90 +++ /dev/null @@ -1,912 +0,0 @@ -module shr_pio_mod - use pio - use shr_kind_mod, only : shr_kind_CS, shr_kind_cl, shr_kind_in - use shr_log_mod, only : shr_log_unit - use shr_mpi_mod, only : shr_mpi_bcast, shr_mpi_chkerr - use shr_sys_mod, only : shr_sys_abort -#ifndef NO_MPIMOD - use mpi, only : mpi_comm_null, mpi_comm_world -#endif - implicit none -#ifdef NO_MPIMOD -#include -#endif - private - public :: shr_pio_init1 - public :: shr_pio_init2 - public :: shr_pio_getiosys - public :: shr_pio_getiotype - public :: shr_pio_getioroot - public :: shr_pio_finalize - public :: shr_pio_getioformat - public :: shr_pio_getrearranger - - interface shr_pio_getiotype - module procedure shr_pio_getiotype_fromid, shr_pio_getiotype_fromname - end interface - interface shr_pio_getioformat - module procedure shr_pio_getioformat_fromid, shr_pio_getioformat_fromname - end interface - interface shr_pio_getiosys - module procedure shr_pio_getiosys_fromid, shr_pio_getiosys_fromname - end interface - interface shr_pio_getioroot - module procedure shr_pio_getioroot_fromid, shr_pio_getioroot_fromname - end interface - interface shr_pio_getindex - module procedure shr_pio_getindex_fromid, shr_pio_getindex_fromname - end interface - interface shr_pio_getrearranger - module procedure shr_pio_getrearranger_fromid, shr_pio_getrearranger_fromname - end interface - - - - type pio_comp_t - integer :: compid - integer :: pio_root - integer :: pio_stride - integer :: pio_numiotasks - integer :: pio_iotype - integer :: pio_rearranger - integer :: pio_netcdf_ioformat - end type pio_comp_t - - character(len=16), allocatable :: io_compname(:) - type(pio_comp_t), allocatable :: pio_comp_settings(:) - type (iosystem_desc_t), allocatable, target :: iosystems(:) - integer :: io_comm - logical :: pio_async_interface - integer, allocatable :: io_compid(:) - integer :: pio_debug_level=0, pio_blocksize=0 - integer(kind=pio_offset_kind) :: pio_buffer_size_limit=-1 - integer :: pio_rearr_opt_comm_type, pio_rearr_opt_fcd - logical :: pio_rearr_opt_c2i_enable_hs, pio_rearr_opt_c2i_enable_isend - integer :: pio_rearr_opt_c2i_max_pend_req - logical :: pio_rearr_opt_i2c_enable_hs, pio_rearr_opt_i2c_enable_isend - integer :: pio_rearr_opt_i2c_max_pend_req - integer :: total_comps=0 - -#define DEBUGI 1 - -#ifdef DEBUGI - integer :: drank -#endif - - -contains -!> -!! @public -!! @brief should be the first routine called after mpi_init. -!! It reads the pio default settings from file drv_in, namelist pio_default_inparm -!! and, if pio_async_interface is true, splits the IO tasks away from the -!! Compute tasks. It then returns the new compute comm in -!! Global_Comm and sets module variable io_comm. -!! -!< - subroutine shr_pio_init1(ncomps, nlfilename, Global_Comm) - integer, intent(in) :: ncomps - character(len=*) :: nlfilename - integer, intent(inout) :: Global_Comm - - - integer :: i, pio_root, pio_stride, pio_numiotasks, pio_iotype, pio_rearranger, pio_netcdf_ioformat - integer :: mpigrp_world, mpigrp, ierr, mpicom - character(*),parameter :: subName = '(shr_pio_init1) ' - integer :: pelist(3,1) - - call shr_pio_read_default_namelist(nlfilename, Global_Comm, pio_stride, pio_root, pio_numiotasks, & - pio_iotype, pio_async_interface, pio_rearranger) - - pio_netcdf_ioformat = PIO_64BIT_OFFSET - call MPI_comm_rank(Global_Comm, drank, ierr) - - io_comm = MPI_COMM_NULL - allocate(pio_comp_settings(ncomps)) - do i=1,ncomps - pio_comp_settings(i)%pio_root = pio_root - pio_comp_settings(i)%pio_stride = pio_stride - pio_comp_settings(i)%pio_numiotasks = pio_numiotasks - pio_comp_settings(i)%pio_iotype = pio_iotype - pio_comp_settings(i)%pio_rearranger = pio_rearranger - pio_comp_settings(i)%pio_netcdf_ioformat = pio_netcdf_ioformat - end do - if(pio_async_interface) then -#ifdef NO_MPI2 - call shr_sys_abort(subname//':: async IO requires an MPI2 compliant MPI library') -#else - - pelist(1,1) = pio_root - pelist(2,1) = pio_root + (pio_numiotasks-1)*pio_stride - pelist(3,1) = pio_stride - - call mpi_comm_group(GLOBAL_COMM, mpigrp_world, ierr) - call shr_mpi_chkerr(ierr,subname//' mpi_comm_group mpigrp_world') - call mpi_group_range_incl(mpigrp_world, 1, pelist, mpigrp,ierr) - call shr_mpi_chkerr(ierr,subname//' mpi_group_range_incl mpigrp') - call mpi_comm_create(GLOBAL_COMM, mpigrp, io_comm, ierr) - - call mpi_group_range_excl(mpigrp_world, 1, pelist, mpigrp,ierr) - call shr_mpi_chkerr(ierr,subname//' mpi_group_range_incl mpigrp') - call mpi_comm_create(GLOBAL_COMM, mpigrp, mpicom, ierr) - Global_COMM=mpicom - - print *,__FILE__,__LINE__,subname, ' complete' -#endif - end if - total_comps = ncomps - end subroutine shr_pio_init1 -!> -!! @public -!! @brief if pio_async_interface is true, tasks in io_comm do not return from this subroutine. -!! -!! if pio_async_interface is false each component namelist pio_inparm is read from compname_modelio.nml -!! Then a subset of each components compute tasks are Identified as IO tasks using the root, stride and count -!! variables to select the tasks. -!! -!< - - - subroutine shr_pio_init2(comp_id, comp_name, comp_iamin, comp_comm, comp_comm_iam) - use shr_string_mod, only : shr_string_toLower - integer, intent(in) :: comp_id(:) - logical, intent(in) :: comp_iamin(:) - character(len=*), intent(in) :: comp_name(:) - integer, intent(in) :: comp_comm(:), comp_comm_iam(:) - integer :: i - character(len=shr_kind_cl) :: nlfilename, cname - integer :: ret - character(*), parameter :: subName = '(shr_pio_init2) ' - - if(pio_debug_level>0) then - if(comp_comm_iam(1)==0) then - write(shr_log_unit,*) 'Setting pio_debuglevel : ',pio_debug_level - end if - call pio_setdebuglevel(pio_debug_level) - endif - ! 0 is a valid value of pio_buffer_size_limit - if(pio_buffer_size_limit>=0) then - if(comp_comm_iam(1)==0) then - write(shr_log_unit,*) 'Setting pio_buffer_size_limit : ',pio_buffer_size_limit - end if - call pio_set_buffer_size_limit(pio_buffer_size_limit) - endif - if(pio_blocksize>0) then - if(comp_comm_iam(1)==0) then - write(shr_log_unit,*) 'Setting pio_blocksize : ',pio_blocksize - end if - call pio_set_blocksize(pio_blocksize) - endif - ! Correct the total_comps value which may be lower in nuopc - total_comps = size(comp_iamin) - - - allocate(io_compid(total_comps), io_compname(total_comps)) - - io_compid = comp_id - io_compname = comp_name - allocate(iosystems(total_comps)) - - if(pio_async_interface) then - call shr_sys_abort('pio_async_interface is not currently supported') -! call pio_init(total_comps,mpi_comm_world, comp_comm, io_comm, iosystems) -! do i=1,total_comps -! ret = pio_set_rearr_opts(iosystems(i), pio_rearr_opt_comm_type,& -! pio_rearr_opt_fcd,& -! pio_rearr_opt_c2i_enable_hs, pio_rearr_opt_c2i_enable_isend,& -! pio_rearr_opt_c2i_max_pend_req,& -! pio_rearr_opt_i2c_enable_hs, pio_rearr_opt_i2c_enable_isend,& -! pio_rearr_opt_i2c_max_pend_req) -! if(ret /= PIO_NOERR) then -! write(shr_log_unit,*) "ERROR: Setting rearranger options failed" -! end if -! end do -! i=1 - else - do i=1,total_comps - if(comp_iamin(i)) then - cname = comp_name(i) - if(len_trim(cname) <= 3) then - nlfilename=trim(shr_string_toLower(cname))//'_modelio.nml' - else - nlfilename=trim(shr_string_toLower(cname(1:3)))//'_modelio.nml_'//cname(4:8) - endif - - call shr_pio_read_component_namelist(nlfilename , comp_comm(i), pio_comp_settings(i)%pio_stride, & - pio_comp_settings(i)%pio_root, pio_comp_settings(i)%pio_numiotasks, & - pio_comp_settings(i)%pio_iotype, pio_comp_settings(i)%pio_rearranger, & - pio_comp_settings(i)%pio_netcdf_ioformat) - call pio_init(comp_comm_iam(i), comp_comm(i), pio_comp_settings(i)%pio_numiotasks, 0, & - pio_comp_settings(i)%pio_stride, & - pio_comp_settings(i)%pio_rearranger, iosystems(i), & - base=pio_comp_settings(i)%pio_root) - ret = pio_set_rearr_opts(iosystems(i), pio_rearr_opt_comm_type,& - pio_rearr_opt_fcd,& - pio_rearr_opt_c2i_enable_hs, pio_rearr_opt_c2i_enable_isend,& - pio_rearr_opt_c2i_max_pend_req,& - pio_rearr_opt_i2c_enable_hs, pio_rearr_opt_i2c_enable_isend,& - pio_rearr_opt_i2c_max_pend_req) - if(ret /= PIO_NOERR) then - write(shr_log_unit,*) "ERROR: Setting rearranger options failed" - end if - end if - end do - end if - do i=1,total_comps - if(comp_iamin(i) .and. (comp_comm_iam(i) == 0)) then - write(shr_log_unit,*) io_compname(i),' : pio_numiotasks = ',pio_comp_settings(i)%pio_numiotasks - write(shr_log_unit,*) io_compname(i),' : pio_stride = ',pio_comp_settings(i)%pio_stride - write(shr_log_unit,*) io_compname(i),' : pio_rearranger = ',pio_comp_settings(i)%pio_rearranger - write(shr_log_unit,*) io_compname(i),' : pio_root = ',pio_comp_settings(i)%pio_root - write(shr_log_unit,*) io_compname(i),' : pio_iotype = ',pio_comp_settings(i)%pio_iotype - end if - enddo - - end subroutine shr_pio_init2 - - - -!=============================================================================== - subroutine shr_pio_finalize( ) - integer :: ierr - integer :: i - do i=1,total_comps - call pio_finalize(iosystems(i), ierr) - end do - - end subroutine shr_pio_finalize - -!=============================================================================== - function shr_pio_getiotype_fromid(compid) result(io_type) - integer, intent(in) :: compid - integer :: io_type - - io_type = pio_comp_settings(shr_pio_getindex(compid))%pio_iotype - - end function shr_pio_getiotype_fromid - - - function shr_pio_getiotype_fromname(component) result(io_type) - ! 'component' must be equal to some element of io_compname(:) - ! (but it is case-insensitive) - character(len=*), intent(in) :: component - integer :: io_type - - io_type = pio_comp_settings(shr_pio_getindex(component))%pio_iotype - - end function shr_pio_getiotype_fromname - - function shr_pio_getrearranger_fromid(compid) result(io_type) - integer, intent(in) :: compid - integer :: io_type - - io_type = pio_comp_settings(shr_pio_getindex(compid))%pio_rearranger - - end function shr_pio_getrearranger_fromid - - - function shr_pio_getrearranger_fromname(component) result(io_type) - ! 'component' must be equal to some element of io_compname(:) - ! (but it is case-insensitive) - character(len=*), intent(in) :: component - integer :: io_type - - io_type = pio_comp_settings(shr_pio_getindex(component))%pio_rearranger - - end function shr_pio_getrearranger_fromname - - function shr_pio_getioformat_fromid(compid) result(io_format) - integer, intent(in) :: compid - integer :: io_format - - io_format = pio_comp_settings(shr_pio_getindex(compid))%pio_netcdf_ioformat - - end function shr_pio_getioformat_fromid - - - function shr_pio_getioformat_fromname(component) result(io_format) - ! 'component' must be equal to some element of io_compname(:) - ! (but it is case-insensitive) - character(len=*), intent(in) :: component - integer :: io_format - - io_format = pio_comp_settings(shr_pio_getindex(component))%pio_netcdf_ioformat - - end function shr_pio_getioformat_fromname - -!=============================================================================== - function shr_pio_getioroot_fromid(compid) result(io_root) - ! 'component' must be equal to some element of io_compname(:) - ! (but it is case-insensitive) - integer, intent(in) :: compid - integer :: io_root - - io_root = pio_comp_settings(shr_pio_getindex(compid))%pio_root - - end function shr_pio_getioroot_fromid - - function shr_pio_getioroot_fromname(component) result(io_root) - ! 'component' must be equal to some element of io_compname(:) - ! (but it is case-insensitive) - character(len=*), intent(in) :: component - integer :: io_root - - io_root = pio_comp_settings(shr_pio_getindex(component))%pio_root - - - end function shr_pio_getioroot_fromname - - -!=============================================================================== - - !! Given a component name, return the index of that component. - !! This is the index into io_compid, io_compname, comp_pio_iotype, etc. - !! If the given component is not found, return -1 - - integer function shr_pio_getindex_fromid(compid) result(index) - implicit none - integer, intent(in) :: compid - integer :: i - - index = -1 - do i=1,total_comps - if(io_compid(i)==compid) then - index = i - exit - end if - end do - - if(index<0) then - call shr_sys_abort('shr_pio_getindex :: compid out of allowed range') - end if - end function shr_pio_getindex_fromid - - - integer function shr_pio_getindex_fromname(component) result(index) - use shr_string_mod, only : shr_string_toupper - - implicit none - - ! 'component' must be equal to some element of io_compname(:) - ! (but it is case-insensitive) - character(len=*), intent(in) :: component - - character(len=len(component)) :: component_ucase - integer :: i - - ! convert component name to upper case in order to match case in io_compname - component_ucase = shr_string_toUpper(component) - - index = -1 ! flag for not found - do i=1,size(io_compname) - if (trim(component_ucase) == trim(io_compname(i))) then - index = i - exit - end if - end do - if(index<0) then - call shr_sys_abort(' shr_pio_getindex:: compid out of allowed range') - end if - end function shr_pio_getindex_fromname - - function shr_pio_getiosys_fromid(compid) result(iosystem) - ! 'component' must be equal to some element of io_compname(:) - ! (but it is case-insensitive) - integer, intent(in) :: compid - type(iosystem_desc_t), pointer :: iosystem - - - iosystem => iosystems(shr_pio_getindex(compid)) - - end function shr_pio_getiosys_fromid - - function shr_pio_getiosys_fromname(component) result(iosystem) - ! 'component' must be equal to some element of io_compname(:) - ! (but it is case-insensitive) - character(len=*), intent(in) :: component - type(iosystem_desc_t), pointer :: iosystem - - iosystem => iosystems(shr_pio_getindex(component)) - - end function shr_pio_getiosys_fromname - -!=============================================================================== - - - - subroutine shr_pio_read_default_namelist(nlfilename, Comm, pio_stride, pio_root, pio_numiotasks, & - pio_iotype, pio_async_interface, pio_rearranger) - - character(len=*), intent(in) :: nlfilename - integer, intent(in) :: Comm - logical, intent(out) :: pio_async_interface - integer, intent(out) :: pio_stride, pio_root, pio_numiotasks, pio_iotype, pio_rearranger - - character(len=shr_kind_cs) :: pio_typename - character(len=shr_kind_cs) :: pio_rearr_comm_type, pio_rearr_comm_fcd - integer :: pio_netcdf_ioformat - integer :: pio_rearr_comm_max_pend_req_comp2io - logical :: pio_rearr_comm_enable_hs_comp2io, pio_rearr_comm_enable_isend_comp2io - integer :: pio_rearr_comm_max_pend_req_io2comp - logical :: pio_rearr_comm_enable_hs_io2comp, pio_rearr_comm_enable_isend_io2comp - character(*),parameter :: subName = '(shr_pio_read_default_namelist) ' - - integer :: iam, ierr, npes, unitn - logical :: iamroot - namelist /pio_default_inparm/ & - pio_async_interface, pio_debug_level, pio_blocksize, & - pio_buffer_size_limit, & - pio_rearr_comm_type, pio_rearr_comm_fcd, & - pio_rearr_comm_max_pend_req_comp2io, pio_rearr_comm_enable_hs_comp2io, & - pio_rearr_comm_enable_isend_comp2io, & - pio_rearr_comm_max_pend_req_io2comp, pio_rearr_comm_enable_hs_io2comp, & - pio_rearr_comm_enable_isend_io2comp - - - call mpi_comm_rank(Comm, iam , ierr) - call shr_mpi_chkerr(ierr,subname//' mpi_comm_rank comm_world') - call mpi_comm_size(Comm, npes, ierr) - call shr_mpi_chkerr(ierr,subname//' mpi_comm_size comm_world') - - if(iam==0) then - iamroot=.true. - else - iamroot=.false. - end if - - !-------------------------------------------------------------------------- - ! read io nml parameters - !-------------------------------------------------------------------------- - pio_stride = -99 ! set based on pio_numiotasks value when initialized < 0 - pio_numiotasks = -99 ! set based on pio_stride value when initialized < 0 - pio_root = -99 - pio_typename = 'nothing' - pio_blocksize= -99 ! io blocking size set internally in pio when < 0 - pio_buffer_size_limit = -99 ! io task memory buffer maximum set internally in pio when < 0 - pio_debug_level = 0 ! no debug info by default - pio_async_interface = .false. ! pio tasks are a subset of component tasks - pio_rearranger = PIO_REARR_SUBSET - pio_netcdf_ioformat = PIO_64BIT_OFFSET - pio_rearr_comm_type = 'p2p' - pio_rearr_comm_fcd = '2denable' - pio_rearr_comm_max_pend_req_comp2io = 0 - pio_rearr_comm_enable_hs_comp2io = .true. - pio_rearr_comm_enable_isend_comp2io = .false. - pio_rearr_comm_max_pend_req_io2comp = 0 - pio_rearr_comm_enable_hs_io2comp = .true. - pio_rearr_comm_enable_isend_io2comp = .false. - - if(iamroot) then - open(newunit=unitn, file=trim(nlfilename), status='old' , iostat=ierr) - if(ierr/=0) then - write(shr_log_unit,*) 'File ',trim(nlfilename),' not found, setting default values.' - else - ierr = 1 - do while( ierr /= 0 ) - read(unitn,nml=pio_default_inparm,iostat=ierr) - if (ierr < 0) then - call shr_sys_abort( subname//':: namelist read returns an'// & - ' end of file or end of record condition '//trim(nlfilename) ) - end if - end do - close(unitn) - call shr_pio_getiotypefromname(pio_typename, pio_iotype, pio_iotype_netcdf) - end if - end if - - call shr_pio_namelist_set(npes, Comm, pio_stride, pio_root, pio_numiotasks, pio_iotype, & - iamroot, pio_rearranger, pio_netcdf_ioformat) - - call shr_mpi_bcast(pio_debug_level, Comm) - call shr_mpi_bcast(pio_blocksize, Comm) - call shr_mpi_bcast(pio_buffer_size_limit, Comm) - call shr_mpi_bcast(pio_async_interface, Comm) - call shr_mpi_bcast(pio_rearranger, Comm) - if (npes == 1) then - pio_rearr_comm_max_pend_req_comp2io = 0 - pio_rearr_comm_max_pend_req_io2comp = 0 - endif - - - call shr_pio_rearr_opts_set(Comm, pio_rearr_comm_type, pio_rearr_comm_fcd, & - pio_rearr_comm_max_pend_req_comp2io, pio_rearr_comm_enable_hs_comp2io, & - pio_rearr_comm_enable_isend_comp2io, & - pio_rearr_comm_max_pend_req_io2comp, pio_rearr_comm_enable_hs_io2comp, & - pio_rearr_comm_enable_isend_io2comp, pio_numiotasks) - - end subroutine shr_pio_read_default_namelist - - subroutine shr_pio_read_component_namelist(nlfilename, Comm, pio_stride, pio_root, & - pio_numiotasks, pio_iotype, pio_rearranger, pio_netcdf_ioformat) - character(len=*), intent(in) :: nlfilename - integer, intent(in) :: Comm - - integer, intent(inout) :: pio_stride, pio_root, pio_numiotasks - integer, intent(inout) :: pio_iotype, pio_rearranger, pio_netcdf_ioformat - character(len=SHR_KIND_CS) :: pio_typename - character(len=SHR_KIND_CS) :: pio_netcdf_format - integer :: unitn - - integer :: iam, ierr, npes - logical :: iamroot - character(*),parameter :: subName = '(shr_pio_read_component_namelist) ' - integer :: pio_default_stride, pio_default_root, pio_default_numiotasks, pio_default_iotype - integer :: pio_default_rearranger, pio_default_netcdf_ioformat - - namelist /pio_inparm/ pio_stride, pio_root, pio_numiotasks, & - pio_typename, pio_rearranger, pio_netcdf_format - - - - call mpi_comm_rank(Comm, iam , ierr) - call shr_mpi_chkerr(ierr,subname//' mpi_comm_rank comm_world') - call mpi_comm_size(Comm, npes, ierr) - call shr_mpi_chkerr(ierr,subname//' mpi_comm_size comm_world') - - if(iam==0) then - iamroot=.true. - else - iamroot=.false. - end if - - pio_default_stride = pio_stride - pio_default_root = pio_root - pio_default_numiotasks = pio_numiotasks - pio_default_iotype = pio_iotype - pio_default_rearranger = pio_rearranger - pio_default_netcdf_ioformat = PIO_64BIT_OFFSET - - !-------------------------------------------------------------------------- - ! read io nml parameters - !-------------------------------------------------------------------------- - pio_stride = -99 ! set based on pio_numiotasks value when initialized < 0 - pio_numiotasks = -99 ! set based on pio_stride value when initialized < 0 - pio_root = -99 - pio_typename = 'nothing' - pio_rearranger = -99 - pio_netcdf_format = '64bit_offset' - - if(iamroot) then - open(newunit=unitn, file=trim(nlfilename), status='old' , iostat=ierr) - if( ierr /= 0) then - write(shr_log_unit,*) 'No ',trim(nlfilename),' found, using defaults for pio settings' - pio_stride = pio_default_stride - pio_root = pio_default_root - pio_numiotasks = pio_default_numiotasks - pio_iotype = pio_default_iotype - pio_rearranger = pio_default_rearranger - pio_netcdf_ioformat = pio_default_netcdf_ioformat - else - ierr = 1 - do while( ierr /= 0 ) - read(unitn,nml=pio_inparm,iostat=ierr) - if (ierr < 0) then - call shr_sys_abort( subname//':: namelist read returns an'// & - ' end of file or end of record condition' ) - end if - end do - close(unitn) - call shr_pio_getiotypefromname(pio_typename, pio_iotype, pio_default_iotype) - call shr_pio_getioformatfromname(pio_netcdf_format, pio_netcdf_ioformat, pio_default_netcdf_ioformat) - end if - if(pio_stride== -99) then - if (pio_numiotasks > 0) then - pio_stride = npes/pio_numiotasks - else - pio_stride = pio_default_stride - endif - endif - if(pio_root == -99) pio_root = pio_default_root - if(pio_rearranger == -99) pio_rearranger = pio_default_rearranger - if(pio_numiotasks == -99) then - pio_numiotasks = npes/pio_stride - endif - endif - - - - call shr_pio_namelist_set(npes, Comm, pio_stride, pio_root, pio_numiotasks, pio_iotype, & - iamroot, pio_rearranger, pio_netcdf_ioformat) - - - end subroutine shr_pio_read_component_namelist - - subroutine shr_pio_getioformatfromname(pio_netcdf_format, pio_netcdf_ioformat, pio_default_netcdf_ioformat) - use shr_string_mod, only : shr_string_toupper - character(len=*), intent(inout) :: pio_netcdf_format - integer, intent(out) :: pio_netcdf_ioformat - integer, intent(in) :: pio_default_netcdf_ioformat - - pio_netcdf_format = shr_string_toupper(pio_netcdf_format) - if ( pio_netcdf_format .eq. 'CLASSIC' ) then - pio_netcdf_ioformat = 0 - elseif ( pio_netcdf_format .eq. '64BIT_OFFSET' ) then - pio_netcdf_ioformat = PIO_64BIT_OFFSET -#ifdef _PNETCDF - elseif ( pio_netcdf_format .eq. '64BIT_DATA' ) then - pio_netcdf_ioformat = PIO_64BIT_DATA -#endif - else - pio_netcdf_ioformat = pio_default_netcdf_ioformat - endif - - end subroutine shr_pio_getioformatfromname - - - subroutine shr_pio_getiotypefromname(typename, iotype, defaulttype) - use shr_string_mod, only : shr_string_toupper - character(len=*), intent(inout) :: typename - integer, intent(out) :: iotype - integer, intent(in) :: defaulttype - - typename = shr_string_toupper(typename) - if ( typename .eq. 'NETCDF' ) then - iotype = pio_iotype_netcdf - else if ( typename .eq. 'PNETCDF') then - iotype = pio_iotype_pnetcdf - else if ( typename .eq. 'NETCDF4P') then - iotype = pio_iotype_netcdf4p - else if ( typename .eq. 'NETCDF4C') then - iotype = pio_iotype_netcdf4c - else if ( typename .eq. 'NOTHING') then - iotype = defaulttype - else if ( typename .eq. 'DEFAULT') then - iotype = defaulttype - else - write(shr_log_unit,*) 'shr_pio_mod: WARNING Bad io_type argument - using iotype_netcdf' - iotype=pio_iotype_netcdf - end if - - end subroutine shr_pio_getiotypefromname - -!=============================================================================== - subroutine shr_pio_namelist_set(npes,mycomm, pio_stride, pio_root, pio_numiotasks, & - pio_iotype, iamroot, pio_rearranger, pio_netcdf_ioformat) - integer, intent(in) :: npes, mycomm - integer, intent(inout) :: pio_stride, pio_root, pio_numiotasks - integer, intent(inout) :: pio_iotype, pio_rearranger, pio_netcdf_ioformat - logical, intent(in) :: iamroot - character(*),parameter :: subName = '(shr_pio_namelist_set) ' - - call shr_mpi_bcast(pio_iotype , mycomm) - call shr_mpi_bcast(pio_stride , mycomm) - call shr_mpi_bcast(pio_root , mycomm) - call shr_mpi_bcast(pio_numiotasks, mycomm) - call shr_mpi_bcast(pio_rearranger, mycomm) - call shr_mpi_bcast(pio_netcdf_ioformat, mycomm) - - if (pio_root<0) then - pio_root = 1 - endif - pio_root = min(pio_root,npes-1) - -! If you are asking for parallel IO then you should use at least two io pes - if(npes > 1 .and. pio_numiotasks == 1 .and. & - (pio_iotype .eq. PIO_IOTYPE_PNETCDF .or. & - pio_iotype .eq. PIO_IOTYPE_NETCDF4P)) then - pio_numiotasks = 2 - pio_stride = min(pio_stride, npes/2) - endif - - !-------------------------------------------------------------------------- - ! check/set/correct io pio parameters - !-------------------------------------------------------------------------- - if (pio_stride>0.and.pio_numiotasks<0) then - pio_numiotasks = max(1,npes/pio_stride) - else if(pio_numiotasks>0 .and. pio_stride<0) then - pio_stride = max(1,npes/pio_numiotasks) - else if(pio_numiotasks<0 .and. pio_stride<0) then - pio_stride = max(1,npes/4) - pio_numiotasks = max(1,npes/pio_stride) - end if - if(pio_stride == 1) then - pio_root = 0 - endif - if(pio_rearranger .ne. PIO_REARR_SUBSET .and. pio_rearranger .ne. PIO_REARR_BOX) then - write(shr_log_unit,*) 'pio_rearranger value, ',pio_rearranger,& - ', not supported - using PIO_REARR_BOX' - pio_rearranger = PIO_REARR_BOX - - endif - - - if (pio_root + (pio_stride)*(pio_numiotasks-1) >= npes .or. & - pio_stride<=0 .or. pio_numiotasks<=0 .or. pio_root < 0 .or. & - pio_root > npes-1) then - if(npes<100) then - pio_stride = max(1,npes/4) - else if(npes<1000) then - pio_stride = max(1,npes/8) - else - pio_stride = max(1,npes/16) - end if - if(pio_stride>1) then - pio_numiotasks = npes/pio_stride - pio_root = min(1,npes-1) - else - pio_numiotasks = npes - pio_root = 0 - end if - if( iamroot) then - write(shr_log_unit,*) 'pio_stride, iotasks or root out of bounds - resetting to defaults: ',& - pio_stride,pio_numiotasks, pio_root - end if - end if - - end subroutine shr_pio_namelist_set - - ! This subroutine sets the global PIO rearranger options - ! The input args that represent the rearranger options are valid only - ! on the root proc of comm - ! The rearranger options are passed to PIO_Init() in shr_pio_init2() - subroutine shr_pio_rearr_opts_set(comm, pio_rearr_comm_type, pio_rearr_comm_fcd, & - pio_rearr_comm_max_pend_req_comp2io, pio_rearr_comm_enable_hs_comp2io, & - pio_rearr_comm_enable_isend_comp2io, & - pio_rearr_comm_max_pend_req_io2comp, pio_rearr_comm_enable_hs_io2comp, & - pio_rearr_comm_enable_isend_io2comp, & - pio_numiotasks) - integer(SHR_KIND_IN), intent(in) :: comm - character(len=shr_kind_cs), intent(in) :: pio_rearr_comm_type, pio_rearr_comm_fcd - integer, intent(in) :: pio_rearr_comm_max_pend_req_comp2io - logical, intent(in) :: pio_rearr_comm_enable_hs_comp2io - logical, intent(in) :: pio_rearr_comm_enable_isend_comp2io - integer, intent(in) :: pio_rearr_comm_max_pend_req_io2comp - logical, intent(in) :: pio_rearr_comm_enable_hs_io2comp - logical, intent(in) :: pio_rearr_comm_enable_isend_io2comp - integer, intent(in) :: pio_numiotasks - - character(*), parameter :: subname = '(shr_pio_rearr_opts_set) ' - integer, parameter :: NUM_REARR_COMM_OPTS = 8 - integer, parameter :: PIO_REARR_COMM_DEF_MAX_PEND_REQ = 64 - integer(SHR_KIND_IN), dimension(NUM_REARR_COMM_OPTS) :: buf - integer :: rank, ierr - - call mpi_comm_rank(comm, rank, ierr) - call shr_mpi_chkerr(ierr,subname//' mpi_comm_rank comm_world') - - buf = 0 - ! buf(1) = comm_type - ! buf(2) = comm_fcd - ! buf(3) = max_pend_req_comp2io - ! buf(4) = enable_hs_comp2io - ! buf(5) = enable_isend_comp2io - ! buf(6) = max_pend_req_io2comp - ! buf(7) = enable_hs_io2comp - ! buf(8) = enable_isend_io2comp - if(rank == 0) then - ! buf(1) = comm_type - select case(pio_rearr_comm_type) - case ("p2p") - case ("default") - buf(1) = pio_rearr_comm_p2p - case ("coll") - buf(1) = pio_rearr_comm_coll - case default - write(shr_log_unit,*) "Invalid PIO rearranger comm type, ", pio_rearr_comm_type - write(shr_log_unit,*) "Resetting PIO rearrange comm type to p2p" - buf(1) = pio_rearr_comm_p2p - end select - - ! buf(2) = comm_fcd - select case(pio_rearr_comm_fcd) - case ("2denable") - case ("default") - buf(2) = pio_rearr_comm_fc_2d_enable - case ("io2comp") - buf(2) = pio_rearr_comm_fc_1d_io2comp - case ("comp2io") - buf(2) = pio_rearr_comm_fc_1d_comp2io - case ("disable") - buf(2) = pio_rearr_comm_fc_2d_disable - case default - write(shr_log_unit,*) "Invalid PIO rearranger comm flow control direction, ", pio_rearr_comm_fcd - write(shr_log_unit,*) "Resetting PIO rearrange comm flow control direction to 2denable" - buf(2) = pio_rearr_comm_fc_2d_enable - end select - - ! buf(3) = max_pend_req_comp2io - if((pio_rearr_comm_max_pend_req_comp2io < 0) .and. & - (pio_rearr_comm_max_pend_req_comp2io /= PIO_REARR_COMM_UNLIMITED_PEND_REQ)) then - - ! Small multiple of pio_numiotasks has proven to perform - ! well empirically, and we do not want to allow maximum for - ! very large process count runs. Can improve this by - ! communicating between iotasks first, and then non-iotasks - ! to iotasks (TO DO) - write(shr_log_unit, *) "Invalid PIO rearranger comm max pend req (comp2io), ",& - pio_rearr_comm_max_pend_req_comp2io - write(shr_log_unit, *) "Resetting PIO rearranger comm max pend req (comp2io) to ", & - max(PIO_REARR_COMM_DEF_MAX_PEND_REQ, 2 * pio_numiotasks) - buf(3) = max(PIO_REARR_COMM_DEF_MAX_PEND_REQ, 2 * pio_numiotasks) - else - buf(3) = pio_rearr_comm_max_pend_req_comp2io - end if - - ! buf(4) = enable_hs_comp2io - if(pio_rearr_comm_enable_hs_comp2io) then - buf(4) = 1 - else - buf(4) = 0 - end if - - ! buf(5) = enable_isend_comp2io - if(pio_rearr_comm_enable_isend_comp2io) then - buf(5) = 1 - else - buf(5) = 0 - end if - - ! buf(6) = max_pend_req_io2comp - if((pio_rearr_comm_max_pend_req_io2comp < 0) .and. & - (pio_rearr_comm_max_pend_req_io2comp /= PIO_REARR_COMM_UNLIMITED_PEND_REQ)) then - write(shr_log_unit, *) "Invalid PIO rearranger comm max pend req (io2comp), ", pio_rearr_comm_max_pend_req_io2comp - write(shr_log_unit, *) "Resetting PIO rearranger comm max pend req (io2comp) to ", PIO_REARR_COMM_DEF_MAX_PEND_REQ - buf(6) = PIO_REARR_COMM_DEF_MAX_PEND_REQ - else - buf(6) = pio_rearr_comm_max_pend_req_io2comp - end if - - ! buf(7) = enable_hs_io2comp - if(pio_rearr_comm_enable_hs_io2comp) then - buf(7) = 1 - else - buf(7) = 0 - end if - - ! buf(8) = enable_isend_io2comp - if(pio_rearr_comm_enable_isend_io2comp) then - buf(8) = 1 - else - buf(8) = 0 - end if - - ! Log the rearranger options - write(shr_log_unit, *) "PIO rearranger options:" - write(shr_log_unit, *) " comm type =", pio_rearr_comm_type - write(shr_log_unit, *) " comm fcd =", pio_rearr_comm_fcd - write(shr_log_unit, *) " max pend req (comp2io) =", pio_rearr_comm_max_pend_req_comp2io - write(shr_log_unit, *) " enable_hs (comp2io) =", pio_rearr_comm_enable_hs_comp2io - write(shr_log_unit, *) " enable_isend (comp2io) =", pio_rearr_comm_enable_isend_comp2io - write(shr_log_unit, *) " max pend req (io2comp) =", pio_rearr_comm_max_pend_req_io2comp - write(shr_log_unit, *) " enable_hs (io2comp) =", pio_rearr_comm_enable_hs_io2comp - write(shr_log_unit, *) " enable_isend (io2comp) =", pio_rearr_comm_enable_isend_io2comp - end if - - call shr_mpi_bcast(buf, comm) - - ! buf(1) = comm_type - ! buf(2) = comm_fcd - ! buf(3) = max_pend_req_comp2io - ! buf(4) = enable_hs_comp2io - ! buf(5) = enable_isend_comp2io - ! buf(6) = max_pend_req_io2comp - ! buf(7) = enable_hs_io2comp - ! buf(8) = enable_isend_io2comp - pio_rearr_opt_comm_type = buf(1) - pio_rearr_opt_fcd = buf(2) - pio_rearr_opt_c2i_max_pend_req = buf(3) - if(buf(4) == 0) then - pio_rearr_opt_c2i_enable_hs = .false. - else - pio_rearr_opt_c2i_enable_hs = .true. - end if - if(buf(5) == 0) then - pio_rearr_opt_c2i_enable_isend = .false. - else - pio_rearr_opt_c2i_enable_isend = .true. - end if - pio_rearr_opt_i2c_max_pend_req = buf(6) - if(buf(7) == 0) then - pio_rearr_opt_i2c_enable_hs = .false. - else - pio_rearr_opt_i2c_enable_hs = .true. - end if - if(buf(8) == 0) then - pio_rearr_opt_i2c_enable_isend = .false. - else - pio_rearr_opt_i2c_enable_isend = .true. - end if - end subroutine -!=============================================================================== - -end module shr_pio_mod diff --git a/streams/dshr_strdata_mod.F90 b/streams/dshr_strdata_mod.F90 index 37de93636..305d161eb 100644 --- a/streams/dshr_strdata_mod.F90 +++ b/streams/dshr_strdata_mod.F90 @@ -26,7 +26,9 @@ module dshr_strdata_mod use shr_cal_mod , only : shr_cal_noleap, shr_cal_gregorian use shr_cal_mod , only : shr_cal_date2ymd, shr_cal_ymd2date use shr_orb_mod , only : shr_orb_decl, shr_orb_cosz, shr_orb_undef_real +#ifdef CESMCOUPLED use shr_pio_mod , only : shr_pio_getiosys, shr_pio_getiotype, shr_pio_getioformat +#endif use shr_string_mod , only : shr_string_listgetname, shr_string_listisvalid, shr_string_listgetnum use dshr_stream_mod , only : shr_stream_streamtype, shr_stream_getModelFieldList, shr_stream_getStreamFieldList @@ -184,7 +186,7 @@ subroutine shr_strdata_init_from_xml(sdat, xmlfilename, model_mesh, clock, compn ! local variables type(ESMF_VM) :: vm - integer :: localPet + integer :: i, localPet character(len=*), parameter :: subname='(shr_strdata_init_from_xml)' ! ---------------------------------------------- rc = ESMF_SUCCESS @@ -193,10 +195,12 @@ subroutine shr_strdata_init_from_xml(sdat, xmlfilename, model_mesh, clock, compn ! Initialize log unit sdat%logunit = logunit +#ifdef CESMCOUPLED ! Initialize sdat pio sdat%pio_subsystem => shr_pio_getiosys(trim(compname)) sdat%io_type = shr_pio_getiotype(trim(compname)) sdat%io_format = shr_pio_getioformat(trim(compname)) +#endif call ESMF_VMGetCurrent(vm, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -206,7 +210,8 @@ subroutine shr_strdata_init_from_xml(sdat, xmlfilename, model_mesh, clock, compn ! Initialize sdat streams (read xml file for streams) sdat%masterproc = (localPet == master_task) - call shr_stream_init_from_xml(xmlfilename, sdat%stream, sdat%masterproc, sdat%logunit, trim(compname), rc=rc) + call shr_stream_init_from_xml(xmlfilename, sdat%stream, sdat%masterproc, sdat%logunit, & + sdat%pio_subsystem, sdat%io_type, sdat%io_format, trim(compname), rc=rc) allocate(sdat%pstrm(shr_strdata_get_stream_count(sdat))) @@ -258,10 +263,12 @@ subroutine shr_strdata_init_from_inline(sdat, my_task, logunit, compname, & sdat%logunit = logunit sdat%masterproc = (my_task == master_task) +#ifdef CESMCOUPLED ! Initialize sdat pio sdat%pio_subsystem => shr_pio_getiosys(trim(compname)) sdat%io_type = shr_pio_getiotype(trim(compname)) sdat%io_format = shr_pio_getioformat(trim(compname)) +#endif ! Initialize sdat%pstrm - ASSUME only 1 stream allocate(sdat%pstrm(1)) @@ -273,6 +280,7 @@ subroutine shr_strdata_init_from_inline(sdat, my_task, logunit, compname, & ! Initialize sdat stream - ASSUME only 1 stream call shr_stream_init_from_inline(sdat%stream, & + sdat%pio_subsystem, sdat%io_type, sdat%io_format, & stream_meshfile, stream_lev_dimname, stream_mapalgo, & stream_yearFirst, stream_yearLast, stream_yearAlign, & stream_offset, stream_taxmode, stream_tintalgo, stream_dtlimit, & diff --git a/streams/dshr_stream_mod.F90 b/streams/dshr_stream_mod.F90 index ebf1cbde7..4aeffaef5 100644 --- a/streams/dshr_stream_mod.F90 +++ b/streams/dshr_stream_mod.F90 @@ -30,7 +30,9 @@ module dshr_stream_mod use pio , only : file_desc_t, pio_inq_varid, iosystem_desc_t, pio_file_is_open use pio , only : pio_nowrite, pio_inquire_dimension, pio_inquire_variable, pio_bcast_error use pio , only : pio_get_att, pio_get_var +#ifdef CESMCOUPLED use shr_pio_mod , only : shr_pio_getiosys, shr_pio_getiotype, shr_pio_getioformat +#endif implicit none private ! default private @@ -120,7 +122,8 @@ module dshr_stream_mod contains !=============================================================================== - subroutine shr_stream_init_from_xml(xmlfilename, streamdat, isroot_task, logunit, compname, rc) + subroutine shr_stream_init_from_xml(xmlfilename, streamdat, isroot_task, logunit, & + pio_subsystem, io_type, io_format, compname, rc) use FoX_DOM, only : extractDataContent, destroy, Node, NodeList, parseFile, getElementsByTagname use FoX_DOM, only : getLength, item @@ -154,11 +157,14 @@ subroutine shr_stream_init_from_xml(xmlfilename, streamdat, isroot_task, logunit ! --------------------------------------------------------------------- ! input/output variables + character(len=*), optional , intent(in) :: xmlfilename type(shr_stream_streamType) , intent(inout), pointer :: streamdat(:) - integer , intent(in) :: logunit logical , intent(in) :: isroot_task + integer , intent(in) :: logunit + type(iosystem_desc_t) , intent(in), pointer :: pio_subsystem + integer , intent(in) :: io_type + integer , intent(in) :: io_format character(len=*) , intent(in) :: compname - character(len=*), optional , intent(in) :: xmlfilename integer , intent(out) :: rc ! local variables @@ -345,9 +351,16 @@ subroutine shr_stream_init_from_xml(xmlfilename, streamdat, isroot_task, logunit call ESMF_VMBroadCast(vm, rtmp, 1, 0, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return streamdat(i)%dtlimit = rtmp(1) +#ifdef CESMCOUPLED + ! Initialize stream pio streamdat(i)%pio_subsystem => shr_pio_getiosys(trim(compname)) - streamdat(i)%pio_iotype = shr_pio_getiotype(trim(compname)) - streamdat(i)%pio_ioformat = shr_pio_getioformat(trim(compname)) + streamdat(i)%pio_iotype = shr_pio_getiotype(trim(compname)) + streamdat(i)%pio_ioformat = shr_pio_getioformat(trim(compname)) +#else + streamdat(i)%pio_subsystem => pio_subsystem + streamdat(i)%pio_iotype = io_type + streamdat(i)%pio_ioformat = io_format +#endif call shr_stream_getCalendar(streamdat(i), 1, streamdat(i)%calendar) ! Error check @@ -367,6 +380,7 @@ end subroutine shr_stream_init_from_xml !=============================================================================== subroutine shr_stream_init_from_inline(streamdat, & + pio_subsystem, io_type, io_format, & stream_meshfile, stream_lev_dimname, stream_mapalgo, & stream_yearFirst, stream_yearLast, stream_yearAlign, & stream_offset, stream_taxmode, stream_tintalgo, stream_dtlimit, & @@ -380,6 +394,9 @@ subroutine shr_stream_init_from_inline(streamdat, & ! input/output variables type(shr_stream_streamType) ,pointer, intent(inout) :: streamdat(:) ! data streams (assume 1 below) + type(iosystem_desc_t) ,pointer, intent(in) :: pio_subsystem ! data structure required for pio operations + integer ,intent(in) :: io_type ! data format + integer ,intent(in) :: io_format ! netcdf format character(*) ,intent(in) :: stream_meshFile ! full pathname to stream mesh file character(*) ,intent(in) :: stream_lev_dimname ! name of vertical dimension in stream character(*) ,intent(in) :: stream_mapalgo ! stream mesh -> model mesh mapping type @@ -420,10 +437,16 @@ subroutine shr_stream_init_from_inline(streamdat, & streamdat(1)%offset = stream_offset streamdat(1)%taxMode = trim(stream_taxMode) streamdat(1)%dtlimit = stream_dtlimit - +#ifdef CESMCOUPLED + ! Initialize stream pio streamdat(1)%pio_subsystem => shr_pio_getiosys(trim(compname)) streamdat(1)%pio_iotype = shr_pio_getiotype(trim(compname)) streamdat(1)%pio_ioformat = shr_pio_getioformat(trim(compname)) +#else + streamdat(1)%pio_subsystem => pio_subsystem + streamdat(1)%pio_iotype = io_type + streamdat(1)%pio_ioformat = io_format +#endif ! initialize stream filenames if (allocated(streamdat(1)%file)) then